|
1 | 1 | 0:01 So let's just take a moment and sketch out the flow of this application
|
2 | 2 | 0:04 just to build a skeleton as we always do.
|
3 |
| -0:06 So, we have a main method, and we'll do something here |
4 |
| -0:09 and of course we'll use the live template from main to call it down here, like so, |
| 3 | +0:06 So, we have a main() method, and we'll do something here |
| 4 | +0:09 and of course we'll use the live template from main() to call it down here, like so, |
5 | 5 | 0:13 from PyCharm, and then, the next thing we want to do
|
6 | 6 | 0:16 of course we are going to say define print header,
|
7 | 7 | 0:18 what we need to do is ask the user
|
8 |
| -0:20 hey what directories subtreat you want to search |
| 8 | +0:20 hey what directories subtree you want to search |
9 | 9 | 0:23 and what do you want to search for,
|
10 | 10 | 0:25 so those are the next two things we are going to need,
|
11 |
| -0:26 we'll say get folder from user, |
12 |
| -0:29 and similarly we'll say get search text from user. |
13 |
| -0:34 then let's just define a search file method here, |
| 11 | +0:26 we'll say get_folder_from_user(), |
| 12 | +0:29 and similarly we'll say get_search_text_from_user(). |
| 13 | +0:34 then let's just define a search_file() method here, |
14 | 14 | 0:37 and we'll figure out the parameters in a minute, ok,
|
15 | 15 | 0:40 we'll reformat so we are all good, via pep 8 and let's start writing,
|
16 |
| -0:44 so print header, you guys know this, this is old hat by now, |
| 16 | +0:44 so print_header(), you guys know this, this is old hat by now, |
17 | 17 | 0:48 so we'll just fly through it,
|
18 | 18 | 0:57 next we are going to get a folder from the user,
|
19 |
| -0:59 we'll say get folder form user and let's just do |
20 |
| -1:01 a quick little test like if they enter nothing we would rather not have our app crush |
| 19 | +0:59 we'll say get_folder_form_user() and let's just do |
| 20 | +1:01 a quick little test like if they enter nothing we would rather not have our app crash |
21 | 21 | 1:06 we'll just say hey search that, moreover,
|
22 | 22 | 1:10 if they enter folder that doesn't exist,
|
23 | 23 | 1:14 we'd also want to build the deal with this so just do a test,
|
|
40 | 40 | 2:08 something like that so we can hit control t and rename this
|
41 | 41 | 2:11 and go I want to search folders, like that, and do the refactoring,
|
42 | 42 | 2:16 and down here and if there was 100 files all potentially leveraging this
|
43 |
| -2:20 and doc strings leveraging and so on, |
| 43 | +2:20 and docstrings leveraging and so on, |
44 | 44 | 2:22 all of that would have been fixed,
|
45 | 45 | 2:25 now we need our folders and text of course, excellent,
|
46 | 46 | 2:28 so these should be pretty easy to write,
|
47 | 47 | 2:29 let's just come here and pull this out,
|
48 | 48 | 2:32 now we are going to do a little more than just get the text that is the folder,
|
49 | 49 | 2:36 we are actually going to verify it.
|
50 | 50 | 2:38 So ask the user what folder do you want to search,
|
51 |
| -2:40 then we'll say if not folder so for some reason it came back empty |
| 51 | +2:40 then we'll say if not folder: so for some reason it came back empty |
52 | 52 | 2:43 I don't think it can ever come back as none
|
53 |
| -2:45 but let's just verify it, and we'll say or if possibly the folder is just white space, right, |
| 53 | +2:45 but let's just verify it, let's little safe and we'll say or if possibly the folder is just white space, right, |
54 | 54 | 2:53 so in either case we'll just return none so we have nothing,
|
55 | 55 | 2:56 there is no folder and that will trigger remember up here
|
56 | 56 | 3:01 that will trigger this and say no, it doesn't work.
|
|
62 | 62 | 3:23 if you give it a file versus a folder, but we are not doing that right now,
|
63 | 63 | 3:25 so we are just going to say if it's not a directory
|
64 | 64 | 3:30 we'll just return none and then finally,
|
65 |
| -3:32 let's clean this up a little bit and say we'll return OS.path.absolutepath |
| 65 | +3:32 let's clean this up a little bit and say we'll return OS.path.absolutepath() |
66 | 66 | 3:37 so we have a nice absolute path for a folder instead of something relative,
|
67 | 67 | 3:41 as you will see having an absolute path is helpful for later on.
|
68 | 68 | 3:45 Next, let's just get some search text here,
|
|
85 | 85 | 4:40 so we would search/users/screencaster/desktop_08_file seracher for cats.
|
86 | 86 | 4:46 Perfect, so we have kind of all this parts of like user input
|
87 | 87 | 4:49 and everything completely done, and now
|
88 |
| -4:51 it's just a matter of implementing the search method. |
89 |
| - |
| 88 | +4:51 it's just a matter of implementing the search method. |
0 commit comments