MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: SpotlightKid+picoredis
Language: Python
Statement Type: Branch

Source Code:
def parse_array(data, start=0):
    endcnt = data.find(CRLF, start + 1)

    if endcnt == -1:
        raise ParseError("Unterminated array element count after pos {}.".format(start + 1))

    try:
        count = int(data[start + 1:endcnt])
    except (ValueError, TypeError):
        raise ParseError("Invalid array element count at pos {} - {}.".format(start + 1, endcnt))

    start = endcnt + CRLFLEN

    if count == -1:
        return None, endcnt

    result = []
    
    for i in range(count):
        if start + 4 < len(data):
            obj, start = _decode(data, start)
            result.append(obj)
        else:
            raise ParseError("Unterminated array element at pos {}".format(start))
    
    return result, start

parse_array(data='*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n', start=0)

Selected Statement: if endcnt == -1:

Function Input:
data: '*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n'
start: 0

Variable Values Before Statement:
endcnt: 2

Value After Statement Execution: No

Variable States During Runtime (line, value):
data: 1
'*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-8232902\r\n$2\r\nxx\r\n*3\r\n$3\r\nSET\r\n$15\r\nmemtier-7630684\r\n$3\r\nAAA\r\n'
start: 1
0
12
4
21
13
21
35
21
43
endcnt: 2
2
count: 8
3
result: 17
22
SET
22
SET, memtier-8232902
22
SET, memtier-8232902, xx
i: 19
0
19
1
19
2
obj: 21
'SET'
21
'memtier-8232902'
21
'xx'
Project Name: rsalmei+alive-progress
Language: Python
Statement Type: Branch

Source Code:
def elapsed_text(seconds, precise, prefix=''):
    seconds = round(seconds, 1 if precise else 0)
    if seconds < 60.:
        return '{}{:{}f}s'.format(prefix, seconds, .1 if precise else .0)

    minutes, seconds = divmod(seconds, 60.)
    if minutes < 60.:
        return '{}{:.0f}:{:0{}f}'.format(prefix, minutes, seconds, 4.1 if precise else 2.0)

    hours, minutes = divmod(minutes, 60.)
    return '{}{:.0f}:{:02.0f}:{:0{}f}'.format(prefix, hours, minutes, seconds,
                                              4.1 if precise else 2.0)

elapsed_text(seconds=1.23, precise=True, prefix='')

Selected Statement: if seconds < 60.:

Function Input:
seconds: 1.23
precise: True
prefix: ''

Variable Values Before Statement:
seconds: 1.23

Value After Statement Execution: No

Variable States During Runtime (line, value):
seconds: 1
1.23
2
1.2
precise: 1
True
prefix: 1
''
Project Name: Storj+storj-kademlia
Language: Python
Statement Type: Branch

Source Code:
def mknode(id=None, ip=None, port=None, intid=None):
    """
    Make a node.  Created a random id if not specified.
    """
    if intid is not None:
        id = pack('>l', intid)
    id = id or hashlib.sha1(str(random.getrandbits(255))).digest()
    return Node(id, ip, port)

mknode(id=None, ip=None, port=None, intid=0)

Selected Statement: if intid is not None:

Function Input:
id: None
ip: None
port: None
intid: 0

Variable Values Before Statement:
intid: 0

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
id: 1
None
6
b'\x00\x00\x00\x00'
ip: 1
None
port: 1
None
intid: 1
0
Project Name: mher+flower
Language: Python
Statement Type: Branch

Source Code:
def strtobool(val):
    """Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    """
    val = val.lower()
    if val in ('y', 'yes', 't', 'true', 'on', '1'):
        return 1
    if val in ('n', 'no', 'f', 'false', 'off', '0'):
        return 0
    raise ValueError(f"invalid truth value {val!r}")

strtobool(val='False')

Selected Statement: if val in ('n', 'no', 'f', 'false', 'off', '0'):

Function Input:
val: 'False'

Variable Values Before Statement:
val: 'false'

Value After Statement Execution: No

Variable States During Runtime (line, value):
val: 1
'False'
8
'false'
Project Name: mher+flower
Language: Python
Statement Type: Branch

