Beispiel #1
0
 def __init__(self,
              component_type,
              key=None,
              list=None,
              name=None,
              **kwargs):
     self.component_type = component_type
     self.key = key or 'name'
     self.name = name or component_type.__name__
     if not isinstance(component_type, type):
         raise UtilitiesError(
             "component_type arg for {} ({}) must be a class".format(
                 self.name, component_type))
     if not isinstance(self.key, str):
         raise UtilitiesError("key arg for {} ({}) must be a string".format(
             self.name, self.key))
     if not hasattr(component_type, self.key):
         raise UtilitiesError(
             "key arg for {} (\'{}\') must be an attribute of {}".format(
                 self.name, self.key, component_type.__name__))
     if list is not None:
         if not all(isinstance(obj, self.component_type) for obj in list):
             raise UtilitiesError(
                 "All of the items in the list arg for {} "
                 "must be of the type specified in the component_type arg ({})"
                 .format(self.name, self.component_type.__name__))
     UserList.__init__(self, list, **kwargs)
Beispiel #2
0
 def __init__(self, dir, filename=None, parser=parseint89, elmin=None):
     UserList.__init__(self)
     if filename is None:
         if not canread(dir):
             raise ValueError('Given path ' + dir +
                              ' does not lead to a readable file.')
         filename = os.path.basename(dir)
         dir = os.path.dirname(dir)
     self.site = filename[:4]
     self.doy = int(filename[4:7])
     self.year = fullyear(int(filename[9:11]))
     try:
         self.rxloc = sitelocs[self.site]
     except KeyError:
         info(
             'First four characters of filename, ' + self.site +
             ', are not a recognized site name. Receiver location unknown.')
     with fileread(os.path.join(dir, filename)) as fid:
         for l in fid:
             try:
                 rec = parser(l)
             except ValueError as e:
                 info(e, end=' on line ' + str(fid.lineno) + '\n')
                 continue
             if elmin is not None and rec.el < elmin:
                 continue
             if rec.snr > 0:
                 self.append(rec)
     self.sort(key=lambda x: x.sod)
Beispiel #3
0
    def __init__(self, teamcity=None, *args, **kwargs):
        self.teamcity = teamcity  # type: TeamCity

        # Hack for ContainerMixin init
        if hasattr(self, 'container') and self.container:
            UserList.__init__(self)
            self.data = self._container_mixin_data
Beispiel #4
0
 def __init__(self, docstring=DEFAULTS['docstring'],
                    options=DEFAULTS['options'],
                    default=None,
                    optional=DEFAULTS['optional'],
                    values=DEFAULTS['values'],
                    category=DEFAULTS['category'],
                    callback=DEFAULTS['callback'],
                    synopsis=DEFAULTS['synopsis'],
                    environ=DEFAULTS['environ'],
                    registry=DEFAULTS['registry'],
                    delim=' ',
                    range=None,
                    mandatory=None,
                    name=DEFAULTS['name'],
                    source=DEFAULTS['source'],
                    template=StringOption):
    """ Initialize a multi argument """
    self.delim = delim
    default = default or []
    self.range = range or [1, '*']
    assert not issubclass(template, MultiArgument), \
           'MultiArguments can not have a MultiArguments as a template'
    assert not issubclass(template, MultiOption), \
           'MultiOptions can not have a MultiOptions as a template'
    assert issubclass(template, GenericOption), \
           'Templates must be a subclass of GenericOption'
    self.template = template(options=options,name=name,values=values)
    UserList.__init__(self, [])
    GenericOption.initialize(self, locals())
Beispiel #5
0
 def __init__(self, *args):
     # print args, len(args), isinstance(args[0], Messages), type(args[0])
     if len(args) == 1 and (isinstance(args[0], UserList)
                            or isinstance(args[0], list)):
         UserList.__init__(self, args[0])
     else:
         UserList.__init__(self, list(args))
Beispiel #6
0
 def __init__(self, parent: "AsyncContextManagerList"):
     UserList.__init__(self)
     self.parent = parent
     self.__stack = None
     self.logger = LOGGER.getChild(
         "AsyncContextManagerListContext.%s"
         % (self.__class__.__qualname__,)
     )
Beispiel #7
0
 def __init__ (self, args = (), undefined = None) :
     """Construct a new `PL_List' with elements specified as optional
        arguments `args' and undefined value `undefined'.
     """
     UserList.__init__ (self)
     self.data      = list (args)
     self.body      = self.data ### alias name for `self.data'
     self.undefined = undefined
