コード例 #1
0
def test_exceptions():
    with pytest.raises(ValueError):
        z1 = zone.Zone(0)

    with pytest.raises(ValueError):
        z2 = zone.Zone([1, 2, 3])

    with pytest.raises(ValueError):
        z3 = zone.Zone([1, 2])
コード例 #2
0
ファイル: keygroup.py プロジェクト: svanzoest/aksy
    def __init__(self, program, index, precache_on_init=True):
        samplerobject.SamplerObject.__init__(self, program.s, None,
                                             "keygrouptools")
        self.current_mod_source_index = 11
        self.attrs = [
            "low_note", "high_note", "mute_group", "fx_override",
            "fx_send_level", "zone_xfade", "zone_xfade_type", "polyphony",
            "tune", "level", "play_trigger", "play_trigger_velocity", "filter",
            "filter_cutoff", "filter_resonance", "filter_attenuation"
        ]
        self.attrs_minimal = ["low_note", "high_note"]
        self.abbr = {
            'polyphony': 'poly',
            'filter_cutoff': 'cutoff',
            'filter_resonance': 'res',
            'MOD_12_14': 'filtenv',
            'MOD_12_15': 'filtenv',
            'MOD_6_1': 'velo',
            'MOD_11_1': 'ampenv',
            'MOD_13_3': 'auxenv',
        }
        self.p = program
        self.index = index
        self.keygroup_index = index
        self.s = program.s

        if getattr(self.s, "samples", None):
            self.samples = self.s.samples
        else:
            self.samples = None

        kgt = self.s.keygrouptools

        self.filter_attributes = [
            'filter', 'filter_cutoff', 'filter_resonance'
        ]

        self.amp_envelope = envelope.Envelope(self, 0)
        self.filter_envelope = envelope.Envelope(self, 1)
        self.aux_envelope = envelope.Envelope(self, 2)

        self.zones = [
            zone.Zone(self, 1),
            zone.Zone(self, 2),
            zone.Zone(self, 3),
            zone.Zone(self, 4)
        ]
        self.mod_matrix = []
        self.mod_matrix_dict = {}

        if precache_on_init:
            self.precache()
コード例 #3
0
ファイル: main.py プロジェクト: flitvious/GHReborn
    def __init__(self):

        # init the renderer
        self.renderer = renderer.Renderer(screen_width=80,
                                          screen_height=50,
                                          fps_limit=20)

        # init the input
        self.keyhandler = k()  #keyhandler.KeyHandler()

        # init the map
        self.zone = zone.Zone()
        # populate zone with roomer algorithm
        self.zone.roomer(max_rooms=30)

        # init fov
        self.fov = renderer.Fov(algo=0, light_walls=True, light_radius=10)

        # load zone information to fov
        self.fov.read_zone(self.zone)

        # create a player object in the zone and make him a fighter
        self.player = entities.Actor('@',
                                     'player',
                                     libtcod.white,
                                     blocks=True,
                                     design=entities.Actor.designs.player,
                                     ai=entities.AI.ais.player_control)

        # put player to random coords inside the zone
        self.zone.add_entity(self.player)
コード例 #4
0
    def create_zone(self, assigned_type, zone_center, zone_points,
                    zones_by_type):
        new_zone = zone.Zone(assigned_type, zone_center.x, zone_center.y,
                             zone_points)
        for loc in zone_points:
            self.zone_map[(loc.x, loc.y)] = new_zone

        zones_by_type[assigned_type.name].append(new_zone)

        self.zones.append(new_zone)
コード例 #5
0
ファイル: plancher.py プロジェクト: mathieu-lemay/misc
    def __init__(self, id):
        self.xml = xmlparser.XmlParser('expo.xml')
        self.id = id

        self.zones = []
        for i in range(self.getLargeur()):
            tmp = []
            for j in range(self.getHauteur()):
                z = zone.Zone(i, j, self.xml.isZone(j, i))
                tmp.append(z)
            self.zones.append(tmp)
