django.utils.datastructures.SortedDict

Here are the examples of the python api django.utils.datastructures.SortedDict taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: talk.org
Source File: options.py
View license
    def __init__(self, meta):
        self.local_fields, self.local_many_to_many = [], []
        self.module_name, self.verbose_name = None, None
        self.verbose_name_plural = None
        self.db_table = ''
        self.ordering = []
        self.unique_together =  []
        self.permissions =  []
        self.object_name, self.app_label = None, None
        self.get_latest_by = None
        self.order_with_respect_to = None
        self.db_tablespace = settings.DEFAULT_TABLESPACE
        self.admin = None
        self.meta = meta
        self.pk = None
        self.has_auto_field, self.auto_field = False, None
        self.one_to_one_field = None
        self.abstract = False
        self.parents = SortedDict()

Example 2

Project: talk.org
Source File: options.py
View license
    def _fill_related_objects_cache(self):
        cache = SortedDict()
        parent_list = self.get_parent_list()
        for parent in self.parents:
            for obj, model in parent._meta.get_all_related_objects_with_model():
                if (obj.field.creation_counter < 0 or obj.field.rel.parent_link) and obj.model not in parent_list:
                    continue
                if not model:
                    cache[obj] = parent
                else:
                    cache[obj] = model
        for klass in get_models():
            for f in klass._meta.local_fields:
                if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
                    cache[RelatedObject(f.rel.to, klass, f)] = None
        self._related_objects_cache = cache

Example 3

Project: talk.org
Source File: options.py
View license
    def _fill_related_many_to_many_cache(self):
        cache = SortedDict()
        parent_list = self.get_parent_list()
        for parent in self.parents:
            for obj, model in parent._meta.get_all_related_m2m_objects_with_model():
                if obj.field.creation_counter < 0 and obj.model not in parent_list:
                    continue
                if not model:
                    cache[obj] = parent
                else:
                    cache[obj] = model
        for klass in get_models():
            for f in klass._meta.local_many_to_many:
                if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
                    cache[RelatedObject(f.rel.to, klass, f)] = None
        if app_cache_ready():
            self._related_many_to_many_cache = cache
        return cache

Example 4

View license
def patterns(*args):
    subdomains = SortedDict()

    for x in args:
        name = x['name']

        if name in subdomains:
            raise ImproperlyConfigured("Duplicate subdomain name: %s" % name)

        subdomains[name] = x

    return subdomains

Example 5

Project: qualitio
Source File: filter.py
View license
    def build_form(self, form_class_id, form_id, initial=None):
        form_class = self.form_classes[form_class_id]
        form_for_class = self.forms.get(form_class, SortedDict())
        if form_id not in form_for_class:
            form = form_class(data=self.data, initial=initial, prefix=self.get_prefix(form_class, form_id))
            form_for_class[form_id] = form
            self.forms[form_class] = form_for_class
        return self.forms[form_class][form_id]

Example 6

Project: qualitio
Source File: filter.py
View license
    def __init__(self, data=None, form_classes=()):
        self.data = data
        self.groups = SortedDict()
        self.form_classes = form_classes or self.get_form_classes()
        self.has_control_params = False
        self.sort_by = None

Example 7

Project: reviewboard
Source File: pages.py
View license
    def get_js_view_data(self):
        """Get data to pass to the JavaScript view."""
        # Fetch the list of the user's API tokens, globally.
        api_tokens = self.user.webapi_tokens.all()

        # Group the API tokens by LocalSite or the global site.
        serialized_api_tokens = SortedDict()
        serialized_api_tokens[''] = \
            self._serialize_api_tokens(None, api_tokens)

        for local_site in self.page.config_view.ordered_user_local_sites:
            serialized_api_tokens[local_site.name] = \
                self._serialize_api_tokens(local_site, api_tokens)

        return {
            'apiTokens': serialized_api_tokens,
        }

Example 8

Project: reviewboard
Source File: pages.py
View license
    def get_js_view_data(self):
        """Get data to pass to the JavaScript view."""
        # Fetch the list of IDs of groups the user has joined.
        joined_group_ids = self.user.review_groups.values_list('pk', flat=True)

        # Fetch the list of groups available to the user.
        serialized_groups = SortedDict()
        serialized_groups[''] = self._serialize_groups(None, joined_group_ids)

        for local_site in self.page.config_view.ordered_user_local_sites:
            serialized_groups[local_site.name] = self._serialize_groups(
                local_site, joined_group_ids)

        return {
            'groups': serialized_groups,
        }

