body_hash
stringlengths
64
64
body
stringlengths
23
109k
docstring
stringlengths
1
57k
path
stringlengths
4
198
name
stringlengths
1
115
repository_name
stringlengths
7
111
repository_stars
float64
0
191k
lang
stringclasses
1 value
body_without_docstring
stringlengths
14
108k
unified
stringlengths
45
133k
92bf83a6c728d7233e0e8a96ad9adb2dff6be0e299f4e9959ff2736918db325a
def import_layout(self, libname: str, cellname: str, yaml_root: str=None, export_pins: bool=True) -> 'LayoutAbstract': '\n Creates an abstract layout master from the provided virtuoso libname and cellname. Adds pin shapes\n from the yaml root to the location dictionary for easy access.\n\n Parameters\n ----------\n libname : str\n virtuoso design library name\n cellname : str\n virtuoso cell name; must be contained within the provided virtuoso design library\n yaml_root : str\n path to yaml file containing pin shapes. These shapes will be added to the location dictionary\n export_pins : bool\n if True, will draw all pin shapes provided in yaml root\n\n Returns\n -------\n abstract_temp : LayoutAbstract\n A design master containing the generated layout_abstract\n ' params = {'libname': libname, 'cellname': cellname, 'yaml_root': yaml_root, 'export_pins': export_pins} abstract_temp = self.new_template(params=params, temp_cls=LayoutAbstract) return abstract_temp
Creates an abstract layout master from the provided virtuoso libname and cellname. Adds pin shapes from the yaml root to the location dictionary for easy access. Parameters ---------- libname : str virtuoso design library name cellname : str virtuoso cell name; must be contained within the provided virtuoso design library yaml_root : str path to yaml file containing pin shapes. These shapes will be added to the location dictionary export_pins : bool if True, will draw all pin shapes provided in yaml root Returns ------- abstract_temp : LayoutAbstract A design master containing the generated layout_abstract
ACG/AyarLayoutGenerator.py
import_layout
AyarLabs/ACG
7
python
def import_layout(self, libname: str, cellname: str, yaml_root: str=None, export_pins: bool=True) -> 'LayoutAbstract': '\n Creates an abstract layout master from the provided virtuoso libname and cellname. Adds pin shapes\n from the yaml root to the location dictionary for easy access.\n\n Parameters\n ----------\n libname : str\n virtuoso design library name\n cellname : str\n virtuoso cell name; must be contained within the provided virtuoso design library\n yaml_root : str\n path to yaml file containing pin shapes. These shapes will be added to the location dictionary\n export_pins : bool\n if True, will draw all pin shapes provided in yaml root\n\n Returns\n -------\n abstract_temp : LayoutAbstract\n A design master containing the generated layout_abstract\n ' params = {'libname': libname, 'cellname': cellname, 'yaml_root': yaml_root, 'export_pins': export_pins} abstract_temp = self.new_template(params=params, temp_cls=LayoutAbstract) return abstract_temp
def import_layout(self, libname: str, cellname: str, yaml_root: str=None, export_pins: bool=True) -> 'LayoutAbstract': '\n Creates an abstract layout master from the provided virtuoso libname and cellname. Adds pin shapes\n from the yaml root to the location dictionary for easy access.\n\n Parameters\n ----------\n libname : str\n virtuoso design library name\n cellname : str\n virtuoso cell name; must be contained within the provided virtuoso design library\n yaml_root : str\n path to yaml file containing pin shapes. These shapes will be added to the location dictionary\n export_pins : bool\n if True, will draw all pin shapes provided in yaml root\n\n Returns\n -------\n abstract_temp : LayoutAbstract\n A design master containing the generated layout_abstract\n ' params = {'libname': libname, 'cellname': cellname, 'yaml_root': yaml_root, 'export_pins': export_pins} abstract_temp = self.new_template(params=params, temp_cls=LayoutAbstract) return abstract_temp<|docstring|>Creates an abstract layout master from the provided virtuoso libname and cellname. Adds pin shapes from the yaml root to the location dictionary for easy access. Parameters ---------- libname : str virtuoso design library name cellname : str virtuoso cell name; must be contained within the provided virtuoso design library yaml_root : str path to yaml file containing pin shapes. These shapes will be added to the location dictionary export_pins : bool if True, will draw all pin shapes provided in yaml root Returns ------- abstract_temp : LayoutAbstract A design master containing the generated layout_abstract<|endoftext|>
e4bebf38d086244f41b5fcd322ed3a09f38a36a6eaa8ccc3839b0ac88915a5d7
def import_cadence_layout(self, libname: str, cellname: str) -> 'AyarLayoutGenerator': '\n This method will extract the layout specified by libname, cellname from Cadence, and return a new\n LayoutAbstract master that can be placed in the current db. This method will also analyze the layout for\n its pins and automatically add them to the location dictionary.\n\n Parameters\n ----------\n libname : str\n Cadence library name where the cell will be located\n cellname : str\n Cadence cell name of the layout to be imported\n\n Returns\n -------\n master : LayoutAbstract\n Newly created master that will contain the imported layout and pin information\n ' temp_file_name = 'test.yaml' expr = ('parse_cad_layout( "%s" "%s" "%s" )' % (libname, cellname, temp_file_name)) self.template_db._prj.impl_db._eval_skill(expr) with open(temp_file_name, 'r') as f: data = yaml.load(f) os.remove(temp_file_name) return self.new_template(params={'libname': libname, 'cellname': cellname, 'data': data}, temp_cls=CadenceLayout)
This method will extract the layout specified by libname, cellname from Cadence, and return a new LayoutAbstract master that can be placed in the current db. This method will also analyze the layout for its pins and automatically add them to the location dictionary. Parameters ---------- libname : str Cadence library name where the cell will be located cellname : str Cadence cell name of the layout to be imported Returns ------- master : LayoutAbstract Newly created master that will contain the imported layout and pin information
ACG/AyarLayoutGenerator.py
import_cadence_layout
AyarLabs/ACG
7
python
def import_cadence_layout(self, libname: str, cellname: str) -> 'AyarLayoutGenerator': '\n This method will extract the layout specified by libname, cellname from Cadence, and return a new\n LayoutAbstract master that can be placed in the current db. This method will also analyze the layout for\n its pins and automatically add them to the location dictionary.\n\n Parameters\n ----------\n libname : str\n Cadence library name where the cell will be located\n cellname : str\n Cadence cell name of the layout to be imported\n\n Returns\n -------\n master : LayoutAbstract\n Newly created master that will contain the imported layout and pin information\n ' temp_file_name = 'test.yaml' expr = ('parse_cad_layout( "%s" "%s" "%s" )' % (libname, cellname, temp_file_name)) self.template_db._prj.impl_db._eval_skill(expr) with open(temp_file_name, 'r') as f: data = yaml.load(f) os.remove(temp_file_name) return self.new_template(params={'libname': libname, 'cellname': cellname, 'data': data}, temp_cls=CadenceLayout)
def import_cadence_layout(self, libname: str, cellname: str) -> 'AyarLayoutGenerator': '\n This method will extract the layout specified by libname, cellname from Cadence, and return a new\n LayoutAbstract master that can be placed in the current db. This method will also analyze the layout for\n its pins and automatically add them to the location dictionary.\n\n Parameters\n ----------\n libname : str\n Cadence library name where the cell will be located\n cellname : str\n Cadence cell name of the layout to be imported\n\n Returns\n -------\n master : LayoutAbstract\n Newly created master that will contain the imported layout and pin information\n ' temp_file_name = 'test.yaml' expr = ('parse_cad_layout( "%s" "%s" "%s" )' % (libname, cellname, temp_file_name)) self.template_db._prj.impl_db._eval_skill(expr) with open(temp_file_name, 'r') as f: data = yaml.load(f) os.remove(temp_file_name) return self.new_template(params={'libname': libname, 'cellname': cellname, 'data': data}, temp_cls=CadenceLayout)<|docstring|>This method will extract the layout specified by libname, cellname from Cadence, and return a new LayoutAbstract master that can be placed in the current db. This method will also analyze the layout for its pins and automatically add them to the location dictionary. Parameters ---------- libname : str Cadence library name where the cell will be located cellname : str Cadence cell name of the layout to be imported Returns ------- master : LayoutAbstract Newly created master that will contain the imported layout and pin information<|endoftext|>
b3a6f48bfb96fb2e57eaad7205f4d0bf809ae4b3cef972b24a2e6c593c3bf70a
def connect_wires(self, rect1: Rectangle, rect2: Rectangle, size: Tuple[(int, int)]=(None, None), extend: bool=False, prim: bool=False) -> Union[(ViaStack, Via)]: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n rect1: Rectangle\n first rectangle to be connected\n rect2: Rectangle\n second rectangle to be connected\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n extend: bool\n Represents whether the enclosure will be extended in the x or y direction to meet drc rules\n prim: bool\n if True, will attempt to create a single primitive via instead of a via stack\n ' if (rect1.layer != rect2.layer): if prim: temp = Via.from_metals(rect1, rect2, size=size) self._db['prim_via'].append(temp) else: temp = ViaStack(rect1, rect2, size=size, extend=extend) self._db['via'].append(temp) return temp
Creates a via stack between the two provided rectangles. This method requires that the provided rectangles overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed. Parameters ---------- rect1: Rectangle first rectangle to be connected rect2: Rectangle second rectangle to be connected size: Tuple[int, int] number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to fill the enclosure extend: bool Represents whether the enclosure will be extended in the x or y direction to meet drc rules prim: bool if True, will attempt to create a single primitive via instead of a via stack
ACG/AyarLayoutGenerator.py
connect_wires
AyarLabs/ACG
7
python
def connect_wires(self, rect1: Rectangle, rect2: Rectangle, size: Tuple[(int, int)]=(None, None), extend: bool=False, prim: bool=False) -> Union[(ViaStack, Via)]: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n rect1: Rectangle\n first rectangle to be connected\n rect2: Rectangle\n second rectangle to be connected\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n extend: bool\n Represents whether the enclosure will be extended in the x or y direction to meet drc rules\n prim: bool\n if True, will attempt to create a single primitive via instead of a via stack\n ' if (rect1.layer != rect2.layer): if prim: temp = Via.from_metals(rect1, rect2, size=size) self._db['prim_via'].append(temp) else: temp = ViaStack(rect1, rect2, size=size, extend=extend) self._db['via'].append(temp) return temp
def connect_wires(self, rect1: Rectangle, rect2: Rectangle, size: Tuple[(int, int)]=(None, None), extend: bool=False, prim: bool=False) -> Union[(ViaStack, Via)]: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n rect1: Rectangle\n first rectangle to be connected\n rect2: Rectangle\n second rectangle to be connected\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n extend: bool\n Represents whether the enclosure will be extended in the x or y direction to meet drc rules\n prim: bool\n if True, will attempt to create a single primitive via instead of a via stack\n ' if (rect1.layer != rect2.layer): if prim: temp = Via.from_metals(rect1, rect2, size=size) self._db['prim_via'].append(temp) else: temp = ViaStack(rect1, rect2, size=size, extend=extend) self._db['via'].append(temp) return temp<|docstring|>Creates a via stack between the two provided rectangles. This method requires that the provided rectangles overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed. Parameters ---------- rect1: Rectangle first rectangle to be connected rect2: Rectangle second rectangle to be connected size: Tuple[int, int] number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to fill the enclosure extend: bool Represents whether the enclosure will be extended in the x or y direction to meet drc rules prim: bool if True, will attempt to create a single primitive via instead of a via stack<|endoftext|>
da6be572cc4a5331d18245476ccdbd36fbc9c6b71d2cdfccb34d1aeec5875b11
def add_prim_via(self, via_id: str, rect: Rectangle, size: Tuple[(int, int)]=(None, None)) -> Via: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n via_id: str\n id for the via to be drawn\n rect: Rectangle\n the rectangle bounding the region to draw the via\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n ' temp = Via(via_id, bbox=rect, size=size) self._db['prim_via'].append(temp) return temp
Creates a via stack between the two provided rectangles. This method requires that the provided rectangles overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed. Parameters ---------- via_id: str id for the via to be drawn rect: Rectangle the rectangle bounding the region to draw the via size: Tuple[int, int] number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to fill the enclosure
ACG/AyarLayoutGenerator.py
add_prim_via
AyarLabs/ACG
7
python
def add_prim_via(self, via_id: str, rect: Rectangle, size: Tuple[(int, int)]=(None, None)) -> Via: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n via_id: str\n id for the via to be drawn\n rect: Rectangle\n the rectangle bounding the region to draw the via\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n ' temp = Via(via_id, bbox=rect, size=size) self._db['prim_via'].append(temp) return temp
def add_prim_via(self, via_id: str, rect: Rectangle, size: Tuple[(int, int)]=(None, None)) -> Via: '\n Creates a via stack between the two provided rectangles. This method requires that the provided rectangles\n overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed.\n\n Parameters\n ----------\n via_id: str\n id for the via to be drawn\n rect: Rectangle\n the rectangle bounding the region to draw the via\n size: Tuple[int, int]\n number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to\n fill the enclosure\n ' temp = Via(via_id, bbox=rect, size=size) self._db['prim_via'].append(temp) return temp<|docstring|>Creates a via stack between the two provided rectangles. This method requires that the provided rectangles overlap. No knowledge of which rectangle is higher/lower in the metal stack is needed. Parameters ---------- via_id: str id for the via to be drawn rect: Rectangle the rectangle bounding the region to draw the via size: Tuple[int, int] number of vias to be placed in the x and y dimension respectively. If (None, None), vias will be placed to fill the enclosure<|endoftext|>
0be904dd3091834785455961931ec0bc61a32f48ab539c79d640339005d5d2e9
def draw_layout(self) -> None: ' Called by higher level BAG functions to create layout ' self.layout_procedure() self._commit_shapes()
Called by higher level BAG functions to create layout
ACG/AyarLayoutGenerator.py
draw_layout
AyarLabs/ACG
7
python
def draw_layout(self) -> None: ' ' self.layout_procedure() self._commit_shapes()
def draw_layout(self) -> None: ' ' self.layout_procedure() self._commit_shapes()<|docstring|>Called by higher level BAG functions to create layout<|endoftext|>
01aaea9ae4ca6f8b481941d34c48803b524cfd78eeea24097008c223a9d1764f
def parse_yaml(self, pathname) -> dict: ' returns the parsed yaml file TODO: change the reference function to something not in bag.core ' return bag.core._parse_yaml_file(pathname)
returns the parsed yaml file TODO: change the reference function to something not in bag.core
ACG/AyarLayoutGenerator.py
parse_yaml
AyarLabs/ACG
7
python
def parse_yaml(self, pathname) -> dict: ' ' return bag.core._parse_yaml_file(pathname)
def parse_yaml(self, pathname) -> dict: ' ' return bag.core._parse_yaml_file(pathname)<|docstring|>returns the parsed yaml file TODO: change the reference function to something not in bag.core<|endoftext|>
d3393a00cae7b3c9dea3d8b6cac316a4ee71ac443bc5c8f29d4a2bd54bbc3f2a
def _commit_shapes(self) -> None: ' Takes all shapes in local db and creates standard BAG equivalents ' self._commit_rect() self._commit_inst() self._commit_via() self.prim_bound_box = self.temp_boundary.to_bbox() self.prim_top_layer = self.grid.tech_info.get_layer_id(self.temp_boundary.layer)
Takes all shapes in local db and creates standard BAG equivalents
ACG/AyarLayoutGenerator.py
_commit_shapes
AyarLabs/ACG
7
python
def _commit_shapes(self) -> None: ' ' self._commit_rect() self._commit_inst() self._commit_via() self.prim_bound_box = self.temp_boundary.to_bbox() self.prim_top_layer = self.grid.tech_info.get_layer_id(self.temp_boundary.layer)
def _commit_shapes(self) -> None: ' ' self._commit_rect() self._commit_inst() self._commit_via() self.prim_bound_box = self.temp_boundary.to_bbox() self.prim_top_layer = self.grid.tech_info.get_layer_id(self.temp_boundary.layer)<|docstring|>Takes all shapes in local db and creates standard BAG equivalents<|endoftext|>
77f612dba0834840d59e7d1b5ab09cfbe7d116b5ea532fbaf64b54e719807a9e
def _commit_rect(self) -> None: ' Takes in all rectangles in the db and creates standard BAG equivalents ' for shape in self._db['rect']: self.temp_boundary = self.temp_boundary.get_enclosure(shape) if (shape.virtual is False): TemplateBase.add_rect(self, shape.lpp, shape.to_bbox())
Takes in all rectangles in the db and creates standard BAG equivalents
ACG/AyarLayoutGenerator.py
_commit_rect
AyarLabs/ACG
7
python
def _commit_rect(self) -> None: ' ' for shape in self._db['rect']: self.temp_boundary = self.temp_boundary.get_enclosure(shape) if (shape.virtual is False): TemplateBase.add_rect(self, shape.lpp, shape.to_bbox())
def _commit_rect(self) -> None: ' ' for shape in self._db['rect']: self.temp_boundary = self.temp_boundary.get_enclosure(shape) if (shape.virtual is False): TemplateBase.add_rect(self, shape.lpp, shape.to_bbox())<|docstring|>Takes in all rectangles in the db and creates standard BAG equivalents<|endoftext|>
fa13017cc0303b486dbcc329b4123070b960b638529367c5a156d32ef6c8a408
def _commit_inst(self) -> None: ' Takes in all inst in the db and creates standard BAG equivalents ' for inst in self._db['instance']: try: bound = inst.master.temp_boundary.shift_origin(origin=inst.origin, orient=inst.orient) except AttributeError: bound = Rectangle(xy=[[0, 0], [0.1, 0.1]], layer='M1', virtual=True) self.temp_boundary = self.temp_boundary.get_enclosure(bound) TemplateBase.add_instance(self, inst.master, inst_name=inst.inst_name, loc=inst.origin, orient=inst.orient)
Takes in all inst in the db and creates standard BAG equivalents
ACG/AyarLayoutGenerator.py
_commit_inst
AyarLabs/ACG
7
python
def _commit_inst(self) -> None: ' ' for inst in self._db['instance']: try: bound = inst.master.temp_boundary.shift_origin(origin=inst.origin, orient=inst.orient) except AttributeError: bound = Rectangle(xy=[[0, 0], [0.1, 0.1]], layer='M1', virtual=True) self.temp_boundary = self.temp_boundary.get_enclosure(bound) TemplateBase.add_instance(self, inst.master, inst_name=inst.inst_name, loc=inst.origin, orient=inst.orient)
def _commit_inst(self) -> None: ' ' for inst in self._db['instance']: try: bound = inst.master.temp_boundary.shift_origin(origin=inst.origin, orient=inst.orient) except AttributeError: bound = Rectangle(xy=[[0, 0], [0.1, 0.1]], layer='M1', virtual=True) self.temp_boundary = self.temp_boundary.get_enclosure(bound) TemplateBase.add_instance(self, inst.master, inst_name=inst.inst_name, loc=inst.origin, orient=inst.orient)<|docstring|>Takes in all inst in the db and creates standard BAG equivalents<|endoftext|>
9c309591435ab5451c9d28c1d6aa42021034838ec989396a0c51bb35c3045ad7
def _commit_via(self) -> None: ' Takes in all vias in the db and creates standard BAG equivalents ' for via in self._db['via']: for connection in via.metal_pairs: TemplateBase.add_via(self, bbox=via.loc['overlap'].to_bbox(), bot_layer=connection[0], top_layer=connection[1], bot_dir=connection[2], extend=via.extend) for via in self._db['prim_via']: TemplateBase.add_via_primitive(self, via_type=via.via_id, loc=via.location, num_rows=via.num_rows, num_cols=via.num_cols, sp_rows=via.sp_rows, sp_cols=via.sp_cols, enc1=via.enc_bot, enc2=via.enc_top, orient=via.orient)
Takes in all vias in the db and creates standard BAG equivalents
ACG/AyarLayoutGenerator.py
_commit_via
AyarLabs/ACG
7
python
def _commit_via(self) -> None: ' ' for via in self._db['via']: for connection in via.metal_pairs: TemplateBase.add_via(self, bbox=via.loc['overlap'].to_bbox(), bot_layer=connection[0], top_layer=connection[1], bot_dir=connection[2], extend=via.extend) for via in self._db['prim_via']: TemplateBase.add_via_primitive(self, via_type=via.via_id, loc=via.location, num_rows=via.num_rows, num_cols=via.num_cols, sp_rows=via.sp_rows, sp_cols=via.sp_cols, enc1=via.enc_bot, enc2=via.enc_top, orient=via.orient)
def _commit_via(self) -> None: ' ' for via in self._db['via']: for connection in via.metal_pairs: TemplateBase.add_via(self, bbox=via.loc['overlap'].to_bbox(), bot_layer=connection[0], top_layer=connection[1], bot_dir=connection[2], extend=via.extend) for via in self._db['prim_via']: TemplateBase.add_via_primitive(self, via_type=via.via_id, loc=via.location, num_rows=via.num_rows, num_cols=via.num_cols, sp_rows=via.sp_rows, sp_cols=via.sp_cols, enc1=via.enc_bot, enc2=via.enc_top, orient=via.orient)<|docstring|>Takes in all vias in the db and creates standard BAG equivalents<|endoftext|>
3b7afc9f52cba6d2d6b1bf474e6fa339b2f9de55889cbbe375dfd4926a19108b
def layout_procedure(self): 'Draws the layout and caculates the coordinates based on LEF' self.get_tech_params() self.get_cell_params() self.calculate_pins() self.calculate_boundary() self.instantiate_layout()
Draws the layout and caculates the coordinates based on LEF
ACG/AyarLayoutGenerator.py
layout_procedure
AyarLabs/ACG
7
python
def layout_procedure(self): self.get_tech_params() self.get_cell_params() self.calculate_pins() self.calculate_boundary() self.instantiate_layout()
def layout_procedure(self): self.get_tech_params() self.get_cell_params() self.calculate_pins() self.calculate_boundary() self.instantiate_layout()<|docstring|>Draws the layout and caculates the coordinates based on LEF<|endoftext|>
f77b24fc9a22458eb91c32a2b2dd810e1b2b1d62836f87dfe2aa7bda1c888646
def instantiate_layout(self): 'We instantiate the layout as a primitive here based on the cell_name read' 'Adding mapping since the stupid lef layout library name is different than the cds.lib name' self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))
We instantiate the layout as a primitive here based on the cell_name read
ACG/AyarLayoutGenerator.py
instantiate_layout
AyarLabs/ACG
7
python
def instantiate_layout(self): 'Adding mapping since the stupid lef layout library name is different than the cds.lib name' self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))
def instantiate_layout(self): 'Adding mapping since the stupid lef layout library name is different than the cds.lib name' self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))<|docstring|>We instantiate the layout as a primitive here based on the cell_name read<|endoftext|>
4371067d3563bdbe876ef6b0bbca83ff0dfaf7606712ef8afece7a799515620e
def get_cell_params(self): 'Read cell parameters from specific Yaml' pathname = open(self.cell_yaml, mode='r') self.cell_dict = yaml.load(pathname) print('{} instantiated'.format(self.params['cellname']))
Read cell parameters from specific Yaml
ACG/AyarLayoutGenerator.py
get_cell_params
AyarLabs/ACG
7
python
def get_cell_params(self): pathname = open(self.cell_yaml, mode='r') self.cell_dict = yaml.load(pathname) print('{} instantiated'.format(self.params['cellname']))
def get_cell_params(self): pathname = open(self.cell_yaml, mode='r') self.cell_dict = yaml.load(pathname) print('{} instantiated'.format(self.params['cellname']))<|docstring|>Read cell parameters from specific Yaml<|endoftext|>
0f66e2607f4a639a34cf85e1dd870e2517b0551c5f2ff9a12817634dc82095df
def get_tech_params(self): 'Get tech information to ensure that information of metal stacks is passed through yaml and not hardcoded' self.tech_layers = tech_info.tech_info['metal_tech']['routing']
Get tech information to ensure that information of metal stacks is passed through yaml and not hardcoded
ACG/AyarLayoutGenerator.py
get_tech_params
AyarLabs/ACG
7
python
def get_tech_params(self): self.tech_layers = tech_info.tech_info['metal_tech']['routing']
def get_tech_params(self): self.tech_layers = tech_info.tech_info['metal_tech']['routing']<|docstring|>Get tech information to ensure that information of metal stacks is passed through yaml and not hardcoded<|endoftext|>
1eb3e5a80a2d53458ae48d4b91bca6d4f397e70855f74309747130fe7917e0de
def calculate_pins(self): 'Calculates the pins on the stdcell/macro and pushes them to loc dict' for keys in self.cell_dict: if re.match('pins', keys): for pins in self.cell_dict['pins']: pins_dict = {pins: []} for layers in self.cell_dict['pins'][pins]: if (layers.upper() in self.tech_layers): for rects in self.cell_dict['pins'][pins][layers]: shape = self.add_rect(layers.upper(), rects, virtual=True) pins_dict[pins].append(shape) self.loc.update(pins_dict) self.pin_list.append(pins)
Calculates the pins on the stdcell/macro and pushes them to loc dict
ACG/AyarLayoutGenerator.py
calculate_pins
AyarLabs/ACG
7
python
def calculate_pins(self): for keys in self.cell_dict: if re.match('pins', keys): for pins in self.cell_dict['pins']: pins_dict = {pins: []} for layers in self.cell_dict['pins'][pins]: if (layers.upper() in self.tech_layers): for rects in self.cell_dict['pins'][pins][layers]: shape = self.add_rect(layers.upper(), rects, virtual=True) pins_dict[pins].append(shape) self.loc.update(pins_dict) self.pin_list.append(pins)
def calculate_pins(self): for keys in self.cell_dict: if re.match('pins', keys): for pins in self.cell_dict['pins']: pins_dict = {pins: []} for layers in self.cell_dict['pins'][pins]: if (layers.upper() in self.tech_layers): for rects in self.cell_dict['pins'][pins][layers]: shape = self.add_rect(layers.upper(), rects, virtual=True) pins_dict[pins].append(shape) self.loc.update(pins_dict) self.pin_list.append(pins)<|docstring|>Calculates the pins on the stdcell/macro and pushes them to loc dict<|endoftext|>
394d1e431ba45e6283217e537bd59d742ec9f85338a987e8ffa67975d6e54d5d
def calculate_boundary(self): 'Calulates the boundary from lef file' for keys in self.cell_dict: if re.match('size', keys): bnd = self.add_rect('OUTLINE', self.cell_dict['size'], virtual=True) bnd_dict = {'bnd': bnd} self.loc.update(bnd_dict)
Calulates the boundary from lef file
ACG/AyarLayoutGenerator.py
calculate_boundary
AyarLabs/ACG
7
python
def calculate_boundary(self): for keys in self.cell_dict: if re.match('size', keys): bnd = self.add_rect('OUTLINE', self.cell_dict['size'], virtual=True) bnd_dict = {'bnd': bnd} self.loc.update(bnd_dict)
def calculate_boundary(self): for keys in self.cell_dict: if re.match('size', keys): bnd = self.add_rect('OUTLINE', self.cell_dict['size'], virtual=True) bnd_dict = {'bnd': bnd} self.loc.update(bnd_dict)<|docstring|>Calulates the boundary from lef file<|endoftext|>
a4e6ec80a5cb160746de5508ad32ab1efb562e1adbea2ccc21c3b33fb499075e
def calculate_obs(self): 'Calulates obstructions in the lef (Can be pushed to ACG/BAG ), cant see a reason for it yet' for keys in self.cell_dict: if re.match('obs', keys): for layers in self.cell_dict['obs']: pass
Calulates obstructions in the lef (Can be pushed to ACG/BAG ), cant see a reason for it yet
ACG/AyarLayoutGenerator.py
calculate_obs
AyarLabs/ACG
7
python
def calculate_obs(self): for keys in self.cell_dict: if re.match('obs', keys): for layers in self.cell_dict['obs']: pass
def calculate_obs(self): for keys in self.cell_dict: if re.match('obs', keys): for layers in self.cell_dict['obs']: pass<|docstring|>Calulates obstructions in the lef (Can be pushed to ACG/BAG ), cant see a reason for it yet<|endoftext|>
b1c4b374f3ee1b63d0fc513600aca1b7196ea76debc9fc6b57a0ce19f188d65a
def instantiate_layout(self): 'We instantiate the layout as a primitive here based on the cell_name read' self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))
We instantiate the layout as a primitive here based on the cell_name read
ACG/AyarLayoutGenerator.py
instantiate_layout
AyarLabs/ACG
7
python
def instantiate_layout(self): self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))
def instantiate_layout(self): self.add_instance_primitive(lib_name=self.params['libname'], cell_name=self.params['cellname'], loc=(0, 0))<|docstring|>We instantiate the layout as a primitive here based on the cell_name read<|endoftext|>
c081adc8724f99d0d18052fea1d32a3540e8981a7b553c0cdb6189ea6b53bd5b
def test_largest_cc(): ' Check the extraction of the largest connected component.\n ' a = np.zeros((6, 6, 6)) a[(1:3, 1:3, 1:3)] = 1 (yield (assert_equal, a, largest_cc(a))) b = a.copy() b[(5, 5, 5)] = 1 (yield (assert_equal, a, largest_cc(b)))
Check the extraction of the largest connected component.
nipy/neurospin/utils/tests/test_mask.py
test_largest_cc
fperez/nipy
1
python
def test_largest_cc(): ' \n ' a = np.zeros((6, 6, 6)) a[(1:3, 1:3, 1:3)] = 1 (yield (assert_equal, a, largest_cc(a))) b = a.copy() b[(5, 5, 5)] = 1 (yield (assert_equal, a, largest_cc(b)))
def test_largest_cc(): ' \n ' a = np.zeros((6, 6, 6)) a[(1:3, 1:3, 1:3)] = 1 (yield (assert_equal, a, largest_cc(a))) b = a.copy() b[(5, 5, 5)] = 1 (yield (assert_equal, a, largest_cc(b)))<|docstring|>Check the extraction of the largest connected component.<|endoftext|>
63ea846f8e773f672a7305f44c8e0f5d1cef8874068f944a405dff597541fb33
def preprocess_corpus(*args, **kwargs): 'Wrapper function for preprocessing module.' preprocessor_type = kwargs['preprocessor_type'] del kwargs['preprocessor_type'] data = [] if (preprocessor_type == hcprep.HcCorpusPreprocessor.__name__): data = hcprep.HcCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == emilleprep.EmilleCorpusPreprocessor.__name__): data = emilleprep.EmilleCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == leipprep.LeipzigPreprocessor.__name__): data = leipprep.LeipzigPreprocessor(*args, **kwargs) return data
Wrapper function for preprocessing module.
tvecs/__main__.py
preprocess_corpus
KshitijKarthick/tvecs
1
python
def preprocess_corpus(*args, **kwargs): preprocessor_type = kwargs['preprocessor_type'] del kwargs['preprocessor_type'] data = [] if (preprocessor_type == hcprep.HcCorpusPreprocessor.__name__): data = hcprep.HcCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == emilleprep.EmilleCorpusPreprocessor.__name__): data = emilleprep.EmilleCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == leipprep.LeipzigPreprocessor.__name__): data = leipprep.LeipzigPreprocessor(*args, **kwargs) return data
def preprocess_corpus(*args, **kwargs): preprocessor_type = kwargs['preprocessor_type'] del kwargs['preprocessor_type'] data = [] if (preprocessor_type == hcprep.HcCorpusPreprocessor.__name__): data = hcprep.HcCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == emilleprep.EmilleCorpusPreprocessor.__name__): data = emilleprep.EmilleCorpusPreprocessor(*args, **kwargs) elif (preprocessor_type == leipprep.LeipzigPreprocessor.__name__): data = leipprep.LeipzigPreprocessor(*args, **kwargs) return data<|docstring|>Wrapper function for preprocessing module.<|endoftext|>
61f96847e6eb6cfb6b74f21b5acce0d7194c055e440ea8ec9cc5c9621daa7e36
def model_generator(preprocessed_corpus, language, output_dir_path=os.path.join('.', 'data', 'models'), iterations=5): "\n Wrapper function for model_generator module.\n\n Function Arguments:\n * preprocessed_corpus - (HcCorpusPreprocessor) - Preprocessed corpus\n * language - (string) - Language of Preprocessed corpus\n * output_dir_path - (string) - Directory to store model [ Def: '.' ]\n * iter - (int) - No of iterations for model [ Def: 5 ]\n " return model.construct_model(preprocessed_corpus=preprocessed_corpus, language=language, output_dir_path=output_dir_path, iterations=iterations)
Wrapper function for model_generator module. Function Arguments: * preprocessed_corpus - (HcCorpusPreprocessor) - Preprocessed corpus * language - (string) - Language of Preprocessed corpus * output_dir_path - (string) - Directory to store model [ Def: '.' ] * iter - (int) - No of iterations for model [ Def: 5 ]
tvecs/__main__.py
model_generator
KshitijKarthick/tvecs
1
python
def model_generator(preprocessed_corpus, language, output_dir_path=os.path.join('.', 'data', 'models'), iterations=5): "\n Wrapper function for model_generator module.\n\n Function Arguments:\n * preprocessed_corpus - (HcCorpusPreprocessor) - Preprocessed corpus\n * language - (string) - Language of Preprocessed corpus\n * output_dir_path - (string) - Directory to store model [ Def: '.' ]\n * iter - (int) - No of iterations for model [ Def: 5 ]\n " return model.construct_model(preprocessed_corpus=preprocessed_corpus, language=language, output_dir_path=output_dir_path, iterations=iterations)
def model_generator(preprocessed_corpus, language, output_dir_path=os.path.join('.', 'data', 'models'), iterations=5): "\n Wrapper function for model_generator module.\n\n Function Arguments:\n * preprocessed_corpus - (HcCorpusPreprocessor) - Preprocessed corpus\n * language - (string) - Language of Preprocessed corpus\n * output_dir_path - (string) - Directory to store model [ Def: '.' ]\n * iter - (int) - No of iterations for model [ Def: 5 ]\n " return model.construct_model(preprocessed_corpus=preprocessed_corpus, language=language, output_dir_path=output_dir_path, iterations=iterations)<|docstring|>Wrapper function for model_generator module. Function Arguments: * preprocessed_corpus - (HcCorpusPreprocessor) - Preprocessed corpus * language - (string) - Language of Preprocessed corpus * output_dir_path - (string) - Directory to store model [ Def: '.' ] * iter - (int) - No of iterations for model [ Def: 5 ]<|endoftext|>
a48d88557c1b038b018571a7b4df9914c3a5b24d3e9e34abd70718c92cc99db5
def bilingual_generator(lang1, lang2, bilingual_dict): 'Load & returns previously generated bilingual dictionary.' bilingual_dict = bg.load_bilingual_dictionary(bilingual_dict) return bilingual_dict
Load & returns previously generated bilingual dictionary.
tvecs/__main__.py
bilingual_generator
KshitijKarthick/tvecs
1
python
def bilingual_generator(lang1, lang2, bilingual_dict): bilingual_dict = bg.load_bilingual_dictionary(bilingual_dict) return bilingual_dict
def bilingual_generator(lang1, lang2, bilingual_dict): bilingual_dict = bg.load_bilingual_dictionary(bilingual_dict) return bilingual_dict<|docstring|>Load & returns previously generated bilingual dictionary.<|endoftext|>
709c0fe0d2af6bacb86f4afc74dc70db698ce735a2490ecac685820b96bd16cf
def map_vector_spaces(*args, **kwargs): 'Generate & return VectorSpaceMapper Instance and maps vectors spaces.' vector_mapper_obj = vm.VectorSpaceMapper(*args, **kwargs) vector_mapper_obj.map_vector_spaces() return vector_mapper_obj
Generate & return VectorSpaceMapper Instance and maps vectors spaces.
tvecs/__main__.py
map_vector_spaces
KshitijKarthick/tvecs
1
python
def map_vector_spaces(*args, **kwargs): vector_mapper_obj = vm.VectorSpaceMapper(*args, **kwargs) vector_mapper_obj.map_vector_spaces() return vector_mapper_obj
def map_vector_spaces(*args, **kwargs): vector_mapper_obj = vm.VectorSpaceMapper(*args, **kwargs) vector_mapper_obj.map_vector_spaces() return vector_mapper_obj<|docstring|>Generate & return VectorSpaceMapper Instance and maps vectors spaces.<|endoftext|>
efd846974315129c069942a65cfececf36288e25a2046d9a8e049b98f4d6ff9a
def parse_config(config_path): 'Used to load and parse config file.' config = json.load(open(config_path, 'r')) lang1_details = config.get('language1', {}) lang1 = lang1_details.get('name', None) lang2_details = config.get('language2', {}) lang2 = lang2_details.get('name', None) model1 = lang1_details.get('model', None) model2 = lang2_details.get('model', None) corpus1 = lang1_details.get('corpora') corpus2 = lang2_details.get('corpora') iterations = config.get('iterations', 5) silent = config.get('silent', False) verbose = config.get('verbose', False) bilingual_dict = config.get('bilingual_dict', '') return (lang1, lang2, model1, model2, corpus1, corpus2, iterations, silent, verbose, bilingual_dict)
Used to load and parse config file.
tvecs/__main__.py
parse_config
KshitijKarthick/tvecs
1
python
def parse_config(config_path): config = json.load(open(config_path, 'r')) lang1_details = config.get('language1', {}) lang1 = lang1_details.get('name', None) lang2_details = config.get('language2', {}) lang2 = lang2_details.get('name', None) model1 = lang1_details.get('model', None) model2 = lang2_details.get('model', None) corpus1 = lang1_details.get('corpora') corpus2 = lang2_details.get('corpora') iterations = config.get('iterations', 5) silent = config.get('silent', False) verbose = config.get('verbose', False) bilingual_dict = config.get('bilingual_dict', ) return (lang1, lang2, model1, model2, corpus1, corpus2, iterations, silent, verbose, bilingual_dict)
def parse_config(config_path): config = json.load(open(config_path, 'r')) lang1_details = config.get('language1', {}) lang1 = lang1_details.get('name', None) lang2_details = config.get('language2', {}) lang2 = lang2_details.get('name', None) model1 = lang1_details.get('model', None) model2 = lang2_details.get('model', None) corpus1 = lang1_details.get('corpora') corpus2 = lang2_details.get('corpora') iterations = config.get('iterations', 5) silent = config.get('silent', False) verbose = config.get('verbose', False) bilingual_dict = config.get('bilingual_dict', ) return (lang1, lang2, model1, model2, corpus1, corpus2, iterations, silent, verbose, bilingual_dict)<|docstring|>Used to load and parse config file.<|endoftext|>
344d900fde9970021bd64e645b46c0d3b6a87651adee3486ffa6ce2db327013e
def args_parser(): 'Utilised for cmdline arguments parsing.' global order_of_tvex_calls, order_of_evaluation parser = argparse.ArgumentParser(description='Script used to generate models') parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true') parser.add_argument('-s', '--silent', help='silence all logging', action='store_true') parser.add_argument('-i', '--iter', help='number of Word2Vec iterations', default=5, action='store') parser.add_argument('-m1', '--model1', dest='model1', help='pre-computed model file path', action='store') parser.add_argument('-m2', '--model2', dest='model2', help='pre-computed model file path', action='store') parser.add_argument('-l1', '--language1', dest='language1', help='language name of model 1/ text 1', action='store') parser.add_argument('-l2', '--l2', dest='language2', help='language name of model 2/ text 2', action='store') parser.add_argument('-c', '--config', dest='config', help='config file path', action='store') parser.add_argument('-b', '--bilingual', dest='bilingual_dict', help='bilingual dictionary path', action='store') parser.add_argument('-r', '--recommendations', dest='recommendations', help='provide recommendations', action='store_true') args = parser.parse_args() logger = log.initialise('TVecs') log.set_logger_normal(logger) parse_success = False try: if args.config: (args.language1, args.language2, args.model1, args.model2, args.corpus1, args.corpus2, args.iter, args.silent, args.verbose, args.bilingual_dict) = parse_config(args.config) if (args.verbose is True): log.set_logger_verbose(logger) elif (args.silent is True): log.set_logger_silent(logger) valid_model = (args.model1 and args.model2) valid_lang = (args.language1 and args.language2) if (valid_model and valid_lang and args.bilingual_dict): logger.info('Loading Model of %s :%s', args.language1, args.model1) model_1 = Word2Vec.load(args.model1) logger.info('Loading Model of %s :%s', args.language2, args.model2) model_2 = Word2Vec.load(args.model2) order_of_evaluation = order_of_tvex_calls[2:] tvex_calls['model_generator']['result'] = (model_1, model_2) parse_success = True elif (args.corpus1 and args.corpus2): order_of_evaluation = order_of_tvex_calls[:] parse_success = True except AttributeError: parse_success = False if (parse_success is False): logger.error('Required arguments not passed, run --help for more details') return old_time = time.time() evaluate(logger, args) tvecs_vm = tvex_calls['vector_space_mapper']['result'] logger.info('Evaluation of Training Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=args.bilingual_dict) (fpath, fname) = ntpath.split(args.bilingual_dict) test_fname = fname.replace('train', 'test') if os.path.exists(os.path.join(fpath, test_fname)): logger.info('Evaluation of Testing Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=os.path.join(fpath, fname)) new_time = time.time() loading_time = (new_time - old_time) logger.info(('Execution Time: ' + str(loading_time))) if (args.recommendations is True): logger.info(('Recommendation Engine: %s => %s' % (args.language1, args.language2))) while (int(raw_input('\nEnter your Choice:\n1> Recommendation\n2> Exit\n\nChoice: ')) == 1): word = raw_input(('\nEnter word in Language %s: ' % args.language1)) tvecs_vm.get_recommendations_from_word(word, pretty_print=True)
Utilised for cmdline arguments parsing.
tvecs/__main__.py
args_parser
KshitijKarthick/tvecs
1
python
def args_parser(): global order_of_tvex_calls, order_of_evaluation parser = argparse.ArgumentParser(description='Script used to generate models') parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true') parser.add_argument('-s', '--silent', help='silence all logging', action='store_true') parser.add_argument('-i', '--iter', help='number of Word2Vec iterations', default=5, action='store') parser.add_argument('-m1', '--model1', dest='model1', help='pre-computed model file path', action='store') parser.add_argument('-m2', '--model2', dest='model2', help='pre-computed model file path', action='store') parser.add_argument('-l1', '--language1', dest='language1', help='language name of model 1/ text 1', action='store') parser.add_argument('-l2', '--l2', dest='language2', help='language name of model 2/ text 2', action='store') parser.add_argument('-c', '--config', dest='config', help='config file path', action='store') parser.add_argument('-b', '--bilingual', dest='bilingual_dict', help='bilingual dictionary path', action='store') parser.add_argument('-r', '--recommendations', dest='recommendations', help='provide recommendations', action='store_true') args = parser.parse_args() logger = log.initialise('TVecs') log.set_logger_normal(logger) parse_success = False try: if args.config: (args.language1, args.language2, args.model1, args.model2, args.corpus1, args.corpus2, args.iter, args.silent, args.verbose, args.bilingual_dict) = parse_config(args.config) if (args.verbose is True): log.set_logger_verbose(logger) elif (args.silent is True): log.set_logger_silent(logger) valid_model = (args.model1 and args.model2) valid_lang = (args.language1 and args.language2) if (valid_model and valid_lang and args.bilingual_dict): logger.info('Loading Model of %s :%s', args.language1, args.model1) model_1 = Word2Vec.load(args.model1) logger.info('Loading Model of %s :%s', args.language2, args.model2) model_2 = Word2Vec.load(args.model2) order_of_evaluation = order_of_tvex_calls[2:] tvex_calls['model_generator']['result'] = (model_1, model_2) parse_success = True elif (args.corpus1 and args.corpus2): order_of_evaluation = order_of_tvex_calls[:] parse_success = True except AttributeError: parse_success = False if (parse_success is False): logger.error('Required arguments not passed, run --help for more details') return old_time = time.time() evaluate(logger, args) tvecs_vm = tvex_calls['vector_space_mapper']['result'] logger.info('Evaluation of Training Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=args.bilingual_dict) (fpath, fname) = ntpath.split(args.bilingual_dict) test_fname = fname.replace('train', 'test') if os.path.exists(os.path.join(fpath, test_fname)): logger.info('Evaluation of Testing Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=os.path.join(fpath, fname)) new_time = time.time() loading_time = (new_time - old_time) logger.info(('Execution Time: ' + str(loading_time))) if (args.recommendations is True): logger.info(('Recommendation Engine: %s => %s' % (args.language1, args.language2))) while (int(raw_input('\nEnter your Choice:\n1> Recommendation\n2> Exit\n\nChoice: ')) == 1): word = raw_input(('\nEnter word in Language %s: ' % args.language1)) tvecs_vm.get_recommendations_from_word(word, pretty_print=True)
def args_parser(): global order_of_tvex_calls, order_of_evaluation parser = argparse.ArgumentParser(description='Script used to generate models') parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true') parser.add_argument('-s', '--silent', help='silence all logging', action='store_true') parser.add_argument('-i', '--iter', help='number of Word2Vec iterations', default=5, action='store') parser.add_argument('-m1', '--model1', dest='model1', help='pre-computed model file path', action='store') parser.add_argument('-m2', '--model2', dest='model2', help='pre-computed model file path', action='store') parser.add_argument('-l1', '--language1', dest='language1', help='language name of model 1/ text 1', action='store') parser.add_argument('-l2', '--l2', dest='language2', help='language name of model 2/ text 2', action='store') parser.add_argument('-c', '--config', dest='config', help='config file path', action='store') parser.add_argument('-b', '--bilingual', dest='bilingual_dict', help='bilingual dictionary path', action='store') parser.add_argument('-r', '--recommendations', dest='recommendations', help='provide recommendations', action='store_true') args = parser.parse_args() logger = log.initialise('TVecs') log.set_logger_normal(logger) parse_success = False try: if args.config: (args.language1, args.language2, args.model1, args.model2, args.corpus1, args.corpus2, args.iter, args.silent, args.verbose, args.bilingual_dict) = parse_config(args.config) if (args.verbose is True): log.set_logger_verbose(logger) elif (args.silent is True): log.set_logger_silent(logger) valid_model = (args.model1 and args.model2) valid_lang = (args.language1 and args.language2) if (valid_model and valid_lang and args.bilingual_dict): logger.info('Loading Model of %s :%s', args.language1, args.model1) model_1 = Word2Vec.load(args.model1) logger.info('Loading Model of %s :%s', args.language2, args.model2) model_2 = Word2Vec.load(args.model2) order_of_evaluation = order_of_tvex_calls[2:] tvex_calls['model_generator']['result'] = (model_1, model_2) parse_success = True elif (args.corpus1 and args.corpus2): order_of_evaluation = order_of_tvex_calls[:] parse_success = True except AttributeError: parse_success = False if (parse_success is False): logger.error('Required arguments not passed, run --help for more details') return old_time = time.time() evaluate(logger, args) tvecs_vm = tvex_calls['vector_space_mapper']['result'] logger.info('Evaluation of Training Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=args.bilingual_dict) (fpath, fname) = ntpath.split(args.bilingual_dict) test_fname = fname.replace('train', 'test') if os.path.exists(os.path.join(fpath, test_fname)): logger.info('Evaluation of Testing Dataset') tvecs_vm.obtain_mean_square_error_from_dataset(dataset_path=os.path.join(fpath, fname)) new_time = time.time() loading_time = (new_time - old_time) logger.info(('Execution Time: ' + str(loading_time))) if (args.recommendations is True): logger.info(('Recommendation Engine: %s => %s' % (args.language1, args.language2))) while (int(raw_input('\nEnter your Choice:\n1> Recommendation\n2> Exit\n\nChoice: ')) == 1): word = raw_input(('\nEnter word in Language %s: ' % args.language1)) tvecs_vm.get_recommendations_from_word(word, pretty_print=True)<|docstring|>Utilised for cmdline arguments parsing.<|endoftext|>
0b348e89b7dcc3072840aeb78411723aad3353e9efaa986a7535a444068cb44d
def evaluate(logger, args): 'Evaluate and run sequence of operations based on user specs.' global tvex_calls, order_of_evaluation for func_name in order_of_evaluation: func = tvex_calls[func_name]['func'] if (func_name is 'preprocessor'): def _preprocess_multiple_corpora(corpus_list, language): res = [] for corpus in corpus_list: fpath = corpus.keys()[0] preprocessor_type = corpus.values()[0] fname = ntpath.split(fpath)[1] logger.info('Preprocessing %s : %s', language, fpath) res.append(func(corpus_fname=fname, preprocessor_type=preprocessor_type, corpus_dir_path=ntpath.split(fpath)[0], encoding='utf-8', need_preprocessing=True, language=language)) return it.chain(*res) tvex_calls[func_name]['result'] = (_preprocess_multiple_corpora(corpus_list=args.corpus1, language=args.language1), _preprocess_multiple_corpora(corpus_list=args.corpus2, language=args.language2)) elif (func_name is 'model_generator'): tvex_calls[func_name]['result'] = (func(preprocessed_corpus=tvex_calls['preprocessor']['result'][0], language=args.language1, iterations=args.iter), func(preprocessed_corpus=tvex_calls['preprocessor']['result'][1], language=args.language2, iterations=args.iter)) elif (func_name is 'bilingual_generator'): tvex_calls[func_name]['result'] = func(lang1=args.language1, lang2=args.language2, bilingual_dict=args.bilingual_dict) elif (func_name is 'vector_space_mapper'): tvex_calls[func_name]['result'] = func(model_1=tvex_calls['model_generator']['result'][0], model_2=tvex_calls['model_generator']['result'][1], bilingual_dict=tvex_calls['bilingual_generator']['result']) else: logger.error('Unknown Function!')
Evaluate and run sequence of operations based on user specs.
tvecs/__main__.py
evaluate
KshitijKarthick/tvecs
1
python
def evaluate(logger, args): global tvex_calls, order_of_evaluation for func_name in order_of_evaluation: func = tvex_calls[func_name]['func'] if (func_name is 'preprocessor'): def _preprocess_multiple_corpora(corpus_list, language): res = [] for corpus in corpus_list: fpath = corpus.keys()[0] preprocessor_type = corpus.values()[0] fname = ntpath.split(fpath)[1] logger.info('Preprocessing %s : %s', language, fpath) res.append(func(corpus_fname=fname, preprocessor_type=preprocessor_type, corpus_dir_path=ntpath.split(fpath)[0], encoding='utf-8', need_preprocessing=True, language=language)) return it.chain(*res) tvex_calls[func_name]['result'] = (_preprocess_multiple_corpora(corpus_list=args.corpus1, language=args.language1), _preprocess_multiple_corpora(corpus_list=args.corpus2, language=args.language2)) elif (func_name is 'model_generator'): tvex_calls[func_name]['result'] = (func(preprocessed_corpus=tvex_calls['preprocessor']['result'][0], language=args.language1, iterations=args.iter), func(preprocessed_corpus=tvex_calls['preprocessor']['result'][1], language=args.language2, iterations=args.iter)) elif (func_name is 'bilingual_generator'): tvex_calls[func_name]['result'] = func(lang1=args.language1, lang2=args.language2, bilingual_dict=args.bilingual_dict) elif (func_name is 'vector_space_mapper'): tvex_calls[func_name]['result'] = func(model_1=tvex_calls['model_generator']['result'][0], model_2=tvex_calls['model_generator']['result'][1], bilingual_dict=tvex_calls['bilingual_generator']['result']) else: logger.error('Unknown Function!')
def evaluate(logger, args): global tvex_calls, order_of_evaluation for func_name in order_of_evaluation: func = tvex_calls[func_name]['func'] if (func_name is 'preprocessor'): def _preprocess_multiple_corpora(corpus_list, language): res = [] for corpus in corpus_list: fpath = corpus.keys()[0] preprocessor_type = corpus.values()[0] fname = ntpath.split(fpath)[1] logger.info('Preprocessing %s : %s', language, fpath) res.append(func(corpus_fname=fname, preprocessor_type=preprocessor_type, corpus_dir_path=ntpath.split(fpath)[0], encoding='utf-8', need_preprocessing=True, language=language)) return it.chain(*res) tvex_calls[func_name]['result'] = (_preprocess_multiple_corpora(corpus_list=args.corpus1, language=args.language1), _preprocess_multiple_corpora(corpus_list=args.corpus2, language=args.language2)) elif (func_name is 'model_generator'): tvex_calls[func_name]['result'] = (func(preprocessed_corpus=tvex_calls['preprocessor']['result'][0], language=args.language1, iterations=args.iter), func(preprocessed_corpus=tvex_calls['preprocessor']['result'][1], language=args.language2, iterations=args.iter)) elif (func_name is 'bilingual_generator'): tvex_calls[func_name]['result'] = func(lang1=args.language1, lang2=args.language2, bilingual_dict=args.bilingual_dict) elif (func_name is 'vector_space_mapper'): tvex_calls[func_name]['result'] = func(model_1=tvex_calls['model_generator']['result'][0], model_2=tvex_calls['model_generator']['result'][1], bilingual_dict=tvex_calls['bilingual_generator']['result']) else: logger.error('Unknown Function!')<|docstring|>Evaluate and run sequence of operations based on user specs.<|endoftext|>
7201e606635966ec0811bb35bcd7fc191f8ae0e5a0f578f4026908635faca1d7
def move(self, folder, tags_add, tags_remove): '\n Move mails in folder maildir according to the given maps.\n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = '( {0} ) AND not folder:"{1}"'.format(conjunct, folder) logging.debug('fts-mv query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-mv: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-mv: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: old_filename = files[0] old_folder = self.get_maildir(old_filename) if (old_folder == folder): logging.debug('fts-mv: refused copy file {0} to own folder'.format(old_filename)) else: new_filename = self.get_new_name(old_filename, os.path.join(self.base_directory, folder)) if os.path.isfile(new_filename): logging.debug('fts-cp refuse: {0} already exists'.format(new_filename)) elif (not os.path.isfile(old_filename)): logging.debug('fts-cp refuse: {0} not found'.format(old_filename)) else: logging.info("fts-cp: '{0}' to folder '{1}'".format(get_message_summary(msg), folder)) if self.copy_file(old_filename, new_filename): self.to_delete.add(old_filename)
Move mails in folder maildir according to the given maps.
afew/FolderTagSync.py
move
naegling/afew
0
python
def move(self, folder, tags_add, tags_remove): '\n \n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = '( {0} ) AND not folder:"{1}"'.format(conjunct, folder) logging.debug('fts-mv query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-mv: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-mv: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: old_filename = files[0] old_folder = self.get_maildir(old_filename) if (old_folder == folder): logging.debug('fts-mv: refused copy file {0} to own folder'.format(old_filename)) else: new_filename = self.get_new_name(old_filename, os.path.join(self.base_directory, folder)) if os.path.isfile(new_filename): logging.debug('fts-cp refuse: {0} already exists'.format(new_filename)) elif (not os.path.isfile(old_filename)): logging.debug('fts-cp refuse: {0} not found'.format(old_filename)) else: logging.info("fts-cp: '{0}' to folder '{1}'".format(get_message_summary(msg), folder)) if self.copy_file(old_filename, new_filename): self.to_delete.add(old_filename)
def move(self, folder, tags_add, tags_remove): '\n \n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = '( {0} ) AND not folder:"{1}"'.format(conjunct, folder) logging.debug('fts-mv query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-mv: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-mv: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: old_filename = files[0] old_folder = self.get_maildir(old_filename) if (old_folder == folder): logging.debug('fts-mv: refused copy file {0} to own folder'.format(old_filename)) else: new_filename = self.get_new_name(old_filename, os.path.join(self.base_directory, folder)) if os.path.isfile(new_filename): logging.debug('fts-cp refuse: {0} already exists'.format(new_filename)) elif (not os.path.isfile(old_filename)): logging.debug('fts-cp refuse: {0} not found'.format(old_filename)) else: logging.info("fts-cp: '{0}' to folder '{1}'".format(get_message_summary(msg), folder)) if self.copy_file(old_filename, new_filename): self.to_delete.add(old_filename)<|docstring|>Move mails in folder maildir according to the given maps.<|endoftext|>
bd4d42fea75f8fdb6494db7f81b9368b4f6aa9b065a6d36a654b005c7768a1c1
def tag(self, folder, tags_add, tags_remove): '\n Update the database after mail files have been moved in the filesystem.\n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = 'folder:"{0}" and not ( {1} )'.format(folder, conjunct) logging.debug('fts-tag query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-tag: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-tag: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: file = files[0] maildir = self.get_maildir(file) if (maildir != folder): logging.warning('fts-tag maildir/file mismatch {0}/{1}'.format(folder, file)) else: adds = [] removes = [] msg_tags = set([tag for tag in msg.get_tags()]) logging.debug('fts-tag msg: {0} in {1} current tags: {2}'.format(get_message_summary(msg), maildir, ','.join(msg_tags))) for tag in tags_add: if (tag not in msg_tags): adds.append(tag) for tag in tags_remove: if (tag in msg_tags): removes.append(tag) self.adj_tags(msg, adds, removes)
Update the database after mail files have been moved in the filesystem.
afew/FolderTagSync.py
tag
naegling/afew
0
python
def tag(self, folder, tags_add, tags_remove): '\n \n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = 'folder:"{0}" and not ( {1} )'.format(folder, conjunct) logging.debug('fts-tag query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-tag: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-tag: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: file = files[0] maildir = self.get_maildir(file) if (maildir != folder): logging.warning('fts-tag maildir/file mismatch {0}/{1}'.format(folder, file)) else: adds = [] removes = [] msg_tags = set([tag for tag in msg.get_tags()]) logging.debug('fts-tag msg: {0} in {1} current tags: {2}'.format(get_message_summary(msg), maildir, ','.join(msg_tags))) for tag in tags_add: if (tag not in msg_tags): adds.append(tag) for tag in tags_remove: if (tag in msg_tags): removes.append(tag) self.adj_tags(msg, adds, removes)
def tag(self, folder, tags_add, tags_remove): '\n \n ' terms = ['tag:{0}'.format(tag) for tag in tags_add] terms.extend(['not tag:{0}'.format(tag) for tag in tags_remove]) conjunct = ' AND '.join(terms) query = 'folder:"{0}" and not ( {1} )'.format(folder, conjunct) logging.debug('fts-tag query: {0}'.format(query)) for msg in notmuch.Query(self.db, query).search_messages(): files = [filename for filename in msg.get_filenames()] num_files = len(files) if (num_files == 0): logging.error('fts-tag: msg without storage file: {0}'.format(get_message_summary(msg))) elif (num_files > 1): logging.info('fts-tag: skipping multi-file msg: {0} in {1}'.format(get_message_summary(msg), ','.join(files))) else: file = files[0] maildir = self.get_maildir(file) if (maildir != folder): logging.warning('fts-tag maildir/file mismatch {0}/{1}'.format(folder, file)) else: adds = [] removes = [] msg_tags = set([tag for tag in msg.get_tags()]) logging.debug('fts-tag msg: {0} in {1} current tags: {2}'.format(get_message_summary(msg), maildir, ','.join(msg_tags))) for tag in tags_add: if (tag not in msg_tags): adds.append(tag) for tag in tags_remove: if (tag in msg_tags): removes.append(tag) self.adj_tags(msg, adds, removes)<|docstring|>Update the database after mail files have been moved in the filesystem.<|endoftext|>
519f792109a51f8026bbe49654a557680d30890fe7f055d58c7630f542c47ccb
def __update_db(self): '\n Update the database after mail files have been moved in the filesystem.\n ' logging.info('fts-mv: update notmuch database') if (not self.dry_run): try: check_call((['notmuch', 'new'] + self.notmuch_args.split())) except CalledProcessError as err: logging.error('fts Could not update notmuch database after moving files: {0}'.format(err)) raise SystemExit
Update the database after mail files have been moved in the filesystem.
afew/FolderTagSync.py
__update_db
naegling/afew
0
python
def __update_db(self): '\n \n ' logging.info('fts-mv: update notmuch database') if (not self.dry_run): try: check_call((['notmuch', 'new'] + self.notmuch_args.split())) except CalledProcessError as err: logging.error('fts Could not update notmuch database after moving files: {0}'.format(err)) raise SystemExit
def __update_db(self): '\n \n ' logging.info('fts-mv: update notmuch database') if (not self.dry_run): try: check_call((['notmuch', 'new'] + self.notmuch_args.split())) except CalledProcessError as err: logging.error('fts Could not update notmuch database after moving files: {0}'.format(err)) raise SystemExit<|docstring|>Update the database after mail files have been moved in the filesystem.<|endoftext|>
aa8e35fb9e7b3563787503665303977566c43b63f1c64a1d632275275d549698
def __init__(self, infos_args, val_obj): 'Initial arguments for generator.\n Arguments:\n infos_args: A dict for generating infos_list.\n val_obj: A object for validating the info.\n ' self.infos_args = infos_args self.val = val_obj
Initial arguments for generator. Arguments: infos_args: A dict for generating infos_list. val_obj: A object for validating the info.
deployment/sskcp-confgenerator/confgenerator/generator.py
__init__
elespejo/sskcp
2
python
def __init__(self, infos_args, val_obj): 'Initial arguments for generator.\n Arguments:\n infos_args: A dict for generating infos_list.\n val_obj: A object for validating the info.\n ' self.infos_args = infos_args self.val = val_obj
def __init__(self, infos_args, val_obj): 'Initial arguments for generator.\n Arguments:\n infos_args: A dict for generating infos_list.\n val_obj: A object for validating the info.\n ' self.infos_args = infos_args self.val = val_obj<|docstring|>Initial arguments for generator. Arguments: infos_args: A dict for generating infos_list. val_obj: A object for validating the info.<|endoftext|>
c3787144567a1273b4d9b23a7b355458af0c34530f3d91786cc19e8e5aa8bada
def _gen_info(self, infos_args): 'Generate infos_list.\n Argument:\n infos_args: the dict of information that from cli parser.\n\n Return:\n infos_list: The list of infos.\n ' pass
Generate infos_list. Argument: infos_args: the dict of information that from cli parser. Return: infos_list: The list of infos.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_info
elespejo/sskcp
2
python
def _gen_info(self, infos_args): 'Generate infos_list.\n Argument:\n infos_args: the dict of information that from cli parser.\n\n Return:\n infos_list: The list of infos.\n ' pass
def _gen_info(self, infos_args): 'Generate infos_list.\n Argument:\n infos_args: the dict of information that from cli parser.\n\n Return:\n infos_list: The list of infos.\n ' pass<|docstring|>Generate infos_list. Argument: infos_args: the dict of information that from cli parser. Return: infos_list: The list of infos.<|endoftext|>
d978f2f0369c3f187285221ec9a51a2f5c1eddb8ef575da819a5c6a1b6913183
def _validate(self, info): "Validate the info.\n Argument:\n self.val: the validator object.\n info: A dict of sskcp client or server information.\n {\n\t \t'mode': [ss/sskcp],\n\t \t'log-dir': [/path/to/log],\n\t \t'listenport': [port],\n 'key': [key],\n\t \t'dest': [/path/to/config],\n ...\n\t }\n\n Return:\n result: (bool, msg)\n " validator = self.val(info) return validator.validate()
Validate the info. Argument: self.val: the validator object. info: A dict of sskcp client or server information. { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], ... } Return: result: (bool, msg)
deployment/sskcp-confgenerator/confgenerator/generator.py
_validate
elespejo/sskcp
2
python
def _validate(self, info): "Validate the info.\n Argument:\n self.val: the validator object.\n info: A dict of sskcp client or server information.\n {\n\t \t'mode': [ss/sskcp],\n\t \t'log-dir': [/path/to/log],\n\t \t'listenport': [port],\n 'key': [key],\n\t \t'dest': [/path/to/config],\n ...\n\t }\n\n Return:\n result: (bool, msg)\n " validator = self.val(info) return validator.validate()
def _validate(self, info): "Validate the info.\n Argument:\n self.val: the validator object.\n info: A dict of sskcp client or server information.\n {\n\t \t'mode': [ss/sskcp],\n\t \t'log-dir': [/path/to/log],\n\t \t'listenport': [port],\n 'key': [key],\n\t \t'dest': [/path/to/config],\n ...\n\t }\n\n Return:\n result: (bool, msg)\n " validator = self.val(info) return validator.validate()<|docstring|>Validate the info. Argument: self.val: the validator object. info: A dict of sskcp client or server information. { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], ... } Return: result: (bool, msg)<|endoftext|>
c4af1e6f55e5689399c6466c70a0ab1af8b31fe745ac0a137924e7878219f1a4
def _gen_config(self, mode, log, dest): "Generate configuration structure and config.env.\n Arguments:\n mode: the mode of sskcp. It is ss or sskcp.\n log: the absolute path of log.\n dest: the absolute path of configuration.\n\n Return:\n 1. A configuration directory for sskcp is created in [dest].\n 2. A log directory for sskcp is created in [log] \n 3. A config.env is generated in [dest]/.\n \n configuration structure:\n info['dest']/\n |_config.env\n |_conf/\n \n Content of config.env:\n LOG_DIR=info['log-dir']\n MODE=info['mode'] \n " if os.path.exists(dest): print('The configuration exists.') yn = input('Do you want to overwrite it?[y/n]') if (yn == 'y'): print(('Remove origin configuration: ' + dest)) shutil.rmtree(dest) elif (yn == 'n'): raise SystemExit('Exit.') else: raise SystemExit((('Worry keyword: ' + yn) + '\nExit.')) print('\nGenerate configuration structure.') print((' - create directory: ' + dest)) os.makedirs((dest + '/conf')) print((' - create log directory: ' + log)) os.makedirs(log, exist_ok=True) print(' - create config.env.') with open((dest + '/config.env'), 'w') as f: f.write(((('LOG_DIR=' + log) + '\nMODE=') + mode))
Generate configuration structure and config.env. Arguments: mode: the mode of sskcp. It is ss or sskcp. log: the absolute path of log. dest: the absolute path of configuration. Return: 1. A configuration directory for sskcp is created in [dest]. 2. A log directory for sskcp is created in [log] 3. A config.env is generated in [dest]/. configuration structure: info['dest']/ |_config.env |_conf/ Content of config.env: LOG_DIR=info['log-dir'] MODE=info['mode']
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_config
elespejo/sskcp
2
python
def _gen_config(self, mode, log, dest): "Generate configuration structure and config.env.\n Arguments:\n mode: the mode of sskcp. It is ss or sskcp.\n log: the absolute path of log.\n dest: the absolute path of configuration.\n\n Return:\n 1. A configuration directory for sskcp is created in [dest].\n 2. A log directory for sskcp is created in [log] \n 3. A config.env is generated in [dest]/.\n \n configuration structure:\n info['dest']/\n |_config.env\n |_conf/\n \n Content of config.env:\n LOG_DIR=info['log-dir']\n MODE=info['mode'] \n " if os.path.exists(dest): print('The configuration exists.') yn = input('Do you want to overwrite it?[y/n]') if (yn == 'y'): print(('Remove origin configuration: ' + dest)) shutil.rmtree(dest) elif (yn == 'n'): raise SystemExit('Exit.') else: raise SystemExit((('Worry keyword: ' + yn) + '\nExit.')) print('\nGenerate configuration structure.') print((' - create directory: ' + dest)) os.makedirs((dest + '/conf')) print((' - create log directory: ' + log)) os.makedirs(log, exist_ok=True) print(' - create config.env.') with open((dest + '/config.env'), 'w') as f: f.write(((('LOG_DIR=' + log) + '\nMODE=') + mode))
def _gen_config(self, mode, log, dest): "Generate configuration structure and config.env.\n Arguments:\n mode: the mode of sskcp. It is ss or sskcp.\n log: the absolute path of log.\n dest: the absolute path of configuration.\n\n Return:\n 1. A configuration directory for sskcp is created in [dest].\n 2. A log directory for sskcp is created in [log] \n 3. A config.env is generated in [dest]/.\n \n configuration structure:\n info['dest']/\n |_config.env\n |_conf/\n \n Content of config.env:\n LOG_DIR=info['log-dir']\n MODE=info['mode'] \n " if os.path.exists(dest): print('The configuration exists.') yn = input('Do you want to overwrite it?[y/n]') if (yn == 'y'): print(('Remove origin configuration: ' + dest)) shutil.rmtree(dest) elif (yn == 'n'): raise SystemExit('Exit.') else: raise SystemExit((('Worry keyword: ' + yn) + '\nExit.')) print('\nGenerate configuration structure.') print((' - create directory: ' + dest)) os.makedirs((dest + '/conf')) print((' - create log directory: ' + log)) os.makedirs(log, exist_ok=True) print(' - create config.env.') with open((dest + '/config.env'), 'w') as f: f.write(((('LOG_DIR=' + log) + '\nMODE=') + mode))<|docstring|>Generate configuration structure and config.env. Arguments: mode: the mode of sskcp. It is ss or sskcp. log: the absolute path of log. dest: the absolute path of configuration. Return: 1. A configuration directory for sskcp is created in [dest]. 2. A log directory for sskcp is created in [log] 3. A config.env is generated in [dest]/. configuration structure: info['dest']/ |_config.env |_conf/ Content of config.env: LOG_DIR=info['log-dir'] MODE=info['mode']<|endoftext|>
14ae47f981bb8d0eca862eead07c946a16edd4bad795d64bb4fa5c30c1d80ed9
def _gen_ss_setting(self, info): 'Generate setting for mode ss.\n Arguments:\n info: the dict of ss info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n ' pass
Generate setting for mode ss. Arguments: info: the dict of ss info. Return: ss_setting: the dict of ss setting for ss.json generation.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_setting
elespejo/sskcp
2
python
def _gen_ss_setting(self, info): 'Generate setting for mode ss.\n Arguments:\n info: the dict of ss info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n ' pass
def _gen_ss_setting(self, info): 'Generate setting for mode ss.\n Arguments:\n info: the dict of ss info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n ' pass<|docstring|>Generate setting for mode ss. Arguments: info: the dict of ss info. Return: ss_setting: the dict of ss setting for ss.json generation.<|endoftext|>
8b500d054c6c704a5b4deef50ed5bcd536df53d2d308a1ab6b6d43e070227dd2
def _gen_sskcp_setting(self, info): 'Generate setting for mode sskcp.\n Arguments:\n info: the dict of sskcp info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n kcp_setting: the dict of ss setting for kcp.json generation.\n ' pass
Generate setting for mode sskcp. Arguments: info: the dict of sskcp info. Return: ss_setting: the dict of ss setting for ss.json generation. kcp_setting: the dict of ss setting for kcp.json generation.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_sskcp_setting
elespejo/sskcp
2
python
def _gen_sskcp_setting(self, info): 'Generate setting for mode sskcp.\n Arguments:\n info: the dict of sskcp info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n kcp_setting: the dict of ss setting for kcp.json generation.\n ' pass
def _gen_sskcp_setting(self, info): 'Generate setting for mode sskcp.\n Arguments:\n info: the dict of sskcp info.\n\n Return:\n ss_setting: the dict of ss setting for ss.json generation.\n kcp_setting: the dict of ss setting for kcp.json generation.\n ' pass<|docstring|>Generate setting for mode sskcp. Arguments: info: the dict of sskcp info. Return: ss_setting: the dict of ss setting for ss.json generation. kcp_setting: the dict of ss setting for kcp.json generation.<|endoftext|>
9296885e7ba8453f4644ed1314f3524e82dab543bc0e56c51e303750c06e1d37
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' pass
Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_conf
elespejo/sskcp
2
python
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' pass
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' pass<|docstring|>Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.<|endoftext|>
2347f75ba90dde8dc0bbe2246abff9bbd82cea0aaf858a86eae24318224f869c
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' pass
Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_kcp_conf
elespejo/sskcp
2
python
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' pass
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' pass<|docstring|>Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.<|endoftext|>
90849de939c91edf556a4bef7f8bcb95454fd69122c3f883ece14246569a787f
def write_json(self, conf, dest, name): 'Write [conf] to a json file in [dest].\n Arguments:\n conf: A dict.\n dest: An absolute path where json file generated.\n name: The name of the json file.\n\n Return:\n A json file named [name] with content [conf] in [dest].\n ' print((((('\nGenerate json file: ' + dest) + '/') + name) + '.json')) with open((((dest + '/') + name) + '.json'), 'w') as outfile: try: json.dump(conf, outfile, indent=4) except json.JSONDecodeError as exc: print(exc) except KeyboardInterrupt: print('You cancelled the operation.')
Write [conf] to a json file in [dest]. Arguments: conf: A dict. dest: An absolute path where json file generated. name: The name of the json file. Return: A json file named [name] with content [conf] in [dest].
deployment/sskcp-confgenerator/confgenerator/generator.py
write_json
elespejo/sskcp
2
python
def write_json(self, conf, dest, name): 'Write [conf] to a json file in [dest].\n Arguments:\n conf: A dict.\n dest: An absolute path where json file generated.\n name: The name of the json file.\n\n Return:\n A json file named [name] with content [conf] in [dest].\n ' print((((('\nGenerate json file: ' + dest) + '/') + name) + '.json')) with open((((dest + '/') + name) + '.json'), 'w') as outfile: try: json.dump(conf, outfile, indent=4) except json.JSONDecodeError as exc: print(exc) except KeyboardInterrupt: print('You cancelled the operation.')
def write_json(self, conf, dest, name): 'Write [conf] to a json file in [dest].\n Arguments:\n conf: A dict.\n dest: An absolute path where json file generated.\n name: The name of the json file.\n\n Return:\n A json file named [name] with content [conf] in [dest].\n ' print((((('\nGenerate json file: ' + dest) + '/') + name) + '.json')) with open((((dest + '/') + name) + '.json'), 'w') as outfile: try: json.dump(conf, outfile, indent=4) except json.JSONDecodeError as exc: print(exc) except KeyboardInterrupt: print('You cancelled the operation.')<|docstring|>Write [conf] to a json file in [dest]. Arguments: conf: A dict. dest: An absolute path where json file generated. name: The name of the json file. Return: A json file named [name] with content [conf] in [dest].<|endoftext|>
f7a88177f5aff118ef4c4f64e44cc8a59a93fc5dc0cdb9eafda8f81cac96cbbc
def load_yaml(self, yaml_file): 'Load yaml to a dict.\n Arguments:\n yaml_file: the absolute path of a yaml file.\n\n Return:\n yaml_dict: the dict of the yaml file. \n ' print(('\nLoad yaml file: ' + yaml_file)) with open(yaml_file, 'r') as file: try: return yaml.load(file) except yaml.YAMLError as exc: print(exc)
Load yaml to a dict. Arguments: yaml_file: the absolute path of a yaml file. Return: yaml_dict: the dict of the yaml file.
deployment/sskcp-confgenerator/confgenerator/generator.py
load_yaml
elespejo/sskcp
2
python
def load_yaml(self, yaml_file): 'Load yaml to a dict.\n Arguments:\n yaml_file: the absolute path of a yaml file.\n\n Return:\n yaml_dict: the dict of the yaml file. \n ' print(('\nLoad yaml file: ' + yaml_file)) with open(yaml_file, 'r') as file: try: return yaml.load(file) except yaml.YAMLError as exc: print(exc)
def load_yaml(self, yaml_file): 'Load yaml to a dict.\n Arguments:\n yaml_file: the absolute path of a yaml file.\n\n Return:\n yaml_dict: the dict of the yaml file. \n ' print(('\nLoad yaml file: ' + yaml_file)) with open(yaml_file, 'r') as file: try: return yaml.load(file) except yaml.YAMLError as exc: print(exc)<|docstring|>Load yaml to a dict. Arguments: yaml_file: the absolute path of a yaml file. Return: yaml_dict: the dict of the yaml file.<|endoftext|>
d37ef412089bb00e8bf9d8dfa2b409e8a1db7c50411b6929189a01108656b2f5
def generate(self): 'Steps for generating sskcp configuration.\n Steps:\n 1. generate list of infos\n 2. for info in infos_list:\n 2.1 validate info\n 2.2 generate structure and config.env\n 2.3 generate setting\n 2.4 generate conf\n 2.5 write file\n ' infos_list = self._gen_info(self.infos_args) for info in infos_list: log = info.pop('log-dir') mode = info.pop('mode') dest = info.pop('dest') self._gen_config(mode, log, dest) if (mode == 'sskcp'): (ss_setting, kcp_setting) = self._gen_sskcp_setting(info) kcp_conf = self._gen_kcp_conf(kcp_setting) self.write_json(kcp_conf, (dest + '/conf'), 'kcp') elif (mode == 'ss'): ss_setting = self._gen_ss_setting(info) ss_conf = self._gen_ss_conf(ss_setting) self.write_json(ss_conf, (dest + '/conf'), 'ss')
Steps for generating sskcp configuration. Steps: 1. generate list of infos 2. for info in infos_list: 2.1 validate info 2.2 generate structure and config.env 2.3 generate setting 2.4 generate conf 2.5 write file
deployment/sskcp-confgenerator/confgenerator/generator.py
generate
elespejo/sskcp
2
python
def generate(self): 'Steps for generating sskcp configuration.\n Steps:\n 1. generate list of infos\n 2. for info in infos_list:\n 2.1 validate info\n 2.2 generate structure and config.env\n 2.3 generate setting\n 2.4 generate conf\n 2.5 write file\n ' infos_list = self._gen_info(self.infos_args) for info in infos_list: log = info.pop('log-dir') mode = info.pop('mode') dest = info.pop('dest') self._gen_config(mode, log, dest) if (mode == 'sskcp'): (ss_setting, kcp_setting) = self._gen_sskcp_setting(info) kcp_conf = self._gen_kcp_conf(kcp_setting) self.write_json(kcp_conf, (dest + '/conf'), 'kcp') elif (mode == 'ss'): ss_setting = self._gen_ss_setting(info) ss_conf = self._gen_ss_conf(ss_setting) self.write_json(ss_conf, (dest + '/conf'), 'ss')
def generate(self): 'Steps for generating sskcp configuration.\n Steps:\n 1. generate list of infos\n 2. for info in infos_list:\n 2.1 validate info\n 2.2 generate structure and config.env\n 2.3 generate setting\n 2.4 generate conf\n 2.5 write file\n ' infos_list = self._gen_info(self.infos_args) for info in infos_list: log = info.pop('log-dir') mode = info.pop('mode') dest = info.pop('dest') self._gen_config(mode, log, dest) if (mode == 'sskcp'): (ss_setting, kcp_setting) = self._gen_sskcp_setting(info) kcp_conf = self._gen_kcp_conf(kcp_setting) self.write_json(kcp_conf, (dest + '/conf'), 'kcp') elif (mode == 'ss'): ss_setting = self._gen_ss_setting(info) ss_conf = self._gen_ss_conf(ss_setting) self.write_json(ss_conf, (dest + '/conf'), 'ss')<|docstring|>Steps for generating sskcp configuration. Steps: 1. generate list of infos 2. for info in infos_list: 2.1 validate info 2.2 generate structure and config.env 2.3 generate setting 2.4 generate conf 2.5 write file<|endoftext|>
5dfaddea62e3f1c113170f0386e25afcd3400a4a0339d8d720b4f79a9d680c58
def _gen_info(self, infos_args): "Generate info list.\n Arguments:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n 'dest': [/path/to/config]\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log],\n\t\t 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['client'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((((((info['dest'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) info['log-dir'] = ((((((info['log-dir'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) return infos_list
Generate info list. Arguments: infos_args = { 'info-file': [/path/to/conf-info], 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config] } Return: infos_list: The list of infos. [ { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config], }, ... ]
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_info
elespejo/sskcp
2
python
def _gen_info(self, infos_args): "Generate info list.\n Arguments:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n 'dest': [/path/to/config]\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log],\n\t\t 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['client'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((((((info['dest'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) info['log-dir'] = ((((((info['log-dir'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) return infos_list
def _gen_info(self, infos_args): "Generate info list.\n Arguments:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n 'dest': [/path/to/config]\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log],\n\t\t 'listenport': [port],\n 'vpsip': [ip],\n 'vpsport': [port]\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['client'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((((((info['dest'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) info['log-dir'] = ((((((info['log-dir'] + '/') + str(info['listenport'])) + '-') + info['vpsip']) + '-') + str(info['vpsport'])) return infos_list<|docstring|>Generate info list. Arguments: infos_args = { 'info-file': [/path/to/conf-info], 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config] } Return: infos_list: The list of infos. [ { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config], }, ... ]<|endoftext|>
0202dead0d36625f4ffbc1f3c6b3ea19c7b974f5b1ca0220245995c0f013dc51
def _gen_ss_setting(self, info): 'Generate ss client setting for mode ss.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']\n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': info['vpsip'], 'serverport': info['vpsport'], 'sskey': ('ss_' + info['key'])} return ss_setting
Generate ss client setting for mode ss. Arguments: info: A dict of sskcp client information. { 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport'] "server": info['vpsip'] "serverport": info['vpsport'] "sskey": "ss_"+info['key'] }
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_setting
elespejo/sskcp
2
python
def _gen_ss_setting(self, info): 'Generate ss client setting for mode ss.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']\n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': info['vpsip'], 'serverport': info['vpsport'], 'sskey': ('ss_' + info['key'])} return ss_setting
def _gen_ss_setting(self, info): 'Generate ss client setting for mode ss.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']\n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': info['vpsip'], 'serverport': info['vpsport'], 'sskey': ('ss_' + info['key'])} return ss_setting<|docstring|>Generate ss client setting for mode ss. Arguments: info: A dict of sskcp client information. { 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport'] "server": info['vpsip'] "serverport": info['vpsport'] "sskey": "ss_"+info['key'] }<|endoftext|>
e7ff71b224d7f5872b5757cc2442b46b5eaed0ecbea36b292ff6193c77dfc7b6
def _gen_sskcp_setting(self, info): 'Generate ss and kcp client setting for mode sskcp.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'mode\': [ss/sskcp],\n\t \t\'log-dir\': [/path/to/log],\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t \t\'dest\': [/path/to/config],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"ssport": info[\'listenport\']\n \t"server": 127.0.0.1\n \t"serverport": info[\'vpsport\']+2000\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'listenport\']+2000 \n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': '127.0.0.1', 'serverport': (info['listenport'] + 2000), 'sskey': ('ss_' + info['key'])} kcp_setting = {'listenport': (info['listenport'] + 2000), 'server': info['vpsip'], 'serverport': info['vpsport'], 'kcpkey': ('kcp_' + info['key'])} return (ss_setting, kcp_setting)
Generate ss and kcp client setting for mode sskcp. Arguments: info: A dict of sskcp client information. { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config], } Return: ss_setting: A setting dict for ss.json generation. { "ssport": info['listenport'] "server": 127.0.0.1 "serverport": info['vpsport']+2000 "sskey": "ss_"+info['key'] } kcp_setting: A setting dict for kcp.json generation. { "listenport": info['listenport']+2000 "server": info['vpsip'] "serverport": info['vpsport'] "kcpkey": "kcp_"+info['key'] }
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_sskcp_setting
elespejo/sskcp
2
python
def _gen_sskcp_setting(self, info): 'Generate ss and kcp client setting for mode sskcp.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'mode\': [ss/sskcp],\n\t \t\'log-dir\': [/path/to/log],\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t \t\'dest\': [/path/to/config],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"ssport": info[\'listenport\']\n \t"server": 127.0.0.1\n \t"serverport": info[\'vpsport\']+2000\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'listenport\']+2000 \n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': '127.0.0.1', 'serverport': (info['listenport'] + 2000), 'sskey': ('ss_' + info['key'])} kcp_setting = {'listenport': (info['listenport'] + 2000), 'server': info['vpsip'], 'serverport': info['vpsport'], 'kcpkey': ('kcp_' + info['key'])} return (ss_setting, kcp_setting)
def _gen_sskcp_setting(self, info): 'Generate ss and kcp client setting for mode sskcp.\n Arguments:\n info: A dict of sskcp client information.\n {\n\t \t\'mode\': [ss/sskcp],\n\t \t\'log-dir\': [/path/to/log],\n\t \t\'listenport\': [port],\n \'vpsip\': [ip],\n \'vpsport\': [port]\n \'key\': [key],\n\t \t\'dest\': [/path/to/config],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"ssport": info[\'listenport\']\n \t"server": 127.0.0.1\n \t"serverport": info[\'vpsport\']+2000\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'listenport\']+2000 \n \t"server": info[\'vpsip\']\n \t"serverport": info[\'vpsport\']\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'server': '127.0.0.1', 'serverport': (info['listenport'] + 2000), 'sskey': ('ss_' + info['key'])} kcp_setting = {'listenport': (info['listenport'] + 2000), 'server': info['vpsip'], 'serverport': info['vpsport'], 'kcpkey': ('kcp_' + info['key'])} return (ss_setting, kcp_setting)<|docstring|>Generate ss and kcp client setting for mode sskcp. Arguments: info: A dict of sskcp client information. { 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'vpsip': [ip], 'vpsport': [port] 'key': [key], 'dest': [/path/to/config], } Return: ss_setting: A setting dict for ss.json generation. { "ssport": info['listenport'] "server": 127.0.0.1 "serverport": info['vpsport']+2000 "sskey": "ss_"+info['key'] } kcp_setting: A setting dict for kcp.json generation. { "listenport": info['listenport']+2000 "server": info['vpsip'] "serverport": info['vpsport'] "kcpkey": "kcp_"+info['key'] }<|endoftext|>
5e33809fb080d7aa1e071720f50f8f6b1a4c4ef4a7ca741e8aaa26b52ecf161d
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': ss_setting['server'], 'server_port': ss_setting['serverport'], 'local_address': '0.0.0.0', 'local_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 600, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf
Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_conf
elespejo/sskcp
2
python
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': ss_setting['server'], 'server_port': ss_setting['serverport'], 'local_address': '0.0.0.0', 'local_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 600, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': ss_setting['server'], 'server_port': ss_setting['serverport'], 'local_address': '0.0.0.0', 'local_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 600, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf<|docstring|>Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.<|endoftext|>
afe72a45cb88331cd5f2de863125ace336fc24dd8c19cdc75f63b15d9cbd3d71
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'localaddr': ('127.0.0.1:' + str(kcp_setting['listenport'])), 'remoteaddr': ((kcp_setting['server'] + ':') + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/clientlog/kcp-20060102.log'} return kcp_conf
Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_kcp_conf
elespejo/sskcp
2
python
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'localaddr': ('127.0.0.1:' + str(kcp_setting['listenport'])), 'remoteaddr': ((kcp_setting['server'] + ':') + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/clientlog/kcp-20060102.log'} return kcp_conf
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'localaddr': ('127.0.0.1:' + str(kcp_setting['listenport'])), 'remoteaddr': ((kcp_setting['server'] + ':') + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/clientlog/kcp-20060102.log'} return kcp_conf<|docstring|>Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.<|endoftext|>
f46eb5a8c2da3f60e26baaa97e6f1df0589b3be29e75ccf537304ca4a73b3d46
def _gen_info(self, infos_args): "Generate info list.\n Argument:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'key': [key],\n 'dest': [/path/to/config],\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log]/[listenport],\n\t\t 'listenport': [port],\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['server'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((info['dest'] + '/') + str(info['listenport'])) info['log-dir'] = ((info['log-dir'] + '/') + str(info['listenport'])) return infos_list
Generate info list. Argument: infos_args = { 'info-file': [/path/to/conf-info], 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], } Return: infos_list: The list of infos. [ { 'mode': [ss/sskcp], 'log-dir': [/path/to/log]/[listenport], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], }, ... ]
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_info
elespejo/sskcp
2
python
def _gen_info(self, infos_args): "Generate info list.\n Argument:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'key': [key],\n 'dest': [/path/to/config],\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log]/[listenport],\n\t\t 'listenport': [port],\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['server'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((info['dest'] + '/') + str(info['listenport'])) info['log-dir'] = ((info['log-dir'] + '/') + str(info['listenport'])) return infos_list
def _gen_info(self, infos_args): "Generate info list.\n Argument:\n infos_args = \n {\n 'info-file': [/path/to/conf-info],\n 'mode': [ss/sskcp],\n 'log-dir': [/path/to/log],\n 'listenport': [port],\n 'key': [key],\n 'dest': [/path/to/config],\n }\n\n Return:\n infos_list: The list of infos.\n [\n\t {\n\t\t 'mode': [ss/sskcp],\n\t\t 'log-dir': [/path/to/log]/[listenport],\n\t\t 'listenport': [port],\n 'key': [key],\n\t\t 'dest': [/path/to/config],\n\t },\n\t ...\n ]\n " info_file = infos_args.pop('info-file') infos_list = self.load_yaml(info_file)['server'] for info in infos_list: for (k, v) in infos_args.items(): if (not (v == None)): info[k] = v info['dest'] = ((info['dest'] + '/') + str(info['listenport'])) info['log-dir'] = ((info['log-dir'] + '/') + str(info['listenport'])) return infos_list<|docstring|>Generate info list. Argument: infos_args = { 'info-file': [/path/to/conf-info], 'mode': [ss/sskcp], 'log-dir': [/path/to/log], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], } Return: infos_list: The list of infos. [ { 'mode': [ss/sskcp], 'log-dir': [/path/to/log]/[listenport], 'listenport': [port], 'key': [key], 'dest': [/path/to/config], }, ... ]<|endoftext|>
04c9ae86b50ad30422f4944fc0bc659c4ea41b81967ede8c9a3edd96059fe648
def _gen_ss_setting(self, info): 'Generate ss server setting for mode ss.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\'],\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'sskey': ('ss_' + str(info['key']))} return ss_setting
Generate ss server setting for mode ss. Arguments: info: A dict of sskcp server information. { 'listenport': [port], 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport'], "sskey": "ss_"+info['key'] }
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_setting
elespejo/sskcp
2
python
def _gen_ss_setting(self, info): 'Generate ss server setting for mode ss.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\'],\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'sskey': ('ss_' + str(info['key']))} return ss_setting
def _gen_ss_setting(self, info): 'Generate ss server setting for mode ss.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\'],\n \t"sskey": "ss_"+info[\'key\']\n }\n ' ss_setting = {'listenport': info['listenport'], 'sskey': ('ss_' + str(info['key']))} return ss_setting<|docstring|>Generate ss server setting for mode ss. Arguments: info: A dict of sskcp server information. { 'listenport': [port], 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport'], "sskey": "ss_"+info['key'] }<|endoftext|>
9e03ba036ac8a38750d1a7a04d3cfd23b8c46b25ac151a8e456eb671592c4deb
def _gen_sskcp_setting(self, info): 'Generate ss and kcp server setting for mode sskcp.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']+2000,\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'vpsport\'] ,\n \t"server": 127.0.0.1,\n \t"serverport": info[\'listenport\']+2000,\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': (info['listenport'] + 2000), 'sskey': ('ss_' + str(info['key']))} kcp_setting = {'listenport': info['listenport'], 'serverport': (info['listenport'] + 2000), 'kcpkey': ('kcp_' + str(info['key']))} return (ss_setting, kcp_setting)
Generate ss and kcp server setting for mode sskcp. Arguments: info: A dict of sskcp server information. { 'listenport': [port], 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport']+2000, "sskey": "ss_"+info['key'] } kcp_setting: A setting dict for kcp.json generation. { "listenport": info['vpsport'] , "server": 127.0.0.1, "serverport": info['listenport']+2000, "kcpkey": "kcp_"+info['key'] }
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_sskcp_setting
elespejo/sskcp
2
python
def _gen_sskcp_setting(self, info): 'Generate ss and kcp server setting for mode sskcp.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']+2000,\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'vpsport\'] ,\n \t"server": 127.0.0.1,\n \t"serverport": info[\'listenport\']+2000,\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': (info['listenport'] + 2000), 'sskey': ('ss_' + str(info['key']))} kcp_setting = {'listenport': info['listenport'], 'serverport': (info['listenport'] + 2000), 'kcpkey': ('kcp_' + str(info['key']))} return (ss_setting, kcp_setting)
def _gen_sskcp_setting(self, info): 'Generate ss and kcp server setting for mode sskcp.\n Arguments:\n info: A dict of sskcp server information.\n {\n\t \t\'listenport\': [port],\n \'key\': [key],\n\t }\n\n Return:\n ss_setting: A setting dict for ss.json generation.\n {\n \t"listenport": info[\'listenport\']+2000,\n \t"sskey": "ss_"+info[\'key\']\n }\n\n kcp_setting: A setting dict for kcp.json generation.\n {\n \t"listenport": info[\'vpsport\'] ,\n \t"server": 127.0.0.1,\n \t"serverport": info[\'listenport\']+2000,\n \t"kcpkey": "kcp_"+info[\'key\']\n }\n ' ss_setting = {'listenport': (info['listenport'] + 2000), 'sskey': ('ss_' + str(info['key']))} kcp_setting = {'listenport': info['listenport'], 'serverport': (info['listenport'] + 2000), 'kcpkey': ('kcp_' + str(info['key']))} return (ss_setting, kcp_setting)<|docstring|>Generate ss and kcp server setting for mode sskcp. Arguments: info: A dict of sskcp server information. { 'listenport': [port], 'key': [key], } Return: ss_setting: A setting dict for ss.json generation. { "listenport": info['listenport']+2000, "sskey": "ss_"+info['key'] } kcp_setting: A setting dict for kcp.json generation. { "listenport": info['vpsport'] , "server": 127.0.0.1, "serverport": info['listenport']+2000, "kcpkey": "kcp_"+info['key'] }<|endoftext|>
9e1adeec930b7f62b257faf6e41bb87fec85c777aa1be5752afab8eca84b87ba
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': '0.0.0.0', 'server_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 300, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf
Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_ss_conf
elespejo/sskcp
2
python
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': '0.0.0.0', 'server_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 300, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf
def _gen_ss_conf(self, ss_setting): 'Generate ss configuration according to [ss_setting].\n Arguments:\n ss_setting: A dict of information that ss configuration needed.\n\n Return:\n ss_conf: A dict that can be dumped to json file that used by ss.\n ' ss_conf = {'server': '0.0.0.0', 'server_port': ss_setting['listenport'], 'password': ss_setting['sskey'], 'timeout': 300, 'method': 'aes-256-cfb', 'fast_open': True} return ss_conf<|docstring|>Generate ss configuration according to [ss_setting]. Arguments: ss_setting: A dict of information that ss configuration needed. Return: ss_conf: A dict that can be dumped to json file that used by ss.<|endoftext|>
b65e8afbc8aa921c236c5ab4e2721c3cd447dd6348f391dcd1619065fa34b41c
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'listen': ('0.0.0.0:' + str(kcp_setting['listenport'])), 'target': ('127.0.0.1:' + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/serverlog/kcp-20060102.log'} return kcp_conf
Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.
deployment/sskcp-confgenerator/confgenerator/generator.py
_gen_kcp_conf
elespejo/sskcp
2
python
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'listen': ('0.0.0.0:' + str(kcp_setting['listenport'])), 'target': ('127.0.0.1:' + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/serverlog/kcp-20060102.log'} return kcp_conf
def _gen_kcp_conf(self, kcp_setting): 'Generate kcp according to [kcp_setting].\n Arguments:\n kcp_setting: A dict of information that kcp configuration needed. \n\n Return:\n kcp_conf: A dict that can be dumped to json file that used by kcp.\n ' kcp_conf = {'listen': ('0.0.0.0:' + str(kcp_setting['listenport'])), 'target': ('127.0.0.1:' + str(kcp_setting['serverport'])), 'key': kcp_setting['kcpkey'], 'mode': 'fast2', 'snmplog': '/serverlog/kcp-20060102.log'} return kcp_conf<|docstring|>Generate kcp according to [kcp_setting]. Arguments: kcp_setting: A dict of information that kcp configuration needed. Return: kcp_conf: A dict that can be dumped to json file that used by kcp.<|endoftext|>
dc01dba24ca114c7686c045a845813cd7d49f8deae81a01b556c9d0e151a0a7d
def activate(self, event): '\n Called when this editor window is activated by the user.\n ' editormixin.EditorMixin.activate(self, event) if (not self): return self.SoundList.SetItem(0, 1, self.patch.get_sound_name(0)) for (index, sound) in enumerate(self.patch.sounds): self.SoundList.SetItem((index + 1), 1, self.patch.get_sound_name((index + 1)))
Called when this editor window is activated by the user.
src/whacked4/ui/editors/soundsframe.py
activate
atsb/WhackEd4
25
python
def activate(self, event): '\n \n ' editormixin.EditorMixin.activate(self, event) if (not self): return self.SoundList.SetItem(0, 1, self.patch.get_sound_name(0)) for (index, sound) in enumerate(self.patch.sounds): self.SoundList.SetItem((index + 1), 1, self.patch.get_sound_name((index + 1)))
def activate(self, event): '\n \n ' editormixin.EditorMixin.activate(self, event) if (not self): return self.SoundList.SetItem(0, 1, self.patch.get_sound_name(0)) for (index, sound) in enumerate(self.patch.sounds): self.SoundList.SetItem((index + 1), 1, self.patch.get_sound_name((index + 1)))<|docstring|>Called when this editor window is activated by the user.<|endoftext|>
14525e8fb21147a82143aeb99e1a2d27869eee35efe5663add64abbedcf1e796
def build_colours(self): "\n Builds priority colour coding colours and blends them with the system's window background color.\n " sys_col = self.SoundList.GetBackgroundColour() for index in range(4): factor = (0.06 * index) sys_factor = (1 - factor) colour = wx.Colour(int(((self.PRIORITY_COLOUR.Red() * factor) + (sys_col.Red() * sys_factor))), int(((self.PRIORITY_COLOUR.Green() * factor) + (sys_col.Green() * sys_factor))), int(((self.PRIORITY_COLOUR.Blue() * factor) + (sys_col.Blue() * sys_factor)))) self.priority_colours.append(colour)
Builds priority colour coding colours and blends them with the system's window background color.
src/whacked4/ui/editors/soundsframe.py
build_colours
atsb/WhackEd4
25
python
def build_colours(self): "\n \n " sys_col = self.SoundList.GetBackgroundColour() for index in range(4): factor = (0.06 * index) sys_factor = (1 - factor) colour = wx.Colour(int(((self.PRIORITY_COLOUR.Red() * factor) + (sys_col.Red() * sys_factor))), int(((self.PRIORITY_COLOUR.Green() * factor) + (sys_col.Green() * sys_factor))), int(((self.PRIORITY_COLOUR.Blue() * factor) + (sys_col.Blue() * sys_factor)))) self.priority_colours.append(colour)
def build_colours(self): "\n \n " sys_col = self.SoundList.GetBackgroundColour() for index in range(4): factor = (0.06 * index) sys_factor = (1 - factor) colour = wx.Colour(int(((self.PRIORITY_COLOUR.Red() * factor) + (sys_col.Red() * sys_factor))), int(((self.PRIORITY_COLOUR.Green() * factor) + (sys_col.Green() * sys_factor))), int(((self.PRIORITY_COLOUR.Blue() * factor) + (sys_col.Blue() * sys_factor)))) self.priority_colours.append(colour)<|docstring|>Builds priority colour coding colours and blends them with the system's window background color.<|endoftext|>
3f9550a7a5c4a8dbfe0c7889e8e39e6904f41f45aebe01430591046fdcc139f8
def build(self, patch): '\n @see: EditorMixin.build\n ' self.patch = patch self.pwads = self.GetMDIParent().pwads self.selected_index = (- 1) self.selected_row = (- 1) self.soundlist_build()
@see: EditorMixin.build
src/whacked4/ui/editors/soundsframe.py
build
atsb/WhackEd4
25
python
def build(self, patch): '\n \n ' self.patch = patch self.pwads = self.GetMDIParent().pwads self.selected_index = (- 1) self.selected_row = (- 1) self.soundlist_build()
def build(self, patch): '\n \n ' self.patch = patch self.pwads = self.GetMDIParent().pwads self.selected_index = (- 1) self.selected_row = (- 1) self.soundlist_build()<|docstring|>@see: EditorMixin.build<|endoftext|>
0c704f21cd7dd885158839e30dd4e12fb807c95f3020b97e6552c63838712141
def update(self): '\n @see: EditorMixin.update\n ' self.pwads = self.GetMDIParent().pwads
@see: EditorMixin.update
src/whacked4/ui/editors/soundsframe.py
update
atsb/WhackEd4
25
python
def update(self): '\n \n ' self.pwads = self.GetMDIParent().pwads
def update(self): '\n \n ' self.pwads = self.GetMDIParent().pwads<|docstring|>@see: EditorMixin.update<|endoftext|>
2f9f3fd9dc88341d58f81d3e3b64169b073c705b120b8610a06d4cde431c2454
def soundlist_build(self): '\n Builds the contents of the sounds list from scratch.\n ' self.SoundList.ClearAll() if (self.SoundList.GetColumnCount() == 0): self.SoundList.InsertColumn(0, 'Index', width=41) self.SoundList.InsertColumn(1, 'Name', width=54) self.SoundList.InsertColumn(2, 'Priority', width=50) self.SoundList.InsertColumn(3, 'Singular', width=58) self.SoundList.InsertItem(0, '0') self.SoundList.SetItemFont(0, config.FONT_MONOSPACED) self.soundlist_update_row(0, 0) for sound_index in range(len(self.patch.sounds)): self.SoundList.InsertItem((sound_index + 1), str((sound_index + 1))) self.SoundList.SetItemFont((sound_index + 1), config.FONT_MONOSPACED) self.soundlist_update_row((sound_index + 1), sound_index) self.list_autosize(self.SoundList) self.SoundList.Select(0, True)
Builds the contents of the sounds list from scratch.
src/whacked4/ui/editors/soundsframe.py
soundlist_build
atsb/WhackEd4
25
python
def soundlist_build(self): '\n \n ' self.SoundList.ClearAll() if (self.SoundList.GetColumnCount() == 0): self.SoundList.InsertColumn(0, 'Index', width=41) self.SoundList.InsertColumn(1, 'Name', width=54) self.SoundList.InsertColumn(2, 'Priority', width=50) self.SoundList.InsertColumn(3, 'Singular', width=58) self.SoundList.InsertItem(0, '0') self.SoundList.SetItemFont(0, config.FONT_MONOSPACED) self.soundlist_update_row(0, 0) for sound_index in range(len(self.patch.sounds)): self.SoundList.InsertItem((sound_index + 1), str((sound_index + 1))) self.SoundList.SetItemFont((sound_index + 1), config.FONT_MONOSPACED) self.soundlist_update_row((sound_index + 1), sound_index) self.list_autosize(self.SoundList) self.SoundList.Select(0, True)
def soundlist_build(self): '\n \n ' self.SoundList.ClearAll() if (self.SoundList.GetColumnCount() == 0): self.SoundList.InsertColumn(0, 'Index', width=41) self.SoundList.InsertColumn(1, 'Name', width=54) self.SoundList.InsertColumn(2, 'Priority', width=50) self.SoundList.InsertColumn(3, 'Singular', width=58) self.SoundList.InsertItem(0, '0') self.SoundList.SetItemFont(0, config.FONT_MONOSPACED) self.soundlist_update_row(0, 0) for sound_index in range(len(self.patch.sounds)): self.SoundList.InsertItem((sound_index + 1), str((sound_index + 1))) self.SoundList.SetItemFont((sound_index + 1), config.FONT_MONOSPACED) self.soundlist_update_row((sound_index + 1), sound_index) self.list_autosize(self.SoundList) self.SoundList.Select(0, True)<|docstring|>Builds the contents of the sounds list from scratch.<|endoftext|>
f17f72e88961b73faafe840a736c1ff7311b023737a8509f95ff591d95b9d572
def soundlist_update_row(self, row_index, sound_index): '\n Updates a sound list row with the data for that sound.\n ' sound = self.patch.sounds[sound_index] if ((row_index == 0) or sound.unused): self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(0)) self.SoundList.SetItem(row_index, 2, '') self.SoundList.SetItem(row_index, 3, '') self.SoundList.SetItemTextColour(row_index, self.UNUSED_TEXT_COLOUR) self.SoundList.SetItemBackgroundColour(row_index, self.UNUSED_BACKGROUND_COLOUR) else: if (sound['isSingular'] == 1): singular = '◾' else: singular = '' self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(row_index)) self.SoundList.SetItem(row_index, 2, str(sound['priority'])) self.SoundList.SetItem(row_index, 3, singular) color_index = int((sound['priority'] / 32)) if (color_index >= len(self.priority_colours)): color_index = (len(self.priority_colours) - 1) self.SoundList.SetItemBackgroundColour(row_index, self.priority_colours[color_index])
Updates a sound list row with the data for that sound.
src/whacked4/ui/editors/soundsframe.py
soundlist_update_row
atsb/WhackEd4
25
python
def soundlist_update_row(self, row_index, sound_index): '\n \n ' sound = self.patch.sounds[sound_index] if ((row_index == 0) or sound.unused): self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(0)) self.SoundList.SetItem(row_index, 2, ) self.SoundList.SetItem(row_index, 3, ) self.SoundList.SetItemTextColour(row_index, self.UNUSED_TEXT_COLOUR) self.SoundList.SetItemBackgroundColour(row_index, self.UNUSED_BACKGROUND_COLOUR) else: if (sound['isSingular'] == 1): singular = '◾' else: singular = self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(row_index)) self.SoundList.SetItem(row_index, 2, str(sound['priority'])) self.SoundList.SetItem(row_index, 3, singular) color_index = int((sound['priority'] / 32)) if (color_index >= len(self.priority_colours)): color_index = (len(self.priority_colours) - 1) self.SoundList.SetItemBackgroundColour(row_index, self.priority_colours[color_index])
def soundlist_update_row(self, row_index, sound_index): '\n \n ' sound = self.patch.sounds[sound_index] if ((row_index == 0) or sound.unused): self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(0)) self.SoundList.SetItem(row_index, 2, ) self.SoundList.SetItem(row_index, 3, ) self.SoundList.SetItemTextColour(row_index, self.UNUSED_TEXT_COLOUR) self.SoundList.SetItemBackgroundColour(row_index, self.UNUSED_BACKGROUND_COLOUR) else: if (sound['isSingular'] == 1): singular = '◾' else: singular = self.SoundList.SetItem(row_index, 1, self.patch.get_sound_name(row_index)) self.SoundList.SetItem(row_index, 2, str(sound['priority'])) self.SoundList.SetItem(row_index, 3, singular) color_index = int((sound['priority'] / 32)) if (color_index >= len(self.priority_colours)): color_index = (len(self.priority_colours) - 1) self.SoundList.SetItemBackgroundColour(row_index, self.priority_colours[color_index])<|docstring|>Updates a sound list row with the data for that sound.<|endoftext|>
d43806033c08dc75de5d1b8523cc5a858c8576f074b2cacd26d14a1bc29ea71a
def sound_select_index(self, row_index, sound_index): '\n Selects a sound by sound index.\n ' self.selected_index = sound_index self.selected_row = row_index self.update_properties()
Selects a sound by sound index.
src/whacked4/ui/editors/soundsframe.py
sound_select_index
atsb/WhackEd4
25
python
def sound_select_index(self, row_index, sound_index): '\n \n ' self.selected_index = sound_index self.selected_row = row_index self.update_properties()
def sound_select_index(self, row_index, sound_index): '\n \n ' self.selected_index = sound_index self.selected_row = row_index self.update_properties()<|docstring|>Selects a sound by sound index.<|endoftext|>
9f024cb94dc5021c7bf3e9361c3de6ab47e7cd2f49ed07bdbdfef21ded99367f
def sound_restore(self, event): "\n Restores the currently selected sound to it's engine state.\n " self.undo_add() self.patch.sounds[self.selected_index] = self.patch.engine.sounds[self.selected_index].clone() self.soundlist_update_row(self.selected_row, self.selected_index) self.update_properties() self.is_modified(True)
Restores the currently selected sound to it's engine state.
src/whacked4/ui/editors/soundsframe.py
sound_restore
atsb/WhackEd4
25
python
def sound_restore(self, event): "\n \n " self.undo_add() self.patch.sounds[self.selected_index] = self.patch.engine.sounds[self.selected_index].clone() self.soundlist_update_row(self.selected_row, self.selected_index) self.update_properties() self.is_modified(True)
def sound_restore(self, event): "\n \n " self.undo_add() self.patch.sounds[self.selected_index] = self.patch.engine.sounds[self.selected_index].clone() self.soundlist_update_row(self.selected_row, self.selected_index) self.update_properties() self.is_modified(True)<|docstring|>Restores the currently selected sound to it's engine state.<|endoftext|>
c02d802cdd2da004175cd93af664517a34c48cd47c5a3da8042b09123bb47483
def sound_play(self, event): '\n Plays the currently selected sound.\n ' if (self.selected_row == 0): return utils.sound_play(self.patch.sounds[self.selected_index].name, self.pwads)
Plays the currently selected sound.
src/whacked4/ui/editors/soundsframe.py
sound_play
atsb/WhackEd4
25
python
def sound_play(self, event): '\n \n ' if (self.selected_row == 0): return utils.sound_play(self.patch.sounds[self.selected_index].name, self.pwads)
def sound_play(self, event): '\n \n ' if (self.selected_row == 0): return utils.sound_play(self.patch.sounds[self.selected_index].name, self.pwads)<|docstring|>Plays the currently selected sound.<|endoftext|>
27cdfded1f2cac9a73060b85d8a603a02bff20a6d9900add3d74ecb61a077285
def update_properties(self): '\n Update the displayed property controls.\n ' if (not self.patch): return sound = self.patch.sounds[self.selected_index] if ((self.selected_row == 0) or sound.unused): self.Priority.ChangeValue('') self.PrioritySpinner.SetValue(0) self.Singular.SetValue(False) self.tools_set_state(False) else: singular = (sound['isSingular'] == 1) self.Priority.ChangeValue(str(sound['priority'])) self.PrioritySpinner.SetValue(sound['priority']) self.Singular.SetValue(singular) self.tools_set_state(True)
Update the displayed property controls.
src/whacked4/ui/editors/soundsframe.py
update_properties
atsb/WhackEd4
25
python
def update_properties(self): '\n \n ' if (not self.patch): return sound = self.patch.sounds[self.selected_index] if ((self.selected_row == 0) or sound.unused): self.Priority.ChangeValue() self.PrioritySpinner.SetValue(0) self.Singular.SetValue(False) self.tools_set_state(False) else: singular = (sound['isSingular'] == 1) self.Priority.ChangeValue(str(sound['priority'])) self.PrioritySpinner.SetValue(sound['priority']) self.Singular.SetValue(singular) self.tools_set_state(True)
def update_properties(self): '\n \n ' if (not self.patch): return sound = self.patch.sounds[self.selected_index] if ((self.selected_row == 0) or sound.unused): self.Priority.ChangeValue() self.PrioritySpinner.SetValue(0) self.Singular.SetValue(False) self.tools_set_state(False) else: singular = (sound['isSingular'] == 1) self.Priority.ChangeValue(str(sound['priority'])) self.PrioritySpinner.SetValue(sound['priority']) self.Singular.SetValue(singular) self.tools_set_state(True)<|docstring|>Update the displayed property controls.<|endoftext|>
5f3fc3f6199e93d6af1c13c4be27732ec89977a72ae23cbfa9309aa16769afcd
def tools_set_state(self, enabled): '\n Sets the state of all tool controls.\n ' if ('nosupport.sounds' in self.patch.engine.features): enabled = False for window in self.WINDOWS_TOOLS: window.Enable(enabled)
Sets the state of all tool controls.
src/whacked4/ui/editors/soundsframe.py
tools_set_state
atsb/WhackEd4
25
python
def tools_set_state(self, enabled): '\n \n ' if ('nosupport.sounds' in self.patch.engine.features): enabled = False for window in self.WINDOWS_TOOLS: window.Enable(enabled)
def tools_set_state(self, enabled): '\n \n ' if ('nosupport.sounds' in self.patch.engine.features): enabled = False for window in self.WINDOWS_TOOLS: window.Enable(enabled)<|docstring|>Sets the state of all tool controls.<|endoftext|>
687d449fd1215992a008e06b9c1b394cb44dcab3b6b64f9f3b6374b71e8de3bc
def set_singular(self, event): '\n Sets the singularity flag for the currently selected sound.\n ' self.undo_add() value = self.Singular.GetValue() sound = self.patch.sounds[self.selected_index] if value: sound['isSingular'] = 1 else: sound['isSingular'] = 0 self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)
Sets the singularity flag for the currently selected sound.
src/whacked4/ui/editors/soundsframe.py
set_singular
atsb/WhackEd4
25
python
def set_singular(self, event): '\n \n ' self.undo_add() value = self.Singular.GetValue() sound = self.patch.sounds[self.selected_index] if value: sound['isSingular'] = 1 else: sound['isSingular'] = 0 self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)
def set_singular(self, event): '\n \n ' self.undo_add() value = self.Singular.GetValue() sound = self.patch.sounds[self.selected_index] if value: sound['isSingular'] = 1 else: sound['isSingular'] = 0 self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)<|docstring|>Sets the singularity flag for the currently selected sound.<|endoftext|>
1ee616312fd7a17477b46be4bbce55811a570d4ca52d26fcb7f570faab56d36f
def set_priority(self, event): '\n Validates and sets a property of the current sound.\n ' self.undo_add() window = self.FindWindowById(windows.SOUNDS_PRIORITY) value = utils.validate_numeric(window) if (value < 0): value = 0 elif (value >= 2147483647): value = 2147483647 if (window.GetValue() != value): window.ChangeValue(str(value)) sound = self.patch.sounds[self.selected_index] sound['priority'] = value self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)
Validates and sets a property of the current sound.
src/whacked4/ui/editors/soundsframe.py
set_priority
atsb/WhackEd4
25
python
def set_priority(self, event): '\n \n ' self.undo_add() window = self.FindWindowById(windows.SOUNDS_PRIORITY) value = utils.validate_numeric(window) if (value < 0): value = 0 elif (value >= 2147483647): value = 2147483647 if (window.GetValue() != value): window.ChangeValue(str(value)) sound = self.patch.sounds[self.selected_index] sound['priority'] = value self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)
def set_priority(self, event): '\n \n ' self.undo_add() window = self.FindWindowById(windows.SOUNDS_PRIORITY) value = utils.validate_numeric(window) if (value < 0): value = 0 elif (value >= 2147483647): value = 2147483647 if (window.GetValue() != value): window.ChangeValue(str(value)) sound = self.patch.sounds[self.selected_index] sound['priority'] = value self.soundlist_update_row(self.selected_row, self.selected_index) self.is_modified(True)<|docstring|>Validates and sets a property of the current sound.<|endoftext|>
72de455abce6e0801dba6b501335a83adb3e7482678ca790f18cd4e1539f8afe
def goto_sound_index(self, sound_index): '\n Selects a sound from the list.\n ' self.SoundList.Select(sound_index, True) self.SoundList.EnsureVisible(sound_index) self.SoundList.SetFocus()
Selects a sound from the list.
src/whacked4/ui/editors/soundsframe.py
goto_sound_index
atsb/WhackEd4
25
python
def goto_sound_index(self, sound_index): '\n \n ' self.SoundList.Select(sound_index, True) self.SoundList.EnsureVisible(sound_index) self.SoundList.SetFocus()
def goto_sound_index(self, sound_index): '\n \n ' self.SoundList.Select(sound_index, True) self.SoundList.EnsureVisible(sound_index) self.SoundList.SetFocus()<|docstring|>Selects a sound from the list.<|endoftext|>
bc5b280a9d8f3db6d4c8fc6f93d18f023e4a60699694f9f373773375e7b2dcc0
def undo_restore_item(self, item): '\n @see: EditorMixin.undo_restore_item\n ' self.patch.sounds[item['index']] = item['item'] self.soundlist_update_row((item['index'] + 1), item['index']) self.update_properties() self.is_modified(True)
@see: EditorMixin.undo_restore_item
src/whacked4/ui/editors/soundsframe.py
undo_restore_item
atsb/WhackEd4
25
python
def undo_restore_item(self, item): '\n \n ' self.patch.sounds[item['index']] = item['item'] self.soundlist_update_row((item['index'] + 1), item['index']) self.update_properties() self.is_modified(True)
def undo_restore_item(self, item): '\n \n ' self.patch.sounds[item['index']] = item['item'] self.soundlist_update_row((item['index'] + 1), item['index']) self.update_properties() self.is_modified(True)<|docstring|>@see: EditorMixin.undo_restore_item<|endoftext|>
59c9e9717ff29f70c04372b438a150068fa1715321b105389c0d0dd1aaa8315c
def undo_store_item(self): '\n @see: EditorMixin.undo_store_item\n ' return {'item': self.patch.sounds[self.selected_index].clone(), 'index': self.selected_index}
@see: EditorMixin.undo_store_item
src/whacked4/ui/editors/soundsframe.py
undo_store_item
atsb/WhackEd4
25
python
def undo_store_item(self): '\n \n ' return {'item': self.patch.sounds[self.selected_index].clone(), 'index': self.selected_index}
def undo_store_item(self): '\n \n ' return {'item': self.patch.sounds[self.selected_index].clone(), 'index': self.selected_index}<|docstring|>@see: EditorMixin.undo_store_item<|endoftext|>
8dce3b40068e74120c37f757b14427f41408d72633bc3abba72be7da2793c03c
def sound_select(self, event): '\n Called when a sound row is selected from the list.\n ' self.sound_select_index(event.GetIndex(), (event.GetIndex() - 1))
Called when a sound row is selected from the list.
src/whacked4/ui/editors/soundsframe.py
sound_select
atsb/WhackEd4
25
python
def sound_select(self, event): '\n \n ' self.sound_select_index(event.GetIndex(), (event.GetIndex() - 1))
def sound_select(self, event): '\n \n ' self.sound_select_index(event.GetIndex(), (event.GetIndex() - 1))<|docstring|>Called when a sound row is selected from the list.<|endoftext|>
f30378fe40837df54861d7de7373a9c05de427387a5d4c5b41b8ea1aa032a47c
def ascii_sanitize(self, s): 'get printable string' import string return filter((lambda x: (x in string.printable)), s)
get printable string
string/ascii_sanitize.py
ascii_sanitize
all3g/pieces
34
python
def ascii_sanitize(self, s): import string return filter((lambda x: (x in string.printable)), s)
def ascii_sanitize(self, s): import string return filter((lambda x: (x in string.printable)), s)<|docstring|>get printable string<|endoftext|>
182242fb00a08f530f0927fd7969e974f233d0fa77d4fdcdd5ec64439521fac5
def get_debug_queries(): "In debug mode Flask-SQLAlchemy will log all the SQL queries sent\n to the database. This information is available until the end of request\n which makes it possible to easily ensure that the SQL generated is the\n one expected on errors or in unittesting. If you don't want to enable\n the DEBUG mode for your unittests you can also enable the query\n recording by setting the ``'SQLALCHEMY_RECORD_QUERIES'`` config variable\n to `True`. This is automatically enabled if Flask is in testing mode.\n\n The value returned will be a list of named tuples with the following\n attributes:\n\n `statement`\n The SQL statement issued\n\n `parameters`\n The parameters for the SQL statement\n\n `start_time` / `end_time`\n Time the query started / the results arrived. Please keep in mind\n that the timer function used depends on your platform. These\n values are only useful for sorting or comparing. They do not\n necessarily represent an absolute timestamp.\n\n `duration`\n Time the query took in seconds\n\n `context`\n A string giving a rough estimation of where in your application\n query was issued. The exact format is undefined so don't try\n to reconstruct filename or function name.\n " return getattr(_request_ctx_stack.top, 'sqlalchemy_queries', [])
In debug mode Flask-SQLAlchemy will log all the SQL queries sent to the database. This information is available until the end of request which makes it possible to easily ensure that the SQL generated is the one expected on errors or in unittesting. If you don't want to enable the DEBUG mode for your unittests you can also enable the query recording by setting the ``'SQLALCHEMY_RECORD_QUERIES'`` config variable to `True`. This is automatically enabled if Flask is in testing mode. The value returned will be a list of named tuples with the following attributes: `statement` The SQL statement issued `parameters` The parameters for the SQL statement `start_time` / `end_time` Time the query started / the results arrived. Please keep in mind that the timer function used depends on your platform. These values are only useful for sorting or comparing. They do not necessarily represent an absolute timestamp. `duration` Time the query took in seconds `context` A string giving a rough estimation of where in your application query was issued. The exact format is undefined so don't try to reconstruct filename or function name.
flaskext/sqlalchemy.py
get_debug_queries
bzzzz/flask-sqlalchemy
1
python
def get_debug_queries(): "In debug mode Flask-SQLAlchemy will log all the SQL queries sent\n to the database. This information is available until the end of request\n which makes it possible to easily ensure that the SQL generated is the\n one expected on errors or in unittesting. If you don't want to enable\n the DEBUG mode for your unittests you can also enable the query\n recording by setting the ``'SQLALCHEMY_RECORD_QUERIES'`` config variable\n to `True`. This is automatically enabled if Flask is in testing mode.\n\n The value returned will be a list of named tuples with the following\n attributes:\n\n `statement`\n The SQL statement issued\n\n `parameters`\n The parameters for the SQL statement\n\n `start_time` / `end_time`\n Time the query started / the results arrived. Please keep in mind\n that the timer function used depends on your platform. These\n values are only useful for sorting or comparing. They do not\n necessarily represent an absolute timestamp.\n\n `duration`\n Time the query took in seconds\n\n `context`\n A string giving a rough estimation of where in your application\n query was issued. The exact format is undefined so don't try\n to reconstruct filename or function name.\n " return getattr(_request_ctx_stack.top, 'sqlalchemy_queries', [])
def get_debug_queries(): "In debug mode Flask-SQLAlchemy will log all the SQL queries sent\n to the database. This information is available until the end of request\n which makes it possible to easily ensure that the SQL generated is the\n one expected on errors or in unittesting. If you don't want to enable\n the DEBUG mode for your unittests you can also enable the query\n recording by setting the ``'SQLALCHEMY_RECORD_QUERIES'`` config variable\n to `True`. This is automatically enabled if Flask is in testing mode.\n\n The value returned will be a list of named tuples with the following\n attributes:\n\n `statement`\n The SQL statement issued\n\n `parameters`\n The parameters for the SQL statement\n\n `start_time` / `end_time`\n Time the query started / the results arrived. Please keep in mind\n that the timer function used depends on your platform. These\n values are only useful for sorting or comparing. They do not\n necessarily represent an absolute timestamp.\n\n `duration`\n Time the query took in seconds\n\n `context`\n A string giving a rough estimation of where in your application\n query was issued. The exact format is undefined so don't try\n to reconstruct filename or function name.\n " return getattr(_request_ctx_stack.top, 'sqlalchemy_queries', [])<|docstring|>In debug mode Flask-SQLAlchemy will log all the SQL queries sent to the database. This information is available until the end of request which makes it possible to easily ensure that the SQL generated is the one expected on errors or in unittesting. If you don't want to enable the DEBUG mode for your unittests you can also enable the query recording by setting the ``'SQLALCHEMY_RECORD_QUERIES'`` config variable to `True`. This is automatically enabled if Flask is in testing mode. The value returned will be a list of named tuples with the following attributes: `statement` The SQL statement issued `parameters` The parameters for the SQL statement `start_time` / `end_time` Time the query started / the results arrived. Please keep in mind that the timer function used depends on your platform. These values are only useful for sorting or comparing. They do not necessarily represent an absolute timestamp. `duration` Time the query took in seconds `context` A string giving a rough estimation of where in your application query was issued. The exact format is undefined so don't try to reconstruct filename or function name.<|endoftext|>
3240baded7a34125197f63f942796d924e002bf70acd826274b590d85db19101
@property def pages(self): 'The total number of pages' return int(ceil((self.total / float(self.per_page))))
The total number of pages
flaskext/sqlalchemy.py
pages
bzzzz/flask-sqlalchemy
1
python
@property def pages(self): return int(ceil((self.total / float(self.per_page))))
@property def pages(self): return int(ceil((self.total / float(self.per_page))))<|docstring|>The total number of pages<|endoftext|>
609fc1cd9f6c789666bd3f13ea3fd669646cbfb0bb24be4f0388807b22db5e9f
def prev(self, error_out=False): 'Returns a :class:`Pagination` object for the previous page.' assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page - 1), self.per_page, error_out)
Returns a :class:`Pagination` object for the previous page.
flaskext/sqlalchemy.py
prev
bzzzz/flask-sqlalchemy
1
python
def prev(self, error_out=False): assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page - 1), self.per_page, error_out)
def prev(self, error_out=False): assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page - 1), self.per_page, error_out)<|docstring|>Returns a :class:`Pagination` object for the previous page.<|endoftext|>
4e28ad8aa370fb03177e4f6fb6e0bb4e7b986fac112922017d7c131d1b366cfe
@property def prev_num(self): 'Number of the previous page.' return (self.page - 1)
Number of the previous page.
flaskext/sqlalchemy.py
prev_num
bzzzz/flask-sqlalchemy
1
python
@property def prev_num(self): return (self.page - 1)
@property def prev_num(self): return (self.page - 1)<|docstring|>Number of the previous page.<|endoftext|>
e95127472cb54db445aa30110e410ac8e9612ff8e7e0de1499a752026d132d4f
@property def has_prev(self): 'True if a previous page exists' return (self.page > 1)
True if a previous page exists
flaskext/sqlalchemy.py
has_prev
bzzzz/flask-sqlalchemy
1
python
@property def has_prev(self): return (self.page > 1)
@property def has_prev(self): return (self.page > 1)<|docstring|>True if a previous page exists<|endoftext|>
f29777887cee54b3467b39b6e9f874560e3ebfbbdec9fdc9943e28ba9fcd9c76
def next(self, error_out=False): 'Returns a :class:`Pagination` object for the next page.' assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page + 1), self.per_page, error_out)
Returns a :class:`Pagination` object for the next page.
flaskext/sqlalchemy.py
next
bzzzz/flask-sqlalchemy
1
python
def next(self, error_out=False): assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page + 1), self.per_page, error_out)
def next(self, error_out=False): assert (self.query is not None), 'a query object is required for this method to work' return self.query.paginate((self.page + 1), self.per_page, error_out)<|docstring|>Returns a :class:`Pagination` object for the next page.<|endoftext|>
0b053f023e059d707af70289ae7a0fd5b4f528a21b5624a325dc78f0b77f32cc
@property def has_next(self): 'True if a next page exists.' return (self.page < self.pages)
True if a next page exists.
flaskext/sqlalchemy.py
has_next
bzzzz/flask-sqlalchemy
1
python
@property def has_next(self): return (self.page < self.pages)
@property def has_next(self): return (self.page < self.pages)<|docstring|>True if a next page exists.<|endoftext|>
af1fd7b7e5fdb23012a82828db775b382352c1c5c848c86f2c8184e46ce3917a
@property def next_num(self): 'Number of the next page' return (self.page + 1)
Number of the next page
flaskext/sqlalchemy.py
next_num
bzzzz/flask-sqlalchemy
1
python
@property def next_num(self): return (self.page + 1)
@property def next_num(self): return (self.page + 1)<|docstring|>Number of the next page<|endoftext|>
be013a3ff26a775d9e972ec5cbb02e6ae23cf22fbfd50ff1363b43c3f8a2fba2
def iter_pages(self, left_edge=2, left_current=2, right_current=5, right_edge=2): 'Iterates over the page numbers in the pagination. The four\n parameters control the thresholds how many numbers should be produced\n from the sides. Skipped page numbers are represented as `None`.\n This is how you could render such a pagination in the templates:\n\n .. sourcecode:: html+jinja\n\n {% macro render_pagination(pagination, endpoint) %}\n <div class=pagination>\n {%- for page in pagination.iter_pages() %}\n {% if page %}\n {% if page != pagination.page %}\n <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>\n {% else %}\n <strong>{{ page }}</strong>\n {% endif %}\n {% else %}\n <span class=ellipsis>…</span>\n {% endif %}\n {%- endfor %}\n </div>\n {% endmacro %}\n ' last = 0 for num in xrange(1, (self.pages + 1)): if ((num <= left_edge) or ((num > ((self.page - left_current) - 1)) and (num < (self.page + right_current))) or (num > (self.pages - right_edge))): if ((last + 1) != num): (yield None) (yield num) last = num
Iterates over the page numbers in the pagination. The four parameters control the thresholds how many numbers should be produced from the sides. Skipped page numbers are represented as `None`. This is how you could render such a pagination in the templates: .. sourcecode:: html+jinja {% macro render_pagination(pagination, endpoint) %} <div class=pagination> {%- for page in pagination.iter_pages() %} {% if page %} {% if page != pagination.page %} <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a> {% else %} <strong>{{ page }}</strong> {% endif %} {% else %} <span class=ellipsis>…</span> {% endif %} {%- endfor %} </div> {% endmacro %}
flaskext/sqlalchemy.py
iter_pages
bzzzz/flask-sqlalchemy
1
python
def iter_pages(self, left_edge=2, left_current=2, right_current=5, right_edge=2): 'Iterates over the page numbers in the pagination. The four\n parameters control the thresholds how many numbers should be produced\n from the sides. Skipped page numbers are represented as `None`.\n This is how you could render such a pagination in the templates:\n\n .. sourcecode:: html+jinja\n\n {% macro render_pagination(pagination, endpoint) %}\n <div class=pagination>\n {%- for page in pagination.iter_pages() %}\n {% if page %}\n {% if page != pagination.page %}\n <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>\n {% else %}\n <strong>{{ page }}</strong>\n {% endif %}\n {% else %}\n <span class=ellipsis>…</span>\n {% endif %}\n {%- endfor %}\n </div>\n {% endmacro %}\n ' last = 0 for num in xrange(1, (self.pages + 1)): if ((num <= left_edge) or ((num > ((self.page - left_current) - 1)) and (num < (self.page + right_current))) or (num > (self.pages - right_edge))): if ((last + 1) != num): (yield None) (yield num) last = num
def iter_pages(self, left_edge=2, left_current=2, right_current=5, right_edge=2): 'Iterates over the page numbers in the pagination. The four\n parameters control the thresholds how many numbers should be produced\n from the sides. Skipped page numbers are represented as `None`.\n This is how you could render such a pagination in the templates:\n\n .. sourcecode:: html+jinja\n\n {% macro render_pagination(pagination, endpoint) %}\n <div class=pagination>\n {%- for page in pagination.iter_pages() %}\n {% if page %}\n {% if page != pagination.page %}\n <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>\n {% else %}\n <strong>{{ page }}</strong>\n {% endif %}\n {% else %}\n <span class=ellipsis>…</span>\n {% endif %}\n {%- endfor %}\n </div>\n {% endmacro %}\n ' last = 0 for num in xrange(1, (self.pages + 1)): if ((num <= left_edge) or ((num > ((self.page - left_current) - 1)) and (num < (self.page + right_current))) or (num > (self.pages - right_edge))): if ((last + 1) != num): (yield None) (yield num) last = num<|docstring|>Iterates over the page numbers in the pagination. The four parameters control the thresholds how many numbers should be produced from the sides. Skipped page numbers are represented as `None`. This is how you could render such a pagination in the templates: .. sourcecode:: html+jinja {% macro render_pagination(pagination, endpoint) %} <div class=pagination> {%- for page in pagination.iter_pages() %} {% if page %} {% if page != pagination.page %} <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a> {% else %} <strong>{{ page }}</strong> {% endif %} {% else %} <span class=ellipsis>…</span> {% endif %} {%- endfor %} </div> {% endmacro %}<|endoftext|>
30b1d50b2daf72cb44ceb07563291923f0331583613dc4ca095b7a63ead98035
def get_or_404(self, ident): 'Like :meth:`get` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.get(ident) if (rv is None): abort(404) return rv
Like :meth:`get` but aborts with 404 if not found instead of returning `None`.
flaskext/sqlalchemy.py
get_or_404
bzzzz/flask-sqlalchemy
1
python
def get_or_404(self, ident): 'Like :meth:`get` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.get(ident) if (rv is None): abort(404) return rv
def get_or_404(self, ident): 'Like :meth:`get` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.get(ident) if (rv is None): abort(404) return rv<|docstring|>Like :meth:`get` but aborts with 404 if not found instead of returning `None`.<|endoftext|>
f3b027b20692822762f7b19ca088619ed9fd104701e5ed6838d2032b82433cc0
def first_or_404(self): 'Like :meth:`first` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.first() if (rv is None): abort(404) return rv
Like :meth:`first` but aborts with 404 if not found instead of returning `None`.
flaskext/sqlalchemy.py
first_or_404
bzzzz/flask-sqlalchemy
1
python
def first_or_404(self): 'Like :meth:`first` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.first() if (rv is None): abort(404) return rv
def first_or_404(self): 'Like :meth:`first` but aborts with 404 if not found instead of\n returning `None`.\n ' rv = self.first() if (rv is None): abort(404) return rv<|docstring|>Like :meth:`first` but aborts with 404 if not found instead of returning `None`.<|endoftext|>
06950170a8827c4b75f64a8655ee92e3676712606a9e055306bb9da37fa51faf
def paginate(self, page, per_page=20, error_out=True): 'Returns `per_page` items from page `page`. By default it will\n abort with 404 if no items were found and the page was larger than\n 1. This behavor can be disabled by setting `error_out` to `False`.\n\n Returns an :class:`Pagination` object.\n ' if (error_out and (page < 1)): abort(404) items = self.limit(per_page).offset(((page - 1) * per_page)).all() if ((not items) and (page != 1) and error_out): abort(404) return Pagination(self, page, per_page, self.count(), items)
Returns `per_page` items from page `page`. By default it will abort with 404 if no items were found and the page was larger than 1. This behavor can be disabled by setting `error_out` to `False`. Returns an :class:`Pagination` object.
flaskext/sqlalchemy.py
paginate
bzzzz/flask-sqlalchemy
1
python
def paginate(self, page, per_page=20, error_out=True): 'Returns `per_page` items from page `page`. By default it will\n abort with 404 if no items were found and the page was larger than\n 1. This behavor can be disabled by setting `error_out` to `False`.\n\n Returns an :class:`Pagination` object.\n ' if (error_out and (page < 1)): abort(404) items = self.limit(per_page).offset(((page - 1) * per_page)).all() if ((not items) and (page != 1) and error_out): abort(404) return Pagination(self, page, per_page, self.count(), items)
def paginate(self, page, per_page=20, error_out=True): 'Returns `per_page` items from page `page`. By default it will\n abort with 404 if no items were found and the page was larger than\n 1. This behavor can be disabled by setting `error_out` to `False`.\n\n Returns an :class:`Pagination` object.\n ' if (error_out and (page < 1)): abort(404) items = self.limit(per_page).offset(((page - 1) * per_page)).all() if ((not items) and (page != 1) and error_out): abort(404) return Pagination(self, page, per_page, self.count(), items)<|docstring|>Returns `per_page` items from page `page`. By default it will abort with 404 if no items were found and the page was larger than 1. This behavor can be disabled by setting `error_out` to `False`. Returns an :class:`Pagination` object.<|endoftext|>
52fc04d7b7f01863d61b13cbeea60a45b7acb0a549b2d0cc8919762a7cf3c33b
@property def metadata(self): 'Returns the metadata' return self.Model.metadata
Returns the metadata
flaskext/sqlalchemy.py
metadata
bzzzz/flask-sqlalchemy
1
python
@property def metadata(self): return self.Model.metadata
@property def metadata(self): return self.Model.metadata<|docstring|>Returns the metadata<|endoftext|>
ceffc85ee7353e23cb49908c469f4c3103b48d4c536a3f867a5227a40aa1e9cd
def init_app(self, app): 'This callback can be used to initialize an application for the\n use with this database setup. Never use a database in the context\n of an application not initialized that way or connections will\n leak.\n ' app.config.setdefault('SQLALCHEMY_DATABASE_URI', 'sqlite://') app.config.setdefault('SQLALCHEMY_NATIVE_UNICODE', None) app.config.setdefault('SQLALCHEMY_ECHO', False) app.config.setdefault('SQLALCHEMY_RECORD_QUERIES', None) app.config.setdefault('SQLALCHEMY_POOL_SIZE', None) app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None) app.config.setdefault('SQLALCHEMY_POOL_RECYCLE', None) @app.after_request def shutdown_session(response): self.session.remove() return response
This callback can be used to initialize an application for the use with this database setup. Never use a database in the context of an application not initialized that way or connections will leak.
flaskext/sqlalchemy.py
init_app
bzzzz/flask-sqlalchemy
1
python
def init_app(self, app): 'This callback can be used to initialize an application for the\n use with this database setup. Never use a database in the context\n of an application not initialized that way or connections will\n leak.\n ' app.config.setdefault('SQLALCHEMY_DATABASE_URI', 'sqlite://') app.config.setdefault('SQLALCHEMY_NATIVE_UNICODE', None) app.config.setdefault('SQLALCHEMY_ECHO', False) app.config.setdefault('SQLALCHEMY_RECORD_QUERIES', None) app.config.setdefault('SQLALCHEMY_POOL_SIZE', None) app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None) app.config.setdefault('SQLALCHEMY_POOL_RECYCLE', None) @app.after_request def shutdown_session(response): self.session.remove() return response
def init_app(self, app): 'This callback can be used to initialize an application for the\n use with this database setup. Never use a database in the context\n of an application not initialized that way or connections will\n leak.\n ' app.config.setdefault('SQLALCHEMY_DATABASE_URI', 'sqlite://') app.config.setdefault('SQLALCHEMY_NATIVE_UNICODE', None) app.config.setdefault('SQLALCHEMY_ECHO', False) app.config.setdefault('SQLALCHEMY_RECORD_QUERIES', None) app.config.setdefault('SQLALCHEMY_POOL_SIZE', None) app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None) app.config.setdefault('SQLALCHEMY_POOL_RECYCLE', None) @app.after_request def shutdown_session(response): self.session.remove() return response<|docstring|>This callback can be used to initialize an application for the use with this database setup. Never use a database in the context of an application not initialized that way or connections will leak.<|endoftext|>
2bf5a1da426f739a89e4b45826cdd174233e5c560a3f58f475f724b540918489
@property def engine(self): 'Gives access to the engine. If the database configuration is bound\n to a specific application (initialized with an application) this will\n always return a database connection. If however the current application\n is used this might raise a :exc:`RuntimeError` if no application is\n active at the moment.\n ' with self._engine_lock: if (self.app is not None): app = self.app else: ctx = _request_ctx_stack.top if (ctx is not None): app = ctx.app else: raise RuntimeError('application not registered on db instance and no application bound to current context') connector = getattr(app, '_sqlalchemy_connector', None) if (connector is None): connector = _EngineConnector(self, app) app._sqlalchemy_connector = connector return connector.get_engine()
Gives access to the engine. If the database configuration is bound to a specific application (initialized with an application) this will always return a database connection. If however the current application is used this might raise a :exc:`RuntimeError` if no application is active at the moment.
flaskext/sqlalchemy.py
engine
bzzzz/flask-sqlalchemy
1
python
@property def engine(self): 'Gives access to the engine. If the database configuration is bound\n to a specific application (initialized with an application) this will\n always return a database connection. If however the current application\n is used this might raise a :exc:`RuntimeError` if no application is\n active at the moment.\n ' with self._engine_lock: if (self.app is not None): app = self.app else: ctx = _request_ctx_stack.top if (ctx is not None): app = ctx.app else: raise RuntimeError('application not registered on db instance and no application bound to current context') connector = getattr(app, '_sqlalchemy_connector', None) if (connector is None): connector = _EngineConnector(self, app) app._sqlalchemy_connector = connector return connector.get_engine()
@property def engine(self): 'Gives access to the engine. If the database configuration is bound\n to a specific application (initialized with an application) this will\n always return a database connection. If however the current application\n is used this might raise a :exc:`RuntimeError` if no application is\n active at the moment.\n ' with self._engine_lock: if (self.app is not None): app = self.app else: ctx = _request_ctx_stack.top if (ctx is not None): app = ctx.app else: raise RuntimeError('application not registered on db instance and no application bound to current context') connector = getattr(app, '_sqlalchemy_connector', None) if (connector is None): connector = _EngineConnector(self, app) app._sqlalchemy_connector = connector return connector.get_engine()<|docstring|>Gives access to the engine. If the database configuration is bound to a specific application (initialized with an application) this will always return a database connection. If however the current application is used this might raise a :exc:`RuntimeError` if no application is active at the moment.<|endoftext|>
b422e3dd44dcd220d541c2c47f2f62a303ed946ac591ce8f9f30da275ff444b2
def create_all(self): 'Creates all tables.' self.Model.metadata.create_all(bind=self.engine)
Creates all tables.
flaskext/sqlalchemy.py
create_all
bzzzz/flask-sqlalchemy
1
python
def create_all(self): self.Model.metadata.create_all(bind=self.engine)
def create_all(self): self.Model.metadata.create_all(bind=self.engine)<|docstring|>Creates all tables.<|endoftext|>
d60dfdcda56ca902e75d5eebe6a39c533e4ab4c02da4eb56c4b680f6f9869d4b
def drop_all(self): 'Drops all tables.' self.Model.metadata.drop_all(bind=self.engine)
Drops all tables.
flaskext/sqlalchemy.py
drop_all
bzzzz/flask-sqlalchemy
1
python
def drop_all(self): self.Model.metadata.drop_all(bind=self.engine)
def drop_all(self): self.Model.metadata.drop_all(bind=self.engine)<|docstring|>Drops all tables.<|endoftext|>
9250fabaac1bc338e36dfbc518253be823cf9aca52c0c55d6268de5315db1337
def reflect(self): 'Reflects tables from the database.' self.Model.metadata.reflect(bind=self.engine)
Reflects tables from the database.
flaskext/sqlalchemy.py
reflect
bzzzz/flask-sqlalchemy
1
python
def reflect(self): self.Model.metadata.reflect(bind=self.engine)
def reflect(self): self.Model.metadata.reflect(bind=self.engine)<|docstring|>Reflects tables from the database.<|endoftext|>
18abf27e8ee2082078a9da8219f9428c793921c433edf14229572c0ef5f6ec5e
def __init__(self, view, syntax): 'Initialize a new ComposerLinter instance.' super(ComposerLinter, self).__init__(view, syntax) self.manifest_path = self.get_manifest_path() if self.manifest_path: self.read_manifest(path.getmtime(self.manifest_path))
Initialize a new ComposerLinter instance.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
__init__
nimzco/Environment
2
python
def __init__(self, view, syntax): super(ComposerLinter, self).__init__(view, syntax) self.manifest_path = self.get_manifest_path() if self.manifest_path: self.read_manifest(path.getmtime(self.manifest_path))
def __init__(self, view, syntax): super(ComposerLinter, self).__init__(view, syntax) self.manifest_path = self.get_manifest_path() if self.manifest_path: self.read_manifest(path.getmtime(self.manifest_path))<|docstring|>Initialize a new ComposerLinter instance.<|endoftext|>
91f19f2734b910f85c5b5f6d08027609c2ff25ea8e9a8f930c00f480c6e6f4f4
def context_sensitive_executable_path(self, cmd): '\n Attempt to locate the composer package specified in cmd.\n\n Searches the local vendor/bin folder first before\n looking in the global system .composer/vendor/bin folder.\n\n Return a tuple of (have_path, path).\n ' local_cmd = None global_cmd = util.which(cmd[0]) if self.manifest_path: local_cmd = self.find_local_cmd_path(cmd[0]) if ((not local_cmd) and (not global_cmd)): persist.printf('WARNING: {} deactivated, cannot locate local or global binary'.format(self.name, cmd[0])) return (False, '') composer_cmd_path = (local_cmd if local_cmd else global_cmd) self.executable_path = composer_cmd_path return (False, composer_cmd_path)
Attempt to locate the composer package specified in cmd. Searches the local vendor/bin folder first before looking in the global system .composer/vendor/bin folder. Return a tuple of (have_path, path).
Sublime/Packages/SublimeLinter/lint/composer_linter.py
context_sensitive_executable_path
nimzco/Environment
2
python
def context_sensitive_executable_path(self, cmd): '\n Attempt to locate the composer package specified in cmd.\n\n Searches the local vendor/bin folder first before\n looking in the global system .composer/vendor/bin folder.\n\n Return a tuple of (have_path, path).\n ' local_cmd = None global_cmd = util.which(cmd[0]) if self.manifest_path: local_cmd = self.find_local_cmd_path(cmd[0]) if ((not local_cmd) and (not global_cmd)): persist.printf('WARNING: {} deactivated, cannot locate local or global binary'.format(self.name, cmd[0])) return (False, ) composer_cmd_path = (local_cmd if local_cmd else global_cmd) self.executable_path = composer_cmd_path return (False, composer_cmd_path)
def context_sensitive_executable_path(self, cmd): '\n Attempt to locate the composer package specified in cmd.\n\n Searches the local vendor/bin folder first before\n looking in the global system .composer/vendor/bin folder.\n\n Return a tuple of (have_path, path).\n ' local_cmd = None global_cmd = util.which(cmd[0]) if self.manifest_path: local_cmd = self.find_local_cmd_path(cmd[0]) if ((not local_cmd) and (not global_cmd)): persist.printf('WARNING: {} deactivated, cannot locate local or global binary'.format(self.name, cmd[0])) return (False, ) composer_cmd_path = (local_cmd if local_cmd else global_cmd) self.executable_path = composer_cmd_path return (False, composer_cmd_path)<|docstring|>Attempt to locate the composer package specified in cmd. Searches the local vendor/bin folder first before looking in the global system .composer/vendor/bin folder. Return a tuple of (have_path, path).<|endoftext|>
e7b9ed6a7fcfed528e056dda55f8bfc1dda11bbf4691a4baf53f253c8b5f800c
def get_manifest_path(self): 'Get the path to the composer.json file for the current file.' curr_file = self.view.file_name() manifest_path = None if curr_file: cwd = path.dirname(curr_file) if cwd: manifest_path = self.rev_parse_manifest_path(cwd) return manifest_path
Get the path to the composer.json file for the current file.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
get_manifest_path
nimzco/Environment
2
python
def get_manifest_path(self): curr_file = self.view.file_name() manifest_path = None if curr_file: cwd = path.dirname(curr_file) if cwd: manifest_path = self.rev_parse_manifest_path(cwd) return manifest_path
def get_manifest_path(self): curr_file = self.view.file_name() manifest_path = None if curr_file: cwd = path.dirname(curr_file) if cwd: manifest_path = self.rev_parse_manifest_path(cwd) return manifest_path<|docstring|>Get the path to the composer.json file for the current file.<|endoftext|>
cda964335fcfa1d8853207ad1468cc413411f69ba37576299f39f75dcc693b4c
def rev_parse_manifest_path(self, cwd): '\n Search parent directories for composer.json.\n\n Starting at the current working directory. Go up one directory\n at a time checking if that directory contains a composer.json\n file. If it does, return that directory.\n ' name = 'composer.json' manifest_path = path.normpath(path.join(cwd, name)) bin_path = path.join(cwd, 'vendor/bin/') if (path.isfile(manifest_path) and path.isdir(bin_path)): return manifest_path parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.rev_parse_manifest_path(parent)
Search parent directories for composer.json. Starting at the current working directory. Go up one directory at a time checking if that directory contains a composer.json file. If it does, return that directory.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
rev_parse_manifest_path
nimzco/Environment
2
python
def rev_parse_manifest_path(self, cwd): '\n Search parent directories for composer.json.\n\n Starting at the current working directory. Go up one directory\n at a time checking if that directory contains a composer.json\n file. If it does, return that directory.\n ' name = 'composer.json' manifest_path = path.normpath(path.join(cwd, name)) bin_path = path.join(cwd, 'vendor/bin/') if (path.isfile(manifest_path) and path.isdir(bin_path)): return manifest_path parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.rev_parse_manifest_path(parent)
def rev_parse_manifest_path(self, cwd): '\n Search parent directories for composer.json.\n\n Starting at the current working directory. Go up one directory\n at a time checking if that directory contains a composer.json\n file. If it does, return that directory.\n ' name = 'composer.json' manifest_path = path.normpath(path.join(cwd, name)) bin_path = path.join(cwd, 'vendor/bin/') if (path.isfile(manifest_path) and path.isdir(bin_path)): return manifest_path parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.rev_parse_manifest_path(parent)<|docstring|>Search parent directories for composer.json. Starting at the current working directory. Go up one directory at a time checking if that directory contains a composer.json file. If it does, return that directory.<|endoftext|>
a69b9a300499b59ff6b6605b4c458d1a2001c8f7002c1fe7abbaf9ecbc276caa
def find_local_cmd_path(self, cmd): '\n Find a local binary in vendor/bin.\n\n Given composer.json filepath and a local binary to find,\n look in vendor/bin for that binary.\n ' cwd = path.dirname(self.manifest_path) binary = self.get_pkg_bin_cmd(cmd) if binary: return path.normpath(path.join(cwd, binary)) return self.find_ancestor_cmd_path(cmd, cwd)
Find a local binary in vendor/bin. Given composer.json filepath and a local binary to find, look in vendor/bin for that binary.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
find_local_cmd_path
nimzco/Environment
2
python
def find_local_cmd_path(self, cmd): '\n Find a local binary in vendor/bin.\n\n Given composer.json filepath and a local binary to find,\n look in vendor/bin for that binary.\n ' cwd = path.dirname(self.manifest_path) binary = self.get_pkg_bin_cmd(cmd) if binary: return path.normpath(path.join(cwd, binary)) return self.find_ancestor_cmd_path(cmd, cwd)
def find_local_cmd_path(self, cmd): '\n Find a local binary in vendor/bin.\n\n Given composer.json filepath and a local binary to find,\n look in vendor/bin for that binary.\n ' cwd = path.dirname(self.manifest_path) binary = self.get_pkg_bin_cmd(cmd) if binary: return path.normpath(path.join(cwd, binary)) return self.find_ancestor_cmd_path(cmd, cwd)<|docstring|>Find a local binary in vendor/bin. Given composer.json filepath and a local binary to find, look in vendor/bin for that binary.<|endoftext|>
e30d9cbdc9b45449e3a775ecae4ee392cc0e3172a771efd6faccc5a1ac8f5715
def find_ancestor_cmd_path(self, cmd, cwd): "Recursively check for command binary in ancestors' vendor/bin directories." vendor_bin = path.normpath(path.join(cwd, 'vendor/bin/')) binary = path.join(vendor_bin, cmd) if (binary and access(binary, X_OK)): return binary parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.find_ancestor_cmd_path(cmd, parent)
Recursively check for command binary in ancestors' vendor/bin directories.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
find_ancestor_cmd_path
nimzco/Environment
2
python
def find_ancestor_cmd_path(self, cmd, cwd): vendor_bin = path.normpath(path.join(cwd, 'vendor/bin/')) binary = path.join(vendor_bin, cmd) if (binary and access(binary, X_OK)): return binary parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.find_ancestor_cmd_path(cmd, parent)
def find_ancestor_cmd_path(self, cmd, cwd): vendor_bin = path.normpath(path.join(cwd, 'vendor/bin/')) binary = path.join(vendor_bin, cmd) if (binary and access(binary, X_OK)): return binary parent = path.normpath(path.join(cwd, '../')) if ((parent == '/') or (parent == cwd)): return None return self.find_ancestor_cmd_path(cmd, parent)<|docstring|>Recursively check for command binary in ancestors' vendor/bin directories.<|endoftext|>
837118a89a6bf1561fed8de9d2338bbb0c8ff38297d405b7db2ada6b6a246b61
def get_pkg_bin_cmd(self, cmd): "\n Check is binary path is defined in composer.json bin property.\n\n Loading a linter to check its own source code is a special case.\n For example, the local phpcs binary when linting phpcs is\n installed at ./scripts/phpcs and not ./vendor/bin/phpcs\n\n This function checks the composer.json `bin` property keys to\n see if the cmd we're looking for is defined for the current\n project.\n " pkg = self.get_manifest() if ('bin' in pkg): for executable in pkg['bin']: if (cmd in executable): return executable return None
Check is binary path is defined in composer.json bin property. Loading a linter to check its own source code is a special case. For example, the local phpcs binary when linting phpcs is installed at ./scripts/phpcs and not ./vendor/bin/phpcs This function checks the composer.json `bin` property keys to see if the cmd we're looking for is defined for the current project.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
get_pkg_bin_cmd
nimzco/Environment
2
python
def get_pkg_bin_cmd(self, cmd): "\n Check is binary path is defined in composer.json bin property.\n\n Loading a linter to check its own source code is a special case.\n For example, the local phpcs binary when linting phpcs is\n installed at ./scripts/phpcs and not ./vendor/bin/phpcs\n\n This function checks the composer.json `bin` property keys to\n see if the cmd we're looking for is defined for the current\n project.\n " pkg = self.get_manifest() if ('bin' in pkg): for executable in pkg['bin']: if (cmd in executable): return executable return None
def get_pkg_bin_cmd(self, cmd): "\n Check is binary path is defined in composer.json bin property.\n\n Loading a linter to check its own source code is a special case.\n For example, the local phpcs binary when linting phpcs is\n installed at ./scripts/phpcs and not ./vendor/bin/phpcs\n\n This function checks the composer.json `bin` property keys to\n see if the cmd we're looking for is defined for the current\n project.\n " pkg = self.get_manifest() if ('bin' in pkg): for executable in pkg['bin']: if (cmd in executable): return executable return None<|docstring|>Check is binary path is defined in composer.json bin property. Loading a linter to check its own source code is a special case. For example, the local phpcs binary when linting phpcs is installed at ./scripts/phpcs and not ./vendor/bin/phpcs This function checks the composer.json `bin` property keys to see if the cmd we're looking for is defined for the current project.<|endoftext|>
a81a348420b5108357aa0f6ffe931a5f9c63592fb21387f144157e05bf1f889b
def get_manifest(self): 'Load manifest file (composer.json).' current_manifest_mtime = path.getmtime(self.manifest_path) if ((current_manifest_mtime != self.cached_manifest_mtime) and (self.hash_manifest() != self.cached_manifest_hash)): self.read_manifest(current_manifest_mtime) return self.cached_manifest
Load manifest file (composer.json).
Sublime/Packages/SublimeLinter/lint/composer_linter.py
get_manifest
nimzco/Environment
2
python
def get_manifest(self): current_manifest_mtime = path.getmtime(self.manifest_path) if ((current_manifest_mtime != self.cached_manifest_mtime) and (self.hash_manifest() != self.cached_manifest_hash)): self.read_manifest(current_manifest_mtime) return self.cached_manifest
def get_manifest(self): current_manifest_mtime = path.getmtime(self.manifest_path) if ((current_manifest_mtime != self.cached_manifest_mtime) and (self.hash_manifest() != self.cached_manifest_hash)): self.read_manifest(current_manifest_mtime) return self.cached_manifest<|docstring|>Load manifest file (composer.json).<|endoftext|>
2a5d9753dda10bdd26329ef8e84c6c650433fb6e80bc93e89530caf0f8eeccce
def read_manifest(self, current_manifest_mtime): 'Read manifest and cache mtime, hash and json content.' self.cached_manifest_mtime = current_manifest_mtime self.cached_manifest_hash = self.hash_manifest() self.cached_manifest = json.load(codecs.open(self.manifest_path, 'r', 'utf-8'))
Read manifest and cache mtime, hash and json content.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
read_manifest
nimzco/Environment
2
python
def read_manifest(self, current_manifest_mtime): self.cached_manifest_mtime = current_manifest_mtime self.cached_manifest_hash = self.hash_manifest() self.cached_manifest = json.load(codecs.open(self.manifest_path, 'r', 'utf-8'))
def read_manifest(self, current_manifest_mtime): self.cached_manifest_mtime = current_manifest_mtime self.cached_manifest_hash = self.hash_manifest() self.cached_manifest = json.load(codecs.open(self.manifest_path, 'r', 'utf-8'))<|docstring|>Read manifest and cache mtime, hash and json content.<|endoftext|>
49f42f569593057eef15eab9a8c7bcb7d2859fceaadbb8609b7e45fc9e05df7a
def hash_manifest(self): 'Calculate the hash of the manifest file.' f = codecs.open(self.manifest_path, 'r', 'utf-8') return hashlib.sha1(f.read().encode('utf-8')).hexdigest()
Calculate the hash of the manifest file.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
hash_manifest
nimzco/Environment
2
python
def hash_manifest(self): f = codecs.open(self.manifest_path, 'r', 'utf-8') return hashlib.sha1(f.read().encode('utf-8')).hexdigest()
def hash_manifest(self): f = codecs.open(self.manifest_path, 'r', 'utf-8') return hashlib.sha1(f.read().encode('utf-8')).hexdigest()<|docstring|>Calculate the hash of the manifest file.<|endoftext|>
a9eaef88edfe53f905e25d929e7701dfb5725639eea913312b79f3fafdb5b8f9
@classmethod @lru_cache(maxsize=None) def can_lint(cls, syntax): "\n Determine if the linter can handle the provided syntax.\n\n This is an optimistic determination based on the linter's syntax alone.\n " can = False syntax = syntax.lower() if cls.syntax: if isinstance(cls.syntax, (tuple, list)): can = (syntax in cls.syntax) elif (cls.syntax == '*'): can = True elif isinstance(cls.syntax, str): can = (syntax == cls.syntax) else: can = (cls.syntax.match(syntax) is not None) return can
Determine if the linter can handle the provided syntax. This is an optimistic determination based on the linter's syntax alone.
Sublime/Packages/SublimeLinter/lint/composer_linter.py
can_lint
nimzco/Environment
2
python
@classmethod @lru_cache(maxsize=None) def can_lint(cls, syntax): "\n Determine if the linter can handle the provided syntax.\n\n This is an optimistic determination based on the linter's syntax alone.\n " can = False syntax = syntax.lower() if cls.syntax: if isinstance(cls.syntax, (tuple, list)): can = (syntax in cls.syntax) elif (cls.syntax == '*'): can = True elif isinstance(cls.syntax, str): can = (syntax == cls.syntax) else: can = (cls.syntax.match(syntax) is not None) return can
@classmethod @lru_cache(maxsize=None) def can_lint(cls, syntax): "\n Determine if the linter can handle the provided syntax.\n\n This is an optimistic determination based on the linter's syntax alone.\n " can = False syntax = syntax.lower() if cls.syntax: if isinstance(cls.syntax, (tuple, list)): can = (syntax in cls.syntax) elif (cls.syntax == '*'): can = True elif isinstance(cls.syntax, str): can = (syntax == cls.syntax) else: can = (cls.syntax.match(syntax) is not None) return can<|docstring|>Determine if the linter can handle the provided syntax. This is an optimistic determination based on the linter's syntax alone.<|endoftext|>
214a108886360e30724880e41b17f4bfd2727abf94c110bfc3fe934231941dfa
def setUp(self): 'This prepares the test environment.\n ' self.browser = webdriver.Firefox() self.addCleanup(self.browser.quit)
This prepares the test environment.
ckanext/socialite/tests/test_e2e/test_facebookauth.py
setUp
ccancellieri/ckanext-socialite
1
python
def setUp(self): '\n ' self.browser = webdriver.Firefox() self.addCleanup(self.browser.quit)
def setUp(self): '\n ' self.browser = webdriver.Firefox() self.addCleanup(self.browser.quit)<|docstring|>This prepares the test environment.<|endoftext|>
6629e126e36e916d757f9d4cc77cf119ac857dca684e22d3701c18e7644eb316
def testPageTitle(self): 'Tests that page title is rendered correctly' driver = self.browser driver.get('http://localhost:5000/user/login') assert ('Login - CKAN' in driver.title)
Tests that page title is rendered correctly
ckanext/socialite/tests/test_e2e/test_facebookauth.py
testPageTitle
ccancellieri/ckanext-socialite
1
python
def testPageTitle(self): driver = self.browser driver.get('http://localhost:5000/user/login') assert ('Login - CKAN' in driver.title)
def testPageTitle(self): driver = self.browser driver.get('http://localhost:5000/user/login') assert ('Login - CKAN' in driver.title)<|docstring|>Tests that page title is rendered correctly<|endoftext|>
bb363f1c40f69763cd0af128c46bb36323ba4c579133f1c3773262dd610ab378
def testButtonRender(self): 'Tests that login button is rendered correctly' driver = self.browser driver.get('http://localhost:5000/user/login') driver.get('http://localhost:5000/user/login') button_link = driver.find_element_by_xpath(u'//a[@id="linkedin-btn"]') assert button_link
Tests that login button is rendered correctly
ckanext/socialite/tests/test_e2e/test_facebookauth.py
testButtonRender
ccancellieri/ckanext-socialite
1
python
def testButtonRender(self): driver = self.browser driver.get('http://localhost:5000/user/login') driver.get('http://localhost:5000/user/login') button_link = driver.find_element_by_xpath(u'//a[@id="linkedin-btn"]') assert button_link
def testButtonRender(self): driver = self.browser driver.get('http://localhost:5000/user/login') driver.get('http://localhost:5000/user/login') button_link = driver.find_element_by_xpath(u'//a[@id="linkedin-btn"]') assert button_link<|docstring|>Tests that login button is rendered correctly<|endoftext|>