Beispiel #8
0
    def __init__(self, value: Optional[Any] = None, id: Optional[UID] = None):
        if value is None:
            value = []

        UserList.__init__(self, value)

        self._id: UID = id if id else UID()
        self._index = 0
Beispiel #9
0
    def __init__(self, l=None):
        if isinstance(l, str):
            UserList.__init__(self)
            self.add(l)
            return
        elif l:
            l = [PBXType.Convert(v) for v in l]

        UserList.__init__(self, l)
Beispiel #10
0
    def __init__(self, nrows, ncols):
        """

        Creates an App

        :param int nrows:
            The number of rows.

        :param int ncols:
            The number of columns.
        """

        UserList.__init__(self)  # Initialize parent class
        # Create list [ncols][nrows]
        self.extend([self._BoardRow(ncols, self) for _ in range(nrows)])

        self._nrows = nrows
        self._ncols = ncols
        self._isrunning = False

        # Array used to store cells elements (rectangles)
        self._cells = [[None] * ncols for _ in range(nrows)]

        # The window
        self._root = Tk()
        # cell's container
        self._canvas = Canvas(self._root, highlightthickness=0)
        self._background_image = None  # background image file name
        # rectange for grid color
        self._bgrect = self._canvas.create_rectangle(1, 1, 2, 2, width=0)
        self._bgimage_id = None
        self._msgbar = None  # message bar component

        # Fields for board properties
        self._title = "game2dboard"  # default window title
        self._cursor = "arrow"  # default mouse cursor
        self._margin = 5  # default board margin (px)
        # default grid cell_spacing (px)
        self._cell_spacing = 1
        self._margin_color = "light grey"  # default border color
        self._cell_color = "white"  # default cell color
        self._grid_color = "black"  # default grid color

        self._on_start = None  # game started callback
        self._on_key_press = None  # user key press callback
        self._on_mouse_click = None  # user mouse callback
        self._on_timer = None  # user timer callback

        # event
        self._timer_interval = 0  # ms
        self._after_id = None  # current timer id
        self._is_in_timer_calback = False
        # register internal key callback
        self._root.bind("<Key>", self._key_press_clbk)
        # register internal mouse callback
        self._canvas.bind("<ButtonPress>", self._mouse_click_clbk)
Beispiel #11
0
    def __init__(self, node_list=None, parent=None, on_attribute=None):
        if node_list is None:
            node_list = []

        for node in node_list:
            node.parent = self

        UserList.__init__(self, node_list)
        BaseNode.__init__(self, parent=parent, on_attribute=on_attribute)
        IndentationMixin.__init__(self, getattr(node_list, "indentation", ""))
Beispiel #12
0
    def __init__(self, values, offset=None, total=None, limit=None):
        UserList.__init__(self, values)

        # if set, this is the index in the overall results of the first element of
        # this list
        self.offset = offset

        # if set, this is the total number of results
        self.total = total

        # if set, this is the limit, either from the user or the implementation
        self.limit = limit
Beispiel #13
0
    def __init__(self, initlist=None, hook_when_init=True):
        """

        :param initlist: iterable object
        :param hook_when_init: run hook points when it is True
        """
        UserList.__init__(self)

        if initlist:
            if hook_when_init:
                self.extend(initlist)
            else:
                self.data.extend(initlist)
Beispiel #14
0
    def __init__(self, components=(), name='', repeats=1):
        Component.__init__(self, name=name)
        UserList.__init__(self)  # explicit calls without super

        self.repeats = possibly_create_parameter(repeats, 'repeats')
        self.repeats.bounds.lb = 1

        # if you provide a list of components to start with, then initialise
        # the Stack from that
        for c in components:
            if isinstance(c, Component):
                self.data.append(c)
            else:
                raise ValueError("You can only initialise a Stack with"
                                 " Components")
