Core#
cli
#
Main module to expose internal functions as command lines.
renameit(config_path=None, config_dir=None)
#
This is the main API that is used to trigger renaming jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path |
Optional[str]
|
File path to configs overriding the default path. Defaults to None. |
None
|
config_dir |
Optional[str]
|
Dir path to other config files if needed. Defaults to None. |
None
|
Source code in renameit/core/cli.py
11 12 13 14 15 16 17 18 19 20 21 22 | |
job_runners
#
This module contains job runner classes that will run the renaming jobs
The module contains the following:
Job- Class representing renaming job.JobRunnerStandard- Implementation for standard job runner.
Job
#
The job class that contains the processing details. Providing the central point for file systems and handlers interactions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Name of the job. |
required |
file_system |
IFileSystem
|
Which file system to use. |
required |
rename_handler |
IHandler
|
Which renaming handler to use. |
required |
operation |
str
|
What operation to do on the matched files, accepted values are (rename, copy) case sensitive. |
required |
Source code in renameit/core/job_runners.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
run()
#
A job needs to run at some point.
Source code in renameit/core/job_runners.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
JobRunnerStandard
#
A simple implementation for executing jobs in sequence.
Source code in renameit/core/job_runners.py
90 91 92 93 94 95 | |
Config#
project
#
Config classes, simply extending the pydantic BaseModel are defined here to provide a contract for users to abide by. Schema definition, validation, serialization and deserialization are all handled within these classes.
We can expose real object instances from within these contracts/configs that can be used later by the app logic in other modules and functions.
FileSystemConfig
#
FileSystemConfig.
Source code in renameit/core/config/project.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
JobConfig
#
JobConfig.
Source code in renameit/core/config/project.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
ProjectConfig
#
UserProjectConfig.
Source code in renameit/core/config/project.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
get_jobs()
#
Get a list of Job objects from their corresponding list of JobConfig.
Returns:
| Type | Description |
|---|---|
List[Job]
|
List[Job]: List of Job objects |
Source code in renameit/core/config/project.py
33 34 35 36 37 38 39 | |
RenameHandlerConfig
#
RenameHandlerConfig.
Source code in renameit/core/config/project.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
parse
#
This module acts as the center point for reconciling user input from config files, env vars and other external configuration services.
Everything related to loading, parsing and rendering configurations can be implemented here.
The result data can be used as input for config classes like the ones in project
load_config(user_file_path=None, user_dir_path=None)
#
Load configurations from files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_file_path |
str
|
Path to the base config file. Defaults to None. |
None
|
user_dir_path |
str
|
Path to the extension config directory. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
OrderedDict
|
Single dict with all the loaded config |
Source code in renameit/core/config/parse.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |