MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: python-eel+Eel
Language: Python
Statement Type: Constant Assignment

Source Code:
def driver():
    TEST_BROWSER = os.environ.get("TEST_BROWSER", "chrome").lower()

    if TEST_BROWSER == "chrome":
        options = webdriver.ChromeOptions()
        options.headless = True
        capabilities = DesiredCapabilities.CHROME
        capabilities["goog:loggingPrefs"] = {"browser": "ALL"}

        if platform.system() == "Windows":
            options.binary_location = "C:/Program Files/Google/Chrome/Application/chrome.exe"

        driver = webdriver.Chrome(
            ChromeDriverManager().install(),
            options=options,
            desired_capabilities=capabilities,
            service_log_path=os.path.devnull,
        )

    # Firefox doesn't currently supported pulling JavaScript console logs, which we currently scan to affirm that
    # JS/Python can communicate in some places. So for now, we can't really use firefox/geckodriver during testing.
    # This may be added in the future: https://github.com/mozilla/geckodriver/issues/284

    # elif TEST_BROWSER == "firefox":
    #     options = webdriver.FirefoxOptions()
    #     options.headless = True
    #     capabilities = DesiredCapabilities.FIREFOX
    #     capabilities['loggingPrefs'] = {"browser": "ALL"}
    #
    #     driver = webdriver.Firefox(options=options, capabilities=capabilities, service_log_path=os.path.devnull)

    else:
        raise ValueError(f"Unsupported browser for testing: {TEST_BROWSER}")

    with mock.patch("eel.browsers.open"):
        yield driver

driver()

Selected Statement: options.headless = True

Function Input:

Variable Values Before Statement:
Constant: True

Value After Statement Execution: True

Variable States During Runtime (line, value):
TEST_BROWSER: 2
'chrome'
options: 5
{_caps={'browserName': 'chrome', 'goog:loggingPrefs': {'browser': 'ALL'}, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>}, _proxy=None, mobile_options=None, _arguments=[], _ignore_local_proxy=False, _binary_location='', _extension_files=[], _extensions=[], _experimental_options={}, _debugger_address=None}
6
{_caps={'browserName': 'chrome', 'goog:loggingPrefs': {'browser': 'ALL'}, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>}, _proxy=None, mobile_options=None, _arguments=[], _ignore_local_proxy=False, _binary_location='', _extension_files=[], _extensions=[], _experimental_options={}, _debugger_address=None, headless=True}
capabilities: 7
{'browserName': 'chrome', 'goog:loggingPrefs': {'browser': 'ALL'}}
Project Name: lra+mackup
Language: Python
Statement Type: Constant Assignment

Source Code:
def get_google_drive_folder_location():
    """
    Try to locate the Google Drive folder.

    Returns:
        (str) Full path to the current Google Drive folder
    """
    gdrive_db_path = "Library/Application Support/Google/Drive/sync_config.db"
    yosemite_gdrive_db_path = (
        "Library/Application Support/Google/Drive/" "user_default/sync_config.db"
    )
    yosemite_gdrive_db = os.path.join(os.environ["HOME"], yosemite_gdrive_db_path)
    if os.path.isfile(yosemite_gdrive_db):
        gdrive_db_path = yosemite_gdrive_db

    googledrive_home = None

    gdrive_db = os.path.join(os.environ["HOME"], gdrive_db_path)
    if os.path.isfile(gdrive_db):
        con = sqlite3.connect(gdrive_db)
        if con:
            cur = con.cursor()
            query = (
                "SELECT data_value "
                "FROM data "
                "WHERE entry_key = 'local_sync_root_path';"
            )
            cur.execute(query)
            data = cur.fetchone()
            googledrive_home = str(data[0])
            con.close()

    if not googledrive_home:
        error(
            constants.ERROR_UNABLE_TO_FIND_STORAGE.format(
                provider="Google Drive install"
            )
        )

    return googledrive_home

get_google_drive_folder_location()