Source Code:
def stringified_dict_contains_value(key, value, str_dict):
    """Checks if dict in for of string like "{'test': 5}" contains
    key/value pair. This works faster, then creating actual dict
    from string since this operation is called for each task in case
    of kwargs search."""
    if not str_dict:
        return False
    value = str(value)
    try:
        # + 3 for key right quote, one for colon and one for space
        key_index = str_dict.index(key) + len(key) + 3
    except ValueError:
        return False
    try:
        comma_index = str_dict.index(',', key_index)
    except ValueError:
        # last value in dict
        comma_index = str_dict.index('}', key_index)
    return str(value) == str_dict[key_index:comma_index].strip('"\'')

stringified_dict_contains_value(key='test', value=5, str_dict="{'test': 5}")

Selected Statement: if not str_dict:

Function Input:
key: 'test'
value: 5
str_dict: "{'test': 5}"

Variable Values Before Statement:
str_dict: "{'test': 5}"

Value After Statement Execution: No

Variable States During Runtime (line, value):
key: 1
'test'
value: 1
5
8
'5'
str_dict: 1
"{'test': 5}"
key_index: 11
9
comma_index: 18
10
Project Name: mher+flower
Language: Python
Statement Type: Branch

Source Code:
def authenticate(pattern, email):
    if '|' in pattern:
        return email in pattern.split('|')
    if '*' in pattern:
        pattern = re.escape(pattern).replace(r'\.\*', r"[A-Za-z0-9!#$%&'*+/=?^_`{|}~.\-]*")
        return re.fullmatch(pattern, email)
    return pattern == email

authenticate(pattern='.*@example.com', email='one@example.com')

Selected Statement: if '*' in pattern:

Function Input:
pattern: '.*@example.com'
email: 'one@example.com'

Variable Values Before Statement:
pattern: '.*@example.com'

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
pattern: 1
'.*@example.com'
5
"[A-Za-z0-9!#$%&'*+/=?^_`{|}~.\\-]*@example\\.com"
email: 1
'one@example.com'
Project Name: albumentations-team+albumentations
Language: Python
Statement Type: Branch

Source Code:
def to_tuple(param, low=None, bias=None):
    """Convert input argument to min-max tuple
    Args:
        param (scalar, tuple or list of 2+ elements): Input value.
            If value is scalar, return value would be (offset - value, offset + value).
            If value is tuple, return value would be value + offset (broadcasted).
        low:  Second element of tuple can be passed as optional argument
        bias: An offset factor added to each element
    """
    if low is not None and bias is not None:
        raise ValueError("Arguments low and bias are mutually exclusive")

    if param is None:
        return param

    if isinstance(param, (int, float)):
        if low is None:
            param = -param, +param
        else:
            param = (low, param) if low < param else (param, low)
    elif isinstance(param, Sequence):
        if len(param) != 2:
            raise ValueError("to_tuple expects 1 or 2 values")
        param = tuple(param)
    else:
        raise ValueError("Argument param must be either scalar (int, float) or tuple")

    if bias is not None:
        return tuple(bias + x for x in param)

    return tuple(param)

to_tuple(param=7, low=3, bias=None)

Selected Statement: if bias is not None:

Function Input:
param: 7
low: 3
bias: None

Variable Values Before Statement:
bias: None

Value After Statement Execution: No

Variable States During Runtime (line, value):
param: 1
7
20
(3, 7)
low: 1
3
bias: 1
None
Project Name: dylanaraps+pywal
Language: Python
Statement Type: Branch

