partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
add_hotkey
Invokes a callback every time a hotkey is pressed. The hotkey must be in the format `ctrl+shift+a, s`. This would trigger when the user holds ctrl, shift and "a" at once, releases, and then presses "s". To represent literal commas, pluses, and spaces, use their names ('comma', 'plus', 'space'). - `...
keyboard/__init__.py
def add_hotkey(hotkey, callback, args=(), suppress=False, timeout=1, trigger_on_release=False): """ Invokes a callback every time a hotkey is pressed. The hotkey must be in the format `ctrl+shift+a, s`. This would trigger when the user holds ctrl, shift and "a" at once, releases, and then presses "s". T...
def add_hotkey(hotkey, callback, args=(), suppress=False, timeout=1, trigger_on_release=False): """ Invokes a callback every time a hotkey is pressed. The hotkey must be in the format `ctrl+shift+a, s`. This would trigger when the user holds ctrl, shift and "a" at once, releases, and then presses "s". T...
[ "Invokes", "a", "callback", "every", "time", "a", "hotkey", "is", "pressed", ".", "The", "hotkey", "must", "be", "in", "the", "format", "ctrl", "+", "shift", "+", "a", "s", ".", "This", "would", "trigger", "when", "the", "user", "holds", "ctrl", "shift...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L597-L740
[ "def", "add_hotkey", "(", "hotkey", ",", "callback", ",", "args", "=", "(", ")", ",", "suppress", "=", "False", ",", "timeout", "=", "1", ",", "trigger_on_release", "=", "False", ")", ":", "if", "args", ":", "callback", "=", "lambda", "callback", "=", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
remap_hotkey
Whenever the hotkey `src` is pressed, suppress it and send `dst` instead. Example: remap('alt+w', 'ctrl+up')
keyboard/__init__.py
def remap_hotkey(src, dst, suppress=True, trigger_on_release=False): """ Whenever the hotkey `src` is pressed, suppress it and send `dst` instead. Example: remap('alt+w', 'ctrl+up') """ def handler(): active_modifiers = sorted(modifier for modifier, state in _listener.modifier_...
def remap_hotkey(src, dst, suppress=True, trigger_on_release=False): """ Whenever the hotkey `src` is pressed, suppress it and send `dst` instead. Example: remap('alt+w', 'ctrl+up') """ def handler(): active_modifiers = sorted(modifier for modifier, state in _listener.modifier_...
[ "Whenever", "the", "hotkey", "src", "is", "pressed", "suppress", "it", "and", "send", "dst", "instead", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L762-L779
[ "def", "remap_hotkey", "(", "src", ",", "dst", ",", "suppress", "=", "True", ",", "trigger_on_release", "=", "False", ")", ":", "def", "handler", "(", ")", ":", "active_modifiers", "=", "sorted", "(", "modifier", "for", "modifier", ",", "state", "in", "_...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
stash_state
Builds a list of all currently pressed scan codes, releases them and returns the list. Pairs well with `restore_state` and `restore_modifiers`.
keyboard/__init__.py
def stash_state(): """ Builds a list of all currently pressed scan codes, releases them and returns the list. Pairs well with `restore_state` and `restore_modifiers`. """ # TODO: stash caps lock / numlock /scrollock state. with _pressed_events_lock: state = sorted(_pressed_events) fo...
def stash_state(): """ Builds a list of all currently pressed scan codes, releases them and returns the list. Pairs well with `restore_state` and `restore_modifiers`. """ # TODO: stash caps lock / numlock /scrollock state. with _pressed_events_lock: state = sorted(_pressed_events) fo...
[ "Builds", "a", "list", "of", "all", "currently", "pressed", "scan", "codes", "releases", "them", "and", "returns", "the", "list", ".", "Pairs", "well", "with", "restore_state", "and", "restore_modifiers", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L782-L792
[ "def", "stash_state", "(", ")", ":", "# TODO: stash caps lock / numlock /scrollock state.", "with", "_pressed_events_lock", ":", "state", "=", "sorted", "(", "_pressed_events", ")", "for", "scan_code", "in", "state", ":", "_os_keyboard", ".", "release", "(", "scan_cod...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
restore_state
Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with `stash_state`, alternative to `restore_modifiers`.
keyboard/__init__.py
def restore_state(scan_codes): """ Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with `stash_state`, alternative to `restore_modifiers`. """ _listener.is_replaying = True with _pressed_events_lock: current = set(_pressed_events) target =...
def restore_state(scan_codes): """ Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with `stash_state`, alternative to `restore_modifiers`. """ _listener.is_replaying = True with _pressed_events_lock: current = set(_pressed_events) target =...
[ "Given", "a", "list", "of", "scan_codes", "ensures", "these", "keys", "and", "only", "these", "keys", "are", "pressed", ".", "Pairs", "well", "with", "stash_state", "alternative", "to", "restore_modifiers", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L794-L809
[ "def", "restore_state", "(", "scan_codes", ")", ":", "_listener", ".", "is_replaying", "=", "True", "with", "_pressed_events_lock", ":", "current", "=", "set", "(", "_pressed_events", ")", "target", "=", "set", "(", "scan_codes", ")", "for", "scan_code", "in",...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
write
Sends artificial keyboard events to the OS, simulating the typing of a given text. Characters not available on the keyboard are typed as explicit unicode characters using OS-specific functionality, such as alt+codepoint. To ensure text integrity, all currently pressed keys are released before the text ...
keyboard/__init__.py
def write(text, delay=0, restore_state_after=True, exact=None): """ Sends artificial keyboard events to the OS, simulating the typing of a given text. Characters not available on the keyboard are typed as explicit unicode characters using OS-specific functionality, such as alt+codepoint. To ensure ...
def write(text, delay=0, restore_state_after=True, exact=None): """ Sends artificial keyboard events to the OS, simulating the typing of a given text. Characters not available on the keyboard are typed as explicit unicode characters using OS-specific functionality, such as alt+codepoint. To ensure ...
[ "Sends", "artificial", "keyboard", "events", "to", "the", "OS", "simulating", "the", "typing", "of", "a", "given", "text", ".", "Characters", "not", "available", "on", "the", "keyboard", "are", "typed", "as", "explicit", "unicode", "characters", "using", "OS",...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L817-L870
[ "def", "write", "(", "text", ",", "delay", "=", "0", ",", "restore_state_after", "=", "True", ",", "exact", "=", "None", ")", ":", "if", "exact", "is", "None", ":", "exact", "=", "_platform", ".", "system", "(", ")", "==", "'Windows'", "state", "=", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
wait
Blocks the program execution until the given hotkey is pressed or, if given no parameters, blocks forever.
keyboard/__init__.py
def wait(hotkey=None, suppress=False, trigger_on_release=False): """ Blocks the program execution until the given hotkey is pressed or, if given no parameters, blocks forever. """ if hotkey: lock = _Event() remove = add_hotkey(hotkey, lambda: lock.set(), suppress=suppress, trigger_on...
def wait(hotkey=None, suppress=False, trigger_on_release=False): """ Blocks the program execution until the given hotkey is pressed or, if given no parameters, blocks forever. """ if hotkey: lock = _Event() remove = add_hotkey(hotkey, lambda: lock.set(), suppress=suppress, trigger_on...
[ "Blocks", "the", "program", "execution", "until", "the", "given", "hotkey", "is", "pressed", "or", "if", "given", "no", "parameters", "blocks", "forever", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L872-L884
[ "def", "wait", "(", "hotkey", "=", "None", ",", "suppress", "=", "False", ",", "trigger_on_release", "=", "False", ")", ":", "if", "hotkey", ":", "lock", "=", "_Event", "(", ")", "remove", "=", "add_hotkey", "(", "hotkey", ",", "lambda", ":", "lock", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
get_hotkey_name
Returns a string representation of hotkey from the given key names, or the currently pressed keys if not given. This function: - normalizes names; - removes "left" and "right" prefixes; - replaces the "+" key name with "plus" to avoid ambiguity; - puts modifier keys first, in a standardized order;...
keyboard/__init__.py
def get_hotkey_name(names=None): """ Returns a string representation of hotkey from the given key names, or the currently pressed keys if not given. This function: - normalizes names; - removes "left" and "right" prefixes; - replaces the "+" key name with "plus" to avoid ambiguity; - puts ...
def get_hotkey_name(names=None): """ Returns a string representation of hotkey from the given key names, or the currently pressed keys if not given. This function: - normalizes names; - removes "left" and "right" prefixes; - replaces the "+" key name with "plus" to avoid ambiguity; - puts ...
[ "Returns", "a", "string", "representation", "of", "hotkey", "from", "the", "given", "key", "names", "or", "the", "currently", "pressed", "keys", "if", "not", "given", ".", "This", "function", ":" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L886-L915
[ "def", "get_hotkey_name", "(", "names", "=", "None", ")", ":", "if", "names", "is", "None", ":", "_listener", ".", "start_if_necessary", "(", ")", "with", "_pressed_events_lock", ":", "names", "=", "[", "e", ".", "name", "for", "e", "in", "_pressed_events"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
read_event
Blocks until a keyboard event happens, then returns that event.
keyboard/__init__.py
def read_event(suppress=False): """ Blocks until a keyboard event happens, then returns that event. """ queue = _queue.Queue(maxsize=1) hooked = hook(queue.put, suppress=suppress) while True: event = queue.get() unhook(hooked) return event
def read_event(suppress=False): """ Blocks until a keyboard event happens, then returns that event. """ queue = _queue.Queue(maxsize=1) hooked = hook(queue.put, suppress=suppress) while True: event = queue.get() unhook(hooked) return event
[ "Blocks", "until", "a", "keyboard", "event", "happens", "then", "returns", "that", "event", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L917-L926
[ "def", "read_event", "(", "suppress", "=", "False", ")", ":", "queue", "=", "_queue", ".", "Queue", "(", "maxsize", "=", "1", ")", "hooked", "=", "hook", "(", "queue", ".", "put", ",", "suppress", "=", "suppress", ")", "while", "True", ":", "event", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
read_key
Blocks until a keyboard event happens, then returns that event's name or, if missing, its scan code.
keyboard/__init__.py
def read_key(suppress=False): """ Blocks until a keyboard event happens, then returns that event's name or, if missing, its scan code. """ event = read_event(suppress) return event.name or event.scan_code
def read_key(suppress=False): """ Blocks until a keyboard event happens, then returns that event's name or, if missing, its scan code. """ event = read_event(suppress) return event.name or event.scan_code
[ "Blocks", "until", "a", "keyboard", "event", "happens", "then", "returns", "that", "event", "s", "name", "or", "if", "missing", "its", "scan", "code", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L928-L934
[ "def", "read_key", "(", "suppress", "=", "False", ")", ":", "event", "=", "read_event", "(", "suppress", ")", "return", "event", ".", "name", "or", "event", ".", "scan_code" ]
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
read_hotkey
Similar to `read_key()`, but blocks until the user presses and releases a hotkey (or single key), then returns a string representing the hotkey pressed. Example: read_hotkey() # "ctrl+shift+p"
keyboard/__init__.py
def read_hotkey(suppress=True): """ Similar to `read_key()`, but blocks until the user presses and releases a hotkey (or single key), then returns a string representing the hotkey pressed. Example: read_hotkey() # "ctrl+shift+p" """ queue = _queue.Queue() fn = lambda e:...
def read_hotkey(suppress=True): """ Similar to `read_key()`, but blocks until the user presses and releases a hotkey (or single key), then returns a string representing the hotkey pressed. Example: read_hotkey() # "ctrl+shift+p" """ queue = _queue.Queue() fn = lambda e:...
[ "Similar", "to", "read_key", "()", "but", "blocks", "until", "the", "user", "presses", "and", "releases", "a", "hotkey", "(", "or", "single", "key", ")", "then", "returns", "a", "string", "representing", "the", "hotkey", "pressed", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L936-L956
[ "def", "read_hotkey", "(", "suppress", "=", "True", ")", ":", "queue", "=", "_queue", ".", "Queue", "(", ")", "fn", "=", "lambda", "e", ":", "queue", ".", "put", "(", "e", ")", "or", "e", ".", "event_type", "==", "KEY_DOWN", "hooked", "=", "hook", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
get_typed_strings
Given a sequence of events, tries to deduce what strings were typed. Strings are separated when a non-textual key is pressed (such as tab or enter). Characters are converted to uppercase according to shift and capslock status. If `allow_backspace` is True, backspaces remove the last character typed. ...
keyboard/__init__.py
def get_typed_strings(events, allow_backspace=True): """ Given a sequence of events, tries to deduce what strings were typed. Strings are separated when a non-textual key is pressed (such as tab or enter). Characters are converted to uppercase according to shift and capslock status. If `allow_backsp...
def get_typed_strings(events, allow_backspace=True): """ Given a sequence of events, tries to deduce what strings were typed. Strings are separated when a non-textual key is pressed (such as tab or enter). Characters are converted to uppercase according to shift and capslock status. If `allow_backsp...
[ "Given", "a", "sequence", "of", "events", "tries", "to", "deduce", "what", "strings", "were", "typed", ".", "Strings", "are", "separated", "when", "a", "non", "-", "textual", "key", "is", "pressed", "(", "such", "as", "tab", "or", "enter", ")", ".", "C...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L958-L1002
[ "def", "get_typed_strings", "(", "events", ",", "allow_backspace", "=", "True", ")", ":", "backspace_name", "=", "'delete'", "if", "_platform", ".", "system", "(", ")", "==", "'Darwin'", "else", "'backspace'", "shift_pressed", "=", "False", "capslock_pressed", "...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
start_recording
Starts recording all keyboard events into a global variable, or the given queue if any. Returns the queue of events and the hooked function. Use `stop_recording()` or `unhook(hooked_function)` to stop.
keyboard/__init__.py
def start_recording(recorded_events_queue=None): """ Starts recording all keyboard events into a global variable, or the given queue if any. Returns the queue of events and the hooked function. Use `stop_recording()` or `unhook(hooked_function)` to stop. """ recorded_events_queue = recorded_eve...
def start_recording(recorded_events_queue=None): """ Starts recording all keyboard events into a global variable, or the given queue if any. Returns the queue of events and the hooked function. Use `stop_recording()` or `unhook(hooked_function)` to stop. """ recorded_events_queue = recorded_eve...
[ "Starts", "recording", "all", "keyboard", "events", "into", "a", "global", "variable", "or", "the", "given", "queue", "if", "any", ".", "Returns", "the", "queue", "of", "events", "and", "the", "hooked", "function", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1005-L1015
[ "def", "start_recording", "(", "recorded_events_queue", "=", "None", ")", ":", "recorded_events_queue", "=", "recorded_events_queue", "or", "_queue", ".", "Queue", "(", ")", "global", "_recording", "_recording", "=", "(", "recorded_events_queue", ",", "hook", "(", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
stop_recording
Stops the global recording of events and returns a list of the events captured.
keyboard/__init__.py
def stop_recording(): """ Stops the global recording of events and returns a list of the events captured. """ global _recording if not _recording: raise ValueError('Must call "start_recording" before.') recorded_events_queue, hooked = _recording unhook(hooked) return list(rec...
def stop_recording(): """ Stops the global recording of events and returns a list of the events captured. """ global _recording if not _recording: raise ValueError('Must call "start_recording" before.') recorded_events_queue, hooked = _recording unhook(hooked) return list(rec...
[ "Stops", "the", "global", "recording", "of", "events", "and", "returns", "a", "list", "of", "the", "events", "captured", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1017-L1027
[ "def", "stop_recording", "(", ")", ":", "global", "_recording", "if", "not", "_recording", ":", "raise", "ValueError", "(", "'Must call \"start_recording\" before.'", ")", "recorded_events_queue", ",", "hooked", "=", "_recording", "unhook", "(", "hooked", ")", "retu...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
record
Records all keyboard events from all keyboards until the user presses the given hotkey. Then returns the list of events recorded, of type `keyboard.KeyboardEvent`. Pairs well with `play(events)`. Note: this is a blocking function. Note: for more details on the keyboard hook and events see `hook`.
keyboard/__init__.py
def record(until='escape', suppress=False, trigger_on_release=False): """ Records all keyboard events from all keyboards until the user presses the given hotkey. Then returns the list of events recorded, of type `keyboard.KeyboardEvent`. Pairs well with `play(events)`. Note: this is a blocking ...
def record(until='escape', suppress=False, trigger_on_release=False): """ Records all keyboard events from all keyboards until the user presses the given hotkey. Then returns the list of events recorded, of type `keyboard.KeyboardEvent`. Pairs well with `play(events)`. Note: this is a blocking ...
[ "Records", "all", "keyboard", "events", "from", "all", "keyboards", "until", "the", "user", "presses", "the", "given", "hotkey", ".", "Then", "returns", "the", "list", "of", "events", "recorded", "of", "type", "keyboard", ".", "KeyboardEvent", ".", "Pairs", ...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1029-L1041
[ "def", "record", "(", "until", "=", "'escape'", ",", "suppress", "=", "False", ",", "trigger_on_release", "=", "False", ")", ":", "start_recording", "(", ")", "wait", "(", "until", ",", "suppress", "=", "suppress", ",", "trigger_on_release", "=", "trigger_on...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
play
Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. Note: the current keyboard state is cleared at the beginning and restored at the end of the function.
keyboard/__init__.py
def play(events, speed_factor=1.0): """ Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. Note: the current keyboard state is cleared at the beginning and restored...
def play(events, speed_factor=1.0): """ Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. Note: the current keyboard state is cleared at the beginning and restored...
[ "Plays", "a", "sequence", "of", "recorded", "events", "maintaining", "the", "relative", "time", "intervals", ".", "If", "speed_factor", "is", "<", "=", "0", "then", "the", "actions", "are", "replayed", "as", "fast", "as", "the", "OS", "allows", ".", "Pairs...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1043-L1063
[ "def", "play", "(", "events", ",", "speed_factor", "=", "1.0", ")", ":", "state", "=", "stash_state", "(", ")", "last_time", "=", "None", "for", "event", "in", "events", ":", "if", "speed_factor", ">", "0", "and", "last_time", "is", "not", "None", ":",...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
add_word_listener
Invokes a callback every time a sequence of characters is typed (e.g. 'pet') and followed by a trigger key (e.g. space). Modifiers (e.g. alt, ctrl, shift) are ignored. - `word` the typed text to be matched. E.g. 'pet'. - `callback` is an argument-less function to be invoked each time the word is ty...
keyboard/__init__.py
def add_word_listener(word, callback, triggers=['space'], match_suffix=False, timeout=2): """ Invokes a callback every time a sequence of characters is typed (e.g. 'pet') and followed by a trigger key (e.g. space). Modifiers (e.g. alt, ctrl, shift) are ignored. - `word` the typed text to be matched...
def add_word_listener(word, callback, triggers=['space'], match_suffix=False, timeout=2): """ Invokes a callback every time a sequence of characters is typed (e.g. 'pet') and followed by a trigger key (e.g. space). Modifiers (e.g. alt, ctrl, shift) are ignored. - `word` the typed text to be matched...
[ "Invokes", "a", "callback", "every", "time", "a", "sequence", "of", "characters", "is", "typed", "(", "e", ".", "g", ".", "pet", ")", "and", "followed", "by", "a", "trigger", "key", "(", "e", ".", "g", ".", "space", ")", ".", "Modifiers", "(", "e",...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1067-L1121
[ "def", "add_word_listener", "(", "word", ",", "callback", ",", "triggers", "=", "[", "'space'", "]", ",", "match_suffix", "=", "False", ",", "timeout", "=", "2", ")", ":", "state", "=", "_State", "(", ")", "state", ".", "current", "=", "''", "state", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
add_abbreviation
Registers a hotkey that replaces one typed text with another. For example add_abbreviation('tm', u'™') Replaces every "tm" followed by a space with a ™ symbol (and no space). The replacement is done by sending backspace events. - `match_suffix` defines if endings of words should also be checked i...
keyboard/__init__.py
def add_abbreviation(source_text, replacement_text, match_suffix=False, timeout=2): """ Registers a hotkey that replaces one typed text with another. For example add_abbreviation('tm', u'™') Replaces every "tm" followed by a space with a ™ symbol (and no space). The replacement is done by send...
def add_abbreviation(source_text, replacement_text, match_suffix=False, timeout=2): """ Registers a hotkey that replaces one typed text with another. For example add_abbreviation('tm', u'™') Replaces every "tm" followed by a space with a ™ symbol (and no space). The replacement is done by send...
[ "Registers", "a", "hotkey", "that", "replaces", "one", "typed", "text", "with", "another", ".", "For", "example" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L1131-L1150
[ "def", "add_abbreviation", "(", "source_text", ",", "replacement_text", ",", "match_suffix", "=", "False", ",", "timeout", "=", "2", ")", ":", "replacement", "=", "'\\b'", "*", "(", "len", "(", "source_text", ")", "+", "1", ")", "+", "replacement_text", "c...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
_KeyboardListener.direct_callback
This function is called for every OS keyboard event and decides if the event should be blocked or not, and passes a copy of the event to other, non-blocking, listeners. There are two ways to block events: remapped keys, which translate events by suppressing and re-emitting; and blocked ...
keyboard/__init__.py
def direct_callback(self, event): """ This function is called for every OS keyboard event and decides if the event should be blocked or not, and passes a copy of the event to other, non-blocking, listeners. There are two ways to block events: remapped keys, which translate ...
def direct_callback(self, event): """ This function is called for every OS keyboard event and decides if the event should be blocked or not, and passes a copy of the event to other, non-blocking, listeners. There are two ways to block events: remapped keys, which translate ...
[ "This", "function", "is", "called", "for", "every", "OS", "keyboard", "event", "and", "decides", "if", "the", "event", "should", "be", "blocked", "or", "not", "and", "passes", "a", "copy", "of", "the", "event", "to", "other", "non", "-", "blocking", "lis...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L220-L289
[ "def", "direct_callback", "(", "self", ",", "event", ")", ":", "# Pass through all fake key events, don't even report to other handlers.", "if", "self", ".", "is_replaying", ":", "return", "True", "if", "not", "all", "(", "hook", "(", "event", ")", "for", "hook", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
_setup_name_tables
Ensures the scan code/virtual key code/name translation tables are filled.
keyboard/_winkeyboard.py
def _setup_name_tables(): """ Ensures the scan code/virtual key code/name translation tables are filled. """ with tables_lock: if to_name: return # Go through every possible scan code, and map them to virtual key codes. # Then vice-versa. all_scan_codes = [(sc, user3...
def _setup_name_tables(): """ Ensures the scan code/virtual key code/name translation tables are filled. """ with tables_lock: if to_name: return # Go through every possible scan code, and map them to virtual key codes. # Then vice-versa. all_scan_codes = [(sc, user3...
[ "Ensures", "the", "scan", "code", "/", "virtual", "key", "code", "/", "name", "translation", "tables", "are", "filled", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_winkeyboard.py#L383-L436
[ "def", "_setup_name_tables", "(", ")", ":", "with", "tables_lock", ":", "if", "to_name", ":", "return", "# Go through every possible scan code, and map them to virtual key codes.", "# Then vice-versa.", "all_scan_codes", "=", "[", "(", "sc", ",", "user32", ".", "MapVirtua...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
prepare_intercept
Registers a Windows low level keyboard hook. The provided callback will be invoked for each high-level keyboard event, and is expected to return True if the key event should be passed to the next program, or False if the event is to be blocked. No event is processed until the Windows messages are pumpe...
keyboard/_winkeyboard.py
def prepare_intercept(callback): """ Registers a Windows low level keyboard hook. The provided callback will be invoked for each high-level keyboard event, and is expected to return True if the key event should be passed to the next program, or False if the event is to be blocked. No event is p...
def prepare_intercept(callback): """ Registers a Windows low level keyboard hook. The provided callback will be invoked for each high-level keyboard event, and is expected to return True if the key event should be passed to the next program, or False if the event is to be blocked. No event is p...
[ "Registers", "a", "Windows", "low", "level", "keyboard", "hook", ".", "The", "provided", "callback", "will", "be", "invoked", "for", "each", "high", "-", "level", "keyboard", "event", "and", "is", "expected", "to", "return", "True", "if", "the", "key", "ev...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_winkeyboard.py#L486-L558
[ "def", "prepare_intercept", "(", "callback", ")", ":", "_setup_name_tables", "(", ")", "def", "process_key", "(", "event_type", ",", "vk", ",", "scan_code", ",", "is_extended", ")", ":", "global", "shift_is_pressed", ",", "altgr_is_pressed", ",", "ignore_next_righ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
GenericListener.start_if_necessary
Starts the listening thread if it wans't already.
keyboard/_generic.py
def start_if_necessary(self): """ Starts the listening thread if it wans't already. """ self.lock.acquire() try: if not self.listening: self.init() self.listening = True self.listening_thread = Thread(target=self.listen...
def start_if_necessary(self): """ Starts the listening thread if it wans't already. """ self.lock.acquire() try: if not self.listening: self.init() self.listening = True self.listening_thread = Thread(target=self.listen...
[ "Starts", "the", "listening", "thread", "if", "it", "wans", "t", "already", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_generic.py#L28-L46
[ "def", "start_if_necessary", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "if", "not", "self", ".", "listening", ":", "self", ".", "init", "(", ")", "self", ".", "listening", "=", "True", "self", ".", "listening_t...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
GenericListener.process
Loops over the underlying queue of events and processes them in order.
keyboard/_generic.py
def process(self): """ Loops over the underlying queue of events and processes them in order. """ assert self.queue is not None while True: event = self.queue.get() if self.pre_process_event(event): self.invoke_handlers(event) s...
def process(self): """ Loops over the underlying queue of events and processes them in order. """ assert self.queue is not None while True: event = self.queue.get() if self.pre_process_event(event): self.invoke_handlers(event) s...
[ "Loops", "over", "the", "underlying", "queue", "of", "events", "and", "processes", "them", "in", "order", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_generic.py#L51-L60
[ "def", "process", "(", "self", ")", ":", "assert", "self", ".", "queue", "is", "not", "None", "while", "True", ":", "event", "=", "self", ".", "queue", ".", "get", "(", ")", "if", "self", ".", "pre_process_event", "(", "event", ")", ":", "self", "....
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
GenericListener.remove_handler
Removes a previously added event handler.
keyboard/_generic.py
def remove_handler(self, handler): """ Removes a previously added event handler. """ while handler in self.handlers: self.handlers.remove(handler)
def remove_handler(self, handler): """ Removes a previously added event handler. """ while handler in self.handlers: self.handlers.remove(handler)
[ "Removes", "a", "previously", "added", "event", "handler", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_generic.py#L70-L73
[ "def", "remove_handler", "(", "self", ",", "handler", ")", ":", "while", "handler", "in", "self", ".", "handlers", ":", "self", ".", "handlers", ".", "remove", "(", "handler", ")" ]
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
move
Moves the mouse. If `absolute`, to position (x, y), otherwise move relative to the current position. If `duration` is non-zero, animates the movement.
keyboard/mouse.py
def move(x, y, absolute=True, duration=0): """ Moves the mouse. If `absolute`, to position (x, y), otherwise move relative to the current position. If `duration` is non-zero, animates the movement. """ x = int(x) y = int(y) # Requires an extra system call on Linux, but `move_relative` is me...
def move(x, y, absolute=True, duration=0): """ Moves the mouse. If `absolute`, to position (x, y), otherwise move relative to the current position. If `duration` is non-zero, animates the movement. """ x = int(x) y = int(y) # Requires an extra system call on Linux, but `move_relative` is me...
[ "Moves", "the", "mouse", ".", "If", "absolute", "to", "position", "(", "x", "y", ")", "otherwise", "move", "relative", "to", "the", "current", "position", ".", "If", "duration", "is", "non", "-", "zero", "animates", "the", "movement", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L69-L101
[ "def", "move", "(", "x", ",", "y", ",", "absolute", "=", "True", ",", "duration", "=", "0", ")", ":", "x", "=", "int", "(", "x", ")", "y", "=", "int", "(", "y", ")", "# Requires an extra system call on Linux, but `move_relative` is measured", "# in millimite...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
drag
Holds the left mouse button, moving from start to end position, then releases. `absolute` and `duration` are parameters regarding the mouse movement.
keyboard/mouse.py
def drag(start_x, start_y, end_x, end_y, absolute=True, duration=0): """ Holds the left mouse button, moving from start to end position, then releases. `absolute` and `duration` are parameters regarding the mouse movement. """ if is_pressed(): release() move(start_x, start_y, absolut...
def drag(start_x, start_y, end_x, end_y, absolute=True, duration=0): """ Holds the left mouse button, moving from start to end position, then releases. `absolute` and `duration` are parameters regarding the mouse movement. """ if is_pressed(): release() move(start_x, start_y, absolut...
[ "Holds", "the", "left", "mouse", "button", "moving", "from", "start", "to", "end", "position", "then", "releases", ".", "absolute", "and", "duration", "are", "parameters", "regarding", "the", "mouse", "movement", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L103-L114
[ "def", "drag", "(", "start_x", ",", "start_y", ",", "end_x", ",", "end_y", ",", "absolute", "=", "True", ",", "duration", "=", "0", ")", ":", "if", "is_pressed", "(", ")", ":", "release", "(", ")", "move", "(", "start_x", ",", "start_y", ",", "abso...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
on_button
Invokes `callback` with `args` when the specified event happens.
keyboard/mouse.py
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)): """ Invokes `callback` with `args` when the specified event happens. """ if not isinstance(buttons, (tuple, list)): buttons = (buttons,) if not isinstance(types, (tuple, list)): types = (types,)...
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)): """ Invokes `callback` with `args` when the specified event happens. """ if not isinstance(buttons, (tuple, list)): buttons = (buttons,) if not isinstance(types, (tuple, list)): types = (types,)...
[ "Invokes", "callback", "with", "args", "when", "the", "specified", "event", "happens", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L116-L128
[ "def", "on_button", "(", "callback", ",", "args", "=", "(", ")", ",", "buttons", "=", "(", "LEFT", ",", "MIDDLE", ",", "RIGHT", ",", "X", ",", "X2", ")", ",", "types", "=", "(", "UP", ",", "DOWN", ",", "DOUBLE", ")", ")", ":", "if", "not", "i...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
wait
Blocks program execution until the given button performs an event.
keyboard/mouse.py
def wait(button=LEFT, target_types=(UP, DOWN, DOUBLE)): """ Blocks program execution until the given button performs an event. """ from threading import Lock lock = Lock() lock.acquire() handler = on_button(lock.release, (), [button], target_types) lock.acquire() _listener.remove_han...
def wait(button=LEFT, target_types=(UP, DOWN, DOUBLE)): """ Blocks program execution until the given button performs an event. """ from threading import Lock lock = Lock() lock.acquire() handler = on_button(lock.release, (), [button], target_types) lock.acquire() _listener.remove_han...
[ "Blocks", "program", "execution", "until", "the", "given", "button", "performs", "an", "event", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L148-L157
[ "def", "wait", "(", "button", "=", "LEFT", ",", "target_types", "=", "(", "UP", ",", "DOWN", ",", "DOUBLE", ")", ")", ":", "from", "threading", "import", "Lock", "lock", "=", "Lock", "(", ")", "lock", ".", "acquire", "(", ")", "handler", "=", "on_b...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
record
Records all mouse events until the user presses the given button. Then returns the list of events recorded. Pairs well with `play(events)`. Note: this is a blocking function. Note: for more details on the mouse hook and events see `hook`.
keyboard/mouse.py
def record(button=RIGHT, target_types=(DOWN,)): """ Records all mouse events until the user presses the given button. Then returns the list of events recorded. Pairs well with `play(events)`. Note: this is a blocking function. Note: for more details on the mouse hook and events see `hook`. """ ...
def record(button=RIGHT, target_types=(DOWN,)): """ Records all mouse events until the user presses the given button. Then returns the list of events recorded. Pairs well with `play(events)`. Note: this is a blocking function. Note: for more details on the mouse hook and events see `hook`. """ ...
[ "Records", "all", "mouse", "events", "until", "the", "user", "presses", "the", "given", "button", ".", "Then", "returns", "the", "list", "of", "events", "recorded", ".", "Pairs", "well", "with", "play", "(", "events", ")", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L188-L200
[ "def", "record", "(", "button", "=", "RIGHT", ",", "target_types", "=", "(", "DOWN", ",", ")", ")", ":", "recorded", "=", "[", "]", "hook", "(", "recorded", ".", "append", ")", "wait", "(", "button", "=", "button", ",", "target_types", "=", "target_t...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
play
Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. The parameters `include_*` define if events of that type should be inluded in the replay or ignored.
keyboard/mouse.py
def play(events, speed_factor=1.0, include_clicks=True, include_moves=True, include_wheel=True): """ Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. The paramete...
def play(events, speed_factor=1.0, include_clicks=True, include_moves=True, include_wheel=True): """ Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with `record()`. The paramete...
[ "Plays", "a", "sequence", "of", "recorded", "events", "maintaining", "the", "relative", "time", "intervals", ".", "If", "speed_factor", "is", "<", "=", "0", "then", "the", "actions", "are", "replayed", "as", "fast", "as", "the", "OS", "allows", ".", "Pairs...
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/mouse.py#L202-L225
[ "def", "play", "(", "events", ",", "speed_factor", "=", "1.0", ",", "include_clicks", "=", "True", ",", "include_moves", "=", "True", ",", "include_wheel", "=", "True", ")", ":", "last_time", "=", "None", "for", "event", "in", "events", ":", "if", "speed...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
normalize_name
Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to the canonical representation (e.g. "left ctrl") if one is known.
keyboard/_canonical_names.py
def normalize_name(name): """ Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to the canonical representation (e.g. "left ctrl") if one is known. """ if not name or not isinstance(name, basestring): raise ValueError('Can only normalize non-empty string names. Unexpect...
def normalize_name(name): """ Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to the canonical representation (e.g. "left ctrl") if one is known. """ if not name or not isinstance(name, basestring): raise ValueError('Can only normalize non-empty string names. Unexpect...
[ "Given", "a", "key", "name", "(", "e", ".", "g", ".", "LEFT", "CONTROL", ")", "clean", "up", "the", "string", "and", "convert", "to", "the", "canonical", "representation", "(", "e", ".", "g", ".", "left", "ctrl", ")", "if", "one", "is", "known", "....
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_canonical_names.py#L1233-L1246
[ "def", "normalize_name", "(", "name", ")", ":", "if", "not", "name", "or", "not", "isinstance", "(", "name", ",", "basestring", ")", ":", "raise", "ValueError", "(", "'Can only normalize non-empty string names. Unexpected '", "+", "repr", "(", "name", ")", ")", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
listen
Appends events to the queue (ButtonEvent, WheelEvent, and MoveEvent).
keyboard/_darwinmouse.py
def listen(queue): """ Appends events to the queue (ButtonEvent, WheelEvent, and MoveEvent). """ if not os.geteuid() == 0: raise OSError("Error 13 - Must be run as administrator") listener = MouseEventListener(lambda e: queue.put(e) or is_allowed(e.name, e.event_type == KEY_UP)) t = threading.Th...
def listen(queue): """ Appends events to the queue (ButtonEvent, WheelEvent, and MoveEvent). """ if not os.geteuid() == 0: raise OSError("Error 13 - Must be run as administrator") listener = MouseEventListener(lambda e: queue.put(e) or is_allowed(e.name, e.event_type == KEY_UP)) t = threading.Th...
[ "Appends", "events", "to", "the", "queue", "(", "ButtonEvent", "WheelEvent", "and", "MoveEvent", ")", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L79-L86
[ "def", "listen", "(", "queue", ")", ":", "if", "not", "os", ".", "geteuid", "(", ")", "==", "0", ":", "raise", "OSError", "(", "\"Error 13 - Must be run as administrator\"", ")", "listener", "=", "MouseEventListener", "(", "lambda", "e", ":", "queue", ".", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
press
Sends a down event for the specified button, using the provided constants
keyboard/_darwinmouse.py
def press(button=LEFT): """ Sends a down event for the specified button, using the provided constants """ location = get_position() button_code, button_down, _, _ = _button_mapping[button] e = Quartz.CGEventCreateMouseEvent( None, button_down, location, button_code) ...
def press(button=LEFT): """ Sends a down event for the specified button, using the provided constants """ location = get_position() button_code, button_down, _, _ = _button_mapping[button] e = Quartz.CGEventCreateMouseEvent( None, button_down, location, button_code) ...
[ "Sends", "a", "down", "event", "for", "the", "specified", "button", "using", "the", "provided", "constants" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L88-L113
[ "def", "press", "(", "button", "=", "LEFT", ")", ":", "location", "=", "get_position", "(", ")", "button_code", ",", "button_down", ",", "_", ",", "_", "=", "_button_mapping", "[", "button", "]", "e", "=", "Quartz", ".", "CGEventCreateMouseEvent", "(", "...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
release
Sends an up event for the specified button, using the provided constants
keyboard/_darwinmouse.py
def release(button=LEFT): """ Sends an up event for the specified button, using the provided constants """ location = get_position() button_code, _, button_up, _ = _button_mapping[button] e = Quartz.CGEventCreateMouseEvent( None, button_up, location, button_code) if ...
def release(button=LEFT): """ Sends an up event for the specified button, using the provided constants """ location = get_position() button_code, _, button_up, _ = _button_mapping[button] e = Quartz.CGEventCreateMouseEvent( None, button_up, location, button_code) if ...
[ "Sends", "an", "up", "event", "for", "the", "specified", "button", "using", "the", "provided", "constants" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L115-L132
[ "def", "release", "(", "button", "=", "LEFT", ")", ":", "location", "=", "get_position", "(", ")", "button_code", ",", "_", ",", "button_up", ",", "_", "=", "_button_mapping", "[", "button", "]", "e", "=", "Quartz", ".", "CGEventCreateMouseEvent", "(", "...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
wheel
Sends a wheel event for the provided number of clicks. May be negative to reverse direction.
keyboard/_darwinmouse.py
def wheel(delta=1): """ Sends a wheel event for the provided number of clicks. May be negative to reverse direction. """ location = get_position() e = Quartz.CGEventCreateMouseEvent( None, Quartz.kCGEventScrollWheel, location, Quartz.kCGMouseButtonLeft) e2 = Quartz.CG...
def wheel(delta=1): """ Sends a wheel event for the provided number of clicks. May be negative to reverse direction. """ location = get_position() e = Quartz.CGEventCreateMouseEvent( None, Quartz.kCGEventScrollWheel, location, Quartz.kCGMouseButtonLeft) e2 = Quartz.CG...
[ "Sends", "a", "wheel", "event", "for", "the", "provided", "number", "of", "clicks", ".", "May", "be", "negative", "to", "reverse", "direction", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L134-L149
[ "def", "wheel", "(", "delta", "=", "1", ")", ":", "location", "=", "get_position", "(", ")", "e", "=", "Quartz", ".", "CGEventCreateMouseEvent", "(", "None", ",", "Quartz", ".", "kCGEventScrollWheel", ",", "location", ",", "Quartz", ".", "kCGMouseButtonLeft"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
move_to
Sets the mouse's location to the specified coordinates.
keyboard/_darwinmouse.py
def move_to(x, y): """ Sets the mouse's location to the specified coordinates. """ for b in _button_state: if _button_state[b]: e = Quartz.CGEventCreateMouseEvent( None, _button_mapping[b][3], # Drag Event (x, y), _button_mappin...
def move_to(x, y): """ Sets the mouse's location to the specified coordinates. """ for b in _button_state: if _button_state[b]: e = Quartz.CGEventCreateMouseEvent( None, _button_mapping[b][3], # Drag Event (x, y), _button_mappin...
[ "Sets", "the", "mouse", "s", "location", "to", "the", "specified", "coordinates", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L151-L167
[ "def", "move_to", "(", "x", ",", "y", ")", ":", "for", "b", "in", "_button_state", ":", "if", "_button_state", "[", "b", "]", ":", "e", "=", "Quartz", ".", "CGEventCreateMouseEvent", "(", "None", ",", "_button_mapping", "[", "b", "]", "[", "3", "]", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
get_position
Returns the mouse's location as a tuple of (x, y).
keyboard/_darwinmouse.py
def get_position(): """ Returns the mouse's location as a tuple of (x, y). """ e = Quartz.CGEventCreate(None) point = Quartz.CGEventGetLocation(e) return (point.x, point.y)
def get_position(): """ Returns the mouse's location as a tuple of (x, y). """ e = Quartz.CGEventCreate(None) point = Quartz.CGEventGetLocation(e) return (point.x, point.y)
[ "Returns", "the", "mouse", "s", "location", "as", "a", "tuple", "of", "(", "x", "y", ")", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinmouse.py#L169-L173
[ "def", "get_position", "(", ")", ":", "e", "=", "Quartz", ".", "CGEventCreate", "(", "None", ")", "point", "=", "Quartz", ".", "CGEventGetLocation", "(", "e", ")", "return", "(", "point", ".", "x", ",", "point", ".", "y", ")" ]
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
KeyMap.character_to_vk
Returns a tuple of (scan_code, modifiers) where ``scan_code`` is a numeric scan code and ``modifiers`` is an array of string modifier names (like 'shift')
keyboard/_darwinkeyboard.py
def character_to_vk(self, character): """ Returns a tuple of (scan_code, modifiers) where ``scan_code`` is a numeric scan code and ``modifiers`` is an array of string modifier names (like 'shift') """ for vk in self.non_layout_keys: if self.non_layout_keys[vk] == character.lower(): ...
def character_to_vk(self, character): """ Returns a tuple of (scan_code, modifiers) where ``scan_code`` is a numeric scan code and ``modifiers`` is an array of string modifier names (like 'shift') """ for vk in self.non_layout_keys: if self.non_layout_keys[vk] == character.lower(): ...
[ "Returns", "a", "tuple", "of", "(", "scan_code", "modifiers", ")", "where", "scan_code", "is", "a", "numeric", "scan", "code", "and", "modifiers", "is", "an", "array", "of", "string", "modifier", "names", "(", "like", "shift", ")" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinkeyboard.py#L174-L185
[ "def", "character_to_vk", "(", "self", ",", "character", ")", ":", "for", "vk", "in", "self", ".", "non_layout_keys", ":", "if", "self", ".", "non_layout_keys", "[", "vk", "]", "==", "character", ".", "lower", "(", ")", ":", "return", "(", "vk", ",", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
KeyMap.vk_to_character
Returns a character corresponding to the specified scan code (with given modifiers applied)
keyboard/_darwinkeyboard.py
def vk_to_character(self, vk, modifiers=[]): """ Returns a character corresponding to the specified scan code (with given modifiers applied) """ if vk in self.non_layout_keys: # Not a character return self.non_layout_keys[vk] elif vk in self.layout_specific_keys: ...
def vk_to_character(self, vk, modifiers=[]): """ Returns a character corresponding to the specified scan code (with given modifiers applied) """ if vk in self.non_layout_keys: # Not a character return self.non_layout_keys[vk] elif vk in self.layout_specific_keys: ...
[ "Returns", "a", "character", "corresponding", "to", "the", "specified", "scan", "code", "(", "with", "given", "modifiers", "applied", ")" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinkeyboard.py#L187-L199
[ "def", "vk_to_character", "(", "self", ",", "vk", ",", "modifiers", "=", "[", "]", ")", ":", "if", "vk", "in", "self", ".", "non_layout_keys", ":", "# Not a character", "return", "self", ".", "non_layout_keys", "[", "vk", "]", "elif", "vk", "in", "self",...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
KeyController.press
Sends a 'down' event for the specified scan code
keyboard/_darwinkeyboard.py
def press(self, key_code): """ Sends a 'down' event for the specified scan code """ if key_code >= 128: # Media key ev = NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( 14, # type (0, 0), # loc...
def press(self, key_code): """ Sends a 'down' event for the specified scan code """ if key_code >= 128: # Media key ev = NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( 14, # type (0, 0), # loc...
[ "Sends", "a", "down", "event", "for", "the", "specified", "scan", "code" ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinkeyboard.py#L239-L284
[ "def", "press", "(", "self", ",", "key_code", ")", ":", "if", "key_code", ">=", "128", ":", "# Media key", "ev", "=", "NSEvent", ".", "otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_", "(", "14", ",", "# type", "(", "0", ...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
KeyEventListener.run
Creates a listener and loops while waiting for an event. Intended to run as a background thread.
keyboard/_darwinkeyboard.py
def run(self): """ Creates a listener and loops while waiting for an event. Intended to run as a background thread. """ self.tap = Quartz.CGEventTapCreate( Quartz.kCGSessionEventTap, Quartz.kCGHeadInsertEventTap, Quartz.kCGEventTapOptionDefault, Qu...
def run(self): """ Creates a listener and loops while waiting for an event. Intended to run as a background thread. """ self.tap = Quartz.CGEventTapCreate( Quartz.kCGSessionEventTap, Quartz.kCGHeadInsertEventTap, Quartz.kCGEventTapOptionDefault, Qu...
[ "Creates", "a", "listener", "and", "loops", "while", "waiting", "for", "an", "event", ".", "Intended", "to", "run", "as", "a", "background", "thread", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_darwinkeyboard.py#L354-L372
[ "def", "run", "(", "self", ")", ":", "self", ".", "tap", "=", "Quartz", ".", "CGEventTapCreate", "(", "Quartz", ".", "kCGSessionEventTap", ",", "Quartz", ".", "kCGHeadInsertEventTap", ",", "Quartz", ".", "kCGEventTapOptionDefault", ",", "Quartz", ".", "CGEvent...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
cleanup_key
Formats a dumpkeys format to our standard.
keyboard/_nixkeyboard.py
def cleanup_key(name): """ Formats a dumpkeys format to our standard. """ name = name.lstrip('+') is_keypad = name.startswith('KP_') for mod in ('Meta_', 'Control_', 'dead_', 'KP_'): if name.startswith(mod): name = name[len(mod):] # Dumpkeys is weird like that. if name == 'R...
def cleanup_key(name): """ Formats a dumpkeys format to our standard. """ name = name.lstrip('+') is_keypad = name.startswith('KP_') for mod in ('Meta_', 'Control_', 'dead_', 'KP_'): if name.startswith(mod): name = name[len(mod):] # Dumpkeys is weird like that. if name == 'R...
[ "Formats", "a", "dumpkeys", "format", "to", "our", "standard", "." ]
boppreh/keyboard
python
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/_nixkeyboard.py#L13-L33
[ "def", "cleanup_key", "(", "name", ")", ":", "name", "=", "name", ".", "lstrip", "(", "'+'", ")", "is_keypad", "=", "name", ".", "startswith", "(", "'KP_'", ")", "for", "mod", "in", "(", "'Meta_'", ",", "'Control_'", ",", "'dead_'", ",", "'KP_'", ")"...
dbb73dfff484f733d5fed8dbc53301af5b6c7f50
train
indentedBlock
Helper method for defining space-delimited indentation blocks, such as those used to define block statements in Python source code. Parameters: - blockStatementExpr - expression defining syntax of statement that is repeated within the indented block - indentStack - list created by c...
pkg_resources/_vendor/pyparsing.py
def indentedBlock(blockStatementExpr, indentStack, indent=True): """ Helper method for defining space-delimited indentation blocks, such as those used to define block statements in Python source code. Parameters: - blockStatementExpr - expression defining syntax of statement that ...
def indentedBlock(blockStatementExpr, indentStack, indent=True): """ Helper method for defining space-delimited indentation blocks, such as those used to define block statements in Python source code. Parameters: - blockStatementExpr - expression defining syntax of statement that ...
[ "Helper", "method", "for", "defining", "space", "-", "delimited", "indentation", "blocks", "such", "as", "those", "used", "to", "define", "block", "statements", "in", "Python", "source", "code", ".", "Parameters", ":", "-", "blockStatementExpr", "-", "expression...
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L5247-L5359
[ "def", "indentedBlock", "(", "blockStatementExpr", ",", "indentStack", ",", "indent", "=", "True", ")", ":", "def", "checkPeerIndent", "(", "s", ",", "l", ",", "t", ")", ":", "if", "l", ">=", "len", "(", "s", ")", ":", "return", "curCol", "=", "col",...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ParseResults.copy
Returns a new copy of a C{ParseResults} object.
pkg_resources/_vendor/pyparsing.py
def copy( self ): """ Returns a new copy of a C{ParseResults} object. """ ret = ParseResults( self.__toklist ) ret.__tokdict = self.__tokdict.copy() ret.__parent = self.__parent ret.__accumNames.update( self.__accumNames ) ret.__name = self.__name ...
def copy( self ): """ Returns a new copy of a C{ParseResults} object. """ ret = ParseResults( self.__toklist ) ret.__tokdict = self.__tokdict.copy() ret.__parent = self.__parent ret.__accumNames.update( self.__accumNames ) ret.__name = self.__name ...
[ "Returns", "a", "new", "copy", "of", "a", "C", "{", "ParseResults", "}", "object", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L755-L764
[ "def", "copy", "(", "self", ")", ":", "ret", "=", "ParseResults", "(", "self", ".", "__toklist", ")", "ret", ".", "__tokdict", "=", "self", ".", "__tokdict", ".", "copy", "(", ")", "ret", ".", "__parent", "=", "self", ".", "__parent", "ret", ".", "...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ParseResults.asXML
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
pkg_resources/_vendor/pyparsing.py
def asXML( self, doctag=None, namedItemsOnly=False, indent="", formatted=True ): """ (Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names. """ nl = "\n" out = [] namedItems = dict((v[1],k) for (k,vlist)...
def asXML( self, doctag=None, namedItemsOnly=False, indent="", formatted=True ): """ (Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names. """ nl = "\n" out = [] namedItems = dict((v[1],k) for (k,vlist)...
[ "(", "Deprecated", ")", "Returns", "the", "parse", "results", "as", "XML", ".", "Tags", "are", "created", "for", "tokens", "and", "lists", "that", "have", "defined", "results", "names", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L766-L825
[ "def", "asXML", "(", "self", ",", "doctag", "=", "None", ",", "namedItemsOnly", "=", "False", ",", "indent", "=", "\"\"", ",", "formatted", "=", "True", ")", ":", "nl", "=", "\"\\n\"", "out", "=", "[", "]", "namedItems", "=", "dict", "(", "(", "v",...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ParserElement.scanString
Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' matches are found. If C{overlap} is specified, then overlapping matches will be reporte...
pkg_resources/_vendor/pyparsing.py
def scanString( self, instring, maxMatches=_MAX_INT, overlap=False ): """ Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' match...
def scanString( self, instring, maxMatches=_MAX_INT, overlap=False ): """ Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' match...
[ "Scan", "the", "input", "string", "for", "expression", "matches", ".", "Each", "match", "will", "return", "the", "matching", "tokens", "start", "location", "and", "end", "location", ".", "May", "be", "called", "with", "optional", "C", "{", "maxMatches", "}",...
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L1658-L1727
[ "def", "scanString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ",", "overlap", "=", "False", ")", ":", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "for", "e", "in", "self", ".", "ignoreExpr...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ParserElement.transformString
Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. Invoking C{transformString()} on a target string will then ...
pkg_resources/_vendor/pyparsing.py
def transformString( self, instring ): """ Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. ...
def transformString( self, instring ): """ Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. ...
[ "Extension", "to", "C", "{", "L", "{", "scanString", "}}", "to", "modify", "matching", "text", "with", "modified", "tokens", "that", "may", "be", "returned", "from", "a", "parse", "action", ".", "To", "use", "C", "{", "transformString", "}", "define", "a...
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L1729-L1770
[ "def", "transformString", "(", "self", ",", "instring", ")", ":", "out", "=", "[", "]", "lastE", "=", "0", "# force preservation of <TAB>s, to minimize unwanted transformation of string, and to\r", "# keep string locs straight between transformString and scanString\r", "self", "....
83c667e0b2a98193851c07115d1af65011ed0fb6
train
bdist_wininst.reinitialize_command
Supplement reinitialize_command to work around http://bugs.python.org/issue20819
setuptools/command/bdist_wininst.py
def reinitialize_command(self, command, reinit_subcommands=0): """ Supplement reinitialize_command to work around http://bugs.python.org/issue20819 """ cmd = self.distribution.reinitialize_command( command, reinit_subcommands) if command in ('install', 'instal...
def reinitialize_command(self, command, reinit_subcommands=0): """ Supplement reinitialize_command to work around http://bugs.python.org/issue20819 """ cmd = self.distribution.reinitialize_command( command, reinit_subcommands) if command in ('install', 'instal...
[ "Supplement", "reinitialize_command", "to", "work", "around", "http", ":", "//", "bugs", ".", "python", ".", "org", "/", "issue20819" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/bdist_wininst.py#L5-L14
[ "def", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", "=", "0", ")", ":", "cmd", "=", "self", ".", "distribution", ".", "reinitialize_command", "(", "command", ",", "reinit_subcommands", ")", "if", "command", "in", "(", "'insta...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
samefile
Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist.
setuptools/command/easy_install.py
def samefile(p1, p2): """ Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. """ both_exist = os.path.exists(p1) and os.path.exists(p2) use_samefile = hasattr(os.path, 'samefile') and both_exist i...
def samefile(p1, p2): """ Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. """ both_exist = os.path.exists(p1) and os.path.exists(p2) use_samefile = hasattr(os.path, 'samefile') and both_exist i...
[ "Determine", "if", "two", "paths", "reference", "the", "same", "file", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L84-L97
[ "def", "samefile", "(", "p1", ",", "p2", ")", ":", "both_exist", "=", "os", ".", "path", ".", "exists", "(", "p1", ")", "and", "os", ".", "path", ".", "exists", "(", "p2", ")", "use_samefile", "=", "hasattr", "(", "os", ".", "path", ",", "'samefi...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
get_site_dirs
Return a list of 'site' dirs
setuptools/command/easy_install.py
def get_site_dirs(): """ Return a list of 'site' dirs """ sitedirs = [] # start with PYTHONPATH sitedirs.extend(_pythonpath()) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) for prefix in prefixes: if prefix: ...
def get_site_dirs(): """ Return a list of 'site' dirs """ sitedirs = [] # start with PYTHONPATH sitedirs.extend(_pythonpath()) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) for prefix in prefixes: if prefix: ...
[ "Return", "a", "list", "of", "site", "dirs" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1393-L1455
[ "def", "get_site_dirs", "(", ")", ":", "sitedirs", "=", "[", "]", "# start with PYTHONPATH", "sitedirs", ".", "extend", "(", "_pythonpath", "(", ")", ")", "prefixes", "=", "[", "sys", ".", "prefix", "]", "if", "sys", ".", "exec_prefix", "!=", "sys", ".",...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
expand_paths
Yield sys.path directories that might contain "old-style" packages
setuptools/command/easy_install.py
def expand_paths(inputs): """Yield sys.path directories that might contain "old-style" packages""" seen = {} for dirname in inputs: dirname = normalize_path(dirname) if dirname in seen: continue seen[dirname] = 1 if not os.path.isdir(dirname): conti...
def expand_paths(inputs): """Yield sys.path directories that might contain "old-style" packages""" seen = {} for dirname in inputs: dirname = normalize_path(dirname) if dirname in seen: continue seen[dirname] = 1 if not os.path.isdir(dirname): conti...
[ "Yield", "sys", ".", "path", "directories", "that", "might", "contain", "old", "-", "style", "packages" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1458-L1496
[ "def", "expand_paths", "(", "inputs", ")", ":", "seen", "=", "{", "}", "for", "dirname", "in", "inputs", ":", "dirname", "=", "normalize_path", "(", "dirname", ")", "if", "dirname", "in", "seen", ":", "continue", "seen", "[", "dirname", "]", "=", "1", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
get_exe_prefixes
Get exe->egg path translations for a given .exe file
setuptools/command/easy_install.py
def get_exe_prefixes(exe_filename): """Get exe->egg path translations for a given .exe file""" prefixes = [ ('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''), ('PLATLIB/', ''), ('SCRIPTS/', 'EGG-INFO/scripts/'), ('DATA/lib/site-packages', ''), ] z = zipfile.ZipF...
def get_exe_prefixes(exe_filename): """Get exe->egg path translations for a given .exe file""" prefixes = [ ('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''), ('PLATLIB/', ''), ('SCRIPTS/', 'EGG-INFO/scripts/'), ('DATA/lib/site-packages', ''), ] z = zipfile.ZipF...
[ "Get", "exe", "-", ">", "egg", "path", "translations", "for", "a", "given", ".", "exe", "file" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1540-L1576
[ "def", "get_exe_prefixes", "(", "exe_filename", ")", ":", "prefixes", "=", "[", "(", "'PURELIB/'", ",", "''", ")", ",", "(", "'PLATLIB/pywin32_system32'", ",", "''", ")", ",", "(", "'PLATLIB/'", ",", "''", ")", ",", "(", "'SCRIPTS/'", ",", "'EGG-INFO/scrip...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
_first_line_re
Return a regular expression based on first_line_re suitable for matching strings.
setuptools/command/easy_install.py
def _first_line_re(): """ Return a regular expression based on first_line_re suitable for matching strings. """ if isinstance(first_line_re.pattern, str): return first_line_re # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern. return re.compile(first_line_re.pattern.d...
def _first_line_re(): """ Return a regular expression based on first_line_re suitable for matching strings. """ if isinstance(first_line_re.pattern, str): return first_line_re # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern. return re.compile(first_line_re.pattern.d...
[ "Return", "a", "regular", "expression", "based", "on", "first_line_re", "suitable", "for", "matching", "strings", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1713-L1722
[ "def", "_first_line_re", "(", ")", ":", "if", "isinstance", "(", "first_line_re", ".", "pattern", ",", "str", ")", ":", "return", "first_line_re", "# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.", "return", "re", ".", "compile", "(", "first_line_re", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
update_dist_caches
Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared si...
setuptools/command/easy_install.py
def update_dist_caches(dist_path, fix_zipimporter_caches): """ Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data fro...
def update_dist_caches(dist_path, fix_zipimporter_caches): """ Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data fro...
[ "Fix", "any", "globally", "cached", "dist_path", "related", "data" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1733-L1812
[ "def", "update_dist_caches", "(", "dist_path", ",", "fix_zipimporter_caches", ")", ":", "# There are several other known sources of stale zipimport.zipimporter", "# instances that we do not clear here, but might if ever given a reason to", "# do so:", "# * Global setuptools pkg_resources.worki...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
_collect_zipimporter_cache_entries
Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip arc...
setuptools/command/easy_install.py
def _collect_zipimporter_cache_entries(normalized_path, cache): """ Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any su...
def _collect_zipimporter_cache_entries(normalized_path, cache): """ Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any su...
[ "Return", "zipimporter", "cache", "entry", "keys", "related", "to", "a", "given", "normalized", "path", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1815-L1832
[ "def", "_collect_zipimporter_cache_entries", "(", "normalized_path", ",", "cache", ")", ":", "result", "=", "[", "]", "prefix_len", "=", "len", "(", "normalized_path", ")", "for", "p", "in", "cache", ":", "np", "=", "normalize_path", "(", "p", ")", "if", "...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
is_python
Is this string a valid Python script?
setuptools/command/easy_install.py
def is_python(text, filename='<string>'): "Is this string a valid Python script?" try: compile(text, filename, 'exec') except (SyntaxError, TypeError): return False else: return True
def is_python(text, filename='<string>'): "Is this string a valid Python script?" try: compile(text, filename, 'exec') except (SyntaxError, TypeError): return False else: return True
[ "Is", "this", "string", "a", "valid", "Python", "script?" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1912-L1919
[ "def", "is_python", "(", "text", ",", "filename", "=", "'<string>'", ")", ":", "try", ":", "compile", "(", "text", ",", "filename", ",", "'exec'", ")", "except", "(", "SyntaxError", ",", "TypeError", ")", ":", "return", "False", "else", ":", "return", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
is_sh
Determine if the specified executable is a .sh (contains a #! line)
setuptools/command/easy_install.py
def is_sh(executable): """Determine if the specified executable is a .sh (contains a #! line)""" try: with io.open(executable, encoding='latin-1') as fp: magic = fp.read(2) except (OSError, IOError): return executable return magic == '#!'
def is_sh(executable): """Determine if the specified executable is a .sh (contains a #! line)""" try: with io.open(executable, encoding='latin-1') as fp: magic = fp.read(2) except (OSError, IOError): return executable return magic == '#!'
[ "Determine", "if", "the", "specified", "executable", "is", "a", ".", "sh", "(", "contains", "a", "#!", "line", ")" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1922-L1929
[ "def", "is_sh", "(", "executable", ")", ":", "try", ":", "with", "io", ".", "open", "(", "executable", ",", "encoding", "=", "'latin-1'", ")", "as", "fp", ":", "magic", "=", "fp", ".", "read", "(", "2", ")", "except", "(", "OSError", ",", "IOError"...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
is_python_script
Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
setuptools/command/easy_install.py
def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ if filename.endswith('.py') or filename.endswith('.pyw'): return True # extension says it's Python if is_python(script_text, filename): return True # it's syntac...
def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ if filename.endswith('.py') or filename.endswith('.pyw'): return True # extension says it's Python if is_python(script_text, filename): return True # it's syntac...
[ "Is", "this", "text", "as", "a", "whole", "a", "Python", "script?", "(", "as", "opposed", "to", "shell", "/", "bat", "/", "etc", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1937-L1948
[ "def", "is_python_script", "(", "script_text", ",", "filename", ")", ":", "if", "filename", ".", "endswith", "(", "'.py'", ")", "or", "filename", ".", "endswith", "(", "'.pyw'", ")", ":", "return", "True", "# extension says it's Python", "if", "is_python", "("...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
get_win_launcher
Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string.
setuptools/command/easy_install.py
def get_win_launcher(type): """ Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. """ launcher_fn = '%s.exe' % type if is_64bit(): launcher_fn = launcher_fn.replace(".", "-64.") ...
def get_win_launcher(type): """ Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. """ launcher_fn = '%s.exe' % type if is_64bit(): launcher_fn = launcher_fn.replace(".", "-64.") ...
[ "Load", "the", "Windows", "launcher", "(", "executable", ")", "suitable", "for", "launching", "a", "script", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2253-L2266
[ "def", "get_win_launcher", "(", "type", ")", ":", "launcher_fn", "=", "'%s.exe'", "%", "type", "if", "is_64bit", "(", ")", ":", "launcher_fn", "=", "launcher_fn", ".", "replace", "(", "\".\"", ",", "\"-64.\"", ")", "else", ":", "launcher_fn", "=", "launche...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install._render_version
Render the Setuptools version and installation details, then exit.
setuptools/command/easy_install.py
def _render_version(): """ Render the Setuptools version and installation details, then exit. """ ver = sys.version[:3] dist = get_distribution('setuptools') tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})' print(tmpl.format(**locals())) ...
def _render_version(): """ Render the Setuptools version and installation details, then exit. """ ver = sys.version[:3] dist = get_distribution('setuptools') tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})' print(tmpl.format(**locals())) ...
[ "Render", "the", "Setuptools", "version", "and", "installation", "details", "then", "exit", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L240-L248
[ "def", "_render_version", "(", ")", ":", "ver", "=", "sys", ".", "version", "[", ":", "3", "]", "dist", "=", "get_distribution", "(", "'setuptools'", ")", "tmpl", "=", "'setuptools {dist.version} from {dist.location} (Python {ver})'", "print", "(", "tmpl", ".", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install._fix_install_dir_for_user_site
Fix the install_dir if "--user" was used.
setuptools/command/easy_install.py
def _fix_install_dir_for_user_site(self): """ Fix the install_dir if "--user" was used. """ if not self.user or not site.ENABLE_USER_SITE: return self.create_home_path() if self.install_userbase is None: msg = "User base directory is not specified...
def _fix_install_dir_for_user_site(self): """ Fix the install_dir if "--user" was used. """ if not self.user or not site.ENABLE_USER_SITE: return self.create_home_path() if self.install_userbase is None: msg = "User base directory is not specified...
[ "Fix", "the", "install_dir", "if", "--", "user", "was", "used", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L372-L385
[ "def", "_fix_install_dir_for_user_site", "(", "self", ")", ":", "if", "not", "self", ".", "user", "or", "not", "site", ".", "ENABLE_USER_SITE", ":", "return", "self", ".", "create_home_path", "(", ")", "if", "self", ".", "install_userbase", "is", "None", ":"...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.check_pth_processing
Empirically verify whether .pth files are supported in inst. dir
setuptools/command/easy_install.py
def check_pth_processing(self): """Empirically verify whether .pth files are supported in inst. dir""" instdir = self.install_dir log.info("Checking .pth file support in %s", instdir) pth_file = self.pseudo_tempname() + ".pth" ok_file = pth_file + '.ok' ok_exists = os.pat...
def check_pth_processing(self): """Empirically verify whether .pth files are supported in inst. dir""" instdir = self.install_dir log.info("Checking .pth file support in %s", instdir) pth_file = self.pseudo_tempname() + ".pth" ok_file = pth_file + '.ok' ok_exists = os.pat...
[ "Empirically", "verify", "whether", ".", "pth", "files", "are", "supported", "in", "inst", ".", "dir" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L537-L594
[ "def", "check_pth_processing", "(", "self", ")", ":", "instdir", "=", "self", ".", "install_dir", "log", ".", "info", "(", "\"Checking .pth file support in %s\"", ",", "instdir", ")", "pth_file", "=", "self", ".", "pseudo_tempname", "(", ")", "+", "\".pth\"", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.install_egg_scripts
Write all the scripts for `dist`, unless scripts are excluded
setuptools/command/easy_install.py
def install_egg_scripts(self, dist): """Write all the scripts for `dist`, unless scripts are excluded""" if not self.exclude_scripts and dist.metadata_isdir('scripts'): for script_name in dist.metadata_listdir('scripts'): if dist.metadata_isdir('scripts/' + script_name): ...
def install_egg_scripts(self, dist): """Write all the scripts for `dist`, unless scripts are excluded""" if not self.exclude_scripts and dist.metadata_isdir('scripts'): for script_name in dist.metadata_listdir('scripts'): if dist.metadata_isdir('scripts/' + script_name): ...
[ "Write", "all", "the", "scripts", "for", "dist", "unless", "scripts", "are", "excluded" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L596-L608
[ "def", "install_egg_scripts", "(", "self", ",", "dist", ")", ":", "if", "not", "self", ".", "exclude_scripts", "and", "dist", ".", "metadata_isdir", "(", "'scripts'", ")", ":", "for", "script_name", "in", "dist", ".", "metadata_listdir", "(", "'scripts'", ")...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.select_scheme
Sets the install directories by applying the install schemes.
setuptools/command/easy_install.py
def select_scheme(self, name): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = INSTALL_SCHEMES[name] for key in SCHEME_KEYS: attrname = 'install_' + key if getattr(self, attrname) ...
def select_scheme(self, name): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = INSTALL_SCHEMES[name] for key in SCHEME_KEYS: attrname = 'install_' + key if getattr(self, attrname) ...
[ "Sets", "the", "install", "directories", "by", "applying", "the", "install", "schemes", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L717-L724
[ "def", "select_scheme", "(", "self", ",", "name", ")", ":", "# it's the caller's problem if they supply a bad name!", "scheme", "=", "INSTALL_SCHEMES", "[", "name", "]", "for", "key", "in", "SCHEME_KEYS", ":", "attrname", "=", "'install_'", "+", "key", "if", "geta...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.write_script
Write an executable file to the scripts directory
setuptools/command/easy_install.py
def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" self.delete_blockers( # clean up old .py/.pyw w/o a script [os.path.join(self.script_dir, x) for x in blockers] ) log.info("Installing %s script to %...
def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" self.delete_blockers( # clean up old .py/.pyw w/o a script [os.path.join(self.script_dir, x) for x in blockers] ) log.info("Installing %s script to %...
[ "Write", "an", "executable", "file", "to", "the", "scripts", "directory" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L828-L846
[ "def", "write_script", "(", "self", ",", "script_name", ",", "contents", ",", "mode", "=", "\"t\"", ",", "blockers", "=", "(", ")", ")", ":", "self", ".", "delete_blockers", "(", "# clean up old .py/.pyw w/o a script", "[", "os", ".", "path", ".", "join", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.exe_to_egg
Extract a bdist_wininst to the directories an egg would use
setuptools/command/easy_install.py
def exe_to_egg(self, dist_filename, egg_tmp): """Extract a bdist_wininst to the directories an egg would use""" # Check for .pth file and set up prefix translations prefixes = get_exe_prefixes(dist_filename) to_compile = [] native_libs = [] top_level = {} def pro...
def exe_to_egg(self, dist_filename, egg_tmp): """Extract a bdist_wininst to the directories an egg would use""" # Check for .pth file and set up prefix translations prefixes = get_exe_prefixes(dist_filename) to_compile = [] native_libs = [] top_level = {} def pro...
[ "Extract", "a", "bdist_wininst", "to", "the", "directories", "an", "egg", "would", "use" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L999-L1050
[ "def", "exe_to_egg", "(", "self", ",", "dist_filename", ",", "egg_tmp", ")", ":", "# Check for .pth file and set up prefix translations", "prefixes", "=", "get_exe_prefixes", "(", "dist_filename", ")", "to_compile", "=", "[", "]", "native_libs", "=", "[", "]", "top_...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
easy_install.installation_report
Helpful installation message for display to package users
setuptools/command/easy_install.py
def installation_report(self, req, dist, what="Installed"): """Helpful installation message for display to package users""" msg = "\n%(what)s %(eggloc)s%(extras)s" if self.multi_version and not self.no_report: msg += '\n' + self.__mv_warning if self.install_dir not in map...
def installation_report(self, req, dist, what="Installed"): """Helpful installation message for display to package users""" msg = "\n%(what)s %(eggloc)s%(extras)s" if self.multi_version and not self.no_report: msg += '\n' + self.__mv_warning if self.install_dir not in map...
[ "Helpful", "installation", "message", "for", "display", "to", "package", "users" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1098-L1110
[ "def", "installation_report", "(", "self", ",", "req", ",", "dist", ",", "what", "=", "\"Installed\"", ")", ":", "msg", "=", "\"\\n%(what)s %(eggloc)s%(extras)s\"", "if", "self", ".", "multi_version", "and", "not", "self", ".", "no_report", ":", "msg", "+=", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
PthDistributions.add
Add `dist` to the distribution map
setuptools/command/easy_install.py
def add(self, dist): """Add `dist` to the distribution map""" new_path = ( dist.location not in self.paths and ( dist.location not in self.sitedirs or # account for '.' being in PYTHONPATH dist.location == os.getcwd() ) ) ...
def add(self, dist): """Add `dist` to the distribution map""" new_path = ( dist.location not in self.paths and ( dist.location not in self.sitedirs or # account for '.' being in PYTHONPATH dist.location == os.getcwd() ) ) ...
[ "Add", "dist", "to", "the", "distribution", "map" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1650-L1662
[ "def", "add", "(", "self", ",", "dist", ")", ":", "new_path", "=", "(", "dist", ".", "location", "not", "in", "self", ".", "paths", "and", "(", "dist", ".", "location", "not", "in", "self", ".", "sitedirs", "or", "# account for '.' being in PYTHONPATH", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
PthDistributions.remove
Remove `dist` from the distribution map
setuptools/command/easy_install.py
def remove(self, dist): """Remove `dist` from the distribution map""" while dist.location in self.paths: self.paths.remove(dist.location) self.dirty = True Environment.remove(self, dist)
def remove(self, dist): """Remove `dist` from the distribution map""" while dist.location in self.paths: self.paths.remove(dist.location) self.dirty = True Environment.remove(self, dist)
[ "Remove", "dist", "from", "the", "distribution", "map" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1664-L1669
[ "def", "remove", "(", "self", ",", "dist", ")", ":", "while", "dist", ".", "location", "in", "self", ".", "paths", ":", "self", ".", "paths", ".", "remove", "(", "dist", ".", "location", ")", "self", ".", "dirty", "=", "True", "Environment", ".", "...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
CommandSpec.from_param
Construct a CommandSpec from a parameter to build_scripts, which may be None.
setuptools/command/easy_install.py
def from_param(cls, param): """ Construct a CommandSpec from a parameter to build_scripts, which may be None. """ if isinstance(param, cls): return param if isinstance(param, list): return cls(param) if param is None: return cls...
def from_param(cls, param): """ Construct a CommandSpec from a parameter to build_scripts, which may be None. """ if isinstance(param, cls): return param if isinstance(param, list): return cls(param) if param is None: return cls...
[ "Construct", "a", "CommandSpec", "from", "a", "parameter", "to", "build_scripts", "which", "may", "be", "None", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1989-L2001
[ "def", "from_param", "(", "cls", ",", "param", ")", ":", "if", "isinstance", "(", "param", ",", "cls", ")", ":", "return", "param", "if", "isinstance", "(", "param", ",", "list", ")", ":", "return", "cls", "(", "param", ")", "if", "param", "is", "N...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
CommandSpec.from_string
Construct a command spec from a simple string representing a command line parseable by shlex.split.
setuptools/command/easy_install.py
def from_string(cls, string): """ Construct a command spec from a simple string representing a command line parseable by shlex.split. """ items = shlex.split(string, **cls.split_args) return cls(items)
def from_string(cls, string): """ Construct a command spec from a simple string representing a command line parseable by shlex.split. """ items = shlex.split(string, **cls.split_args) return cls(items)
[ "Construct", "a", "command", "spec", "from", "a", "simple", "string", "representing", "a", "command", "line", "parseable", "by", "shlex", ".", "split", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2008-L2014
[ "def", "from_string", "(", "cls", ",", "string", ")", ":", "items", "=", "shlex", ".", "split", "(", "string", ",", "*", "*", "cls", ".", "split_args", ")", "return", "cls", "(", "items", ")" ]
83c667e0b2a98193851c07115d1af65011ed0fb6
train
CommandSpec._extract_options
Extract any options from the first line of the script.
setuptools/command/easy_install.py
def _extract_options(orig_script): """ Extract any options from the first line of the script. """ first = (orig_script + '\n').splitlines()[0] match = _first_line_re().match(first) options = match.group(1) or '' if match else '' return options.strip()
def _extract_options(orig_script): """ Extract any options from the first line of the script. """ first = (orig_script + '\n').splitlines()[0] match = _first_line_re().match(first) options = match.group(1) or '' if match else '' return options.strip()
[ "Extract", "any", "options", "from", "the", "first", "line", "of", "the", "script", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2023-L2030
[ "def", "_extract_options", "(", "orig_script", ")", ":", "first", "=", "(", "orig_script", "+", "'\\n'", ")", ".", "splitlines", "(", ")", "[", "0", "]", "match", "=", "_first_line_re", "(", ")", ".", "match", "(", "first", ")", "options", "=", "match"...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ScriptWriter.get_args
Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points.
setuptools/command/easy_install.py
def get_args(cls, dist, header=None): """ Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. """ if header is None: header = cls.get_header() spec = str(dist.as_requirement()) for type_ in 'console',...
def get_args(cls, dist, header=None): """ Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. """ if header is None: header = cls.get_header() spec = str(dist.as_requirement()) for type_ in 'console',...
[ "Yield", "write_script", "()", "argument", "tuples", "for", "a", "distribution", "s", "console_scripts", "and", "gui_scripts", "entry", "points", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2097-L2112
[ "def", "get_args", "(", "cls", ",", "dist", ",", "header", "=", "None", ")", ":", "if", "header", "is", "None", ":", "header", "=", "cls", ".", "get_header", "(", ")", "spec", "=", "str", "(", "dist", ".", "as_requirement", "(", ")", ")", "for", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ScriptWriter.best
Select the best ScriptWriter for this environment.
setuptools/command/easy_install.py
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
[ "Select", "the", "best", "ScriptWriter", "for", "this", "environment", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2130-L2137
[ "def", "best", "(", "cls", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", "or", "(", "os", ".", "name", "==", "'java'", "and", "os", ".", "_name", "==", "'nt'", ")", ":", "return", "WindowsScriptWriter", ".", "best", "(", ")", "else", ":"...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
ScriptWriter.get_header
Create a #! line, getting options (if any) from script_text
setuptools/command/easy_install.py
def get_header(cls, script_text="", executable=None): """Create a #! line, getting options (if any) from script_text""" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header()
def get_header(cls, script_text="", executable=None): """Create a #! line, getting options (if any) from script_text""" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header()
[ "Create", "a", "#!", "line", "getting", "options", "(", "if", "any", ")", "from", "script_text" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2145-L2149
[ "def", "get_header", "(", "cls", ",", "script_text", "=", "\"\"", ",", "executable", "=", "None", ")", ":", "cmd", "=", "cls", ".", "command_spec_class", ".", "best", "(", ")", ".", "from_param", "(", "executable", ")", "cmd", ".", "install_options", "("...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
WindowsScriptWriter.best
Select the best ScriptWriter suitable for Windows
setuptools/command/easy_install.py
def best(cls): """ Select the best ScriptWriter suitable for Windows """ writer_lookup = dict( executable=WindowsExecutableLauncherWriter, natural=cls, ) # for compatibility, use the executable launcher by default launcher = os.environ.get(...
def best(cls): """ Select the best ScriptWriter suitable for Windows """ writer_lookup = dict( executable=WindowsExecutableLauncherWriter, natural=cls, ) # for compatibility, use the executable launcher by default launcher = os.environ.get(...
[ "Select", "the", "best", "ScriptWriter", "suitable", "for", "Windows" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2162-L2172
[ "def", "best", "(", "cls", ")", ":", "writer_lookup", "=", "dict", "(", "executable", "=", "WindowsExecutableLauncherWriter", ",", "natural", "=", "cls", ",", ")", "# for compatibility, use the executable launcher by default", "launcher", "=", "os", ".", "environ", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
WindowsScriptWriter._get_script_args
For Windows, add a .py extension
setuptools/command/easy_install.py
def _get_script_args(cls, type_, name, header, script_text): "For Windows, add a .py extension" ext = dict(console='.pya', gui='.pyw')[type_] if ext not in os.environ['PATHEXT'].lower().split(';'): msg = ( "{ext} not listed in PATHEXT; scripts will not be " ...
def _get_script_args(cls, type_, name, header, script_text): "For Windows, add a .py extension" ext = dict(console='.pya', gui='.pyw')[type_] if ext not in os.environ['PATHEXT'].lower().split(';'): msg = ( "{ext} not listed in PATHEXT; scripts will not be " ...
[ "For", "Windows", "add", "a", ".", "py", "extension" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2175-L2188
[ "def", "_get_script_args", "(", "cls", ",", "type_", ",", "name", ",", "header", ",", "script_text", ")", ":", "ext", "=", "dict", "(", "console", "=", "'.pya'", ",", "gui", "=", "'.pyw'", ")", "[", "type_", "]", "if", "ext", "not", "in", "os", "."...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
WindowsScriptWriter._adjust_header
Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is).
setuptools/command/easy_install.py
def _adjust_header(cls, type_, orig_header): """ Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). """ pattern = 'pythonw.exe' repl = 'python.exe' if type_ == 'gui': pattern, repl = repl, p...
def _adjust_header(cls, type_, orig_header): """ Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). """ pattern = 'pythonw.exe' repl = 'python.exe' if type_ == 'gui': pattern, repl = repl, p...
[ "Make", "sure", "pythonw", "is", "used", "for", "gui", "and", "and", "python", "is", "used", "for", "console", "(", "regardless", "of", "what", "sys", ".", "executable", "is", ")", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2191-L2202
[ "def", "_adjust_header", "(", "cls", ",", "type_", ",", "orig_header", ")", ":", "pattern", "=", "'pythonw.exe'", "repl", "=", "'python.exe'", "if", "type_", "==", "'gui'", ":", "pattern", ",", "repl", "=", "repl", ",", "pattern", "pattern_ob", "=", "re", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
WindowsExecutableLauncherWriter._get_script_args
For Windows, add a .py extension and an .exe launcher
setuptools/command/easy_install.py
def _get_script_args(cls, type_, name, header, script_text): """ For Windows, add a .py extension and an .exe launcher """ if type_ == 'gui': launcher_type = 'gui' ext = '-script.pyw' old = ['.pyw'] else: launcher_type = 'cli' ...
def _get_script_args(cls, type_, name, header, script_text): """ For Windows, add a .py extension and an .exe launcher """ if type_ == 'gui': launcher_type = 'gui' ext = '-script.pyw' old = ['.pyw'] else: launcher_type = 'cli' ...
[ "For", "Windows", "add", "a", ".", "py", "extension", "and", "an", ".", "exe", "launcher" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2219-L2245
[ "def", "_get_script_args", "(", "cls", ",", "type_", ",", "name", ",", "header", ",", "script_text", ")", ":", "if", "type_", "==", "'gui'", ":", "launcher_type", "=", "'gui'", "ext", "=", "'-script.pyw'", "old", "=", "[", "'.pyw'", "]", "else", ":", "...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
upload._load_password_from_keyring
Attempt to load password from keyring. Suppress Exceptions.
setuptools/command/upload.py
def _load_password_from_keyring(self): """ Attempt to load password from keyring. Suppress Exceptions. """ try: keyring = __import__('keyring') return keyring.get_password(self.repository, self.username) except Exception: pass
def _load_password_from_keyring(self): """ Attempt to load password from keyring. Suppress Exceptions. """ try: keyring = __import__('keyring') return keyring.get_password(self.repository, self.username) except Exception: pass
[ "Attempt", "to", "load", "password", "from", "keyring", ".", "Suppress", "Exceptions", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/upload.py#L179-L187
[ "def", "_load_password_from_keyring", "(", "self", ")", ":", "try", ":", "keyring", "=", "__import__", "(", "'keyring'", ")", "return", "keyring", ".", "get_password", "(", "self", ".", "repository", ",", "self", ".", "username", ")", "except", "Exception", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
_to_str
Convert a filename to a string (on Python 2, explicitly a byte string, not Unicode) as distutils checks for the exact type str.
setuptools/build_meta.py
def _to_str(s): """ Convert a filename to a string (on Python 2, explicitly a byte string, not Unicode) as distutils checks for the exact type str. """ if sys.version_info[0] == 2 and not isinstance(s, str): # Assume it's Unicode, as that's what the PEP says # should be provided....
def _to_str(s): """ Convert a filename to a string (on Python 2, explicitly a byte string, not Unicode) as distutils checks for the exact type str. """ if sys.version_info[0] == 2 and not isinstance(s, str): # Assume it's Unicode, as that's what the PEP says # should be provided....
[ "Convert", "a", "filename", "to", "a", "string", "(", "on", "Python", "2", "explicitly", "a", "byte", "string", "not", "Unicode", ")", "as", "distutils", "checks", "for", "the", "exact", "type", "str", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/build_meta.py#L78-L88
[ "def", "_to_str", "(", "s", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "==", "2", "and", "not", "isinstance", "(", "s", ",", "str", ")", ":", "# Assume it's Unicode, as that's what the PEP says", "# should be provided.", "return", "s", ".", "...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
Distribution.patch
Replace distutils.dist.Distribution with this class for the duration of this context.
setuptools/build_meta.py
def patch(cls): """ Replace distutils.dist.Distribution with this class for the duration of this context. """ orig = distutils.core.Distribution distutils.core.Distribution = cls try: yield finally: distutils.core.Distributi...
def patch(cls): """ Replace distutils.dist.Distribution with this class for the duration of this context. """ orig = distutils.core.Distribution distutils.core.Distribution = cls try: yield finally: distutils.core.Distributi...
[ "Replace", "distutils", ".", "dist", ".", "Distribution", "with", "this", "class", "for", "the", "duration", "of", "this", "context", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/build_meta.py#L64-L75
[ "def", "patch", "(", "cls", ")", ":", "orig", "=", "distutils", ".", "core", ".", "Distribution", "distutils", ".", "core", ".", "Distribution", "=", "cls", "try", ":", "yield", "finally", ":", "distutils", ".", "core", ".", "Distribution", "=", "orig" ]
83c667e0b2a98193851c07115d1af65011ed0fb6
train
run
Run the script in sys.argv[1] as if it had been invoked naturally.
setuptools/launch.py
def run(): """ Run the script in sys.argv[1] as if it had been invoked naturally. """ __builtins__ script_name = sys.argv[1] namespace = dict( __file__=script_name, __name__='__main__', __doc__=None, ) sys.argv[:] = sys.argv[1:] open_ = getattr(tokenize, ...
def run(): """ Run the script in sys.argv[1] as if it had been invoked naturally. """ __builtins__ script_name = sys.argv[1] namespace = dict( __file__=script_name, __name__='__main__', __doc__=None, ) sys.argv[:] = sys.argv[1:] open_ = getattr(tokenize, ...
[ "Run", "the", "script", "in", "sys", ".", "argv", "[", "1", "]", "as", "if", "it", "had", "been", "invoked", "naturally", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/launch.py#L13-L31
[ "def", "run", "(", ")", ":", "__builtins__", "script_name", "=", "sys", ".", "argv", "[", "1", "]", "namespace", "=", "dict", "(", "__file__", "=", "script_name", ",", "__name__", "=", "'__main__'", ",", "__doc__", "=", "None", ",", ")", "sys", ".", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py.run
Build modules, packages, and copy data files to build directory
setuptools/command/build_py.py
def run(self): """Build modules, packages, and copy data files to build directory""" if not self.py_modules and not self.packages: return if self.py_modules: self.build_modules() if self.packages: self.build_packages() self.build_package_...
def run(self): """Build modules, packages, and copy data files to build directory""" if not self.py_modules and not self.packages: return if self.py_modules: self.build_modules() if self.packages: self.build_packages() self.build_package_...
[ "Build", "modules", "packages", "and", "copy", "data", "files", "to", "build", "directory" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L43-L61
[ "def", "run", "(", "self", ")", ":", "if", "not", "self", ".", "py_modules", "and", "not", "self", ".", "packages", ":", "return", "if", "self", ".", "py_modules", ":", "self", ".", "build_modules", "(", ")", "if", "self", ".", "packages", ":", "self...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py._get_data_files
Generate list of '(package,src_dir,build_dir,filenames)' tuples
setuptools/command/build_py.py
def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() return list(map(self._get_pkg_data_files, self.packages or ()))
def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() return list(map(self._get_pkg_data_files, self.packages or ()))
[ "Generate", "list", "of", "(", "package", "src_dir", "build_dir", "filenames", ")", "tuples" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L80-L83
[ "def", "_get_data_files", "(", "self", ")", ":", "self", ".", "analyze_manifest", "(", ")", "return", "list", "(", "map", "(", "self", ".", "_get_pkg_data_files", ",", "self", ".", "packages", "or", "(", ")", ")", ")" ]
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py.find_data_files
Return filenames for package's data files in 'src_dir
setuptools/command/build_py.py
def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" patterns = self._get_platform_patterns( self.package_data, package, src_dir, ) globs_expanded = map(glob, patterns) # flatten the expanded...
def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" patterns = self._get_platform_patterns( self.package_data, package, src_dir, ) globs_expanded = map(glob, patterns) # flatten the expanded...
[ "Return", "filenames", "for", "package", "s", "data", "files", "in", "src_dir" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L99-L114
[ "def", "find_data_files", "(", "self", ",", "package", ",", "src_dir", ")", ":", "patterns", "=", "self", ".", "_get_platform_patterns", "(", "self", ".", "package_data", ",", "package", ",", "src_dir", ",", ")", "globs_expanded", "=", "map", "(", "glob", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py.build_package_data
Copy data files into build directory
setuptools/command/build_py.py
def build_package_data(self): """Copy data files into build directory""" for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) self.mkpath(os.path.dirname(target)) s...
def build_package_data(self): """Copy data files into build directory""" for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) self.mkpath(os.path.dirname(target)) s...
[ "Copy", "data", "files", "into", "build", "directory" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L116-L127
[ "def", "build_package_data", "(", "self", ")", ":", "for", "package", ",", "src_dir", ",", "build_dir", ",", "filenames", "in", "self", ".", "data_files", ":", "for", "filename", "in", "filenames", ":", "target", "=", "os", ".", "path", ".", "join", "(",...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py.check_package
Check namespace packages' __init__ for declare_namespace
setuptools/command/build_py.py
def check_package(self, package, package_dir): """Check namespace packages' __init__ for declare_namespace""" try: return self.packages_checked[package] except KeyError: pass init_py = orig.build_py.check_package(self, package, package_dir) self.packages_...
def check_package(self, package, package_dir): """Check namespace packages' __init__ for declare_namespace""" try: return self.packages_checked[package] except KeyError: pass init_py = orig.build_py.check_package(self, package, package_dir) self.packages_...
[ "Check", "namespace", "packages", "__init__", "for", "declare_namespace" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L156-L184
[ "def", "check_package", "(", "self", ",", "package", ",", "package_dir", ")", ":", "try", ":", "return", "self", ".", "packages_checked", "[", "package", "]", "except", "KeyError", ":", "pass", "init_py", "=", "orig", ".", "build_py", ".", "check_package", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py.exclude_data_files
Filter filenames for package's data files in 'src_dir
setuptools/command/build_py.py
def exclude_data_files(self, package, src_dir, files): """Filter filenames for package's data files in 'src_dir'""" files = list(files) patterns = self._get_platform_patterns( self.exclude_package_data, package, src_dir, ) match_groups = ( ...
def exclude_data_files(self, package, src_dir, files): """Filter filenames for package's data files in 'src_dir'""" files = list(files) patterns = self._get_platform_patterns( self.exclude_package_data, package, src_dir, ) match_groups = ( ...
[ "Filter", "filenames", "for", "package", "s", "data", "files", "in", "src_dir" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L196-L217
[ "def", "exclude_data_files", "(", "self", ",", "package", ",", "src_dir", ",", "files", ")", ":", "files", "=", "list", "(", "files", ")", "patterns", "=", "self", ".", "_get_platform_patterns", "(", "self", ".", "exclude_package_data", ",", "package", ",", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
build_py._get_platform_patterns
yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir.
setuptools/command/build_py.py
def _get_platform_patterns(spec, package, src_dir): """ yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. """ raw_patterns = itertools....
def _get_platform_patterns(spec, package, src_dir): """ yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. """ raw_patterns = itertools....
[ "yield", "platform", "-", "specific", "path", "patterns", "(", "suitable", "for", "glob", "or", "fn_match", ")", "from", "a", "glob", "-", "based", "spec", "(", "such", "as", "self", ".", "package_data", "or", "self", ".", "exclude_package_data", ")", "mat...
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/build_py.py#L220-L235
[ "def", "_get_platform_patterns", "(", "spec", ",", "package", ",", "src_dir", ")", ":", "raw_patterns", "=", "itertools", ".", "chain", "(", "spec", ".", "get", "(", "''", ",", "[", "]", ")", ",", "spec", ".", "get", "(", "package", ",", "[", "]", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
require_metadata
Prevent improper installs without necessary metadata. See #659
setup.py
def require_metadata(): "Prevent improper installs without necessary metadata. See #659" egg_info_dir = os.path.join(here, 'setuptools.egg-info') if not os.path.exists(egg_info_dir): msg = ( "Cannot build setuptools without metadata. " "Run `bootstrap.py`." ) ...
def require_metadata(): "Prevent improper installs without necessary metadata. See #659" egg_info_dir = os.path.join(here, 'setuptools.egg-info') if not os.path.exists(egg_info_dir): msg = ( "Cannot build setuptools without metadata. " "Run `bootstrap.py`." ) ...
[ "Prevent", "improper", "installs", "without", "necessary", "metadata", ".", "See", "#659" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setup.py#L16-L24
[ "def", "require_metadata", "(", ")", ":", "egg_info_dir", "=", "os", ".", "path", ".", "join", "(", "here", ",", "'setuptools.egg-info'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "egg_info_dir", ")", ":", "msg", "=", "(", "\"Cannot build ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
pypi_link
Given the filename, including md5 fragment, construct the dependency link for PyPI.
setup.py
def pypi_link(pkg_filename): """ Given the filename, including md5 fragment, construct the dependency link for PyPI. """ root = 'https://files.pythonhosted.org/packages/source' name, sep, rest = pkg_filename.partition('-') parts = root, name[0], name, pkg_filename return '/'.join(parts)
def pypi_link(pkg_filename): """ Given the filename, including md5 fragment, construct the dependency link for PyPI. """ root = 'https://files.pythonhosted.org/packages/source' name, sep, rest = pkg_filename.partition('-') parts = root, name[0], name, pkg_filename return '/'.join(parts)
[ "Given", "the", "filename", "including", "md5", "fragment", "construct", "the", "dependency", "link", "for", "PyPI", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setup.py#L79-L87
[ "def", "pypi_link", "(", "pkg_filename", ")", ":", "root", "=", "'https://files.pythonhosted.org/packages/source'", "name", ",", "sep", ",", "rest", "=", "pkg_filename", ".", "partition", "(", "'-'", ")", "parts", "=", "root", ",", "name", "[", "0", "]", ","...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
glibc_version_string
Returns glibc version string, or None if not using glibc.
setuptools/glibc.py
def glibc_version_string(): "Returns glibc version string, or None if not using glibc." # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "If filename is NULL, then the returned handle is for the # main program". This way we can let the linker do the work to figure ou...
def glibc_version_string(): "Returns glibc version string, or None if not using glibc." # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "If filename is NULL, then the returned handle is for the # main program". This way we can let the linker do the work to figure ou...
[ "Returns", "glibc", "version", "string", "or", "None", "if", "not", "using", "glibc", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/glibc.py#L10-L32
[ "def", "glibc_version_string", "(", ")", ":", "# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen", "# manpage says, \"If filename is NULL, then the returned handle is for the", "# main program\". This way we can let the linker do the work to figure out", "# which libc our process ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
unpack_archive
Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it will be extracted. The callback must return the desired extract path (which may be the same as...
setuptools/archive_util.py
def unpack_archive(filename, extract_dir, progress_filter=default_filter, drivers=None): """Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it...
def unpack_archive(filename, extract_dir, progress_filter=default_filter, drivers=None): """Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it...
[ "Unpack", "filename", "to", "extract_dir", "or", "raise", "UnrecognizedFormat" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/archive_util.py#L28-L60
[ "def", "unpack_archive", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ",", "drivers", "=", "None", ")", ":", "for", "driver", "in", "drivers", "or", "extraction_drivers", ":", "try", ":", "driver", "(", "filename", ",", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
unpack_zipfile
Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.
setuptools/archive_util.py
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter): """Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument. ...
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter): """Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument. ...
[ "Unpack", "zip", "filename", "to", "extract_dir" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/archive_util.py#L90-L124
[ "def", "unpack_zipfile", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ")", ":", "if", "not", "zipfile", ".", "is_zipfile", "(", "filename", ")", ":", "raise", "UnrecognizedFormat", "(", "\"%s is not a zip file\"", "%", "(", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
unpack_tarfile
Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.
setuptools/archive_util.py
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` a...
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` a...
[ "Unpack", "tar", "/", "tar", ".", "gz", "/", "tar", ".", "bz2", "filename", "to", "extract_dir" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/archive_util.py#L127-L170
[ "def", "unpack_tarfile", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ")", ":", "try", ":", "tarobj", "=", "tarfile", ".", "open", "(", "filename", ")", "except", "tarfile", ".", "TarError", ":", "raise", "UnrecognizedFor...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
msvc9_find_vcvarsall
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visu...
setuptools/msvc.py
def msvc9_find_vcvarsall(version): """ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ...
def msvc9_find_vcvarsall(version): """ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ...
[ "Patched", "distutils", ".", "msvc9compiler", ".", "find_vcvarsall", "to", "use", "the", "standalone", "compiler", "build", "for", "Python", "(", "VCForPython", ")", ".", "Fall", "back", "to", "original", "behavior", "when", "the", "standalone", "compiler", "is"...
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L63-L103
[ "def", "msvc9_find_vcvarsall", "(", "version", ")", ":", "VC_BASE", "=", "r'Software\\%sMicrosoft\\DevDiv\\VCForPython\\%0.1f'", "key", "=", "VC_BASE", "%", "(", "''", ",", "version", ")", "try", ":", "# Per-user installs register the compiler path here", "productdir", "=...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
msvc9_query_vcvarsall
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Microsoft Windows S...
setuptools/msvc.py
def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs): """ Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Vi...
def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs): """ Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Vi...
[ "Patched", "distutils", ".", "msvc9compiler", ".", "query_vcvarsall", "for", "support", "extra", "compilers", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L106-L150
[ "def", "msvc9_query_vcvarsall", "(", "ver", ",", "arch", "=", "'x86'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Try to get environement from vcvarsall.bat (Classical way)", "try", ":", "orig", "=", "get_unpatched", "(", "msvc9_query_vcvarsall", ")", ...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
msvc14_get_vc_env
Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual Studio 20...
setuptools/msvc.py
def msvc14_get_vc_env(plat_spec): """ Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86...
def msvc14_get_vc_env(plat_spec): """ Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86...
[ "Patched", "distutils", ".", "_msvccompiler", ".", "_get_vc_env", "for", "support", "extra", "compilers", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L153-L188
[ "def", "msvc14_get_vc_env", "(", "plat_spec", ")", ":", "# Try to get environment from vcvarsall.bat (Classical way)", "try", ":", "return", "get_unpatched", "(", "msvc14_get_vc_env", ")", "(", "plat_spec", ")", "except", "distutils", ".", "errors", ".", "DistutilsPlatfor...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
msvc14_gen_lib_options
Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2)
setuptools/msvc.py
def msvc14_gen_lib_options(*args, **kwargs): """ Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2) """ if "numpy.distutils" in sys.modules: import numpy as np if LegacyVersion(np.__...
def msvc14_gen_lib_options(*args, **kwargs): """ Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2) """ if "numpy.distutils" in sys.modules: import numpy as np if LegacyVersion(np.__...
[ "Patched", "distutils", ".", "_msvccompiler", ".", "gen_lib_options", "for", "fix", "compatibility", "between", "numpy", ".", "distutils", "and", "distutils", ".", "_msvccompiler", "(", "for", "Numpy", "<", "1", ".", "11", ".", "2", ")" ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L191-L201
[ "def", "msvc14_gen_lib_options", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "\"numpy.distutils\"", "in", "sys", ".", "modules", ":", "import", "numpy", "as", "np", "if", "LegacyVersion", "(", "np", ".", "__version__", ")", "<", "LegacyVersi...
83c667e0b2a98193851c07115d1af65011ed0fb6
train
_augment_exception
Add details to the exception message to help guide the user as to what action will resolve it.
setuptools/msvc.py
def _augment_exception(exc, version, arch=''): """ Add details to the exception message to help guide the user as to what action will resolve it. """ # Error if MSVC++ directory not found or environment not set message = exc.args[0] if "vcvarsall" in message.lower() or "visual c" in message...
def _augment_exception(exc, version, arch=''): """ Add details to the exception message to help guide the user as to what action will resolve it. """ # Error if MSVC++ directory not found or environment not set message = exc.args[0] if "vcvarsall" in message.lower() or "visual c" in message...
[ "Add", "details", "to", "the", "exception", "message", "to", "help", "guide", "the", "user", "as", "to", "what", "action", "will", "resolve", "it", "." ]
pypa/setuptools
python
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/msvc.py#L204-L237
[ "def", "_augment_exception", "(", "exc", ",", "version", ",", "arch", "=", "''", ")", ":", "# Error if MSVC++ directory not found or environment not set", "message", "=", "exc", ".", "args", "[", "0", "]", "if", "\"vcvarsall\"", "in", "message", ".", "lower", "(...
83c667e0b2a98193851c07115d1af65011ed0fb6