Selected Statement: gdrive_db_path = "Library/Application Support/Google/Drive/sync_config.db"

Function Input:

Variable Values Before Statement:
Constant: "Library/Application Support/Google/Drive/sync_config.db"

Value After Statement Execution: "Library/Application Support/Google/Drive/sync_config.db"

Variable States During Runtime (line, value):
gdrive_db_path: 8
'Library/Application Support/Google/Drive/sync_config.db'
yosemite_gdrive_db_path: 9
'Library/Application Support/Google/Drive/user_default/sync_config.db'
yosemite_gdrive_db: 12
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/lra+mackup/lra+mackup/tests/fixtures/Library/Application Support/Google/Drive/user_default/sync_config.db'
googledrive_home: 16
None
30
'/Users/whatever/Google Drive'
gdrive_db: 18
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/lra+mackup/lra+mackup/tests/fixtures/Library/Application Support/Google/Drive/sync_config.db'
con: 20
REPR FAILED
cur: 22
REPR FAILED
query: 23
"SELECT data_value FROM data WHERE entry_key = 'local_sync_root_path';"
data: 29
('/Users/whatever/Google Drive',)
Project Name: lra+mackup
Language: Python
Statement Type: Constant Assignment

Source Code:
def can_file_be_synced_on_current_platform(path):
    """
    Check if the given path can be synced locally.

    Check if it makes sense to sync the file at the given path on the current
    platform.
    For now we don't sync any file in the ~/Library folder on GNU/Linux.
    There might be other exceptions in the future.

    Args:
        (str): Path to the file or folder to check. If relative, prepend it
               with the home folder.
               'abc' becomes '~/abc'
               '/def' stays '/def'

    Returns:
        (bool): True if given file can be synced
    """
    can_be_synced = True

    # If the given path is relative, prepend home
    fullpath = os.path.join(os.environ["HOME"], path)

    # Compute the ~/Library path on macOS
    # End it with a slash because we are looking for this specific folder and
    # not any file/folder named LibrarySomething
    library_path = os.path.join(os.environ["HOME"], "Library/")

    if platform.system() == constants.PLATFORM_LINUX:
        if fullpath.startswith(library_path):
            can_be_synced = False

    return can_be_synced

can_file_be_synced_on_current_platform(path='some/file')

Selected Statement: can_be_synced = True

Function Input:
path: 'some/file'

Variable Values Before Statement:
Constant: True

Value After Statement Execution: True

Variable States During Runtime (line, value):
path: 1
'some/file'
can_be_synced: 19
True
fullpath: 22
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/lra+mackup/lra+mackup/tests/fixtures/some/file'
library_path: 27
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/lra+mackup/lra+mackup/tests/fixtures/Library/'
Project Name: lra+mackup
Language: Python
Statement Type: Constant Assignment

Source Code:
def is_process_running(process_name):
    """
    Check if a process with the given name is running.

    Args:
        (str): Process name, e.g. "Sublime Text"

    Returns:
        (bool): True if the process is running
    """
    is_running = False

    # On systems with pgrep, check if the given process is running
    if os.path.isfile("/usr/bin/pgrep"):
        dev_null = open(os.devnull, "wb")
        returncode = subprocess.call(["/usr/bin/pgrep", process_name], stdout=dev_null)
        is_running = bool(returncode == 0)

    return is_running

is_process_running(process_name='a*')

Selected Statement: is_running = False

Function Input:
process_name: 'a*'

Variable Values Before Statement:
Constant: False

Value After Statement Execution: False

Variable States During Runtime (line, value):
process_name: 1
'a*'
is_running: 11
False
17
True
dev_null: 15
<_io.BufferedWriter name='/dev/null'>
returncode: 16
0
Project Name: cyril-s+aptly-ctl
Language: Python
Statement Type: Constant Assignment

