Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code execute_plan>
  MAKE_FUNCTION defaults
  STORE_NAME execute_plan
  RETURN_CONST None
END
CODE execute_plan(plan)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + list
  CALL 0
  STORE_FAST execution_result
  LOAD_FAST plan
  GET_ITER
L1:
  EXTENDED_ARG 2
  FOR_ITER L14
  STORE_FAST task
  LOAD_FAST task
  LOAD_CONST 'action'
  BINARY_SUBSCR
  STORE_FAST action
  LOAD_FAST action
  LOAD_CONST 'delete'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L2
  LOAD_GLOBAL NULL + generate_delete_user_command
  LOAD_FAST task
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'username'
  CALL 1
  LOAD_FAST task
  LOAD_CONST 'manage_home'
  BINARY_SUBSCR
  KW_NAMES ('username', 'manage_home')
  CALL 2
  STORE_FAST command
  LOAD_GLOBAL NULL + execute_command
  LOAD_FAST command
  CALL 1
  STORE_FAST command_output
  LOAD_FAST execution_result
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + dict
  LOAD_FAST task
  LOAD_FAST command_output
  KW_NAMES ('task', 'command_output')
  CALL 2
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + remove_sudoers_entry
  LOAD_FAST task
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'username'
  CALL 1
  KW_NAMES ('username',)
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L2:
  LOAD_FAST action
  LOAD_CONST 'add'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L5
  LOAD_GLOBAL NULL + generate_add_user_command
  LOAD_FAST task
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'proposed_user'
  CALL 1
  LOAD_FAST task
  LOAD_CONST 'manage_home'
  BINARY_SUBSCR
  KW_NAMES ('proposed_user', 'manage_home')
  CALL 2
  STORE_FAST command
  LOAD_GLOBAL NULL + execute_command
  LOAD_FAST command
  CALL 1
  STORE_FAST command_output
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR public_keys
  POP_JUMP_IF_FALSE L3
  LOAD_FAST task
  LOAD_CONST 'manage_home'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L3
  LOAD_FAST task
  LOAD_CONST 'manage_keys'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L3
  LOAD_GLOBAL NULL + write_authorized_keys
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  CALL 1
  POP_TOP
L3:
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR sudoers_entry
  POP_JUMP_IF_FALSE L4
  LOAD_GLOBAL NULL + write_sudoers_entry
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR name
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR sudoers_entry
  KW_NAMES ('username', 'sudoers_entry')
  CALL 2
  POP_TOP
L4:
  LOAD_FAST execution_result
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + dict
  LOAD_FAST task
  LOAD_FAST command_output
  KW_NAMES ('task', 'command_output')
  CALL 2
  CALL 1
  POP_TOP
  EXTENDED_ARG 1
  JUMP_BACKWARD L1
L5:
  LOAD_FAST action
  LOAD_CONST 'update'
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L6
  EXTENDED_ARG 1
  JUMP_BACKWARD L1
L6:
  LOAD_FAST task
  LOAD_CONST 'user_comparison'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'result'
  CALL 1
  STORE_FAST result
  LOAD_CONST 0
  STORE_FAST action_count
  LOAD_GLOBAL NULL + iteritems
  LOAD_FAST result
  CALL 1
  GET_ITER
L7:
  FOR_ITER L9
  UNPACK_SEQUENCE 2
  STORE_FAST k
  STORE_FAST _
  LOAD_CONST '_action'
  LOAD_FAST k
  CONTAINS_OP 0
  POP_JUMP_IF_TRUE L8
  JUMP_BACKWARD L7
L8:
  LOAD_FAST action_count
  LOAD_CONST 1
  BINARY_OP +=
  STORE_FAST action_count
  JUMP_BACKWARD L7
L9:
  END_FOR
  LOAD_CONST None
  STORE_FAST command_output
  LOAD_FAST task
  LOAD_CONST 'manage_home'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L10
  LOAD_FAST task
  LOAD_CONST 'manage_keys'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L10
  LOAD_FAST action_count
  LOAD_CONST 1
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L10
  LOAD_CONST 'public_keys_action'
  LOAD_FAST result
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L10
  LOAD_GLOBAL NULL + write_authorized_keys
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  CALL 1
  POP_TOP
  JUMP_FORWARD L13
L10:
  LOAD_FAST action_count
  LOAD_CONST 1
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L11
  LOAD_CONST 'sudoers_entry_action'
  LOAD_FAST result
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L11
  LOAD_GLOBAL NULL + write_sudoers_entry
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR name
  LOAD_FAST task
  LOAD_CONST 'user_comparison'
  BINARY_SUBSCR
  LOAD_CONST 'result'
  BINARY_SUBSCR
  LOAD_CONST 'replacement_sudoers_entry'
  BINARY_SUBSCR
  KW_NAMES ('username', 'sudoers_entry')
  CALL 2
  POP_TOP
  JUMP_FORWARD L13
L11:
  LOAD_GLOBAL NULL + generate_modify_user_command
  LOAD_FAST task
  KW_NAMES ('task',)
  CALL 1
  STORE_FAST command
  LOAD_GLOBAL NULL + execute_command
  LOAD_FAST command
  CALL 1
  STORE_FAST command_output
  LOAD_FAST task
  LOAD_CONST 'manage_home'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L12
  LOAD_FAST task
  LOAD_CONST 'manage_keys'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L12
  LOAD_FAST result
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'public_keys_action'
  CALL 1
  POP_JUMP_IF_FALSE L12
  LOAD_GLOBAL NULL + write_authorized_keys
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  CALL 1
  POP_TOP
L12:
  LOAD_FAST result
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'sudoers_entry_action'
  CALL 1
  POP_JUMP_IF_FALSE L13
  LOAD_GLOBAL NULL + write_sudoers_entry
  LOAD_FAST task
  LOAD_CONST 'proposed_user'
  BINARY_SUBSCR
  LOAD_ATTR name
  LOAD_FAST task
  LOAD_CONST 'user_comparison'
  BINARY_SUBSCR
  LOAD_CONST 'result'
  BINARY_SUBSCR
  LOAD_CONST 'replacement_sudoers_entry'
  BINARY_SUBSCR
  KW_NAMES ('username', 'sudoers_entry')
  CALL 2
  POP_TOP
L13:
  LOAD_FAST execution_result
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + dict
  LOAD_FAST task
  LOAD_FAST command_output
  KW_NAMES ('task', 'command_output')
  CALL 2
  CALL 1
  POP_TOP
  EXTENDED_ARG 2
  JUMP_BACKWARD L1
L14:
  END_FOR
  RETURN_CONST None
END

def execute_plan(plan=None):
    """pass"""
    execution_result = list()
    for task in plan:
        action = task['action']
        if action == 'delete':
            command = generate_delete_user_command(username=task.get('username'), manage_home=task['manage_home'])
            command_output = execute_command(command)
            execution_result.append(dict(task=task, command_output=command_output))
            remove_sudoers_entry(username=task.get('username'))
        elif action == 'add':
            command = generate_add_user_command(proposed_user=task.get('proposed_user'), manage_home=task['manage_home'])
            command_output = execute_command(command)
            if task['proposed_user'].public_keys and task['manage_home'] and task['manage_keys']:
                write_authorized_keys(task['proposed_user'])
            if task['proposed_user'].sudoers_entry:
                write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['proposed_user'].sudoers_entry)
            execution_result.append(dict(task=task, command_output=command_output))
        elif action == 'update':
            result = task['user_comparison'].get('result')
            action_count = 0
            for k, _ in iteritems(result):
                if '_action' in k:
                    action_count += 1
            command_output = None
            if task['manage_home'] and task['manage_keys'] and (action_count == 1) and ('public_keys_action' in result):
                write_authorized_keys(task['proposed_user'])
            elif action_count == 1 and 'sudoers_entry_action' in result:
                write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['user_comparison']['result']['replacement_sudoers_entry'])
            else:
                command = generate_modify_user_command(task=task)
                command_output = execute_command(command)
                if task['manage_home'] and task['manage_keys'] and result.get('public_keys_action'):
                    write_authorized_keys(task['proposed_user'])
                if result.get('sudoers_entry_action'):
                    write_sudoers_entry(username=task['proposed_user'].name, sudoers_entry=task['user_comparison']['result']['replacement_sudoers_entry'])
            execution_result.append(dict(task=task, command_output=command_output))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code output>
  MAKE_FUNCTION 0
  STORE_NAME output
  RETURN_CONST None
END
CODE output(self, output, accepts, set_http_code, set_content_type)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL Decorator
  LOAD_ATTR NULL|self + _get_graph
  LOAD_FAST output
  CALL 1
  STORE_FAST graph
  LOAD_FAST graph
  POP_JUMP_IF_NONE L3
  LOAD_FAST self
  LOAD_ATTR format_selector
  LOAD_ATTR NULL|self + decide
  LOAD_FAST accepts
  LOAD_FAST graph
  LOAD_ATTR context_aware
  CALL 2
  UNPACK_SEQUENCE 2
  STORE_FAST output_mimetype
  STORE_FAST output_format
  LOAD_FAST output_mimetype
  POP_JUMP_IF_NOT_NONE L1
  PUSH_NULL
  LOAD_FAST set_http_code
  LOAD_CONST '406 Not Acceptable'
  CALL 1
  POP_TOP
  LOAD_CONST '406 Not Acceptable'
  LOAD_ATTR NULL|self + encode
  LOAD_CONST 'utf-8'
  CALL 1
  BUILD_LIST 1
  RETURN_VALUE
L1:
  LOAD_CONST 'text'
  LOAD_FAST output_mimetype
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L2
  LOAD_FAST output_mimetype
  LOAD_CONST '; charset=utf-8'
  BINARY_OP +
  STORE_FAST output_mimetype
L2:
  LOAD_FAST graph
  LOAD_ATTR NULL|self + serialize
  LOAD_FAST output_format
  KW_NAMES ('format',)
  CALL 1
  STORE_FAST serialized
  PUSH_NULL
  LOAD_FAST set_content_type
  LOAD_FAST output_mimetype
  CALL 1
  POP_TOP
  LOAD_FAST serialized
  BUILD_LIST 1
  RETURN_VALUE
L3:
  LOAD_FAST output
  RETURN_VALUE
END

def output(self, output, accepts, set_http_code, set_content_type):
    """pass"""
    graph = Decorator._get_graph(output)
    if graph is not None:
        output_mimetype, output_format = self.format_selector.decide(accepts, graph.context_aware)
        if output_mimetype is None:
            set_http_code('406 Not Acceptable')
            return ['406 Not Acceptable'.encode('utf-8')]
        if 'text' in output_mimetype:
            output_mimetype = output_mimetype + '; charset=utf-8'
        serialized = graph.serialize(format=output_format)
        set_content_type(output_mimetype)
        return [serialized]
    else:
        return output

code-search-net/code_search_net (python, train split)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code add>
  MAKE_FUNCTION 0
  STORE_NAME add
  RETURN_CONST None
END
CODE add(self, src)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + get_checksum
  LOAD_FAST src
  CALL 1
  STORE_FAST checksum
  LOAD_FAST self
  LOAD_ATTR NULL|self + get_filename
  LOAD_FAST checksum
  CALL 1
  STORE_FAST filename
  LOAD_FAST filename
  POP_JUMP_IF_TRUE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + _get_new_name
  CALL 0
  STORE_FAST new_name
  LOAD_FAST self
  LOAD_ATTR _storage_dir
  LOAD_CONST '/'
  BINARY_OP +
  LOAD_FAST new_name
  BINARY_OP +
  STORE_FAST new_realpath
  LOAD_GLOBAL os
  LOAD_ATTR NULL|self + makedirs
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + split
  LOAD_FAST new_realpath
  CALL 1
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST True
  KW_NAMES ('exist_ok',)
  CALL 2
  POP_TOP
  LOAD_GLOBAL shutil
  LOAD_ATTR NULL|self + copyfile
  LOAD_FAST src
  LOAD_FAST new_realpath
  CALL 2
  POP_TOP
  LOAD_FAST checksum
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + getmtime
  LOAD_FAST new_realpath
  CALL 1
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + getsize
  LOAD_FAST new_realpath
  CALL 1
  LOAD_CONST ('checksum', 'mtime', 'size')
  BUILD_CONST_KEY_MAP 3
  LOAD_FAST self
  LOAD_ATTR _log
  LOAD_FAST new_name
  STORE_SUBSCR
  LOAD_FAST self
  LOAD_ATTR NULL|self + write_log
  CALL 0
  POP_TOP
L1:
  LOAD_FAST checksum
  RETURN_VALUE
END

def add(self, src):
    """pass"""
    checksum = get_checksum(src)
    filename = self.get_filename(checksum)
    if not filename:
        new_name = self._get_new_name()
        new_realpath = self._storage_dir + '/' + new_name
        os.makedirs(os.path.split(new_realpath)[0], exist_ok=True)
        shutil.copyfile(src, new_realpath)
        self._log[new_name] = {'checksum': checksum, 'mtime': os.path.getmtime(new_realpath), 'size': os.path.getsize(new_realpath)}
        self.write_log()
    return checksum


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code schemas>
  MAKE_FUNCTION 0
  STORE_NAME schemas
  RETURN_CONST None
