repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter._index_mountpoints | def _index_mountpoints(self):
"""Finds all mountpoints and stores them in :attr:`mountpoints`"""
# find all mountponits
self.mountpoints = {}
# noinspection PyBroadException
try:
result = _util.check_output_(['mount'])
for line in result.splitlines():
... | python | def _index_mountpoints(self):
"""Finds all mountpoints and stores them in :attr:`mountpoints`"""
# find all mountponits
self.mountpoints = {}
# noinspection PyBroadException
try:
result = _util.check_output_(['mount'])
for line in result.splitlines():
... | [
"def",
"_index_mountpoints",
"(",
"self",
")",
":",
"# find all mountponits",
"self",
".",
"mountpoints",
"=",
"{",
"}",
"# noinspection PyBroadException",
"try",
":",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'mount'",
"]",
")",
"for",
"line",
... | Finds all mountpoints and stores them in :attr:`mountpoints` | [
"Finds",
"all",
"mountpoints",
"and",
"stores",
"them",
"in",
":",
"attr",
":",
"mountpoints"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L88-L101 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter._index_loopbacks | def _index_loopbacks(self):
"""Finds all loopbacks and stores them in :attr:`loopbacks`"""
self.loopbacks = {}
try:
result = _util.check_output_(['losetup', '-a'])
for line in result.splitlines():
m = re.match(r'(.+): (.+) \((.+)\).*', line)
... | python | def _index_loopbacks(self):
"""Finds all loopbacks and stores them in :attr:`loopbacks`"""
self.loopbacks = {}
try:
result = _util.check_output_(['losetup', '-a'])
for line in result.splitlines():
m = re.match(r'(.+): (.+) \((.+)\).*', line)
... | [
"def",
"_index_loopbacks",
"(",
"self",
")",
":",
"self",
".",
"loopbacks",
"=",
"{",
"}",
"try",
":",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-a'",
"]",
")",
"for",
"line",
"in",
"result",
".",
"splitlines",
"(",
... | Finds all loopbacks and stores them in :attr:`loopbacks` | [
"Finds",
"all",
"loopbacks",
"and",
"stores",
"them",
"in",
":",
"attr",
":",
"loopbacks"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L103-L114 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_bindmounts | def find_bindmounts(self):
"""Finds all bind mountpoints that are inside mounts that match the :attr:`re_pattern`"""
for mountpoint, (orig, fs, opts) in self.mountpoints.items():
if 'bind' in opts and re.match(self.re_pattern, mountpoint):
yield mountpoint | python | def find_bindmounts(self):
"""Finds all bind mountpoints that are inside mounts that match the :attr:`re_pattern`"""
for mountpoint, (orig, fs, opts) in self.mountpoints.items():
if 'bind' in opts and re.match(self.re_pattern, mountpoint):
yield mountpoint | [
"def",
"find_bindmounts",
"(",
"self",
")",
":",
"for",
"mountpoint",
",",
"(",
"orig",
",",
"fs",
",",
"opts",
")",
"in",
"self",
".",
"mountpoints",
".",
"items",
"(",
")",
":",
"if",
"'bind'",
"in",
"opts",
"and",
"re",
".",
"match",
"(",
"self"... | Finds all bind mountpoints that are inside mounts that match the :attr:`re_pattern` | [
"Finds",
"all",
"bind",
"mountpoints",
"that",
"are",
"inside",
"mounts",
"that",
"match",
"the",
":",
"attr",
":",
"re_pattern"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L116-L121 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_mounts | def find_mounts(self):
"""Finds all mountpoints that are mounted to a directory matching :attr:`re_pattern` or originate from a
directory matching :attr:`orig_re_pattern`.
"""
for mountpoint, (orig, fs, opts) in self.mountpoints.items():
if 'bind' not in opts and (re.match(s... | python | def find_mounts(self):
"""Finds all mountpoints that are mounted to a directory matching :attr:`re_pattern` or originate from a
directory matching :attr:`orig_re_pattern`.
"""
for mountpoint, (orig, fs, opts) in self.mountpoints.items():
if 'bind' not in opts and (re.match(s... | [
"def",
"find_mounts",
"(",
"self",
")",
":",
"for",
"mountpoint",
",",
"(",
"orig",
",",
"fs",
",",
"opts",
")",
"in",
"self",
".",
"mountpoints",
".",
"items",
"(",
")",
":",
"if",
"'bind'",
"not",
"in",
"opts",
"and",
"(",
"re",
".",
"match",
"... | Finds all mountpoints that are mounted to a directory matching :attr:`re_pattern` or originate from a
directory matching :attr:`orig_re_pattern`. | [
"Finds",
"all",
"mountpoints",
"that",
"are",
"mounted",
"to",
"a",
"directory",
"matching",
":",
"attr",
":",
"re_pattern",
"or",
"originate",
"from",
"a",
"directory",
"matching",
":",
"attr",
":",
"orig_re_pattern",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L123-L131 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_base_images | def find_base_images(self):
"""Finds all mountpoints that are mounted to a directory matching :attr:`orig_re_pattern`."""
for mountpoint, _ in self.mountpoints.items():
if re.match(self.orig_re_pattern, mountpoint):
yield mountpoint | python | def find_base_images(self):
"""Finds all mountpoints that are mounted to a directory matching :attr:`orig_re_pattern`."""
for mountpoint, _ in self.mountpoints.items():
if re.match(self.orig_re_pattern, mountpoint):
yield mountpoint | [
"def",
"find_base_images",
"(",
"self",
")",
":",
"for",
"mountpoint",
",",
"_",
"in",
"self",
".",
"mountpoints",
".",
"items",
"(",
")",
":",
"if",
"re",
".",
"match",
"(",
"self",
".",
"orig_re_pattern",
",",
"mountpoint",
")",
":",
"yield",
"mountp... | Finds all mountpoints that are mounted to a directory matching :attr:`orig_re_pattern`. | [
"Finds",
"all",
"mountpoints",
"that",
"are",
"mounted",
"to",
"a",
"directory",
"matching",
":",
"attr",
":",
"orig_re_pattern",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L133-L138 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_volume_groups | def find_volume_groups(self):
"""Finds all volume groups that are mounted through a loopback originating from :attr:`orig_re_pattern`.
Generator yields tuples of vgname, pvname
"""
os.environ['LVM_SUPPRESS_FD_WARNINGS'] = '1'
# find volume groups
try:
resul... | python | def find_volume_groups(self):
"""Finds all volume groups that are mounted through a loopback originating from :attr:`orig_re_pattern`.
Generator yields tuples of vgname, pvname
"""
os.environ['LVM_SUPPRESS_FD_WARNINGS'] = '1'
# find volume groups
try:
resul... | [
"def",
"find_volume_groups",
"(",
"self",
")",
":",
"os",
".",
"environ",
"[",
"'LVM_SUPPRESS_FD_WARNINGS'",
"]",
"=",
"'1'",
"# find volume groups",
"try",
":",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'pvdisplay'",
"]",
")",
"pvname",
"=",
... | Finds all volume groups that are mounted through a loopback originating from :attr:`orig_re_pattern`.
Generator yields tuples of vgname, pvname | [
"Finds",
"all",
"volume",
"groups",
"that",
"are",
"mounted",
"through",
"a",
"loopback",
"originating",
"from",
":",
"attr",
":",
"orig_re_pattern",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L140-L170 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_loopbacks | def find_loopbacks(self):
"""Finds all loopbacks originating from :attr:`orig_re_pattern`.
Generator yields device names
"""
for dev, source in self.loopbacks.items():
if re.match(self.orig_re_pattern, source):
yield dev | python | def find_loopbacks(self):
"""Finds all loopbacks originating from :attr:`orig_re_pattern`.
Generator yields device names
"""
for dev, source in self.loopbacks.items():
if re.match(self.orig_re_pattern, source):
yield dev | [
"def",
"find_loopbacks",
"(",
"self",
")",
":",
"for",
"dev",
",",
"source",
"in",
"self",
".",
"loopbacks",
".",
"items",
"(",
")",
":",
"if",
"re",
".",
"match",
"(",
"self",
".",
"orig_re_pattern",
",",
"source",
")",
":",
"yield",
"dev"
] | Finds all loopbacks originating from :attr:`orig_re_pattern`.
Generator yields device names | [
"Finds",
"all",
"loopbacks",
"originating",
"from",
":",
"attr",
":",
"orig_re_pattern",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L172-L180 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.unmount_bindmounts | def unmount_bindmounts(self):
"""Unmounts all bind mounts identified by :func:`find_bindmounts`"""
for mountpoint in self.find_bindmounts():
_util.clean_unmount(['umount'], mountpoint, rmdir=False) | python | def unmount_bindmounts(self):
"""Unmounts all bind mounts identified by :func:`find_bindmounts`"""
for mountpoint in self.find_bindmounts():
_util.clean_unmount(['umount'], mountpoint, rmdir=False) | [
"def",
"unmount_bindmounts",
"(",
"self",
")",
":",
"for",
"mountpoint",
"in",
"self",
".",
"find_bindmounts",
"(",
")",
":",
"_util",
".",
"clean_unmount",
"(",
"[",
"'umount'",
"]",
",",
"mountpoint",
",",
"rmdir",
"=",
"False",
")"
] | Unmounts all bind mounts identified by :func:`find_bindmounts` | [
"Unmounts",
"all",
"bind",
"mounts",
"identified",
"by",
":",
"func",
":",
"find_bindmounts"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L182-L186 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.unmount_volume_groups | def unmount_volume_groups(self):
"""Unmounts all volume groups and related loopback devices as identified by :func:`find_volume_groups`"""
for vgname, pvname in self.find_volume_groups():
_util.check_output_(['lvchange', '-a', 'n', vgname])
_util.check_output_(['losetup', '-d', ... | python | def unmount_volume_groups(self):
"""Unmounts all volume groups and related loopback devices as identified by :func:`find_volume_groups`"""
for vgname, pvname in self.find_volume_groups():
_util.check_output_(['lvchange', '-a', 'n', vgname])
_util.check_output_(['losetup', '-d', ... | [
"def",
"unmount_volume_groups",
"(",
"self",
")",
":",
"for",
"vgname",
",",
"pvname",
"in",
"self",
".",
"find_volume_groups",
"(",
")",
":",
"_util",
".",
"check_output_",
"(",
"[",
"'lvchange'",
",",
"'-a'",
",",
"'n'",
",",
"vgname",
"]",
")",
"_util... | Unmounts all volume groups and related loopback devices as identified by :func:`find_volume_groups` | [
"Unmounts",
"all",
"volume",
"groups",
"and",
"related",
"loopback",
"devices",
"as",
"identified",
"by",
":",
"func",
":",
"find_volume_groups"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L200-L205 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.unmount_loopbacks | def unmount_loopbacks(self):
"""Unmounts all loopback devices as identified by :func:`find_loopbacks`"""
# re-index loopback devices
self._index_loopbacks()
for dev in self.find_loopbacks():
_util.check_output_(['losetup', '-d', dev]) | python | def unmount_loopbacks(self):
"""Unmounts all loopback devices as identified by :func:`find_loopbacks`"""
# re-index loopback devices
self._index_loopbacks()
for dev in self.find_loopbacks():
_util.check_output_(['losetup', '-d', dev]) | [
"def",
"unmount_loopbacks",
"(",
"self",
")",
":",
"# re-index loopback devices",
"self",
".",
"_index_loopbacks",
"(",
")",
"for",
"dev",
"in",
"self",
".",
"find_loopbacks",
"(",
")",
":",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-d'",
... | Unmounts all loopback devices as identified by :func:`find_loopbacks` | [
"Unmounts",
"all",
"loopback",
"devices",
"as",
"identified",
"by",
":",
"func",
":",
"find_loopbacks"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L207-L214 |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter.find_clean_dirs | def find_clean_dirs(self):
"""Finds all (temporary) directories according to the glob and re patterns that should be cleaned."""
for folder in glob.glob(self.glob_pattern):
if re.match(self.re_pattern, folder):
yield folder
for folder in glob.glob(self.orig_glob_patt... | python | def find_clean_dirs(self):
"""Finds all (temporary) directories according to the glob and re patterns that should be cleaned."""
for folder in glob.glob(self.glob_pattern):
if re.match(self.re_pattern, folder):
yield folder
for folder in glob.glob(self.orig_glob_patt... | [
"def",
"find_clean_dirs",
"(",
"self",
")",
":",
"for",
"folder",
"in",
"glob",
".",
"glob",
"(",
"self",
".",
"glob_pattern",
")",
":",
"if",
"re",
".",
"match",
"(",
"self",
".",
"re_pattern",
",",
"folder",
")",
":",
"yield",
"folder",
"for",
"fol... | Finds all (temporary) directories according to the glob and re patterns that should be cleaned. | [
"Finds",
"all",
"(",
"temporary",
")",
"directories",
"according",
"to",
"the",
"glob",
"and",
"re",
"patterns",
"that",
"should",
"be",
"cleaned",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L216-L224 |
ralphje/imagemounter | imagemounter/_util.py | expand_path | def expand_path(path):
"""
Expand the given path to either an Encase image or a dd image
i.e. if path is '/path/to/image.E01' then the result of this method will be
/path/to/image.E*'
and if path is '/path/to/image.001' then the result of this method will be
'/path/to/image.[0-9][0-9]?'
"""
... | python | def expand_path(path):
"""
Expand the given path to either an Encase image or a dd image
i.e. if path is '/path/to/image.E01' then the result of this method will be
/path/to/image.E*'
and if path is '/path/to/image.001' then the result of this method will be
'/path/to/image.[0-9][0-9]?'
"""
... | [
"def",
"expand_path",
"(",
"path",
")",
":",
"if",
"is_encase",
"(",
"path",
")",
":",
"return",
"glob",
".",
"glob",
"(",
"path",
"[",
":",
"-",
"2",
"]",
"+",
"'??'",
")",
"or",
"[",
"path",
"]",
"ext_match",
"=",
"re",
".",
"match",
"(",
"r'... | Expand the given path to either an Encase image or a dd image
i.e. if path is '/path/to/image.E01' then the result of this method will be
/path/to/image.E*'
and if path is '/path/to/image.001' then the result of this method will be
'/path/to/image.[0-9][0-9]?' | [
"Expand",
"the",
"given",
"path",
"to",
"either",
"an",
"Encase",
"image",
"or",
"a",
"dd",
"image",
"i",
".",
"e",
".",
"if",
"path",
"is",
"/",
"path",
"/",
"to",
"/",
"image",
".",
"E01",
"then",
"the",
"result",
"of",
"this",
"method",
"will",
... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/_util.py#L78-L93 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.add_disk | def add_disk(self, path, force_disk_indexes=True, **args):
"""Adds a disk specified by the path to the ImageParser.
:param path: The path to the disk volume
:param force_disk_indexes: If true, always uses disk indexes. If False, only uses disk indexes if this is the
... | python | def add_disk(self, path, force_disk_indexes=True, **args):
"""Adds a disk specified by the path to the ImageParser.
:param path: The path to the disk volume
:param force_disk_indexes: If true, always uses disk indexes. If False, only uses disk indexes if this is the
... | [
"def",
"add_disk",
"(",
"self",
",",
"path",
",",
"force_disk_indexes",
"=",
"True",
",",
"*",
"*",
"args",
")",
":",
"if",
"self",
".",
"disks",
"and",
"self",
".",
"disks",
"[",
"0",
"]",
".",
"index",
"is",
"None",
":",
"raise",
"DiskIndexError",
... | Adds a disk specified by the path to the ImageParser.
:param path: The path to the disk volume
:param force_disk_indexes: If true, always uses disk indexes. If False, only uses disk indexes if this is the
second volume you add. If you plan on using this method, always... | [
"Adds",
"a",
"disk",
"specified",
"by",
"the",
"path",
"to",
"the",
"ImageParser",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L75-L93 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.init | def init(self, single=None, swallow_exceptions=True):
"""Handles all important disk-mounting tasks, i.e. calls the :func:`Disk.init` function on all underlying
disks. It yields every volume that is encountered, including volumes that have not been mounted.
:param single: indicates whether the :... | python | def init(self, single=None, swallow_exceptions=True):
"""Handles all important disk-mounting tasks, i.e. calls the :func:`Disk.init` function on all underlying
disks. It yields every volume that is encountered, including volumes that have not been mounted.
:param single: indicates whether the :... | [
"def",
"init",
"(",
"self",
",",
"single",
"=",
"None",
",",
"swallow_exceptions",
"=",
"True",
")",
":",
"for",
"d",
"in",
"self",
".",
"disks",
":",
"for",
"v",
"in",
"d",
".",
"init",
"(",
"single",
",",
"swallow_exceptions",
"=",
"swallow_exception... | Handles all important disk-mounting tasks, i.e. calls the :func:`Disk.init` function on all underlying
disks. It yields every volume that is encountered, including volumes that have not been mounted.
:param single: indicates whether the :class:`Disk` should be mounted as a single disk, not as a single ... | [
"Handles",
"all",
"important",
"disk",
"-",
"mounting",
"tasks",
"i",
".",
"e",
".",
"calls",
"the",
":",
"func",
":",
"Disk",
".",
"init",
"function",
"on",
"all",
"underlying",
"disks",
".",
"It",
"yields",
"every",
"volume",
"that",
"is",
"encountered... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L95-L107 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.mount_disks | def mount_disks(self):
"""Mounts all disks in the parser, i.e. calling :func:`Disk.mount` on all underlying disks. You probably want to
use :func:`init` instead.
:return: whether all mounts have succeeded
:rtype: bool"""
result = True
for disk in self.disks:
... | python | def mount_disks(self):
"""Mounts all disks in the parser, i.e. calling :func:`Disk.mount` on all underlying disks. You probably want to
use :func:`init` instead.
:return: whether all mounts have succeeded
:rtype: bool"""
result = True
for disk in self.disks:
... | [
"def",
"mount_disks",
"(",
"self",
")",
":",
"result",
"=",
"True",
"for",
"disk",
"in",
"self",
".",
"disks",
":",
"result",
"=",
"disk",
".",
"mount",
"(",
")",
"and",
"result",
"return",
"result"
] | Mounts all disks in the parser, i.e. calling :func:`Disk.mount` on all underlying disks. You probably want to
use :func:`init` instead.
:return: whether all mounts have succeeded
:rtype: bool | [
"Mounts",
"all",
"disks",
"in",
"the",
"parser",
"i",
".",
"e",
".",
"calling",
":",
"func",
":",
"Disk",
".",
"mount",
"on",
"all",
"underlying",
"disks",
".",
"You",
"probably",
"want",
"to",
"use",
":",
"func",
":",
"init",
"instead",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L109-L119 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.rw_active | def rw_active(self):
"""Indicates whether a read-write cache is active in any of the disks.
:rtype: bool"""
result = False
for disk in self.disks:
result = disk.rw_active() or result
return result | python | def rw_active(self):
"""Indicates whether a read-write cache is active in any of the disks.
:rtype: bool"""
result = False
for disk in self.disks:
result = disk.rw_active() or result
return result | [
"def",
"rw_active",
"(",
"self",
")",
":",
"result",
"=",
"False",
"for",
"disk",
"in",
"self",
".",
"disks",
":",
"result",
"=",
"disk",
".",
"rw_active",
"(",
")",
"or",
"result",
"return",
"result"
] | Indicates whether a read-write cache is active in any of the disks.
:rtype: bool | [
"Indicates",
"whether",
"a",
"read",
"-",
"write",
"cache",
"is",
"active",
"in",
"any",
"of",
"the",
"disks",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L121-L128 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.init_volumes | def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True):
"""Detects volumes (as volume system or as single volume) in all disks and yields the volumes. This calls
:func:`Disk.init_volumes` on all disks and should be called after :func:`mount_disks`.
:rtype... | python | def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True):
"""Detects volumes (as volume system or as single volume) in all disks and yields the volumes. This calls
:func:`Disk.init_volumes` on all disks and should be called after :func:`mount_disks`.
:rtype... | [
"def",
"init_volumes",
"(",
"self",
",",
"single",
"=",
"None",
",",
"only_mount",
"=",
"None",
",",
"skip_mount",
"=",
"None",
",",
"swallow_exceptions",
"=",
"True",
")",
":",
"for",
"disk",
"in",
"self",
".",
"disks",
":",
"logger",
".",
"info",
"("... | Detects volumes (as volume system or as single volume) in all disks and yields the volumes. This calls
:func:`Disk.init_volumes` on all disks and should be called after :func:`mount_disks`.
:rtype: generator | [
"Detects",
"volumes",
"(",
"as",
"volume",
"system",
"or",
"as",
"single",
"volume",
")",
"in",
"all",
"disks",
"and",
"yields",
"the",
"volumes",
".",
"This",
"calls",
":",
"func",
":",
"Disk",
".",
"init_volumes",
"on",
"all",
"disks",
"and",
"should",... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L130-L139 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.get_by_index | def get_by_index(self, index):
"""Returns a Volume or Disk by its index."""
try:
return self[index]
except KeyError:
for v in self.get_volumes():
if v.index == str(index):
return v
raise KeyError(index) | python | def get_by_index(self, index):
"""Returns a Volume or Disk by its index."""
try:
return self[index]
except KeyError:
for v in self.get_volumes():
if v.index == str(index):
return v
raise KeyError(index) | [
"def",
"get_by_index",
"(",
"self",
",",
"index",
")",
":",
"try",
":",
"return",
"self",
"[",
"index",
"]",
"except",
"KeyError",
":",
"for",
"v",
"in",
"self",
".",
"get_volumes",
"(",
")",
":",
"if",
"v",
".",
"index",
"==",
"str",
"(",
"index",... | Returns a Volume or Disk by its index. | [
"Returns",
"a",
"Volume",
"or",
"Disk",
"by",
"its",
"index",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L141-L150 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.get_volumes | def get_volumes(self):
"""Gets a list of all volumes of all disks, concatenating :func:`Disk.get_volumes` of all disks.
:rtype: list"""
volumes = []
for disk in self.disks:
volumes.extend(disk.get_volumes())
return volumes | python | def get_volumes(self):
"""Gets a list of all volumes of all disks, concatenating :func:`Disk.get_volumes` of all disks.
:rtype: list"""
volumes = []
for disk in self.disks:
volumes.extend(disk.get_volumes())
return volumes | [
"def",
"get_volumes",
"(",
"self",
")",
":",
"volumes",
"=",
"[",
"]",
"for",
"disk",
"in",
"self",
".",
"disks",
":",
"volumes",
".",
"extend",
"(",
"disk",
".",
"get_volumes",
"(",
")",
")",
"return",
"volumes"
] | Gets a list of all volumes of all disks, concatenating :func:`Disk.get_volumes` of all disks.
:rtype: list | [
"Gets",
"a",
"list",
"of",
"all",
"volumes",
"of",
"all",
"disks",
"concatenating",
":",
"func",
":",
"Disk",
".",
"get_volumes",
"of",
"all",
"disks",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L152-L160 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.clean | def clean(self, remove_rw=False, allow_lazy=False):
"""Cleans all volumes of all disks (:func:`Volume.unmount`) and all disks (:func:`Disk.unmount`). Volume errors
are ignored, but returns immediately on disk unmount error.
:param bool remove_rw: indicates whether a read-write cache should be r... | python | def clean(self, remove_rw=False, allow_lazy=False):
"""Cleans all volumes of all disks (:func:`Volume.unmount`) and all disks (:func:`Disk.unmount`). Volume errors
are ignored, but returns immediately on disk unmount error.
:param bool remove_rw: indicates whether a read-write cache should be r... | [
"def",
"clean",
"(",
"self",
",",
"remove_rw",
"=",
"False",
",",
"allow_lazy",
"=",
"False",
")",
":",
"# To ensure clean unmount after reconstruct, we sort across all volumes in all our disks to provide a proper",
"# order",
"volumes",
"=",
"list",
"(",
"sorted",
"(",
"... | Cleans all volumes of all disks (:func:`Volume.unmount`) and all disks (:func:`Disk.unmount`). Volume errors
are ignored, but returns immediately on disk unmount error.
:param bool remove_rw: indicates whether a read-write cache should be removed
:param bool allow_lazy: indicates whether lazy u... | [
"Cleans",
"all",
"volumes",
"of",
"all",
"disks",
"(",
":",
"func",
":",
"Volume",
".",
"unmount",
")",
"and",
"all",
"disks",
"(",
":",
"func",
":",
"Disk",
".",
"unmount",
")",
".",
"Volume",
"errors",
"are",
"ignored",
"but",
"returns",
"immediately... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L162-L183 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.force_clean | def force_clean(self, remove_rw=False, allow_lazy=False, retries=5, sleep_interval=0.5):
"""Attempts to call the clean method, but will retry automatically if an error is raised. When the attempts
run out, it will raise the last error.
Note that the method will only catch :class:`ImageMounterEr... | python | def force_clean(self, remove_rw=False, allow_lazy=False, retries=5, sleep_interval=0.5):
"""Attempts to call the clean method, but will retry automatically if an error is raised. When the attempts
run out, it will raise the last error.
Note that the method will only catch :class:`ImageMounterEr... | [
"def",
"force_clean",
"(",
"self",
",",
"remove_rw",
"=",
"False",
",",
"allow_lazy",
"=",
"False",
",",
"retries",
"=",
"5",
",",
"sleep_interval",
"=",
"0.5",
")",
":",
"while",
"True",
":",
"try",
":",
"self",
".",
"clean",
"(",
"remove_rw",
"=",
... | Attempts to call the clean method, but will retry automatically if an error is raised. When the attempts
run out, it will raise the last error.
Note that the method will only catch :class:`ImageMounterError` exceptions.
:param bool remove_rw: indicates whether a read-write cache should be remo... | [
"Attempts",
"to",
"call",
"the",
"clean",
"method",
"but",
"will",
"retry",
"automatically",
"if",
"an",
"error",
"is",
"raised",
".",
"When",
"the",
"attempts",
"run",
"out",
"it",
"will",
"raise",
"the",
"last",
"error",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L185-L208 |
ralphje/imagemounter | imagemounter/parser.py | ImageParser.reconstruct | def reconstruct(self):
"""Reconstructs the filesystem of all volumes mounted by the parser by inspecting the last mount point and
bind mounting everything.
:raises: NoRootFoundError if no root could be found
:return: the root :class:`Volume`
"""
volumes = list(sorted((v ... | python | def reconstruct(self):
"""Reconstructs the filesystem of all volumes mounted by the parser by inspecting the last mount point and
bind mounting everything.
:raises: NoRootFoundError if no root could be found
:return: the root :class:`Volume`
"""
volumes = list(sorted((v ... | [
"def",
"reconstruct",
"(",
"self",
")",
":",
"volumes",
"=",
"list",
"(",
"sorted",
"(",
"(",
"v",
"for",
"v",
"in",
"self",
".",
"get_volumes",
"(",
")",
"if",
"v",
".",
"mountpoint",
"and",
"v",
".",
"info",
".",
"get",
"(",
"'lastmountpoint'",
"... | Reconstructs the filesystem of all volumes mounted by the parser by inspecting the last mount point and
bind mounting everything.
:raises: NoRootFoundError if no root could be found
:return: the root :class:`Volume` | [
"Reconstructs",
"the",
"filesystem",
"of",
"all",
"volumes",
"mounted",
"by",
"the",
"parser",
"by",
"inspecting",
"the",
"last",
"mount",
"point",
"and",
"bind",
"mounting",
"everything",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L210-L233 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem._make_subvolume | def _make_subvolume(self, **args):
"""Creates a subvolume, adds it to this class and returns it."""
from imagemounter.volume import Volume
v = Volume(disk=self.disk, parent=self.parent,
volume_detector=self.volume_detector,
**args) # vstype is not passed d... | python | def _make_subvolume(self, **args):
"""Creates a subvolume, adds it to this class and returns it."""
from imagemounter.volume import Volume
v = Volume(disk=self.disk, parent=self.parent,
volume_detector=self.volume_detector,
**args) # vstype is not passed d... | [
"def",
"_make_subvolume",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"from",
"imagemounter",
".",
"volume",
"import",
"Volume",
"v",
"=",
"Volume",
"(",
"disk",
"=",
"self",
".",
"disk",
",",
"parent",
"=",
"self",
".",
"parent",
",",
"volume_detect... | Creates a subvolume, adds it to this class and returns it. | [
"Creates",
"a",
"subvolume",
"adds",
"it",
"to",
"this",
"class",
"and",
"returns",
"it",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L68-L76 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem._make_single_subvolume | def _make_single_subvolume(self, only_one=True, **args):
"""Creates a subvolume, adds it to this class, sets the volume index to 0 and returns it.
:param bool only_one: if this volume system already has at least one volume, it is returned instead.
"""
if only_one and self.volumes:
... | python | def _make_single_subvolume(self, only_one=True, **args):
"""Creates a subvolume, adds it to this class, sets the volume index to 0 and returns it.
:param bool only_one: if this volume system already has at least one volume, it is returned instead.
"""
if only_one and self.volumes:
... | [
"def",
"_make_single_subvolume",
"(",
"self",
",",
"only_one",
"=",
"True",
",",
"*",
"*",
"args",
")",
":",
"if",
"only_one",
"and",
"self",
".",
"volumes",
":",
"return",
"self",
".",
"volumes",
"[",
"0",
"]",
"if",
"self",
".",
"parent",
".",
"ind... | Creates a subvolume, adds it to this class, sets the volume index to 0 and returns it.
:param bool only_one: if this volume system already has at least one volume, it is returned instead. | [
"Creates",
"a",
"subvolume",
"adds",
"it",
"to",
"this",
"class",
"sets",
"the",
"volume",
"index",
"to",
"0",
"and",
"returns",
"it",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L78-L92 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem.detect_volumes | def detect_volumes(self, vstype=None, method=None, force=False):
"""Iterator for detecting volumes within this volume system.
:param str vstype: The volume system type to use. If None, uses :attr:`vstype`
:param str method: The detection method to use. If None, uses :attr:`detection`
:p... | python | def detect_volumes(self, vstype=None, method=None, force=False):
"""Iterator for detecting volumes within this volume system.
:param str vstype: The volume system type to use. If None, uses :attr:`vstype`
:param str method: The detection method to use. If None, uses :attr:`detection`
:p... | [
"def",
"detect_volumes",
"(",
"self",
",",
"vstype",
"=",
"None",
",",
"method",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"has_detected",
"and",
"not",
"force",
":",
"logger",
".",
"warning",
"(",
"\"Detection already ran.\"",
... | Iterator for detecting volumes within this volume system.
:param str vstype: The volume system type to use. If None, uses :attr:`vstype`
:param str method: The detection method to use. If None, uses :attr:`detection`
:param bool force: Specify if you wnat to force running the detection if has_D... | [
"Iterator",
"for",
"detecting",
"volumes",
"within",
"this",
"volume",
"system",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L94-L120 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem._determine_auto_detection_method | def _determine_auto_detection_method():
"""Return the detection method to use when the detection method is 'auto'"""
if dependencies.pytsk3.is_available:
return 'pytsk3'
elif dependencies.mmls.is_available:
return 'mmls'
elif dependencies.parted.is_available:
... | python | def _determine_auto_detection_method():
"""Return the detection method to use when the detection method is 'auto'"""
if dependencies.pytsk3.is_available:
return 'pytsk3'
elif dependencies.mmls.is_available:
return 'mmls'
elif dependencies.parted.is_available:
... | [
"def",
"_determine_auto_detection_method",
"(",
")",
":",
"if",
"dependencies",
".",
"pytsk3",
".",
"is_available",
":",
"return",
"'pytsk3'",
"elif",
"dependencies",
".",
"mmls",
".",
"is_available",
":",
"return",
"'mmls'",
"elif",
"dependencies",
".",
"parted",... | Return the detection method to use when the detection method is 'auto | [
"Return",
"the",
"detection",
"method",
"to",
"use",
"when",
"the",
"detection",
"method",
"is",
"auto"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L123-L133 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem._load_disktype_data | def _load_disktype_data(self):
"""Calls the :command:`disktype` command and obtains the disk GUID from GPT volume systems. As we
are running the tool anyway, the label is also extracted from the tool if it is not yet set.
The disktype data is only loaded and not assigned to volumes yet.
... | python | def _load_disktype_data(self):
"""Calls the :command:`disktype` command and obtains the disk GUID from GPT volume systems. As we
are running the tool anyway, the label is also extracted from the tool if it is not yet set.
The disktype data is only loaded and not assigned to volumes yet.
... | [
"def",
"_load_disktype_data",
"(",
"self",
")",
":",
"if",
"not",
"_util",
".",
"command_exists",
"(",
"'disktype'",
")",
":",
"logger",
".",
"warning",
"(",
"\"disktype not installed, could not detect volume type\"",
")",
"return",
"None",
"disktype",
"=",
"_util",... | Calls the :command:`disktype` command and obtains the disk GUID from GPT volume systems. As we
are running the tool anyway, the label is also extracted from the tool if it is not yet set.
The disktype data is only loaded and not assigned to volumes yet. | [
"Calls",
"the",
":",
"command",
":",
"disktype",
"command",
"and",
"obtains",
"the",
"disk",
"GUID",
"from",
"GPT",
"volume",
"systems",
".",
"As",
"we",
"are",
"running",
"the",
"tool",
"anyway",
"the",
"label",
"is",
"also",
"extracted",
"from",
"the",
... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L140-L173 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeSystem._assign_disktype_data | def _assign_disktype_data(self, volume, slot=None):
"""Assigns cached disktype data to a volume."""
if slot is None:
slot = volume.slot
if slot in self._disktype:
data = self._disktype[slot]
if not volume.info.get('guid') and 'guid' in data:
v... | python | def _assign_disktype_data(self, volume, slot=None):
"""Assigns cached disktype data to a volume."""
if slot is None:
slot = volume.slot
if slot in self._disktype:
data = self._disktype[slot]
if not volume.info.get('guid') and 'guid' in data:
v... | [
"def",
"_assign_disktype_data",
"(",
"self",
",",
"volume",
",",
"slot",
"=",
"None",
")",
":",
"if",
"slot",
"is",
"None",
":",
"slot",
"=",
"volume",
".",
"slot",
"if",
"slot",
"in",
"self",
".",
"_disktype",
":",
"data",
"=",
"self",
".",
"_diskty... | Assigns cached disktype data to a volume. | [
"Assigns",
"cached",
"disktype",
"data",
"to",
"a",
"volume",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L175-L185 |
ralphje/imagemounter | imagemounter/volume_system.py | VolumeDetector._format_index | def _format_index(self, volume_system, idx):
"""Returns a formatted index given the disk index idx."""
if volume_system.parent.index is not None:
return '{0}.{1}'.format(volume_system.parent.index, idx)
else:
return str(idx) | python | def _format_index(self, volume_system, idx):
"""Returns a formatted index given the disk index idx."""
if volume_system.parent.index is not None:
return '{0}.{1}'.format(volume_system.parent.index, idx)
else:
return str(idx) | [
"def",
"_format_index",
"(",
"self",
",",
"volume_system",
",",
"idx",
")",
":",
"if",
"volume_system",
".",
"parent",
".",
"index",
"is",
"not",
"None",
":",
"return",
"'{0}.{1}'",
".",
"format",
"(",
"volume_system",
".",
"parent",
".",
"index",
",",
"... | Returns a formatted index given the disk index idx. | [
"Returns",
"a",
"formatted",
"index",
"given",
"the",
"disk",
"index",
"idx",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L199-L205 |
ralphje/imagemounter | imagemounter/volume_system.py | SingleVolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""'Detects' a single volume. It should not be called other than from a :class:`Disk`."""
volume = volume_system._make_single_subvolume(offset=0)
is_directory = os.path.isdir(volume_system.parent.get_raw_path())
if is_directory:
... | python | def detect(self, volume_system, vstype='detect'):
"""'Detects' a single volume. It should not be called other than from a :class:`Disk`."""
volume = volume_system._make_single_subvolume(offset=0)
is_directory = os.path.isdir(volume_system.parent.get_raw_path())
if is_directory:
... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"volume",
"=",
"volume_system",
".",
"_make_single_subvolume",
"(",
"offset",
"=",
"0",
")",
"is_directory",
"=",
"os",
".",
"path",
".",
"isdir",
"(",
"volume_sy... | Detects' a single volume. It should not be called other than from a :class:`Disk`. | [
"Detects",
"a",
"single",
"volume",
".",
"It",
"should",
"not",
"be",
"called",
"other",
"than",
"from",
"a",
":",
"class",
":",
"Disk",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L212-L235 |
ralphje/imagemounter | imagemounter/volume_system.py | Pytsk3VolumeDetector._find_volumes | def _find_volumes(self, volume_system, vstype='detect'):
"""Finds all volumes based on the pytsk3 library."""
try:
# noinspection PyUnresolvedReferences
import pytsk3
except ImportError:
logger.error("pytsk3 not installed, could not detect volumes")
... | python | def _find_volumes(self, volume_system, vstype='detect'):
"""Finds all volumes based on the pytsk3 library."""
try:
# noinspection PyUnresolvedReferences
import pytsk3
except ImportError:
logger.error("pytsk3 not installed, could not detect volumes")
... | [
"def",
"_find_volumes",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"try",
":",
"# noinspection PyUnresolvedReferences",
"import",
"pytsk3",
"except",
"ImportError",
":",
"logger",
".",
"error",
"(",
"\"pytsk3 not installed, could not ... | Finds all volumes based on the pytsk3 library. | [
"Finds",
"all",
"volumes",
"based",
"on",
"the",
"pytsk3",
"library",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L241-L288 |
ralphje/imagemounter | imagemounter/volume_system.py | Pytsk3VolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""Generator that mounts every partition of this image and yields the mountpoint."""
# Loop over all volumes in image.
for p in self._find_volumes(volume_system, vstype):
import pytsk3
volume = volume_system._make_subvol... | python | def detect(self, volume_system, vstype='detect'):
"""Generator that mounts every partition of this image and yields the mountpoint."""
# Loop over all volumes in image.
for p in self._find_volumes(volume_system, vstype):
import pytsk3
volume = volume_system._make_subvol... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"# Loop over all volumes in image.",
"for",
"p",
"in",
"self",
".",
"_find_volumes",
"(",
"volume_system",
",",
"vstype",
")",
":",
"import",
"pytsk3",
"volume",
"=",... | Generator that mounts every partition of this image and yields the mountpoint. | [
"Generator",
"that",
"mounts",
"every",
"partition",
"of",
"this",
"image",
"and",
"yields",
"the",
"mountpoint",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L291-L319 |
ralphje/imagemounter | imagemounter/volume_system.py | PartedVolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""Finds and mounts all volumes based on parted.
:param VolumeSystem volume_system: The volume system.
"""
# for some reason, parted does not properly return extended volume types in its machine
# output, so we need to execute i... | python | def detect(self, volume_system, vstype='detect'):
"""Finds and mounts all volumes based on parted.
:param VolumeSystem volume_system: The volume system.
"""
# for some reason, parted does not properly return extended volume types in its machine
# output, so we need to execute i... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"# for some reason, parted does not properly return extended volume types in its machine",
"# output, so we need to execute it twice.",
"meta_volumes",
"=",
"[",
"]",
"# noinspection PyB... | Finds and mounts all volumes based on parted.
:param VolumeSystem volume_system: The volume system. | [
"Finds",
"and",
"mounts",
"all",
"volumes",
"based",
"on",
"parted",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L326-L404 |
ralphje/imagemounter | imagemounter/volume_system.py | MmlsVolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""Finds and mounts all volumes based on mmls."""
try:
cmd = ['mmls']
if volume_system.parent.offset:
cmd.extend(['-o', str(volume_system.parent.offset // volume_system.disk.block_size)])
if vstype in ... | python | def detect(self, volume_system, vstype='detect'):
"""Finds and mounts all volumes based on mmls."""
try:
cmd = ['mmls']
if volume_system.parent.offset:
cmd.extend(['-o', str(volume_system.parent.offset // volume_system.disk.block_size)])
if vstype in ... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"try",
":",
"cmd",
"=",
"[",
"'mmls'",
"]",
"if",
"volume_system",
".",
"parent",
".",
"offset",
":",
"cmd",
".",
"extend",
"(",
"[",
"'-o'",
",",
"str",
... | Finds and mounts all volumes based on mmls. | [
"Finds",
"and",
"mounts",
"all",
"volumes",
"based",
"on",
"mmls",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L411-L482 |
ralphje/imagemounter | imagemounter/volume_system.py | VssVolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""Detect volume shadow copy volumes in the specified path."""
path = volume_system.parent._paths['vss']
try:
volume_info = _util.check_output_(["vshadowinfo", "-o", str(volume_system.parent.offset),
... | python | def detect(self, volume_system, vstype='detect'):
"""Detect volume shadow copy volumes in the specified path."""
path = volume_system.parent._paths['vss']
try:
volume_info = _util.check_output_(["vshadowinfo", "-o", str(volume_system.parent.offset),
... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"path",
"=",
"volume_system",
".",
"parent",
".",
"_paths",
"[",
"'vss'",
"]",
"try",
":",
"volume_info",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"\"vshad... | Detect volume shadow copy volumes in the specified path. | [
"Detect",
"volume",
"shadow",
"copy",
"volumes",
"in",
"the",
"specified",
"path",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L490-L517 |
ralphje/imagemounter | imagemounter/volume_system.py | LvmVolumeDetector.detect | def detect(self, volume_system, vstype='detect'):
"""Gather information about lvolumes, gathering their label, size and raw path"""
volume_group = volume_system.parent.info.get('volume_group')
result = _util.check_output_(["lvm", "lvdisplay", volume_group])
cur_v = None
for l i... | python | def detect(self, volume_system, vstype='detect'):
"""Gather information about lvolumes, gathering their label, size and raw path"""
volume_group = volume_system.parent.info.get('volume_group')
result = _util.check_output_(["lvm", "lvdisplay", volume_group])
cur_v = None
for l i... | [
"def",
"detect",
"(",
"self",
",",
"volume_system",
",",
"vstype",
"=",
"'detect'",
")",
":",
"volume_group",
"=",
"volume_system",
".",
"parent",
".",
"info",
".",
"get",
"(",
"'volume_group'",
")",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
... | Gather information about lvolumes, gathering their label, size and raw path | [
"Gather",
"information",
"about",
"lvolumes",
"gathering",
"their",
"label",
"size",
"and",
"raw",
"path"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume_system.py#L525-L551 |
ralphje/imagemounter | imagemounter/volume.py | Volume._get_fstype_from_parser | def _get_fstype_from_parser(self, fstype=None):
"""Load fstype information from the parser instance."""
if fstype:
self.fstype = fstype
elif self.index in self.disk.parser.fstypes:
self.fstype = self.disk.parser.fstypes[self.index]
elif '*' in self.disk.parser.fst... | python | def _get_fstype_from_parser(self, fstype=None):
"""Load fstype information from the parser instance."""
if fstype:
self.fstype = fstype
elif self.index in self.disk.parser.fstypes:
self.fstype = self.disk.parser.fstypes[self.index]
elif '*' in self.disk.parser.fst... | [
"def",
"_get_fstype_from_parser",
"(",
"self",
",",
"fstype",
"=",
"None",
")",
":",
"if",
"fstype",
":",
"self",
".",
"fstype",
"=",
"fstype",
"elif",
"self",
".",
"index",
"in",
"self",
".",
"disk",
".",
"parser",
".",
"fstypes",
":",
"self",
".",
... | Load fstype information from the parser instance. | [
"Load",
"fstype",
"information",
"from",
"the",
"parser",
"instance",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L99-L122 |
ralphje/imagemounter | imagemounter/volume.py | Volume.get_description | def get_description(self, with_size=True, with_index=True):
"""Obtains a generic description of the volume, containing the file system type, index, label and NTFS version.
If *with_size* is provided, the volume size is also included.
"""
desc = ''
if with_size and self.size:
... | python | def get_description(self, with_size=True, with_index=True):
"""Obtains a generic description of the volume, containing the file system type, index, label and NTFS version.
If *with_size* is provided, the volume size is also included.
"""
desc = ''
if with_size and self.size:
... | [
"def",
"get_description",
"(",
"self",
",",
"with_size",
"=",
"True",
",",
"with_index",
"=",
"True",
")",
":",
"desc",
"=",
"''",
"if",
"with_size",
"and",
"self",
".",
"size",
":",
"desc",
"+=",
"'{0} '",
".",
"format",
"(",
"self",
".",
"get_formatt... | Obtains a generic description of the volume, containing the file system type, index, label and NTFS version.
If *with_size* is provided, the volume size is also included. | [
"Obtains",
"a",
"generic",
"description",
"of",
"the",
"volume",
"containing",
"the",
"file",
"system",
"type",
"index",
"label",
"and",
"NTFS",
"version",
".",
"If",
"*",
"with_size",
"*",
"is",
"provided",
"the",
"volume",
"size",
"is",
"also",
"included",... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L124-L146 |
ralphje/imagemounter | imagemounter/volume.py | Volume.get_formatted_size | def get_formatted_size(self):
"""Obtains the size of the volume in a human-readable format (i.e. in TiBs, GiBs or MiBs)."""
if self.size is not None:
if self.size < 1024:
return "{0} B".format(self.size)
elif self.size < 1024 ** 2:
return "{0} KiB... | python | def get_formatted_size(self):
"""Obtains the size of the volume in a human-readable format (i.e. in TiBs, GiBs or MiBs)."""
if self.size is not None:
if self.size < 1024:
return "{0} B".format(self.size)
elif self.size < 1024 ** 2:
return "{0} KiB... | [
"def",
"get_formatted_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"size",
"is",
"not",
"None",
":",
"if",
"self",
".",
"size",
"<",
"1024",
":",
"return",
"\"{0} B\"",
".",
"format",
"(",
"self",
".",
"size",
")",
"elif",
"self",
".",
"size",
... | Obtains the size of the volume in a human-readable format (i.e. in TiBs, GiBs or MiBs). | [
"Obtains",
"the",
"size",
"of",
"the",
"volume",
"in",
"a",
"human",
"-",
"readable",
"format",
"(",
"i",
".",
"e",
".",
"in",
"TiBs",
"GiBs",
"or",
"MiBs",
")",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L148-L163 |
ralphje/imagemounter | imagemounter/volume.py | Volume._get_blkid_type | def _get_blkid_type(self):
"""Retrieves the FS type from the blkid command."""
try:
result = _util.check_output_(['blkid', '-p', '-O', str(self.offset), self.get_raw_path()])
if not result:
return None
# noinspection PyTypeChecker
blkid_re... | python | def _get_blkid_type(self):
"""Retrieves the FS type from the blkid command."""
try:
result = _util.check_output_(['blkid', '-p', '-O', str(self.offset), self.get_raw_path()])
if not result:
return None
# noinspection PyTypeChecker
blkid_re... | [
"def",
"_get_blkid_type",
"(",
"self",
")",
":",
"try",
":",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'blkid'",
",",
"'-p'",
",",
"'-O'",
",",
"str",
"(",
"self",
".",
"offset",
")",
",",
"self",
".",
"get_raw_path",
"(",
")",
"]",
... | Retrieves the FS type from the blkid command. | [
"Retrieves",
"the",
"FS",
"type",
"from",
"the",
"blkid",
"command",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L166-L184 |
ralphje/imagemounter | imagemounter/volume.py | Volume._get_magic_type | def _get_magic_type(self):
"""Checks the volume for its magic bytes and returns the magic."""
try:
with io.open(self.disk.get_fs_path(), "rb") as file:
file.seek(self.offset)
fheader = file.read(min(self.size, 4096) if self.size else 4096)
except IOEr... | python | def _get_magic_type(self):
"""Checks the volume for its magic bytes and returns the magic."""
try:
with io.open(self.disk.get_fs_path(), "rb") as file:
file.seek(self.offset)
fheader = file.read(min(self.size, 4096) if self.size else 4096)
except IOEr... | [
"def",
"_get_magic_type",
"(",
"self",
")",
":",
"try",
":",
"with",
"io",
".",
"open",
"(",
"self",
".",
"disk",
".",
"get_fs_path",
"(",
")",
",",
"\"rb\"",
")",
"as",
"file",
":",
"file",
".",
"seek",
"(",
"self",
".",
"offset",
")",
"fheader",
... | Checks the volume for its magic bytes and returns the magic. | [
"Checks",
"the",
"volume",
"for",
"its",
"magic",
"bytes",
"and",
"returns",
"the",
"magic",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L187-L228 |
ralphje/imagemounter | imagemounter/volume.py | Volume.get_raw_path | def get_raw_path(self, include_self=False):
"""Retrieves the base mount path of the volume. Typically equals to :func:`Disk.get_fs_path` but may also be the
path to a logical volume. This is used to determine the source path for a mount call.
The value returned is normally based on the parent's... | python | def get_raw_path(self, include_self=False):
"""Retrieves the base mount path of the volume. Typically equals to :func:`Disk.get_fs_path` but may also be the
path to a logical volume. This is used to determine the source path for a mount call.
The value returned is normally based on the parent's... | [
"def",
"get_raw_path",
"(",
"self",
",",
"include_self",
"=",
"False",
")",
":",
"v",
"=",
"self",
"if",
"not",
"include_self",
":",
"# lv / vss_store are exceptions, as it covers the volume itself, not the child volume",
"if",
"v",
".",
"_paths",
".",
"get",
"(",
"... | Retrieves the base mount path of the volume. Typically equals to :func:`Disk.get_fs_path` but may also be the
path to a logical volume. This is used to determine the source path for a mount call.
The value returned is normally based on the parent's paths, e.g. if this volume is mounted to a more specif... | [
"Retrieves",
"the",
"base",
"mount",
"path",
"of",
"the",
"volume",
".",
"Typically",
"equals",
"to",
":",
"func",
":",
"Disk",
".",
"get_fs_path",
"but",
"may",
"also",
"be",
"the",
"path",
"to",
"a",
"logical",
"volume",
".",
"This",
"is",
"used",
"t... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L230-L272 |
ralphje/imagemounter | imagemounter/volume.py | Volume.get_safe_label | def get_safe_label(self):
"""Returns a label that is safe to add to a path in the mountpoint for this volume."""
if self.info.get('label') == '/':
return 'root'
suffix = re.sub(r"[/ \(\)]+", "_", self.info.get('label')) if self.info.get('label') else ""
if suffix and suffix... | python | def get_safe_label(self):
"""Returns a label that is safe to add to a path in the mountpoint for this volume."""
if self.info.get('label') == '/':
return 'root'
suffix = re.sub(r"[/ \(\)]+", "_", self.info.get('label')) if self.info.get('label') else ""
if suffix and suffix... | [
"def",
"get_safe_label",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
".",
"get",
"(",
"'label'",
")",
"==",
"'/'",
":",
"return",
"'root'",
"suffix",
"=",
"re",
".",
"sub",
"(",
"r\"[/ \\(\\)]+\"",
",",
"\"_\"",
",",
"self",
".",
"info",
".",
... | Returns a label that is safe to add to a path in the mountpoint for this volume. | [
"Returns",
"a",
"label",
"that",
"is",
"safe",
"to",
"add",
"to",
"a",
"path",
"in",
"the",
"mountpoint",
"for",
"this",
"volume",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L274-L285 |
ralphje/imagemounter | imagemounter/volume.py | Volume.carve | def carve(self, freespace=True):
"""Call this method to carve the free space of the volume for (deleted) files. Note that photorec has its
own interface that temporarily takes over the shell.
:param freespace: indicates whether the entire volume should be carved (False) or only the free space (... | python | def carve(self, freespace=True):
"""Call this method to carve the free space of the volume for (deleted) files. Note that photorec has its
own interface that temporarily takes over the shell.
:param freespace: indicates whether the entire volume should be carved (False) or only the free space (... | [
"def",
"carve",
"(",
"self",
",",
"freespace",
"=",
"True",
")",
":",
"self",
".",
"_make_mountpoint",
"(",
"var_name",
"=",
"'carve'",
",",
"suffix",
"=",
"\"carve\"",
",",
"in_paths",
"=",
"True",
")",
"# if no slot, we need to make a loopback that we can use to... | Call this method to carve the free space of the volume for (deleted) files. Note that photorec has its
own interface that temporarily takes over the shell.
:param freespace: indicates whether the entire volume should be carved (False) or only the free space (True)
:type freespace: bool
... | [
"Call",
"this",
"method",
"to",
"carve",
"the",
"free",
"space",
"of",
"the",
"volume",
"for",
"(",
"deleted",
")",
"files",
".",
"Note",
"that",
"photorec",
"has",
"its",
"own",
"interface",
"that",
"temporarily",
"takes",
"over",
"the",
"shell",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L288-L339 |
ralphje/imagemounter | imagemounter/volume.py | Volume.detect_volume_shadow_copies | def detect_volume_shadow_copies(self):
"""Method to call vshadowmount and mount NTFS volume shadow copies.
:return: iterable with the :class:`Volume` objects of the VSS
:raises CommandNotFoundError: if the underlying command does not exist
:raises SubSystemError: if the underlying comma... | python | def detect_volume_shadow_copies(self):
"""Method to call vshadowmount and mount NTFS volume shadow copies.
:return: iterable with the :class:`Volume` objects of the VSS
:raises CommandNotFoundError: if the underlying command does not exist
:raises SubSystemError: if the underlying comma... | [
"def",
"detect_volume_shadow_copies",
"(",
"self",
")",
":",
"self",
".",
"_make_mountpoint",
"(",
"var_name",
"=",
"'vss'",
",",
"suffix",
"=",
"\"vss\"",
",",
"in_paths",
"=",
"True",
")",
"try",
":",
"_util",
".",
"check_call_",
"(",
"[",
"\"vshadowmount\... | Method to call vshadowmount and mount NTFS volume shadow copies.
:return: iterable with the :class:`Volume` objects of the VSS
:raises CommandNotFoundError: if the underlying command does not exist
:raises SubSystemError: if the underlying command fails
:raises NoMountpointAvailableErro... | [
"Method",
"to",
"call",
"vshadowmount",
"and",
"mount",
"NTFS",
"volume",
"shadow",
"copies",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L342-L359 |
ralphje/imagemounter | imagemounter/volume.py | Volume._should_mount | def _should_mount(self, only_mount=None, skip_mount=None):
"""Indicates whether this volume should be mounted. Internal method, used by imount.py"""
om = only_mount is None or \
self.index in only_mount or \
self.info.get('lastmountpoint') in only_mount or \
self.inf... | python | def _should_mount(self, only_mount=None, skip_mount=None):
"""Indicates whether this volume should be mounted. Internal method, used by imount.py"""
om = only_mount is None or \
self.index in only_mount or \
self.info.get('lastmountpoint') in only_mount or \
self.inf... | [
"def",
"_should_mount",
"(",
"self",
",",
"only_mount",
"=",
"None",
",",
"skip_mount",
"=",
"None",
")",
":",
"om",
"=",
"only_mount",
"is",
"None",
"or",
"self",
".",
"index",
"in",
"only_mount",
"or",
"self",
".",
"info",
".",
"get",
"(",
"'lastmoun... | Indicates whether this volume should be mounted. Internal method, used by imount.py | [
"Indicates",
"whether",
"this",
"volume",
"should",
"be",
"mounted",
".",
"Internal",
"method",
"used",
"by",
"imount",
".",
"py"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L361-L372 |
ralphje/imagemounter | imagemounter/volume.py | Volume.init | def init(self, only_mount=None, skip_mount=None, swallow_exceptions=True):
"""Generator that mounts this volume and either yields itself or recursively generates its subvolumes.
More specifically, this function will call :func:`load_fsstat_data` (iff *no_stats* is False), followed by
:func:`mou... | python | def init(self, only_mount=None, skip_mount=None, swallow_exceptions=True):
"""Generator that mounts this volume and either yields itself or recursively generates its subvolumes.
More specifically, this function will call :func:`load_fsstat_data` (iff *no_stats* is False), followed by
:func:`mou... | [
"def",
"init",
"(",
"self",
",",
"only_mount",
"=",
"None",
",",
"skip_mount",
"=",
"None",
",",
"swallow_exceptions",
"=",
"True",
")",
":",
"if",
"swallow_exceptions",
":",
"self",
".",
"exception",
"=",
"None",
"try",
":",
"if",
"not",
"self",
".",
... | Generator that mounts this volume and either yields itself or recursively generates its subvolumes.
More specifically, this function will call :func:`load_fsstat_data` (iff *no_stats* is False), followed by
:func:`mount`, followed by a call to :func:`detect_mountpoint`, after which ``self`` is yielded,... | [
"Generator",
"that",
"mounts",
"this",
"volume",
"and",
"either",
"yields",
"itself",
"or",
"recursively",
"generates",
"its",
"subvolumes",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L374-L409 |
ralphje/imagemounter | imagemounter/volume.py | Volume.init_volume | def init_volume(self, fstype=None):
"""Initializes a single volume. You should use this method instead of :func:`mount` if you want some sane checks
before mounting.
"""
logger.debug("Initializing volume {0}".format(self))
if not self._should_mount():
return False
... | python | def init_volume(self, fstype=None):
"""Initializes a single volume. You should use this method instead of :func:`mount` if you want some sane checks
before mounting.
"""
logger.debug("Initializing volume {0}".format(self))
if not self._should_mount():
return False
... | [
"def",
"init_volume",
"(",
"self",
",",
"fstype",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Initializing volume {0}\"",
".",
"format",
"(",
"self",
")",
")",
"if",
"not",
"self",
".",
"_should_mount",
"(",
")",
":",
"return",
"False",
"if",
... | Initializes a single volume. You should use this method instead of :func:`mount` if you want some sane checks
before mounting. | [
"Initializes",
"a",
"single",
"volume",
".",
"You",
"should",
"use",
"this",
"method",
"instead",
"of",
":",
"func",
":",
"mount",
"if",
"you",
"want",
"some",
"sane",
"checks",
"before",
"mounting",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L411-L436 |
ralphje/imagemounter | imagemounter/volume.py | Volume._make_mountpoint | def _make_mountpoint(self, casename=None, var_name='mountpoint', suffix='', in_paths=False):
"""Creates a directory that can be used as a mountpoint. The directory is stored in :attr:`mountpoint`,
or the varname as specified by the argument. If in_paths is True, the path is stored in the :attr:`_paths`
... | python | def _make_mountpoint(self, casename=None, var_name='mountpoint', suffix='', in_paths=False):
"""Creates a directory that can be used as a mountpoint. The directory is stored in :attr:`mountpoint`,
or the varname as specified by the argument. If in_paths is True, the path is stored in the :attr:`_paths`
... | [
"def",
"_make_mountpoint",
"(",
"self",
",",
"casename",
"=",
"None",
",",
"var_name",
"=",
"'mountpoint'",
",",
"suffix",
"=",
"''",
",",
"in_paths",
"=",
"False",
")",
":",
"parser",
"=",
"self",
".",
"disk",
".",
"parser",
"if",
"parser",
".",
"moun... | Creates a directory that can be used as a mountpoint. The directory is stored in :attr:`mountpoint`,
or the varname as specified by the argument. If in_paths is True, the path is stored in the :attr:`_paths`
attribute instead.
:returns: the mountpoint path
:raises NoMountpointAvailableE... | [
"Creates",
"a",
"directory",
"that",
"can",
"be",
"used",
"as",
"a",
"mountpoint",
".",
"The",
"directory",
"is",
"stored",
"in",
":",
"attr",
":",
"mountpoint",
"or",
"the",
"varname",
"as",
"specified",
"by",
"the",
"argument",
".",
"If",
"in_paths",
"... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L438-L495 |
ralphje/imagemounter | imagemounter/volume.py | Volume._clear_mountpoint | def _clear_mountpoint(self):
"""Clears a created mountpoint. Does not unmount it, merely deletes it."""
if self.mountpoint:
os.rmdir(self.mountpoint)
self.mountpoint = "" | python | def _clear_mountpoint(self):
"""Clears a created mountpoint. Does not unmount it, merely deletes it."""
if self.mountpoint:
os.rmdir(self.mountpoint)
self.mountpoint = "" | [
"def",
"_clear_mountpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"mountpoint",
":",
"os",
".",
"rmdir",
"(",
"self",
".",
"mountpoint",
")",
"self",
".",
"mountpoint",
"=",
"\"\""
] | Clears a created mountpoint. Does not unmount it, merely deletes it. | [
"Clears",
"a",
"created",
"mountpoint",
".",
"Does",
"not",
"unmount",
"it",
"merely",
"deletes",
"it",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L497-L502 |
ralphje/imagemounter | imagemounter/volume.py | Volume._find_loopback | def _find_loopback(self, use_loopback=True, var_name='loopback'):
"""Finds a free loopback device that can be used. The loopback is stored in :attr:`loopback`. If *use_loopback*
is True, the loopback will also be used directly.
:returns: the loopback address
:raises NoLoopbackAvailableE... | python | def _find_loopback(self, use_loopback=True, var_name='loopback'):
"""Finds a free loopback device that can be used. The loopback is stored in :attr:`loopback`. If *use_loopback*
is True, the loopback will also be used directly.
:returns: the loopback address
:raises NoLoopbackAvailableE... | [
"def",
"_find_loopback",
"(",
"self",
",",
"use_loopback",
"=",
"True",
",",
"var_name",
"=",
"'loopback'",
")",
":",
"# noinspection PyBroadException",
"try",
":",
"loopback",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-f'",
"]",
")",
... | Finds a free loopback device that can be used. The loopback is stored in :attr:`loopback`. If *use_loopback*
is True, the loopback will also be used directly.
:returns: the loopback address
:raises NoLoopbackAvailableError: if no loopback could be found | [
"Finds",
"a",
"free",
"loopback",
"device",
"that",
"can",
"be",
"used",
".",
"The",
"loopback",
"is",
"stored",
"in",
":",
"attr",
":",
"loopback",
".",
"If",
"*",
"use_loopback",
"*",
"is",
"True",
"the",
"loopback",
"will",
"also",
"be",
"used",
"di... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L504-L531 |
ralphje/imagemounter | imagemounter/volume.py | Volume.determine_fs_type | def determine_fs_type(self):
"""Determines the FS type for this partition. This function is used internally to determine which mount system
to use, based on the file system description. Return values include *ext*, *ufs*, *ntfs*, *lvm* and *luks*.
Note: does not do anything if fstype is already... | python | def determine_fs_type(self):
"""Determines the FS type for this partition. This function is used internally to determine which mount system
to use, based on the file system description. Return values include *ext*, *ufs*, *ntfs*, *lvm* and *luks*.
Note: does not do anything if fstype is already... | [
"def",
"determine_fs_type",
"(",
"self",
")",
":",
"fstype_fallback",
"=",
"None",
"if",
"isinstance",
"(",
"self",
".",
"fstype",
",",
"filesystems",
".",
"FallbackFileSystemType",
")",
":",
"fstype_fallback",
"=",
"self",
".",
"fstype",
".",
"fallback",
"eli... | Determines the FS type for this partition. This function is used internally to determine which mount system
to use, based on the file system description. Return values include *ext*, *ufs*, *ntfs*, *lvm* and *luks*.
Note: does not do anything if fstype is already set to something sensible. | [
"Determines",
"the",
"FS",
"type",
"for",
"this",
"partition",
".",
"This",
"function",
"is",
"used",
"internally",
"to",
"determine",
"which",
"mount",
"system",
"to",
"use",
"based",
"on",
"the",
"file",
"system",
"description",
".",
"Return",
"values",
"i... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L538-L595 |
ralphje/imagemounter | imagemounter/volume.py | Volume.mount | def mount(self, fstype=None):
"""Based on the file system type as determined by :func:`determine_fs_type`, the proper mount command is executed
for this volume. The volume is mounted in a temporary path (or a pretty path if :attr:`pretty` is enabled) in
the mountpoint as specified by :attr:`moun... | python | def mount(self, fstype=None):
"""Based on the file system type as determined by :func:`determine_fs_type`, the proper mount command is executed
for this volume. The volume is mounted in a temporary path (or a pretty path if :attr:`pretty` is enabled) in
the mountpoint as specified by :attr:`moun... | [
"def",
"mount",
"(",
"self",
",",
"fstype",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"parent",
".",
"is_mounted",
":",
"raise",
"NotMountedError",
"(",
"self",
".",
"parent",
")",
"if",
"fstype",
"is",
"None",
":",
"fstype",
"=",
"self",
".",... | Based on the file system type as determined by :func:`determine_fs_type`, the proper mount command is executed
for this volume. The volume is mounted in a temporary path (or a pretty path if :attr:`pretty` is enabled) in
the mountpoint as specified by :attr:`mountpoint`.
If the file system type... | [
"Based",
"on",
"the",
"file",
"system",
"type",
"as",
"determined",
"by",
":",
"func",
":",
"determine_fs_type",
"the",
"proper",
"mount",
"command",
"is",
"executed",
"for",
"this",
"volume",
".",
"The",
"volume",
"is",
"mounted",
"in",
"a",
"temporary",
... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L597-L632 |
ralphje/imagemounter | imagemounter/volume.py | Volume.bindmount | def bindmount(self, mountpoint):
"""Bind mounts the volume to another mountpoint. Only works if the volume is already mounted.
:raises NotMountedError: when the volume is not yet mounted
:raises SubsystemError: when the underlying command failed
"""
if not self.mountpoint:
... | python | def bindmount(self, mountpoint):
"""Bind mounts the volume to another mountpoint. Only works if the volume is already mounted.
:raises NotMountedError: when the volume is not yet mounted
:raises SubsystemError: when the underlying command failed
"""
if not self.mountpoint:
... | [
"def",
"bindmount",
"(",
"self",
",",
"mountpoint",
")",
":",
"if",
"not",
"self",
".",
"mountpoint",
":",
"raise",
"NotMountedError",
"(",
"self",
")",
"try",
":",
"_util",
".",
"check_call_",
"(",
"[",
"'mount'",
",",
"'--bind'",
",",
"self",
".",
"m... | Bind mounts the volume to another mountpoint. Only works if the volume is already mounted.
:raises NotMountedError: when the volume is not yet mounted
:raises SubsystemError: when the underlying command failed | [
"Bind",
"mounts",
"the",
"volume",
"to",
"another",
"mountpoint",
".",
"Only",
"works",
"if",
"the",
"volume",
"is",
"already",
"mounted",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L634-L652 |
ralphje/imagemounter | imagemounter/volume.py | Volume.get_volumes | def get_volumes(self):
"""Recursively gets a list of all subvolumes and the current volume."""
if self.volumes:
volumes = []
for v in self.volumes:
volumes.extend(v.get_volumes())
volumes.append(self)
return volumes
else:
... | python | def get_volumes(self):
"""Recursively gets a list of all subvolumes and the current volume."""
if self.volumes:
volumes = []
for v in self.volumes:
volumes.extend(v.get_volumes())
volumes.append(self)
return volumes
else:
... | [
"def",
"get_volumes",
"(",
"self",
")",
":",
"if",
"self",
".",
"volumes",
":",
"volumes",
"=",
"[",
"]",
"for",
"v",
"in",
"self",
".",
"volumes",
":",
"volumes",
".",
"extend",
"(",
"v",
".",
"get_volumes",
"(",
")",
")",
"volumes",
".",
"append"... | Recursively gets a list of all subvolumes and the current volume. | [
"Recursively",
"gets",
"a",
"list",
"of",
"all",
"subvolumes",
"and",
"the",
"current",
"volume",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L654-L664 |
ralphje/imagemounter | imagemounter/volume.py | Volume._load_fsstat_data | def _load_fsstat_data(self, timeout=3):
"""Using :command:`fsstat`, adds some additional information of the volume to the Volume."""
def stats_thread():
try:
cmd = ['fsstat', self.get_raw_path(), '-o', str(self.offset // self.disk.block_size)]
# Setting the ... | python | def _load_fsstat_data(self, timeout=3):
"""Using :command:`fsstat`, adds some additional information of the volume to the Volume."""
def stats_thread():
try:
cmd = ['fsstat', self.get_raw_path(), '-o', str(self.offset // self.disk.block_size)]
# Setting the ... | [
"def",
"_load_fsstat_data",
"(",
"self",
",",
"timeout",
"=",
"3",
")",
":",
"def",
"stats_thread",
"(",
")",
":",
"try",
":",
"cmd",
"=",
"[",
"'fsstat'",
",",
"self",
".",
"get_raw_path",
"(",
")",
",",
"'-o'",
",",
"str",
"(",
"self",
".",
"offs... | Using :command:`fsstat`, adds some additional information of the volume to the Volume. | [
"Using",
":",
"command",
":",
"fsstat",
"adds",
"some",
"additional",
"information",
"of",
"the",
"volume",
"to",
"the",
"Volume",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L667-L734 |
ralphje/imagemounter | imagemounter/volume.py | Volume.detect_mountpoint | def detect_mountpoint(self):
"""Attempts to detect the previous mountpoint if this was not done through :func:`load_fsstat_data`. This
detection does some heuristic method on the mounted volume.
"""
if self.info.get('lastmountpoint'):
return self.info.get('lastmountpoint')
... | python | def detect_mountpoint(self):
"""Attempts to detect the previous mountpoint if this was not done through :func:`load_fsstat_data`. This
detection does some heuristic method on the mounted volume.
"""
if self.info.get('lastmountpoint'):
return self.info.get('lastmountpoint')
... | [
"def",
"detect_mountpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
".",
"get",
"(",
"'lastmountpoint'",
")",
":",
"return",
"self",
".",
"info",
".",
"get",
"(",
"'lastmountpoint'",
")",
"if",
"not",
"self",
".",
"mountpoint",
":",
"return",
... | Attempts to detect the previous mountpoint if this was not done through :func:`load_fsstat_data`. This
detection does some heuristic method on the mounted volume. | [
"Attempts",
"to",
"detect",
"the",
"previous",
"mountpoint",
"if",
"this",
"was",
"not",
"done",
"through",
":",
"func",
":",
"load_fsstat_data",
".",
"This",
"detection",
"does",
"some",
"heuristic",
"method",
"on",
"the",
"mounted",
"volume",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L736-L770 |
ralphje/imagemounter | imagemounter/volume.py | Volume.unmount | def unmount(self, allow_lazy=False):
"""Unounts the volume from the filesystem.
:raises SubsystemError: if one of the underlying processes fails
:raises CleanupError: if the cleanup fails
"""
for volume in self.volumes:
try:
volume.unmount(allow_lazy... | python | def unmount(self, allow_lazy=False):
"""Unounts the volume from the filesystem.
:raises SubsystemError: if one of the underlying processes fails
:raises CleanupError: if the cleanup fails
"""
for volume in self.volumes:
try:
volume.unmount(allow_lazy... | [
"def",
"unmount",
"(",
"self",
",",
"allow_lazy",
"=",
"False",
")",
":",
"for",
"volume",
"in",
"self",
".",
"volumes",
":",
"try",
":",
"volume",
".",
"unmount",
"(",
"allow_lazy",
"=",
"allow_lazy",
")",
"except",
"ImageMounterError",
":",
"pass",
"if... | Unounts the volume from the filesystem.
:raises SubsystemError: if one of the underlying processes fails
:raises CleanupError: if the cleanup fails | [
"Unounts",
"the",
"volume",
"from",
"the",
"filesystem",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L773-L854 |
ralphje/imagemounter | imagemounter/dependencies.py | require | def require(*requirements, **kwargs):
"""Decorator that can be used to require requirements.
:param requirements: List of requirements that should be verified
:param none_on_failure: If true, does not raise a PrerequisiteFailedError, but instead returns None
"""
# TODO: require(*requirements, none_... | python | def require(*requirements, **kwargs):
"""Decorator that can be used to require requirements.
:param requirements: List of requirements that should be verified
:param none_on_failure: If true, does not raise a PrerequisiteFailedError, but instead returns None
"""
# TODO: require(*requirements, none_... | [
"def",
"require",
"(",
"*",
"requirements",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: require(*requirements, none_on_failure=False) is not supported by Python 2",
"none_on_failure",
"=",
"kwargs",
".",
"get",
"(",
"'none_on_failure'",
",",
"False",
")",
"def",
"inner"... | Decorator that can be used to require requirements.
:param requirements: List of requirements that should be verified
:param none_on_failure: If true, does not raise a PrerequisiteFailedError, but instead returns None | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"require",
"requirements",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/dependencies.py#L8-L28 |
ralphje/imagemounter | imagemounter/dependencies.py | CommandDependency.status_message | def status_message(self):
"""Detailed message about whether the dependency is installed.
:rtype: str
"""
if self.is_available:
return "INSTALLED {0!s}"
elif self.why and self.package:
return "MISSING {0!s:<20}needed for {0.why}, part of the {0.package} ... | python | def status_message(self):
"""Detailed message about whether the dependency is installed.
:rtype: str
"""
if self.is_available:
return "INSTALLED {0!s}"
elif self.why and self.package:
return "MISSING {0!s:<20}needed for {0.why}, part of the {0.package} ... | [
"def",
"status_message",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_available",
":",
"return",
"\"INSTALLED {0!s}\"",
"elif",
"self",
".",
"why",
"and",
"self",
".",
"package",
":",
"return",
"\"MISSING {0!s:<20}needed for {0.why}, part of the {0.package} package\"... | Detailed message about whether the dependency is installed.
:rtype: str | [
"Detailed",
"message",
"about",
"whether",
"the",
"dependency",
"is",
"installed",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/dependencies.py#L97-L111 |
ralphje/imagemounter | imagemounter/filesystems.py | FileSystemType.detect | def detect(self, source, description):
"""Detects the type of a volume based on the provided information. It returns the plausibility for all
file system types as a dict. Although it is only responsible for returning its own plausibility, it is possible
that one type of filesystem is more likely... | python | def detect(self, source, description):
"""Detects the type of a volume based on the provided information. It returns the plausibility for all
file system types as a dict. Although it is only responsible for returning its own plausibility, it is possible
that one type of filesystem is more likely... | [
"def",
"detect",
"(",
"self",
",",
"source",
",",
"description",
")",
":",
"if",
"source",
"==",
"\"guid\"",
"and",
"description",
"in",
"self",
".",
"guids",
":",
"return",
"{",
"self",
":",
"100",
"}",
"description",
"=",
"description",
".",
"lower",
... | Detects the type of a volume based on the provided information. It returns the plausibility for all
file system types as a dict. Although it is only responsible for returning its own plausibility, it is possible
that one type of filesystem is more likely than another, e.g. when NTFS detects it is likely... | [
"Detects",
"the",
"type",
"of",
"a",
"volume",
"based",
"on",
"the",
"provided",
"information",
".",
"It",
"returns",
"the",
"plausibility",
"for",
"all",
"file",
"system",
"types",
"as",
"a",
"dict",
".",
"Although",
"it",
"is",
"only",
"responsible",
"fo... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L36-L65 |
ralphje/imagemounter | imagemounter/filesystems.py | FileSystemType.mount | def mount(self, volume):
"""Mounts the given volume on the provided mountpoint. The default implementation simply calls mount.
:param Volume volume: The volume to be mounted
:param mountpoint: The file system path to mount the filesystem on.
:raises UnsupportedFilesystemError: when the ... | python | def mount(self, volume):
"""Mounts the given volume on the provided mountpoint. The default implementation simply calls mount.
:param Volume volume: The volume to be mounted
:param mountpoint: The file system path to mount the filesystem on.
:raises UnsupportedFilesystemError: when the ... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"volume",
".",
"_make_mountpoint",
"(",
")",
"try",
":",
"self",
".",
"_call_mount",
"(",
"volume",
",",
"volume",
".",
"mountpoint",
",",
"self",
".",
"_mount_type",
"or",
"self",
".",
"type",
",",... | Mounts the given volume on the provided mountpoint. The default implementation simply calls mount.
:param Volume volume: The volume to be mounted
:param mountpoint: The file system path to mount the filesystem on.
:raises UnsupportedFilesystemError: when the volume system type can not be mounte... | [
"Mounts",
"the",
"given",
"volume",
"on",
"the",
"provided",
"mountpoint",
".",
"The",
"default",
"implementation",
"simply",
"calls",
"mount",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L67-L81 |
ralphje/imagemounter | imagemounter/filesystems.py | FileSystemType._call_mount | def _call_mount(self, volume, mountpoint, type=None, opts=""):
"""Calls the mount command, specifying the mount type and mount options."""
# default arguments for calling mount
if opts and not opts.endswith(','):
opts += ","
opts += 'loop,offset=' + str(volume.offset) + ',si... | python | def _call_mount(self, volume, mountpoint, type=None, opts=""):
"""Calls the mount command, specifying the mount type and mount options."""
# default arguments for calling mount
if opts and not opts.endswith(','):
opts += ","
opts += 'loop,offset=' + str(volume.offset) + ',si... | [
"def",
"_call_mount",
"(",
"self",
",",
"volume",
",",
"mountpoint",
",",
"type",
"=",
"None",
",",
"opts",
"=",
"\"\"",
")",
":",
"# default arguments for calling mount",
"if",
"opts",
"and",
"not",
"opts",
".",
"endswith",
"(",
"','",
")",
":",
"opts",
... | Calls the mount command, specifying the mount type and mount options. | [
"Calls",
"the",
"mount",
"command",
"specifying",
"the",
"mount",
"type",
"and",
"mount",
"options",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L83-L102 |
ralphje/imagemounter | imagemounter/filesystems.py | Jffs2FileSystemType.mount | def mount(self, volume):
"""Perform specific operations to mount a JFFS2 image. This kind of image is sometimes used for things like
bios images. so external tools are required but given this method you don't have to memorize anything and it
works fast and easy.
Note that this module mi... | python | def mount(self, volume):
"""Perform specific operations to mount a JFFS2 image. This kind of image is sometimes used for things like
bios images. so external tools are required but given this method you don't have to memorize anything and it
works fast and easy.
Note that this module mi... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"# we have to make a ram-device to store the image, we keep 20% overhead",
"size_in_kb",
"=",
"int",
"(",
"(",
"volume",
".",
"size",
"/",
"1024",
")",
"*",
"1.2",
")",
"_util",
".",
"check_call_",
"(",
"[",
... | Perform specific operations to mount a JFFS2 image. This kind of image is sometimes used for things like
bios images. so external tools are required but given this method you don't have to memorize anything and it
works fast and easy.
Note that this module might not yet work while mounting mult... | [
"Perform",
"specific",
"operations",
"to",
"mount",
"a",
"JFFS2",
"image",
".",
"This",
"kind",
"of",
"image",
"is",
"sometimes",
"used",
"for",
"things",
"like",
"bios",
"images",
".",
"so",
"external",
"tools",
"are",
"required",
"but",
"given",
"this",
... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L279-L293 |
ralphje/imagemounter | imagemounter/filesystems.py | LuksFileSystemType.mount | def mount(self, volume):
"""Command that is an alternative to the :func:`mount` command that opens a LUKS container. The opened volume is
added to the subvolume set of this volume. Requires the user to enter the key manually.
TODO: add support for :attr:`keys`
:return: the Volume conta... | python | def mount(self, volume):
"""Command that is an alternative to the :func:`mount` command that opens a LUKS container. The opened volume is
added to the subvolume set of this volume. Requires the user to enter the key manually.
TODO: add support for :attr:`keys`
:return: the Volume conta... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"# Open a loopback device",
"volume",
".",
"_find_loopback",
"(",
")",
"# Check if this is a LUKS device",
"# noinspection PyBroadException",
"try",
":",
"_util",
".",
"check_call_",
"(",
"[",
"\"cryptsetup\"",
","... | Command that is an alternative to the :func:`mount` command that opens a LUKS container. The opened volume is
added to the subvolume set of this volume. Requires the user to enter the key manually.
TODO: add support for :attr:`keys`
:return: the Volume contained in the LUKS container, or None ... | [
"Command",
"that",
"is",
"an",
"alternative",
"to",
"the",
":",
"func",
":",
"mount",
"command",
"that",
"opens",
"a",
"LUKS",
"container",
".",
"The",
"opened",
"volume",
"is",
"added",
"to",
"the",
"subvolume",
"set",
"of",
"this",
"volume",
".",
"Requ... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L307-L398 |
ralphje/imagemounter | imagemounter/filesystems.py | BdeFileSystemType.mount | def mount(self, volume):
"""Mounts a BDE container. Uses key material provided by the :attr:`keys` attribute. The key material should be
provided in the same format as to :cmd:`bdemount`, used as follows:
k:full volume encryption and tweak key
p:passphrase
r:recovery password
... | python | def mount(self, volume):
"""Mounts a BDE container. Uses key material provided by the :attr:`keys` attribute. The key material should be
provided in the same format as to :cmd:`bdemount`, used as follows:
k:full volume encryption and tweak key
p:passphrase
r:recovery password
... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"volume",
".",
"_paths",
"[",
"'bde'",
"]",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'image_mounter_bde_'",
")",
"try",
":",
"if",
"volume",
".",
"key",
":",
"t",
",",
"v",
"=",
"vo... | Mounts a BDE container. Uses key material provided by the :attr:`keys` attribute. The key material should be
provided in the same format as to :cmd:`bdemount`, used as follows:
k:full volume encryption and tweak key
p:passphrase
r:recovery password
s:file to startup key (.bek)
... | [
"Mounts",
"a",
"BDE",
"container",
".",
"Uses",
"key",
"material",
"provided",
"by",
"the",
":",
"attr",
":",
"keys",
"attribute",
".",
"The",
"key",
"material",
"should",
"be",
"provided",
"in",
"the",
"same",
"format",
"as",
"to",
":",
"cmd",
":",
"b... | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L411-L451 |
ralphje/imagemounter | imagemounter/filesystems.py | LvmFileSystemType.mount | def mount(self, volume):
"""Performs mount actions on a LVM. Scans for active volume groups from the loopback device, activates it
and fills :attr:`volumes` with the logical volumes.
:raises NoLoopbackAvailableError: when no loopback was available
:raises IncorrectFilesystemError: when ... | python | def mount(self, volume):
"""Performs mount actions on a LVM. Scans for active volume groups from the loopback device, activates it
and fills :attr:`volumes` with the logical volumes.
:raises NoLoopbackAvailableError: when no loopback was available
:raises IncorrectFilesystemError: when ... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"os",
".",
"environ",
"[",
"'LVM_SUPPRESS_FD_WARNINGS'",
"]",
"=",
"'1'",
"# find free loopback device",
"volume",
".",
"_find_loopback",
"(",
")",
"time",
".",
"sleep",
"(",
"0.2",
")",
"try",
":",
"# ... | Performs mount actions on a LVM. Scans for active volume groups from the loopback device, activates it
and fills :attr:`volumes` with the logical volumes.
:raises NoLoopbackAvailableError: when no loopback was available
:raises IncorrectFilesystemError: when the volume is not a volume group | [
"Performs",
"mount",
"actions",
"on",
"a",
"LVM",
".",
"Scans",
"for",
"active",
"volume",
"groups",
"from",
"the",
"loopback",
"device",
"activates",
"it",
"and",
"fills",
":",
"attr",
":",
"volumes",
"with",
"the",
"logical",
"volumes",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L460-L494 |
ralphje/imagemounter | imagemounter/filesystems.py | RaidFileSystemType.mount | def mount(self, volume):
"""Add the volume to a RAID system. The RAID array is activated as soon as the array can be activated.
:raises NoLoopbackAvailableError: if no loopback device was found
"""
volume._find_loopback()
raid_status = None
try:
# use mdadm... | python | def mount(self, volume):
"""Add the volume to a RAID system. The RAID array is activated as soon as the array can be activated.
:raises NoLoopbackAvailableError: if no loopback device was found
"""
volume._find_loopback()
raid_status = None
try:
# use mdadm... | [
"def",
"mount",
"(",
"self",
",",
"volume",
")",
":",
"volume",
".",
"_find_loopback",
"(",
")",
"raid_status",
"=",
"None",
"try",
":",
"# use mdadm to mount the loopback to a md device",
"# incremental and run as soon as available",
"output",
"=",
"_util",
".",
"che... | Add the volume to a RAID system. The RAID array is activated as soon as the array can be activated.
:raises NoLoopbackAvailableError: if no loopback device was found | [
"Add",
"the",
"volume",
"to",
"a",
"RAID",
"system",
".",
"The",
"RAID",
"array",
"is",
"activated",
"as",
"soon",
"as",
"the",
"array",
"can",
"be",
"activated",
"."
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/filesystems.py#L508-L552 |
mbr/latex | latex/__init__.py | escape | def escape(s, fold_newlines=True):
"""Escapes a string to make it usable in LaTeX text mode. Will replace
special characters as well as newlines.
Some problematic characters like ``[`` and ``]`` are escaped into groups
(e.g. ``{[}``), because they tend to cause problems when mixed with ``\\``
newli... | python | def escape(s, fold_newlines=True):
"""Escapes a string to make it usable in LaTeX text mode. Will replace
special characters as well as newlines.
Some problematic characters like ``[`` and ``]`` are escaped into groups
(e.g. ``{[}``), because they tend to cause problems when mixed with ``\\``
newli... | [
"def",
"escape",
"(",
"s",
",",
"fold_newlines",
"=",
"True",
")",
":",
"def",
"sub",
"(",
"m",
")",
":",
"c",
"=",
"m",
".",
"group",
"(",
")",
"if",
"c",
"in",
"CHAR_ESCAPE",
":",
"return",
"CHAR_ESCAPE",
"[",
"c",
"]",
"if",
"c",
".",
"isspa... | Escapes a string to make it usable in LaTeX text mode. Will replace
special characters as well as newlines.
Some problematic characters like ``[`` and ``]`` are escaped into groups
(e.g. ``{[}``), because they tend to cause problems when mixed with ``\\``
newlines otherwise.
:param s: The string t... | [
"Escapes",
"a",
"string",
"to",
"make",
"it",
"usable",
"in",
"LaTeX",
"text",
"mode",
".",
"Will",
"replace",
"special",
"characters",
"as",
"well",
"as",
"newlines",
"."
] | train | https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/__init__.py#L37-L61 |
mbr/latex | latex/build.py | build_pdf | def build_pdf(source, texinputs=[], builder=None):
"""Builds a LaTeX source to PDF.
Will automatically instantiate an available builder (or raise a
:class:`exceptions.RuntimeError` if none are available) and build the
supplied source with it.
Parameters are passed on to the builder's
:meth:`~l... | python | def build_pdf(source, texinputs=[], builder=None):
"""Builds a LaTeX source to PDF.
Will automatically instantiate an available builder (or raise a
:class:`exceptions.RuntimeError` if none are available) and build the
supplied source with it.
Parameters are passed on to the builder's
:meth:`~l... | [
"def",
"build_pdf",
"(",
"source",
",",
"texinputs",
"=",
"[",
"]",
",",
"builder",
"=",
"None",
")",
":",
"if",
"builder",
"is",
"None",
":",
"builders",
"=",
"PREFERRED_BUILDERS",
"elif",
"builder",
"not",
"in",
"BUILDERS",
":",
"raise",
"RuntimeError",
... | Builds a LaTeX source to PDF.
Will automatically instantiate an available builder (or raise a
:class:`exceptions.RuntimeError` if none are available) and build the
supplied source with it.
Parameters are passed on to the builder's
:meth:`~latex.build.LatexBuilder.build_pdf` function.
:param b... | [
"Builds",
"a",
"LaTeX",
"source",
"to",
"PDF",
"."
] | train | https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/build.py#L207-L235 |
mbr/latex | latex/errors.py | parse_log | def parse_log(log, context_size=3):
"""Parses latex log output and tries to extract error messages.
Requires ``-file-line-error`` to be active.
:param log: The contents of the logfile as a string.
:param context_size: Number of lines to keep as context, including the
original ... | python | def parse_log(log, context_size=3):
"""Parses latex log output and tries to extract error messages.
Requires ``-file-line-error`` to be active.
:param log: The contents of the logfile as a string.
:param context_size: Number of lines to keep as context, including the
original ... | [
"def",
"parse_log",
"(",
"log",
",",
"context_size",
"=",
"3",
")",
":",
"lines",
"=",
"log",
".",
"splitlines",
"(",
")",
"errors",
"=",
"[",
"]",
"for",
"n",
",",
"line",
"in",
"enumerate",
"(",
"lines",
")",
":",
"m",
"=",
"LATEX_ERR_RE",
".",
... | Parses latex log output and tries to extract error messages.
Requires ``-file-line-error`` to be active.
:param log: The contents of the logfile as a string.
:param context_size: Number of lines to keep as context, including the
original error line.
:return: A dictionary conta... | [
"Parses",
"latex",
"log",
"output",
"and",
"tries",
"to",
"extract",
"error",
"messages",
"."
] | train | https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/errors.py#L7-L34 |
mbr/latex | latex/jinja2.py | make_env | def make_env(*args, **kwargs):
"""Creates an :py:class:`~jinja2.Environment` with different defaults.
Per default, ``autoescape`` will be disabled and ``trim_blocks`` enabled.
All start/end/prefix strings will be changed for a more LaTeX-friendly
version (see the docs for details).
Any arguments w... | python | def make_env(*args, **kwargs):
"""Creates an :py:class:`~jinja2.Environment` with different defaults.
Per default, ``autoescape`` will be disabled and ``trim_blocks`` enabled.
All start/end/prefix strings will be changed for a more LaTeX-friendly
version (see the docs for details).
Any arguments w... | [
"def",
"make_env",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ka",
"=",
"ENV_ARGS",
".",
"copy",
"(",
")",
"ka",
".",
"update",
"(",
"kwargs",
")",
"env",
"=",
"Environment",
"(",
"*",
"args",
",",
"*",
"*",
"ka",
")",
"env",
".",
... | Creates an :py:class:`~jinja2.Environment` with different defaults.
Per default, ``autoescape`` will be disabled and ``trim_blocks`` enabled.
All start/end/prefix strings will be changed for a more LaTeX-friendly
version (see the docs for details).
Any arguments will be passed on to the :py:class:`~ji... | [
"Creates",
"an",
":",
"py",
":",
"class",
":",
"~jinja2",
".",
"Environment",
"with",
"different",
"defaults",
"."
] | train | https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/jinja2.py#L41-L60 |
e-dard/flask-s3 | flask_s3.py | split_metadata_params | def split_metadata_params(headers):
"""
Given a dict of headers for s3, seperates those that are boto3
parameters and those that must be metadata
"""
params = {}
metadata = {}
for header_name in headers:
if header_name.lower() in header_mapping:
params[header_mapping[hea... | python | def split_metadata_params(headers):
"""
Given a dict of headers for s3, seperates those that are boto3
parameters and those that must be metadata
"""
params = {}
metadata = {}
for header_name in headers:
if header_name.lower() in header_mapping:
params[header_mapping[hea... | [
"def",
"split_metadata_params",
"(",
"headers",
")",
":",
"params",
"=",
"{",
"}",
"metadata",
"=",
"{",
"}",
"for",
"header_name",
"in",
"headers",
":",
"if",
"header_name",
".",
"lower",
"(",
")",
"in",
"header_mapping",
":",
"params",
"[",
"header_mappi... | Given a dict of headers for s3, seperates those that are boto3
parameters and those that must be metadata | [
"Given",
"a",
"dict",
"of",
"headers",
"for",
"s3",
"seperates",
"those",
"that",
"are",
"boto3",
"parameters",
"and",
"those",
"that",
"must",
"be",
"metadata"
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L63-L76 |
e-dard/flask-s3 | flask_s3.py | hash_file | def hash_file(filename):
"""
Generate a hash for the contents of a file
"""
hasher = hashlib.sha1()
with open(filename, 'rb') as f:
buf = f.read(65536)
while len(buf) > 0:
hasher.update(buf)
buf = f.read(65536)
return hasher.hexdigest() | python | def hash_file(filename):
"""
Generate a hash for the contents of a file
"""
hasher = hashlib.sha1()
with open(filename, 'rb') as f:
buf = f.read(65536)
while len(buf) > 0:
hasher.update(buf)
buf = f.read(65536)
return hasher.hexdigest() | [
"def",
"hash_file",
"(",
"filename",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"buf",
"=",
"f",
".",
"read",
"(",
"65536",
")",
"while",
"len",
"(",
"buf",
")",
... | Generate a hash for the contents of a file | [
"Generate",
"a",
"hash",
"for",
"the",
"contents",
"of",
"a",
"file"
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L86-L97 |
e-dard/flask-s3 | flask_s3.py | _get_bucket_name | def _get_bucket_name(**values):
"""
Generates the bucket name for url_for.
"""
app = current_app
# manage other special values, all have no meaning for static urls
values.pop('_external', False) # external has no meaning here
values.pop('_anchor', None) # anchor as well
values.pop('_me... | python | def _get_bucket_name(**values):
"""
Generates the bucket name for url_for.
"""
app = current_app
# manage other special values, all have no meaning for static urls
values.pop('_external', False) # external has no meaning here
values.pop('_anchor', None) # anchor as well
values.pop('_me... | [
"def",
"_get_bucket_name",
"(",
"*",
"*",
"values",
")",
":",
"app",
"=",
"current_app",
"# manage other special values, all have no meaning for static urls",
"values",
".",
"pop",
"(",
"'_external'",
",",
"False",
")",
"# external has no meaning here",
"values",
".",
"... | Generates the bucket name for url_for. | [
"Generates",
"the",
"bucket",
"name",
"for",
"url_for",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L100-L129 |
e-dard/flask-s3 | flask_s3.py | url_for | def url_for(endpoint, **values):
"""
Generates a URL to the given endpoint.
If the endpoint is for a static resource then an Amazon S3 URL is
generated, otherwise the call is passed on to `flask.url_for`.
Because this function is set as a jinja environment variable when
`FlaskS3.init_app` is i... | python | def url_for(endpoint, **values):
"""
Generates a URL to the given endpoint.
If the endpoint is for a static resource then an Amazon S3 URL is
generated, otherwise the call is passed on to `flask.url_for`.
Because this function is set as a jinja environment variable when
`FlaskS3.init_app` is i... | [
"def",
"url_for",
"(",
"endpoint",
",",
"*",
"*",
"values",
")",
":",
"app",
"=",
"current_app",
"if",
"app",
".",
"config",
".",
"get",
"(",
"'TESTING'",
",",
"False",
")",
"and",
"not",
"app",
".",
"config",
".",
"get",
"(",
"'FLASKS3_OVERRIDE_TESTIN... | Generates a URL to the given endpoint.
If the endpoint is for a static resource then an Amazon S3 URL is
generated, otherwise the call is passed on to `flask.url_for`.
Because this function is set as a jinja environment variable when
`FlaskS3.init_app` is invoked, this function replaces
`flask.url... | [
"Generates",
"a",
"URL",
"to",
"the",
"given",
"endpoint",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L132-L165 |
e-dard/flask-s3 | flask_s3.py | _bp_static_url | def _bp_static_url(blueprint):
""" builds the absolute url path for a blueprint's static folder """
u = six.u('%s%s' % (blueprint.url_prefix or '', blueprint.static_url_path or ''))
return u | python | def _bp_static_url(blueprint):
""" builds the absolute url path for a blueprint's static folder """
u = six.u('%s%s' % (blueprint.url_prefix or '', blueprint.static_url_path or ''))
return u | [
"def",
"_bp_static_url",
"(",
"blueprint",
")",
":",
"u",
"=",
"six",
".",
"u",
"(",
"'%s%s'",
"%",
"(",
"blueprint",
".",
"url_prefix",
"or",
"''",
",",
"blueprint",
".",
"static_url_path",
"or",
"''",
")",
")",
"return",
"u"
] | builds the absolute url path for a blueprint's static folder | [
"builds",
"the",
"absolute",
"url",
"path",
"for",
"a",
"blueprint",
"s",
"static",
"folder"
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L168-L171 |
e-dard/flask-s3 | flask_s3.py | _gather_files | def _gather_files(app, hidden, filepath_filter_regex=None):
""" Gets all files in static folders and returns in dict."""
dirs = [(six.text_type(app.static_folder), app.static_url_path)]
if hasattr(app, 'blueprints'):
blueprints = app.blueprints.values()
bp_details = lambda x: (x.static_folde... | python | def _gather_files(app, hidden, filepath_filter_regex=None):
""" Gets all files in static folders and returns in dict."""
dirs = [(six.text_type(app.static_folder), app.static_url_path)]
if hasattr(app, 'blueprints'):
blueprints = app.blueprints.values()
bp_details = lambda x: (x.static_folde... | [
"def",
"_gather_files",
"(",
"app",
",",
"hidden",
",",
"filepath_filter_regex",
"=",
"None",
")",
":",
"dirs",
"=",
"[",
"(",
"six",
".",
"text_type",
"(",
"app",
".",
"static_folder",
")",
",",
"app",
".",
"static_url_path",
")",
"]",
"if",
"hasattr",
... | Gets all files in static folders and returns in dict. | [
"Gets",
"all",
"files",
"in",
"static",
"folders",
"and",
"returns",
"in",
"dict",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L174-L204 |
e-dard/flask-s3 | flask_s3.py | _static_folder_path | def _static_folder_path(static_url, static_folder, static_asset):
"""
Returns a path to a file based on the static folder, and not on the
filesystem holding the file.
Returns a path relative to static_url for static_asset
"""
# first get the asset path relative to the static folder.
# stati... | python | def _static_folder_path(static_url, static_folder, static_asset):
"""
Returns a path to a file based on the static folder, and not on the
filesystem holding the file.
Returns a path relative to static_url for static_asset
"""
# first get the asset path relative to the static folder.
# stati... | [
"def",
"_static_folder_path",
"(",
"static_url",
",",
"static_folder",
",",
"static_asset",
")",
":",
"# first get the asset path relative to the static folder.",
"# static_asset is not simply a filename because it could be",
"# sub-directory then file etc.",
"if",
"not",
"static_asset... | Returns a path to a file based on the static folder, and not on the
filesystem holding the file.
Returns a path relative to static_url for static_asset | [
"Returns",
"a",
"path",
"to",
"a",
"file",
"based",
"on",
"the",
"static",
"folder",
"and",
"not",
"on",
"the",
"filesystem",
"holding",
"the",
"file",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L212-L227 |
e-dard/flask-s3 | flask_s3.py | _write_files | def _write_files(s3, app, static_url_loc, static_folder, files, bucket,
ex_keys=None, hashes=None):
""" Writes all the files inside a static folder to S3. """
should_gzip = app.config.get('FLASKS3_GZIP')
add_mime = app.config.get('FLASKS3_FORCE_MIMETYPE')
gzip_include_only = app.config.... | python | def _write_files(s3, app, static_url_loc, static_folder, files, bucket,
ex_keys=None, hashes=None):
""" Writes all the files inside a static folder to S3. """
should_gzip = app.config.get('FLASKS3_GZIP')
add_mime = app.config.get('FLASKS3_FORCE_MIMETYPE')
gzip_include_only = app.config.... | [
"def",
"_write_files",
"(",
"s3",
",",
"app",
",",
"static_url_loc",
",",
"static_folder",
",",
"files",
",",
"bucket",
",",
"ex_keys",
"=",
"None",
",",
"hashes",
"=",
"None",
")",
":",
"should_gzip",
"=",
"app",
".",
"config",
".",
"get",
"(",
"'FLAS... | Writes all the files inside a static folder to S3. | [
"Writes",
"all",
"the",
"files",
"inside",
"a",
"static",
"folder",
"to",
"S3",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L230-L308 |
e-dard/flask-s3 | flask_s3.py | get_setting | def get_setting(name, app=None):
"""
Returns the value for `name` settings (looks into `app` config, and into
DEFAULT_SETTINGS). Returns None if not set.
:param name: (str) name of a setting (e.g. FLASKS3_URL_STYLE)
:param app: Flask app instance
:return: setting value or None
"""
def... | python | def get_setting(name, app=None):
"""
Returns the value for `name` settings (looks into `app` config, and into
DEFAULT_SETTINGS). Returns None if not set.
:param name: (str) name of a setting (e.g. FLASKS3_URL_STYLE)
:param app: Flask app instance
:return: setting value or None
"""
def... | [
"def",
"get_setting",
"(",
"name",
",",
"app",
"=",
"None",
")",
":",
"default_value",
"=",
"DEFAULT_SETTINGS",
".",
"get",
"(",
"name",
",",
"None",
")",
"return",
"app",
".",
"config",
".",
"get",
"(",
"name",
",",
"default_value",
")",
"if",
"app",
... | Returns the value for `name` settings (looks into `app` config, and into
DEFAULT_SETTINGS). Returns None if not set.
:param name: (str) name of a setting (e.g. FLASKS3_URL_STYLE)
:param app: Flask app instance
:return: setting value or None | [
"Returns",
"the",
"value",
"for",
"name",
"settings",
"(",
"looks",
"into",
"app",
"config",
"and",
"into",
"DEFAULT_SETTINGS",
")",
".",
"Returns",
"None",
"if",
"not",
"set",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L321-L333 |
e-dard/flask-s3 | flask_s3.py | create_all | def create_all(app, user=None, password=None, bucket_name=None,
location=None, include_hidden=False,
filepath_filter_regex=None, put_bucket_acl=True):
"""
Uploads of the static assets associated with a Flask application to
Amazon S3.
All static assets are identified on the... | python | def create_all(app, user=None, password=None, bucket_name=None,
location=None, include_hidden=False,
filepath_filter_regex=None, put_bucket_acl=True):
"""
Uploads of the static assets associated with a Flask application to
Amazon S3.
All static assets are identified on the... | [
"def",
"create_all",
"(",
"app",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"bucket_name",
"=",
"None",
",",
"location",
"=",
"None",
",",
"include_hidden",
"=",
"False",
",",
"filepath_filter_regex",
"=",
"None",
",",
"put_bucket_acl",
"... | Uploads of the static assets associated with a Flask application to
Amazon S3.
All static assets are identified on the local filesystem, including
any static assets associated with *registered* blueprints. In turn,
each asset is uploaded to the bucket described by `bucket_name`. If
the bucket does ... | [
"Uploads",
"of",
"the",
"static",
"assets",
"associated",
"with",
"a",
"Flask",
"application",
"to",
"Amazon",
"S3",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L336-L454 |
e-dard/flask-s3 | flask_s3.py | FlaskS3.init_app | def init_app(self, app):
"""
An alternative way to pass your :class:`flask.Flask` application
object to Flask-S3. :meth:`init_app` also takes care of some
default `settings`_.
:param app: the :class:`flask.Flask` application object.
"""
for k, v in DEFAULT_SETTI... | python | def init_app(self, app):
"""
An alternative way to pass your :class:`flask.Flask` application
object to Flask-S3. :meth:`init_app` also takes care of some
default `settings`_.
:param app: the :class:`flask.Flask` application object.
"""
for k, v in DEFAULT_SETTI... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"for",
"k",
",",
"v",
"in",
"DEFAULT_SETTINGS",
".",
"items",
"(",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"k",
",",
"v",
")",
"if",
"app",
".",
"debug",
"and",
"not",
"get_set... | An alternative way to pass your :class:`flask.Flask` application
object to Flask-S3. :meth:`init_app` also takes care of some
default `settings`_.
:param app: the :class:`flask.Flask` application object. | [
"An",
"alternative",
"way",
"to",
"pass",
"your",
":",
"class",
":",
"flask",
".",
"Flask",
"application",
"object",
"to",
"Flask",
"-",
"S3",
".",
":",
"meth",
":",
"init_app",
"also",
"takes",
"care",
"of",
"some",
"default",
"settings",
"_",
"."
] | train | https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L472-L491 |
taleinat/fuzzysearch | src/fuzzysearch/no_deletions.py | find_near_matches_no_deletions_ngrams | def find_near_matches_no_deletions_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowe... | python | def find_near_matches_no_deletions_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowe... | [
"def",
"find_near_matches_no_deletions_ngrams",
"(",
"subsequence",
",",
"sequence",
",",
"search_params",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"max_substitutions",
",",
"max_insertions",
",",
"max_... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/no_deletions.py#L41-L125 |
taleinat/fuzzysearch | src/fuzzysearch/__init__.py | find_near_matches | def find_near_matches(subsequence, sequence,
max_substitutions=None,
max_insertions=None,
max_deletions=None,
max_l_dist=None):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the... | python | def find_near_matches(subsequence, sequence,
max_substitutions=None,
max_insertions=None,
max_deletions=None,
max_l_dist=None):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the... | [
"def",
"find_near_matches",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
"=",
"None",
",",
"max_insertions",
"=",
"None",
",",
"max_deletions",
"=",
"None",
",",
"max_l_dist",
"=",
"None",
")",
":",
"search_params",
"=",
"LevenshteinSearchParams"... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/__init__.py#L30-L51 |
taleinat/fuzzysearch | src/fuzzysearch/substitutions_only.py | find_near_matches_substitutions | def find_near_matches_substitutions(subsequence, sequence, max_substitutions):
"""Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
o... | python | def find_near_matches_substitutions(subsequence, sequence, max_substitutions):
"""Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
o... | [
"def",
"find_near_matches_substitutions",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
":",
"_check_arguments",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
"if",
"max_substitutions",
"==",
"0",
":",
"return",
"[",
"Matc... | Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
of the sequence. | [
"Find",
"near",
"-",
"matches",
"of",
"the",
"subsequence",
"in",
"the",
"sequence",
"."
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/substitutions_only.py#L37-L62 |
taleinat/fuzzysearch | src/fuzzysearch/substitutions_only.py | find_near_matches_substitutions_lp | def find_near_matches_substitutions_lp(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the... | python | def find_near_matches_substitutions_lp(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the... | [
"def",
"find_near_matches_substitutions_lp",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
":",
"_check_arguments",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
"return",
"list",
"(",
"_find_near_matches_substitutions_lp",
"(",... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the number of character substitutions must be less than max_substitutions
* no deletions or insertions... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/substitutions_only.py#L65-L78 |
taleinat/fuzzysearch | src/fuzzysearch/substitutions_only.py | find_near_matches_substitutions_ngrams | def find_near_matches_substitutions_ngrams(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relativ... | python | def find_near_matches_substitutions_ngrams(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relativ... | [
"def",
"find_near_matches_substitutions_ngrams",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
":",
"_check_arguments",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
"match_starts",
"=",
"set",
"(",
")",
"matches",
"=",
"[... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the number of character substitutions must be less than max_substitutions
* no deletions or insertions... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/substitutions_only.py#L144-L163 |
taleinat/fuzzysearch | src/fuzzysearch/substitutions_only.py | has_near_match_substitutions_ngrams | def has_near_match_substitutions_ngrams(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to t... | python | def has_near_match_substitutions_ngrams(subsequence, sequence,
max_substitutions):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to t... | [
"def",
"has_near_match_substitutions_ngrams",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
":",
"_check_arguments",
"(",
"subsequence",
",",
"sequence",
",",
"max_substitutions",
")",
"for",
"match",
"in",
"_find_near_matches_substitutions_ngrams",
... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the number of character substitutions must be less than max_substitutions
* no deletions or insertions... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/substitutions_only.py#L211-L226 |
taleinat/fuzzysearch | src/fuzzysearch/generic_search.py | find_near_matches_generic | def find_near_matches_generic(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of ... | python | def find_near_matches_generic(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of ... | [
"def",
"find_near_matches_generic",
"(",
"subsequence",
",",
"sequence",
",",
"search_params",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"# if the limitations are so strict that only exact matches are allowed,",... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/generic_search.py#L24-L56 |
taleinat/fuzzysearch | src/fuzzysearch/generic_search.py | _find_near_matches_generic_linear_programming | def _find_near_matches_generic_linear_programming(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximu... | python | def _find_near_matches_generic_linear_programming(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximu... | [
"def",
"_find_near_matches_generic_linear_programming",
"(",
"subsequence",
",",
"sequence",
",",
"search_params",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"max_substitutions",
",",
"max_insertions",
",",... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/generic_search.py#L59-L176 |
taleinat/fuzzysearch | src/fuzzysearch/generic_search.py | find_near_matches_generic_ngrams | def find_near_matches_generic_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed num... | python | def find_near_matches_generic_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed num... | [
"def",
"find_near_matches_generic_ngrams",
"(",
"subsequence",
",",
"sequence",
",",
"search_params",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"matches",
"=",
"list",
"(",
"_find_near_matches_generic_ng... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/generic_search.py#L202-L222 |
taleinat/fuzzysearch | src/fuzzysearch/generic_search.py | has_near_match_generic_ngrams | def has_near_match_generic_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number... | python | def has_near_match_generic_ngrams(subsequence, sequence, search_params):
"""search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number... | [
"def",
"has_near_match_generic_ngrams",
"(",
"subsequence",
",",
"sequence",
",",
"search_params",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"for",
"match",
"in",
"_find_near_matches_generic_ngrams",
"("... | search for near-matches of subsequence in sequence
This searches for near-matches, where the nearly-matching parts of the
sequence must meet the following limitations (relative to the subsequence):
* the maximum allowed number of character substitutions
* the maximum allowed number of new characters i... | [
"search",
"for",
"near",
"-",
"matches",
"of",
"subsequence",
"in",
"sequence"
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/generic_search.py#L252-L268 |
taleinat/fuzzysearch | src/fuzzysearch/levenshtein_ngram.py | _expand | def _expand(subsequence, sequence, max_l_dist):
"""Expand a partial match of a Levenstein search.
An expansion must begin at the beginning of the sequence, which makes
this much simpler than a full search, and allows for greater optimization.
"""
# If given a long sub-sequence and relatively small ... | python | def _expand(subsequence, sequence, max_l_dist):
"""Expand a partial match of a Levenstein search.
An expansion must begin at the beginning of the sequence, which makes
this much simpler than a full search, and allows for greater optimization.
"""
# If given a long sub-sequence and relatively small ... | [
"def",
"_expand",
"(",
"subsequence",
",",
"sequence",
",",
"max_l_dist",
")",
":",
"# If given a long sub-sequence and relatively small max distance,",
"# use a more complex algorithm better optimized for such cases.",
"if",
"len",
"(",
"subsequence",
")",
">",
"max",
"(",
"... | Expand a partial match of a Levenstein search.
An expansion must begin at the beginning of the sequence, which makes
this much simpler than a full search, and allows for greater optimization. | [
"Expand",
"a",
"partial",
"match",
"of",
"a",
"Levenstein",
"search",
"."
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/levenshtein_ngram.py#L9-L20 |
taleinat/fuzzysearch | src/fuzzysearch/levenshtein_ngram.py | _py_expand_short | def _py_expand_short(subsequence, sequence, max_l_dist):
"""Straightforward implementation of partial match expansion."""
# The following diagram shows the score calculation step.
#
# Each new score is the minimum of:
# * a OR a + 1 (substitution, if needed)
# * b + 1 (deletion, i.e. skipping ... | python | def _py_expand_short(subsequence, sequence, max_l_dist):
"""Straightforward implementation of partial match expansion."""
# The following diagram shows the score calculation step.
#
# Each new score is the minimum of:
# * a OR a + 1 (substitution, if needed)
# * b + 1 (deletion, i.e. skipping ... | [
"def",
"_py_expand_short",
"(",
"subsequence",
",",
"sequence",
",",
"max_l_dist",
")",
":",
"# The following diagram shows the score calculation step.",
"#",
"# Each new score is the minimum of:",
"# * a OR a + 1 (substitution, if needed)",
"# * b + 1 (deletion, i.e. skipping a sequen... | Straightforward implementation of partial match expansion. | [
"Straightforward",
"implementation",
"of",
"partial",
"match",
"expansion",
"."
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/levenshtein_ngram.py#L23-L75 |
taleinat/fuzzysearch | src/fuzzysearch/levenshtein_ngram.py | _py_expand_long | def _py_expand_long(subsequence, sequence, max_l_dist):
"""Partial match expansion, optimized for long sub-sequences."""
# The additional optimization in this version is to limit the part of
# the sub-sequence inspected for each sequence character. The start and
# end of the iteration are limited to th... | python | def _py_expand_long(subsequence, sequence, max_l_dist):
"""Partial match expansion, optimized for long sub-sequences."""
# The additional optimization in this version is to limit the part of
# the sub-sequence inspected for each sequence character. The start and
# end of the iteration are limited to th... | [
"def",
"_py_expand_long",
"(",
"subsequence",
",",
"sequence",
",",
"max_l_dist",
")",
":",
"# The additional optimization in this version is to limit the part of",
"# the sub-sequence inspected for each sequence character. The start and",
"# end of the iteration are limited to the range wh... | Partial match expansion, optimized for long sub-sequences. | [
"Partial",
"match",
"expansion",
"optimized",
"for",
"long",
"sub",
"-",
"sequences",
"."
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/levenshtein_ngram.py#L78-L144 |
taleinat/fuzzysearch | src/fuzzysearch/levenshtein.py | find_near_matches_levenshtein | def find_near_matches_levenshtein(subsequence, sequence, max_l_dist):
"""Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
of the seq... | python | def find_near_matches_levenshtein(subsequence, sequence, max_l_dist):
"""Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
of the seq... | [
"def",
"find_near_matches_levenshtein",
"(",
"subsequence",
",",
"sequence",
",",
"max_l_dist",
")",
":",
"if",
"not",
"subsequence",
":",
"raise",
"ValueError",
"(",
"'Given subsequence is empty!'",
")",
"if",
"max_l_dist",
"<",
"0",
":",
"raise",
"ValueError",
"... | Find near-matches of the subsequence in the sequence.
This chooses a suitable fuzzy search implementation according to the given
parameters.
Returns a list of fuzzysearch.Match objects describing the matching parts
of the sequence. | [
"Find",
"near",
"-",
"matches",
"of",
"the",
"subsequence",
"in",
"the",
"sequence",
"."
] | train | https://github.com/taleinat/fuzzysearch/blob/04be1b4490de92601400be5ecc999003ff2f621f/src/fuzzysearch/levenshtein.py#L9-L40 |
abw333/dominoes | dominoes/game.py | _randomized_hands | def _randomized_hands():
'''
:return: 4 hands, obtained by shuffling the 28 dominoes used in
this variation of the game, and distributing them evenly
'''
all_dominoes = [dominoes.Domino(i, j) for i in range(7) for j in range(i, 7)]
random.shuffle(all_dominoes)
return [dominoes.Hand(... | python | def _randomized_hands():
'''
:return: 4 hands, obtained by shuffling the 28 dominoes used in
this variation of the game, and distributing them evenly
'''
all_dominoes = [dominoes.Domino(i, j) for i in range(7) for j in range(i, 7)]
random.shuffle(all_dominoes)
return [dominoes.Hand(... | [
"def",
"_randomized_hands",
"(",
")",
":",
"all_dominoes",
"=",
"[",
"dominoes",
".",
"Domino",
"(",
"i",
",",
"j",
")",
"for",
"i",
"in",
"range",
"(",
"7",
")",
"for",
"j",
"in",
"range",
"(",
"i",
",",
"7",
")",
"]",
"random",
".",
"shuffle",
... | :return: 4 hands, obtained by shuffling the 28 dominoes used in
this variation of the game, and distributing them evenly | [
":",
"return",
":",
"4",
"hands",
"obtained",
"by",
"shuffling",
"the",
"28",
"dominoes",
"used",
"in",
"this",
"variation",
"of",
"the",
"game",
"and",
"distributing",
"them",
"evenly"
] | train | https://github.com/abw333/dominoes/blob/ea9f532c9b834117a5c07d214711515872f7537e/dominoes/game.py#L6-L14 |
abw333/dominoes | dominoes/game.py | _validate_player | def _validate_player(player):
'''
Checks that a player is a valid player. Valid players are: 0, 1, 2, and 3.
:param int player: player to be validated
:return: None
:raises NoSuchPlayerException: if the player is invalid
'''
valid_players = range(4)
if player not in valid_players:
... | python | def _validate_player(player):
'''
Checks that a player is a valid player. Valid players are: 0, 1, 2, and 3.
:param int player: player to be validated
:return: None
:raises NoSuchPlayerException: if the player is invalid
'''
valid_players = range(4)
if player not in valid_players:
... | [
"def",
"_validate_player",
"(",
"player",
")",
":",
"valid_players",
"=",
"range",
"(",
"4",
")",
"if",
"player",
"not",
"in",
"valid_players",
":",
"valid_players",
"=",
"', '",
".",
"join",
"(",
"str",
"(",
"p",
")",
"for",
"p",
"in",
"valid_players",
... | Checks that a player is a valid player. Valid players are: 0, 1, 2, and 3.
:param int player: player to be validated
:return: None
:raises NoSuchPlayerException: if the player is invalid | [
"Checks",
"that",
"a",
"player",
"is",
"a",
"valid",
"player",
".",
"Valid",
"players",
"are",
":",
"0",
"1",
"2",
"and",
"3",
"."
] | train | https://github.com/abw333/dominoes/blob/ea9f532c9b834117a5c07d214711515872f7537e/dominoes/game.py#L16-L28 |
abw333/dominoes | dominoes/game.py | _domino_hand | def _domino_hand(d, hands):
'''
:param Domino d: domino to find within the hands
:param list hands: hands to find domino in
:return: index of the hand that contains the specified domino
:raises NoSuchDominoException: if no hand contains the specified domino
'''
for i, hand in enumerate(hands... | python | def _domino_hand(d, hands):
'''
:param Domino d: domino to find within the hands
:param list hands: hands to find domino in
:return: index of the hand that contains the specified domino
:raises NoSuchDominoException: if no hand contains the specified domino
'''
for i, hand in enumerate(hands... | [
"def",
"_domino_hand",
"(",
"d",
",",
"hands",
")",
":",
"for",
"i",
",",
"hand",
"in",
"enumerate",
"(",
"hands",
")",
":",
"if",
"d",
"in",
"hand",
":",
"return",
"i",
"raise",
"dominoes",
".",
"NoSuchDominoException",
"(",
"'{} is not in any hand!'",
... | :param Domino d: domino to find within the hands
:param list hands: hands to find domino in
:return: index of the hand that contains the specified domino
:raises NoSuchDominoException: if no hand contains the specified domino | [
":",
"param",
"Domino",
"d",
":",
"domino",
"to",
"find",
"within",
"the",
"hands",
":",
"param",
"list",
"hands",
":",
"hands",
"to",
"find",
"domino",
"in",
":",
"return",
":",
"index",
"of",
"the",
"hand",
"that",
"contains",
"the",
"specified",
"do... | train | https://github.com/abw333/dominoes/blob/ea9f532c9b834117a5c07d214711515872f7537e/dominoes/game.py#L30-L41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.