mori
¶
Mori 💀 (qurry.capsule.mori
)
## Why Mori?
There are many dedicated data structures for Qurrium If we say one of them like a tree in forest, then all data structures combine, it makes a forest or ‘森’ read as mori in Japanese. Definitely NOT because I’m a DeadBeat, the fan of Hololive VTuber Mori Calliope, and I didn’t want to name something after her for a not short time.
gitsync
¶
GitSync - A quick way to create .gitignore (qurry.capsule.mori.gitsync
)
- class qurry.capsule.mori.gitsync.GitSyncControl(iterable=(), /)[source]¶
A gitignore file generator. A quick way to create .gitignore
- comment(comment: str) None [source]¶
Add comment to .gitignore.
- Parameters:
comment (str) – The comment to be added.
- export(save_location: Path | str = PosixPath('.'), open_args: OpenArgs | None = None, print_args: PrintArgs | None = None) None [source]¶
Export .gitignore
- Parameters:
save_location (Path) – The location of .gitignore.
open_args (Optional[OpenArgs], optional) –
The other arguments for
open()
function. Defaults to DEFAULT_OPEN_ARGS, which is: >>> {’mode’: ‘w+’, ‘encoding’: ‘utf-8’,
}
print_args (Optional[PrintArgs], optional) – The other arguments for
print()
function. Defaults to DEFAULT_PRINT_ARGS, which is: >>> {}
- ignore(filename: str, force: bool = False) bool [source]¶
Add file to ignore from sync.
- Parameters:
- Returns:
- The file is added to be ignored and return True.
If force is True, it will add the file again even if it’s already added, otherwise it will return False if the file is already added.
- Return type:
- load(save_location: Path | str, take_duplicate: bool = False, open_args: OpenArgs | None = None)[source]¶
Read existed .gitignore
- Parameters:
save_location (Path) – The location of .gitignore.
take_duplicate (bool, optional) – Take duplicate item in .gitignore. Defaults to False.
open_args (Optional[OpenArgs], optional) –
The other arguments for
open()
function. Defaults to DEFAULT_OPEN_ARGS, which is: >>> {’mode’: ‘w+’, ‘encoding’: ‘utf-8’,
}
- Raises:
FileNotFoundError – The .gitignore is not found.
TypeError – The save_location is not the type of ‘str’ or ‘Path’.
taglist
¶
TagList (qurry.capsule.mori.taglist
)
- class qurry.capsule.mori.taglist.TagList(o: dict[_K, Iterable[Any]] | None = None, name: str = 'TagList', tuple_str_auto_transplie: bool = True)[source]¶
Specific data structures of
qurrium
like dict[str, list[any]].>>> bla = TagList()
>>> bla.guider('strTag1', [...]) >>> bla.guider(('tupleTag1', ), [...]) >>> # other adding of key and value via `.guider()` >>> bla ... { ... (): [...], # something which does not specify tags. ... 'strTag1': [...], # something ... ('tupleTag1', ): [...], ... ... # other hashable as key in python ... }
- Parameters:
name (str, optional) – The name of this :cls:`TagList`. Defaults to TagList.
- Raises:
ValueError – When input is not a dict.
- class ParamsControl(open_args: OpenArgs, json_dump_args: JSONDumpArgs, save_location: Path)[source]¶
The type of arguments for
params_control()
- json_dump_args: JSONDumpArgs¶
The arguments for
json.dump()
function. Defaults to DEFAULT_JSON_DUMP_ARGS, which is: >>> {‘indent’: 2,
}
- export(name: str | None, save_location: Path | str = PosixPath('.'), taglist_name: str = 'TagList', open_args: OpenArgs | None = None, json_dump_args: JSONDumpArgs | None = None) Path [source]¶
Export :cls:`TagList` to a file.
- Parameters:
name (Optional[str], optional) – The file name should be something like “{name}.{taglist_name}.json” or “{taglist_name}.json” when ‘name’ is None.
save_location (Path) – The location of file. Defaults to Path(‘./’).
taglist_name (str, optional) – The suffix name for this tagList. Defaults to __name__. The file name will be “{name}.{taglist_name}.json” or “{taglist_name}.json” when ‘name’ is None.
open_args (Optional[OpenArgs], optional) –
The other arguments for
open()
function. Defaults to DEFAULT_OPEN_ARGS, which is: >>> {’mode’: ‘w+’, ‘encoding’: ‘utf-8’,
}
json_dump_args (Optional[JSONDumpArgs], optional) –
The other arguments for
json.dump()
function. Defaults to DEFAULT_JSON_DUMP_ARGS, which is: >>> {’indent’: 2,
}
- Raises:
ValueError – When filetype is not supported.
- Returns:
The path of exported file.
- Return type:
Path
- guider(proposal_tag: _K | None = None, v: Any = None) None [source]¶
Append a value to the :cls:`TagList` with a tag.
- Parameters:
proposal_tag (any) – The tag for this value.
v (any) – The value for legacy.
- classmethod params_control(open_args: OpenArgs | None = None, json_dump_args: JSONDumpArgs | None = None, save_location: Path | str = PosixPath('.'), is_read_only: bool = False) ParamsControl [source]¶
Handling all arguments.
- Parameters:
open_args (Optional[OpenArgs], optional) –
The other arguments for
open()
function. Defaults to DEFAULT_OPEN_ARGS, which is: >>> {’mode’: ‘w+’, ‘encoding’: ‘utf-8’,
}
json_dump_args (Optional[JSONDumpArgs], optional) –
The other arguments for
json.dump()
function. Defaults to DEFAULT_JSON_DUMP_ARGS, which is: >>> {’indent’: 2,
}
save_location (Path, optional) – The exported location. Defaults to Path(‘./’).
is_read_only (bool, optional) – Whether to read a file of :cls:`TagList` exportation.
- Returns:
Current arguments.
- Return type:
- classmethod read(filename: str, save_location: Path | str = PosixPath('.'), taglist_name: str = 'TagList', tuple_str_auto_transplie: bool = True, open_args: OpenArgs | None = None, json_dump_args: JSONDumpArgs | None = None) TagList [source]¶
Read a :cls:`TagList` from a file.
- Parameters:
filename (str) – The file name of exported :cls:`TagList`. The file name should be something like “{name}.{taglist_name}.json” or “{taglist_name}.json” when ‘name’ is None.
save_location (Path) – The location of file. Defaults to Path(‘./’).
taglist_name (str, optional) – The class name of :cls:`TagList`. Defaults to __name__.
tuple_str_auto_transplie (bool, optional) – Whether to transplie tuple string in the keys of the dict to real tuple. Defaults to True.
open_args (Optional[OpenArgs], optional) –
The other arguments for
open()
function. Defaults to DEFAULT_OPEN_ARGS, which is: >>> {’mode’: ‘w+’, ‘encoding’: ‘utf-8’,
}
json_dump_args (Optional[JSONDumpArgs], optional) –
The other arguments for
json.dump()
function. Defaults to DEFAULT_JSON_DUMP_ARGS, which is: >>> {’indent’: 2,
}
- Raises:
FileNotFoundError – When file not found.
- Returns:
The path of exported file.
- Return type:
- qurry.capsule.mori.taglist.key_tuple_loads(o: _T) _T [source]¶
- qurry.capsule.mori.taglist.key_tuple_loads(o: dict[_K, _T]) dict[_K, _T]
- qurry.capsule.mori.taglist.key_tuple_loads(o: dict[Hashable, _T]) dict[Hashable, _T]
If a dictionary with string keys which read from json may originally be a python tuple, then transplies as a tuple.