END
CODE schemas(self)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 'SELECT schema_name FROM information_schema.schemata\n                 ORDER BY schema_name'
  STORE_FAST sql
  LOAD_FAST self
  LOAD_ATTR NULL|self + query
  LOAD_FAST sql
  CALL 1
  LOAD_ATTR NULL|self + fetchall
  CALL 0
  STORE_FAST schemas
  LOAD_FAST schemas
  GET_ITER
  LOAD_FAST_AND_CLEAR s
  SWAP 2
L1:
  BUILD_LIST 0
  SWAP 2
L2:
  FOR_ITER L5
  STORE_FAST s
  LOAD_FAST s
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST None
  LOAD_CONST 3
  BINARY_SLICE
  LOAD_CONST 'pg_'
  COMPARE_OP !=
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST s
  LOAD_CONST 0
  BINARY_SUBSCR
  LIST_APPEND 2
  JUMP_BACKWARD L2
L5:
  END_FOR
L6:
  SWAP 2
  STORE_FAST s
  RETURN_VALUE
L7:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST s
  RERAISE 0
  EXC try=L1..L3 -> handler=L7 depth=2 lasti=False
  EXC try=L4..L6 -> handler=L7 depth=2 lasti=False
END

def schemas(self):
    """pass"""
    sql = 'SELECT schema_name FROM information_schema.schemata\n                 ORDER BY schema_name'
    schemas = self.query(sql).fetchall()
    return [s[0] for s in schemas if s[0][:3] != 'pg_']


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code tables>
  MAKE_FUNCTION 0
  STORE_NAME tables
  RETURN_CONST None
END
CODE tables(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR schema
  POP_JUMP_IF_FALSE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + tables_in_schema
  LOAD_FAST self
  LOAD_ATTR schema
  CALL 1
  RETURN_VALUE
L1:
  BUILD_LIST 0
  STORE_FAST tables
  LOAD_FAST self
  LOAD_ATTR schemas
  GET_ITER
L2:
  FOR_ITER L7
  STORE_FAST schema
  LOAD_FAST tables
  LOAD_FAST self
  LOAD_ATTR NULL|self + tables_in_schema
  LOAD_FAST schema
  CALL 1
  GET_ITER
  LOAD_FAST_AND_CLEAR t
  SWAP 2
L3:
  BUILD_LIST 0
  SWAP 2
L4:
  FOR_ITER L5
  STORE_FAST t
  LOAD_FAST schema
  LOAD_CONST '.'
  BINARY_OP +
  LOAD_FAST t
  BINARY_OP +
  LIST_APPEND 2
  JUMP_BACKWARD L4
L5:
  END_FOR
L6:
  SWAP 2
  STORE_FAST t
  BINARY_OP +
  STORE_FAST tables
  JUMP_BACKWARD L2
L7:
  END_FOR
  LOAD_FAST tables
  RETURN_VALUE
L8:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST t
  RERAISE 0
  EXC try=L3..L6 -> handler=L8 depth=4 lasti=False
END

def tables(self):
    """pass"""
    if self.schema:
        return self.tables_in_schema(self.schema)
    else:
        tables = []
        for schema in self.schemas:
            tables = tables + [schema + '.' + t for t in self.tables_in_schema(schema)]
        return tables


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _valid_table_name>
  MAKE_FUNCTION 0
  STORE_NAME _valid_table_name
  RETURN_CONST None
END
CODE _valid_table_name(self, table)
  DOC 'pass'
  RESUME 0
  LOAD_FAST table
  POP_JUMP_IF_NONE L1
  LOAD_GLOBAL NULL + len
  LOAD_FAST table
  LOAD_ATTR NULL|self + strip
  CALL 0
  CALL 1
  POP_JUMP_IF_TRUE L2
L1:
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'Invalid table name: %r'
  LOAD_FAST table
  BINARY_OP %
  CALL 1
  RAISE_VARARGS 1
L2:
  LOAD_FAST table
  LOAD_ATTR NULL|self + strip
  CALL 0
  RETURN_VALUE
END

def _valid_table_name(self, table):
    """pass"""
    if table is None or not len(table.strip()):
        raise ValueError('Invalid table name: %r' % table)
    return table.strip()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code build_query>
  MAKE_FUNCTION 0
  STORE_NAME build_query
  RETURN_CONST None
END
CODE build_query(self, sql, lookup)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL six
  LOAD_ATTR NULL|self + iteritems
  LOAD_FAST lookup
  CALL 1
  GET_ITER
L1:
  FOR_ITER L2
  UNPACK_SEQUENCE 2
  STORE_FAST key
  STORE_FAST val
  LOAD_FAST sql
  LOAD_ATTR NULL|self + replace
  LOAD_CONST '$'
  LOAD_FAST key
  BINARY_OP +
  LOAD_FAST val
  CALL 2
  STORE_FAST sql
  JUMP_BACKWARD L1
L2:
  END_FOR
  LOAD_FAST sql
  RETURN_VALUE
END

def build_query(self, sql, lookup):
    """pass"""
    for key, val in six.iteritems(lookup):
        sql = sql.replace('$' + key, val)
    return sql


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code tables_in_schema>
  MAKE_FUNCTION 0
  STORE_NAME tables_in_schema
  RETURN_CONST None
END
CODE tables_in_schema(self, schema)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 'SELECT table_name\n                 FROM information_schema.tables\n                 WHERE table_schema = %s'
  STORE_FAST sql
  LOAD_FAST self
  LOAD_ATTR NULL|self + query
  LOAD_FAST sql
  LOAD_FAST schema
  BUILD_TUPLE 1
  CALL 2
  LOAD_ATTR NULL|self + fetchall
  CALL 0
  GET_ITER
  LOAD_FAST_AND_CLEAR t
  SWAP 2
L1:
  BUILD_LIST 0
  SWAP 2
L2:
  FOR_ITER L3
  STORE_FAST t
  LOAD_FAST t
  LOAD_CONST 0
  BINARY_SUBSCR
  LIST_APPEND 2
  JUMP_BACKWARD L2
L3:
  END_FOR
L4:
  SWAP 2
  STORE_FAST t
  RETURN_VALUE
L5:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST t
  RERAISE 0
  EXC try=L1..L4 -> handler=L5 depth=2 lasti=False
END

def tables_in_schema(self, schema):
    """pass"""
    sql = 'SELECT table_name\n                 FROM information_schema.tables\n                 WHERE table_schema = %s'
    return [t[0] for t in self.query(sql, (schema,)).fetchall()]


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code parse_table_name>
  MAKE_FUNCTION 0
  STORE_NAME parse_table_name
  RETURN_CONST None
END
CODE parse_table_name(self, table)
  DOC 'pass'
  RESUME 0
  LOAD_CONST '.'
  LOAD_FAST table
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L1
  LOAD_FAST table
  LOAD_ATTR NULL|self + split
  LOAD_CONST '.'
  CALL 1
  UNPACK_SEQUENCE 2
  STORE_FAST schema
  STORE_FAST table
  LOAD_FAST schema
  LOAD_FAST table
  BUILD_TUPLE 2
  RETURN_VALUE
L1:
  LOAD_CONST None
  STORE_FAST schema
  LOAD_FAST schema
  LOAD_FAST table
  BUILD_TUPLE 2
  RETURN_VALUE
END

def parse_table_name(self, table):
    """pass"""
    if '.' in table:
        schema, table = table.split('.')
    else:
        schema = None
    return (schema, table)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code read_authorized_keys>
  MAKE_FUNCTION defaults
  STORE_NAME read_authorized_keys
  RETURN_CONST None
END
CODE read_authorized_keys(username)
  DOC 'pass'
  RESUME 0
  LOAD_CONST '{0}/.ssh/authorized_keys'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + expanduser
  LOAD_CONST '~{0}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST username
  CALL 1
  CALL 1
  CALL 1
  STORE_FAST authorized_keys_path
  LOAD_GLOBAL NULL + random_string
  LOAD_GLOBAL RANDOM_FILE_EXT_LENGTH
  KW_NAMES ('length',)
  CALL 1
  STORE_FAST rnd_chars
  LOAD_CONST '/tmp/authorized_keys_{0}_{1}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST username
  LOAD_FAST rnd_chars
  CALL 2
  STORE_FAST tmp_authorized_keys_path
  LOAD_GLOBAL NULL + list
  CALL 0
  STORE_FAST authorized_keys
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} cp {1} {2}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST authorized_keys_path
  LOAD_FAST tmp_authorized_keys_path
  CALL 3
  CALL 1
  CALL 1
  CALL 1
  STORE_FAST copy_result
  LOAD_FAST copy_result
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST 1
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + decode
  LOAD_CONST 'UTF-8'
  CALL 1
  STORE_FAST result_message
  LOAD_CONST 'you must have a tty to run sudo'
  LOAD_FAST result_message
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + OSError
  LOAD_CONST "/etc/sudoers is blocked sudo. Remove entry: 'Defaults    requiretty'."
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_CONST 'No such file or directory'
  LOAD_FAST result_message
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L7
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} chmod 755 {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST tmp_authorized_keys_path
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + open
  LOAD_FAST tmp_authorized_keys_path
  CALL 1
  BEFORE_WITH
L2:
  STORE_FAST keys_file
  LOAD_FAST keys_file
  GET_ITER
L3:
  FOR_ITER L4
  STORE_FAST key
  LOAD_FAST authorized_keys
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + PublicKey
  LOAD_FAST key
  KW_NAMES ('raw',)
  CALL 1
  CALL 1
  POP_TOP
  JUMP_BACKWARD L3
L4:
  END_FOR
L5:
  NOP
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
L6:
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} rm {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST tmp_authorized_keys_path
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
L7:
  LOAD_FAST authorized_keys
  RETURN_VALUE
L8:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L9
  RERAISE 2
L9:
  POP_TOP
L10:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  JUMP_BACKWARD L6
L11:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L5 -> handler=L8 depth=1 lasti=True
  EXC try=L8..L10 -> handler=L11 depth=3 lasti=True
END

def read_authorized_keys(username=None):
    """pass"""
    authorized_keys_path = '{0}/.ssh/authorized_keys'.format(os.path.expanduser('~{0}'.format(username)))
    rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH)
    tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(username, rnd_chars)
    authorized_keys = list()
    copy_result = execute_command(shlex.split(str('{0} cp {1} {2}'.format(sudo_check(), authorized_keys_path, tmp_authorized_keys_path))))
    result_message = copy_result[0][1].decode('UTF-8')
    if 'you must have a tty to run sudo' in result_message:
        raise OSError("/etc/sudoers is blocked sudo. Remove entry: 'Defaults    requiretty'.")
    elif 'No such file or directory' not in result_message:
        execute_command(shlex.split(str('{0} chmod 755 {1}'.format(sudo_check(), tmp_authorized_keys_path))))
        with open(tmp_authorized_keys_path) as keys_file:
            for key in keys_file:
                authorized_keys.append(PublicKey(raw=key))
        execute_command(shlex.split(str('{0} rm {1}'.format(sudo_check(), tmp_authorized_keys_path))))
    return authorized_keys


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code write_authorized_keys>
  MAKE_FUNCTION defaults
  STORE_NAME write_authorized_keys
  RETURN_CONST None
