index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
21,452
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/outputs/glances_stdout_csv.py
51,52
17,120
build_header
GlancesStdoutCsv
53,71
52,71
class GlancesStdoutCsv(object): """This class manages the StdoutCsv display.""" separator = ',' na = 'N/A' def __init__(self, config=None, args=None): # Init self.config = config self.args = args # Display the header only on the first line self.header = True ...
class GlancesStdoutCsv(object): """This class manages the StdoutCsv display.""" separator = ',' na = 'N/A' def __init__(self, config=None, args=None): # Init self.config = config self.args = args # Display the header only on the first line self.header = True ...
line = '' if attribute is not None: line += '{}.{}{}'.format(plugin, attribute, self.separator) else: if isinstance(stat, dict): for k in stat.keys(): line += '{}.{}{}'.format(plugin, str(k), self.separator) elif isinstance...
"""Build and return the header line""" line = '' if attribute is not None: line += '{}.{}{}'.format(plugin, attribute, self.separator) else: if isinstance(stat, dict): for k in stat.keys(): line += '{}.{}{}'.format(plugin, str(...
57
733
204
937
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """StdoutCsv interface class.""" import time from glances.globals import printandflush class GlancesStdoutCsv(object): """This class ma...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """StdoutCsv interface class.""" import time from glances.globals import printandflush class GlancesStdoutCsv(object): """This class ma...
21,453
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/outputs/glances_stdout_issue.py
70,71
42,136
update
GlancesStdoutIssue
72,136
71,136
class GlancesStdoutIssue(object): """This class manages the Issue display.""" def __init__(self, config=None, args=None): # Init self.config = config self.args = args def end(self): pass def print_version(self): sys.stdout.write('=' * TERMINAL_WIDTH + '\n') ...
class GlancesStdoutIssue(object): """This class manages the Issue display.""" def __init__(self, config=None, args=None): # Init self.config = config self.args = args def end(self): pass def print_version(self): sys.stdout.write('=' * TERMINAL_WIDTH + '\n') ...
self.print_version() for plugin in sorted(stats._plugins): if stats._plugins[plugin].is_disabled(): continue try: # Update the stats stats._plugins[plugin].update() except Exception: pass time.s...
"""Display issue""" self.print_version() for plugin in sorted(stats._plugins): if stats._plugins[plugin].is_disabled(): continue try: # Update the stats stats._plugins[plugin].update() except Exception: ...
240
379
786
1,165
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Issue interface class.""" import os import sys import platform import time import pprint from glances.timer import Counter from glances im...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Issue interface class.""" import os import sys import platform import time import pprint from glances.timer import Counter from glances im...
21,454
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/outputs/glances_stdout_issue.py
34,35
27,42
disable
colors
35,42
35,42
class colors: RED = '\033[91m' GREEN = '\033[92m' ORANGE = '\033[93m' BLUE = '\033[94m' NO = '\033[0m' def disable(self): FILL_FUNC_BODY
class colors: RED = '\033[91m' GREEN = '\033[92m' ORANGE = '\033[93m' BLUE = '\033[94m' NO = '\033[0m' def disable(self): FILL_FUNC_BODY
self.RED = '' self.GREEN = '' self.BLUE = '' self.ORANGE = '' self.NO = ''
self.RED = '' self.GREEN = '' self.BLUE = '' self.ORANGE = '' self.NO = ''
15
90
48
138
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Issue interface class.""" import os import sys import platform import time import pprint from glances.timer import Counter from glances im...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Issue interface class.""" import os import sys import platform import time import pprint from glances.timer import Counter from glances im...
21,455
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/outputs/glances_stdout_json.py
38,39
17,55
update
GlancesStdoutJson
43,55
39,55
class GlancesStdoutJson(object): """This class manages the Stdout JSON display.""" def __init__(self, config=None, args=None): # Init self.config = config self.args = args # Build the list of plugin to display self.plugins_list = self.build_list() def build_list(se...
class GlancesStdoutJson(object): """This class manages the Stdout JSON display.""" def __init__(self, config=None, args=None): # Init self.config = config self.args = args # Build the list of plugin to display self.plugins_list = self.build_list() def build_list(se...
for plugin in self.plugins_list: # Check if the plugin exist and is enable if plugin in stats.getPluginsList() and stats.get_plugin(plugin).is_enabled(): stat = stats.get_plugin(plugin).get_json() else: continue # Display stats ...
"""Display stats in JSON format to stdout. Refresh every duration second. """ for plugin in self.plugins_list: # Check if the plugin exist and is enable if plugin in stats.getPluginsList() and stats.get_plugin(plugin).is_enabled(): stat = stats.ge...
40
215
127
342
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Stdout interface class.""" import time from glances.globals import printandflush class GlancesStdoutJson(object): """This class mana...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Stdout interface class.""" import time from glances.globals import printandflush class GlancesStdoutJson(object): """This class mana...
21,456
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/outputs/glances_unicode.py
24,25
1,30
unicode_message
26,30
25,30
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage unicode message for Glances output.""" _unicode_message = { 'ARROW_LEFT': [u'\u2190', u'<'], 'ARROW_RIGHT': [u'\u2192', u'>'...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage unicode message for Glances output.""" _unicode_message = { 'ARROW_LEFT': [u'\u2190', u'<'], 'ARROW_RIGHT': [u'\u2192', u'>'...
if args and hasattr(args, 'disable_unicode') and args.disable_unicode: return _unicode_message[key][1] else: return _unicode_message[key][0]
"""Return the unicode message for the given key.""" if args and hasattr(args, 'disable_unicode') and args.disable_unicode: return _unicode_message[key][1] else: return _unicode_message[key][0]
12
304
58
362
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage unicode message for Glances output.""" _unicode_message = { 'ARROW_LEFT': [u'\u2190', u'<'], 'ARROW_RIGHT': [u'\u2192', u'>'...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage unicode message for Glances output.""" _unicode_message = { 'ARROW_LEFT': [u'\u2190', u'<'], 'ARROW_RIGHT': [u'\u2192', u'>'...
21,457
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/password.py
56,58
24,127
check_password
GlancesPassword
62,67
58,67
class GlancesPassword(object): """This class contains all the methods relating to password.""" def __init__(self, username='glances', config=None): self.username = username self.config = config self.password_dir = self.local_password_path() self.password_filename = self.usernam...
class GlancesPassword(object): """This class contains all the methods relating to password.""" def __init__(self, username='glances', config=None): self.username = username self.config = config self.password_dir = self.local_password_path() self.password_filename = self.usernam...
logger.info("Check password") salt, encrypted_password = hashed_password.split('$') re_encrypted_password = self.get_hash(plain_password, salt=salt) return encrypted_password == re_encrypted_password
"""Encode the plain_password with the salt of the hashed_password. Return the comparison with the encrypted_password. """ logger.info("Check password") salt, encrypted_password = hashed_password.split('$') re_encrypted_password = self.get_hash(plain_password, salt=salt) ...
14
1,199
69
1,268
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage password.""" import getpass import hashlib import os import sys import uuid from io import open from glances.globals import b, safe...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage password.""" import getpass import hashlib import os import sys import uuid from io import open from glances.globals import b, safe...
21,458
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/password_list.py
46,47
16,66
get_password
GlancesPasswordList
52,63
47,63
class GlancesPasswordList(GlancesPassword): """Manage the Glances passwords list for the client|browser/server.""" _section = "passwords" def __init__(self, config=None, args=None): super(GlancesPasswordList, self).__init__() # password_dict is a dict (JSON compliant) # {'host': 'p...
class GlancesPasswordList(GlancesPassword): """Manage the Glances passwords list for the client|browser/server.""" _section = "passwords" def __init__(self, config=None, args=None): super(GlancesPasswordList, self).__init__() # password_dict is a dict (JSON compliant) # {'host': 'p...
if host is None: return self._password_dict else: try: return self._password_dict[host] except (KeyError, TypeError): try: return self._password_dict['default'] except (KeyError, TypeError): ...
"""Get the password from a Glances client or server. If host=None, return the current server list (dict). Else, return the host's password (or the default one if defined or None) """ if host is None: return self._password_dict else: try: ...
21
409
85
494
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances passwords list.""" from glances.logger import logger from glances.password import GlancesPassword class GlancesPasswor...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances passwords list.""" from glances.logger import logger from glances.password import GlancesPassword class GlancesPasswor...
21,459
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/plugins/containers/stats_streamer.py
73,74
15,87
_post_update_hook
StatsStreamer
75,78
74,78
class StatsStreamer: """ Utility class to stream an iterable using a background / daemon Thread Use `StatsStreamer.stats` to access the latest streamed results """ def __init__(self, iterable, initial_stream_value=None, sleep_duration=0.1): """ iterable: an Iterable instance that n...
class StatsStreamer: """ Utility class to stream an iterable using a background / daemon Thread Use `StatsStreamer.stats` to access the latest streamed results """ def __init__(self, iterable, initial_stream_value=None, sleep_duration=0.1): """ iterable: an Iterable instance that n...
self._last_update_time = time.time() self.result_lock.release()
"""Hook that runs after worker thread updates the raw_stats""" self._last_update_time = time.time() self.result_lock.release()
4
616
28
644
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only import threading import time from glances.logger import logger class StatsStreamer: """ Utility class to stream an iterable using a ba...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only import threading import time from glances.logger import logger class StatsStreamer: """ Utility class to stream an iterable using a ba...
21,460
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/plugins/sensors/sensor/glances_batpercent.py
135,137
83,152
battery_percent
GlancesGrabBat
138,152
137,152
class GlancesGrabBat(object): """Get batteries stats using the batinfo library.""" def __init__(self): """Init batteries stats.""" self.bat_list = [] if batinfo_tag: self.bat = batinfo.batteries() elif psutil_tag: self.bat = psutil else: ...
class GlancesGrabBat(object): """Get batteries stats using the batinfo library.""" def __init__(self): """Init batteries stats.""" self.bat_list = [] if batinfo_tag: self.bat = batinfo.batteries() elif psutil_tag: self.bat = psutil else: ...
if not batinfo_tag or not self.bat.stat: return [] # Init the b_sum (sum of percent) # and Loop over batteries (yes a computer could have more than 1 battery) b_sum = 0 for b in self.bat.stat: try: b_sum += int(b.capacity) exce...
"""Get batteries capacity percent.""" if not batinfo_tag or not self.bat.stat: return [] # Init the b_sum (sum of percent) # and Loop over batteries (yes a computer could have more than 1 battery) b_sum = 0 for b in self.bat.stat: try: ...
53
490
138
628
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Battery plugin.""" import psutil from glances.logger import logger from glances.plugins.plugin.model import GlancesPluginModel # Batinfo ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Battery plugin.""" import psutil from glances.logger import logger from glances.plugins.plugin.model import GlancesPluginModel # Batinfo ...
21,461
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/plugins/sensors/sensor/glances_batpercent.py
61,63
36,83
update
PluginModel
64,83
63,83
class PluginModel(GlancesPluginModel): """Glances battery capacity plugin. stats is a list """ def __init__(self, args=None, config=None): """Init the plugin.""" super(PluginModel, self).__init__(args=args, config=config, stats_init_value=[]) # Init the sensor class tr...
class PluginModel(GlancesPluginModel): """Glances battery capacity plugin. stats is a list """ def __init__(self, args=None, config=None): """Init the plugin.""" super(PluginModel, self).__init__(args=args, config=config, stats_init_value=[]) # Init the sensor class tr...
# Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats self.glances_grab_bat.update() stats = self.glances_grab_bat.get() elif self.input_method == 'snmp': # Update stats using SNMP # No...
"""Update battery capacity stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats self.glances_grab_bat.update() stats = self.glances_grab_bat.get() elif self.input_meth...
40
264
138
402
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Battery plugin.""" import psutil from glances.logger import logger from glances.plugins.plugin.model import GlancesPluginModel # Batinfo ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Battery plugin.""" import psutil from glances.logger import logger from glances.plugins.plugin.model import GlancesPluginModel # Batinfo ...
21,462
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/plugins/sensors/sensor/glances_hddtemp.py
123,124
61,152
fetch
GlancesGrabHDDTemp
125,148
124,148
class GlancesGrabHDDTemp(object): """Get hddtemp stats using a socket connection.""" def __init__(self, host='127.0.0.1', port=7634, args=None): """Init hddtemp stats.""" self.args = args self.host = host self.port = port self.cache = "" self.reset() def res...
class GlancesGrabHDDTemp(object): """Get hddtemp stats using a socket connection.""" def __init__(self, host='127.0.0.1', port=7634, args=None): """Init hddtemp stats.""" self.args = args self.host = host self.port = port self.cache = "" self.reset() def res...
# Taking care of sudden deaths/stops of hddtemp daemon try: sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((self.host, self.port)) data = b'' while True: received = sck.recv(4096) if not received: ...
"""Fetch the data from hddtemp daemon.""" # Taking care of sudden deaths/stops of hddtemp daemon try: sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((self.host, self.port)) data = b'' while True: received = sck....
84
852
265
1,117
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """HDD temperature plugin.""" import os import socket from glances.globals import nativestr from glances.logger import logger from glances.pl...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """HDD temperature plugin.""" import os import socket from glances.globals import nativestr from glances.logger import logger from glances.pl...
21,463
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/plugins/sensors/sensor/glances_hddtemp.py
40,42
20,61
update
PluginModel
43,61
42,61
class PluginModel(GlancesPluginModel): """Glances HDD temperature sensors plugin. stats is a list """ def __init__(self, args=None, config=None): """Init the plugin.""" super(PluginModel, self).__init__(args=args, config=config, stats_init_value=[]) # Init the sensor class ...
class PluginModel(GlancesPluginModel): """Glances HDD temperature sensors plugin. stats is a list """ def __init__(self, args=None, config=None): """Init the plugin.""" super(PluginModel, self).__init__(args=args, config=config, stats_init_value=[]) # Init the sensor class ...
# Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib stats = self.hddtemp.get() else: # Update stats using SNMP # Not available for the moment pass ...
"""Update HDD stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib stats = self.hddtemp.get() else: # Update stats using SNMP ...
44
284
118
402
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """HDD temperature plugin.""" import os import socket from glances.globals import nativestr from glances.logger import logger from glances.pl...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """HDD temperature plugin.""" import os import socket from glances.globals import nativestr from glances.logger import logger from glances.pl...
21,466
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/programs.py
18,19
1,71
create_program_dict
20,41
19,41
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # from collections import Counter # from glances.logger import logger # This constant defines the list of available processes sort key sort_pro...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # from collections import Counter # from glances.logger import logger # This constant defines the list of available processes sort key sort_pro...
return { 'time_since_update': p['time_since_update'], # some values can be None, e.g. macOS system processes 'num_threads': p['num_threads'] or 0, 'cpu_percent': p['cpu_percent'] or 0, 'memory_percent': p['memory_percent'] or 0, 'cpu_times': p['cpu_times'] or {}, ...
"""Create a new entry in the dict (new program)""" return { 'time_since_update': p['time_since_update'], # some values can be None, e.g. macOS system processes 'num_threads': p['num_threads'] or 0, 'cpu_percent': p['cpu_percent'] or 0, 'memory_percent': p['memory_percent'...
72
630
261
891
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # from collections import Counter # from glances.logger import logger # This constant defines the list of available processes sort key sort_pro...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # from collections import Counter # from glances.logger import logger # This constant defines the list of available processes sort key sort_pro...
21,467
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/secure.py
34,35
1,79
__secure_popen
39,79
35,79
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Secures functions for Glances""" from subprocess import Popen, PIPE import re from glances.globals import nativestr def secure_popen(cmd...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Secures functions for Glances""" from subprocess import Popen, PIPE import re from glances.globals import nativestr def secure_popen(cmd...
# Split by redirection '>' cmd_split_redirect = cmd.split('>') if len(cmd_split_redirect) > 2: return 'Glances error: Only one file redirection allowed ({})'.format(cmd) elif len(cmd_split_redirect) == 2: stdout_redirect = cmd_split_redirect[1].strip() cmd = cmd_split_redirect[0]...
"""A more or less secure way to execute system command Manage redirection (>) and pipes (|) """ # Split by redirection '>' cmd_split_redirect = cmd.split('>') if len(cmd_split_redirect) > 2: return 'Glances error: Only one file redirection allowed ({})'.format(cmd) elif len(cmd_spli...
170
267
583
850
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Secures functions for Glances""" from subprocess import Popen, PIPE import re from glances.globals import nativestr def secure_popen(cmd...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Secures functions for Glances""" from subprocess import Popen, PIPE import re from glances.globals import nativestr def secure_popen(cmd...
21,468
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/snmp.py
80,81
22,114
getbulk_by_oid
GlancesSNMPClient
94,114
81,114
class GlancesSNMPClient(object): """SNMP client class (based on pysnmp library).""" def __init__(self, host='localhost', port=161, version='2c', community='public', user='private', auth=''): super(GlancesSNMPClient, self).__init__() self.cmdGen = cmdgen.CommandGenerator() self.version ...
class GlancesSNMPClient(object): """SNMP client class (based on pysnmp library).""" def __init__(self, host='localhost', port=161, version='2c', community='public', user='private', auth=''): super(GlancesSNMPClient, self).__init__() self.cmdGen = cmdgen.CommandGenerator() self.version ...
if self.version.startswith('3'): errorIndication, errorStatus, errorIndex, varBinds = self.cmdGen.getCmd( cmdgen.UsmUserData(self.user, self.auth), cmdgen.UdpTransportTarget((self.host, self.port)), non_repeaters, max_repetitions, ...
"""SNMP getbulk request. In contrast to snmpwalk, this information will typically be gathered in a single transaction with the agent, rather than one transaction per variable found. * non_repeaters: This specifies the number of supplied variables that should not be it...
49
748
260
1,008
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # import sys from glances.logger import logger # Import mandatory PySNMP lib try: from pysnmp.entity.rfc3413.oneliner import cmdgen except ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # import sys from glances.logger import logger # Import mandatory PySNMP lib try: from pysnmp.entity.rfc3413.oneliner import cmdgen except ...
21,469
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/standalone.py
138,139
30,211
__serve_once
GlancesStandalone
143,174
139,174
class GlancesStandalone(object): """This class creates and manages the Glances standalone session.""" def __init__(self, config=None, args=None): self.config = config self.args = args # Quiet mode self._quiet = args.quiet self.refresh_time = args.time # Init st...
class GlancesStandalone(object): """This class creates and manages the Glances standalone session.""" def __init__(self, config=None, args=None): self.config = config self.args = args # Quiet mode self._quiet = args.quiet self.refresh_time = args.time # Init st...
# Update stats # Start a counter used to compute the time needed counter = Counter() self.stats.update() logger.debug('Stats updated duration: {} seconds'.format(counter.get())) # Patch for issue1326 to avoid < 0 refresh adapted_refresh = (self.refresh_time - cou...
"""Main loop for the CLI. :return: True if we should continue (no exit key has been pressed) """ # Update stats # Start a counter used to compute the time needed counter = Counter() self.stats.update() logger.debug('Stats updated duration: {} seconds'.for...
130
1,576
357
1,933
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances standalone session.""" import sys import time from glances.logger import logger from glances.globals import WINDOWS fr...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances standalone session.""" import sys import time from glances.logger import logger from glances.globals import WINDOWS fr...
21,470
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/static_list.py
28,29
17,81
load
GlancesStaticServer
30,74
29,74
class GlancesStaticServer(object): """Manage the static servers list for the client browser.""" _section = "serverlist" def __init__(self, config=None, args=None): # server_list is a list of dict (JSON compliant) # [ {'key': 'zeroconf name', ip': '172.1.2.3', 'port': 61209, 'cpu': 3, 'mem'...
class GlancesStaticServer(object): """Manage the static servers list for the client browser.""" _section = "serverlist" def __init__(self, config=None, args=None): # server_list is a list of dict (JSON compliant) # [ {'key': 'zeroconf name', ip': '172.1.2.3', 'port': 61209, 'cpu': 3, 'mem'...
server_list = [] if config is None: logger.debug("No configuration file available. Cannot load server list.") elif not config.has_section(self._section): logger.warning("No [%s] section in the configuration file. Cannot load server list." % self._section) else: ...
"""Load the server list from the configuration file.""" server_list = [] if config is None: logger.debug("No configuration file available. Cannot load server list.") elif not config.has_section(self._section): logger.warning("No [%s] section in the configuration ...
186
261
565
826
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances server static list.""" from socket import gaierror, gethostbyname from glances.logger import logger class GlancesStat...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances server static list.""" from socket import gaierror, gethostbyname from glances.logger import logger class GlancesStat...
21,472
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/stats_client.py
54,55
19,62
update
GlancesStatsClient
56,62
55,62
class GlancesStatsClient(GlancesStats): """This class stores, updates and gives stats for the client.""" def __init__(self, config=None, args=None): """Init the GlancesStatsClient class.""" super(GlancesStatsClient, self).__init__(config=config, args=args) # Init the configuration ...
class GlancesStatsClient(GlancesStats): """This class stores, updates and gives stats for the client.""" def __init__(self, config=None, args=None): """Init the GlancesStatsClient class.""" super(GlancesStatsClient, self).__init__(config=config, args=args) # Init the configuration ...
# For Glances client mode for p in input_stats: # Update plugin stats with items sent by the server self._plugins[p].set_stats(input_stats[p]) # Update the views for the updated stats self._plugins[p].update_views()
"""Update all the stats.""" # For Glances client mode for p in input_stats: # Update plugin stats with items sent by the server self._plugins[p].set_stats(input_stats[p]) # Update the views for the updated stats self._plugins[p].update_views()
29
352
75
427
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats server manager.""" import sys from glances.stats import GlancesStats from glances.globals import sys_path from glances.logger im...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats server manager.""" import sys from glances.stats import GlancesStats from glances.globals import sys_path from glances.logger im...
21,473
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/stats_client_snmp.py
48,49
30,115
check_snmp
GlancesStatsClientSNMP
50,77
49,77
class GlancesStatsClientSNMP(GlancesStats): """This class stores, updates and gives stats for the SNMP client.""" def __init__(self, config=None, args=None): super(GlancesStatsClientSNMP, self).__init__() # Init the configuration self.config = config # Init the arguments ...
class GlancesStatsClientSNMP(GlancesStats): """This class stores, updates and gives stats for the SNMP client.""" def __init__(self, config=None, args=None): super(GlancesStatsClientSNMP, self).__init__() # Init the configuration self.config = config # Init the arguments ...
# Import the SNMP client class from glances.snmp import GlancesSNMPClient # Create an instance of the SNMP client snmp_client = GlancesSNMPClient( host=self.args.client, port=self.args.snmp_port, version=self.args.snmp_version, community=s...
"""Check if SNMP is available on the server.""" # Import the SNMP client class from glances.snmp import GlancesSNMPClient # Create an instance of the SNMP client snmp_client = GlancesSNMPClient( host=self.args.client, port=self.args.snmp_port, ...
79
523
363
886
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats manager.""" import re from glances.stats import GlancesStats from glances.globals import iteritems from glances.logger import lo...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats manager.""" import re from glances.stats import GlancesStats from glances.globals import iteritems from glances.logger import lo...
21,474
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/stats_server.py
45,46
18,53
_set_stats
GlancesStatsServer
47,50
46,50
class GlancesStatsServer(GlancesStats): """This class stores, updates and gives stats for the server.""" def __init__(self, config=None, args=None): # Init the stats super(GlancesStatsServer, self).__init__(config=config, args=args) # Init the all_stats dict used by the server ...
class GlancesStatsServer(GlancesStats): """This class stores, updates and gives stats for the server.""" def __init__(self, config=None, args=None): # Init the stats super(GlancesStatsServer, self).__init__(config=config, args=args) # Init the all_stats dict used by the server ...
# Build the all_stats with the get_raw() method of the plugins return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enabled()}
"""Set the stats to the input_stats one.""" # Build the all_stats with the get_raw() method of the plugins return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enabled()}
20
330
56
386
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats server manager.""" import collections from glances.stats import GlancesStats from glances.logger import logger class GlancesSt...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The stats server manager.""" import collections from glances.stats import GlancesStats from glances.logger import logger class GlancesSt...
21,475
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/timer.py
19,20
1,72
getTimeSinceLastUpdate
21,33
20,33
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
global last_update_times # assert(IOType in ['net', 'disk', 'process_disk']) current_time = time() last_time = last_update_times.get(IOType) if not last_time: time_since_update = 1 else: time_since_update = current_time - last_time last_update_times[IOType] = current_time ...
"""Return the elapsed time since last update.""" global last_update_times # assert(IOType in ['net', 'disk', 'process_disk']) current_time = time() last_time = last_update_times.get(IOType) if not last_time: time_since_update = 1 else: time_since_update = current_time - last_...
31
393
125
518
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
21,476
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/timer.py
64,65
58,72
start
Counter
65,67
65,67
class Counter(object): """The counter class.""" def __init__(self): self.start() def start(self): FILL_FUNC_BODY def reset(self): self.start() def get(self): return (datetime.now() - self.target).total_seconds()
class Counter(object): """The counter class.""" def __init__(self): self.start() def start(self): FILL_FUNC_BODY def reset(self): self.start() def get(self): return (datetime.now() - self.target).total_seconds()
self.target = datetime.now()
self.target = datetime.now()
3
85
13
98
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
21,477
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/timer.py
51,52
33,58
set
Timer
52,54
52,54
class Timer(object): """The timer class. A simple chronometer.""" def __init__(self, duration): self.duration = duration self.start() def start(self): self.target = time() + self.duration def reset(self, duration=None): if duration is not None: self.set(dur...
class Timer(object): """The timer class. A simple chronometer.""" def __init__(self, duration): self.duration = duration self.start() def start(self): self.target = time() + self.duration def reset(self, duration=None): if duration is not None: self.set(dur...
self.duration = duration
self.duration = duration
3
157
10
167
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """The timer manager.""" from time import time from datetime import datetime # Global list to manage the elapsed time last_update_times = {} ...
21,478
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/web_list.py
32,33
16,115
load
GlancesWebList
34,108
33,108
class GlancesWebList(object): """Manage the Web/Url list for the ports plugin.""" _section = "ports" _default_refresh = 60 _default_timeout = 3 def __init__(self, config=None, args=None): # web_list is a list of dict (JSON compliant) # [ {'url': 'http://blog.nicolargo.com', ...
class GlancesWebList(object): """Manage the Web/Url list for the ports plugin.""" _section = "ports" _default_refresh = 60 _default_timeout = 3 def __init__(self, config=None, args=None): # web_list is a list of dict (JSON compliant) # [ {'url': 'http://blog.nicolargo.com', ...
web_list = [] if config is None: logger.debug("No configuration file available. Cannot load ports list.") elif not config.has_section(self._section): logger.debug("No [%s] section in the configuration file. Cannot load ports list." % self._section) else: ...
"""Load the web list from the configuration file.""" web_list = [] if config is None: logger.debug("No configuration file available. Cannot load ports list.") elif not config.has_section(self._section): logger.debug("No [%s] section in the configuration file. Can...
271
275
942
1,217
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances web/url list (Ports plugin).""" from glances.globals import urlparse from glances.logger import logger class GlancesWe...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Manage the Glances web/url list (Ports plugin).""" from glances.globals import urlparse from glances.logger import logger class GlancesWe...
21,479
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/glances/webserver.py
39,40
18,43
end
GlancesWebServer
41,43
40,43
class GlancesWebServer(object): """This class creates and manages the Glances Web server session.""" def __init__(self, config=None, args=None): # Init stats self.stats = GlancesStats(config, args) if not WINDOWS and args.no_kernel_threads: # Ignore kernel threads in proces...
class GlancesWebServer(object): """This class creates and manages the Glances Web server session.""" def __init__(self, config=None, args=None): # Init stats self.stats = GlancesStats(config, args) if not WINDOWS and args.no_kernel_threads: # Ignore kernel threads in proces...
self.web.end() self.stats.end()
"""End of the Web server.""" self.web.end() self.stats.end()
2
209
18
227
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances Restful/API and Web based interface.""" from glances.globals import WINDOWS from glances.processes import glances_processes from gl...
# -*- coding: utf-8 -*- # # This file is part of Glances. # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances Restful/API and Web based interface.""" from glances.globals import WINDOWS from glances.processes import glances_processes from gl...
21,480
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/setup.py
56,57
1,144
get_install_extras_require
57,85
57,85
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
extras_require = { 'action': ['chevron'], 'browser': ['zeroconf>=0.19.1'], 'cloud': ['requests'], 'containers': ['docker>=6.1.1', 'python-dateutil', 'six', 'podman', 'packaging'], 'export': ['bernhard', 'cassandra-driver', 'elasticsearch', 'graphitesender', ...
extras_require = { 'action': ['chevron'], 'browser': ['zeroconf>=0.19.1'], 'cloud': ['requests'], 'containers': ['docker>=6.1.1', 'python-dateutil', 'six', 'podman', 'packaging'], 'export': ['bernhard', 'cassandra-driver', 'elasticsearch', 'graphitesender', ...
73
1,026
404
1,430
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
21,481
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/setup.py
94,95
85,106
run
tests
95,106
95,106
class tests(Command): user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): FILL_FUNC_BODY
class tests(Command): user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): FILL_FUNC_BODY
import subprocess import sys for t in glob.glob('unitest.py'): ret = subprocess.call([sys.executable, t]) != 0 if ret != 0: raise SystemExit(ret) raise SystemExit(0) # Setup !
import subprocess import sys for t in glob.glob('unitest.py'): ret = subprocess.call([sys.executable, t]) != 0 if ret != 0: raise SystemExit(ret) raise SystemExit(0) # Setup !
25
58
86
144
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
#!/usr/bin/env python import glob import os import re import sys from io import open from setuptools import setup, Command if sys.version_info < (3, 8): print('Glances requires at least Python 3.8 to run.') sys.exit(1) # Global functions ################## with open(os.path.join('glances', '__init__.py'),...
21,482
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances
/home/hieuvd/dung_repo/raw/stars_01/nicolargo_glances/glances/unitest-xmlrpc.py
155,156
35,199
test_010_all_limits
TestGlances
157,164
156,164
class TestGlances(unittest.TestCase): """Test Glances class.""" def setUp(self): """The function is called *every time* before test_*.""" print('\n' + '=' * 78) def test_000_start_server(self): """Start the Glances Web Server.""" global pid print('INFO: [TEST_000] ...
class TestGlances(unittest.TestCase): """Test Glances class.""" def setUp(self): """The function is called *every time* before test_*.""" print('\n' + '=' * 78) def test_000_start_server(self): """Start the Glances Web Server.""" global pid print('INFO: [TEST_000] ...
method = "getAllLimits()" print('INFO: [TEST_010] Method: %s' % method) req = json.loads(client.getAllLimits()) self.assertIsInstance(req, dict) self.assertIsInstance(req['cpu'], dict)
"""All limits.""" method = "getAllLimits()" print('INFO: [TEST_010] Method: %s' % method) req = json.loads(client.getAllLimits()) self.assertIsInstance(req, dict) self.assertIsInstance(req['cpu'], dict)
16
1,581
82
1,663
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unitary tests suite for the XML-RPC API.""" import os import json import shlex import subprocess import tim...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unitary tests suite for the XML-RPC API.""" import os import json import shlex import subprocess import tim...
21,504
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/release.py
10,11
1,38
get_new_setup_py_lines
11,23
11,23
#!/usr/bin/env python from subprocess import call import os import re version = None def get_new_setup_py_lines(): FILL_FUNC_BODYlines = list(get_new_setup_py_lines()) with open('setup.py', 'w') as sf: sf.writelines(lines) call('git pull', shell=True) call('git commit -am "Bump to {}"'.format(version), shell=T...
#!/usr/bin/env python from subprocess import call import os import re version = None def get_new_setup_py_lines(): FILL_FUNC_BODYlines = list(get_new_setup_py_lines()) with open('setup.py', 'w') as sf: sf.writelines(lines) call('git pull', shell=True) call('git commit -am "Bump to {}"'.format(version), shell=T...
global version with open('setup.py', 'r') as sf: current_setup = sf.readlines() for line in current_setup: if line.startswith('VERSION = '): major, minor = re.findall(r"VERSION = '(\d+)\.(\d+)'", line)[0] version = "{}.{}".format(major, int(minor) + 1) yie...
global version with open('setup.py', 'r') as sf: current_setup = sf.readlines() for line in current_setup: if line.startswith('VERSION = '): major, minor = re.findall(r"VERSION = '(\d+)\.(\d+)'", line)[0] version = "{}.{}".format(major, int(minor) + 1) yie...
38
238
142
380
#!/usr/bin/env python from subprocess import call import os import re version = None def get_new_setup_py_lines(): FILL_FUNC_BODYlines = list(get_new_setup_py_lines()) with open('setup.py', 'w') as sf: sf.writelines(lines) call('git pull', shell=True) call('git commit -am "Bump to {}"'.format(version), shell=T...
#!/usr/bin/env python from subprocess import call import os import re version = None def get_new_setup_py_lines(): FILL_FUNC_BODYlines = list(get_new_setup_py_lines()) with open('setup.py', 'w') as sf: sf.writelines(lines) call('git pull', shell=True) call('git commit -am "Bump to {}"'.format(version), shell=T...
21,505
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/argument_parser.py
66,67
7,93
_prepare_arguments
Parser
76,84
67,84
class Parser(object): """Argument parser that can handle arguments with our special placeholder. """ def __init__(self): self._parser = ArgumentParser(prog='thefuck', add_help=False) self._add_arguments() def _add_arguments(self): """Adds arguments to parser.""" se...
class Parser(object): """Argument parser that can handle arguments with our special placeholder. """ def __init__(self): self._parser = ArgumentParser(prog='thefuck', add_help=False) self._add_arguments() def _add_arguments(self): """Adds arguments to parser.""" se...
if ARGUMENT_PLACEHOLDER in argv: index = argv.index(ARGUMENT_PLACEHOLDER) return argv[index + 1:] + ['--'] + argv[:index] elif argv and not argv[0].startswith('-') and argv[0] != '--': return ['--'] + argv else: return argv
"""Prepares arguments by: - removing placeholder and moving arguments after it to beginning, we need this to distinguish arguments from `command` with ours; - adding `--` before `command`, so our parse would ignore arguments of `command`. """ if ARGUMENT_PL...
31
745
112
857
import sys from argparse import ArgumentParser, SUPPRESS from .const import ARGUMENT_PLACEHOLDER from .utils import get_alias class Parser(object): """Argument parser that can handle arguments with our special placeholder. """ def __init__(self): self._parser = ArgumentParser(prog='thefuck',...
import sys from argparse import ArgumentParser, SUPPRESS from .const import ARGUMENT_PLACEHOLDER from .utils import get_alias class Parser(object): """Argument parser that can handle arguments with our special placeholder. """ def __init__(self): self._parser = ArgumentParser(prog='thefuck',...
21,506
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/conf.py
54,55
20,140
_get_user_dir_path
Settings
56,68
55,68
class Settings(dict): def __getattr__(self, item): return self.get(item) def __setattr__(self, key, value): self[key] = value def init(self, args=None): """Fills `settings` with values from `settings.py` and env.""" from .logs import exception self._setup_user_dir(...
class Settings(dict): def __getattr__(self, item): return self.get(item) def __setattr__(self, key, value): self[key] = value def init(self, args=None): """Fills `settings` with values from `settings.py` and env.""" from .logs import exception self._setup_user_dir(...
xdg_config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') user_dir = Path(xdg_config_home, 'thefuck').expanduser() legacy_user_dir = Path('~', '.thefuck').expanduser() # For backward compatibility use legacy '~/.thefuck' if it exists: if legacy_user_dir.is_dir(): ...
"""Returns Path object representing the user config resource""" xdg_config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') user_dir = Path(xdg_config_home, 'thefuck').expanduser() legacy_user_dir = Path('~', '.thefuck').expanduser() # For backward compatibility use legacy ...
40
1,104
169
1,273
import os import sys from warnings import warn from six import text_type from . import const from .system import Path try: import importlib.util def load_source(name, pathname, _file=None): module_spec = importlib.util.spec_from_file_location(name, pathname) module = importlib.util.module_from...
import os import sys from warnings import warn from six import text_type from . import const from .system import Path try: import importlib.util def load_source(name, pathname, _file=None): module_spec = importlib.util.spec_from_file_location(name, pathname) module = importlib.util.module_from...
21,507
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/corrector.py
8,9
1,93
get_loaded_rules
15,22
9,22
import sys from .conf import settings from .types import Rule from .system import Path from . import logs def get_loaded_rules(rules_paths): FILL_FUNC_BODYdef get_rules_import_paths(): """Yields all rules import paths. :rtype: Iterable[Path] """ # Bundled rules: yield Path(__file__).parent.joinp...
import sys from .conf import settings from .types import Rule from .system import Path from . import logs def get_loaded_rules(rules_paths): """Yields all available rules. :type rules_paths: [Path] :rtype: Iterable[Rule] """ FILL_FUNC_BODYdef get_rules_import_paths(): """Yields all rules import ...
for path in rules_paths: if path.name != '__init__.py': rule = Rule.from_path(path) if rule and rule.is_enabled: yield rule
"""Yields all available rules. :type rules_paths: [Path] :rtype: Iterable[Rule] """ for path in rules_paths: if path.name != '__init__.py': rule = Rule.from_path(path) if rule and rule.is_enabled: yield rule
17
705
60
765
import sys from .conf import settings from .types import Rule from .system import Path from . import logs def get_loaded_rules(rules_paths): FILL_FUNC_BODYdef get_rules_import_paths(): """Yields all rules import paths. :rtype: Iterable[Path] """ # Bundled rules: yield Path(__file__).parent.joinp...
import sys from .conf import settings from .types import Rule from .system import Path from . import logs def get_loaded_rules(rules_paths): """Yields all available rules. :type rules_paths: [Path] :rtype: Iterable[Rule] """ FILL_FUNC_BODYdef get_rules_import_paths(): """Yields all rules import ...
21,508
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/entrypoints/alias.py
8,9
1,29
_get_alias
9,26
9,26
import six from ..conf import settings from ..logs import warn from ..shells import shell from ..utils import which def _get_alias(known_args): FILL_FUNC_BODYdef print_alias(known_args): settings.init(known_args) print(_get_alias(known_args))
import six from ..conf import settings from ..logs import warn from ..shells import shell from ..utils import which def _get_alias(known_args): FILL_FUNC_BODYdef print_alias(known_args): settings.init(known_args) print(_get_alias(known_args))
if six.PY2: warn("The Fuck will drop Python 2 support soon, more details " "https://github.com/nvbn/thefuck/issues/685") alias = shell.app_alias(known_args.alias) if known_args.enable_experimental_instant_mode: if six.PY2: warn("Instant mode requires Python 3") ...
if six.PY2: warn("The Fuck will drop Python 2 support soon, more details " "https://github.com/nvbn/thefuck/issues/685") alias = shell.app_alias(known_args.alias) if known_args.enable_experimental_instant_mode: if six.PY2: warn("Instant mode requires Python 3") ...
39
84
171
255
import six from ..conf import settings from ..logs import warn from ..shells import shell from ..utils import which def _get_alias(known_args): FILL_FUNC_BODYdef print_alias(known_args): settings.init(known_args) print(_get_alias(known_args))
import six from ..conf import settings from ..logs import warn from ..shells import shell from ..utils import which def _get_alias(known_args): FILL_FUNC_BODYdef print_alias(known_args): settings.init(known_args) print(_get_alias(known_args))
21,509
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/entrypoints/fix_command.py
13,14
1,49
_get_raw_command
14,29
14,29
from pprint import pformat import os import sys from difflib import SequenceMatcher from .. import logs, types, const from ..conf import settings from ..corrector import get_corrected_commands from ..exceptions import EmptyCommand from ..ui import select_command from ..utils import get_alias, get_all_executables def ...
from pprint import pformat import os import sys from difflib import SequenceMatcher from .. import logs, types, const from ..conf import settings from ..corrector import get_corrected_commands from ..exceptions import EmptyCommand from ..ui import select_command from ..utils import get_alias, get_all_executables def ...
if known_args.force_command: return [known_args.force_command] elif not os.environ.get('TF_HISTORY'): return known_args.command else: history = os.environ['TF_HISTORY'].split('\n')[::-1] alias = get_alias() executables = get_all_executables() for command in hi...
if known_args.force_command: return [known_args.force_command] elif not os.environ.get('TF_HISTORY'): return known_args.command else: history = os.environ['TF_HISTORY'].split('\n')[::-1] alias = get_alias() executables = get_all_executables() for command in hi...
39
307
172
479
from pprint import pformat import os import sys from difflib import SequenceMatcher from .. import logs, types, const from ..conf import settings from ..corrector import get_corrected_commands from ..exceptions import EmptyCommand from ..ui import select_command from ..utils import get_alias, get_all_executables def ...
from pprint import pformat import os import sys from difflib import SequenceMatcher from .. import logs, types, const from ..conf import settings from ..corrector import get_corrected_commands from ..exceptions import EmptyCommand from ..ui import select_command from ..utils import get_alias, get_all_executables def ...
21,510
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/entrypoints/main.py
16,17
1,41
main
17,41
17,41
# Initialize output before importing any module, that can use colorama. from ..system import init_output init_output() import os # noqa: E402 import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 from ..utils import get_installation_version # noqa: E402 from ....
# Initialize output before importing any module, that can use colorama. from ..system import init_output init_output() import os # noqa: E402 import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 from ..utils import get_installation_version # noqa: E402 from ....
parser = Parser() known_args = parser.parse(sys.argv) if known_args.help: parser.print_help() elif known_args.version: logs.version(get_installation_version(), sys.version.split()[0], shell.info()) # It's important to check if an alias is being requested before ...
parser = Parser() known_args = parser.parse(sys.argv) if known_args.help: parser.print_help() elif known_args.version: logs.version(get_installation_version(), sys.version.split()[0], shell.info()) # It's important to check if an alias is being requested before ...
77
184
308
492
# Initialize output before importing any module, that can use colorama. from ..system import init_output init_output() import os # noqa: E402 import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 from ..utils import get_installation_version # noqa: E402 from ....
# Initialize output before importing any module, that can use colorama. from ..system import init_output init_output() import os # noqa: E402 import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 from ..utils import get_installation_version # noqa: E402 from ....
21,511
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/entrypoints/shell_logger.py
33,34
1,80
_spawn
39,64
34,64
import array import fcntl from functools import partial import mmap import os import pty import signal import sys import termios import tty from .. import logs, const def _read(f, fd): data = os.read(fd, 1024) try: f.write(data) except ValueError: position = const.LOG_SIZE_IN_BYTES - const...
import array import fcntl from functools import partial import mmap import os import pty import signal import sys import termios import tty from .. import logs, const def _read(f, fd): data = os.read(fd, 1024) try: f.write(data) except ValueError: position = const.LOG_SIZE_IN_BYTES - const...
pid, master_fd = pty.fork() if pid == pty.CHILD: os.execlp(shell, shell) try: mode = tty.tcgetattr(pty.STDIN_FILENO) tty.setraw(pty.STDIN_FILENO) restore = True except tty.error: # This is the same as termios.error restore = False _set_pty_size(master_fd...
"""Create a spawned process. Modified version of pty.spawn with terminal size support. """ pid, master_fd = pty.fork() if pid == pty.CHILD: os.execlp(shell, shell) try: mode = tty.tcgetattr(pty.STDIN_FILENO) tty.setraw(pty.STDIN_FILENO) restore = True exce...
50
558
270
828
import array import fcntl from functools import partial import mmap import os import pty import signal import sys import termios import tty from .. import logs, const def _read(f, fd): data = os.read(fd, 1024) try: f.write(data) except ValueError: position = const.LOG_SIZE_IN_BYTES - const...
import array import fcntl from functools import partial import mmap import os import pty import signal import sys import termios import tty from .. import logs, const def _read(f, fd): data = os.read(fd, 1024) try: f.write(data) except ValueError: position = const.LOG_SIZE_IN_BYTES - const...
21,512
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/adb_unknown_command.py
48,49
1,55
get_new_command
49,55
49,55
from thefuck.utils import is_app, get_closest, replace_argument _ADB_COMMANDS = ( 'backup', 'bugreport', 'connect', 'devices', 'disable-verity', 'disconnect', 'enable-verity', 'emu', 'forward', 'get-devpath', 'get-serialno', 'get-state', 'install', 'install-mult...
from thefuck.utils import is_app, get_closest, replace_argument _ADB_COMMANDS = ( 'backup', 'bugreport', 'connect', 'devices', 'disable-verity', 'disconnect', 'enable-verity', 'emu', 'forward', 'get-devpath', 'get-serialno', 'get-state', 'install', 'install-mult...
for idx, arg in enumerate(command.script_parts[1:]): # allowed params to ADB are a/d/e/s/H/P/L where s, H, P and L take additional args # for example 'adb -s 111 logcat' or 'adb -e logcat' if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-H', '-P', '-L'): adb_cmd...
for idx, arg in enumerate(command.script_parts[1:]): # allowed params to ADB are a/d/e/s/H/P/L where s, H, P and L take additional args # for example 'adb -s 111 logcat' or 'adb -e logcat' if not arg[0] == '-' and not command.script_parts[idx] in ('-s', '-H', '-P', '-L'): adb_cmd...
53
309
160
469
from thefuck.utils import is_app, get_closest, replace_argument _ADB_COMMANDS = ( 'backup', 'bugreport', 'connect', 'devices', 'disable-verity', 'disconnect', 'enable-verity', 'emu', 'forward', 'get-devpath', 'get-serialno', 'get-state', 'install', 'install-mult...
from thefuck.utils import is_app, get_closest, replace_argument _ADB_COMMANDS = ( 'backup', 'bugreport', 'connect', 'devices', 'disable-verity', 'disconnect', 'enable-verity', 'emu', 'forward', 'get-devpath', 'get-serialno', 'get-state', 'install', 'install-mult...
21,513
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/ag_literal.py
4,6
1,11
match
6,9
6,9
from thefuck.utils import for_app @for_app('ag') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('ag', 'ag -Q', 1)
from thefuck.utils import for_app @for_app('ag') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('ag', 'ag -Q', 1)
return command.output.endswith('run ag with -Q\n')
return command.output.endswith('run ag with -Q\n')
5
66
24
90
from thefuck.utils import for_app @for_app('ag') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('ag', 'ag -Q', 1)
from thefuck.utils import for_app @for_app('ag') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('ag', 'ag -Q', 1)
21,514
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/apt_get.py
46,47
1,51
get_new_command
47,51
47,51
from types import ModuleType from thefuck.specific.apt import apt_available from thefuck.utils import memoize, which from thefuck.shells import shell try: from CommandNotFound import CommandNotFound enabled_by_default = apt_available if isinstance(CommandNotFound, ModuleType): # For ubuntu 18.04+...
from types import ModuleType from thefuck.specific.apt import apt_available from thefuck.utils import memoize, which from thefuck.shells import shell try: from CommandNotFound import CommandNotFound enabled_by_default = apt_available if isinstance(CommandNotFound, ModuleType): # For ubuntu 18.04+...
executable = _get_executable(command) name = get_package(executable) formatme = shell.and_('sudo apt-get install {}', '{}') return formatme.format(name, command.script)
executable = _get_executable(command) name = get_package(executable) formatme = shell.and_('sudo apt-get install {}', '{}') return formatme.format(name, command.script)
16
349
61
410
from types import ModuleType from thefuck.specific.apt import apt_available from thefuck.utils import memoize, which from thefuck.shells import shell try: from CommandNotFound import CommandNotFound enabled_by_default = apt_available if isinstance(CommandNotFound, ModuleType): # For ubuntu 18.04+...
from types import ModuleType from thefuck.specific.apt import apt_available from thefuck.utils import memoize, which from thefuck.shells import shell try: from CommandNotFound import CommandNotFound enabled_by_default = apt_available if isinstance(CommandNotFound, ModuleType): # For ubuntu 18.04+...
21,515
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/apt_get_search.py
13,14
1,15
get_new_command
14,15
14,15
import re from thefuck.specific.apt import apt_available from thefuck.utils import for_app enabled_by_default = apt_available @for_app('apt-get') def match(command): return command.script.startswith('apt-get search') def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.specific.apt import apt_available from thefuck.utils import for_app enabled_by_default = apt_available @for_app('apt-get') def match(command): return command.script.startswith('apt-get search') def get_new_command(command): FILL_FUNC_BODY
return re.sub(r'^apt-get', 'apt-cache', command.script)
return re.sub(r'^apt-get', 'apt-cache', command.script)
4
94
24
118
import re from thefuck.specific.apt import apt_available from thefuck.utils import for_app enabled_by_default = apt_available @for_app('apt-get') def match(command): return command.script.startswith('apt-get search') def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.specific.apt import apt_available from thefuck.utils import for_app enabled_by_default = apt_available @for_app('apt-get') def match(command): return command.script.startswith('apt-get search') def get_new_command(command): FILL_FUNC_BODY
21,516
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/apt_invalid_operation.py
15,17
1,64
_parse_apt_operations
17,27
17,27
import subprocess from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, eager, replace_command enabled_by_default = apt_available @sudo_support @for_app('apt', 'apt-get', 'apt-cache') def match(command): return 'E: Invalid operation' in c...
import subprocess from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, eager, replace_command enabled_by_default = apt_available @sudo_support @for_app('apt', 'apt-get', 'apt-cache') def match(command): return 'E: Invalid operation' in c...
is_commands_list = False for line in help_text_lines: line = line.decode().strip() if is_commands_list and line: yield line.split()[0] elif line.startswith('Basic commands:') \ or line.startswith('Most used commands:'): is_commands_list = True
is_commands_list = False for line in help_text_lines: line = line.decode().strip() if is_commands_list and line: yield line.split()[0] elif line.startswith('Basic commands:') \ or line.startswith('Most used commands:'): is_commands_list = True
27
465
103
568
import subprocess from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, eager, replace_command enabled_by_default = apt_available @sudo_support @for_app('apt', 'apt-get', 'apt-cache') def match(command): return 'E: Invalid operation' in c...
import subprocess from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, eager, replace_command enabled_by_default = apt_available @sudo_support @for_app('apt', 'apt-get', 'apt-cache') def match(command): return 'E: Invalid operation' in c...
21,517
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/apt_list_upgradable.py
14,16
1,17
get_new_command
16,17
16,17
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): return 'apt list --upgradable' in command.output @sudo_support def get_new_command(command): FILL_...
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): return 'apt list --upgradable' in command.output @sudo_support def get_new_command(command): FILL_...
return 'apt list --upgradable'
return 'apt list --upgradable'
4
111
12
123
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): return 'apt list --upgradable' in command.output @sudo_support def get_new_command(command): FILL_...
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): return 'apt list --upgradable' in command.output @sudo_support def get_new_command(command): FILL_...
21,518
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/apt_upgrade.py
8,11
1,17
match
11,14
11,14
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return 'apt upgrade'
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return 'apt upgrade'
return command.script == "apt list --upgradable" and len(command.output.strip().split('\n')) > 1
return command.script == "apt list --upgradable" and len(command.output.strip().split('\n')) > 1
10
101
36
137
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return 'apt upgrade'
from thefuck.specific.apt import apt_available from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app enabled_by_default = apt_available @sudo_support @for_app('apt') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return 'apt upgrade'
21,519
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/aws_cli.py
14,15
1,18
get_new_command
15,18
15,18
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)" OPTIONS = "^\\s*\\*\\s(.*)" @for_app('aws') def match(command): return "usage:" in command.output and "maybe you meant:" in command.output def get_new_command(command): FILL_FUNC_...
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)" OPTIONS = "^\\s*\\*\\s(.*)" @for_app('aws') def match(command): return "usage:" in command.output and "maybe you meant:" in command.output def get_new_command(command): FILL_FUNC_...
mistake = re.search(INVALID_CHOICE, command.output).group(0) options = re.findall(OPTIONS, command.output, flags=re.MULTILINE) return [replace_argument(command.script, mistake, o) for o in options]
mistake = re.search(INVALID_CHOICE, command.output).group(0) options = re.findall(OPTIONS, command.output, flags=re.MULTILINE) return [replace_argument(command.script, mistake, o) for o in options]
17
122
72
194
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)" OPTIONS = "^\\s*\\*\\s(.*)" @for_app('aws') def match(command): return "usage:" in command.output and "maybe you meant:" in command.output def get_new_command(command): FILL_FUNC_...
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)" OPTIONS = "^\\s*\\*\\s(.*)" @for_app('aws') def match(command): return "usage:" in command.output and "maybe you meant:" in command.output def get_new_command(command): FILL_FUNC_...
21,520
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/az_cli.py
9,11
1,18
match
11,14
11,14
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?=az)(?:.*): '(.*)' is not in the '.*' command group." OPTIONS = "^The most similar choice to '.*' is:\n\\s*(.*)$" @for_app('az') def match(command): FILL_FUNC_BODYdef get_new_command(command): mistake = re.search(INVALID_CHOICE, c...
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?=az)(?:.*): '(.*)' is not in the '.*' command group." OPTIONS = "^The most similar choice to '.*' is:\n\\s*(.*)$" @for_app('az') def match(command): FILL_FUNC_BODYdef get_new_command(command): mistake = re.search(INVALID_CHOICE, c...
return "is not in the" in command.output and "command group" in command.output
return "is not in the" in command.output and "command group" in command.output
12
180
27
207
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?=az)(?:.*): '(.*)' is not in the '.*' command group." OPTIONS = "^The most similar choice to '.*' is:\n\\s*(.*)$" @for_app('az') def match(command): FILL_FUNC_BODYdef get_new_command(command): mistake = re.search(INVALID_CHOICE, c...
import re from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?=az)(?:.*): '(.*)' is not in the '.*' command group." OPTIONS = "^The most similar choice to '.*' is:\n\\s*(.*)$" @for_app('az') def match(command): FILL_FUNC_BODYdef get_new_command(command): mistake = re.search(INVALID_CHOICE, c...
21,521
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_install.py
8,9
1,25
_get_suggestions
9,13
9,13
import re from thefuck.utils import for_app from thefuck.specific.brew import brew_available enabled_by_default = brew_available def _get_suggestions(str): FILL_FUNC_BODY@for_app('brew', at_least=2) def match(command): is_proper_command = ('install' in command.script and 'No available fo...
import re from thefuck.utils import for_app from thefuck.specific.brew import brew_available enabled_by_default = brew_available def _get_suggestions(str): FILL_FUNC_BODY@for_app('brew', at_least=2) def match(command): is_proper_command = ('install' in command.script and 'No available fo...
suggestions = str.replace(" or ", ", ").split(", ") return suggestions
suggestions = str.replace(" or ", ", ").split(", ") return suggestions
10
211
27
238
import re from thefuck.utils import for_app from thefuck.specific.brew import brew_available enabled_by_default = brew_available def _get_suggestions(str): FILL_FUNC_BODY@for_app('brew', at_least=2) def match(command): is_proper_command = ('install' in command.script and 'No available fo...
import re from thefuck.utils import for_app from thefuck.specific.brew import brew_available enabled_by_default = brew_available def _get_suggestions(str): FILL_FUNC_BODY@for_app('brew', at_least=2) def match(command): is_proper_command = ('install' in command.script and 'No available fo...
21,522
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_link.py
10,11
1,16
get_new_command
11,16
11,16
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['ln', 'link'] and "brew link --overwrite --dry-run" in command.output) def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['ln', 'link'] and "brew link --overwrite --dry-run" in command.output) def get_new_command(command): FILL_FUNC_BODY
command_parts = command.script_parts[:] command_parts[1] = 'link' command_parts.insert(2, '--overwrite') command_parts.insert(3, '--dry-run') return ' '.join(command_parts)
command_parts = command.script_parts[:] command_parts[1] = 'link' command_parts.insert(2, '--overwrite') command_parts.insert(3, '--dry-run') return ' '.join(command_parts)
13
94
73
167
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['ln', 'link'] and "brew link --overwrite --dry-run" in command.output) def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['ln', 'link'] and "brew link --overwrite --dry-run" in command.output) def get_new_command(command): FILL_FUNC_BODY
21,523
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_reinstall.py
18,19
1,20
get_new_command
19,20
19,20
import re from thefuck.utils import for_app warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and ' r'up-to-date') message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall ' r'[^`]+`') @for_app('brew', at_least=2) def ma...
import re from thefuck.utils import for_app warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and ' r'up-to-date') message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall ' r'[^`]+`') @for_app('brew', at_least=2) def ma...
return command.script.replace('install', 'reinstall')
return command.script.replace('install', 'reinstall')
3
169
16
185
import re from thefuck.utils import for_app warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and ' r'up-to-date') message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall ' r'[^`]+`') @for_app('brew', at_least=2) def ma...
import re from thefuck.utils import for_app warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and ' r'up-to-date') message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall ' r'[^`]+`') @for_app('brew', at_least=2) def ma...
21,524
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_uninstall.py
10,11
1,15
get_new_command
11,15
11,15
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['uninstall', 'rm', 'remove'] and "brew uninstall --force" in command.output) def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['uninstall', 'rm', 'remove'] and "brew uninstall --force" in command.output) def get_new_command(command): FILL_FUNC_BODY
command_parts = command.script_parts[:] command_parts[1] = 'uninstall' command_parts.insert(2, '--force') return ' '.join(command_parts)
command_parts = command.script_parts[:] command_parts[1] = 'uninstall' command_parts.insert(2, '--force') return ' '.join(command_parts)
11
92
55
147
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['uninstall', 'rm', 'remove'] and "brew uninstall --force" in command.output) def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): return (command.script_parts[1] in ['uninstall', 'rm', 'remove'] and "brew uninstall --force" in command.output) def get_new_command(command): FILL_FUNC_BODY
21,525
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_unknown_command.py
13,14
1,83
_get_brew_commands
15,21
14,21
import os import re from thefuck.utils import get_closest, replace_command from thefuck.specific.brew import get_brew_path_prefix, brew_available BREW_CMD_PATH = '/Homebrew/Library/Homebrew/cmd' TAP_PATH = '/Homebrew/Library/Taps' TAP_CMD_PATH = '/%s/%s/cmd' enabled_by_default = brew_available def _get_brew_command...
import os import re from thefuck.utils import get_closest, replace_command from thefuck.specific.brew import get_brew_path_prefix, brew_available BREW_CMD_PATH = '/Homebrew/Library/Homebrew/cmd' TAP_PATH = '/Homebrew/Library/Taps' TAP_CMD_PATH = '/%s/%s/cmd' enabled_by_default = brew_available def _get_brew_command...
brew_cmd_path = brew_path_prefix + BREW_CMD_PATH return [name[:-3] for name in os.listdir(brew_cmd_path) if name.endswith(('.rb', '.sh'))]
"""To get brew default commands on local environment""" brew_cmd_path = brew_path_prefix + BREW_CMD_PATH return [name[:-3] for name in os.listdir(brew_cmd_path) if name.endswith(('.rb', '.sh'))]
14
903
70
973
import os import re from thefuck.utils import get_closest, replace_command from thefuck.specific.brew import get_brew_path_prefix, brew_available BREW_CMD_PATH = '/Homebrew/Library/Homebrew/cmd' TAP_PATH = '/Homebrew/Library/Taps' TAP_CMD_PATH = '/%s/%s/cmd' enabled_by_default = brew_available def _get_brew_command...
import os import re from thefuck.utils import get_closest, replace_command from thefuck.specific.brew import get_brew_path_prefix, brew_available BREW_CMD_PATH = '/Homebrew/Library/Homebrew/cmd' TAP_PATH = '/Homebrew/Library/Taps' TAP_CMD_PATH = '/%s/%s/cmd' enabled_by_default = brew_available def _get_brew_command...
21,526
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/brew_update_formula.py
4,6
1,13
match
6,11
6,11
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('update', 'upgrade')
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('update', 'upgrade')
return ('update' in command.script and "Error: This command updates brew itself" in command.output and "Use `brew upgrade" in command.output)
return ('update' in command.script and "Error: This command updates brew itself" in command.output and "Use `brew upgrade" in command.output)
19
67
47
114
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('update', 'upgrade')
from thefuck.utils import for_app @for_app('brew', at_least=2) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('update', 'upgrade')
21,527
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cargo.py
5,6
1,7
get_new_command
6,7
6,7
def match(command): return command.script == 'cargo' def get_new_command(command): FILL_FUNC_BODY
def match(command): return command.script == 'cargo' def get_new_command(command): FILL_FUNC_BODY
return 'cargo build'
return 'cargo build'
3
39
9
48
def match(command): return command.script == 'cargo' def get_new_command(command): FILL_FUNC_BODY
def match(command): return command.script == 'cargo' def get_new_command(command): FILL_FUNC_BODY
21,528
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cargo_no_command.py
5,7
1,16
match
7,11
7,11
import re from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): broken = command.script_parts[1] fix = re.findall(r'Did you mean `([^`]*)`', command.output)[0] return replace_argument(command.script, broken, fix)
import re from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): broken = command.script_parts[1] fix = re.findall(r'Did you mean `([^`]*)`', command.output)[0] return replace_argument(command.script, broken, fix)
return ('no such subcommand' in command.output.lower() and 'Did you mean' in command.output)
return ('no such subcommand' in command.output.lower() and 'Did you mean' in command.output)
12
117
35
152
import re from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): broken = command.script_parts[1] fix = re.findall(r'Did you mean `([^`]*)`', command.output)[0] return replace_argument(command.script, broken, fix)
import re from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): broken = command.script_parts[1] fix = re.findall(r'Did you mean `([^`]*)`', command.output)[0] return replace_argument(command.script, broken, fix)
21,529
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cat_dir.py
5,7
1,15
match
7,13
7,13
import os from thefuck.utils import for_app @for_app('cat', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('cat', 'ls', 1)
import os from thefuck.utils import for_app @for_app('cat', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('cat', 'ls', 1)
return ( command.output.startswith('cat: ') and os.path.isdir(command.script_parts[1]) )
return ( command.output.startswith('cat: ') and os.path.isdir(command.script_parts[1]) )
7
73
47
120
import os from thefuck.utils import for_app @for_app('cat', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('cat', 'ls', 1)
import os from thefuck.utils import for_app @for_app('cat', at_least=1) def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script.replace('cat', 'ls', 1)
21,530
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cd_cs.py
12,13
1,22
match
13,17
13,17
# -*- encoding: utf-8 -*- # Redirects cs to cd when there is a typo # Due to the proximity of the keys - d and s - this seems like a common typo # ~ > cs /etc/ # cs: command not found # ~ > fuck # cd /etc/ [enter/↑/↓/ctrl+c] # /etc > def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd' + '...
# -*- encoding: utf-8 -*- # Redirects cs to cd when there is a typo # Due to the proximity of the keys - d and s - this seems like a common typo # ~ > cs /etc/ # cs: command not found # ~ > fuck # cd /etc/ [enter/↑/↓/ctrl+c] # /etc > def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd' + '...
if command.script_parts[0] == 'cs': return True
if command.script_parts[0] == 'cs': return True
6
150
25
175
# -*- encoding: utf-8 -*- # Redirects cs to cd when there is a typo # Due to the proximity of the keys - d and s - this seems like a common typo # ~ > cs /etc/ # cs: command not found # ~ > fuck # cd /etc/ [enter/↑/↓/ctrl+c] # /etc > def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd' + '...
# -*- encoding: utf-8 -*- # Redirects cs to cd when there is a typo # Due to the proximity of the keys - d and s - this seems like a common typo # ~ > cs /etc/ # cs: command not found # ~ > fuck # cd /etc/ [enter/↑/↓/ctrl+c] # /etc > def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd' + '...
21,531
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cd_mkdir.py
18,20
1,22
get_new_command
20,22
20,22
import re from thefuck.utils import for_app from thefuck.specific.sudo import sudo_support from thefuck.shells import shell @sudo_support @for_app('cd') def match(command): return ( command.script.startswith('cd ') and any(( 'no such file or directory' in command.output.lower(), 'c...
import re from thefuck.utils import for_app from thefuck.specific.sudo import sudo_support from thefuck.shells import shell @sudo_support @for_app('cd') def match(command): return ( command.script.startswith('cd ') and any(( 'no such file or directory' in command.output.lower(), 'c...
repl = shell.and_('mkdir -p \\1', 'cd \\1') return re.sub(r'^cd (.*)', repl, command.script)
repl = shell.and_('mkdir -p \\1', 'cd \\1') return re.sub(r'^cd (.*)', repl, command.script)
12
157
43
200
import re from thefuck.utils import for_app from thefuck.specific.sudo import sudo_support from thefuck.shells import shell @sudo_support @for_app('cd') def match(command): return ( command.script.startswith('cd ') and any(( 'no such file or directory' in command.output.lower(), 'c...
import re from thefuck.utils import for_app from thefuck.specific.sudo import sudo_support from thefuck.shells import shell @sudo_support @for_app('cd') def match(command): return ( command.script.startswith('cd ') and any(( 'no such file or directory' in command.output.lower(), 'c...
21,532
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cd_parent.py
11,12
1,17
match
12,15
12,15
# Adds the missing space between the cd command and the target directory # when trying to cd to the parent directory. # # Does not really save chars, but is fun :D # # Example: # > cd.. # cd..: command not found def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd ..'
# Adds the missing space between the cd command and the target directory # when trying to cd to the parent directory. # # Does not really save chars, but is fun :D # # Example: # > cd.. # cd..: command not found def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd ..'
return command.script == 'cd..'
return command.script == 'cd..'
4
96
16
112
# Adds the missing space between the cd command and the target directory # when trying to cd to the parent directory. # # Does not really save chars, but is fun :D # # Example: # > cd.. # cd..: command not found def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd ..'
# Adds the missing space between the cd command and the target directory # when trying to cd to the parent directory. # # Does not really save chars, but is fun :D # # Example: # > cd.. # cd..: command not found def match(command): FILL_FUNC_BODYdef get_new_command(command): return 'cd ..'
21,533
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/chmod_x.py
5,6
1,16
match
6,12
6,12
import os from thefuck.shells import shell def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_( 'chmod +x {}'.format(command.script_parts[0][2:]), command.script)
import os from thefuck.shells import shell def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_( 'chmod +x {}'.format(command.script_parts[0][2:]), command.script)
return (command.script.startswith('./') and 'permission denied' in command.output.lower() and os.path.exists(command.script_parts[0]) and not os.access(command.script_parts[0], os.X_OK))
return (command.script.startswith('./') and 'permission denied' in command.output.lower() and os.path.exists(command.script_parts[0]) and not os.access(command.script_parts[0], os.X_OK))
13
76
75
151
import os from thefuck.shells import shell def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_( 'chmod +x {}'.format(command.script_parts[0][2:]), command.script)
import os from thefuck.shells import shell def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_( 'chmod +x {}'.format(command.script_parts[0][2:]), command.script)
21,534
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/choco_install.py
10,11
1,26
get_new_command
11,25
11,25
from thefuck.utils import for_app, which @for_app("choco", "cinst") def match(command): return ((command.script.startswith('choco install') or 'cinst' in command.script_parts) and 'Installing the following packages' in command.output) def get_new_command(command): FILL_FUNC_BODYenabled_by_default = ...
from thefuck.utils import for_app, which @for_app("choco", "cinst") def match(command): return ((command.script.startswith('choco install') or 'cinst' in command.script_parts) and 'Installing the following packages' in command.output) def get_new_command(command): FILL_FUNC_BODYenabled_by_default = ...
# Find the argument that is the package name for script_part in command.script_parts: if ( script_part not in ["choco", "cinst", "install"] # Need exact match (bc chocolatey is a package) and not script_part.startswith('-') # Leading hyphens are parameters...
# Find the argument that is the package name for script_part in command.script_parts: if ( script_part not in ["choco", "cinst", "install"] # Need exact match (bc chocolatey is a package) and not script_part.startswith('-') # Leading hyphens are parameters...
66
121
159
280
from thefuck.utils import for_app, which @for_app("choco", "cinst") def match(command): return ((command.script.startswith('choco install') or 'cinst' in command.script_parts) and 'Installing the following packages' in command.output) def get_new_command(command): FILL_FUNC_BODYenabled_by_default = ...
from thefuck.utils import for_app, which @for_app("choco", "cinst") def match(command): return ((command.script.startswith('choco install') or 'cinst' in command.script_parts) and 'Installing the following packages' in command.output) def get_new_command(command): FILL_FUNC_BODYenabled_by_default = ...
21,535
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/composer_not_command.py
13,14
1,23
get_new_command
14,23
14,23
import re from thefuck.utils import replace_argument, for_app @for_app('composer') def match(command): return (('did you mean this?' in command.output.lower() or 'did you mean one of these?' in command.output.lower())) or ( "install" in command.script_parts and "composer require" in command.o...
import re from thefuck.utils import replace_argument, for_app @for_app('composer') def match(command): return (('did you mean this?' in command.output.lower() or 'did you mean one of these?' in command.output.lower())) or ( "install" in command.script_parts and "composer require" in command.o...
if "install" in command.script_parts and "composer require" in command.output.lower(): broken_cmd, new_cmd = "install", "require" else: broken_cmd = re.findall(r"Command \"([^']*)\" is not defined", command.output)[0] new_cmd = re.findall(r'Did you mean this\?[^\n]*\n\s*([^\n]*)', comman...
if "install" in command.script_parts and "composer require" in command.output.lower(): broken_cmd, new_cmd = "install", "require" else: broken_cmd = re.findall(r"Command \"([^']*)\" is not defined", command.output)[0] new_cmd = re.findall(r'Did you mean this\?[^\n]*\n\s*([^\n]*)', comman...
49
123
209
332
import re from thefuck.utils import replace_argument, for_app @for_app('composer') def match(command): return (('did you mean this?' in command.output.lower() or 'did you mean one of these?' in command.output.lower())) or ( "install" in command.script_parts and "composer require" in command.o...
import re from thefuck.utils import replace_argument, for_app @for_app('composer') def match(command): return (('did you mean this?' in command.output.lower() or 'did you mean one of these?' in command.output.lower())) or ( "install" in command.script_parts and "composer require" in command.o...
21,536
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/conda_mistype.py
13,14
1,18
get_new_command
14,18
14,18
import re from thefuck.utils import replace_command, for_app @for_app("conda") def match(command): """ Match a mistyped command """ return "Did you mean 'conda" in command.output def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.utils import replace_command, for_app @for_app("conda") def match(command): """ Match a mistyped command """ return "Did you mean 'conda" in command.output def get_new_command(command): FILL_FUNC_BODY
match = re.findall(r"'conda ([^']*)'", command.output) broken_cmd = match[0] correct_cmd = match[1] return replace_command(command, broken_cmd, [correct_cmd])
match = re.findall(r"'conda ([^']*)'", command.output) broken_cmd = match[0] correct_cmd = match[1] return replace_command(command, broken_cmd, [correct_cmd])
15
86
65
151
import re from thefuck.utils import replace_command, for_app @for_app("conda") def match(command): """ Match a mistyped command """ return "Did you mean 'conda" in command.output def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.utils import replace_command, for_app @for_app("conda") def match(command): """ Match a mistyped command """ return "Did you mean 'conda" in command.output def get_new_command(command): FILL_FUNC_BODY
21,537
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cp_create_destination.py
5,7
1,16
match
7,14
7,14
from thefuck.shells import shell from thefuck.utils import for_app @for_app("cp", "mv") def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_(u"mkdir -p {}".format(command.script_parts[-1]), command.script)
from thefuck.shells import shell from thefuck.utils import for_app @for_app("cp", "mv") def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_(u"mkdir -p {}".format(command.script_parts[-1]), command.script)
return ( "No such file or directory" in command.output or command.output.startswith("cp: directory") and command.output.rstrip().endswith("does not exist") )
return ( "No such file or directory" in command.output or command.output.startswith("cp: directory") and command.output.rstrip().endswith("does not exist") )
17
90
62
152
from thefuck.shells import shell from thefuck.utils import for_app @for_app("cp", "mv") def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_(u"mkdir -p {}".format(command.script_parts[-1]), command.script)
from thefuck.shells import shell from thefuck.utils import for_app @for_app("cp", "mv") def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_(u"mkdir -p {}".format(command.script_parts[-1]), command.script)
21,538
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cp_omitting_directory.py
6,9
1,16
match
9,13
9,13
import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app @sudo_support @for_app('cp') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(r'^cp', 'cp -a', command.script)
import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app @sudo_support @for_app('cp') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(r'^cp', 'cp -a', command.script)
output = command.output.lower() return 'omitting directory' in output or 'is a directory' in output
output = command.output.lower() return 'omitting directory' in output or 'is a directory' in output
14
94
34
128
import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app @sudo_support @for_app('cp') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(r'^cp', 'cp -a', command.script)
import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app @sudo_support @for_app('cp') def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(r'^cp', 'cp -a', command.script)
21,539
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/cpp11.py
4,6
1,13
match
6,11
6,11
from thefuck.utils import for_app @for_app('g++', 'clang++') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script + ' -std=c++11'
from thefuck.utils import for_app @for_app('g++', 'clang++') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script + ' -std=c++11'
return ('This file requires compiler and library support for the ' 'ISO C++ 2011 standard.' in command.output or '-Wc++11-extensions' in command.output)
return ('This file requires compiler and library support for the ' 'ISO C++ 2011 standard.' in command.output or '-Wc++11-extensions' in command.output)
21
69
55
124
from thefuck.utils import for_app @for_app('g++', 'clang++') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script + ' -std=c++11'
from thefuck.utils import for_app @for_app('g++', 'clang++') def match(command): FILL_FUNC_BODYdef get_new_command(command): return command.script + ' -std=c++11'
21,540
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/dirty_untar.py
41,42
1,54
side_effect
42,54
42,54
import tarfile import os from thefuck.utils import for_app from thefuck.shells import shell tar_extensions = ('.tar', '.tar.Z', '.tar.bz2', '.tar.gz', '.tar.lz', '.tar.lzma', '.tar.xz', '.taz', '.tb2', '.tbz', '.tbz2', '.tgz', '.tlz', '.txz', '.tz') def _is_tar_extract(cmd): ...
import tarfile import os from thefuck.utils import for_app from thefuck.shells import shell tar_extensions = ('.tar', '.tar.Z', '.tar.bz2', '.tar.gz', '.tar.lz', '.tar.lzma', '.tar.xz', '.taz', '.tb2', '.tbz', '.tbz2', '.tgz', '.tlz', '.txz', '.tz') def _is_tar_extract(cmd): ...
with tarfile.TarFile(_tar_file(old_cmd.script_parts)[0]) as archive: for file in archive.getnames(): if not os.path.abspath(file).startswith(os.getcwd()): # it's unsafe to overwrite files outside of the current directory continue try: ...
with tarfile.TarFile(_tar_file(old_cmd.script_parts)[0]) as archive: for file in archive.getnames(): if not os.path.abspath(file).startswith(os.getcwd()): # it's unsafe to overwrite files outside of the current directory continue try: ...
45
385
138
523
import tarfile import os from thefuck.utils import for_app from thefuck.shells import shell tar_extensions = ('.tar', '.tar.Z', '.tar.bz2', '.tar.gz', '.tar.lz', '.tar.lzma', '.tar.xz', '.taz', '.tb2', '.tbz', '.tbz2', '.tgz', '.tlz', '.txz', '.tz') def _is_tar_extract(cmd): ...
import tarfile import os from thefuck.utils import for_app from thefuck.shells import shell tar_extensions = ('.tar', '.tar.Z', '.tar.bz2', '.tar.gz', '.tar.lz', '.tar.lzma', '.tar.xz', '.taz', '.tb2', '.tbz', '.tbz2', '.tgz', '.tlz', '.txz', '.tz') def _is_tar_extract(cmd): ...
21,541
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/dirty_unzip.py
7,8
1,61
_is_bad_zip
8,15
8,15
import os import zipfile from thefuck.utils import for_app from thefuck.shells import shell def _is_bad_zip(file): FILL_FUNC_BODYdef _zip_file(command): # unzip works that way: # unzip [-flags] file[.zip] [file(s) ...] [-x file(s) ...] # ^ ^ files to unzip from the archive # ...
import os import zipfile from thefuck.utils import for_app from thefuck.shells import shell def _is_bad_zip(file): FILL_FUNC_BODYdef _zip_file(command): # unzip works that way: # unzip [-flags] file[.zip] [file(s) ...] [-x file(s) ...] # ^ ^ files to unzip from the archive # ...
try: with zipfile.ZipFile(file, 'r') as archive: return len(archive.namelist()) > 1 except Exception: return False
try: with zipfile.ZipFile(file, 'r') as archive: return len(archive.namelist()) > 1 except Exception: return False
14
444
53
497
import os import zipfile from thefuck.utils import for_app from thefuck.shells import shell def _is_bad_zip(file): FILL_FUNC_BODYdef _zip_file(command): # unzip works that way: # unzip [-flags] file[.zip] [file(s) ...] [-x file(s) ...] # ^ ^ files to unzip from the archive # ...
import os import zipfile from thefuck.utils import for_app from thefuck.shells import shell def _is_bad_zip(file): FILL_FUNC_BODYdef _zip_file(command): # unzip works that way: # unzip [-flags] file[.zip] [file(s) ...] [-x file(s) ...] # ^ ^ files to unzip from the archive # ...
21,542
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/django_south_ghost.py
1,2
1,9
match
2,7
2,7
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --delete-ghost-migrations'.format(command.script)
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --delete-ghost-migrations'.format(command.script)
return 'manage.py' in command.script and \ 'migrate' in command.script \ and 'or pass --delete-ghost-migrations' in command.output
return 'manage.py' in command.script and \ 'migrate' in command.script \ and 'or pass --delete-ghost-migrations' in command.output
16
48
54
102
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --delete-ghost-migrations'.format(command.script)
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --delete-ghost-migrations'.format(command.script)
21,543
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/django_south_merge.py
1,2
1,9
match
2,7
2,7
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --merge'.format(command.script)
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --merge'.format(command.script)
return 'manage.py' in command.script and \ 'migrate' in command.script \ and '--merge: will just attempt the migration' in command.output
return 'manage.py' in command.script and \ 'migrate' in command.script \ and '--merge: will just attempt the migration' in command.output
19
41
51
92
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --merge'.format(command.script)
def match(command): FILL_FUNC_BODYdef get_new_command(command): return u'{} --merge'.format(command.script)
21,544
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/dnf_no_such_command.py
17,18
1,38
_parse_operations
18,22
18,22
import subprocess import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, replace_command from thefuck.specific.dnf import dnf_available regex = re.compile(r'No such command: (.*)\.') @sudo_support @for_app('dnf') def match(command): return 'no such command' in command.output...
import subprocess import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, replace_command from thefuck.specific.dnf import dnf_available regex = re.compile(r'No such command: (.*)\.') @sudo_support @for_app('dnf') def match(command): return 'no such command' in command.output...
operation_regex = re.compile(r'^([a-z-]+) +', re.MULTILINE) return operation_regex.findall(help_text_lines)
operation_regex = re.compile(r'^([a-z-]+) +', re.MULTILINE) return operation_regex.findall(help_text_lines)
7
282
52
334
import subprocess import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, replace_command from thefuck.specific.dnf import dnf_available regex = re.compile(r'No such command: (.*)\.') @sudo_support @for_app('dnf') def match(command): return 'no such command' in command.output...
import subprocess import re from thefuck.specific.sudo import sudo_support from thefuck.utils import for_app, replace_command from thefuck.specific.dnf import dnf_available regex = re.compile(r'No such command: (.*)\.') @sudo_support @for_app('dnf') def match(command): return 'no such command' in command.output...
21,545
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/docker_image_being_used_by_container.py
14,15
1,21
get_new_command
19,21
15,21
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): ''' Matches a command's output with docker's output warning you that you need to remove a container before removing an image. ''' return 'image is being used by running container' in command.o...
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): ''' Matches a command's output with docker's output warning you that you need to remove a container before removing an image. ''' return 'image is being used by running container' in command.o...
container_id = command.output.strip().split(' ') return shell.and_('docker container rm -f {}', '{}').format(container_id[-1], command.script)
''' Prepends docker container rm -f {container ID} to the previous docker image rm {image ID} command ''' container_id = command.output.strip().split(' ') return shell.and_('docker container rm -f {}', '{}').format(container_id[-1], command.script)
12
144
48
192
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): ''' Matches a command's output with docker's output warning you that you need to remove a container before removing an image. ''' return 'image is being used by running container' in command.o...
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): ''' Matches a command's output with docker's output warning you that you need to remove a container before removing an image. ''' return 'image is being used by running container' in command.o...
21,546
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/docker_login.py
5,7
1,14
match
7,12
7,12
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_('docker login', command.script)
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_('docker login', command.script)
return ('docker' in command.script and "access denied" in command.output and "may require 'docker login'" in command.output)
return ('docker' in command.script and "access denied" in command.output and "may require 'docker login'" in command.output)
16
72
43
115
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_('docker login', command.script)
from thefuck.utils import for_app from thefuck.shells import shell @for_app('docker') def match(command): FILL_FUNC_BODYdef get_new_command(command): return shell.and_('docker login', command.script)
21,547
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/docker_not_command.py
14,15
1,50
_parse_commands
15,21
15,21
from itertools import dropwhile, takewhile, islice import re import subprocess from thefuck.utils import replace_command, for_app, which, cache from thefuck.specific.sudo import sudo_support @sudo_support @for_app('docker') def match(command): return 'is not a docker command' in command.output or 'Usage: docker' ...
from itertools import dropwhile, takewhile, islice import re import subprocess from thefuck.utils import replace_command, for_app, which, cache from thefuck.specific.sudo import sudo_support @sudo_support @for_app('docker') def match(command): return 'is not a docker command' in command.output or 'Usage: docker' ...
lines = dropwhile(lambda line: not line.startswith(starts_with), lines) lines = islice(lines, 1, None) lines = list(takewhile(lambda line: line.strip(), lines)) return [line.strip().split(' ')[0] for line in lines]
lines = dropwhile(lambda line: not line.startswith(starts_with), lines) lines = islice(lines, 1, None) lines = list(takewhile(lambda line: line.strip(), lines)) return [line.strip().split(' ')[0] for line in lines]
25
497
84
581
from itertools import dropwhile, takewhile, islice import re import subprocess from thefuck.utils import replace_command, for_app, which, cache from thefuck.specific.sudo import sudo_support @sudo_support @for_app('docker') def match(command): return 'is not a docker command' in command.output or 'Usage: docker' ...
from itertools import dropwhile, takewhile, islice import re import subprocess from thefuck.utils import replace_command, for_app, which, cache from thefuck.specific.sudo import sudo_support @sudo_support @for_app('docker') def match(command): return 'is not a docker command' in command.output or 'Usage: docker' ...
21,548
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/dry.py
9,10
1,16
get_new_command
10,15
10,15
def match(command): split_command = command.script_parts return (split_command and len(split_command) >= 2 and split_command[0] == split_command[1]) def get_new_command(command): FILL_FUNC_BODYpriority = 900
def match(command): split_command = command.script_parts return (split_command and len(split_command) >= 2 and split_command[0] == split_command[1]) def get_new_command(command): FILL_FUNC_BODYpriority = 900
return ' '.join(command.script_parts[1:]) # it should be rare enough to actually have to type twice the same word, so # this rule can have a higher priority to come before things like "cd cd foo"
return ' '.join(command.script_parts[1:]) # it should be rare enough to actually have to type twice the same word, so # this rule can have a higher priority to come before things like "cd cd foo"
35
81
60
141
def match(command): split_command = command.script_parts return (split_command and len(split_command) >= 2 and split_command[0] == split_command[1]) def get_new_command(command): FILL_FUNC_BODYpriority = 900
def match(command): split_command = command.script_parts return (split_command and len(split_command) >= 2 and split_command[0] == split_command[1]) def get_new_command(command): FILL_FUNC_BODYpriority = 900
21,549
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/fab_command_not_found.py
25,26
1,39
get_new_command
26,39
26,39
from thefuck.utils import eager, get_closest, for_app @for_app('fab') def match(command): return 'Warning: Command(s) not found:' in command.output # We need different behavior then in get_all_matched_commands. @eager def _get_between(content, start, end=None): should_yield = False for line in content.s...
from thefuck.utils import eager, get_closest, for_app @for_app('fab') def match(command): return 'Warning: Command(s) not found:' in command.output # We need different behavior then in get_all_matched_commands. @eager def _get_between(content, start, end=None): should_yield = False for line in content.s...
not_found_commands = _get_between( command.output, 'Warning: Command(s) not found:', 'Available commands:') possible_commands = _get_between( command.output, 'Available commands:') script = command.script for not_found in not_found_commands: fix = get_closest(not_found, ...
not_found_commands = _get_between( command.output, 'Warning: Command(s) not found:', 'Available commands:') possible_commands = _get_between( command.output, 'Available commands:') script = command.script for not_found in not_found_commands: fix = get_closest(not_found, ...
35
189
144
333
from thefuck.utils import eager, get_closest, for_app @for_app('fab') def match(command): return 'Warning: Command(s) not found:' in command.output # We need different behavior then in get_all_matched_commands. @eager def _get_between(content, start, end=None): should_yield = False for line in content.s...
from thefuck.utils import eager, get_closest, for_app @for_app('fab') def match(command): return 'Warning: Command(s) not found:' in command.output # We need different behavior then in get_all_matched_commands. @eager def _get_between(content, start, end=None): should_yield = False for line in content.s...
21,550
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/fix_alt_space.py
7,9
1,16
match
9,13
9,13
# -*- encoding: utf-8 -*- import re from thefuck.specific.sudo import sudo_support @sudo_support def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(u' ', ' ', command.script)
# -*- encoding: utf-8 -*- import re from thefuck.specific.sudo import sudo_support @sudo_support def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(u' ', ' ', command.script)
return ('command not found' in command.output.lower() and u' ' in command.script)
return ('command not found' in command.output.lower() and u' ' in command.script)
11
85
33
118
# -*- encoding: utf-8 -*- import re from thefuck.specific.sudo import sudo_support @sudo_support def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(u' ', ' ', command.script)
# -*- encoding: utf-8 -*- import re from thefuck.specific.sudo import sudo_support @sudo_support def match(command): FILL_FUNC_BODY@sudo_support def get_new_command(command): return re.sub(u' ', ' ', command.script)
21,551
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/fix_file.py
63,66
1,81
get_new_command
66,81
66,81
import re import os from thefuck.utils import memoize, default_settings from thefuck.conf import settings from thefuck.shells import shell # order is important: only the first match is considered patterns = ( # js, node: '^ at {file}:{line}:{col}', # cargo: '^ {file}:{line}:{col}', # python, ...
import re import os from thefuck.utils import memoize, default_settings from thefuck.conf import settings from thefuck.shells import shell # order is important: only the first match is considered patterns = ( # js, node: '^ at {file}:{line}:{col}', # cargo: '^ {file}:{line}:{col}', # python, ...
m = _search(command.output) # Note: there does not seem to be a standard for columns, so they are just # ignored by default if settings.fixcolcmd and 'col' in m.groupdict(): editor_call = settings.fixcolcmd.format(editor=os.environ['EDITOR'], file...
m = _search(command.output) # Note: there does not seem to be a standard for columns, so they are just # ignored by default if settings.fixcolcmd and 'col' in m.groupdict(): editor_call = settings.fixcolcmd.format(editor=os.environ['EDITOR'], file...
44
612
191
803
import re import os from thefuck.utils import memoize, default_settings from thefuck.conf import settings from thefuck.shells import shell # order is important: only the first match is considered patterns = ( # js, node: '^ at {file}:{line}:{col}', # cargo: '^ {file}:{line}:{col}', # python, ...
import re import os from thefuck.utils import memoize, default_settings from thefuck.conf import settings from thefuck.shells import shell # order is important: only the first match is considered patterns = ( # js, node: '^ at {file}:{line}:{col}', # cargo: '^ {file}:{line}:{col}', # python, ...
21,552
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/gem_unknown_command.py
6,8
1,37
match
8,13
8,13
import re import subprocess from thefuck.utils import for_app, eager, replace_command, cache, which @for_app('gem') def match(command): FILL_FUNC_BODYdef _get_unknown_command(command): return re.findall(r'Unknown command (.*)$', command.output)[0] @eager def _get_all_commands(): proc = subprocess.Popen(['ge...
import re import subprocess from thefuck.utils import for_app, eager, replace_command, cache, which @for_app('gem') def match(command): FILL_FUNC_BODYdef _get_unknown_command(command): return re.findall(r'Unknown command (.*)$', command.output)[0] @eager def _get_all_commands(): proc = subprocess.Popen(['ge...
return ('ERROR: While executing gem ... (Gem::CommandLineError)' in command.output and 'Unknown command' in command.output)
return ('ERROR: While executing gem ... (Gem::CommandLineError)' in command.output and 'Unknown command' in command.output)
14
278
44
322
import re import subprocess from thefuck.utils import for_app, eager, replace_command, cache, which @for_app('gem') def match(command): FILL_FUNC_BODYdef _get_unknown_command(command): return re.findall(r'Unknown command (.*)$', command.output)[0] @eager def _get_all_commands(): proc = subprocess.Popen(['ge...
import re import subprocess from thefuck.utils import for_app, eager, replace_command, cache, which @for_app('gem') def match(command): FILL_FUNC_BODYdef _get_unknown_command(command): return re.findall(r'Unknown command (.*)$', command.output)[0] @eager def _get_all_commands(): proc = subprocess.Popen(['ge...
21,553
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_add.py
8,10
1,28
_get_missing_file
10,17
10,17
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.system import Path from thefuck.utils import memoize @memoize def _get_missing_file(command): FILL_FUNC_BODY@git_support def match(command): return ('did not match any file(s) known to git.' in command.output ...
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.system import Path from thefuck.utils import memoize @memoize def _get_missing_file(command): FILL_FUNC_BODY@git_support def match(command): return ('did not match any file(s) known to git.' in command.output ...
pathspec = re.findall( r"error: pathspec '([^']*)' " r'did not match any file\(s\) known to git.', command.output)[0] if Path(pathspec).exists(): return pathspec
pathspec = re.findall( r"error: pathspec '([^']*)' " r'did not match any file\(s\) known to git.', command.output)[0] if Path(pathspec).exists(): return pathspec
20
187
73
260
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.system import Path from thefuck.utils import memoize @memoize def _get_missing_file(command): FILL_FUNC_BODY@git_support def match(command): return ('did not match any file(s) known to git.' in command.output ...
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.system import Path from thefuck.utils import memoize @memoize def _get_missing_file(command): FILL_FUNC_BODY@git_support def match(command): return ('did not match any file(s) known to git.' in command.output ...
21,554
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_add_force.py
5,7
1,14
match
7,11
7,11
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, 'add', 'add --force')
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, 'add', 'add --force')
return ('add' in command.script_parts and 'Use -f if you really want to add them.' in command.output)
return ('add' in command.script_parts and 'Use -f if you really want to add them.' in command.output)
16
81
38
119
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, 'add', 'add --force')
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, 'add', 'add --force')
21,555
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_bisect_usage.py
12,14
1,17
get_new_command
14,17
14,17
import re from thefuck.utils import replace_command from thefuck.specific.git import git_support @git_support def match(command): return ('bisect' in command.script_parts and 'usage: git bisect' in command.output) @git_support def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.utils import replace_command from thefuck.specific.git import git_support @git_support def match(command): return ('bisect' in command.script_parts and 'usage: git bisect' in command.output) @git_support def get_new_command(command): FILL_FUNC_BODY
broken = re.findall(r'git bisect ([^ $]*).*', command.script)[0] usage = re.findall(r'usage: git bisect \[([^\]]+)\]', command.output)[0] return replace_command(command, broken, usage.split('|'))
broken = re.findall(r'git bisect ([^ $]*).*', command.script)[0] usage = re.findall(r'usage: git bisect \[([^\]]+)\]', command.output)[0] return replace_command(command, broken, usage.split('|'))
18
95
79
174
import re from thefuck.utils import replace_command from thefuck.specific.git import git_support @git_support def match(command): return ('bisect' in command.script_parts and 'usage: git bisect' in command.output) @git_support def get_new_command(command): FILL_FUNC_BODY
import re from thefuck.utils import replace_command from thefuck.specific.git import git_support @git_support def match(command): return ('bisect' in command.script_parts and 'usage: git bisect' in command.output) @git_support def get_new_command(command): FILL_FUNC_BODY
21,556
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_branch_0flag.py
11,13
1,25
match
13,16
13,16
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import memoize @memoize def first_0flag(script_parts): return next((p for p in script_parts if len(p) == 2 and p.startswith("0")), None) @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_comman...
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import memoize @memoize def first_0flag(script_parts): return next((p for p in script_parts if len(p) == 2 and p.startswith("0")), None) @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_comman...
return command.script_parts[1] == "branch" and first_0flag(command.script_parts)
return command.script_parts[1] == "branch" and first_0flag(command.script_parts)
6
237
32
269
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import memoize @memoize def first_0flag(script_parts): return next((p for p in script_parts if len(p) == 2 and p.startswith("0")), None) @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_comman...
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import memoize @memoize def first_0flag(script_parts): return next((p for p in script_parts if len(p) == 2 and p.startswith("0")), None) @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_comman...
21,557
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_branch_delete.py
5,7
1,14
match
7,11
7,11
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, '-d', '-D')
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, '-d', '-D')
return ('branch -d' in command.script and 'If you are sure you want to delete it' in command.output)
return ('branch -d' in command.script and 'If you are sure you want to delete it' in command.output)
17
79
37
116
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, '-d', '-D')
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return replace_argument(command.script, '-d', '-D')
21,558
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_branch_delete_checked_out.py
6,8
1,20
match
8,15
8,15
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import replace_argument @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_("git checkout master", "{}").format( replace_argument(command.script, "-d", "...
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import replace_argument @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_("git checkout master", "{}").format( replace_argument(command.script, "-d", "...
return ( ("branch -d" in command.script or "branch -D" in command.script) and "error: Cannot delete branch '" in command.output and "' checked out at '" in command.output )
return ( ("branch -d" in command.script or "branch -D" in command.script) and "error: Cannot delete branch '" in command.output and "' checked out at '" in command.output )
28
109
64
173
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import replace_argument @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_("git checkout master", "{}").format( replace_argument(command.script, "-d", "...
from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import replace_argument @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_("git checkout master", "{}").format( replace_argument(command.script, "-d", "...
21,559
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_branch_exists.py
7,9
1,26
match
9,13
9,13
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import eager @git_support def match(command): FILL_FUNC_BODY@git_support @eager def get_new_command(command): branch_name = re.findall( r"fatal: A branch named '(.+)' already exists.", command.output...
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import eager @git_support def match(command): FILL_FUNC_BODY@git_support @eager def get_new_command(command): branch_name = re.findall( r"fatal: A branch named '(.+)' already exists.", command.output...
return ("fatal: A branch named '" in command.output and "' already exists." in command.output)
return ("fatal: A branch named '" in command.output and "' already exists." in command.output)
14
262
33
295
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import eager @git_support def match(command): FILL_FUNC_BODY@git_support @eager def get_new_command(command): branch_name = re.findall( r"fatal: A branch named '(.+)' already exists.", command.output...
import re from thefuck.shells import shell from thefuck.specific.git import git_support from thefuck.utils import eager @git_support def match(command): FILL_FUNC_BODY@git_support @eager def get_new_command(command): branch_name = re.findall( r"fatal: A branch named '(.+)' already exists.", command.output...
21,560
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_branch_list.py
5,7
1,15
match
7,12
7,12
from thefuck.shells import shell from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_('git branch --delete list', 'git branch')
from thefuck.shells import shell from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_('git branch --delete list', 'git branch')
# catches "git branch list" in place of "git branch" return (command.script_parts and command.script_parts[1:] == 'branch list'.split())
# catches "git branch list" in place of "git branch" return (command.script_parts and command.script_parts[1:] == 'branch list'.split())
17
79
51
130
from thefuck.shells import shell from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_('git branch --delete list', 'git branch')
from thefuck.shells import shell from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return shell.and_('git branch --delete list', 'git branch')
21,561
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_checkout.py
15,16
1,50
get_branches
16,30
16,30
import re import subprocess from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support from thefuck.shells import shell @git_support def match(command): return ('did not match any file(s) known to git' in command.output and "Did you forget to 'git...
import re import subprocess from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support from thefuck.shells import shell @git_support def match(command): return ('did not match any file(s) known to git' in command.output and "Did you forget to 'git...
proc = subprocess.Popen( ['git', 'branch', '-a', '--no-color', '--no-column'], stdout=subprocess.PIPE) for line in proc.stdout.readlines(): line = line.decode('utf-8') if '->' in line: # Remote HEAD like b' remotes/origin/HEAD -> origin/master' continue if...
proc = subprocess.Popen( ['git', 'branch', '-a', '--no-color', '--no-column'], stdout=subprocess.PIPE) for line in proc.stdout.readlines(): line = line.decode('utf-8') if '->' in line: # Remote HEAD like b' remotes/origin/HEAD -> origin/master' continue if...
42
357
182
539
import re import subprocess from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support from thefuck.shells import shell @git_support def match(command): return ('did not match any file(s) known to git' in command.output and "Did you forget to 'git...
import re import subprocess from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support from thefuck.shells import shell @git_support def match(command): return ('did not match any file(s) known to git' in command.output and "Did you forget to 'git...
21,562
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_clone_git_clone.py
4,6
1,13
match
6,10
6,10
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return command.script.replace(' git clone ', ' ', 1)
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return command.script.replace(' git clone ', ' ', 1)
return (' git clone ' in command.script and 'fatal: Too many arguments.' in command.output)
return (' git clone ' in command.script and 'fatal: Too many arguments.' in command.output)
14
68
33
101
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return command.script.replace(' git clone ', ' ', 1)
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return command.script.replace(' git clone ', ' ', 1)
21,563
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_clone_missing.py
17,18
1,43
match
18,41
18,41
''' Rule: git_clone_missing Correct missing `git clone` command when pasting a git URL ```sh >>> https://github.com/nvbn/thefuck.git git clone https://github.com/nvbn/thefuck.git ``` Author: Miguel Guthridge ''' from six.moves.urllib import parse from thefuck.utils import which def match(command): FILL_FUNC_BODYde...
''' Rule: git_clone_missing Correct missing `git clone` command when pasting a git URL ```sh >>> https://github.com/nvbn/thefuck.git git clone https://github.com/nvbn/thefuck.git ``` Author: Miguel Guthridge ''' from six.moves.urllib import parse from thefuck.utils import which def match(command): FILL_FUNC_BODYde...
# We want it to be a URL by itself if len(command.script_parts) != 1: return False # Ensure we got the error we expected if which(command.script_parts[0]) or not ( 'No such file or directory' in command.output or 'not found' in command.output or 'is not recognised as' in ...
# We want it to be a URL by itself if len(command.script_parts) != 1: return False # Ensure we got the error we expected if which(command.script_parts[0]) or not ( 'No such file or directory' in command.output or 'not found' in command.output or 'is not recognised as' in ...
105
138
246
384
''' Rule: git_clone_missing Correct missing `git clone` command when pasting a git URL ```sh >>> https://github.com/nvbn/thefuck.git git clone https://github.com/nvbn/thefuck.git ``` Author: Miguel Guthridge ''' from six.moves.urllib import parse from thefuck.utils import which def match(command): FILL_FUNC_BODYde...
''' Rule: git_clone_missing Correct missing `git clone` command when pasting a git URL ```sh >>> https://github.com/nvbn/thefuck.git git clone https://github.com/nvbn/thefuck.git ``` Author: Miguel Guthridge ''' from six.moves.urllib import parse from thefuck.utils import which def match(command): FILL_FUNC_BODYde...
21,564
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_commit_add.py
5,7
1,18
match
7,13
7,13
from thefuck.utils import eager, replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@eager @git_support def get_new_command(command): for opt in ("-a", "-p"): yield replace_argument(command.script, "commit", "commit {}".format(opt))
from thefuck.utils import eager, replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@eager @git_support def get_new_command(command): for opt in ("-a", "-p"): yield replace_argument(command.script, "commit", "commit {}".format(opt))
return ( "commit" in command.script_parts and "no changes added to commit" in command.output )
return ( "commit" in command.script_parts and "no changes added to commit" in command.output )
14
103
40
143
from thefuck.utils import eager, replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@eager @git_support def get_new_command(command): for opt in ("-a", "-p"): yield replace_argument(command.script, "commit", "commit {}".format(opt))
from thefuck.utils import eager, replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@eager @git_support def get_new_command(command): for opt in ("-a", "-p"): yield replace_argument(command.script, "commit", "commit {}".format(opt))
21,565
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_commit_amend.py
4,6
1,12
match
6,9
6,9
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return 'git commit --amend'
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return 'git commit --amend'
return ('commit' in command.script_parts)
return ('commit' in command.script_parts)
4
61
18
79
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return 'git commit --amend'
from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): return 'git commit --amend'
21,566
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_commit_reset.py
9,11
1,12
get_new_command
11,12
11,12
from thefuck.specific.git import git_support @git_support def match(command): return ('commit' in command.script_parts) @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.specific.git import git_support @git_support def match(command): return ('commit' in command.script_parts) @git_support def get_new_command(command): FILL_FUNC_BODY
return 'git reset HEAD~'
return 'git reset HEAD~'
4
66
11
77
from thefuck.specific.git import git_support @git_support def match(command): return ('commit' in command.script_parts) @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.specific.git import git_support @git_support def match(command): return ('commit' in command.script_parts) @git_support def get_new_command(command): FILL_FUNC_BODY
21,567
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_diff_no_index.py
14,16
1,17
get_new_command
16,17
16,17
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): files = [arg for arg in command.script_parts[2:] if not arg.startswith('-')] return ('diff' in command.script and '--no-index' not in command.script and...
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): files = [arg for arg in command.script_parts[2:] if not arg.startswith('-')] return ('diff' in command.script and '--no-index' not in command.script and...
return replace_argument(command.script, 'diff', 'diff --no-index')
return replace_argument(command.script, 'diff', 'diff --no-index')
5
128
22
150
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): files = [arg for arg in command.script_parts[2:] if not arg.startswith('-')] return ('diff' in command.script and '--no-index' not in command.script and...
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): files = [arg for arg in command.script_parts[2:] if not arg.startswith('-')] return ('diff' in command.script and '--no-index' not in command.script and...
21,568
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_diff_staged.py
11,13
1,14
get_new_command
13,14
13,14
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): return ('diff' in command.script and '--staged' not in command.script) @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): return ('diff' in command.script and '--staged' not in command.script) @git_support def get_new_command(command): FILL_FUNC_BODY
return replace_argument(command.script, 'diff', 'diff --staged')
return replace_argument(command.script, 'diff', 'diff --staged')
5
88
21
109
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): return ('diff' in command.script and '--staged' not in command.script) @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): return ('diff' in command.script and '--staged' not in command.script) @git_support def get_new_command(command): FILL_FUNC_BODY
21,569
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_fix_stash.py
27,29
1,38
get_new_command
29,38
29,38
from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): if command.script_parts and len(command.script_parts) > 1: return (command.script_parts[1] == 'stash' and 'usage:' in command.output) else:...
from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): if command.script_parts and len(command.script_parts) > 1: return (command.script_parts[1] == 'stash' and 'usage:' in command.output) else:...
stash_cmd = command.script_parts[2] fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False) if fixed is not None: return replace_argument(command.script, stash_cmd, fixed) else: cmd = command.script_parts[:] cmd.insert(2, 'save') return ' '.join(cmd...
stash_cmd = command.script_parts[2] fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False) if fixed is not None: return replace_argument(command.script, stash_cmd, fixed) else: cmd = command.script_parts[:] cmd.insert(2, 'save') return ' '.join(cmd...
26
197
118
315
from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): if command.script_parts and len(command.script_parts) > 1: return (command.script_parts[1] == 'stash' and 'usage:' in command.output) else:...
from thefuck import utils from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): if command.script_parts and len(command.script_parts) > 1: return (command.script_parts[1] == 'stash' and 'usage:' in command.output) else:...
21,570
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_flag_after_filename.py
13,15
1,32
get_new_command
15,32
15,32
import re from thefuck.specific.git import git_support error_pattern = "fatal: bad flag '(.*?)' used after filename" error_pattern2 = "fatal: option '(.*?)' must come before non-option arguments" @git_support def match(command): return re.search(error_pattern, command.output) or re.search(error_pattern2, command...
import re from thefuck.specific.git import git_support error_pattern = "fatal: bad flag '(.*?)' used after filename" error_pattern2 = "fatal: option '(.*?)' must come before non-option arguments" @git_support def match(command): return re.search(error_pattern, command.output) or re.search(error_pattern2, command...
command_parts = command.script_parts[:] # find the bad flag bad_flag = match(command).group(1) bad_flag_index = command_parts.index(bad_flag) # find the filename for index in reversed(range(bad_flag_index)): if command_parts[index][0] != '-': filename_index = index ...
command_parts = command.script_parts[:] # find the bad flag bad_flag = match(command).group(1) bad_flag_index = command_parts.index(bad_flag) # find the filename for index in reversed(range(bad_flag_index)): if command_parts[index][0] != '-': filename_index = index ...
45
130
190
320
import re from thefuck.specific.git import git_support error_pattern = "fatal: bad flag '(.*?)' used after filename" error_pattern2 = "fatal: option '(.*?)' must come before non-option arguments" @git_support def match(command): return re.search(error_pattern, command.output) or re.search(error_pattern2, command...
import re from thefuck.specific.git import git_support error_pattern = "fatal: bad flag '(.*?)' used after filename" error_pattern2 = "fatal: option '(.*?)' must come before non-option arguments" @git_support def match(command): return re.search(error_pattern, command.output) or re.search(error_pattern2, command...
21,571
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_help_aliased.py
9,11
1,13
get_new_command
11,13
11,13
from thefuck.specific.git import git_support @git_support def match(command): return 'help' in command.script and ' is aliased to ' in command.output @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.specific.git import git_support @git_support def match(command): return 'help' in command.script and ' is aliased to ' in command.output @git_support def get_new_command(command): FILL_FUNC_BODY
aliased = command.output.split('`', 2)[2].split("'", 1)[0].split(' ', 1)[0] return 'git help {}'.format(aliased)
aliased = command.output.split('`', 2)[2].split("'", 1)[0].split(' ', 1)[0] return 'git help {}'.format(aliased)
11
74
50
124
from thefuck.specific.git import git_support @git_support def match(command): return 'help' in command.script and ' is aliased to ' in command.output @git_support def get_new_command(command): FILL_FUNC_BODY
from thefuck.specific.git import git_support @git_support def match(command): return 'help' in command.script and ' is aliased to ' in command.output @git_support def get_new_command(command): FILL_FUNC_BODY
21,572
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_hook_bypass.py
14,16
1,28
get_new_command
16,26
16,26
from thefuck.utils import replace_argument from thefuck.specific.git import git_support hooked_commands = ("am", "commit", "push") @git_support def match(command): return any( hooked_command in command.script_parts for hooked_command in hooked_commands ) @git_support def get_new_command(command): F...
from thefuck.utils import replace_argument from thefuck.specific.git import git_support hooked_commands = ("am", "commit", "push") @git_support def match(command): return any( hooked_command in command.script_parts for hooked_command in hooked_commands ) @git_support def get_new_command(command): F...
hooked_command = next( hooked_command for hooked_command in hooked_commands if hooked_command in command.script_parts ) return replace_argument( command.script, hooked_command, hooked_command + " --no-verify" )
hooked_command = next( hooked_command for hooked_command in hooked_commands if hooked_command in command.script_parts ) return replace_argument( command.script, hooked_command, hooked_command + " --no-verify" )
22
127
89
216
from thefuck.utils import replace_argument from thefuck.specific.git import git_support hooked_commands = ("am", "commit", "push") @git_support def match(command): return any( hooked_command in command.script_parts for hooked_command in hooked_commands ) @git_support def get_new_command(command): F...
from thefuck.utils import replace_argument from thefuck.specific.git import git_support hooked_commands = ("am", "commit", "push") @git_support def match(command): return any( hooked_command in command.script_parts for hooked_command in hooked_commands ) @git_support def get_new_command(command): F...
21,573
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_lfs_mistype.py
14,16
1,19
get_new_command
16,19
16,19
import re from thefuck.utils import get_all_matched_commands, replace_command from thefuck.specific.git import git_support @git_support def match(command): ''' Match a mistyped command ''' return 'lfs' in command.script and 'Did you mean this?' in command.output @git_support def get_new_command(comm...
import re from thefuck.utils import get_all_matched_commands, replace_command from thefuck.specific.git import git_support @git_support def match(command): ''' Match a mistyped command ''' return 'lfs' in command.script and 'Did you mean this?' in command.output @git_support def get_new_command(comm...
broken_cmd = re.findall(r'Error: unknown command "([^"]*)" for "git-lfs"', command.output)[0] matched = get_all_matched_commands(command.output, ['Did you mean', ' for usage.']) return replace_command(command, broken_cmd, matched)
broken_cmd = re.findall(r'Error: unknown command "([^"]*)" for "git-lfs"', command.output)[0] matched = get_all_matched_commands(command.output, ['Did you mean', ' for usage.']) return replace_command(command, broken_cmd, matched)
22
113
83
196
import re from thefuck.utils import get_all_matched_commands, replace_command from thefuck.specific.git import git_support @git_support def match(command): ''' Match a mistyped command ''' return 'lfs' in command.script and 'Did you mean this?' in command.output @git_support def get_new_command(comm...
import re from thefuck.utils import get_all_matched_commands, replace_command from thefuck.specific.git import git_support @git_support def match(command): ''' Match a mistyped command ''' return 'lfs' in command.script and 'Did you mean this?' in command.output @git_support def get_new_command(comm...
21,574
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_main_master.py
9,11
1,17
get_new_command
11,16
11,16
from thefuck.specific.git import git_support @git_support def match(command): return "'master'" in command.output or "'main'" in command.output @git_support def get_new_command(command): FILL_FUNC_BODYpriority = 1200
from thefuck.specific.git import git_support @git_support def match(command): return "'master'" in command.output or "'main'" in command.output @git_support def get_new_command(command): FILL_FUNC_BODYpriority = 1200
if "'master'" in command.output: return command.script.replace("master", "main") return command.script.replace("main", "master")
if "'master'" in command.output: return command.script.replace("master", "main") return command.script.replace("main", "master")
10
79
46
125
from thefuck.specific.git import git_support @git_support def match(command): return "'master'" in command.output or "'main'" in command.output @git_support def get_new_command(command): FILL_FUNC_BODYpriority = 1200
from thefuck.specific.git import git_support @git_support def match(command): return "'master'" in command.output or "'main'" in command.output @git_support def get_new_command(command): FILL_FUNC_BODYpriority = 1200
21,575
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck
/home/hieuvd/dung_repo/raw/stars_01/nvbn_thefuck/thefuck/thefuck/rules/git_merge.py
6,8
1,19
match
8,13
8,13
import re from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): unknown_branch = re.findall(r'merge: (.+) - not something we can merge', command.output)[0] remote_branch = re.findall(r'D...
import re from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): unknown_branch = re.findall(r'merge: (.+) - not something we can merge', command.output)[0] remote_branch = re.findall(r'D...
return ('merge' in command.script and ' - not something we can merge' in command.output and 'Did you mean this?' in command.output)
return ('merge' in command.script and ' - not something we can merge' in command.output and 'Did you mean this?' in command.output)
21
153
46
199
import re from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): unknown_branch = re.findall(r'merge: (.+) - not something we can merge', command.output)[0] remote_branch = re.findall(r'D...
import re from thefuck.utils import replace_argument from thefuck.specific.git import git_support @git_support def match(command): FILL_FUNC_BODY@git_support def get_new_command(command): unknown_branch = re.findall(r'merge: (.+) - not something we can merge', command.output)[0] remote_branch = re.findall(r'D...