helpers¶
- pygitrepo.helpers.join_s3_uri(bucket, key)[source]¶
Join AWS S3 URI from bucket and key.
- Return type
- pygitrepo.helpers.s3_key_smart_join(parts, is_dir)[source]¶
Note, it assume that there’s no such double slack in your path. It ensure that there’s only one consecutive “/” in the s3 key.
- Parameters
parts (typing.List[str]) – list of s3 key path parts, could have “/”
is_dir (bool) – if True, the s3 key ends with “/”. otherwise enforce no tailing “/”.
- Return type
Example:
>>> s3_key_smart_join(parts=["/a/", "b/", "/c"], is_dir=True) a/b/c/ >>> s3_key_smart_join(parts=["/a/", "b/", "/c"], is_dir=False) a/b/c
- pygitrepo.helpers.make_s3_console_url(bucket=None, prefix=None, s3_uri=None)[source]¶
Return an AWS Console url that you can use to open it in your browser.
- Return type
- pygitrepo.helpers.s3_uri_to_url(s3_uri)[source]¶
Convert a S3 URI to AWS S3 Console url for preview.
:type s3_uri :rtype: str
- pygitrepo.helpers.ensure_s3_object(s3_key_or_uri)[source]¶
Raise exception if the string is not in valid format for a AWS S3 object
- pygitrepo.helpers.ensure_s3_dir(s3_key_or_uri)[source]¶
Raise exception if the string is not in valid format for a AWS S3 directory
- pygitrepo.helpers.strip_comment_line_with_symbol(line, start)[source]¶
Strip comments from line string.
- pygitrepo.helpers.strip_comments(string, comment_symbols=frozenset({'#', '//'}))[source]¶
Strip comments from json string.
- Parameters
string – A string containing json with comments started by comment_symbols.
comment_symbols – Iterable of symbols that start a line comment (default # or //).
- Returns
The string with the comments removed.
- pygitrepo.helpers.remove_if_exists(abspath)[source]¶
Remove a file or a directory (and it’s files) if exists.