END
CODE write_authorized_keys(user)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + list
  CALL 0
  STORE_FAST authorized_keys
  LOAD_CONST '{0}/.ssh'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + expanduser
  LOAD_CONST '~{0}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST user
  LOAD_ATTR name
  CALL 1
  CALL 1
  CALL 1
  STORE_FAST authorized_keys_dir
  LOAD_GLOBAL NULL + random_string
  LOAD_GLOBAL RANDOM_FILE_EXT_LENGTH
  KW_NAMES ('length',)
  CALL 1
  STORE_FAST rnd_chars
  LOAD_CONST '{0}/authorized_keys'
  LOAD_ATTR NULL|self + format
  LOAD_FAST authorized_keys_dir
  CALL 1
  STORE_FAST authorized_keys_path
  LOAD_CONST '/tmp/authorized_keys_{0}_{1}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST user
  LOAD_ATTR name
  LOAD_FAST rnd_chars
  CALL 2
  STORE_FAST tmp_authorized_keys_path
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + isdir
  LOAD_FAST authorized_keys_dir
  CALL 1
  POP_JUMP_IF_TRUE L1
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} mkdir -p {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST authorized_keys_dir
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
L1:
  LOAD_FAST user
  LOAD_ATTR public_keys
  GET_ITER
L2:
  FOR_ITER L3
  STORE_FAST key
  LOAD_FAST authorized_keys
  LOAD_ATTR NULL|self + append
  LOAD_CONST '{0}\n'
  LOAD_ATTR NULL|self + format
  LOAD_FAST key
  LOAD_ATTR raw
  CALL 1
  CALL 1
  POP_TOP
  JUMP_BACKWARD L2
L3:
  END_FOR
  LOAD_GLOBAL NULL + open
  LOAD_FAST tmp_authorized_keys_path
  LOAD_GLOBAL NULL + text_type
  LOAD_CONST 'w+'
  CALL 1
  KW_NAMES ('mode',)
  CALL 2
  BEFORE_WITH
L4:
  STORE_FAST keys_file
  LOAD_FAST keys_file
  LOAD_ATTR NULL|self + writelines
  LOAD_FAST authorized_keys
  CALL 1
  POP_TOP
L5:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
L6:
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} cp {1} {2}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST tmp_authorized_keys_path
  LOAD_FAST authorized_keys_path
  CALL 3
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} chown -R {1} {2}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST user
  LOAD_ATTR name
  LOAD_FAST authorized_keys_dir
  CALL 3
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} chmod 700 {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST authorized_keys_dir
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} chmod 600 {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST authorized_keys_path
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + execute_command
  LOAD_GLOBAL shlex
  LOAD_ATTR NULL|self + split
  LOAD_GLOBAL NULL + str
  LOAD_CONST '{0} rm {1}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL NULL + sudo_check
  CALL 0
  LOAD_FAST tmp_authorized_keys_path
  CALL 2
  CALL 1
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L7:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L8
  RERAISE 2
L8:
  POP_TOP
L9:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  EXTENDED_ARG 1
  JUMP_BACKWARD L6
L10:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L4..L5 -> handler=L7 depth=1 lasti=True
  EXC try=L7..L9 -> handler=L10 depth=3 lasti=True
END

def write_authorized_keys(user=None):
    """pass"""
    authorized_keys = list()
    authorized_keys_dir = '{0}/.ssh'.format(os.path.expanduser('~{0}'.format(user.name)))
    rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH)
    authorized_keys_path = '{0}/authorized_keys'.format(authorized_keys_dir)
    tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(user.name, rnd_chars)
    if not os.path.isdir(authorized_keys_dir):
        execute_command(shlex.split(str('{0} mkdir -p {1}'.format(sudo_check(), authorized_keys_dir))))
    for key in user.public_keys:
        authorized_keys.append('{0}\n'.format(key.raw))
    with open(tmp_authorized_keys_path, mode=text_type('w+')) as keys_file:
        keys_file.writelines(authorized_keys)
    execute_command(shlex.split(str('{0} cp {1} {2}'.format(sudo_check(), tmp_authorized_keys_path, authorized_keys_path))))
    execute_command(shlex.split(str('{0} chown -R {1} {2}'.format(sudo_check(), user.name, authorized_keys_dir))))
    execute_command(shlex.split(str('{0} chmod 700 {1}'.format(sudo_check(), authorized_keys_dir))))
    execute_command(shlex.split(str('{0} chmod 600 {1}'.format(sudo_check(), authorized_keys_path))))
    execute_command(shlex.split(str('{0} rm {1}'.format(sudo_check(), tmp_authorized_keys_path))))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code b64encoded>
  MAKE_FUNCTION 0
  STORE_NAME b64encoded
  RETURN_CONST None
