bulk_mv package
Submodules
bulk_mv.bmv_generator module
bulk_mv.bmv_parser module
- class bulk_mv.bmv_parser.BmvParser
Bases:
object
- get_operations(tree, ops, current_path)
Extracts operation instructions from BMV Parse tree
- Parameters:
tree (dict) – BMV Parse tree
ops (dict) – Dictionary to store operations
current_path (str) – Current path of the directory
- Returns:
Dictionary of operations
- Return type:
dict
- parse(data)
Parses a BMV string and returns a dictionary of operations
- Parameters:
data (str) – BMV string
- Returns:
Dictionary of operations
- Return type:
dict
- class bulk_mv.bmv_parser.TreeToOperations(visit_tokens: bool = True)
Bases:
Transformer
- add_op(items)
Creates a dict representation of an add operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of an add operation
- Return type:
dict
- block(items)
Creates a dict representation of a block.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a block
- Return type:
dict
- block_item(items)
Creates a dict representation of a block item.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a block item
- Return type:
dict
- delete_op(items)
Creates a dict representation of a delete operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a delete operation
- Return type:
dict
- dir(items)
Creates a dict representation of a directory.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a directory
- Return type:
dict
- dir_op(items)
Creates a dict representation of a directory operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a directory operation
- Return type:
dict
- dirname(items)
Creates a dict representation of a directory name.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a directory name
- Return type:
dict
- entity(items)
Creates a dict representation of an entity.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of an entity
- Return type:
dict
- file_op(items)
Creates a dict representation of a file operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a file operation
- Return type:
dict
- filename(items)
Creates a dict representation of a file name.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a file name
- Return type:
dict
- lbrace(_)
- lbrack(_)
- move_dir_op(items)
Creates a dict representation of a directory move operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a directory move operation
- Return type:
dict
- move_file_op(items)
Creates a dict representation of a file move operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a file move operation
- Return type:
dict
- rbrace(_)
- rbrack(_)
- rename_dir_op(items)
Creates a dict representation of a directory rename operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a directory rename operation
- Return type:
dict
- rename_file_op(items)
Creates a dict representation of a file rename operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a file rename operation
- Return type:
dict
- rename_op(_)
- start(items)
- unary_op(items)
Creates a dict representation of a unary operation.
- Parameters:
items (array) – Array of node items from the Lark parser
- Returns:
dict representation of a unary operation
- Return type:
dict
bulk_mv.cli module
- bulk_mv.cli.run(start_path)
Runs the full pipeline for bmv.
- Parameters:
start_path (str) – The directory where you want to run bmv in.
- Returns:
error code
- Return type:
int
bulk_mv.file_tree module
- class bulk_mv.file_tree.FileTree(path)
Bases:
object
- add_child(child)
Adds a child FileTree node to the callee FileTree node
- Parameters:
child (FileTree) – the node to be made a child
- all_paths()
Genterates every path for every node under a FileTree node
- Returns:
array of string paths
- Return type:
array
- children()
Gets the children of the callee FileTree node
- Returns:
array of FileTree nodes
- Return type:
array
- name()
Gets the name of the callee FileTree node
Is derived from the path. The name is the last substring of the path after the last slash.
For example, if the path is “foo/bar/baz”, the name is “baz”.
- Returns:
the name of the callee FileTree node
- Return type:
str
bulk_mv.file_tree_builder module
bulk_mv.helpers module
- bulk_mv.helpers.get_last_index_of_substring(string, substring)
Returns index of the final substring occurring in a given string For example, the index of the last ‘/’ character in path/to/some/file is 12.
- Parameters:
string (str) – The full string
substring (str) – The substring your searching for in string
- Returns:
the last index, or -1 if the substring is not found
- Return type:
int
bulk_mv.operations module
- bulk_mv.operations.perform_adds(paths)
Creates all files from given paths
- Parameters:
paths (array) – Array of string paths
- bulk_mv.operations.perform_deletes(paths)
Deletes all files from given paths If the path doesn’t exist, bmv will silently continue with next operations
- Parameters:
paths (array) – Array of string paths
- bulk_mv.operations.perform_moves(movements)
Moves old file/dir names to new paths as specified by movements
- Parameters:
movements (dict) – dict containing current_path and new_path as keys
- bulk_mv.operations.perform_renames(renamings)
Renames old file/dir names to new ones as specified by renamings
- Parameters:
renamings (dict) – dict containing old_path and new_path as keys