Example 9

Project: django-basic-stats
Source File: views.py
View license
    def _android_versions(self):
        result = SortedDict()
        versions = ['android 2.1', 'android 2.2', 'android 2.3',
                    'android 4.0', 'android 4.1', 'android 4.2', 'android 4.3']
        for version in versions:
            result[version] = self._device_entries(version).count()
        return result

Example 10

Project: django-simple-open-graph
Source File: utils.py
View license
def string_to_dict(string):
    dict = SortedDict()
    if string:
        string = str(string)
        for arg in string.split(','):
            arg = arg.strip()
            key, value = arg.split('=', 1)

            if key in dict:
                current_value = dict[key]
                if type(current_value) == list:
                    dict[key].append(value)
                else:
                    dict[key] = [current_value, value]                    
            else:
                dict[key] = value
    return dict

Example 11

Project: django-form-designer
Source File: models.py
View license
    def get_field_dict(self):
        field_dict = SortedDict()
        names = []
        for field in self.formdefinitionfield_set.all():
            field_dict[field.name] = field
        return field_dict

Example 12

Project: django-dredis-cache
Source File: cache.py
View license
    def get_many(self, keys, version=None):
        """
        Retrieve many keys.
        """
        recovered_data = SortedDict()
        new_keys = map(lambda key: self.make_key(key, version=version), keys)
        map_keys = dict(zip(new_keys, keys))
        caches = self.get_caches(new_keys)
        for cache, keys in caches.items():
            values = cache.mget(keys)
            for key, value in zip(keys, values):
                if value is None:
                    continue
                value = self.unpickle(value)
                if isinstance(value, basestring):
                    value = smart_unicode(value)
                recovered_data[map_keys[key]] = value
        return recovered_data

Example 13

Project: django-shrink
Source File: shrink.py
View license
    def __init__(self, parser, token):
        bits = token.split_contents()
        if len(bits) < 2:
            raise TemplateSyntaxError(self.error_message)
        self.destination = bits[1].strip('\'"')
        attrs = SortedDict()
        for bit in bits[2:]:
            m = kw_pat.match(bit)
            if not m:
                raise TemplateSyntaxError(self.error_message)
            attrs[m.group('key')] = m.group('value')
        self.attrs = flatatt(attrs)
        self.nodelist = parser.parse((self.endtag,))
        parser.delete_first_token()

Example 14

Project: jaikuenginepatch
Source File: ragendjatags.py
View license
@register.simple_tag
def include_form_fields(form=None, fields=None, as_choice='as_table',
        global_errors=True):
    fields=fields.replace(' ', '').split(',')
    if not global_errors:
        form.errors[NON_FIELD_ERRORS] = form.error_class()
    
    fields_backup = deepcopy(form.fields)
                    
    form.fields = SortedDict()
    for field in fields:
        if field in fields_backup:
            form.fields[field] = fields_backup[field]
                
    resulting_text = getattr(form, as_choice)()
    
    form.fields = fields_backup
    return resulting_text

Example 15

Project: django-fancypages
Source File: library.py
View license
def get_grouped_content_blocks():
    blocks = {}
    for block in _content_blocks.values():
        if block._meta.abstract:
            continue
        if not block.name or not block.code:
            raise ImproperlyConfigured(
                "a block model has to provide a 'name' and 'code' attributes"
            )
        group = getattr(block, 'group', _('Ungrouped'))
        blocks.setdefault(unicode(group), []).append({
            'code': block.code,
            'name': unicode(block.name)
        })
    # we now have to sort the the groups alphabetically
    return SortedDict([(g, blocks[g]) for g in sorted(blocks.keys())])

Example 16

Project: WAPT
Source File: utils.py
View license
    def safe_summary(self, encoded):
        from django.contrib.auth.hashers import mask_hash
        from django.utils.translation import ugettext_noop as _
        from django.utils.datastructures import SortedDict
        handler = self.passlib_handler
        items = [
            # since this is user-facing, we're reporting passlib's name,
            # without the distracting PASSLIB_HASHER_PREFIX prepended.
            (_('algorithm'), handler.name),
        ]
        if hasattr(handler, "parsehash"):
            kwds = handler.parsehash(encoded, sanitize=mask_hash)
            for key, value in iteritems(kwds):
                key = self._translate_kwds.get(key, key)
                items.append((_(key), value))
        return SortedDict(items)

Example 17