END
CODE b64encoded(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _b64encoded
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + text_type
  LOAD_FAST self
  LOAD_ATTR _b64encoded
  CALL 1
  LOAD_ATTR NULL|self + strip
  LOAD_CONST '\r\n'
  CALL 1
  RETURN_VALUE
L1:
  LOAD_GLOBAL NULL + base64encode
  LOAD_FAST self
  LOAD_ATTR raw
  CALL 1
  RETURN_VALUE
END

def b64encoded(self):
    """pass"""
    if self._b64encoded:
        return text_type(self._b64encoded).strip('\r\n')
    else:
        return base64encode(self.raw)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code raw>
  MAKE_FUNCTION 0
  STORE_NAME raw
  RETURN_CONST None
END
CODE raw(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _raw
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + text_type
  LOAD_FAST self
  LOAD_ATTR _raw
  CALL 1
  LOAD_ATTR NULL|self + strip
  LOAD_CONST '\r\n'
  CALL 1
  RETURN_VALUE
L1:
  LOAD_GLOBAL NULL + text_type
  LOAD_GLOBAL NULL + base64decode
  LOAD_FAST self
  LOAD_ATTR _b64encoded
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + strip
  LOAD_CONST '\r\n'
  CALL 1
  RETURN_VALUE
END

def raw(self):
    """pass"""
    if self._raw:
        return text_type(self._raw).strip('\r\n')
    else:
        return text_type(base64decode(self._b64encoded)).strip('\r\n')


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (False,)
  LOAD_CONST <code add_format>
  MAKE_FUNCTION defaults
  STORE_NAME add_format
  RETURN_CONST None
END
CODE add_format(mimetype, format, requires_context)
  DOC 'pass'
  RESUME 0
  LOAD_FAST format
  LOAD_GLOBAL formats
  LOAD_FAST mimetype
  STORE_SUBSCR
  LOAD_FAST requires_context
  POP_JUMP_IF_TRUE L1
  LOAD_GLOBAL ctxless_mimetypes
  LOAD_ATTR NULL|self + append
  LOAD_FAST mimetype
  CALL 1
  POP_TOP
L1:
  LOAD_GLOBAL all_mimetypes
  LOAD_ATTR NULL|self + append
  LOAD_FAST mimetype
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def add_format(mimetype, format, requires_context=False):
    """pass"""
    global formats
    global ctxless_mimetypes
    global all_mimetypes
    formats[mimetype] = format
    if not requires_context:
        ctxless_mimetypes.append(mimetype)
    all_mimetypes.append(mimetype)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (False,)
  LOAD_CONST <code add_format>
  MAKE_FUNCTION defaults
  STORE_NAME add_format
  RETURN_CONST None
END
CODE add_format(self, mimetype, format, requires_context)
  DOC 'pass'
  RESUME 0
  LOAD_FAST format
  LOAD_FAST self
  LOAD_ATTR formats
  LOAD_FAST mimetype
  STORE_SUBSCR
  LOAD_FAST requires_context
  POP_JUMP_IF_TRUE L1
  LOAD_FAST self
  LOAD_ATTR ctxless_mimetypes
  LOAD_ATTR NULL|self + append
  LOAD_FAST mimetype
  CALL 1
  POP_TOP
L1:
  LOAD_FAST self
  LOAD_ATTR all_mimetypes
  LOAD_ATTR NULL|self + append
  LOAD_FAST mimetype
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def add_format(self, mimetype, format, requires_context=False):
    """pass"""
    self.formats[mimetype] = format
    if not requires_context:
        self.ctxless_mimetypes.append(mimetype)
    self.all_mimetypes.append(mimetype)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code get_default_mimetype>
  MAKE_FUNCTION 0
  STORE_NAME get_default_mimetype
  RETURN_CONST None
END
CODE get_default_mimetype(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR default_mimetype
  STORE_FAST mimetype
  LOAD_FAST mimetype
  POP_JUMP_IF_NOT_NONE L1
  LOAD_GLOBAL DEFAULT_MIMETYPE
  STORE_FAST mimetype
L1:
  LOAD_FAST mimetype
  POP_JUMP_IF_NOT_NONE L2
  LOAD_CONST 'application/rdf+xml'
  STORE_FAST mimetype
L2:
  LOAD_FAST mimetype
  RETURN_VALUE
END

def get_default_mimetype(self):
    """pass"""
    mimetype = self.default_mimetype
    if mimetype is None:
        mimetype = DEFAULT_MIMETYPE
    if mimetype is None:
        mimetype = 'application/rdf+xml'
    return mimetype


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST 1
  LOAD_CONST 1
  LOAD_CONST 2
  LOAD_NAME HTTP_STATUS_CODES_TO_RETRY
  LOAD_CONST <code <lambda>>
  MAKE_FUNCTION 0
  LOAD_CONST ('retries', 'interval', 'backoff', 'http_status_codes_to_retry', 'fn')
  BUILD_CONST_KEY_MAP 5
  LOAD_CONST <code send_http>
  MAKE_FUNCTION kwdefaults
  STORE_NAME send_http
  RETURN_CONST None
END
CODE <lambda>(x)
  RESUME 0
  LOAD_FAST x
  RETURN_VALUE
END
CODE send_http(session, method, url, *, retries, interval, backoff, http_status_codes_to_retry, fn, **kwargs)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST interval
  STORE_FAST backoff_interval
  LOAD_CONST None
  STORE_FAST raised_exc
  LOAD_CONST 0
  STORE_FAST attempt
  LOAD_FAST method
  LOAD_CONST ('get', 'patch', 'post')
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L2
  LOAD_GLOBAL ValueError
  RAISE_VARARGS 1
L2:
  LOAD_FAST retries
  LOAD_CONST -1
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L3
  LOAD_CONST -1
  STORE_FAST attempt
  JUMP_FORWARD L5
L3:
  LOAD_FAST retries
  LOAD_CONST 0
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L4
  LOAD_CONST 1
  STORE_FAST attempt
  JUMP_FORWARD L5
L4:
  LOAD_FAST retries
  LOAD_CONST 1
  BINARY_OP +
  STORE_FAST attempt
L5:
  LOAD_FAST attempt
  LOAD_CONST 0
  COMPARE_OP !=
  EXTENDED_ARG 1
  POP_JUMP_IF_FALSE L34
L6:
  LOAD_FAST raised_exc
  POP_JUMP_IF_FALSE L11
  LOAD_GLOBAL logger
  LOAD_ATTR NULL|self + error
  LOAD_CONST 'Caught "%s" url:%s method:%s, remaining tries %s, sleeping %.2fsecs'
  LOAD_FAST raised_exc
  LOAD_FAST method
  LOAD_ATTR NULL|self + upper
  CALL 0
  LOAD_FAST url
  LOAD_FAST attempt
  LOAD_FAST backoff_interval
  CALL 6
  POP_TOP
  LOAD_GLOBAL asyncio
  LOAD_ATTR NULL|self + sleep
  LOAD_FAST backoff_interval
  CALL 1
  GET_AWAITABLE 0
  LOAD_CONST None
L7:
  SEND L10
L8:
  YIELD_VALUE 2
L9:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L7
L10:
  END_SEND
  POP_TOP
  LOAD_FAST backoff_interval
  LOAD_FAST backoff
  BINARY_OP *=
  STORE_FAST backoff_interval
L11:
  NOP
L12:
  PUSH_NULL
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST session
  LOAD_FAST method
  CALL 2
  LOAD_FAST url
  BUILD_TUPLE 1
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  GET_AWAITABLE 0
  LOAD_CONST None
L13:
  SEND L16
L14:
  YIELD_VALUE 3
L15:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L13
L16:
  END_SEND
  BEFORE_ASYNC_WITH
  GET_AWAITABLE 1
  LOAD_CONST None
L17:
  SEND L20
L18:
  YIELD_VALUE 3
L19:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L17
L20:
  END_SEND
L21:
  STORE_FAST response
  LOAD_FAST response
  LOAD_ATTR status
  LOAD_CONST 200
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L32
  PUSH_NULL
  LOAD_FAST fn
  LOAD_FAST response
  CALL 1
  GET_AWAITABLE 0
  LOAD_CONST None
L22:
  SEND L25
L23:
  YIELD_VALUE 4
L24:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L22
L25:
  END_SEND
L26:
  SWAP 2
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  GET_AWAITABLE 2
  LOAD_CONST None
L27:
  SEND L30
L28:
  YIELD_VALUE 3
L29:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L27
L30:
  END_SEND
  POP_TOP
L31:
  RETURN_VALUE
L32:
  LOAD_FAST response
  LOAD_ATTR status
  LOAD_FAST http_status_codes_to_retry
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L33
  LOAD_GLOBAL logger
  LOAD_ATTR NULL|self + error
  LOAD_CONST 'Received invalid response code:%s error:%s response:%s url:%s'
  LOAD_FAST response
  LOAD_ATTR status
  LOAD_CONST ''
  LOAD_FAST response
  LOAD_ATTR reason
  LOAD_FAST url
  CALL 5
  POP_TOP
  LOAD_GLOBAL aiohttp
  LOAD_ATTR NULL|self + ClientResponseError
  LOAD_FAST response
  LOAD_ATTR status
  LOAD_FAST response
  LOAD_ATTR reason
  LOAD_FAST response
  LOAD_ATTR request_info
  LOAD_FAST response
  LOAD_ATTR history
  KW_NAMES ('code', 'message', 'request_info', 'history')
  CALL 4
  RAISE_VARARGS 1
L33:
  LOAD_GLOBAL NULL + FailedRequest
  LOAD_FAST response
  LOAD_ATTR status
  LOAD_CONST 'Non-retryable response code'
  LOAD_CONST 'aiohttp.ClientResponseError'
  LOAD_FAST url
  KW_NAMES ('code', 'message', 'raised', 'url')
  CALL 4
  RAISE_VARARGS 1
L34:
  LOAD_FAST raised_exc
  POP_JUMP_IF_FALSE L35
  LOAD_FAST raised_exc
  RAISE_VARARGS 1
L35:
  RETURN_CONST None
L36:
  CLEANUP_THROW
L37:
  JUMP_BACKWARD L10
L38:
  CLEANUP_THROW
L39:
  JUMP_BACKWARD L16
L40:
  CLEANUP_THROW
L41:
  JUMP_BACKWARD L20
L42:
  CLEANUP_THROW
L43:
  JUMP_BACKWARD L25
L44:
  CLEANUP_THROW
L45:
  JUMP_BACKWARD L30
L46:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  GET_AWAITABLE 2
  LOAD_CONST None
L47:
  SEND L51
L48:
  YIELD_VALUE 4
L49:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L47
L50:
  CLEANUP_THROW
L51:
  END_SEND
  POP_JUMP_IF_TRUE L52
  RERAISE 2
L52:
  POP_TOP
L53:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  JUMP_FORWARD L55
L54:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L55:
  NOP
L56:
  LOAD_CONST None
  STORE_FAST raised_exc
  JUMP_BACKWARD L34
L57:
  PUSH_EXC_INFO
  LOAD_GLOBAL aiohttp
  LOAD_ATTR ClientError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L68
  STORE_FAST exc
L58:
  NOP
L59:
  LOAD_FAST exc
  LOAD_ATTR code
  STORE_FAST code
L60:
  JUMP_FORWARD L65
L61:
  PUSH_EXC_INFO
  LOAD_GLOBAL AttributeError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L63
  POP_TOP
  LOAD_CONST ''
  STORE_FAST code
L62:
  POP_EXCEPT
  JUMP_FORWARD L65
L63:
  RERAISE 0
L64:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L65:
  LOAD_GLOBAL NULL + FailedRequest
  LOAD_FAST code
  LOAD_FAST exc
  LOAD_FAST exc
  LOAD_ATTR __class__
  LOAD_ATTR __module__
  FORMAT_VALUE str
  LOAD_CONST '.'
  LOAD_FAST exc
  LOAD_ATTR __class__
  LOAD_ATTR __qualname__
  FORMAT_VALUE str
  BUILD_STRING 3
  LOAD_FAST url
  KW_NAMES ('code', 'message', 'raised', 'url')
  CALL 4
  STORE_FAST raised_exc
L66:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  JUMP_FORWARD L74
L67:
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RERAISE 1
L68:
  LOAD_GLOBAL asyncio
  LOAD_ATTR TimeoutError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L72
  STORE_FAST exc
L69:
  LOAD_GLOBAL NULL + FailedRequest
  LOAD_CONST ''
  LOAD_CONST 'asyncio.TimeoutError'
  LOAD_FAST exc
  LOAD_ATTR __class__
  LOAD_ATTR __module__
  FORMAT_VALUE str
  LOAD_CONST '.'
  LOAD_FAST exc
  LOAD_ATTR __class__
  LOAD_ATTR __qualname__
  FORMAT_VALUE str
  BUILD_STRING 3
  LOAD_FAST url
  KW_NAMES ('code', 'message', 'raised', 'url')
  CALL 4
  STORE_FAST raised_exc
L70:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  JUMP_FORWARD L74
L71:
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RERAISE 1
L72:
  RERAISE 0
L73:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L74:
  LOAD_FAST attempt
  LOAD_CONST 1
  BINARY_OP -=
  STORE_FAST attempt
  LOAD_FAST attempt
  LOAD_CONST 0
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L76
L75:
  EXTENDED_ARG 2
  JUMP_BACKWARD L6
L76:
  EXTENDED_ARG 1
  JUMP_BACKWARD L34
L77:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L8 -> handler=L77 depth=0 lasti=True
  EXC try=L8..L9 -> handler=L36 depth=2 lasti=False
  EXC try=L9..L11 -> handler=L77 depth=0 lasti=True
  EXC try=L12..L14 -> handler=L57 depth=0 lasti=False
  EXC try=L14..L15 -> handler=L38 depth=2 lasti=False
  EXC try=L15..L18 -> handler=L57 depth=0 lasti=False
  EXC try=L18..L19 -> handler=L40 depth=3 lasti=False
  EXC try=L19..L21 -> handler=L57 depth=0 lasti=False
  EXC try=L21..L23 -> handler=L46 depth=1 lasti=True
  EXC try=L23..L24 -> handler=L42 depth=3 lasti=False
  EXC try=L24..L26 -> handler=L46 depth=1 lasti=True
  EXC try=L26..L28 -> handler=L57 depth=0 lasti=False
  EXC try=L28..L29 -> handler=L44 depth=3 lasti=False
  EXC try=L29..L31 -> handler=L57 depth=0 lasti=False
  EXC try=L31..L32 -> handler=L77 depth=0 lasti=True
  EXC try=L32..L34 -> handler=L46 depth=1 lasti=True
  EXC try=L34..L37 -> handler=L77 depth=0 lasti=True
  EXC try=L38..L39 -> handler=L57 depth=0 lasti=False
  EXC try=L40..L41 -> handler=L57 depth=0 lasti=False
  EXC try=L42..L43 -> handler=L46 depth=1 lasti=True
  EXC try=L44..L45 -> handler=L57 depth=0 lasti=False
  EXC try=L46..L48 -> handler=L54 depth=3 lasti=True
  EXC try=L48..L49 -> handler=L50 depth=6 lasti=False
  EXC try=L49..L53 -> handler=L54 depth=3 lasti=True
  EXC try=L53..L55 -> handler=L57 depth=0 lasti=False
  EXC try=L56..L57 -> handler=L77 depth=0 lasti=True
  EXC try=L57..L58 -> handler=L73 depth=1 lasti=True
  EXC try=L59..L60 -> handler=L61 depth=1 lasti=False
  EXC try=L60..L61 -> handler=L67 depth=1 lasti=True
  EXC try=L61..L62 -> handler=L64 depth=2 lasti=True
  EXC try=L62..L63 -> handler=L67 depth=1 lasti=True
  EXC try=L63..L64 -> handler=L64 depth=2 lasti=True
  EXC try=L64..L66 -> handler=L67 depth=1 lasti=True
  EXC try=L66..L67 -> handler=L77 depth=0 lasti=True
  EXC try=L67..L69 -> handler=L73 depth=1 lasti=True
  EXC try=L69..L70 -> handler=L71 depth=1 lasti=True
  EXC try=L70..L71 -> handler=L77 depth=0 lasti=True
  EXC try=L71..L73 -> handler=L73 depth=1 lasti=True
  EXC try=L73..L75 -> handler=L77 depth=0 lasti=True
END

async def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x: x, **kwargs):
    """pass"""
    backoff_interval = interval
    raised_exc = None
    attempt = 0
    if method not in ['get', 'patch', 'post']:
        raise ValueError
    if retries == -1:
        attempt = -1
    elif retries == 0:
        attempt = 1
    else:
        attempt = retries + 1
    while attempt != 0:
        if raised_exc:
            logger.error('Caught "%s" url:%s method:%s, remaining tries %s, sleeping %.2fsecs', raised_exc, method.upper(), url, attempt, backoff_interval)
            await asyncio.sleep(backoff_interval)
            backoff_interval *= backoff
        try:
            async with await getattr(session, method)(url, **kwargs) as response:
                if response.status == 200:
                    return await fn(response)
                elif response.status in http_status_codes_to_retry:
                    logger.error('Received invalid response code:%s error:%s response:%s url:%s', response.status, '', response.reason, url)
                    raise aiohttp.ClientResponseError(code=response.status, message=response.reason, request_info=response.request_info, history=response.history)
                else:
                    raise FailedRequest(code=response.status, message='Non-retryable response code', raised='aiohttp.ClientResponseError', url=url)
        except aiohttp.ClientError as exc:
            try:
                code = exc.code
            except AttributeError:
                code = ''
            raised_exc = FailedRequest(code=code, message=exc, raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)
        except asyncio.TimeoutError as exc:
            raised_exc = FailedRequest(code='', message='asyncio.TimeoutError', raised='%s.%s' % (exc.__class__.__module__, exc.__class__.__qualname__), url=url)
        else:
            raised_exc = None
            break
        attempt -= 1
    if raised_exc:
        raise raised_exc


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code generate_output>
  MAKE_FUNCTION 0
  STORE_NAME generate_output
  RETURN_CONST None
END
CODE generate_output(self, writer)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + codecs_open
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + join
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + dirname
  LOAD_GLOBAL __file__
  CALL 1
  LOAD_CONST 'sitemap-stylesheet.xsl'
  CALL 2
  LOAD_CONST 'r'
  LOAD_CONST 'utf-8'
  KW_NAMES ('encoding',)
  CALL 3
  BEFORE_WITH
L1:
  STORE_FAST fd_origin
  LOAD_GLOBAL NULL + codecs_open
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + join
  LOAD_FAST self
  LOAD_ATTR path_output
  LOAD_CONST 'sitemap-stylesheet.xsl'
  CALL 2
  LOAD_CONST 'w'
  LOAD_CONST 'utf-8'
  KW_NAMES ('encoding',)
  CALL 3
  BEFORE_WITH
L2:
  STORE_FAST fd_destination
  LOAD_FAST fd_origin
  LOAD_ATTR NULL|self + read
  CALL 0
  STORE_FAST xsl
  LOAD_FAST xsl
  LOAD_ATTR NULL|self + replace
  LOAD_CONST '{{ SITENAME }}'
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'SITENAME'
  CALL 1
  CALL 2
  STORE_FAST xsl
  LOAD_FAST fd_destination
  LOAD_ATTR NULL|self + write
  LOAD_FAST xsl
  CALL 1
  POP_TOP
L3:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
L4:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
L5:
  LOAD_CONST ''
  STORE_FAST urls
  LOAD_GLOBAL NULL + sorted
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_CONST 'articles'
  BINARY_SUBSCR
  LOAD_FAST self
  LOAD_ATTR __get_date_key
  LOAD_CONST True
  KW_NAMES ('key', 'reverse')
  CALL 3
  STORE_FAST articles_sorted
  LOAD_GLOBAL NULL + list
  LOAD_GLOBAL NULL + filter
  LOAD_CONST <code generate_output.<locals>.<lambda>>
  MAKE_FUNCTION 0
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'pages'
  CALL 1
  CALL 2
  CALL 1
  STORE_FAST pages_with_date
  LOAD_GLOBAL NULL + sorted
  LOAD_FAST pages_with_date
  LOAD_FAST self
  LOAD_ATTR __get_date_key
  LOAD_CONST True
  KW_NAMES ('key', 'reverse')
  CALL 3
  STORE_FAST pages_with_date_sorted
  LOAD_GLOBAL NULL + list
  LOAD_GLOBAL NULL + filter
  LOAD_CONST <code generate_output.<locals>.<lambda>>
  MAKE_FUNCTION 0
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'pages'
  CALL 1
  CALL 2
  CALL 1
  STORE_FAST pages_without_date
  LOAD_GLOBAL NULL + sorted
  LOAD_FAST pages_without_date
  LOAD_FAST self
  LOAD_ATTR __get_title_key
  LOAD_CONST False
  KW_NAMES ('key', 'reverse')
  CALL 3
  STORE_FAST pages_without_date_sorted
  LOAD_FAST pages_with_date_sorted
  LOAD_FAST pages_without_date_sorted
  BINARY_OP +
  STORE_FAST pages_sorted
  LOAD_CONST 'index'
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'DIRECT_TEMPLATES'
  CALL 1
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L8
  LOAD_CONST None
  STORE_FAST index_reference
  LOAD_GLOBAL NULL + len
  LOAD_FAST articles_sorted
  CALL 1
  LOAD_CONST 0
  COMPARE_OP >
  POP_JUMP_IF_FALSE L6
  LOAD_FAST articles_sorted
  LOAD_CONST 0
  BINARY_SUBSCR
  STORE_FAST index_reference
  JUMP_FORWARD L7
L6:
  LOAD_GLOBAL NULL + len
  LOAD_FAST pages_sorted
  CALL 1
  LOAD_CONST 0
  COMPARE_OP >
  POP_JUMP_IF_FALSE L7
  LOAD_FAST pages_sorted
  LOAD_CONST 0
  BINARY_SUBSCR
  STORE_FAST index_reference
L7:
  LOAD_FAST index_reference
  POP_JUMP_IF_NONE L8
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_url_node_for_content
  LOAD_FAST index_reference
  LOAD_CONST 'index'
  LOAD_FAST self
  LOAD_ATTR url_site
  KW_NAMES ('url',)
  CALL 3
  BINARY_OP +=
  STORE_FAST urls
L8:
  LOAD_FAST articles_sorted
  GET_ITER
L9:
  FOR_ITER L10
  STORE_FAST article
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_url_node_for_content
  LOAD_FAST article
  LOAD_CONST 'articles'
  LOAD_GLOBAL NULL + urljoin
  LOAD_FAST self
  LOAD_ATTR url_site
  LOAD_FAST article
  LOAD_ATTR url
  CALL 2
  KW_NAMES ('url',)
  CALL 3
  BINARY_OP +=
  STORE_FAST urls
  JUMP_BACKWARD L9
L10:
  END_FOR
  LOAD_FAST pages_sorted
  GET_ITER
L11:
  FOR_ITER L12
  STORE_FAST page
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_url_node_for_content
  LOAD_FAST page
  LOAD_CONST 'pages'
  LOAD_GLOBAL NULL + urljoin
  LOAD_FAST self
  LOAD_ATTR url_site
  LOAD_FAST page
  LOAD_ATTR url
  CALL 2
  KW_NAMES ('url',)
  CALL 3
  BINARY_OP +=
  STORE_FAST urls
  JUMP_BACKWARD L11
L12:
  END_FOR
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'CATEGORY_URL'
  CALL 1
  POP_JUMP_IF_FALSE L13
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __process_url_wrapper_elements
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'categories'
  CALL 1
  CALL 1
  BINARY_OP +=
  STORE_FAST urls
L13:
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'TAG_URL'
  CALL 1
  POP_JUMP_IF_FALSE L14
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __process_url_wrapper_elements
  LOAD_GLOBAL NULL + sorted
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'tags'
  CALL 1
  LOAD_CONST <code generate_output.<locals>.<lambda>>
  MAKE_FUNCTION 0
  KW_NAMES ('key',)
  CALL 2
  CALL 1
  BINARY_OP +=
  STORE_FAST urls
L14:
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'AUTHOR_URL'
  CALL 1
  POP_JUMP_IF_FALSE L15
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __process_url_wrapper_elements
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'authors'
  CALL 1
  CALL 1
  BINARY_OP +=
  STORE_FAST urls
L15:
  LOAD_GLOBAL NULL + list
  LOAD_GLOBAL NULL + filter
  LOAD_CONST <code generate_output.<locals>.<lambda>>
  MAKE_FUNCTION 0
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'DIRECT_TEMPLATES'
  CALL 1
  CALL 2
  CALL 1
  GET_ITER
L16:
  FOR_ITER L17
  STORE_FAST direct_template
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST articles_sorted
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST 'modified'
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST articles_sorted
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST 'date'
  LOAD_CONST None
  CALL 3
  CALL 3
  STORE_FAST modification_time
  LOAD_FAST self
  LOAD_ATTR NULL|self + __get_direct_template_url
  LOAD_FAST direct_template
  CALL 1
  STORE_FAST url
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_url_node_for_content
  LOAD_CONST None
  LOAD_CONST 'others'
  LOAD_FAST url
  LOAD_FAST modification_time
  CALL 4
  BINARY_OP +=
  STORE_FAST urls
  JUMP_BACKWARD L16
L17:
  END_FOR
  LOAD_GLOBAL NULL + codecs_open
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + join
  LOAD_FAST self
  LOAD_ATTR path_output
  LOAD_CONST 'sitemap.xml'
  CALL 2
  LOAD_CONST 'w'
  LOAD_CONST 'utf-8'
  KW_NAMES ('encoding',)
  CALL 3
  BEFORE_WITH
L18:
  STORE_FAST fd
  LOAD_FAST fd
  LOAD_ATTR NULL|self + write
  LOAD_FAST self
  LOAD_ATTR xml_wrap
  LOAD_FAST self
  LOAD_ATTR url_site
  LOAD_FAST urls
  LOAD_CONST ('SITEURL', 'urls')
  BUILD_CONST_KEY_MAP 2
  BINARY_OP %
  CALL 1
  POP_TOP
L19:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  RETURN_CONST None
L20:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L21
  RERAISE 2
L21:
  POP_TOP
L22:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  EXTENDED_ARG 3
  JUMP_BACKWARD L4
L23:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L24:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L25
  RERAISE 2
L25:
  POP_TOP
L26:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  EXTENDED_ARG 3
  JUMP_BACKWARD L5
L27:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L28:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L29
  RERAISE 2
L29:
  POP_TOP
L30:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  RETURN_CONST None
L31:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L1..L2 -> handler=L24 depth=1 lasti=True
  EXC try=L2..L3 -> handler=L20 depth=2 lasti=True
  EXC try=L3..L4 -> handler=L24 depth=1 lasti=True
  EXC try=L18..L19 -> handler=L28 depth=1 lasti=True
  EXC try=L20..L22 -> handler=L23 depth=4 lasti=True
  EXC try=L22..L24 -> handler=L24 depth=1 lasti=True
  EXC try=L24..L26 -> handler=L27 depth=3 lasti=True
  EXC try=L28..L30 -> handler=L31 depth=3 lasti=True
END
CODE generate_output.<locals>.<lambda>(p)
  RESUME 0
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST p
  LOAD_CONST 'modified'
  LOAD_CONST False
  CALL 3
  COPY 1
  POP_JUMP_IF_TRUE L1
  POP_TOP
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST p
  LOAD_CONST 'date'
  LOAD_CONST False
  CALL 3
L1:
  RETURN_VALUE
END
CODE generate_output.<locals>.<lambda>(p)
  RESUME 0
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST p
  LOAD_CONST 'modified'
  LOAD_CONST None
  CALL 3
  LOAD_CONST None
  IS_OP 0
  COPY 1
  POP_JUMP_IF_FALSE L1
  POP_TOP
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST p
  LOAD_CONST 'date'
  LOAD_CONST None
  CALL 3
  LOAD_CONST None
  IS_OP 0
L1:
  RETURN_VALUE
END
CODE generate_output.<locals>.<lambda>(x)
  RESUME 0
  LOAD_FAST x
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_ATTR name
  RETURN_VALUE
END
CODE generate_output.<locals>.<lambda>(p)
  RESUME 0
  LOAD_FAST p
  LOAD_CONST 'index'
  COMPARE_OP !=
  RETURN_VALUE
END

def generate_output(self, writer):
    """pass"""
    with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:
        with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:
            xsl = fd_origin.read()
            xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))
            fd_destination.write(xsl)
    urls = ''
    articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)
    pages_with_date = list(filter(lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False), self.context.get('pages')))
    pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)
    pages_without_date = list(filter(lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None, self.context.get('pages')))
    pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)
    pages_sorted = pages_with_date_sorted + pages_without_date_sorted
    if 'index' in self.context.get('DIRECT_TEMPLATES'):
        index_reference = None
        if len(articles_sorted) > 0:
            index_reference = articles_sorted[0]
        elif len(pages_sorted) > 0:
            index_reference = pages_sorted[0]
        if index_reference is not None:
            urls += self.__create_url_node_for_content(index_reference, 'index', url=self.url_site)
    for article in articles_sorted:
        urls += self.__create_url_node_for_content(article, 'articles', url=urljoin(self.url_site, article.url))
    for page in pages_sorted:
        urls += self.__create_url_node_for_content(page, 'pages', url=urljoin(self.url_site, page.url))
    if self.context.get('CATEGORY_URL'):
        urls += self.__process_url_wrapper_elements(self.context.get('categories'))
    if self.context.get('TAG_URL'):
        urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0].name))
    if self.context.get('AUTHOR_URL'):
        urls += self.__process_url_wrapper_elements(self.context.get('authors'))
    for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):
        modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))
        url = self.__get_direct_template_url(direct_template)
        urls += self.__create_url_node_for_content(None, 'others', url, modification_time)
    with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:
        fd.write(self.xml_wrap % {'SITEURL': self.url_site, 'urls': urls})


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __get_direct_template_url>
  MAKE_FUNCTION 0
  STORE_NAME __get_direct_template_url
  RETURN_CONST None
