repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
llllllllll/codetransformer
codetransformer/transformers/interpolated_strings.py
interpolated_strings.transform_stringlike
def transform_stringlike(self, const): """ Yield instructions to process a str or bytes constant. """ yield LOAD_CONST(const) if isinstance(const, bytes): yield from self.bytes_instrs elif isinstance(const, str): yield from self.str_instrs
python
def transform_stringlike(self, const): """ Yield instructions to process a str or bytes constant. """ yield LOAD_CONST(const) if isinstance(const, bytes): yield from self.bytes_instrs elif isinstance(const, str): yield from self.str_instrs
[ "def", "transform_stringlike", "(", "self", ",", "const", ")", ":", "yield", "LOAD_CONST", "(", "const", ")", "if", "isinstance", "(", "const", ",", "bytes", ")", ":", "yield", "from", "self", ".", "bytes_instrs", "elif", "isinstance", "(", "const", ",", ...
Yield instructions to process a str or bytes constant.
[ "Yield", "instructions", "to", "process", "a", "str", "or", "bytes", "constant", "." ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/transformers/interpolated_strings.py#L109-L117
llllllllll/codetransformer
codetransformer/instructions.py
_mk_call_init
def _mk_call_init(class_): """Create an __init__ function for a call type instruction. Parameters ---------- class_ : type The type to bind the function to. Returns ------- __init__ : callable The __init__ method for the class. """ def __init__(self, packed=no_defau...
python
def _mk_call_init(class_): """Create an __init__ function for a call type instruction. Parameters ---------- class_ : type The type to bind the function to. Returns ------- __init__ : callable The __init__ method for the class. """ def __init__(self, packed=no_defau...
[ "def", "_mk_call_init", "(", "class_", ")", ":", "def", "__init__", "(", "self", ",", "packed", "=", "no_default", ",", "*", ",", "positional", "=", "0", ",", "keyword", "=", "0", ")", ":", "if", "packed", "is", "no_default", ":", "arg", "=", "int", ...
Create an __init__ function for a call type instruction. Parameters ---------- class_ : type The type to bind the function to. Returns ------- __init__ : callable The __init__ method for the class.
[ "Create", "an", "__init__", "function", "for", "a", "call", "type", "instruction", "." ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/instructions.py#L270-L293
llllllllll/codetransformer
codetransformer/instructions.py
Instruction.steal
def steal(self, instr): """Steal the jump index off of `instr`. This makes anything that would have jumped to `instr` jump to this Instruction instead. Parameters ---------- instr : Instruction The instruction to steal the jump sources from. Returns...
python
def steal(self, instr): """Steal the jump index off of `instr`. This makes anything that would have jumped to `instr` jump to this Instruction instead. Parameters ---------- instr : Instruction The instruction to steal the jump sources from. Returns...
[ "def", "steal", "(", "self", ",", "instr", ")", ":", "instr", ".", "_stolen_by", "=", "self", "for", "jmp", "in", "instr", ".", "_target_of", ":", "jmp", ".", "arg", "=", "self", "self", ".", "_target_of", "=", "instr", ".", "_target_of", "instr", "....
Steal the jump index off of `instr`. This makes anything that would have jumped to `instr` jump to this Instruction instead. Parameters ---------- instr : Instruction The instruction to steal the jump sources from. Returns ------- self : Ins...
[ "Steal", "the", "jump", "index", "off", "of", "instr", "." ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/instructions.py#L161-L186
llllllllll/codetransformer
codetransformer/instructions.py
Instruction.from_opcode
def from_opcode(cls, opcode, arg=_no_arg): """ Create an instruction from an opcode and raw argument. Parameters ---------- opcode : int Opcode for the instruction to create. arg : int, optional The argument for the instruction. Returns ...
python
def from_opcode(cls, opcode, arg=_no_arg): """ Create an instruction from an opcode and raw argument. Parameters ---------- opcode : int Opcode for the instruction to create. arg : int, optional The argument for the instruction. Returns ...
[ "def", "from_opcode", "(", "cls", ",", "opcode", ",", "arg", "=", "_no_arg", ")", ":", "return", "type", "(", "cls", ")", "(", "opname", "[", "opcode", "]", ",", "(", "cls", ",", ")", ",", "{", "}", ",", "opcode", "=", "opcode", ")", "(", "arg"...
Create an instruction from an opcode and raw argument. Parameters ---------- opcode : int Opcode for the instruction to create. arg : int, optional The argument for the instruction. Returns ------- intsr : Instruction An insta...
[ "Create", "an", "instruction", "from", "an", "opcode", "and", "raw", "argument", "." ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/instructions.py#L189-L205
llllllllll/codetransformer
codetransformer/instructions.py
Instruction.stack_effect
def stack_effect(self): """ The net effect of executing this instruction on the interpreter stack. Instructions that pop values off the stack have negative stack effect equal to the number of popped values. Instructions that push values onto the stack have positive stack effect...
python
def stack_effect(self): """ The net effect of executing this instruction on the interpreter stack. Instructions that pop values off the stack have negative stack effect equal to the number of popped values. Instructions that push values onto the stack have positive stack effect...
[ "def", "stack_effect", "(", "self", ")", ":", "if", "self", ".", "opcode", "==", "NOP", ".", "opcode", ":", "# noqa", "# dis.stack_effect is broken here", "return", "0", "return", "stack_effect", "(", "self", ".", "opcode", ",", "*", "(", "(", "self", ".",...
The net effect of executing this instruction on the interpreter stack. Instructions that pop values off the stack have negative stack effect equal to the number of popped values. Instructions that push values onto the stack have positive stack effect equal to the number of popped value...
[ "The", "net", "effect", "of", "executing", "this", "instruction", "on", "the", "interpreter", "stack", "." ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/instructions.py#L208-L236
llllllllll/codetransformer
codetransformer/instructions.py
Instruction.equiv
def equiv(self, instr): """Check equivalence of instructions. This checks against the types and the arguments of the instructions Parameters ---------- instr : Instruction The instruction to check against. Returns ------- is_equiv : bool ...
python
def equiv(self, instr): """Check equivalence of instructions. This checks against the types and the arguments of the instructions Parameters ---------- instr : Instruction The instruction to check against. Returns ------- is_equiv : bool ...
[ "def", "equiv", "(", "self", ",", "instr", ")", ":", "return", "type", "(", "self", ")", "==", "type", "(", "instr", ")", "and", "self", ".", "arg", "==", "instr", ".", "arg" ]
Check equivalence of instructions. This checks against the types and the arguments of the instructions Parameters ---------- instr : Instruction The instruction to check against. Returns ------- is_equiv : bool If the instructions are equ...
[ "Check", "equivalence", "of", "instructions", ".", "This", "checks", "against", "the", "types", "and", "the", "arguments", "of", "the", "instructions" ]
train
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/instructions.py#L238-L259
jedie/DragonPy
boot_dragonpy.py
create_environment
def create_environment(home_dir, site_packages=False, clear=False, unzip_setuptools=False, prompt=None, search_dirs=None, download=False, no_setuptools=False, no_pip=False, no_wheel=False, symlink=True): """ Creates a ne...
python
def create_environment(home_dir, site_packages=False, clear=False, unzip_setuptools=False, prompt=None, search_dirs=None, download=False, no_setuptools=False, no_pip=False, no_wheel=False, symlink=True): """ Creates a ne...
[ "def", "create_environment", "(", "home_dir", ",", "site_packages", "=", "False", ",", "clear", "=", "False", ",", "unzip_setuptools", "=", "False", ",", "prompt", "=", "None", ",", "search_dirs", "=", "None", ",", "download", "=", "False", ",", "no_setuptoo...
Creates a new environment in ``home_dir``. If ``site_packages`` is true, then the global ``site-packages/`` directory will be on the path. If ``clear`` is true (default False) then the environment will first be cleared.
[ "Creates", "a", "new", "environment", "in", "home_dir", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L913-L956
jedie/DragonPy
boot_dragonpy.py
path_locations
def path_locations(home_dir): """Return the path locations for the environment (where libraries are, where scripts go, etc)""" home_dir = os.path.abspath(home_dir) # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its # prefix arg is broken: http://bugs.python.org/issue3386 if is_win: ...
python
def path_locations(home_dir): """Return the path locations for the environment (where libraries are, where scripts go, etc)""" home_dir = os.path.abspath(home_dir) # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its # prefix arg is broken: http://bugs.python.org/issue3386 if is_win: ...
[ "def", "path_locations", "(", "home_dir", ")", ":", "home_dir", "=", "os", ".", "path", ".", "abspath", "(", "home_dir", ")", "# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its", "# prefix arg is broken: http://bugs.python.org/issue3386", "if", "is_win", ":", "...
Return the path locations for the environment (where libraries are, where scripts go, etc)
[ "Return", "the", "path", "locations", "for", "the", "environment", "(", "where", "libraries", "are", "where", "scripts", "go", "etc", ")" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L961-L1003
jedie/DragonPy
boot_dragonpy.py
copy_tcltk
def copy_tcltk(src, dest, symlink): """ copy tcl/tk libraries on Windows (issue #93) """ if majver == 2: libver = '8.5' else: libver = '8.6' for name in ['tcl', 'tk']: srcdir = src + '/tcl/' + name + libver dstdir = dest + '/tcl/' + name + libver copyfileordir(src...
python
def copy_tcltk(src, dest, symlink): """ copy tcl/tk libraries on Windows (issue #93) """ if majver == 2: libver = '8.5' else: libver = '8.6' for name in ['tcl', 'tk']: srcdir = src + '/tcl/' + name + libver dstdir = dest + '/tcl/' + name + libver copyfileordir(src...
[ "def", "copy_tcltk", "(", "src", ",", "dest", ",", "symlink", ")", ":", "if", "majver", "==", "2", ":", "libver", "=", "'8.5'", "else", ":", "libver", "=", "'8.6'", "for", "name", "in", "[", "'tcl'", ",", "'tk'", "]", ":", "srcdir", "=", "src", "...
copy tcl/tk libraries on Windows (issue #93)
[ "copy", "tcl", "/", "tk", "libraries", "on", "Windows", "(", "issue", "#93", ")" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L1075-L1084
jedie/DragonPy
boot_dragonpy.py
install_python
def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, symlink=True): """Install just the base environment, no distutils patches etc""" if sys.executable.startswith(bin_dir): print('Please use the *system* python to run this script') return if clear: rmtree(li...
python
def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, symlink=True): """Install just the base environment, no distutils patches etc""" if sys.executable.startswith(bin_dir): print('Please use the *system* python to run this script') return if clear: rmtree(li...
[ "def", "install_python", "(", "home_dir", ",", "lib_dir", ",", "inc_dir", ",", "bin_dir", ",", "site_packages", ",", "clear", ",", "symlink", "=", "True", ")", ":", "if", "sys", ".", "executable", ".", "startswith", "(", "bin_dir", ")", ":", "print", "("...
Install just the base environment, no distutils patches etc
[ "Install", "just", "the", "base", "environment", "no", "distutils", "patches", "etc" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L1096-L1438
jedie/DragonPy
boot_dragonpy.py
fix_lib64
def fix_lib64(lib_dir, symlink=True): """ Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y instead of lib/pythonX.Y. If this is such a platform we'll just create a symlink so lib64 points to lib """ # PyPy's library path scheme is not affected by this. # Return earl...
python
def fix_lib64(lib_dir, symlink=True): """ Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y instead of lib/pythonX.Y. If this is such a platform we'll just create a symlink so lib64 points to lib """ # PyPy's library path scheme is not affected by this. # Return earl...
[ "def", "fix_lib64", "(", "lib_dir", ",", "symlink", "=", "True", ")", ":", "# PyPy's library path scheme is not affected by this.", "# Return early or we will die on the following assert.", "if", "is_pypy", ":", "logger", ".", "debug", "(", "'PyPy detected, skipping lib64 symli...
Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y instead of lib/pythonX.Y. If this is such a platform we'll just create a symlink so lib64 points to lib
[ "Some", "platforms", "(", "particularly", "Gentoo", "on", "x64", ")", "put", "things", "in", "lib64", "/", "pythonX", ".", "Y", "instead", "of", "lib", "/", "pythonX", ".", "Y", ".", "If", "this", "is", "such", "a", "platform", "we", "ll", "just", "c...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L1524-L1555
jedie/DragonPy
boot_dragonpy.py
mach_o_change
def mach_o_change(path, what, value): """ Replace a given name (what) in any LC_LOAD_DYLIB command found in the given binary with a new name (value), provided it's shorter. """ def do_macho(file, bits, endian): # Read Mach-O header (the magic number is assumed read by the caller) cp...
python
def mach_o_change(path, what, value): """ Replace a given name (what) in any LC_LOAD_DYLIB command found in the given binary with a new name (value), provided it's shorter. """ def do_macho(file, bits, endian): # Read Mach-O header (the magic number is assumed read by the caller) cp...
[ "def", "mach_o_change", "(", "path", ",", "what", ",", "value", ")", ":", "def", "do_macho", "(", "file", ",", "bits", ",", "endian", ")", ":", "# Read Mach-O header (the magic number is assumed read by the caller)", "cputype", ",", "cpusubtype", ",", "filetype", ...
Replace a given name (what) in any LC_LOAD_DYLIB command found in the given binary with a new name (value), provided it's shorter.
[ "Replace", "a", "given", "name", "(", "what", ")", "in", "any", "LC_LOAD_DYLIB", "command", "found", "in", "the", "given", "binary", "with", "a", "new", "name", "(", "value", ")", "provided", "it", "s", "shorter", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L21664-L21720
jedie/DragonPy
boot_dragonpy.py
EnvSubprocess._get_bin_dir
def _get_bin_dir(self): """ Normaly we have a ...env/bin/ dir. But under Windows we have ...env/Scripts/ But not PyPy2 under Windows, see: https://bitbucket.org/pypy/pypy/issues/2125/tcl-doesnt-work-inside-a-virtualenv-on#comment-21247266 So just try to test via os.path....
python
def _get_bin_dir(self): """ Normaly we have a ...env/bin/ dir. But under Windows we have ...env/Scripts/ But not PyPy2 under Windows, see: https://bitbucket.org/pypy/pypy/issues/2125/tcl-doesnt-work-inside-a-virtualenv-on#comment-21247266 So just try to test via os.path....
[ "def", "_get_bin_dir", "(", "self", ")", ":", "for", "subdir", "in", "(", "\"bin\"", ",", "\"Scripts\"", ")", ":", "bin_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "abs_home_dir", ",", "subdir", ")", "if", "os", ".", "path", ".", "...
Normaly we have a ...env/bin/ dir. But under Windows we have ...env/Scripts/ But not PyPy2 under Windows, see: https://bitbucket.org/pypy/pypy/issues/2125/tcl-doesnt-work-inside-a-virtualenv-on#comment-21247266 So just try to test via os.path.isdir()
[ "Normaly", "we", "have", "a", "...", "env", "/", "bin", "/", "dir", ".", "But", "under", "Windows", "we", "have", "...", "env", "/", "Scripts", "/", "But", "not", "PyPy2", "under", "Windows", "see", ":", "https", ":", "//", "bitbucket", ".", "org", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L1885-L1899
jedie/DragonPy
boot_dragonpy.py
EnvSubprocess._get_python_cmd
def _get_python_cmd(self): """ return the python executable in the virtualenv. Try first sys.executable but use fallbacks. """ file_names = ["pypy.exe", "python.exe", "python"] executable = sys.executable if executable is not None: executable = os.path...
python
def _get_python_cmd(self): """ return the python executable in the virtualenv. Try first sys.executable but use fallbacks. """ file_names = ["pypy.exe", "python.exe", "python"] executable = sys.executable if executable is not None: executable = os.path...
[ "def", "_get_python_cmd", "(", "self", ")", ":", "file_names", "=", "[", "\"pypy.exe\"", ",", "\"python.exe\"", ",", "\"python\"", "]", "executable", "=", "sys", ".", "executable", "if", "executable", "is", "not", "None", ":", "executable", "=", "os", ".", ...
return the python executable in the virtualenv. Try first sys.executable but use fallbacks.
[ "return", "the", "python", "executable", "in", "the", "virtualenv", ".", "Try", "first", "sys", ".", "executable", "but", "use", "fallbacks", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/boot_dragonpy.py#L1901-L1912
jedie/DragonPy
dragonpy/utils/humanize.py
hex_repr
def hex_repr(d): """ >>> hex_repr({"A":0x1,"B":0xabc}) 'A=$01 B=$0abc' """ txt = [] for k, v in sorted(d.items()): if isinstance(v, int): txt.append("%s=%s" % (k, nice_hex(v))) else: txt.append("%s=%s" % (k, v)) return " ".join(txt)
python
def hex_repr(d): """ >>> hex_repr({"A":0x1,"B":0xabc}) 'A=$01 B=$0abc' """ txt = [] for k, v in sorted(d.items()): if isinstance(v, int): txt.append("%s=%s" % (k, nice_hex(v))) else: txt.append("%s=%s" % (k, v)) return " ".join(txt)
[ "def", "hex_repr", "(", "d", ")", ":", "txt", "=", "[", "]", "for", "k", ",", "v", "in", "sorted", "(", "d", ".", "items", "(", ")", ")", ":", "if", "isinstance", "(", "v", ",", "int", ")", ":", "txt", ".", "append", "(", "\"%s=%s\"", "%", ...
>>> hex_repr({"A":0x1,"B":0xabc}) 'A=$01 B=$0abc'
[ ">>>", "hex_repr", "(", "{", "A", ":", "0x1", "B", ":", "0xabc", "}", ")", "A", "=", "$01", "B", "=", "$0abc" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/humanize.py#L56-L67
jedie/DragonPy
dragonpy/core/gui_starter.py
StarterGUI._run_dragonpy_cli
def _run_dragonpy_cli(self, *args): """ Run DragonPy cli with given args. Add "--verbosity" from GUI. """ verbosity = self.frame_settings.var_verbosity.get() verbosity_no = VERBOSITY_DICT2[verbosity] log.debug("Verbosity: %i (%s)" % (verbosity_no, verbosity)) ...
python
def _run_dragonpy_cli(self, *args): """ Run DragonPy cli with given args. Add "--verbosity" from GUI. """ verbosity = self.frame_settings.var_verbosity.get() verbosity_no = VERBOSITY_DICT2[verbosity] log.debug("Verbosity: %i (%s)" % (verbosity_no, verbosity)) ...
[ "def", "_run_dragonpy_cli", "(", "self", ",", "*", "args", ")", ":", "verbosity", "=", "self", ".", "frame_settings", ".", "var_verbosity", ".", "get", "(", ")", "verbosity_no", "=", "VERBOSITY_DICT2", "[", "verbosity", "]", "log", ".", "debug", "(", "\"Ve...
Run DragonPy cli with given args. Add "--verbosity" from GUI.
[ "Run", "DragonPy", "cli", "with", "given", "args", ".", "Add", "--", "verbosity", "from", "GUI", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/gui_starter.py#L221-L238
jedie/DragonPy
dragonpy/core/gui_starter.py
StarterGUI._run_command
def _run_command(self, command): """ Run DragonPy cli with given command like "run" or "editor" Add "--machine" from GUI. "--verbosity" will also be set, later. """ machine_name = self.frame_run_buttons.var_machine.get() self._run_dragonpy_cli("--machine", machine...
python
def _run_command(self, command): """ Run DragonPy cli with given command like "run" or "editor" Add "--machine" from GUI. "--verbosity" will also be set, later. """ machine_name = self.frame_run_buttons.var_machine.get() self._run_dragonpy_cli("--machine", machine...
[ "def", "_run_command", "(", "self", ",", "command", ")", ":", "machine_name", "=", "self", ".", "frame_run_buttons", ".", "var_machine", ".", "get", "(", ")", "self", ".", "_run_dragonpy_cli", "(", "\"--machine\"", ",", "machine_name", ",", "command", ")" ]
Run DragonPy cli with given command like "run" or "editor" Add "--machine" from GUI. "--verbosity" will also be set, later.
[ "Run", "DragonPy", "cli", "with", "given", "command", "like", "run", "or", "editor", "Add", "--", "machine", "from", "GUI", ".", "--", "verbosity", "will", "also", "be", "set", "later", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/gui_starter.py#L240-L247
jedie/DragonPy
dragonpy/utils/srecord_utils.py
int_to_padded_hex_byte
def int_to_padded_hex_byte(integer): """ Convert an int to a 0-padded hex byte string example: 65 == 41, 10 == 0A Returns: The hex byte as string (ex: "0C") """ to_hex = hex(integer) xpos = to_hex.find('x') hex_byte = to_hex[xpos+1 : len(to_hex)].upper() if len(hex_byte)...
python
def int_to_padded_hex_byte(integer): """ Convert an int to a 0-padded hex byte string example: 65 == 41, 10 == 0A Returns: The hex byte as string (ex: "0C") """ to_hex = hex(integer) xpos = to_hex.find('x') hex_byte = to_hex[xpos+1 : len(to_hex)].upper() if len(hex_byte)...
[ "def", "int_to_padded_hex_byte", "(", "integer", ")", ":", "to_hex", "=", "hex", "(", "integer", ")", "xpos", "=", "to_hex", ".", "find", "(", "'x'", ")", "hex_byte", "=", "to_hex", "[", "xpos", "+", "1", ":", "len", "(", "to_hex", ")", "]", ".", "...
Convert an int to a 0-padded hex byte string example: 65 == 41, 10 == 0A Returns: The hex byte as string (ex: "0C")
[ "Convert", "an", "int", "to", "a", "0", "-", "padded", "hex", "byte", "string", "example", ":", "65", "==", "41", "10", "==", "0A", "Returns", ":", "The", "hex", "byte", "as", "string", "(", "ex", ":", "0C", ")" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L36-L49
jedie/DragonPy
dragonpy/utils/srecord_utils.py
compute_srec_checksum
def compute_srec_checksum(srec): """ Compute the checksum byte of a given S-Record Returns: The checksum as a string hex byte (ex: "0C") """ # Get the summable data from srec # start at 2 to remove the S* record entry data = srec[2:len(srec)] sum = 0 # For each byte, convert...
python
def compute_srec_checksum(srec): """ Compute the checksum byte of a given S-Record Returns: The checksum as a string hex byte (ex: "0C") """ # Get the summable data from srec # start at 2 to remove the S* record entry data = srec[2:len(srec)] sum = 0 # For each byte, convert...
[ "def", "compute_srec_checksum", "(", "srec", ")", ":", "# Get the summable data from srec", "# start at 2 to remove the S* record entry", "data", "=", "srec", "[", "2", ":", "len", "(", "srec", ")", "]", "sum", "=", "0", "# For each byte, convert to int and add.", "# (s...
Compute the checksum byte of a given S-Record Returns: The checksum as a string hex byte (ex: "0C")
[ "Compute", "the", "checksum", "byte", "of", "a", "given", "S", "-", "Record", "Returns", ":", "The", "checksum", "as", "a", "string", "hex", "byte", "(", "ex", ":", "0C", ")" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L52-L78
jedie/DragonPy
dragonpy/utils/srecord_utils.py
validate_srec_checksum
def validate_srec_checksum(srec): """ Validate if the checksum of the supplied s-record is valid Returns: True if valid, False if not """ checksum = srec[len(srec)-2:] # Strip the original checksum and compare with the computed one if compute_srec_checksum(srec[:len(srec) - 2]) == i...
python
def validate_srec_checksum(srec): """ Validate if the checksum of the supplied s-record is valid Returns: True if valid, False if not """ checksum = srec[len(srec)-2:] # Strip the original checksum and compare with the computed one if compute_srec_checksum(srec[:len(srec) - 2]) == i...
[ "def", "validate_srec_checksum", "(", "srec", ")", ":", "checksum", "=", "srec", "[", "len", "(", "srec", ")", "-", "2", ":", "]", "# Strip the original checksum and compare with the computed one", "if", "compute_srec_checksum", "(", "srec", "[", ":", "len", "(", ...
Validate if the checksum of the supplied s-record is valid Returns: True if valid, False if not
[ "Validate", "if", "the", "checksum", "of", "the", "supplied", "s", "-", "record", "is", "valid", "Returns", ":", "True", "if", "valid", "False", "if", "not" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L81-L92
jedie/DragonPy
dragonpy/utils/srecord_utils.py
get_readable_string
def get_readable_string(integer): r""" Convert an integer to a readable 2-character representation. This is useful for reversing examples: 41 == ".A", 13 == "\n", 20 (space) == "__" Returns a readable 2-char representation of an int. """ if integer == 9: #\t readable_strin...
python
def get_readable_string(integer): r""" Convert an integer to a readable 2-character representation. This is useful for reversing examples: 41 == ".A", 13 == "\n", 20 (space) == "__" Returns a readable 2-char representation of an int. """ if integer == 9: #\t readable_strin...
[ "def", "get_readable_string", "(", "integer", ")", ":", "if", "integer", "==", "9", ":", "#\\t", "readable_string", "=", "\"\\\\t\"", "elif", "integer", "==", "10", ":", "#\\r", "readable_string", "=", "\"\\\\r\"", "elif", "integer", "==", "13", ":", "#\\n",...
r""" Convert an integer to a readable 2-character representation. This is useful for reversing examples: 41 == ".A", 13 == "\n", 20 (space) == "__" Returns a readable 2-char representation of an int.
[ "r", "Convert", "an", "integer", "to", "a", "readable", "2", "-", "character", "representation", ".", "This", "is", "useful", "for", "reversing", "examples", ":", "41", "==", ".", "A", "13", "==", "\\", "n", "20", "(", "space", ")", "==", "__", "Retu...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L95-L114
jedie/DragonPy
dragonpy/utils/srecord_utils.py
offset_byte_in_data
def offset_byte_in_data(target_data, offset, target_byte_pos, readable = False, wraparound = False): """ Offset a given byte in the provided data payload (kind of rot(x)) readable will return a human-readable representation of the byte+offset wraparound will wrap around 255 to 0 (ex: 257 = 2...
python
def offset_byte_in_data(target_data, offset, target_byte_pos, readable = False, wraparound = False): """ Offset a given byte in the provided data payload (kind of rot(x)) readable will return a human-readable representation of the byte+offset wraparound will wrap around 255 to 0 (ex: 257 = 2...
[ "def", "offset_byte_in_data", "(", "target_data", ",", "offset", ",", "target_byte_pos", ",", "readable", "=", "False", ",", "wraparound", "=", "False", ")", ":", "byte_pos", "=", "target_byte_pos", "*", "2", "prefix", "=", "target_data", "[", ":", "byte_pos",...
Offset a given byte in the provided data payload (kind of rot(x)) readable will return a human-readable representation of the byte+offset wraparound will wrap around 255 to 0 (ex: 257 = 2) Returns: the offseted byte
[ "Offset", "a", "given", "byte", "in", "the", "provided", "data", "payload", "(", "kind", "of", "rot", "(", "x", "))", "readable", "will", "return", "a", "human", "-", "readable", "representation", "of", "the", "byte", "+", "offset", "wraparound", "will", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L117-L144
jedie/DragonPy
dragonpy/utils/srecord_utils.py
offset_data
def offset_data(data_section, offset, readable = False, wraparound = False): """ Offset the whole data section. see offset_byte_in_data for more information Returns: the entire data section + offset on each byte """ for pos in range(0, len(data_section)/2): data_section = off...
python
def offset_data(data_section, offset, readable = False, wraparound = False): """ Offset the whole data section. see offset_byte_in_data for more information Returns: the entire data section + offset on each byte """ for pos in range(0, len(data_section)/2): data_section = off...
[ "def", "offset_data", "(", "data_section", ",", "offset", ",", "readable", "=", "False", ",", "wraparound", "=", "False", ")", ":", "for", "pos", "in", "range", "(", "0", ",", "len", "(", "data_section", ")", "/", "2", ")", ":", "data_section", "=", ...
Offset the whole data section. see offset_byte_in_data for more information Returns: the entire data section + offset on each byte
[ "Offset", "the", "whole", "data", "section", ".", "see", "offset_byte_in_data", "for", "more", "information", "Returns", ":", "the", "entire", "data", "section", "+", "offset", "on", "each", "byte" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L149-L158
jedie/DragonPy
dragonpy/utils/srecord_utils.py
parse_srec
def parse_srec(srec): """ Extract the data portion of a given S-Record (without checksum) Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum """ record_type = srec[0:2] data_len = srec[2:4] addr_len = __ADDR_LEN.get(record_ty...
python
def parse_srec(srec): """ Extract the data portion of a given S-Record (without checksum) Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum """ record_type = srec[0:2] data_len = srec[2:4] addr_len = __ADDR_LEN.get(record_ty...
[ "def", "parse_srec", "(", "srec", ")", ":", "record_type", "=", "srec", "[", "0", ":", "2", "]", "data_len", "=", "srec", "[", "2", ":", "4", "]", "addr_len", "=", "__ADDR_LEN", ".", "get", "(", "record_type", ")", "*", "2", "addr", "=", "srec", ...
Extract the data portion of a given S-Record (without checksum) Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum
[ "Extract", "the", "data", "portion", "of", "a", "given", "S", "-", "Record", "(", "without", "checksum", ")", "Returns", ":", "the", "record", "type", "the", "lenght", "of", "the", "data", "section", "the", "write", "address", "the", "data", "itself", "a...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L161-L172
jedie/DragonPy
PyDC/PyDC/__init__.py
convert
def convert(source_file, destination_file, cfg): """ convert in every way. """ source_ext = os.path.splitext(source_file)[1] source_ext = source_ext.lower() dest_ext = os.path.splitext(destination_file)[1] dest_ext = dest_ext.lower() if source_ext not in (".wav", ".cas", ".bas"): ...
python
def convert(source_file, destination_file, cfg): """ convert in every way. """ source_ext = os.path.splitext(source_file)[1] source_ext = source_ext.lower() dest_ext = os.path.splitext(destination_file)[1] dest_ext = dest_ext.lower() if source_ext not in (".wav", ".cas", ".bas"): ...
[ "def", "convert", "(", "source_file", ",", "destination_file", ",", "cfg", ")", ":", "source_ext", "=", "os", ".", "path", ".", "splitext", "(", "source_file", ")", "[", "1", "]", "source_ext", "=", "source_ext", ".", "lower", "(", ")", "dest_ext", "=", ...
convert in every way.
[ "convert", "in", "every", "way", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/__init__.py#L29-L70
jedie/DragonPy
dragonpy/Dragon64/config.py
Dragon64Cfg.get_initial_RAM
def get_initial_RAM(self): """ init the Dragon RAM See: http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=5&t=4444 """ mem_FF = [0xff for _ in xrange(4)] mem_00 = [0x00 for _ in xrange(4)] mem = [] for _ in xrange(self.RAM_SIZE // 8): me...
python
def get_initial_RAM(self): """ init the Dragon RAM See: http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=5&t=4444 """ mem_FF = [0xff for _ in xrange(4)] mem_00 = [0x00 for _ in xrange(4)] mem = [] for _ in xrange(self.RAM_SIZE // 8): me...
[ "def", "get_initial_RAM", "(", "self", ")", ":", "mem_FF", "=", "[", "0xff", "for", "_", "in", "xrange", "(", "4", ")", "]", "mem_00", "=", "[", "0x00", "for", "_", "in", "xrange", "(", "4", ")", "]", "mem", "=", "[", "]", "for", "_", "in", "...
init the Dragon RAM See: http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=5&t=4444
[ "init", "the", "Dragon", "RAM", "See", ":", "http", ":", "//", "archive", ".", "worldofdragon", ".", "org", "/", "phpBB3", "/", "viewtopic", ".", "php?f", "=", "5&t", "=", "4444" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon64/config.py#L65-L78
jedie/DragonPy
basic_editor/scrolled_text.py
ScrolledText.save_position
def save_position(self): """ save cursor and scroll position """ # save text cursor position: self.old_text_pos = self.index(tkinter.INSERT) # save scroll position: self.old_first, self.old_last = self.yview()
python
def save_position(self): """ save cursor and scroll position """ # save text cursor position: self.old_text_pos = self.index(tkinter.INSERT) # save scroll position: self.old_first, self.old_last = self.yview()
[ "def", "save_position", "(", "self", ")", ":", "# save text cursor position:", "self", ".", "old_text_pos", "=", "self", ".", "index", "(", "tkinter", ".", "INSERT", ")", "# save scroll position:", "self", ".", "old_first", ",", "self", ".", "old_last", "=", "...
save cursor and scroll position
[ "save", "cursor", "and", "scroll", "position" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/basic_editor/scrolled_text.py#L92-L99
jedie/DragonPy
basic_editor/scrolled_text.py
ScrolledText.restore_position
def restore_position(self): """ restore cursor and scroll position """ # restore text cursor position: self.mark_set(tkinter.INSERT, self.old_text_pos) # restore scroll position: self.yview_moveto(self.old_first)
python
def restore_position(self): """ restore cursor and scroll position """ # restore text cursor position: self.mark_set(tkinter.INSERT, self.old_text_pos) # restore scroll position: self.yview_moveto(self.old_first)
[ "def", "restore_position", "(", "self", ")", ":", "# restore text cursor position:", "self", ".", "mark_set", "(", "tkinter", ".", "INSERT", ",", "self", ".", "old_text_pos", ")", "# restore scroll position:", "self", ".", "yview_moveto", "(", "self", ".", "old_fi...
restore cursor and scroll position
[ "restore", "cursor", "and", "scroll", "position" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/basic_editor/scrolled_text.py#L101-L108
jedie/DragonPy
basic_editor/highlighting.py
TkTextHighlighting.__update_interval
def __update_interval(self): """ highlight the current line """ self.update() self.after_id = self.text.after(250, self.__update_interval)
python
def __update_interval(self): """ highlight the current line """ self.update() self.after_id = self.text.after(250, self.__update_interval)
[ "def", "__update_interval", "(", "self", ")", ":", "self", ".", "update", "(", ")", "self", ".", "after_id", "=", "self", ".", "text", ".", "after", "(", "250", ",", "self", ".", "__update_interval", ")" ]
highlight the current line
[ "highlight", "the", "current", "line" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/basic_editor/highlighting.py#L63-L66
jedie/DragonPy
basic_editor/highlighting.py
TkTextHighlightCurrentLine.update
def update(self, event=None, force=False): """ highlight the current line """ line_no = self.text.index(tkinter.INSERT).split(".")[0] # if not force: # if line_no == self.current_line: # log.critical("no highlight line needed.") # return # lo...
python
def update(self, event=None, force=False): """ highlight the current line """ line_no = self.text.index(tkinter.INSERT).split(".")[0] # if not force: # if line_no == self.current_line: # log.critical("no highlight line needed.") # return # lo...
[ "def", "update", "(", "self", ",", "event", "=", "None", ",", "force", "=", "False", ")", ":", "line_no", "=", "self", ".", "text", ".", "index", "(", "tkinter", ".", "INSERT", ")", ".", "split", "(", "\".\"", ")", "[", "0", "]", "# if not force:",...
highlight the current line
[ "highlight", "the", "current", "line" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/basic_editor/highlighting.py#L179-L192
jedie/DragonPy
dragonpy/components/rom.py
ROMFile.download
def download(self): """ Request url and return his content The Requested content will be cached into the default temp directory. """ if os.path.isfile(self.archive_path): print("Use %r" % self.archive_path) with open(self.archive_path, "rb") as f: ...
python
def download(self): """ Request url and return his content The Requested content will be cached into the default temp directory. """ if os.path.isfile(self.archive_path): print("Use %r" % self.archive_path) with open(self.archive_path, "rb") as f: ...
[ "def", "download", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "archive_path", ")", ":", "print", "(", "\"Use %r\"", "%", "self", ".", "archive_path", ")", "with", "open", "(", "self", ".", "archive_path", ",", "\...
Request url and return his content The Requested content will be cached into the default temp directory.
[ "Request", "url", "and", "return", "his", "content", "The", "Requested", "content", "will", "be", "cached", "into", "the", "default", "temp", "directory", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/components/rom.py#L139-L159
jedie/DragonPy
dragonpy/core/gui.py
BaseTkinterGUI.paste_clipboard
def paste_clipboard(self, event): """ Send the clipboard content as user input to the CPU. """ log.critical("paste clipboard") clipboard = self.root.clipboard_get() for line in clipboard.splitlines(): log.critical("paste line: %s", repr(line)) self...
python
def paste_clipboard(self, event): """ Send the clipboard content as user input to the CPU. """ log.critical("paste clipboard") clipboard = self.root.clipboard_get() for line in clipboard.splitlines(): log.critical("paste line: %s", repr(line)) self...
[ "def", "paste_clipboard", "(", "self", ",", "event", ")", ":", "log", ".", "critical", "(", "\"paste clipboard\"", ")", "clipboard", "=", "self", ".", "root", ".", "clipboard_get", "(", ")", "for", "line", "in", "clipboard", ".", "splitlines", "(", ")", ...
Send the clipboard content as user input to the CPU.
[ "Send", "the", "clipboard", "content", "as", "user", "input", "to", "the", "CPU", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/gui.py#L219-L227
jedie/DragonPy
dragonpy/core/gui.py
DragonTkinterGUI.display_callback
def display_callback(self, cpu_cycles, op_address, address, value): """ called via memory write_byte_middleware """ self.display.write_byte(cpu_cycles, op_address, address, value) return value
python
def display_callback(self, cpu_cycles, op_address, address, value): """ called via memory write_byte_middleware """ self.display.write_byte(cpu_cycles, op_address, address, value) return value
[ "def", "display_callback", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ",", "value", ")", ":", "self", ".", "display", ".", "write_byte", "(", "cpu_cycles", ",", "op_address", ",", "address", ",", "value", ")", "return", "value" ]
called via memory write_byte_middleware
[ "called", "via", "memory", "write_byte_middleware" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/gui.py#L346-L349
jedie/DragonPy
dragonpy/core/gui.py
ScrolledTextGUI.event_key_pressed
def event_key_pressed(self, event): """ So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa. """ char = event.char if not char: return if char in string.ascii_letters: char = invert_shift(char) ...
python
def event_key_pressed(self, event): """ So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa. """ char = event.char if not char: return if char in string.ascii_letters: char = invert_shift(char) ...
[ "def", "event_key_pressed", "(", "self", ",", "event", ")", ":", "char", "=", "event", ".", "char", "if", "not", "char", ":", "return", "if", "char", "in", "string", ".", "ascii_letters", ":", "char", "=", "invert_shift", "(", "char", ")", "self", ".",...
So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa.
[ "So", "a", "invert", "shift", "for", "user", "inputs", ":", "Convert", "all", "lowercase", "letters", "to", "uppercase", "and", "vice", "versa", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/gui.py#L439-L455
jedie/DragonPy
dragonpy/__init__.py
fix_virtualenv_tkinter
def fix_virtualenv_tkinter(): """ work-a-round for tkinter under windows in a virtualenv: "TclError: Can't find a usable init.tcl..." Known bug, see: https://github.com/pypa/virtualenv/issues/93 There are "fix tk" file here: C:\Python27\Lib\lib-tk\FixTk.py C:\Python34\Lib\tki...
python
def fix_virtualenv_tkinter(): """ work-a-round for tkinter under windows in a virtualenv: "TclError: Can't find a usable init.tcl..." Known bug, see: https://github.com/pypa/virtualenv/issues/93 There are "fix tk" file here: C:\Python27\Lib\lib-tk\FixTk.py C:\Python34\Lib\tki...
[ "def", "fix_virtualenv_tkinter", "(", ")", ":", "if", "\"TCL_LIBRARY\"", "in", "os", ".", "environ", ":", "# Fix not needed (e.g. virtualenv issues #93 fixed?)", "return", "if", "not", "hasattr", "(", "sys", ",", "\"real_prefix\"", ")", ":", "# we are not in a activated...
work-a-round for tkinter under windows in a virtualenv: "TclError: Can't find a usable init.tcl..." Known bug, see: https://github.com/pypa/virtualenv/issues/93 There are "fix tk" file here: C:\Python27\Lib\lib-tk\FixTk.py C:\Python34\Lib\tkinter\_fix.py These modules will be au...
[ "work", "-", "a", "-", "round", "for", "tkinter", "under", "windows", "in", "a", "virtualenv", ":", "TclError", ":", "Can", "t", "find", "a", "usable", "init", ".", "tcl", "...", "Known", "bug", "see", ":", "https", ":", "//", "github", ".", "com", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/__init__.py#L14-L76
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.internal_reset
def internal_reset(self): """ internal state reset. used e.g. in unittests """ log.critical("PIA internal_reset()") self.empty_key_toggle = True self.current_input_char = None self.input_repead = 0
python
def internal_reset(self): """ internal state reset. used e.g. in unittests """ log.critical("PIA internal_reset()") self.empty_key_toggle = True self.current_input_char = None self.input_repead = 0
[ "def", "internal_reset", "(", "self", ")", ":", "log", ".", "critical", "(", "\"PIA internal_reset()\"", ")", "self", ".", "empty_key_toggle", "=", "True", "self", ".", "current_input_char", "=", "None", "self", ".", "input_repead", "=", "0" ]
internal state reset. used e.g. in unittests
[ "internal", "state", "reset", ".", "used", "e", ".", "g", ".", "in", "unittests" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L152-L160
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.read_PIA0_A_data
def read_PIA0_A_data(self, cpu_cycles, op_address, address): """ read from 0xff00 -> PIA 0 A side Data reg. bit 7 | PA7 | joystick comparison input bit 6 | PA6 | keyboard matrix row 7 bit 5 | PA5 | keyboard matrix row 6 bit 4 | PA4 | keyboard matrix row 5 bit 3 |...
python
def read_PIA0_A_data(self, cpu_cycles, op_address, address): """ read from 0xff00 -> PIA 0 A side Data reg. bit 7 | PA7 | joystick comparison input bit 6 | PA6 | keyboard matrix row 7 bit 5 | PA5 | keyboard matrix row 6 bit 4 | PA4 | keyboard matrix row 5 bit 3 |...
[ "def", "read_PIA0_A_data", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ")", ":", "pia0b", "=", "self", ".", "pia_0_B_data", ".", "value", "# $ff02", "# FIXME: Find a way to handle CoCo and Dragon in the same way!", "if", "self", ".", "cfg", "....
read from 0xff00 -> PIA 0 A side Data reg. bit 7 | PA7 | joystick comparison input bit 6 | PA6 | keyboard matrix row 7 bit 5 | PA5 | keyboard matrix row 6 bit 4 | PA4 | keyboard matrix row 5 bit 3 | PA3 | keyboard matrix row 4 & left joystick switch 2 bit 2 | PA2 | keyb...
[ "read", "from", "0xff00", "-", ">", "PIA", "0", "A", "side", "Data", "reg", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L218-L299
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.write_PIA0_A_data
def write_PIA0_A_data(self, cpu_cycles, op_address, address, value): """ write to 0xff00 -> PIA 0 A side Data reg. """ log.error("%04x| write $%02x (%s) to $%04x -> PIA 0 A side Data reg.\t|%s", op_address, value, byte2bit_string(value), address, self.cfg.mem_info.get_shortest(op...
python
def write_PIA0_A_data(self, cpu_cycles, op_address, address, value): """ write to 0xff00 -> PIA 0 A side Data reg. """ log.error("%04x| write $%02x (%s) to $%04x -> PIA 0 A side Data reg.\t|%s", op_address, value, byte2bit_string(value), address, self.cfg.mem_info.get_shortest(op...
[ "def", "write_PIA0_A_data", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ",", "value", ")", ":", "log", ".", "error", "(", "\"%04x| write $%02x (%s) to $%04x -> PIA 0 A side Data reg.\\t|%s\"", ",", "op_address", ",", "value", ",", "byte2bit_stri...
write to 0xff00 -> PIA 0 A side Data reg.
[ "write", "to", "0xff00", "-", ">", "PIA", "0", "A", "side", "Data", "reg", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L301-L307
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.read_PIA0_A_control
def read_PIA0_A_control(self, cpu_cycles, op_address, address): """ read from 0xff01 -> PIA 0 A side control register """ value = 0xb3 log.error( "%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\t|%s", op_address, address, value, byte2bi...
python
def read_PIA0_A_control(self, cpu_cycles, op_address, address): """ read from 0xff01 -> PIA 0 A side control register """ value = 0xb3 log.error( "%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\t|%s", op_address, address, value, byte2bi...
[ "def", "read_PIA0_A_control", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ")", ":", "value", "=", "0xb3", "log", ".", "error", "(", "\"%04x| read $%04x (PIA 0 A side Control reg.) send $%02x (%s) back.\\t|%s\"", ",", "op_address", ",", "address", ...
read from 0xff01 -> PIA 0 A side control register
[ "read", "from", "0xff01", "-", ">", "PIA", "0", "A", "side", "control", "register" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L309-L319
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.write_PIA0_A_control
def write_PIA0_A_control(self, cpu_cycles, op_address, address, value): """ write to 0xff01 -> PIA 0 A side control register TODO: Handle IRQ bit 7 | IRQ 1 (HSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CA2) is an output = 1 bit 4 | Control li...
python
def write_PIA0_A_control(self, cpu_cycles, op_address, address, value): """ write to 0xff01 -> PIA 0 A side control register TODO: Handle IRQ bit 7 | IRQ 1 (HSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CA2) is an output = 1 bit 4 | Control li...
[ "def", "write_PIA0_A_control", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ",", "value", ")", ":", "log", ".", "error", "(", "\"%04x| write $%02x (%s) to $%04x -> PIA 0 A side Control reg.\\t|%s\"", ",", "op_address", ",", "value", ",", "byte2bi...
write to 0xff01 -> PIA 0 A side control register TODO: Handle IRQ bit 7 | IRQ 1 (HSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CA2) is an output = 1 bit 4 | Control line 2 (CA2) set by bit 3 = 1 bit 3 | select line LSB of analog multiplexor (MUX): 0 =...
[ "write", "to", "0xff01", "-", ">", "PIA", "0", "A", "side", "control", "register" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L321-L344
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.read_PIA0_B_data
def read_PIA0_B_data(self, cpu_cycles, op_address, address): """ read from 0xff02 -> PIA 0 B side Data reg. bit 7 | PB7 | keyboard matrix column 8 bit 6 | PB6 | keyboard matrix column 7 / ram size output bit 5 | PB5 | keyboard matrix column 6 bit 4 | PB4 | keyboard matri...
python
def read_PIA0_B_data(self, cpu_cycles, op_address, address): """ read from 0xff02 -> PIA 0 B side Data reg. bit 7 | PB7 | keyboard matrix column 8 bit 6 | PB6 | keyboard matrix column 7 / ram size output bit 5 | PB5 | keyboard matrix column 6 bit 4 | PB4 | keyboard matri...
[ "def", "read_PIA0_B_data", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ")", ":", "value", "=", "self", ".", "pia_0_B_data", ".", "value", "# $ff02", "log", ".", "debug", "(", "\"%04x| read $%04x (PIA 0 B side Data reg.) send $%02x (%s) back.\\t|...
read from 0xff02 -> PIA 0 B side Data reg. bit 7 | PB7 | keyboard matrix column 8 bit 6 | PB6 | keyboard matrix column 7 / ram size output bit 5 | PB5 | keyboard matrix column 6 bit 4 | PB4 | keyboard matrix column 5 bit 3 | PB3 | keyboard matrix column 4 bit 2 | PB2 | k...
[ "read", "from", "0xff02", "-", ">", "PIA", "0", "B", "side", "Data", "reg", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L346-L367
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.read_PIA0_B_control
def read_PIA0_B_control(self, cpu_cycles, op_address, address): """ read from 0xff03 -> PIA 0 B side Control reg. """ value = self.pia_0_B_control.value log.error( "%04x| read $%04x (PIA 0 B side Control reg.) send $%02x (%s) back.\t|%s", op_address, addre...
python
def read_PIA0_B_control(self, cpu_cycles, op_address, address): """ read from 0xff03 -> PIA 0 B side Control reg. """ value = self.pia_0_B_control.value log.error( "%04x| read $%04x (PIA 0 B side Control reg.) send $%02x (%s) back.\t|%s", op_address, addre...
[ "def", "read_PIA0_B_control", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ")", ":", "value", "=", "self", ".", "pia_0_B_control", ".", "value", "log", ".", "error", "(", "\"%04x| read $%04x (PIA 0 B side Control reg.) send $%02x (%s) back.\\t|%s\"...
read from 0xff03 -> PIA 0 B side Control reg.
[ "read", "from", "0xff03", "-", ">", "PIA", "0", "B", "side", "Control", "reg", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L379-L389
jedie/DragonPy
dragonpy/Dragon32/MC6821_PIA.py
PIA.write_PIA0_B_control
def write_PIA0_B_control(self, cpu_cycles, op_address, address, value): """ write to 0xff03 -> PIA 0 B side Control reg. TODO: Handle IRQ bit 7 | IRQ 1 (VSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CB2) is an output = 1 bit 4 | Control line 2...
python
def write_PIA0_B_control(self, cpu_cycles, op_address, address, value): """ write to 0xff03 -> PIA 0 B side Control reg. TODO: Handle IRQ bit 7 | IRQ 1 (VSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CB2) is an output = 1 bit 4 | Control line 2...
[ "def", "write_PIA0_B_control", "(", "self", ",", "cpu_cycles", ",", "op_address", ",", "address", ",", "value", ")", ":", "log", ".", "critical", "(", "\"%04x| write $%02x (%s) to $%04x -> PIA 0 B side Control reg.\\t|%s\"", ",", "op_address", ",", "value", ",", "byte...
write to 0xff03 -> PIA 0 B side Control reg. TODO: Handle IRQ bit 7 | IRQ 1 (VSYNC) flag bit 6 | IRQ 2 flag(not used) bit 5 | Control line 2 (CB2) is an output = 1 bit 4 | Control line 2 (CB2) set by bit 3 = 1 bit 3 | select line MSB of analog multiplexor (MUX): 0 = con...
[ "write", "to", "0xff03", "-", ">", "PIA", "0", "B", "side", "Control", "reg", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/MC6821_PIA.py#L391-L433
jedie/DragonPy
dragonpy/CoCo/config.py
CoCo2bCfg.basic_addresses_write
def basic_addresses_write(self, cycles, last_op_address, address, word): """ 0113 0019 TXTTAB RMB 2 *PV BEGINNING OF BASIC PROGRAM 0114 001B VARTAB RMB 2 *PV START OF VARIABLES 0115 001D ARYTAB RMB 2 *PV START OF ARRAYS 0116 001F ARYEND RMB 2 *PV END OF ARRAYS (+1) 0117 0...
python
def basic_addresses_write(self, cycles, last_op_address, address, word): """ 0113 0019 TXTTAB RMB 2 *PV BEGINNING OF BASIC PROGRAM 0114 001B VARTAB RMB 2 *PV START OF VARIABLES 0115 001D ARYTAB RMB 2 *PV START OF ARRAYS 0116 001F ARYEND RMB 2 *PV END OF ARRAYS (+1) 0117 0...
[ "def", "basic_addresses_write", "(", "self", ",", "cycles", ",", "last_op_address", ",", "address", ",", "word", ")", ":", "log", ".", "critical", "(", "\"%04x| write $%04x to $%04x\"", ",", "last_op_address", ",", "word", ",", "address", ")", "return", "word" ]
0113 0019 TXTTAB RMB 2 *PV BEGINNING OF BASIC PROGRAM 0114 001B VARTAB RMB 2 *PV START OF VARIABLES 0115 001D ARYTAB RMB 2 *PV START OF ARRAYS 0116 001F ARYEND RMB 2 *PV END OF ARRAYS (+1) 0117 0021 FRETOP RMB 2 *PV START OF STRING STORAGE (TOP OF FREE RAM) 0118 0023 STRTAB RMB 2...
[ "0113", "0019", "TXTTAB", "RMB", "2", "*", "PV", "BEGINNING", "OF", "BASIC", "PROGRAM", "0114", "001B", "VARTAB", "RMB", "2", "*", "PV", "START", "OF", "VARIABLES", "0115", "001D", "ARYTAB", "RMB", "2", "*", "PV", "START", "OF", "ARRAYS", "0116", "001F...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/CoCo/config.py#L95-L107
jedie/DragonPy
basic_editor/editor.py
EditorWindow.event_text_key
def event_text_key(self, event): """ So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa. """ char = event.char if not char or char not in string.ascii_letters: # ignore all non letter inputs return ...
python
def event_text_key(self, event): """ So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa. """ char = event.char if not char or char not in string.ascii_letters: # ignore all non letter inputs return ...
[ "def", "event_text_key", "(", "self", ",", "event", ")", ":", "char", "=", "event", ".", "char", "if", "not", "char", "or", "char", "not", "in", "string", ".", "ascii_letters", ":", "# ignore all non letter inputs", "return", "converted_char", "=", "invert_shi...
So a "invert shift" for user inputs: Convert all lowercase letters to uppercase and vice versa.
[ "So", "a", "invert", "shift", "for", "user", "inputs", ":", "Convert", "all", "lowercase", "letters", "to", "uppercase", "and", "vice", "versa", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/basic_editor/editor.py#L156-L170
jedie/DragonPy
PyDC/PyDC/bitstream_handler.py
pop_bytes_from_bit_list
def pop_bytes_from_bit_list(bit_list, count): """ >>> bit_str = ( ... "00110011" ... "00001111" ... "01010101" ... "11001100") >>> bit_list = [int(i) for i in bit_str] >>> bit_list, bytes = pop_bytes_from_bit_list(bit_list, 1) >>> bytes [[0, 0, 1, 1, 0, 0, 1, 1]] >...
python
def pop_bytes_from_bit_list(bit_list, count): """ >>> bit_str = ( ... "00110011" ... "00001111" ... "01010101" ... "11001100") >>> bit_list = [int(i) for i in bit_str] >>> bit_list, bytes = pop_bytes_from_bit_list(bit_list, 1) >>> bytes [[0, 0, 1, 1, 0, 0, 1, 1]] >...
[ "def", "pop_bytes_from_bit_list", "(", "bit_list", ",", "count", ")", ":", "data_bit_count", "=", "count", "*", "8", "data_bit_list", "=", "bit_list", "[", ":", "data_bit_count", "]", "data", "=", "list", "(", "iter_steps", "(", "data_bit_list", ",", "steps", ...
>>> bit_str = ( ... "00110011" ... "00001111" ... "01010101" ... "11001100") >>> bit_list = [int(i) for i in bit_str] >>> bit_list, bytes = pop_bytes_from_bit_list(bit_list, 1) >>> bytes [[0, 0, 1, 1, 0, 0, 1, 1]] >>> bit_list, bytes = pop_bytes_from_bit_list(bit_list, 2) ...
[ ">>>", "bit_str", "=", "(", "...", "00110011", "...", "00001111", "...", "01010101", "...", "11001100", ")", ">>>", "bit_list", "=", "[", "int", "(", "i", ")", "for", "i", "in", "bit_str", "]", ">>>", "bit_list", "bytes", "=", "pop_bytes_from_bit_list", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/bitstream_handler.py#L40-L64
jedie/DragonPy
PyDC/PyDC/bitstream_handler.py
print_bit_list_stats
def print_bit_list_stats(bit_list): """ >>> print_bit_list_stats([1,1,1,1,0,0,0,0]) 8 Bits: 4 positive bits and 4 negative bits """ print "%i Bits:" % len(bit_list), positive_count = 0 negative_count = 0 for bit in bit_list: if bit == 1: positive_count += 1 ...
python
def print_bit_list_stats(bit_list): """ >>> print_bit_list_stats([1,1,1,1,0,0,0,0]) 8 Bits: 4 positive bits and 4 negative bits """ print "%i Bits:" % len(bit_list), positive_count = 0 negative_count = 0 for bit in bit_list: if bit == 1: positive_count += 1 ...
[ "def", "print_bit_list_stats", "(", "bit_list", ")", ":", "print", "\"%i Bits:\"", "%", "len", "(", "bit_list", ")", ",", "positive_count", "=", "0", "negative_count", "=", "0", "for", "bit", "in", "bit_list", ":", "if", "bit", "==", "1", ":", "positive_co...
>>> print_bit_list_stats([1,1,1,1,0,0,0,0]) 8 Bits: 4 positive bits and 4 negative bits
[ ">>>", "print_bit_list_stats", "(", "[", "1", "1", "1", "1", "0", "0", "0", "0", "]", ")", "8", "Bits", ":", "4", "positive", "bits", "and", "4", "negative", "bits" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/bitstream_handler.py#L321-L336
jedie/DragonPy
dragonpy/core/machine.py
Machine.inject_basic_program
def inject_basic_program(self, ascii_listing): """ save the given ASCII BASIC program listing into the emulator RAM. """ program_start = self.cpu.memory.read_word( self.machine_api.PROGRAM_START_ADDR ) tokens = self.machine_api.ascii_listing2program_dump(ascii...
python
def inject_basic_program(self, ascii_listing): """ save the given ASCII BASIC program listing into the emulator RAM. """ program_start = self.cpu.memory.read_word( self.machine_api.PROGRAM_START_ADDR ) tokens = self.machine_api.ascii_listing2program_dump(ascii...
[ "def", "inject_basic_program", "(", "self", ",", "ascii_listing", ")", ":", "program_start", "=", "self", ".", "cpu", ".", "memory", ".", "read_word", "(", "self", ".", "machine_api", ".", "PROGRAM_START_ADDR", ")", "tokens", "=", "self", ".", "machine_api", ...
save the given ASCII BASIC program listing into the emulator RAM.
[ "save", "the", "given", "ASCII", "BASIC", "program", "listing", "into", "the", "emulator", "RAM", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/machine.py#L95-L111
jedie/DragonPy
dragonpy/Dragon32/dragon_charmap.py
get_rgb_color
def get_rgb_color(color): """ >>> get_rgb_color(BLUE) ((0, 0, 0), (33, 16, 181)) >>> get_rgb_color(NORMAL) ((0, 65, 0), (0, 255, 0)) """ if color == INVERTED: foreground = (0, 255, 0) background = (0, 65, 0) elif color == NORMAL: foreground = (0, 65, 0) b...
python
def get_rgb_color(color): """ >>> get_rgb_color(BLUE) ((0, 0, 0), (33, 16, 181)) >>> get_rgb_color(NORMAL) ((0, 65, 0), (0, 255, 0)) """ if color == INVERTED: foreground = (0, 255, 0) background = (0, 65, 0) elif color == NORMAL: foreground = (0, 65, 0) b...
[ "def", "get_rgb_color", "(", "color", ")", ":", "if", "color", "==", "INVERTED", ":", "foreground", "=", "(", "0", ",", "255", ",", "0", ")", "background", "=", "(", "0", ",", "65", ",", "0", ")", "elif", "color", "==", "NORMAL", ":", "foreground",...
>>> get_rgb_color(BLUE) ((0, 0, 0), (33, 16, 181)) >>> get_rgb_color(NORMAL) ((0, 65, 0), (0, 255, 0))
[ ">>>", "get_rgb_color", "(", "BLUE", ")", "((", "0", "0", "0", ")", "(", "33", "16", "181", "))" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/dragon_charmap.py#L57-L74
jedie/DragonPy
dragonpy/Dragon32/dragon_charmap.py
create_wiki_page
def create_wiki_page(): """ for http://archive.worldofdragon.org/index.php?title=CharMap """ print ( '{| class="wikitable"' ' style="font-family: monospace;' ' background-color:#ffffcc;"' ' cellpadding="10"' ) print("|-") print("! POKE") print("value") ...
python
def create_wiki_page(): """ for http://archive.worldofdragon.org/index.php?title=CharMap """ print ( '{| class="wikitable"' ' style="font-family: monospace;' ' background-color:#ffffcc;"' ' cellpadding="10"' ) print("|-") print("! POKE") print("value") ...
[ "def", "create_wiki_page", "(", ")", ":", "print", "(", "'{| class=\"wikitable\"'", "' style=\"font-family: monospace;'", "' background-color:#ffffcc;\"'", "' cellpadding=\"10\"'", ")", "print", "(", "\"|-\"", ")", "print", "(", "\"! POKE\"", ")", "print", "(", "\"value\"...
for http://archive.worldofdragon.org/index.php?title=CharMap
[ "for", "http", ":", "//", "archive", ".", "worldofdragon", ".", "org", "/", "index", ".", "php?title", "=", "CharMap" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/dragon_charmap.py#L218-L253
jedie/DragonPy
PyDC/PyDC/basic_tokens.py
bytes2codeline
def bytes2codeline(raw_bytes): """ >>> data = (0x87,0x20,0x22,0x48,0x45,0x4c,0x4c,0x4f,0x20,0x57,0x4f,0x52,0x4c,0x44,0x21,0x22) >>> bytes2codeline(data) 'PRINT "HELLO WORLD!"' """ code_line = "" func_token = False for byte_no in raw_bytes: if byte_no == 0xff: # Next byte is a fun...
python
def bytes2codeline(raw_bytes): """ >>> data = (0x87,0x20,0x22,0x48,0x45,0x4c,0x4c,0x4f,0x20,0x57,0x4f,0x52,0x4c,0x44,0x21,0x22) >>> bytes2codeline(data) 'PRINT "HELLO WORLD!"' """ code_line = "" func_token = False for byte_no in raw_bytes: if byte_no == 0xff: # Next byte is a fun...
[ "def", "bytes2codeline", "(", "raw_bytes", ")", ":", "code_line", "=", "\"\"", "func_token", "=", "False", "for", "byte_no", "in", "raw_bytes", ":", "if", "byte_no", "==", "0xff", ":", "# Next byte is a function token", "func_token", "=", "True", "continue", "el...
>>> data = (0x87,0x20,0x22,0x48,0x45,0x4c,0x4c,0x4f,0x20,0x57,0x4f,0x52,0x4c,0x44,0x21,0x22) >>> bytes2codeline(data) 'PRINT "HELLO WORLD!"'
[ ">>>", "data", "=", "(", "0x87", "0x20", "0x22", "0x48", "0x45", "0x4c", "0x4c", "0x4f", "0x20", "0x57", "0x4f", "0x52", "0x4c", "0x44", "0x21", "0x22", ")", ">>>", "bytes2codeline", "(", "data", ")", "PRINT", "HELLO", "WORLD!" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/basic_tokens.py#L130-L159
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.analyze
def analyze(self): """ Example output: 394Hz ( 28 Samples) exist: 1 613Hz ( 18 Samples) exist: 1 788Hz ( 14 Samples) exist: 1 919Hz ( 12 Samples) exist: 329 ********* 1002Hz ( 11 Samples) exist: 1704 **********************************...
python
def analyze(self): """ Example output: 394Hz ( 28 Samples) exist: 1 613Hz ( 18 Samples) exist: 1 788Hz ( 14 Samples) exist: 1 919Hz ( 12 Samples) exist: 329 ********* 1002Hz ( 11 Samples) exist: 1704 **********************************...
[ "def", "analyze", "(", "self", ")", ":", "log", ".", "debug", "(", "\"enable half sinus scan\"", ")", "self", ".", "half_sinus", "=", "True", "statistics", "=", "self", ".", "_get_statistics", "(", ")", "width", "=", "50", "max_count", "=", "max", "(", "...
Example output: 394Hz ( 28 Samples) exist: 1 613Hz ( 18 Samples) exist: 1 788Hz ( 14 Samples) exist: 1 919Hz ( 12 Samples) exist: 329 ********* 1002Hz ( 11 Samples) exist: 1704 ********************************************** 1103Hz ( 10 Sam...
[ "Example", "output", ":" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L167-L204
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.sync
def sync(self, length): """ synchronized weave sync trigger """ # go in wave stream to the first bit try: self.next() except StopIteration: print "Error: no bits identified!" sys.exit(-1) log.info("First bit is at: %s" % self....
python
def sync(self, length): """ synchronized weave sync trigger """ # go in wave stream to the first bit try: self.next() except StopIteration: print "Error: no bits identified!" sys.exit(-1) log.info("First bit is at: %s" % self....
[ "def", "sync", "(", "self", ",", "length", ")", ":", "# go in wave stream to the first bit", "try", ":", "self", ".", "next", "(", ")", "except", "StopIteration", ":", "print", "\"Error: no bits identified!\"", "sys", ".", "exit", "(", "-", "1", ")", "log", ...
synchronized weave sync trigger
[ "synchronized", "weave", "sync", "trigger" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L206-L242
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.iter_bitstream
def iter_bitstream(self, iter_duration_generator): """ iterate over self.iter_trigger() and yield the bits """ assert self.half_sinus == False # Allways trigger full sinus cycle # build min/max Hz values bit_nul_min_hz = self.cfg.BIT_NUL_HZ - self.cfg.HZ_VARIATIO...
python
def iter_bitstream(self, iter_duration_generator): """ iterate over self.iter_trigger() and yield the bits """ assert self.half_sinus == False # Allways trigger full sinus cycle # build min/max Hz values bit_nul_min_hz = self.cfg.BIT_NUL_HZ - self.cfg.HZ_VARIATIO...
[ "def", "iter_bitstream", "(", "self", ",", "iter_duration_generator", ")", ":", "assert", "self", ".", "half_sinus", "==", "False", "# Allways trigger full sinus cycle", "# build min/max Hz values", "bit_nul_min_hz", "=", "self", ".", "cfg", ".", "BIT_NUL_HZ", "-", "s...
iterate over self.iter_trigger() and yield the bits
[ "iterate", "over", "self", ".", "iter_trigger", "()", "and", "yield", "the", "bits" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L250-L345
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.iter_duration
def iter_duration(self, iter_trigger): """ yield the duration of two frames in a row. """ print process_info = ProcessInfo(self.frame_count, use_last_rates=4) start_time = time.time() next_status = start_time + 0.25 old_pos = next(iter_trigger) fo...
python
def iter_duration(self, iter_trigger): """ yield the duration of two frames in a row. """ print process_info = ProcessInfo(self.frame_count, use_last_rates=4) start_time = time.time() next_status = start_time + 0.25 old_pos = next(iter_trigger) fo...
[ "def", "iter_duration", "(", "self", ",", "iter_trigger", ")", ":", "print", "process_info", "=", "ProcessInfo", "(", "self", ".", "frame_count", ",", "use_last_rates", "=", "4", ")", "start_time", "=", "time", ".", "time", "(", ")", "next_status", "=", "s...
yield the duration of two frames in a row.
[ "yield", "the", "duration", "of", "two", "frames", "in", "a", "row", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L347-L368
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.iter_trigger
def iter_trigger(self, iter_wave_values): """ trigger middle crossing of the wave sinus curve """ window_size = (2 * self.cfg.END_COUNT) + self.cfg.MID_COUNT # sinus curve goes from negative into positive: pos_null_transit = [(0, self.cfg.END_COUNT), (self.cfg.END_COUNT,...
python
def iter_trigger(self, iter_wave_values): """ trigger middle crossing of the wave sinus curve """ window_size = (2 * self.cfg.END_COUNT) + self.cfg.MID_COUNT # sinus curve goes from negative into positive: pos_null_transit = [(0, self.cfg.END_COUNT), (self.cfg.END_COUNT,...
[ "def", "iter_trigger", "(", "self", ",", "iter_wave_values", ")", ":", "window_size", "=", "(", "2", "*", "self", ".", "cfg", ".", "END_COUNT", ")", "+", "self", ".", "cfg", ".", "MID_COUNT", "# sinus curve goes from negative into positive:", "pos_null_transit", ...
trigger middle crossing of the wave sinus curve
[ "trigger", "middle", "crossing", "of", "the", "wave", "sinus", "curve" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L370-L417
jedie/DragonPy
PyDC/PyDC/wave2bitstream.py
Wave2Bitstream.iter_wave_values
def iter_wave_values(self): """ yield frame numer + volume value from the WAVE file """ typecode = self.get_typecode(self.samplewidth) if log.level >= 5: if self.cfg.AVG_COUNT > 1: # merge samples -> log output in iter_avg_wave_values ...
python
def iter_wave_values(self): """ yield frame numer + volume value from the WAVE file """ typecode = self.get_typecode(self.samplewidth) if log.level >= 5: if self.cfg.AVG_COUNT > 1: # merge samples -> log output in iter_avg_wave_values ...
[ "def", "iter_wave_values", "(", "self", ")", ":", "typecode", "=", "self", ".", "get_typecode", "(", "self", ".", "samplewidth", ")", "if", "log", ".", "level", ">=", "5", ":", "if", "self", ".", "cfg", ".", "AVG_COUNT", ">", "1", ":", "# merge samples...
yield frame numer + volume value from the WAVE file
[ "yield", "frame", "numer", "+", "volume", "value", "from", "the", "WAVE", "file" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/wave2bitstream.py#L441-L510
jedie/DragonPy
dragonpy/utils/hex2bin.py
iter_steps
def iter_steps(g, steps): """ iterate over 'g' in blocks with a length of the given 'step' count. >>> for v in iter_steps([1,2,3,4,5], steps=2): v [1, 2] [3, 4] [5] >>> for v in iter_steps([1,2,3,4,5,6,7,8,9], steps=3): v [1, 2, 3] [4, 5, 6] [7, 8, 9] ...
python
def iter_steps(g, steps): """ iterate over 'g' in blocks with a length of the given 'step' count. >>> for v in iter_steps([1,2,3,4,5], steps=2): v [1, 2] [3, 4] [5] >>> for v in iter_steps([1,2,3,4,5,6,7,8,9], steps=3): v [1, 2, 3] [4, 5, 6] [7, 8, 9] ...
[ "def", "iter_steps", "(", "g", ",", "steps", ")", ":", "values", "=", "[", "]", "for", "value", "in", "g", ":", "values", ".", "append", "(", "value", ")", "if", "len", "(", "values", ")", "==", "steps", ":", "yield", "list", "(", "values", ")", ...
iterate over 'g' in blocks with a length of the given 'step' count. >>> for v in iter_steps([1,2,3,4,5], steps=2): v [1, 2] [3, 4] [5] >>> for v in iter_steps([1,2,3,4,5,6,7,8,9], steps=3): v [1, 2, 3] [4, 5, 6] [7, 8, 9] 12345678 12345678 ...
[ "iterate", "over", "g", "in", "blocks", "with", "a", "length", "of", "the", "given", "step", "count", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/hex2bin.py#L18-L46
jedie/DragonPy
dragonpy/components/memory.py
Memory.get
def get(self, start, end): """ used in unittests """ return [self.read_byte(addr) for addr in xrange(start, end)]
python
def get(self, start, end): """ used in unittests """ return [self.read_byte(addr) for addr in xrange(start, end)]
[ "def", "get", "(", "self", ",", "start", ",", "end", ")", ":", "return", "[", "self", ".", "read_byte", "(", "addr", ")", "for", "addr", "in", "xrange", "(", "start", ",", "end", ")", "]" ]
used in unittests
[ "used", "in", "unittests" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/components/memory.py#L308-L312
jedie/DragonPy
dragonpy/components/periphery.py
TkPeripheryBase._new_output_char
def _new_output_char(self, char): """ insert in text field """ self.text.config(state=tkinter.NORMAL) self.text.insert("end", char) self.text.see("end") self.text.config(state=tkinter.DISABLED)
python
def _new_output_char(self, char): """ insert in text field """ self.text.config(state=tkinter.NORMAL) self.text.insert("end", char) self.text.see("end") self.text.config(state=tkinter.DISABLED)
[ "def", "_new_output_char", "(", "self", ",", "char", ")", ":", "self", ".", "text", ".", "config", "(", "state", "=", "tkinter", ".", "NORMAL", ")", "self", ".", "text", ".", "insert", "(", "\"end\"", ",", "char", ")", "self", ".", "text", ".", "se...
insert in text field
[ "insert", "in", "text", "field" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/components/periphery.py#L209-L214
jedie/DragonPy
dragonpy/components/periphery.py
InputPollThread.check_cpu_interval
def check_cpu_interval(self, cpu_process): """ work-a-round for blocking input """ try: # log.critical("check_cpu_interval()") if not cpu_process.is_alive(): log.critical("raise SystemExit, because CPU is not alive.") _thread.interru...
python
def check_cpu_interval(self, cpu_process): """ work-a-round for blocking input """ try: # log.critical("check_cpu_interval()") if not cpu_process.is_alive(): log.critical("raise SystemExit, because CPU is not alive.") _thread.interru...
[ "def", "check_cpu_interval", "(", "self", ",", "cpu_process", ")", ":", "try", ":", "# log.critical(\"check_cpu_interval()\")", "if", "not", "cpu_process", ".", "is_alive", "(", ")", ":", "log", ".", "critical", "(", "\"raise SystemExit, because CPU is not al...
work-a-round for blocking input
[ "work", "-", "a", "-", "round", "for", "blocking", "input" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/components/periphery.py#L249-L263
jedie/DragonPy
dragonpy/Dragon32/gui_config.py
BaseTkinterGUIConfig.command_cycles_per_sec
def command_cycles_per_sec(self, event=None): """ TODO: refactor: move code to CPU! """ try: cycles_per_sec = self.cycles_per_sec_var.get() except ValueError: self.cycles_per_sec_var.set(self.runtime_cfg.cycles_per_sec) return self.cyc...
python
def command_cycles_per_sec(self, event=None): """ TODO: refactor: move code to CPU! """ try: cycles_per_sec = self.cycles_per_sec_var.get() except ValueError: self.cycles_per_sec_var.set(self.runtime_cfg.cycles_per_sec) return self.cyc...
[ "def", "command_cycles_per_sec", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "cycles_per_sec", "=", "self", ".", "cycles_per_sec_var", ".", "get", "(", ")", "except", "ValueError", ":", "self", ".", "cycles_per_sec_var", ".", "set", "(", ...
TODO: refactor: move code to CPU!
[ "TODO", ":", "refactor", ":", "move", "code", "to", "CPU!" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/gui_config.py#L209-L226
jedie/DragonPy
dragonpy/Dragon32/gui_config.py
BaseTkinterGUIConfig.command_max_delay
def command_max_delay(self, event=None): """ CPU burst max running time - self.runtime_cfg.max_delay """ try: max_delay = self.max_delay_var.get() except ValueError: max_delay = self.runtime_cfg.max_delay if max_delay < 0: max_delay = self.runtime_cfg...
python
def command_max_delay(self, event=None): """ CPU burst max running time - self.runtime_cfg.max_delay """ try: max_delay = self.max_delay_var.get() except ValueError: max_delay = self.runtime_cfg.max_delay if max_delay < 0: max_delay = self.runtime_cfg...
[ "def", "command_max_delay", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "max_delay", "=", "self", ".", "max_delay_var", ".", "get", "(", ")", "except", "ValueError", ":", "max_delay", "=", "self", ".", "runtime_cfg", ".", "max_delay", "...
CPU burst max running time - self.runtime_cfg.max_delay
[ "CPU", "burst", "max", "running", "time", "-", "self", ".", "runtime_cfg", ".", "max_delay" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/gui_config.py#L228-L242
jedie/DragonPy
dragonpy/Dragon32/gui_config.py
BaseTkinterGUIConfig.command_inner_burst_op_count
def command_inner_burst_op_count(self, event=None): """ CPU burst max running time - self.runtime_cfg.inner_burst_op_count """ try: inner_burst_op_count = self.inner_burst_op_count_var.get() except ValueError: inner_burst_op_count = self.runtime_cfg.inner_burst_op_count ...
python
def command_inner_burst_op_count(self, event=None): """ CPU burst max running time - self.runtime_cfg.inner_burst_op_count """ try: inner_burst_op_count = self.inner_burst_op_count_var.get() except ValueError: inner_burst_op_count = self.runtime_cfg.inner_burst_op_count ...
[ "def", "command_inner_burst_op_count", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "inner_burst_op_count", "=", "self", ".", "inner_burst_op_count_var", ".", "get", "(", ")", "except", "ValueError", ":", "inner_burst_op_count", "=", "self", "."...
CPU burst max running time - self.runtime_cfg.inner_burst_op_count
[ "CPU", "burst", "max", "running", "time", "-", "self", ".", "runtime_cfg", ".", "inner_burst_op_count" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/gui_config.py#L244-L255
jedie/DragonPy
dragonpy/Dragon32/gui_config.py
BaseTkinterGUIConfig.command_max_burst_count
def command_max_burst_count(self, event=None): """ max CPU burst op count - self.runtime_cfg.max_burst_count """ try: max_burst_count = self.max_burst_count_var.get() except ValueError: max_burst_count = self.runtime_cfg.max_burst_count if max_burst_count < 1: ...
python
def command_max_burst_count(self, event=None): """ max CPU burst op count - self.runtime_cfg.max_burst_count """ try: max_burst_count = self.max_burst_count_var.get() except ValueError: max_burst_count = self.runtime_cfg.max_burst_count if max_burst_count < 1: ...
[ "def", "command_max_burst_count", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "max_burst_count", "=", "self", ".", "max_burst_count_var", ".", "get", "(", ")", "except", "ValueError", ":", "max_burst_count", "=", "self", ".", "runtime_cfg", ...
max CPU burst op count - self.runtime_cfg.max_burst_count
[ "max", "CPU", "burst", "op", "count", "-", "self", ".", "runtime_cfg", ".", "max_burst_count" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/gui_config.py#L257-L268
jedie/DragonPy
dragonpy/Dragon32/gui_config.py
BaseTkinterGUIConfig.command_max_run_time
def command_max_run_time(self, event=None): """ CPU burst max running time - self.runtime_cfg.max_run_time """ try: max_run_time = self.max_run_time_var.get() except ValueError: max_run_time = self.runtime_cfg.max_run_time self.runtime_cfg.max_run_time = max_run_...
python
def command_max_run_time(self, event=None): """ CPU burst max running time - self.runtime_cfg.max_run_time """ try: max_run_time = self.max_run_time_var.get() except ValueError: max_run_time = self.runtime_cfg.max_run_time self.runtime_cfg.max_run_time = max_run_...
[ "def", "command_max_run_time", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "max_run_time", "=", "self", ".", "max_run_time_var", ".", "get", "(", ")", "except", "ValueError", ":", "max_run_time", "=", "self", ".", "runtime_cfg", ".", "max...
CPU burst max running time - self.runtime_cfg.max_run_time
[ "CPU", "burst", "max", "running", "time", "-", "self", ".", "runtime_cfg", ".", "max_run_time" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/Dragon32/gui_config.py#L270-L278
jedie/DragonPy
dragonpy/core/cli.py
cli
def cli(ctx, **kwargs): """ DragonPy is a Open source (GPL v3 or later) emulator for the 30 years old homecomputer Dragon 32 and Tandy TRS-80 Color Computer (CoCo)... Homepage: https://github.com/jedie/DragonPy """ log.critical("cli kwargs: %s", repr(kwargs)) ctx.obj = CliConfig(**kwarg...
python
def cli(ctx, **kwargs): """ DragonPy is a Open source (GPL v3 or later) emulator for the 30 years old homecomputer Dragon 32 and Tandy TRS-80 Color Computer (CoCo)... Homepage: https://github.com/jedie/DragonPy """ log.critical("cli kwargs: %s", repr(kwargs)) ctx.obj = CliConfig(**kwarg...
[ "def", "cli", "(", "ctx", ",", "*", "*", "kwargs", ")", ":", "log", ".", "critical", "(", "\"cli kwargs: %s\"", ",", "repr", "(", "kwargs", ")", ")", "ctx", ".", "obj", "=", "CliConfig", "(", "*", "*", "kwargs", ")" ]
DragonPy is a Open source (GPL v3 or later) emulator for the 30 years old homecomputer Dragon 32 and Tandy TRS-80 Color Computer (CoCo)... Homepage: https://github.com/jedie/DragonPy
[ "DragonPy", "is", "a", "Open", "source", "(", "GPL", "v3", "or", "later", ")", "emulator", "for", "the", "30", "years", "old", "homecomputer", "Dragon", "32", "and", "Tandy", "TRS", "-", "80", "Color", "Computer", "(", "CoCo", ")", "..." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/cli.py#L147-L156
jedie/DragonPy
dragonpy/utils/pager.py
_windows_get_window_size
def _windows_get_window_size(): """Return (width, height) of available window area on Windows. (0, 0) if no console is allocated. """ sbi = CONSOLE_SCREEN_BUFFER_INFO() ret = windll.kernel32.GetConsoleScreenBufferInfo(console_handle, byref(sbi)) if ret == 0: return (0, 0) return (...
python
def _windows_get_window_size(): """Return (width, height) of available window area on Windows. (0, 0) if no console is allocated. """ sbi = CONSOLE_SCREEN_BUFFER_INFO() ret = windll.kernel32.GetConsoleScreenBufferInfo(console_handle, byref(sbi)) if ret == 0: return (0, 0) return (...
[ "def", "_windows_get_window_size", "(", ")", ":", "sbi", "=", "CONSOLE_SCREEN_BUFFER_INFO", "(", ")", "ret", "=", "windll", ".", "kernel32", ".", "GetConsoleScreenBufferInfo", "(", "console_handle", ",", "byref", "(", "sbi", ")", ")", "if", "ret", "==", "0", ...
Return (width, height) of available window area on Windows. (0, 0) if no console is allocated.
[ "Return", "(", "width", "height", ")", "of", "available", "window", "area", "on", "Windows", ".", "(", "0", "0", ")", "if", "no", "console", "is", "allocated", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L64-L73
jedie/DragonPy
dragonpy/utils/pager.py
_posix_get_window_size
def _posix_get_window_size(): """Return (width, height) of console terminal on POSIX system. (0, 0) on IOError, i.e. when no console is allocated. """ # see README.txt for reference information # http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html from fcntl import ioctl ...
python
def _posix_get_window_size(): """Return (width, height) of console terminal on POSIX system. (0, 0) on IOError, i.e. when no console is allocated. """ # see README.txt for reference information # http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html from fcntl import ioctl ...
[ "def", "_posix_get_window_size", "(", ")", ":", "# see README.txt for reference information", "# http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html", "from", "fcntl", "import", "ioctl", "from", "termios", "import", "TIOCGWINSZ", "from", "array", "import", "arr...
Return (width, height) of console terminal on POSIX system. (0, 0) on IOError, i.e. when no console is allocated.
[ "Return", "(", "width", "height", ")", "of", "console", "terminal", "on", "POSIX", "system", ".", "(", "0", "0", ")", "on", "IOError", "i", ".", "e", ".", "when", "no", "console", "is", "allocated", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L75-L102
jedie/DragonPy
dragonpy/utils/pager.py
dumpkey
def dumpkey(key): """ Helper to convert result of `getch` (string) or `getchars` (list) to hex string. """ def hex3fy(key): """Helper to convert string into hex string (Python 3 compatible)""" from binascii import hexlify # Python 3 strings are no longer binary, encode them f...
python
def dumpkey(key): """ Helper to convert result of `getch` (string) or `getchars` (list) to hex string. """ def hex3fy(key): """Helper to convert string into hex string (Python 3 compatible)""" from binascii import hexlify # Python 3 strings are no longer binary, encode them f...
[ "def", "dumpkey", "(", "key", ")", ":", "def", "hex3fy", "(", "key", ")", ":", "\"\"\"Helper to convert string into hex string (Python 3 compatible)\"\"\"", "from", "binascii", "import", "hexlify", "# Python 3 strings are no longer binary, encode them for hexlify()", "if", "PY3...
Helper to convert result of `getch` (string) or `getchars` (list) to hex string.
[ "Helper", "to", "convert", "result", "of", "getch", "(", "string", ")", "or", "getchars", "(", "list", ")", "to", "hex", "string", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L170-L188
jedie/DragonPy
dragonpy/utils/pager.py
_getch_unix
def _getch_unix(_getall=False): """ # --- current algorithm --- # 1. switch to char-by-char input mode # 2. turn off echo # 3. wait for at least one char to appear # 4. read the rest of the character buffer (_getall=True) # 5. return list of characters (_getall on) # or a single c...
python
def _getch_unix(_getall=False): """ # --- current algorithm --- # 1. switch to char-by-char input mode # 2. turn off echo # 3. wait for at least one char to appear # 4. read the rest of the character buffer (_getall=True) # 5. return list of characters (_getall on) # or a single c...
[ "def", "_getch_unix", "(", "_getall", "=", "False", ")", ":", "import", "sys", ",", "termios", "fd", "=", "sys", ".", "stdin", ".", "fileno", "(", ")", "# save old terminal settings", "old_settings", "=", "termios", ".", "tcgetattr", "(", "fd", ")", "chars...
# --- current algorithm --- # 1. switch to char-by-char input mode # 2. turn off echo # 3. wait for at least one char to appear # 4. read the rest of the character buffer (_getall=True) # 5. return list of characters (_getall on) # or a single char (_getall off)
[ "#", "---", "current", "algorithm", "---", "#", "1", ".", "switch", "to", "char", "-", "by", "-", "char", "input", "mode", "#", "2", ".", "turn", "off", "echo", "#", "3", ".", "wait", "for", "at", "least", "one", "char", "to", "appear", "#", "4",...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L208-L265
jedie/DragonPy
dragonpy/utils/pager.py
prompt
def prompt(pagenum): """ Show default prompt to continue and process keypress. It assumes terminal/console understands carriage return \r character. """ prompt = "Page -%s-. Press any key to continue . . . " % pagenum echo(prompt) if getch() in [ESC_, CTRL_C_, 'q', 'Q']: return Fals...
python
def prompt(pagenum): """ Show default prompt to continue and process keypress. It assumes terminal/console understands carriage return \r character. """ prompt = "Page -%s-. Press any key to continue . . . " % pagenum echo(prompt) if getch() in [ESC_, CTRL_C_, 'q', 'Q']: return Fals...
[ "def", "prompt", "(", "pagenum", ")", ":", "prompt", "=", "\"Page -%s-. Press any key to continue . . . \"", "%", "pagenum", "echo", "(", "prompt", ")", "if", "getch", "(", ")", "in", "[", "ESC_", ",", "CTRL_C_", ",", "'q'", ",", "'Q'", "]", ":", "return",...
Show default prompt to continue and process keypress. It assumes terminal/console understands carriage return \r character.
[ "Show", "default", "prompt", "to", "continue", "and", "process", "keypress", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L311-L321
jedie/DragonPy
dragonpy/utils/pager.py
page
def page(content, pagecallback=prompt): """ Output `content`, call `pagecallback` after every page with page number as a parameter. `pagecallback` may return False to terminate pagination. Default callback shows prompt, waits for keypress and aborts on 'q', ESC or Ctrl-C. """ width = ge...
python
def page(content, pagecallback=prompt): """ Output `content`, call `pagecallback` after every page with page number as a parameter. `pagecallback` may return False to terminate pagination. Default callback shows prompt, waits for keypress and aborts on 'q', ESC or Ctrl-C. """ width = ge...
[ "def", "page", "(", "content", ",", "pagecallback", "=", "prompt", ")", ":", "width", "=", "getwidth", "(", ")", "height", "=", "getheight", "(", ")", "pagenum", "=", "1", "try", ":", "try", ":", "line", "=", "content", ".", "next", "(", ")", ".", ...
Output `content`, call `pagecallback` after every page with page number as a parameter. `pagecallback` may return False to terminate pagination. Default callback shows prompt, waits for keypress and aborts on 'q', ESC or Ctrl-C.
[ "Output", "content", "call", "pagecallback", "after", "every", "page", "with", "page", "number", "as", "a", "parameter", ".", "pagecallback", "may", "return", "False", "to", "terminate", "pagination", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/pager.py#L323-L377
jedie/DragonPy
dragonpy/sbc09/create_trace.py
reformat_v09_trace
def reformat_v09_trace(raw_trace, max_lines=None): """ reformat v09 trace simmilar to XRoar one and add CC and Memory-Information. Note: v09 traces contains the register info line one trace line later! We reoder it as XRoar done: addr+Opcode with resulted registers """ print() ...
python
def reformat_v09_trace(raw_trace, max_lines=None): """ reformat v09 trace simmilar to XRoar one and add CC and Memory-Information. Note: v09 traces contains the register info line one trace line later! We reoder it as XRoar done: addr+Opcode with resulted registers """ print() ...
[ "def", "reformat_v09_trace", "(", "raw_trace", ",", "max_lines", "=", "None", ")", ":", "print", "(", ")", "print", "(", "\"Reformat v09 trace...\"", ")", "mem_info", "=", "SBC09MemInfo", "(", "sys", ".", "stderr", ")", "result", "=", "[", "]", "next_update"...
reformat v09 trace simmilar to XRoar one and add CC and Memory-Information. Note: v09 traces contains the register info line one trace line later! We reoder it as XRoar done: addr+Opcode with resulted registers
[ "reformat", "v09", "trace", "simmilar", "to", "XRoar", "one", "and", "add", "CC", "and", "Memory", "-", "Information", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/sbc09/create_trace.py#L88-L157
jedie/DragonPy
PyDC/PyDC/utils.py
human_duration
def human_duration(t): """ Converts a time duration into a friendly text representation. >>> human_duration("type error") Traceback (most recent call last): ... TypeError: human_duration() argument must be integer or float >>> human_duration(0.01) u'10.0 ms' >>> human_duration(0.9)...
python
def human_duration(t): """ Converts a time duration into a friendly text representation. >>> human_duration("type error") Traceback (most recent call last): ... TypeError: human_duration() argument must be integer or float >>> human_duration(0.01) u'10.0 ms' >>> human_duration(0.9)...
[ "def", "human_duration", "(", "t", ")", ":", "if", "not", "isinstance", "(", "t", ",", "(", "int", ",", "float", ")", ")", ":", "raise", "TypeError", "(", "\"human_duration() argument must be integer or float\"", ")", "chunks", "=", "(", "(", "60", "*", "6...
Converts a time duration into a friendly text representation. >>> human_duration("type error") Traceback (most recent call last): ... TypeError: human_duration() argument must be integer or float >>> human_duration(0.01) u'10.0 ms' >>> human_duration(0.9) u'900.0 ms' >>> human_dura...
[ "Converts", "a", "time", "duration", "into", "a", "friendly", "text", "representation", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L29-L76
jedie/DragonPy
PyDC/PyDC/utils.py
average
def average(old_avg, current_value, count): """ Calculate the average. Count must start with 0 >>> average(None, 3.23, 0) 3.23 >>> average(0, 1, 0) 1.0 >>> average(2.5, 5, 4) 3.0 """ if old_avg is None: return current_value return (float(old_avg) * count + current_va...
python
def average(old_avg, current_value, count): """ Calculate the average. Count must start with 0 >>> average(None, 3.23, 0) 3.23 >>> average(0, 1, 0) 1.0 >>> average(2.5, 5, 4) 3.0 """ if old_avg is None: return current_value return (float(old_avg) * count + current_va...
[ "def", "average", "(", "old_avg", ",", "current_value", ",", "count", ")", ":", "if", "old_avg", "is", "None", ":", "return", "current_value", "return", "(", "float", "(", "old_avg", ")", "*", "count", "+", "current_value", ")", "/", "(", "count", "+", ...
Calculate the average. Count must start with 0 >>> average(None, 3.23, 0) 3.23 >>> average(0, 1, 0) 1.0 >>> average(2.5, 5, 4) 3.0
[ "Calculate", "the", "average", ".", "Count", "must", "start", "with", "0" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L111-L124
jedie/DragonPy
PyDC/PyDC/utils.py
iter_window
def iter_window(g, window_size): """ interate over 'g' bit-by-bit and yield a window with the given 'window_size' width. >>> for v in iter_window([1,2,3,4], window_size=2): v [1, 2] [2, 3] [3, 4] >>> for v in iter_window([1,2,3,4,5], window_size=3): v [1, 2, 3] [2, 3, 4] [3, 4, ...
python
def iter_window(g, window_size): """ interate over 'g' bit-by-bit and yield a window with the given 'window_size' width. >>> for v in iter_window([1,2,3,4], window_size=2): v [1, 2] [2, 3] [3, 4] >>> for v in iter_window([1,2,3,4,5], window_size=3): v [1, 2, 3] [2, 3, 4] [3, 4, ...
[ "def", "iter_window", "(", "g", ",", "window_size", ")", ":", "values", "=", "collections", ".", "deque", "(", "maxlen", "=", "window_size", ")", "for", "value", "in", "g", ":", "values", ".", "append", "(", "value", ")", "if", "len", "(", "values", ...
interate over 'g' bit-by-bit and yield a window with the given 'window_size' width. >>> for v in iter_window([1,2,3,4], window_size=2): v [1, 2] [2, 3] [3, 4] >>> for v in iter_window([1,2,3,4,5], window_size=3): v [1, 2, 3] [2, 3, 4] [3, 4, 5] >>> for v in iter_window([1,2,3,4], w...
[ "interate", "over", "g", "bit", "-", "by", "-", "bit", "and", "yield", "a", "window", "with", "the", "given", "window_size", "width", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L158-L182
jedie/DragonPy
PyDC/PyDC/utils.py
count_continuous_pattern
def count_continuous_pattern(bitstream, pattern): """ >>> pattern = list(bytes2bit_strings("A")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> count_continuous_pattern(bitstream, pattern) 3 >>> pattern = list(bytes2bit_strings("X")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> coun...
python
def count_continuous_pattern(bitstream, pattern): """ >>> pattern = list(bytes2bit_strings("A")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> count_continuous_pattern(bitstream, pattern) 3 >>> pattern = list(bytes2bit_strings("X")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> coun...
[ "def", "count_continuous_pattern", "(", "bitstream", ",", "pattern", ")", ":", "assert", "isinstance", "(", "bitstream", ",", "(", "collections", ".", "Iterable", ",", "types", ".", "GeneratorType", ")", ")", "assert", "isinstance", "(", "pattern", ",", "(", ...
>>> pattern = list(bytes2bit_strings("A")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> count_continuous_pattern(bitstream, pattern) 3 >>> pattern = list(bytes2bit_strings("X")) >>> bitstream = bytes2bit_strings("AAAXXX") >>> count_continuous_pattern(bitstream, pattern) 0
[ ">>>", "pattern", "=", "list", "(", "bytes2bit_strings", "(", "A", "))", ">>>", "bitstream", "=", "bytes2bit_strings", "(", "AAAXXX", ")", ">>>", "count_continuous_pattern", "(", "bitstream", "pattern", ")", "3" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L185-L208
jedie/DragonPy
PyDC/PyDC/utils.py
find_iter_window
def find_iter_window(bitstream, pattern, max_pos=None): """ >>> pattern = list(bytes2bit_strings("B")) >>> bitstream = bytes2bit_strings("AAABCCC") >>> find_iter_window(bitstream, pattern) 24 >>> "".join(list(bitstream2string(bitstream))) 'CCC' >>> find_iter_window(bytes2bit_strings("HE...
python
def find_iter_window(bitstream, pattern, max_pos=None): """ >>> pattern = list(bytes2bit_strings("B")) >>> bitstream = bytes2bit_strings("AAABCCC") >>> find_iter_window(bitstream, pattern) 24 >>> "".join(list(bitstream2string(bitstream))) 'CCC' >>> find_iter_window(bytes2bit_strings("HE...
[ "def", "find_iter_window", "(", "bitstream", ",", "pattern", ",", "max_pos", "=", "None", ")", ":", "assert", "isinstance", "(", "bitstream", ",", "(", "collections", ".", "Iterable", ",", "types", ".", "GeneratorType", ")", ")", "assert", "isinstance", "(",...
>>> pattern = list(bytes2bit_strings("B")) >>> bitstream = bytes2bit_strings("AAABCCC") >>> find_iter_window(bitstream, pattern) 24 >>> "".join(list(bitstream2string(bitstream))) 'CCC' >>> find_iter_window(bytes2bit_strings("HELLO!"), list(bytes2bit_strings("LO"))) 24 >>> find_iter_win...
[ ">>>", "pattern", "=", "list", "(", "bytes2bit_strings", "(", "B", "))", ">>>", "bitstream", "=", "bytes2bit_strings", "(", "AAABCCC", ")", ">>>", "find_iter_window", "(", "bitstream", "pattern", ")", "24", ">>>", ".", "join", "(", "list", "(", "bitstream2st...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L217-L250
jedie/DragonPy
PyDC/PyDC/utils.py
count_the_same
def count_the_same(iterable, sentinel): """ >>> count_the_same([0x55,0x55,0x55,0x55,0x3C,"foo","bar"],0x55) (4, 60) >>> 0x3C == 60 True """ count = 0 x = None for count, x in enumerate(iterable): if x != sentinel: break return count, x
python
def count_the_same(iterable, sentinel): """ >>> count_the_same([0x55,0x55,0x55,0x55,0x3C,"foo","bar"],0x55) (4, 60) >>> 0x3C == 60 True """ count = 0 x = None for count, x in enumerate(iterable): if x != sentinel: break return count, x
[ "def", "count_the_same", "(", "iterable", ",", "sentinel", ")", ":", "count", "=", "0", "x", "=", "None", "for", "count", ",", "x", "in", "enumerate", "(", "iterable", ")", ":", "if", "x", "!=", "sentinel", ":", "break", "return", "count", ",", "x" ]
>>> count_the_same([0x55,0x55,0x55,0x55,0x3C,"foo","bar"],0x55) (4, 60) >>> 0x3C == 60 True
[ ">>>", "count_the_same", "(", "[", "0x55", "0x55", "0x55", "0x55", "0x3C", "foo", "bar", "]", "0x55", ")", "(", "4", "60", ")", ">>>", "0x3C", "==", "60", "True" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L253-L265
jedie/DragonPy
PyDC/PyDC/utils.py
diff_info
def diff_info(data): """ >>> diff_info([5,5,10,10,5,5,10,10]) (0, 15) >>> diff_info([5,10,10,5,5,10,10,5]) (15, 0) """ def get_diff(l): diff = 0 for no1, no2 in iter_steps(l, steps=2): diff += abs(no1 - no2) return diff data1 = data[2:] diff1 = ge...
python
def diff_info(data): """ >>> diff_info([5,5,10,10,5,5,10,10]) (0, 15) >>> diff_info([5,10,10,5,5,10,10,5]) (15, 0) """ def get_diff(l): diff = 0 for no1, no2 in iter_steps(l, steps=2): diff += abs(no1 - no2) return diff data1 = data[2:] diff1 = ge...
[ "def", "diff_info", "(", "data", ")", ":", "def", "get_diff", "(", "l", ")", ":", "diff", "=", "0", "for", "no1", ",", "no2", "in", "iter_steps", "(", "l", ",", "steps", "=", "2", ")", ":", "diff", "+=", "abs", "(", "no1", "-", "no2", ")", "r...
>>> diff_info([5,5,10,10,5,5,10,10]) (0, 15) >>> diff_info([5,10,10,5,5,10,10,5]) (15, 0)
[ ">>>", "diff_info", "(", "[", "5", "5", "10", "10", "5", "5", "10", "10", "]", ")", "(", "0", "15", ")", ">>>", "diff_info", "(", "[", "5", "10", "10", "5", "5", "10", "10", "5", "]", ")", "(", "15", "0", ")" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L268-L287
jedie/DragonPy
PyDC/PyDC/utils.py
count_sign
def count_sign(values, min_value): """ >>> count_sign([3,-1,-2], 0) (1, 2) >>> count_sign([3,-1,-2], 2) (1, 0) >>> count_sign([0,-1],0) (0, 1) """ positive_count = 0 negative_count = 0 for value in values: if value > min_value: positive_count += 1 ...
python
def count_sign(values, min_value): """ >>> count_sign([3,-1,-2], 0) (1, 2) >>> count_sign([3,-1,-2], 2) (1, 0) >>> count_sign([0,-1],0) (0, 1) """ positive_count = 0 negative_count = 0 for value in values: if value > min_value: positive_count += 1 ...
[ "def", "count_sign", "(", "values", ",", "min_value", ")", ":", "positive_count", "=", "0", "negative_count", "=", "0", "for", "value", "in", "values", ":", "if", "value", ">", "min_value", ":", "positive_count", "+=", "1", "elif", "value", "<", "-", "mi...
>>> count_sign([3,-1,-2], 0) (1, 2) >>> count_sign([3,-1,-2], 2) (1, 0) >>> count_sign([0,-1],0) (0, 1)
[ ">>>", "count_sign", "(", "[", "3", "-", "1", "-", "2", "]", "0", ")", "(", "1", "2", ")", ">>>", "count_sign", "(", "[", "3", "-", "1", "-", "2", "]", "2", ")", "(", "1", "0", ")", ">>>", "count_sign", "(", "[", "0", "-", "1", "]", "0"...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L363-L379
jedie/DragonPy
PyDC/PyDC/utils.py
bits2codepoint
def bits2codepoint(bits): """ >>> c = bits2codepoint([0, 0, 0, 1, 0, 0, 1, 0]) >>> c 72 >>> chr(c) 'H' >>> bits2codepoint("00010010") 72 >>> bits2codepoint([0, 0, 1, 1, 0, 0, 1, 0]) 76 """ bit_string = "".join([str(c) for c in reversed(bits)]) return int(bit_string,...
python
def bits2codepoint(bits): """ >>> c = bits2codepoint([0, 0, 0, 1, 0, 0, 1, 0]) >>> c 72 >>> chr(c) 'H' >>> bits2codepoint("00010010") 72 >>> bits2codepoint([0, 0, 1, 1, 0, 0, 1, 0]) 76 """ bit_string = "".join([str(c) for c in reversed(bits)]) return int(bit_string,...
[ "def", "bits2codepoint", "(", "bits", ")", ":", "bit_string", "=", "\"\"", ".", "join", "(", "[", "str", "(", "c", ")", "for", "c", "in", "reversed", "(", "bits", ")", "]", ")", "return", "int", "(", "bit_string", ",", "2", ")" ]
>>> c = bits2codepoint([0, 0, 0, 1, 0, 0, 1, 0]) >>> c 72 >>> chr(c) 'H' >>> bits2codepoint("00010010") 72 >>> bits2codepoint([0, 0, 1, 1, 0, 0, 1, 0]) 76
[ ">>>", "c", "=", "bits2codepoint", "(", "[", "0", "0", "0", "1", "0", "0", "1", "0", "]", ")", ">>>", "c", "72", ">>>", "chr", "(", "c", ")", "H" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L397-L412
jedie/DragonPy
PyDC/PyDC/utils.py
byte2bit_string
def byte2bit_string(data): """ >>> byte2bit_string("H") '00010010' >>> byte2bit_string(0x55) '10101010' """ if isinstance(data, basestring): assert len(data) == 1 data = ord(data) bits = '{0:08b}'.format(data) bits = bits[::-1] return bits
python
def byte2bit_string(data): """ >>> byte2bit_string("H") '00010010' >>> byte2bit_string(0x55) '10101010' """ if isinstance(data, basestring): assert len(data) == 1 data = ord(data) bits = '{0:08b}'.format(data) bits = bits[::-1] return bits
[ "def", "byte2bit_string", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "basestring", ")", ":", "assert", "len", "(", "data", ")", "==", "1", "data", "=", "ord", "(", "data", ")", "bits", "=", "'{0:08b}'", ".", "format", "(", "data", ...
>>> byte2bit_string("H") '00010010' >>> byte2bit_string(0x55) '10101010'
[ ">>>", "byte2bit_string", "(", "H", ")", "00010010" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L450-L464
jedie/DragonPy
PyDC/PyDC/utils.py
codepoints2bitstream
def codepoints2bitstream(codepoints): """ >>> list(codepoints2bitstream([0x48,0x45])) [0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0] >>> list(codepoints2bitstream(0x48)) [0, 0, 0, 1, 0, 0, 1, 0] """ if isinstance(codepoints, int): codepoints = [codepoints] for codepoint in code...
python
def codepoints2bitstream(codepoints): """ >>> list(codepoints2bitstream([0x48,0x45])) [0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0] >>> list(codepoints2bitstream(0x48)) [0, 0, 0, 1, 0, 0, 1, 0] """ if isinstance(codepoints, int): codepoints = [codepoints] for codepoint in code...
[ "def", "codepoints2bitstream", "(", "codepoints", ")", ":", "if", "isinstance", "(", "codepoints", ",", "int", ")", ":", "codepoints", "=", "[", "codepoints", "]", "for", "codepoint", "in", "codepoints", ":", "bit_string", "=", "byte2bit_string", "(", "codepoi...
>>> list(codepoints2bitstream([0x48,0x45])) [0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0] >>> list(codepoints2bitstream(0x48)) [0, 0, 0, 1, 0, 0, 1, 0]
[ ">>>", "list", "(", "codepoints2bitstream", "(", "[", "0x48", "0x45", "]", "))", "[", "0", "0", "0", "1", "0", "0", "1", "0", "1", "0", "1", "0", "0", "0", "1", "0", "]", ">>>", "list", "(", "codepoints2bitstream", "(", "0x48", "))", "[", "0", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L466-L478
jedie/DragonPy
PyDC/PyDC/utils.py
print_codepoint_stream
def print_codepoint_stream(codepoint_stream, display_block_count=8, no_repr=False): """ >>> def g(txt): ... for c in txt: yield ord(c) >>> codepoint_stream = g("HELLO!") >>> print_codepoint_stream(codepoint_stream) ... # doctest: +NORMALIZE_WHITESPACE 6 | 0x48 'H' | 0x45 'E' | 0x4c 'L...
python
def print_codepoint_stream(codepoint_stream, display_block_count=8, no_repr=False): """ >>> def g(txt): ... for c in txt: yield ord(c) >>> codepoint_stream = g("HELLO!") >>> print_codepoint_stream(codepoint_stream) ... # doctest: +NORMALIZE_WHITESPACE 6 | 0x48 'H' | 0x45 'E' | 0x4c 'L...
[ "def", "print_codepoint_stream", "(", "codepoint_stream", ",", "display_block_count", "=", "8", ",", "no_repr", "=", "False", ")", ":", "in_line_count", "=", "0", "line", "=", "[", "]", "for", "no", ",", "codepoint", "in", "enumerate", "(", "codepoint_stream",...
>>> def g(txt): ... for c in txt: yield ord(c) >>> codepoint_stream = g("HELLO!") >>> print_codepoint_stream(codepoint_stream) ... # doctest: +NORMALIZE_WHITESPACE 6 | 0x48 'H' | 0x45 'E' | 0x4c 'L' | 0x4c 'L' | 0x4f 'O' | 0x21 '!' |
[ ">>>", "def", "g", "(", "txt", ")", ":", "...", "for", "c", "in", "txt", ":", "yield", "ord", "(", "c", ")", ">>>", "codepoint_stream", "=", "g", "(", "HELLO!", ")", ">>>", "print_codepoint_stream", "(", "codepoint_stream", ")", "...", "#", "doctest", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L523-L553
jedie/DragonPy
PyDC/PyDC/utils.py
pformat_codepoints
def pformat_codepoints(codepoints): """ >>> l = pformat_codepoints([13, 70, 111, 111, 32, 66, 97, 114, 32, 33, 13]) >>> repr(l) "['\\\\r', 'Foo Bar !', '\\\\r']" """ printable = string.printable.replace("\n", "").replace("\r", "") line = [] strings = "" for codepoint in codepoints: ...
python
def pformat_codepoints(codepoints): """ >>> l = pformat_codepoints([13, 70, 111, 111, 32, 66, 97, 114, 32, 33, 13]) >>> repr(l) "['\\\\r', 'Foo Bar !', '\\\\r']" """ printable = string.printable.replace("\n", "").replace("\r", "") line = [] strings = "" for codepoint in codepoints: ...
[ "def", "pformat_codepoints", "(", "codepoints", ")", ":", "printable", "=", "string", ".", "printable", ".", "replace", "(", "\"\\n\"", ",", "\"\"", ")", ".", "replace", "(", "\"\\r\"", ",", "\"\"", ")", "line", "=", "[", "]", "strings", "=", "\"\"", "...
>>> l = pformat_codepoints([13, 70, 111, 111, 32, 66, 97, 114, 32, 33, 13]) >>> repr(l) "['\\\\r', 'Foo Bar !', '\\\\r']"
[ ">>>", "l", "=", "pformat_codepoints", "(", "[", "13", "70", "111", "111", "32", "66", "97", "114", "32", "33", "13", "]", ")", ">>>", "repr", "(", "l", ")", "[", "\\\\\\\\", "r", "Foo", "Bar", "!", "\\\\\\\\", "r", "]" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L563-L581
jedie/DragonPy
PyDC/PyDC/utils.py
print_block_bit_list
def print_block_bit_list(block_bit_list, display_block_count=8, no_repr=False): """ >>> bit_list = ( ... [0,0,1,1,0,0,1,0], # L ... [1,0,0,1,0,0,1,0], # I ... ) >>> print_block_bit_list(bit_list) ... # doctest: +NORMALIZE_WHITESPACE 2 - 00110010 10010010 0x4c 'L' 0x49 'I' ...
python
def print_block_bit_list(block_bit_list, display_block_count=8, no_repr=False): """ >>> bit_list = ( ... [0,0,1,1,0,0,1,0], # L ... [1,0,0,1,0,0,1,0], # I ... ) >>> print_block_bit_list(bit_list) ... # doctest: +NORMALIZE_WHITESPACE 2 - 00110010 10010010 0x4c 'L' 0x49 'I' ...
[ "def", "print_block_bit_list", "(", "block_bit_list", ",", "display_block_count", "=", "8", ",", "no_repr", "=", "False", ")", ":", "def", "print_line", "(", "no", ",", "line", ",", "line_info", ")", ":", "print", "\"%4s - %s\"", "%", "(", "no", ",", "line...
>>> bit_list = ( ... [0,0,1,1,0,0,1,0], # L ... [1,0,0,1,0,0,1,0], # I ... ) >>> print_block_bit_list(bit_list) ... # doctest: +NORMALIZE_WHITESPACE 2 - 00110010 10010010 0x4c 'L' 0x49 'I'
[ ">>>", "bit_list", "=", "(", "...", "[", "0", "0", "1", "1", "0", "0", "1", "0", "]", "#", "L", "...", "[", "1", "0", "0", "1", "0", "0", "1", "0", "]", "#", "I", "...", ")", ">>>", "print_block_bit_list", "(", "bit_list", ")", "...", "#", ...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L583-L632
jedie/DragonPy
PyDC/PyDC/utils.py
print_bitlist
def print_bitlist(bitstream, no_repr=False): """ >>> bitstream = bytes2bitstream("Hallo World!") >>> print_bitlist(bitstream) ... # doctest: +NORMALIZE_WHITESPACE 8 - 00010010 10000110 00110110 00110110 11110110 00000100 11101010 11110110 0x48 'H' 0x61 'a' 0x6c 'l' 0x6c 'l' 0x6f 'o' 0x...
python
def print_bitlist(bitstream, no_repr=False): """ >>> bitstream = bytes2bitstream("Hallo World!") >>> print_bitlist(bitstream) ... # doctest: +NORMALIZE_WHITESPACE 8 - 00010010 10000110 00110110 00110110 11110110 00000100 11101010 11110110 0x48 'H' 0x61 'a' 0x6c 'l' 0x6c 'l' 0x6f 'o' 0x...
[ "def", "print_bitlist", "(", "bitstream", ",", "no_repr", "=", "False", ")", ":", "block_bit_list", "=", "iter_steps", "(", "bitstream", ",", "steps", "=", "8", ")", "print_block_bit_list", "(", "block_bit_list", ",", "no_repr", "=", "no_repr", ")" ]
>>> bitstream = bytes2bitstream("Hallo World!") >>> print_bitlist(bitstream) ... # doctest: +NORMALIZE_WHITESPACE 8 - 00010010 10000110 00110110 00110110 11110110 00000100 11101010 11110110 0x48 'H' 0x61 'a' 0x6c 'l' 0x6c 'l' 0x6f 'o' 0x20 ' ' 0x57 'W' 0x6f 'o' 12 - 01001110 00110110 001...
[ ">>>", "bitstream", "=", "bytes2bitstream", "(", "Hallo", "World!", ")", ">>>", "print_bitlist", "(", "bitstream", ")", "...", "#", "doctest", ":", "+", "NORMALIZE_WHITESPACE", "8", "-", "00010010", "10000110", "00110110", "00110110", "11110110", "00000100", "11...
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L634-L651
jedie/DragonPy
PyDC/PyDC/utils.py
get_word
def get_word(byte_iterator): """ return a uint16 value >>> g=iter([0x1e, 0x12]) >>> v=get_word(g) >>> v 7698 >>> hex(v) '0x1e12' """ byte_values = list(itertools.islice(byte_iterator, 2)) try: word = (byte_values[0] << 8) | byte_values[1] except TypeError, err: ...
python
def get_word(byte_iterator): """ return a uint16 value >>> g=iter([0x1e, 0x12]) >>> v=get_word(g) >>> v 7698 >>> hex(v) '0x1e12' """ byte_values = list(itertools.islice(byte_iterator, 2)) try: word = (byte_values[0] << 8) | byte_values[1] except TypeError, err: ...
[ "def", "get_word", "(", "byte_iterator", ")", ":", "byte_values", "=", "list", "(", "itertools", ".", "islice", "(", "byte_iterator", ",", "2", ")", ")", "try", ":", "word", "=", "(", "byte_values", "[", "0", "]", "<<", "8", ")", "|", "byte_values", ...
return a uint16 value >>> g=iter([0x1e, 0x12]) >>> v=get_word(g) >>> v 7698 >>> hex(v) '0x1e12'
[ "return", "a", "uint16", "value" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L654-L670
jedie/DragonPy
PyDC/PyDC/utils.py
sinus_values
def sinus_values(count, max_value): """ >>> values = list(sinus_values(10, 32768)) >>> len(values) 10 >>> values [0, 21063, 32270, 28378, 11207, -11207, -28378, -32270, -21063, 0] >>> tl = TextLevelMeter(32768, width=40) >>> for v in values: ... tl.feed(v) '| ...
python
def sinus_values(count, max_value): """ >>> values = list(sinus_values(10, 32768)) >>> len(values) 10 >>> values [0, 21063, 32270, 28378, 11207, -11207, -28378, -32270, -21063, 0] >>> tl = TextLevelMeter(32768, width=40) >>> for v in values: ... tl.feed(v) '| ...
[ "def", "sinus_values", "(", "count", ",", "max_value", ")", ":", "count", "-=", "1", "for", "index", "in", "xrange", "(", "0", ",", "count", "+", "1", ")", ":", "angle", "=", "360.0", "/", "count", "*", "index", "y", "=", "math", ".", "sin", "(",...
>>> values = list(sinus_values(10, 32768)) >>> len(values) 10 >>> values [0, 21063, 32270, 28378, 11207, -11207, -28378, -32270, -21063, 0] >>> tl = TextLevelMeter(32768, width=40) >>> for v in values: ... tl.feed(v) '| * |' '| ...
[ ">>>", "values", "=", "list", "(", "sinus_values", "(", "10", "32768", "))", ">>>", "len", "(", "values", ")", "10", ">>>", "values", "[", "0", "21063", "32270", "28378", "11207", "-", "11207", "-", "28378", "-", "32270", "-", "21063", "0", "]" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L684-L711
jedie/DragonPy
PyDC/PyDC/utils.py
sinus_values_by_hz
def sinus_values_by_hz(framerate, hz, max_value): """ Create sinus values with the given framerate and Hz. Note: We skip the first zero-crossing, so the values can be used directy in a loop. >>> values = sinus_values_by_hz(22050, 1200, 255) >>> len(values) # 22050 / 1200Hz = 18,375 18 >...
python
def sinus_values_by_hz(framerate, hz, max_value): """ Create sinus values with the given framerate and Hz. Note: We skip the first zero-crossing, so the values can be used directy in a loop. >>> values = sinus_values_by_hz(22050, 1200, 255) >>> len(values) # 22050 / 1200Hz = 18,375 18 >...
[ "def", "sinus_values_by_hz", "(", "framerate", ",", "hz", ",", "max_value", ")", ":", "count", "=", "int", "(", "round", "(", "float", "(", "framerate", ")", "/", "float", "(", "hz", ")", ")", ")", "count", "+=", "1", "values", "=", "tuple", "(", "...
Create sinus values with the given framerate and Hz. Note: We skip the first zero-crossing, so the values can be used directy in a loop. >>> values = sinus_values_by_hz(22050, 1200, 255) >>> len(values) # 22050 / 1200Hz = 18,375 18 >>> values (87, 164, 221, 251, 251, 221, 164, 87, 0, -87, -...
[ "Create", "sinus", "values", "with", "the", "given", "framerate", "and", "Hz", ".", "Note", ":", "We", "skip", "the", "first", "zero", "-", "crossing", "so", "the", "values", "can", "be", "used", "directy", "in", "a", "loop", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/utils.py#L713-L755
jedie/DragonPy
dragonpy/utils/starter.py
get_module_name
def get_module_name(package): """ package must have these attributes: e.g.: package.DISTRIBUTION_NAME = "DragonPyEmulator" package.DIST_GROUP = "console_scripts" package.ENTRY_POINT = "DragonPy" :return: a string like: "dragonpy.core.cli" """ distribution = get_distribut...
python
def get_module_name(package): """ package must have these attributes: e.g.: package.DISTRIBUTION_NAME = "DragonPyEmulator" package.DIST_GROUP = "console_scripts" package.ENTRY_POINT = "DragonPy" :return: a string like: "dragonpy.core.cli" """ distribution = get_distribut...
[ "def", "get_module_name", "(", "package", ")", ":", "distribution", "=", "get_distribution", "(", "package", ".", "DISTRIBUTION_NAME", ")", "entry_info", "=", "distribution", ".", "get_entry_info", "(", "package", ".", "DIST_GROUP", ",", "package", ".", "ENTRY_POI...
package must have these attributes: e.g.: package.DISTRIBUTION_NAME = "DragonPyEmulator" package.DIST_GROUP = "console_scripts" package.ENTRY_POINT = "DragonPy" :return: a string like: "dragonpy.core.cli"
[ "package", "must", "have", "these", "attributes", ":", "e", ".", "g", ".", ":", "package", ".", "DISTRIBUTION_NAME", "=", "DragonPyEmulator", "package", ".", "DIST_GROUP", "=", "console_scripts", "package", ".", "ENTRY_POINT", "=", "DragonPy" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/starter.py#L26-L44
jedie/DragonPy
dragonpy/utils/starter.py
_run
def _run(*args, **kwargs): """ Run current executable via subprocess and given args """ verbose = kwargs.pop("verbose", False) if verbose: click.secho(" ".join([repr(i) for i in args]), bg='blue', fg='white') executable = args[0] if not os.path.isfile(executable): raise Runt...
python
def _run(*args, **kwargs): """ Run current executable via subprocess and given args """ verbose = kwargs.pop("verbose", False) if verbose: click.secho(" ".join([repr(i) for i in args]), bg='blue', fg='white') executable = args[0] if not os.path.isfile(executable): raise Runt...
[ "def", "_run", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "kwargs", ".", "pop", "(", "\"verbose\"", ",", "False", ")", "if", "verbose", ":", "click", ".", "secho", "(", "\" \"", ".", "join", "(", "[", "repr", "(", "i", ...
Run current executable via subprocess and given args
[ "Run", "current", "executable", "via", "subprocess", "and", "given", "args" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/starter.py#L53-L67
jedie/DragonPy
bootstrap/source_after_install.py
after_install
def after_install(options, home_dir): # --- CUT here --- """ called after virtualenv was created and pip/setuptools installed. Now we installed requirement libs/packages. """ if options.install_type==INST_PYPI: requirements=NORMAL_INSTALLATION elif options.install_type==INST_GIT: ...
python
def after_install(options, home_dir): # --- CUT here --- """ called after virtualenv was created and pip/setuptools installed. Now we installed requirement libs/packages. """ if options.install_type==INST_PYPI: requirements=NORMAL_INSTALLATION elif options.install_type==INST_GIT: ...
[ "def", "after_install", "(", "options", ",", "home_dir", ")", ":", "# --- CUT here ---", "if", "options", ".", "install_type", "==", "INST_PYPI", ":", "requirements", "=", "NORMAL_INSTALLATION", "elif", "options", ".", "install_type", "==", "INST_GIT", ":", "requi...
called after virtualenv was created and pip/setuptools installed. Now we installed requirement libs/packages.
[ "called", "after", "virtualenv", "was", "created", "and", "pip", "/", "setuptools", "installed", ".", "Now", "we", "installed", "requirement", "libs", "/", "packages", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/bootstrap/source_after_install.py#L14-L37
jedie/DragonPy
dragonpy/utils/simple_debugger.py
print_exc_plus
def print_exc_plus(): """ Print the usual traceback information, followed by a listing of all the local variables in each frame. """ sys.stderr.flush() # for eclipse sys.stdout.flush() # for eclipse tb = sys.exc_info()[2] while True: if not tb.tb_next: break ...
python
def print_exc_plus(): """ Print the usual traceback information, followed by a listing of all the local variables in each frame. """ sys.stderr.flush() # for eclipse sys.stdout.flush() # for eclipse tb = sys.exc_info()[2] while True: if not tb.tb_next: break ...
[ "def", "print_exc_plus", "(", ")", ":", "sys", ".", "stderr", ".", "flush", "(", ")", "# for eclipse", "sys", ".", "stdout", ".", "flush", "(", ")", "# for eclipse", "tb", "=", "sys", ".", "exc_info", "(", ")", "[", "2", "]", "while", "True", ":", ...
Print the usual traceback information, followed by a listing of all the local variables in each frame.
[ "Print", "the", "usual", "traceback", "information", "followed", "by", "a", "listing", "of", "all", "the", "local", "variables", "in", "each", "frame", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/simple_debugger.py#L27-L88
jedie/DragonPy
PyDC/PyDC/CassetteObjects.py
FileContent.add_block_data
def add_block_data(self, block_length, data): """ add a block of tokenized BASIC source code lines. >>> cfg = Dragon32Config >>> fc = FileContent(cfg) >>> block = [ ... 0x1e,0x12,0x0,0xa,0x80,0x20,0x49,0x20,0xcb,0x20,0x31,0x20,0xbc,0x20,0x31,0x30,0x0, ... 0x0,0x...
python
def add_block_data(self, block_length, data): """ add a block of tokenized BASIC source code lines. >>> cfg = Dragon32Config >>> fc = FileContent(cfg) >>> block = [ ... 0x1e,0x12,0x0,0xa,0x80,0x20,0x49,0x20,0xcb,0x20,0x31,0x20,0xbc,0x20,0x31,0x30,0x0, ... 0x0,0x...
[ "def", "add_block_data", "(", "self", ",", "block_length", ",", "data", ")", ":", "# data = list(data)", "# # print repr(data)", "# print_as_hex_list(data)", "# print_codepoint_stream(data)", "# sys.exit()", "# create from codepoint list a iterat...
add a block of tokenized BASIC source code lines. >>> cfg = Dragon32Config >>> fc = FileContent(cfg) >>> block = [ ... 0x1e,0x12,0x0,0xa,0x80,0x20,0x49,0x20,0xcb,0x20,0x31,0x20,0xbc,0x20,0x31,0x30,0x0, ... 0x0,0x0] >>> len(block) 19 >>> fc.add_block_data...
[ "add", "a", "block", "of", "tokenized", "BASIC", "source", "code", "lines", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/CassetteObjects.py#L81-L212
jedie/DragonPy
PyDC/PyDC/CassetteObjects.py
FileContent.add_ascii_block
def add_ascii_block(self, block_length, data): """ add a block of ASCII BASIC source code lines. >>> data = [ ... 0xd, ... 0x31,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0x54,0x45,0x53,0x54,0x22, ... 0xd, ... 0x32,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0...
python
def add_ascii_block(self, block_length, data): """ add a block of ASCII BASIC source code lines. >>> data = [ ... 0xd, ... 0x31,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0x54,0x45,0x53,0x54,0x22, ... 0xd, ... 0x32,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0...
[ "def", "add_ascii_block", "(", "self", ",", "block_length", ",", "data", ")", ":", "data", "=", "iter", "(", "data", ")", "data", ".", "next", "(", ")", "# Skip first \\r", "byte_count", "=", "1", "# incl. first \\r", "while", "True", ":", "code", "=", "...
add a block of ASCII BASIC source code lines. >>> data = [ ... 0xd, ... 0x31,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0x54,0x45,0x53,0x54,0x22, ... 0xd, ... 0x32,0x30,0x20,0x50,0x52,0x49,0x4e,0x54,0x20,0x22,0x48,0x45,0x4c,0x4c,0x4f,0x20,0x57,0x4f,0x52,0x4c,0x44,0x21,0x22, ...
[ "add", "a", "block", "of", "ASCII", "BASIC", "source", "code", "lines", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/CassetteObjects.py#L214-L268
jedie/DragonPy
PyDC/PyDC/CassetteObjects.py
CassetteFile.get_filename_block_as_codepoints
def get_filename_block_as_codepoints(self): """ TODO: Support tokenized BASIC. Now we only create ASCII BASIC. """ codepoints = [] codepoints += list(string2codepoint(self.filename.ljust(8, " "))) codepoints.append(self.cfg.FTYPE_BASIC) # one byte file type codepo...
python
def get_filename_block_as_codepoints(self): """ TODO: Support tokenized BASIC. Now we only create ASCII BASIC. """ codepoints = [] codepoints += list(string2codepoint(self.filename.ljust(8, " "))) codepoints.append(self.cfg.FTYPE_BASIC) # one byte file type codepo...
[ "def", "get_filename_block_as_codepoints", "(", "self", ")", ":", "codepoints", "=", "[", "]", "codepoints", "+=", "list", "(", "string2codepoint", "(", "self", ".", "filename", ".", "ljust", "(", "8", ",", "\" \"", ")", ")", ")", "codepoints", ".", "appen...
TODO: Support tokenized BASIC. Now we only create ASCII BASIC.
[ "TODO", ":", "Support", "tokenized", "BASIC", ".", "Now", "we", "only", "create", "ASCII", "BASIC", "." ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/CassetteObjects.py#L389-L417
jedie/DragonPy
PyDC/PyDC/CassetteObjects.py
Cassette.buffer2file
def buffer2file(self): """ add the code buffer content to CassetteFile() instance """ if self.current_file is not None and self.buffer: self.current_file.add_block_data(self.buffered_block_length, self.buffer) self.buffer = [] self.buffered_block_lengt...
python
def buffer2file(self): """ add the code buffer content to CassetteFile() instance """ if self.current_file is not None and self.buffer: self.current_file.add_block_data(self.buffered_block_length, self.buffer) self.buffer = [] self.buffered_block_lengt...
[ "def", "buffer2file", "(", "self", ")", ":", "if", "self", ".", "current_file", "is", "not", "None", "and", "self", ".", "buffer", ":", "self", ".", "current_file", ".", "add_block_data", "(", "self", ".", "buffered_block_length", ",", "self", ".", "buffer...
add the code buffer content to CassetteFile() instance
[ "add", "the", "code", "buffer", "content", "to", "CassetteFile", "()", "instance" ]
train
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/PyDC/PyDC/CassetteObjects.py#L509-L516