Project: transifex
Source File: fieldsets.py
View license
    def render(self, context):
        form = template.Variable(self.form_variable).resolve(context)
        new_form = copy.copy(form)
        new_form.fields = SortedDict(
            [(key, form.fields[key]) for key in self.fields]
        )
        context[self.variable_name] = new_form
        return u''

Example 18

Project: couchdbkit
Source File: loading.py
View license
    def register_schema(self, app_label, *schema):
        """ register a Document object"""
        for s in schema:
            schema_name = schema[0].__name__.lower()
            schema_dict = self.app_schema.setdefault(app_label, SortedDict())
            if schema_name in schema_dict:
                fname1 = os.path.abspath(sys.modules[s.__module__].__file__)
                fname2 = os.path.abspath(sys.modules[schema_dict[schema_name].__module__].__file__)
                if os.path.splitext(fname1)[0] == os.path.splitext(fname2)[0]:
                    continue
            schema_dict[schema_name] = s

Example 19

Project: django-mptt
Source File: models.py
View license
    def populate_tree_cache(self):
        # Cache has already been filled
        if self._children_cache is not None:
            return
        opts = self._meta
        nodes = self._tree_manager.filter(**{
                    opts.tree_id_attr: getattr(self, opts.tree_id_attr)})
        node_dict = SortedDict([(n.pk, n) for n in nodes])
        for node in node_dict.values():
            if node == self:
                node = node_dict[node.pk] = self
            # _children_cache will only be modified up the tree, so initialise
            # it when we're going down
            node._children_cache = []
            # Ensure parent points to our object with the cache
            parent_id = getattr(node, '%s_id' % opts.parent_attr)
            if parent_id is not None:
                setattr(node, opts.parent_attr, node_dict[parent_id])
                node_dict[parent_id]._children_cache.append(node)

Example 20

Project: Roll-Your-Own
Source File: summary.py
View license
    def __init__(self, meta_options, summary_attrs):
        self.locale = getattr(meta_options, 'locale', None)
        self.currency = getattr(meta_options, 'currency', None)
        self.decimal_html = getattr(meta_options, 'decimal_html', None)

        self.elements = SortedDict()
        self.items = SortedDict()
        self.extras = SortedDict()
        self.totals = SortedDict()

Example 21

Project: django-remote-forms
Source File: widgets.py
View license
    def as_dict(self):
        widget_dict = SortedDict()
        widget_dict['title'] = self.widget.__class__.__name__
        widget_dict['name'] = self.widget.name
        widget_dict['value'] = self.widget.value
        widget_dict['attrs'] = self.widget.attrs
        widget_dict['choices'] = self.widget.choices
        widget_dict['input_type'] = 'radio'

        return widget_dict

Example 22

Project: django-autoreports
Source File: api.py
View license
    def get_fields_of_form(self, report=None):
        fields_form_filter = SortedDict({})
        fields_form_display = SortedDict({})
        if report and report.options:
            report_options_order = get_ordered_fields(report)
            for field_name, opts in report_options_order:
                fields_form_filter, fields_form_display = self.get_field_of_form(field_name, opts,
                                                               fields_form_filter=fields_form_filter,
                                                               fields_form_display=fields_form_display)
        else:
            for field_name in self.get_report_filter_fields():
                fields_form_filter, fields_form_display = self.get_field_of_form(field_name, default=True,
                                                               fields_form_filter=fields_form_filter,
                                                               fields_form_display=fields_form_display)
            for field_name in self.get_report_display_fields():
                fields_form_filter, fields_form_display = self.get_field_of_form(field_name, default=False,
                                                               fields_form_filter=fields_form_filter,
                                                               fields_form_display=fields_form_display)
        return (fields_form_filter, fields_form_display)

Example 23

Project: django-dockit
Source File: loading.py
View license
    def register_indexes(self, app_label, *indexes):
        index_dict = self.app_indexes.setdefault(app_label, SortedDict())
        for index in indexes:
            index_name = index.global_hash()
            if index_name in index_dict:
                continue
            index_dict[index_name] = index
        if self.app_cache_ready():
            self.register_indexes_with_backend(indexes)
            self.post_app_ready() #TODO find a better solution, like on_app_ready
        else:
            self.pending_indexes.extend(indexes)

Example 24