コード例 #6
0
 def create_zone(self, zone_id, gameplay_zone_data, save_slot_data):
     if sims4.zone_utils._global_zone_id is not None:
         raise RuntimeError('_global_zone_id is already set to {}'.format(
             sims4.zone_utils._global_zone_id))
     sims4.zone_utils._global_zone_id = zone_id
     if save_slot_data is not None:
         save_slot_data_id = save_slot_data.slot_id
     else:
         save_slot_data_id = None
     new_zone = zone.Zone(zone_id, save_slot_data_id)
     self.add(new_zone)
     new_zone.start_services(gameplay_zone_data, save_slot_data)
     return new_zone
コード例 #7
0
 def create_zone(self, zone_id, gameplay_zone_data, save_slot_data):
     if sims4.zone_utils.zone_id is not None:
         raise RuntimeError(
             'Attempting to set _zone_id to {} when its already set {}.'.
             format(zone_id, sims4.zone_utils.zone_id))
     if save_slot_data is not None:
         save_slot_data_id = save_slot_data.slot_id
     else:
         save_slot_data_id = None
     new_zone = zone.Zone(zone_id, save_slot_data_id)
     logger.info('Created new zone {} with id {}.', new_zone, zone_id)
     self.add(new_zone)
     return new_zone
コード例 #8
0
ファイル: tzconvert.py プロジェクト: eventable/PyCalendar
    def parseZone(self, line, f):
        os = StringIO.StringIO()
        os.write(line)
        last_line = None
        for nextline in f:
            nextline = nextline[:-1]
            if nextline.startswith("\t") or nextline.startswith(" "):
                os.write("\n")
                os.write(nextline)
            elif nextline.startswith("#") or len(nextline) == 0:
                continue
            else:
                last_line = nextline
                break

        zoneitem = zone.Zone()
        zoneitem.parse(os.getvalue())
        self.zones[zoneitem.name] = zoneitem

        return last_line
コード例 #9
0
ファイル: test_area.py プロジェクト: DealPete/shadow-hunters
def test_getAdjacent():

    # Put two areas in a zone
    a = area.Area(name="A",
                  desc="area_desc",
                  domain=[8],
                  action=lambda: 5,
                  resource_id="a_id")
    b = area.Area(name="B",
                  desc="area_desc",
                  domain=[9],
                  action=lambda: 5,
                  resource_id="b_id")
    z = zone.Zone([a, b])
    for x in z.areas:
        x.zone = z

    assert a.zone == z
    assert b.zone == z

    # Test adjacency
    assert a.getAdjacent() == b
    assert b.getAdjacent() == a
コード例 #10
0
def test_fields():

    # sample areas
    a1 = area.Area(name="area1",
                   desc="area desc",
                   domain=[8],
                   action=lambda: 1,
                   resource_id="r_id")
    a2 = area.Area(name="area2",
                   desc="area desc",
                   domain=[9],
                   action=lambda: 0,
                   resource_id="r_id")

    # test initialization
    areas = [a1, a2]
    z = zone.Zone(areas)

    # test fields
    assert z.areas == areas

    # test dump
    assert z.dump() == [a1.dump(), a2.dump()]
コード例 #11
0
ファイル: rapport.py プロジェクト: mathieu-lemay/misc
                    
                    #Si on se rend ici, on ajoute un kiosque
                    self.nbKiosques += 1
    
    def aDejaEteComptee(self, zonesDejaComptees, x, y):
        for i in (zonesDejaComptees):
            if (i == [x, y]):
                return True
        return False

if __name__ == '__main__':
    import xmlparser
    xml = xmlparser.XmlParser('expo.xml')
    
    app = QApplication([])
    qdb = db.Database()
    qdb.openSqlConnection("QSQLITE", "db.sqlite")
        
    zones = []
    for i in range(xml.getLargeur()):
        tmp = []
        for j in range(xml.getHauteur()):
            z = zone.Zone(i, j, xml.isZone(j, i))
            tmp.append(z)
        zones.append(tmp)
    
    v = VueRapportExposant(100, zones)
    #~ v = VueRapportGeneral(zones)
    v.show()
    app.exec_()
    qdb.closeSqlConnection()