repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
ddorn/GUI
GUI/text.py
SimpleText.render
def render(self, display): """Render basicly the text.""" # to handle changing objects / callable if self.text != self._last_text: self._render() display.blit(self._surface, (self.topleft, self.size))
python
def render(self, display): """Render basicly the text.""" # to handle changing objects / callable if self.text != self._last_text: self._render() display.blit(self._surface, (self.topleft, self.size))
[ "def", "render", "(", "self", ",", "display", ")", ":", "# to handle changing objects / callable", "if", "self", ".", "text", "!=", "self", ".", "_last_text", ":", "self", ".", "_render", "(", ")", "display", ".", "blit", "(", "self", ".", "_surface", ",",...
Render basicly the text.
[ "Render", "basicly", "the", "text", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L111-L117
train
ddorn/GUI
GUI/text.py
InLineTextBox.cursor
def cursor(self): """The position of the cursor in the text.""" if self._cursor < 0: self.cursor = 0 if self._cursor > len(self): self.cursor = len(self) return self._cursor
python
def cursor(self): """The position of the cursor in the text.""" if self._cursor < 0: self.cursor = 0 if self._cursor > len(self): self.cursor = len(self) return self._cursor
[ "def", "cursor", "(", "self", ")", ":", "if", "self", ".", "_cursor", "<", "0", ":", "self", ".", "cursor", "=", "0", "if", "self", ".", "_cursor", ">", "len", "(", "self", ")", ":", "self", ".", "cursor", "=", "len", "(", "self", ")", "return"...
The position of the cursor in the text.
[ "The", "position", "of", "the", "cursor", "in", "the", "text", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L151-L159
train
ddorn/GUI
GUI/text.py
InLineTextBox.move_cursor_one_letter
def move_cursor_one_letter(self, letter=RIGHT): """Move the cursor of one letter to the right (1) or the the left.""" assert letter in (self.RIGHT, self.LEFT) if letter == self.RIGHT: self.cursor += 1 if self.cursor > len(self.text): self.cursor -= 1 ...
python
def move_cursor_one_letter(self, letter=RIGHT): """Move the cursor of one letter to the right (1) or the the left.""" assert letter in (self.RIGHT, self.LEFT) if letter == self.RIGHT: self.cursor += 1 if self.cursor > len(self.text): self.cursor -= 1 ...
[ "def", "move_cursor_one_letter", "(", "self", ",", "letter", "=", "RIGHT", ")", ":", "assert", "letter", "in", "(", "self", ".", "RIGHT", ",", "self", ".", "LEFT", ")", "if", "letter", "==", "self", ".", "RIGHT", ":", "self", ".", "cursor", "+=", "1"...
Move the cursor of one letter to the right (1) or the the left.
[ "Move", "the", "cursor", "of", "one", "letter", "to", "the", "right", "(", "1", ")", "or", "the", "the", "left", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L184-L195
train
ddorn/GUI
GUI/text.py
InLineTextBox.move_cursor_one_word
def move_cursor_one_word(self, word=LEFT): """Move the cursor of one word to the right (1) or the the left (-1).""" assert word in (self.RIGHT, self.LEFT) if word == self.RIGHT: papy = self.text.find(' ', self.cursor) + 1 if not papy: papy = len(self) ...
python
def move_cursor_one_word(self, word=LEFT): """Move the cursor of one word to the right (1) or the the left (-1).""" assert word in (self.RIGHT, self.LEFT) if word == self.RIGHT: papy = self.text.find(' ', self.cursor) + 1 if not papy: papy = len(self) ...
[ "def", "move_cursor_one_word", "(", "self", ",", "word", "=", "LEFT", ")", ":", "assert", "word", "in", "(", "self", ".", "RIGHT", ",", "self", ".", "LEFT", ")", "if", "word", "==", "self", ".", "RIGHT", ":", "papy", "=", "self", ".", "text", ".", ...
Move the cursor of one word to the right (1) or the the left (-1).
[ "Move", "the", "cursor", "of", "one", "word", "to", "the", "right", "(", "1", ")", "or", "the", "the", "left", "(", "-", "1", ")", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L197-L211
train
ddorn/GUI
GUI/text.py
InLineTextBox.delete_one_letter
def delete_one_letter(self, letter=RIGHT): """Delete one letter the right or the the left of the cursor.""" assert letter in (self.RIGHT, self.LEFT) if letter == self.LEFT: papy = self.cursor self.text = self.text[:self.cursor - 1] + self.text[self.cursor:] ...
python
def delete_one_letter(self, letter=RIGHT): """Delete one letter the right or the the left of the cursor.""" assert letter in (self.RIGHT, self.LEFT) if letter == self.LEFT: papy = self.cursor self.text = self.text[:self.cursor - 1] + self.text[self.cursor:] ...
[ "def", "delete_one_letter", "(", "self", ",", "letter", "=", "RIGHT", ")", ":", "assert", "letter", "in", "(", "self", ".", "RIGHT", ",", "self", ".", "LEFT", ")", "if", "letter", "==", "self", ".", "LEFT", ":", "papy", "=", "self", ".", "cursor", ...
Delete one letter the right or the the left of the cursor.
[ "Delete", "one", "letter", "the", "right", "or", "the", "the", "left", "of", "the", "cursor", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L213-L224
train
ddorn/GUI
GUI/text.py
InLineTextBox.delete_one_word
def delete_one_word(self, word=RIGHT): """Delete one word the right or the the left of the cursor.""" assert word in (self.RIGHT, self.LEFT) if word == self.RIGHT: papy = self.text.find(' ', self.cursor) + 1 if not papy: papy = len(self.text) ...
python
def delete_one_word(self, word=RIGHT): """Delete one word the right or the the left of the cursor.""" assert word in (self.RIGHT, self.LEFT) if word == self.RIGHT: papy = self.text.find(' ', self.cursor) + 1 if not papy: papy = len(self.text) ...
[ "def", "delete_one_word", "(", "self", ",", "word", "=", "RIGHT", ")", ":", "assert", "word", "in", "(", "self", ".", "RIGHT", ",", "self", ".", "LEFT", ")", "if", "word", "==", "self", ".", "RIGHT", ":", "papy", "=", "self", ".", "text", ".", "f...
Delete one word the right or the the left of the cursor.
[ "Delete", "one", "word", "the", "right", "or", "the", "the", "left", "of", "the", "cursor", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L226-L242
train
ddorn/GUI
GUI/text.py
InLineTextBox.add_letter
def add_letter(self, letter): """Add a letter at the cursor pos.""" assert isinstance(letter, str) assert len(letter) == 1 self.text = self.text[:self.cursor] + letter + self.text[self.cursor:] self.cursor += 1
python
def add_letter(self, letter): """Add a letter at the cursor pos.""" assert isinstance(letter, str) assert len(letter) == 1 self.text = self.text[:self.cursor] + letter + self.text[self.cursor:] self.cursor += 1
[ "def", "add_letter", "(", "self", ",", "letter", ")", ":", "assert", "isinstance", "(", "letter", ",", "str", ")", "assert", "len", "(", "letter", ")", "==", "1", "self", ".", "text", "=", "self", ".", "text", "[", ":", "self", ".", "cursor", "]", ...
Add a letter at the cursor pos.
[ "Add", "a", "letter", "at", "the", "cursor", "pos", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L244-L250
train
ddorn/GUI
GUI/text.py
InLineTextBox.update
def update(self, event_or_list): """Update the text and position of cursor according to the event passed.""" event_or_list = super().update(event_or_list) for e in event_or_list: if e.type == KEYDOWN: if e.key == K_RIGHT: if e.mod * KMOD_CTRL: ...
python
def update(self, event_or_list): """Update the text and position of cursor according to the event passed.""" event_or_list = super().update(event_or_list) for e in event_or_list: if e.type == KEYDOWN: if e.key == K_RIGHT: if e.mod * KMOD_CTRL: ...
[ "def", "update", "(", "self", ",", "event_or_list", ")", ":", "event_or_list", "=", "super", "(", ")", ".", "update", "(", "event_or_list", ")", "for", "e", "in", "event_or_list", ":", "if", "e", ".", "type", "==", "KEYDOWN", ":", "if", "e", ".", "ke...
Update the text and position of cursor according to the event passed.
[ "Update", "the", "text", "and", "position", "of", "cursor", "according", "to", "the", "event", "passed", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L256-L291
train
ddorn/GUI
GUI/text.py
InLineTextBox._render
def _render(self): """ Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. """ self._last_text = self.text self._surface = self.font.render(self.text, True, self.color, self.bg_color) size = self.wid...
python
def _render(self): """ Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. """ self._last_text = self.text self._surface = self.font.render(self.text, True, self.color, self.bg_color) size = self.wid...
[ "def", "_render", "(", "self", ")", ":", "self", ".", "_last_text", "=", "self", ".", "text", "self", ".", "_surface", "=", "self", ".", "font", ".", "render", "(", "self", ".", "text", ",", "True", ",", "self", ".", "color", ",", "self", ".", "b...
Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
[ "Render", "the", "text", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L293-L304
train
ddorn/GUI
GUI/text.py
InLinePassBox.shawn_text
def shawn_text(self): """The text displayed instead of the real one.""" if len(self._shawn_text) == len(self): return self._shawn_text if self.style == self.DOTS: return chr(0x2022) * len(self) ranges = [ (902, 1366), (192, 683), ...
python
def shawn_text(self): """The text displayed instead of the real one.""" if len(self._shawn_text) == len(self): return self._shawn_text if self.style == self.DOTS: return chr(0x2022) * len(self) ranges = [ (902, 1366), (192, 683), ...
[ "def", "shawn_text", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_shawn_text", ")", "==", "len", "(", "self", ")", ":", "return", "self", ".", "_shawn_text", "if", "self", ".", "style", "==", "self", ".", "DOTS", ":", "return", "chr", "(...
The text displayed instead of the real one.
[ "The", "text", "displayed", "instead", "of", "the", "real", "one", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L348-L372
train
ddorn/GUI
GUI/text.py
InLinePassBox.cursor_pos
def cursor_pos(self): """The cursor position in pixels.""" if len(self) == 0: return self.left + self.default_text.get_width() papy = self._surface.get_width() if papy > self.w: shift = papy - self.width else: shift = 0 return self.le...
python
def cursor_pos(self): """The cursor position in pixels.""" if len(self) == 0: return self.left + self.default_text.get_width() papy = self._surface.get_width() if papy > self.w: shift = papy - self.width else: shift = 0 return self.le...
[ "def", "cursor_pos", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "self", ".", "left", "+", "self", ".", "default_text", ".", "get_width", "(", ")", "papy", "=", "self", ".", "_surface", ".", "get_width", "(", ")"...
The cursor position in pixels.
[ "The", "cursor", "position", "in", "pixels", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L374-L385
train
ddorn/GUI
GUI/text.py
InLinePassBox._render
def _render(self): """ Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. """ self._last_text = self.shawn_text self._surface = self.font.render(self.shawn_text, True, self.color, self.bg_color) siz...
python
def _render(self): """ Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. """ self._last_text = self.shawn_text self._surface = self.font.render(self.shawn_text, True, self.color, self.bg_color) siz...
[ "def", "_render", "(", "self", ")", ":", "self", ".", "_last_text", "=", "self", ".", "shawn_text", "self", ".", "_surface", "=", "self", ".", "font", ".", "render", "(", "self", ".", "shawn_text", ",", "True", ",", "self", ".", "color", ",", "self",...
Render the text. Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
[ "Render", "the", "text", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L387-L398
train
ddorn/GUI
GUI/text.py
InLinePassBox.render
def render(self, display): """Render basicly the text.""" # to handle changing objects / callable if self.shawn_text != self._last_text: self._render() if self.text: papy = self._surface.get_width() if papy <= self.width: display.blit...
python
def render(self, display): """Render basicly the text.""" # to handle changing objects / callable if self.shawn_text != self._last_text: self._render() if self.text: papy = self._surface.get_width() if papy <= self.width: display.blit...
[ "def", "render", "(", "self", ",", "display", ")", ":", "# to handle changing objects / callable", "if", "self", ".", "shawn_text", "!=", "self", ".", "_last_text", ":", "self", ".", "_render", "(", ")", "if", "self", ".", "text", ":", "papy", "=", "self",...
Render basicly the text.
[ "Render", "basicly", "the", "text", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L400-L418
train
ddorn/GUI
GUI/text.py
LaText.latex_to_img
def latex_to_img(tex): """Return a pygame image from a latex template.""" with tempfile.TemporaryDirectory() as tmpdirname: with open(tmpdirname + r'\tex.tex', 'w') as f: f.write(tex) os.system(r"latex {0}\tex.tex -halt-on-error -interaction=batchmode -disable-in...
python
def latex_to_img(tex): """Return a pygame image from a latex template.""" with tempfile.TemporaryDirectory() as tmpdirname: with open(tmpdirname + r'\tex.tex', 'w') as f: f.write(tex) os.system(r"latex {0}\tex.tex -halt-on-error -interaction=batchmode -disable-in...
[ "def", "latex_to_img", "(", "tex", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tmpdirname", ":", "with", "open", "(", "tmpdirname", "+", "r'\\tex.tex'", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "tex", ")", ...
Return a pygame image from a latex template.
[ "Return", "a", "pygame", "image", "from", "a", "latex", "template", "." ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L443-L456
train
ddorn/GUI
GUI/colors.py
mix
def mix(color1, color2, pos=0.5): """ Return the mix of two colors at a state of :pos: Retruns color1 * pos + color2 * (1 - pos) """ opp_pos = 1 - pos red = color1[0] * pos + color2[0] * opp_pos green = color1[1] * pos + color2[1] * opp_pos blue = color1[2] * pos + color2[2] * opp_pos ...
python
def mix(color1, color2, pos=0.5): """ Return the mix of two colors at a state of :pos: Retruns color1 * pos + color2 * (1 - pos) """ opp_pos = 1 - pos red = color1[0] * pos + color2[0] * opp_pos green = color1[1] * pos + color2[1] * opp_pos blue = color1[2] * pos + color2[2] * opp_pos ...
[ "def", "mix", "(", "color1", ",", "color2", ",", "pos", "=", "0.5", ")", ":", "opp_pos", "=", "1", "-", "pos", "red", "=", "color1", "[", "0", "]", "*", "pos", "+", "color2", "[", "0", "]", "*", "opp_pos", "green", "=", "color1", "[", "1", "]...
Return the mix of two colors at a state of :pos: Retruns color1 * pos + color2 * (1 - pos)
[ "Return", "the", "mix", "of", "two", "colors", "at", "a", "state", "of", ":", "pos", ":" ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/colors.py#L13-L24
train
ddorn/GUI
GUI/colors.py
name2rgb
def name2rgb(name): """Convert the name of a color into its RGB value""" try: import colour except ImportError: raise ImportError('You need colour to be installed: pip install colour') c = colour.Color(name) color = int(c.red * 255), int(c.green * 255), int(c.blue * 255) return ...
python
def name2rgb(name): """Convert the name of a color into its RGB value""" try: import colour except ImportError: raise ImportError('You need colour to be installed: pip install colour') c = colour.Color(name) color = int(c.red * 255), int(c.green * 255), int(c.blue * 255) return ...
[ "def", "name2rgb", "(", "name", ")", ":", "try", ":", "import", "colour", "except", "ImportError", ":", "raise", "ImportError", "(", "'You need colour to be installed: pip install colour'", ")", "c", "=", "colour", ".", "Color", "(", "name", ")", "color", "=", ...
Convert the name of a color into its RGB value
[ "Convert", "the", "name", "of", "a", "color", "into", "its", "RGB", "value" ]
e1fcb5286d24e0995f280d5180222e51895c368c
https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/colors.py#L27-L36
train
lord63/tldr.py
tldr/parser.py
parse_page
def parse_page(page): """Parse the command man page.""" colors = get_config()['colors'] with io.open(page, encoding='utf-8') as f: lines = f.readlines() output_lines = [] for line in lines[1:]: if is_headline(line): continue elif is_description(line): ...
python
def parse_page(page): """Parse the command man page.""" colors = get_config()['colors'] with io.open(page, encoding='utf-8') as f: lines = f.readlines() output_lines = [] for line in lines[1:]: if is_headline(line): continue elif is_description(line): ...
[ "def", "parse_page", "(", "page", ")", ":", "colors", "=", "get_config", "(", ")", "[", "'colors'", "]", "with", "io", ".", "open", "(", "page", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", ...
Parse the command man page.
[ "Parse", "the", "command", "man", "page", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/parser.py#L12-L34
train
unbit/sftpclone
sftpclone/sftpclone.py
configure_logging
def configure_logging(level=logging.DEBUG): """Configure the module logging engine.""" if level == logging.DEBUG: # For debugging purposes, log from everyone! logging.basicConfig( level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s' ) re...
python
def configure_logging(level=logging.DEBUG): """Configure the module logging engine.""" if level == logging.DEBUG: # For debugging purposes, log from everyone! logging.basicConfig( level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s' ) re...
[ "def", "configure_logging", "(", "level", "=", "logging", ".", "DEBUG", ")", ":", "if", "level", "==", "logging", ".", "DEBUG", ":", "# For debugging purposes, log from everyone!", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", ",", ...
Configure the module logging engine.
[ "Configure", "the", "module", "logging", "engine", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L33-L50
train
unbit/sftpclone
sftpclone/sftpclone.py
path_join
def path_join(*args): """ Wrapper around `os.path.join`. Makes sure to join paths of the same type (bytes). """ args = (paramiko.py3compat.u(arg) for arg in args) return os.path.join(*args)
python
def path_join(*args): """ Wrapper around `os.path.join`. Makes sure to join paths of the same type (bytes). """ args = (paramiko.py3compat.u(arg) for arg in args) return os.path.join(*args)
[ "def", "path_join", "(", "*", "args", ")", ":", "args", "=", "(", "paramiko", ".", "py3compat", ".", "u", "(", "arg", ")", "for", "arg", "in", "args", ")", "return", "os", ".", "path", ".", "join", "(", "*", "args", ")" ]
Wrapper around `os.path.join`. Makes sure to join paths of the same type (bytes).
[ "Wrapper", "around", "os", ".", "path", ".", "join", ".", "Makes", "sure", "to", "join", "paths", "of", "the", "same", "type", "(", "bytes", ")", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L53-L59
train
unbit/sftpclone
sftpclone/sftpclone.py
parse_username_password_hostname
def parse_username_password_hostname(remote_url): """ Parse a command line string and return username, password, remote hostname and remote path. :param remote_url: A command line string. :return: A tuple, containing username, password, remote hostname and remote path. """ assert remote_url ...
python
def parse_username_password_hostname(remote_url): """ Parse a command line string and return username, password, remote hostname and remote path. :param remote_url: A command line string. :return: A tuple, containing username, password, remote hostname and remote path. """ assert remote_url ...
[ "def", "parse_username_password_hostname", "(", "remote_url", ")", ":", "assert", "remote_url", "assert", "':'", "in", "remote_url", "if", "'@'", "in", "remote_url", ":", "username", ",", "hostname", "=", "remote_url", ".", "rsplit", "(", "'@'", ",", "1", ")",...
Parse a command line string and return username, password, remote hostname and remote path. :param remote_url: A command line string. :return: A tuple, containing username, password, remote hostname and remote path.
[ "Parse", "a", "command", "line", "string", "and", "return", "username", "password", "remote", "hostname", "and", "remote", "path", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L62-L85
train
unbit/sftpclone
sftpclone/sftpclone.py
get_ssh_agent_keys
def get_ssh_agent_keys(logger): """ Ask the SSH agent for a list of keys, and return it. :return: A reference to the SSH agent and a list of keys. """ agent, agent_keys = None, None try: agent = paramiko.agent.Agent() _agent_keys = agent.get_keys() if not _agent_keys: ...
python
def get_ssh_agent_keys(logger): """ Ask the SSH agent for a list of keys, and return it. :return: A reference to the SSH agent and a list of keys. """ agent, agent_keys = None, None try: agent = paramiko.agent.Agent() _agent_keys = agent.get_keys() if not _agent_keys: ...
[ "def", "get_ssh_agent_keys", "(", "logger", ")", ":", "agent", ",", "agent_keys", "=", "None", ",", "None", "try", ":", "agent", "=", "paramiko", ".", "agent", ".", "Agent", "(", ")", "_agent_keys", "=", "agent", ".", "get_keys", "(", ")", "if", "not",...
Ask the SSH agent for a list of keys, and return it. :return: A reference to the SSH agent and a list of keys.
[ "Ask", "the", "SSH", "agent", "for", "a", "list", "of", "keys", "and", "return", "it", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L88-L113
train
unbit/sftpclone
sftpclone/sftpclone.py
create_parser
def create_parser(): """Create the CLI argument parser.""" parser = argparse.ArgumentParser( description='Sync a local and a remote folder through SFTP.' ) parser.add_argument( "path", type=str, metavar="local-path", help="the path of the local folder", ) ...
python
def create_parser(): """Create the CLI argument parser.""" parser = argparse.ArgumentParser( description='Sync a local and a remote folder through SFTP.' ) parser.add_argument( "path", type=str, metavar="local-path", help="the path of the local folder", ) ...
[ "def", "create_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Sync a local and a remote folder through SFTP.'", ")", "parser", ".", "add_argument", "(", "\"path\"", ",", "type", "=", "str", ",", "metavar", "=",...
Create the CLI argument parser.
[ "Create", "the", "CLI", "argument", "parser", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L628-L747
train
unbit/sftpclone
sftpclone/sftpclone.py
main
def main(args=None): """The main.""" parser = create_parser() args = vars(parser.parse_args(args)) log_mapping = { 'CRITICAL': logging.CRITICAL, 'ERROR': logging.ERROR, 'WARNING': logging.WARNING, 'INFO': logging.INFO, 'DEBUG': logging.DEBUG, 'NOTSET': lo...
python
def main(args=None): """The main.""" parser = create_parser() args = vars(parser.parse_args(args)) log_mapping = { 'CRITICAL': logging.CRITICAL, 'ERROR': logging.ERROR, 'WARNING': logging.WARNING, 'INFO': logging.INFO, 'DEBUG': logging.DEBUG, 'NOTSET': lo...
[ "def", "main", "(", "args", "=", "None", ")", ":", "parser", "=", "create_parser", "(", ")", "args", "=", "vars", "(", "parser", ".", "parse_args", "(", "args", ")", ")", "log_mapping", "=", "{", "'CRITICAL'", ":", "logging", ".", "CRITICAL", ",", "'...
The main.
[ "The", "main", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L750-L806
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone._must_be_deleted
def _must_be_deleted(local_path, r_st): """Return True if the remote correspondent of local_path has to be deleted. i.e. if it doesn't exists locally or if it has a different type from the remote one.""" # if the file doesn't exists if not os.path.lexists(local_path): return...
python
def _must_be_deleted(local_path, r_st): """Return True if the remote correspondent of local_path has to be deleted. i.e. if it doesn't exists locally or if it has a different type from the remote one.""" # if the file doesn't exists if not os.path.lexists(local_path): return...
[ "def", "_must_be_deleted", "(", "local_path", ",", "r_st", ")", ":", "# if the file doesn't exists", "if", "not", "os", ".", "path", ".", "lexists", "(", "local_path", ")", ":", "return", "True", "# or if the file type is different", "l_st", "=", "os", ".", "lst...
Return True if the remote correspondent of local_path has to be deleted. i.e. if it doesn't exists locally or if it has a different type from the remote one.
[ "Return", "True", "if", "the", "remote", "correspondent", "of", "local_path", "has", "to", "be", "deleted", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L369-L382
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone._match_modes
def _match_modes(self, remote_path, l_st): """Match mod, utime and uid/gid with locals one.""" self.sftp.chmod(remote_path, S_IMODE(l_st.st_mode)) self.sftp.utime(remote_path, (l_st.st_atime, l_st.st_mtime)) if self.chown: self.sftp.chown(remote_path, l_st.st_uid, l_st.st_gi...
python
def _match_modes(self, remote_path, l_st): """Match mod, utime and uid/gid with locals one.""" self.sftp.chmod(remote_path, S_IMODE(l_st.st_mode)) self.sftp.utime(remote_path, (l_st.st_atime, l_st.st_mtime)) if self.chown: self.sftp.chown(remote_path, l_st.st_uid, l_st.st_gi...
[ "def", "_match_modes", "(", "self", ",", "remote_path", ",", "l_st", ")", ":", "self", ".", "sftp", ".", "chmod", "(", "remote_path", ",", "S_IMODE", "(", "l_st", ".", "st_mode", ")", ")", "self", ".", "sftp", ".", "utime", "(", "remote_path", ",", "...
Match mod, utime and uid/gid with locals one.
[ "Match", "mod", "utime", "and", "uid", "/", "gid", "with", "locals", "one", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L384-L390
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.file_upload
def file_upload(self, local_path, remote_path, l_st): """Upload local_path to remote_path and set permission and mtime.""" self.sftp.put(local_path, remote_path) self._match_modes(remote_path, l_st)
python
def file_upload(self, local_path, remote_path, l_st): """Upload local_path to remote_path and set permission and mtime.""" self.sftp.put(local_path, remote_path) self._match_modes(remote_path, l_st)
[ "def", "file_upload", "(", "self", ",", "local_path", ",", "remote_path", ",", "l_st", ")", ":", "self", ".", "sftp", ".", "put", "(", "local_path", ",", "remote_path", ")", "self", ".", "_match_modes", "(", "remote_path", ",", "l_st", ")" ]
Upload local_path to remote_path and set permission and mtime.
[ "Upload", "local_path", "to", "remote_path", "and", "set", "permission", "and", "mtime", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L392-L395
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.remote_delete
def remote_delete(self, remote_path, r_st): """Remove the remote directory node.""" # If it's a directory, then delete content and directory if S_ISDIR(r_st.st_mode): for item in self.sftp.listdir_attr(remote_path): full_path = path_join(remote_path, item.filename) ...
python
def remote_delete(self, remote_path, r_st): """Remove the remote directory node.""" # If it's a directory, then delete content and directory if S_ISDIR(r_st.st_mode): for item in self.sftp.listdir_attr(remote_path): full_path = path_join(remote_path, item.filename) ...
[ "def", "remote_delete", "(", "self", ",", "remote_path", ",", "r_st", ")", ":", "# If it's a directory, then delete content and directory", "if", "S_ISDIR", "(", "r_st", ".", "st_mode", ")", ":", "for", "item", "in", "self", ".", "sftp", ".", "listdir_attr", "("...
Remove the remote directory node.
[ "Remove", "the", "remote", "directory", "node", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L397-L413
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.check_for_deletion
def check_for_deletion(self, relative_path=None): """Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder. """ if not relative_path: relative_path = str() # root of shared directory tree ...
python
def check_for_deletion(self, relative_path=None): """Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder. """ if not relative_path: relative_path = str() # root of shared directory tree ...
[ "def", "check_for_deletion", "(", "self", ",", "relative_path", "=", "None", ")", ":", "if", "not", "relative_path", ":", "relative_path", "=", "str", "(", ")", "# root of shared directory tree", "remote_path", "=", "path_join", "(", "self", ".", "remote_path", ...
Traverse the entire remote_path tree. Find files/directories that need to be deleted, not being present in the local folder.
[ "Traverse", "the", "entire", "remote_path", "tree", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L415-L445
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.create_update_symlink
def create_update_symlink(self, link_destination, remote_path): """Create a new link pointing to link_destination in remote_path position.""" try: # if there's anything, delete it self.sftp.remove(remote_path) except IOError: # that's fine, nothing exists there! pass ...
python
def create_update_symlink(self, link_destination, remote_path): """Create a new link pointing to link_destination in remote_path position.""" try: # if there's anything, delete it self.sftp.remove(remote_path) except IOError: # that's fine, nothing exists there! pass ...
[ "def", "create_update_symlink", "(", "self", ",", "link_destination", ",", "remote_path", ")", ":", "try", ":", "# if there's anything, delete it", "self", ".", "sftp", ".", "remove", "(", "remote_path", ")", "except", "IOError", ":", "# that's fine, nothing exists th...
Create a new link pointing to link_destination in remote_path position.
[ "Create", "a", "new", "link", "pointing", "to", "link_destination", "in", "remote_path", "position", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L447-L460
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.node_check_for_upload_create
def node_check_for_upload_create(self, relative_path, f): """Check if the given directory tree node has to be uploaded/created on the remote folder.""" if not relative_path: # we're at the root of the shared directory tree relative_path = str() # the (absolute) local add...
python
def node_check_for_upload_create(self, relative_path, f): """Check if the given directory tree node has to be uploaded/created on the remote folder.""" if not relative_path: # we're at the root of the shared directory tree relative_path = str() # the (absolute) local add...
[ "def", "node_check_for_upload_create", "(", "self", ",", "relative_path", ",", "f", ")", ":", "if", "not", "relative_path", ":", "# we're at the root of the shared directory tree", "relative_path", "=", "str", "(", ")", "# the (absolute) local address of f.", "local_path", ...
Check if the given directory tree node has to be uploaded/created on the remote folder.
[ "Check", "if", "the", "given", "directory", "tree", "node", "has", "to", "be", "uploaded", "/", "created", "on", "the", "remote", "folder", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L462-L583
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.check_for_upload_create
def check_for_upload_create(self, relative_path=None): """Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.""" for f in os.listdir( path_join( self.local_path, relative_path) if ...
python
def check_for_upload_create(self, relative_path=None): """Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.""" for f in os.listdir( path_join( self.local_path, relative_path) if ...
[ "def", "check_for_upload_create", "(", "self", ",", "relative_path", "=", "None", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "path_join", "(", "self", ".", "local_path", ",", "relative_path", ")", "if", "relative_path", "else", "self", ".", "lo...
Traverse the relative_path tree and check for files that need to be uploaded/created. Relativity here refers to the shared directory tree.
[ "Traverse", "the", "relative_path", "tree", "and", "check", "for", "files", "that", "need", "to", "be", "uploaded", "/", "created", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L585-L593
train
unbit/sftpclone
sftpclone/sftpclone.py
SFTPClone.run
def run(self): """Run the sync. Confront the local and the remote directories and perform the needed changes.""" # Check if remote path is present try: self.sftp.stat(self.remote_path) except FileNotFoundError as e: if self.create_remote_directory: ...
python
def run(self): """Run the sync. Confront the local and the remote directories and perform the needed changes.""" # Check if remote path is present try: self.sftp.stat(self.remote_path) except FileNotFoundError as e: if self.create_remote_directory: ...
[ "def", "run", "(", "self", ")", ":", "# Check if remote path is present", "try", ":", "self", ".", "sftp", ".", "stat", "(", "self", ".", "remote_path", ")", "except", "FileNotFoundError", "as", "e", ":", "if", "self", ".", "create_remote_directory", ":", "s...
Run the sync. Confront the local and the remote directories and perform the needed changes.
[ "Run", "the", "sync", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L595-L625
train
unbit/sftpclone
sftpclone/t/utils.py
list_files
def list_files(start_path): """tree unix command replacement.""" s = u'\n' for root, dirs, files in os.walk(start_path): level = root.replace(start_path, '').count(os.sep) indent = ' ' * 4 * level s += u'{}{}/\n'.format(indent, os.path.basename(root)) sub_indent = ' ' * 4 * (...
python
def list_files(start_path): """tree unix command replacement.""" s = u'\n' for root, dirs, files in os.walk(start_path): level = root.replace(start_path, '').count(os.sep) indent = ' ' * 4 * level s += u'{}{}/\n'.format(indent, os.path.basename(root)) sub_indent = ' ' * 4 * (...
[ "def", "list_files", "(", "start_path", ")", ":", "s", "=", "u'\\n'", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "start_path", ")", ":", "level", "=", "root", ".", "replace", "(", "start_path", ",", "''", ")", ".", "cou...
tree unix command replacement.
[ "tree", "unix", "command", "replacement", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L26-L36
train
unbit/sftpclone
sftpclone/t/utils.py
file_tree
def file_tree(start_path): """ Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/ """ nested_dirs = {} root_dir = start_path.rstrip(os.sep) start = roo...
python
def file_tree(start_path): """ Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/ """ nested_dirs = {} root_dir = start_path.rstrip(os.sep) start = roo...
[ "def", "file_tree", "(", "start_path", ")", ":", "nested_dirs", "=", "{", "}", "root_dir", "=", "start_path", ".", "rstrip", "(", "os", ".", "sep", ")", "start", "=", "root_dir", ".", "rfind", "(", "os", ".", "sep", ")", "+", "1", "for", "path", ",...
Create a nested dictionary that represents the folder structure of `start_path`. Liberally adapted from http://code.activestate.com/recipes/577879-create-a-nested-dictionary-from-oswalk/
[ "Create", "a", "nested", "dictionary", "that", "represents", "the", "folder", "structure", "of", "start_path", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L39-L54
train
unbit/sftpclone
sftpclone/t/utils.py
capture_sys_output
def capture_sys_output(): """Capture standard output and error.""" capture_out, capture_err = StringIO(), StringIO() current_out, current_err = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = capture_out, capture_err yield capture_out, capture_err finally: sys.stdout, sy...
python
def capture_sys_output(): """Capture standard output and error.""" capture_out, capture_err = StringIO(), StringIO() current_out, current_err = sys.stdout, sys.stderr try: sys.stdout, sys.stderr = capture_out, capture_err yield capture_out, capture_err finally: sys.stdout, sy...
[ "def", "capture_sys_output", "(", ")", ":", "capture_out", ",", "capture_err", "=", "StringIO", "(", ")", ",", "StringIO", "(", ")", "current_out", ",", "current_err", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "try", ":", "sys", ".", "stdout"...
Capture standard output and error.
[ "Capture", "standard", "output", "and", "error", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L58-L66
train
unbit/sftpclone
sftpclone/t/utils.py
suppress_logging
def suppress_logging(log_level=logging.CRITICAL): """Suppress logging.""" logging.disable(log_level) yield logging.disable(logging.NOTSET)
python
def suppress_logging(log_level=logging.CRITICAL): """Suppress logging.""" logging.disable(log_level) yield logging.disable(logging.NOTSET)
[ "def", "suppress_logging", "(", "log_level", "=", "logging", ".", "CRITICAL", ")", ":", "logging", ".", "disable", "(", "log_level", ")", "yield", "logging", ".", "disable", "(", "logging", ".", "NOTSET", ")" ]
Suppress logging.
[ "Suppress", "logging", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L70-L74
train
unbit/sftpclone
sftpclone/t/utils.py
override_env_variables
def override_env_variables(): """Override user environmental variables with custom one.""" env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME") old = [os.environ[v] if v in os.environ else None for v in env_vars] for v in env_vars: os.environ[v] = "test" yield for i, v in enumerate(env_...
python
def override_env_variables(): """Override user environmental variables with custom one.""" env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME") old = [os.environ[v] if v in os.environ else None for v in env_vars] for v in env_vars: os.environ[v] = "test" yield for i, v in enumerate(env_...
[ "def", "override_env_variables", "(", ")", ":", "env_vars", "=", "(", "\"LOGNAME\"", ",", "\"USER\"", ",", "\"LNAME\"", ",", "\"USERNAME\"", ")", "old", "=", "[", "os", ".", "environ", "[", "v", "]", "if", "v", "in", "os", ".", "environ", "else", "None...
Override user environmental variables with custom one.
[ "Override", "user", "environmental", "variables", "with", "custom", "one", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L78-L89
train
unbit/sftpclone
sftpclone/t/utils.py
override_ssh_auth_env
def override_ssh_auth_env(): """Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.""" ssh_auth_sock = "SSH_AUTH_SOCK" old_ssh_auth_sock = os.environ.get(ssh_auth_sock) del os.environ[ssh_auth_sock] yield if old_ssh_auth_sock: os.environ[ssh_auth_sock] = ol...
python
def override_ssh_auth_env(): """Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.""" ssh_auth_sock = "SSH_AUTH_SOCK" old_ssh_auth_sock = os.environ.get(ssh_auth_sock) del os.environ[ssh_auth_sock] yield if old_ssh_auth_sock: os.environ[ssh_auth_sock] = ol...
[ "def", "override_ssh_auth_env", "(", ")", ":", "ssh_auth_sock", "=", "\"SSH_AUTH_SOCK\"", "old_ssh_auth_sock", "=", "os", ".", "environ", ".", "get", "(", "ssh_auth_sock", ")", "del", "os", ".", "environ", "[", "ssh_auth_sock", "]", "yield", "if", "old_ssh_auth_...
Override the `$SSH_AUTH_SOCK `env variable to mock the absence of an SSH agent.
[ "Override", "the", "$SSH_AUTH_SOCK", "env", "variable", "to", "mock", "the", "absence", "of", "an", "SSH", "agent", "." ]
1cc89478e680fc4e0d12b1a15b5bafd0390d05da
https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/t/utils.py#L93-L103
train
lord63/tldr.py
tldr/config.py
get_config
def get_config(): """Get the configurations from .tldrrc and return it as a dict.""" config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if not path.exists(config_path): sys.exit("Can't find config file at: {0}. You may use `tldr init` " ...
python
def get_config(): """Get the configurations from .tldrrc and return it as a dict.""" config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if not path.exists(config_path): sys.exit("Can't find config file at: {0}. You may use `tldr init` " ...
[ "def", "get_config", "(", ")", ":", "config_path", "=", "path", ".", "join", "(", "(", "os", ".", "environ", ".", "get", "(", "'TLDR_CONFIG_DIR'", ")", "or", "path", ".", "expanduser", "(", "'~'", ")", ")", ",", "'.tldrrc'", ")", "if", "not", "path",...
Get the configurations from .tldrrc and return it as a dict.
[ "Get", "the", "configurations", "from", ".", "tldrrc", "and", "return", "it", "as", "a", "dict", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/config.py#L14-L38
train
lord63/tldr.py
tldr/cli.py
parse_man_page
def parse_man_page(command, platform): """Parse the man page and return the parsed lines.""" page_path = find_page_location(command, platform) output_lines = parse_page(page_path) return output_lines
python
def parse_man_page(command, platform): """Parse the man page and return the parsed lines.""" page_path = find_page_location(command, platform) output_lines = parse_page(page_path) return output_lines
[ "def", "parse_man_page", "(", "command", ",", "platform", ")", ":", "page_path", "=", "find_page_location", "(", "command", ",", "platform", ")", "output_lines", "=", "parse_page", "(", "page_path", ")", "return", "output_lines" ]
Parse the man page and return the parsed lines.
[ "Parse", "the", "man", "page", "and", "return", "the", "parsed", "lines", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L22-L26
train
lord63/tldr.py
tldr/cli.py
find_page_location
def find_page_location(command, specified_platform): """Find the command man page in the pages directory.""" repo_directory = get_config()['repo_directory'] default_platform = get_config()['platform'] command_platform = ( specified_platform if specified_platform else default_platform) with ...
python
def find_page_location(command, specified_platform): """Find the command man page in the pages directory.""" repo_directory = get_config()['repo_directory'] default_platform = get_config()['platform'] command_platform = ( specified_platform if specified_platform else default_platform) with ...
[ "def", "find_page_location", "(", "command", ",", "specified_platform", ")", ":", "repo_directory", "=", "get_config", "(", ")", "[", "'repo_directory'", "]", "default_platform", "=", "get_config", "(", ")", "[", "'platform'", "]", "command_platform", "=", "(", ...
Find the command man page in the pages directory.
[ "Find", "the", "command", "man", "page", "in", "the", "pages", "directory", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L29-L62
train
lord63/tldr.py
tldr/cli.py
find
def find(command, on): """Find the command usage.""" output_lines = parse_man_page(command, on) click.echo(''.join(output_lines))
python
def find(command, on): """Find the command usage.""" output_lines = parse_man_page(command, on) click.echo(''.join(output_lines))
[ "def", "find", "(", "command", ",", "on", ")", ":", "output_lines", "=", "parse_man_page", "(", "command", ",", "on", ")", "click", ".", "echo", "(", "''", ".", "join", "(", "output_lines", ")", ")" ]
Find the command usage.
[ "Find", "the", "command", "usage", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L101-L104
train
lord63/tldr.py
tldr/cli.py
update
def update(): """Update to the latest pages.""" repo_directory = get_config()['repo_directory'] os.chdir(repo_directory) click.echo("Check for updates...") local = subprocess.check_output('git rev-parse master'.split()).strip() remote = subprocess.check_output( 'git ls-remote https://gi...
python
def update(): """Update to the latest pages.""" repo_directory = get_config()['repo_directory'] os.chdir(repo_directory) click.echo("Check for updates...") local = subprocess.check_output('git rev-parse master'.split()).strip() remote = subprocess.check_output( 'git ls-remote https://gi...
[ "def", "update", "(", ")", ":", "repo_directory", "=", "get_config", "(", ")", "[", "'repo_directory'", "]", "os", ".", "chdir", "(", "repo_directory", ")", "click", ".", "echo", "(", "\"Check for updates...\"", ")", "local", "=", "subprocess", ".", "check_o...
Update to the latest pages.
[ "Update", "to", "the", "latest", "pages", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L108-L125
train
lord63/tldr.py
tldr/cli.py
init
def init(): """Init config file.""" default_config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if path.exists(default_config_path): click.echo("There is already a config file exists, " "skip initializing it.") else:...
python
def init(): """Init config file.""" default_config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if path.exists(default_config_path): click.echo("There is already a config file exists, " "skip initializing it.") else:...
[ "def", "init", "(", ")", ":", "default_config_path", "=", "path", ".", "join", "(", "(", "os", ".", "environ", ".", "get", "(", "'TLDR_CONFIG_DIR'", ")", "or", "path", ".", "expanduser", "(", "'~'", ")", ")", ",", "'.tldrrc'", ")", "if", "path", ".",...
Init config file.
[ "Init", "config", "file", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L129-L161
train
lord63/tldr.py
tldr/cli.py
locate
def locate(command, on): """Locate the command's man page.""" location = find_page_location(command, on) click.echo(location)
python
def locate(command, on): """Locate the command's man page.""" location = find_page_location(command, on) click.echo(location)
[ "def", "locate", "(", "command", ",", "on", ")", ":", "location", "=", "find_page_location", "(", "command", ",", "on", ")", "click", ".", "echo", "(", "location", ")" ]
Locate the command's man page.
[ "Locate", "the", "command", "s", "man", "page", "." ]
73cf9f86254691b2476910ea6a743b6d8bd04963
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/cli.py#L175-L178
train
brentp/cruzdb
cruzdb/sqlsoup.py
TableClassType.relate
def relate(cls, propname, *args, **kwargs): """Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct. """ class_mapper(cls)._configure_property(propname, relation...
python
def relate(cls, propname, *args, **kwargs): """Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct. """ class_mapper(cls)._configure_property(propname, relation...
[ "def", "relate", "(", "cls", ",", "propname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "class_mapper", "(", "cls", ")", ".", "_configure_property", "(", "propname", ",", "relationship", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ...
Produce a relationship between this mapped table and another one. This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship` construct.
[ "Produce", "a", "relationship", "between", "this", "mapped", "table", "and", "another", "one", ".", "This", "makes", "usage", "of", "SQLAlchemy", "s", ":", "func", ":", "sqlalchemy", ".", "orm", ".", "relationship", "construct", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L93-L101
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.execute
def execute(self, stmt, **params): """Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct. """ return self.session.execute(sql.text(stmt...
python
def execute(self, stmt, **params): """Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct. """ return self.session.execute(sql.text(stmt...
[ "def", "execute", "(", "self", ",", "stmt", ",", "*", "*", "params", ")", ":", "return", "self", ".", "session", ".", "execute", "(", "sql", ".", "text", "(", "stmt", ",", "bind", "=", "self", ".", "bind", ")", ",", "*", "*", "params", ")" ]
Execute a SQL statement. The statement may be a string SQL string, an :func:`sqlalchemy.sql.expression.select` construct, or a :func:`sqlalchemy.sql.expression.text` construct.
[ "Execute", "a", "SQL", "statement", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L229-L238
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.map_to
def map_to(self, attrname, tablename=None, selectable=None, schema=None, base=None, mapper_args=util.immutabledict()): """Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String a...
python
def map_to(self, attrname, tablename=None, selectable=None, schema=None, base=None, mapper_args=util.immutabledict()): """Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String a...
[ "def", "map_to", "(", "self", ",", "attrname", ",", "tablename", "=", "None", ",", "selectable", "=", "None", ",", "schema", "=", "None", ",", "base", "=", "None", ",", "mapper_args", "=", "util", ".", "immutabledict", "(", ")", ")", ":", "if", "attr...
Configure a mapping to the given attrname. This is the "master" method that can be used to create any configuration. :param attrname: String attribute name which will be established as an attribute on this :class:.`.SQLSoup` instance. :param base: a Python class wh...
[ "Configure", "a", "mapping", "to", "the", "given", "attrname", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L292-L373
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.map
def map(self, selectable, base=None, **mapper_args): """Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will ...
python
def map(self, selectable, base=None, **mapper_args): """Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will ...
[ "def", "map", "(", "self", ",", "selectable", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "return", "_class_for_table", "(", "self", ".", "session", ",", "self", ".", "engine", ",", "selectable", ",", "base", "or", "self", ".", ...
Map a selectable directly. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will be used as the base for the mapped class. If ``None``,...
[ "Map", "a", "selectable", "directly", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L376-L399
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.with_labels
def with_labels(self, selectable, base=None, **mapper_args): """Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expressio...
python
def with_labels(self, selectable, base=None, **mapper_args): """Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expressio...
[ "def", "with_labels", "(", "self", ",", "selectable", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "# TODO give meaningful aliases", "return", "self", ".", "map", "(", "expression", ".", "_clause_element_as_expr", "(", "selectable", ")", "...
Map a selectable directly, wrapping the selectable in a subquery with labels. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param selectable: an :func:`.expression.select` construct. :param base: a Python class which will be u...
[ "Map", "a", "selectable", "directly", "wrapping", "the", "selectable", "in", "a", "subquery", "with", "labels", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L401-L423
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.join
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or tabl...
python
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or tabl...
[ "def", "join", "(", "self", ",", "left", ",", "right", ",", "onclause", "=", "None", ",", "isouter", "=", "False", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "j", "=", "join", "(", "left", ",", "right", ",", "onclause", "="...
Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause con...
[ "Create", "an", ":", "func", ":", ".", "expression", ".", "join", "and", "map", "to", "it", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L425-L447
train
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.entity
def entity(self, attr, schema=None): """Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`. """ try: return self._cache[attr] except KeyError, ke: return self.map_to(a...
python
def entity(self, attr, schema=None): """Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`. """ try: return self._cache[attr] except KeyError, ke: return self.map_to(a...
[ "def", "entity", "(", "self", ",", "attr", ",", "schema", "=", "None", ")", ":", "try", ":", "return", "self", ".", "_cache", "[", "attr", "]", "except", "KeyError", ",", "ke", ":", "return", "self", ".", "map_to", "(", "attr", ",", "tablename", "=...
Return the named entity from this :class:`.SQLSoup`, or create if not present. For more generalized mapping, see :meth:`.map_to`.
[ "Return", "the", "named", "entity", "from", "this", ":", "class", ":", ".", "SQLSoup", "or", "create", "if", "not", "present", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L449-L459
train
brentp/cruzdb
cruzdb/intersecter.py
distance
def distance(f1, f2): """\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 ...
python
def distance(f1, f2): """\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 ...
[ "def", "distance", "(", "f1", ",", "f2", ")", ":", "if", "f1", ".", "end", "<", "f2", ".", "start", ":", "return", "f2", ".", "start", "-", "f1", ".", "end", "if", "f2", ".", "end", "<", "f1", ".", "start", ":", "return", "f1", ".", "start", ...
\ Distance between 2 features. The integer result is always positive or zero. If the features overlap or touch, it is zero. >>> from intersecter import Feature, distance >>> distance(Feature(1, 2), Feature(12, 13)) 10 >>> distance(Feature(1, 2), Feature(2, 3)) 0 >>> distance(Feature(1, 1...
[ "\\", "Distance", "between", "2", "features", ".", "The", "integer", "result", "is", "always", "positive", "or", "zero", ".", "If", "the", "features", "overlap", "or", "touch", "it", "is", "zero", ".", ">>>", "from", "intersecter", "import", "Feature", "di...
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L269-L284
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.find
def find(self, start, end, chrom=None): """Return a object of all stored intervals intersecting between (start, end) inclusive.""" intervals = self.intervals[chrom] ilen = len(intervals) # NOTE: we only search for starts, since any feature that starts within max_len of # the quer...
python
def find(self, start, end, chrom=None): """Return a object of all stored intervals intersecting between (start, end) inclusive.""" intervals = self.intervals[chrom] ilen = len(intervals) # NOTE: we only search for starts, since any feature that starts within max_len of # the quer...
[ "def", "find", "(", "self", ",", "start", ",", "end", ",", "chrom", "=", "None", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "chrom", "]", "ilen", "=", "len", "(", "intervals", ")", "# NOTE: we only search for starts, since any feature that star...
Return a object of all stored intervals intersecting between (start, end) inclusive.
[ "Return", "a", "object", "of", "all", "stored", "intervals", "intersecting", "between", "(", "start", "end", ")", "inclusive", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L147-L161
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.left
def left(self, f, n=1): """return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] if intervals == [...
python
def left(self, f, n=1): """return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] if intervals == [...
[ "def", "left", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "f", ".", "chrom", "]", "if", "intervals", "==", "[", "]", ":", "return", "[", "]", "iright", "=", "binsearch_left_start", "(", "...
return the nearest n features strictly to the left of a Feature f. Overlapping features are not considered as to the left. f: a Feature object n: the number of features to return
[ "return", "the", "nearest", "n", "features", "strictly", "to", "the", "left", "of", "a", "Feature", "f", ".", "Overlapping", "features", "are", "not", "considered", "as", "to", "the", "left", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L163-L192
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.right
def right(self, f, n=1): """return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] ilen = len(int...
python
def right(self, f, n=1): """return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return """ intervals = self.intervals[f.chrom] ilen = len(int...
[ "def", "right", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "intervals", "=", "self", ".", "intervals", "[", "f", ".", "chrom", "]", "ilen", "=", "len", "(", "intervals", ")", "iright", "=", "binsearch_right_end", "(", "intervals", ",", "f...
return the nearest n features strictly to the right of a Feature f. Overlapping features are not considered as to the right. f: a Feature object n: the number of features to return
[ "return", "the", "nearest", "n", "features", "strictly", "to", "the", "right", "of", "a", "Feature", "f", ".", "Overlapping", "features", "are", "not", "considered", "as", "to", "the", "right", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L194-L215
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.upstream
def upstream(self, f, n=1): """find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: return se...
python
def upstream(self, f, n=1): """find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: return se...
[ "def", "upstream", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "if", "f", ".", "strand", "==", "-", "1", ":", "return", "self", ".", "right", "(", "f", ",", "n", ")", "return", "self", ".", "left", "(", "f", ",", "n", ")" ]
find n upstream features where upstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return
[ "find", "n", "upstream", "features", "where", "upstream", "is", "determined", "by", "the", "strand", "of", "the", "query", "Feature", "f", "Overlapping", "features", "are", "not", "considered", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L218-L228
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.downstream
def downstream(self, f, n=1): """find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: ret...
python
def downstream(self, f, n=1): """find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return """ if f.strand == -1: ret...
[ "def", "downstream", "(", "self", ",", "f", ",", "n", "=", "1", ")", ":", "if", "f", ".", "strand", "==", "-", "1", ":", "return", "self", ".", "left", "(", "f", ",", "n", ")", "return", "self", ".", "right", "(", "f", ",", "n", ")" ]
find n downstream features where downstream is determined by the strand of the query Feature f Overlapping features are not considered. f: a Feature object n: the number of features to return
[ "find", "n", "downstream", "features", "where", "downstream", "is", "determined", "by", "the", "strand", "of", "the", "query", "Feature", "f", "Overlapping", "features", "are", "not", "considered", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L231-L241
train
brentp/cruzdb
cruzdb/intersecter.py
Intersecter.knearest
def knearest(self, f_or_start, end=None, chrom=None, k=1): """return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return """ if end is not None: f = Feature(f_or_start, end, chrom=chrom) else: f = ...
python
def knearest(self, f_or_start, end=None, chrom=None, k=1): """return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return """ if end is not None: f = Feature(f_or_start, end, chrom=chrom) else: f = ...
[ "def", "knearest", "(", "self", ",", "f_or_start", ",", "end", "=", "None", ",", "chrom", "=", "None", ",", "k", "=", "1", ")", ":", "if", "end", "is", "not", "None", ":", "f", "=", "Feature", "(", "f_or_start", ",", "end", ",", "chrom", "=", "...
return the n nearest neighbors to the given feature f: a Feature object k: the number of features to return
[ "return", "the", "n", "nearest", "neighbors", "to", "the", "given", "feature", "f", ":", "a", "Feature", "object", "k", ":", "the", "number", "of", "features", "to", "return" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/intersecter.py#L243-L266
train
brentp/cruzdb
scripts/interval_tree.py
IntervalTree.find
def find(self, start, end): """find all elements between (or overlapping) start and end""" if self.intervals and not end < self.intervals[0].start: overlapping = [i for i in self.intervals if i.end >= start and i.start <= end] else:...
python
def find(self, start, end): """find all elements between (or overlapping) start and end""" if self.intervals and not end < self.intervals[0].start: overlapping = [i for i in self.intervals if i.end >= start and i.start <= end] else:...
[ "def", "find", "(", "self", ",", "start", ",", "end", ")", ":", "if", "self", ".", "intervals", "and", "not", "end", "<", "self", ".", "intervals", "[", "0", "]", ".", "start", ":", "overlapping", "=", "[", "i", "for", "i", "in", "self", ".", "...
find all elements between (or overlapping) start and end
[ "find", "all", "elements", "between", "(", "or", "overlapping", ")", "start", "and", "end" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/scripts/interval_tree.py#L77-L91
train
brentp/cruzdb
cruzdb/sequence.py
sequence
def sequence(db, chrom, start, end): """ return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag' """...
python
def sequence(db, chrom, start, end): """ return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag' """...
[ "def", "sequence", "(", "db", ",", "chrom", ",", "start", ",", "end", ")", ":", "url", "=", "\"http://genome.ucsc.edu/cgi-bin/das/%s\"", "%", "db", "url", "+=", "\"/dna?segment=%s:%i,%i\"", "xml", "=", "U", ".", "urlopen", "(", "url", "%", "(", "chrom", ",...
return the sequence for a region using the UCSC DAS server. note the start is 1-based each feature will have it's own .sequence method which sends the correct start and end to this function. >>> sequence('hg18', 'chr2', 2223, 2230) 'caacttag'
[ "return", "the", "sequence", "for", "a", "region", "using", "the", "UCSC", "DAS", "server", ".", "note", "the", "start", "is", "1", "-", "based", "each", "feature", "will", "have", "it", "s", "own", ".", "sequence", "method", "which", "sends", "the", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sequence.py#L10-L23
train
brentp/cruzdb
cruzdb/mirror.py
set_table
def set_table(genome, table, table_name, connection_string, metadata): """ alter the table to work between different dialects """ table = Table(table_name, genome._metadata, autoload=True, autoload_with=genome.bind, extend_existing=True) #print "\t".join([c.name for c in tab...
python
def set_table(genome, table, table_name, connection_string, metadata): """ alter the table to work between different dialects """ table = Table(table_name, genome._metadata, autoload=True, autoload_with=genome.bind, extend_existing=True) #print "\t".join([c.name for c in tab...
[ "def", "set_table", "(", "genome", ",", "table", ",", "table_name", ",", "connection_string", ",", "metadata", ")", ":", "table", "=", "Table", "(", "table_name", ",", "genome", ".", "_metadata", ",", "autoload", "=", "True", ",", "autoload_with", "=", "ge...
alter the table to work between different dialects
[ "alter", "the", "table", "to", "work", "between", "different", "dialects" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/mirror.py#L39-L80
train
brentp/cruzdb
cruzdb/__init__.py
Genome.create_url
def create_url(self, db="", user="genome", host="genome-mysql.cse.ucsc.edu", password="", dialect="mysqldb"): """ internal: create a dburl from a set of parameters or the defaults on this object """ if os.path.exists(db): db = "sqlite:///" + db # Is t...
python
def create_url(self, db="", user="genome", host="genome-mysql.cse.ucsc.edu", password="", dialect="mysqldb"): """ internal: create a dburl from a set of parameters or the defaults on this object """ if os.path.exists(db): db = "sqlite:///" + db # Is t...
[ "def", "create_url", "(", "self", ",", "db", "=", "\"\"", ",", "user", "=", "\"genome\"", ",", "host", "=", "\"genome-mysql.cse.ucsc.edu\"", ",", "password", "=", "\"\"", ",", "dialect", "=", "\"mysqldb\"", ")", ":", "if", "os", ".", "path", ".", "exists...
internal: create a dburl from a set of parameters or the defaults on this object
[ "internal", ":", "create", "a", "dburl", "from", "a", "set", "of", "parameters", "or", "the", "defaults", "on", "this", "object" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L69-L92
train
brentp/cruzdb
cruzdb/__init__.py
Genome.mirror
def mirror(self, tables, dest_url): """ miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db' """ ...
python
def mirror(self, tables, dest_url): """ miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db' """ ...
[ "def", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")", ":", "from", "mirror", "import", "mirror", "return", "mirror", "(", "self", ",", "tables", ",", "dest_url", ")" ]
miror a set of `tables` from `dest_url` Returns a new Genome object Parameters ---------- tables : list an iterable of tables dest_url: str a dburl string, e.g. 'sqlite:///local.db'
[ "miror", "a", "set", "of", "tables", "from", "dest_url" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L94-L110
train
brentp/cruzdb
cruzdb/__init__.py
Genome.dataframe
def dataframe(self, table): """ create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset f...
python
def dataframe(self, table): """ create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset f...
[ "def", "dataframe", "(", "self", ",", "table", ")", ":", "from", "pandas", "import", "DataFrame", "if", "isinstance", "(", "table", ",", "six", ".", "string_types", ")", ":", "table", "=", "getattr", "(", "self", ",", "table", ")", "try", ":", "rec", ...
create a pandas dataframe from a table or query Parameters ---------- table : table a table in this database or a query limit: integer an integer limit on the query offset: integer an offset for the query
[ "create", "a", "pandas", "dataframe", "from", "a", "table", "or", "query" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L112-L140
train
brentp/cruzdb
cruzdb/__init__.py
Genome.load_file
def load_file(self, fname, table=None, sep="\t", bins=False, indexes=None): """ use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file t...
python
def load_file(self, fname, table=None, sep="\t", bins=False, indexes=None): """ use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file t...
[ "def", "load_file", "(", "self", ",", "fname", ",", "table", "=", "None", ",", "sep", "=", "\"\\t\"", ",", "bins", "=", "False", ",", "indexes", "=", "None", ")", ":", "convs", "=", "{", "\"#chr\"", ":", "\"chrom\"", ",", "\"start\"", ":", "\"txStart...
use some of the machinery in pandas to load a file into a table Parameters ---------- fname : str filename or filehandle to load table : str table to load the file to sep : str CSV separator bins : bool add a "bin" colu...
[ "use", "some", "of", "the", "machinery", "in", "pandas", "to", "load", "a", "file", "into", "a", "table" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L146-L228
train
brentp/cruzdb
cruzdb/__init__.py
Genome.david_go
def david_go(refseq_list, annot=('SP_PIR_KEYWORDS', 'GOTERM_BP_FAT', 'GOTERM_CC_FAT', 'GOTERM_MF_FAT')): """ open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names ...
python
def david_go(refseq_list, annot=('SP_PIR_KEYWORDS', 'GOTERM_BP_FAT', 'GOTERM_CC_FAT', 'GOTERM_MF_FAT')): """ open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names ...
[ "def", "david_go", "(", "refseq_list", ",", "annot", "=", "(", "'SP_PIR_KEYWORDS'", ",", "'GOTERM_BP_FAT'", ",", "'GOTERM_CC_FAT'", ",", "'GOTERM_MF_FAT'", ")", ")", ":", "URL", "=", "\"http://david.abcc.ncifcrf.gov/api.jsp?type=REFSEQ_MRNA&ids=%s&tool=term2term&annot=\"", ...
open a web-browser to the DAVID online enrichment tool Parameters ---------- refseq_list : list list of refseq names to check for enrichment annot : list iterable of DAVID annotations to check for enrichment
[ "open", "a", "web", "-", "browser", "to", "the", "DAVID", "online", "enrichment", "tool" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L231-L248
train
brentp/cruzdb
cruzdb/__init__.py
Genome.bin_query
def bin_query(self, table, chrom, start, end): """ perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table tabl...
python
def bin_query(self, table, chrom, start, end): """ perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table tabl...
[ "def", "bin_query", "(", "self", ",", "table", ",", "chrom", ",", "start", ",", "end", ")", ":", "if", "isinstance", "(", "table", ",", "six", ".", "string_types", ")", ":", "table", "=", "getattr", "(", "self", ",", "table", ")", "try", ":", "tbl"...
perform an efficient spatial query using the bin column if available. The possible bins are calculated from the `start` and `end` sent to this function. Parameters ---------- table : str or table table to query chrom : str chromosome for the query...
[ "perform", "an", "efficient", "spatial", "query", "using", "the", "bin", "column", "if", "available", ".", "The", "possible", "bins", "are", "calculated", "from", "the", "start", "and", "end", "sent", "to", "this", "function", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L250-L289
train
brentp/cruzdb
cruzdb/__init__.py
Genome.upstream
def upstream(self, table, chrom_or_feat, start=None, end=None, k=1): """ Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a...
python
def upstream(self, table, chrom_or_feat, start=None, end=None, k=1): """ Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a...
[ "def", "upstream", "(", "self", ",", "table", ",", "chrom_or_feat", ",", "start", "=", "None", ",", "end", "=", "None", ",", "k", "=", "1", ")", ":", "res", "=", "self", ".", "knearest", "(", "table", ",", "chrom_or_feat", ",", "start", ",", "end",...
Return k-nearest upstream features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a feature with .chrom, .start, .end attributes start : int ...
[ "Return", "k", "-", "nearest", "upstream", "features" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L291-L321
train
brentp/cruzdb
cruzdb/__init__.py
Genome.knearest
def knearest(self, table, chrom_or_feat, start=None, end=None, k=1, _direction=None): """ Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromoso...
python
def knearest(self, table, chrom_or_feat, start=None, end=None, k=1, _direction=None): """ Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromoso...
[ "def", "knearest", "(", "self", ",", "table", ",", "chrom_or_feat", ",", "start", "=", "None", ",", "end", "=", "None", ",", "k", "=", "1", ",", "_direction", "=", "None", ")", ":", "assert", "_direction", "in", "(", "None", ",", "\"up\"", ",", "\"...
Return k-nearest features Parameters ---------- table : str or table table against which to query chrom_or_feat : str or feat either a chromosome, e.g. 'chr3' or a feature with .chrom, .start, .end attributes start : int if `chr...
[ "Return", "k", "-", "nearest", "features" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L355-L441
train
brentp/cruzdb
cruzdb/__init__.py
Genome.annotate
def annotate(self, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, parallel=False): """ annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list ...
python
def annotate(self, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, parallel=False): """ annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list ...
[ "def", "annotate", "(", "self", ",", "fname", ",", "tables", ",", "feature_strand", "=", "False", ",", "in_memory", "=", "False", ",", "header", "=", "None", ",", "out", "=", "sys", ".", "stdout", ",", "parallel", "=", "False", ")", ":", "from", ".",...
annotate a file with a number of tables Parameters ---------- fname : str or file file name or file-handle tables : list list of tables with which to annotate `fname` feature_strand : bool if this is True, then the up/downstream designations...
[ "annotate", "a", "file", "with", "a", "number", "of", "tables" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L449-L484
train
brentp/cruzdb
cruzdb/__init__.py
Genome.bins
def bins(start, end): """ Get all the bin numbers for a particular interval defined by (start, end] """ if end - start < 536870912: offsets = [585, 73, 9, 1] else: raise BigException offsets = [4681, 585, 73, 9, 1] binFirstShift...
python
def bins(start, end): """ Get all the bin numbers for a particular interval defined by (start, end] """ if end - start < 536870912: offsets = [585, 73, 9, 1] else: raise BigException offsets = [4681, 585, 73, 9, 1] binFirstShift...
[ "def", "bins", "(", "start", ",", "end", ")", ":", "if", "end", "-", "start", "<", "536870912", ":", "offsets", "=", "[", "585", ",", "73", ",", "9", ",", "1", "]", "else", ":", "raise", "BigException", "offsets", "=", "[", "4681", ",", "585", ...
Get all the bin numbers for a particular interval defined by (start, end]
[ "Get", "all", "the", "bin", "numbers", "for", "a", "particular", "interval", "defined", "by", "(", "start", "end", "]" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L487-L508
train
brentp/cruzdb
cruzdb/__init__.py
Genome.save_bed
def save_bed(cls, query, filename=sys.stdout): """ write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output """ out = _open(filename...
python
def save_bed(cls, query, filename=sys.stdout): """ write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output """ out = _open(filename...
[ "def", "save_bed", "(", "cls", ",", "query", ",", "filename", "=", "sys", ".", "stdout", ")", ":", "out", "=", "_open", "(", "filename", ",", "'w'", ")", "for", "o", "in", "query", ":", "out", ".", "write", "(", "o", ".", "bed", "(", ")", "+", ...
write a bed12 file of the query. Parameters ---------- query : query a table or query to save to file filename : file string or filehandle to write output
[ "write", "a", "bed12", "file", "of", "the", "query", ".", "Parameters", "----------" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/__init__.py#L514-L528
train
peterbe/django-static
django_static/templatetags/django_static.py
staticfile_node
def staticfile_node(parser, token, optimize_if_possible=False): """For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as varia...
python
def staticfile_node(parser, token, optimize_if_possible=False): """For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as varia...
[ "def", "staticfile_node", "(", "parser", ",", "token", ",", "optimize_if_possible", "=", "False", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "tag", "=", "args", "[", "0", "]", "if", "len", "(", "args", ")", "==", "4", "and", "ar...
For example: {% staticfile "/js/foo.js" %} or {% staticfile "/js/foo.js" as variable_name %} Or for multiples: {% staticfile "/foo.js; /bar.js" %} or {% staticfile "/foo.js; /bar.js" as variable_name %}
[ "For", "example", ":", "{", "%", "staticfile", "/", "js", "/", "foo", ".", "js", "%", "}", "or", "{", "%", "staticfile", "/", "js", "/", "foo", ".", "js", "as", "variable_name", "%", "}", "Or", "for", "multiples", ":", "{", "%", "staticfile", "/"...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L185-L209
train
peterbe/django-static
django_static/templatetags/django_static.py
_mkdir
def _mkdir(newdir): """works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well """ if os.path.isdir(newdir): pass elif os.path.isfile(newdir): ...
python
def _mkdir(newdir): """works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well """ if os.path.isdir(newdir): pass elif os.path.isfile(newdir): ...
[ "def", "_mkdir", "(", "newdir", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "newdir", ")", ":", "pass", "elif", "os", ".", "path", ".", "isfile", "(", "newdir", ")", ":", "raise", "OSError", "(", "\"a file with the same name as the desired \"", ...
works the way a good mkdir should :) - already exists, silently complete - regular file in the way, raise an exception - parent directory(ies) does not exist, make them as well
[ "works", "the", "way", "a", "good", "mkdir", "should", ":", ")", "-", "already", "exists", "silently", "complete", "-", "regular", "file", "in", "the", "way", "raise", "an", "exception", "-", "parent", "directory", "(", "ies", ")", "does", "not", "exist"...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L641-L657
train
peterbe/django-static
django_static/templatetags/django_static.py
_find_filepath_in_roots
def _find_filepath_in_roots(filename): """Look for filename in all MEDIA_ROOTS, and return the first one found.""" for root in settings.DJANGO_STATIC_MEDIA_ROOTS: filepath = _filename2filepath(filename, root) if os.path.isfile(filepath): return filepath, root # havent found it in...
python
def _find_filepath_in_roots(filename): """Look for filename in all MEDIA_ROOTS, and return the first one found.""" for root in settings.DJANGO_STATIC_MEDIA_ROOTS: filepath = _filename2filepath(filename, root) if os.path.isfile(filepath): return filepath, root # havent found it in...
[ "def", "_find_filepath_in_roots", "(", "filename", ")", ":", "for", "root", "in", "settings", ".", "DJANGO_STATIC_MEDIA_ROOTS", ":", "filepath", "=", "_filename2filepath", "(", "filename", ",", "root", ")", "if", "os", ".", "path", ".", "isfile", "(", "filepat...
Look for filename in all MEDIA_ROOTS, and return the first one found.
[ "Look", "for", "filename", "in", "all", "MEDIA_ROOTS", "and", "return", "the", "first", "one", "found", "." ]
05c0d2f302274b9d3f7df6ad92bd861889316ebd
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L660-L677
train
peterbe/django-static
django_static/templatetags/django_static.py
default_combine_filenames_generator
def default_combine_filenames_generator(filenames, max_length=40): """Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. ...
python
def default_combine_filenames_generator(filenames, max_length=40): """Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. ...
[ "def", "default_combine_filenames_generator", "(", "filenames", ",", "max_length", "=", "40", ")", ":", "path", "=", "None", "names", "=", "[", "]", "extension", "=", "None", "timestamps", "=", "[", "]", "for", "filename", "in", "filenames", ":", "name", "...
Return a new filename to use as the combined file name for a bunch of files. A precondition is that they all have the same file extension Given that the list of files can have different paths, we aim to use the most common path. Example: /somewhere/else/foo.js /somewhere/bar.js /...
[ "Return", "a", "new", "filename", "to", "use", "as", "the", "combined", "file", "name", "for", "a", "bunch", "of", "files", ".", "A", "precondition", "is", "that", "they", "all", "have", "the", "same", "file", "extension" ]
05c0d2f302274b9d3f7df6ad92bd861889316ebd
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L695-L745
train
peterbe/django-static
django_static/templatetags/django_static.py
StaticFilesNode.render
def render(self, context): """inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: ...
python
def render(self, context): """inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: ...
[ "def", "render", "(", "self", ",", "context", ")", ":", "code", "=", "self", ".", "nodelist", ".", "render", "(", "context", ")", "if", "not", "settings", ".", "DJANGO_STATIC", ":", "# Append MEDIA_URL if set", "# quick and dirty", "if", "settings", ".", "DJ...
inspect the code and look for files that can be turned into combos. Basically, the developer could type this: {% slimall %} <link href="/one.css"/> <link href="/two.css"/> {% endslimall %} And it should be reconsidered like this: <link href="{% slimfile "/on...
[ "inspect", "the", "code", "and", "look", "for", "files", "that", "can", "be", "turned", "into", "combos", ".", "Basically", "the", "developer", "could", "type", "this", ":", "{", "%", "slimall", "%", "}", "<link", "href", "=", "/", "one", ".", "css", ...
05c0d2f302274b9d3f7df6ad92bd861889316ebd
https://github.com/peterbe/django-static/blob/05c0d2f302274b9d3f7df6ad92bd861889316ebd/django_static/templatetags/django_static.py#L276-L385
train
brentp/cruzdb
cruzdb/models.py
Interval.overlaps
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
python
def overlaps(self, other): """ check for overlap with the other interval """ if self.chrom != other.chrom: return False if self.start >= other.end: return False if other.start >= self.end: return False return True
[ "def", "overlaps", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "False", "if", "self", ".", "start", ">=", "other", ".", "end", ":", "return", "False", "if", "other", ".", "start", ">=...
check for overlap with the other interval
[ "check", "for", "overlap", "with", "the", "other", "interval" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L81-L88
train
brentp/cruzdb
cruzdb/models.py
Interval.is_upstream_of
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
python
def is_upstream_of(self, other): """ check if this is upstream of the `other` interval taking the strand of the other interval into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "+": return self.end <= other.start ...
[ "def", "is_upstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "return", "self", "....
check if this is upstream of the `other` interval taking the strand of the other interval into account
[ "check", "if", "this", "is", "upstream", "of", "the", "other", "interval", "taking", "the", "strand", "of", "the", "other", "interval", "into", "account" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L90-L99
train
brentp/cruzdb
cruzdb/models.py
Interval.distance
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
python
def distance(self, other_or_start=None, end=None, features=False): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start ...
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "False", ")", ":", "if", "end", "is", "None", ":", "assert", "other_or_start", ".", "chrom", "==", "self", ".", "chrom", "other_start", "...
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L101-L128
train
brentp/cruzdb
cruzdb/models.py
ABase.exons
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
python
def exons(self): """ return a list of exons [(start, stop)] for this object if appropriate """ # drop the trailing comma if not self.is_gene_pred: return [] if hasattr(self, "exonStarts"): try: starts = (long(s) for s in self.exonStarts[:-1].sp...
[ "def", "exons", "(", "self", ")", ":", "# drop the trailing comma", "if", "not", "self", ".", "is_gene_pred", ":", "return", "[", "]", "if", "hasattr", "(", "self", ",", "\"exonStarts\"", ")", ":", "try", ":", "starts", "=", "(", "long", "(", "s", ")",...
return a list of exons [(start, stop)] for this object if appropriate
[ "return", "a", "list", "of", "exons", "[", "(", "start", "stop", ")", "]", "for", "this", "object", "if", "appropriate" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L160-L180
train
brentp/cruzdb
cruzdb/models.py
ABase.gene_features
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
python
def gene_features(self): """ return a list of features for the gene features of this object. This would include exons, introns, utrs, etc. """ nm, strand = self.gene_name, self.strand feats = [(self.chrom, self.start, self.end, nm, strand, 'gene')] for feat in ('i...
[ "def", "gene_features", "(", "self", ")", ":", "nm", ",", "strand", "=", "self", ".", "gene_name", ",", "self", ".", "strand", "feats", "=", "[", "(", "self", ".", "chrom", ",", "self", ".", "start", ",", "self", ".", "end", ",", "nm", ",", "stra...
return a list of features for the gene features of this object. This would include exons, introns, utrs, etc.
[ "return", "a", "list", "of", "features", "for", "the", "gene", "features", "of", "this", "object", ".", "This", "would", "include", "exons", "introns", "utrs", "etc", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L183-L203
train
brentp/cruzdb
cruzdb/models.py
ABase.tss
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
python
def tss(self, up=0, down=0): """ Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction ...
[ "def", "tss", "(", "self", ",", "up", "=", "0", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "tss", "=", "self", ".", "txEnd", "if", "self", ".", "strand", "==", "'-'", "else", "self", ".", "...
Return a start, end tuple of positions around the transcription-start site Parameters ---------- up : int if greature than 0, the strand is used to add this many upstream bases in the appropriate direction down : int if greature than 0, the str...
[ "Return", "a", "start", "end", "tuple", "of", "positions", "around", "the", "transcription", "-", "start", "site" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L205-L231
train
brentp/cruzdb
cruzdb/models.py
ABase.promoter
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
python
def promoter(self, up=2000, down=0): """ Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add...
[ "def", "promoter", "(", "self", ",", "up", "=", "2000", ",", "down", "=", "0", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "return", "None", "return", "self", ".", "tss", "(", "up", "=", "up", ",", "down", "=", "down", ")" ]
Return a start, end tuple of positions for the promoter region of this gene Parameters ---------- up : int this distance upstream that is considered the promoter down : int the strand is used to add this many downstream bases into the gene.
[ "Return", "a", "start", "end", "tuple", "of", "positions", "for", "the", "promoter", "region", "of", "this", "gene" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L233-L248
train
brentp/cruzdb
cruzdb/models.py
ABase.coding_exons
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
python
def coding_exons(self): """ includes the entire exon as long as any of it is > cdsStart and < cdsEnd """ # drop the trailing comma starts = (long(s) for s in self.exonStarts[:-1].split(",")) ends = (long(s) for s in self.exonEnds[:-1].split(",")) return [(...
[ "def", "coding_exons", "(", "self", ")", ":", "# drop the trailing comma", "starts", "=", "(", "long", "(", "s", ")", "for", "s", "in", "self", ".", "exonStarts", "[", ":", "-", "1", "]", ".", "split", "(", "\",\"", ")", ")", "ends", "=", "(", "lon...
includes the entire exon as long as any of it is > cdsStart and < cdsEnd
[ "includes", "the", "entire", "exon", "as", "long", "as", "any", "of", "it", "is", ">", "cdsStart", "and", "<", "cdsEnd" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L251-L261
train
brentp/cruzdb
cruzdb/models.py
ABase.cds
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
python
def cds(self): """just the parts of the exons that are translated""" ces = self.coding_exons if len(ces) < 1: return ces ces[0] = (self.cdsStart, ces[0][1]) ces[-1] = (ces[-1][0], self.cdsEnd) assert all((s < e for s, e in ces)) return ces
[ "def", "cds", "(", "self", ")", ":", "ces", "=", "self", ".", "coding_exons", "if", "len", "(", "ces", ")", "<", "1", ":", "return", "ces", "ces", "[", "0", "]", "=", "(", "self", ".", "cdsStart", ",", "ces", "[", "0", "]", "[", "1", "]", "...
just the parts of the exons that are translated
[ "just", "the", "parts", "of", "the", "exons", "that", "are", "translated" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L264-L271
train
brentp/cruzdb
cruzdb/models.py
ABase.is_downstream_of
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
python
def is_downstream_of(self, other): """ return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account """ if self.chrom != other.chrom: return None if getattr(other, "strand", None) == "-": # other feature is ...
[ "def", "is_downstream_of", "(", "self", ",", "other", ")", ":", "if", "self", ".", "chrom", "!=", "other", ".", "chrom", ":", "return", "None", "if", "getattr", "(", "other", ",", "\"strand\"", ",", "None", ")", "==", "\"-\"", ":", "# other feature is on...
return a boolean indicating whether this feature is downstream of `other` taking the strand of other into account
[ "return", "a", "boolean", "indicating", "whether", "this", "feature", "is", "downstream", "of", "other", "taking", "the", "strand", "of", "other", "into", "account" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L348-L357
train
brentp/cruzdb
cruzdb/models.py
ABase.features
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
python
def features(self, other_start, other_end): """ return e.g. "intron;exon" if the other_start, end overlap introns and exons """ # completely encases gene. if other_start <= self.start and other_end >= self.end: return ['gene' if self.cdsStart != self.cdsEnd el...
[ "def", "features", "(", "self", ",", "other_start", ",", "other_end", ")", ":", "# completely encases gene.", "if", "other_start", "<=", "self", ".", "start", "and", "other_end", ">=", "self", ".", "end", ":", "return", "[", "'gene'", "if", "self", ".", "c...
return e.g. "intron;exon" if the other_start, end overlap introns and exons
[ "return", "e", ".", "g", ".", "intron", ";", "exon", "if", "the", "other_start", "end", "overlap", "introns", "and", "exons" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L359-L382
train
brentp/cruzdb
cruzdb/models.py
ABase.upstream
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
python
def upstream(self, distance): """ return the (start, end) of the region before the geneStart """ if getattr(self, "strand", None) == "+": e = self.start s = e - distance else: s = self.end e = s + distance return self._xstre...
[ "def", "upstream", "(", "self", ",", "distance", ")", ":", "if", "getattr", "(", "self", ",", "\"strand\"", ",", "None", ")", "==", "\"+\"", ":", "e", "=", "self", ".", "start", "s", "=", "e", "-", "distance", "else", ":", "s", "=", "self", ".", ...
return the (start, end) of the region before the geneStart
[ "return", "the", "(", "start", "end", ")", "of", "the", "region", "before", "the", "geneStart" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L414-L424
train
brentp/cruzdb
cruzdb/models.py
ABase.utr5
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
python
def utr5(self): """ return the 5' UTR if appropriate """ if not self.is_coding or len(self.exons) < 2: return (None, None) if self.strand == "+": s, e = (self.txStart, self.cdsStart) else: s, e = (self.cdsEnd, self.txEnd) if s == e: return ...
[ "def", "utr5", "(", "self", ")", ":", "if", "not", "self", ".", "is_coding", "or", "len", "(", "self", ".", "exons", ")", "<", "2", ":", "return", "(", "None", ",", "None", ")", "if", "self", ".", "strand", "==", "\"+\"", ":", "s", ",", "e", ...
return the 5' UTR if appropriate
[ "return", "the", "5", "UTR", "if", "appropriate" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L439-L449
train
brentp/cruzdb
cruzdb/models.py
ABase.sequence
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
python
def sequence(self, per_exon=False): """ Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented """ db = self.db if not per_exon: start = self.txStart + 1 retu...
[ "def", "sequence", "(", "self", ",", "per_exon", "=", "False", ")", ":", "db", "=", "self", ".", "db", "if", "not", "per_exon", ":", "start", "=", "self", ".", "txStart", "+", "1", "return", "_sequence", "(", "db", ",", "self", ".", "chrom", ",", ...
Return the sequence for this feature. if per-exon is True, return an array of exon sequences This sequence is never reverse complemented
[ "Return", "the", "sequence", "for", "this", "feature", ".", "if", "per", "-", "exon", "is", "True", "return", "an", "array", "of", "exon", "sequences", "This", "sequence", "is", "never", "reverse", "complemented" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L527-L542
train
brentp/cruzdb
cruzdb/models.py
ABase.ncbi_blast
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
python
def ncbi_blast(self, db="nr", megablast=True, sequence=None): """ perform an NCBI blast against the sequence of this feature """ import requests requests.defaults.max_retries = 4 assert sequence in (None, "cds", "mrna") seq = self.sequence() if sequence is None el...
[ "def", "ncbi_blast", "(", "self", ",", "db", "=", "\"nr\"", ",", "megablast", "=", "True", ",", "sequence", "=", "None", ")", ":", "import", "requests", "requests", ".", "defaults", ".", "max_retries", "=", "4", "assert", "sequence", "in", "(", "None", ...
perform an NCBI blast against the sequence of this feature
[ "perform", "an", "NCBI", "blast", "against", "the", "sequence", "of", "this", "feature" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L548-L591
train
brentp/cruzdb
cruzdb/models.py
ABase.blat
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
python
def blat(self, db=None, sequence=None, seq_type="DNA"): """ make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence. """ from . blat_blast import blat, blat_all assert se...
[ "def", "blat", "(", "self", ",", "db", "=", "None", ",", "sequence", "=", "None", ",", "seq_type", "=", "\"DNA\"", ")", ":", "from", ".", "blat_blast", "import", "blat", ",", "blat_all", "assert", "sequence", "in", "(", "None", ",", "\"cds\"", ",", "...
make a request to the genome-browsers BLAT interface sequence is one of None, "mrna", "cds" returns a list of features that are hits to this sequence.
[ "make", "a", "request", "to", "the", "genome", "-", "browsers", "BLAT", "interface", "sequence", "is", "one", "of", "None", "mrna", "cds", "returns", "a", "list", "of", "features", "that", "are", "hits", "to", "this", "sequence", "." ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L593-L605
train
brentp/cruzdb
cruzdb/models.py
ABase.bed
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
python
def bed(self, *attrs, **kwargs): """ return a bed formatted string of this feature """ exclude = ("chrom", "start", "end", "txStart", "txEnd", "chromStart", "chromEnd") if self.is_gene_pred: return self.bed12(**kwargs) return "\t".join(map(str,...
[ "def", "bed", "(", "self", ",", "*", "attrs", ",", "*", "*", "kwargs", ")", ":", "exclude", "=", "(", "\"chrom\"", ",", "\"start\"", ",", "\"end\"", ",", "\"txStart\"", ",", "\"txEnd\"", ",", "\"chromStart\"", ",", "\"chromEnd\"", ")", "if", "self", "....
return a bed formatted string of this feature
[ "return", "a", "bed", "formatted", "string", "of", "this", "feature" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L614-L625
train
brentp/cruzdb
cruzdb/models.py
ABase.bed12
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
python
def bed12(self, score="0", rgb="."): """ return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval """ if not self.is_gene_pred: raise CruzException("can't create bed12 from non genepred feature") exons = list(self.exon...
[ "def", "bed12", "(", "self", ",", "score", "=", "\"0\"", ",", "rgb", "=", "\".\"", ")", ":", "if", "not", "self", ".", "is_gene_pred", ":", "raise", "CruzException", "(", "\"can't create bed12 from non genepred feature\"", ")", "exons", "=", "list", "(", "se...
return a bed12 (http://genome.ucsc.edu/FAQ/FAQformat.html#format1) representation of this interval
[ "return", "a", "bed12", "(", "http", ":", "//", "genome", ".", "ucsc", ".", "edu", "/", "FAQ", "/", "FAQformat", ".", "html#format1", ")", "representation", "of", "this", "interval" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L628-L644
train
brentp/cruzdb
cruzdb/models.py
ABase.localize
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
python
def localize(self, *positions, **kwargs): """ convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg """ cdna = kwargs.get('cdna', False) # TODO: account for strand ?? add kwarg ?? # if it's to the CDNA, the...
[ "def", "localize", "(", "self", ",", "*", "positions", ",", "*", "*", "kwargs", ")", ":", "cdna", "=", "kwargs", ".", "get", "(", "'cdna'", ",", "False", ")", "# TODO: account for strand ?? add kwarg ??", "# if it's to the CDNA, then it's based on the cdsStart", "st...
convert global coordinate(s) to local taking introns into account and cds/tx-Start depending on cdna=True kwarg
[ "convert", "global", "coordinate", "(", "s", ")", "to", "local", "taking", "introns", "into", "account", "and", "cds", "/", "tx", "-", "Start", "depending", "on", "cdna", "=", "True", "kwarg" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L665-L709
train
brentp/cruzdb
cruzdb/models.py
cpgIslandExt.distance
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
python
def distance(self, other_or_start=None, end=None, features="unused", shore_dist=3000): """ check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute i...
[ "def", "distance", "(", "self", ",", "other_or_start", "=", "None", ",", "end", "=", "None", ",", "features", "=", "\"unused\"", ",", "shore_dist", "=", "3000", ")", ":", "# leave features kwarg to match signature from Feature.distance", "if", "end", "is", "None",...
check the distance between this an another interval Parameters ---------- other_or_start : Interval or int either an integer or an Interval with a start attribute indicating the start of the interval end : int if `other_or_start` is an integer, this ...
[ "check", "the", "distance", "between", "this", "an", "another", "interval", "Parameters", "----------" ]
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/models.py#L725-L758
train
brentp/cruzdb
cruzdb/annotate.py
annotate
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
python
def annotate(g, fname, tables, feature_strand=False, in_memory=False, header=None, out=sys.stdout, _chrom=None, parallel=False): """ annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a stran...
[ "def", "annotate", "(", "g", ",", "fname", ",", "tables", ",", "feature_strand", "=", "False", ",", "in_memory", "=", "False", ",", "header", "=", "None", ",", "out", "=", "sys", ".", "stdout", ",", "_chrom", "=", "None", ",", "parallel", "=", "False...
annotate bed file in fname with tables. distances are integers for distance. and intron/exon/utr5 etc for gene-pred tables. if the annotation features have a strand, the distance reported is negative if the annotation feature is upstream of the feature in question if feature_strand is True, then the dis...
[ "annotate", "bed", "file", "in", "fname", "with", "tables", ".", "distances", "are", "integers", "for", "distance", ".", "and", "intron", "/", "exon", "/", "utr5", "etc", "for", "gene", "-", "pred", "tables", ".", "if", "the", "annotation", "features", "...
9068d46e25952f4a929dde0242beb31fa4c7e89a
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/annotate.py#L28-L171
train
ome/omego
omego/main.py
entry_point
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
python
def entry_point(): """ External entry point which calls main() and if Stop is raised, calls sys.exit() """ try: main("omego", items=[ (InstallCommand.NAME, InstallCommand), (UpgradeCommand.NAME, UpgradeCommand), (ConvertCommand.NAME, ConvertCommand), ...
[ "def", "entry_point", "(", ")", ":", "try", ":", "main", "(", "\"omego\"", ",", "items", "=", "[", "(", "InstallCommand", ".", "NAME", ",", "InstallCommand", ")", ",", "(", "UpgradeCommand", ".", "NAME", ",", "UpgradeCommand", ")", ",", "(", "ConvertComm...
External entry point which calls main() and if Stop is raised, calls sys.exit()
[ "External", "entry", "point", "which", "calls", "main", "()", "and", "if", "Stop", "is", "raised", "calls", "sys", ".", "exit", "()" ]
2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb
https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/main.py#L40-L58
train