Description
findOrBuildFile: find or build file
Explanation
- find - Find that
text length is small enough
to fit in an existing file,
from which the text came or
to which the text, otherwise, belongs
- build - If the text
length is too great (too large
in quantity value), then build a
new file(s), and split the text
between multiple files
End "Description"
Parameters
function name, f_1(v_p = None)
The variable called, v_p (shown above), is the parameters, as a var type list([]) object.
v_p includes vars, as follows:
#About the function parameters
v_p[0] = <my text>
v_p[1] = <indicate file name, else leave as, str("Build a new file.")>
v_p[2] = <indicate if saving to dropbox versus saving to my lapatop (my limited storage maximum requirements about my laptop, if saving to my laptop, leave the param as bool(False). If save to dropbox, then, indicate, bool(True).>
#Example
v_1 = [
str("This is some text, from a file."), #The file name from which the text was taken is assigned to var v_1[1], below.
str("fileName.py"),
bool(False)
]
from f import f_1
f_1(v_1)
End "Parameters"
Procedure
1. (Part 1) Find text-qty, about the file to be edited. Example - len(text_data_str_of_file)
2.1. (Part 2) If the text-qty is greater than 50,000, then the file may become too large; consequently, some text must be saved to another file, also (save the text to multiple files)
2.2. To save to another file, also (i.e., also means - in addition to saving the text to the specified file, where the var arg sent to this module, to function f_1(params), received as var params (or var v_p, in this case), specifies the file to save to) - a new file must be created; consequently, since file names are in the format, <fileName_idHere.py>, find the id-value of the name of the current file (the, "idHere", part of the file name); then, add 1 to it (thus, building the new file name, with the format, <fileName_newIdHere.py>).
Example 1
import f as m_1
v_1 = "data_1.py"
with open(v_1, "r") as v_f:
v_t = v_f.read()
v_f.close() #*See Note 1, below.
del v_f
#<modify/edit v_t here>
#then, option 1:
v_2 = [v_t, "Build a new file.", ["dropbox", False]]
m_1.f_1(v_2) #(1) build new file(s), if needed; (2) print v_t to file(s)
#or, option 2:
v_2 = [v_t, v_1, ["dropbox", False]]
m_1.f_1(v_2) #(1) build new file(s), if needed; (2) print v_t to file(s)
End "Procedure"
Definitions
<> : denotes aliases as references, between the character, less than, "<" and the character, greater than, ">". Example - <fileName.py>, means that a file name belongs at that position, fileName, but it doesn't mean that the file name is "fileName" + the extension ".py". Example 2 - <fN_id.py> could be filled in with something like, "urlData_112.py", or whatever file name would be suitable for the application one is working on.
qty abbr English-United-States: quantity
m_f abbr python3.10-code-syntax: module_1
v_f abbr python3.10-code-syntax: variable_file_document_object
v_t abbr python3.10-code-syntax: variable_text_from_file
module python3.10-code-syntax: Is a file with ".py" extension, in its file name. A file with a ".py" extension, in its name, is used to run python syntax code in the command-line-interface.
method python3.10-code-syntax: A method is a function.
del abbr python3.10-code-syntax: delete variable name and value from the command-line-interface instance
End "Definitions"
Notes
*Note 1 - Text from a file becomes available, only after the file is closed, using the .close() method. This module uses <fileName>.close().
End "Notes"
"""