END
CODE __get_direct_template_url(self, name)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR pelican_settings
  LOAD_ATTR NULL|self + get
  LOAD_CONST '{}_SAVE_AS'
  LOAD_ATTR NULL|self + format
  LOAD_FAST name
  LOAD_ATTR NULL|self + upper
  CALL 0
  CALL 1
  CALL 1
  STORE_FAST url
  LOAD_FAST url
  POP_JUMP_IF_NOT_NONE L1
  LOAD_FAST self
  LOAD_ATTR settings
  LOAD_ATTR NULL|self + get
  LOAD_CONST '{}_URL'
  LOAD_ATTR NULL|self + format
  LOAD_FAST name
  LOAD_ATTR NULL|self + upper
  CALL 0
  CALL 1
  LOAD_CONST '{}.html'
  LOAD_ATTR NULL|self + format
  LOAD_FAST name
  CALL 1
  CALL 2
  STORE_FAST url
L1:
  LOAD_GLOBAL NULL + urljoin
  LOAD_FAST self
  LOAD_ATTR url_site
  LOAD_FAST url
  CALL 2
  RETURN_VALUE
END

def __get_direct_template_url(self, name):
    """pass"""
    url = self.pelican_settings.get('{}_SAVE_AS'.format(name.upper()))
    if url is None:
        url = self.settings.get('{}_URL'.format(name.upper()), '{}.html'.format(name))
    return urljoin(self.url_site, url)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __process_url_wrapper_elements>
  MAKE_FUNCTION 0
  STORE_NAME __process_url_wrapper_elements
  RETURN_CONST None
END
CODE __process_url_wrapper_elements(self, elements)
  DOC 'pass'
  RESUME 0
  LOAD_CONST ''
  STORE_FAST urls
  LOAD_FAST elements
  GET_ITER
L1:
  FOR_ITER L2
  UNPACK_SEQUENCE 2
  STORE_FAST url_wrapper
  STORE_FAST articles
  LOAD_FAST urls
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_url_node_for_content
  LOAD_FAST url_wrapper
  LOAD_CONST 'others'
  LOAD_GLOBAL NULL + urljoin
  LOAD_FAST self
  LOAD_ATTR url_site
  LOAD_FAST url_wrapper
  LOAD_ATTR url
  CALL 2
  LOAD_FAST self
  LOAD_ATTR NULL|self + __get_date_key
  LOAD_GLOBAL NULL + sorted
  LOAD_FAST articles
  LOAD_FAST self
  LOAD_ATTR __get_date_key
  LOAD_CONST True
  KW_NAMES ('key', 'reverse')
  CALL 3
  LOAD_CONST 0
  BINARY_SUBSCR
  CALL 1
  KW_NAMES ('url', 'modification_time')
  CALL 4
  BINARY_OP +=
  STORE_FAST urls
  JUMP_BACKWARD L1
L2:
  END_FOR
  LOAD_FAST urls
  RETURN_VALUE
END

def __process_url_wrapper_elements(self, elements):
    """pass"""
    urls = ''
    for url_wrapper, articles in elements:
        urls += self.__create_url_node_for_content(url_wrapper, 'others', url=urljoin(self.url_site, url_wrapper.url), modification_time=self.__get_date_key(sorted(articles, key=self.__get_date_key, reverse=True)[0]))
    return urls


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None)
  LOAD_CONST <code __create_url_node_for_content>
  MAKE_FUNCTION defaults
  STORE_NAME __create_url_node_for_content
  RETURN_CONST None
END
CODE __create_url_node_for_content(self, content, content_type, url, modification_time)
  DOC 'pass'
  RESUME 0
  LOAD_FAST url
  STORE_FAST loc
  LOAD_FAST loc
  POP_JUMP_IF_NOT_NONE L1
  LOAD_GLOBAL NULL + urljoin
  LOAD_FAST self
  LOAD_ATTR url_site
  PUSH_NULL
  LOAD_FAST self
  LOAD_ATTR context
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'ARTICLE_URL'
  CALL 1
  LOAD_ATTR format
  LOAD_CONST ()
  BUILD_MAP 0
  LOAD_FAST content
  LOAD_ATTR url_format
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  CALL 2
  STORE_FAST loc
L1:
  LOAD_CONST None
  STORE_FAST lastmod
  LOAD_FAST modification_time
  POP_JUMP_IF_NONE L2
  LOAD_FAST modification_time
  LOAD_ATTR NULL|self + strftime
  LOAD_CONST '%Y-%m-%d'
  CALL 1
  STORE_FAST lastmod
  JUMP_FORWARD L4
L2:
  LOAD_FAST content
  POP_JUMP_IF_NONE L4
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST content
  LOAD_CONST 'modified'
  LOAD_CONST None
  CALL 3
  POP_JUMP_IF_NONE L3
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST content
  LOAD_CONST 'modified'
  CALL 2
  LOAD_ATTR NULL|self + strftime
  LOAD_CONST '%Y-%m-%d'
  CALL 1
  STORE_FAST lastmod
  JUMP_FORWARD L4
L3:
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST content
  LOAD_CONST 'date'
  LOAD_CONST None
  CALL 3
  POP_JUMP_IF_NONE L4
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST content
  LOAD_CONST 'date'
  CALL 2
  LOAD_ATTR NULL|self + strftime
  LOAD_CONST '%Y-%m-%d'
  CALL 1
  STORE_FAST lastmod
L4:
  LOAD_CONST '<loc>{}</loc>'
  LOAD_ATTR NULL|self + format
  LOAD_FAST loc
  CALL 1
  STORE_FAST output
  LOAD_FAST lastmod
  POP_JUMP_IF_NONE L5
  LOAD_FAST output
  LOAD_CONST '\n<lastmod>{}</lastmod>'
  LOAD_ATTR NULL|self + format
  LOAD_FAST lastmod
  CALL 1
  BINARY_OP +=
  STORE_FAST output
L5:
  LOAD_FAST output
  LOAD_CONST '\n<changefreq>{}</changefreq>'
  LOAD_ATTR NULL|self + format
  LOAD_FAST self
  LOAD_ATTR settings
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'changefrequencies'
  CALL 1
  LOAD_ATTR NULL|self + get
  LOAD_FAST content_type
  CALL 1
  CALL 1
  BINARY_OP +=
  STORE_FAST output
  LOAD_FAST output
  LOAD_CONST '\n<priority>{:.2f}</priority>'
  LOAD_ATTR NULL|self + format
  LOAD_FAST self
  LOAD_ATTR settings
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'priorities'
  CALL 1
  LOAD_ATTR NULL|self + get
  LOAD_FAST content_type
  CALL 1
  CALL 1
  BINARY_OP +=
  STORE_FAST output
  LOAD_FAST self
  LOAD_ATTR template_url
  LOAD_ATTR NULL|self + format
  LOAD_FAST output
  CALL 1
  RETURN_VALUE
