Exemple #1
0
 def decode(self, obj):
     if len(obj) == 1:
         tag, val = first(obj.items())
         info = self.tags.get(tag)
         if info:
             return info["decoder"](val)
     return obj
Exemple #2
0
    def get_method_checkout_phase_object(self):
        """
        :rtype: E-Commerce.front.checkout.CheckoutPhaseViewMixin|None
        """
        if hasattr(self, "_checkout_phase_object"):
            return self._checkout_phase_object

        method = self.get_method()
        if not method:
            return None
        phases = get_checkout_phases_for_service(self.checkout_process, method)
        phase = first(phases)
        if not phase:
            return None
        self._checkout_phase_object = phase
        return phase
Exemple #3
0
    def get_context_data(self, **kwargs):
        context = super(AddonUploadConfirmView, self).get_context_data(**kwargs)

        with zipfile.ZipFile(self.get_addon_path()) as zf:
            context["filenames"] = sorted(zf.namelist())
            pkg_info_path = first(filename for filename in context["filenames"] if filename.endswith("PKG-INFO"))
            if pkg_info_path:
                context["pkg_info"] = zf.read(pkg_info_path).decode("UTF-8", "replace")

        context["toolbar"] = Toolbar([
            PostActionButton(
                icon="fa fa-download",
                form_id="install_form",
                text=_("Install Addon"),
                extra_css_class="btn-success",
            )
        ], view=self)
        return context
Exemple #4
0
def morph(rule, result):

    if rule in result:  # if our rule is contained in the right hand side of a rule,
        found = False
        br = False
        for letter in result:
            print(letter)
            if letter == rule:
                found = True
            if found:
                br = True
                # here we are following our symbol, so now we apply rules.
                #print(letter)
                fn = first(letter, cfg)
                if "@" in fn:
                    br = False
                    fn.remove("@")
                if rule not in follows:
                    f[rule] = fn
                else:
                    f[rule] += fn
            if br:
                break
Exemple #5
0
def get_taxes_of_effective_rules(taxing_context, tax_rules):
    """
    Get taxes grouped by priority from effective tax rules.

    Effective tax rules is determined by first limiting the scope to the
    rules that match the given taxing context (see `TaxRule.match`) and
    then further limiting the matching rules by selecting only the rules
    in the highest numbered override group.

    The `Tax` objects in the effective rules will be grouped by the
    priority of the rules.  The tax groups are returned as list of tax
    lists.

    :type taxing_context: E-Commerce.core.taxing.TaxingContext
    :param tax_rules:
      Tax rules to filter from.  These should be ordered desceding by
      override group and then ascending by priority.
    :type tax_rules: Iterable[TaxRule]
    :rtype: list[list[E-Commerce.core.models.Tax]]
    """
    # Limit our scope to only matching rules
    matching_rules = (
        tax_rule for tax_rule in tax_rules
        if tax_rule.matches(taxing_context))

    # Further limit our scope to the highest numbered override group
    grouped_by_override = groupby(matching_rules, attrgetter('override_group'))
    highest_override_group = first(grouped_by_override, (None, []))[1]

    # Group rules by priority
    grouped_rules = groupby(highest_override_group, attrgetter('priority'))
    tax_groups = [
        [rule.tax for rule in rules]
        for (_, rules) in grouped_rules]

    return tax_groups
Exemple #6
0
Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    cal.hello()
AttributeError: 'Student1' object has no attribute 'hello'
>>> cal=Student1()
>>> cal.result()
Sum is:  30
Sub is:  -10
>>> 
 RESTART: C:/Users/Monika/AppData/Local/Programs/Python/Python36-32/Programs/student5.py 
>>> stud=Student()
Traceback (most recent call last):
  File "<pyshell#68>", line 1, in <module>
    stud=Student()
NameError: name 'Student' is not defined
>>> stud=first()
Traceback (most recent call last):
  File "<pyshell#69>", line 1, in <module>
    stud=first()
TypeError: __init__() missing 2 required positional arguments: 'x' and 'y'
>>> stud=first(6,3)
>>> stud.add()
Addition is:  9
>>> stud.sub()
Substraction is:  3
>>> 
 RESTART: C:/Users/Monika/AppData/Local/Programs/Python/Python36-32/Programs/Inheritance.py 
Traceback (most recent call last):
  File "C:/Users/Monika/AppData/Local/Programs/Python/Python36-32/Programs/Inheritance.py", line 1, in <module>
    from first import *
ModuleNotFoundError: No module named 'first'
Exemple #7
0
 def get_suppliers_column(iterable):
     return first([col for col in iterable if col.id in ["suppliers", "shopproduct_suppliers"]], default=None)
Exemple #8
0
 def current_pane(self):
     pane_id = self.request.POST.get("pane_id")
     return first(filter(lambda x: x.identifier == pane_id, self.panes), None)
Exemple #9
0
_sage_const_2 = Integer(2)
_sage_const_20 = Integer(20)
_sage_const_0 = Integer(0)
_sage_const_1 = Integer(1)  #!/usr/bin/env sage
# -*- coding: utf-8 -*-

import sys

sys.path.append("/usr/lib/pymodules/python2.6/")

from sage.all import *
from first import *
from sorti import *
from random import *

DenSource = first(Primes(), _sage_const_20)
Rats = []

for Den in DenSource:
    for Num in range(_sage_const_1, Den):

        Rats.append(Num / Den)

LA = Rats[:-_sage_const_1]
LB = Rats[_sage_const_1:]

A = [[_sage_const_0, _sage_const_0], [_sage_const_1, _sage_const_1]] + [[a, None] for a in LA]
B = [[_sage_const_0, True], [_sage_const_1, True]] + [[b, False] for b in LB]

AI, AIR = sorti(A, lambda (a1, b1), (a2, b2): int(sign(a1 - a2)))
Exemple #10
0
	p = Process(target=cci, args=(50, "long_term", long_id, basic_id))
	p.start()
	processes.append(p)
	p = Process(target=pivots, args=(30, "long_term", long_id, basic_id))
	p.start()
	processes.append(p)
	p = Process(target=rsi, args=(25, "long_term", long_id, basic_id))
	p.start()
	processes.append(p)
	p = Process(target=atr, args=(50, "long_term", long_id, basic_id))
	p.start()
	processes.append(p)
	p = Process(target=stoch, args=(3, "long_term", long_id, basic_id))
	p.start()
	processes.append(p)
	first("short_term", short_id);
	final(1)
	for p in processes:
		p.join()

	p = Process(target=subsector)
	p.start()
	processes.append(p)
	p = Process(target=industry)
	p.start()
	processes.append(p)
	for p in processes:
		p.join()

	#############################################
	# Fifth Step								#
Exemple #11
0
 def get_selected_reload_method(self):
     return first(rm for rm in self.reload_methods if rm.identifier == self.cleaned_data["reload_method"])
Exemple #12
0
 def get_by_object(self, obj):
     return first(
         form_info for form_info in self.values() if isinstance(obj, form_info.model))