Collects the attributes from PYQUIL_PROGRAM_PROPERTIES on the Program object program
    into a dictionary.

    :param program: Program to collect attributes from.
    :return: Dictionary of attributes, keyed on the string attribute name.
11278
def _extract_attribute_dictionary_from_program(program: Program) -> Dict[str, Any]:
    
    attrs = {}
    for prop in PYQUIL_PROGRAM_PROPERTIES:
        attrs[prop] = getattr(program, prop)
    return attrs
1322684
def properties(self):
        
        if 'properties' in self._values:
            return self._values['properties']
        self._values['properties'] = copy.deepcopy(self._defaults['properties'])
        return self._values['properties']
902278
def _pys2attributes(self, line):
        """"""

        splitline = self._split_tidy(line)

        selection_data = map(ast.literal_eval, splitline[:5])
        selection = Selection(*selection_data)

        tab = int(splitline[5])

        attrs = {}
        for col, ele in enumerate(splitline[6:]):
            if not (col % 2):
                # Odd entries are keys
                key = ast.literal_eval(ele)

            else:
                # Even cols are values
                attrs[key] = ast.literal_eval(ele)

        self.code_array.cell_attributes.append((selection, tab, attrs))
910703
def to_dict(self):
        
        return {
            'body': self._body,
            'method': self._method,
            'properties': self._properties,
            'channel': self._channel
        }
728416
function extract_program_stats(prog) {
    var stats = {};
    var sources_array = source_stats(prog);

    stats.inputs = input_stats(prog);
    stats.input_total = count_procs(stats.inputs);
    stats.sources = sources_array;
    stats.source_total = sources_array.length;
    stats.reducers = reducer_stats(prog);
    stats.reducer_total = count_procs(stats.reducers);
    stats.functions = function_stats(prog);
    stats.procs = proc_stats(prog);
    stats.proc_total = count_procs(stats.procs);
    stats.views = view_stats(prog);
    stats.view_total = count_procs(stats.views);
    stats.subs = sub_stats(prog);
    stats.imports = import_stats(prog);
    return stats;
}
1144777
def percolate_declares(program: Program) -> Program:
    
    declare_program = Program()
    instrs_program = Program()

    for instr in program:
        if isinstance(instr, Declare):
            declare_program += instr
        else:
            instrs_program += instr

    p = declare_program + instrs_program
    p._defined_gates = program._defined_gates

    return p
1081087
def application_properties(self, value):
        
        self._app_properties = value
        properties = dict(self._app_properties)
        self.message.application_properties = properties
1161929
def _abbrev_program(program: Program, max_len=10):
    
    program_lines = program.out().splitlines()
    if max_len is not None and len(program_lines) > max_len:
        first_n = max_len // 2
        last_n = max_len - first_n
        excluded = len(program_lines) - max_len
        program_lines = (program_lines[:first_n] + [f'... {excluded} instrs not shown ...']
                         + program_lines[-last_n:])

    return '; '.join(program_lines)
12373
def _get_attributes(self, attributes):
    

    params = []

    if isinstance(attributes, dict):
      for attribute_key in attributes.keys():
        attribute_value = attributes.get(attribute_key)
        # Omit attribute values that are not supported by the log endpoint.
        if validator.is_attribute_valid(attribute_key, attribute_value):
          attribute_id = self.config.get_attribute_id(attribute_key)
          if attribute_id:
            params.append({
              'entity_id': attribute_id,
              'key': attribute_key,
              'type': self.EventParams.CUSTOM,
              'value': attribute_value
            })

    # Append Bot Filtering Attribute
    bot_filtering_value = self._get_bot_filtering()
    if isinstance(bot_filtering_value, bool):
      params.append({
          'entity_id': enums.ControlAttributes.BOT_FILTERING,
          'key': enums.ControlAttributes.BOT_FILTERING,
          'type': self.EventParams.CUSTOM,
          'value': bot_filtering_value
      })

    return params
1360917
def to_dict(self):
        '''
        '''
        mapping = dict()
        for attr in dir(self):
            if attr.startswith('_'):
                continue
            if not isinstance(getattr(self.__class__, attr), property):
                continue
            try:
                value = getattr(self, attr)
            except AttributeError:
                if attr in self._OPTIONAL_ATTRS:
                    continue
                else:
                    raise AttributeError(
                        'Required attribute "{0}" does not exist on '
                        'instance of type "{1}.'.format(
                            attr, self.__class__.__name__
                        )
                    )
            mapping[attr] = value
        return mapping