END

def __create_url_node_for_content(self, content, content_type, url=None, modification_time=None):
    """pass"""
    loc = url
    if loc is None:
        loc = urljoin(self.url_site, self.context.get('ARTICLE_URL').format(**content.url_format))
    lastmod = None
    if modification_time is not None:
        lastmod = modification_time.strftime('%Y-%m-%d')
    elif content is not None:
        if getattr(content, 'modified', None) is not None:
            lastmod = getattr(content, 'modified').strftime('%Y-%m-%d')
        elif getattr(content, 'date', None) is not None:
            lastmod = getattr(content, 'date').strftime('%Y-%m-%d')
    output = '<loc>{}</loc>'.format(loc)
    if lastmod is not None:
        output += '\n<lastmod>{}</lastmod>'.format(lastmod)
    output += '\n<changefreq>{}</changefreq>'.format(self.settings.get('changefrequencies').get(content_type))
    output += '\n<priority>{:.2f}</priority>'.format(self.settings.get('priorities').get(content_type))
    return self.template_url.format(output)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (True,)
  LOAD_CONST <code add_attachment>
  MAKE_FUNCTION defaults
  STORE_NAME add_attachment
  RETURN_CONST None
END
CODE add_attachment(message, attachment, rfc2231)
  DOC 'pass'
  RESUME 0
  LOAD_FAST attachment
  LOAD_ATTR NULL|self + read
  CALL 0
  STORE_FAST data
  LOAD_GLOBAL NULL + MIMEBase
  LOAD_CONST 'application'
  LOAD_CONST 'octet-stream'
  CALL 2
  STORE_FAST part
  LOAD_FAST part
  LOAD_ATTR NULL|self + set_payload
  LOAD_FAST data
  CALL 1
  POP_TOP
  LOAD_GLOBAL encoders
  LOAD_ATTR NULL|self + encode_base64
  LOAD_FAST part
  CALL 1
  POP_TOP
  LOAD_FAST rfc2231
  POP_JUMP_IF_FALSE L1
  LOAD_FAST attachment
  LOAD_ATTR name
  JUMP_FORWARD L2
L1:
  LOAD_GLOBAL NULL + Header
  LOAD_FAST attachment
  LOAD_ATTR name
  CALL 1
  LOAD_ATTR NULL|self + encode
  CALL 0
L2:
  STORE_FAST filename
  LOAD_FAST part
  LOAD_ATTR NULL|self + add_header
  LOAD_CONST 'Content-Disposition'
  LOAD_CONST 'attachment'
  LOAD_FAST filename
  KW_NAMES ('filename',)
  CALL 3
  POP_TOP
  LOAD_FAST message
  LOAD_ATTR NULL|self + attach
  LOAD_FAST part
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def add_attachment(message, attachment, rfc2231=True):
    """pass"""
    data = attachment.read()
    part = MIMEBase('application', 'octet-stream')
    part.set_payload(data)
    encoders.encode_base64(part)
    filename = attachment.name if rfc2231 else Header(attachment.name).encode()
    part.add_header('Content-Disposition', 'attachment', filename=filename)
    message.attach(part)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _login>
  MAKE_FUNCTION 0
  STORE_NAME _login
  RETURN_CONST None