Project: django-dockit
Source File: options.py
View license
    def contribute_to_class(self, cls, name):
        #the following needs to happen after fields are populated
        if self.typed_field:
            if self.typed_key:
                if self.virtual:
                    raise TypeError("Virtual Schemas may not have a typed_key")
                #CONSIDER this will break if fields are registered after the meta, gennerally have the virtual create the field for you
                if self.typed_field not in self.fields:
                    raise TypeError("Non-virtual Schemas that specify a typed field and a typed key must have that typed field defined.")
                self.fields[self.typed_field].schemas[self.typed_key] = cls
                self.proxy = True
            else:
                #if not self.virtual:
                #    raise TypeError("Schemas that specify a typed_field and not a typed_key must be virtual.")
                if self.typed_field not in self.fields:
                    from dockit.schema.fields import SchemaTypeField
                    self.polymorphic_schemas = SortedDict()
                    field = SchemaTypeField(self.polymorphic_schemas, editable=False)
                    field.contribute_to_class(cls, self.typed_field)

Example 25

Project: django-hyperadmin
Source File: resources.py
View license
    def register_endpoints(self):
        self.endpoints = SortedDict()
        for endpoint_cls, kwargs in self.get_view_endpoints():
            self._register_endpoint(endpoint_cls, **kwargs)
        for key, endpoint in self._installed_endpoints.iteritems():
            self.endpoints[key] = self.fork(**self.get_endpoint_kwargs())

Example 26

View license
    @property
    def contributor_dict(self):
        d = SortedDict({})
        for k, v in self.to_dict().items():
            if k.startswith("contributor"):
                d[k.replace("contributor ", "")] = v
        return d

Example 27

View license
    @property
    def intermediary_dict(self):
        d = SortedDict({})
        for k, v in self.to_dict().items():
            if k.startswith("intermediary"):
                d[k.replace("intermediary ", "")] = v
        return d

Example 28

Project: cgstudiomap
Source File: utils.py
View license
    def safe_summary(self, encoded):
        from django.contrib.auth.hashers import mask_hash
        from django.utils.translation import ugettext_noop as _
        from django.utils.datastructures import SortedDict
        handler = self.passlib_handler
        items = [
            # since this is user-facing, we're reporting passlib's name,
            # without the distracting PASSLIB_HASHER_PREFIX prepended.
            (_('algorithm'), handler.name),
        ]
        if hasattr(handler, "parsehash"):
            kwds = handler.parsehash(encoded, sanitize=mask_hash)
            for key, value in iteritems(kwds):
                key = self._translate_kwds.get(key, key)
                items.append((_(key), value))
        return SortedDict(items)

Example 29

Project: 1flow
Source File: admin.py
View license
    def get_actions(self, request):

        try:
            self.actions.append('csv_export')

        except AttributeError:
            self.actions = ('csv_export', )

        actions = super(CSVAdminMixin, self).get_actions(request)

        return actions or SortedDict()

Example 30

Project: django-compositepks
Source File: loading.py
View license
    def get_models(self, app_mod=None):
        """
        Given a module containing models, returns a list of the models.
        Otherwise returns a list of all installed models.
        """
        self._populate()
        if app_mod:
            return self.app_models.get(app_mod.__name__.split('.')[-2], SortedDict()).values()
        else:
            model_list = []
            for app_entry in self.app_models.itervalues():
                model_list.extend(app_entry.values())
            return model_list

Example 31

Project: django-compositepks
Source File: loading.py
View license
    def get_model(self, app_label, model_name, seed_cache=True):
        """
        Returns the model matching the given app_label and case-insensitive
        model_name.

        Returns None if no model is found.
        """
        if seed_cache:
            self._populate()
        return self.app_models.get(app_label, SortedDict()).get(model_name.lower())

Example 32

Project: django-compositepks
Source File: options.py
View license
    def _fill_related_many_to_many_cache(self):
        cache = SortedDict()
        parent_list = self.get_parent_list()
        for parent in self.parents:
            for obj, model in parent._meta.get_all_related_m2m_objects_with_model():
                if obj.field.creation_counter < 0 and obj.model not in parent_list:
                    continue
                if not model:
                    cache[obj] = parent
                else:
                    cache[obj] = model
        for klass in get_models():
            for f in klass._meta.local_many_to_many:
                if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
                    cache[RelatedObject(f.rel.to, klass, f)] = None
        if app_cache_ready():
            self._related_many_to_many_cache = cache
        return cache

Example 33

View license
def find_static_files(cache_root, ignore_patterns=()):
    found_files = SortedDict()
    for finder in finders.get_finders():
        for path, storage in finder.list(ignore_patterns):
            abspath = storage.path(path)
            # ensure we dont include any files which are part of the cache
            # root as it will invalidate the real files
            if abspath.startswith(cache_root):
                continue
            found_files[path] = abspath
    return found_files