Beispiel #15
0
 def __init__(self, arg, rotation=None, scale=None):
     """
     Args
     ----
     arg: int or list
         Int specifying the number of pdf files to add or
         a list of pdf filenames.
     rotation: int or list
         degrees
     table_of_contents: bool
         Int specifying the number of pdf files to add or
         a list ints specifying the degrees of rotation. 
     """
     Container.__init__(self, child=None)
     UserList.__init__(self)
     
     if isinstance(rotation, int) is True:
         self.rotation = [0] * arg
                 
     elif isinstance(arg, list):
         self.rotation = rotation
         
     else:
         self.rotation = None
         
     if isinstance(scale, float) is True:
         self.scale = [1.0] * arg
                 
     elif isinstance(scale, list):
         self.scale = scale
         
     else:
         self.scale = None
         
     if isinstance(arg, int) is True:
         if arg <= 0:
             raise ValueError('Number of columns must be >= 1.')
         else:
             self.data = [None] * arg
                 
     elif isinstance(arg, list):
         self.data = arg
             
     else:
         raise TypeError("""
         Pages class requires either: an int specifying the number of columns,
         or a list of column contents.
         """)
 def __init__(self, data=None, elementType=None, stringRepr=None, 
              comments="", keywords=[]):
     if data is not None and len(data)!=0:
         assert( hasattr(data[0], '__class__') )
         if elementType is not None:
             assert( isinstance(data[0], elementType) )
             
     UserList.__init__(self, data)
     # save call to __setattr__
     self.__dict__['elementType'] = elementType
     #self.elementType = elementType # class of elements in that set
     self.stringRepr = stringRepr # this will hold a concise string repr of
                                  # the set of objects in that list
     self.__dict__['comments'] = comments
     self.__dict__['keywords'] = keywords
     self.selector = None
    def __init__(self, data=None, elementType=None, stringRepr=None,
                 comments="", keywords=[]):
        if data is not None and len(data)!=0:
            assert( hasattr(data[0], '__class__') )
            if elementType is not None:
                assert( isinstance(data[0], elementType) )

        UserList.__init__(self, data)
        # save call to __setattr__
        self.__dict__['elementType'] = elementType
        #self.elementType = elementType # class of elements in that set
        self.stringRepr = stringRepr # this will hold a concise string repr of
                                     # the set of objects in that list
        self.__dict__['comments'] = comments
        self.__dict__['keywords'] = keywords
        self.selector = None
Beispiel #18
0
    def __init__(self, arg):

        Container.__init__(self, child=None)
        UserList.__init__(self)
        
        
        if isinstance(arg, int) is True:
            if arg <= 0:
                raise ValueError('Number of columns must be >= 1.')
            else:
                self.num_cols = arg
                self.data = [None] * arg
                    
        elif isinstance(arg, list):
            self.data = arg
            self.num_cols = len(arg)
                
        else:
            raise TypeError("""
            Columns class requires either: an int specifying the number of columns,
            or a list of column contents.
            """)
Beispiel #19
0
 def __init__(self,
              type,
              fetch=False,
              recursive=1,
              fields=None,
              detail=None,
              filters=None,
              parent_uuid=None,
              back_refs_uuid=None,
              data=None,
              session=None):
     super(Collection, self).__init__(session=session)
     UserList.__init__(self, initlist=data)
     self.type = type
     self.fields = fields or []
     self.filters = filters or []
     self.parent_uuid = list(self._sanitize_uuid(parent_uuid))
     self.back_refs_uuid = list(self._sanitize_uuid(back_refs_uuid))
     self.detail = detail
     if fetch:
         self.fetch(recursive=recursive)
     self.emit('created', self)
Beispiel #20
0
    def __init__(self,
                 docstring=DEFAULTS['docstring'],
                 options=DEFAULTS['options'],
                 default=None,
                 optional=DEFAULTS['optional'],
                 values=DEFAULTS['values'],
                 category=DEFAULTS['category'],
                 callback=DEFAULTS['callback'],
                 synopsis=DEFAULTS['synopsis'],
                 environ=DEFAULTS['environ'],
                 registry=DEFAULTS['registry'],
                 delim=',',
                 range=None,
                 mandatory=None,
                 name=DEFAULTS['name'],
                 source=DEFAULTS['source'],
                 template=StringOption):
        """
      Initialize a multi option

      This class is initialized with the same options as the
      Option class with one addition: delim.  The 'delim' argument
      specifies what the delimiter is for each item in the list.
      If the delimiter is 'None' or whitespace, each item in the
      list is assumed to be delimited by whitespace.

      """
        self.delim = delim
        default = default = []
        self.range = range or [1, '*']
        assert not issubclass(template, MultiOption), \
               'MultiOptions can not have a MultiOption as a template'
        assert issubclass(template, GenericOption), \
               'Templates must be a subclass of GenericOption'
        self.template = template(options=options, name=name, values=values)
        UserList.__init__(self, [])
        GenericOption.initialize(self, locals())
Beispiel #21
0
 def __init__(self, kind, kids=[]):
     self.type = intern(kind)
     UserList.__init__(self, kids)
Beispiel #22
0
 def __init__(self, owner_id, data):
     UserList.__init__(self, data)
     self._owner_id = owner_id
Beispiel #23
0
 def __init__(self):
     UserList.__init__(self)
     self._noderefs = {}