END
CODE _login(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR connection_details
  UNPACK_SEQUENCE 4
  STORE_FAST server
  STORE_FAST port
  STORE_FAST mode
  STORE_FAST debug
  LOAD_FAST mode
  LOAD_CONST 'SSL'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL smtplib
  LOAD_ATTR SMTP_SSL
  STORE_FAST smtp_class
  JUMP_FORWARD L2
L1:
  LOAD_GLOBAL smtplib
  LOAD_ATTR SMTP
  STORE_FAST smtp_class
L2:
  PUSH_NULL
  LOAD_FAST smtp_class
  LOAD_FAST server
  LOAD_FAST port
  CALL 2
  STORE_FAST smtp
  LOAD_FAST smtp
  LOAD_ATTR NULL|self + set_debuglevel
  LOAD_FAST debug
  CALL 1
  POP_TOP
  LOAD_FAST mode
  LOAD_CONST 'TLS'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L3
  LOAD_FAST smtp
  LOAD_ATTR NULL|self + starttls
  CALL 0
  POP_TOP
L3:
  LOAD_FAST self
  LOAD_ATTR NULL|self + authenticate
  LOAD_FAST smtp
  CALL 1
  POP_TOP
  LOAD_FAST smtp
  RETURN_VALUE
END

def _login(self):
    """pass"""
    server, port, mode, debug = self.connection_details
    if mode == 'SSL':
        smtp_class = smtplib.SMTP_SSL
    else:
        smtp_class = smtplib.SMTP
    smtp = smtp_class(server, port)
    smtp.set_debuglevel(debug)
    if mode == 'TLS':
        smtp.starttls()
    self.authenticate(smtp)
    return smtp


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST ((),)
  LOAD_CONST <code send>
  MAKE_FUNCTION defaults
  STORE_NAME send
  RETURN_CONST None
END
CODE send(self, email, attachments)
  DOC 'pass'
  RESUME 0
  LOAD_FAST email
  LOAD_ATTR NULL|self + as_mime
  LOAD_FAST attachments
  CALL 1
  STORE_FAST msg
  LOAD_CONST 'From'
  LOAD_FAST msg
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + sender_address
  CALL 0
  LOAD_FAST msg
  LOAD_CONST 'From'
  STORE_SUBSCR
L1:
  LOAD_FAST self
  LOAD_ATTR _conn
  POP_JUMP_IF_FALSE L2
  LOAD_FAST self
  LOAD_ATTR _conn
  LOAD_ATTR NULL|self + sendmail
  LOAD_FAST self
  LOAD_ATTR username
  LOAD_FAST email
  LOAD_ATTR recipients
  LOAD_FAST msg
  LOAD_ATTR NULL|self + as_string
  CALL 0
  CALL 3
  POP_TOP
  RETURN_CONST None
L2:
  LOAD_FAST self
  BEFORE_WITH
L3:
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _conn
  LOAD_ATTR NULL|self + sendmail
  LOAD_FAST self
  LOAD_ATTR username
  LOAD_FAST email
  LOAD_ATTR recipients
  LOAD_FAST msg
  LOAD_ATTR NULL|self + as_string
  CALL 0
  CALL 3
  POP_TOP
L4:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  RETURN_CONST None
L5:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L6
  RERAISE 2
L6:
  POP_TOP
L7:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  RETURN_CONST None
L8:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L3..L4 -> handler=L5 depth=1 lasti=True
  EXC try=L5..L7 -> handler=L8 depth=3 lasti=True
END

def send(self, email, attachments=()):
    """pass"""
    msg = email.as_mime(attachments)
    if 'From' not in msg:
        msg['From'] = self.sender_address()
    if self._conn:
        self._conn.sendmail(self.username, email.recipients, msg.as_string())
    else:
        with self:
            self._conn.sendmail(self.username, email.recipients, msg.as_string())


Input:
CODE <module>()
  DOC 'attributes'
  RESUME 0
  LOAD_CONST 'attributes'
  LOAD_CONST 'background'
  BUILD_LIST 2
  BUILD_TUPLE 1
  LOAD_CONST <code check>
  MAKE_FUNCTION defaults
  STORE_NAME check
  RETURN_CONST None
END
CODE check(qpi_or_h5file, checks)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + isinstance
  LOAD_FAST checks
  LOAD_GLOBAL str
  CALL 2
  POP_JUMP_IF_FALSE L1
  LOAD_FAST checks
  BUILD_LIST 1
  STORE_FAST checks
L1:
  LOAD_FAST checks
  GET_ITER
L2:
  FOR_ITER L4
  STORE_FAST ch
  LOAD_FAST ch
  LOAD_CONST ('attributes', 'background')
  CONTAINS_OP 1
  POP_JUMP_IF_TRUE L3
  JUMP_BACKWARD L2
L3:
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'Unknown check: {}'
  LOAD_ATTR NULL|self + format
  LOAD_GLOBAL check
  CALL 1
  CALL 1
  RAISE_VARARGS 1
L4:
  END_FOR
  LOAD_GLOBAL NULL + isinstance
  LOAD_FAST qpi_or_h5file
  LOAD_GLOBAL QPImage
  CALL 2
  POP_JUMP_IF_FALSE L5
  LOAD_FAST qpi_or_h5file
  STORE_FAST qpi
  JUMP_FORWARD L6
L5:
  LOAD_GLOBAL NULL + QPImage
  LOAD_FAST qpi_or_h5file
  LOAD_CONST 'r'
  KW_NAMES ('h5file', 'h5mode')
  CALL 2
  STORE_FAST qpi
L6:
  LOAD_CONST 'attributes'
  LOAD_FAST checks
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L7
  LOAD_GLOBAL NULL + check_attributes
  LOAD_FAST qpi
  CALL 1
  POP_TOP
L7:
  LOAD_CONST 'background'
  LOAD_FAST checks
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L8
  LOAD_GLOBAL NULL + check_background
  LOAD_FAST qpi
  CALL 1
  POP_TOP
  RETURN_CONST None
L8:
  RETURN_CONST None
END

def check(qpi_or_h5file, checks=['attributes', 'background']):
    """pass"""
    if isinstance(checks, str):
        checks = [checks]
    for ch in checks:
        if ch not in ['attributes', 'background']:
            raise ValueError('Unknown check: {}'.format(check))
    if isinstance(qpi_or_h5file, QPImage):
        qpi = qpi_or_h5file
    else:
        qpi = QPImage(h5file=qpi_or_h5file, h5mode='r')
    if 'attributes' in checks:
        check_attributes(qpi)
    if 'background' in checks:
        check_background(qpi)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code check_attributes>
  MAKE_FUNCTION 0
  STORE_NAME check_attributes
  RETURN_CONST None
END
CODE check_attributes(qpi)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST missing_attrs
  LOAD_GLOBAL DATA_KEYS
  GET_ITER
L1:
  FOR_ITER L3
  STORE_FAST key
  LOAD_FAST key
  LOAD_FAST qpi
  LOAD_ATTR meta
  CONTAINS_OP 1
  POP_JUMP_IF_TRUE L2
  JUMP_BACKWARD L1
L2:
  LOAD_FAST missing_attrs
  LOAD_ATTR NULL|self + append
  LOAD_FAST key
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L3:
  END_FOR
  LOAD_FAST missing_attrs
  POP_JUMP_IF_FALSE L4
  LOAD_CONST 'Attributes are missing: {} '
  LOAD_ATTR NULL|self + format
  LOAD_FAST missing_attrs
  CALL 1
  LOAD_CONST 'in {}!'
  LOAD_ATTR NULL|self + format
  LOAD_FAST qpi
  CALL 1
  BINARY_OP +
  STORE_FAST msg
  LOAD_GLOBAL NULL + IntegrityCheckError
  LOAD_FAST msg
  CALL 1
  RAISE_VARARGS 1
L4:
  RETURN_CONST None
END

def check_attributes(qpi):
    """pass"""
    missing_attrs = []
    for key in DATA_KEYS:
        if key not in qpi.meta:
            missing_attrs.append(key)
    if missing_attrs:
        msg = 'Attributes are missing: {} '.format(missing_attrs) + 'in {}!'.format(qpi)
        raise IntegrityCheckError(msg)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code check_background>
  MAKE_FUNCTION 0
  STORE_NAME check_background
  RETURN_CONST None
END
CODE check_background(qpi)
  DOC 'pass'
  RESUME 0
  LOAD_FAST qpi
  LOAD_ATTR _amp
  LOAD_FAST qpi
  LOAD_ATTR _pha
  BUILD_TUPLE 2
  GET_ITER
L1:
  FOR_ITER L12
  STORE_FAST imdat
  NOP
L2:
  LOAD_FAST imdat
  LOAD_ATTR NULL|self + get_bg
  LOAD_CONST 'fit'
  LOAD_CONST True
  KW_NAMES ('key', 'ret_attrs')
  CALL 2
  UNPACK_SEQUENCE 2
  STORE_FAST fit
  STORE_FAST attrs
L3:
  LOAD_GLOBAL NULL + dict
  LOAD_FAST attrs
  CALL 1
  STORE_FAST kwargs
  LOAD_CONST 'estimate_bg_from_mask'
  STORE_FAST binkey
  LOAD_FAST binkey
  LOAD_FAST imdat
  LOAD_ATTR h5
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L4
  LOAD_FAST imdat
  LOAD_ATTR h5
  LOAD_FAST binkey
  BINARY_SUBSCR
  LOAD_CONST None
  LOAD_CONST None
  BINARY_SLICE
  LOAD_FAST kwargs
  LOAD_CONST 'from_mask'
  STORE_SUBSCR
  JUMP_FORWARD L5
L4:
  LOAD_CONST None
  LOAD_FAST kwargs
  LOAD_CONST 'from_mask'
  STORE_SUBSCR
L5:
  LOAD_GLOBAL h5py
  LOAD_ATTR NULL|self + File
  LOAD_CONST 'check.h5'
  LOAD_CONST 'core'
  LOAD_CONST False
  KW_NAMES ('driver', 'backing_store')
  CALL 3
  BEFORE_WITH
L6:
  STORE_FAST h5
  LOAD_FAST imdat
  LOAD_ATTR NULL|self + __class__
  LOAD_FAST h5
  CALL 1
  STORE_FAST testimdat
  LOAD_FAST imdat
  LOAD_ATTR raw
  LOAD_FAST testimdat
  LOAD_CONST 'raw'
  STORE_SUBSCR
L7:
  NOP
L8:
  LOAD_FAST imdat
  LOAD_ATTR NULL|self + get_bg
  LOAD_CONST 'data'
  CALL 1
  STORE_FAST bg
L9:
  LOAD_FAST testimdat
  LOAD_ATTR NULL|self + set_bg
  LOAD_FAST bg
  LOAD_CONST 'data'
  KW_NAMES ('key',)
  CALL 2
  POP_TOP
L10:
  PUSH_NULL
  LOAD_FAST testimdat
  LOAD_ATTR estimate_bg
  LOAD_CONST ()
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  POP_TOP
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + allclose
  LOAD_FAST testimdat
  LOAD_ATTR NULL|self + get_bg
  LOAD_CONST 'fit'
  KW_NAMES ('key',)
  CALL 1
  LOAD_FAST fit
  CALL 2
  POP_JUMP_IF_TRUE L11
  LOAD_CONST 'Wrong estimated (fitted) background!'
  STORE_FAST msg
  LOAD_GLOBAL NULL + IntegrityCheckError
  LOAD_FAST msg
  CALL 1
  RAISE_VARARGS 1
L11:
  NOP
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  JUMP_BACKWARD L1
L12:
  END_FOR
  RETURN_CONST None
L13:
  PUSH_EXC_INFO
  LOAD_GLOBAL KeyError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L15
  POP_TOP
L14:
  POP_EXCEPT
  JUMP_BACKWARD L10
L15:
  RERAISE 0
L16:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L17:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L18
  RERAISE 2
L18:
  POP_TOP
L19:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  EXTENDED_ARG 1
  JUMP_BACKWARD L1
L20:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L21:
  PUSH_EXC_INFO
  LOAD_GLOBAL KeyError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L23
  POP_TOP
L22:
  POP_EXCEPT
  EXTENDED_ARG 1
  JUMP_BACKWARD L1
L23:
  RERAISE 0
L24:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L3 -> handler=L21 depth=1 lasti=False
  EXC try=L6..L7 -> handler=L17 depth=2 lasti=True
  EXC try=L8..L9 -> handler=L13 depth=2 lasti=False
  EXC try=L9..L11 -> handler=L17 depth=2 lasti=True
  EXC try=L13..L14 -> handler=L16 depth=3 lasti=True
  EXC try=L14..L15 -> handler=L17 depth=2 lasti=True
  EXC try=L15..L16 -> handler=L16 depth=3 lasti=True
  EXC try=L16..L17 -> handler=L17 depth=2 lasti=True
  EXC try=L17..L19 -> handler=L20 depth=4 lasti=True
  EXC try=L21..L22 -> handler=L24 depth=2 lasti=True
  EXC try=L23..L24 -> handler=L24 depth=2 lasti=True
END

def check_background(qpi):
    """pass"""
    for imdat in [qpi._amp, qpi._pha]:
        try:
            fit, attrs = imdat.get_bg(key='fit', ret_attrs=True)
        except KeyError:
            pass
        else:
            kwargs = dict(attrs)
            binkey = 'estimate_bg_from_mask'
            if binkey in imdat.h5:
                kwargs['from_mask'] = imdat.h5[binkey][:]
            else:
                kwargs['from_mask'] = None
            with h5py.File('check.h5', driver='core', backing_store=False) as h5:
                testimdat = imdat.__class__(h5)
                testimdat['raw'] = imdat.raw
                try:
                    bg = imdat.get_bg('data')
                except KeyError:
                    pass
                else:
                    testimdat.set_bg(bg, key='data')
                testimdat.estimate_bg(**kwargs)
                if not np.allclose(testimdat.get_bg(key='fit'), fit):
                    msg = 'Wrong estimated (fitted) background!'
                    raise IntegrityCheckError(msg)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code write_image_dataset>
  MAKE_FUNCTION defaults
  STORE_NAME write_image_dataset
  RETURN_CONST None
END
CODE write_image_dataset(group, key, data, h5dtype)
  DOC 'pass'
  RESUME 0
  LOAD_FAST h5dtype
  POP_JUMP_IF_NOT_NONE L1
  LOAD_FAST data
  LOAD_ATTR dtype
  STORE_FAST h5dtype
L1:
  LOAD_FAST key
  LOAD_FAST group
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L2
  LOAD_FAST group
  LOAD_FAST key
  DELETE_SUBSCR
L2:
  LOAD_FAST group
  LOAD_ATTR file
  LOAD_ATTR driver
  LOAD_CONST 'core'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L3
  BUILD_MAP 0
  STORE_FAST kwargs
  JUMP_FORWARD L4
L3:
  LOAD_CONST True
  LOAD_FAST data
  LOAD_ATTR shape
  LOAD_CONST ('fletcher32', 'chunks')
  BUILD_CONST_KEY_MAP 2
  STORE_FAST kwargs
  LOAD_FAST kwargs
  LOAD_ATTR NULL|self + update
  LOAD_GLOBAL COMPRESSION
  CALL 1
  POP_TOP
L4:
  PUSH_NULL
  LOAD_FAST group
  LOAD_ATTR create_dataset
  LOAD_FAST key
  BUILD_TUPLE 1
  LOAD_CONST 'data'
  LOAD_FAST data
  LOAD_ATTR NULL|self + astype
  LOAD_FAST h5dtype
  CALL 1
  BUILD_MAP 1
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST dset
  LOAD_FAST dset
  LOAD_ATTR attrs
  LOAD_ATTR NULL|self + create
  LOAD_CONST 'CLASS'
  LOAD_CONST b'IMAGE'
  CALL 2
  POP_TOP
  LOAD_FAST dset
  LOAD_ATTR attrs
  LOAD_ATTR NULL|self + create
  LOAD_CONST 'IMAGE_VERSION'
  LOAD_CONST b'1.2'
  CALL 2
  POP_TOP
  LOAD_FAST dset
  LOAD_ATTR attrs
  LOAD_ATTR NULL|self + create
  LOAD_CONST 'IMAGE_SUBCLASS'
  LOAD_CONST b'IMAGE_GRAYSCALE'
  CALL 2
  POP_TOP
  LOAD_FAST dset
  RETURN_VALUE
END

def write_image_dataset(group, key, data, h5dtype=None):
    """pass"""
    if h5dtype is None:
        h5dtype = data.dtype
    if key in group:
        del group[key]
    if group.file.driver == 'core':
        kwargs = {}
    else:
        kwargs = {'fletcher32': True, 'chunks': data.shape}
        kwargs.update(COMPRESSION)
    dset = group.create_dataset(key, data=data.astype(h5dtype), **kwargs)
    dset.attrs.create('CLASS', b'IMAGE')
    dset.attrs.create('IMAGE_VERSION', b'1.2')
    dset.attrs.create('IMAGE_SUBCLASS', b'IMAGE_GRAYSCALE')
    return dset


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code info>
  MAKE_FUNCTION 0
  STORE_NAME info
  RETURN_CONST None
END
CODE info(self)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST info
  LOAD_FAST self
  LOAD_ATTR __class__
  LOAD_ATTR __name__
  LOAD_ATTR NULL|self + lower
  CALL 0
  STORE_FAST name
  LOAD_GLOBAL VALID_BG_KEYS
  GET_ITER
L1:
  FOR_ITER L5
  STORE_FAST key
  LOAD_FAST key
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'bg_data'
  BINARY_SUBSCR
  CONTAINS_OP 0
  POP_JUMP_IF_TRUE L2
  JUMP_BACKWARD L1
L2:
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'bg_data'
  BINARY_SUBSCR
  LOAD_FAST key
  BINARY_SUBSCR
  LOAD_ATTR attrs
  STORE_FAST attrs
  LOAD_FAST attrs
  GET_ITER
L3:
  FOR_ITER L4
  STORE_FAST akey
  LOAD_FAST attrs
  LOAD_FAST akey
  BINARY_SUBSCR
  STORE_FAST atr
  LOAD_CONST '{} background {}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST name
  LOAD_FAST akey
  CALL 2
  STORE_FAST var
  LOAD_FAST info
  LOAD_ATTR NULL|self + append
  LOAD_FAST var
  LOAD_FAST atr
  BUILD_TUPLE 2
  CALL 1
  POP_TOP
  JUMP_BACKWARD L3
L4:
  END_FOR
  JUMP_BACKWARD L1
L5:
  END_FOR
  LOAD_CONST 'fit'
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'bg_data'
  BINARY_SUBSCR
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L8
  LOAD_CONST '{} background from mask'
  LOAD_ATTR NULL|self + format
  LOAD_FAST name
  CALL 1
  STORE_FAST var_mask
  LOAD_CONST 'estimate_bg_from_mask'
  LOAD_FAST self
  LOAD_ATTR h5
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L6
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'estimate_bg_from_mask'
  BINARY_SUBSCR
  POP_JUMP_IF_NONE L6
  LOAD_FAST info
  LOAD_ATTR NULL|self + append
  LOAD_FAST var_mask
  LOAD_CONST True
  BUILD_TUPLE 2
  CALL 1
  POP_TOP
  LOAD_FAST info
  RETURN_VALUE
L6:
  LOAD_CONST 'estimate_bg_from_binary'
  LOAD_FAST self
  LOAD_ATTR h5
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L7
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'estimate_bg_from_binary'
  BINARY_SUBSCR
  POP_JUMP_IF_NONE L7
  LOAD_GLOBAL warnings
  LOAD_ATTR NULL|self + warn
  LOAD_CONST 'Old file format detected!'
  LOAD_GLOBAL DeprecationWarning
  CALL 2
  POP_TOP
  LOAD_FAST info
  LOAD_ATTR NULL|self + append
  LOAD_FAST var_mask
  LOAD_CONST True
  BUILD_TUPLE 2
  CALL 1
  POP_TOP
  LOAD_FAST info
  RETURN_VALUE
L7:
  LOAD_FAST info
  LOAD_ATTR NULL|self + append
  LOAD_FAST var_mask
  LOAD_CONST False
  BUILD_TUPLE 2
  CALL 1
  POP_TOP
L8:
  LOAD_FAST info
  RETURN_VALUE
END

def info(self):
    """pass"""
    info = []
    name = self.__class__.__name__.lower()
    for key in VALID_BG_KEYS:
        if key in self.h5['bg_data']:
            attrs = self.h5['bg_data'][key].attrs
            for akey in attrs:
                atr = attrs[akey]
                var = '{} background {}'.format(name, akey)
                info.append((var, atr))
    if 'fit' in self.h5['bg_data']:
        var_mask = '{} background from mask'.format(name)
        if 'estimate_bg_from_mask' in self.h5 and self.h5['estimate_bg_from_mask'] is not None:
            info.append((var_mask, True))
        elif 'estimate_bg_from_binary' in self.h5 and self.h5['estimate_bg_from_binary'] is not None:
            warnings.warn('Old file format detected!', DeprecationWarning)
            info.append((var_mask, True))
        else:
            info.append((var_mask, False))
    return info


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code del_bg>
  MAKE_FUNCTION 0
  STORE_NAME del_bg
  RETURN_CONST None
END
CODE del_bg(self, key)
  DOC 'pass'
  RESUME 0
  LOAD_FAST key
  LOAD_GLOBAL VALID_BG_KEYS
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'Invalid bg key: {}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST key
  CALL 1
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_FAST key
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'bg_data'
  BINARY_SUBSCR
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L2
  LOAD_FAST self
  LOAD_ATTR h5
  LOAD_CONST 'bg_data'
  BINARY_SUBSCR
  LOAD_FAST key
  DELETE_SUBSCR
  RETURN_CONST None
L2:
  LOAD_CONST "No bg data to clear for '{}' in {}."
  LOAD_ATTR NULL|self + format
  LOAD_FAST key
  LOAD_FAST self
  CALL 2
  STORE_FAST msg
  LOAD_GLOBAL warnings
  LOAD_ATTR NULL|self + warn
  LOAD_FAST msg
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def del_bg(self, key):
    """pass"""
    if key not in VALID_BG_KEYS:
        raise ValueError('Invalid bg key: {}'.format(key))
    if key in self.h5['bg_data']:
        del self.h5['bg_data'][key]
    else:
        msg = "No bg data to clear for '{}' in {}.".format(key, self)
        warnings.warn(msg)


Input:
CODE <module>()
  DOC 'return'
  RESUME 0
  LOAD_CONST 'return'
  LOAD_NAME int
  BUILD_TUPLE 2
  LOAD_CONST <code main>
  MAKE_FUNCTION annotations
  STORE_NAME main
  RETURN_CONST None
END
CODE main()
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL argparse
  LOAD_ATTR NULL|self + ArgumentParser
  CALL 0
  STORE_FAST parser
  LOAD_FAST parser
  LOAD_ATTR NULL|self + add_argument
  LOAD_CONST '--overwrite'
  LOAD_CONST 'Overwrites the unformatted source files with the well-formatted code in place. If not set, an exception is raised if any of the files do not conform to the style guide.'
  LOAD_CONST 'store_true'
  KW_NAMES ('help', 'action')
  CALL 3
  POP_TOP
  LOAD_FAST parser
  LOAD_ATTR NULL|self + parse_args
  CALL 0
  STORE_FAST args
  LOAD_GLOBAL NULL + bool
  LOAD_FAST args
  LOAD_ATTR overwrite
  CALL 1
  STORE_FAST overwrite
  LOAD_GLOBAL pathlib
  LOAD_ATTR NULL|self + Path
  LOAD_GLOBAL __file__
  CALL 1
  LOAD_ATTR parent
  STORE_FAST repo_root
  LOAD_GLOBAL NULL + print
  LOAD_CONST "YAPF'ing..."
  CALL 1
  POP_TOP
  LOAD_FAST overwrite
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('yapf', '--in-place', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py')
  LIST_EXTEND 1
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  KW_NAMES ('cwd',)
  CALL 2
  POP_TOP
  JUMP_FORWARD L2
L1:
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('yapf', '--diff', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py')
  LIST_EXTEND 1
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  KW_NAMES ('cwd',)
  CALL 2
  POP_TOP
L2:
  LOAD_GLOBAL NULL + print
  LOAD_CONST "Mypy'ing..."
  CALL 1
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('mypy', 'icontract', 'tests')
  LIST_EXTEND 1
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  KW_NAMES ('cwd',)
  CALL 2
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST "Pylint'ing..."
  CALL 1
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('pylint', '--rcfile=pylint.rc', 'tests', 'icontract')
  LIST_EXTEND 1
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  KW_NAMES ('cwd',)
  CALL 2
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST "Pydocstyle'ing..."
  CALL 1
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  LOAD_CONST 'pydocstyle'
  LOAD_CONST 'icontract'
  BUILD_LIST 2
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  KW_NAMES ('cwd',)
  CALL 2
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Testing...'
  CALL 1
  POP_TOP
  LOAD_GLOBAL os
  LOAD_ATTR environ
  LOAD_ATTR NULL|self + copy
  CALL 0
  STORE_FAST env
  LOAD_CONST 'true'
  LOAD_FAST env
  LOAD_CONST 'ICONTRACT_SLOW'
  STORE_SUBSCR
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('coverage', 'run', '--source', 'icontract', '-m', 'unittest', 'discover', 'tests')
  LIST_EXTEND 1
  LOAD_FAST repo_root
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  LOAD_FAST env
  KW_NAMES ('cwd', 'env')
  CALL 3
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  LOAD_CONST 'coverage'
  LOAD_CONST 'report'
  BUILD_LIST 2
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Doctesting...'
  CALL 1
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('python3', '-m', 'doctest', 'README.rst')
  LIST_EXTEND 1
  CALL 1
  POP_TOP
  LOAD_FAST repo_root
  LOAD_CONST 'icontract'
  BINARY_OP /
  LOAD_ATTR NULL|self + glob
  LOAD_CONST '**/*.py'
  CALL 1
  GET_ITER
L3:
  FOR_ITER L4
  STORE_FAST pth
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  LOAD_CONST 'python3'
  LOAD_CONST '-m'
  LOAD_CONST 'doctest'
  LOAD_FAST pth
  LOAD_ATTR NULL|self + as_posix
  CALL 0
  BUILD_LIST 4
  CALL 1
  POP_TOP
  JUMP_BACKWARD L3
L4:
  END_FOR
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Checking the restructured text of the readme...'
  CALL 1
  POP_TOP
  LOAD_GLOBAL subprocess
  LOAD_ATTR NULL|self + check_call
  BUILD_LIST 0
  LOAD_CONST ('python3', 'setup.py', 'check', '--restructuredtext', '--strict')
  LIST_EXTEND 1
  CALL 1
  POP_TOP
  RETURN_CONST 0
END

def main() -> int:
    """pass"""
    parser = argparse.ArgumentParser()
    parser.add_argument('--overwrite', help='Overwrites the unformatted source files with the well-formatted code in place. If not set, an exception is raised if any of the files do not conform to the style guide.', action='store_true')
    args = parser.parse_args()
    overwrite = bool(args.overwrite)
    repo_root = pathlib.Path(__file__).parent
    print("YAPF'ing...")
    if overwrite:
        subprocess.check_call(['yapf', '--in-place', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py'], cwd=repo_root.as_posix())
    else:
        subprocess.check_call(['yapf', '--diff', '--style=style.yapf', '--recursive', 'tests', 'icontract', 'setup.py', 'precommit.py'], cwd=repo_root.as_posix())
    print("Mypy'ing...")
    subprocess.check_call(['mypy', 'icontract', 'tests'], cwd=repo_root.as_posix())
    print("Pylint'ing...")
    subprocess.check_call(['pylint', '--rcfile=pylint.rc', 'tests', 'icontract'], cwd=repo_root.as_posix())
    print("Pydocstyle'ing...")
    subprocess.check_call(['pydocstyle', 'icontract'], cwd=repo_root.as_posix())
    print('Testing...')
    env = os.environ.copy()
    env['ICONTRACT_SLOW'] = 'true'
    subprocess.check_call(['coverage', 'run', '--source', 'icontract', '-m', 'unittest', 'discover', 'tests'], cwd=repo_root.as_posix(), env=env)
    subprocess.check_call(['coverage', 'report'])
    print('Doctesting...')
    subprocess.check_call(['python3', '-m', 'doctest', 'README.rst'])
    for pth in (repo_root / 'icontract').glob('**/*.py'):
        subprocess.check_call(['python3', '-m', 'doctest', pth.as_posix()])
    print('Checking the restructured text of the readme...')
    subprocess.check_call(['python3', 'setup.py', 'check', '--restructuredtext', '--strict'])
    return 0


Input:
CODE <module>()
  DOC 'bases'
  RESUME 0
  LOAD_CONST 'bases'
  LOAD_NAME List
  LOAD_NAME type
  BINARY_SUBSCR
  LOAD_CONST 'namespace'
  LOAD_NAME MutableMapping
  LOAD_NAME str
  LOAD_NAME Any
  BUILD_TUPLE 2
  BINARY_SUBSCR
  LOAD_CONST 'return'
  LOAD_CONST None
  BUILD_TUPLE 6
  LOAD_CONST <code _collapse_invariants>
  MAKE_FUNCTION annotations
  STORE_NAME _collapse_invariants
  RETURN_CONST None
END
CODE _collapse_invariants(bases, namespace)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST invariants
  LOAD_FAST bases
  GET_ITER
L1:
  FOR_ITER L3
  STORE_FAST base
  LOAD_GLOBAL NULL + hasattr
  LOAD_FAST base
  LOAD_CONST '__invariants__'
  CALL 2
  POP_JUMP_IF_TRUE L2
  JUMP_BACKWARD L1
L2:
  LOAD_FAST invariants
  LOAD_ATTR NULL|self + extend
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST base
  LOAD_CONST '__invariants__'
  CALL 2
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L3:
  END_FOR
  LOAD_CONST '__invariants__'
  LOAD_FAST namespace
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L4
  LOAD_FAST invariants
  LOAD_ATTR NULL|self + extend
  LOAD_FAST namespace
  LOAD_CONST '__invariants__'
  BINARY_SUBSCR
  CALL 1
  POP_TOP
L4:
  LOAD_FAST invariants
  POP_JUMP_IF_FALSE L5
  LOAD_FAST invariants
  LOAD_FAST namespace
  LOAD_CONST '__invariants__'
  STORE_SUBSCR
  RETURN_CONST None
L5:
  RETURN_CONST None
END

def _collapse_invariants(bases: List[type], namespace: MutableMapping[str, Any]) -> None:
    """pass"""
    invariants = []
    for base in bases:
        if hasattr(base, '__invariants__'):
            invariants.extend(getattr(base, '__invariants__'))
    if '__invariants__' in namespace:
        invariants.extend(namespace['__invariants__'])
    if invariants:
        namespace['__invariants__'] = invariants


Input:
CODE <module>()
  DOC 'base_preconditions'
  RESUME 0
  LOAD_CONST 'base_preconditions'
  LOAD_NAME List
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  BINARY_SUBSCR
  LOAD_CONST 'bases_have_func'
  LOAD_NAME bool
  LOAD_CONST 'preconditions'
  LOAD_NAME List
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  BINARY_SUBSCR
  LOAD_CONST 'func'
  LOAD_NAME Callable
  LOAD_CONST Ellipsis
  LOAD_NAME Any
  BUILD_TUPLE 2
  BINARY_SUBSCR
  LOAD_CONST 'return'
  LOAD_NAME List
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  BINARY_SUBSCR
  BUILD_TUPLE 10
  LOAD_CONST <code _collapse_preconditions>
  MAKE_FUNCTION annotations
  STORE_NAME _collapse_preconditions
  RETURN_CONST None
END
CODE _collapse_preconditions(base_preconditions, bases_have_func, preconditions, func)
  DOC 'pass'
  RESUME 0
  LOAD_FAST base_preconditions
  POP_JUMP_IF_TRUE L1
  LOAD_FAST bases_have_func
  POP_JUMP_IF_FALSE L1
  LOAD_FAST preconditions
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + TypeError
  LOAD_CONST "The function {} can not weaken the preconditions because the bases specify no preconditions at all. Hence this function must accept all possible input since the preconditions are OR'ed and no precondition implies a dummy precondition which is always fulfilled."
  LOAD_ATTR NULL|self + format
  LOAD_FAST func
  LOAD_ATTR __qualname__
  CALL 1
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_FAST base_preconditions
  LOAD_FAST preconditions
  BINARY_OP +
  RETURN_VALUE
END

def _collapse_preconditions(base_preconditions: List[List[Contract]], bases_have_func: bool, preconditions: List[List[Contract]], func: Callable[..., Any]) -> List[List[Contract]]:
    """pass"""
    if not base_preconditions and bases_have_func and preconditions:
        raise TypeError("The function {} can not weaken the preconditions because the bases specify no preconditions at all. Hence this function must accept all possible input since the preconditions are OR'ed and no precondition implies a dummy precondition which is always fulfilled.".format(func.__qualname__))
    return base_preconditions + preconditions


Input:
CODE <module>()
  DOC 'base_snapshots'
  RESUME 0
  LOAD_CONST 'base_snapshots'
  LOAD_NAME List
  LOAD_NAME Snapshot
  BINARY_SUBSCR
  LOAD_CONST 'snapshots'
  LOAD_NAME List
  LOAD_NAME Snapshot
  BINARY_SUBSCR
  LOAD_CONST 'return'
  LOAD_NAME List
  LOAD_NAME Snapshot
  BINARY_SUBSCR
  BUILD_TUPLE 6
  LOAD_CONST <code _collapse_snapshots>
  MAKE_FUNCTION annotations
  STORE_NAME _collapse_snapshots
  RETURN_CONST None
END
CODE _collapse_snapshots(base_snapshots, snapshots)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + set
  CALL 0
  STORE_FAST seen_names
  LOAD_FAST base_snapshots
  LOAD_FAST snapshots
  BINARY_OP +
  STORE_FAST collapsed
  LOAD_FAST collapsed
  GET_ITER
L1:
  FOR_ITER L3
  STORE_FAST snap
  LOAD_FAST snap
  LOAD_ATTR name
  LOAD_FAST seen_names
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L2
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'There are conflicting snapshots with the name: {!r}.\n\nPlease mind that the snapshots are inherited from the base classes. Does one of the base classes defines a snapshot with the same name?'
  LOAD_ATTR NULL|self + format
  LOAD_FAST snap
  LOAD_ATTR name
  CALL 1
  CALL 1
  RAISE_VARARGS 1
L2:
  LOAD_FAST seen_names
  LOAD_ATTR NULL|self + add
  LOAD_FAST snap
  LOAD_ATTR name
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L3:
  END_FOR
  LOAD_FAST collapsed
  RETURN_VALUE
END

def _collapse_snapshots(base_snapshots: List[Snapshot], snapshots: List[Snapshot]) -> List[Snapshot]:
    """pass"""
    seen_names = set()
    collapsed = base_snapshots + snapshots
    for snap in collapsed:
        if snap.name in seen_names:
            raise ValueError('There are conflicting snapshots with the name: {!r}.\n\nPlease mind that the snapshots are inherited from the base classes. Does one of the base classes defines a snapshot with the same name?'.format(snap.name))
        seen_names.add(snap.name)
    return collapsed


Input:
CODE <module>()
  DOC 'base_postconditions'
  RESUME 0
  LOAD_CONST 'base_postconditions'
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  LOAD_CONST 'postconditions'
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  LOAD_CONST 'return'
  LOAD_NAME List
  LOAD_NAME Contract
  BINARY_SUBSCR
  BUILD_TUPLE 6
  LOAD_CONST <code _collapse_postconditions>
  MAKE_FUNCTION annotations
  STORE_NAME _collapse_postconditions
  RETURN_CONST None
END
CODE _collapse_postconditions(base_postconditions, postconditions)
  DOC 'pass'
  RESUME 0
  LOAD_FAST base_postconditions
  LOAD_FAST postconditions
  BINARY_OP +
  RETURN_VALUE
END

def _collapse_postconditions(base_postconditions: List[Contract], postconditions: List[Contract]) -> List[Contract]:
    """pass"""
    return base_postconditions + postconditions