Source Code:
def _get_part(self, s, decimal):
        "Strips first part of string containing either non-decimal or decimal characters." \
        + " Returns tuple (part, remider)."
        div = 0
        for c in s:
            if decimal and not c.isdecimal():
                break
            elif not decimal and c.isdecimal():
                break
            else:
                div += 1

        return (s[:div], s[div:])

_get_part(self=2.2.0~rc5, s='2.2.0~rc5', decimal=False, self.epoch=0, self.revision='0', self.revision_allowed_chars=('.', '+', '~'), self.upstream_version='2.2.0~rc5', self.upstream_version_allowed_chars=('.', '+', '~', '-', ':'), self.version='2.2.0~rc5')

Selected Statement: div = 0

Function Input:
self: 2.2.0~rc5
s: '2.2.0~rc5'
decimal: False
self.epoch: 0
self.revision: '0'
self.revision_allowed_chars: ('.', '+', '~')
self.upstream_version: '2.2.0~rc5'
self.upstream_version_allowed_chars: ('.', '+', '~', '-', ':')
self.version: '2.2.0~rc5'

Variable Values Before Statement:
Constant: 0

Value After Statement Execution: 0

Variable States During Runtime (line, value):
self: 1
2.2.0~rc5
s: 1
'2.2.0~rc5'
decimal: 1
False
self.epoch: 1
0
self.revision: 1
'0'
self.revision_allowed_chars: 1
('.', '+', '~')
self.upstream_version: 1
'2.2.0~rc5'
self.upstream_version_allowed_chars: 1
('.', '+', '~', '-', ':')
self.version: 1
'2.2.0~rc5'
div: 4
0
c: 5
'2'
Project Name: JGoutin+rfs
Language: Python
Statement Type: Constant Assignment

Source Code:
def _copy(src, dst, src_is_storage, dst_is_storage):
    """
    Copies file from source to destination

    Args:
        src (str or file-like object): Source file.
        dst (str or file-like object): Destination file.
        src_is_storage (bool): Source is storage.
        dst_is_storage (bool): Destination is storage.
    """
    # If both storage: Tries to perform same storage direct copy
    if src_is_storage and dst_is_storage:
        system = get_instance(src)
        if system is get_instance(dst):

            # Checks if same file
            if system.relpath(src) == system.relpath(dst):
                raise same_file_error(
                    "'%s' and '%s' are the same file" % (src, dst))

            # Tries to copy
            try:
                return system.copy(src, dst)
            except (UnsupportedOperation, ObjectException):
                pass

    # At least one storage object: copies streams
    with cos_open(src, 'rb') as fsrc:
        with cos_open(dst, 'wb') as fdst:

            # Get stream buffer size
            for stream in (fdst, fsrc):
                try:
                    buffer_size = getattr(stream, '_buffer_size')
                    break
                except AttributeError:
                    continue
            else:
                buffer_size = 16384

            # Read and write
            copyfileobj(fsrc, fdst, buffer_size)

_copy(src='dummy_read://file.txt', dst='/tmp/pytest-of-jinjun/pytest-198/test_cos_open0/file_dst.txt', src_is_storage=True, dst_is_storage=False)

Selected Statement: buffer_size = 16384

Function Input:
src: 'dummy_read://file.txt'
dst: '/tmp/pytest-of-jinjun/pytest-198/test_cos_open0/file_dst.txt'
src_is_storage: True
dst_is_storage: False

Variable Values Before Statement:
Constant: 16384

Value After Statement Execution: 16384

Variable States During Runtime (line, value):
src: 1
'dummy_read://file.txt'
dst: 1
'/tmp/pytest-of-jinjun/pytest-198/test_cos_open0/file_dst.txt'
src_is_storage: 1
True
dst_is_storage: 1
False
fsrc: 28
fdst: 29
<_io.BufferedWriter name='/tmp/pytest-of-jinjun/pytest-198/test_cos_open0/file_dst.txt'>
stream: 32
<_io.BufferedWriter name='/tmp/pytest-of-jinjun/pytest-198/test_cos_open0/file_dst.txt'>
32
buffer_size: 39
16384
Project Name: GEMPACKsoftware+HARPY
Language: Python
Statement Type: Constant Assignment

