Browse Source

Added file path exception checks to script.

Fixed file path exception bugs.
master
Craig Oates 6 years ago
parent
commit
b2377b1241
  1. 8
      WetPancake/DataProcessing.fs
  2. 41
      WetPancake/Script.fsx

8
WetPancake/DataProcessing.fs

@ -23,10 +23,10 @@
let FilePathIsValid filePath =
match filePath with
| filePath when Path.GetExtension filePath = ".txt" ->
raise (ArgumentException("Invalid argument. File must be a .txt file and include avalidfilepath.","filePath"))
| filePath when File.Exists filePath ->
raise (ArgumentException("Invalid argument. File must be a .txt file and include avalidfilepath.","filePath"))
| filePath when Path.GetExtension filePath <> ".txt" ->
raise (ArgumentException("Invalid argument. File must be a .txt file.","filePath"))
| filePath when not (File.Exists filePath) ->
raise (ArgumentException("Invalid argument. File must include a valid file path.","filePath"))
| _ -> ignore
let SortIntoGroups groupSize text =

41
WetPancake/Script.fsx

@ -18,6 +18,16 @@ open DataServices
open WetPancake
open System
// Template Files
[<Literal>]
let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt"
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
[<Literal>]
let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
// System Services
let ss_number = PickRandomNumber 10
let ss_item =
@ -91,18 +101,16 @@ let dp_sentencesException =
SentencesIsValid 0 // enter a number here
|> ignore
"No exception thrown"
with :? ArgumentException as ex ->
ex.Message
(* Functions to include:
=====================
1.) GibberishLevelIsValid
2.) SentencesIsValid
3.) FilePathIsValid
*)
with :? ArgumentException as ex -> ex.Message
let dp_filePathIsValidException =
let invalidPath = "C:/notvalid/test.txt"
let invalidFileType = "C:/notvalid/test.doc"
// Template file paths by the open & load declarations
try
FilePathIsValid TestPost // enter filepath here
|> ignore
"No exception thrown"
with :? ArgumentException as ex -> ex.Message
// Data Structuring
let ds_map = Map.empty
@ -146,15 +154,6 @@ printfn "Text: %A" dss_sentences
// Product Services (Pancake)
[<Literal>]
let DesktopClock = __SOURCE_DIRECTORY__ + @"\TextFiles\desktop-clock-info.txt"
[<Literal>]
let ConsoleWaterworks = __SOURCE_DIRECTORY__ + @"\TextFiles\console-waterworks-announcement.txt"
[<Literal>]
let WordGenerator = __SOURCE_DIRECTORY__ + @"\TextFiles\word-generator.txt"
[<Literal>]
let TestPost = __SOURCE_DIRECTORY__ + @"\TextFiles\test-post.txt"
let ps_result1 = Pancake.RequestRandomTextAsync()
let ps_result2 = Pancake.RequestTextAsync 5 10
let ps_result3 = Pancake.RequestTextFromFileAsync 3 10 DesktopClock

Loading…
Cancel
Save