300802
def get_attributes(obj):
    
    if not obj or type(obj) is not dict:
        return {}

    keys = list(obj.keys())
    if len(keys) > 0:
        key = keys[0]
    else:
        return {}
    key_obj = obj.get(key, {})
    if type(key_obj) is not dict:
        # if the object is not a dict
        # it is probably already scoped to attributes
        return obj
    if key != "attributes":
        attrs = key_obj.get('attributes')
        if type(attrs) is not dict:
            # if the attributes doesn't exist,
            # it is probably already scoped to attributes
            return obj
    else:
        # if the attributes exist, we return the value, except if it's not a dict type
        attrs = key_obj
        if type(attrs) is not dict:
            return obj

    return attrs
908170
def parse(self):
        
        (options, args) = self.parser.parse_args()
        self._set_attributes(args, options)
        return self._create_dictionary()
145705
def _get_attributes(self, path):
        
        path_grp = self.handle[path]
        path_attr = path_grp.attrs
        return dict(path_attr)
1201363
def attributes(attrs):
    
    attrs = attrs or {}
    ident = attrs.get("id", "")
    classes = attrs.get("classes", [])
    keyvals = [[x, attrs[x]] for x in attrs if (x != "classes" and x != "id")]
    return [ident, classes, keyvals]
217776
def getEncodableAttributes(self, obj, codec=None):
        
        if not self._compiled:
            self.compile()

        if self.is_dict:
            return dict(obj)

        if self.shortcut_encode and self.dynamic:
            return obj.__dict__.copy()

        attrs = {}

        if self.static_attrs:
            for attr in self.static_attrs:
                attrs[attr] = getattr(obj, attr, pyamf.Undefined)

        if not self.dynamic:
            if self.non_static_encodable_properties:
                for attr in self.non_static_encodable_properties:
                    attrs[attr] = getattr(obj, attr)

            return attrs

        dynamic_props = util.get_properties(obj)

        if not self.shortcut_encode:
            dynamic_props = set(dynamic_props)

            if self.encodable_properties:
                dynamic_props.update(self.encodable_properties)

            if self.static_attrs:
                dynamic_props.difference_update(self.static_attrs)

            if self.exclude_attrs:
                dynamic_props.difference_update(self.exclude_attrs)

        for attr in dynamic_props:
            attrs[attr] = getattr(obj, attr)

        if self.proxy_attrs is not None and attrs and codec:
            context = codec.context

            for k, v in attrs.copy().iteritems():
                if k in self.proxy_attrs:
                    attrs[k] = context.getProxyForObject(v)

        if self.synonym_attrs:
            missing = object()

            for k, v in self.synonym_attrs.iteritems():
                value = attrs.pop(k, missing)

                if value is missing:
                    continue

                attrs[v] = value

        return attrs
148004
def attrs(self):
        
        return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk")
1188069
def _attributes2pys(self):
        

        # Remove doublettes
        purged_cell_attributes = []
        purged_cell_attributes_keys = []
        for selection, tab, attr_dict in self.code_array.cell_attributes:
            if purged_cell_attributes_keys and \
               (selection, tab) == purged_cell_attributes_keys[-1]:
                purged_cell_attributes[-1][2].update(attr_dict)
            else:
                purged_cell_attributes_keys.append((selection, tab))
                purged_cell_attributes.append([selection, tab, attr_dict])

        for selection, tab, attr_dict in purged_cell_attributes:
            sel_list = [selection.block_tl, selection.block_br,
                        selection.rows, selection.cols, selection.cells]

            tab_list = [tab]

            attr_dict_list = []
            for key in attr_dict:
                attr_dict_list.append(key)
                attr_dict_list.append(attr_dict[key])

                if config["font_save_enabled"] and key == 'textfont':
                    self.fonts_used.append(attr_dict[key])

            line_list = map(repr, sel_list + tab_list + attr_dict_list)

            self.pys_file.write(u"\t".join(line_list) + u"\n")