Source Code:
def _setHeaderBaseData(array, coeff_name, hao, long_name) -> None:
        if not isinstance(array, (np.ndarray, np.float32, np.int32,np.float64)):
            print(type(array))
            raise HeaderArrayObj.UnsupportedArrayType("'array' must be of numpy.ndarray type.")

        # Defaults handling
        if coeff_name is None:
            coeff_name = " " * 12
        if long_name is None:
            long_name = coeff_name
        if len(coeff_name) < 12:
            coeff_name = coeff_name.ljust(12)
        if len(long_name) < 70:
            long_name = long_name.ljust(70)
        hao.array = array
        hao.coeff_name = coeff_name
        hao.long_name = long_name

_setHeaderBaseData(array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), coeff_name=None, hao={_coeff_name='', _array=None, _sets=None, _long_name=''}, long_name='Creation Date and Time                                                ')

Selected Statement: coeff_name = " " * 12

Function Input:
array: array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70')
coeff_name: None
hao: {_coeff_name='', _array=None, _sets=None, _long_name=''}
long_name: 'Creation Date and Time                                                '

Variable Values Before Statement:
Constant: " " * 12

Value After Statement Execution: " " * 12

Variable States During Runtime (line, value):
array: 1
array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70')
coeff_name: 1
None
8
'            '
hao: 1
{_coeff_name='', _array=None, _sets=None, _long_name=''}
15
{_coeff_name='', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name=''}
16
{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name=''}
17
{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name='Creation Date and Time                                                '}
long_name: 1
'Creation Date and Time                                                '
Project Name: MrTango+click
Language: Python
Statement Type: Constant Assignment

Source Code:
def convert_type(ty, default=None):
    """Converts a callable or python ty into the most appropriate param
    ty.
    """
    guessed_type = False
    if ty is None and default is not None:
        if isinstance(default, tuple):
            ty = tuple(map(type, default))
        else:
            ty = type(default)
        guessed_type = True

    if isinstance(ty, tuple):
        return Tuple(ty)
    if isinstance(ty, ParamType):
        return ty
    if ty is text_type or ty is str or ty is None:
        return STRING
    if ty is int:
        return INT
    # Booleans are only okay if not guessed.  This is done because for
    # flags the default value is actually a bit of a lie in that it
    # indicates which of the flags is the one we want.  See get_default()
    # for more information.
    if ty is bool and not guessed_type:
        return BOOL
    if ty is float:
        return FLOAT
    if guessed_type:
        return STRING

    # Catch a common mistake
    if __debug__:
        try:
            if issubclass(ty, ParamType):
                raise AssertionError('Attempted to use an uninstantiated '
                                     'parameter type (%s).' % ty)
        except TypeError:
            pass
    return FuncParamType(ty)

convert_type(ty=None, default=None)

Selected Statement: guessed_type = False

Function Input:
ty: None
default: None

Variable Values Before Statement:
Constant: False

Value After Statement Execution: False

Variable States During Runtime (line, value):
ty: 1
None
default: 1
None
guessed_type: 5
False
Project Name: MrTango+click
Language: Python
Statement Type: Constant Assignment

Source Code:
def make_default_short_help(help, max_length=45):
    words = help.split()
    total_length = 0
    result = []
    done = False

    for word in words:
        if word[-1:] == '.':
            done = True
        new_length = result and 1 + len(word) or len(word)
        if total_length + new_length > max_length:
            result.append('...')
            done = True
        else:
            if result:
                result.append(' ')
            result.append(word)
        if done:
            break
        total_length += new_length

    return ''.join(result)

make_default_short_help(help='Hello World!', max_length=45)

Selected Statement: total_length = 0

Function Input:
help: 'Hello World!'
max_length: 45

Variable Values Before Statement:
Constant: 0

Value After Statement Execution: 0