Beispiel #24
0
 def __init__(self, *arg, **kw):
     Model.__init__(self, **kw)
     UserList.__init__(self, *arg, **kw)
Beispiel #25
0
 def __init__(self, owner: Freezable) -> None:
     UserList.__init__(self)
     asyncio.Event.__init__(self)
     self._owner = owner
     self.frozen = False
Beispiel #26
0
 def __init__(self, req):
     self.height = req.height
     self.width = req.width
     UserList.__init__(self, [self.width,
                                       self.height])
Beispiel #27
0
 def __init__(self,items=[]):
     UserList.__init__(self,items)
Beispiel #28
0
 def __init__(self, seq = []):
     UserList.__init__(self, seq)
     self.unique = True
Beispiel #29
0
 def __init__(self, pattern):
     # TODO: this is a stop-gap, follow the discussion on the group to figure out how we're actually
     super(Pattern, self).__init__()
     UserList.__init__(self, initlist=pattern)
Beispiel #30
0
 def __init__(self, any_list):
     UserList.__init__(self, any_list)
Beispiel #31
0
 def __init__(self):
     UserList.__init__(self)
     self._noderefs = {}
Beispiel #32
0
 def __init__(self, data=None):
     """Construct a new list from a given list of :class:`Course`s. If no
     list is given, a new empty list is made."""
     UserList.__init__(self, data if data else [])
Beispiel #33
0
 def __init__(self, lst=[]):
     UserList.__init__(self, lst)
 def __init__(self, name='', *args):
     UserList.__init__(self, *args)
     self.__name__ = name
     if args:
         self._update()
Beispiel #35
0
 def __init__(self, data=None):
     UserList.__init__(self, data)
     self.tList = self.data
Beispiel #36
0
	def __init__(self, initlist=None, on_change=None):
		UserList.__init__(self, initlist)
		self._on_change = on_change
Beispiel #37
0
 def __init__(self, list, **kwds):
     UserList.__init__(self, list)
     self.pos = -1
     self._is_operator = kwds.get("operator")
     self.__doc__ = kwds.get("doc")
     self.declared = False
Beispiel #38
0
 def __init__(self):
     UserList.__init__(self)
     self.current_deck = None
     self.reload()
Beispiel #39
0
 def __init__(self,list,**kwds):
     UserList.__init__(self,list)
     self.pos = -1
     self._is_operator = kwds.get("operator")
     self.__doc__ = kwds.get("doc")
     self.declared = False
Beispiel #40
0
 def __init__(self, owner_id, data):
     UserList.__init__(self, data)
     self._owner_id = owner_id
Beispiel #41
0
 def __init__(self, hosts, loop=None):
     UserList.__init__(self, hosts)
     self.loop = (loop or asyncio.get_event_loop())
Beispiel #42
0
 def __init__(self):
     UserList.__init__(self)
     self.db_session = DBManager.create_session()
     self.current_deck = None
Beispiel #43
0
 def __init__(self, items=None, eol=None, path=None, encoding='utf-8'):
     UserList.__init__(self, items or [])
     self._eol = eol
     self.path = path
     self.encoding = encoding
Beispiel #44
0
 def __init__(self, any_list):
     UserList.__init__(self, any_list)
Beispiel #45
0
 def __init__(self, initialdata=None):
     AnnotationLayerBase.__init__(self)
     UserList.__init__(self, initialdata)
 def __init__(self, data=[], meta=None):
     UserList.__init__(self, data)
     self._meta = meta
Beispiel #47
0
 def __init__(self):
     UserList.__init__(self)
Beispiel #48
0
 def __init__(self, seq = []):
     UserList.__init__(self, Split(seq))
Beispiel #49
0
 def __init__(self, seq=[]):
     UserList.__init__(self, Split(seq))
Beispiel #50
0
 def __init__(self, name, data=None):
     self.name = name
     if data is None:
         data = []
     UserList.__init__(self, data)
Beispiel #51
0
 def __init__(self, type_, children=[]):
     # TODO: consider intern()ing type string
     self.type = type_
     UserList.__init__(self, children)
Beispiel #52
0
 def __init__(self, items=None, eol=None, path=None, encoding='utf-8'):
     UserList.__init__(self, items or [])
     self._eol = eol
     self.path = path
     self.encoding = encoding
Beispiel #53
0
 def __init__(self, type, kids=[]):
     self.type = intern(type)
     UserList.__init__(self, kids)
Beispiel #54
0
 def __init__(self, seq=[]):
     UserList.__init__(self, seq)
     self.unique = True
Beispiel #55
0
 def __init__(self):
     UserList.__init__(self)
     self.db_session = DBManager.create_session()