Source Code:
def file(input_file, light=False):
    """Import colorscheme from json file."""
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))

    theme_name = ".".join((input_file, "json"))
    bri = "light" if light else "dark"

    user_theme_file = os.path.join(CONF_DIR, "colorschemes", bri, theme_name)
    theme_file = os.path.join(MODULE_DIR, "colorschemes", bri, theme_name)

    # Find the theme file.
    if input_file in ("random", "random_dark"):
        theme_file = get_random_theme()

    elif input_file == "random_light":
        theme_file = get_random_theme(light)

    elif input_file == "random_user":
        theme_file = get_random_theme_user()

    elif os.path.isfile(user_theme_file):
        theme_file = user_theme_file

    elif os.path.isfile(input_file):
        theme_file = input_file

    # Parse the theme file.
    if os.path.isfile(theme_file):
        logging.info("Set theme to \033[1;37m%s\033[0m.",
                     os.path.basename(theme_file))
        util.save_file(os.path.basename(theme_file),
                       os.path.join(CACHE_DIR, "last_used_theme"))
        return parse(theme_file)

    logging.error("No %s colorscheme file found.", bri)
    logging.error("Try adding   '-l' to set light themes.")
    logging.error("Try removing '-l' to set dark themes.")
    sys.exit(1)

file(input_file='tests/test_files/test_file.json', light=False)

Selected Statement: if input_file in ("random", "random_dark"):

Function Input:
input_file: 'tests/test_files/test_file.json'
light: False

Variable Values Before Statement:
input_file: 'tests/test_files/test_file.json'

Value After Statement Execution: No

Variable States During Runtime (line, value):
input_file: 1
'tests/test_files/test_file.json'
light: 1
False
theme_name: 6
'tests/test_files/test_file.json.json'
bri: 7
'dark'
user_theme_file: 9
'/home/jinjun/.config/wal/colorschemes/dark/tests/test_files/test_file.json.json'
theme_file: 10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/dylanaraps+pywal/dylanaraps+pywal/pywal/colorschemes/dark/tests/test_files/test_file.json.json'
26
'tests/test_files/test_file.json'
Project Name: dylanaraps+pywal
Language: Python
Statement Type: Branch

Source Code:
def parse(theme_file):
    """Parse the theme file."""
    data = util.read_file_json(theme_file)

    if "wallpaper" not in data:
        data["wallpaper"] = "None"

    if "alpha" not in data:
        data["alpha"] = util.Color.alpha_num

    # Terminal.sexy format.
    if "color" in data:
        data = terminal_sexy_to_wal(data)

    return data

parse(theme_file='tests/test_files/test_file.json')

Selected Statement: if "alpha" not in data:

Function Input:
theme_file: 'tests/test_files/test_file.json'

Variable Values Before Statement:
data: {'wallpaper': '5.png', 'alpha': '100', 'special': {'background': '#1F211E', 'foreground': '#F5F1F4', 'cursor': '#F5F1F4'}, 'colors': {'color0': '#1F211E', 'color1': '#4B7A85', 'color2': '#CC6A93', 'color3': '#5C9894', 'color4': '#A0A89B', 'color5': '#D1B9A9', 'color6': '#E3D6D8', 'color7': '#F5F1F4', 'color8': '#666666', 'color9': '#4B7A85', 'color10': '#CC6A93', 'color11': '#5C9894', 'color12': '#A0A89B', 'color13': '#D1B9A9', 'color14': '#E3D6D8', 'color15': '#F5F1F4'}}

Value After Statement Execution: No

Variable States During Runtime (line, value):
theme_file: 1
'tests/test_files/test_file.json'
data: 3
{'wallpaper': '5.png', 'alpha': '100', 'special': {'background': '#1F211E', 'foreground': '#F5F1F4', 'cursor': '#F5F1F4'}, 'colors': {'color0': '#1F211E', 'color1': '#4B7A85', 'color2': '#CC6A93', 'color3': '#5C9894', 'color4': '#A0A89B', 'color5': '#D1B9A9', 'color6': '#E3D6D8', 'color7': '#F5F1F4', 'color8': '#666666', 'color9': '#4B7A85', 'color10': '#CC6A93', 'color11': '#5C9894', 'color12': '#A0A89B', 'color13': '#D1B9A9', 'color14': '#E3D6D8', 'color15': '#F5F1F4'}}
Project Name: biobootloader+wolverine
Language: Python
Statement Type: Branch