Example 34

Project: nexus-memcache
Source File: nexus_modules.py
View license
    def index(self, request):
        try:
            cache_stats = ((k, SortedDict(sorted(v.iteritems(), key=lambda x: x[0]))) for k, v in self.get_stats())
        except AttributeError:
            cache_stats = []
        
        return self.render_to_response("nexus/memcache/index.html", {
            'cache_stats': cache_stats,
        }, request)

Example 35

Project: djangorest-alchemy
Source File: serializers.py
View license
    def get_fields(self):
        ret = SortedDict()

        try:
            # URI field for get pk field
            pk_field = primary_key(self.cls.__class__)

            request = self.context['request']
            ret["href"] = AlchemyUriField(
                source=pk_field,
                path=request.build_absolute_uri(request.path),
                read_only=True,
            )
        except KeyNotFoundException:
            return super(AlchemyListSerializer, self).get_fields()

        return ret

Example 36

Project: nexus
Source File: sites.py
View license
    def __init__(self, name=None, app_name='nexus'):
        self._registry = {}
        self._categories = SortedDict()
        if name is None:
            self.name = 'nexus'
        else:
            self.name = name
        self.app_name = app_name

Example 37

Project: dndtools
Source File: filterset.py
View license
def filters_for_model(model, fields=None, exclude=None, filter_for_field=None):
    field_dict = SortedDict()
    opts = model._meta
    if fields is None:
        fields = [f.name for f in sorted(opts.fields + opts.many_to_many)]
    for f in fields:
        if exclude is not None and f in exclude:
            continue
        field = get_model_field(model, f)
        if field is None:
            field_dict[f] = None
            continue
        filter_ = filter_for_field(field, f)
        if filter_:
            field_dict[f] = filter_
    return field_dict

Example 38

Project: dndtools
Source File: filterset.py
View license
    @property
    def form(self):
        if not hasattr(self, '_form'):
            fields = SortedDict([(name, filter_.field) for name, filter_ in self.filters.iteritems()])
            fields[ORDER_BY_FIELD] = self.ordering_field
            Form =  type('%sForm' % self.__class__.__name__, (self._meta.form,), fields)
            if self.is_bound:
                self._form = Form(self.data, prefix=self.form_prefix)
            else:
                self._form = Form(prefix=self.form_prefix)
        return self._form

Example 39

Project: fumblerooski
Source File: charts.py
View license
    def __init__(self):
        # Use a SortedDict for the opeions so they are added in a
        # deterministic manner; this eases things like dealing with cache keys 
        # or writing unit tests.
        self.options = SortedDict()
        self.datasets = []
        self.axes = []
        self.datarange = None
        self.alt = None

Example 40

Project: ecobasa
Source File: profile.py
View license
    def get_fields(self):
        """
        Overwriting this, because otherwise we get a:

        Cannot set required=True and read_only=True

        /ecobasa/lib/python2.7/site-packages/rest_framework/fields.py in __init__
        assert not (read_only and required), "Cannot set required=True and read_only=True"

        coming from:
        /ecobasa/src/cosinnus/cosinnus/models/serializers/profile.py in UserSimpleSerializer
        profile = _UserProfileSerializer(source='cosinnus_profile', many=False, read_only=True)

        Since we don't need this whole serialisation at the moment, this sort
        it fixes the issue. Once we want to use serialisation, remove this and
        implement this class properly. TODO
        """
        return SortedDict()

Example 41

Project: djep
Source File: cms_plugins.py
View license
    def render(self, context, instance, placeholder):
        schedule = utils.create_schedule(row_duration=instance.row_duration,
                                         merge_sections=instance.merge_sections)
        incl_sections = instance.sections.all()
        if not incl_sections:
            schedule = schedule
        else:
            s = SortedDict()
            for k, v in schedule.iteritems():
                if k in incl_sections:
                    s[k] = v
            schedule = s
        context.update({
            'instance': instance,
            'schedule': schedule,
            'placeholder': placeholder,
        })
        return context

Example 42