Variable States During Runtime (line, value):
help: 1
'Hello World!'
max_length: 1
45
words: 2
Hello, World!
total_length: 3
0
20
5
20
12
result: 4
17
Hello
16
Hello,  
17
Hello,  , World!
done: 5
False
word: 7
'Hello'
7
'World!'
new_length: 10
5
10
7
Project Name: MrTango+click
Language: Python
Statement Type: Constant Assignment

Source Code:
def join_options(options):
    """Given a list of option strings this joins them in the most appropriate
    way and returns them in the form ``(formatted_string,
    any_prefix_is_slash)`` where the second item in the tuple is a flag that
    indicates if any of the option prefixes was a slash.
    """
    rv = []
    any_prefix_is_slash = False
    for opt in options:
        prefix = split_opt(opt)[0]
        if prefix == '/':
            any_prefix_is_slash = True
        rv.append((len(prefix), opt))

    rv.sort(key=lambda x: x[0])

    rv = ', '.join(x[1] for x in rv)
    return rv, any_prefix_is_slash

join_options(options=['--help'])

Selected Statement: any_prefix_is_slash = False

Function Input:
options: --help

Variable Values Before Statement:
Constant: False

Value After Statement Execution: False

Variable States During Runtime (line, value):
options: 1
--help
rv: 7
13
[(2, '--help')]
17
'--help'
any_prefix_is_slash: 8
False
opt: 9
'--help'
prefix: 10
'--'
Project Name: mher+flower
Language: Python
Statement Type: Constant Assignment

Source Code:
def parse_search_terms(raw_search_value):
    search_regexp = r'(?:[^\s,"]|"(?:\\.|[^"])*")+'  # splits by space, ignores space in quotes
    if not raw_search_value:
        return {}
    parsed_search = {}
    for query_part in re.findall(search_regexp, raw_search_value):
        if not query_part:
            continue
        if query_part.startswith('result:'):
            parsed_search['result'] = preprocess_search_value(query_part[len('result:'):])
        elif query_part.startswith('args:'):
            if 'args' not in parsed_search:
                parsed_search['args'] = []
            parsed_search['args'].append(preprocess_search_value(query_part[len('args:'):]))
        elif query_part.startswith('kwargs:'):
            if 'kwargs'not in parsed_search:
                parsed_search['kwargs'] = {}
            try:
                key, value = [p.strip() for p in query_part[len('kwargs:'):].split('=')]
            except ValueError:
                continue
            parsed_search['kwargs'][key] = preprocess_search_value(value)
        elif query_part.startswith('state'):
            if 'state' not in parsed_search:
                parsed_search['state'] = []
            parsed_search['state'].append(preprocess_search_value(query_part[len('state:'):]))
        else:
            parsed_search['any'] = preprocess_search_value(query_part)
    return parsed_search

parse_search_terms(raw_search_value={})

Selected Statement: search_regexp = r'(?:[^\s,"]|"(?:\\.|[^"])*")+'  # splits by space, ignores space in quotes

Function Input:

Variable Values Before Statement:
Constant: r'(?:[^\s,"]|"(?:\\.|[^"])*")+'

Value After Statement Execution: r'(?:[^\s,"]|"(?:\\.|[^"])*")+'

Variable States During Runtime (line, value):
raw_search_value: 1
search_regexp: 2
'(?:[^\\s,"]|"(?:\\\\.|[^"])*")+'
Project Name: google-research+arxiv-latex-cleaner
Language: Python
Statement Type: Constant Assignment

