text
stringlengths
81
112k
Reads node-label pairs in csv format and returns a list of tuples and a node-label matrix. Inputs: - file_path: The path where the node-label matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ") - number_of_nodes: The number of nodes of the full graph. It is po...
Writes a user name and associated topic names per row. def write_screen_name_to_topics(filepath, user_label_matrix, node_to_id, id_to_name, label_to_lemma, lemma_to_keyword, separator=","): """ Writes a user name and associated topic names per row. """ user_label_matrix = spsp.coo_matrix(user_label_mat...
Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], #...
Sends a ping packet to ID's from 0 to maximum and prints out any returned messages. Actually send a broadcast and will retry (resend) the ping 3 times ... def sweep(port, rate, ID, retry=3): """ Sends a ping packet to ID's from 0 to maximum and prints out any returned messages. Actually send a broadcast and wi...
Semi-automatic effective epsilon threshold calculation. def calculate_epsilon_effective(rho, epsilon, seed_degree, neighbor_degrees, mean_degree): """ Semi-automatic effective epsilon threshold calculation. """ # Calculate a weighted neighborhood degree average. # neighborhood_degree = rho*seed_deg...
Extracts local community features for all graph nodes based on the partitioning of node-centric similarity vectors. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. - rho: Restart probability - epsilon: Approximation thres...
Read or form and store the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy array containing the labelled node indices. - number_of_categories: The number of categories/classes in ...
Form the seed nodes for training and testing. Inputs: - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - labelled_node_indices: A NumPy array containing the labelled node indices. - number_of_categories: The number of categories/classes in the learning. ...
Iterative data fold stratification/balancing for two folds. Based on: Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the stratification of multi-label data. In Machine Learning and Knowledge Discovery in Databases (pp. 145-158). Springer Berlin Heidelberg. Inp...
Given the discriminator distances, this function forms the node-label prediction matrix. It is assumed that the number of true labels is known. Inputs: - y_pred: A NumPy array that contains the distance from the discriminator for each label for each user. - y_test: The node-label ground truth fo...
Calculates the F-scores and F-score averages given a classification result and a ground truth. Inputs: - y_pred: The node-label prediction for the test set in a SciPy sparse CSR matrix format. - y_test: The node-label ground truth for the test set in a SciPy sparse CSR matrix format. Outputs: - ...
Transforms the raw buffer data read in into a list of bytes def decode(buff): """ Transforms the raw buffer data read in into a list of bytes """ pp = list(map(ord, buff)) if 0 == len(pp) == 1: pp = [] return pp
This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid packets. def read(self, how_much=128): # FIXME: 128 might be too much ... what is larges...
This toggles the RTS pin and reads in data. It also converts the buffer back into a list of bytes and searches through the list to find valid packets of info. If there is more than one packet, this returns an array of valid packets. def read2(self, how_much=128): # FIXME: 128 might be too much ... what is large...
This is a simple serial write command. It toggles the RTS pin and formats all of the data into bytes before it writes. def write(self, pkt): """ This is a simple serial write command. It toggles the RTS pin and formats all of the data into bytes before it writes. """ self.setRTS(self.DD_WRITE) self.flush...
Sends a packet and waits for a return. If no return is given, then it resends the packet. If an error occurs, it also resends the packet. in: pkt - command packet to send to servo cnt - how many retries should this do? default = 5 out: array of packets def sendPkt(self, pkt, retry=5, sleep_time=0.01): ...
Writes sparse matrix in separated value format. def scipy_sparse_to_csv(filepath, matrix, separator=",", directed=False, numbering="matlab"): """ Writes sparse matrix in separated value format. """ matrix = spsp.coo_matrix(matrix) shape = matrix.shape nnz = matrix.getnnz() if numbering ==...
Reads an edge list in csv format and returns the adjacency matrix in SciPy Sparse COOrdinate format. Inputs: - file_path: The path where the adjacency matrix is stored. - separator: The delimiter among values (e.g. ",", "\t", " ") - undirected: If True, create the reciprocal edge for eac...
publish the package itself def publish(build): """ publish the package itself """ build.packages.install("wheel") build.packages.install("twine") build.executables.run([ "python", "setup.py", "sdist", "bdist_wheel", "--universal", "--release" ]) build.executables.run([ "...
Calculates the approximate personalized PageRank starting from a seed node without self-loops. def fast_approximate_personalized_pagerank(s, r, w_i, a_i, ...
Calculates the approximate personalized PageRank starting from a seed node with self-loops. Introduced in: Andersen, R., Chung, F., & Lang, K. (2006, October). Local graph partitioning using pagerank vectors. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE ...
Returns a sparse feature matrix as calculated by a Matlab routine. def read_matlab_features(array_paths, number_of_nodes, dimensionality): """ Returns a sparse feature matrix as calculated by a Matlab routine. """ # Read the data array file_row_gen = get_file_row_generator(array_paths[0], "\t") ...
Extracts hierarchical community features using the MROC method. Introduced in: Wang, X., Tang, L., Liu, H., & Wang, L. (2013). Learning with multi-resolution overlapping communities. Knowledge and information systems, 36(2), 517-535. Inputs: - A in R^(nxn): Adjacency mat...
Finds communities with shared nodes to a seed community. Called by mroc. Inputs: - c_j: The seed community for which we want to find which communities overlap. - reverse_index_rows: A node to community indicator matrix. - unavailable_communities: A set of communities that have already ei...
Calculates the Jaccard similarity between two sets of nodes. Called by mroc. Inputs: - c_1: Community (set of nodes) 1. - c_2: Community (set of nodes) 2. Outputs: - jaccard_similarity: The Jaccard similarity of these two communities. def jaccard(c_1, c_2): """ Calculates the Jaccard si...
Performs community embedding using the LOUVAIN method. Introduced in: Blondel, V. D., Guillaume, J. L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory and Experiment, 2008(10), P10008. Inputs...
Performs spectral graph embedding using the graph symmetric normalized Laplacian matrix. Introduced in: Belkin, M., & Niyogi, P. (2003). Laplacian eigenmaps for dimensionality reduction and data representation. Neural computation, 15(6), 1373-1396. Inputs: - A in R^(nx...
Performs spectral graph embedding on the centrality reweighted adjacency matrix Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a scipy.sparse.coo_matrix - k: The number of social dimensions/eigenvectors to extract - max_iter: The maximum ...
Forms the community indicator normalized feature matrix for any graph. Inputs: - A in R^(nxn): Adjacency matrix of an undirected network represented as a SciPy Sparse COOrdinate matrix. Outputs: - X in R^(nxC_n): The latent space embedding represented as a SciPy Sparse COOrdinate matrix. def base_communitie...
Creates an embeded ("nodetached") pkcs7 signature. This is equivalent to the output of:: openssl smime -sign -signer cert -inkey key -outform DER -nodetach < data :type data: bytes :type cert: str :type key: str def create_embeded_pkcs7_signature(data, cert, key): """ Creates an embe...
Create a key and save it into ``file_``. Note that ``file`` must be opened in binary mode. def create_key(file_): """ Create a key and save it into ``file_``. Note that ``file`` must be opened in binary mode. """ pkey = crypto.PKey() pkey.generate_key(crypto.TYPE_RSA, 2048) file_.wri...
Create a CSR for a key, and save it into ``file``. def create_csr(key_file, organization_name, common_name, serial_number, file_): """Create a CSR for a key, and save it into ``file``.""" key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_file.read()) req = crypto.X509Req() subj = req.get_subject()...
Fits a Linear Support Vector Classifier to the labelled graph-based features using the LIBLINEAR library. One-vs-All: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html LinearSVC: http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html Inputs:...
Trains meta-labeler for predicting number of labels for each user. Based on: Tang, L., Rajan, S., & Narayanan, V. K. (2009, April). Large scale multi-label classification via metalabeler. In Proceedings of the 18th international conference on World wide web (pp. 211-220). ACM. def meta...
Uses a trained model and the unlabelled features to produce a user-to-label distance matrix. Inputs: - feature_matrix: The graph based-features in either NumPy or SciPy sparse array format. - model: A trained scikit-learn One-vs-All multi-label scheme of linear SVC models. - classifier_t...
Uses a trained model and the unlabelled features to associate users with labels. The decision is done as per scikit-learn: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html#sklearn.svm.Lin...
Returns a client for a given service. The `sandbox` argument should only be necessary if a the client will be used to make a request. If it will only be used to serialize objects, it is irrelevant. Avoid the overhead of determining the sandbox mode in the calling context if only serialization operatio...
Convert a sequence to primitive equivalents. def _extract_seq(extractor, seq): """Convert a sequence to primitive equivalents.""" subtype = Any if seq.__args__ and seq.__args__[0] is not Any: subtype = seq.__args__[0] return _array_type(extractor.extract(subtype))
returns True if the type in question is a Sequence[] object from the typing module. def _is_sequence(typ): """ returns True if the type in question is a Sequence[] object from the typing module. """ # PEP_560 deprecates issubclass for # List types, for the time being # we'll support a s...
take an attrs based class, and convert it to jsonschema. def extract(cls, extractor, typ): """ take an attrs based class, and convert it to jsonschema. """ schema = { "title": typ.__name__, "type": "object", "properties": {}, ...
Try to read README.rst or return empty string if failed. :return: File contents. :rtype: str def readme(): """Try to read README.rst or return empty string if failed. :return: File contents. :rtype: str """ path = os.path.realpath(os.path.join(os.path.dirname(__file__), 'README.rst')) ...
http://pyserial.readthedocs.io/en/latest/shortintro.html This calls the command line tool from pyserial to list the available serial ports. def listSerialPorts(): """ http://pyserial.readthedocs.io/en/latest/shortintro.html This calls the command line tool from pyserial to list the available serial ports. """...
This will pretty print out a packet's fields. in: dictionary of a packet out: nothing ... everything is printed to screen def prettyPrintPacket(ctrl_table): """ This will pretty print out a packet's fields. in: dictionary of a packet out: nothing ... everything is printed to screen """ print('---------------...
Reads a Json file in: file name out: length of file, dictionary def read(fname): """ Reads a Json file in: file name out: length of file, dictionary """ try: with open(fname, 'r') as f: data = json.load(f) return data except IOError: raise Exception('Could not open {0!s} for reading'.fo...
Writes a Json file in: fname - file name data - dictionary of data to put into the file out: nothing, everything is written to a file def write(fname, data): """ Writes a Json file in: fname - file name data - dictionary of data to put into the file out: nothing, everything is written to a file ...
This makes a generic packet. TODO: look a struct ... does that add value using it? 0xFF, 0xFF, 0xFD, 0x00, ID, LEN_L, LEN_H, INST, PARAM 1, PARAM 2, ..., PARAM N, CRC_L, CRC_H] in: ID - servo id instr - instruction reg - register params - instruction parameter values out: packet def makePacket(ID, instr,...
Creates a packet that writes a value(s) to servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. def makeWritePacket(ID, reg, values=None): """ Creates a packet that writes a value(s) to servo ID at location reg. Make sure the values are in...
Creates a packet that reads the register(s) of servo ID at location reg. Make sure the values are in little endian (use Packet.le() if necessary) for 16 b (word size) values. def makeReadPacket(ID, reg, values=None): """ Creates a packet that reads the register(s) of servo ID at location reg. Make sure the values...
Resets a servo to one of 3 reset states: XL320_RESET_ALL = 0xFF XL320_RESET_ALL_BUT_ID = 0x01 XL320_RESET_ALL_BUT_ID_BAUD_RATE = 0x02 def makeResetPacket(ID, param): """ Resets a servo to one of 3 reset states: XL320_RESET_ALL = 0xFF XL320_RESET_ALL_BUT_ID ...
Commands the servo to an angle (in degrees) def makeServoPacket(ID, angle): """ Commands the servo to an angle (in degrees) """ if not (0.0 <= angle <= 300.0): raise Exception('makeServoPacket(), angle out of bounds: {}'.format(angle)) val = int(angle/300*1023) # lo, hi = le(val) # print('servo cmd {} deg : {...
Sets the maximum servo angle (in the CCW direction) def makeServoMaxLimitPacket(ID, angle): """ Sets the maximum servo angle (in the CCW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CCW_ANGLE_LIMIT, le(angle)) return pkt
Sets the minimum servo angle (in the CW direction) def makeServoMinLimitPacket(ID, angle): """ Sets the minimum servo angle (in the CW direction) """ angle = int(angle/300.0*1023) pkt = makeWritePacket(ID, xl320.XL320_CW_ANGLE_LIMIT, le(angle)) return pkt
Run servo between 0.0 to 1.0, where 1.0 is 100% (full) speed. def makeServoSpeedPacket(ID, maxSpeed): """ Run servo between 0.0 to 1.0, where 1.0 is 100% (full) speed. """ if 0.0 > maxSpeed > 1.0: raise Exception('makeServoSpeed: max speed is a percentage (0.0-1.0)') speed = int(maxSpeed*1023) pkt = makeWriteP...
Turn on/off the servo LED and also sets the color. def makeLEDPacket(ID, color): """ Turn on/off the servo LED and also sets the color. """ # pkt = [255, 255, 253, 0, ID, 11, 0, 3, 25, 0, 2 crc_l, crc_h] pkt = makeWritePacket(ID, xl320.XL320_LED, [color]) return pkt
It is the delay time per data value that takes from the transmission of Instruction Packet until the return of Status Packet. 0 to 254 (0xFE) can be used, and the delay time per data value is 2 usec. That is to say, if the data value is 10, 20 usec is delayed. The initial value is 250 (0xFA) (i.e., 0.5 msec). def ...
Sets the xl-320 to either servo or wheel mode def makeControlModePacket(ID, mode): """ Sets the xl-320 to either servo or wheel mode """ pkt = makeWritePacket(ID, xl320.XL320_CONTROL_MODE, le(mode)) return pkt
Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet def makeBaudRatePacket(ID, rate): """ Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet """ if rate not in [0, 1, 2, 3]: raise Exception('Packet.makeBaudRatePacket: wrong rate {}'...
Write sync angle information to servos. info = [[ID, angle], [ID, angle], ...] def makeSyncAnglePacket(info): """ Write sync angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] # since all servo angles have the same register addr (XL320_GOAL...
Write bulk angle information to servos. info = [[ID, angle], [ID, angle], ...] def makeBulkAnglePacket(info): """ Write bulk angle information to servos. info = [[ID, angle], [ID, angle], ...] """ addr = le(xl320.XL320_GOAL_POSITION) data = [] for pkt in info: data.append(pkt[0]) # ID data.append(addr[0...
not done def prettyPrintPacket(pkt): """ not done """ s = 'packet ID: {} instr: {} len: {}'.format(pkt[4], pkt[7], int((pkt[6] << 8) + pkt[5])) if len(s) > 10: params = pkt[8:-2] s += ' params: {}'.format(params) return s
Search through a string of binary for a valid xl320 package. in: buffer to search through out: a list of valid data packet def findPkt(pkt): """ Search through a string of binary for a valid xl320 package. in: buffer to search through out: a list of valid data packet """ # print('findpkt', pkt) # print('---...
Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) def packetToDict(pkt): """ Given a packet, this turns it into a dictionary ... is this useful? in: packet, array of numbers out: dictionary (key, value) """ d = { 'id': pkt[4], '...
Fetch and store all metadata from the AFIP. def populate_all(): """Fetch and store all metadata from the AFIP.""" ReceiptType.objects.populate() ConceptType.objects.populate() DocumentType.objects.populate() VatType.objects.populate() TaxType.objects.populate() CurrencyType.objects.populate...
Returns the id for the first currency The `default` parameter of a foreign key *MUST* be a primary key (and not an instance), else migrations break. This helper method exists solely for that purpose. def first_currency(): """ Returns the id for the first currency The `default` parameter of a ...
Populate the database with types retrieved from the AFIP. If no ticket is provided, the most recent available one will be used. def populate(self, ticket=None): """ Populate the database with types retrieved from the AFIP. If no ticket is provided, the most recent available one will b...
Returns the certificate as an OpenSSL object Returns the certificate as an OpenSSL object (rather than as a file object). def certificate_object(self): """ Returns the certificate as an OpenSSL object Returns the certificate as an OpenSSL object (rather than as a file ...
Gets the certificate expiration from the certificate Gets the certificate expiration from the certificate file. Note that this value is stored into ``certificate_expiration`` when an instance is saved, so you should generally prefer that method (since this one requires reading and pars...
Creates a key file for this TaxPayer Creates a key file for this TaxPayer if it does not have one, and immediately saves it. Returns True if and only if a key was created. def generate_key(self, force=False): """ Creates a key file for this TaxPayer Creates a key file...
Creates a CSR for this TaxPayer's key Creates a file-like object that contains the CSR which can be used to request a new certificate from AFIP. def generate_csr(self, basename='djangoafip'): """ Creates a CSR for this TaxPayer's key Creates a file-like object that contains th...
Create an AuthTicket for a given service. def create_ticket(self, service): """Create an AuthTicket for a given service.""" ticket = AuthTicket(owner=self, service=service) ticket.authorize() return ticket
Return an existing AuthTicket for a given service. def get_ticket(self, service): """Return an existing AuthTicket for a given service.""" return self.auth_tickets \ .filter(expires__gt=datetime.now(timezone.utc), service=service) \ .last()
Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,). def fetch_points_of_sales(self, ticket=None): """ Fetch all point of sales objects. Fetch all point of ...
This TaxPayer's logo as a data uri. def logo_as_data_uri(self): """This TaxPayer's logo as a data uri.""" _, ext = os.path.splitext(self.logo.file.name) with open(self.logo.file.name, 'rb') as f: data = base64.b64encode(f.read()) return 'data:image/{};base64,{}'.format( ...
Send this ticket to AFIP for authorization. def authorize(self): """Send this ticket to AFIP for authorization.""" request = self.__create_request_xml() request = self.__sign_request(request) request = b64encode(request).decode() client = clients.get_client('wsaa', self.owner.i...
Assign numbers in preparation for validating these receipts. WARNING: Don't call the method manually unless you know what you're doing! def _assign_numbers(self): """ Assign numbers in preparation for validating these receipts. WARNING: Don't call the method manually unless yo...
Checks that all receipts returned by this queryset are groupable. "Groupable" means that they can be validated together: they have the same POS and receipt type. Returns the same queryset is all receipts are groupable, otherwise, raises :class:`~.CannotValidateTogether`. def check_gro...
Validates all receipts matching this queryset. Note that, due to how AFIP implements its numbering, this method is not thread-safe, or even multiprocess-safe. Because of this, it is possible that not all instances matching this queryset are validated properly. Obviously, only successfu...
Returns the number for the last validated receipt. def fetch_last_receipt_number(self, point_of_sales, receipt_type): """Returns the number for the last validated receipt.""" client = clients.get_client('wsfe', point_of_sales.owner.is_sandboxed) response_xml = client.service.FECompUltimoAutoriz...
Returns the sum of all Vat objects. def total_vat(self): """Returns the sum of all Vat objects.""" q = Vat.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
Returns the sum of all Tax objects. def total_tax(self): """Returns the sum of all Tax objects.""" q = Tax.objects.filter(receipt=self).aggregate(total=Sum('amount')) return q['total'] or 0
Returns True if this instance is validated. Note that resolving this property requires a DB query, so if you've a very large amount of receipts you should prefetch (see django's ``select_related``) the ``validation`` field. Even so, a DB query *may* be triggered. If you need a ...
Validates this receipt. This is a shortcut to :class:`~.ReceiptQuerySet`'s method of the same name. Calling this validates only this instance. :param AuthTicket ticket: Use this ticket. If None, one will be loaded or created automatically. :param bool raise_: If True, an ex...
Creates a ReceiptPDF object for a given receipt. Does not actually generate the related PDF file. All attributes will be completed with the information for the relevant ``TaxPayerProfile`` instance. :param Receipt receipt: The receipt for the PDF which will be generated. d...
Save the receipt as a PDF related to this model. The related :class:`~.Receipt` should be validated first, of course. :param bool save_model: If True, immediately save this model instance. def save_pdf(self, save_model=True): """ Save the receipt as a PDF related to this model. ...
Auto-assign and return the total amount for this tax. def compute_amount(self): """Auto-assign and return the total amount for this tax.""" self.amount = self.base_amount * self.aliquot / 100 return self.amount
Returns the label-absorbing random walk transition probability matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural random walk transition probability matrix. def get_label_based_random_walk_matrix(adjacency_matrix, label...
Returns the natural random walk transition probability matrix given the adjacency matrix. Input: - A: A sparse matrix that contains the adjacency matrix of the graph. Output: - W: A sparse matrix that contains the natural random walk transition probability matrix. def get_natural_random_walk_matrix(adjacenc...
test whether it is a middleware :return: Boolean def is_middleware(func) -> bool: """ test whether it is a middleware :return: Boolean """ if inspect.isfunction(func): _check = func _name = func.__name__ else: _check = func.__call__ _name = func.__class__.__...
Checks the number valiaty for the Rondônia state def start(st_reg_number): """Checks the number valiaty for the Rondônia state""" divisor = 11 weight = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] if len(st_reg_number) != 9 and len(st_reg_number) != 14: return False if len(st_reg_number) == ...
Checks the number valiaty for the São Paulo state def start(st_reg_number): """Checks the number valiaty for the São Paulo state""" divisor = 11 verificador_one = int(st_reg_number[len(st_reg_number)-4]) verificador_two = int(st_reg_number[len(st_reg_number)-1]) weights_first = [1, 3, 4, 5, 6, 7,...
Checks the number valiaty for the Pernanbuco state def start(st_reg_number): """Checks the number valiaty for the Pernanbuco state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 8 for i in range(len(st_...
set response header :param key: the key of header :param value: the value of header def set_header(self, key: str, value: str) -> None: """ set response header :param key: the key of header :param value: the value of header """ self.headers[key] = value
Checks the number valiaty for the Bahia state def start(st_reg_number): """Checks the number valiaty for the Bahia state""" weights_second_digit = range(len(st_reg_number)-1, 1, -1) weights_first_digit = range(len(st_reg_number), 1, -1) second_digits = st_reg_number[-1:] number_state_registration ...
generate http response payload and send to writer async def send_http_response(writer, http_code: int, headers: List[Tuple[str, str]], content: bytes, http_status: str= None ...
start server async def serve(http_handler: HTTP_WRAPPER_TYPE, websocket_handler=None, address: str='127.0.0.1', port: int=8000): """ start server """ return await asyncio.start_server(SocketWrapper(http_handler, websocket_handler), address, port)
format body into different type :param body: :return: def __body_format(self, body): """ format body into different type :param body: :return: """ ctype, pdict = parse_header(self.content_type) if ctype == 'application/json': self.for...
Checks the number valiaty for the Paraiba state def start(st_reg_number): """Checks the number valiaty for the Paraiba state""" #st_reg_number = str(st_reg_number) weights = [9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 9: return False ...
Checks the number valiaty for the Mato Grosso state def start(st_reg_number): """Checks the number valiaty for the Mato Grosso state""" #st_reg_number = str(st_reg_number) weights = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 11: ret...
Checks the number valiaty for the Sergipe state def start(st_reg_number): """Checks the number valiaty for the Sergipe state""" divisor = 11 if len(st_reg_number) > 9: return False if len(st_reg_number) < 9: return False sum_total = 0 peso = 9 for i in range(len(st_reg_n...
Checks the number valiaty for the Espirito Santo state def start(st_reg_number): """Checks the number valiaty for the Espirito Santo state""" weights = [9, 8, 7, 6, 5, 4, 3, 2] number_state_registration = st_reg_number[0:len(st_reg_number) - 1] digit_state_registration = st_reg_number[-1] if st_r...