-
-
Notifications
You must be signed in to change notification settings - Fork 1
File Functions
Imagine you have a collection of important notes, photos, or documents that you work with regularly. Sometimes you need to save new information, check what's already stored, or organize things neatly in folders. This library is like a friendly helper designed to make those everyday file tasks simple and reliable, even if you're not a computer expert. Think of it as a digital assistant that quietly handles the behind-the-scenes work of managing your files and folders, so you can focus on what matters most to you.
At its heart, this toolset takes care of routine chores that often trip people up. For instance, if you want to create a new folder for your project, it checks whether that space already exists and sets it up perfectly without any fuss. When you need to read information from a file-like a list of contacts or settings-it carefully opens the document, grabs what you need, and handles any surprises, such as missing files, without causing confusion. Similarly, adding new details to an existing file or replacing old content with fresh updates becomes as straightforward as jotting a note in a notebook, all while keeping your original information safe.
What makes this library especially helpful is how it anticipates little problems you might not even think about. It gently removes empty lines from lists to keep things tidy, adjusts text to match your preferred style, and even understands when to look for special instructions hidden in configuration files. If something seems off-like a file that's misplaced or formatted incorrectly-it won't leave you guessing; instead, it offers clear guidance so you know exactly how to move forward. This thoughtful approach means you spend less time wrestling with technical hiccups and more time using your information productively.
Whether you're keeping track of personal projects, organizing work materials, or building something new, this library works quietly in the background to keep your digital workspace running smoothly. It's built for real-world use, where things aren't always perfect, and it treats your files with care-ensuring that saving, finding, and updating your data feels effortless. By turning complex file operations into simple, trustworthy actions, it gives you peace of mind, knowing your important information is always handled with precision and ease.
This function ensures that a specific storage location for your files is properly prepared by automatically setting up the necessary folders if they haven't been created yet, so you can immediately start saving your work without encountering errors about missing directories.
-
fn: A string representing the full path to the desired storage location. The function creates this directory and any required parent folders if they don't already exist, ensuring the path is ready for file operations.
Returns None.
When you need to access the information stored in a file, this function will retrieve it for you, ensuring that any extra blank space at the start or end is removed for regular text documents, and if the file cannot be located, it will indicate this by providing no data.
-
fn: A string representing the file path to read; the result depends on whether a file exists at this location, returning its content if present or nothing if absent. -
binary: A boolean value (defaulting to False) that determines the format of the returned content: when True, the content is provided as raw binary data, and when False, it is delivered as cleaned text with unnecessary spacing removed.
Returns a string (with leading and trailing whitespace stripped) if the file exists and binary is False, a bytes object if the file exists and binary is True, or None if the file does not exist.
This function allows you to add your written content to the end of an existing document while keeping all previous information intact, and if the document doesn't exist yet, it automatically creates a new one to store your content without affecting anything else you've previously written.
-
fname: A string representing the path and name of the document where content will be added; determines which document receives the new text or gets created if missing. -
text: A string containing the content to be inserted at the end of the document; directly becomes the new material appended to the existing content.
Returns None.
This function takes your information and stores it safely inside a designated file on your computer, completely replacing any previous contents so the file now holds only the new details you provided without leaving behind old material.
-
fn: A string representing the full path and name of the file where content will be stored, determining exactly which file gets created or overwritten on your system. -
data: A string containing the specific text content to be saved, which becomes the sole information present in the file after the operation completes.
Returns None.
def ReadFile2List(fname, Unique=True, Delimiter="\n", ForceLower=False, ForceUpper=False, NoStripEmpty=False):
This function takes a text file and transforms its content into a clean, organized list where each distinct piece of information appears just once, automatically skipping any blank lines while giving you simple choices to control whether everything shows up in lowercase letters, uppercase letters, or exactly as written, making it effortless to prepare data for further use without worrying about duplicates or inconsistent formatting.
-
fname: String specifying the file path to read; the content of this file becomes the source for the resulting list. -
Unique: Boolean determining whether duplicate entries are removed from the final list when set to True. -
Delimiter: String character or sequence used to split the file content into individual list items; defaults to line breaks. -
ForceLower: Boolean that converts all list items to lowercase letters when enabled. -
ForceUpper: Boolean that converts all list items to uppercase letters when enabled. -
NoStripEmpty: Boolean controlling whether empty lines remain in the list; when True preserves them, otherwise removes them.
Returns a list of strings containing the processed file content, or None if the specified file does not exist.
This function helps you securely access your stored credentials by automatically locating and reading the correct configuration file on your computer, intelligently replacing any placeholder references with actual values from your system's environment settings, and providing immediate, clear feedback if anything is missing or incorrectly formatted to ensure your work proceeds smoothly without unexpected interruptions.
-
gid: Represents a custom identifier for selecting a specific token file; expected to be a string. When provided, the function uses this identifier to locate the corresponding token file instead of defaulting to the current program's name. -
userhome: Represents a custom directory path for token storage; expected to be a string. When provided, the function searches for token files in this specified directory rather than the default system location.
Returns a dictionary containing token names as keys and their resolved values as strings, where environment variable placeholders have been substituted with actual system values.
If you would like to help support this project financially, please click on the heart shaped sponsor's button in the right column of this page. I also have a merch store with some awesome and really cool products. Please visit supporting Jackrabbit for more options.
All subscriptions/sales go to the costs of sustaining Jackrabbit AI. Thank you.