Source Code:
def _remove_command(text, command, keep_text=False):
  """Removes '\\command{*}' from the string 'text'.

  Regex `base_pattern` used to match balanced parentheses taken from:
  https://stackoverflow.com/questions/546433/regular-expression-to-match-balanced-parentheses/35271017#35271017
  """
  base_pattern = r'\\' + command + r'\{((?:[^{}]+|\{(?1)\})*)\}'
  # Loops in case of nested commands that need to retain text, e.g.,
  # \red{hello \red{world}}.
  while True:
    all_substitutions = []
    has_match = False
    for match in regex.finditer(base_pattern, text):
      # In case there are only spaces or nothing up to the following newline,
      # adds a percent, not to alter the newlines.
      has_match = True
      new_substring = (
          ''
          if not keep_text
          else text[match.span()[0] + len(command) + 2 : match.span()[1] - 1]
      )
      if match.span()[1] < len(text):
        next_newline = text[match.span()[1] :].find('\n')
        if next_newline != -1:
          text_until_newline = text[
              match.span()[1] : match.span()[1] + next_newline
          ]
          if (
              not text_until_newline or text_until_newline.isspace()
          ) and not keep_text:
            new_substring = '%'
      all_substitutions.append(
          (match.span()[0], match.span()[1], new_substring)
      )

    for start, end, new_substring in reversed(all_substitutions):
      text = text[:start] + new_substring + text[end:]

    if not keep_text or not has_match:
      break

  return text

_remove_command(text='A\\todo{B\nC}D\nE\n\\end{document}', command='todo', keep_text=False)

Selected Statement: has_match = False

Function Input:
text: 'A\\todo{B\nC}D\nE\n\\end{document}'
command: 'todo'
keep_text: False

Variable Values Before Statement:
Constant: False

Value After Statement Execution: False

Variable States During Runtime (line, value):
text: 1
'A\\todo{B\nC}D\nE\n\\end{document}'
37
'AD\nE\n\\end{document}'
command: 1
'todo'
keep_text: 1
False
base_pattern: 7
'\\\\todo\\{((?:[^{}]+|\\{(?1)\\})*)\\}'
all_substitutions: 11
32
[(1, 11, '')]
has_match: 12
False
16
True
match: 13
<regex.Match object; span=(1, 11), match='\\todo{B\nC}'>
new_substring: 17
''
next_newline: 23
1
text_until_newline: 25
'D'
start: 36
1
end: 36
11
Project Name: google-research+arxiv-latex-cleaner
Language: Python
Statement Type: Constant Assignment

Source Code:
def _remove_comments_inline(text):
  """Removes the comments from the string 'text' and ignores % inside \\url{}."""
  if 'auto-ignore' in text:
    return text
  if text.lstrip(' ').lstrip('\t').startswith('%'):
    return ''

  url_pattern = r'\\url\{(?>[^{}]|(?R))*\}'

  def remove_comments(segment):
    """Remove comments from a segment of text."""
    if segment.lstrip().startswith('%'):
      return ''
    match = regex.search(r'(?<!\\)%', segment)
    if match:
      return segment[: match.end()] + '\n'
    else:
      return segment

  # split the text into segments based on \url{} tags
  segments = regex.split(f'({url_pattern})', text)

  for i in range(len(segments)):
    # only process segments that are not part of a \url{} tag
    if not regex.match(url_pattern, segments[i]):
      segments[i] = remove_comments(segments[i])

  final_text = ''.join(segments)
  return (
      final_text
      if final_text.endswith('\n') or final_text.endswith('\\n')
      else final_text + '\n'
  )

_remove_comments_inline(text='Foo %Comment\n')

Selected Statement: url_pattern = r'\\url\{(?>[^{}]|(?R))*\}'

Function Input:
text: 'Foo %Comment\n'

Variable Values Before Statement:
Constant: r'\\url\{(?>[^{}]|(?R))*\}'

Value After Statement Execution: r'\\url\{(?>[^{}]|(?R))*\}'

Variable States During Runtime (line, value):
text: 1
'Foo %Comment\n'
url_pattern: 8
'\\\\url\\{(?>[^{}]|(?R))*\\}'
remove_comments: 10
<function _remove_comments_inline.<locals>.remove_comments at 0x7f185616f280>
segments: 21
Foo %Comment

26
Foo %

i: 23
0
final_text: 28
'Foo %\n'