Project: element43
Source File: views.py
View license
    def metadata(self, request):
        """
        Return a dictionary of metadata about the view.
        Used to return responses for OPTIONS requests.
        """

        # This is used by ViewSets to disambiguate instance vs list views
        view_name_suffix = getattr(self, 'suffix', None)

        # By default we can't provide any form-like information, however the
        # generic views override this implementation and add additional
        # information for POST and PUT methods, based on the serializer.
        ret = SortedDict()
        ret['name'] = get_view_name(self.__class__, view_name_suffix)
        ret['description'] = get_view_description(self.__class__)
        ret['renders'] = [renderer.media_type for renderer in self.renderer_classes]
        ret['parses'] = [parser.media_type for parser in self.parser_classes]
        ret['filters'] = OrdersFilter.Meta.fields
        return ret

Example 43

Project: element43
Source File: views.py
View license
    def metadata(self, request):
        """
        Return a dictionary of metadata about the view.
        Used to return responses for OPTIONS requests.
        """

        # This is used by ViewSets to disambiguate instance vs list views
        view_name_suffix = getattr(self, 'suffix', None)

        # By default we can't provide any form-like information, however the
        # generic views override this implementation and add additional
        # information for POST and PUT methods, based on the serializer.
        ret = SortedDict()
        ret['name'] = get_view_name(self.__class__, view_name_suffix)
        ret['description'] = get_view_description(self.__class__)
        ret['renders'] = [renderer.media_type for renderer in self.renderer_classes]
        ret['parses'] = [parser.media_type for parser in self.parser_classes]
        ret['filters'] = ItemRegionStatFilter.Meta.fields
        return ret

Example 44

Project: element43
Source File: views.py
View license
    def metadata(self, request):
        """
        Return a dictionary of metadata about the view.
        Used to return responses for OPTIONS requests.
        """

        # This is used by ViewSets to disambiguate instance vs list views
        view_name_suffix = getattr(self, 'suffix', None)

        # By default we can't provide any form-like information, however the
        # generic views override this implementation and add additional
        # information for POST and PUT methods, based on the serializer.
        ret = SortedDict()
        ret['name'] = get_view_name(self.__class__, view_name_suffix)
        ret['description'] = get_view_description(self.__class__)
        ret['renders'] = [renderer.media_type for renderer in self.renderer_classes]
        ret['parses'] = [parser.media_type for parser in self.parser_classes]
        ret['filters'] = OrderHistoryFilter.Meta.fields
        return ret

Example 45

Project: zipfelchappe
Source File: models.py
View license
    def extraform(self):
        """ Returns additional form required to pledge to this project """
        fields = SortedDict()

        for field in self.extrafields.all():
            field.add_formfield(fields, self)

        return type(b'Form%s' % self.pk, (forms.Form,), fields)

Example 46

Project: django-dashvisor
Source File: file.py
View license
    def __init__(self):
        self.servers = SortedDict()
        fp = open(settings.DASHVISOR_CONFIG_FILE)
        index = 0
        for line in fp.xreadlines():
            id = str(index)
            server = Server(line.strip(), id=id)
            self.servers[id] = server
            index += 1
        fp.close()

Example 47

Project: django-dashvisor
Source File: server.py
View license
    def refresh(self):
        self.status = SortedDict(("%s:%s" % (i['group'], i['name']), i) for i in self.connection.supervisor.getAllProcessInfo())
        for key, program in self.status.items():
            program['id'] = key
            program['human_name'] = program['name']
            if program['name'] != program['group']:
                program['human_name'] = "%s:%s" % (program['group'], program['name'])

Example 48

Project: django-sha2
Source File: hashers.py
View license
    def safe_summary(self, encoded):
        algorithm, salt, hash = encoded.split('$', 2)
        assert algorithm == self.algorithm
        return SortedDict([
            ('algorithm', algorithm),
            ('salt', mask_hash(salt, show=2)),
            ('hash', mask_hash(hash)),
        ])

Example 49

Project: baobab
Source File: handle_south.py
View license
    @classmethod
    def get_apps(cls):
        if not cls.apps:
            app = filter(lambda x: x.startswith('baobab.'),
                         settings.INSTALLED_APPS)
            app = map(lambda x: x.rsplit('.', 1)[1], app)
            ignore = ['ignore'] * len(app)
            cls.apps = SortedDict(zip(app, ignore))
        return cls.apps

Example 50

Project: Geotrek-admin
Source File: middleware.py
View license
def get_language_from_path(path):
    from django.conf import settings
    supported = SortedDict(settings.LANGUAGES)
    regex_match = language_code_prefix_re.match(path)
    if not regex_match:
        return None
    lang_code = regex_match.group(1)
    try:
        return get_supported_language_variant(lang_code, supported)
    except LookupError:
        return None