Source Code:
def apply_changes(file_path: str, changes: List, confirm: bool = False):
    """
    Pass changes as loaded json (list of dicts)
    """
    with open(file_path) as f:
        original_file_lines = f.readlines()

    # Filter out explanation elements
    operation_changes = [change for change in changes if "operation" in change]
    explanations = [
        change["explanation"] for change in changes if "explanation" in change
    ]

    # Sort the changes in reverse line order
    operation_changes.sort(key=lambda x: x["line"], reverse=True)

    file_lines = original_file_lines.copy()
    for change in operation_changes:
        operation = change["operation"]
        line = change["line"]
        content = change["content"]

        if operation == "Replace":
            file_lines[line - 1] = content + "\n"
        elif operation == "Delete":
            del file_lines[line - 1]
        elif operation == "InsertAfter":
            file_lines.insert(line, content + "\n")

    # Print explanations
    cprint("Explanations:", "blue")
    for explanation in explanations:
        cprint(f"- {explanation}", "blue")

    # Display changes diff
    print("\nChanges to be made:")
    diff = difflib.unified_diff(original_file_lines, file_lines, lineterm="")
    for line in diff:
        if line.startswith("+"):
            cprint(line, "green", end="")
        elif line.startswith("-"):
            cprint(line, "red", end="")
        else:
            print(line, end="")

    if confirm:
        # check if user wants to apply changes or exit
        confirmation = input("Do you want to apply these changes? (y/n): ")
        if confirmation.lower() != "y":
            print("Changes not applied")
            sys.exit(0)

    with open(file_path, "w") as f:
        f.writelines(file_lines)
    print("Changes applied.")

apply_changes(file_path='/tmp/tmp6qrrn_j9', changes=[{'operation': 'Replace', 'line': 2, 'content': 'new second line'}], confirm=False)

Selected Statement: if operation == "Replace":

Function Input:
file_path: '/tmp/tmp6qrrn_j9'
changes: operation: Replace
line: 2
content: new second line
confirm: False

Variable Values Before Statement:
operation: 'Replace'

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
file_path: 1
'/tmp/tmp6qrrn_j9'
changes: 1
operation: Replace
line: 2
content: new second line
confirm: 1
False
f: 5
<_io.TextIOWrapper name='/tmp/tmp6qrrn_j9' mode='r' encoding='UTF-8'>
53
<_io.TextIOWrapper name='/tmp/tmp6qrrn_j9' mode='w' encoding='UTF-8'>
original_file_lines: 6
first line

second line

third line
operation_changes: 9
operation: Replace
line: 2
content: new second line
explanations: 10
file_lines: 17
first line

second line

third line
24
first line

new second line

third line
change: 18
operation: Replace
line: 2
content: new second line
operation: 19
'Replace'
line: 20
2
38
'--- '
38
'+++ '
38
'@@ -1,3 +1,3 @@'
38
' first line\n'
38
'-second line\n'
38
'+new second line\n'
38
' third line'
content: 21
'new second line'
diff: 37
<generator object unified_diff at 0x7f5b71b2cba0>
Project Name: cctbx+cctbx_project
Language: Python
Statement Type: Branch

Source Code:
def import_ext(name, optional=False):
  components = name.split(".")
  if (len(components) > 1):
    __import__(".".join(components[:-1]))
  previous_dlopenflags = None
  if (sys.platform.startswith("linux")) :
    previous_dlopenflags = sys.getdlopenflags()
    sys.setdlopenflags(0x100|0x2)
  try: mod = __import__(name)
  except ImportError as e:
    if (optional): return None
    error_msg = str(e)
    m = symbol_not_found_pat.search(error_msg)
    if m:
      error_msg = (  error_msg[:m.start(1)]
                   + cpp_function_name.demangle(m.group(1))
                   + error_msg[m.end(1):])
    raise ImportError(
      "\n  ".join(['__import__("%s"): %s' % (name, error_msg), "sys.path:"]
      + ["  "+p for p in sys.path]))
  for comp in components[1:]:
    mod = getattr(mod, comp)
  if (previous_dlopenflags is not None):
    sys.setdlopenflags(previous_dlopenflags)
  if (python_libstdcxx_so is not None):
    mod_file = getattr(mod, "__file__", None)
    if (mod_file is not None):
      for line in easy_run.fully_buffered(
                    command='/usr/bin/ldd "%s"' % mod_file).stdout_lines:
        if (line.strip().startswith("libstdc++.so")):
          mod_libstdcxx_so = line.split()[0]
          if (mod_libstdcxx_so != python_libstdcxx_so):
            raise SystemError("""\
FATAL: libstdc++.so mismatch:
  %s: %s
  %s: %s""" % (sys.executable, python_libstdcxx_so,
               mod_file, mod_libstdcxx_so))
          break
  return mod

import_ext(name='boost_python_meta_ext', optional=False)

Selected Statement: if (optional): return None

Function Input:
name: 'boost_python_meta_ext'
optional: False

Variable Values Before Statement:
optional: False

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
name: 1
'boost_python_meta_ext'
optional: 1
False
components: 2
boost_python_meta_ext
previous_dlopenflags: 5
None
7
258
e: 10
ModuleNotFoundError("No module named 'boost_python_meta_ext'")
error_msg: 12
"No module named 'boost_python_meta_ext'"
m: 13
None
Project Name: nbedos+termtosvg
Language: Python
Statement Type: Branch

Source Code:
def _make_text_tag(column, attributes, text, cell_width):
    """Build SVG text element based on content and style attributes"""
    text_tag_attributes = {
        'x': str(column * cell_width),
        'textLength': str(wcswidth(text) * cell_width),
    }
    if attributes['bold']:
        text_tag_attributes['font-weight'] = 'bold'

    if attributes['italics']:
        text_tag_attributes['font-style'] = 'italic'

    decoration = ''
    if attributes['underscore']:
        decoration = 'underline'
    if attributes['strikethrough']:
        decoration += ' line-through'
    if decoration:
        text_tag_attributes['text-decoration'] = decoration

    if attributes['color'].startswith('#'):
        text_tag_attributes['fill'] = attributes['color']
    else:
        text_tag_attributes['class'] = attributes['color']

    text_tag = etree.Element('text', text_tag_attributes)
    text_tag.text = text
    return text_tag

_make_text_tag(column=0, attributes={'color': 'red', 'bold': False, 'italics': False, 'underscore': False, 'strikethrough': False}, text='A', cell_width=8)

Selected Statement: if attributes['bold']:

Function Input:
column: 0
attributes: color: red
bold: no
italics: no
underscore: no
strikethrough: no
text: 'A'
cell_width: 8

Variable Values Before Statement:
attributes: color: red
bold: no
italics: no
underscore: no
strikethrough: no

Value After Statement Execution: No

Variable States During Runtime (line, value):
column: 1
0
attributes: 1
color: red
bold: no
italics: no
underscore: no
strikethrough: no
text: 1
'A'
cell_width: 1
8
text_tag_attributes: 3
x: 0
textLength: 8
24
x: 0
textLength: 8
class: red
decoration: 13
''
text_tag: 26
<Element text at 0x7ff5ea583680>
Project Name: Mikubill+sd-webui-controlnet
Language: Python
Statement Type: Branch

Source Code:
def digit_version(version_str: str, length: int = 4):
    """Convert a version string into a tuple of integers.

    This method is usually used for comparing two versions. For pre-release
    versions: alpha < beta < rc.

    Args:
        version_str (str): The version string.
        length (int): The maximum number of version levels. Default: 4.

    Returns:
        tuple[int]: The version info in digits (integers).
    """
    assert 'parrots' not in version_str
    version = parse(version_str)
    assert version.release, f'failed to parse version {version_str}'
    release = list(version.release)
    release = release[:length]
    if len(release) < length:
        release = release + [0] * (length - len(release))
    if version.is_prerelease:
        mapping = {'a': -3, 'b': -2, 'rc': -1}
        val = -4
        # version.pre can be None
        if version.pre:
            if version.pre[0] not in mapping:
                warnings.warn(f'unknown prerelease version {version.pre[0]}, '
                              'version checking may go wrong')
            else:
                val = mapping[version.pre[0]]
            release.extend([val, version.pre[-1]])
        else:
            release.extend([val, 0])

    elif version.is_postrelease:
        release.extend([1, version.post])
    else:
        release.extend([0, 0])
    return tuple(release)

digit_version(version_str='2.2.2+cu121', length=4)

Selected Statement: if len(release) < length:

Function Input:
version_str: '2.2.2+cu121'
length: 4

Variable Values Before Statement:
length: 4

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
version_str: 1
'2.2.2+cu121'
length: 1
4
version: 15
<Version('2.2.2+cu121')>
release: 17
[2, 2, 2]
20
[2, 2, 2, 0]
38
[2, 2, 2, 0, 0, 0]
Project Name: cloudtools+troposphere
Language: Python
Statement Type: Branch

Source Code:
def from_file(filepath, delimiter="", blanklines=False):
    """Imports userdata from a file.

    :type filepath: string

    :param filepath  The absolute path to the file.

    :type delimiter: string

    :param: delimiter  Delimiter to use with the troposphere.Join().

    :type blanklines: boolean

    :param blanklines  If blank lines should be ignored

    rtype: troposphere.Base64
    :return The base64 representation of the file.
    """
    data = []

    try:
        with open(filepath, "r") as f:
            for line in f:
                if blanklines and line.strip("\n\r ") == "":
                    continue

                data.append(line)
    except IOError:
        raise IOError("Error opening or reading file: {}".format(filepath))

    return Base64(Join(delimiter, data))

from_file(filepath='/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/cloudtools+troposphere/cloudtools+troposphere/tests/userdata_test_scripts/char_escaping.sh', delimiter='', blanklines=False)

Selected Statement: if blanklines and line.strip("\n\r ") == "":

Function Input:
filepath: '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/cloudtools+troposphere/cloudtools+troposphere/tests/userdata_test_scripts/char_escaping.sh'
delimiter: ''
blanklines: False

Variable Values Before Statement:
blanklines: False

Value After Statement Execution: No

Variable States During Runtime (line, value):
filepath: 1
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/cloudtools+troposphere/cloudtools+troposphere/tests/userdata_test_scripts/char_escaping.sh'
delimiter: 1
''
blanklines: 1
False
data: 19
27
\n

27
\n

\

27
\n

\

    

27
\n

\

    

?

27
\n

\

    

?

""

27
\n

\

    

?

""



27
\n

\

    

?

""



<>

f: 22
<_io.TextIOWrapper name='/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/cloudtools+troposphere/cloudtools+troposphere/tests/userdata_test_scripts/char_escaping.sh' mode='r' encoding='UTF-8'>
line: 23
'\\n\n'
23
'\\\n'
23
'    \n'
23
'?\n'
23
'""\n'
23
'\n'
23
'<>\n'
Project Name: d3rp+clima
Language: Python
Statement Type: Branch

Source Code:
def SeparateFlagArgs(args: list):
  """Splits a list of args into those for Flags and those for Fire.

  If an isolated '--' arg is not present in the arg list, then all of the args
  are for Fire. If there is an isolated '--', then the args after the final '--'
  are flag args, and the rest of the args are fire args.

  Args:
    args: The list of arguments received by the Fire command.
  Returns:
    A tuple with the Fire args (a list), followed by the Flag args (a list).
  """
  if len(args) > 0 and (args[-1] == '-h' or args[-1] == '--help') and '--' not in args:
    args.pop()
    args.append('--')
    args.append('-h')

  if '--' in args:
    separator_index = len(args) - 1 - args[::-1].index('--')  # index of last --
    flag_args = args[separator_index + 1:]
    args = args[:separator_index]
    return args, flag_args

  return args, []

SeparateFlagArgs(args=['a', 'b', '--'])

Selected Statement: if '--' in args:

Function Input:
args: a, b, --

Variable Values Before Statement:
args: a, b, --

Value After Statement Execution: Yes

Variable States During Runtime (line, value):
args: 1
a, b, --
21
a, b
separator_index: 19
2
flag_args: 20