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
alrifqi/django
django/contrib/sitemaps/views.py
352
2953
import datetime from calendar import timegm from functools import wraps from django.contrib.sites.shortcuts import get_current_site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger from django.http import Http404 from django.template.response import TemplateResponse from django.utils.http import http_date def x_robots_tag(func): @wraps(func) def inner(request, *args, **kwargs): response = func(request, *args, **kwargs) response['X-Robots-Tag'] = 'noindex, noodp, noarchive' return response return inner @x_robots_tag def index(request, sitemaps, template_name='sitemap_index.xml', content_type='application/xml', sitemap_url_name='django.contrib.sitemaps.views.sitemap'): req_protocol = request.scheme req_site = get_current_site(request) sites = [] for section, site in sitemaps.items(): if callable(site): site = site() protocol = req_protocol if site.protocol is None else site.protocol sitemap_url = urlresolvers.reverse( sitemap_url_name, kwargs={'section': section}) absolute_url = '%s://%s%s' % (protocol, req_site.domain, sitemap_url) sites.append(absolute_url) for page in range(2, site.paginator.num_pages + 1): sites.append('%s?p=%s' % (absolute_url, page)) return TemplateResponse(request, template_name, {'sitemaps': sites}, content_type=content_type) @x_robots_tag def sitemap(request, sitemaps, section=None, template_name='sitemap.xml', content_type='application/xml'): req_protocol = request.scheme req_site = get_current_site(request) if section is not None: if section not in sitemaps: raise Http404("No sitemap available for section: %r" % section) maps = [sitemaps[section]] else: maps = sitemaps.values() page = request.GET.get("p", 1) urls = [] for site in maps: try: if callable(site): site = site() urls.extend(site.get_urls(page=page, site=req_site, protocol=req_protocol)) except EmptyPage: raise Http404("Page %s empty" % page) except PageNotAnInteger: raise Http404("No page '%s'" % page) response = TemplateResponse(request, template_name, {'urlset': urls}, content_type=content_type) if hasattr(site, 'latest_lastmod'): # if latest_lastmod is defined for site, set header so as # ConditionalGetMiddleware is able to send 304 NOT MODIFIED lastmod = site.latest_lastmod response['Last-Modified'] = http_date( timegm( lastmod.utctimetuple() if isinstance(lastmod, datetime.datetime) else lastmod.timetuple() ) ) return response
bsd-3-clause
[ 646, 2197, 199, 504, 11234, 492, 900, 13844, 199, 504, 9143, 492, 14018, 199, 199, 504, 1639, 14, 2828, 14, 8619, 14, 17469, 492, 664, 63, 1818, 63, 2124, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 1018, 14, 22073, 492, 9630, 3276, 12, 10331, 1763, 2493, 2674, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1455, 63, 602, 421, 199, 318, 671, 63, 28889, 63, 1450, 8, 1532, 304, 272, 768, 13582, 8, 1532, 9, 272, 347, 6506, 8, 1069, 12, 627, 589, 12, 1011, 958, 304, 267, 1177, 275, 2562, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 1177, 459, 56, 13, 50, 2873, 16673, 13, 1931, 418, 275, 283, 889, 1080, 12, 949, 364, 80, 12, 949, 6404, 7, 267, 372, 1177, 272, 372, 6506, 421, 199, 32, 88, 63, 28889, 63, 1450, 199, 318, 1478, 8, 1069, 12, 4770, 8919, 12, 881, 1978, 63, 354, 534, 17205, 63, 1080, 14, 1652, 297, 1564, 63, 466, 534, 3578, 15, 1652, 297, 881, 25121, 63, 633, 63, 354, 534, 1176, 14, 2828, 14, 30515, 14, 4196, 14, 17205, 735, 339, 2648, 63, 3922, 275, 1056, 14, 5512, 272, 2648, 63, 2124, 275, 664, 63, 1818, 63, 2124, 8, 1069, 9, 339, 15424, 275, 942, 272, 367, 3420, 12, 4770, 315, 4770, 8919, 14, 1744, 837, 267, 340, 4550, 8, 2124, 304, 288, 4770, 275, 4770, 342, 267, 4113, 275, 2648, 63, 3922, 340, 4770, 14, 3922, 365, 488, 587, 4770, 14, 3922, 267, 25121, 63, 633, 275, 32403, 14, 4471, 8, 288, 25121, 63, 633, 63, 354, 12, 2074, 3713, 2792, 356, 3420, 1552, 267, 3679, 63, 633, 275, 1543, 83, 13827, 83, 5, 83, 7, 450, 334, 3922, 12, 2648, 63, 2124, 14, 2261, 12, 25121, 63, 633, 9, 267, 15424, 14, 740, 8, 6116, 63, 633, 9, 267, 367, 2034, 315, 1425, 8, 18, 12, 4770, 14, 22073, 14, 1507, 63, 5856, 435, 413, 304, 288, 15424, 14, 740, 3508, 83, 31, 80, 2458, 83, 7, 450, 334, 6116, 63, 633, 12, 2034, 430, 339, 372, 29264, 8, 1069, 12, 1978, 63, 354, 12, 791, 30515, 356, 15424, 1386, 1169, 1564, 63, 466, 29, 1317, 63, 466, 9, 421, 199, 32, 88, 63, 28889, 63, 1450, 199, 318, 25121, 8, 1069, 12, 4770, 8919, 12, 3420, 29, 403, 12, 288, 1978, 63, 354, 534, 17205, 14, 1652, 297, 1564, 63, 466, 534, 3578, 15, 1652, 735, 339, 2648, 63, 3922, 275, 1056, 14, 5512, 272, 2648, 63, 2124, 275, 664, 63, 1818, 63, 2124, 8, 1069, 9, 339, 340, 3420, 365, 440, 488, 26, 267, 340, 3420, 440, 315, 4770, 8919, 26, 288, 746, 4760, 5188, 480, 1944, 25121, 2808, 367, 3420, 26, 450, 82, 2, 450, 3420, 9, 267, 9033, 275, 359, 30515, 59, 2792, 2677, 272, 587, 26, 267, 9033, 275, 4770, 8919, 14, 1459, 342, 272, 2034, 275, 1056, 14, 2970, 14, 362, 480, 80, 401, 413, 9, 339, 8187, 275, 942, 272, 367, 4770, 315, 9033, 26, 267, 862, 26, 288, 340, 4550, 8, 2124, 304, 355, 4770, 275, 4770, 342, 288, 8187, 14, 2880, 8, 2124, 14, 362, 63, 3603, 8, 1606, 29, 1606, 12, 4770, 29, 2103, 63, 2124, 12, 4228, 4113, 29, 2103, 63, 3922, 430, 267, 871, 9630, 3276, 26, 288, 746, 4760, 5188, 480, 3276, 450, 83, 2701, 2, 450, 2034, 9, 267, 871, 10331, 1763, 2493, 2674, 26, 288, 746, 4760, 5188, 480, 1944, 2034, 1543, 83, 4065, 450, 2034, 9, 272, 1177, 275, 29264, 8, 1069, 12, 1978, 63, 354, 12, 791, 633, 409, 356, 8187, 1386, 1816, 1564, 63, 466, 29, 1317, 63, 466, 9, 272, 340, 2688, 8, 2124, 12, 283, 7410, 63, 2019, 1494, 735, 267, 327, 340, 8839, 63, 2019, 1494, 365, 3247, 367, 4770, 12, 663, 1406, 880, 465, 267, 327, 24191, 1002, 6608, 365, 7688, 370, 3222, 20398, 2845, 10362, 1914, 19679, 267, 2061, 1494, 275, 4770, 14, 7410, 63, 2019, 1494, 267, 1177, 459, 6090, 13, 11911, 418, 275, 1455, 63, 602, 8, 288, 900, 13844, 8, 355, 2061, 1494, 14, 5834, 22309, 342, 340, 1228, 8, 2019, 1494, 12, 2197, 14, 2083, 9, 355, 587, 2061, 1494, 14, 22309, 342, 288, 776, 267, 776, 272, 372, 1177, 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 ]
[ 2197, 199, 504, 11234, 492, 900, 13844, 199, 504, 9143, 492, 14018, 199, 199, 504, 1639, 14, 2828, 14, 8619, 14, 17469, 492, 664, 63, 1818, 63, 2124, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 1018, 14, 22073, 492, 9630, 3276, 12, 10331, 1763, 2493, 2674, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1455, 63, 602, 421, 199, 318, 671, 63, 28889, 63, 1450, 8, 1532, 304, 272, 768, 13582, 8, 1532, 9, 272, 347, 6506, 8, 1069, 12, 627, 589, 12, 1011, 958, 304, 267, 1177, 275, 2562, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 1177, 459, 56, 13, 50, 2873, 16673, 13, 1931, 418, 275, 283, 889, 1080, 12, 949, 364, 80, 12, 949, 6404, 7, 267, 372, 1177, 272, 372, 6506, 421, 199, 32, 88, 63, 28889, 63, 1450, 199, 318, 1478, 8, 1069, 12, 4770, 8919, 12, 881, 1978, 63, 354, 534, 17205, 63, 1080, 14, 1652, 297, 1564, 63, 466, 534, 3578, 15, 1652, 297, 881, 25121, 63, 633, 63, 354, 534, 1176, 14, 2828, 14, 30515, 14, 4196, 14, 17205, 735, 339, 2648, 63, 3922, 275, 1056, 14, 5512, 272, 2648, 63, 2124, 275, 664, 63, 1818, 63, 2124, 8, 1069, 9, 339, 15424, 275, 942, 272, 367, 3420, 12, 4770, 315, 4770, 8919, 14, 1744, 837, 267, 340, 4550, 8, 2124, 304, 288, 4770, 275, 4770, 342, 267, 4113, 275, 2648, 63, 3922, 340, 4770, 14, 3922, 365, 488, 587, 4770, 14, 3922, 267, 25121, 63, 633, 275, 32403, 14, 4471, 8, 288, 25121, 63, 633, 63, 354, 12, 2074, 3713, 2792, 356, 3420, 1552, 267, 3679, 63, 633, 275, 1543, 83, 13827, 83, 5, 83, 7, 450, 334, 3922, 12, 2648, 63, 2124, 14, 2261, 12, 25121, 63, 633, 9, 267, 15424, 14, 740, 8, 6116, 63, 633, 9, 267, 367, 2034, 315, 1425, 8, 18, 12, 4770, 14, 22073, 14, 1507, 63, 5856, 435, 413, 304, 288, 15424, 14, 740, 3508, 83, 31, 80, 2458, 83, 7, 450, 334, 6116, 63, 633, 12, 2034, 430, 339, 372, 29264, 8, 1069, 12, 1978, 63, 354, 12, 791, 30515, 356, 15424, 1386, 1169, 1564, 63, 466, 29, 1317, 63, 466, 9, 421, 199, 32, 88, 63, 28889, 63, 1450, 199, 318, 25121, 8, 1069, 12, 4770, 8919, 12, 3420, 29, 403, 12, 288, 1978, 63, 354, 534, 17205, 14, 1652, 297, 1564, 63, 466, 534, 3578, 15, 1652, 735, 339, 2648, 63, 3922, 275, 1056, 14, 5512, 272, 2648, 63, 2124, 275, 664, 63, 1818, 63, 2124, 8, 1069, 9, 339, 340, 3420, 365, 440, 488, 26, 267, 340, 3420, 440, 315, 4770, 8919, 26, 288, 746, 4760, 5188, 480, 1944, 25121, 2808, 367, 3420, 26, 450, 82, 2, 450, 3420, 9, 267, 9033, 275, 359, 30515, 59, 2792, 2677, 272, 587, 26, 267, 9033, 275, 4770, 8919, 14, 1459, 342, 272, 2034, 275, 1056, 14, 2970, 14, 362, 480, 80, 401, 413, 9, 339, 8187, 275, 942, 272, 367, 4770, 315, 9033, 26, 267, 862, 26, 288, 340, 4550, 8, 2124, 304, 355, 4770, 275, 4770, 342, 288, 8187, 14, 2880, 8, 2124, 14, 362, 63, 3603, 8, 1606, 29, 1606, 12, 4770, 29, 2103, 63, 2124, 12, 4228, 4113, 29, 2103, 63, 3922, 430, 267, 871, 9630, 3276, 26, 288, 746, 4760, 5188, 480, 3276, 450, 83, 2701, 2, 450, 2034, 9, 267, 871, 10331, 1763, 2493, 2674, 26, 288, 746, 4760, 5188, 480, 1944, 2034, 1543, 83, 4065, 450, 2034, 9, 272, 1177, 275, 29264, 8, 1069, 12, 1978, 63, 354, 12, 791, 633, 409, 356, 8187, 1386, 1816, 1564, 63, 466, 29, 1317, 63, 466, 9, 272, 340, 2688, 8, 2124, 12, 283, 7410, 63, 2019, 1494, 735, 267, 327, 340, 8839, 63, 2019, 1494, 365, 3247, 367, 4770, 12, 663, 1406, 880, 465, 267, 327, 24191, 1002, 6608, 365, 7688, 370, 3222, 20398, 2845, 10362, 1914, 19679, 267, 2061, 1494, 275, 4770, 14, 7410, 63, 2019, 1494, 267, 1177, 459, 6090, 13, 11911, 418, 275, 1455, 63, 602, 8, 288, 900, 13844, 8, 355, 2061, 1494, 14, 5834, 22309, 342, 340, 1228, 8, 2019, 1494, 12, 2197, 14, 2083, 9, 355, 587, 2061, 1494, 14, 22309, 342, 288, 776, 267, 776, 272, 372, 1177, 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, 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 ]
alviano/wasp
tests/asp/cautious/test6.gus.gringo.cautious.asp.test.py
1
20192
input = """ 1 1 1 1 63 1 1 1 1 64 1 1 2 0 65 66 1 1 2 0 67 68 1 1 2 0 69 70 1 1 2 0 71 72 1 1 2 0 66 65 1 1 2 0 68 67 1 1 2 0 70 69 1 1 2 0 72 71 1 81 1 1 66 1 82 1 1 65 1 83 1 1 68 1 84 1 1 67 1 85 1 1 70 1 86 1 1 69 1 87 1 1 72 1 88 1 1 71 1 89 1 1 66 1 90 1 1 68 1 91 1 1 67 1 92 1 1 69 1 93 2 1 68 81 1 94 1 0 81 1 95 2 1 70 82 1 96 2 1 72 82 1 97 2 1 66 83 1 98 1 0 83 1 99 1 0 84 1 100 2 1 69 84 1 101 2 1 72 85 1 102 2 1 65 85 1 103 1 0 86 1 104 2 1 67 86 1 105 2 1 70 87 1 106 2 1 65 87 1 107 2 1 65 89 1 108 2 1 67 90 1 109 2 1 68 91 1 110 2 1 70 92 1 81 2 1 68 93 1 111 2 1 67 93 1 81 1 0 94 1 82 2 1 70 95 1 111 2 1 69 95 1 82 2 1 72 96 1 112 2 1 71 96 1 83 2 1 66 97 1 113 2 1 65 97 1 83 1 0 98 1 84 1 0 99 1 113 2 1 70 100 1 84 2 1 69 100 1 85 2 1 72 101 1 114 2 1 71 101 1 115 2 1 66 102 1 85 2 1 65 102 1 86 1 0 103 1 115 2 1 68 104 1 86 2 1 67 104 1 87 2 1 70 105 1 116 2 1 69 105 1 117 2 1 66 106 1 87 2 1 65 106 1 118 2 1 70 107 1 119 2 1 72 107 1 89 2 1 65 107 1 120 1 0 108 1 90 2 1 67 108 1 118 2 1 69 108 1 121 2 1 66 109 1 91 2 1 68 109 1 122 1 0 109 1 92 2 1 70 110 1 123 2 1 72 110 1 121 2 1 65 110 1 124 1 0 111 1 93 2 1 67 111 1 95 2 1 69 111 1 96 2 1 71 112 1 100 2 1 70 113 1 125 2 1 72 113 1 97 2 1 65 113 1 101 2 1 71 114 1 102 2 1 66 115 1 104 2 1 68 115 1 126 1 0 115 1 127 1 0 116 1 128 2 1 67 116 1 105 2 1 69 116 1 106 2 1 66 117 1 128 2 1 68 117 1 129 1 0 117 1 107 2 1 70 118 1 108 2 1 69 118 1 107 2 1 72 119 1 130 2 1 71 119 1 108 1 0 120 1 109 2 1 66 121 1 110 2 1 65 121 1 109 1 0 122 1 110 2 1 72 123 1 131 2 1 71 123 1 111 1 0 124 1 113 2 1 72 125 1 132 2 1 71 125 1 115 1 0 126 1 116 1 0 127 1 117 2 1 68 128 1 116 2 1 67 128 1 117 1 0 129 1 119 2 1 71 130 1 123 2 1 71 131 1 125 2 1 71 132 1 139 1 1 120 1 140 1 1 122 1 141 1 1 94 1 142 1 1 124 1 143 1 1 98 1 144 1 1 99 1 145 1 1 126 1 146 1 1 103 1 147 1 1 129 1 148 1 1 127 1 149 2 1 108 139 1 150 2 1 109 140 1 151 2 1 81 141 1 152 2 1 111 142 1 153 2 1 83 143 1 154 2 1 84 144 1 155 2 1 115 145 1 156 2 1 86 146 1 157 2 1 117 147 1 158 2 1 116 148 1 139 2 1 120 149 1 159 2 1 90 149 1 160 2 1 118 149 1 161 2 1 121 150 1 162 2 1 91 150 1 140 2 1 122 150 1 163 2 1 93 151 1 141 2 1 94 151 1 142 2 1 124 152 1 163 2 1 93 152 1 164 2 1 95 152 1 165 2 1 97 153 1 143 2 1 98 153 1 144 2 1 99 154 1 166 2 1 100 154 1 167 2 1 102 155 1 168 2 1 104 155 1 145 2 1 126 155 1 146 2 1 103 156 1 168 2 1 104 156 1 169 2 1 106 157 1 170 2 1 128 157 1 147 2 1 129 157 1 148 2 1 127 158 1 170 2 1 128 158 1 219 2 1 165 179 1 220 2 1 167 179 1 221 2 1 169 179 1 222 2 1 161 179 1 223 2 1 163 159 1 224 1 0 159 1 225 2 1 168 159 1 226 2 1 170 159 1 227 2 1 162 159 1 228 2 1 163 162 1 229 1 0 162 1 230 2 1 168 162 1 231 2 1 170 162 1 232 2 1 168 163 1 233 2 1 170 163 1 234 1 0 163 1 235 2 1 170 168 1 236 2 1 164 160 1 237 2 1 166 160 1 238 1 0 160 1 239 2 1 171 160 1 240 2 1 180 160 1 241 1 0 164 1 242 2 1 171 164 1 243 2 1 166 164 1 244 1 0 166 1 245 2 1 171 166 1 246 2 1 164 180 1 247 2 1 166 180 1 248 1 0 180 1 249 2 1 171 180 1 250 2 1 182 178 1 251 2 1 183 178 1 252 2 1 184 178 1 253 1 0 178 1 254 2 1 181 178 1 255 2 1 182 181 1 256 2 1 183 181 1 257 2 1 184 181 1 258 1 0 181 1 259 2 1 184 182 1 260 1 0 182 1 261 2 1 183 182 1 262 2 1 184 183 1 263 1 0 183 1 264 1 0 184 1 265 1 0 140 1 266 1 0 141 1 293 2 1 146 148 1 294 2 1 179 161 1 295 2 1 179 165 1 296 2 1 161 165 1 297 1 0 165 1 298 2 1 179 167 1 299 2 1 161 167 1 300 1 0 167 1 301 2 1 165 167 1 302 2 1 179 169 1 303 2 1 161 169 1 304 1 0 169 1 305 2 1 165 169 1 306 2 1 167 169 1 307 2 1 159 162 1 308 2 1 159 163 1 309 2 1 162 163 1 310 2 1 159 168 1 311 2 1 162 168 1 312 2 1 163 168 1 313 1 0 168 1 314 2 1 159 170 1 315 2 1 162 170 1 316 2 1 163 170 1 317 1 0 170 1 318 2 1 168 170 1 319 2 1 160 164 1 320 2 1 180 164 1 321 2 1 160 166 1 322 2 1 180 166 1 323 2 1 164 166 1 324 2 1 160 171 1 325 2 1 180 171 1 326 2 1 164 171 1 327 2 1 166 171 1 328 1 0 171 1 329 2 1 160 180 1 330 2 1 178 181 1 331 2 1 178 182 1 332 2 1 181 182 1 333 2 1 178 183 1 334 2 1 181 183 1 335 2 1 182 183 1 336 2 1 178 184 1 337 2 1 181 184 1 338 2 1 182 184 1 339 2 1 183 184 1 340 1 0 200 1 341 1 0 218 1 342 1 0 223 1 343 1 0 236 1 344 1 0 250 5 345 627 10 5 340 341 342 343 344 266 280 308 319 331 65 155 129 78 200 57 65 129 78 200 1 346 1 1 345 1 347 1 0 346 1 348 1 0 190 1 349 1 0 211 1 350 1 0 228 1 351 1 0 246 1 352 1 0 255 5 353 619 10 5 348 349 350 351 352 267 281 309 320 332 57 155 129 78 200 57 65 129 78 200 1 354 1 1 353 1 355 1 0 354 1 356 1 0 201 1 357 1 0 219 1 358 1 0 224 1 359 1 0 237 1 360 1 0 251 5 361 627 10 5 356 357 358 359 360 268 282 295 321 333 65 155 129 78 200 57 65 155 78 200 1 362 1 1 361 1 347 1 0 362 1 363 1 0 191 1 364 1 0 212 1 365 1 0 229 1 366 1 0 247 1 367 1 0 256 5 368 619 10 5 363 364 365 366 367 269 283 296 322 334 57 155 129 78 200 57 65 155 78 200 1 369 1 1 368 1 355 1 0 369 1 370 1 0 202 1 371 1 0 220 1 372 1 0 225 1 373 1 0 238 1 374 1 0 252 5 375 627 10 5 370 371 372 373 374 271 285 298 310 336 65 155 129 78 200 57 65 155 129 200 1 376 1 1 375 1 347 1 0 376 1 377 1 0 192 1 378 1 0 213 1 379 1 0 230 1 380 1 0 248 1 381 1 0 257 5 382 619 10 5 377 378 379 380 381 272 286 299 311 337 57 155 129 78 200 57 65 155 129 200 1 383 1 1 382 1 355 1 0 383 1 384 1 0 194 1 385 1 0 205 1 386 1 0 232 1 387 1 0 241 1 388 1 0 259 5 389 529 10 5 384 385 386 387 388 273 287 300 312 338 57 65 129 78 200 57 65 155 129 200 1 390 1 1 389 1 391 1 0 390 1 392 1 0 197 1 393 1 0 208 1 394 1 0 215 1 395 1 0 244 1 396 1 0 262 5 397 555 10 5 392 393 394 395 396 274 288 301 313 339 57 65 155 78 200 57 65 155 129 200 1 398 1 1 397 1 399 1 0 398 1 400 1 0 203 1 401 1 0 221 1 402 1 0 226 1 403 1 0 239 1 404 1 0 253 5 405 627 10 5 400 401 402 403 404 275 289 302 314 324 65 155 129 78 200 57 65 155 129 78 1 406 1 1 405 1 347 1 0 406 1 407 1 0 193 1 408 1 0 214 1 409 1 0 231 1 410 1 0 249 1 411 1 0 258 5 412 619 10 5 407 408 409 410 411 276 290 303 315 325 57 155 129 78 200 57 65 155 129 78 1 413 1 1 412 1 355 1 0 413 1 414 1 0 195 1 415 1 0 206 1 416 1 0 233 1 417 1 0 242 1 418 1 0 260 5 419 529 10 5 414 415 416 417 418 277 291 304 316 326 57 65 129 78 200 57 65 155 129 78 1 420 1 1 419 1 391 1 0 420 1 421 1 0 198 1 422 1 0 209 1 423 1 0 216 1 424 1 0 245 1 425 1 0 263 5 426 555 10 5 421 422 423 424 425 278 292 305 317 327 57 65 155 78 200 57 65 155 129 78 1 427 1 1 426 1 399 1 0 427 1 428 1 0 204 1 429 1 0 222 1 430 1 0 227 1 431 1 0 240 1 432 1 0 254 5 433 627 10 5 428 429 430 431 432 265 294 307 329 330 65 155 129 78 200 57 155 129 78 200 1 434 1 1 433 1 347 1 0 434 1 435 1 0 196 1 436 1 0 207 1 437 1 0 234 1 438 1 0 243 1 439 1 0 261 5 440 529 10 5 435 436 437 438 439 270 284 297 323 335 57 65 129 78 200 57 65 155 78 200 1 441 1 1 440 1 391 1 0 441 1 442 1 0 199 1 443 1 0 210 1 444 1 0 217 1 445 1 0 235 1 446 1 0 264 5 447 606 10 5 442 443 444 445 446 279 293 306 318 328 57 65 155 129 200 57 65 155 129 78 1 448 1 1 447 1 449 1 0 448 1 391 1 1 347 1 391 1 1 355 1 399 1 1 347 1 399 1 1 355 1 449 1 1 347 1 449 1 1 355 1 449 1 1 391 1 449 1 1 399 1 450 1 1 347 1 450 1 1 355 1 450 1 1 391 1 450 1 1 399 1 355 1 1 347 1 399 1 1 391 1 450 1 1 449 1 451 2 1 355 140 1 451 2 1 391 141 1 451 2 1 399 143 1 451 2 1 449 145 1 451 2 1 450 147 1 452 2 1 347 139 1 452 2 1 391 142 1 452 2 1 399 144 1 452 2 1 449 146 1 452 2 1 450 148 1 453 2 1 355 161 1 453 2 1 399 165 1 453 2 1 449 167 1 453 2 1 450 169 1 453 2 1 347 179 1 454 2 1 347 159 1 454 2 1 355 162 1 454 2 1 391 163 1 454 2 1 449 168 1 454 2 1 450 170 1 455 2 1 347 160 1 455 2 1 391 164 1 455 2 1 399 166 1 455 2 1 450 171 1 455 2 1 355 180 1 456 2 1 347 178 1 456 2 1 355 181 1 456 2 1 391 182 1 456 2 1 399 183 1 456 2 1 449 184 3 10 63 64 66 68 70 72 65 67 69 71 0 0 2 457 10 0 4 63 64 66 68 70 72 65 67 69 71 2 458 10 0 5 63 64 66 68 70 72 65 67 69 71 1 459 2 1 458 457 1 1 1 1 459 0 10 pipe(1,2) 11 pipe(1,4) 12 pipe(2,3) 13 pipe(2,4) 14 pipe(3,4) 15 pipe(3,5) 22 swap(pipe(1,2),pipe(1,2)) 23 swap(pipe(1,4),pipe(1,4)) 24 swap(pipe(2,3),pipe(2,3)) 25 swap(pipe(2,4),pipe(2,4)) 26 swap(pipe(3,4),pipe(3,4)) 27 swap(pipe(3,5),pipe(3,5)) 28 swap(pipe(1,2),pipe(2,1)) 29 swap(pipe(1,4),pipe(4,1)) 30 swap(pipe(2,3),pipe(3,2)) 31 swap(pipe(2,4),pipe(4,2)) 32 swap(pipe(3,4),pipe(4,3)) 33 swap(pipe(3,5),pipe(5,3)) 34 symm_pipe(1,2) 35 symm_pipe(1,4) 36 symm_pipe(2,3) 37 symm_pipe(2,4) 38 symm_pipe(3,4) 39 symm_pipe(3,5) 40 symm_pipe(2,1) 41 symm_pipe(4,1) 42 symm_pipe(3,2) 43 symm_pipe(4,2) 44 symm_pipe(4,3) 45 symm_pipe(5,3) 46 less_ico(pipe(1,2),pipe(2,3)) 47 less_ico(pipe(1,4),pipe(2,3)) 48 less_ico(pipe(1,2),pipe(2,4)) 49 less_ico(pipe(1,4),pipe(2,4)) 50 less_ico(pipe(1,2),pipe(3,4)) 51 less_ico(pipe(1,4),pipe(3,4)) 52 less_ico(pipe(2,3),pipe(3,4)) 53 less_ico(pipe(2,4),pipe(3,4)) 54 less_ico(pipe(1,2),pipe(3,5)) 55 less_ico(pipe(1,4),pipe(3,5)) 56 less_ico(pipe(2,3),pipe(3,5)) 57 less_ico(pipe(2,4),pipe(3,5)) 58 less_ico(pipe(1,2),pipe(1,4)) 59 less_ico(pipe(2,3),pipe(2,4)) 60 less_ico(pipe(3,4),pipe(3,5)) 9 tank(1) 3 valves_per_pipe(1) 61 drop(2,1) 62 drop(4,1) 2 valves_number(4) 63 valve(1,2) 64 valve(1,4) 66 valve(2,3) 68 valve(2,4) 70 valve(3,4) 72 valve(3,5) 65 valve(3,2) 67 valve(4,2) 69 valve(4,3) 71 valve(5,3) 73 broken(pipe(1,2),pipe(1,2)) 74 broken(pipe(1,4),pipe(1,4)) 75 broken(pipe(2,3),pipe(2,3)) 76 broken(pipe(2,4),pipe(2,4)) 77 broken(pipe(3,4),pipe(3,4)) 78 broken(pipe(3,5),pipe(3,5)) 89 broken(pipe(1,2),pipe(2,3)) 90 broken(pipe(1,2),pipe(2,4)) 91 broken(pipe(1,4),pipe(2,4)) 92 broken(pipe(1,4),pipe(3,4)) 93 broken(pipe(2,3),pipe(2,4)) 94 broken(pipe(2,3),pipe(1,2)) 95 broken(pipe(2,3),pipe(3,4)) 96 broken(pipe(2,3),pipe(3,5)) 97 broken(pipe(2,4),pipe(2,3)) 98 broken(pipe(2,4),pipe(1,2)) 99 broken(pipe(2,4),pipe(1,4)) 100 broken(pipe(2,4),pipe(3,4)) 101 broken(pipe(3,4),pipe(3,5)) 102 broken(pipe(3,4),pipe(2,3)) 103 broken(pipe(3,4),pipe(1,4)) 104 broken(pipe(3,4),pipe(2,4)) 105 broken(pipe(3,5),pipe(3,4)) 106 broken(pipe(3,5),pipe(2,3)) 118 broken(pipe(1,2),pipe(3,4)) 119 broken(pipe(1,2),pipe(3,5)) 120 broken(pipe(1,2),pipe(1,4)) 121 broken(pipe(1,4),pipe(2,3)) 122 broken(pipe(1,4),pipe(1,2)) 123 broken(pipe(1,4),pipe(3,5)) 124 broken(pipe(2,3),pipe(1,4)) 125 broken(pipe(2,4),pipe(3,5)) 126 broken(pipe(3,4),pipe(1,2)) 127 broken(pipe(3,5),pipe(1,4)) 128 broken(pipe(3,5),pipe(2,4)) 129 broken(pipe(3,5),pipe(1,2)) 79 extend(pipe(1,2),2) 80 extend(pipe(1,4),4) 81 extend(pipe(2,3),2) 82 extend(pipe(2,3),3) 83 extend(pipe(2,4),2) 84 extend(pipe(2,4),4) 85 extend(pipe(3,4),3) 86 extend(pipe(3,4),4) 87 extend(pipe(3,5),3) 88 extend(pipe(3,5),5) 107 extend(pipe(1,2),3) 108 extend(pipe(1,2),4) 109 extend(pipe(1,4),2) 110 extend(pipe(1,4),3) 111 extend(pipe(2,3),4) 112 extend(pipe(2,3),5) 113 extend(pipe(2,4),3) 114 extend(pipe(3,4),5) 115 extend(pipe(3,4),2) 116 extend(pipe(3,5),4) 117 extend(pipe(3,5),2) 130 extend(pipe(1,2),5) 131 extend(pipe(1,4),5) 132 extend(pipe(2,4),5) 133 reached(pipe(1,2),1) 134 reached(pipe(1,4),1) 135 reached(pipe(2,3),1) 136 reached(pipe(2,4),1) 137 reached(pipe(3,4),1) 138 reached(pipe(3,5),1) 149 reached(pipe(1,2),4) 150 reached(pipe(1,4),2) 151 reached(pipe(2,3),2) 152 reached(pipe(2,3),4) 153 reached(pipe(2,4),2) 154 reached(pipe(2,4),4) 155 reached(pipe(3,4),2) 156 reached(pipe(3,4),4) 157 reached(pipe(3,5),2) 158 reached(pipe(3,5),4) 172 reached(pipe(1,2),3) 173 reached(pipe(1,4),3) 174 reached(pipe(2,3),3) 175 reached(pipe(2,4),3) 176 reached(pipe(3,4),3) 177 reached(pipe(3,5),3) 185 reached(pipe(1,2),5) 186 reached(pipe(1,4),5) 187 reached(pipe(2,3),5) 188 reached(pipe(2,4),5) 189 reached(pipe(3,4),5) 139 deliver(pipe(1,2),pipe(1,4)) 140 deliver(pipe(1,4),pipe(1,2)) 141 deliver(pipe(2,3),pipe(1,2)) 142 deliver(pipe(2,3),pipe(1,4)) 143 deliver(pipe(2,4),pipe(1,2)) 144 deliver(pipe(2,4),pipe(1,4)) 145 deliver(pipe(3,4),pipe(1,2)) 146 deliver(pipe(3,4),pipe(1,4)) 147 deliver(pipe(3,5),pipe(1,2)) 148 deliver(pipe(3,5),pipe(1,4)) 159 deliver(pipe(1,2),pipe(2,4)) 160 deliver(pipe(1,2),pipe(3,4)) 161 deliver(pipe(1,4),pipe(2,3)) 162 deliver(pipe(1,4),pipe(2,4)) 163 deliver(pipe(2,3),pipe(2,4)) 164 deliver(pipe(2,3),pipe(3,4)) 165 deliver(pipe(2,4),pipe(2,3)) 166 deliver(pipe(2,4),pipe(3,4)) 167 deliver(pipe(3,4),pipe(2,3)) 168 deliver(pipe(3,4),pipe(2,4)) 169 deliver(pipe(3,5),pipe(2,3)) 170 deliver(pipe(3,5),pipe(2,4)) 171 deliver(pipe(3,5),pipe(3,4)) 178 deliver(pipe(1,2),pipe(3,5)) 179 deliver(pipe(1,2),pipe(2,3)) 180 deliver(pipe(1,4),pipe(3,4)) 181 deliver(pipe(1,4),pipe(3,5)) 182 deliver(pipe(2,3),pipe(3,5)) 183 deliver(pipe(2,4),pipe(3,5)) 184 deliver(pipe(3,4),pipe(3,5)) 16 dem(1,2,57) 17 dem(1,4,65) 18 dem(2,3,155) 19 dem(2,4,129) 20 dem(3,4,78) 21 dem(3,5,200) 190 compare(pipe(1,4),pipe(2,3),pipe(1,2),-57) 191 compare(pipe(1,4),pipe(2,4),pipe(1,2),-57) 192 compare(pipe(1,4),pipe(3,4),pipe(1,2),-57) 193 compare(pipe(1,4),pipe(3,5),pipe(1,2),-57) 194 compare(pipe(2,3),pipe(3,4),pipe(1,2),-57) 195 compare(pipe(2,3),pipe(3,5),pipe(1,2),-57) 196 compare(pipe(2,3),pipe(2,4),pipe(1,2),-57) 197 compare(pipe(2,4),pipe(3,4),pipe(1,2),-57) 198 compare(pipe(2,4),pipe(3,5),pipe(1,2),-57) 199 compare(pipe(3,4),pipe(3,5),pipe(1,2),-57) 200 compare(pipe(1,2),pipe(2,3),pipe(1,4),-65) 201 compare(pipe(1,2),pipe(2,4),pipe(1,4),-65) 202 compare(pipe(1,2),pipe(3,4),pipe(1,4),-65) 203 compare(pipe(1,2),pipe(3,5),pipe(1,4),-65) 204 compare(pipe(1,2),pipe(1,4),pipe(1,4),-65) 205 compare(pipe(2,3),pipe(3,4),pipe(1,4),-65) 206 compare(pipe(2,3),pipe(3,5),pipe(1,4),-65) 207 compare(pipe(2,3),pipe(2,4),pipe(1,4),-65) 208 compare(pipe(2,4),pipe(3,4),pipe(1,4),-65) 209 compare(pipe(2,4),pipe(3,5),pipe(1,4),-65) 210 compare(pipe(3,4),pipe(3,5),pipe(1,4),-65) 211 compare(pipe(1,4),pipe(2,3),pipe(2,3),-155) 212 compare(pipe(1,4),pipe(2,4),pipe(2,3),-155) 213 compare(pipe(1,4),pipe(3,4),pipe(2,3),-155) 214 compare(pipe(1,4),pipe(3,5),pipe(2,3),-155) 215 compare(pipe(2,4),pipe(3,4),pipe(2,3),-155) 216 compare(pipe(2,4),pipe(3,5),pipe(2,3),-155) 217 compare(pipe(3,4),pipe(3,5),pipe(2,3),-155) 218 compare(pipe(1,2),pipe(2,3),pipe(2,3),-155) 219 compare(pipe(1,2),pipe(2,4),pipe(2,3),-155) 220 compare(pipe(1,2),pipe(3,4),pipe(2,3),-155) 221 compare(pipe(1,2),pipe(3,5),pipe(2,3),-155) 222 compare(pipe(1,2),pipe(1,4),pipe(2,3),-155) 223 compare(pipe(1,2),pipe(2,3),pipe(2,4),-129) 224 compare(pipe(1,2),pipe(2,4),pipe(2,4),-129) 225 compare(pipe(1,2),pipe(3,4),pipe(2,4),-129) 226 compare(pipe(1,2),pipe(3,5),pipe(2,4),-129) 227 compare(pipe(1,2),pipe(1,4),pipe(2,4),-129) 228 compare(pipe(1,4),pipe(2,3),pipe(2,4),-129) 229 compare(pipe(1,4),pipe(2,4),pipe(2,4),-129) 230 compare(pipe(1,4),pipe(3,4),pipe(2,4),-129) 231 compare(pipe(1,4),pipe(3,5),pipe(2,4),-129) 232 compare(pipe(2,3),pipe(3,4),pipe(2,4),-129) 233 compare(pipe(2,3),pipe(3,5),pipe(2,4),-129) 234 compare(pipe(2,3),pipe(2,4),pipe(2,4),-129) 235 compare(pipe(3,4),pipe(3,5),pipe(2,4),-129) 236 compare(pipe(1,2),pipe(2,3),pipe(3,4),-78) 237 compare(pipe(1,2),pipe(2,4),pipe(3,4),-78) 238 compare(pipe(1,2),pipe(3,4),pipe(3,4),-78) 239 compare(pipe(1,2),pipe(3,5),pipe(3,4),-78) 240 compare(pipe(1,2),pipe(1,4),pipe(3,4),-78) 241 compare(pipe(2,3),pipe(3,4),pipe(3,4),-78) 242 compare(pipe(2,3),pipe(3,5),pipe(3,4),-78) 243 compare(pipe(2,3),pipe(2,4),pipe(3,4),-78) 244 compare(pipe(2,4),pipe(3,4),pipe(3,4),-78) 245 compare(pipe(2,4),pipe(3,5),pipe(3,4),-78) 246 compare(pipe(1,4),pipe(2,3),pipe(3,4),-78) 247 compare(pipe(1,4),pipe(2,4),pipe(3,4),-78) 248 compare(pipe(1,4),pipe(3,4),pipe(3,4),-78) 249 compare(pipe(1,4),pipe(3,5),pipe(3,4),-78) 250 compare(pipe(1,2),pipe(2,3),pipe(3,5),-200) 251 compare(pipe(1,2),pipe(2,4),pipe(3,5),-200) 252 compare(pipe(1,2),pipe(3,4),pipe(3,5),-200) 253 compare(pipe(1,2),pipe(3,5),pipe(3,5),-200) 254 compare(pipe(1,2),pipe(1,4),pipe(3,5),-200) 255 compare(pipe(1,4),pipe(2,3),pipe(3,5),-200) 256 compare(pipe(1,4),pipe(2,4),pipe(3,5),-200) 257 compare(pipe(1,4),pipe(3,4),pipe(3,5),-200) 258 compare(pipe(1,4),pipe(3,5),pipe(3,5),-200) 259 compare(pipe(2,3),pipe(3,4),pipe(3,5),-200) 260 compare(pipe(2,3),pipe(3,5),pipe(3,5),-200) 261 compare(pipe(2,3),pipe(2,4),pipe(3,5),-200) 262 compare(pipe(2,4),pipe(3,4),pipe(3,5),-200) 263 compare(pipe(2,4),pipe(3,5),pipe(3,5),-200) 264 compare(pipe(3,4),pipe(3,5),pipe(3,5),-200) 265 compare(pipe(1,2),pipe(1,4),pipe(1,2),57) 266 compare(pipe(1,2),pipe(2,3),pipe(1,2),57) 267 compare(pipe(1,4),pipe(2,3),pipe(1,2),57) 268 compare(pipe(1,2),pipe(2,4),pipe(1,2),57) 269 compare(pipe(1,4),pipe(2,4),pipe(1,2),57) 270 compare(pipe(2,3),pipe(2,4),pipe(1,2),57) 271 compare(pipe(1,2),pipe(3,4),pipe(1,2),57) 272 compare(pipe(1,4),pipe(3,4),pipe(1,2),57) 273 compare(pipe(2,3),pipe(3,4),pipe(1,2),57) 274 compare(pipe(2,4),pipe(3,4),pipe(1,2),57) 275 compare(pipe(1,2),pipe(3,5),pipe(1,2),57) 276 compare(pipe(1,4),pipe(3,5),pipe(1,2),57) 277 compare(pipe(2,3),pipe(3,5),pipe(1,2),57) 278 compare(pipe(2,4),pipe(3,5),pipe(1,2),57) 279 compare(pipe(3,4),pipe(3,5),pipe(1,2),57) 280 compare(pipe(1,2),pipe(2,3),pipe(1,4),65) 281 compare(pipe(1,4),pipe(2,3),pipe(1,4),65) 282 compare(pipe(1,2),pipe(2,4),pipe(1,4),65) 283 compare(pipe(1,4),pipe(2,4),pipe(1,4),65) 284 compare(pipe(2,3),pipe(2,4),pipe(1,4),65) 285 compare(pipe(1,2),pipe(3,4),pipe(1,4),65) 286 compare(pipe(1,4),pipe(3,4),pipe(1,4),65) 287 compare(pipe(2,3),pipe(3,4),pipe(1,4),65) 288 compare(pipe(2,4),pipe(3,4),pipe(1,4),65) 289 compare(pipe(1,2),pipe(3,5),pipe(1,4),65) 290 compare(pipe(1,4),pipe(3,5),pipe(1,4),65) 291 compare(pipe(2,3),pipe(3,5),pipe(1,4),65) 292 compare(pipe(2,4),pipe(3,5),pipe(1,4),65) 293 compare(pipe(3,4),pipe(3,5),pipe(1,4),65) 294 compare(pipe(1,2),pipe(1,4),pipe(2,3),155) 295 compare(pipe(1,2),pipe(2,4),pipe(2,3),155) 296 compare(pipe(1,4),pipe(2,4),pipe(2,3),155) 297 compare(pipe(2,3),pipe(2,4),pipe(2,3),155) 298 compare(pipe(1,2),pipe(3,4),pipe(2,3),155) 299 compare(pipe(1,4),pipe(3,4),pipe(2,3),155) 300 compare(pipe(2,3),pipe(3,4),pipe(2,3),155) 301 compare(pipe(2,4),pipe(3,4),pipe(2,3),155) 302 compare(pipe(1,2),pipe(3,5),pipe(2,3),155) 303 compare(pipe(1,4),pipe(3,5),pipe(2,3),155) 304 compare(pipe(2,3),pipe(3,5),pipe(2,3),155) 305 compare(pipe(2,4),pipe(3,5),pipe(2,3),155) 306 compare(pipe(3,4),pipe(3,5),pipe(2,3),155) 307 compare(pipe(1,2),pipe(1,4),pipe(2,4),129) 308 compare(pipe(1,2),pipe(2,3),pipe(2,4),129) 309 compare(pipe(1,4),pipe(2,3),pipe(2,4),129) 310 compare(pipe(1,2),pipe(3,4),pipe(2,4),129) 311 compare(pipe(1,4),pipe(3,4),pipe(2,4),129) 312 compare(pipe(2,3),pipe(3,4),pipe(2,4),129) 313 compare(pipe(2,4),pipe(3,4),pipe(2,4),129) 314 compare(pipe(1,2),pipe(3,5),pipe(2,4),129) 315 compare(pipe(1,4),pipe(3,5),pipe(2,4),129) 316 compare(pipe(2,3),pipe(3,5),pipe(2,4),129) 317 compare(pipe(2,4),pipe(3,5),pipe(2,4),129) 318 compare(pipe(3,4),pipe(3,5),pipe(2,4),129) 319 compare(pipe(1,2),pipe(2,3),pipe(3,4),78) 320 compare(pipe(1,4),pipe(2,3),pipe(3,4),78) 321 compare(pipe(1,2),pipe(2,4),pipe(3,4),78) 322 compare(pipe(1,4),pipe(2,4),pipe(3,4),78) 323 compare(pipe(2,3),pipe(2,4),pipe(3,4),78) 324 compare(pipe(1,2),pipe(3,5),pipe(3,4),78) 325 compare(pipe(1,4),pipe(3,5),pipe(3,4),78) 326 compare(pipe(2,3),pipe(3,5),pipe(3,4),78) 327 compare(pipe(2,4),pipe(3,5),pipe(3,4),78) 328 compare(pipe(3,4),pipe(3,5),pipe(3,4),78) 329 compare(pipe(1,2),pipe(1,4),pipe(3,4),78) 330 compare(pipe(1,2),pipe(1,4),pipe(3,5),200) 331 compare(pipe(1,2),pipe(2,3),pipe(3,5),200) 332 compare(pipe(1,4),pipe(2,3),pipe(3,5),200) 333 compare(pipe(1,2),pipe(2,4),pipe(3,5),200) 334 compare(pipe(1,4),pipe(2,4),pipe(3,5),200) 335 compare(pipe(2,3),pipe(2,4),pipe(3,5),200) 336 compare(pipe(1,2),pipe(3,4),pipe(3,5),200) 337 compare(pipe(1,4),pipe(3,4),pipe(3,5),200) 338 compare(pipe(2,3),pipe(3,4),pipe(3,5),200) 339 compare(pipe(2,4),pipe(3,4),pipe(3,5),200) 347 lower(pipe(1,2)) 355 lower(pipe(1,4)) 391 lower(pipe(2,3)) 399 lower(pipe(2,4)) 449 lower(pipe(3,4)) 450 lower(pipe(3,5)) 451 worst_deliv_dem(1,2,57) 452 worst_deliv_dem(1,4,65) 453 worst_deliv_dem(2,3,155) 454 worst_deliv_dem(2,4,129) 455 worst_deliv_dem(3,4,78) 456 worst_deliv_dem(3,5,200) 4 junction(1) 5 junction(2) 6 junction(3) 7 junction(4) 8 junction(5) 0 B+ 0 B- 1 0 1 """ output = """ {valve(1,2), valve(1,4), lower(pipe(3,4)), lower(pipe(2,4)), lower(pipe(2,3))} """
apache-2.0
[ 1210, 275, 408, 199, 17, 413, 413, 413, 13668, 199, 17, 413, 413, 413, 5049, 199, 17, 413, 499, 378, 11738, 14157, 199, 17, 413, 499, 378, 13296, 10851, 199, 17, 413, 499, 378, 14610, 10045, 199, 17, 413, 499, 378, 17245, 15323, 199, 17, 413, 499, 378, 14157, 11738, 199, 17, 413, 499, 378, 10851, 13296, 199, 17, 413, 499, 378, 10045, 14610, 199, 17, 413, 499, 378, 15323, 17245, 199, 17, 19071, 413, 413, 14157, 199, 17, 18051, 413, 413, 11738, 199, 17, 20582, 413, 413, 10851, 199, 17, 8264, 413, 413, 13296, 199, 17, 16412, 413, 413, 10045, 199, 17, 10300, 413, 413, 14610, 199, 17, 10513, 413, 413, 15323, 199, 17, 10523, 413, 413, 17245, 199, 17, 17838, 413, 413, 14157, 199, 17, 9137, 413, 413, 10851, 199, 17, 21358, 413, 413, 13296, 199, 17, 20140, 413, 413, 14610, 199, 17, 18969, 499, 413, 10851, 19071, 199, 17, 18729, 413, 378, 19071, 199, 17, 16102, 499, 413, 10045, 18051, 199, 17, 15580, 499, 413, 15323, 18051, 199, 17, 15997, 499, 413, 14157, 20582, 199, 17, 16096, 413, 378, 20582, 199, 17, 8806, 413, 378, 8264, 199, 17, 2948, 499, 413, 14610, 8264, 199, 17, 14313, 499, 413, 15323, 16412, 199, 17, 12996, 499, 413, 11738, 16412, 199, 17, 22363, 413, 378, 10300, 199, 17, 21083, 499, 413, 13296, 10300, 199, 17, 20462, 499, 413, 10045, 10513, 199, 17, 23746, 499, 413, 11738, 10513, 199, 17, 23543, 499, 413, 11738, 17838, 199, 17, 24579, 499, 413, 13296, 9137, 199, 17, 24058, 499, 413, 10851, 21358, 199, 17, 16814, 499, 413, 10045, 20140, 199, 17, 19071, 499, 413, 10851, 18969, 199, 17, 20128, 499, 413, 13296, 18969, 199, 17, 19071, 413, 378, 18729, 199, 17, 18051, 499, 413, 10045, 16102, 199, 17, 20128, 499, 413, 14610, 16102, 199, 17, 18051, 499, 413, 15323, 15580, 199, 17, 20240, 499, 413, 17245, 15580, 199, 17, 20582, 499, 413, 14157, 15997, 199, 17, 24073, 499, 413, 11738, 15997, 199, 17, 20582, 413, 378, 16096, 199, 17, 8264, 413, 378, 8806, 199, 17, 24073, 499, 413, 10045, 2948, 199, 17, 8264, 499, 413, 14610, 2948, 199, 17, 16412, 499, 413, 15323, 14313, 199, 17, 23510, 499, 413, 17245, 14313, 199, 17, 22560, 499, 413, 14157, 12996, 199, 17, 16412, 499, 413, 11738, 12996, 199, 17, 10300, 413, 378, 22363, 199, 17, 22560, 499, 413, 10851, 21083, 199, 17, 10300, 499, 413, 13296, 21083, 199, 17, 10513, 499, 413, 10045, 20462, 199, 17, 25186, 499, 413, 14610, 20462, 199, 17, 26189, 499, 413, 14157, 23746, 199, 17, 10513, 499, 413, 11738, 23746, 199, 17, 25760, 499, 413, 10045, 23543, 199, 17, 26497, 499, 413, 15323, 23543, 199, 17, 17838, 499, 413, 11738, 23543, 199, 17, 13960, 413, 378, 24579, 199, 17, 9137, 499, 413, 13296, 24579, 199, 17, 25760, 499, 413, 14610, 24579, 199, 17, 26228, 499, 413, 14157, 24058, 199, 17, 21358, 499, 413, 10851, 24058, 199, 17, 24557, 413, 378, 24058, 199, 17, 20140, 499, 413, 10045, 16814, 199, 17, 11869, 499, 413, 15323, 16814, 199, 17, 26228, 499, 413, 11738, 16814, 199, 17, 25442, 413, 378, 20128, 199, 17, 18969, 499, 413, 13296, 20128, 199, 17, 16102, 499, 413, 14610, 20128, 199, 17, 15580, 499, 413, 17245, 20240, 199, 17, 2948, 499, 413, 10045, 24073, 199, 17, 19163, 499, 413, 15323, 24073, 199, 17, 15997, 499, 413, 11738, 24073, 199, 17, 14313, 499, 413, 17245, 23510, 199, 17, 12996, 499, 413, 14157, 22560, 199, 17, 21083, 499, 413, 10851, 22560, 199, 17, 21572, 413, 378, 22560, 199, 17, 12792, 413, 378, 25186, 199, 17, 7960, 499, 413, 13296, 25186, 199, 17, 20462, 499, 413, 14610, 25186, 199, 17, 23746, 499, 413, 14157, 26189, 199, 17, 7960, 499, 413, 10851, 26189, 199, 17, 25454, 413, 378, 26189, 199, 17, 23543, 499, 413, 10045, 25760, 199, 17, 24579, 499, 413, 14610, 25760, 199, 17, 23543, 499, 413, 15323, 26497, 199, 17, 21334, 499, 413, 17245, 26497, 199, 17, 24579, 413, 378, 13960, 199, 17, 24058, 499, 413, 14157, 26228, 199, 17, 16814, 499, 413, 11738, 26228, 199, 17, 24058, 413, 378, 24557, 199, 17, 16814, 499, 413, 15323, 11869, 199, 17, 30542, 499, 413, 17245, 11869, 199, 17, 20128, 413, 378, 25442, 199, 17, 24073, 499, 413, 15323, 19163, 199, 17, 27207, 499, 413, 17245, 19163, 199, 17, 22560, 413, 378, 21572, 199, 17, 25186, 413, 378, 12792, 199, 17, 26189, 499, 413, 10851, 7960, 199, 17, 25186, 499, 413, 13296, 7960, 199, 17, 26189, 413, 378, 25454, 199, 17, 26497, 499, 413, 17245, 21334, 199, 17, 11869, 499, 413, 17245, 30542, 199, 17, 19163, 499, 413, 17245, 27207, 199, 17, 22317, 413, 413, 13960, 199, 17, 22796, 413, 413, 24557, 199, 17, 413, 2953, 413, 413, 18729, 199, 17, 31308, 413, 413, 25442, 199, 17, 29235, 413, 413, 16096, 199, 17, 21771, 413, 413, 8806, 199, 17, 28818, 413, 413, 21572, 199, 17, 31263, 413, 413, 22363, 199, 17, 28513, 413, 413, 25454, 199, 17, 30300, 413, 413, 12792, 199, 17, 28528, 499, 413, 24579, 22317, 199, 17, 14711, 499, 413, 24058, 22796, 199, 17, 413, 2869, 499, 413, 19071, 413, 2953, 199, 17, 413, 2528, 499, 413, 20128, 31308, 199, 17, 25828, 499, 413, 20582, 29235, 199, 17, 31693, 499, 413, 8264, 21771, 199, 17, 29710, 499, 413, 22560, 28818, 199, 17, 32609, 499, 413, 10300, 31263, 199, 17, 32400, 499, 413, 26189, 28513, 199, 17, 413, 2010, 499, 413, 25186, 30300, 199, 17, 22317, 499, 413, 13960, 28528, 199, 17, 413, 1427, 499, 413, 9137, 28528, 199, 17, 21235, 499, 413, 25760, 28528, 199, 17, 32372, 499, 413, 26228, 14711, 199, 17, 32729, 499, 413, 21358, 14711, 199, 17, 22796, 499, 413, 24557, 14711, 199, 17, 24619, 499, 413, 18969, 413, 2869, 199, 17, 413, 2953, 499, 413, 18729, 413, 2869, 199, 17, 31308, 499, 413, 25442, 413, 2528, 199, 17, 24619, 499, 413, 18969, 413, 2528, 199, 17, 30380, 499, 413, 16102, 413, 2528, 199, 17, 31852, 499, 413, 15997, 25828, 199, 17, 29235, 499, 413, 16096, 25828, 199, 17, 21771, 499, 413, 8806, 31693, 199, 17, 29923, 499, 413, 2948, 31693, 199, 17, 31650, 499, 413, 12996, 29710, 199, 17, 413 ]
[ 275, 408, 199, 17, 413, 413, 413, 13668, 199, 17, 413, 413, 413, 5049, 199, 17, 413, 499, 378, 11738, 14157, 199, 17, 413, 499, 378, 13296, 10851, 199, 17, 413, 499, 378, 14610, 10045, 199, 17, 413, 499, 378, 17245, 15323, 199, 17, 413, 499, 378, 14157, 11738, 199, 17, 413, 499, 378, 10851, 13296, 199, 17, 413, 499, 378, 10045, 14610, 199, 17, 413, 499, 378, 15323, 17245, 199, 17, 19071, 413, 413, 14157, 199, 17, 18051, 413, 413, 11738, 199, 17, 20582, 413, 413, 10851, 199, 17, 8264, 413, 413, 13296, 199, 17, 16412, 413, 413, 10045, 199, 17, 10300, 413, 413, 14610, 199, 17, 10513, 413, 413, 15323, 199, 17, 10523, 413, 413, 17245, 199, 17, 17838, 413, 413, 14157, 199, 17, 9137, 413, 413, 10851, 199, 17, 21358, 413, 413, 13296, 199, 17, 20140, 413, 413, 14610, 199, 17, 18969, 499, 413, 10851, 19071, 199, 17, 18729, 413, 378, 19071, 199, 17, 16102, 499, 413, 10045, 18051, 199, 17, 15580, 499, 413, 15323, 18051, 199, 17, 15997, 499, 413, 14157, 20582, 199, 17, 16096, 413, 378, 20582, 199, 17, 8806, 413, 378, 8264, 199, 17, 2948, 499, 413, 14610, 8264, 199, 17, 14313, 499, 413, 15323, 16412, 199, 17, 12996, 499, 413, 11738, 16412, 199, 17, 22363, 413, 378, 10300, 199, 17, 21083, 499, 413, 13296, 10300, 199, 17, 20462, 499, 413, 10045, 10513, 199, 17, 23746, 499, 413, 11738, 10513, 199, 17, 23543, 499, 413, 11738, 17838, 199, 17, 24579, 499, 413, 13296, 9137, 199, 17, 24058, 499, 413, 10851, 21358, 199, 17, 16814, 499, 413, 10045, 20140, 199, 17, 19071, 499, 413, 10851, 18969, 199, 17, 20128, 499, 413, 13296, 18969, 199, 17, 19071, 413, 378, 18729, 199, 17, 18051, 499, 413, 10045, 16102, 199, 17, 20128, 499, 413, 14610, 16102, 199, 17, 18051, 499, 413, 15323, 15580, 199, 17, 20240, 499, 413, 17245, 15580, 199, 17, 20582, 499, 413, 14157, 15997, 199, 17, 24073, 499, 413, 11738, 15997, 199, 17, 20582, 413, 378, 16096, 199, 17, 8264, 413, 378, 8806, 199, 17, 24073, 499, 413, 10045, 2948, 199, 17, 8264, 499, 413, 14610, 2948, 199, 17, 16412, 499, 413, 15323, 14313, 199, 17, 23510, 499, 413, 17245, 14313, 199, 17, 22560, 499, 413, 14157, 12996, 199, 17, 16412, 499, 413, 11738, 12996, 199, 17, 10300, 413, 378, 22363, 199, 17, 22560, 499, 413, 10851, 21083, 199, 17, 10300, 499, 413, 13296, 21083, 199, 17, 10513, 499, 413, 10045, 20462, 199, 17, 25186, 499, 413, 14610, 20462, 199, 17, 26189, 499, 413, 14157, 23746, 199, 17, 10513, 499, 413, 11738, 23746, 199, 17, 25760, 499, 413, 10045, 23543, 199, 17, 26497, 499, 413, 15323, 23543, 199, 17, 17838, 499, 413, 11738, 23543, 199, 17, 13960, 413, 378, 24579, 199, 17, 9137, 499, 413, 13296, 24579, 199, 17, 25760, 499, 413, 14610, 24579, 199, 17, 26228, 499, 413, 14157, 24058, 199, 17, 21358, 499, 413, 10851, 24058, 199, 17, 24557, 413, 378, 24058, 199, 17, 20140, 499, 413, 10045, 16814, 199, 17, 11869, 499, 413, 15323, 16814, 199, 17, 26228, 499, 413, 11738, 16814, 199, 17, 25442, 413, 378, 20128, 199, 17, 18969, 499, 413, 13296, 20128, 199, 17, 16102, 499, 413, 14610, 20128, 199, 17, 15580, 499, 413, 17245, 20240, 199, 17, 2948, 499, 413, 10045, 24073, 199, 17, 19163, 499, 413, 15323, 24073, 199, 17, 15997, 499, 413, 11738, 24073, 199, 17, 14313, 499, 413, 17245, 23510, 199, 17, 12996, 499, 413, 14157, 22560, 199, 17, 21083, 499, 413, 10851, 22560, 199, 17, 21572, 413, 378, 22560, 199, 17, 12792, 413, 378, 25186, 199, 17, 7960, 499, 413, 13296, 25186, 199, 17, 20462, 499, 413, 14610, 25186, 199, 17, 23746, 499, 413, 14157, 26189, 199, 17, 7960, 499, 413, 10851, 26189, 199, 17, 25454, 413, 378, 26189, 199, 17, 23543, 499, 413, 10045, 25760, 199, 17, 24579, 499, 413, 14610, 25760, 199, 17, 23543, 499, 413, 15323, 26497, 199, 17, 21334, 499, 413, 17245, 26497, 199, 17, 24579, 413, 378, 13960, 199, 17, 24058, 499, 413, 14157, 26228, 199, 17, 16814, 499, 413, 11738, 26228, 199, 17, 24058, 413, 378, 24557, 199, 17, 16814, 499, 413, 15323, 11869, 199, 17, 30542, 499, 413, 17245, 11869, 199, 17, 20128, 413, 378, 25442, 199, 17, 24073, 499, 413, 15323, 19163, 199, 17, 27207, 499, 413, 17245, 19163, 199, 17, 22560, 413, 378, 21572, 199, 17, 25186, 413, 378, 12792, 199, 17, 26189, 499, 413, 10851, 7960, 199, 17, 25186, 499, 413, 13296, 7960, 199, 17, 26189, 413, 378, 25454, 199, 17, 26497, 499, 413, 17245, 21334, 199, 17, 11869, 499, 413, 17245, 30542, 199, 17, 19163, 499, 413, 17245, 27207, 199, 17, 22317, 413, 413, 13960, 199, 17, 22796, 413, 413, 24557, 199, 17, 413, 2953, 413, 413, 18729, 199, 17, 31308, 413, 413, 25442, 199, 17, 29235, 413, 413, 16096, 199, 17, 21771, 413, 413, 8806, 199, 17, 28818, 413, 413, 21572, 199, 17, 31263, 413, 413, 22363, 199, 17, 28513, 413, 413, 25454, 199, 17, 30300, 413, 413, 12792, 199, 17, 28528, 499, 413, 24579, 22317, 199, 17, 14711, 499, 413, 24058, 22796, 199, 17, 413, 2869, 499, 413, 19071, 413, 2953, 199, 17, 413, 2528, 499, 413, 20128, 31308, 199, 17, 25828, 499, 413, 20582, 29235, 199, 17, 31693, 499, 413, 8264, 21771, 199, 17, 29710, 499, 413, 22560, 28818, 199, 17, 32609, 499, 413, 10300, 31263, 199, 17, 32400, 499, 413, 26189, 28513, 199, 17, 413, 2010, 499, 413, 25186, 30300, 199, 17, 22317, 499, 413, 13960, 28528, 199, 17, 413, 1427, 499, 413, 9137, 28528, 199, 17, 21235, 499, 413, 25760, 28528, 199, 17, 32372, 499, 413, 26228, 14711, 199, 17, 32729, 499, 413, 21358, 14711, 199, 17, 22796, 499, 413, 24557, 14711, 199, 17, 24619, 499, 413, 18969, 413, 2869, 199, 17, 413, 2953, 499, 413, 18729, 413, 2869, 199, 17, 31308, 499, 413, 25442, 413, 2528, 199, 17, 24619, 499, 413, 18969, 413, 2528, 199, 17, 30380, 499, 413, 16102, 413, 2528, 199, 17, 31852, 499, 413, 15997, 25828, 199, 17, 29235, 499, 413, 16096, 25828, 199, 17, 21771, 499, 413, 8806, 31693, 199, 17, 29923, 499, 413, 2948, 31693, 199, 17, 31650, 499, 413, 12996, 29710, 199, 17, 413, 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,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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 ]
abdoosh00/edx-rtl-final
lms/djangoapps/verify_student/tests/test_views.py
5
4251
""" verify_student/start?course_id=MITx/6.002x/2013_Spring # create /upload_face?course_id=MITx/6.002x/2013_Spring /upload_photo_id /confirm # mark_ready() ---> To Payment """ import urllib from mock import patch, Mock, ANY from django.test import TestCase from django.test.utils import override_settings from django.conf import settings from django.core.urlresolvers import reverse from django.core.exceptions import ObjectDoesNotExist from xmodule.modulestore.tests.factories import CourseFactory from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from student.tests.factories import UserFactory from course_modes.models import CourseMode from verify_student.views import render_to_response from verify_student.models import SoftwareSecurePhotoVerification def mock_render_to_response(*args, **kwargs): return render_to_response(*args, **kwargs) render_mock = Mock(side_effect=mock_render_to_response) class StartView(TestCase): def start_url(self, course_id=""): return "/verify_student/{0}".format(urllib.quote(course_id)) def test_start_new_verification(self): """ Test the case where the user has no pending `PhotoVerficiationAttempts`, but is just starting their first. """ user = UserFactory.create(username="rusty", password="test") self.client.login(username="rusty", password="test") def must_be_logged_in(self): self.assertHttpForbidden(self.client.get(self.start_url())) @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) class TestVerifyView(TestCase): def setUp(self): self.user = UserFactory.create(username="rusty", password="test") self.client.login(username="rusty", password="test") self.course_id = 'Robot/999/Test_Course' CourseFactory.create(org='Robot', number='999', display_name='Test Course') verified_mode = CourseMode(course_id=self.course_id, mode_slug="verified", mode_display_name="Verified Certificate", min_price=50) verified_mode.save() def test_invalid_course(self): fake_course_id = "Robot/999/Fake_Course" url = reverse('verify_student_verify', kwargs={"course_id": fake_course_id}) response = self.client.get(url) self.assertEquals(response.status_code, 302) @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) class TestReverifyView(TestCase): """ Tests for the reverification views """ def setUp(self): self.user = UserFactory.create(username="rusty", password="test") self.client.login(username="rusty", password="test") @patch('verify_student.views.render_to_response', render_mock) def test_reverify_get(self): url = reverse('verify_student_reverify') response = self.client.get(url) self.assertEquals(response.status_code, 200) ((_template, context), _kwargs) = render_mock.call_args self.assertFalse(context['error']) @patch('verify_student.views.render_to_response', render_mock) def test_reverify_post_failure(self): url = reverse('verify_student_reverify') response = self.client.post(url, {'face_image': '', 'photo_id_image': ''}) self.assertEquals(response.status_code, 200) ((template, context), _kwargs) = render_mock.call_args self.assertIn('photo_reverification', template) self.assertTrue(context['error']) @patch.dict(settings.FEATURES, {'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING': True}) def test_reverify_post_success(self): url = reverse('verify_student_reverify') response = self.client.post(url, {'face_image': ',', 'photo_id_image': ','}) self.assertEquals(response.status_code, 302) try: verification_attempt = SoftwareSecurePhotoVerification.objects.get(user=self.user) self.assertIsNotNone(verification_attempt) except ObjectDoesNotExist: self.fail('No verification object generated')
agpl-3.0
[ 624, 421, 199, 4712, 63, 5500, 15, 928, 31, 1972, 63, 344, 29, 13965, 88, 15, 22, 14, 7432, 88, 15, 6965, 63, 51, 2700, 316, 327, 1218, 1598, 1182, 5064, 63, 1409, 31, 1972, 63, 344, 29, 13965, 88, 15, 22, 14, 7432, 88, 15, 6965, 63, 51, 2700, 316, 1598, 1182, 5064, 63, 13834, 63, 344, 1598, 1182, 9548, 327, 2216, 63, 2179, 342, 421, 1553, 5118, 4005, 25523, 199, 199, 624, 199, 646, 4011, 199, 504, 1683, 492, 3371, 12, 4420, 12, 1821, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 20736, 14, 2219, 14, 2219, 492, 7393, 63, 3998, 63, 45, 26477, 63, 27011, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 4911, 63, 5500, 14, 4196, 492, 3795, 63, 475, 63, 1310, 199, 504, 4911, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 421, 199, 318, 1683, 63, 3352, 63, 475, 63, 1310, 2031, 589, 12, 1011, 958, 304, 272, 372, 3795, 63, 475, 63, 1310, 2031, 589, 12, 1011, 958, 9, 199, 199, 3352, 63, 1805, 275, 4420, 8, 2441, 63, 5881, 29, 1805, 63, 3352, 63, 475, 63, 1310, 9, 421, 199, 533, 7707, 2768, 8, 1746, 304, 339, 347, 1343, 63, 633, 8, 277, 12, 2518, 63, 344, 17364, 267, 372, 3286, 4712, 63, 5500, 5321, 16, 5469, 908, 8, 4078, 14, 3513, 8, 1972, 63, 344, 430, 339, 347, 511, 63, 928, 63, 1222, 63, 16257, 8, 277, 304, 267, 408, 267, 1379, 314, 1930, 2382, 314, 922, 965, 949, 9413, 658, 21258, 3673, 4294, 425, 15322, 1086, 3559, 267, 1325, 365, 2951, 6617, 3932, 1642, 14, 267, 408, 267, 922, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 339, 347, 1471, 63, 1235, 63, 12419, 63, 262, 8, 277, 304, 267, 291, 14, 479, 5779, 17454, 8, 277, 14, 1258, 14, 362, 8, 277, 14, 928, 63, 633, 4059, 421, 199, 32, 4415, 63, 1751, 8, 27011, 29, 2864, 63, 3998, 63, 45, 26477, 63, 27011, 9, 199, 533, 1379, 7496, 2768, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1972, 63, 344, 275, 283, 21823, 15, 5637, 15, 774, 63, 6979, 7, 267, 17862, 14, 981, 8, 1308, 534, 21823, 297, 1329, 534, 5637, 297, 2929, 63, 354, 534, 774, 5531, 358, 267, 16317, 63, 632, 275, 27312, 8, 1972, 63, 344, 29, 277, 14, 1972, 63, 344, 12, 3521, 818, 63, 5464, 628, 12949, 401, 3521, 818, 63, 2918, 63, 354, 628, 3673, 4541, 12904, 401, 3521, 1748, 63, 4777, 29, 1400, 9, 267, 16317, 63, 632, 14, 2117, 342, 339, 347, 511, 63, 3197, 63, 1972, 8, 277, 304, 267, 4026, 63, 1972, 63, 344, 275, 298, 21823, 15, 5637, 15, 8249, 63, 6979, 2, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 4712, 297, 1993, 2074, 8871, 1972, 63, 344, 582, 4026, 63, 1972, 63, 344, 1552, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 633, 9, 398, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 421, 199, 32, 4415, 63, 1751, 8, 27011, 29, 2864, 63, 3998, 63, 45, 26477, 63, 27011, 9, 199, 533, 1379, 497, 4712, 2768, 8, 1746, 304, 272, 408, 272, 6496, 367, 314, 295, 16257, 6858, 339, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 339, 768, 2068, 360, 4712, 63, 5500, 14, 4196, 14, 3352, 63, 475, 63, 1310, 297, 3795, 63, 1805, 9, 272, 347, 511, 63, 264, 4712, 63, 362, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 633, 9, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 334, 1547, 1160, 12, 1067, 395, 485, 958, 9, 275, 3795, 63, 1805, 14, 1250, 63, 589, 267, 291, 14, 3334, 8, 1100, 459, 705, 1105, 339, 768, 2068, 360, 4712, 63, 5500, 14, 4196, 14, 3352, 63, 475, 63, 1310, 297, 3795, 63, 1805, 9, 272, 347, 511, 63, 264, 4712, 63, 1932, 63, 5328, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 1409, 63, 1569, 356, 3260, 5101, 283, 13834, 63, 344, 63, 1569, 356, 283, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 3666, 1160, 12, 1067, 395, 485, 958, 9, 275, 3795, 63, 1805, 14, 1250, 63, 589, 267, 291, 14, 4080, 360, 13834, 63, 264, 16257, 297, 1978, 9, 267, 291, 14, 1815, 8, 1100, 459, 705, 1105, 339, 768, 2068, 14, 807, 8, 1751, 14, 13313, 12, 791, 10774, 7474, 619, 948, 63, 22443, 63, 840, 29317, 63, 7466, 1922, 63, 2707, 63, 2864, 1206, 356, 715, 1552, 272, 347, 511, 63, 264, 4712, 63, 1932, 63, 3742, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 1409, 63, 1569, 356, 30048, 5101, 283, 13834, 63, 344, 63, 1569, 356, 1656, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 862, 26, 288, 14786, 63, 16880, 275, 2290, 24117, 21258, 22595, 14, 1462 ]
[ 421, 199, 4712, 63, 5500, 15, 928, 31, 1972, 63, 344, 29, 13965, 88, 15, 22, 14, 7432, 88, 15, 6965, 63, 51, 2700, 316, 327, 1218, 1598, 1182, 5064, 63, 1409, 31, 1972, 63, 344, 29, 13965, 88, 15, 22, 14, 7432, 88, 15, 6965, 63, 51, 2700, 316, 1598, 1182, 5064, 63, 13834, 63, 344, 1598, 1182, 9548, 327, 2216, 63, 2179, 342, 421, 1553, 5118, 4005, 25523, 199, 199, 624, 199, 646, 4011, 199, 504, 1683, 492, 3371, 12, 4420, 12, 1821, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 20736, 14, 2219, 14, 2219, 492, 7393, 63, 3998, 63, 45, 26477, 63, 27011, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 4911, 63, 5500, 14, 4196, 492, 3795, 63, 475, 63, 1310, 199, 504, 4911, 63, 5500, 14, 992, 492, 2290, 24117, 21258, 22595, 421, 199, 318, 1683, 63, 3352, 63, 475, 63, 1310, 2031, 589, 12, 1011, 958, 304, 272, 372, 3795, 63, 475, 63, 1310, 2031, 589, 12, 1011, 958, 9, 199, 199, 3352, 63, 1805, 275, 4420, 8, 2441, 63, 5881, 29, 1805, 63, 3352, 63, 475, 63, 1310, 9, 421, 199, 533, 7707, 2768, 8, 1746, 304, 339, 347, 1343, 63, 633, 8, 277, 12, 2518, 63, 344, 17364, 267, 372, 3286, 4712, 63, 5500, 5321, 16, 5469, 908, 8, 4078, 14, 3513, 8, 1972, 63, 344, 430, 339, 347, 511, 63, 928, 63, 1222, 63, 16257, 8, 277, 304, 267, 408, 267, 1379, 314, 1930, 2382, 314, 922, 965, 949, 9413, 658, 21258, 3673, 4294, 425, 15322, 1086, 3559, 267, 1325, 365, 2951, 6617, 3932, 1642, 14, 267, 408, 267, 922, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 339, 347, 1471, 63, 1235, 63, 12419, 63, 262, 8, 277, 304, 267, 291, 14, 479, 5779, 17454, 8, 277, 14, 1258, 14, 362, 8, 277, 14, 928, 63, 633, 4059, 421, 199, 32, 4415, 63, 1751, 8, 27011, 29, 2864, 63, 3998, 63, 45, 26477, 63, 27011, 9, 199, 533, 1379, 7496, 2768, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1972, 63, 344, 275, 283, 21823, 15, 5637, 15, 774, 63, 6979, 7, 267, 17862, 14, 981, 8, 1308, 534, 21823, 297, 1329, 534, 5637, 297, 2929, 63, 354, 534, 774, 5531, 358, 267, 16317, 63, 632, 275, 27312, 8, 1972, 63, 344, 29, 277, 14, 1972, 63, 344, 12, 3521, 818, 63, 5464, 628, 12949, 401, 3521, 818, 63, 2918, 63, 354, 628, 3673, 4541, 12904, 401, 3521, 1748, 63, 4777, 29, 1400, 9, 267, 16317, 63, 632, 14, 2117, 342, 339, 347, 511, 63, 3197, 63, 1972, 8, 277, 304, 267, 4026, 63, 1972, 63, 344, 275, 298, 21823, 15, 5637, 15, 8249, 63, 6979, 2, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 4712, 297, 1993, 2074, 8871, 1972, 63, 344, 582, 4026, 63, 1972, 63, 344, 1552, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 633, 9, 398, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 421, 199, 32, 4415, 63, 1751, 8, 27011, 29, 2864, 63, 3998, 63, 45, 26477, 63, 27011, 9, 199, 533, 1379, 497, 4712, 2768, 8, 1746, 304, 272, 408, 272, 6496, 367, 314, 295, 16257, 6858, 339, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 267, 291, 14, 1258, 14, 2886, 8, 2473, 628, 19622, 89, 401, 2505, 628, 396, 531, 339, 768, 2068, 360, 4712, 63, 5500, 14, 4196, 14, 3352, 63, 475, 63, 1310, 297, 3795, 63, 1805, 9, 272, 347, 511, 63, 264, 4712, 63, 362, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 633, 9, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 334, 1547, 1160, 12, 1067, 395, 485, 958, 9, 275, 3795, 63, 1805, 14, 1250, 63, 589, 267, 291, 14, 3334, 8, 1100, 459, 705, 1105, 339, 768, 2068, 360, 4712, 63, 5500, 14, 4196, 14, 3352, 63, 475, 63, 1310, 297, 3795, 63, 1805, 9, 272, 347, 511, 63, 264, 4712, 63, 1932, 63, 5328, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 1409, 63, 1569, 356, 3260, 5101, 283, 13834, 63, 344, 63, 1569, 356, 283, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 3666, 1160, 12, 1067, 395, 485, 958, 9, 275, 3795, 63, 1805, 14, 1250, 63, 589, 267, 291, 14, 4080, 360, 13834, 63, 264, 16257, 297, 1978, 9, 267, 291, 14, 1815, 8, 1100, 459, 705, 1105, 339, 768, 2068, 14, 807, 8, 1751, 14, 13313, 12, 791, 10774, 7474, 619, 948, 63, 22443, 63, 840, 29317, 63, 7466, 1922, 63, 2707, 63, 2864, 1206, 356, 715, 1552, 272, 347, 511, 63, 264, 4712, 63, 1932, 63, 3742, 8, 277, 304, 267, 1166, 275, 3837, 360, 4712, 63, 5500, 63, 264, 4712, 358, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 1409, 63, 1569, 356, 30048, 5101, 283, 13834, 63, 344, 63, 1569, 356, 1656, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 862, 26, 288, 14786, 63, 16880, 275, 2290, 24117, 21258, 22595, 14, 1462, 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,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ore.Signal(object, object, object) # (row, col, state) def __init__(self, columns): QtGui.QWidget.__init__(self) self.layout = QtGui.QGridLayout() self.layout.setSpacing(0) self.setLayout(self.layout) self.headers = [] self.columns = columns col = 1 for c in columns: label = VerticalLabel.VerticalLabel(c, orientation='vertical') self.headers.append(label) self.layout.addWidget(label, 0, col) col += 1 self.rowNames = [] self.rowWidgets = [] self.oldRows = {} ## remember settings from removed rows; reapply if they reappear. def updateRows(self, rows): for r in self.rowNames[:]: if r not in rows: self.removeRow(r) for r in rows: if r not in self.rowNames: self.addRow(r) def addRow(self, name): label = QtGui.QLabel(name) row = len(self.rowNames)+1 self.layout.addWidget(label, row, 0) checks = [] col = 1 for c in self.columns: check = QtGui.QCheckBox('') check.col = c check.row = name self.layout.addWidget(check, row, col) checks.append(check) if name in self.oldRows: check.setChecked(self.oldRows[name][col]) col += 1 #QtCore.QObject.connect(check, QtCore.SIGNAL('stateChanged(int)'), self.checkChanged) check.stateChanged.connect(self.checkChanged) self.rowNames.append(name) self.rowWidgets.append([label] + checks) def removeRow(self, name): row = self.rowNames.index(name) self.oldRows[name] = self.saveState()['rows'][row] ## save for later self.rowNames.pop(row) for w in self.rowWidgets[row]: w.setParent(None) #QtCore.QObject.disconnect(w, QtCore.SIGNAL('stateChanged(int)'), self.checkChanged) if isinstance(w, QtGui.QCheckBox): w.stateChanged.disconnect(self.checkChanged) self.rowWidgets.pop(row) for i in range(row, len(self.rowNames)): widgets = self.rowWidgets[i] for j in range(len(widgets)): widgets[j].setParent(None) self.layout.addWidget(widgets[j], i+1, j) def checkChanged(self, state): check = QtCore.QObject.sender(self) #self.emit(QtCore.SIGNAL('stateChanged'), check.row, check.col, state) self.sigStateChanged.emit(check.row, check.col, state) def saveState(self): rows = [] for i in range(len(self.rowNames)): row = [self.rowNames[i]] + [c.isChecked() for c in self.rowWidgets[i][1:]] rows.append(row) return {'cols': self.columns, 'rows': rows} def restoreState(self, state): rows = [r[0] for r in state['rows']] self.updateRows(rows) for r in state['rows']: rowNum = self.rowNames.index(r[0]) for i in range(1, len(r)): self.rowWidgets[rowNum][i].setChecked(r[i])
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2508, 4238, 492, 5928, 12, 10565, 199, 504, 1275, 492, 5444, 3294, 4314, 199, 199, 363, 452, 363, 275, 788, 1799, 3186, 418, 199, 199, 533, 2670, 3186, 8, 10604, 14, 23894, 304, 2286, 5259, 2223, 6970, 275, 10565, 14, 11274, 8, 785, 12, 909, 12, 909, 9, 327, 334, 1143, 12, 1048, 12, 1174, 9, 2286, 347, 636, 826, 721, 277, 12, 4362, 304, 267, 5928, 14, 23894, 855, 826, 721, 277, 9, 267, 291, 14, 4209, 275, 5928, 14, 49, 7900, 4798, 342, 267, 291, 14, 4209, 14, 409, 24052, 8, 16, 9, 267, 291, 14, 409, 4798, 8, 277, 14, 4209, 9, 267, 291, 14, 2139, 275, 942, 267, 291, 14, 3406, 275, 4362, 267, 1048, 275, 413, 267, 367, 286, 315, 4362, 26, 288, 1768, 275, 5444, 3294, 4314, 14, 19462, 4314, 8, 67, 12, 16774, 534, 7870, 358, 288, 291, 14, 2139, 14, 740, 8, 1302, 9, 288, 291, 14, 4209, 14, 9475, 8, 1302, 12, 378, 12, 1048, 9, 288, 1048, 847, 413, 2728, 291, 14, 1143, 5866, 275, 942, 267, 291, 14, 1143, 12462, 275, 942, 267, 291, 14, 1753, 13405, 275, 1052, 221, 925, 21027, 2202, 687, 4829, 4730, 27, 295, 4998, 340, 2985, 295, 27307, 14, 268, 339, 347, 1678, 13405, 8, 277, 12, 4730, 304, 267, 367, 519, 315, 291, 14, 1143, 5866, 32734, 288, 340, 519, 440, 315, 4730, 26, 355, 291, 14, 2168, 5810, 8, 82, 9, 267, 367, 519, 315, 4730, 26, 288, 340, 519, 440, 315, 291, 14, 1143, 5866, 26, 355, 291, 14, 525, 5810, 8, 82, 9, 339, 347, 1050, 5810, 8, 277, 12, 536, 304, 267, 1768, 275, 5928, 14, 19890, 8, 354, 9, 267, 1962, 275, 822, 8, 277, 14, 1143, 5866, 6393, 17, 267, 291, 14, 4209, 14, 9475, 8, 1302, 12, 1962, 12, 378, 9, 267, 5920, 275, 942, 267, 1048, 275, 413, 267, 367, 286, 315, 291, 14, 3406, 26, 288, 1104, 275, 5928, 14, 49, 20530, 8355, 288, 1104, 14, 761, 275, 286, 288, 1104, 14, 1143, 275, 536, 288, 291, 14, 4209, 14, 9475, 8, 1074, 12, 1962, 12, 1048, 9, 288, 5920, 14, 740, 8, 1074, 9, 288, 340, 536, 315, 291, 14, 1753, 13405, 26, 355, 1104, 14, 26657, 8, 277, 14, 1753, 13405, 59, 354, 1527, 761, 566, 288, 1048, 847, 413, 288, 327, 10901, 14, 32260, 14, 2242, 8, 1074, 12, 10565, 14, 16496, 360, 929, 6970, 8, 442, 11218, 291, 14, 1074, 6970, 9, 288, 1104, 14, 929, 6970, 14, 2242, 8, 277, 14, 1074, 6970, 9, 267, 291, 14, 1143, 5866, 14, 740, 8, 354, 9, 267, 291, 14, 1143, 12462, 14, 740, 779, 1302, 61, 435, 5920, 9, 5493, 347, 2813, 5810, 8, 277, 12, 536, 304, 267, 1962, 275, 291, 14, 1143, 5866, 14, 1080, 8, 354, 9, 267, 291, 14, 1753, 13405, 59, 354, 61, 275, 291, 14, 2117, 2223, 12047, 3838, 3488, 1143, 61, 221, 925, 3354, 367, 2945, 267, 291, 14, 1143, 5866, 14, 1935, 8, 1143, 9, 267, 367, 336, 315, 291, 14, 1143, 12462, 59, 1143, 2189, 288, 336, 14, 409, 6652, 8, 403, 9, 288, 327, 10901, 14, 32260, 14, 10673, 8, 87, 12, 10565, 14, 16496, 360, 929, 6970, 8, 442, 11218, 291, 14, 1074, 6970, 9, 288, 340, 1228, 8, 87, 12, 5928, 14, 49, 20530, 304, 355, 336, 14, 929, 6970, 14, 10673, 8, 277, 14, 1074, 6970, 9, 267, 291, 14, 1143, 12462, 14, 1935, 8, 1143, 9, 267, 367, 284, 315, 1425, 8, 1143, 12, 822, 8, 277, 14, 1143, 5866, 2298, 288, 11114, 275, 291, 14, 1143, 12462, 59, 73, 61, 288, 367, 1335, 315, 1425, 8, 552, 8, 8583, 2298, 355, 11114, 59, 74, 1055, 409, 6652, 8, 403, 9, 355, 291, 14, 4209, 14, 9475, 8, 8583, 59, 74, 467, 284, 11, 17, 12, 1335, 9, 339, 347, 1104, 6970, 8, 277, 12, 1174, 304, 267, 1104, 275, 10565, 14, 32260, 14, 8114, 8, 277, 9, 267, 327, 277, 14, 8159, 8, 10901, 14, 16496, 360, 929, 6970, 659, 1104, 14, 1143, 12, 1104, 14, 761, 12, 1174, 9, 267, 291, 14, 4093, 2223, 6970, 14, 8159, 8, 1074, 14, 1143, 12, 1104, 14, 761, 12, 1174, 9, 5493, 347, 3354, 2223, 8, 277, 304, 267, 4730, 275, 942, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1143, 5866, 2298, 288, 1962, 275, 359, 277, 14, 1143, 5866, 59, 73, 2677, 435, 359, 67, 14, 25374, 342, 367, 286, 315, 291, 14, 1143, 12462, 59, 73, 1527, 17, 21316, 288, 4730, 14, 740, 8, 1143, 9, 267, 372, 791, 4574, 356, 291, 14, 3406, 12, 283, 3838, 356, 4730, 93, 5493, 347, 9066, 2223, 8, 277, 12, 1174, 304, 267, 4730, 275, 359, 82, 59, 16, 61, 367, 519, 315, 1174, 459, 3838, 6538, 267, 291, 14, 873, 13405, 8, 3838, 9, 267, 367, 519, 315, 1174, 459, 3838, 2565, 288, 1962, 5667, 275, 291, 14, 1143, 5866, 14, 1080, 8, 82, 59, 16, 566, 288, 367, 284, 315, 1425, 8, 17, 12, 822, 8, 82, 2298, 355, 291, 14, 1143, 12462, 59, 1143, 5667, 1527, 73, 1055, 26657, 8, 82, 59, 73, 566, 1467, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2508, 4238, 492, 5928, 12, 10565, 199, 504, 1275, 492, 5444, 3294, 4314, 199, 199, 363, 452, 363, 275, 788, 1799, 3186, 418, 199, 199, 533, 2670, 3186, 8, 10604, 14, 23894, 304, 2286, 5259, 2223, 6970, 275, 10565, 14, 11274, 8, 785, 12, 909, 12, 909, 9, 327, 334, 1143, 12, 1048, 12, 1174, 9, 2286, 347, 636, 826, 721, 277, 12, 4362, 304, 267, 5928, 14, 23894, 855, 826, 721, 277, 9, 267, 291, 14, 4209, 275, 5928, 14, 49, 7900, 4798, 342, 267, 291, 14, 4209, 14, 409, 24052, 8, 16, 9, 267, 291, 14, 409, 4798, 8, 277, 14, 4209, 9, 267, 291, 14, 2139, 275, 942, 267, 291, 14, 3406, 275, 4362, 267, 1048, 275, 413, 267, 367, 286, 315, 4362, 26, 288, 1768, 275, 5444, 3294, 4314, 14, 19462, 4314, 8, 67, 12, 16774, 534, 7870, 358, 288, 291, 14, 2139, 14, 740, 8, 1302, 9, 288, 291, 14, 4209, 14, 9475, 8, 1302, 12, 378, 12, 1048, 9, 288, 1048, 847, 413, 2728, 291, 14, 1143, 5866, 275, 942, 267, 291, 14, 1143, 12462, 275, 942, 267, 291, 14, 1753, 13405, 275, 1052, 221, 925, 21027, 2202, 687, 4829, 4730, 27, 295, 4998, 340, 2985, 295, 27307, 14, 268, 339, 347, 1678, 13405, 8, 277, 12, 4730, 304, 267, 367, 519, 315, 291, 14, 1143, 5866, 32734, 288, 340, 519, 440, 315, 4730, 26, 355, 291, 14, 2168, 5810, 8, 82, 9, 267, 367, 519, 315, 4730, 26, 288, 340, 519, 440, 315, 291, 14, 1143, 5866, 26, 355, 291, 14, 525, 5810, 8, 82, 9, 339, 347, 1050, 5810, 8, 277, 12, 536, 304, 267, 1768, 275, 5928, 14, 19890, 8, 354, 9, 267, 1962, 275, 822, 8, 277, 14, 1143, 5866, 6393, 17, 267, 291, 14, 4209, 14, 9475, 8, 1302, 12, 1962, 12, 378, 9, 267, 5920, 275, 942, 267, 1048, 275, 413, 267, 367, 286, 315, 291, 14, 3406, 26, 288, 1104, 275, 5928, 14, 49, 20530, 8355, 288, 1104, 14, 761, 275, 286, 288, 1104, 14, 1143, 275, 536, 288, 291, 14, 4209, 14, 9475, 8, 1074, 12, 1962, 12, 1048, 9, 288, 5920, 14, 740, 8, 1074, 9, 288, 340, 536, 315, 291, 14, 1753, 13405, 26, 355, 1104, 14, 26657, 8, 277, 14, 1753, 13405, 59, 354, 1527, 761, 566, 288, 1048, 847, 413, 288, 327, 10901, 14, 32260, 14, 2242, 8, 1074, 12, 10565, 14, 16496, 360, 929, 6970, 8, 442, 11218, 291, 14, 1074, 6970, 9, 288, 1104, 14, 929, 6970, 14, 2242, 8, 277, 14, 1074, 6970, 9, 267, 291, 14, 1143, 5866, 14, 740, 8, 354, 9, 267, 291, 14, 1143, 12462, 14, 740, 779, 1302, 61, 435, 5920, 9, 5493, 347, 2813, 5810, 8, 277, 12, 536, 304, 267, 1962, 275, 291, 14, 1143, 5866, 14, 1080, 8, 354, 9, 267, 291, 14, 1753, 13405, 59, 354, 61, 275, 291, 14, 2117, 2223, 12047, 3838, 3488, 1143, 61, 221, 925, 3354, 367, 2945, 267, 291, 14, 1143, 5866, 14, 1935, 8, 1143, 9, 267, 367, 336, 315, 291, 14, 1143, 12462, 59, 1143, 2189, 288, 336, 14, 409, 6652, 8, 403, 9, 288, 327, 10901, 14, 32260, 14, 10673, 8, 87, 12, 10565, 14, 16496, 360, 929, 6970, 8, 442, 11218, 291, 14, 1074, 6970, 9, 288, 340, 1228, 8, 87, 12, 5928, 14, 49, 20530, 304, 355, 336, 14, 929, 6970, 14, 10673, 8, 277, 14, 1074, 6970, 9, 267, 291, 14, 1143, 12462, 14, 1935, 8, 1143, 9, 267, 367, 284, 315, 1425, 8, 1143, 12, 822, 8, 277, 14, 1143, 5866, 2298, 288, 11114, 275, 291, 14, 1143, 12462, 59, 73, 61, 288, 367, 1335, 315, 1425, 8, 552, 8, 8583, 2298, 355, 11114, 59, 74, 1055, 409, 6652, 8, 403, 9, 355, 291, 14, 4209, 14, 9475, 8, 8583, 59, 74, 467, 284, 11, 17, 12, 1335, 9, 339, 347, 1104, 6970, 8, 277, 12, 1174, 304, 267, 1104, 275, 10565, 14, 32260, 14, 8114, 8, 277, 9, 267, 327, 277, 14, 8159, 8, 10901, 14, 16496, 360, 929, 6970, 659, 1104, 14, 1143, 12, 1104, 14, 761, 12, 1174, 9, 267, 291, 14, 4093, 2223, 6970, 14, 8159, 8, 1074, 14, 1143, 12, 1104, 14, 761, 12, 1174, 9, 5493, 347, 3354, 2223, 8, 277, 304, 267, 4730, 275, 942, 267, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1143, 5866, 2298, 288, 1962, 275, 359, 277, 14, 1143, 5866, 59, 73, 2677, 435, 359, 67, 14, 25374, 342, 367, 286, 315, 291, 14, 1143, 12462, 59, 73, 1527, 17, 21316, 288, 4730, 14, 740, 8, 1143, 9, 267, 372, 791, 4574, 356, 291, 14, 3406, 12, 283, 3838, 356, 4730, 93, 5493, 347, 9066, 2223, 8, 277, 12, 1174, 304, 267, 4730, 275, 359, 82, 59, 16, 61, 367, 519, 315, 1174, 459, 3838, 6538, 267, 291, 14, 873, 13405, 8, 3838, 9, 267, 367, 519, 315, 1174, 459, 3838, 2565, 288, 1962, 5667, 275, 291, 14, 1143, 5866, 14, 1080, 8, 82, 59, 16, 566, 288, 367, 284, 315, 1425, 8, 17, 12, 822, 8, 82, 2298, 355, 291, 14, 1143, 12462, 59, 1143, 5667, 1527, 73, 1055, 26657, 8, 82, 59, 73, 566, 1467, 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, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dya2/python-for-android
python3-alpha/python3-src/Lib/test/crashers/gc_inspection.py
195
1092
""" gc.get_referrers() can be used to see objects before they are fully built. Note that this is only an example. There are many ways to crash Python by using gc.get_referrers(), as well as many extension modules (even when they are using perfectly documented patterns to build objects). Identifying and removing all places that expose to the GC a partially-built object is a long-term project. A patch was proposed on SF specifically for this example but I consider fixing just this single example a bit pointless (#1517042). A fix would include a whole-scale code review, possibly with an API change to decouple object creation and GC registration, and according fixes to the documentation for extension module writers. It's unlikely to happen, though. So this is currently classified as "gc.get_referrers() is dangerous, use only for debugging". """ import gc def g(): marker = object() yield marker # now the marker is in the tuple being constructed [tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple] print(tup) print(tup[1]) tuple(g())
apache-2.0
[ 624, 199, 9493, 14, 362, 63, 21928, 21105, 342, 883, 506, 1202, 370, 1937, 2251, 2544, 2985, 787, 9999, 6137, 14, 199, 199, 7443, 626, 642, 365, 1454, 376, 2893, 14, 221, 6006, 787, 5002, 15217, 370, 12420, 2018, 199, 991, 1808, 9486, 14, 362, 63, 21928, 21105, 1062, 465, 5521, 465, 5002, 3329, 4621, 334, 12056, 199, 6526, 2985, 787, 1808, 23668, 590, 22751, 7970, 370, 1900, 2251, 680, 199, 199, 17062, 3338, 316, 436, 12881, 1006, 9825, 626, 23705, 370, 314, 31555, 282, 199, 462, 9406, 13, 11730, 909, 365, 282, 1846, 13, 5125, 2199, 14, 221, 437, 3371, 1990, 14075, 641, 199, 13107, 22543, 367, 642, 2893, 1325, 473, 11201, 5325, 316, 2951, 642, 2849, 199, 2694, 282, 4546, 2376, 2003, 15196, 1046, 1196, 13011, 680, 199, 199, 33, 5325, 3955, 2387, 282, 8852, 13, 3467, 1233, 11248, 12, 12570, 543, 376, 3261, 199, 1461, 370, 477, 17600, 909, 7143, 436, 31555, 10991, 12, 436, 7182, 199, 26205, 370, 314, 3794, 367, 3329, 859, 2211, 878, 14, 221, 2779, 1159, 625, 24227, 199, 475, 5992, 12, 10617, 14, 221, 2002, 642, 365, 5544, 11534, 1290, 465, 199, 2, 9493, 14, 362, 63, 21928, 21105, 342, 365, 366, 21480, 12, 675, 1454, 367, 10201, 1674, 199, 624, 199, 199, 646, 9486, 421, 199, 318, 486, 837, 272, 3608, 275, 909, 342, 272, 1995, 3608, 272, 327, 3063, 314, 3608, 365, 315, 314, 2008, 3769, 14701, 272, 359, 17034, 61, 275, 359, 88, 367, 671, 315, 9486, 14, 362, 63, 21928, 21105, 8, 4211, 9, 340, 730, 8, 88, 9, 365, 2008, 61, 272, 870, 8, 17034, 9, 272, 870, 8, 17034, 59, 17, 566, 421, 199, 2960, 8, 71, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9493, 14, 362, 63, 21928, 21105, 342, 883, 506, 1202, 370, 1937, 2251, 2544, 2985, 787, 9999, 6137, 14, 199, 199, 7443, 626, 642, 365, 1454, 376, 2893, 14, 221, 6006, 787, 5002, 15217, 370, 12420, 2018, 199, 991, 1808, 9486, 14, 362, 63, 21928, 21105, 1062, 465, 5521, 465, 5002, 3329, 4621, 334, 12056, 199, 6526, 2985, 787, 1808, 23668, 590, 22751, 7970, 370, 1900, 2251, 680, 199, 199, 17062, 3338, 316, 436, 12881, 1006, 9825, 626, 23705, 370, 314, 31555, 282, 199, 462, 9406, 13, 11730, 909, 365, 282, 1846, 13, 5125, 2199, 14, 221, 437, 3371, 1990, 14075, 641, 199, 13107, 22543, 367, 642, 2893, 1325, 473, 11201, 5325, 316, 2951, 642, 2849, 199, 2694, 282, 4546, 2376, 2003, 15196, 1046, 1196, 13011, 680, 199, 199, 33, 5325, 3955, 2387, 282, 8852, 13, 3467, 1233, 11248, 12, 12570, 543, 376, 3261, 199, 1461, 370, 477, 17600, 909, 7143, 436, 31555, 10991, 12, 436, 7182, 199, 26205, 370, 314, 3794, 367, 3329, 859, 2211, 878, 14, 221, 2779, 1159, 625, 24227, 199, 475, 5992, 12, 10617, 14, 221, 2002, 642, 365, 5544, 11534, 1290, 465, 199, 2, 9493, 14, 362, 63, 21928, 21105, 342, 365, 366, 21480, 12, 675, 1454, 367, 10201, 1674, 199, 624, 199, 199, 646, 9486, 421, 199, 318, 486, 837, 272, 3608, 275, 909, 342, 272, 1995, 3608, 272, 327, 3063, 314, 3608, 365, 315, 314, 2008, 3769, 14701, 272, 359, 17034, 61, 275, 359, 88, 367, 671, 315, 9486, 14, 362, 63, 21928, 21105, 8, 4211, 9, 340, 730, 8, 88, 9, 365, 2008, 61, 272, 870, 8, 17034, 9, 272, 870, 8, 17034, 59, 17, 566, 421, 199, 2960, 8, 71, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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Liggins/fitting
first.py
1
7031
import copy import echidna import echidna.output.plot as plot import echidna.core.spectra as spectra from echidna.output import store import matplotlib.pyplot as plt import argparse import glob import numpy as np import os def convertor(path): flist=np.array(glob.glob(path)) for ntuple in flist: os.system("python ~/echidna/echidna/scripts/dump_spectra_ntuple.py -c ~/workspace/PhD/fitting/config.yml -f "+ str(ntuple)+" -s hdf5/") def combinerNtuple(path,filename): flist=np.array(glob.glob(path)) print flist first = True for hdf5 in flist: print hdf5 if first: spectrum1 = store.fill_from_ntuple(hdf5) first = False else: spectrum2 = store.fill_from_ntuple(hdf5) spectrum1.add(spectrum2) store.dump(filename, spectrum1) def combiner(path,filename): flist=np.array(glob.glob(path)) print flist first = True for hdf5 in flist: print hdf5 if first: spectrum1 = store.load(hdf5) first = False else: spectrum2 = store.load(hdf5) spectrum1.add(spectrum2) store.dump(filename, spectrum1) """The way you should do it is to define a lot of spectra and then plot them. You don't really know how to normlise the histrogram or indeed weather that is of any uses in the first place. """ def slicer(spectrumPath,filler,nslice): for i in range(nslice): spectrum=store.load(spectrumPath) print spectrum.sum() shrink_dict = {"energy_reco_low": 0., "energy_reco_high": 0.6, "radial_reco_low": i*6000.0/nslice, "radial_reco_high": (i+1)*6000/nslice} spectrum.cut(**shrink_dict) spectrum.scale(1) spec2=copy.copy(spectrum) spec2._name=str(i*1000)+"mm to "+str((i+1)*1000)+"mm" print type(spec2) filler.append(spec2) def slicerMC(spectrumPath,filler,nslice): for i in range(nslice): spectrum=store.load(spectrumPath) print spectrum.sum() shrink_dict = {"energy_mc_low": 0., "energy_mc_high": 1, "radial_mc_low": i*6000.0/nslice, "radial_mc_high": (i+1)*6000/nslice} spectrum.cut(**shrink_dict) spectrum.scale(1) spec2=copy.copy(spectrum) spec2._name="MC" print type(spec2) print "This gives the number os events in each window:" print "mc : "+str(i*6000.0/nslice)+"mm to "+str((i+1)*6000.0/nslice)+"mm : "+str(spec2.sum()) filler.append(spec2) def slicerReco(spectrumPath,filler,nslice): for i in range(nslice): spectrum=store.load(spectrumPath) print spectrum.sum() shrink_dict = {"energy_reco_low": 0., "energy_reco_high": 1., "radial_reco_low": i*6000.0/nslice, "radial_reco_high": (i+1)*6000/nslice} spectrum.cut(**shrink_dict) spectrum.scale(1) spec2=copy.copy(spectrum) spec2._name="Reco" print type(spec2) print "This gives the number os events in each window:" print "reco : "+str(i*6000.0/nslice)+"mm to "+str((i+1)*6000.0/nslice)+"mm : "+str(spec2.sum()) filler.append(spec2) def signalPlotter(spectra,dim,name): i=0 for spec in spectra: fig = plt.figure() ax= fig.add_subplot(1,1,1) par = spec.get_config().get_par(dim) width = par.get_width() bins = np.linspace(par._low,par._high, par._bins+1) x = bins[:-1] + 0.5*width plt.xlabel(str(dim)+ " [" + par.get_unit() + "]") plt.ylabel("Events per " + str(width) + " " + par.get_unit() + " bin") ax.set(title="Normalised energy spectrum in "+str(i*1000)+"mm to "+str((i+1)*1000)+"mm ",ylabel="Events per " + str(width) + " " + par.get_unit() + " bin", xlabel=str(dim)+" [" + par.get_unit() + "]") ax.hist(x,bins,weights=spec.project(dim),histtype="stepfilled", color="RoyalBlue",label=spec._name) fig.savefig("slice_"+str(name)+"_"+str(i*1000)+"_"+str((i+1)*1000)+".png") i=1+i def combiPlotter(spectra,dim,name): i=0 fig = plt.figure() ax= fig.add_subplot(1,1,1) for spec in spectra: par = spec.get_config().get_par(dim) width = par.get_width() bins = np.linspace(par._low,par._high, par._bins+1) x = bins[:-1] + 0.5*width plt.xlabel(str(dim)+ " [" + par.get_unit() + "]") plt.ylabel("Events per " + str(width) + " " + par.get_unit() + " bin") ax.set(title="Normalised energy spectrum in 1000mm slices",ylabel="Events per " + str(width) + " " + par.get_unit() + " bin", xlabel="energy_reco"+ " [" + par.get_unit() + "]") ax.hist(x,bins,weights=spec.project("energy_reco"),label=spec._name,histtype='step') ax.set_ylim([0,0.03]) ax.set_xlim([0.2,0.7]) ax.legend(loc="best") fig.savefig("combined_"+str(name)+".png") def func(path,nslice,name): spectra=[] slicer(path,spectra,nslice) signalPlotter(spectra,"energy_reco",name) combiPlotter(spectra,"energy_reco",name) def po210(): convertor("po210_ntuple/*") combiner("hdf5/SolarPo**ntuple*","hdf5/SolarPo210_combined.hdf5") plotpath="plots/" func("hdf5/SolarPo210_combined.hdf5",6,"po210") def bi210(): convertor("bi210_ntuple/*") combiner("hdf5/SolarBi**ntuple*","hdf5/SolarBi210_combined.hdf5") plotpath="plots/" func("hdf5/SolarBi210_combined.hdf5",6,"bi210") def compair(spectrumPathReco,spectrumPathMC,name): spectraReco=[] spectraMC=[] slicerReco(spectrumPathReco,spectraReco,6) slicerMC(spectrumPathMC,spectraMC,6) for i in range(0,len(spectraReco)): fig = plt.figure() ax= fig.add_subplot(1,1,1) par = spectraReco[i].get_config().get_par("energy_reco") width = par.get_width() bins = np.linspace(par._low,par._high, par._bins+1) x = bins[:-1] + 0.5*width ax.set(title="Normalised energy spectrum in "+str(i*1000)+"mm to "+str((i+1)*1000)+"mm ",ylabel="Events per " + str(width) + " " + par.get_unit() + " bin", xlabel="Energy [" + par.get_unit() + "]") ax.hist(x,bins,weights=spectraReco[i].project("energy_reco"),histtype="stepfilled",label=spectraReco[i]._name) par = spectraMC[i].get_config().get_par("energy_mc") width = par.get_width() bins = np.linspace(par._low,par._high, par._bins+1) x = bins[:-1] + 0.5*width ax.hist(x,bins,weights=spectraMC[i].project("energy_mc"),histtype="stepfilled",label=spectraMC[i]._name,alpha=0.75) ax.legend(loc=2) fig.savefig("compare_"+str(name)+"_"+str(i*1000)+"_"+str((i+1)*1000)+".png") if __name__=="__main__": print "You need to compare the recon against the mc" print "You should bin in bigger bins becuase you could then bin in 4d" """You need to plot the standard spectra"""
mit
[ 646, 1331, 199, 646, 325, 335, 344, 3540, 199, 646, 325, 335, 344, 3540, 14, 1199, 14, 2798, 465, 5137, 199, 646, 325, 335, 344, 3540, 14, 1018, 14, 20865, 345, 465, 30900, 345, 199, 504, 325, 335, 344, 3540, 14, 1199, 492, 3877, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 7534, 199, 646, 5739, 199, 646, 2680, 465, 980, 199, 646, 747, 199, 199, 318, 3957, 269, 8, 515, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 367, 302, 2960, 315, 28579, 26, 267, 747, 14, 2253, 480, 1548, 6146, 15, 12736, 344, 3540, 15, 12736, 344, 3540, 15, 6429, 15, 2724, 63, 20865, 345, 63, 343, 1363, 14, 647, 446, 67, 6146, 15, 13249, 15, 5663, 36, 15, 3269, 1337, 15, 888, 14, 11714, 446, 70, 7210, 620, 8, 343, 1363, 18663, 446, 83, 394, 1587, 21, 13589, 1362, 199, 318, 5300, 16187, 46, 2960, 8, 515, 12, 1501, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 870, 28579, 272, 1642, 275, 715, 272, 367, 394, 1587, 21, 315, 28579, 26, 267, 870, 394, 1587, 21, 267, 340, 1642, 26, 288, 20645, 17, 275, 3877, 14, 4498, 63, 504, 63, 343, 1363, 8, 19912, 21, 9, 288, 1642, 275, 756, 267, 587, 26, 288, 20645, 18, 275, 3877, 14, 4498, 63, 504, 63, 343, 1363, 8, 19912, 21, 9, 288, 20645, 17, 14, 525, 8, 18142, 18, 9, 272, 3877, 14, 2724, 8, 1501, 12, 20645, 17, 9, 4388, 199, 318, 5300, 16187, 8, 515, 12, 1501, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 870, 28579, 272, 1642, 275, 715, 272, 367, 394, 1587, 21, 315, 28579, 26, 267, 870, 394, 1587, 21, 267, 340, 1642, 26, 288, 20645, 17, 275, 3877, 14, 912, 8, 19912, 21, 9, 288, 1642, 275, 756, 267, 587, 26, 288, 20645, 18, 275, 3877, 14, 912, 8, 19912, 21, 9, 288, 20645, 17, 14, 525, 8, 18142, 18, 9, 272, 3877, 14, 2724, 8, 1501, 12, 20645, 17, 9, 421, 199, 624, 1918, 4340, 1265, 1077, 886, 652, 365, 370, 5627, 282, 13918, 402, 30900, 345, 436, 2066, 5137, 3062, 14, 272, 2047, 2793, 1133, 7710, 5715, 4212, 370, 6316, 317, 261, 314, 13612, 293, 1679, 503, 31043, 379, 29643, 626, 365, 402, 1263, 4440, 315, 314, 1642, 272, 4192, 14, 221, 199, 624, 199, 199, 318, 308, 27975, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 264, 331, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 264, 331, 63, 6260, 582, 378, 14, 22, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 29, 495, 8, 73, 10, 5279, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 5279, 18663, 596, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 199, 199, 318, 308, 27975, 7608, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 5466, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 5466, 63, 6260, 582, 413, 12, 1993, 298, 12841, 279, 63, 5466, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 5466, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 628, 7608, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 870, 298, 2765, 10557, 314, 1329, 747, 4474, 315, 1924, 4353, 5424, 2126, 870, 298, 5466, 520, 7210, 495, 8, 73, 10, 32623, 14, 16, 15, 561, 3037, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 32623, 14, 16, 15, 561, 3037, 18663, 596, 520, 7210, 495, 8, 1650, 18, 14, 1838, 1012, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 199, 199, 318, 308, 27975, 497, 331, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 264, 331, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 264, 331, 63, 6260, 582, 413, 2020, 1993, 298, 12841, 279, 63, 264, 331, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 628, 497, 331, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 870, 298, 2765, 10557, 314, 1329, 747, 4474, 315, 1924, 4353, 5424, 2126, 870, 298, 264, 331, 520, 7210, 495, 8, 73, 10, 32623, 14, 16, 15, 561, 3037, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 32623, 14, 16, 15, 561, 3037, 18663, 596, 520, 7210, 495, 8, 1650, 18, 14, 1838, 1012, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 421, 199, 318, 4673, 10711, 351, 8, 20865, 345, 12, 3572, 12, 354, 304, 272, 284, 29, 16, 272, 367 ]
[ 1331, 199, 646, 325, 335, 344, 3540, 199, 646, 325, 335, 344, 3540, 14, 1199, 14, 2798, 465, 5137, 199, 646, 325, 335, 344, 3540, 14, 1018, 14, 20865, 345, 465, 30900, 345, 199, 504, 325, 335, 344, 3540, 14, 1199, 492, 3877, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 7534, 199, 646, 5739, 199, 646, 2680, 465, 980, 199, 646, 747, 199, 199, 318, 3957, 269, 8, 515, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 367, 302, 2960, 315, 28579, 26, 267, 747, 14, 2253, 480, 1548, 6146, 15, 12736, 344, 3540, 15, 12736, 344, 3540, 15, 6429, 15, 2724, 63, 20865, 345, 63, 343, 1363, 14, 647, 446, 67, 6146, 15, 13249, 15, 5663, 36, 15, 3269, 1337, 15, 888, 14, 11714, 446, 70, 7210, 620, 8, 343, 1363, 18663, 446, 83, 394, 1587, 21, 13589, 1362, 199, 318, 5300, 16187, 46, 2960, 8, 515, 12, 1501, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 870, 28579, 272, 1642, 275, 715, 272, 367, 394, 1587, 21, 315, 28579, 26, 267, 870, 394, 1587, 21, 267, 340, 1642, 26, 288, 20645, 17, 275, 3877, 14, 4498, 63, 504, 63, 343, 1363, 8, 19912, 21, 9, 288, 1642, 275, 756, 267, 587, 26, 288, 20645, 18, 275, 3877, 14, 4498, 63, 504, 63, 343, 1363, 8, 19912, 21, 9, 288, 20645, 17, 14, 525, 8, 18142, 18, 9, 272, 3877, 14, 2724, 8, 1501, 12, 20645, 17, 9, 4388, 199, 318, 5300, 16187, 8, 515, 12, 1501, 304, 272, 28579, 29, 1590, 14, 1144, 8, 6463, 14, 6463, 8, 515, 430, 272, 870, 28579, 272, 1642, 275, 715, 272, 367, 394, 1587, 21, 315, 28579, 26, 267, 870, 394, 1587, 21, 267, 340, 1642, 26, 288, 20645, 17, 275, 3877, 14, 912, 8, 19912, 21, 9, 288, 1642, 275, 756, 267, 587, 26, 288, 20645, 18, 275, 3877, 14, 912, 8, 19912, 21, 9, 288, 20645, 17, 14, 525, 8, 18142, 18, 9, 272, 3877, 14, 2724, 8, 1501, 12, 20645, 17, 9, 421, 199, 624, 1918, 4340, 1265, 1077, 886, 652, 365, 370, 5627, 282, 13918, 402, 30900, 345, 436, 2066, 5137, 3062, 14, 272, 2047, 2793, 1133, 7710, 5715, 4212, 370, 6316, 317, 261, 314, 13612, 293, 1679, 503, 31043, 379, 29643, 626, 365, 402, 1263, 4440, 315, 314, 1642, 272, 4192, 14, 221, 199, 624, 199, 199, 318, 308, 27975, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 264, 331, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 264, 331, 63, 6260, 582, 378, 14, 22, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 29, 495, 8, 73, 10, 5279, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 5279, 18663, 596, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 199, 199, 318, 308, 27975, 7608, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 5466, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 5466, 63, 6260, 582, 413, 12, 1993, 298, 12841, 279, 63, 5466, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 5466, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 628, 7608, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 870, 298, 2765, 10557, 314, 1329, 747, 4474, 315, 1924, 4353, 5424, 2126, 870, 298, 5466, 520, 7210, 495, 8, 73, 10, 32623, 14, 16, 15, 561, 3037, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 32623, 14, 16, 15, 561, 3037, 18663, 596, 520, 7210, 495, 8, 1650, 18, 14, 1838, 1012, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 199, 199, 318, 308, 27975, 497, 331, 8, 18142, 2042, 12, 1289, 1435, 12, 561, 3037, 304, 272, 367, 284, 315, 1425, 8, 561, 3037, 304, 2126, 20645, 29, 1617, 14, 912, 8, 18142, 2042, 9, 2126, 870, 20645, 14, 1838, 342, 2126, 19790, 63, 807, 275, 2420, 8443, 63, 264, 331, 63, 674, 582, 378, 2020, 1993, 298, 8443, 63, 264, 331, 63, 6260, 582, 413, 2020, 1993, 298, 12841, 279, 63, 264, 331, 63, 674, 582, 284, 10, 32623, 14, 16, 15, 561, 3037, 12, 1993, 298, 12841, 279, 63, 264, 331, 63, 6260, 582, 334, 73, 11, 17, 3342, 32623, 15, 561, 3037, 93, 2126, 20645, 14, 5919, 3682, 23733, 63, 807, 9, 2126, 20645, 14, 3467, 8, 17, 9, 2126, 3158, 18, 29, 1574, 14, 1574, 8, 18142, 9, 2126, 3158, 18, 423, 354, 628, 497, 331, 2, 2126, 870, 730, 8, 1650, 18, 9, 2126, 870, 298, 2765, 10557, 314, 1329, 747, 4474, 315, 1924, 4353, 5424, 2126, 870, 298, 264, 331, 520, 7210, 495, 8, 73, 10, 32623, 14, 16, 15, 561, 3037, 18663, 596, 370, 7210, 495, 1332, 73, 11, 17, 3342, 32623, 14, 16, 15, 561, 3037, 18663, 596, 520, 7210, 495, 8, 1650, 18, 14, 1838, 1012, 2126, 1794, 1435, 14, 740, 8, 1650, 18, 9, 421, 199, 318, 4673, 10711, 351, 8, 20865, 345, 12, 3572, 12, 354, 304, 272, 284, 29, 16, 272, 367, 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 ]
MichaelNedzelsky/intellij-community
python/lib/Lib/stat.py
145
1667
"""Constants/functions for interpreting results of os.stat() and os.lstat(). Suggested usage: from stat import * """ # XXX Strictly spoken, this module may have to be adapted for each POSIX # implementation; in practice, however, the numeric constants used by # stat() are almost universal (even for stat() emulations on non-UNIX # systems like MS-DOS). # Indices for stat struct members in tuple returned by os.stat() ST_MODE = 0 ST_INO = 1 ST_DEV = 2 ST_NLINK = 3 ST_UID = 4 ST_GID = 5 ST_SIZE = 6 ST_ATIME = 7 ST_MTIME = 8 ST_CTIME = 9 # Extract bits from the mode def S_IMODE(mode): return mode & 07777 def S_IFMT(mode): return mode & 0170000 # Constants used as S_IFMT() for various file types # (not all are implemented on all systems) S_IFDIR = 0040000 S_IFCHR = 0020000 S_IFBLK = 0060000 S_IFREG = 0100000 S_IFIFO = 0010000 S_IFLNK = 0120000 S_IFSOCK = 0140000 # Functions to test for each file type def S_ISDIR(mode): return S_IFMT(mode) == S_IFDIR def S_ISCHR(mode): return S_IFMT(mode) == S_IFCHR def S_ISBLK(mode): return S_IFMT(mode) == S_IFBLK def S_ISREG(mode): return S_IFMT(mode) == S_IFREG def S_ISFIFO(mode): return S_IFMT(mode) == S_IFIFO def S_ISLNK(mode): return S_IFMT(mode) == S_IFLNK def S_ISSOCK(mode): return S_IFMT(mode) == S_IFSOCK # Names for permission bits S_ISUID = 04000 S_ISGID = 02000 S_ENFMT = S_ISGID S_ISVTX = 01000 S_IREAD = 00400 S_IWRITE = 00200 S_IEXEC = 00100 S_IRWXU = 00700 S_IRUSR = 00400 S_IWUSR = 00200 S_IXUSR = 00100 S_IRWXG = 00070 S_IRGRP = 00040 S_IWGRP = 00020 S_IXGRP = 00010 S_IRWXO = 00007 S_IROTH = 00004 S_IWOTH = 00002 S_IXOTH = 00001
apache-2.0
[ 624, 22185, 15, 5777, 367, 6421, 1337, 2058, 402, 747, 14, 3736, 342, 436, 747, 14, 26956, 1252, 199, 199, 51, 17417, 4503, 26, 687, 5672, 492, 627, 199, 624, 199, 199, 3, 5787, 23052, 590, 25664, 917, 12, 642, 859, 1443, 1172, 370, 506, 26266, 367, 1924, 18169, 199, 3, 4514, 27, 315, 24471, 12, 13432, 12, 314, 8950, 5262, 1202, 701, 199, 3, 5672, 342, 787, 18871, 17508, 334, 12056, 367, 5672, 342, 17423, 1298, 641, 2222, 13, 19584, 199, 3, 10460, 2839, 14282, 13, 32735, 680, 199, 199, 3, 1010, 12503, 367, 5672, 2702, 7556, 315, 2008, 2138, 701, 747, 14, 3736, 342, 199, 199, 840, 63, 6963, 221, 275, 378, 199, 840, 63, 568, 47, 257, 275, 413, 199, 840, 63, 13260, 257, 275, 499, 199, 840, 63, 46, 7916, 275, 650, 199, 840, 63, 6685, 257, 275, 841, 199, 840, 63, 39, 998, 257, 275, 959, 199, 840, 63, 4305, 221, 275, 1227, 199, 840, 63, 619, 3465, 275, 1520, 199, 840, 63, 45, 4961, 275, 1695, 199, 840, 63, 1028, 3465, 275, 1749, 199, 199, 3, 12892, 5821, 687, 314, 818, 199, 199, 318, 428, 63, 1469, 9125, 8, 632, 304, 272, 372, 818, 1253, 378, 16713, 199, 199, 318, 428, 63, 4656, 5747, 8, 632, 304, 272, 372, 818, 1253, 378, 1196, 993, 199, 199, 3, 22296, 1202, 465, 428, 63, 4656, 5747, 342, 367, 7750, 570, 2943, 199, 3, 334, 1397, 1006, 787, 6366, 641, 1006, 10460, 9, 199, 199, 51, 63, 4656, 3022, 221, 275, 378, 966, 993, 199, 51, 63, 4656, 1244, 50, 221, 275, 378, 996, 993, 199, 51, 63, 4656, 7847, 43, 221, 275, 378, 1690, 993, 199, 51, 63, 4656, 5616, 221, 275, 378, 15274, 199, 51, 63, 11100, 3230, 221, 275, 378, 614, 993, 199, 51, 63, 41, 3143, 22780, 221, 275, 378, 713, 993, 199, 51, 63, 4656, 9469, 275, 378, 1079, 993, 199, 199, 3, 17471, 370, 511, 367, 1924, 570, 730, 199, 199, 318, 428, 63, 1311, 3022, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 3022, 199, 199, 318, 428, 63, 1311, 1244, 50, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 1244, 50, 199, 199, 318, 428, 63, 1311, 7847, 43, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 7847, 43, 199, 199, 318, 428, 63, 1311, 5616, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 5616, 199, 199, 318, 428, 63, 1311, 20925, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 11100, 3230, 199, 199, 318, 428, 63, 1311, 44, 22780, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 41, 3143, 22780, 199, 199, 318, 428, 63, 1311, 9469, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 9469, 199, 199, 3, 23923, 367, 4983, 5821, 199, 199, 51, 63, 1311, 6685, 275, 378, 23641, 199, 51, 63, 1311, 39, 998, 275, 378, 8269, 199, 51, 63, 742, 22831, 275, 428, 63, 1311, 39, 998, 199, 51, 63, 1311, 8156, 56, 275, 378, 5279, 199, 51, 63, 41, 5670, 275, 378, 27130, 199, 51, 63, 41, 10387, 275, 378, 24215, 199, 51, 63, 41, 10276, 275, 378, 16569, 199, 51, 63, 3927, 16783, 53, 275, 378, 1780, 383, 199, 51, 63, 3927, 22592, 275, 378, 27130, 199, 51, 63, 22275, 22592, 275, 378, 24215, 199, 51, 63, 3867, 22592, 275, 378, 16569, 199, 51, 63, 3927, 16783, 39, 275, 21551, 2760, 199, 51, 63, 3927, 3975, 48, 275, 21551, 2167, 199, 51, 63, 22275, 3975, 48, 275, 378, 20734, 199, 51, 63, 3867, 3975, 48, 275, 378, 17657, 199, 51, 63, 3927, 16783, 47, 275, 378, 22530, 199, 51, 63, 41, 1092, 2080, 275, 378, 16643, 199, 51, 63, 22275, 22949, 275, 378, 9425, 199, 51, 63, 3867, 22949, 275, 378, 4183, 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 ]
[ 22185, 15, 5777, 367, 6421, 1337, 2058, 402, 747, 14, 3736, 342, 436, 747, 14, 26956, 1252, 199, 199, 51, 17417, 4503, 26, 687, 5672, 492, 627, 199, 624, 199, 199, 3, 5787, 23052, 590, 25664, 917, 12, 642, 859, 1443, 1172, 370, 506, 26266, 367, 1924, 18169, 199, 3, 4514, 27, 315, 24471, 12, 13432, 12, 314, 8950, 5262, 1202, 701, 199, 3, 5672, 342, 787, 18871, 17508, 334, 12056, 367, 5672, 342, 17423, 1298, 641, 2222, 13, 19584, 199, 3, 10460, 2839, 14282, 13, 32735, 680, 199, 199, 3, 1010, 12503, 367, 5672, 2702, 7556, 315, 2008, 2138, 701, 747, 14, 3736, 342, 199, 199, 840, 63, 6963, 221, 275, 378, 199, 840, 63, 568, 47, 257, 275, 413, 199, 840, 63, 13260, 257, 275, 499, 199, 840, 63, 46, 7916, 275, 650, 199, 840, 63, 6685, 257, 275, 841, 199, 840, 63, 39, 998, 257, 275, 959, 199, 840, 63, 4305, 221, 275, 1227, 199, 840, 63, 619, 3465, 275, 1520, 199, 840, 63, 45, 4961, 275, 1695, 199, 840, 63, 1028, 3465, 275, 1749, 199, 199, 3, 12892, 5821, 687, 314, 818, 199, 199, 318, 428, 63, 1469, 9125, 8, 632, 304, 272, 372, 818, 1253, 378, 16713, 199, 199, 318, 428, 63, 4656, 5747, 8, 632, 304, 272, 372, 818, 1253, 378, 1196, 993, 199, 199, 3, 22296, 1202, 465, 428, 63, 4656, 5747, 342, 367, 7750, 570, 2943, 199, 3, 334, 1397, 1006, 787, 6366, 641, 1006, 10460, 9, 199, 199, 51, 63, 4656, 3022, 221, 275, 378, 966, 993, 199, 51, 63, 4656, 1244, 50, 221, 275, 378, 996, 993, 199, 51, 63, 4656, 7847, 43, 221, 275, 378, 1690, 993, 199, 51, 63, 4656, 5616, 221, 275, 378, 15274, 199, 51, 63, 11100, 3230, 221, 275, 378, 614, 993, 199, 51, 63, 41, 3143, 22780, 221, 275, 378, 713, 993, 199, 51, 63, 4656, 9469, 275, 378, 1079, 993, 199, 199, 3, 17471, 370, 511, 367, 1924, 570, 730, 199, 199, 318, 428, 63, 1311, 3022, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 3022, 199, 199, 318, 428, 63, 1311, 1244, 50, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 1244, 50, 199, 199, 318, 428, 63, 1311, 7847, 43, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 7847, 43, 199, 199, 318, 428, 63, 1311, 5616, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 5616, 199, 199, 318, 428, 63, 1311, 20925, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 11100, 3230, 199, 199, 318, 428, 63, 1311, 44, 22780, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 41, 3143, 22780, 199, 199, 318, 428, 63, 1311, 9469, 8, 632, 304, 272, 372, 428, 63, 4656, 5747, 8, 632, 9, 508, 428, 63, 4656, 9469, 199, 199, 3, 23923, 367, 4983, 5821, 199, 199, 51, 63, 1311, 6685, 275, 378, 23641, 199, 51, 63, 1311, 39, 998, 275, 378, 8269, 199, 51, 63, 742, 22831, 275, 428, 63, 1311, 39, 998, 199, 51, 63, 1311, 8156, 56, 275, 378, 5279, 199, 51, 63, 41, 5670, 275, 378, 27130, 199, 51, 63, 41, 10387, 275, 378, 24215, 199, 51, 63, 41, 10276, 275, 378, 16569, 199, 51, 63, 3927, 16783, 53, 275, 378, 1780, 383, 199, 51, 63, 3927, 22592, 275, 378, 27130, 199, 51, 63, 22275, 22592, 275, 378, 24215, 199, 51, 63, 3867, 22592, 275, 378, 16569, 199, 51, 63, 3927, 16783, 39, 275, 21551, 2760, 199, 51, 63, 3927, 3975, 48, 275, 21551, 2167, 199, 51, 63, 22275, 3975, 48, 275, 378, 20734, 199, 51, 63, 3867, 3975, 48, 275, 378, 17657, 199, 51, 63, 3927, 16783, 47, 275, 378, 22530, 199, 51, 63, 41, 1092, 2080, 275, 378, 16643, 199, 51, 63, 22275, 22949, 275, 378, 9425, 199, 51, 63, 3867, 22949, 275, 378, 4183, 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, 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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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 ]
Widiot/simpleblog
venv/lib/python3.5/site-packages/pip/_vendor/retrying.py
934
9972
## Copyright 2013-2014 Ray Holder ## ## 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 random from pip._vendor import six import sys import time import traceback # sys.maxint / 2, since Python 3.2 doesn't have a sys.maxint... MAX_WAIT = 1073741823 def retry(*dargs, **dkw): """ Decorator function that instantiates the Retrying object @param *dargs: positional arguments passed to Retrying object @param **dkw: keyword arguments passed to the Retrying object """ # support both @retry and @retry() as valid syntax if len(dargs) == 1 and callable(dargs[0]): def wrap_simple(f): @six.wraps(f) def wrapped_f(*args, **kw): return Retrying().call(f, *args, **kw) return wrapped_f return wrap_simple(dargs[0]) else: def wrap(f): @six.wraps(f) def wrapped_f(*args, **kw): return Retrying(*dargs, **dkw).call(f, *args, **kw) return wrapped_f return wrap class Retrying(object): def __init__(self, stop=None, wait=None, stop_max_attempt_number=None, stop_max_delay=None, wait_fixed=None, wait_random_min=None, wait_random_max=None, wait_incrementing_start=None, wait_incrementing_increment=None, wait_exponential_multiplier=None, wait_exponential_max=None, retry_on_exception=None, retry_on_result=None, wrap_exception=False, stop_func=None, wait_func=None, wait_jitter_max=None): self._stop_max_attempt_number = 5 if stop_max_attempt_number is None else stop_max_attempt_number self._stop_max_delay = 100 if stop_max_delay is None else stop_max_delay self._wait_fixed = 1000 if wait_fixed is None else wait_fixed self._wait_random_min = 0 if wait_random_min is None else wait_random_min self._wait_random_max = 1000 if wait_random_max is None else wait_random_max self._wait_incrementing_start = 0 if wait_incrementing_start is None else wait_incrementing_start self._wait_incrementing_increment = 100 if wait_incrementing_increment is None else wait_incrementing_increment self._wait_exponential_multiplier = 1 if wait_exponential_multiplier is None else wait_exponential_multiplier self._wait_exponential_max = MAX_WAIT if wait_exponential_max is None else wait_exponential_max self._wait_jitter_max = 0 if wait_jitter_max is None else wait_jitter_max # TODO add chaining of stop behaviors # stop behavior stop_funcs = [] if stop_max_attempt_number is not None: stop_funcs.append(self.stop_after_attempt) if stop_max_delay is not None: stop_funcs.append(self.stop_after_delay) if stop_func is not None: self.stop = stop_func elif stop is None: self.stop = lambda attempts, delay: any(f(attempts, delay) for f in stop_funcs) else: self.stop = getattr(self, stop) # TODO add chaining of wait behaviors # wait behavior wait_funcs = [lambda *args, **kwargs: 0] if wait_fixed is not None: wait_funcs.append(self.fixed_sleep) if wait_random_min is not None or wait_random_max is not None: wait_funcs.append(self.random_sleep) if wait_incrementing_start is not None or wait_incrementing_increment is not None: wait_funcs.append(self.incrementing_sleep) if wait_exponential_multiplier is not None or wait_exponential_max is not None: wait_funcs.append(self.exponential_sleep) if wait_func is not None: self.wait = wait_func elif wait is None: self.wait = lambda attempts, delay: max(f(attempts, delay) for f in wait_funcs) else: self.wait = getattr(self, wait) # retry on exception filter if retry_on_exception is None: self._retry_on_exception = self.always_reject else: self._retry_on_exception = retry_on_exception # TODO simplify retrying by Exception types # retry on result filter if retry_on_result is None: self._retry_on_result = self.never_reject else: self._retry_on_result = retry_on_result self._wrap_exception = wrap_exception def stop_after_attempt(self, previous_attempt_number, delay_since_first_attempt_ms): """Stop after the previous attempt >= stop_max_attempt_number.""" return previous_attempt_number >= self._stop_max_attempt_number def stop_after_delay(self, previous_attempt_number, delay_since_first_attempt_ms): """Stop after the time from the first attempt >= stop_max_delay.""" return delay_since_first_attempt_ms >= self._stop_max_delay def no_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): """Don't sleep at all before retrying.""" return 0 def fixed_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): """Sleep a fixed amount of time between each retry.""" return self._wait_fixed def random_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): """Sleep a random amount of time between wait_random_min and wait_random_max""" return random.randint(self._wait_random_min, self._wait_random_max) def incrementing_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): """ Sleep an incremental amount of time after each attempt, starting at wait_incrementing_start and incrementing by wait_incrementing_increment """ result = self._wait_incrementing_start + (self._wait_incrementing_increment * (previous_attempt_number - 1)) if result < 0: result = 0 return result def exponential_sleep(self, previous_attempt_number, delay_since_first_attempt_ms): exp = 2 ** previous_attempt_number result = self._wait_exponential_multiplier * exp if result > self._wait_exponential_max: result = self._wait_exponential_max if result < 0: result = 0 return result def never_reject(self, result): return False def always_reject(self, result): return True def should_reject(self, attempt): reject = False if attempt.has_exception: reject |= self._retry_on_exception(attempt.value[1]) else: reject |= self._retry_on_result(attempt.value) return reject def call(self, fn, *args, **kwargs): start_time = int(round(time.time() * 1000)) attempt_number = 1 while True: try: attempt = Attempt(fn(*args, **kwargs), attempt_number, False) except: tb = sys.exc_info() attempt = Attempt(tb, attempt_number, True) if not self.should_reject(attempt): return attempt.get(self._wrap_exception) delay_since_first_attempt_ms = int(round(time.time() * 1000)) - start_time if self.stop(attempt_number, delay_since_first_attempt_ms): if not self._wrap_exception and attempt.has_exception: # get() on an attempt with an exception should cause it to be raised, but raise just in case raise attempt.get() else: raise RetryError(attempt) else: sleep = self.wait(attempt_number, delay_since_first_attempt_ms) if self._wait_jitter_max: jitter = random.random() * self._wait_jitter_max sleep = sleep + max(0, jitter) time.sleep(sleep / 1000.0) attempt_number += 1 class Attempt(object): """ An Attempt encapsulates a call to a target function that may end as a normal return value from the function or an Exception depending on what occurred during the execution. """ def __init__(self, value, attempt_number, has_exception): self.value = value self.attempt_number = attempt_number self.has_exception = has_exception def get(self, wrap_exception=False): """ Return the return value of this Attempt instance or raise an Exception. If wrap_exception is true, this Attempt is wrapped inside of a RetryError before being raised. """ if self.has_exception: if wrap_exception: raise RetryError(self) else: six.reraise(self.value[0], self.value[1], self.value[2]) else: return self.value def __repr__(self): if self.has_exception: return "Attempts: {0}, Error:\n{1}".format(self.attempt_number, "".join(traceback.format_tb(self.value[2]))) else: return "Attempts: {0}, Value: {1}".format(self.attempt_number, self.value) class RetryError(Exception): """ A RetryError encapsulates the last Attempt instance right before giving up. """ def __init__(self, last_attempt): self.last_attempt = last_attempt def __str__(self): return "RetryError[{0}]".format(self.last_attempt)
mit
[ 309, 1898, 6171, 13, 7280, 30703, 869, 2149, 199, 309, 199, 309, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 309, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 309, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 309, 199, 309, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 309, 199, 309, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 309, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 309, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 309, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 309, 4204, 1334, 314, 844, 14, 199, 199, 646, 2196, 199, 504, 7305, 423, 9884, 492, 3816, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 421, 199, 3, 984, 14, 21411, 1182, 499, 12, 3967, 2018, 650, 14, 18, 3181, 1133, 1172, 282, 984, 14, 21411, 1396, 199, 4283, 63, 12458, 275, 1616, 28403, 1085, 1789, 421, 199, 318, 7269, 2031, 31895, 12, 1011, 68, 829, 304, 272, 408, 272, 30684, 805, 626, 9034, 2335, 314, 20506, 316, 909, 272, 768, 635, 627, 31895, 26, 11333, 2368, 3032, 370, 20506, 316, 909, 272, 768, 635, 1011, 68, 829, 26, 4252, 2368, 3032, 370, 314, 20506, 316, 909, 272, 408, 272, 327, 2291, 3865, 768, 7154, 436, 768, 7154, 342, 465, 1686, 6302, 272, 340, 822, 8, 31895, 9, 508, 413, 436, 4550, 8, 31895, 59, 16, 4682, 267, 347, 4816, 63, 4129, 8, 70, 304, 953, 768, 4174, 14, 13582, 8, 70, 9, 288, 347, 8072, 63, 70, 2031, 589, 12, 1011, 829, 304, 355, 372, 20506, 316, 1252, 1250, 8, 70, 12, 627, 589, 12, 1011, 829, 9, 953, 372, 8072, 63, 70, 398, 372, 4816, 63, 4129, 8, 31895, 59, 16, 566, 339, 587, 26, 267, 347, 4816, 8, 70, 304, 953, 768, 4174, 14, 13582, 8, 70, 9, 288, 347, 8072, 63, 70, 2031, 589, 12, 1011, 829, 304, 355, 372, 20506, 316, 2031, 31895, 12, 1011, 68, 829, 680, 1250, 8, 70, 12, 627, 589, 12, 1011, 829, 9, 953, 372, 8072, 63, 70, 398, 372, 4816, 421, 199, 533, 20506, 316, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 326, 3631, 29, 403, 12, 3618, 29, 403, 12, 326, 3631, 63, 988, 63, 16880, 63, 1955, 29, 403, 12, 326, 3631, 63, 988, 63, 5814, 29, 403, 12, 326, 3618, 63, 5964, 29, 403, 12, 326, 3618, 63, 2355, 63, 827, 29, 403, 12, 3618, 63, 2355, 63, 988, 29, 403, 12, 326, 3618, 63, 9728, 316, 63, 928, 29, 403, 12, 3618, 63, 9728, 316, 63, 9728, 29, 403, 12, 326, 3618, 63, 27093, 63, 15812, 29, 403, 12, 3618, 63, 27093, 63, 988, 29, 403, 12, 326, 7269, 63, 265, 63, 1971, 29, 403, 12, 326, 7269, 63, 265, 63, 1099, 29, 403, 12, 326, 4816, 63, 1971, 29, 797, 12, 326, 3631, 63, 1532, 29, 403, 12, 326, 3618, 63, 1532, 29, 403, 12, 326, 3618, 63, 17676, 351, 63, 988, 29, 403, 304, 398, 291, 423, 2379, 63, 988, 63, 16880, 63, 1955, 275, 959, 340, 3631, 63, 988, 63, 16880, 63, 1955, 365, 488, 587, 3631, 63, 988, 63, 16880, 63, 1955, 267, 291, 423, 2379, 63, 988, 63, 5814, 275, 2948, 340, 3631, 63, 988, 63, 5814, 365, 488, 587, 3631, 63, 988, 63, 5814, 267, 291, 423, 2573, 63, 5964, 275, 5198, 340, 3618, 63, 5964, 365, 488, 587, 3618, 63, 5964, 267, 291, 423, 2573, 63, 2355, 63, 827, 275, 378, 340, 3618, 63, 2355, 63, 827, 365, 488, 587, 3618, 63, 2355, 63, 827, 267, 291, 423, 2573, 63, 2355, 63, 988, 275, 5198, 340, 3618, 63, 2355, 63, 988, 365, 488, 587, 3618, 63, 2355, 63, 988, 267, 291, 423, 2573, 63, 9728, 316, 63, 928, 275, 378, 340, 3618, 63, 9728, 316, 63, 928, 365, 488, 587, 3618, 63, 9728, 316, 63, 928, 267, 291, 423, 2573, 63, 9728, 316, 63, 9728, 275, 2948, 340, 3618, 63, 9728, 316, 63, 9728, 365, 488, 587, 3618, 63, 9728, 316, 63, 9728, 267, 291, 423, 2573, 63, 27093, 63, 15812, 275, 413, 340, 3618, 63, 27093, 63, 15812, 365, 488, 587, 3618, 63, 27093, 63, 15812, 267, 291, 423, 2573, 63, 27093, 63, 988, 275, 9141, 63, 12458, 340, 3618, 63, 27093, 63, 988, 365, 488, 587, 3618, 63, 27093, 63, 988, 267, 291, 423, 2573, 63, 17676, 351, 63, 988, 275, 378, 340, 3618, 63, 17676, 351, 63, 988, 365, 488, 587, 3618, 63, 17676, 351, 63, 988, 398, 327, 3254, 1050, 6036, 316, 402, 3631, 5112, 1384, 267, 327, 3631, 5953, 267, 3631, 63, 9204, 275, 942, 267, 340, 3631, 63, 988, 63, 16880, 63, 1955, 365, 440, 488, 26, 288, 3631, 63, 9204, 14, 740, 8, 277, 14, 2379, 63, 4399, 63, 16880, 9, 398, 340, 3631, 63, 988, 63, 5814, 365, 440, 488, 26, 288, 3631, 63, 9204, 14, 740, 8, 277, 14, 2379, 63, 4399, 63, 5814, 9, 398, 340, 3631, 63, 1532, 365, 440, 488, 26, 288, 291, 14, 2379, 275, 3631, 63, 1532, 398, 916, 3631, 365, 488, 26, 288, 291, 14, 2379, 275, 2400, 12454, 12, 7339, 26, 1263, 8, 70, 8, 13143, 12, 7339, 9, 367, 289, 315, 3631, 63, 9204, 9, 398, 587, 26, 288, 291, 14, 2379, 275, 2519, 8, 277, 12, 3631, 9, 398, 327, 3254, 1050, 6036, 316, 402, 3618, 5112, 1384, 267, 327, 3618, 5953, 267, 3618, 63, 9204, 275, 359, 2734, 627, 589, 12, 1011, 958, 26, 378, 61, 267, 340, 3618, 63, 5964, 365, 440, 488, 26, 288, 3618, 63, 9204, 14, 740, 8, 277, 14, 5964, 63, 4532, 9, 398, 340, 3618, 63, 2355, 63, 827, 365, 440, 488, 503, 3618, 63, 2355, 63, 988, 365, 440, 488, 26, 288, 3618, 63, 9204, 14, 740, 8, 277, 14, 2355, 63, 4532, 9, 398, 340, 3618, 63, 9728, 316, 63, 928, 365, 440, 488, 503, 3618, 63, 9728, 316 ]
[ 1898, 6171, 13, 7280, 30703, 869, 2149, 199, 309, 199, 309, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 309, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 309, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 309, 199, 309, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 309, 199, 309, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 309, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 309, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 309, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 309, 4204, 1334, 314, 844, 14, 199, 199, 646, 2196, 199, 504, 7305, 423, 9884, 492, 3816, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 421, 199, 3, 984, 14, 21411, 1182, 499, 12, 3967, 2018, 650, 14, 18, 3181, 1133, 1172, 282, 984, 14, 21411, 1396, 199, 4283, 63, 12458, 275, 1616, 28403, 1085, 1789, 421, 199, 318, 7269, 2031, 31895, 12, 1011, 68, 829, 304, 272, 408, 272, 30684, 805, 626, 9034, 2335, 314, 20506, 316, 909, 272, 768, 635, 627, 31895, 26, 11333, 2368, 3032, 370, 20506, 316, 909, 272, 768, 635, 1011, 68, 829, 26, 4252, 2368, 3032, 370, 314, 20506, 316, 909, 272, 408, 272, 327, 2291, 3865, 768, 7154, 436, 768, 7154, 342, 465, 1686, 6302, 272, 340, 822, 8, 31895, 9, 508, 413, 436, 4550, 8, 31895, 59, 16, 4682, 267, 347, 4816, 63, 4129, 8, 70, 304, 953, 768, 4174, 14, 13582, 8, 70, 9, 288, 347, 8072, 63, 70, 2031, 589, 12, 1011, 829, 304, 355, 372, 20506, 316, 1252, 1250, 8, 70, 12, 627, 589, 12, 1011, 829, 9, 953, 372, 8072, 63, 70, 398, 372, 4816, 63, 4129, 8, 31895, 59, 16, 566, 339, 587, 26, 267, 347, 4816, 8, 70, 304, 953, 768, 4174, 14, 13582, 8, 70, 9, 288, 347, 8072, 63, 70, 2031, 589, 12, 1011, 829, 304, 355, 372, 20506, 316, 2031, 31895, 12, 1011, 68, 829, 680, 1250, 8, 70, 12, 627, 589, 12, 1011, 829, 9, 953, 372, 8072, 63, 70, 398, 372, 4816, 421, 199, 533, 20506, 316, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 326, 3631, 29, 403, 12, 3618, 29, 403, 12, 326, 3631, 63, 988, 63, 16880, 63, 1955, 29, 403, 12, 326, 3631, 63, 988, 63, 5814, 29, 403, 12, 326, 3618, 63, 5964, 29, 403, 12, 326, 3618, 63, 2355, 63, 827, 29, 403, 12, 3618, 63, 2355, 63, 988, 29, 403, 12, 326, 3618, 63, 9728, 316, 63, 928, 29, 403, 12, 3618, 63, 9728, 316, 63, 9728, 29, 403, 12, 326, 3618, 63, 27093, 63, 15812, 29, 403, 12, 3618, 63, 27093, 63, 988, 29, 403, 12, 326, 7269, 63, 265, 63, 1971, 29, 403, 12, 326, 7269, 63, 265, 63, 1099, 29, 403, 12, 326, 4816, 63, 1971, 29, 797, 12, 326, 3631, 63, 1532, 29, 403, 12, 326, 3618, 63, 1532, 29, 403, 12, 326, 3618, 63, 17676, 351, 63, 988, 29, 403, 304, 398, 291, 423, 2379, 63, 988, 63, 16880, 63, 1955, 275, 959, 340, 3631, 63, 988, 63, 16880, 63, 1955, 365, 488, 587, 3631, 63, 988, 63, 16880, 63, 1955, 267, 291, 423, 2379, 63, 988, 63, 5814, 275, 2948, 340, 3631, 63, 988, 63, 5814, 365, 488, 587, 3631, 63, 988, 63, 5814, 267, 291, 423, 2573, 63, 5964, 275, 5198, 340, 3618, 63, 5964, 365, 488, 587, 3618, 63, 5964, 267, 291, 423, 2573, 63, 2355, 63, 827, 275, 378, 340, 3618, 63, 2355, 63, 827, 365, 488, 587, 3618, 63, 2355, 63, 827, 267, 291, 423, 2573, 63, 2355, 63, 988, 275, 5198, 340, 3618, 63, 2355, 63, 988, 365, 488, 587, 3618, 63, 2355, 63, 988, 267, 291, 423, 2573, 63, 9728, 316, 63, 928, 275, 378, 340, 3618, 63, 9728, 316, 63, 928, 365, 488, 587, 3618, 63, 9728, 316, 63, 928, 267, 291, 423, 2573, 63, 9728, 316, 63, 9728, 275, 2948, 340, 3618, 63, 9728, 316, 63, 9728, 365, 488, 587, 3618, 63, 9728, 316, 63, 9728, 267, 291, 423, 2573, 63, 27093, 63, 15812, 275, 413, 340, 3618, 63, 27093, 63, 15812, 365, 488, 587, 3618, 63, 27093, 63, 15812, 267, 291, 423, 2573, 63, 27093, 63, 988, 275, 9141, 63, 12458, 340, 3618, 63, 27093, 63, 988, 365, 488, 587, 3618, 63, 27093, 63, 988, 267, 291, 423, 2573, 63, 17676, 351, 63, 988, 275, 378, 340, 3618, 63, 17676, 351, 63, 988, 365, 488, 587, 3618, 63, 17676, 351, 63, 988, 398, 327, 3254, 1050, 6036, 316, 402, 3631, 5112, 1384, 267, 327, 3631, 5953, 267, 3631, 63, 9204, 275, 942, 267, 340, 3631, 63, 988, 63, 16880, 63, 1955, 365, 440, 488, 26, 288, 3631, 63, 9204, 14, 740, 8, 277, 14, 2379, 63, 4399, 63, 16880, 9, 398, 340, 3631, 63, 988, 63, 5814, 365, 440, 488, 26, 288, 3631, 63, 9204, 14, 740, 8, 277, 14, 2379, 63, 4399, 63, 5814, 9, 398, 340, 3631, 63, 1532, 365, 440, 488, 26, 288, 291, 14, 2379, 275, 3631, 63, 1532, 398, 916, 3631, 365, 488, 26, 288, 291, 14, 2379, 275, 2400, 12454, 12, 7339, 26, 1263, 8, 70, 8, 13143, 12, 7339, 9, 367, 289, 315, 3631, 63, 9204, 9, 398, 587, 26, 288, 291, 14, 2379, 275, 2519, 8, 277, 12, 3631, 9, 398, 327, 3254, 1050, 6036, 316, 402, 3618, 5112, 1384, 267, 327, 3618, 5953, 267, 3618, 63, 9204, 275, 359, 2734, 627, 589, 12, 1011, 958, 26, 378, 61, 267, 340, 3618, 63, 5964, 365, 440, 488, 26, 288, 3618, 63, 9204, 14, 740, 8, 277, 14, 5964, 63, 4532, 9, 398, 340, 3618, 63, 2355, 63, 827, 365, 440, 488, 503, 3618, 63, 2355, 63, 988, 365, 440, 488, 26, 288, 3618, 63, 9204, 14, 740, 8, 277, 14, 2355, 63, 4532, 9, 398, 340, 3618, 63, 9728, 316, 63, 928, 365, 440, 488, 503, 3618, 63, 9728, 316, 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 ]
Kamp9/scipy
benchmarks/benchmarks/sparse_linalg_solve.py
52
1688
""" Check the speed of the conjugate gradient solver. """ from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import assert_equal try: from scipy import linalg, sparse from scipy.sparse.linalg import cg except ImportError: pass from .common import Benchmark def _create_sparse_poisson1d(n): # Make Gilbert Strang's favorite matrix # http://www-math.mit.edu/~gs/PIX/cupcakematrix.jpg P1d = sparse.diags([[-1]*(n-1), [2]*n, [-1]*(n-1)], [-1, 0, 1]) assert_equal(P1d.shape, (n, n)) return P1d def _create_sparse_poisson2d(n): P1d = _create_sparse_poisson1d(n) P2d = sparse.kronsum(P1d, P1d) assert_equal(P2d.shape, (n*n, n*n)) return P2d class Bench(Benchmark): params = [ [4, 6, 10, 16, 25, 40, 64, 100, 160, 250, 400, 640, 1000, 1600], ['sparse', 'dense'] ] param_names = ['(n,n)', 'solver'] def setup(self, n, solver): dense_is_active = (n**2 < 600) sparse_is_active = (n**2 < 20000) if solver == 'dense' and not dense_is_active: raise NotImplementedError() if solver == 'sparse' and not sparse_is_active: raise NotImplementedError() self.b = np.ones(n*n) self.P_sparse = _create_sparse_poisson2d(n) self.P_dense = self.P_sparse.A def time_cg(self, n, solver): if solver == 'dense': linalg.solve(self.P_dense, self.b) else: cg(self.P_sparse, self.b) def time_spsolve(self, n, solver): if solver == 'dense': linalg.solve(self.P_dense, self.b) else: cg(self.P_sparse, self.b)
bsd-3-clause
[ 624, 199, 1799, 314, 8112, 402, 314, 27246, 6709, 10196, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1452, 199, 199, 893, 26, 272, 687, 7026, 492, 16727, 12, 5178, 272, 687, 7026, 14, 4421, 14, 10096, 492, 19711, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 1275, 2330, 492, 27067, 421, 199, 318, 485, 981, 63, 4421, 63, 29606, 17, 68, 8, 78, 304, 272, 327, 4155, 598, 382, 12504, 8303, 621, 1159, 17914, 1175, 3634, 272, 327, 1455, 921, 1544, 13, 3442, 14, 1147, 14, 8654, 22500, 458, 15, 18545, 15, 17500, 696, 415, 3642, 14, 8476, 272, 510, 17, 68, 275, 5178, 14, 2391, 458, 22844, 17, 3672, 8, 78, 13, 17, 395, 359, 18, 3672, 78, 12, 5243, 17, 3672, 8, 78, 13, 17, 4360, 5243, 17, 12, 378, 12, 413, 566, 272, 702, 63, 1452, 8, 48, 17, 68, 14, 1392, 12, 334, 78, 12, 302, 430, 272, 372, 510, 17, 68, 421, 199, 318, 485, 981, 63, 4421, 63, 29606, 18, 68, 8, 78, 304, 272, 510, 17, 68, 275, 485, 981, 63, 4421, 63, 29606, 17, 68, 8, 78, 9, 272, 510, 18, 68, 275, 5178, 14, 75, 2641, 1838, 8, 48, 17, 68, 12, 510, 17, 68, 9, 272, 702, 63, 1452, 8, 48, 18, 68, 14, 1392, 12, 334, 78, 10, 78, 12, 302, 10, 78, 430, 272, 372, 510, 18, 68, 421, 199, 533, 699, 5368, 8, 18644, 304, 272, 1862, 275, 359, 267, 359, 20, 12, 1227, 12, 1616, 12, 3193, 12, 5661, 12, 6335, 12, 5049, 12, 2948, 12, 21235, 12, 16074, 12, 8290, 12, 5049, 16, 12, 5198, 12, 3193, 383, 467, 267, 788, 4421, 297, 283, 7253, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 8, 78, 12, 78, 3196, 283, 11263, 418, 339, 347, 3272, 8, 277, 12, 302, 12, 10196, 304, 267, 9363, 63, 374, 63, 2682, 275, 334, 78, 538, 18, 665, 11624, 9, 267, 5178, 63, 374, 63, 2682, 275, 334, 78, 538, 18, 665, 499, 993, 9, 398, 340, 10196, 508, 283, 7253, 7, 436, 440, 9363, 63, 374, 63, 2682, 26, 288, 746, 4279, 342, 398, 340, 10196, 508, 283, 4421, 7, 436, 440, 5178, 63, 374, 63, 2682, 26, 288, 746, 4279, 342, 398, 291, 14, 66, 275, 980, 14, 4548, 8, 78, 10, 78, 9, 267, 291, 14, 48, 63, 4421, 275, 485, 981, 63, 4421, 63, 29606, 18, 68, 8, 78, 9, 267, 291, 14, 48, 63, 7253, 275, 291, 14, 48, 63, 4421, 14, 33, 339, 347, 900, 63, 12595, 8, 277, 12, 302, 12, 10196, 304, 267, 340, 10196, 508, 283, 7253, 356, 288, 16727, 14, 11356, 8, 277, 14, 48, 63, 7253, 12, 291, 14, 66, 9, 267, 587, 26, 288, 19711, 8, 277, 14, 48, 63, 4421, 12, 291, 14, 66, 9, 339, 347, 900, 63, 681, 11356, 8, 277, 12, 302, 12, 10196, 304, 267, 340, 10196, 508, 283, 7253, 356, 288, 16727, 14, 11356, 8, 277, 14, 48, 63, 7253, 12, 291, 14, 66, 9, 267, 587, 26, 288, 19711, 8, 277, 14, 48, 63, 4421, 12, 291, 14, 66, 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 ]
[ 199, 1799, 314, 8112, 402, 314, 27246, 6709, 10196, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1452, 199, 199, 893, 26, 272, 687, 7026, 492, 16727, 12, 5178, 272, 687, 7026, 14, 4421, 14, 10096, 492, 19711, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 1275, 2330, 492, 27067, 421, 199, 318, 485, 981, 63, 4421, 63, 29606, 17, 68, 8, 78, 304, 272, 327, 4155, 598, 382, 12504, 8303, 621, 1159, 17914, 1175, 3634, 272, 327, 1455, 921, 1544, 13, 3442, 14, 1147, 14, 8654, 22500, 458, 15, 18545, 15, 17500, 696, 415, 3642, 14, 8476, 272, 510, 17, 68, 275, 5178, 14, 2391, 458, 22844, 17, 3672, 8, 78, 13, 17, 395, 359, 18, 3672, 78, 12, 5243, 17, 3672, 8, 78, 13, 17, 4360, 5243, 17, 12, 378, 12, 413, 566, 272, 702, 63, 1452, 8, 48, 17, 68, 14, 1392, 12, 334, 78, 12, 302, 430, 272, 372, 510, 17, 68, 421, 199, 318, 485, 981, 63, 4421, 63, 29606, 18, 68, 8, 78, 304, 272, 510, 17, 68, 275, 485, 981, 63, 4421, 63, 29606, 17, 68, 8, 78, 9, 272, 510, 18, 68, 275, 5178, 14, 75, 2641, 1838, 8, 48, 17, 68, 12, 510, 17, 68, 9, 272, 702, 63, 1452, 8, 48, 18, 68, 14, 1392, 12, 334, 78, 10, 78, 12, 302, 10, 78, 430, 272, 372, 510, 18, 68, 421, 199, 533, 699, 5368, 8, 18644, 304, 272, 1862, 275, 359, 267, 359, 20, 12, 1227, 12, 1616, 12, 3193, 12, 5661, 12, 6335, 12, 5049, 12, 2948, 12, 21235, 12, 16074, 12, 8290, 12, 5049, 16, 12, 5198, 12, 3193, 383, 467, 267, 788, 4421, 297, 283, 7253, 418, 272, 1622, 272, 1215, 63, 1247, 275, 788, 8, 78, 12, 78, 3196, 283, 11263, 418, 339, 347, 3272, 8, 277, 12, 302, 12, 10196, 304, 267, 9363, 63, 374, 63, 2682, 275, 334, 78, 538, 18, 665, 11624, 9, 267, 5178, 63, 374, 63, 2682, 275, 334, 78, 538, 18, 665, 499, 993, 9, 398, 340, 10196, 508, 283, 7253, 7, 436, 440, 9363, 63, 374, 63, 2682, 26, 288, 746, 4279, 342, 398, 340, 10196, 508, 283, 4421, 7, 436, 440, 5178, 63, 374, 63, 2682, 26, 288, 746, 4279, 342, 398, 291, 14, 66, 275, 980, 14, 4548, 8, 78, 10, 78, 9, 267, 291, 14, 48, 63, 4421, 275, 485, 981, 63, 4421, 63, 29606, 18, 68, 8, 78, 9, 267, 291, 14, 48, 63, 7253, 275, 291, 14, 48, 63, 4421, 14, 33, 339, 347, 900, 63, 12595, 8, 277, 12, 302, 12, 10196, 304, 267, 340, 10196, 508, 283, 7253, 356, 288, 16727, 14, 11356, 8, 277, 14, 48, 63, 7253, 12, 291, 14, 66, 9, 267, 587, 26, 288, 19711, 8, 277, 14, 48, 63, 4421, 12, 291, 14, 66, 9, 339, 347, 900, 63, 681, 11356, 8, 277, 12, 302, 12, 10196, 304, 267, 340, 10196, 508, 283, 7253, 356, 288, 16727, 14, 11356, 8, 277, 14, 48, 63, 7253, 12, 291, 14, 66, 9, 267, 587, 26, 288, 19711, 8, 277, 14, 48, 63, 4421, 12, 291, 14, 66, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AirChen/MachineLearningDoc
collective_intelligence/chapter_7/treepredict.py
1
6590
#!/usr/bin/python from math import log from PIL import Image, ImageDraw my_data=[['slashdot','USA','yes',18,'None'], ['google','France','yes',23,'Premium'], ['digg','USA','yes',24,'Basic'], ['kiwitobes','France','yes',23,'Basic'], ['google','UK','no',21,'Premium'], ['(direct)','New Zealand','no',12,'None'], ['(direct)','UK','no',21,'Basic'], ['google','USA','no',24,'Premium'], ['slashdot','France','yes',19,'None'], ['digg','USA','no',18,'None'], ['google','UK','no',18,'None'], ['kiwitobes','UK','no',19,'None'], ['digg','New Zealand','yes',12,'Basic'], ['slashdot','UK','no',21,'None'], ['google','UK','yes',18,'Basic'], ['kiwitobes','France','yes',19,'Basic']] class decisionnode: def __init__(self, col = -1, value = None, results = None, tb = None, fb = None): self.col = col self.value = value self.results = results self.tb = tb self.fb = fb def divideset(rows, column, value): split_function = None if isinstance(value, int) or isinstance(value, float): split_function = lambda row:row[column] >= value else: split_function = lambda row:row[column] == value set1 = [row for row in rows if split_function(row)] set2 = [row for row in rows if not split_function(row)] return (set1, set2) def uniquecount(rows): results = {} for row in rows: r = row[len(row)-1] if r not in results: results[r] = 0 results[r] += 1 return results def giniimpurity(rows): total = len(rows) counts = uniquecount(rows) imp = 0.0 for k1 in counts: p1 = float(counts[k1])/total for k2 in counts: if k1 == k2: continue p2 = float(counts[k2])/total imp += p1*p2 return imp def entropy(rows): log2 = lambda x:log(x)/log(2) results = uniquecount(rows) total = len(rows) ent = 0.0 for k in results: p = float(results[k])/total ent = ent - p*log2(p) return ent def buildtree(rows, scoref=entropy): if len(rows) == 0: return decisionnode() current_score = scoref(rows) best_gain = 0.0 best_criteria = None best_sets = None column_count = len(rows[0])-1 for col in range(0, column_count): column_values = {} for row in rows: column_values[row[col]] = 1 for value in column_values.keys(): set1, set2 = divideset(rows, col, value) p = float(len(set1))/len(rows) gain = current_score - p * scoref(set1) - (1-p) * scoref(set2) if gain > best_gain and len(set1) > 0 and len(set2) > 0: best_gain = gain best_criteria = (col, value) best_sets = (set1, set2) if best_gain > 0.0: trueBranch = buildtree(best_sets[0]) falseBranch = buildtree(best_sets[1]) return decisionnode(col = best_criteria[0], value = best_criteria[1], tb = trueBranch, fb = falseBranch) else: return decisionnode(results = uniquecount(rows)) def printtree(tree, indent = ''): if tree.results != None: print str(tree.results) else: print str(tree.col) + ':' + str(tree.value) + '?' print indent + 'T->' printtree(tree.tb, indent+' ') print indent + 'F->' printtree(tree.fb, indent+' ') def getwidth(tree): if tree.tb == None and tree.fb == None: return 1 return getwidth(tree.tb) + getwidth(tree.fb) def getdepth(tree): if tree.tb == None and tree.fb == None: return 0 return max(getdepth(tree.tb),getdepth(tree.fb)) + 1 def drawtree(tree, jpeg = 'tree.jpg'): w = getwidth(tree)*100 h = getdepth(tree)*100+120 img = Image.new('RGB', (w,h), (255,255,255)) draw = ImageDraw.Draw(img) drawnode(draw, tree, w/2, 20) img.save(jpeg, 'JPEG') def drawnode(draw, tree, x, y): if tree.results == None: w1 = getwidth(tree.fb)*100 w2 = getwidth(tree.tb)*100 left = x - (w1+w2)/2 right = x + (w1+w2)/2 draw.text((x-20,y-10), str(tree.col) + ':' + str(tree.value),(0,0,0)) draw.line((x, y, left+w1/2, y+100), fill = (255, 0, 0)) draw.line((x, y, right-w2/2, y+100), fill = (255, 0, 0)) drawnode(draw, tree.fb, left+w1/2, y+100) drawnode(draw, tree.tb, right-w2/2, y+100) else: txt = ' \n'.join(['%s:%d'%v for v in tree.results.items()]) draw.text((x-20, y), txt, (0, 0, 0)) def classify(observation, tree): if tree.results != None: return tree.results else: v = observation[tree.col] branch = None if isinstance(v, int) or isinstance(v, float): if v >= tree.value: branch = tree.tb else: branch = tree.fb else: if v == tree.value: branch = tree.tb else: branch = tree.fb return classify(observation, branch) def prune(tree, mingain): if tree.tb.results == None: prune(tree.tb, mingain) if tree.fb.results == None: prune(tree.fb, mingain) if tree.tb.results != None and tree.fb.results != None: tb,fb = [],[] for v,c in tree.tb.results.items(): tb += [[v]]*c for v,c in tree.fb.results.items(): fb += [[v]]*c delta = entropy(tb+fb) - (entropy(tb) + entropy(fb)/2) if delta < mingain: tree.tb, tree.fb = None, None tree.results = uniquecount(tb + fb) def mdclassify(observation, tree): if tree.results != None: return tree.results else: v = observation[tree.col] if v == None: tr, fr = mdclassify(observation, tree.tb), mdclassify(observation, tree.fb) tcount = sum(tr.values()) fcount = sum(fr.values()) tw = float(tcount)/(tcount + fcount) fw = 1 - tw result = {} for k,v in tr.items(): result[k] = v*tw for k,v in fr.items(): if k not in result: result[k] = 0 result[k] += v*fw return result else: branch = None if isinstance(v, int) or isinstance(v, float): if v >= tree.value: branch = tree.tb else: branch = tree.fb else: else: branch = tree.fb if v == tree.value: branch = tree.tb return mdclassify(observation, branch) def variance(rows): if len(rows)==0: return 0 data = [float(row[len(row)-1]) for row in rows] mean = sum(data)/len(rows) variance = sum([(d - mean) ** 2 for d in data])/len(data) return variance if __name__ == "__main__": # print divideset(my_data, 3, 20) # print giniimpurity(my_data) # print entropy(my_data) # # print 'test' # set1, set2 = divideset(my_data, 2, 'yes') # print giniimpurity(set1) # print entropy(set2) tree = buildtree(my_data) # printtree(tree) # drawtree(tree, jpeg = 'treeview.jpg') # print classify(['(direct)', 'USA', 'yes', 5], tree) # prune(tree, 0.1) # printtree(tree) # print '-------------------' # prune(tree, 1.0) # printtree(tree) print mdclassify(['google', None, 'yes', None], tree) print '-------------------' print mdclassify(['google', 'France', None, None], tree)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 504, 3473, 492, 943, 199, 504, 14937, 492, 6047, 12, 6047, 9654, 199, 199, 1662, 63, 576, 1524, 459, 7001, 3287, 1673, 1668, 33, 1673, 5066, 297, 1085, 2584, 403, 995, 199, 198, 459, 3098, 1673, 13848, 554, 1673, 5066, 297, 1789, 2584, 2398, 23481, 995, 199, 198, 459, 328, 2721, 1673, 1668, 33, 1673, 5066, 297, 1194, 2584, 6845, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 13848, 554, 1673, 5066, 297, 1789, 2584, 6845, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 889, 297, 2025, 2584, 2398, 23481, 995, 199, 198, 459, 8, 2275, 9, 1673, 4665, 3107, 69, 279, 460, 1673, 889, 297, 713, 2584, 403, 995, 199, 198, 459, 8, 2275, 9, 1673, 26667, 1673, 889, 297, 2025, 2584, 6845, 995, 199, 198, 459, 3098, 1673, 1668, 33, 1673, 889, 297, 1194, 2584, 2398, 23481, 995, 199, 198, 459, 7001, 3287, 1673, 13848, 554, 1673, 5066, 297, 1167, 2584, 403, 995, 199, 198, 459, 328, 2721, 1673, 1668, 33, 1673, 889, 297, 1085, 2584, 403, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 889, 297, 1085, 2584, 403, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 26667, 1673, 889, 297, 1167, 2584, 403, 995, 199, 198, 459, 328, 2721, 1673, 4665, 3107, 69, 279, 460, 1673, 5066, 297, 713, 2584, 6845, 995, 199, 198, 459, 7001, 3287, 1673, 26667, 1673, 889, 297, 2025, 2584, 403, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 5066, 297, 1085, 2584, 6845, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 13848, 554, 1673, 5066, 297, 1167, 2584, 6845, 6538, 28550, 199, 533, 14692, 932, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1048, 275, 446, 17, 12, 574, 275, 488, 12, 2058, 275, 488, 12, 7070, 275, 488, 12, 24209, 275, 488, 304, 507, 198, 277, 14, 761, 275, 1048, 507, 198, 277, 14, 585, 275, 574, 507, 198, 277, 14, 2604, 275, 2058, 507, 198, 277, 14, 5842, 275, 7070, 507, 198, 277, 14, 4675, 275, 24209, 686, 199, 318, 23003, 409, 8, 3838, 12, 2763, 12, 574, 304, 199, 198, 1294, 63, 1593, 275, 488, 199, 198, 692, 1228, 8, 585, 12, 1109, 9, 503, 1228, 8, 585, 12, 2069, 304, 507, 198, 1294, 63, 1593, 275, 2400, 1962, 26, 1143, 59, 2301, 61, 2356, 574, 199, 198, 2836, 26, 507, 198, 1294, 63, 1593, 275, 2400, 1962, 26, 1143, 59, 2301, 61, 508, 574, 18118, 198, 409, 17, 275, 359, 1143, 367, 1962, 315, 4730, 340, 3715, 63, 1593, 8, 1143, 1874, 199, 198, 409, 18, 275, 359, 1143, 367, 1962, 315, 4730, 340, 440, 3715, 63, 1593, 8, 1143, 1874, 8299, 198, 1107, 334, 409, 17, 12, 663, 18, 9, 507, 199, 318, 3747, 835, 8, 3838, 304, 199, 198, 2604, 275, 1052, 199, 198, 509, 1962, 315, 4730, 26, 507, 198, 82, 275, 1962, 59, 552, 8, 1143, 7216, 17, 61, 507, 198, 692, 519, 440, 315, 2058, 26, 686, 198, 2604, 59, 82, 61, 275, 378, 507, 198, 2604, 59, 82, 61, 847, 413, 18118, 198, 1107, 2058, 507, 199, 318, 486, 2730, 3236, 5581, 8, 3838, 304, 199, 198, 2923, 275, 822, 8, 3838, 9, 199, 198, 6851, 275, 3747, 835, 8, 3838, 9, 199, 198, 3236, 275, 378, 14, 16, 199, 198, 509, 1022, 17, 315, 8242, 26, 507, 198, 80, 17, 275, 2069, 8, 6851, 59, 75, 17, 23067, 2923, 507, 198, 509, 1022, 18, 315, 8242, 26, 686, 198, 692, 1022, 17, 508, 1022, 18, 26, 1585, 198, 6958, 686, 198, 80, 18, 275, 2069, 8, 6851, 59, 75, 18, 23067, 2923, 686, 198, 3236, 847, 299, 17, 10, 80, 18, 1585, 199, 198, 1107, 1742, 507, 199, 318, 19490, 8, 3838, 304, 199, 198, 793, 18, 275, 2400, 671, 26, 793, 8, 88, 2447, 793, 8, 18, 9, 199, 198, 2604, 275, 3747, 835, 8, 3838, 9, 199, 198, 2923, 275, 822, 8, 3838, 9, 199, 198, 484, 275, 378, 14, 16, 199, 198, 509, 1022, 315, 2058, 26, 507, 198, 80, 275, 2069, 8, 2604, 59, 75, 23067, 2923, 507, 198, 484, 275, 15992, 446, 299, 10, 793, 18, 8, 80, 9, 18118, 198, 1107, 15992, 199, 199, 318, 1900, 2350, 8, 3838, 12, 5396, 70, 29, 10435, 304, 199, 198, 692, 822, 8, 3838, 9, 508, 378, 26, 507, 198, 1107, 14692, 932, 342, 199, 198, 1818, 63, 3397, 275, 5396, 70, 8, 3838, 9, 8299, 198, 7010, 63, 13020, 275, 378, 14, 16, 199, 198, 7010, 63, 20525, 275, 488, 199, 198, 7010, 63, 2193, 275, 488, 8299, 198, 2301, 63, 835, 275, 822, 8, 3838, 59, 16, 566, 13, 17, 199, 198, 509, 1048, 315, 1425, 8, 16, 12, 2763, 63, 835, 304, 507, 198, 2301, 63, 1459, 275, 1052, 507, 198, 509, 1962, 315, 4730, 26, 686, 198, 2301, 63, 1459, 59, 1143, 59, 761, 2677, 275, 413, 1585, 507, 198, 509, 574, 315, 2763, 63, 1459, 14, 1612, 837, 686, 198, 409, 17, 12, 663, 18, 275, 23003, 409, 8, 3838, 12, 1048, 12, 574, 9, 686, 198, 80, 275, 2069, 8, 552, 8, 409, 17, 13342, 552, 8, 3838, 9, 686, 198, 13020, 275, 1453, 63, 3397, 446, 299, 627, 5396, 70, 8, 409, 17, 9, 446, 334, 17, 13, 80, 9, 627, 5396, 70, 8, 409, 18, 9, 686, 198, 692, 15334, 690, 5526, 63, 13020, 436, 822, 8, 409, 17, 9, 690, 378, 436, 822, 8, 409, 18, 9, 690, 378, 26, 1585, 198, 7010, 63, 13020, 275, 15334, 1585, 198, 7010, 63, 20525, 275, 334, 761, 12, 574, 9, 1585, 198, 7010, 63, 2193, 275, 334, 409, 17, 12, 663, 18, 9, 421, 198, 692, 5526, 63, 13020, 690, 378, 14, 16, 26, 507, 198, 2052, 12526, 275, 1900, 2350, 8, 7010, 63, 2193, 59, 16, 566, 507, 198, 3910, 12526, 275, 1900, 2350, 8, 7010, 63, 2193, 59, 17, 566, 507, 198, 1107, 14692, 932, 8, 761, 275, 5526, 63, 20525, 59, 16, 467, 574, 275, 5526, 63, 20525, 59, 17, 467, 7070, 275, 2549, 12526, 12, 24209, 275, 3055, 12526, 9, 18118, 198, 2836, 26, 507, 198, 1107, 14692 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 504, 3473, 492, 943, 199, 504, 14937, 492, 6047, 12, 6047, 9654, 199, 199, 1662, 63, 576, 1524, 459, 7001, 3287, 1673, 1668, 33, 1673, 5066, 297, 1085, 2584, 403, 995, 199, 198, 459, 3098, 1673, 13848, 554, 1673, 5066, 297, 1789, 2584, 2398, 23481, 995, 199, 198, 459, 328, 2721, 1673, 1668, 33, 1673, 5066, 297, 1194, 2584, 6845, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 13848, 554, 1673, 5066, 297, 1789, 2584, 6845, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 889, 297, 2025, 2584, 2398, 23481, 995, 199, 198, 459, 8, 2275, 9, 1673, 4665, 3107, 69, 279, 460, 1673, 889, 297, 713, 2584, 403, 995, 199, 198, 459, 8, 2275, 9, 1673, 26667, 1673, 889, 297, 2025, 2584, 6845, 995, 199, 198, 459, 3098, 1673, 1668, 33, 1673, 889, 297, 1194, 2584, 2398, 23481, 995, 199, 198, 459, 7001, 3287, 1673, 13848, 554, 1673, 5066, 297, 1167, 2584, 403, 995, 199, 198, 459, 328, 2721, 1673, 1668, 33, 1673, 889, 297, 1085, 2584, 403, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 889, 297, 1085, 2584, 403, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 26667, 1673, 889, 297, 1167, 2584, 403, 995, 199, 198, 459, 328, 2721, 1673, 4665, 3107, 69, 279, 460, 1673, 5066, 297, 713, 2584, 6845, 995, 199, 198, 459, 7001, 3287, 1673, 26667, 1673, 889, 297, 2025, 2584, 403, 995, 199, 198, 459, 3098, 1673, 26667, 1673, 5066, 297, 1085, 2584, 6845, 995, 199, 198, 459, 8810, 2503, 2873, 397, 1673, 13848, 554, 1673, 5066, 297, 1167, 2584, 6845, 6538, 28550, 199, 533, 14692, 932, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1048, 275, 446, 17, 12, 574, 275, 488, 12, 2058, 275, 488, 12, 7070, 275, 488, 12, 24209, 275, 488, 304, 507, 198, 277, 14, 761, 275, 1048, 507, 198, 277, 14, 585, 275, 574, 507, 198, 277, 14, 2604, 275, 2058, 507, 198, 277, 14, 5842, 275, 7070, 507, 198, 277, 14, 4675, 275, 24209, 686, 199, 318, 23003, 409, 8, 3838, 12, 2763, 12, 574, 304, 199, 198, 1294, 63, 1593, 275, 488, 199, 198, 692, 1228, 8, 585, 12, 1109, 9, 503, 1228, 8, 585, 12, 2069, 304, 507, 198, 1294, 63, 1593, 275, 2400, 1962, 26, 1143, 59, 2301, 61, 2356, 574, 199, 198, 2836, 26, 507, 198, 1294, 63, 1593, 275, 2400, 1962, 26, 1143, 59, 2301, 61, 508, 574, 18118, 198, 409, 17, 275, 359, 1143, 367, 1962, 315, 4730, 340, 3715, 63, 1593, 8, 1143, 1874, 199, 198, 409, 18, 275, 359, 1143, 367, 1962, 315, 4730, 340, 440, 3715, 63, 1593, 8, 1143, 1874, 8299, 198, 1107, 334, 409, 17, 12, 663, 18, 9, 507, 199, 318, 3747, 835, 8, 3838, 304, 199, 198, 2604, 275, 1052, 199, 198, 509, 1962, 315, 4730, 26, 507, 198, 82, 275, 1962, 59, 552, 8, 1143, 7216, 17, 61, 507, 198, 692, 519, 440, 315, 2058, 26, 686, 198, 2604, 59, 82, 61, 275, 378, 507, 198, 2604, 59, 82, 61, 847, 413, 18118, 198, 1107, 2058, 507, 199, 318, 486, 2730, 3236, 5581, 8, 3838, 304, 199, 198, 2923, 275, 822, 8, 3838, 9, 199, 198, 6851, 275, 3747, 835, 8, 3838, 9, 199, 198, 3236, 275, 378, 14, 16, 199, 198, 509, 1022, 17, 315, 8242, 26, 507, 198, 80, 17, 275, 2069, 8, 6851, 59, 75, 17, 23067, 2923, 507, 198, 509, 1022, 18, 315, 8242, 26, 686, 198, 692, 1022, 17, 508, 1022, 18, 26, 1585, 198, 6958, 686, 198, 80, 18, 275, 2069, 8, 6851, 59, 75, 18, 23067, 2923, 686, 198, 3236, 847, 299, 17, 10, 80, 18, 1585, 199, 198, 1107, 1742, 507, 199, 318, 19490, 8, 3838, 304, 199, 198, 793, 18, 275, 2400, 671, 26, 793, 8, 88, 2447, 793, 8, 18, 9, 199, 198, 2604, 275, 3747, 835, 8, 3838, 9, 199, 198, 2923, 275, 822, 8, 3838, 9, 199, 198, 484, 275, 378, 14, 16, 199, 198, 509, 1022, 315, 2058, 26, 507, 198, 80, 275, 2069, 8, 2604, 59, 75, 23067, 2923, 507, 198, 484, 275, 15992, 446, 299, 10, 793, 18, 8, 80, 9, 18118, 198, 1107, 15992, 199, 199, 318, 1900, 2350, 8, 3838, 12, 5396, 70, 29, 10435, 304, 199, 198, 692, 822, 8, 3838, 9, 508, 378, 26, 507, 198, 1107, 14692, 932, 342, 199, 198, 1818, 63, 3397, 275, 5396, 70, 8, 3838, 9, 8299, 198, 7010, 63, 13020, 275, 378, 14, 16, 199, 198, 7010, 63, 20525, 275, 488, 199, 198, 7010, 63, 2193, 275, 488, 8299, 198, 2301, 63, 835, 275, 822, 8, 3838, 59, 16, 566, 13, 17, 199, 198, 509, 1048, 315, 1425, 8, 16, 12, 2763, 63, 835, 304, 507, 198, 2301, 63, 1459, 275, 1052, 507, 198, 509, 1962, 315, 4730, 26, 686, 198, 2301, 63, 1459, 59, 1143, 59, 761, 2677, 275, 413, 1585, 507, 198, 509, 574, 315, 2763, 63, 1459, 14, 1612, 837, 686, 198, 409, 17, 12, 663, 18, 275, 23003, 409, 8, 3838, 12, 1048, 12, 574, 9, 686, 198, 80, 275, 2069, 8, 552, 8, 409, 17, 13342, 552, 8, 3838, 9, 686, 198, 13020, 275, 1453, 63, 3397, 446, 299, 627, 5396, 70, 8, 409, 17, 9, 446, 334, 17, 13, 80, 9, 627, 5396, 70, 8, 409, 18, 9, 686, 198, 692, 15334, 690, 5526, 63, 13020, 436, 822, 8, 409, 17, 9, 690, 378, 436, 822, 8, 409, 18, 9, 690, 378, 26, 1585, 198, 7010, 63, 13020, 275, 15334, 1585, 198, 7010, 63, 20525, 275, 334, 761, 12, 574, 9, 1585, 198, 7010, 63, 2193, 275, 334, 409, 17, 12, 663, 18, 9, 421, 198, 692, 5526, 63, 13020, 690, 378, 14, 16, 26, 507, 198, 2052, 12526, 275, 1900, 2350, 8, 7010, 63, 2193, 59, 16, 566, 507, 198, 3910, 12526, 275, 1900, 2350, 8, 7010, 63, 2193, 59, 17, 566, 507, 198, 1107, 14692, 932, 8, 761, 275, 5526, 63, 20525, 59, 16, 467, 574, 275, 5526, 63, 20525, 59, 17, 467, 7070, 275, 2549, 12526, 12, 24209, 275, 3055, 12526, 9, 18118, 198, 2836, 26, 507, 198, 1107, 14692, 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, 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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 ]
audunv/andp
python/andp/view/web/remote.py
1
3288
# -*- coding: utf-8; -*- # Copyright (C) 2009 Østfold University College # # This file is part of ANDP. # # ANDP 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. """ This module handles the remote control interface """ import subprocess, cStringIO from PIL import Image, ImageDraw, ImageFont from mod_python import apache import andp.model.remote from andp.view.web import Page class RemoteQR(Page): """ Returns a QR code image, and records the client's address for remote-control callbacks """ path = "/remote/qr" showDebug = False fontPath = "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf" # Quite randomly chosen def Main(self): host = self.req.get_remote_host(apache.REMOTE_NOLOOKUP) andp.model.remote.RegisterClient(self.req, host) sessionID = andp.model.remote.SessionIDForHost(self.req, host) cmd = ("qrencode", "-s", "16", "-m", "0", "-o", "-") proc = subprocess.Popen(cmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE) uri = "http://%s.%s/%s" % (self.req.config["network"]["host"], self.req.config["network"]["domain"], sessionID) buf = cStringIO.StringIO(proc.communicate(uri)[0]) qrImage = Image.open(buf) font = ImageFont.truetype(self.fontPath, 64) # Big enough to scale down well bottomText = "%s.%s/%s" % (self.req.config["network"]["host"], self.req.config["network"]["domain"], sessionID) bottomImage = Image.new("RGB", font.getsize(bottomText), (0, 0, 0)) bottomDraw = ImageDraw.Draw(bottomImage) bottomDraw.text((0, 0), bottomText, font = font) del bottomDraw bottomImage = bottomImage.resize((qrImage.size[0], (float(qrImage.size[0]) / bottomImage.size[0]) * bottomImage.size[1]), Image.ANTIALIAS) compositeImage = Image.new("RGB", (qrImage.size[0], qrImage.size[1] + bottomImage.size[1]), (0, 0, 0)) compositeImage.paste(qrImage, (0, 0)) compositeImage.paste(bottomImage, (0, qrImage.size[1])) buf = cStringIO.StringIO() compositeImage.save(buf, "PNG") self.SendHeader(contentType = "image/png") self.Write(buf.getvalue()) return apache.OK class RemoteRemote(Page): """ Displays remote-control UI """ path = None # Hard-coded in handler.py :-/ def Main(self): sessionID = self.req.uri[1:5] host = andp.model.remote.HostBySessionID(self.req, sessionID) if not host: return apache.HTTP_NOT_FOUND self.SendHeader() self.Write("foo") return apache.OK
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 27, 1882, 199, 199, 3, 1898, 334, 35, 9, 8937, 13333, 247, 270, 14011, 15904, 3626, 274, 303, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 2401, 48, 14, 199, 3, 221, 199, 3, 2401, 48, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 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, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 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, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 199, 3, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 199, 199, 2765, 859, 10022, 314, 3982, 3304, 3217, 199, 199, 624, 199, 199, 646, 3873, 12, 15073, 199, 199, 504, 14937, 492, 6047, 12, 6047, 9654, 12, 6047, 6986, 199, 199, 504, 3413, 63, 1548, 492, 17098, 199, 199, 646, 436, 80, 14, 1238, 14, 3846, 199, 199, 504, 436, 80, 14, 1345, 14, 2520, 492, 10331, 199, 199, 533, 17283, 26779, 8, 3276, 304, 272, 408, 339, 1803, 282, 1413, 50, 1233, 1834, 12, 436, 5767, 314, 1890, 1159, 2287, 367, 272, 3982, 13, 2785, 13484, 2286, 408, 2286, 931, 275, 3286, 3846, 15, 16596, 2, 272, 2498, 7084, 275, 756, 272, 5023, 2042, 275, 3286, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 15, 32264, 13, 2075, 1745, 13, 422, 65, 15, 3673, 65, 14, 32264, 2, 327, 1413, 2577, 19311, 12414, 339, 347, 11298, 8, 277, 304, 267, 1591, 275, 291, 14, 2103, 14, 362, 63, 3846, 63, 1102, 8, 3796, 14, 16058, 63, 2826, 29149, 9, 398, 436, 80, 14, 1238, 14, 3846, 14, 7099, 3041, 8, 277, 14, 2103, 12, 1591, 9, 267, 2351, 998, 275, 436, 80, 14, 1238, 14, 3846, 14, 4434, 998, 1858, 4965, 8, 277, 14, 2103, 12, 1591, 9, 398, 2088, 275, 1689, 81, 25894, 401, 3905, 83, 401, 298, 975, 401, 3905, 77, 401, 298, 16, 401, 3905, 79, 401, 3905, 531, 267, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 9009, 275, 3873, 14, 6089, 12, 3839, 275, 3873, 14, 6089, 9, 398, 5108, 275, 298, 1014, 13827, 83, 4111, 83, 3149, 83, 2, 450, 334, 277, 14, 2103, 14, 888, 905, 1200, 6611, 1102, 2255, 291, 14, 2103, 14, 888, 905, 1200, 6611, 2261, 2255, 2351, 998, 9, 267, 4123, 275, 15073, 14, 6424, 8, 4687, 14, 10664, 8, 2302, 2788, 16, 566, 267, 29757, 3491, 275, 6047, 14, 1490, 8, 1436, 9, 398, 5023, 275, 6047, 6986, 14, 2052, 466, 8, 277, 14, 4246, 2042, 12, 5049, 9, 327, 13123, 8321, 370, 4666, 3224, 5521, 398, 9048, 1872, 275, 2071, 83, 4111, 83, 3149, 83, 2, 450, 334, 277, 14, 2103, 14, 888, 905, 1200, 6611, 1102, 2255, 291, 14, 2103, 14, 888, 905, 1200, 6611, 2261, 2255, 2351, 998, 9, 267, 9048, 3491, 275, 6047, 14, 1222, 480, 12067, 401, 5023, 14, 20733, 8, 8305, 1872, 395, 334, 16, 12, 378, 12, 378, 430, 267, 9048, 9654, 275, 6047, 9654, 14, 9654, 8, 8305, 3491, 9, 267, 9048, 9654, 14, 505, 1332, 16, 12, 378, 395, 9048, 1872, 12, 5023, 275, 5023, 9, 267, 2150, 9048, 9654, 267, 9048, 3491, 275, 9048, 3491, 14, 8709, 1332, 16596, 3491, 14, 890, 59, 16, 467, 334, 1609, 8, 16596, 3491, 14, 890, 59, 16, 566, 1182, 9048, 3491, 14, 890, 59, 16, 566, 627, 9048, 3491, 14, 890, 59, 17, 2522, 6047, 14, 1441, 4938, 11352, 9, 398, 19306, 3491, 275, 6047, 14, 1222, 480, 12067, 401, 334, 16596, 3491, 14, 890, 59, 16, 467, 29757, 3491, 14, 890, 59, 17, 61, 435, 9048, 3491, 14, 890, 59, 17, 2522, 334, 16, 12, 378, 12, 378, 430, 267, 19306, 3491, 14, 16586, 8, 16596, 3491, 12, 334, 16, 12, 378, 430, 267, 19306, 3491, 14, 16586, 8, 8305, 3491, 12, 334, 16, 12, 29757, 3491, 14, 890, 59, 17, 2459, 398, 4123, 275, 15073, 14, 6424, 342, 267, 19306, 3491, 14, 2117, 8, 1436, 12, 298, 24454, 531, 2728, 291, 14, 6795, 2567, 8, 1317, 804, 275, 298, 1569, 15, 4524, 531, 267, 291, 14, 3534, 8, 1436, 14, 7150, 1012, 2728, 372, 17098, 14, 3593, 199, 199, 533, 17283, 6713, 8, 3276, 304, 272, 408, 339, 28750, 3982, 13, 2785, 14041, 2286, 408, 339, 931, 275, 488, 327, 22825, 13, 15282, 315, 3016, 14, 647, 22901, 15, 339, 347, 11298, 8, 277, 304, 267, 2351, 998, 275, 291, 14, 2103, 14, 2302, 59, 17, 26, 21, 61, 398, 1591, 275, 436, 80, 14, 1238, 14, 3846, 14, 4965, 2175, 4434, 998, 8, 277, 14, 2103, 12, 2351, 998, 9, 267, 340, 440, 1591, 26, 288, 372, 17098, 14, 2856, 63, 4609, 63, 13945, 2728, 291, 14, 6795, 2567, 342, 267, 291, 14, 3534, 480, 1421, 531, 398, 372, 17098, 14, 3593, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 27, 1882, 199, 199, 3, 1898, 334, 35, 9, 8937, 13333, 247, 270, 14011, 15904, 3626, 274, 303, 199, 3, 221, 199, 3, 961, 570, 365, 1777, 402, 2401, 48, 14, 199, 3, 221, 199, 3, 2401, 48, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 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, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 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, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 199, 3, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 199, 199, 2765, 859, 10022, 314, 3982, 3304, 3217, 199, 199, 624, 199, 199, 646, 3873, 12, 15073, 199, 199, 504, 14937, 492, 6047, 12, 6047, 9654, 12, 6047, 6986, 199, 199, 504, 3413, 63, 1548, 492, 17098, 199, 199, 646, 436, 80, 14, 1238, 14, 3846, 199, 199, 504, 436, 80, 14, 1345, 14, 2520, 492, 10331, 199, 199, 533, 17283, 26779, 8, 3276, 304, 272, 408, 339, 1803, 282, 1413, 50, 1233, 1834, 12, 436, 5767, 314, 1890, 1159, 2287, 367, 272, 3982, 13, 2785, 13484, 2286, 408, 2286, 931, 275, 3286, 3846, 15, 16596, 2, 272, 2498, 7084, 275, 756, 272, 5023, 2042, 275, 3286, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 15, 32264, 13, 2075, 1745, 13, 422, 65, 15, 3673, 65, 14, 32264, 2, 327, 1413, 2577, 19311, 12414, 339, 347, 11298, 8, 277, 304, 267, 1591, 275, 291, 14, 2103, 14, 362, 63, 3846, 63, 1102, 8, 3796, 14, 16058, 63, 2826, 29149, 9, 398, 436, 80, 14, 1238, 14, 3846, 14, 7099, 3041, 8, 277, 14, 2103, 12, 1591, 9, 267, 2351, 998, 275, 436, 80, 14, 1238, 14, 3846, 14, 4434, 998, 1858, 4965, 8, 277, 14, 2103, 12, 1591, 9, 398, 2088, 275, 1689, 81, 25894, 401, 3905, 83, 401, 298, 975, 401, 3905, 77, 401, 298, 16, 401, 3905, 79, 401, 3905, 531, 267, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 9009, 275, 3873, 14, 6089, 12, 3839, 275, 3873, 14, 6089, 9, 398, 5108, 275, 298, 1014, 13827, 83, 4111, 83, 3149, 83, 2, 450, 334, 277, 14, 2103, 14, 888, 905, 1200, 6611, 1102, 2255, 291, 14, 2103, 14, 888, 905, 1200, 6611, 2261, 2255, 2351, 998, 9, 267, 4123, 275, 15073, 14, 6424, 8, 4687, 14, 10664, 8, 2302, 2788, 16, 566, 267, 29757, 3491, 275, 6047, 14, 1490, 8, 1436, 9, 398, 5023, 275, 6047, 6986, 14, 2052, 466, 8, 277, 14, 4246, 2042, 12, 5049, 9, 327, 13123, 8321, 370, 4666, 3224, 5521, 398, 9048, 1872, 275, 2071, 83, 4111, 83, 3149, 83, 2, 450, 334, 277, 14, 2103, 14, 888, 905, 1200, 6611, 1102, 2255, 291, 14, 2103, 14, 888, 905, 1200, 6611, 2261, 2255, 2351, 998, 9, 267, 9048, 3491, 275, 6047, 14, 1222, 480, 12067, 401, 5023, 14, 20733, 8, 8305, 1872, 395, 334, 16, 12, 378, 12, 378, 430, 267, 9048, 9654, 275, 6047, 9654, 14, 9654, 8, 8305, 3491, 9, 267, 9048, 9654, 14, 505, 1332, 16, 12, 378, 395, 9048, 1872, 12, 5023, 275, 5023, 9, 267, 2150, 9048, 9654, 267, 9048, 3491, 275, 9048, 3491, 14, 8709, 1332, 16596, 3491, 14, 890, 59, 16, 467, 334, 1609, 8, 16596, 3491, 14, 890, 59, 16, 566, 1182, 9048, 3491, 14, 890, 59, 16, 566, 627, 9048, 3491, 14, 890, 59, 17, 2522, 6047, 14, 1441, 4938, 11352, 9, 398, 19306, 3491, 275, 6047, 14, 1222, 480, 12067, 401, 334, 16596, 3491, 14, 890, 59, 16, 467, 29757, 3491, 14, 890, 59, 17, 61, 435, 9048, 3491, 14, 890, 59, 17, 2522, 334, 16, 12, 378, 12, 378, 430, 267, 19306, 3491, 14, 16586, 8, 16596, 3491, 12, 334, 16, 12, 378, 430, 267, 19306, 3491, 14, 16586, 8, 8305, 3491, 12, 334, 16, 12, 29757, 3491, 14, 890, 59, 17, 2459, 398, 4123, 275, 15073, 14, 6424, 342, 267, 19306, 3491, 14, 2117, 8, 1436, 12, 298, 24454, 531, 2728, 291, 14, 6795, 2567, 8, 1317, 804, 275, 298, 1569, 15, 4524, 531, 267, 291, 14, 3534, 8, 1436, 14, 7150, 1012, 2728, 372, 17098, 14, 3593, 199, 199, 533, 17283, 6713, 8, 3276, 304, 272, 408, 339, 28750, 3982, 13, 2785, 14041, 2286, 408, 339, 931, 275, 488, 327, 22825, 13, 15282, 315, 3016, 14, 647, 22901, 15, 339, 347, 11298, 8, 277, 304, 267, 2351, 998, 275, 291, 14, 2103, 14, 2302, 59, 17, 26, 21, 61, 398, 1591, 275, 436, 80, 14, 1238, 14, 3846, 14, 4965, 2175, 4434, 998, 8, 277, 14, 2103, 12, 2351, 998, 9, 267, 340, 440, 1591, 26, 288, 372, 17098, 14, 2856, 63, 4609, 63, 13945, 2728, 291, 14, 6795, 2567, 342, 267, 291, 14, 3534, 480, 1421, 531, 398, 372, 17098, 14, 3593, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bitcity/django
django/core/cache/backends/base.py
145
9680
"Base Cache class." from __future__ import unicode_literals import time import warnings from django.core.exceptions import DjangoRuntimeWarning, ImproperlyConfigured from django.utils.module_loading import import_string class InvalidCacheBackendError(ImproperlyConfigured): pass class CacheKeyWarning(DjangoRuntimeWarning): pass # Stub class to ensure not passing in a `timeout` argument results in # the default timeout DEFAULT_TIMEOUT = object() # Memcached does not accept keys longer than this. MEMCACHE_MAX_KEY_LENGTH = 250 def default_key_func(key, key_prefix, version): """ Default function to generate keys. Constructs the key used by all other methods. By default it prepends the `key_prefix'. KEY_FUNCTION can be used to specify an alternate function with custom key making behavior. """ return '%s:%s:%s' % (key_prefix, version, key) def get_key_func(key_func): """ Function to decide which key function to use. Defaults to ``default_key_func``. """ if key_func is not None: if callable(key_func): return key_func else: return import_string(key_func) return default_key_func class BaseCache(object): def __init__(self, params): timeout = params.get('timeout', params.get('TIMEOUT', 300)) if timeout is not None: try: timeout = int(timeout) except (ValueError, TypeError): timeout = 300 self.default_timeout = timeout options = params.get('OPTIONS', {}) max_entries = params.get('max_entries', options.get('MAX_ENTRIES', 300)) try: self._max_entries = int(max_entries) except (ValueError, TypeError): self._max_entries = 300 cull_frequency = params.get('cull_frequency', options.get('CULL_FREQUENCY', 3)) try: self._cull_frequency = int(cull_frequency) except (ValueError, TypeError): self._cull_frequency = 3 self.key_prefix = params.get('KEY_PREFIX', '') self.version = params.get('VERSION', 1) self.key_func = get_key_func(params.get('KEY_FUNCTION')) def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT): """ Returns the timeout value usable by this backend based upon the provided timeout. """ if timeout == DEFAULT_TIMEOUT: timeout = self.default_timeout elif timeout == 0: # ticket 21147 - avoid time.time() related precision issues timeout = -1 return None if timeout is None else time.time() + timeout def make_key(self, key, version=None): """Constructs the key used by all other methods. By default it uses the key_func to generate a key (which, by default, prepends the `key_prefix' and 'version'). An different key function can be provided at the time of cache construction; alternatively, you can subclass the cache backend to provide custom key making behavior. """ if version is None: version = self.version new_key = self.key_func(key, self.key_prefix, version) return new_key def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): """ Set a value in the cache if the key does not already exist. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. Returns True if the value was stored, False otherwise. """ raise NotImplementedError('subclasses of BaseCache must provide an add() method') def get(self, key, default=None, version=None): """ Fetch a given key from the cache. If the key does not exist, return default, which itself defaults to None. """ raise NotImplementedError('subclasses of BaseCache must provide a get() method') def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): """ Set a value in the cache. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ raise NotImplementedError('subclasses of BaseCache must provide a set() method') def delete(self, key, version=None): """ Delete a key from the cache, failing silently. """ raise NotImplementedError('subclasses of BaseCache must provide a delete() method') def get_many(self, keys, version=None): """ Fetch a bunch of keys from the cache. For certain backends (memcached, pgsql) this can be *much* faster when fetching multiple values. Returns a dict mapping each key in keys to its value. If the given key is missing, it will be missing from the response dict. """ d = {} for k in keys: val = self.get(k, version=version) if val is not None: d[k] = val return d def get_or_set(self, key, default=None, timeout=DEFAULT_TIMEOUT, version=None): """ Fetch a given key from the cache. If the key does not exist, the key is added and set to the default value. The default value can also be any callable. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. Returns the value of the key stored or retrieved on success, False on error. """ if default is None: raise ValueError('You need to specify a value.') val = self.get(key, version=version) if val is None: if callable(default): default = default() val = self.add(key, default, timeout=timeout, version=version) if val: return self.get(key, version=version) return val def has_key(self, key, version=None): """ Returns True if the key is in the cache and has not expired. """ return self.get(key, version=version) is not None def incr(self, key, delta=1, version=None): """ Add delta to value in the cache. If the key does not exist, raise a ValueError exception. """ value = self.get(key, version=version) if value is None: raise ValueError("Key '%s' not found" % key) new_value = value + delta self.set(key, new_value, version=version) return new_value def decr(self, key, delta=1, version=None): """ Subtract delta from value in the cache. If the key does not exist, raise a ValueError exception. """ return self.incr(key, -delta, version=version) def __contains__(self, key): """ Returns True if the key is in the cache and has not expired. """ # This is a separate method, rather than just a copy of has_key(), # so that it always has the same functionality as has_key(), even # if a subclass overrides it. return self.has_key(key) def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None): """ Set a bunch of values in the cache at once from a dict of key/value pairs. For certain backends (memcached), this is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ for key, value in data.items(): self.set(key, value, timeout=timeout, version=version) def delete_many(self, keys, version=None): """ Set a bunch of values in the cache at once. For certain backends (memcached), this is much more efficient than calling delete() multiple times. """ for key in keys: self.delete(key, version=version) def clear(self): """Remove *all* values from the cache at once.""" raise NotImplementedError('subclasses of BaseCache must provide a clear() method') def validate_key(self, key): """ Warn about keys that would not be portable to the memcached backend. This encourages (but does not force) writing backend-portable cache code. """ if len(key) > MEMCACHE_MAX_KEY_LENGTH: warnings.warn('Cache key will cause errors if used with memcached: ' '%s (longer than %s)' % (key, MEMCACHE_MAX_KEY_LENGTH), CacheKeyWarning) for char in key: if ord(char) < 33 or ord(char) == 127: warnings.warn('Cache key contains characters that will cause ' 'errors if used with memcached: %r' % key, CacheKeyWarning) def incr_version(self, key, delta=1, version=None): """Adds delta to the cache version for the supplied key. Returns the new version. """ if version is None: version = self.version value = self.get(key, version=version) if value is None: raise ValueError("Key '%s' not found" % key) self.set(key, value, version=version + delta) self.delete(key, version=version) return version + delta def decr_version(self, key, delta=1, version=None): """Substracts delta from the cache version for the supplied key. Returns the new version. """ return self.incr_version(key, -delta, version) def close(self, **kwargs): """Close the cache connection""" pass
bsd-3-clause
[ 2, 1563, 11977, 1021, 2122, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 3598, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 5634, 14357, 3849, 12, 11897, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 421, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 421, 199, 533, 11977, 1197, 3849, 8, 9323, 14357, 3849, 304, 272, 986, 421, 199, 3, 23429, 1021, 370, 4868, 440, 9476, 315, 282, 658, 2593, 64, 1423, 2058, 315, 199, 3, 314, 849, 2653, 199, 3472, 63, 8899, 275, 909, 342, 199, 199, 3, 30465, 5245, 1630, 440, 4729, 2883, 8088, 2419, 642, 14, 199, 10293, 8677, 63, 4283, 63, 3078, 63, 9127, 275, 16074, 421, 199, 318, 849, 63, 498, 63, 1532, 8, 498, 12, 790, 63, 1861, 12, 1015, 304, 272, 408, 272, 3758, 805, 370, 3550, 2883, 14, 339, 9215, 83, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 19986, 3198, 272, 314, 658, 498, 63, 1861, 1370, 9301, 63, 15476, 883, 506, 1202, 370, 4165, 376, 18034, 272, 805, 543, 3537, 790, 10663, 5953, 14, 272, 408, 272, 372, 1543, 83, 2689, 83, 2689, 83, 7, 450, 334, 498, 63, 1861, 12, 1015, 12, 790, 9, 421, 199, 318, 664, 63, 498, 63, 1532, 8, 498, 63, 1532, 304, 272, 408, 272, 6801, 370, 19822, 1314, 790, 805, 370, 675, 14, 339, 7827, 370, 1124, 885, 63, 498, 63, 1532, 4345, 272, 408, 272, 340, 790, 63, 1532, 365, 440, 488, 26, 267, 340, 4550, 8, 498, 63, 1532, 304, 288, 372, 790, 63, 1532, 267, 587, 26, 288, 372, 492, 63, 875, 8, 498, 63, 1532, 9, 272, 372, 849, 63, 498, 63, 1532, 421, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 1862, 14, 362, 360, 8899, 297, 9601, 430, 267, 340, 2653, 365, 440, 488, 26, 288, 862, 26, 355, 2653, 275, 1109, 8, 2593, 9, 288, 871, 334, 3393, 12, 3146, 304, 355, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 398, 1511, 275, 1862, 14, 362, 360, 8808, 297, 5009, 267, 1390, 63, 3189, 275, 1862, 14, 362, 360, 988, 63, 3189, 297, 1511, 14, 362, 360, 4283, 63, 1309, 23359, 297, 9601, 430, 267, 862, 26, 288, 291, 423, 988, 63, 3189, 275, 1109, 8, 988, 63, 3189, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 988, 63, 3189, 275, 9601, 398, 286, 979, 63, 11132, 275, 1862, 14, 362, 360, 67, 979, 63, 11132, 297, 1511, 14, 362, 360, 35, 3785, 63, 38, 5255, 17059, 297, 650, 430, 267, 862, 26, 288, 291, 423, 67, 979, 63, 11132, 275, 1109, 8, 67, 979, 63, 11132, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 67, 979, 63, 11132, 275, 650, 398, 291, 14, 498, 63, 1861, 275, 1862, 14, 362, 360, 3078, 63, 6351, 297, 4074, 267, 291, 14, 1023, 275, 1862, 14, 362, 360, 4612, 297, 413, 9, 267, 291, 14, 498, 63, 1532, 275, 664, 63, 498, 63, 1532, 8, 1162, 14, 362, 360, 3078, 63, 15476, 1333, 339, 347, 664, 63, 4620, 63, 2593, 8, 277, 12, 2653, 29, 3472, 63, 8899, 304, 267, 408, 267, 1803, 314, 2653, 574, 18025, 701, 642, 4865, 4079, 12188, 314, 2741, 267, 2653, 14, 267, 408, 267, 340, 2653, 508, 6186, 63, 8899, 26, 288, 2653, 275, 291, 14, 885, 63, 2593, 267, 916, 2653, 508, 378, 26, 288, 327, 12052, 30301, 2417, 446, 5126, 900, 14, 521, 342, 4048, 7151, 10876, 288, 2653, 275, 446, 17, 267, 372, 488, 340, 2653, 365, 488, 587, 900, 14, 521, 342, 435, 2653, 339, 347, 1852, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 27943, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 267, 4440, 314, 790, 63, 1532, 370, 3550, 282, 790, 334, 6777, 12, 701, 849, 12, 267, 19986, 3198, 314, 658, 498, 63, 1861, 7, 436, 283, 1023, 1959, 1626, 3365, 790, 267, 805, 883, 506, 2741, 737, 314, 900, 402, 2581, 14538, 27, 267, 8679, 17330, 12, 1265, 883, 5516, 314, 2581, 4865, 370, 5647, 267, 3537, 790, 10663, 5953, 14, 267, 408, 267, 340, 1015, 365, 488, 26, 288, 1015, 275, 291, 14, 1023, 398, 892, 63, 498, 275, 291, 14, 498, 63, 1532, 8, 498, 12, 291, 14, 498, 63, 1861, 12, 1015, 9, 267, 372, 892, 63, 498, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 376, 1050, 342, 1083, 358, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 664, 342, 1083, 358, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 663, 342, 1083, 358, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 3145 ]
[ 1563, 11977, 1021, 2122, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 3598, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 5634, 14357, 3849, 12, 11897, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 421, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 421, 199, 533, 11977, 1197, 3849, 8, 9323, 14357, 3849, 304, 272, 986, 421, 199, 3, 23429, 1021, 370, 4868, 440, 9476, 315, 282, 658, 2593, 64, 1423, 2058, 315, 199, 3, 314, 849, 2653, 199, 3472, 63, 8899, 275, 909, 342, 199, 199, 3, 30465, 5245, 1630, 440, 4729, 2883, 8088, 2419, 642, 14, 199, 10293, 8677, 63, 4283, 63, 3078, 63, 9127, 275, 16074, 421, 199, 318, 849, 63, 498, 63, 1532, 8, 498, 12, 790, 63, 1861, 12, 1015, 304, 272, 408, 272, 3758, 805, 370, 3550, 2883, 14, 339, 9215, 83, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 19986, 3198, 272, 314, 658, 498, 63, 1861, 1370, 9301, 63, 15476, 883, 506, 1202, 370, 4165, 376, 18034, 272, 805, 543, 3537, 790, 10663, 5953, 14, 272, 408, 272, 372, 1543, 83, 2689, 83, 2689, 83, 7, 450, 334, 498, 63, 1861, 12, 1015, 12, 790, 9, 421, 199, 318, 664, 63, 498, 63, 1532, 8, 498, 63, 1532, 304, 272, 408, 272, 6801, 370, 19822, 1314, 790, 805, 370, 675, 14, 339, 7827, 370, 1124, 885, 63, 498, 63, 1532, 4345, 272, 408, 272, 340, 790, 63, 1532, 365, 440, 488, 26, 267, 340, 4550, 8, 498, 63, 1532, 304, 288, 372, 790, 63, 1532, 267, 587, 26, 288, 372, 492, 63, 875, 8, 498, 63, 1532, 9, 272, 372, 849, 63, 498, 63, 1532, 421, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 1862, 14, 362, 360, 8899, 297, 9601, 430, 267, 340, 2653, 365, 440, 488, 26, 288, 862, 26, 355, 2653, 275, 1109, 8, 2593, 9, 288, 871, 334, 3393, 12, 3146, 304, 355, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 398, 1511, 275, 1862, 14, 362, 360, 8808, 297, 5009, 267, 1390, 63, 3189, 275, 1862, 14, 362, 360, 988, 63, 3189, 297, 1511, 14, 362, 360, 4283, 63, 1309, 23359, 297, 9601, 430, 267, 862, 26, 288, 291, 423, 988, 63, 3189, 275, 1109, 8, 988, 63, 3189, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 988, 63, 3189, 275, 9601, 398, 286, 979, 63, 11132, 275, 1862, 14, 362, 360, 67, 979, 63, 11132, 297, 1511, 14, 362, 360, 35, 3785, 63, 38, 5255, 17059, 297, 650, 430, 267, 862, 26, 288, 291, 423, 67, 979, 63, 11132, 275, 1109, 8, 67, 979, 63, 11132, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 67, 979, 63, 11132, 275, 650, 398, 291, 14, 498, 63, 1861, 275, 1862, 14, 362, 360, 3078, 63, 6351, 297, 4074, 267, 291, 14, 1023, 275, 1862, 14, 362, 360, 4612, 297, 413, 9, 267, 291, 14, 498, 63, 1532, 275, 664, 63, 498, 63, 1532, 8, 1162, 14, 362, 360, 3078, 63, 15476, 1333, 339, 347, 664, 63, 4620, 63, 2593, 8, 277, 12, 2653, 29, 3472, 63, 8899, 304, 267, 408, 267, 1803, 314, 2653, 574, 18025, 701, 642, 4865, 4079, 12188, 314, 2741, 267, 2653, 14, 267, 408, 267, 340, 2653, 508, 6186, 63, 8899, 26, 288, 2653, 275, 291, 14, 885, 63, 2593, 267, 916, 2653, 508, 378, 26, 288, 327, 12052, 30301, 2417, 446, 5126, 900, 14, 521, 342, 4048, 7151, 10876, 288, 2653, 275, 446, 17, 267, 372, 488, 340, 2653, 365, 488, 587, 900, 14, 521, 342, 435, 2653, 339, 347, 1852, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 27943, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 267, 4440, 314, 790, 63, 1532, 370, 3550, 282, 790, 334, 6777, 12, 701, 849, 12, 267, 19986, 3198, 314, 658, 498, 63, 1861, 7, 436, 283, 1023, 1959, 1626, 3365, 790, 267, 805, 883, 506, 2741, 737, 314, 900, 402, 2581, 14538, 27, 267, 8679, 17330, 12, 1265, 883, 5516, 314, 2581, 4865, 370, 5647, 267, 3537, 790, 10663, 5953, 14, 267, 408, 267, 340, 1015, 365, 488, 26, 288, 1015, 275, 291, 14, 1023, 398, 892, 63, 498, 275, 291, 14, 498, 63, 1532, 8, 498, 12, 291, 14, 498, 63, 1861, 12, 1015, 9, 267, 372, 892, 63, 498, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 376, 1050, 342, 1083, 358, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 664, 342, 1083, 358, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 3472, 63, 8899, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 663, 342, 1083, 358, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 360, 19094, 402, 3523, 4437, 1471, 5647, 282, 3145, 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,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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 ]
ksachs/invenio
modules/websession/lib/webgroup_dblayer.py
33
14303
# -*- coding: utf-8 -*- ## ## This file is part of Invenio. ## Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 CERN. ## ## Invenio 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. ## ## Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ Database related functions for groups""" __revision__ = "$Id$" from time import localtime from zlib import decompress from invenio.config import CFG_SITE_LANG from invenio.dbquery import run_sql, OperationalError from invenio.dateutils import convert_datestruct_to_datetext from invenio.messages import gettext_set_language from invenio.websession_config import CFG_WEBSESSION_GROUP_JOIN_POLICY def get_groups_by_user_status(uid, user_status, login_method='INTERNAL'): """Select all the groups the user is admin of. @param uid: user id @return: ((id_usergroup, group_name, group_description, )) """ query = """SELECT g.id, g.name, g.description FROM usergroup g, user_usergroup ug WHERE ug.id_user=%s AND ug.id_usergroup=g.id AND ug.user_status=%s AND g.login_method = %s ORDER BY g.name""" uid = int(uid) res = run_sql(query, (uid, user_status, login_method)) return res def get_groups_by_login_method(uid, login_method): """Select all the groups the user is member of selecting the login_method. @param uid: user id @param login_method: the login_method (>0 external) @return: ((id_usergroup, group_name, group_description, )) """ query = """SELECT g.id, g.name, g.description FROM usergroup g, user_usergroup ug WHERE ug.id_user=%s AND ug.id_usergroup=g.id AND g.login_method=%s ORDER BY g.name""" uid = int(uid) res = run_sql(query, (uid, login_method)) return res def get_groups_with_description(uid): """Select all the groups the user is member of. @param uid: user id @return: ((id_usergroup, group_name, group_description, )) """ query = """SELECT g.id, g.name, g.description FROM usergroup g, user_usergroup ug WHERE ug.id_user=%s AND ug.id_usergroup=g.id ORDER BY g.name""" uid = int(uid) res = run_sql(query, (uid, )) return res def get_external_groups(uid): """Select all the groups the user is member of selecting the login_method. @param uid: user id @param login_method: the login_method (>0 external) @return: ((id_usergroup, group_name, group_description, )) """ query = """SELECT g.id, g.name, g.description FROM usergroup g, user_usergroup ug WHERE ug.id_user=%s AND ug.id_usergroup=g.id AND g.login_method != 'INTERNAL' ORDER BY g.name""" uid = int(uid) res = run_sql(query, (uid, )) return res def get_groups(uid): """Select all the groups id the user is member of.""" query = """SELECT g.id, g.name FROM usergroup g, user_usergroup ug WHERE ug.id_user=%s AND ug.id_usergroup=g.id """ res = run_sql(query, (uid, )) res = list(res) return res def get_group_id(group_name, login_method='INTERNAL'): """@return: the id of the group called group_name with given login_method.""" return run_sql(""" SELECT id FROM usergroup WHERE login_method = %s AND name = %s""", (login_method, group_name,)) def get_login_method_groups(uid, login_method='INTERNAL'): """Select all the external groups of a particular login_method for which the user is subscrided. @return: ((group_name, group_id)) """ return run_sql(""" SELECT g.name as name, g.id as id FROM user_usergroup as u JOIN usergroup as g ON u.id_usergroup = g.id WHERE u.id_user = %s and g.login_method = %s""", (uid, login_method,)) def get_all_login_method_groups(login_method): """Select all the external groups of a particular login_method. @return: ({group_name: group_id, ...}) """ return dict(run_sql(""" SELECT name, id FROM usergroup WHERE login_method = %s""", (login_method,))) def get_all_users_with_groups_with_login_method(login_method): """Select all the users that belong at least to one external group of kind login_method. """ return dict(run_sql(""" SELECT DISTINCT u.email, u.id FROM user AS u JOIN user_usergroup AS uu ON u.id = uu.id_user JOIN usergroup AS ug ON ug.id = uu.id_usergroup WHERE ug.login_method = %s""", (login_method,))) def get_visible_group_list(uid, pattern=""): """List the group the user can join (not already member of the group regardless user's status). @return: groups {id : name} whose name matches pattern """ grpID = [] groups = {} #list the group the user is member of""" query = """SELECT distinct(id_usergroup) FROM user_usergroup WHERE id_user=%s """ uid = int(uid) res = run_sql(query, (uid,)) map(lambda x: grpID.append(int(x[0])), res) query2 = """SELECT id,name FROM usergroup WHERE (join_policy='%s' OR join_policy='%s')""" % ( CFG_WEBSESSION_GROUP_JOIN_POLICY['VISIBLEOPEN'], CFG_WEBSESSION_GROUP_JOIN_POLICY['VISIBLEMAIL']) if len(grpID) == 1 : query2 += """ AND id!=%i""" % grpID[0] elif len(grpID) > 1: query2 += """ AND id NOT IN %s""" % str(tuple(grpID)) if pattern: try: res2 = run_sql(query2 + """ AND name RLIKE %s ORDER BY name""", (pattern,)) except OperationalError: res2 = () else: res2 = run_sql(query2 + """ ORDER BY name""") map(lambda x: groups.setdefault(x[0], x[1]), res2) return groups def insert_new_group(uid, new_group_name, new_group_description, join_policy, login_method='INTERNAL'): """Create a new group and affiliate a user.""" query1 = """INSERT INTO usergroup (id, name, description, join_policy, login_method) VALUES (NULL,%s,%s,%s,%s) """ params1 = (new_group_name, new_group_description, join_policy, login_method) res1 = run_sql(query1, params1) date = convert_datestruct_to_datetext(localtime()) uid = int(uid) query2 = """INSERT INTO user_usergroup (id_user, id_usergroup, user_status, user_status_date) VALUES (%s,%s,'A',%s) """ params2 = (uid, res1, date) res2 = run_sql(query2, params2) return res1 def insert_only_new_group(new_group_name, new_group_description, join_policy, login_method='INTERNAL'): """Create a group with no user in (yet). @return: its id """ query = """INSERT INTO usergroup (name, description, join_policy, login_method) VALUES (%s, %s, %s, %s) """ res = run_sql(query, (new_group_name, new_group_description, join_policy, login_method)) return res def insert_new_member(uid, grpID, status): """Insert new member.""" query = """INSERT INTO user_usergroup (id_user, id_usergroup, user_status, user_status_date) VALUES (%s,%s,%s,%s) """ date = convert_datestruct_to_datetext(localtime()) res = run_sql(query, (uid, grpID, status, date)) return res def get_group_infos(grpID): """Get group infos.""" query = """SELECT id,name,description,join_policy,login_method FROM usergroup WHERE id = %s""" res = run_sql(query, (grpID, )) return res def get_all_groups_description(login_method): """Get all groups description, dictionary with key name.""" query = """SELECT name, description FROM usergroup WHERE login_method = %s """ res = run_sql(query, (login_method, )) if res: return dict(res) else: return {} def update_group_infos(grpID, group_name, group_description, join_policy): """Update group.""" res = run_sql("""UPDATE usergroup SET name=%s, description=%s, join_policy=%s WHERE id=%s""", (group_name, group_description, join_policy, grpID)) return res def get_user_status(uid, grpID): """Get the status of the user for the given group.""" query = """SELECT user_status FROM user_usergroup WHERE id_user = %s AND id_usergroup=%s""" uid = int(uid) res = run_sql(query, (uid, grpID)) return res def get_users_by_status(grpID, status, ln=CFG_SITE_LANG): """Get the list of users with the given status. @return: ((id, nickname),) nickname= user # uid if the user has no nickname """ _ = gettext_set_language(ln) res = run_sql("""SELECT ug.id_user, u.nickname FROM user_usergroup ug, user u WHERE ug.id_usergroup = %s AND ug.id_user=u.id AND user_status = %s""", (grpID, status)) users = [] if res: for (mid, nickname) in res: nn = nickname if not nickname: nn = _("user") + "#%i" % mid users.append((mid, nn)) return tuple(users) def delete_member(grpID, member_id): """Delete member.""" query = """DELETE FROM user_usergroup WHERE id_usergroup = %s AND id_user = %s""" member_id = int(member_id) res = run_sql(query, (grpID, member_id)) return res def delete_group_and_members(grpID): """Delete the group and its members.""" query = """DELETE FROM usergroup WHERE id = %s """ res = run_sql(query, (grpID,)) query = """DELETE FROM user_usergroup WHERE id_usergroup = %s """ res = run_sql(query, (grpID,)) return res def add_pending_member(grpID, member_id, user_status): """Change user status: Pending member becomes normal member""" date = convert_datestruct_to_datetext(localtime()) res = run_sql("""UPDATE user_usergroup SET user_status = %s, user_status_date = %s WHERE id_usergroup = %s AND id_user = %s""", (user_status, date, grpID, member_id)) return res def leave_group(grpID, uid): """Remove user from the group member list.""" query = """DELETE FROM user_usergroup WHERE id_usergroup=%s AND id_user=%s""" uid = int(uid) res = run_sql(query, (grpID, uid)) return res def drop_external_groups(userId): """Drops all the external groups memberships of userid.""" query = """DELETE user_usergroup FROM user_usergroup, usergroup WHERE user_usergroup.id_user=%s AND usergroup.id = user_usergroup.id_usergroup AND usergroup.login_method <> 'INTERNAL'""" return run_sql(query, (userId,)) def group_name_exist(group_name, login_method='INTERNAL'): """Get all group id whose name like group_name and login_method.""" query = """SELECT id FROM usergroup WHERE login_method=%s AND name=%s""" res = run_sql(query, (login_method, group_name)) return res def get_group_login_method(grpID): """Return the login_method of the group or None if the grpID doesn't exist.""" query = """SELECT login_method FROM usergroup WHERE id=%s""" res = run_sql(query, (grpID, )) if res: return res[0][0] else: return None def count_nb_group_user(uid, user_status): """ @param uid: user id @param status: member status @return: integer of number of groups the user belongs to with the given status, 0 if none """ res = run_sql("""SELECT count(id_user) FROM user_usergroup WHERE id_user = %s AND user_status = %s""", (uid, user_status)) if res: return int(res[0][0]) else: return 0 def get_all_users(): """@return: all the email:id""" query = """SELECT UPPER(email), id FROM user WHERE email != '' """ res = run_sql(query) if res: return dict(res) else: return {} def get_users_in_group(grpID): """@return: all uids of users belonging to group grpID""" query = """SELECT id_user FROM user_usergroup WHERE id_usergroup = %s """ res = run_sql(query, (grpID, )) return [uid[0] for uid in res] ########################## helpful functions ################################## def __decompress_last(item): """private function, used to shorten code""" item = list(item) item[-1] = decompress(item[-1]) return item
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 8692, 4048, 3423, 367, 4652, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 504, 900, 492, 2257, 521, 199, 504, 12472, 492, 24733, 199, 199, 504, 13640, 14, 888, 492, 10974, 63, 7917, 63, 7442, 199, 504, 13640, 14, 697, 1131, 492, 1255, 63, 3009, 12, 6654, 6279, 547, 199, 504, 13640, 14, 602, 1208, 492, 3957, 63, 602, 1820, 63, 475, 63, 602, 505, 199, 504, 13640, 14, 3431, 492, 9796, 63, 409, 63, 3671, 199, 504, 13640, 14, 2520, 1730, 63, 888, 492, 10974, 63, 5408, 11087, 9577, 63, 7823, 63, 23321, 63, 15976, 421, 199, 318, 664, 63, 2634, 63, 991, 63, 751, 63, 1205, 8, 1535, 12, 922, 63, 1205, 12, 4676, 63, 765, 534, 17681, 735, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 4628, 402, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 399, 71, 14, 751, 63, 1205, 2458, 83, 2401, 2151, 486, 14, 2886, 63, 765, 275, 450, 83, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 922, 63, 1205, 12, 4676, 63, 765, 430, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 63, 991, 63, 2886, 63, 765, 8, 1535, 12, 4676, 63, 765, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 30090, 314, 4676, 63, 765, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 635, 4676, 63, 765, 26, 314, 4676, 63, 765, 334, 30, 16, 5957, 9, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 486, 14, 2886, 63, 765, 2458, 83, 199, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 4676, 63, 765, 430, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 63, 1045, 63, 1802, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 5082, 272, 372, 522, 421, 199, 318, 664, 63, 5159, 63, 2634, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 30090, 314, 4676, 63, 765, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 635, 4676, 63, 765, 26, 314, 4676, 63, 765, 334, 30, 16, 5957, 9, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 486, 14, 2886, 63, 765, 1137, 283, 17681, 7, 199, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 5082, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 1305, 314, 922, 365, 3653, 402, 1041, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 486, 14, 354, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 12235, 14, 199, 309, 1898, 334, 35, 9, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 24354, 14, 199, 309, 199, 309, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 309, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 309, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 309, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 309, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 309, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 8692, 4048, 3423, 367, 4652, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 504, 900, 492, 2257, 521, 199, 504, 12472, 492, 24733, 199, 199, 504, 13640, 14, 888, 492, 10974, 63, 7917, 63, 7442, 199, 504, 13640, 14, 697, 1131, 492, 1255, 63, 3009, 12, 6654, 6279, 547, 199, 504, 13640, 14, 602, 1208, 492, 3957, 63, 602, 1820, 63, 475, 63, 602, 505, 199, 504, 13640, 14, 3431, 492, 9796, 63, 409, 63, 3671, 199, 504, 13640, 14, 2520, 1730, 63, 888, 492, 10974, 63, 5408, 11087, 9577, 63, 7823, 63, 23321, 63, 15976, 421, 199, 318, 664, 63, 2634, 63, 991, 63, 751, 63, 1205, 8, 1535, 12, 922, 63, 1205, 12, 4676, 63, 765, 534, 17681, 735, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 4628, 402, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 399, 71, 14, 751, 63, 1205, 2458, 83, 2401, 2151, 486, 14, 2886, 63, 765, 275, 450, 83, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 922, 63, 1205, 12, 4676, 63, 765, 430, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 63, 991, 63, 2886, 63, 765, 8, 1535, 12, 4676, 63, 765, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 30090, 314, 4676, 63, 765, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 635, 4676, 63, 765, 26, 314, 4676, 63, 765, 334, 30, 16, 5957, 9, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 486, 14, 2886, 63, 765, 2458, 83, 199, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 4676, 63, 765, 430, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 63, 1045, 63, 1802, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 5082, 272, 372, 522, 421, 199, 318, 664, 63, 5159, 63, 2634, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 314, 922, 365, 3653, 402, 30090, 314, 4676, 63, 765, 14, 272, 768, 635, 1747, 26, 922, 1305, 272, 768, 635, 4676, 63, 765, 26, 314, 4676, 63, 765, 334, 30, 16, 5957, 9, 272, 768, 1107, 26, 3666, 344, 63, 751, 923, 12, 1598, 1572, 63, 354, 12, 1598, 1572, 63, 1802, 12, 5082, 272, 408, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 1993, 486, 14, 354, 12, 1993, 486, 14, 1802, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 71, 14, 344, 63, 751, 923, 29, 71, 14, 344, 2401, 2151, 486, 14, 2886, 63, 765, 1137, 283, 17681, 7, 199, 2049, 16044, 6515, 486, 14, 354, 624, 272, 1747, 275, 1109, 8, 1535, 9, 272, 522, 275, 1255, 63, 3009, 8, 1131, 12, 334, 1535, 12, 5082, 272, 372, 522, 199, 199, 318, 664, 63, 2634, 8, 1535, 304, 272, 408, 5446, 1006, 314, 4652, 1305, 314, 922, 365, 3653, 402, 1041, 272, 1827, 275, 408, 4859, 486, 14, 344, 12, 486, 14, 354, 2049, 4442, 922, 923, 486, 12, 922, 63, 751, 923, 399, 71, 2049, 6038, 399, 71, 14, 344, 63, 751, 2458, 83, 2401, 2151, 399, 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, 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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 ]
kmonsoor/python-for-android
python3-alpha/extra_modules/gdata/Crypto/Protocol/Chaffing.py
44
9496
"""This file implements the chaffing algorithm. Winnowing and chaffing is a technique for enhancing privacy without requiring strong encryption. In short, the technique takes a set of authenticated message blocks (the wheat) and adds a number of chaff blocks which have randomly chosen data and MAC fields. This means that to an adversary, the chaff blocks look as valid as the wheat blocks, and so the authentication would have to be performed on every block. By tailoring the number of chaff blocks added to the message, the sender can make breaking the message computationally infeasible. There are many other interesting properties of the winnow/chaff technique. For example, say Alice is sending a message to Bob. She packetizes the message and performs an all-or-nothing transformation on the packets. Then she authenticates each packet with a message authentication code (MAC). The MAC is a hash of the data packet, and there is a secret key which she must share with Bob (key distribution is an exercise left to the reader). She then adds a serial number to each packet, and sends the packets to Bob. Bob receives the packets, and using the shared secret authentication key, authenticates the MACs for each packet. Those packets that have bad MACs are simply discarded. The remainder are sorted by serial number, and passed through the reverse all-or-nothing transform. The transform means that an eavesdropper (say Eve) must acquire all the packets before any of the data can be read. If even one packet is missing, the data is useless. There's one twist: by adding chaff packets, Alice and Bob can make Eve's job much harder, since Eve now has to break the shared secret key, or try every combination of wheat and chaff packet to read any of the message. The cool thing is that Bob doesn't need to add any additional code; the chaff packets are already filtered out because their MACs don't match (in all likelihood -- since the data and MACs for the chaff packets are randomly chosen it is possible, but very unlikely that a chaff MAC will match the chaff data). And Alice need not even be the party adding the chaff! She could be completely unaware that a third party, say Charles, is adding chaff packets to her messages as they are transmitted. For more information on winnowing and chaffing see this paper: Ronald L. Rivest, "Chaffing and Winnowing: Confidentiality without Encryption" http://theory.lcs.mit.edu/~rivest/chaffing.txt """ __revision__ = "$Id: Chaffing.py,v 1.7 2003/02/28 15:23:21 akuchling Exp $" from Crypto.Util.number import bytes_to_long class Chaff: """Class implementing the chaff adding algorithm. Methods for subclasses: _randnum(size): Returns a randomly generated number with a byte-length equal to size. Subclasses can use this to implement better random data and MAC generating algorithms. The default algorithm is probably not very cryptographically secure. It is most important that the chaff data does not contain any patterns that can be used to discern it from wheat data without running the MAC. """ def __init__(self, factor=1.0, blocksper=1): """Chaff(factor:float, blocksper:int) factor is the number of message blocks to add chaff to, expressed as a percentage between 0.0 and 1.0. blocksper is the number of chaff blocks to include for each block being chaffed. Thus the defaults add one chaff block to every message block. By changing the defaults, you can adjust how computationally difficult it could be for an adversary to brute-force crack the message. The difficulty is expressed as: pow(blocksper, int(factor * number-of-blocks)) For ease of implementation, when factor < 1.0, only the first int(factor*number-of-blocks) message blocks are chaffed. """ if not (0.0<=factor<=1.0): raise ValueError("'factor' must be between 0.0 and 1.0") if blocksper < 0: raise ValueError("'blocksper' must be zero or more") self.__factor = factor self.__blocksper = blocksper def chaff(self, blocks): """chaff( [(serial-number:int, data:string, MAC:string)] ) : [(int, string, string)] Add chaff to message blocks. blocks is a list of 3-tuples of the form (serial-number, data, MAC). Chaff is created by choosing a random number of the same byte-length as data, and another random number of the same byte-length as MAC. The message block's serial number is placed on the chaff block and all the packet's chaff blocks are randomly interspersed with the single wheat block. This method then returns a list of 3-tuples of the same form. Chaffed blocks will contain multiple instances of 3-tuples with the same serial number, but the only way to figure out which blocks are wheat and which are chaff is to perform the MAC hash and compare values. """ chaffedblocks = [] # count is the number of blocks to add chaff to. blocksper is the # number of chaff blocks to add per message block that is being # chaffed. count = len(blocks) * self.__factor blocksper = list(range(self.__blocksper)) for i, wheat in map(None, list(range(len(blocks))), blocks): # it shouldn't matter which of the n blocks we add chaff to, so for # ease of implementation, we'll just add them to the first count # blocks if i < count: serial, data, mac = wheat datasize = len(data) macsize = len(mac) addwheat = 1 # add chaff to this block for j in blocksper: import sys chaffdata = self._randnum(datasize) chaffmac = self._randnum(macsize) chaff = (serial, chaffdata, chaffmac) # mix up the order, if the 5th bit is on then put the # wheat on the list if addwheat and bytes_to_long(self._randnum(16)) & 0x40: chaffedblocks.append(wheat) addwheat = 0 chaffedblocks.append(chaff) if addwheat: chaffedblocks.append(wheat) else: # just add the wheat chaffedblocks.append(wheat) return chaffedblocks def _randnum(self, size): # TBD: Not a very secure algorithm. # TBD: size * 2 to work around possible bug in RandomPool from Crypto.Util import randpool import time pool = randpool.RandomPool(size * 2) while size > pool.entropy: pass # we now have enough entropy in the pool to get size bytes of random # data... well, probably return pool.get_bytes(size) if __name__ == '__main__': text = """\ We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed. That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. """ print('Original text:\n==========') print(text) print('==========') # first transform the text into packets blocks = [] ; size = 40 for i in range(0, len(text), size): blocks.append( text[i:i+size] ) # now get MACs for all the text blocks. The key is obvious... print('Calculating MACs...') from Crypto.Hash import HMAC, SHA key = 'Jefferson' macs = [HMAC.new(key, block, digestmod=SHA).digest() for block in blocks] assert len(blocks) == len(macs) # put these into a form acceptable as input to the chaffing procedure source = [] m = map(None, list(range(len(blocks))), blocks, macs) print(m) for i, data, mac in m: source.append((i, data, mac)) # now chaff these print('Adding chaff...') c = Chaff(factor=0.5, blocksper=2) chaffed = c.chaff(source) from base64 import encodestring # print the chaffed message blocks. meanwhile, separate the wheat from # the chaff wheat = [] print('chaffed message blocks:') for i, data, mac in chaffed: # do the authentication h = HMAC.new(key, data, digestmod=SHA) pmac = h.digest() if pmac == mac: tag = '-->' wheat.append(data) else: tag = ' ' # base64 adds a trailing newline print(tag, '%3d' % i, \ repr(data), encodestring(mac)[:-1]) # now decode the message packets and check it against the original text print('Undigesting wheat...') newtext = "".join(wheat) if newtext == text: print('They match!') else: print('They differ!')
apache-2.0
[ 624, 2765, 570, 9031, 314, 682, 9181, 316, 5563, 14, 199, 199, 8886, 2131, 316, 436, 682, 9181, 316, 365, 282, 32414, 367, 655, 72, 15763, 16254, 4085, 1928, 29963, 199, 9370, 14396, 14, 221, 1010, 3974, 12, 314, 32414, 6181, 282, 663, 402, 15082, 199, 1188, 5664, 334, 1589, 336, 16614, 9, 436, 9584, 282, 1329, 402, 682, 9181, 5664, 1314, 1172, 199, 2355, 590, 12414, 666, 436, 13347, 1504, 14, 221, 961, 4910, 626, 370, 376, 1503, 14895, 695, 12, 314, 199, 335, 9181, 5664, 3648, 465, 1686, 465, 314, 336, 16614, 5664, 12, 436, 880, 314, 6299, 199, 2027, 854, 1172, 370, 506, 10585, 641, 4036, 1853, 14, 221, 4885, 9483, 6854, 314, 1329, 402, 682, 9181, 199, 4166, 3483, 370, 314, 1245, 12, 314, 8904, 883, 1852, 27485, 314, 1245, 199, 31598, 1183, 315, 771, 305, 7247, 14, 221, 6006, 787, 5002, 1163, 19604, 4382, 402, 199, 1589, 4747, 2131, 15, 335, 9181, 32414, 14, 199, 199, 1858, 2893, 12, 14722, 437, 3037, 365, 10209, 282, 1245, 370, 699, 2873, 14, 221, 428, 426, 1706, 69, 280, 90, 397, 314, 199, 1188, 436, 18628, 376, 1006, 13, 269, 13, 16323, 13315, 641, 314, 14593, 14, 221, 9442, 199, 19195, 28532, 2335, 1924, 3644, 543, 282, 1245, 6299, 1233, 334, 9410, 680, 221, 710, 199, 9410, 365, 282, 2631, 402, 314, 666, 3644, 12, 436, 2337, 365, 282, 7565, 790, 1314, 21920, 1471, 199, 6251, 543, 699, 2873, 334, 498, 4084, 365, 376, 26511, 3602, 370, 314, 7002, 680, 221, 428, 426, 2066, 199, 525, 83, 282, 3012, 1329, 370, 1924, 3644, 12, 436, 16178, 314, 14593, 370, 699, 2873, 14, 199, 199, 22593, 23192, 314, 14593, 12, 436, 1808, 314, 5709, 7565, 6299, 790, 12, 199, 1178, 2815, 2335, 314, 13347, 83, 367, 1924, 3644, 14, 221, 18049, 261, 14593, 626, 1172, 4875, 13347, 83, 787, 199, 11184, 590, 22002, 14, 221, 710, 15748, 787, 3355, 701, 3012, 1329, 12, 436, 3032, 199, 8304, 314, 3837, 1006, 13, 269, 13, 16323, 5793, 14, 221, 710, 5793, 4910, 626, 376, 199, 69, 7047, 4824, 529, 334, 19787, 662, 432, 9, 1471, 16919, 1006, 314, 14593, 2544, 1263, 402, 314, 666, 883, 199, 1235, 1586, 14, 221, 982, 2755, 1373, 3644, 365, 4124, 12, 314, 666, 365, 31291, 14, 199, 199, 10924, 1159, 1373, 8900, 631, 26, 701, 7791, 682, 9181, 14593, 12, 437, 3037, 436, 699, 2873, 883, 1852, 662, 432, 1159, 3906, 199, 77, 2133, 12159, 424, 12, 3967, 662, 432, 3063, 965, 370, 2059, 314, 5709, 7565, 790, 12, 503, 862, 4036, 199, 6560, 3155, 402, 336, 16614, 436, 682, 9181, 3644, 370, 1586, 1263, 402, 314, 1245, 14, 221, 710, 32268, 199, 2127, 365, 626, 699, 2873, 3181, 1133, 1929, 370, 1050, 1263, 4722, 1233, 27, 314, 682, 9181, 14593, 199, 1530, 2575, 9806, 734, 2952, 3932, 13347, 83, 2793, 1133, 1336, 334, 262, 1006, 22046, 1553, 199, 8585, 314, 666, 436, 13347, 83, 367, 314, 682, 9181, 14593, 787, 19311, 12414, 652, 365, 199, 13893, 12, 1325, 7437, 625, 24227, 626, 282, 682, 9181, 13347, 911, 1336, 314, 682, 9181, 666, 680, 221, 6061, 199, 28001, 1929, 440, 2755, 506, 314, 17135, 7791, 314, 682, 9181, 1, 221, 428, 426, 4293, 506, 14793, 199, 324, 14600, 626, 282, 10919, 17135, 12, 14722, 6659, 2978, 12, 365, 7791, 682, 9181, 14593, 370, 14737, 199, 3431, 465, 2985, 787, 29818, 14, 199, 199, 1858, 1655, 2556, 641, 4747, 2131, 316, 436, 682, 9181, 316, 1937, 642, 15220, 26, 199, 199, 50, 8125, 68, 491, 14, 820, 1912, 270, 12, 298, 1049, 9181, 316, 436, 13036, 2131, 316, 26, 1448, 329, 3256, 1209, 1928, 3447, 7950, 2, 199, 1014, 921, 1589, 1089, 14, 76, 1259, 14, 1147, 14, 8654, 22500, 6053, 270, 15, 335, 9181, 316, 14, 2424, 199, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 445, 2411, 556, 316, 14, 647, 12, 86, 413, 14, 23, 13004, 15, 996, 15, 1651, 4114, 26, 1789, 26, 2025, 282, 75, 2133, 2983, 7910, 2672, 2, 199, 199, 504, 18855, 14, 9562, 14, 1955, 492, 2783, 63, 475, 63, 2809, 199, 199, 533, 445, 2411, 556, 26, 272, 408, 2543, 18234, 314, 682, 9181, 7791, 5563, 14, 339, 17653, 367, 9180, 26, 953, 485, 3759, 1507, 8, 890, 304, 355, 1803, 282, 19311, 4046, 1329, 543, 282, 3696, 13, 1267, 4472, 355, 370, 1568, 14, 221, 20196, 883, 675, 642, 370, 5669, 8034, 2196, 355, 666, 436, 13347, 12999, 18036, 14, 221, 710, 849, 5563, 365, 355, 8646, 440, 7437, 13230, 25537, 11153, 14, 221, 2779, 365, 4750, 355, 11012, 626, 314, 682, 9181, 666, 1630, 440, 1395, 1263, 7970, 355, 626, 883, 506, 1202, 370, 4339, 27569, 652, 687, 336, 16614, 666, 1928, 3879, 355, 314, 13347, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 6535, 29, 17, 14, 16, 12, 5664, 529, 29, 17, 304, 267, 408, 1049, 9181, 8, 4778, 26, 1609, 12, 5664, 529, 26, 442, 9, 398, 6535, 365, 314, 1329, 402, 1245, 5664, 370, 1050, 682, 9181, 370, 12, 267, 19147, 465, 282, 16327, 3382, 378, 14, 16, 436, 413, 14, 16, 14, 221, 5664, 529, 365, 267, 314, 1329, 402, 682, 9181, 5664, 370, 2387, 367, 1924, 1853, 3769, 267, 682, 9181, 379, 14, 221, 20227, 314, 4243, 1050, 1373, 682, 9181, 1853, 370, 4036, 267, 1245, 1853, 14, 221, 4885, 13729, 314, 4243, 12, 1265, 883, 11311, 4212, 267, 14009, 1183, 29870, 652, 4293, 506, 367, 376, 1503, 14895, 695, 370, 267, 11665, 938, 13, 3990, 286, 8085, 314, 1245, 14, 221, 710, 23976, 17323, 365, 19147, 267, 465, 26, 953, 13131, 8, 4166, 529, 12, 1109, 8, 4778, 627, 1329, 13, 1618, 13, 4166, 430, 398, 2104, 325, 482, 402, 4514, 12, 1380, 6535, 665, 413, 14, 16, 12, 1454, 314, 1642, 267, 1109, 8, 4778, 10, 1955, 13, 1618, 13, 4166, 9, 1245, 5664, 787, 682, 9181, 379, 14, 267, 408, 398, 340, 440, 334, 16, 14, 16, 12932, 4778, 12932, 17, 14, 16, 304, 288, 746, 1722, 15587, 4778, 7, 1471, 506, 3382, 378, 14, 16, 436, 413, 14, 16, 531, 267, 340, 5664, 529 ]
[ 2765, 570, 9031, 314, 682, 9181, 316, 5563, 14, 199, 199, 8886, 2131, 316, 436, 682, 9181, 316, 365, 282, 32414, 367, 655, 72, 15763, 16254, 4085, 1928, 29963, 199, 9370, 14396, 14, 221, 1010, 3974, 12, 314, 32414, 6181, 282, 663, 402, 15082, 199, 1188, 5664, 334, 1589, 336, 16614, 9, 436, 9584, 282, 1329, 402, 682, 9181, 5664, 1314, 1172, 199, 2355, 590, 12414, 666, 436, 13347, 1504, 14, 221, 961, 4910, 626, 370, 376, 1503, 14895, 695, 12, 314, 199, 335, 9181, 5664, 3648, 465, 1686, 465, 314, 336, 16614, 5664, 12, 436, 880, 314, 6299, 199, 2027, 854, 1172, 370, 506, 10585, 641, 4036, 1853, 14, 221, 4885, 9483, 6854, 314, 1329, 402, 682, 9181, 199, 4166, 3483, 370, 314, 1245, 12, 314, 8904, 883, 1852, 27485, 314, 1245, 199, 31598, 1183, 315, 771, 305, 7247, 14, 221, 6006, 787, 5002, 1163, 19604, 4382, 402, 199, 1589, 4747, 2131, 15, 335, 9181, 32414, 14, 199, 199, 1858, 2893, 12, 14722, 437, 3037, 365, 10209, 282, 1245, 370, 699, 2873, 14, 221, 428, 426, 1706, 69, 280, 90, 397, 314, 199, 1188, 436, 18628, 376, 1006, 13, 269, 13, 16323, 13315, 641, 314, 14593, 14, 221, 9442, 199, 19195, 28532, 2335, 1924, 3644, 543, 282, 1245, 6299, 1233, 334, 9410, 680, 221, 710, 199, 9410, 365, 282, 2631, 402, 314, 666, 3644, 12, 436, 2337, 365, 282, 7565, 790, 1314, 21920, 1471, 199, 6251, 543, 699, 2873, 334, 498, 4084, 365, 376, 26511, 3602, 370, 314, 7002, 680, 221, 428, 426, 2066, 199, 525, 83, 282, 3012, 1329, 370, 1924, 3644, 12, 436, 16178, 314, 14593, 370, 699, 2873, 14, 199, 199, 22593, 23192, 314, 14593, 12, 436, 1808, 314, 5709, 7565, 6299, 790, 12, 199, 1178, 2815, 2335, 314, 13347, 83, 367, 1924, 3644, 14, 221, 18049, 261, 14593, 626, 1172, 4875, 13347, 83, 787, 199, 11184, 590, 22002, 14, 221, 710, 15748, 787, 3355, 701, 3012, 1329, 12, 436, 3032, 199, 8304, 314, 3837, 1006, 13, 269, 13, 16323, 5793, 14, 221, 710, 5793, 4910, 626, 376, 199, 69, 7047, 4824, 529, 334, 19787, 662, 432, 9, 1471, 16919, 1006, 314, 14593, 2544, 1263, 402, 314, 666, 883, 199, 1235, 1586, 14, 221, 982, 2755, 1373, 3644, 365, 4124, 12, 314, 666, 365, 31291, 14, 199, 199, 10924, 1159, 1373, 8900, 631, 26, 701, 7791, 682, 9181, 14593, 12, 437, 3037, 436, 699, 2873, 883, 1852, 662, 432, 1159, 3906, 199, 77, 2133, 12159, 424, 12, 3967, 662, 432, 3063, 965, 370, 2059, 314, 5709, 7565, 790, 12, 503, 862, 4036, 199, 6560, 3155, 402, 336, 16614, 436, 682, 9181, 3644, 370, 1586, 1263, 402, 314, 1245, 14, 221, 710, 32268, 199, 2127, 365, 626, 699, 2873, 3181, 1133, 1929, 370, 1050, 1263, 4722, 1233, 27, 314, 682, 9181, 14593, 199, 1530, 2575, 9806, 734, 2952, 3932, 13347, 83, 2793, 1133, 1336, 334, 262, 1006, 22046, 1553, 199, 8585, 314, 666, 436, 13347, 83, 367, 314, 682, 9181, 14593, 787, 19311, 12414, 652, 365, 199, 13893, 12, 1325, 7437, 625, 24227, 626, 282, 682, 9181, 13347, 911, 1336, 314, 682, 9181, 666, 680, 221, 6061, 199, 28001, 1929, 440, 2755, 506, 314, 17135, 7791, 314, 682, 9181, 1, 221, 428, 426, 4293, 506, 14793, 199, 324, 14600, 626, 282, 10919, 17135, 12, 14722, 6659, 2978, 12, 365, 7791, 682, 9181, 14593, 370, 14737, 199, 3431, 465, 2985, 787, 29818, 14, 199, 199, 1858, 1655, 2556, 641, 4747, 2131, 316, 436, 682, 9181, 316, 1937, 642, 15220, 26, 199, 199, 50, 8125, 68, 491, 14, 820, 1912, 270, 12, 298, 1049, 9181, 316, 436, 13036, 2131, 316, 26, 1448, 329, 3256, 1209, 1928, 3447, 7950, 2, 199, 1014, 921, 1589, 1089, 14, 76, 1259, 14, 1147, 14, 8654, 22500, 6053, 270, 15, 335, 9181, 316, 14, 2424, 199, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 445, 2411, 556, 316, 14, 647, 12, 86, 413, 14, 23, 13004, 15, 996, 15, 1651, 4114, 26, 1789, 26, 2025, 282, 75, 2133, 2983, 7910, 2672, 2, 199, 199, 504, 18855, 14, 9562, 14, 1955, 492, 2783, 63, 475, 63, 2809, 199, 199, 533, 445, 2411, 556, 26, 272, 408, 2543, 18234, 314, 682, 9181, 7791, 5563, 14, 339, 17653, 367, 9180, 26, 953, 485, 3759, 1507, 8, 890, 304, 355, 1803, 282, 19311, 4046, 1329, 543, 282, 3696, 13, 1267, 4472, 355, 370, 1568, 14, 221, 20196, 883, 675, 642, 370, 5669, 8034, 2196, 355, 666, 436, 13347, 12999, 18036, 14, 221, 710, 849, 5563, 365, 355, 8646, 440, 7437, 13230, 25537, 11153, 14, 221, 2779, 365, 4750, 355, 11012, 626, 314, 682, 9181, 666, 1630, 440, 1395, 1263, 7970, 355, 626, 883, 506, 1202, 370, 4339, 27569, 652, 687, 336, 16614, 666, 1928, 3879, 355, 314, 13347, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 6535, 29, 17, 14, 16, 12, 5664, 529, 29, 17, 304, 267, 408, 1049, 9181, 8, 4778, 26, 1609, 12, 5664, 529, 26, 442, 9, 398, 6535, 365, 314, 1329, 402, 1245, 5664, 370, 1050, 682, 9181, 370, 12, 267, 19147, 465, 282, 16327, 3382, 378, 14, 16, 436, 413, 14, 16, 14, 221, 5664, 529, 365, 267, 314, 1329, 402, 682, 9181, 5664, 370, 2387, 367, 1924, 1853, 3769, 267, 682, 9181, 379, 14, 221, 20227, 314, 4243, 1050, 1373, 682, 9181, 1853, 370, 4036, 267, 1245, 1853, 14, 221, 4885, 13729, 314, 4243, 12, 1265, 883, 11311, 4212, 267, 14009, 1183, 29870, 652, 4293, 506, 367, 376, 1503, 14895, 695, 370, 267, 11665, 938, 13, 3990, 286, 8085, 314, 1245, 14, 221, 710, 23976, 17323, 365, 19147, 267, 465, 26, 953, 13131, 8, 4166, 529, 12, 1109, 8, 4778, 627, 1329, 13, 1618, 13, 4166, 430, 398, 2104, 325, 482, 402, 4514, 12, 1380, 6535, 665, 413, 14, 16, 12, 1454, 314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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 ]
oscarolar/odoo
openerp/report/printscreen/ps_form.py
381
5211
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import openerp from openerp.report.interface import report_int import openerp.tools as tools from openerp.report import render from lxml import etree import time, os class report_printscreen_list(report_int): def __init__(self, name): report_int.__init__(self, name) def _parse_node(self, root_node): result = [] for node in root_node: if node.tag == 'field': attrsa = node.attrib attrs = {} if not attrsa is None: for key,val in attrsa.items(): attrs[key] = val result.append(attrs['name']) else: result.extend(self._parse_node(node)) return result def _parse_string(self, view): dom = etree.XML(view) return self._parse_node(dom) def create(self, cr, uid, ids, datas, context=None): if not context: context={} datas['ids'] = ids registry = openerp.registry(cr.dbname) model = registry[datas['model']] # title come from description of model which are specified in py file. self.title = model._description result = model.fields_view_get(cr, uid, view_type='form', context=context) fields_order = self._parse_string(result['arch']) rows = model.read(cr, uid, datas['ids'], result['fields'].keys() ) self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model._description) return self.obj.get(), 'pdf' def _create_table(self, uid, ids, fields, fields_order, results, context, title=''): pageSize=[297.0,210.0] new_doc = etree.Element("report") config = etree.SubElement(new_doc, 'config') # build header def _append_node(name, text): n = etree.SubElement(config, name) n.text = text _append_node('date', time.strftime('%d/%m/%Y')) _append_node('PageSize', '%.2fmm,%.2fmm' % tuple(pageSize)) _append_node('PageWidth', '%.2f' % (pageSize[0] * 2.8346,)) _append_node('PageHeight', '%.2f' %(pageSize[1] * 2.8346,)) _append_node('report-header', title) l = [] t = 0 strmax = (pageSize[0]-40) * 2.8346 for f in fields_order: s = 0 if fields[f]['type'] in ('date','time','float','integer'): s = 60 strmax -= s else: t += fields[f].get('size', 56) / 28 + 1 l.append(s) for pos in range(len(l)): if not l[pos]: s = fields[fields_order[pos]].get('size', 56) / 28 + 1 l[pos] = strmax * s / t _append_node('tableSize', ','.join(map(str,l)) ) header = etree.SubElement(new_doc, 'header') for f in fields_order: field = etree.SubElement(header, 'field') field.text = fields[f]['string'] or '' lines = etree.SubElement(new_doc, 'lines') for line in results: node_line = etree.SubElement(lines, 'row') for f in fields_order: if fields[f]['type']=='many2one' and line[f]: line[f] = line[f][1] if fields[f]['type'] in ('one2many','many2many') and line[f]: line[f] = '( '+str(len(line[f])) + ' )' if fields[f]['type'] == 'float': precision=(('digits' in fields[f]) and fields[f]['digits'][1]) or 2 line[f]=round(line[f],precision) col = etree.SubElement(node_line, 'col', tree='no') if line[f] is not None: col.text = tools.ustr(line[f] or '') else: col.text = '/' transform = etree.XSLT( etree.parse(os.path.join(tools.config['root_path'], 'addons/base/report/custom_new.xsl'))) rml = etree.tostring(transform(new_doc)) self.obj = render.rml(rml, self.title) self.obj.render() return True report_printscreen_list('report.printscreen.form') # 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, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 5166, 199, 504, 5166, 14, 3070, 14, 3266, 492, 3622, 63, 442, 199, 646, 5166, 14, 2537, 465, 7249, 199, 199, 504, 5166, 14, 3070, 492, 3795, 199, 504, 14490, 492, 7559, 199, 199, 646, 900, 12, 747, 421, 199, 533, 3622, 63, 1361, 5410, 63, 513, 8, 3070, 63, 442, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 3622, 63, 442, 855, 826, 721, 277, 12, 536, 9, 339, 347, 485, 1122, 63, 932, 8, 277, 12, 1738, 63, 932, 304, 267, 754, 275, 942, 267, 367, 1031, 315, 1738, 63, 932, 26, 288, 340, 1031, 14, 1450, 508, 283, 698, 356, 355, 1921, 2231, 275, 1031, 14, 6640, 355, 3290, 275, 1052, 355, 340, 440, 1921, 2231, 365, 488, 26, 490, 367, 790, 12, 637, 315, 1921, 2231, 14, 1744, 837, 717, 3290, 59, 498, 61, 275, 1139, 355, 754, 14, 740, 8, 3288, 459, 354, 1105, 288, 587, 26, 355, 754, 14, 2880, 8, 277, 423, 1122, 63, 932, 8, 932, 430, 267, 372, 754, 339, 347, 485, 1122, 63, 875, 8, 277, 12, 2455, 304, 267, 8266, 275, 7559, 14, 4317, 8, 1345, 9, 267, 372, 291, 423, 1122, 63, 932, 8, 4556, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 29, 403, 304, 267, 340, 440, 1067, 26, 288, 1067, 7622, 267, 15012, 459, 1580, 418, 275, 2762, 267, 7086, 275, 5166, 14, 5189, 8, 1556, 14, 13238, 9, 267, 1402, 275, 7086, 59, 11563, 459, 1238, 6538, 267, 327, 2538, 11492, 687, 1369, 402, 1402, 1314, 787, 2013, 315, 1134, 570, 14, 267, 291, 14, 1213, 275, 1402, 423, 1802, 267, 754, 275, 1402, 14, 955, 63, 1345, 63, 362, 8, 1556, 12, 1747, 12, 2455, 63, 466, 534, 964, 297, 1067, 29, 1100, 9, 398, 1504, 63, 1648, 275, 291, 423, 1122, 63, 875, 8, 1099, 459, 1047, 1105, 267, 4730, 275, 1402, 14, 739, 8, 1556, 12, 1747, 12, 15012, 459, 1580, 995, 754, 459, 955, 2278, 1612, 342, 776, 267, 291, 423, 981, 63, 1224, 8, 1535, 12, 15012, 459, 1580, 995, 754, 459, 955, 995, 1504, 63, 1648, 12, 4730, 12, 1067, 12, 1402, 423, 1802, 9, 267, 372, 291, 14, 1113, 14, 362, 1062, 283, 5607, 7, 2378, 347, 485, 981, 63, 1224, 8, 277, 12, 1747, 12, 2762, 12, 1504, 12, 1504, 63, 1648, 12, 2058, 12, 1067, 12, 2538, 9280, 267, 2034, 2320, 1524, 12615, 14, 16, 12, 12725, 14, 16, 61, 398, 892, 63, 1301, 275, 7559, 14, 2162, 480, 3070, 531, 267, 1101, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 888, 358, 398, 327, 1900, 1406, 267, 347, 485, 740, 63, 932, 8, 354, 12, 1318, 304, 288, 302, 275, 7559, 14, 10571, 8, 888, 12, 536, 9, 288, 302, 14, 505, 275, 1318, 398, 485, 740, 63, 932, 360, 602, 297, 900, 14, 6205, 3508, 68, 3149, 77, 3149, 57, 1333, 267, 485, 740, 63, 932, 360, 3276, 2320, 297, 22769, 18, 70, 596, 8719, 14, 18, 70, 596, 7, 450, 2008, 8, 1606, 2320, 430, 267, 485, 740, 63, 932, 360, 3276, 6216, 297, 22769, 18, 70, 7, 450, 334, 1606, 2320, 59, 16, 61, 627, 499, 14, 24, 12583, 4641, 267, 485, 740, 63, 932, 360, 3276, 8436, 297, 22769, 18, 70, 7, 2818, 1606, 2320, 59, 17, 61, 627, 499, 14, 24, 12583, 4641, 267, 485, 740, 63, 932, 360, 3070, 13, 1291, 297, 2538, 9, 398, 634, 275, 942, 267, 307, 275, 378, 267, 620, 988, 275, 334, 1606, 2320, 59, 16, 11285, 2167, 9, 627, 499, 14, 24, 12583, 267, 367, 289, 315, 1504, 63, 1648, 26, 288, 308, 275, 378, 288, 340, 1504, 59, 70, 2733, 466, 418, 315, 661, 602, 1673, 521, 1673, 1609, 1673, 4115, 735, 355, 308, 275, 5212, 355, 620, 988, 4862, 308, 288, 587, 26, 355, 307, 847, 1504, 59, 70, 1055, 362, 360, 890, 297, 12001, 9, 1182, 7294, 435, 413, 288, 634, 14, 740, 8, 83, 9, 267, 367, 2086, 315, 1425, 8, 552, 8, 76, 2298, 288, 340, 440, 634, 59, 1712, 2189, 355, 308, 275, 1504, 59, 955, 63, 1648, 59, 1712, 20230, 362, 360, 890, 297, 12001, 9, 1182, 7294, 435, 413, 355, 634, 59, 1712, 61, 275, 620, 988, 627, 308, 1182, 307, 267, 485, 740, 63, 932, 360, 1224, 2320, 297, 12814, 904, 8, 1130, 8, 495, 12, 76, 430, 776, 398, 1406, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 1291, 358, 267, 367, 289, 315, 1504, 63, 1648, 26, 288, 901, 275, 7559, 14, 10571, 8, 1291, 12, 283, 698, 358, 288, 901, 14, 505, 275, 1504, 59, 70, 2733, 875, 418, 503, 2125, 398, 2385, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 1278, 358, 267, 367, 1004, 315, 2058, 26, 288, 1031, 63, 604, 275, 7559, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 5166, 199, 504, 5166, 14, 3070, 14, 3266, 492, 3622, 63, 442, 199, 646, 5166, 14, 2537, 465, 7249, 199, 199, 504, 5166, 14, 3070, 492, 3795, 199, 504, 14490, 492, 7559, 199, 199, 646, 900, 12, 747, 421, 199, 533, 3622, 63, 1361, 5410, 63, 513, 8, 3070, 63, 442, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 3622, 63, 442, 855, 826, 721, 277, 12, 536, 9, 339, 347, 485, 1122, 63, 932, 8, 277, 12, 1738, 63, 932, 304, 267, 754, 275, 942, 267, 367, 1031, 315, 1738, 63, 932, 26, 288, 340, 1031, 14, 1450, 508, 283, 698, 356, 355, 1921, 2231, 275, 1031, 14, 6640, 355, 3290, 275, 1052, 355, 340, 440, 1921, 2231, 365, 488, 26, 490, 367, 790, 12, 637, 315, 1921, 2231, 14, 1744, 837, 717, 3290, 59, 498, 61, 275, 1139, 355, 754, 14, 740, 8, 3288, 459, 354, 1105, 288, 587, 26, 355, 754, 14, 2880, 8, 277, 423, 1122, 63, 932, 8, 932, 430, 267, 372, 754, 339, 347, 485, 1122, 63, 875, 8, 277, 12, 2455, 304, 267, 8266, 275, 7559, 14, 4317, 8, 1345, 9, 267, 372, 291, 423, 1122, 63, 932, 8, 4556, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 29, 403, 304, 267, 340, 440, 1067, 26, 288, 1067, 7622, 267, 15012, 459, 1580, 418, 275, 2762, 267, 7086, 275, 5166, 14, 5189, 8, 1556, 14, 13238, 9, 267, 1402, 275, 7086, 59, 11563, 459, 1238, 6538, 267, 327, 2538, 11492, 687, 1369, 402, 1402, 1314, 787, 2013, 315, 1134, 570, 14, 267, 291, 14, 1213, 275, 1402, 423, 1802, 267, 754, 275, 1402, 14, 955, 63, 1345, 63, 362, 8, 1556, 12, 1747, 12, 2455, 63, 466, 534, 964, 297, 1067, 29, 1100, 9, 398, 1504, 63, 1648, 275, 291, 423, 1122, 63, 875, 8, 1099, 459, 1047, 1105, 267, 4730, 275, 1402, 14, 739, 8, 1556, 12, 1747, 12, 15012, 459, 1580, 995, 754, 459, 955, 2278, 1612, 342, 776, 267, 291, 423, 981, 63, 1224, 8, 1535, 12, 15012, 459, 1580, 995, 754, 459, 955, 995, 1504, 63, 1648, 12, 4730, 12, 1067, 12, 1402, 423, 1802, 9, 267, 372, 291, 14, 1113, 14, 362, 1062, 283, 5607, 7, 2378, 347, 485, 981, 63, 1224, 8, 277, 12, 1747, 12, 2762, 12, 1504, 12, 1504, 63, 1648, 12, 2058, 12, 1067, 12, 2538, 9280, 267, 2034, 2320, 1524, 12615, 14, 16, 12, 12725, 14, 16, 61, 398, 892, 63, 1301, 275, 7559, 14, 2162, 480, 3070, 531, 267, 1101, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 888, 358, 398, 327, 1900, 1406, 267, 347, 485, 740, 63, 932, 8, 354, 12, 1318, 304, 288, 302, 275, 7559, 14, 10571, 8, 888, 12, 536, 9, 288, 302, 14, 505, 275, 1318, 398, 485, 740, 63, 932, 360, 602, 297, 900, 14, 6205, 3508, 68, 3149, 77, 3149, 57, 1333, 267, 485, 740, 63, 932, 360, 3276, 2320, 297, 22769, 18, 70, 596, 8719, 14, 18, 70, 596, 7, 450, 2008, 8, 1606, 2320, 430, 267, 485, 740, 63, 932, 360, 3276, 6216, 297, 22769, 18, 70, 7, 450, 334, 1606, 2320, 59, 16, 61, 627, 499, 14, 24, 12583, 4641, 267, 485, 740, 63, 932, 360, 3276, 8436, 297, 22769, 18, 70, 7, 2818, 1606, 2320, 59, 17, 61, 627, 499, 14, 24, 12583, 4641, 267, 485, 740, 63, 932, 360, 3070, 13, 1291, 297, 2538, 9, 398, 634, 275, 942, 267, 307, 275, 378, 267, 620, 988, 275, 334, 1606, 2320, 59, 16, 11285, 2167, 9, 627, 499, 14, 24, 12583, 267, 367, 289, 315, 1504, 63, 1648, 26, 288, 308, 275, 378, 288, 340, 1504, 59, 70, 2733, 466, 418, 315, 661, 602, 1673, 521, 1673, 1609, 1673, 4115, 735, 355, 308, 275, 5212, 355, 620, 988, 4862, 308, 288, 587, 26, 355, 307, 847, 1504, 59, 70, 1055, 362, 360, 890, 297, 12001, 9, 1182, 7294, 435, 413, 288, 634, 14, 740, 8, 83, 9, 267, 367, 2086, 315, 1425, 8, 552, 8, 76, 2298, 288, 340, 440, 634, 59, 1712, 2189, 355, 308, 275, 1504, 59, 955, 63, 1648, 59, 1712, 20230, 362, 360, 890, 297, 12001, 9, 1182, 7294, 435, 413, 355, 634, 59, 1712, 61, 275, 620, 988, 627, 308, 1182, 307, 267, 485, 740, 63, 932, 360, 1224, 2320, 297, 12814, 904, 8, 1130, 8, 495, 12, 76, 430, 776, 398, 1406, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 1291, 358, 267, 367, 289, 315, 1504, 63, 1648, 26, 288, 901, 275, 7559, 14, 10571, 8, 1291, 12, 283, 698, 358, 288, 901, 14, 505, 275, 1504, 59, 70, 2733, 875, 418, 503, 2125, 398, 2385, 275, 7559, 14, 10571, 8, 1222, 63, 1301, 12, 283, 1278, 358, 267, 367, 1004, 315, 2058, 26, 288, 1031, 63, 604, 275, 7559, 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, 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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 ]
petertodd/checklocktimeverify-demos
lib/python-bitcoinlib/bitcoin/signature.py
10
1637
# Copyright (C) 2012-2014 The python-bitcoinlib developers # # This file is part of python-bitcoinlib. # # It is subject to the license terms in the LICENSE file found in the top-level # directory of this distribution. # # No part of python-bitcoinlib, including this file, may be copied, modified, # propagated, or distributed except according to the terms contained in the # LICENSE file. from __future__ import absolute_import, division, print_function, unicode_literals from bitcoin.core.serialize import * # Py3 compatibility import sys if sys.version > '3': from io import BytesIO as _BytesIO else: from cStringIO import StringIO as _BytesIO class DERSignature(ImmutableSerializable): __slots__ = ['length', 'r', 's'] def __init__(self, r, s, length): object.__setattr__(self, 'r', r) object.__setattr__(self, 's', s) object.__setattr__(self, 'length', length) @classmethod def stream_deserialize(cls, f): assert ser_read(f, 1) == b"\x30" rs = BytesSerializer.stream_deserialize(f) f = _BytesIO(rs) assert ser_read(f, 1) == b"\x02" r = BytesSerializer.stream_deserialize(f) assert ser_read(f, 1) == b"\x02" s = BytesSerializer.stream_deserialize(f) return cls(r, s, len(r + s)) def stream_serialize(self, f): f.write(b"\x30") f.write(b"\x02") BytesSerializer.stream_serialize(self.r, f) f.write(b"\x30") BytesSerializer.stream_serialize(self.s, f) def __repr__(self): return 'DERSignature(%s, %s)' % (self.r, self.s) __all__ = ( 'DERSignature', )
gpl-3.0
[ 3, 1898, 334, 35, 9, 6029, 13, 7280, 710, 2366, 13, 22816, 773, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2366, 13, 22816, 773, 14, 199, 3, 199, 3, 2779, 365, 5420, 370, 314, 4190, 2895, 315, 314, 5113, 570, 1911, 315, 314, 2746, 13, 1896, 199, 3, 2082, 402, 642, 4084, 14, 199, 3, 199, 3, 3091, 1777, 402, 2366, 13, 22816, 773, 12, 5893, 642, 570, 12, 1443, 506, 8876, 12, 6042, 12, 199, 3, 25350, 12, 503, 1854, 871, 7182, 370, 314, 2895, 10470, 315, 314, 199, 3, 5113, 570, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 504, 27214, 14, 1018, 14, 3549, 492, 627, 199, 199, 3, 1611, 19, 7163, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 690, 283, 19, 356, 272, 687, 5890, 492, 11808, 465, 485, 15466, 199, 2836, 26, 272, 687, 15073, 492, 5228, 465, 485, 15466, 421, 199, 533, 577, 3960, 1030, 1463, 8, 29174, 3571, 14065, 304, 272, 636, 7257, 363, 275, 788, 1267, 297, 283, 82, 297, 283, 83, 418, 339, 347, 636, 826, 721, 277, 12, 519, 12, 308, 12, 2582, 304, 267, 909, 855, 10202, 721, 277, 12, 283, 82, 297, 519, 9, 267, 909, 855, 10202, 721, 277, 12, 283, 83, 297, 308, 9, 267, 909, 855, 10202, 721, 277, 12, 283, 1267, 297, 2582, 9, 339, 768, 3744, 272, 347, 2547, 63, 11143, 8, 1886, 12, 289, 304, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 1216, 2, 267, 10717, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 289, 275, 485, 15466, 8, 2393, 9, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 996, 2, 267, 519, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 996, 2, 267, 308, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 372, 843, 8, 82, 12, 308, 12, 822, 8, 82, 435, 308, 430, 339, 347, 2547, 63, 3549, 8, 277, 12, 289, 304, 267, 289, 14, 952, 8, 66, 3212, 88, 1216, 531, 267, 289, 14, 952, 8, 66, 3212, 88, 996, 531, 267, 9879, 7299, 14, 1745, 63, 3549, 8, 277, 14, 82, 12, 289, 9, 267, 289, 14, 952, 8, 66, 3212, 88, 1216, 531, 267, 9879, 7299, 14, 1745, 63, 3549, 8, 277, 14, 83, 12, 289, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 36, 3960, 1030, 1463, 4042, 83, 12, 450, 83, 3171, 450, 334, 277, 14, 82, 12, 291, 14, 83, 9, 421, 199, 363, 452, 363, 275, 334, 272, 283, 36, 3960, 1030, 1463, 297, 199, 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 ]
[ 1898, 334, 35, 9, 6029, 13, 7280, 710, 2366, 13, 22816, 773, 19782, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2366, 13, 22816, 773, 14, 199, 3, 199, 3, 2779, 365, 5420, 370, 314, 4190, 2895, 315, 314, 5113, 570, 1911, 315, 314, 2746, 13, 1896, 199, 3, 2082, 402, 642, 4084, 14, 199, 3, 199, 3, 3091, 1777, 402, 2366, 13, 22816, 773, 12, 5893, 642, 570, 12, 1443, 506, 8876, 12, 6042, 12, 199, 3, 25350, 12, 503, 1854, 871, 7182, 370, 314, 2895, 10470, 315, 314, 199, 3, 5113, 570, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 504, 27214, 14, 1018, 14, 3549, 492, 627, 199, 199, 3, 1611, 19, 7163, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 690, 283, 19, 356, 272, 687, 5890, 492, 11808, 465, 485, 15466, 199, 2836, 26, 272, 687, 15073, 492, 5228, 465, 485, 15466, 421, 199, 533, 577, 3960, 1030, 1463, 8, 29174, 3571, 14065, 304, 272, 636, 7257, 363, 275, 788, 1267, 297, 283, 82, 297, 283, 83, 418, 339, 347, 636, 826, 721, 277, 12, 519, 12, 308, 12, 2582, 304, 267, 909, 855, 10202, 721, 277, 12, 283, 82, 297, 519, 9, 267, 909, 855, 10202, 721, 277, 12, 283, 83, 297, 308, 9, 267, 909, 855, 10202, 721, 277, 12, 283, 1267, 297, 2582, 9, 339, 768, 3744, 272, 347, 2547, 63, 11143, 8, 1886, 12, 289, 304, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 1216, 2, 267, 10717, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 289, 275, 485, 15466, 8, 2393, 9, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 996, 2, 267, 519, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 702, 8926, 63, 739, 8, 70, 12, 413, 9, 508, 330, 3212, 88, 996, 2, 267, 308, 275, 9879, 7299, 14, 1745, 63, 11143, 8, 70, 9, 267, 372, 843, 8, 82, 12, 308, 12, 822, 8, 82, 435, 308, 430, 339, 347, 2547, 63, 3549, 8, 277, 12, 289, 304, 267, 289, 14, 952, 8, 66, 3212, 88, 1216, 531, 267, 289, 14, 952, 8, 66, 3212, 88, 996, 531, 267, 9879, 7299, 14, 1745, 63, 3549, 8, 277, 14, 82, 12, 289, 9, 267, 289, 14, 952, 8, 66, 3212, 88, 1216, 531, 267, 9879, 7299, 14, 1745, 63, 3549, 8, 277, 14, 83, 12, 289, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 36, 3960, 1030, 1463, 4042, 83, 12, 450, 83, 3171, 450, 334, 277, 14, 82, 12, 291, 14, 83, 9, 421, 199, 363, 452, 363, 275, 334, 272, 283, 36, 3960, 1030, 1463, 297, 199, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
neslihanturan/artge
app/signals.py
1
2014
from django.db.models.signals import post_save, pre_delete, pre_save from django.dispatch import receiver from app.forms import MenuForm from django import forms from app.models import * from django.core.exceptions import ObjectDoesNotExist #from django.db.models.base import ObjectDoesNotExist @receiver(post_save, sender=SubMenuItem) def sub_menu_post_save(sender, **kwargs): try: instance = kwargs.get('instance', None) if instance.menuitem.smenus.count() == 1: # first sub menu created print('ilkini olusturdun') MenuItem.objects.filter(pk=instance.menuitem.pk).update(is_active = False) #if dont update db, only this instance will be updated instance.menuitem.refresh_from_db() #to make all instances syncronised print("from signals= title:",instance.menuitem.item_name," id:",id(instance.menuitem),", aktif mi:",instance.menuitem.is_active) ##delete code here ###MenuForm.remove_field(instance.menuitem.form) print("2. message",instance.menuitem.smenus.count()) except (MenuItem.DoesNotExist, ObjectDoesNotExist) as e: print('error2') @receiver(pre_delete, sender=SubMenuItem) def sub_menu_pre_delete(sender, **kwargs): print("deleting") try: instance = kwargs.get('instance', None) if instance.menuitem.smenus.count() == 1: # last remained sub menu will be deleted soon print('hepsini sildin') MenuItem.objects.filter(pk=instance.menuitem.pk).update(is_active = True) #if dont update db, only this instance will be updated instance.menuitem.refresh_from_db() #to make all instances syncronised print("1. message",instance.menuitem.smenus.count()) except (MenuItem.DoesNotExist, ObjectDoesNotExist) as e: print('error1') post_save.connect(sub_menu_post_save, sender=SubMenuItem, dispatch_uid="sub_menu_post_save") pre_delete.connect(sub_menu_pre_delete, sender=SubMenuItem, dispatch_uid="sub_menu_pre_delete")
gpl-3.0
[ 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 2963, 63, 2117, 12, 876, 63, 1807, 12, 876, 63, 2117, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1145, 14, 3351, 492, 18281, 2821, 199, 504, 1639, 492, 4513, 199, 504, 1145, 14, 992, 492, 627, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 3, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 24803, 199, 199, 32, 10244, 8, 1932, 63, 2117, 12, 8904, 29, 2610, 20973, 9, 199, 318, 1007, 63, 4470, 63, 1932, 63, 2117, 8, 8114, 12, 1011, 958, 304, 272, 862, 26, 267, 1256, 275, 2074, 14, 362, 360, 842, 297, 488, 9, 267, 340, 1256, 14, 4470, 1053, 14, 83, 30969, 14, 835, 342, 508, 413, 26, 327, 1642, 1007, 6269, 2737, 288, 870, 360, 382, 75, 2730, 9113, 833, 300, 68, 324, 358, 288, 18281, 2081, 14, 1462, 14, 1541, 8, 2051, 29, 842, 14, 4470, 1053, 14, 2051, 680, 873, 8, 374, 63, 2682, 275, 756, 9, 221, 327, 692, 21542, 1678, 1592, 12, 1454, 642, 1256, 911, 506, 4588, 288, 1256, 14, 4470, 1053, 14, 6635, 63, 504, 63, 697, 342, 327, 475, 1852, 1006, 4454, 9560, 14829, 9096, 288, 870, 480, 504, 10166, 29, 2538, 6783, 842, 14, 4470, 1053, 14, 1053, 63, 354, 4589, 1305, 6783, 344, 8, 842, 14, 4470, 1053, 395, 401, 282, 75, 9142, 10684, 6783, 842, 14, 4470, 1053, 14, 374, 63, 2682, 9, 288, 925, 1807, 1233, 2348, 288, 6754, 5977, 2821, 14, 2168, 63, 698, 8, 842, 14, 4470, 1053, 14, 964, 9, 267, 870, 480, 18, 14, 1245, 401, 842, 14, 4470, 1053, 14, 83, 30969, 14, 835, 1012, 272, 871, 334, 20973, 14, 7400, 12, 24803, 9, 465, 325, 26, 267, 870, 360, 705, 18, 358, 421, 199, 32, 10244, 8, 657, 63, 1807, 12, 8904, 29, 2610, 20973, 9, 199, 318, 1007, 63, 4470, 63, 657, 63, 1807, 8, 8114, 12, 1011, 958, 304, 272, 870, 480, 7346, 1337, 531, 272, 862, 26, 267, 1256, 275, 2074, 14, 362, 360, 842, 297, 488, 9, 267, 340, 1256, 14, 4470, 1053, 14, 83, 30969, 14, 835, 342, 508, 413, 26, 327, 2061, 5706, 379, 1007, 6269, 911, 506, 5463, 18930, 288, 870, 360, 426, 1190, 2730, 308, 668, 262, 358, 288, 18281, 2081, 14, 1462, 14, 1541, 8, 2051, 29, 842, 14, 4470, 1053, 14, 2051, 680, 873, 8, 374, 63, 2682, 275, 715, 9, 221, 327, 692, 21542, 1678, 1592, 12, 1454, 642, 1256, 911, 506, 4588, 288, 1256, 14, 4470, 1053, 14, 6635, 63, 504, 63, 697, 342, 327, 475, 1852, 1006, 4454, 9560, 14829, 9096, 267, 870, 480, 17, 14, 1245, 401, 842, 14, 4470, 1053, 14, 83, 30969, 14, 835, 1012, 272, 871, 334, 20973, 14, 7400, 12, 24803, 9, 465, 325, 26, 267, 870, 360, 705, 17, 358, 199, 199, 1932, 63, 2117, 14, 2242, 8, 954, 63, 4470, 63, 1932, 63, 2117, 12, 8904, 29, 2610, 20973, 12, 7634, 63, 1535, 628, 954, 63, 4470, 63, 1932, 63, 2117, 531, 199, 657, 63, 1807, 14, 2242, 8, 954, 63, 4470, 63, 657, 63, 1807, 12, 8904, 29, 2610, 20973, 12, 7634, 63, 1535, 628, 954, 63, 4470, 63, 657, 63, 1807, 531, 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 ]
[ 1639, 14, 697, 14, 992, 14, 10458, 492, 2963, 63, 2117, 12, 876, 63, 1807, 12, 876, 63, 2117, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1145, 14, 3351, 492, 18281, 2821, 199, 504, 1639, 492, 4513, 199, 504, 1145, 14, 992, 492, 627, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 3, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 24803, 199, 199, 32, 10244, 8, 1932, 63, 2117, 12, 8904, 29, 2610, 20973, 9, 199, 318, 1007, 63, 4470, 63, 1932, 63, 2117, 8, 8114, 12, 1011, 958, 304, 272, 862, 26, 267, 1256, 275, 2074, 14, 362, 360, 842, 297, 488, 9, 267, 340, 1256, 14, 4470, 1053, 14, 83, 30969, 14, 835, 342, 508, 413, 26, 327, 1642, 1007, 6269, 2737, 288, 870, 360, 382, 75, 2730, 9113, 833, 300, 68, 324, 358, 288, 18281, 2081, 14, 1462, 14, 1541, 8, 2051, 29, 842, 14, 4470, 1053, 14, 2051, 680, 873, 8, 374, 63, 2682, 275, 756, 9, 221, 327, 692, 21542, 1678, 1592, 12, 1454, 642, 1256, 911, 506, 4588, 288, 1256, 14, 4470, 1053, 14, 6635, 63, 504, 63, 697, 342, 327, 475, 1852, 1006, 4454, 9560, 14829, 9096, 288, 870, 480, 504, 10166, 29, 2538, 6783, 842, 14, 4470, 1053, 14, 1053, 63, 354, 4589, 1305, 6783, 344, 8, 842, 14, 4470, 1053, 395, 401, 282, 75, 9142, 10684, 6783, 842, 14, 4470, 1053, 14, 374, 63, 2682, 9, 288, 925, 1807, 1233, 2348, 288, 6754, 5977, 2821, 14, 2168, 63, 698, 8, 842, 14, 4470, 1053, 14, 964, 9, 267, 870, 480, 18, 14, 1245, 401, 842, 14, 4470, 1053, 14, 83, 30969, 14, 835, 1012, 272, 871, 334, 20973, 14, 7400, 12, 24803, 9, 465, 325, 26, 267, 870, 360, 705, 18, 358, 421, 199, 32, 10244, 8, 657, 63, 1807, 12, 8904, 29, 2610, 20973, 9, 199, 318, 1007, 63, 4470, 63, 657, 63, 1807, 8, 8114, 12, 1011, 958, 304, 272, 870, 480, 7346, 1337, 531, 272, 862, 26, 267, 1256, 275, 2074, 14, 362, 360, 842, 297, 488, 9, 267, 340, 1256, 14, 4470, 1053, 14, 83, 30969, 14, 835, 342, 508, 413, 26, 327, 2061, 5706, 379, 1007, 6269, 911, 506, 5463, 18930, 288, 870, 360, 426, 1190, 2730, 308, 668, 262, 358, 288, 18281, 2081, 14, 1462, 14, 1541, 8, 2051, 29, 842, 14, 4470, 1053, 14, 2051, 680, 873, 8, 374, 63, 2682, 275, 715, 9, 221, 327, 692, 21542, 1678, 1592, 12, 1454, 642, 1256, 911, 506, 4588, 288, 1256, 14, 4470, 1053, 14, 6635, 63, 504, 63, 697, 342, 327, 475, 1852, 1006, 4454, 9560, 14829, 9096, 267, 870, 480, 17, 14, 1245, 401, 842, 14, 4470, 1053, 14, 83, 30969, 14, 835, 1012, 272, 871, 334, 20973, 14, 7400, 12, 24803, 9, 465, 325, 26, 267, 870, 360, 705, 17, 358, 199, 199, 1932, 63, 2117, 14, 2242, 8, 954, 63, 4470, 63, 1932, 63, 2117, 12, 8904, 29, 2610, 20973, 12, 7634, 63, 1535, 628, 954, 63, 4470, 63, 1932, 63, 2117, 531, 199, 657, 63, 1807, 14, 2242, 8, 954, 63, 4470, 63, 657, 63, 1807, 12, 8904, 29, 2610, 20973, 12, 7634, 63, 1535, 628, 954, 63, 4470, 63, 657, 63, 1807, 531, 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, 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,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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 ]
Boussadia/weboob
modules/hybride/calendar.py
6
1146
# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class HybrideCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.city = u'Lille' self.location = u'18 rue Gosselet' self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.category = CATEGORIES.CINE
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 6423, 90, 274, 80, 762, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 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, 29896, 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, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 29896, 14, 10732, 14, 8183, 492, 3523, 18688, 2390, 12, 9074, 5622, 48, 12, 18460, 12, 445, 12649, 28743, 421, 199, 533, 869, 28564, 2188, 18688, 2390, 8, 1563, 18688, 2390, 304, 339, 347, 636, 826, 721, 277, 304, 267, 3523, 18688, 2390, 855, 826, 721, 277, 9, 267, 291, 14, 3690, 275, 399, 7, 44, 17142, 7, 267, 291, 14, 1985, 275, 399, 7, 1085, 221, 431, 598, 736, 261, 2723, 7, 267, 291, 14, 4041, 275, 413, 267, 291, 14, 3936, 681, 275, 9074, 5622, 48, 14, 12191, 20562, 267, 291, 14, 1205, 275, 18460, 14, 1864, 28830, 1149, 267, 291, 14, 3710, 275, 445, 12649, 28743, 14, 35, 3565, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 6423, 90, 274, 80, 762, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 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, 29896, 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, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 29896, 14, 10732, 14, 8183, 492, 3523, 18688, 2390, 12, 9074, 5622, 48, 12, 18460, 12, 445, 12649, 28743, 421, 199, 533, 869, 28564, 2188, 18688, 2390, 8, 1563, 18688, 2390, 304, 339, 347, 636, 826, 721, 277, 304, 267, 3523, 18688, 2390, 855, 826, 721, 277, 9, 267, 291, 14, 3690, 275, 399, 7, 44, 17142, 7, 267, 291, 14, 1985, 275, 399, 7, 1085, 221, 431, 598, 736, 261, 2723, 7, 267, 291, 14, 4041, 275, 413, 267, 291, 14, 3936, 681, 275, 9074, 5622, 48, 14, 12191, 20562, 267, 291, 14, 1205, 275, 18460, 14, 1864, 28830, 1149, 267, 291, 14, 3710, 275, 445, 12649, 28743, 14, 35, 3565, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
googlefonts/cu2qu
tests/utils.py
2
9055
from __future__ import print_function, division, absolute_import from . import CUBIC_GLYPHS from fontTools.pens.pointPen import PointToSegmentPen, SegmentToPointPen from fontTools.misc.py23 import isclose import unittest class BaseDummyPen(object): """Base class for pens that record the commands they are called with.""" def __init__(self, *args, **kwargs): self.commands = [] def __str__(self): """Return the pen commands as a string of python code.""" return _repr_pen_commands(self.commands) def addComponent(self, glyphName, transformation, **kwargs): self.commands.append(('addComponent', (glyphName, transformation), kwargs)) class DummyPen(BaseDummyPen): """A SegmentPen that records the commands it's called with.""" def moveTo(self, pt): self.commands.append(('moveTo', (pt,), {})) def lineTo(self, pt): self.commands.append(('lineTo', (pt,), {})) def curveTo(self, *points): self.commands.append(('curveTo', points, {})) def qCurveTo(self, *points): self.commands.append(('qCurveTo', points, {})) def closePath(self): self.commands.append(('closePath', tuple(), {})) def endPath(self): self.commands.append(('endPath', tuple(), {})) class DummyPointPen(BaseDummyPen): """A PointPen that records the commands it's called with.""" def beginPath(self, **kwargs): self.commands.append(('beginPath', tuple(), kwargs)) def endPath(self): self.commands.append(('endPath', tuple(), {})) def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs): kwargs['segmentType'] = str(segmentType) if segmentType else None kwargs['smooth'] = smooth kwargs['name'] = name self.commands.append(('addPoint', (pt,), kwargs)) class DummyGlyph(object): """Provides a minimal interface for storing a glyph's outline data in a SegmentPen-oriented way. The glyph's outline consists in the list of SegmentPen commands required to draw it. """ # the SegmentPen class used to draw on this glyph type DrawingPen = DummyPen def __init__(self, glyph=None): """If another glyph (i.e. any object having a 'draw' method) is given, its outline data is copied to self. """ self._pen = self.DrawingPen() self.outline = self._pen.commands if glyph: self.appendGlyph(glyph) def appendGlyph(self, glyph): """Copy another glyph's outline onto self.""" glyph.draw(self._pen) def getPen(self): """Return the SegmentPen that can 'draw' on this glyph.""" return self._pen def getPointPen(self): """Return a PointPen adapter that can 'draw' on this glyph.""" return PointToSegmentPen(self._pen) def draw(self, pen): """Use another SegmentPen to replay the glyph's outline commands.""" if self.outline: for cmd, args, kwargs in self.outline: getattr(pen, cmd)(*args, **kwargs) def drawPoints(self, pointPen): """Use another PointPen to replay the glyph's outline commands, indirectly through an adapter. """ pen = SegmentToPointPen(pointPen) self.draw(pen) def __eq__(self, other): """Return True if 'other' glyph's outline is the same as self.""" if hasattr(other, 'outline'): return self.outline == other.outline elif hasattr(other, 'draw'): return self.outline == self.__class__(other).outline return NotImplemented def __ne__(self, other): """Return True if 'other' glyph's outline is different from self.""" return not (self == other) def approx(self, other, rel_tol=1e-12): if hasattr(other, 'outline'): outline2 == other.outline elif hasattr(other, 'draw'): outline2 = self.__class__(other).outline else: raise TypeError(type(other).__name__) outline1 = self.outline if len(outline1) != len(outline2): return False for (cmd1, arg1, kwd1), (cmd2, arg2, kwd2) in zip(outline1, outline2): if cmd1 != cmd2: return False if kwd1 != kwd2: return False if arg1: if isinstance(arg1[0], tuple): if not arg2 or not isinstance(arg2[0], tuple): return False for (x1, y1), (x2, y2) in zip(arg1, arg2): if ( not isclose(x1, x2, rel_tol=rel_tol) or not isclose(y1, y2, rel_tol=rel_tol) ): return False elif arg1 != arg2: return False elif arg2: return False return True def __str__(self): """Return commands making up the glyph's outline as a string.""" return str(self._pen) class DummyPointGlyph(DummyGlyph): """Provides a minimal interface for storing a glyph's outline data in a PointPen-oriented way. The glyph's outline consists in the list of PointPen commands required to draw it. """ # the PointPen class used to draw on this glyph type DrawingPen = DummyPointPen def appendGlyph(self, glyph): """Copy another glyph's outline onto self.""" glyph.drawPoints(self._pen) def getPen(self): """Return a SegmentPen adapter that can 'draw' on this glyph.""" return SegmentToPointPen(self._pen) def getPointPen(self): """Return the PointPen that can 'draw' on this glyph.""" return self._pen def draw(self, pen): """Use another SegmentPen to replay the glyph's outline commands, indirectly through an adapter. """ pointPen = PointToSegmentPen(pen) self.drawPoints(pointPen) def drawPoints(self, pointPen): """Use another PointPen to replay the glyph's outline commands.""" if self.outline: for cmd, args, kwargs in self.outline: getattr(pointPen, cmd)(*args, **kwargs) def _repr_pen_commands(commands): """ >>> print(_repr_pen_commands([ ... ('moveTo', tuple(), {}), ... ('lineTo', ((1.0, 0.1),), {}), ... ('curveTo', ((1.0, 0.1), (2.0, 0.2), (3.0, 0.3)), {}) ... ])) pen.moveTo() pen.lineTo((1, 0.1)) pen.curveTo((1, 0.1), (2, 0.2), (3, 0.3)) >>> print(_repr_pen_commands([ ... ('beginPath', tuple(), {}), ... ('addPoint', ((1.0, 0.1),), ... {"segmentType":"line", "smooth":True, "name":"test", "z":1}), ... ])) pen.beginPath() pen.addPoint((1, 0.1), name='test', segmentType='line', smooth=True, z=1) >>> print(_repr_pen_commands([ ... ('addComponent', ('A', (1, 0, 0, 1, 0, 0)), {}) ... ])) pen.addComponent('A', (1, 0, 0, 1, 0, 0)) """ s = [] for cmd, args, kwargs in commands: if args: if isinstance(args[0], tuple): # cast float to int if there're no digits after decimal point, # and round floats to 12 decimal digits (more than enough) args = [ tuple((int(v) if int(v) == v else round(v, 12)) for v in pt) for pt in args ] args = ", ".join(repr(a) for a in args) if kwargs: kwargs = ", ".join("%s=%r" % (k, v) for k, v in sorted(kwargs.items())) if args and kwargs: s.append("pen.%s(%s, %s)" % (cmd, args, kwargs)) elif args: s.append("pen.%s(%s)" % (cmd, args)) elif kwargs: s.append("pen.%s(%s)" % (cmd, kwargs)) else: s.append("pen.%s()" % cmd) return "\n".join(s) class TestDummyGlyph(unittest.TestCase): def test_equal(self): # verify that the copy and the copy of the copy are equal to # the source glyph's outline, as well as to each other source = CUBIC_GLYPHS['a'] copy = DummyGlyph(source) copy2 = DummyGlyph(copy) self.assertEqual(source, copy) self.assertEqual(source, copy2) self.assertEqual(copy, copy2) # assert equality doesn't hold any more after modification copy.outline.pop() self.assertNotEqual(source, copy) self.assertNotEqual(copy, copy2) class TestDummyPointGlyph(unittest.TestCase): def test_equal(self): # same as above but using the PointPen protocol source = CUBIC_GLYPHS['a'] copy = DummyPointGlyph(source) copy2 = DummyPointGlyph(copy) self.assertEqual(source, copy) self.assertEqual(source, copy2) self.assertEqual(copy, copy2) copy.outline.pop() self.assertNotEqual(source, copy) self.assertNotEqual(copy, copy2) if __name__ == "__main__": unittest.main()
apache-2.0
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 3679, 63, 646, 199, 504, 1275, 492, 445, 2533, 948, 63, 2226, 7431, 15467, 199, 504, 5023, 11654, 14, 897, 83, 14, 1403, 15597, 492, 7584, 1378, 12520, 15597, 12, 29858, 23807, 15597, 199, 504, 5023, 11654, 14, 9923, 14, 647, 1789, 492, 365, 1600, 199, 646, 2882, 421, 199, 533, 3523, 11324, 15597, 8, 785, 304, 272, 408, 1563, 1021, 367, 299, 8764, 626, 2777, 314, 3718, 2985, 787, 2797, 543, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 4405, 275, 942, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 314, 12374, 3718, 465, 282, 1059, 402, 2366, 1233, 1041, 267, 372, 485, 2722, 63, 897, 63, 4405, 8, 277, 14, 4405, 9, 339, 347, 1050, 7004, 8, 277, 12, 14165, 985, 12, 13315, 12, 1011, 958, 304, 267, 291, 14, 4405, 14, 740, 4725, 525, 7004, 297, 334, 26768, 12, 13315, 395, 2074, 430, 421, 199, 533, 9762, 15597, 8, 1563, 11324, 15597, 304, 272, 408, 33, 29858, 15597, 626, 5767, 314, 3718, 652, 1159, 2797, 543, 1041, 339, 347, 4057, 1378, 8, 277, 12, 10063, 304, 267, 291, 14, 4405, 14, 740, 4725, 31773, 297, 334, 541, 4706, 17003, 339, 347, 1004, 1378, 8, 277, 12, 10063, 304, 267, 291, 14, 4405, 14, 740, 4725, 604, 1378, 297, 334, 541, 4706, 17003, 339, 347, 15318, 1378, 8, 277, 12, 627, 3438, 304, 267, 291, 14, 4405, 14, 740, 4725, 11895, 1378, 297, 4501, 12, 17003, 339, 347, 1894, 20966, 1378, 8, 277, 12, 627, 3438, 304, 267, 291, 14, 4405, 14, 740, 4725, 81, 20966, 1378, 297, 4501, 12, 17003, 339, 347, 4002, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 1600, 2042, 297, 2008, 1062, 17003, 339, 347, 1284, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 500, 2042, 297, 2008, 1062, 17003, 421, 199, 533, 9762, 3428, 15597, 8, 1563, 11324, 15597, 304, 272, 408, 33, 7584, 15597, 626, 5767, 314, 3718, 652, 1159, 2797, 543, 1041, 339, 347, 5386, 2042, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 4405, 14, 740, 4725, 5037, 2042, 297, 2008, 1062, 2074, 430, 339, 347, 1284, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 500, 2042, 297, 2008, 1062, 17003, 339, 347, 1050, 3428, 8, 277, 12, 10063, 12, 8135, 804, 29, 403, 12, 19608, 29, 797, 12, 536, 29, 403, 12, 1011, 958, 304, 267, 2074, 459, 9255, 804, 418, 275, 620, 8, 9255, 804, 9, 340, 8135, 804, 587, 488, 267, 2074, 459, 19169, 418, 275, 19608, 267, 2074, 459, 354, 418, 275, 536, 267, 291, 14, 4405, 14, 740, 4725, 525, 3428, 297, 334, 541, 4706, 2074, 430, 421, 199, 533, 9762, 15533, 8, 785, 304, 272, 408, 17473, 282, 13460, 3217, 367, 16915, 282, 14165, 1159, 17964, 666, 315, 282, 272, 29858, 15597, 13, 16039, 287, 471, 4340, 14, 710, 14165, 1159, 17964, 18581, 315, 314, 769, 402, 272, 29858, 15597, 3718, 1415, 370, 5954, 652, 14, 272, 408, 339, 327, 314, 29858, 15597, 1021, 1202, 370, 5954, 641, 642, 14165, 730, 272, 17813, 316, 15597, 275, 9762, 15597, 339, 347, 636, 826, 721, 277, 12, 14165, 29, 403, 304, 267, 408, 3917, 4573, 14165, 334, 73, 14, 69, 14, 1263, 909, 9445, 282, 283, 5485, 7, 1083, 9, 365, 1627, 12, 267, 2399, 17964, 666, 365, 8876, 370, 291, 14, 267, 408, 267, 291, 423, 897, 275, 291, 14, 9654, 316, 15597, 342, 267, 291, 14, 11550, 275, 291, 423, 897, 14, 4405, 267, 340, 14165, 26, 288, 291, 14, 740, 15533, 8, 13723, 9, 339, 347, 5666, 15533, 8, 277, 12, 14165, 304, 267, 408, 5116, 4573, 14165, 1159, 17964, 14602, 291, 1041, 267, 14165, 14, 5485, 8, 277, 423, 897, 9, 339, 347, 664, 15597, 8, 277, 304, 267, 408, 1767, 314, 29858, 15597, 626, 883, 283, 5485, 7, 641, 642, 14165, 1041, 267, 372, 291, 423, 897, 339, 347, 664, 3428, 15597, 8, 277, 304, 267, 408, 1767, 282, 7584, 15597, 12146, 626, 883, 283, 5485, 7, 641, 642, 14165, 1041, 267, 372, 7584, 1378, 12520, 15597, 8, 277, 423, 897, 9, 339, 347, 5954, 8, 277, 12, 12374, 304, 267, 408, 6119, 4573, 29858, 15597, 370, 24331, 314, 14165, 1159, 17964, 3718, 1041, 267, 340, 291, 14, 11550, 26, 288, 367, 2088, 12, 1249, 12, 2074, 315, 291, 14, 11550, 26, 355, 2519, 8, 897, 12, 2088, 25967, 589, 12, 1011, 958, 9, 339, 347, 5954, 10225, 8, 277, 12, 2376, 15597, 304, 267, 408, 6119, 4573, 7584, 15597, 370, 24331, 314, 14165, 1159, 17964, 3718, 12, 267, 19458, 590, 4012, 376, 12146, 14, 267, 408, 267, 12374, 275, 29858, 23807, 15597, 8, 1403, 15597, 9, 267, 291, 14, 5485, 8, 897, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 1767, 715, 340, 283, 1848, 7, 14165, 1159, 17964, 365, 314, 2011, 465, 291, 1041, 267, 340, 2688, 8, 1848, 12, 283, 11550, 735, 288, 372, 291, 14, 11550, 508, 1163, 14, 11550, 267, 916, 2688, 8, 1848, 12, 283, 5485, 735, 288, 372, 291, 14, 11550, 508, 291, 855, 533, 721, 1848, 680, 11550, 267, 372, 3784, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 408, 1767, 715, 340, 283, 1848, 7, 14165, 1159, 17964, 365, 3365, 687, 291, 1041, 267, 372, 440, 334, 277, 508, 1163, 9, 339, 347, 14106, 8, 277, 12, 1163, 12, 4668, 63, 6896, 29, 17, 69, 13, 713, 304, 267, 340, 2688, 8, 1848, 12, 283, 11550, 735, 288, 17964, 18, 508, 1163, 14, 11550, 267, 916, 2688, 8, 1848, 12, 283, 5485, 735, 288, 17964, 18, 275, 291, 855, 533, 721, 1848, 680, 11550, 267, 587, 26, 288, 746, 3146, 8, 466, 8, 1848, 2843, 354, 3368, 267, 17964, 17, 275, 291, 14, 11550, 267, 340, 822, 8, 11550, 17, 9, 1137, 822, 8, 11550, 18, 304, 288, 372, 756, 267, 367, 334, 1760, 17, 12, 1680, 17, 12, 4775, 68, 17, 395, 334, 1760, 18, 12, 1680, 18, 12, 4775, 68, 18, 9, 315, 3482, 8 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 3679, 63, 646, 199, 504, 1275, 492, 445, 2533, 948, 63, 2226, 7431, 15467, 199, 504, 5023, 11654, 14, 897, 83, 14, 1403, 15597, 492, 7584, 1378, 12520, 15597, 12, 29858, 23807, 15597, 199, 504, 5023, 11654, 14, 9923, 14, 647, 1789, 492, 365, 1600, 199, 646, 2882, 421, 199, 533, 3523, 11324, 15597, 8, 785, 304, 272, 408, 1563, 1021, 367, 299, 8764, 626, 2777, 314, 3718, 2985, 787, 2797, 543, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 4405, 275, 942, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 314, 12374, 3718, 465, 282, 1059, 402, 2366, 1233, 1041, 267, 372, 485, 2722, 63, 897, 63, 4405, 8, 277, 14, 4405, 9, 339, 347, 1050, 7004, 8, 277, 12, 14165, 985, 12, 13315, 12, 1011, 958, 304, 267, 291, 14, 4405, 14, 740, 4725, 525, 7004, 297, 334, 26768, 12, 13315, 395, 2074, 430, 421, 199, 533, 9762, 15597, 8, 1563, 11324, 15597, 304, 272, 408, 33, 29858, 15597, 626, 5767, 314, 3718, 652, 1159, 2797, 543, 1041, 339, 347, 4057, 1378, 8, 277, 12, 10063, 304, 267, 291, 14, 4405, 14, 740, 4725, 31773, 297, 334, 541, 4706, 17003, 339, 347, 1004, 1378, 8, 277, 12, 10063, 304, 267, 291, 14, 4405, 14, 740, 4725, 604, 1378, 297, 334, 541, 4706, 17003, 339, 347, 15318, 1378, 8, 277, 12, 627, 3438, 304, 267, 291, 14, 4405, 14, 740, 4725, 11895, 1378, 297, 4501, 12, 17003, 339, 347, 1894, 20966, 1378, 8, 277, 12, 627, 3438, 304, 267, 291, 14, 4405, 14, 740, 4725, 81, 20966, 1378, 297, 4501, 12, 17003, 339, 347, 4002, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 1600, 2042, 297, 2008, 1062, 17003, 339, 347, 1284, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 500, 2042, 297, 2008, 1062, 17003, 421, 199, 533, 9762, 3428, 15597, 8, 1563, 11324, 15597, 304, 272, 408, 33, 7584, 15597, 626, 5767, 314, 3718, 652, 1159, 2797, 543, 1041, 339, 347, 5386, 2042, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 4405, 14, 740, 4725, 5037, 2042, 297, 2008, 1062, 2074, 430, 339, 347, 1284, 2042, 8, 277, 304, 267, 291, 14, 4405, 14, 740, 4725, 500, 2042, 297, 2008, 1062, 17003, 339, 347, 1050, 3428, 8, 277, 12, 10063, 12, 8135, 804, 29, 403, 12, 19608, 29, 797, 12, 536, 29, 403, 12, 1011, 958, 304, 267, 2074, 459, 9255, 804, 418, 275, 620, 8, 9255, 804, 9, 340, 8135, 804, 587, 488, 267, 2074, 459, 19169, 418, 275, 19608, 267, 2074, 459, 354, 418, 275, 536, 267, 291, 14, 4405, 14, 740, 4725, 525, 3428, 297, 334, 541, 4706, 2074, 430, 421, 199, 533, 9762, 15533, 8, 785, 304, 272, 408, 17473, 282, 13460, 3217, 367, 16915, 282, 14165, 1159, 17964, 666, 315, 282, 272, 29858, 15597, 13, 16039, 287, 471, 4340, 14, 710, 14165, 1159, 17964, 18581, 315, 314, 769, 402, 272, 29858, 15597, 3718, 1415, 370, 5954, 652, 14, 272, 408, 339, 327, 314, 29858, 15597, 1021, 1202, 370, 5954, 641, 642, 14165, 730, 272, 17813, 316, 15597, 275, 9762, 15597, 339, 347, 636, 826, 721, 277, 12, 14165, 29, 403, 304, 267, 408, 3917, 4573, 14165, 334, 73, 14, 69, 14, 1263, 909, 9445, 282, 283, 5485, 7, 1083, 9, 365, 1627, 12, 267, 2399, 17964, 666, 365, 8876, 370, 291, 14, 267, 408, 267, 291, 423, 897, 275, 291, 14, 9654, 316, 15597, 342, 267, 291, 14, 11550, 275, 291, 423, 897, 14, 4405, 267, 340, 14165, 26, 288, 291, 14, 740, 15533, 8, 13723, 9, 339, 347, 5666, 15533, 8, 277, 12, 14165, 304, 267, 408, 5116, 4573, 14165, 1159, 17964, 14602, 291, 1041, 267, 14165, 14, 5485, 8, 277, 423, 897, 9, 339, 347, 664, 15597, 8, 277, 304, 267, 408, 1767, 314, 29858, 15597, 626, 883, 283, 5485, 7, 641, 642, 14165, 1041, 267, 372, 291, 423, 897, 339, 347, 664, 3428, 15597, 8, 277, 304, 267, 408, 1767, 282, 7584, 15597, 12146, 626, 883, 283, 5485, 7, 641, 642, 14165, 1041, 267, 372, 7584, 1378, 12520, 15597, 8, 277, 423, 897, 9, 339, 347, 5954, 8, 277, 12, 12374, 304, 267, 408, 6119, 4573, 29858, 15597, 370, 24331, 314, 14165, 1159, 17964, 3718, 1041, 267, 340, 291, 14, 11550, 26, 288, 367, 2088, 12, 1249, 12, 2074, 315, 291, 14, 11550, 26, 355, 2519, 8, 897, 12, 2088, 25967, 589, 12, 1011, 958, 9, 339, 347, 5954, 10225, 8, 277, 12, 2376, 15597, 304, 267, 408, 6119, 4573, 7584, 15597, 370, 24331, 314, 14165, 1159, 17964, 3718, 12, 267, 19458, 590, 4012, 376, 12146, 14, 267, 408, 267, 12374, 275, 29858, 23807, 15597, 8, 1403, 15597, 9, 267, 291, 14, 5485, 8, 897, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 1767, 715, 340, 283, 1848, 7, 14165, 1159, 17964, 365, 314, 2011, 465, 291, 1041, 267, 340, 2688, 8, 1848, 12, 283, 11550, 735, 288, 372, 291, 14, 11550, 508, 1163, 14, 11550, 267, 916, 2688, 8, 1848, 12, 283, 5485, 735, 288, 372, 291, 14, 11550, 508, 291, 855, 533, 721, 1848, 680, 11550, 267, 372, 3784, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 408, 1767, 715, 340, 283, 1848, 7, 14165, 1159, 17964, 365, 3365, 687, 291, 1041, 267, 372, 440, 334, 277, 508, 1163, 9, 339, 347, 14106, 8, 277, 12, 1163, 12, 4668, 63, 6896, 29, 17, 69, 13, 713, 304, 267, 340, 2688, 8, 1848, 12, 283, 11550, 735, 288, 17964, 18, 508, 1163, 14, 11550, 267, 916, 2688, 8, 1848, 12, 283, 5485, 735, 288, 17964, 18, 275, 291, 855, 533, 721, 1848, 680, 11550, 267, 587, 26, 288, 746, 3146, 8, 466, 8, 1848, 2843, 354, 3368, 267, 17964, 17, 275, 291, 14, 11550, 267, 340, 822, 8, 11550, 17, 9, 1137, 822, 8, 11550, 18, 304, 288, 372, 756, 267, 367, 334, 1760, 17, 12, 1680, 17, 12, 4775, 68, 17, 395, 334, 1760, 18, 12, 1680, 18, 12, 4775, 68, 18, 9, 315, 3482, 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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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 ]
Aristocles/CouchPotatoServer
libs/chardet/charsetgroupprober.py
217
3642
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library 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; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### import constants, sys from charsetprober import CharSetProber class CharSetGroupProber(CharSetProber): def __init__(self): CharSetProber.__init__(self) self._mActiveNum = 0 self._mProbers = [] self._mBestGuessProber = None def reset(self): CharSetProber.reset(self) self._mActiveNum = 0 for prober in self._mProbers: if prober: prober.reset() prober.active = constants.True self._mActiveNum += 1 self._mBestGuessProber = None def get_charset_name(self): if not self._mBestGuessProber: self.get_confidence() if not self._mBestGuessProber: return None # self._mBestGuessProber = self._mProbers[0] return self._mBestGuessProber.get_charset_name() def feed(self, aBuf): for prober in self._mProbers: if not prober: continue if not prober.active: continue st = prober.feed(aBuf) if not st: continue if st == constants.eFoundIt: self._mBestGuessProber = prober return self.get_state() elif st == constants.eNotMe: prober.active = constants.False self._mActiveNum -= 1 if self._mActiveNum <= 0: self._mState = constants.eNotMe return self.get_state() return self.get_state() def get_confidence(self): st = self.get_state() if st == constants.eFoundIt: return 0.99 elif st == constants.eNotMe: return 0.01 bestConf = 0.0 self._mBestGuessProber = None for prober in self._mProbers: if not prober: continue if not prober.active: if constants._debug: sys.stderr.write(prober.get_charset_name() + ' not active\n') continue cf = prober.get_confidence() if constants._debug: sys.stderr.write('%s confidence = %s\n' % (prober.get_charset_name(), cf)) if bestConf < cf: bestConf = cf self._mBestGuessProber = prober if not self._mBestGuessProber: return 0.0 return bestConf # else: # self._mBestGuessProber = self._mProbers[0] # return self._mBestGuessProber.get_confidence()
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 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, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 5262, 12, 984, 199, 504, 5960, 19903, 492, 31727, 199, 199, 533, 6659, 1084, 2448, 8029, 8, 15159, 304, 272, 347, 636, 826, 721, 277, 304, 267, 31727, 855, 826, 721, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 291, 423, 77, 8029, 83, 275, 942, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 5493, 347, 5305, 8, 277, 304, 267, 31727, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 16118, 26, 355, 16118, 14, 3958, 342, 355, 16118, 14, 2682, 275, 5262, 14, 549, 355, 291, 423, 77, 7472, 5667, 847, 413, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 291, 14, 362, 63, 13969, 342, 288, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 372, 488, 199, 3, 4483, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 267, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 6043, 63, 354, 342, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 1980, 288, 340, 440, 16118, 14, 2682, 26, 1980, 288, 410, 275, 16118, 14, 3871, 8, 22353, 9, 288, 340, 440, 410, 26, 1980, 288, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 355, 372, 291, 14, 362, 63, 929, 342, 288, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 355, 16118, 14, 2682, 275, 5262, 14, 797, 355, 291, 423, 77, 7472, 5667, 4862, 413, 355, 340, 291, 423, 77, 7472, 5667, 2695, 378, 26, 490, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 490, 372, 291, 14, 362, 63, 929, 342, 267, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 410, 275, 291, 14, 362, 63, 929, 342, 267, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 288, 372, 378, 14, 1020, 267, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 288, 372, 378, 14, 614, 267, 5526, 8930, 275, 378, 14, 16, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 19903, 14, 362, 63, 6043, 63, 354, 342, 435, 283, 440, 4702, 60, 78, 358, 355, 1980, 288, 3980, 275, 16118, 14, 362, 63, 13969, 342, 288, 340, 5262, 423, 1757, 26, 355, 984, 14, 3083, 14, 952, 3508, 83, 15197, 275, 450, 83, 60, 78, 7, 450, 334, 19903, 14, 362, 63, 6043, 63, 354, 1062, 3980, 430, 288, 340, 5526, 8930, 665, 3980, 26, 355, 5526, 8930, 275, 3980, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 372, 378, 14, 16, 267, 372, 5526, 8930, 199, 3, 263, 587, 26, 199, 3, 3322, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 199, 3, 3322, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 13969, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 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, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 5262, 12, 984, 199, 504, 5960, 19903, 492, 31727, 199, 199, 533, 6659, 1084, 2448, 8029, 8, 15159, 304, 272, 347, 636, 826, 721, 277, 304, 267, 31727, 855, 826, 721, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 291, 423, 77, 8029, 83, 275, 942, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 5493, 347, 5305, 8, 277, 304, 267, 31727, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 16118, 26, 355, 16118, 14, 3958, 342, 355, 16118, 14, 2682, 275, 5262, 14, 549, 355, 291, 423, 77, 7472, 5667, 847, 413, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 291, 14, 362, 63, 13969, 342, 288, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 372, 488, 199, 3, 4483, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 267, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 6043, 63, 354, 342, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 1980, 288, 340, 440, 16118, 14, 2682, 26, 1980, 288, 410, 275, 16118, 14, 3871, 8, 22353, 9, 288, 340, 440, 410, 26, 1980, 288, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 355, 372, 291, 14, 362, 63, 929, 342, 288, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 355, 16118, 14, 2682, 275, 5262, 14, 797, 355, 291, 423, 77, 7472, 5667, 4862, 413, 355, 340, 291, 423, 77, 7472, 5667, 2695, 378, 26, 490, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 490, 372, 291, 14, 362, 63, 929, 342, 267, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 410, 275, 291, 14, 362, 63, 929, 342, 267, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 288, 372, 378, 14, 1020, 267, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 288, 372, 378, 14, 614, 267, 5526, 8930, 275, 378, 14, 16, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 19903, 14, 362, 63, 6043, 63, 354, 342, 435, 283, 440, 4702, 60, 78, 358, 355, 1980, 288, 3980, 275, 16118, 14, 362, 63, 13969, 342, 288, 340, 5262, 423, 1757, 26, 355, 984, 14, 3083, 14, 952, 3508, 83, 15197, 275, 450, 83, 60, 78, 7, 450, 334, 19903, 14, 362, 63, 6043, 63, 354, 1062, 3980, 430, 288, 340, 5526, 8930, 665, 3980, 26, 355, 5526, 8930, 275, 3980, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 372, 378, 14, 16, 267, 372, 5526, 8930, 199, 3, 263, 587, 26, 199, 3, 3322, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 199, 3, 3322, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 13969, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jobelenus/thegreco
ignore/tracegen.py
1
1364
#!/usr/bin/env python # vim:ts=4:sts=4:sw=4:et:wrap:ai:fileencoding=utf-8: import collections #import matplotlib.pyplot as plt factor = 1/4 class TraceGenerator(): def __init__(self): fname='/Users/jobelenus/work/thegreco/cpu.entries' self.fname = fname with open(self.fname) as f: self.lines = f.readlines() self.cpu = map(int, self.lines) def gen_cpu_trace(self): return self.cpu def gen_mem_trace(self): self.mem = collections.deque(self.cpu) self.mem.rotate(len(self.cpu)/4) return self.mem def gen_disk_trace(self): self.disk = collections.deque(self.cpu) self.disk.rotate(2*len(self.cpu)/4) return self.disk def gen_net_trace(self): self.net = collections.deque(self.cpu) self.net.rotate(3*len(self.cpu)/4) return self.net def gen_trace(self): self.gen_cpu_trace() self.gen_mem_trace() self.gen_disk_trace() self.gen_net_trace() self.trace = zip(self.cpu, self.mem, self.disk, self.net) return self.trace #tg = TraceGenerator() #cpu = tg.gen_cpu_trace() #mem = tg.gen_mem_trace() #disk = tg.gen_disk_trace() #net = tg.gen_net_trace() #trace = zip(cpu, mem, disk, net) #print trace #plt.bar(range(0,len(cpu)), cpu) #plt.show()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 1086, 29, 20, 26, 10329, 29, 20, 26, 3519, 29, 20, 26, 386, 26, 3823, 26, 5789, 26, 493, 2991, 29, 1624, 13, 24, 26, 199, 199, 646, 5055, 199, 3, 646, 8027, 14, 13563, 465, 4488, 199, 199, 4778, 275, 413, 15, 20, 199, 199, 533, 11680, 7599, 837, 2043, 2126, 272, 347, 636, 826, 721, 277, 304, 267, 6748, 8805, 12117, 15, 743, 1235, 552, 527, 15, 800, 15, 1589, 9157, 331, 15, 3541, 14, 3189, 7, 267, 291, 14, 5252, 275, 6748, 267, 543, 1551, 8, 277, 14, 5252, 9, 465, 289, 26, 288, 291, 14, 1278, 275, 289, 14, 9684, 342, 288, 291, 14, 3541, 275, 2341, 8, 442, 12, 291, 14, 1278, 9, 2126, 272, 347, 3805, 63, 3541, 63, 3446, 8, 277, 304, 267, 372, 291, 14, 3541, 339, 347, 3805, 63, 5286, 63, 3446, 8, 277, 304, 267, 291, 14, 5286, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 5286, 14, 12873, 8, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 5286, 339, 347, 3805, 63, 4032, 63, 3446, 8, 277, 304, 267, 291, 14, 4032, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 4032, 14, 12873, 8, 18, 10, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 4032, 339, 347, 3805, 63, 846, 63, 3446, 8, 277, 304, 267, 291, 14, 846, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 846, 14, 12873, 8, 19, 10, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 846, 2126, 272, 347, 3805, 63, 3446, 8, 277, 304, 267, 291, 14, 2268, 63, 3541, 63, 3446, 342, 267, 291, 14, 2268, 63, 5286, 63, 3446, 342, 267, 291, 14, 2268, 63, 4032, 63, 3446, 342, 267, 291, 14, 2268, 63, 846, 63, 3446, 342, 267, 291, 14, 3446, 275, 3482, 8, 277, 14, 3541, 12, 291, 14, 5286, 12, 291, 14, 4032, 12, 291, 14, 846, 9, 267, 372, 291, 14, 3446, 199, 199, 3, 17699, 275, 11680, 7599, 342, 199, 3, 3541, 275, 22387, 14, 2268, 63, 3541, 63, 3446, 342, 199, 3, 5286, 275, 22387, 14, 2268, 63, 5286, 63, 3446, 342, 199, 3, 4032, 275, 22387, 14, 2268, 63, 4032, 63, 3446, 342, 199, 3, 846, 275, 22387, 14, 2268, 63, 846, 63, 3446, 342, 199, 3, 3446, 275, 3482, 8, 3541, 12, 7573, 12, 4543, 12, 1851, 9, 199, 199, 3, 1361, 3307, 199, 3, 6003, 14, 1700, 8, 1842, 8, 16, 12, 552, 8, 3541, 1826, 5033, 9, 199, 3, 6003, 14, 2384, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6695, 26, 1086, 29, 20, 26, 10329, 29, 20, 26, 3519, 29, 20, 26, 386, 26, 3823, 26, 5789, 26, 493, 2991, 29, 1624, 13, 24, 26, 199, 199, 646, 5055, 199, 3, 646, 8027, 14, 13563, 465, 4488, 199, 199, 4778, 275, 413, 15, 20, 199, 199, 533, 11680, 7599, 837, 2043, 2126, 272, 347, 636, 826, 721, 277, 304, 267, 6748, 8805, 12117, 15, 743, 1235, 552, 527, 15, 800, 15, 1589, 9157, 331, 15, 3541, 14, 3189, 7, 267, 291, 14, 5252, 275, 6748, 267, 543, 1551, 8, 277, 14, 5252, 9, 465, 289, 26, 288, 291, 14, 1278, 275, 289, 14, 9684, 342, 288, 291, 14, 3541, 275, 2341, 8, 442, 12, 291, 14, 1278, 9, 2126, 272, 347, 3805, 63, 3541, 63, 3446, 8, 277, 304, 267, 372, 291, 14, 3541, 339, 347, 3805, 63, 5286, 63, 3446, 8, 277, 304, 267, 291, 14, 5286, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 5286, 14, 12873, 8, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 5286, 339, 347, 3805, 63, 4032, 63, 3446, 8, 277, 304, 267, 291, 14, 4032, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 4032, 14, 12873, 8, 18, 10, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 4032, 339, 347, 3805, 63, 846, 63, 3446, 8, 277, 304, 267, 291, 14, 846, 275, 5055, 14, 22983, 8, 277, 14, 3541, 9, 267, 291, 14, 846, 14, 12873, 8, 19, 10, 552, 8, 277, 14, 3541, 2447, 20, 9, 267, 372, 291, 14, 846, 2126, 272, 347, 3805, 63, 3446, 8, 277, 304, 267, 291, 14, 2268, 63, 3541, 63, 3446, 342, 267, 291, 14, 2268, 63, 5286, 63, 3446, 342, 267, 291, 14, 2268, 63, 4032, 63, 3446, 342, 267, 291, 14, 2268, 63, 846, 63, 3446, 342, 267, 291, 14, 3446, 275, 3482, 8, 277, 14, 3541, 12, 291, 14, 5286, 12, 291, 14, 4032, 12, 291, 14, 846, 9, 267, 372, 291, 14, 3446, 199, 199, 3, 17699, 275, 11680, 7599, 342, 199, 3, 3541, 275, 22387, 14, 2268, 63, 3541, 63, 3446, 342, 199, 3, 5286, 275, 22387, 14, 2268, 63, 5286, 63, 3446, 342, 199, 3, 4032, 275, 22387, 14, 2268, 63, 4032, 63, 3446, 342, 199, 3, 846, 275, 22387, 14, 2268, 63, 846, 63, 3446, 342, 199, 3, 3446, 275, 3482, 8, 3541, 12, 7573, 12, 4543, 12, 1851, 9, 199, 199, 3, 1361, 3307, 199, 3, 6003, 14, 1700, 8, 1842, 8, 16, 12, 552, 8, 3541, 1826, 5033, 9, 199, 3, 6003, 14, 2384, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
F5Networks/f5-ansible
ansible_collections/f5networks/f5_modules/plugins/modules/bigip_device_group.py
1
19251
#!/usr/bin/python # -*- 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 DOCUMENTATION = r''' --- module: bigip_device_group short_description: Manage device groups on a BIG-IP description: - Managing device groups allows you to create HA pairs and clusters of BIG-IP devices. Usage of this module should be done in conjunction with the C(bigip_configsync_actions) to sync the configuration across the pair or cluster if auto-sync is disabled. version_added: "1.0.0" options: name: description: - Specifies the name of the device group. type: str required: True type: description: - Specifies the type of group. - A C(sync-failover) device group contains devices that synchronize their configuration data and fail over to one another when a device becomes unavailable. - A C(sync-only) device group has no such failover. When creating a new device group, this option will default to C(sync-only). - This setting cannot be changed once it has been set. type: str choices: - sync-failover - sync-only description: description: - Description of the device group. type: str auto_sync: description: - Indicates whether configuration synchronization occurs manually or automatically. - When creating a new device group, this option will default to C(no). type: bool default: no save_on_auto_sync: description: - When performing an auto-sync, specifies whether the configuration will be saved or not. - When C(no), only the running configuration will be changed on the device(s) being synced to. - When creating a new device group, this option will default to C(no). type: bool full_sync: description: - Specifies whether the system synchronizes the entire configuration during synchronization operations. - When C(no), the system performs incremental synchronization operations, based on the cache size specified in C(max_incremental_sync_size). - Incremental configuration synchronization is a mechanism for synchronizing a device-group's configuration among its members, without requiring a full configuration load for each configuration change. - In order for this to work, all devices in the device-group must initially agree on the configuration. Typically this requires at least one full configuration load to each device. - When creating a new device group, this option will default to C(no). type: bool max_incremental_sync_size: description: - Specifies the size of the changes cache for incremental sync. - For example, using the default, if you make more than 1024 KB worth of incremental changes, the system performs a full synchronization operation. - Using incremental synchronization operations can reduce the per-device sync/load time for configuration changes. - This setting is relevant only when C(full_sync) is C(no). type: int state: description: - When C(state) is C(present), ensures the device group exists. - When C(state) is C(absent), ensures the device group is removed. type: str choices: - present - absent default: present network_failover: description: - Indicates whether failover occurs over the network or is hard-wired. - This parameter is only valid for C(type)s that are C(sync-failover). type: bool notes: - This module is primarily used as a component of configuring HA pairs of BIG-IP devices. - Requires BIG-IP >= 12.1.x. extends_documentation_fragment: f5networks.f5_modules.f5 author: - Tim Rupp (@caphrim007) - Wojciech Wypior (@wojtek0806) ''' EXAMPLES = r''' - name: Create a sync-only device group bigip_device_group: name: foo-group provider: password: secret server: lb.mydomain.com user: admin delegate_to: localhost - name: Create a sync-only device group with auto-sync enabled bigip_device_group: name: foo-group auto_sync: yes provider: password: secret server: lb.mydomain.com user: admin delegate_to: localhost ''' RETURN = r''' save_on_auto_sync: description: The new save_on_auto_sync value of the device group. returned: changed type: bool sample: true full_sync: description: The new full_sync value of the device group. returned: changed type: bool sample: false description: description: The new description of the device group. returned: changed type: str sample: this is a device group type: description: The new type of the device group. returned: changed type: str sample: sync-failover auto_sync: description: The new auto_sync value of the device group. returned: changed type: bool sample: true max_incremental_sync_size: description: The new sync size of the device group. returned: changed type: int sample: 1000 network_failover: description: Whether or not network failover is enabled. returned: changed type: bool sample: yes ''' from datetime import datetime from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE from ..module_utils.bigip import F5RestClient from ..module_utils.common import ( F5ModuleError, AnsibleF5Parameters, f5_argument_spec ) from ..module_utils.icontrol import tmos_version from ..module_utils.teem import send_teem class Parameters(AnsibleF5Parameters): api_map = { 'saveOnAutoSync': 'save_on_auto_sync', 'fullLoadOnSync': 'full_sync', 'autoSync': 'auto_sync', 'incrementalConfigSyncSizeMax': 'max_incremental_sync_size', 'networkFailover': 'network_failover', } api_attributes = [ 'saveOnAutoSync', 'fullLoadOnSync', 'description', 'type', 'autoSync', 'incrementalConfigSyncSizeMax', 'networkFailover', ] returnables = [ 'save_on_auto_sync', 'full_sync', 'description', 'type', 'auto_sync', 'max_incremental_sync_size', 'network_failover', ] updatables = [ 'save_on_auto_sync', 'full_sync', 'description', 'auto_sync', 'max_incremental_sync_size', 'network_failover', ] @property def max_incremental_sync_size(self): if not self.full_sync and self._values['max_incremental_sync_size'] is not None: if self._values['__warnings'] is None: self._values['__warnings'] = [] self._values['__warnings'].append( [ dict( msg='"max_incremental_sync_size has no effect if "full_sync" is not true', version='2.4' ) ] ) if self._values['max_incremental_sync_size'] is None: return None return int(self._values['max_incremental_sync_size']) class ApiParameters(Parameters): @property def network_failover(self): if self._values['network_failover'] is None: return None elif self._values['network_failover'] == 'enabled': return True return False @property def auto_sync(self): if self._values['auto_sync'] is None: return None elif self._values['auto_sync'] == 'enabled': return True return False @property def save_on_auto_sync(self): if self._values['save_on_auto_sync'] is None: return None elif self._values['save_on_auto_sync'] in BOOLEANS_TRUE: return True else: return False @property def full_sync(self): if self._values['full_sync'] is None: return None elif self._values['full_sync'] in BOOLEANS_TRUE: return True else: return False class ModuleParameters(Parameters): pass class Changes(Parameters): def to_return(self): result = {} try: for returnable in self.returnables: change = getattr(self, returnable) if isinstance(change, dict): result.update(change) else: result[returnable] = change result = self._filter_params(result) except Exception: raise return result class UsableChanges(Changes): @property def network_failover(self): if self._values['network_failover'] is None: return None elif self._values['network_failover']: return 'enabled' return 'disabled' @property def auto_sync(self): if self._values['auto_sync'] is None: return None elif self._values['auto_sync']: return 'enabled' return 'disabled' @property def save_on_auto_sync(self): if self._values['save_on_auto_sync'] is None: return None elif self._values['save_on_auto_sync'] in BOOLEANS_TRUE: return "true" else: return "false" @property def full_sync(self): if self._values['full_sync'] is None: return None elif self._values['full_sync'] in BOOLEANS_TRUE: return "true" else: return "false" class ReportableChanges(Changes): @property def network_failover(self): if self._values['network_failover'] is None: return None elif self._values['network_failover'] == 'enabled': return 'yes' return 'no' @property def auto_sync(self): if self._values['auto_sync'] is None: return None elif self._values['auto_sync'] == 'enabled': return 'yes' return 'no' @property def save_on_auto_sync(self): if self._values['save_on_auto_sync'] is None: return None elif self._values['save_on_auto_sync'] in BOOLEANS_TRUE: return "yes" return "no" @property def full_sync(self): if self._values['full_sync'] is None: return None elif self._values['full_sync'] in BOOLEANS_TRUE: return "yes" return "no" class ModuleManager(object): def __init__(self, *args, **kwargs): self.module = kwargs.get('module', None) self.client = F5RestClient(**self.module.params) self.want = ModuleParameters(params=self.module.params) self.have = ApiParameters() self.changes = UsableChanges() def _set_changed_options(self): changed = {} for key in Parameters.returnables: if getattr(self.want, key) is not None: changed[key] = getattr(self.want, key) if changed: self.changes = UsableChanges(params=changed) def _update_changed_options(self): changed = {} for key in Parameters.updatables: if getattr(self.want, key) is not None: attr1 = getattr(self.want, key) attr2 = getattr(self.have, key) if attr1 != attr2: changed[key] = attr1 if changed: self.changes = UsableChanges(params=changed) return True return False def _announce_deprecations(self, result): warnings = result.pop('__warnings', []) for warning in warnings: self.module.deprecate( msg=warning['msg'], version=warning['version'] ) def exec_module(self): start = datetime.now().isoformat() version = tmos_version(self.client) changed = False result = dict() state = self.want.state if state == "present": changed = self.present() elif state == "absent": changed = self.absent() reportable = ReportableChanges(params=self.changes.to_return()) changes = reportable.to_return() result.update(**changes) result.update(dict(changed=changed)) self._announce_deprecations(result) send_teem(start, self.client, self.module, version) return result def present(self): if self.exists(): return self.update() else: return self.create() def should_update(self): result = self._update_changed_options() if result: return True return False def update(self): self.have = self.read_current_from_device() if not self.should_update(): return False if self.module.check_mode: return True self.update_on_device() return True def remove(self): if self.module.check_mode: return True self.remove_members_in_group_from_device() self.remove_from_device() if self.exists(): raise F5ModuleError("Failed to delete the device group") return True def create(self): self._set_changed_options() if self.want.type == 'sync-only' and self.want.network_failover is not None: raise F5ModuleError( "'network_failover' may only be specified when 'type' is 'sync-failover'." ) if self.module.check_mode: return True self.create_on_device() return True def absent(self): if self.exists(): return self.remove() return False def exists(self): errors = [401, 403, 409, 500, 501, 502, 503, 504] uri = "https://{0}:{1}/mgmt/tm/cm/device-group/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.name ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if resp.status == 404 or 'code' in response and response['code'] == 404: return False if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: return True if resp.status in errors or 'code' in response and response['code'] in errors: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) def remove_members_in_group_from_device(self): uri = "https://{0}:{1}/mgmt/tm/cm/device-group/{2}/devices/".format( self.client.provider['server'], self.client.provider['server_port'], self.want.name ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if resp.status not in [200, 201] or 'code' in response and response['code'] not in [200, 201]: raise F5ModuleError(resp.content) for item in response['items']: new_uri = uri + '{0}'.format(item['name']) response = self.client.api.delete(new_uri) if response.status == 200: return True raise F5ModuleError(response.content) def create_on_device(self): params = self.changes.api_params() params['name'] = self.want.name params['partition'] = self.want.partition uri = "https://{0}:{1}/mgmt/tm/cm/device-group/".format( self.client.provider['server'], self.client.provider['server_port'], ) resp = self.client.api.post(uri, json=params) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: return True raise F5ModuleError(resp.content) def update_on_device(self): params = self.changes.api_params() uri = "https://{0}:{1}/mgmt/tm/cm/device-group/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.name ) resp = self.client.api.patch(uri, json=params) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: return True raise F5ModuleError(resp.content) def remove_from_device(self): uri = "https://{0}:{1}/mgmt/tm/cm/device-group/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.name ) response = self.client.api.delete(uri) if response.status == 200: return True raise F5ModuleError(response.content) def read_current_from_device(self): uri = "https://{0}:{1}/mgmt/tm/cm/device-group/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.name ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: return ApiParameters(params=response) raise F5ModuleError(resp.content) class ArgumentSpec(object): def __init__(self): self.supports_check_mode = True argument_spec = dict( type=dict( choices=['sync-failover', 'sync-only'] ), description=dict(), auto_sync=dict( type='bool', default='no' ), save_on_auto_sync=dict( type='bool', ), full_sync=dict( type='bool' ), name=dict( required=True ), max_incremental_sync_size=dict( type='int' ), state=dict( default='present', choices=['absent', 'present'] ), network_failover=dict(type='bool'), ) self.argument_spec = {} self.argument_spec.update(f5_argument_spec) self.argument_spec.update(argument_spec) def main(): spec = ArgumentSpec() module = AnsibleModule( argument_spec=spec.argument_spec, supports_check_mode=spec.supports_check_mode ) try: mm = ModuleManager(module=module) results = mm.exec_module() module.exit_json(**results) except F5ModuleError as ex: module.fail_json(msg=str(ex)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 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, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 27281, 63, 1782, 63, 923, 199, 3612, 63, 1802, 26, 14944, 2243, 4652, 641, 282, 16524, 13, 1772, 199, 1802, 26, 523, 446, 4688, 7407, 2243, 4652, 6127, 1265, 370, 1218, 16100, 6342, 436, 13865, 272, 402, 16524, 13, 1772, 7256, 14, 11028, 402, 642, 859, 1077, 506, 4224, 315, 22888, 272, 543, 314, 445, 8, 17833, 63, 7532, 1870, 63, 3723, 9, 370, 7604, 314, 2897, 9371, 272, 314, 4092, 503, 4350, 340, 2599, 13, 5186, 365, 6980, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 16, 14, 16, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 11015, 314, 536, 402, 314, 2243, 1572, 14, 272, 730, 26, 620, 272, 1415, 26, 715, 523, 730, 26, 272, 1369, 26, 489, 446, 11015, 314, 730, 402, 1572, 14, 489, 446, 437, 445, 8, 5186, 13, 667, 23165, 9, 2243, 1572, 3509, 7256, 626, 31021, 3932, 267, 2897, 666, 436, 2449, 1806, 370, 1373, 4573, 1380, 282, 2243, 15410, 267, 18735, 14, 489, 446, 437, 445, 8, 5186, 13, 2118, 9, 2243, 1572, 965, 949, 4066, 1433, 23165, 14, 3979, 6425, 282, 892, 267, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 5186, 13, 2118, 680, 489, 446, 961, 4260, 3913, 506, 2896, 5403, 652, 965, 2757, 663, 14, 272, 730, 26, 620, 272, 3415, 26, 489, 446, 7604, 13, 667, 23165, 489, 446, 7604, 13, 2118, 523, 1369, 26, 272, 1369, 26, 489, 446, 11994, 402, 314, 2243, 1572, 14, 272, 730, 26, 620, 523, 2599, 63, 5186, 26, 272, 1369, 26, 489, 446, 19334, 3775, 2897, 29509, 11058, 10250, 503, 267, 5847, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 272, 849, 26, 949, 523, 3354, 63, 265, 63, 2495, 63, 5186, 26, 272, 1369, 26, 489, 446, 3979, 19203, 376, 2599, 13, 5186, 12, 9314, 3775, 314, 2897, 267, 911, 506, 6290, 503, 440, 14, 489, 446, 3979, 445, 8, 889, 395, 1454, 314, 3879, 2897, 911, 506, 2896, 641, 314, 267, 2243, 8, 83, 9, 3769, 9560, 6867, 370, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 523, 2615, 63, 5186, 26, 272, 1369, 26, 489, 446, 11015, 3775, 314, 2656, 15354, 6491, 314, 8039, 2897, 267, 5309, 29509, 5331, 14, 489, 446, 3979, 445, 8, 889, 395, 314, 2656, 18628, 16316, 29509, 5331, 12, 267, 4079, 641, 314, 2581, 1568, 2013, 315, 445, 8, 988, 63, 23760, 63, 5186, 63, 890, 680, 489, 446, 14684, 2897, 29509, 365, 282, 14729, 367, 15354, 9147, 267, 282, 2243, 13, 923, 1159, 2897, 16885, 2399, 7556, 12, 1928, 29963, 282, 267, 2615, 2897, 2248, 367, 1924, 2897, 1570, 14, 489, 446, 1010, 1865, 367, 642, 370, 1736, 12, 1006, 7256, 315, 314, 2243, 13, 923, 1471, 22801, 267, 10601, 641, 314, 2897, 14, 26914, 642, 5074, 737, 5210, 1373, 2615, 267, 2897, 2248, 370, 1924, 2243, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 523, 1390, 63, 23760, 63, 5186, 63, 890, 26, 272, 1369, 26, 489, 446, 11015, 314, 1568, 402, 314, 4493, 2581, 367, 16316, 7604, 14, 489, 446, 2104, 2893, 12, 1808, 314, 849, 12, 340, 1265, 1852, 1655, 2419, 6619, 27638, 25235, 402, 267, 16316, 4493, 12, 314, 2656, 18628, 282, 2615, 29509, 3439, 14, 489, 446, 11719, 16316, 29509, 5331, 883, 7114, 314, 1126, 13, 1782, 7604, 15, 912, 267, 900, 367, 2897, 4493, 14, 489, 446, 961, 4260, 365, 12082, 1454, 1380, 445, 8, 2861, 63, 5186, 9, 365, 445, 8, 889, 680, 272, 730, 26, 1109, 523, 1174, 26, 272, 1369, 26, 489, 446, 3979, 445, 8, 929, 9, 365, 445, 8, 1881, 395, 15620, 314, 2243, 1572, 3495, 14, 489, 446, 3979, 445, 8, 929, 9, 365, 445, 8, 5575, 395, 15620, 221, 314, 2243, 1572, 365, 4829, 14, 272, 730, 26, 620, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 272, 849, 26, 3451, 523, 2784, 63, 667, 23165, 26, 272, 1369, 26, 489, 446, 19334, 3775, 1433, 23165, 11058, 1806, 314, 2784, 503, 365, 7508, 13, 14249, 581, 14, 489, 446, 961, 2725, 365, 1454, 1686, 367, 445, 8, 466, 9, 83, 626, 787, 445, 8, 5186, 13, 667, 23165, 680, 272, 730, 26, 2155, 199, 5983, 26, 523, 446, 961, 859, 365, 1979, 30468, 1202, 465, 282, 3931, 402, 1101, 4039, 16100, 6342, 402, 272, 16524, 13, 1772, 7256, 14, 523, 446, 15127, 16524, 13, 1772, 2356, 3144, 14, 17, 14, 88, 14, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 7642, 14, 70, 21, 63, 3112, 14, 70, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 523, 446, 644, 79, 74, 559, 12736, 644, 89, 1038, 269, 8593, 2027, 74, 266, 75, 16, 11901, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 7604, 13, 2118, 2243, 1572, 523, 27281, 63, 1782, 63, 923, 26, 272, 536, 26, 3925, 13, 923, 272, 5022, 26, 489, 2505, 26, 7565, 489, 1654, 26, 11104, 14, 30945, 14, 957, 489, 922, 26, 4628, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2790, 282, 7604, 13, 2118, 2243, 1572, 543, 2599, 13, 5186, 5223, 523, 27281, 63, 1782, 63, 923, 26, 272, 536, 26, 3925, 13, 923, 272, 2599, 63, 5186, 26, 9456, 272, 5022, 26, 489, 2505 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 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, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 27281, 63, 1782, 63, 923, 199, 3612, 63, 1802, 26, 14944, 2243, 4652, 641, 282, 16524, 13, 1772, 199, 1802, 26, 523, 446, 4688, 7407, 2243, 4652, 6127, 1265, 370, 1218, 16100, 6342, 436, 13865, 272, 402, 16524, 13, 1772, 7256, 14, 11028, 402, 642, 859, 1077, 506, 4224, 315, 22888, 272, 543, 314, 445, 8, 17833, 63, 7532, 1870, 63, 3723, 9, 370, 7604, 314, 2897, 9371, 272, 314, 4092, 503, 4350, 340, 2599, 13, 5186, 365, 6980, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 16, 14, 16, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 11015, 314, 536, 402, 314, 2243, 1572, 14, 272, 730, 26, 620, 272, 1415, 26, 715, 523, 730, 26, 272, 1369, 26, 489, 446, 11015, 314, 730, 402, 1572, 14, 489, 446, 437, 445, 8, 5186, 13, 667, 23165, 9, 2243, 1572, 3509, 7256, 626, 31021, 3932, 267, 2897, 666, 436, 2449, 1806, 370, 1373, 4573, 1380, 282, 2243, 15410, 267, 18735, 14, 489, 446, 437, 445, 8, 5186, 13, 2118, 9, 2243, 1572, 965, 949, 4066, 1433, 23165, 14, 3979, 6425, 282, 892, 267, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 5186, 13, 2118, 680, 489, 446, 961, 4260, 3913, 506, 2896, 5403, 652, 965, 2757, 663, 14, 272, 730, 26, 620, 272, 3415, 26, 489, 446, 7604, 13, 667, 23165, 489, 446, 7604, 13, 2118, 523, 1369, 26, 272, 1369, 26, 489, 446, 11994, 402, 314, 2243, 1572, 14, 272, 730, 26, 620, 523, 2599, 63, 5186, 26, 272, 1369, 26, 489, 446, 19334, 3775, 2897, 29509, 11058, 10250, 503, 267, 5847, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 272, 849, 26, 949, 523, 3354, 63, 265, 63, 2495, 63, 5186, 26, 272, 1369, 26, 489, 446, 3979, 19203, 376, 2599, 13, 5186, 12, 9314, 3775, 314, 2897, 267, 911, 506, 6290, 503, 440, 14, 489, 446, 3979, 445, 8, 889, 395, 1454, 314, 3879, 2897, 911, 506, 2896, 641, 314, 267, 2243, 8, 83, 9, 3769, 9560, 6867, 370, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 523, 2615, 63, 5186, 26, 272, 1369, 26, 489, 446, 11015, 3775, 314, 2656, 15354, 6491, 314, 8039, 2897, 267, 5309, 29509, 5331, 14, 489, 446, 3979, 445, 8, 889, 395, 314, 2656, 18628, 16316, 29509, 5331, 12, 267, 4079, 641, 314, 2581, 1568, 2013, 315, 445, 8, 988, 63, 23760, 63, 5186, 63, 890, 680, 489, 446, 14684, 2897, 29509, 365, 282, 14729, 367, 15354, 9147, 267, 282, 2243, 13, 923, 1159, 2897, 16885, 2399, 7556, 12, 1928, 29963, 282, 267, 2615, 2897, 2248, 367, 1924, 2897, 1570, 14, 489, 446, 1010, 1865, 367, 642, 370, 1736, 12, 1006, 7256, 315, 314, 2243, 13, 923, 1471, 22801, 267, 10601, 641, 314, 2897, 14, 26914, 642, 5074, 737, 5210, 1373, 2615, 267, 2897, 2248, 370, 1924, 2243, 14, 489, 446, 3979, 6425, 282, 892, 2243, 1572, 12, 642, 945, 911, 849, 370, 445, 8, 889, 680, 272, 730, 26, 2155, 523, 1390, 63, 23760, 63, 5186, 63, 890, 26, 272, 1369, 26, 489, 446, 11015, 314, 1568, 402, 314, 4493, 2581, 367, 16316, 7604, 14, 489, 446, 2104, 2893, 12, 1808, 314, 849, 12, 340, 1265, 1852, 1655, 2419, 6619, 27638, 25235, 402, 267, 16316, 4493, 12, 314, 2656, 18628, 282, 2615, 29509, 3439, 14, 489, 446, 11719, 16316, 29509, 5331, 883, 7114, 314, 1126, 13, 1782, 7604, 15, 912, 267, 900, 367, 2897, 4493, 14, 489, 446, 961, 4260, 365, 12082, 1454, 1380, 445, 8, 2861, 63, 5186, 9, 365, 445, 8, 889, 680, 272, 730, 26, 1109, 523, 1174, 26, 272, 1369, 26, 489, 446, 3979, 445, 8, 929, 9, 365, 445, 8, 1881, 395, 15620, 314, 2243, 1572, 3495, 14, 489, 446, 3979, 445, 8, 929, 9, 365, 445, 8, 5575, 395, 15620, 221, 314, 2243, 1572, 365, 4829, 14, 272, 730, 26, 620, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 272, 849, 26, 3451, 523, 2784, 63, 667, 23165, 26, 272, 1369, 26, 489, 446, 19334, 3775, 1433, 23165, 11058, 1806, 314, 2784, 503, 365, 7508, 13, 14249, 581, 14, 489, 446, 961, 2725, 365, 1454, 1686, 367, 445, 8, 466, 9, 83, 626, 787, 445, 8, 5186, 13, 667, 23165, 680, 272, 730, 26, 2155, 199, 5983, 26, 523, 446, 961, 859, 365, 1979, 30468, 1202, 465, 282, 3931, 402, 1101, 4039, 16100, 6342, 402, 272, 16524, 13, 1772, 7256, 14, 523, 446, 15127, 16524, 13, 1772, 2356, 3144, 14, 17, 14, 88, 14, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 7642, 14, 70, 21, 63, 3112, 14, 70, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 523, 446, 644, 79, 74, 559, 12736, 644, 89, 1038, 269, 8593, 2027, 74, 266, 75, 16, 11901, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 7604, 13, 2118, 2243, 1572, 523, 27281, 63, 1782, 63, 923, 26, 272, 536, 26, 3925, 13, 923, 272, 5022, 26, 489, 2505, 26, 7565, 489, 1654, 26, 11104, 14, 30945, 14, 957, 489, 922, 26, 4628, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2790, 282, 7604, 13, 2118, 2243, 1572, 543, 2599, 13, 5186, 5223, 523, 27281, 63, 1782, 63, 923, 26, 272, 536, 26, 3925, 13, 923, 272, 2599, 63, 5186, 26, 9456, 272, 5022, 26, 489, 2505, 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,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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 ]
totolef/Sick-beard
lib/imdb/parser/http/characterParser.py
143
8139
""" parser.http.characterParser module (imdb package). This module provides the classes (and the instances), used to parse the IMDb pages on the akas.imdb.com server about a character. E.g., for "Jesse James" the referred pages would be: main details: http://www.imdb.com/character/ch0000001/ biography: http://www.imdb.com/character/ch0000001/bio ...and so on... Copyright 2007-2009 Davide Alberani <da@erlug.linux.it> 2008 H. Turgut Uyar <uyar@tekir.org> 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import re from utils import Attribute, Extractor, DOMParserBase, build_movie, \ analyze_imdbid from personParser import DOMHTMLMaindetailsParser from imdb.Movie import Movie _personIDs = re.compile(r'/name/nm([0-9]{7})') class DOMHTMLCharacterMaindetailsParser(DOMHTMLMaindetailsParser): """Parser for the "filmography" page of a given character. The page should be provided as a string, as taken from the akas.imdb.com server. The final result will be a dictionary, with a key for every relevant section. Example: bparser = DOMHTMLCharacterMaindetailsParser() result = bparser.parse(character_biography_html_string) """ _containsObjects = True _film_attrs = [Attribute(key=None, multi=True, path={ 'link': "./a[1]/@href", 'title': ".//text()", 'status': "./i/a//text()", 'roleID': "./a/@href" }, postprocess=lambda x: build_movie(x.get('title') or u'', movieID=analyze_imdbid(x.get('link') or u''), roleID=_personIDs.findall(x.get('roleID') or u''), status=x.get('status') or None, _parsingCharacter=True))] extractors = [ Extractor(label='title', path="//title", attrs=Attribute(key='name', path="./text()", postprocess=lambda x: \ x.replace(' (Character)', '').replace( '- Filmography by type', '').strip())), Extractor(label='headshot', path="//a[@name='headshot']", attrs=Attribute(key='headshot', path="./img/@src")), Extractor(label='akas', path="//div[h5='Alternate Names:']", attrs=Attribute(key='akas', path="./div//text()", postprocess=lambda x: x.strip().split(' / '))), Extractor(label='filmography', path="//div[@class='filmo'][not(h5)]/ol/li", attrs=_film_attrs), Extractor(label='filmography sections', group="//div[@class='filmo'][h5]", group_key="./h5/a/text()", group_key_normalize=lambda x: x.lower()[:-1], path="./ol/li", attrs=_film_attrs), ] preprocessors = [ # Check that this doesn't cut "status"... (re.compile(r'<br>(\.\.\.| ).+?</li>', re.I | re.M), '</li>')] class DOMHTMLCharacterBioParser(DOMParserBase): """Parser for the "biography" page of a given character. The page should be provided as a string, as taken from the akas.imdb.com server. The final result will be a dictionary, with a key for every relevant section. Example: bparser = DOMHTMLCharacterBioParser() result = bparser.parse(character_biography_html_string) """ _defGetRefs = True extractors = [ Extractor(label='introduction', path="//div[@id='_intro']", attrs=Attribute(key='introduction', path=".//text()", postprocess=lambda x: x.strip())), Extractor(label='biography', path="//span[@class='_biography']", attrs=Attribute(key='biography', multi=True, path={ 'info': "./preceding-sibling::h4[1]//text()", 'text': ".//text()" }, postprocess=lambda x: u'%s: %s' % ( x.get('info').strip(), x.get('text').replace('\n', ' ').replace('||', '\n\n').strip()))), ] preprocessors = [ (re.compile('(<div id="swiki.2.3.1">)', re.I), r'\1<div id="_intro">'), (re.compile('(<a name="history">)\s*(<table .*?</table>)', re.I | re.DOTALL), r'</div>\2\1</a>'), (re.compile('(<a name="[^"]+">)(<h4>)', re.I), r'</span>\1</a>\2'), (re.compile('(</h4>)</a>', re.I), r'\1<span class="_biography">'), (re.compile('<br/><br/>', re.I), r'||'), (re.compile('\|\|\n', re.I), r'</span>'), ] class DOMHTMLCharacterQuotesParser(DOMParserBase): """Parser for the "quotes" page of a given character. The page should be provided as a string, as taken from the akas.imdb.com server. The final result will be a dictionary, with a key for every relevant section. Example: qparser = DOMHTMLCharacterQuotesParser() result = qparser.parse(character_quotes_html_string) """ _defGetRefs = True extractors = [ Extractor(label='charquotes', group="//h5", group_key="./a/text()", path="./following-sibling::div[1]", attrs=Attribute(key=None, path={'txt': ".//text()", 'movieID': ".//a[1]/@href"}, postprocess=lambda x: (analyze_imdbid(x['movieID']), x['txt'].strip().replace(': ', ': ').replace(': ', ': ').split('||')))) ] preprocessors = [ (re.compile('(</h5>)', re.I), r'\1<div>'), (re.compile('\s*<br/><br/>\s*', re.I), r'||'), (re.compile('\|\|\s*(<hr/>)', re.I), r'</div>\1'), (re.compile('\s*<br/>\s*', re.I), r'::') ] def postprocess_data(self, data): if not data: return {} newData = {} for title in data: movieID, quotes = data[title] if movieID is None: movie = title else: movie = Movie(title=title, movieID=movieID, accessSystem=self._as, modFunct=self._modFunct) newData[movie] = [quote.split('::') for quote in quotes] return {'quotes': newData} from personParser import DOMHTMLSeriesParser _OBJECTS = { 'character_main_parser': ((DOMHTMLCharacterMaindetailsParser,), {'kind': 'character'}), 'character_series_parser': ((DOMHTMLSeriesParser,), None), 'character_bio_parser': ((DOMHTMLCharacterBioParser,), None), 'character_quotes_parser': ((DOMHTMLCharacterQuotesParser,), None) }
gpl-3.0
[ 624, 199, 2087, 14, 1014, 14, 10856, 2842, 859, 334, 17117, 2559, 680, 199, 199, 2765, 859, 6571, 314, 3992, 334, 460, 314, 4454, 395, 1202, 370, 2198, 199, 1589, 473, 5127, 66, 6497, 641, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 3595, 282, 4528, 14, 199, 37, 14, 71, 2020, 367, 298, 42, 397, 261, 1603, 14015, 2, 314, 25713, 6497, 3955, 506, 26, 272, 2446, 2436, 26, 257, 1455, 921, 1544, 14, 17117, 14, 957, 15, 10856, 15, 335, 3273, 17, 15, 272, 28897, 9773, 26, 420, 1455, 921, 1544, 14, 17117, 14, 957, 15, 10856, 15, 335, 3273, 17, 15, 17614, 272, 2263, 460, 880, 641, 1396, 199, 199, 7384, 10219, 13, 8664, 577, 65, 5624, 4580, 605, 26455, 665, 983, 32, 281, 32047, 14, 5135, 14, 390, 30, 2049, 9079, 869, 14, 377, 17629, 337, 738, 89, 285, 665, 29514, 285, 32, 266, 75, 723, 14, 1308, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 646, 295, 199, 504, 3778, 492, 3882, 12, 18925, 12, 14316, 2842, 1563, 12, 1900, 63, 10888, 12, 971, 490, 19897, 63, 17117, 344, 199, 504, 4954, 2842, 492, 14316, 4943, 6756, 5087, 2842, 199, 199, 504, 18232, 14, 19088, 492, 31248, 199, 199, 63, 5484, 12818, 275, 295, 14, 2014, 8, 82, 9807, 354, 15, 10756, 779, 16, 13, 25, 8194, 23, 1552, 358, 199, 533, 14316, 4943, 14852, 6756, 5087, 2842, 8, 10462, 4943, 6756, 5087, 2842, 304, 272, 408, 2842, 367, 314, 298, 1289, 573, 9773, 2, 2034, 402, 282, 1627, 4528, 14, 272, 710, 2034, 1077, 506, 2741, 465, 282, 1059, 12, 465, 9394, 687, 272, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 14, 221, 710, 4242, 754, 911, 506, 282, 272, 2600, 12, 543, 282, 790, 367, 4036, 12082, 3420, 14, 339, 5679, 26, 267, 330, 2087, 275, 14316, 4943, 14852, 6756, 5087, 2842, 342, 267, 754, 275, 330, 2087, 14, 1122, 8, 10856, 63, 17614, 9773, 63, 1360, 63, 875, 9, 272, 408, 272, 485, 6134, 11188, 275, 715, 339, 485, 1289, 77, 63, 3288, 275, 359, 1646, 8, 498, 29, 403, 12, 1993, 3510, 29, 549, 12, 1993, 931, 3126, 2079, 283, 1073, 356, 26069, 65, 59, 17, 12978, 32, 6399, 401, 2079, 283, 1213, 356, 3680, 501, 505, 24017, 2079, 283, 1205, 356, 26069, 73, 15, 65, 501, 505, 24017, 2079, 283, 3756, 998, 356, 26069, 65, 15, 32, 6399, 2, 2079, 1660, 1993, 2963, 1412, 29, 2734, 671, 26, 2079, 1900, 63, 10888, 8, 88, 14, 362, 360, 1213, 358, 503, 399, 6448, 2892, 14360, 998, 29, 21184, 63, 17117, 344, 8, 88, 14, 362, 360, 1073, 358, 503, 399, 7, 659, 2892, 4719, 998, 3699, 5484, 12818, 14, 6452, 8, 88, 14, 362, 360, 3756, 998, 358, 503, 399, 7, 659, 2892, 2004, 29, 88, 14, 362, 360, 1205, 358, 503, 488, 12, 2892, 485, 11059, 14852, 29, 549, 10524, 339, 2402, 13451, 275, 359, 288, 18925, 8, 1302, 534, 1213, 297, 717, 931, 628, 501, 1213, 401, 717, 3290, 29, 1646, 8, 498, 534, 354, 297, 1169, 931, 628, 13186, 505, 24017, 1169, 2963, 1412, 29, 2734, 671, 26, 971, 2511, 671, 14, 1814, 360, 334, 14852, 3196, 12548, 1814, 8, 3147, 2475, 17887, 573, 9773, 701, 730, 297, 12548, 1913, 22606, 953, 18925, 8, 1302, 534, 2993, 2782, 297, 717, 931, 628, 501, 65, 14251, 354, 534, 2993, 2782, 6256, 717, 3290, 29, 1646, 8, 498, 534, 2993, 2782, 297, 1169, 931, 628, 13186, 4060, 15, 32, 2164, 8150, 953, 18925, 8, 1302, 534, 1151, 305, 297, 717, 931, 628, 501, 3015, 59, 72, 21, 534, 19978, 323, 23923, 26, 6256, 717, 3290, 29, 1646, 8, 498, 534, 1151, 305, 297, 1169, 931, 628, 13186, 3015, 501, 505, 24017, 1169, 2963, 1412, 29, 2734, 671, 26, 671, 14, 1913, 1252, 1294, 360, 1182, 283, 11508, 953, 18925, 8, 1302, 534, 1289, 573, 9773, 297, 717, 931, 628, 501, 3015, 14251, 533, 534, 1289, 573, 3488, 1397, 8, 72, 21, 1874, 15, 393, 15, 317, 401, 717, 3290, 3699, 1289, 77, 63, 3288, 395, 953, 18925, 8, 1302, 534, 1289, 573, 9773, 10189, 297, 717, 1572, 628, 501, 3015, 14251, 533, 534, 1289, 573, 3488, 72, 21, 11472, 717, 1572, 63, 498, 628, 13186, 72, 21, 15, 65, 15, 505, 24017, 717, 1572, 63, 498, 63, 7721, 29, 2734, 671, 26, 671, 14, 2325, 342, 4439, 17, 467, 717, 931, 628, 13186, 393, 15, 317, 401, 717, 3290, 3699, 1289, 77, 63, 3288, 395, 288, 1622, 339, 876, 10547, 275, 359, 288, 327, 2670, 626, 642, 3181, 1133, 10415, 298, 1205, 2, 1396, 288, 334, 264, 14, 2014, 8, 82, 7601, 3289, 30, 2961, 3134, 3134, 14, 92, 257, 7092, 23778, 1108, 317, 4206, 295, 14, 41, 1204, 295, 14, 45, 395, 11936, 317, 30, 5440, 421, 199, 533, 14316, 4943, 14852, 34, 2308, 2842, 8, 10462, 2842, 1563, 304, 272, 408, 2842, 367, 314, 298, 17614, 9773, 2, 2034, 402, 282, 1627, 4528, 14, 272, 710, 2034, 1077, 506, 2741, 465, 282, 1059, 12, 465, 9394, 687, 272, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 14, 221, 710, 4242, 754, 911, 506, 282, 272, 2600, 12, 543, 282, 790, 367, 4036, 12082, 3420, 14, 339, 5679, 26, 267, 330 ]
[ 199, 2087, 14, 1014, 14, 10856, 2842, 859, 334, 17117, 2559, 680, 199, 199, 2765, 859, 6571, 314, 3992, 334, 460, 314, 4454, 395, 1202, 370, 2198, 199, 1589, 473, 5127, 66, 6497, 641, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 3595, 282, 4528, 14, 199, 37, 14, 71, 2020, 367, 298, 42, 397, 261, 1603, 14015, 2, 314, 25713, 6497, 3955, 506, 26, 272, 2446, 2436, 26, 257, 1455, 921, 1544, 14, 17117, 14, 957, 15, 10856, 15, 335, 3273, 17, 15, 272, 28897, 9773, 26, 420, 1455, 921, 1544, 14, 17117, 14, 957, 15, 10856, 15, 335, 3273, 17, 15, 17614, 272, 2263, 460, 880, 641, 1396, 199, 199, 7384, 10219, 13, 8664, 577, 65, 5624, 4580, 605, 26455, 665, 983, 32, 281, 32047, 14, 5135, 14, 390, 30, 2049, 9079, 869, 14, 377, 17629, 337, 738, 89, 285, 665, 29514, 285, 32, 266, 75, 723, 14, 1308, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 624, 199, 199, 646, 295, 199, 504, 3778, 492, 3882, 12, 18925, 12, 14316, 2842, 1563, 12, 1900, 63, 10888, 12, 971, 490, 19897, 63, 17117, 344, 199, 504, 4954, 2842, 492, 14316, 4943, 6756, 5087, 2842, 199, 199, 504, 18232, 14, 19088, 492, 31248, 199, 199, 63, 5484, 12818, 275, 295, 14, 2014, 8, 82, 9807, 354, 15, 10756, 779, 16, 13, 25, 8194, 23, 1552, 358, 199, 533, 14316, 4943, 14852, 6756, 5087, 2842, 8, 10462, 4943, 6756, 5087, 2842, 304, 272, 408, 2842, 367, 314, 298, 1289, 573, 9773, 2, 2034, 402, 282, 1627, 4528, 14, 272, 710, 2034, 1077, 506, 2741, 465, 282, 1059, 12, 465, 9394, 687, 272, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 14, 221, 710, 4242, 754, 911, 506, 282, 272, 2600, 12, 543, 282, 790, 367, 4036, 12082, 3420, 14, 339, 5679, 26, 267, 330, 2087, 275, 14316, 4943, 14852, 6756, 5087, 2842, 342, 267, 754, 275, 330, 2087, 14, 1122, 8, 10856, 63, 17614, 9773, 63, 1360, 63, 875, 9, 272, 408, 272, 485, 6134, 11188, 275, 715, 339, 485, 1289, 77, 63, 3288, 275, 359, 1646, 8, 498, 29, 403, 12, 1993, 3510, 29, 549, 12, 1993, 931, 3126, 2079, 283, 1073, 356, 26069, 65, 59, 17, 12978, 32, 6399, 401, 2079, 283, 1213, 356, 3680, 501, 505, 24017, 2079, 283, 1205, 356, 26069, 73, 15, 65, 501, 505, 24017, 2079, 283, 3756, 998, 356, 26069, 65, 15, 32, 6399, 2, 2079, 1660, 1993, 2963, 1412, 29, 2734, 671, 26, 2079, 1900, 63, 10888, 8, 88, 14, 362, 360, 1213, 358, 503, 399, 6448, 2892, 14360, 998, 29, 21184, 63, 17117, 344, 8, 88, 14, 362, 360, 1073, 358, 503, 399, 7, 659, 2892, 4719, 998, 3699, 5484, 12818, 14, 6452, 8, 88, 14, 362, 360, 3756, 998, 358, 503, 399, 7, 659, 2892, 2004, 29, 88, 14, 362, 360, 1205, 358, 503, 488, 12, 2892, 485, 11059, 14852, 29, 549, 10524, 339, 2402, 13451, 275, 359, 288, 18925, 8, 1302, 534, 1213, 297, 717, 931, 628, 501, 1213, 401, 717, 3290, 29, 1646, 8, 498, 534, 354, 297, 1169, 931, 628, 13186, 505, 24017, 1169, 2963, 1412, 29, 2734, 671, 26, 971, 2511, 671, 14, 1814, 360, 334, 14852, 3196, 12548, 1814, 8, 3147, 2475, 17887, 573, 9773, 701, 730, 297, 12548, 1913, 22606, 953, 18925, 8, 1302, 534, 2993, 2782, 297, 717, 931, 628, 501, 65, 14251, 354, 534, 2993, 2782, 6256, 717, 3290, 29, 1646, 8, 498, 534, 2993, 2782, 297, 1169, 931, 628, 13186, 4060, 15, 32, 2164, 8150, 953, 18925, 8, 1302, 534, 1151, 305, 297, 717, 931, 628, 501, 3015, 59, 72, 21, 534, 19978, 323, 23923, 26, 6256, 717, 3290, 29, 1646, 8, 498, 534, 1151, 305, 297, 1169, 931, 628, 13186, 3015, 501, 505, 24017, 1169, 2963, 1412, 29, 2734, 671, 26, 671, 14, 1913, 1252, 1294, 360, 1182, 283, 11508, 953, 18925, 8, 1302, 534, 1289, 573, 9773, 297, 717, 931, 628, 501, 3015, 14251, 533, 534, 1289, 573, 3488, 1397, 8, 72, 21, 1874, 15, 393, 15, 317, 401, 717, 3290, 3699, 1289, 77, 63, 3288, 395, 953, 18925, 8, 1302, 534, 1289, 573, 9773, 10189, 297, 717, 1572, 628, 501, 3015, 14251, 533, 534, 1289, 573, 3488, 72, 21, 11472, 717, 1572, 63, 498, 628, 13186, 72, 21, 15, 65, 15, 505, 24017, 717, 1572, 63, 498, 63, 7721, 29, 2734, 671, 26, 671, 14, 2325, 342, 4439, 17, 467, 717, 931, 628, 13186, 393, 15, 317, 401, 717, 3290, 3699, 1289, 77, 63, 3288, 395, 288, 1622, 339, 876, 10547, 275, 359, 288, 327, 2670, 626, 642, 3181, 1133, 10415, 298, 1205, 2, 1396, 288, 334, 264, 14, 2014, 8, 82, 7601, 3289, 30, 2961, 3134, 3134, 14, 92, 257, 7092, 23778, 1108, 317, 4206, 295, 14, 41, 1204, 295, 14, 45, 395, 11936, 317, 30, 5440, 421, 199, 533, 14316, 4943, 14852, 34, 2308, 2842, 8, 10462, 2842, 1563, 304, 272, 408, 2842, 367, 314, 298, 17614, 9773, 2, 2034, 402, 282, 1627, 4528, 14, 272, 710, 2034, 1077, 506, 2741, 465, 282, 1059, 12, 465, 9394, 687, 272, 314, 282, 75, 305, 14, 17117, 14, 957, 1654, 14, 221, 710, 4242, 754, 911, 506, 282, 272, 2600, 12, 543, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
huanpc/IoT-1
gui/controller/.venv/lib/python3.5/site-packages/django/forms/forms.py
141
19457
""" Form classes """ from __future__ import unicode_literals import copy from collections import OrderedDict from django.core.exceptions import NON_FIELD_ERRORS, ValidationError # BoundField is imported for backwards compatibility in Django 1.9 from django.forms.boundfield import BoundField # NOQA from django.forms.fields import Field, FileField # pretty_name is imported for backwards compatibility in Django 1.9 from django.forms.utils import ErrorDict, ErrorList, pretty_name # NOQA from django.forms.widgets import Media, MediaDefiningClass from django.utils import six from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.functional import cached_property from django.utils.html import conditional_escape, html_safe from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ __all__ = ('BaseForm', 'Form') class DeclarativeFieldsMetaclass(MediaDefiningClass): """ Metaclass that collects Fields declared on the base classes. """ def __new__(mcs, name, bases, attrs): # Collect fields from current class. current_fields = [] for key, value in list(attrs.items()): if isinstance(value, Field): current_fields.append((key, value)) attrs.pop(key) current_fields.sort(key=lambda x: x[1].creation_counter) attrs['declared_fields'] = OrderedDict(current_fields) new_class = (super(DeclarativeFieldsMetaclass, mcs) .__new__(mcs, name, bases, attrs)) # Walk through the MRO. declared_fields = OrderedDict() for base in reversed(new_class.__mro__): # Collect fields from base class. if hasattr(base, 'declared_fields'): declared_fields.update(base.declared_fields) # Field shadowing. for attr, value in base.__dict__.items(): if value is None and attr in declared_fields: declared_fields.pop(attr) new_class.base_fields = declared_fields new_class.declared_fields = declared_fields return new_class @html_safe @python_2_unicode_compatible class BaseForm(object): # This is the main implementation of all the Form logic. Note that this # class is different than Form. See the comments by the Form class for more # information. Any improvements to the form API should be made to *this* # class, not to the Form class. field_order = None prefix = None def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None): self.is_bound = data is not None or files is not None self.data = data or {} self.files = files or {} self.auto_id = auto_id if prefix is not None: self.prefix = prefix self.initial = initial or {} self.error_class = error_class # Translators: This is the default suffix added to form field labels self.label_suffix = label_suffix if label_suffix is not None else _(':') self.empty_permitted = empty_permitted self._errors = None # Stores the errors after clean() has been called. # The base_fields class attribute is the *class-wide* definition of # fields. Because a particular *instance* of the class might want to # alter self.fields, we create self.fields here by copying base_fields. # Instances should always modify self.fields; they should not modify # self.base_fields. self.fields = copy.deepcopy(self.base_fields) self._bound_fields_cache = {} self.order_fields(self.field_order if field_order is None else field_order) def order_fields(self, field_order): """ Rearranges the fields according to field_order. field_order is a list of field names specifying the order. Fields not included in the list are appended in the default order for backward compatibility with subclasses not overriding field_order. If field_order is None, all fields are kept in the order defined in the class. Unknown fields in field_order are ignored to allow disabling fields in form subclasses without redefining ordering. """ if field_order is None: return fields = OrderedDict() for key in field_order: try: fields[key] = self.fields.pop(key) except KeyError: # ignore unknown fields pass fields.update(self.fields) # add remaining fields in original order self.fields = fields def __str__(self): return self.as_table() def __repr__(self): if self._errors is None: is_valid = "Unknown" else: is_valid = self.is_bound and not bool(self._errors) return '<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>' % { 'cls': self.__class__.__name__, 'bound': self.is_bound, 'valid': is_valid, 'fields': ';'.join(self.fields), } def __iter__(self): for name in self.fields: yield self[name] def __getitem__(self, name): "Returns a BoundField with the given name." try: field = self.fields[name] except KeyError: raise KeyError( "Key %r not found in '%s'" % (name, self.__class__.__name__)) if name not in self._bound_fields_cache: self._bound_fields_cache[name] = field.get_bound_field(self, name) return self._bound_fields_cache[name] @property def errors(self): "Returns an ErrorDict for the data provided for the form" if self._errors is None: self.full_clean() return self._errors def is_valid(self): """ Returns True if the form has no errors. Otherwise, False. If errors are being ignored, returns False. """ return self.is_bound and not self.errors def add_prefix(self, field_name): """ Returns the field name with a prefix appended, if this Form has a prefix set. Subclasses may wish to override. """ return '%s-%s' % (self.prefix, field_name) if self.prefix else field_name def add_initial_prefix(self, field_name): """ Add a 'initial' prefix for checking dynamic initial values """ return 'initial-%s' % self.add_prefix(field_name) def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row): "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()." top_errors = self.non_field_errors() # Errors that should be displayed above all fields. output, hidden_fields = [], [] for name, field in self.fields.items(): html_class_attr = '' bf = self[name] # Escape and cache in local variable. bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) if bf.is_hidden: if bf_errors: top_errors.extend( [_('(Hidden field %(name)s) %(error)s') % {'name': name, 'error': force_text(e)} for e in bf_errors]) hidden_fields.append(six.text_type(bf)) else: # Create a 'class="..."' attribute if the row should have any # CSS classes applied. css_classes = bf.css_classes() if css_classes: html_class_attr = ' class="%s"' % css_classes if errors_on_separate_row and bf_errors: output.append(error_row % force_text(bf_errors)) if bf.label: label = conditional_escape(force_text(bf.label)) label = bf.label_tag(label) or '' else: label = '' if field.help_text: help_text = help_text_html % force_text(field.help_text) else: help_text = '' output.append(normal_row % { 'errors': force_text(bf_errors), 'label': force_text(label), 'field': six.text_type(bf), 'help_text': help_text, 'html_class_attr': html_class_attr, 'css_classes': css_classes, 'field_name': bf.html_name, }) if top_errors: output.insert(0, error_row % force_text(top_errors)) if hidden_fields: # Insert any hidden fields in the last row. str_hidden = ''.join(hidden_fields) if output: last_row = output[-1] # Chop off the trailing row_ender (e.g. '</td></tr>') and # insert the hidden fields. if not last_row.endswith(row_ender): # This can happen in the as_p() case (and possibly others # that users write): if there are only top errors, we may # not be able to conscript the last row for our purposes, # so insert a new, empty row. last_row = (normal_row % { 'errors': '', 'label': '', 'field': '', 'help_text': '', 'html_class_attr': html_class_attr, 'css_classes': '', 'field_name': '', }) output.append(last_row) output[-1] = last_row[:-len(row_ender)] + str_hidden + row_ender else: # If there aren't any rows in the output, just append the # hidden fields. output.append(str_hidden) return mark_safe('\n'.join(output)) def as_table(self): "Returns this form rendered as HTML <tr>s -- excluding the <table></table>." return self._html_output( normal_row='<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', error_row='<tr><td colspan="2">%s</td></tr>', row_ender='</td></tr>', help_text_html='<br /><span class="helptext">%s</span>', errors_on_separate_row=False) def as_ul(self): "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." return self._html_output( normal_row='<li%(html_class_attr)s>%(errors)s%(label)s %(field)s%(help_text)s</li>', error_row='<li>%s</li>', row_ender='</li>', help_text_html=' <span class="helptext">%s</span>', errors_on_separate_row=False) def as_p(self): "Returns this form rendered as HTML <p>s." return self._html_output( normal_row='<p%(html_class_attr)s>%(label)s %(field)s%(help_text)s</p>', error_row='%s', row_ender='</p>', help_text_html=' <span class="helptext">%s</span>', errors_on_separate_row=True) def non_field_errors(self): """ Returns an ErrorList of errors that aren't associated with a particular field -- i.e., from Form.clean(). Returns an empty ErrorList if there are none. """ return self.errors.get(NON_FIELD_ERRORS, self.error_class(error_class='nonfield')) def add_error(self, field, error): """ Update the content of `self._errors`. The `field` argument is the name of the field to which the errors should be added. If its value is None the errors will be treated as NON_FIELD_ERRORS. The `error` argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. What we define as an "error" can be either a simple string or an instance of ValidationError with its message attribute set and what we define as list or dictionary can be an actual `list` or `dict` or an instance of ValidationError with its `error_list` or `error_dict` attribute set. If `error` is a dictionary, the `field` argument *must* be None and errors will be added to the fields that correspond to the keys of the dictionary. """ if not isinstance(error, ValidationError): # Normalize to ValidationError and let its constructor # do the hard work of making sense of the input. error = ValidationError(error) if hasattr(error, 'error_dict'): if field is not None: raise TypeError( "The argument `field` must be `None` when the `error` " "argument contains errors for multiple fields." ) else: error = error.error_dict else: error = {field or NON_FIELD_ERRORS: error.error_list} for field, error_list in error.items(): if field not in self.errors: if field != NON_FIELD_ERRORS and field not in self.fields: raise ValueError( "'%s' has no field named '%s'." % (self.__class__.__name__, field)) if field == NON_FIELD_ERRORS: self._errors[field] = self.error_class(error_class='nonfield') else: self._errors[field] = self.error_class() self._errors[field].extend(error_list) if field in self.cleaned_data: del self.cleaned_data[field] def has_error(self, field, code=None): if code is None: return field in self.errors if field in self.errors: for error in self.errors.as_data()[field]: if error.code == code: return True return False def full_clean(self): """ Cleans all of self.data and populates self._errors and self.cleaned_data. """ self._errors = ErrorDict() if not self.is_bound: # Stop further processing. return self.cleaned_data = {} # If the form is permitted to be empty, and none of the form data has # changed from the initial data, short circuit any validation. if self.empty_permitted and not self.has_changed(): return self._clean_fields() self._clean_form() self._post_clean() def _clean_fields(self): for name, field in self.fields.items(): # value_from_datadict() gets the data from the data dictionaries. # Each widget type knows how to retrieve its own data, because some # widgets split data over several HTML fields. if field.disabled: value = self.initial.get(name, field.initial) else: value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) try: if isinstance(field, FileField): initial = self.initial.get(name, field.initial) value = field.clean(value, initial) else: value = field.clean(value) self.cleaned_data[name] = value if hasattr(self, 'clean_%s' % name): value = getattr(self, 'clean_%s' % name)() self.cleaned_data[name] = value except ValidationError as e: self.add_error(name, e) def _clean_form(self): try: cleaned_data = self.clean() except ValidationError as e: self.add_error(None, e) else: if cleaned_data is not None: self.cleaned_data = cleaned_data def _post_clean(self): """ An internal hook for performing additional cleaning after form cleaning is complete. Used for model validation in model forms. """ pass def clean(self): """ Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named '__all__'. """ return self.cleaned_data def has_changed(self): """ Returns True if data differs from initial. """ return bool(self.changed_data) @cached_property def changed_data(self): data = [] for name, field in self.fields.items(): prefixed_name = self.add_prefix(name) data_value = field.widget.value_from_datadict(self.data, self.files, prefixed_name) if not field.show_hidden_initial: initial_value = self.initial.get(name, field.initial) if callable(initial_value): initial_value = initial_value() else: initial_prefixed_name = self.add_initial_prefix(name) hidden_widget = field.hidden_widget() try: initial_value = field.to_python(hidden_widget.value_from_datadict( self.data, self.files, initial_prefixed_name)) except ValidationError: # Always assume data has changed if validation fails. data.append(name) continue if field.has_changed(initial_value, data_value): data.append(name) return data @property def media(self): """ Provide a description of all media required to render the widgets on this form """ media = Media() for field in self.fields.values(): media = media + field.widget.media return media def is_multipart(self): """ Returns True if the form needs to be multipart-encoded, i.e. it has FileInput. Otherwise, False. """ for field in self.fields.values(): if field.widget.needs_multipart_form: return True return False def hidden_fields(self): """ Returns a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates. """ return [field for field in self if field.is_hidden] def visible_fields(self): """ Returns a list of BoundField objects that aren't hidden fields. The opposite of the hidden_fields() method. """ return [field for field in self if not field.is_hidden] class Form(six.with_metaclass(DeclarativeFieldsMetaclass, BaseForm)): "A collection of Fields, plus their associated data." # This is a separate class from BaseForm in order to abstract the way # self.fields is specified. This class (Form) is the one that does the # fancy metaclass stuff purely for the semantic sugar -- it allows one # to define a form using declarative syntax. # BaseForm itself has no way of designating self.fields.
mit
[ 624, 199, 2821, 3992, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1331, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11214, 63, 8609, 63, 21477, 12, 8505, 199, 3, 21972, 792, 365, 8439, 367, 8552, 7163, 315, 5634, 413, 14, 25, 199, 504, 1639, 14, 3351, 14, 3556, 698, 492, 21972, 792, 221, 327, 20432, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 3814, 792, 199, 3, 7268, 63, 354, 365, 8439, 367, 8552, 7163, 315, 5634, 413, 14, 25, 199, 504, 1639, 14, 3351, 14, 1208, 492, 4520, 2141, 12, 4520, 1296, 12, 7268, 63, 354, 221, 327, 20432, 199, 504, 1639, 14, 3351, 14, 8583, 492, 12300, 12, 12300, 872, 2408, 316, 2543, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 12, 3517, 63, 3489, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 199, 363, 452, 363, 275, 661, 1563, 2821, 297, 283, 2821, 358, 421, 199, 533, 1487, 4925, 1905, 7304, 29387, 8, 11398, 872, 2408, 316, 2543, 304, 272, 408, 272, 6288, 533, 626, 8775, 83, 16424, 14290, 641, 314, 1300, 3992, 14, 272, 408, 272, 347, 636, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 304, 267, 327, 19649, 1504, 687, 1453, 1021, 14, 267, 1453, 63, 955, 275, 942, 267, 367, 790, 12, 574, 315, 769, 8, 3288, 14, 1744, 5109, 288, 340, 1228, 8, 585, 12, 5024, 304, 355, 1453, 63, 955, 14, 740, 1332, 498, 12, 574, 430, 355, 3290, 14, 1935, 8, 498, 9, 267, 1453, 63, 955, 14, 3191, 8, 498, 29, 2734, 671, 26, 671, 59, 17, 1055, 8782, 63, 5337, 9, 267, 3290, 459, 13545, 63, 955, 418, 275, 8773, 8, 1818, 63, 955, 9, 398, 892, 63, 533, 275, 334, 4792, 8, 31963, 1905, 7304, 29387, 12, 333, 1259, 9, 288, 221, 855, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 430, 398, 327, 644, 4878, 4012, 314, 603, 1092, 14, 267, 14290, 63, 955, 275, 8773, 342, 267, 367, 1300, 315, 10822, 8, 1222, 63, 533, 855, 17335, 18580, 288, 327, 19649, 1504, 687, 1300, 1021, 14, 288, 340, 2688, 8, 1095, 12, 283, 13545, 63, 955, 735, 355, 14290, 63, 955, 14, 873, 8, 1095, 14, 13545, 63, 955, 9, 953, 327, 5024, 15084, 316, 14, 288, 367, 1921, 12, 574, 315, 1300, 855, 807, 4343, 1744, 837, 355, 340, 574, 365, 488, 436, 1921, 315, 14290, 63, 955, 26, 490, 14290, 63, 955, 14, 1935, 8, 962, 9, 398, 892, 63, 533, 14, 1095, 63, 955, 275, 14290, 63, 955, 267, 892, 63, 533, 14, 13545, 63, 955, 275, 14290, 63, 955, 398, 372, 892, 63, 533, 421, 199, 32, 1360, 63, 3489, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 3523, 2821, 8, 785, 304, 272, 327, 961, 365, 314, 2446, 4514, 402, 1006, 314, 8204, 9661, 14, 3390, 626, 642, 272, 327, 1021, 365, 3365, 2419, 8204, 14, 1666, 314, 6786, 701, 314, 8204, 1021, 367, 1655, 272, 327, 2556, 14, 6184, 19053, 1470, 370, 314, 1824, 3261, 1077, 506, 6326, 370, 627, 3749, 10, 272, 327, 1021, 12, 440, 370, 314, 8204, 1021, 14, 272, 901, 63, 1648, 275, 488, 272, 2403, 275, 488, 339, 347, 636, 826, 721, 277, 12, 666, 29, 403, 12, 1584, 29, 403, 12, 2599, 63, 344, 534, 344, 4970, 83, 297, 2403, 29, 403, 12, 326, 2536, 29, 403, 12, 1125, 63, 533, 29, 547, 1296, 12, 1768, 63, 4511, 29, 403, 12, 326, 2701, 63, 28843, 29, 797, 12, 901, 63, 1648, 29, 403, 304, 267, 291, 14, 374, 63, 3556, 275, 666, 365, 440, 488, 503, 1584, 365, 440, 488, 267, 291, 14, 576, 275, 666, 503, 1052, 267, 291, 14, 1725, 275, 1584, 503, 1052, 267, 291, 14, 2495, 63, 344, 275, 2599, 63, 344, 267, 340, 2403, 365, 440, 488, 26, 288, 291, 14, 1861, 275, 2403, 267, 291, 14, 2747, 275, 2536, 503, 1052, 267, 291, 14, 705, 63, 533, 275, 1125, 63, 533, 267, 327, 26355, 26, 961, 365, 314, 849, 4739, 3483, 370, 1824, 901, 3628, 267, 291, 14, 1302, 63, 4511, 275, 1768, 63, 4511, 340, 1768, 63, 4511, 365, 440, 488, 587, 485, 11633, 267, 291, 14, 1667, 63, 28843, 275, 2701, 63, 28843, 267, 291, 423, 2550, 275, 488, 221, 327, 31299, 314, 2552, 2410, 3633, 342, 965, 2757, 2797, 14, 398, 327, 710, 1300, 63, 955, 1021, 2225, 365, 314, 627, 533, 13, 13062, 10, 5492, 402, 267, 327, 1504, 14, 13821, 282, 6770, 627, 842, 10, 402, 314, 1021, 5594, 2934, 370, 267, 327, 17355, 291, 14, 955, 12, 781, 1218, 291, 14, 955, 2348, 701, 16743, 1300, 63, 955, 14, 267, 327, 10066, 83, 1077, 3544, 2811, 291, 14, 955, 27, 2985, 1077, 440, 2811, 267, 327, 291, 14, 1095, 63, 955, 14, 267, 291, 14, 955, 275, 1331, 14, 8293, 8, 277, 14, 1095, 63, 955, 9, 267, 291, 423, 3556, 63, 955, 63, 1637, 275, 1052, 267, 291, 14, 1648, 63, 955, 8, 277, 14, 698, 63, 1648, 340, 901, 63, 1648, 365, 488, 587, 901, 63, 1648, 9, 339, 347, 1865, 63, 955, 8, 277, 12, 901, 63, 1648, 304, 267, 408, 267, 799, 285, 8404, 314, 1504, 7182, 370, 901, 63, 1648, 14, 398, 901, 63, 1648, 365, 282, 769, 402, 901, 1561, 9176, 314, 1865, 14, 16424, 440, 267, 5120, 315, 314, 769, 787, 11544, 315, 314, 849, 1865, 367, 13388, 267, 7163, 543, 9180, 440, 18972, 901, 63, 1648, 14, 982, 901, 63, 1648, 267, 365, 488, 12, 1006, 1504, 787, 16204, 315, 314, 1865, 3247, 315, 314, 1021, 14, 267, 14831, 1504, 315, 901, 63, 1648, 787, 5525, 370, 2040, 30723, 1504, 315, 267, 1824, 9180, 1928, 295, 318, 7969, 7794 ]
[ 199, 2821, 3992, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1331, 199, 504, 5055, 492, 8773, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11214, 63, 8609, 63, 21477, 12, 8505, 199, 3, 21972, 792, 365, 8439, 367, 8552, 7163, 315, 5634, 413, 14, 25, 199, 504, 1639, 14, 3351, 14, 3556, 698, 492, 21972, 792, 221, 327, 20432, 199, 504, 1639, 14, 3351, 14, 955, 492, 5024, 12, 3814, 792, 199, 3, 7268, 63, 354, 365, 8439, 367, 8552, 7163, 315, 5634, 413, 14, 25, 199, 504, 1639, 14, 3351, 14, 1208, 492, 4520, 2141, 12, 4520, 1296, 12, 7268, 63, 354, 221, 327, 20432, 199, 504, 1639, 14, 3351, 14, 8583, 492, 12300, 12, 12300, 872, 2408, 316, 2543, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 12, 3517, 63, 3489, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 199, 363, 452, 363, 275, 661, 1563, 2821, 297, 283, 2821, 358, 421, 199, 533, 1487, 4925, 1905, 7304, 29387, 8, 11398, 872, 2408, 316, 2543, 304, 272, 408, 272, 6288, 533, 626, 8775, 83, 16424, 14290, 641, 314, 1300, 3992, 14, 272, 408, 272, 347, 636, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 304, 267, 327, 19649, 1504, 687, 1453, 1021, 14, 267, 1453, 63, 955, 275, 942, 267, 367, 790, 12, 574, 315, 769, 8, 3288, 14, 1744, 5109, 288, 340, 1228, 8, 585, 12, 5024, 304, 355, 1453, 63, 955, 14, 740, 1332, 498, 12, 574, 430, 355, 3290, 14, 1935, 8, 498, 9, 267, 1453, 63, 955, 14, 3191, 8, 498, 29, 2734, 671, 26, 671, 59, 17, 1055, 8782, 63, 5337, 9, 267, 3290, 459, 13545, 63, 955, 418, 275, 8773, 8, 1818, 63, 955, 9, 398, 892, 63, 533, 275, 334, 4792, 8, 31963, 1905, 7304, 29387, 12, 333, 1259, 9, 288, 221, 855, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 430, 398, 327, 644, 4878, 4012, 314, 603, 1092, 14, 267, 14290, 63, 955, 275, 8773, 342, 267, 367, 1300, 315, 10822, 8, 1222, 63, 533, 855, 17335, 18580, 288, 327, 19649, 1504, 687, 1300, 1021, 14, 288, 340, 2688, 8, 1095, 12, 283, 13545, 63, 955, 735, 355, 14290, 63, 955, 14, 873, 8, 1095, 14, 13545, 63, 955, 9, 953, 327, 5024, 15084, 316, 14, 288, 367, 1921, 12, 574, 315, 1300, 855, 807, 4343, 1744, 837, 355, 340, 574, 365, 488, 436, 1921, 315, 14290, 63, 955, 26, 490, 14290, 63, 955, 14, 1935, 8, 962, 9, 398, 892, 63, 533, 14, 1095, 63, 955, 275, 14290, 63, 955, 267, 892, 63, 533, 14, 13545, 63, 955, 275, 14290, 63, 955, 398, 372, 892, 63, 533, 421, 199, 32, 1360, 63, 3489, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 3523, 2821, 8, 785, 304, 272, 327, 961, 365, 314, 2446, 4514, 402, 1006, 314, 8204, 9661, 14, 3390, 626, 642, 272, 327, 1021, 365, 3365, 2419, 8204, 14, 1666, 314, 6786, 701, 314, 8204, 1021, 367, 1655, 272, 327, 2556, 14, 6184, 19053, 1470, 370, 314, 1824, 3261, 1077, 506, 6326, 370, 627, 3749, 10, 272, 327, 1021, 12, 440, 370, 314, 8204, 1021, 14, 272, 901, 63, 1648, 275, 488, 272, 2403, 275, 488, 339, 347, 636, 826, 721, 277, 12, 666, 29, 403, 12, 1584, 29, 403, 12, 2599, 63, 344, 534, 344, 4970, 83, 297, 2403, 29, 403, 12, 326, 2536, 29, 403, 12, 1125, 63, 533, 29, 547, 1296, 12, 1768, 63, 4511, 29, 403, 12, 326, 2701, 63, 28843, 29, 797, 12, 901, 63, 1648, 29, 403, 304, 267, 291, 14, 374, 63, 3556, 275, 666, 365, 440, 488, 503, 1584, 365, 440, 488, 267, 291, 14, 576, 275, 666, 503, 1052, 267, 291, 14, 1725, 275, 1584, 503, 1052, 267, 291, 14, 2495, 63, 344, 275, 2599, 63, 344, 267, 340, 2403, 365, 440, 488, 26, 288, 291, 14, 1861, 275, 2403, 267, 291, 14, 2747, 275, 2536, 503, 1052, 267, 291, 14, 705, 63, 533, 275, 1125, 63, 533, 267, 327, 26355, 26, 961, 365, 314, 849, 4739, 3483, 370, 1824, 901, 3628, 267, 291, 14, 1302, 63, 4511, 275, 1768, 63, 4511, 340, 1768, 63, 4511, 365, 440, 488, 587, 485, 11633, 267, 291, 14, 1667, 63, 28843, 275, 2701, 63, 28843, 267, 291, 423, 2550, 275, 488, 221, 327, 31299, 314, 2552, 2410, 3633, 342, 965, 2757, 2797, 14, 398, 327, 710, 1300, 63, 955, 1021, 2225, 365, 314, 627, 533, 13, 13062, 10, 5492, 402, 267, 327, 1504, 14, 13821, 282, 6770, 627, 842, 10, 402, 314, 1021, 5594, 2934, 370, 267, 327, 17355, 291, 14, 955, 12, 781, 1218, 291, 14, 955, 2348, 701, 16743, 1300, 63, 955, 14, 267, 327, 10066, 83, 1077, 3544, 2811, 291, 14, 955, 27, 2985, 1077, 440, 2811, 267, 327, 291, 14, 1095, 63, 955, 14, 267, 291, 14, 955, 275, 1331, 14, 8293, 8, 277, 14, 1095, 63, 955, 9, 267, 291, 423, 3556, 63, 955, 63, 1637, 275, 1052, 267, 291, 14, 1648, 63, 955, 8, 277, 14, 698, 63, 1648, 340, 901, 63, 1648, 365, 488, 587, 901, 63, 1648, 9, 339, 347, 1865, 63, 955, 8, 277, 12, 901, 63, 1648, 304, 267, 408, 267, 799, 285, 8404, 314, 1504, 7182, 370, 901, 63, 1648, 14, 398, 901, 63, 1648, 365, 282, 769, 402, 901, 1561, 9176, 314, 1865, 14, 16424, 440, 267, 5120, 315, 314, 769, 787, 11544, 315, 314, 849, 1865, 367, 13388, 267, 7163, 543, 9180, 440, 18972, 901, 63, 1648, 14, 982, 901, 63, 1648, 267, 365, 488, 12, 1006, 1504, 787, 16204, 315, 314, 1865, 3247, 315, 314, 1021, 14, 267, 14831, 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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 ]
sbelharbi/structured-output-ae
sop_embed/experiments/lfpw_4l_out_unl.py
1
14984
from sop_embed.da import DenoisingAutoencoder from sop_embed.tools import NonLinearity from sop_embed.tools import CostType from sop_embed.tools import ModelMLP from sop_embed.tools import train_one_epoch_chuncks from sop_embed.tools import theano_fns from sop_embed.tools import sharedX_value from sop_embed.tools import collect_stats_epoch from sop_embed.tools import plot_stats from sop_embed.tools import split_data_to_minibatchs_eval from sop_embed.tools import split_data_to_minibatchs_embed from sop_embed.tools import evaluate_model from sop_embed.tools import StaticAnnealedWeightRate from sop_embed.tools import StaticExponentialDecayWeightRate from sop_embed.tools import StaticExponentialDecayWeightRateSingle from sop_embed.tools import StaticAnnealedWeightRateSingle from sop_embed.tools import print_stats_train from sop_embed.learning_rule import AdaDelta from sop_embed.learning_rule import Momentum import theano.tensor as T import theano import numpy as np import cPickle as pkl import datetime as DT import os import inspect import sys import shutil from random import shuffle # Alexnet: 9216 # VGG16: 25088 def standardize(data): """ Normalize the data with respect to finding the mean and the standard deviation of it and dividing by mean and standard deviation. """ mu = np.mean(data, axis=0) sigma = np.std(data, axis=0) if sigma.nonzero()[0].shape[0] == 0: raise Exception("Std dev should not be zero") norm_data = (data - mu) / sigma return norm_data if __name__ == "__main__": type_mod = "" if type_mod is "alexnet": dim_in = 9216 if type_mod is "vgg_16": dim_in = 25088 if type_mod is "vgg_19": dim_in = 9216 if type_mod is "googlenet": dim_in = 9216 faceset = "lfpw" fd_data = "../../inout/data/face/" + faceset + "_u_helen/" path_valid = fd_data + type_mod + "valid.pkl" w, h = 50, 50 if type_mod is not None and type_mod is not "": w, h = dim_in, 1 input = T.fmatrix("x_input") output = T.fmatrix("y_output") # Create mixed data nbr_sup, nbr_xx, nbr_yy = 676, 2330, 2330 id_data = type_mod + "ch_tr_" + str(nbr_sup) + '_' + str(nbr_xx) + '_' +\ str(nbr_yy) # List train chuncks l_ch_tr = [fd_data + "train.pkl"] time_exp = DT.datetime.now().strftime('%m_%d_%Y_%H_%M_%s') fold_exp = "../../exps/" + faceset + "_" + time_exp if not os.path.exists(fold_exp): os.makedirs(fold_exp) nbr_layers = 4 init_w_path = "../../inout/init_weights/" + str(nbr_layers) + '_' +\ faceset + '_layers/' if not os.path.exists(init_w_path): os.makedirs(init_w_path) rnd = np.random.RandomState(1231) nhid_l0 = 1025 nhid_l1 = 512 nhid_l2 = 64 # Create the AE in 1 nvis, nhid = w*h, nhid_l0 path_ini_params_l0 = init_w_path + "dae_w_l0_init_" + str(nvis) + '_' +\ str(nhid) + ".pkl" dae_l0 = DenoisingAutoencoder(input, nvis=nvis, nhid=nhid, L1_reg=0., L2_reg=1e-2, rnd=rnd, nonlinearity=NonLinearity.SIGMOID, cost_type=CostType.MeanSquared, reverse=False, corruption_level=0.2) if not os.path.isfile(path_ini_params_l0): dae_l0.save_params(path_ini_params_l0) else: dae_l0.set_params_vals(path_ini_params_l0) # Create the AE in 2 nvis, nhid = nhid_l0, nhid_l1 path_ini_params_l1 = init_w_path + "dae_w_l1_init_" + str(nvis) + '_' +\ str(nhid) + ".pkl" dae_l1 = DenoisingAutoencoder(dae_l0.encode((input)), nvis=nhid_l0, nhid=nhid_l1, L1_reg=0., L2_reg=1e-2, rnd=rnd, nonlinearity=NonLinearity.SIGMOID, cost_type=CostType.MeanSquared, reverse=False, corruption_level=0.01) if not os.path.isfile(path_ini_params_l1): dae_l1.save_params(path_ini_params_l1) else: dae_l1.set_params_vals(path_ini_params_l1) # Create the AE in 3 nvis, nhid = nhid_l1, nhid_l2 path_ini_params_l2 = init_w_path + "dae_w_l2_init_" + str(nvis) + '_' +\ str(nhid) + ".pkl" dae_l2 = DenoisingAutoencoder(dae_l1.encode(dae_l0.encode((input))), nvis=nhid_l1, nhid=nhid_l2, L1_reg=0., L2_reg=0., rnd=rnd, nonlinearity=NonLinearity.TANH, cost_type=CostType.MeanSquared, reverse=False) if not os.path.isfile(path_ini_params_l2): dae_l2.save_params(path_ini_params_l2) else: dae_l2.set_params_vals(path_ini_params_l2) # Create the AE out nvis, nhid = 68*2, nhid_l2 path_ini_params_l3 = init_w_path + "dae_w_l3_init_" + str(nvis) + '_' +\ str(nhid) + ".pkl" dae_l3 = DenoisingAutoencoder(output, L1_reg=0., L2_reg=1e-2, nvis=nvis, nhid=nhid, rnd=rnd, nonlinearity=NonLinearity.TANH, cost_type=CostType.MeanSquared, reverse=True) if not os.path.isfile(path_ini_params_l3): dae_l3.save_params(path_ini_params_l3) else: dae_l3.set_params_vals(path_ini_params_l3) # Create the network rng = np.random.RandomState(23455) layer0 = { "rng": rng, "n_in": w*h, "n_out": nhid_l0, "W": dae_l0.hidden.W, "b": dae_l0.hidden.b, "activation": NonLinearity.SIGMOID } layer1 = { "rng": rng, "n_in": nhid_l0, "n_out": nhid_l1, "W": dae_l1.hidden.W, "b": dae_l1.hidden.b, "activation": NonLinearity.SIGMOID } layer2 = { "rng": rng, "n_in": nhid_l1, "n_out": nhid_l2, "W": dae_l2.hidden.W, "b": dae_l2.hidden.b, "activation": NonLinearity.TANH } layer3 = { "rng": rng, "n_in": nhid_l2, "n_out": 68*2, "W": dae_l3.hidden.W_prime, "b": dae_l3.hidden.b_prime, "activation": NonLinearity.TANH } layers = [layer0, layer1, layer2, layer3] # dropout = [float(sys.argv[1]), float(sys.argv[2]), float(sys.argv[3]), # float(sys.argv[4])] dropout = [0.0, 0.0, 0.0, 0.0] # number of the hidden layer just before the output ae. Default: None id_code = None model = ModelMLP(layers, input, l1_reg=0., l2_reg=0., reg_bias=False, dropout=dropout, id_code=id_code) aes_in = [] aes_out = [dae_l3] if id_code is not None: assert aes_out != [] # Train # Data tr_batch_size = 10 vl_batch_size = 8000 with open(path_valid, 'r') as f: l_samples_vl = pkl.load(f) list_minibatchs_vl = split_data_to_minibatchs_eval( l_samples_vl, vl_batch_size) max_epochs = int(1000) lr_vl = 1e-3 lr = sharedX_value(lr_vl, name="lr") # cost weights separate = True l_in = [sharedX_value(0., name="l_in"), sharedX_value(0.0, name="l_in2")] l_out = [sharedX_value(1., name="l_out")] l_sup = sharedX_value(1., name="l_sup") l_code = sharedX_value(0.0, name="l_code") if not separate: assert l_sup.get_value() + l_in.get_value() + l_out.get_value() == 1. if l_in[0].get_value() != 0. and aes_in == []: raise ValueError("You setup the l_in but no aes in found.") if l_out[0].get_value() != 0. and aes_out == []: raise ValueError("You setup the l_out but no aes out found.") # Train criterion cost_type = CostType.MeanSquared # CostType.MeanSquared # Compile the functions # Momentum(0.9, nesterov_momentum=False, # imagenet=False, imagenetDecay=5e-4, # max_colm_norm=False) train_updates, eval_fn = theano_fns( model, aes_in, aes_out, l_in, l_out, l_sup, l_code, lr, cost_type, updaters={ "all": Momentum(0.9, nesterov_momentum=False, imagenet=False, imagenetDecay=5e-4, max_colm_norm=False), "in": Momentum(0.9, nesterov_momentum=False, imagenet=False, imagenetDecay=5e-4, max_colm_norm=False), "out": Momentum(0.9, nesterov_momentum=False, imagenet=False, imagenetDecay=5e-4, max_colm_norm=False), "code": None}, max_colm_norm=False, max_norm=15.0, eye=False) # How to update the weight costs updater_wc = StaticAnnealedWeightRate(anneal_end=500, anneal_start=0) updater_wc_in = StaticAnnealedWeightRateSingle(anneal_end=500, down=True, init_vl=1., end_vl=0., anneal_start=100) updater_wc_in2 = StaticAnnealedWeightRateSingle(anneal_end=500, down=True, init_vl=0.0, end_vl=0., anneal_start=400) updater_wc_out = StaticAnnealedWeightRateSingle(anneal_end=700, down=True, init_vl=1., end_vl=0., anneal_start=100) # how to update the weight code # l_code_updater = StaticExponentialDecayWeightRateSingle(slop=20, # anneal_start=0) to_update = {"l_in": True, "l_out": True} if aes_in == []: to_update["l_in"] = False if aes_out == []: to_update["l_out"] = False # Train i = 0 # Stats train_stats = {"in_cost": [], "out_cost": [], "all_cost": [], "tr_pure_cost": [], "code_cost": [], "in_cost_mb": [], "out_cost_mb": [], "all_cost_mb": [], "tr_pure_cost_mb": [], "error_tr": [], "error_vl": [], "error_tr_mb": [], "error_vl_mb": [], "code_cost_mb": [], "best_epoch": 0, "best_mb": 0} # tag if aes_in == [] and aes_out == []: tag = "sup" elif aes_in != [] and aes_out == []: tag = "sup + in" elif aes_in == [] and aes_out != []: tag = "sup + out" elif aes_in != [] and aes_out != []: tag = "sup + in + out" tag += ", data: " + faceset + " " + id_data # First evaluation on valid error_mn, _ = evaluate_model(list_minibatchs_vl, eval_fn) vl_error_begin = np.mean(error_mn) shutil.copy(inspect.stack()[0][1], fold_exp) l_ch_tr_vl = [] for ch in l_ch_tr: with open(ch, 'r') as f: l_samples = pkl.load(f) l_ch_tr_vl.append(l_samples) stop = False while i < max_epochs: stop = (i == max_epochs - 1) stats = train_one_epoch_chuncks( train_updates, eval_fn, l_ch_tr_vl, l_in, l_out, l_sup, l_code, list_minibatchs_vl, model, aes_in, aes_out, i, fold_exp, train_stats, vl_error_begin, tag, tr_batch_size, stop=stop) # Shuffle the minibatchs: to avoid periodic behavior. # for ts in xrange(100): # shuffle(l_ch_tr_vl) # Collect stats train_stats = collect_stats_epoch(stats, train_stats) # Print train stats # print_stats_train(train_stats, i, "", 0) # reduce the frequency of the disc access, it costs too much!!! if stop: # Plot stats: epoch plot_stats(train_stats, "epoch", fold_exp, tag) # Save stats with open(fold_exp + "/train_stats.pkl", 'w') as f_ts: pkl.dump(train_stats, f_ts) # Update the cost weights if aes_in != [] or aes_out != []: # updater_wc(l_sup, l_in, l_out, i, to_update) updater_wc_out(l_out[0], i) print "\n", l_sup.get_value(), l_out[0].get_value() for el in l_in: print el.get_value(), print "" if id_code is not None: l_code_updater(l_code, i) print "l_code:", l_code.get_value() # Check the stopping criterion # [TODO] # Update lr # if (i % 1 == 0): # lr.set_value(np.cast[theano.config.floatX](lr.get_value()/1.0001)) # print "lr:", lr.get_value() i += 1 del stats cmd = "python evaluate_face_new_data_unl.py " + str(faceset) + " " +\ str(fold_exp) + " mlp" # with open("./" + str(time_exp) + ".py", "w") as python_file: # python_file.write("import os \n") # cmd2 = 'os.system("' + cmd + '")' # python_file.write(cmd2) os.system(cmd) # # std_data = standardize(x_data) # std_data = np.asarray(x_data, dtype=theano.config.floatX) # # dae_l0.fit(learning_rate=9.96*1e-3, # shuffle_data=True, # data=std_data, # weights_file=weights_file_l0, # recons_img_file=None, # corruption_level=0.095, # batch_size=40, # n_epochs=2) # # dae_l0_obj_out = open("dae_l0_obj.pkl", "wb") # pkl.dump(dae_l0, dae_l0_obj_out, protocol=pkl.HIGHEST_PROTOCOL) # # dae_l0_out = dae_l0.encode((input)) # dae_l0_h = dae_l0.encode(std_data) # dae_l0_h_fn = theano.function([], dae_l0_h) # dae_l1_in = dae_l0_h_fn() # dae_l1_in = np.asarray(dae_l1_in, dtype=theano.config.floatX) # # dae_l1 = DenoisingAutoencoder(dae_l0_out, # L1_reg=1e-4, # L2_reg=6*1e-4, # nvis=nhid_l0, # nhid=nhid_l1, # rnd=rnd, # reverse=True) # # dae_l1.fit(learning_rate=0.95*1e-2, # data=dae_l1_in, # shuffle_data=True, # recons_img_file=None, # weights_file=weights_file_l1, # corruption_level=0.1, # batch_size=25, # n_epochs=2) # 1400 # # dae_l1_obj_out = open("dae_l1_obj.pkl", "wb") # pkl.dump(dae_l1, dae_l1_obj_out, protocol=pkl.HIGHEST_PROTOCOL)
lgpl-3.0
[ 504, 308, 411, 63, 6427, 14, 983, 492, 25187, 79, 11136, 3358, 9347, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 10172, 3049, 7945, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 24681, 804, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5822, 1698, 48, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3560, 63, 368, 63, 7367, 63, 335, 324, 5618, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 14377, 63, 31492, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5709, 56, 63, 585, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 8775, 63, 3200, 63, 7367, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5137, 63, 3200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3715, 63, 576, 63, 475, 63, 827, 21454, 83, 63, 2579, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3715, 63, 576, 63, 475, 63, 827, 21454, 83, 63, 6427, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 9352, 63, 1238, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 2493, 685, 65, 1146, 16359, 6621, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 21079, 872, 9972, 16359, 6621, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 21079, 872, 9972, 16359, 6621, 7200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 2493, 685, 65, 1146, 16359, 6621, 7200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 870, 63, 3200, 63, 2834, 199, 504, 308, 411, 63, 6427, 14, 10546, 63, 2200, 492, 437, 983, 13411, 199, 504, 308, 411, 63, 6427, 14, 10546, 63, 2200, 492, 3930, 434, 453, 199, 199, 646, 14377, 14, 3128, 465, 377, 199, 646, 14377, 199, 646, 2680, 465, 980, 199, 646, 17572, 465, 3803, 76, 199, 646, 2197, 465, 19852, 199, 646, 747, 199, 646, 6485, 199, 646, 984, 199, 646, 5145, 199, 504, 2196, 492, 13031, 199, 199, 3, 22986, 846, 26, 1749, 9669, 199, 3, 812, 2916, 975, 26, 16074, 1299, 421, 199, 318, 28974, 806, 8, 576, 304, 272, 408, 272, 21017, 314, 666, 543, 14021, 370, 17196, 314, 4615, 436, 314, 4465, 272, 18458, 402, 652, 436, 487, 11604, 701, 4615, 436, 4465, 18458, 14, 272, 408, 272, 8504, 275, 980, 14, 3670, 8, 576, 12, 3114, 29, 16, 9, 272, 10819, 275, 980, 14, 1516, 8, 576, 12, 3114, 29, 16, 9, 272, 340, 10819, 14, 10262, 3430, 16, 1055, 1392, 59, 16, 61, 508, 378, 26, 267, 746, 2186, 480, 11976, 4866, 1077, 440, 506, 4697, 531, 339, 6316, 63, 576, 275, 334, 576, 446, 8504, 9, 1182, 10819, 272, 372, 6316, 63, 576, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 730, 63, 1494, 275, 3087, 272, 340, 730, 63, 1494, 365, 298, 24421, 846, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 340, 730, 63, 1494, 365, 298, 27948, 63, 975, 582, 267, 8134, 63, 262, 275, 16074, 1299, 272, 340, 730, 63, 1494, 365, 298, 27948, 63, 1167, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 340, 730, 63, 1494, 365, 298, 28069, 552, 386, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 8870, 409, 275, 298, 276, 8796, 2, 272, 6111, 63, 576, 275, 298, 9707, 262, 548, 15, 576, 15, 1409, 6687, 435, 8870, 409, 435, 2668, 85, 63, 426, 552, 6687, 272, 931, 63, 1078, 275, 6111, 63, 576, 435, 730, 63, 1494, 435, 298, 1078, 14, 23947, 2, 272, 336, 12, 394, 275, 5238, 12, 5238, 272, 340, 730, 63, 1494, 365, 440, 488, 436, 730, 63, 1494, 365, 440, 10812, 267, 336, 12, 394, 275, 8134, 63, 262, 12, 413, 272, 1324, 275, 377, 14, 70, 3642, 480, 88, 63, 1210, 531, 272, 1072, 275, 377, 14, 70, 3642, 480, 89, 63, 1199, 531, 339, 327, 2790, 13492, 666, 272, 31646, 63, 1961, 12, 31646, 63, 2154, 12, 31646, 63, 7566, 275, 1227, 2114, 12, 499, 14137, 12, 499, 14137, 272, 1305, 63, 576, 275, 730, 63, 1494, 435, 298, 335, 63, 454, 12172, 435, 620, 8, 23299, 63, 1961, 9, 435, 14135, 435, 620, 8, 23299, 63, 2154, 9, 435, 14135, 17992, 267, 620, 8, 23299, 63, 7566, 9, 272, 327, 3820, 3560, 682, 324, 5618, 272, 634, 63, 335, 63, 454, 275, 359, 2592, 63, 576, 435, 298, 2834, 14, 23947, 937, 339, 900, 63, 1474, 275, 19852, 14, 2083, 14, 2131, 1252, 6205, 3508, 77, 4970, 68, 4970, 57, 4970, 40, 4970, 45, 4970, 83, 358, 272, 20675, 63, 1474, 275, 298, 9707, 476, 1190, 6687, 435, 8870, 409, 435, 14220, 435, 900, 63, 1474, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 14011, 63, 1474, 304, 267, 747, 14, 8347, 8, 14011, 63, 1474, 9, 272, 31646, 63, 4359, 275, 841, 272, 4205, 63, 87, 63, 515, 275, 298, 9707, 262, 548, 15, 826, 63, 4916, 6687, 435, 620, 8, 23299, 63, 4359, 9, 435, 14135, 17992, 267, 8870, 409, 435, 2513, 4359, 4805, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 826, 63, 87, 63, 515, 304, 267, 747, 14, 8347, 8, 826, 63, 87, 63, 515, 9, 339, 20665, 275, 980, 14, 2355, 14, 15726, 8, 713, 2192, 9, 272, 302, 18209, 63, 76, 16, 275, 1616, 821, 272, 302, 18209, 63, 76, 17, 275, 10574, 272, 302, 18209, 63, 76, 18, 275, 5049, 339, 327, 2790, 314, 24475, 315, 413, 272, 302, 5068, 12, 302, 18209, 275, 336, 10, 72, 12, 302, 18209, 63, 76, 16, 272, 931, 63, 2730, 63, 1162, 63, 76, 16, 275, 4205, 63, 87, 63, 515, 435, 298, 9747, 63, 87, 63, 76, 16, 63, 826, 12172, 435, 620, 8, 78, 5068, 9, 435, 14135, 17992, 267, 620, 8, 78, 18209, 9, 435, 3680, 23947, 2, 272, 366, 3624, 63, 76, 16, 275, 25187, 79, 11136, 3358, 9347, 8, 1210, 12, 3303, 302, 5068, 29, 78, 5068, 12, 3303, 302, 18209, 29, 78, 18209, 12, 3303, 491, 17, 63, 1135, 29, 16, 2020, 3303, 491, 18, 63, 1135, 29, 17, 69, 13, 18, 12, 3303, 20665, 29, 30006, 12, 3303, 2222, 30440, 29, 6932, 3049, 7945, 14, 7864 ]
[ 308, 411, 63, 6427, 14, 983, 492, 25187, 79, 11136, 3358, 9347, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 10172, 3049, 7945, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 24681, 804, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5822, 1698, 48, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3560, 63, 368, 63, 7367, 63, 335, 324, 5618, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 14377, 63, 31492, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5709, 56, 63, 585, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 8775, 63, 3200, 63, 7367, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 5137, 63, 3200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3715, 63, 576, 63, 475, 63, 827, 21454, 83, 63, 2579, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 3715, 63, 576, 63, 475, 63, 827, 21454, 83, 63, 6427, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 9352, 63, 1238, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 2493, 685, 65, 1146, 16359, 6621, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 21079, 872, 9972, 16359, 6621, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 21079, 872, 9972, 16359, 6621, 7200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 13599, 2493, 685, 65, 1146, 16359, 6621, 7200, 199, 504, 308, 411, 63, 6427, 14, 2537, 492, 870, 63, 3200, 63, 2834, 199, 504, 308, 411, 63, 6427, 14, 10546, 63, 2200, 492, 437, 983, 13411, 199, 504, 308, 411, 63, 6427, 14, 10546, 63, 2200, 492, 3930, 434, 453, 199, 199, 646, 14377, 14, 3128, 465, 377, 199, 646, 14377, 199, 646, 2680, 465, 980, 199, 646, 17572, 465, 3803, 76, 199, 646, 2197, 465, 19852, 199, 646, 747, 199, 646, 6485, 199, 646, 984, 199, 646, 5145, 199, 504, 2196, 492, 13031, 199, 199, 3, 22986, 846, 26, 1749, 9669, 199, 3, 812, 2916, 975, 26, 16074, 1299, 421, 199, 318, 28974, 806, 8, 576, 304, 272, 408, 272, 21017, 314, 666, 543, 14021, 370, 17196, 314, 4615, 436, 314, 4465, 272, 18458, 402, 652, 436, 487, 11604, 701, 4615, 436, 4465, 18458, 14, 272, 408, 272, 8504, 275, 980, 14, 3670, 8, 576, 12, 3114, 29, 16, 9, 272, 10819, 275, 980, 14, 1516, 8, 576, 12, 3114, 29, 16, 9, 272, 340, 10819, 14, 10262, 3430, 16, 1055, 1392, 59, 16, 61, 508, 378, 26, 267, 746, 2186, 480, 11976, 4866, 1077, 440, 506, 4697, 531, 339, 6316, 63, 576, 275, 334, 576, 446, 8504, 9, 1182, 10819, 272, 372, 6316, 63, 576, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 730, 63, 1494, 275, 3087, 272, 340, 730, 63, 1494, 365, 298, 24421, 846, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 340, 730, 63, 1494, 365, 298, 27948, 63, 975, 582, 267, 8134, 63, 262, 275, 16074, 1299, 272, 340, 730, 63, 1494, 365, 298, 27948, 63, 1167, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 340, 730, 63, 1494, 365, 298, 28069, 552, 386, 582, 267, 8134, 63, 262, 275, 1749, 9669, 272, 8870, 409, 275, 298, 276, 8796, 2, 272, 6111, 63, 576, 275, 298, 9707, 262, 548, 15, 576, 15, 1409, 6687, 435, 8870, 409, 435, 2668, 85, 63, 426, 552, 6687, 272, 931, 63, 1078, 275, 6111, 63, 576, 435, 730, 63, 1494, 435, 298, 1078, 14, 23947, 2, 272, 336, 12, 394, 275, 5238, 12, 5238, 272, 340, 730, 63, 1494, 365, 440, 488, 436, 730, 63, 1494, 365, 440, 10812, 267, 336, 12, 394, 275, 8134, 63, 262, 12, 413, 272, 1324, 275, 377, 14, 70, 3642, 480, 88, 63, 1210, 531, 272, 1072, 275, 377, 14, 70, 3642, 480, 89, 63, 1199, 531, 339, 327, 2790, 13492, 666, 272, 31646, 63, 1961, 12, 31646, 63, 2154, 12, 31646, 63, 7566, 275, 1227, 2114, 12, 499, 14137, 12, 499, 14137, 272, 1305, 63, 576, 275, 730, 63, 1494, 435, 298, 335, 63, 454, 12172, 435, 620, 8, 23299, 63, 1961, 9, 435, 14135, 435, 620, 8, 23299, 63, 2154, 9, 435, 14135, 17992, 267, 620, 8, 23299, 63, 7566, 9, 272, 327, 3820, 3560, 682, 324, 5618, 272, 634, 63, 335, 63, 454, 275, 359, 2592, 63, 576, 435, 298, 2834, 14, 23947, 937, 339, 900, 63, 1474, 275, 19852, 14, 2083, 14, 2131, 1252, 6205, 3508, 77, 4970, 68, 4970, 57, 4970, 40, 4970, 45, 4970, 83, 358, 272, 20675, 63, 1474, 275, 298, 9707, 476, 1190, 6687, 435, 8870, 409, 435, 14220, 435, 900, 63, 1474, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 14011, 63, 1474, 304, 267, 747, 14, 8347, 8, 14011, 63, 1474, 9, 272, 31646, 63, 4359, 275, 841, 272, 4205, 63, 87, 63, 515, 275, 298, 9707, 262, 548, 15, 826, 63, 4916, 6687, 435, 620, 8, 23299, 63, 4359, 9, 435, 14135, 17992, 267, 8870, 409, 435, 2513, 4359, 4805, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 826, 63, 87, 63, 515, 304, 267, 747, 14, 8347, 8, 826, 63, 87, 63, 515, 9, 339, 20665, 275, 980, 14, 2355, 14, 15726, 8, 713, 2192, 9, 272, 302, 18209, 63, 76, 16, 275, 1616, 821, 272, 302, 18209, 63, 76, 17, 275, 10574, 272, 302, 18209, 63, 76, 18, 275, 5049, 339, 327, 2790, 314, 24475, 315, 413, 272, 302, 5068, 12, 302, 18209, 275, 336, 10, 72, 12, 302, 18209, 63, 76, 16, 272, 931, 63, 2730, 63, 1162, 63, 76, 16, 275, 4205, 63, 87, 63, 515, 435, 298, 9747, 63, 87, 63, 76, 16, 63, 826, 12172, 435, 620, 8, 78, 5068, 9, 435, 14135, 17992, 267, 620, 8, 78, 18209, 9, 435, 3680, 23947, 2, 272, 366, 3624, 63, 76, 16, 275, 25187, 79, 11136, 3358, 9347, 8, 1210, 12, 3303, 302, 5068, 29, 78, 5068, 12, 3303, 302, 18209, 29, 78, 18209, 12, 3303, 491, 17, 63, 1135, 29, 16, 2020, 3303, 491, 18, 63, 1135, 29, 17, 69, 13, 18, 12, 3303, 20665, 29, 30006, 12, 3303, 2222, 30440, 29, 6932, 3049, 7945, 14, 7864, 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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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 ]
XiaodunServerGroup/ddyedx
common/djangoapps/course_modes/migrations/0005_auto__add_field_coursemode_expiration_datetime.py
59
1858
# -*- 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 'CourseMode.expiration_datetime' db.add_column('course_modes_coursemode', 'expiration_datetime', self.gf('django.db.models.fields.DateTimeField')(default=None, null=True, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'CourseMode.expiration_datetime' db.delete_column('course_modes_coursemode', 'expiration_datetime') models = { 'course_modes.coursemode': { 'Meta': {'unique_together': "(('course_id', 'mode_slug', 'currency'),)", 'object_name': 'CourseMode'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'currency': ('django.db.models.fields.CharField', [], {'default': "'usd'", 'max_length': '8'}), 'expiration_date': ('django.db.models.fields.DateField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'expiration_datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'min_price': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'mode_display_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'mode_slug': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'suggested_prices': ('django.db.models.fields.CommaSeparatedIntegerField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}) } } complete_apps = ['course_modes']
agpl-3.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, 6979, 1385, 14, 15469, 63, 2083, 7, 267, 1592, 14, 525, 63, 2301, 360, 1972, 63, 10433, 63, 1972, 632, 297, 283, 15469, 63, 2083, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 885, 29, 403, 12, 2973, 29, 549, 12, 4596, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 6979, 1385, 14, 15469, 63, 2083, 7, 267, 1592, 14, 1807, 63, 2301, 360, 1972, 63, 10433, 63, 1972, 632, 297, 283, 15469, 63, 2083, 358, 2378, 1709, 275, 469, 267, 283, 1972, 63, 10433, 14, 1972, 632, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 1972, 63, 344, 297, 283, 632, 63, 5464, 297, 283, 4968, 9878, 283, 785, 63, 354, 356, 283, 6979, 1385, 2267, 288, 283, 1972, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 4968, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 31597, 4662, 283, 988, 63, 1267, 356, 283, 24, 1604, 288, 283, 15469, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 885, 356, 283, 403, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 15469, 63, 2083, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 403, 297, 283, 2307, 356, 283, 549, 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, 827, 63, 4777, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 632, 63, 2918, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 632, 63, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 29833, 63, 32434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 25732, 20727, 3901, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 1972, 63, 10433, 418, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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, 6979, 1385, 14, 15469, 63, 2083, 7, 267, 1592, 14, 525, 63, 2301, 360, 1972, 63, 10433, 63, 1972, 632, 297, 283, 15469, 63, 2083, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 885, 29, 403, 12, 2973, 29, 549, 12, 4596, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 6979, 1385, 14, 15469, 63, 2083, 7, 267, 1592, 14, 1807, 63, 2301, 360, 1972, 63, 10433, 63, 1972, 632, 297, 283, 15469, 63, 2083, 358, 2378, 1709, 275, 469, 267, 283, 1972, 63, 10433, 14, 1972, 632, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 1972, 63, 344, 297, 283, 632, 63, 5464, 297, 283, 4968, 9878, 283, 785, 63, 354, 356, 283, 6979, 1385, 2267, 288, 283, 1972, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 4968, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 31597, 4662, 283, 988, 63, 1267, 356, 283, 24, 1604, 288, 283, 15469, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 885, 356, 283, 403, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 15469, 63, 2083, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 403, 297, 283, 2307, 356, 283, 549, 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, 827, 63, 4777, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 632, 63, 2918, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 1604, 288, 283, 632, 63, 5464, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 29833, 63, 32434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 25732, 20727, 3901, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 1972, 63, 10433, 418, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
tensorflow/tensorflow
tensorflow/python/distribute/values_util.py
11
14810
# Copyright 2020 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. # ============================================================================== """Utility functions used by values.py and ps_values.py.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.distribute import distribute_lib from tensorflow.python.distribute import distribution_strategy_context as ds_context from tensorflow.python.distribute import reduce_util from tensorflow.python.eager import context from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs from tensorflow.python.saved_model import save_context from tensorflow.python.saved_model import save_options from tensorflow.python.training.saving import saveable_object def write_object_proto(var, proto, options): """Update a SavedObject proto for the caller. If a DistributedVariable object supports this method, it will be called when saving with a pre-built `SavedObject` proto representing the object, plus an instance of `SaveOptions`. This method is then free to modify that proto instance. `DistributedVariable` with `AUTO` or `ON_WRITE` synchronization optionally write out information about their components to the `experimental_distributed_variable_components` field of a `SavedVariable` (depending on the `SaveOptions` variable policy). Args: var: The DistributedVariable object. proto: A pre-built `SavedObject` proto for this object. It is assumed this will be a `SavedVariable` instance. options: A `SaveOptions` instance. """ if options.experimental_variable_policy._expand_distributed_variables( # pylint: disable=protected-access ): for var in var.values: var_proto = ( proto.variable.experimental_distributed_variable_components.add()) var_proto.name = var.name.split(":")[0] var_proto.device = var.device def get_on_write_saveable(var, primary_var, name): """Return saveable spec for AUTO and ON_WRITE variables.""" # We use a callable so that we don't have to evaluate this expression # in the case where we are trying to restore instead of save. def tensor(): if context.executing_eagerly() and not primary_var.is_initialized(): # A SaveSpec tensor value of `None` indicates that the variable is # uninitialized. return None strategy = var.distribute_strategy return strategy.extended.read_var(var) spec = saveable_object.SaveSpec( tensor=tensor, slice_spec="", name=name, dtype=var.dtype, device=primary_var.device) return tensor, [spec] def get_on_write_restore_ops(var, tensor): """Return restore ops for AUTO and ON_WRITE variables.""" packed_var = var._packed_variable # pylint: disable=protected-access if packed_var is not None: return control_flow_ops.group( tuple( assign_on_device(d, packed_var, tensor) for d in packed_var.devices)) return control_flow_ops.group( tuple( assign_on_device(v.device, v, tensor) for v in var.values)) def get_on_read_saveable(var, primary_var, name): """Return saveables for ON_READ variable.""" # We use a callable so that we don't have to evaluate this expression # in the case where we are trying to restore instead of save. def tensor(): return var._get_cross_replica() # pylint: disable=protected-access spec = saveable_object.SaveSpec( tensor=tensor, slice_spec="", name=name, dtype=var.dtype, device=primary_var.device) return tensor, [spec] def get_on_read_restore_ops(var, tensor, aggregation): """Return restore ops for ON_READ variables.""" # To preserve the sum across save and restore, we have to divide the # total across all devices when restoring a variable that was summed # when saving. if aggregation == vs.VariableAggregation.SUM: strategy = var.distribute_strategy tensor = math_ops.cast(tensor / strategy.num_replicas_in_sync, var.dtype) return control_flow_ops.group( tuple( assign_on_device(v.device, v, tensor) for v in var.values)) # Utility function that indicates if you are in an UpdateContext when running # in a replica fn. def in_replica_update_context(): return distribute_lib.get_update_replica_id() is not None def on_write_assign(var, value, use_locking=False, name=None, read_value=True): assign_fn = lambda var, *a, **kw: var.assign(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=assign_fn, value=value, use_locking=use_locking, name=name, read_value=read_value) def on_write_assign_add(var, value, use_locking=False, name=None, read_value=True): assign_add_fn = lambda var, *a, **kw: var.assign_add(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=assign_add_fn, value=value, use_locking=use_locking, name=name, read_value=read_value) def on_write_assign_sub(var, value, use_locking=False, name=None, read_value=True): assign_sub_fn = lambda var, *a, **kw: var.assign_sub(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=assign_sub_fn, value=value, use_locking=use_locking, name=name, read_value=read_value) def assign_on_each_device(var, assign_func, value, read_value): """Update the variable on each replica with the given assign_func and value.""" if var._packed_variable is not None: # pylint: disable=protected-access update = control_flow_ops.group( tuple( assign_func(d, var._packed_variable, value) for d in var._devices)) # pylint: disable=protected-access else: update = control_flow_ops.group( tuple(assign_func(v.device, v, value) for v in var._values)) # pylint: disable=protected-access if not read_value: return update with ops.control_dependencies([update] if update else []): return var.read_value() def on_read_assign_sub_cross_replica(var, value, read_value=True): with ds_context.enter_or_assert_strategy(var.distribute_strategy): if ds_context.in_cross_replica_context(): if var.aggregation == vs.VariableAggregation.SUM: raise ValueError( "SyncOnReadVariable does not support `assign_sub` in " "cross-replica context when aggregation is set to " "`tf.VariableAggregation.SUM`.") return assign_on_each_device(var, assign_sub_on_device, value, read_value) def on_read_assign_add_cross_replica(var, value, read_value=True): with ds_context.enter_or_assert_strategy(var.distribute_strategy): if ds_context.in_cross_replica_context(): if var.aggregation == vs.VariableAggregation.SUM: raise ValueError( "SyncOnReadVariable does not support `assign_add` in " "cross-replica context when aggregation is set to " "`tf.VariableAggregation.SUM`.") return assign_on_each_device(var, assign_add_on_device, value, read_value) def on_read_assign_cross_replica(var, value, read_value=True): """Return the value of the variable in cross replica context.""" with ds_context.enter_or_assert_strategy(var.distribute_strategy): if ds_context.in_cross_replica_context(): # To preserve the sum across save and restore, we have to divide the # total across all devices when restoring a variable that was summed # when saving. tensor = value if var.aggregation == vs.VariableAggregation.SUM: strategy = var._distribute_strategy # pylint: disable=protected-access tensor = math_ops.cast(tensor / strategy.num_replicas_in_sync, var.dtype) return assign_on_each_device(var, assign_on_device, tensor, read_value) def scatter_sub(var, sparse_delta, use_locking=False, name=None): scatter_sub_fn = lambda var, *a, **kw: var.scatter_sub(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_sub_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_add(var, sparse_delta, use_locking=False, name=None): scatter_add_fn = lambda var, *a, **kw: var.scatter_add(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_add_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_mul(var, sparse_delta, use_locking=False, name=None): scatter_mul_fn = lambda var, *a, **kw: var.scatter_mul(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_mul_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_div(var, sparse_delta, use_locking=False, name=None): scatter_div_fn = lambda var, *a, **kw: var.scatter_div(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_div_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_min(var, sparse_delta, use_locking=False, name=None): scatter_min_fn = lambda var, *a, **kw: var.scatter_min(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_min_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_max(var, sparse_delta, use_locking=False, name=None): scatter_max_fn = lambda var, *a, **kw: var.scatter_max(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_max_fn, value=sparse_delta, use_locking=use_locking, name=name) def scatter_update(var, sparse_delta, use_locking=False, name=None): scatter_update_fn = lambda var, *a, **kw: var.scatter_update(*a, **kw) return var._update( # pylint: disable=protected-access update_fn=scatter_update_fn, value=sparse_delta, use_locking=use_locking, name=name) def get_current_replica_id_as_int(): """Returns the current replica ID as an integer, or `None`.""" replica_context = ds_context.get_replica_context() if replica_context: replica_id = replica_context._replica_id # pylint: disable=protected-access if not isinstance(replica_id, int): replica_id = tensor_util.constant_value(replica_id) else: replica_id = distribute_lib.get_update_replica_id() return replica_id def assign_on_device(device, variable, tensor): with ops.device(device): return variable.assign(tensor) def assign_add_on_device(device, variable, tensor): with ops.device(device): return variable.assign_add(tensor) def assign_sub_on_device(device, variable, tensor): with ops.device(device): return variable.assign_sub(tensor) def assert_replica_context(strategy): replica_context = ds_context.get_replica_context() if not replica_context: raise RuntimeError( "Replica-local variables may only be assigned in a replica context.") if replica_context.strategy is not strategy: raise RuntimeError( "Replica-local variables may only be assigned in a replica context.") def apply_aggregation(strategy, value, aggregation, destinations): if aggregation == vs.VariableAggregation.ONLY_FIRST_REPLICA: return strategy.extended.broadcast_to( strategy.experimental_local_results(value)[0], destinations=destinations) reduce_op = reduce_util.ReduceOp.from_variable_aggregation(aggregation) return strategy.extended.reduce_to(reduce_op, value, destinations) aggregation_error_msg = ( "You must specify an aggregation method to update a " "{variable_type} in Replica Context. You can do so by passing " "an explicit value for argument `aggregation` to tf.Variable(..)." "e.g. `tf.Variable(..., aggregation=tf.VariableAggregation.SUM)`" "`tf.VariableAggregation` lists the possible aggregation methods." "This is required because {variable_type} should always be " "kept in sync. When updating them or assigning to them in a " "replica context, we automatically try to aggregate the values " "before updating the variable. For this aggregation, we need to " "know the aggregation method. " "Another alternative is to not try to update such " "{variable_type} in replica context, but in cross replica " "context. You can enter cross replica context by calling " "`tf.distribute.get_replica_context().merge_call(merge_fn, ..)`." "Inside `merge_fn`, you can then update the {variable_type} " "using `tf.distribute.StrategyExtended.update()`.") scatter_error_msg = ("{op_name} is only supported for mirrored " "variable (variable created within certain " "`tf.distribute.Strategy` scope) with NONE or " "`ONLY_FIRST_REPLICA` aggregation, got: {aggregation}.") def is_saving_non_distributed(): """Returns whether we're saving a non-distributed version of the model. It returns True iff we are in saving context and are saving a non-distributed version of the model. That is, SaveOptions.experimental_variable_policy is NONE. Returns: A boolean. """ if not save_context.in_save_context(): return False options = save_context.get_save_options() return (options.experimental_variable_policy != save_options.VariablePolicy.EXPAND_DISTRIBUTED_VARIABLES) def mark_as_unsaveable(): """Marks the function as unsaveable if not inside save context.""" if ops.inside_function() and not save_context.in_save_context(): ops.get_default_graph().mark_as_unsaveable(""" ConcreteFunction that uses distributed variables in certain way cannot be saved. If you're saving with tf.saved_model.save(..., signatures=f.get_concrete_function()) do @tf.function(input_signature=...) def f_with_input_signature(): ... tf.saved_model.save(..., signatures=f_with_input_signature)` instead.""")
apache-2.0
[ 3, 1898, 25455, 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, 17505, 3423, 1202, 701, 1338, 14, 647, 436, 7347, 63, 1459, 14, 647, 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, 504, 3228, 14, 1548, 14, 3470, 492, 11207, 63, 773, 199, 504, 3228, 14, 1548, 14, 3470, 492, 4084, 63, 8590, 63, 1100, 465, 6364, 63, 1100, 199, 504, 3228, 14, 1548, 14, 3470, 492, 7114, 63, 1974, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 465, 8118, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 3354, 63, 1100, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 3354, 63, 1419, 199, 504, 3228, 14, 1548, 14, 7588, 14, 30172, 492, 3354, 461, 63, 785, 421, 199, 318, 2218, 63, 785, 63, 2625, 8, 1391, 12, 4104, 12, 1511, 304, 523, 408, 4152, 282, 29026, 1692, 4104, 367, 314, 8025, 14, 819, 982, 282, 17484, 2773, 909, 5171, 642, 1083, 12, 652, 911, 506, 2797, 1380, 523, 13369, 543, 282, 876, 13, 11730, 658, 21969, 1692, 64, 4104, 6144, 314, 909, 12, 12254, 376, 523, 1256, 402, 658, 8229, 4558, 2313, 961, 1083, 365, 2066, 2867, 370, 2811, 626, 4104, 523, 1256, 14, 819, 658, 27398, 2773, 64, 543, 658, 13883, 64, 503, 658, 615, 63, 10387, 64, 29509, 14190, 2043, 2218, 734, 2556, 3595, 3932, 7323, 370, 314, 2043, 658, 18924, 63, 16832, 63, 1975, 63, 4608, 64, 901, 402, 282, 2043, 658, 21969, 2773, 64, 334, 2601, 3219, 641, 314, 658, 8229, 4558, 64, 1750, 4592, 680, 819, 3033, 26, 272, 2729, 26, 710, 17484, 2773, 909, 14, 272, 4104, 26, 437, 876, 13, 11730, 658, 21969, 1692, 64, 4104, 367, 642, 909, 14, 2779, 365, 10826, 642, 489, 911, 506, 282, 658, 21969, 2773, 64, 1256, 14, 272, 1511, 26, 437, 658, 8229, 4558, 64, 1256, 14, 523, 408, 523, 340, 1511, 14, 18924, 63, 1975, 63, 3185, 423, 4441, 63, 16832, 63, 3669, 8, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 523, 3461, 272, 367, 2729, 315, 2729, 14, 1459, 26, 489, 2729, 63, 2625, 275, 334, 881, 4104, 14, 1975, 14, 18924, 63, 16832, 63, 1975, 63, 4608, 14, 525, 1012, 489, 2729, 63, 2625, 14, 354, 275, 2729, 14, 354, 14, 1294, 20063, 59, 16, 61, 489, 2729, 63, 2625, 14, 1782, 275, 2729, 14, 1782, 421, 199, 318, 664, 63, 265, 63, 952, 63, 2117, 461, 8, 1391, 12, 5062, 63, 1391, 12, 536, 304, 523, 408, 1767, 3354, 461, 3158, 367, 25420, 436, 5258, 63, 10387, 2860, 1041, 523, 327, 2136, 675, 282, 4550, 880, 626, 781, 2793, 1133, 1172, 370, 9352, 642, 3965, 523, 327, 315, 314, 1930, 2382, 781, 787, 9936, 370, 9066, 3140, 402, 3354, 14, 523, 347, 2345, 837, 272, 340, 1067, 14, 23722, 63, 24377, 342, 436, 440, 5062, 63, 1391, 14, 374, 63, 12486, 837, 489, 327, 437, 11063, 5307, 2345, 574, 402, 658, 403, 64, 9126, 626, 314, 1750, 365, 489, 327, 625, 12486, 14, 489, 372, 488, 272, 10054, 275, 2729, 14, 3470, 63, 8590, 272, 372, 10054, 14, 10525, 14, 739, 63, 1391, 8, 1391, 9, 819, 3158, 275, 3354, 461, 63, 785, 14, 8229, 5307, 8, 489, 2345, 29, 3128, 12, 489, 6014, 63, 1650, 8772, 489, 536, 29, 354, 12, 489, 2152, 29, 1391, 14, 2271, 12, 489, 2243, 29, 3327, 63, 1391, 14, 1782, 9, 819, 372, 2345, 12, 359, 1650, 61, 421, 199, 318, 664, 63, 265, 63, 952, 63, 8011, 63, 1483, 8, 1391, 12, 2345, 304, 523, 408, 1767, 9066, 4156, 367, 25420, 436, 5258, 63, 10387, 2860, 1041, 523, 13170, 63, 1391, 275, 2729, 423, 12286, 63, 1975, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 523, 340, 13170, 63, 1391, 365, 440, 488, 26, 272, 372, 3304, 63, 1659, 63, 1483, 14, 923, 8, 267, 2008, 8, 288, 5090, 63, 265, 63, 1782, 8, 68, 12, 13170, 63, 1391, 12, 2345, 9, 288, 367, 366, 315, 13170, 63, 1391, 14, 6410, 430, 523, 372, 3304, 63, 1659, 63, 1483, 14, 923, 8, 489, 2008, 8, 881, 5090, 63, 265, 63, 1782, 8, 86, 14, 1782, 12, 373, 12, 2345, 9, 881, 367, 373, 315, 2729, 14, 1459, 430, 421, 199, 318, 664, 63, 265, 63, 739, 63, 2117, 461, 8, 1391, 12, 5062, 63, 1391, 12, 536, 304, 523, 408, 1767, 3354, 5921, 367, 5258, 63, 5670, 1750, 1041, 819, 327, 2136, 675, 282, 4550, 880, 626, 781, 2793, 1133, 1172, 370, 9352, 642, 3965, 523, 327, 315, 314, 1930, 2382, 781, 787, 9936, 370, 9066, 3140, 402, 3354, 14, 523, 347, 2345, 837, 272, 372, 2729, 423, 362, 63, 7925, 63, 12317, 342, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 819, 3158, 275, 3354, 461, 63, 785, 14, 8229, 5307, 8, 489, 2345, 29, 3128, 12, 489, 6014, 63, 1650, 8772, 489, 536, 29, 354 ]
[ 1898, 25455, 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, 17505, 3423, 1202, 701, 1338, 14, 647, 436, 7347, 63, 1459, 14, 647, 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, 504, 3228, 14, 1548, 14, 3470, 492, 11207, 63, 773, 199, 504, 3228, 14, 1548, 14, 3470, 492, 4084, 63, 8590, 63, 1100, 465, 6364, 63, 1100, 199, 504, 3228, 14, 1548, 14, 3470, 492, 7114, 63, 1974, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2345, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 465, 8118, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 3354, 63, 1100, 199, 504, 3228, 14, 1548, 14, 8420, 63, 1238, 492, 3354, 63, 1419, 199, 504, 3228, 14, 1548, 14, 7588, 14, 30172, 492, 3354, 461, 63, 785, 421, 199, 318, 2218, 63, 785, 63, 2625, 8, 1391, 12, 4104, 12, 1511, 304, 523, 408, 4152, 282, 29026, 1692, 4104, 367, 314, 8025, 14, 819, 982, 282, 17484, 2773, 909, 5171, 642, 1083, 12, 652, 911, 506, 2797, 1380, 523, 13369, 543, 282, 876, 13, 11730, 658, 21969, 1692, 64, 4104, 6144, 314, 909, 12, 12254, 376, 523, 1256, 402, 658, 8229, 4558, 2313, 961, 1083, 365, 2066, 2867, 370, 2811, 626, 4104, 523, 1256, 14, 819, 658, 27398, 2773, 64, 543, 658, 13883, 64, 503, 658, 615, 63, 10387, 64, 29509, 14190, 2043, 2218, 734, 2556, 3595, 3932, 7323, 370, 314, 2043, 658, 18924, 63, 16832, 63, 1975, 63, 4608, 64, 901, 402, 282, 2043, 658, 21969, 2773, 64, 334, 2601, 3219, 641, 314, 658, 8229, 4558, 64, 1750, 4592, 680, 819, 3033, 26, 272, 2729, 26, 710, 17484, 2773, 909, 14, 272, 4104, 26, 437, 876, 13, 11730, 658, 21969, 1692, 64, 4104, 367, 642, 909, 14, 2779, 365, 10826, 642, 489, 911, 506, 282, 658, 21969, 2773, 64, 1256, 14, 272, 1511, 26, 437, 658, 8229, 4558, 64, 1256, 14, 523, 408, 523, 340, 1511, 14, 18924, 63, 1975, 63, 3185, 423, 4441, 63, 16832, 63, 3669, 8, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 523, 3461, 272, 367, 2729, 315, 2729, 14, 1459, 26, 489, 2729, 63, 2625, 275, 334, 881, 4104, 14, 1975, 14, 18924, 63, 16832, 63, 1975, 63, 4608, 14, 525, 1012, 489, 2729, 63, 2625, 14, 354, 275, 2729, 14, 354, 14, 1294, 20063, 59, 16, 61, 489, 2729, 63, 2625, 14, 1782, 275, 2729, 14, 1782, 421, 199, 318, 664, 63, 265, 63, 952, 63, 2117, 461, 8, 1391, 12, 5062, 63, 1391, 12, 536, 304, 523, 408, 1767, 3354, 461, 3158, 367, 25420, 436, 5258, 63, 10387, 2860, 1041, 523, 327, 2136, 675, 282, 4550, 880, 626, 781, 2793, 1133, 1172, 370, 9352, 642, 3965, 523, 327, 315, 314, 1930, 2382, 781, 787, 9936, 370, 9066, 3140, 402, 3354, 14, 523, 347, 2345, 837, 272, 340, 1067, 14, 23722, 63, 24377, 342, 436, 440, 5062, 63, 1391, 14, 374, 63, 12486, 837, 489, 327, 437, 11063, 5307, 2345, 574, 402, 658, 403, 64, 9126, 626, 314, 1750, 365, 489, 327, 625, 12486, 14, 489, 372, 488, 272, 10054, 275, 2729, 14, 3470, 63, 8590, 272, 372, 10054, 14, 10525, 14, 739, 63, 1391, 8, 1391, 9, 819, 3158, 275, 3354, 461, 63, 785, 14, 8229, 5307, 8, 489, 2345, 29, 3128, 12, 489, 6014, 63, 1650, 8772, 489, 536, 29, 354, 12, 489, 2152, 29, 1391, 14, 2271, 12, 489, 2243, 29, 3327, 63, 1391, 14, 1782, 9, 819, 372, 2345, 12, 359, 1650, 61, 421, 199, 318, 664, 63, 265, 63, 952, 63, 8011, 63, 1483, 8, 1391, 12, 2345, 304, 523, 408, 1767, 9066, 4156, 367, 25420, 436, 5258, 63, 10387, 2860, 1041, 523, 13170, 63, 1391, 275, 2729, 423, 12286, 63, 1975, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 523, 340, 13170, 63, 1391, 365, 440, 488, 26, 272, 372, 3304, 63, 1659, 63, 1483, 14, 923, 8, 267, 2008, 8, 288, 5090, 63, 265, 63, 1782, 8, 68, 12, 13170, 63, 1391, 12, 2345, 9, 288, 367, 366, 315, 13170, 63, 1391, 14, 6410, 430, 523, 372, 3304, 63, 1659, 63, 1483, 14, 923, 8, 489, 2008, 8, 881, 5090, 63, 265, 63, 1782, 8, 86, 14, 1782, 12, 373, 12, 2345, 9, 881, 367, 373, 315, 2729, 14, 1459, 430, 421, 199, 318, 664, 63, 265, 63, 739, 63, 2117, 461, 8, 1391, 12, 5062, 63, 1391, 12, 536, 304, 523, 408, 1767, 3354, 5921, 367, 5258, 63, 5670, 1750, 1041, 819, 327, 2136, 675, 282, 4550, 880, 626, 781, 2793, 1133, 1172, 370, 9352, 642, 3965, 523, 327, 315, 314, 1930, 2382, 781, 787, 9936, 370, 9066, 3140, 402, 3354, 14, 523, 347, 2345, 837, 272, 372, 2729, 423, 362, 63, 7925, 63, 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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 ]
drmrd/ansible
test/units/playbook/test_attribute.py
119
1823
# (c) 2015, Marius Gedminas <marius@gedmin.as> # # 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.compat.tests import unittest from ansible.playbook.attribute import Attribute class TestAttribute(unittest.TestCase): def setUp(self): self.one = Attribute(priority=100) self.two = Attribute(priority=0) def test_eq(self): self.assertTrue(self.one == self.one) self.assertFalse(self.one == self.two) def test_ne(self): self.assertFalse(self.one != self.one) self.assertTrue(self.one != self.two) def test_lt(self): self.assertFalse(self.one < self.one) self.assertTrue(self.one < self.two) self.assertFalse(self.two < self.one) def test_gt(self): self.assertFalse(self.one > self.one) self.assertFalse(self.one > self.two) self.assertTrue(self.two > self.one) def test_le(self): self.assertTrue(self.one <= self.one) self.assertTrue(self.one <= self.two) self.assertFalse(self.two <= self.one) def test_ge(self): self.assertTrue(self.one >= self.one) self.assertFalse(self.one >= self.two) self.assertTrue(self.two >= self.one)
gpl-3.0
[ 3, 334, 67, 9, 6900, 12, 603, 759, 527, 598, 379, 827, 305, 665, 77, 759, 527, 32, 3046, 827, 14, 305, 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, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 14205, 14, 3215, 492, 3882, 421, 199, 533, 1379, 1646, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 368, 275, 3882, 8, 6693, 29, 1960, 9, 267, 291, 14, 5601, 275, 3882, 8, 6693, 29, 16, 9, 339, 347, 511, 63, 4077, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 508, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 508, 291, 14, 5601, 9, 339, 347, 511, 63, 685, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 1137, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 1137, 291, 14, 5601, 9, 339, 347, 511, 63, 4116, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 665, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 665, 291, 14, 5601, 9, 267, 291, 14, 3334, 8, 277, 14, 5601, 665, 291, 14, 368, 9, 339, 347, 511, 63, 3308, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 690, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 690, 291, 14, 5601, 9, 267, 291, 14, 1815, 8, 277, 14, 5601, 690, 291, 14, 368, 9, 339, 347, 511, 63, 274, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 2695, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 2695, 291, 14, 5601, 9, 267, 291, 14, 3334, 8, 277, 14, 5601, 2695, 291, 14, 368, 9, 339, 347, 511, 63, 303, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 2356, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 2356, 291, 14, 5601, 9, 267, 291, 14, 1815, 8, 277, 14, 5601, 2356, 291, 14, 368, 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 ]
[ 334, 67, 9, 6900, 12, 603, 759, 527, 598, 379, 827, 305, 665, 77, 759, 527, 32, 3046, 827, 14, 305, 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, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 14205, 14, 3215, 492, 3882, 421, 199, 533, 1379, 1646, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 368, 275, 3882, 8, 6693, 29, 1960, 9, 267, 291, 14, 5601, 275, 3882, 8, 6693, 29, 16, 9, 339, 347, 511, 63, 4077, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 508, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 508, 291, 14, 5601, 9, 339, 347, 511, 63, 685, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 1137, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 1137, 291, 14, 5601, 9, 339, 347, 511, 63, 4116, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 665, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 665, 291, 14, 5601, 9, 267, 291, 14, 3334, 8, 277, 14, 5601, 665, 291, 14, 368, 9, 339, 347, 511, 63, 3308, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 368, 690, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 690, 291, 14, 5601, 9, 267, 291, 14, 1815, 8, 277, 14, 5601, 690, 291, 14, 368, 9, 339, 347, 511, 63, 274, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 2695, 291, 14, 368, 9, 267, 291, 14, 1815, 8, 277, 14, 368, 2695, 291, 14, 5601, 9, 267, 291, 14, 3334, 8, 277, 14, 5601, 2695, 291, 14, 368, 9, 339, 347, 511, 63, 303, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 368, 2356, 291, 14, 368, 9, 267, 291, 14, 3334, 8, 277, 14, 368, 2356, 291, 14, 5601, 9, 267, 291, 14, 1815, 8, 277, 14, 5601, 2356, 291, 14, 368, 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,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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 ]
wunderlins/learning
python/django/lib/python2.7/site-packages/django/contrib/gis/geoip2/base.py
335
9054
import os import socket import geoip2.database from django.conf import settings from django.core.validators import ipv4_re from django.utils import six from django.utils.ipv6 import is_valid_ipv6_address from .resources import City, Country # Creating the settings dictionary with any settings, if needed. GEOIP_SETTINGS = { 'GEOIP_PATH': getattr(settings, 'GEOIP_PATH', None), 'GEOIP_CITY': getattr(settings, 'GEOIP_CITY', 'GeoLite2-City.mmdb'), 'GEOIP_COUNTRY': getattr(settings, 'GEOIP_COUNTRY', 'GeoLite2-Country.mmdb'), } class GeoIP2Exception(Exception): pass class GeoIP2(object): # The flags for GeoIP memory caching. # Try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order. MODE_AUTO = 0 # Use the C extension with memory map. MODE_MMAP_EXT = 1 # Read from memory map. Pure Python. MODE_MMAP = 2 # Read database as standard file. Pure Python. MODE_FILE = 4 # Load database into memory. Pure Python. MODE_MEMORY = 8 cache_options = {opt: None for opt in (0, 1, 2, 4, 8)} # Paths to the city & country binary databases. _city_file = '' _country_file = '' # Initially, pointers to GeoIP file references are NULL. _city = None _country = None def __init__(self, path=None, cache=0, country=None, city=None): """ Initialize the GeoIP object. No parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP datasets. * path: Base directory to where GeoIP data is located or the full path to where the city or country data files (*.mmdb) are located. Assumes that both the city and country data sets are located in this directory; overrides the GEOIP_PATH setting. * cache: The cache settings when opening up the GeoIP datasets. May be an integer in (0, 1, 2, 4, 8) corresponding to the MODE_AUTO, MODE_MMAP_EXT, MODE_MMAP, MODE_FILE, and MODE_MEMORY, `GeoIPOptions` C API settings, respectively. Defaults to 0, meaning MODE_AUTO. * country: The name of the GeoIP country data file. Defaults to 'GeoLite2-Country.mmdb'; overrides the GEOIP_COUNTRY setting. * city: The name of the GeoIP city data file. Defaults to 'GeoLite2-City.mmdb'; overrides the GEOIP_CITY setting. """ # Checking the given cache option. if cache in self.cache_options: self._cache = cache else: raise GeoIP2Exception('Invalid GeoIP caching option: %s' % cache) # Getting the GeoIP data path. if not path: path = GEOIP_SETTINGS['GEOIP_PATH'] if not path: raise GeoIP2Exception('GeoIP path must be provided via parameter or the GEOIP_PATH setting.') if not isinstance(path, six.string_types): raise TypeError('Invalid path type: %s' % type(path).__name__) if os.path.isdir(path): # Constructing the GeoIP database filenames using the settings # dictionary. If the database files for the GeoLite country # and/or city datasets exist, then try to open them. country_db = os.path.join(path, country or GEOIP_SETTINGS['GEOIP_COUNTRY']) if os.path.isfile(country_db): self._country = geoip2.database.Reader(country_db, mode=cache) self._country_file = country_db city_db = os.path.join(path, city or GEOIP_SETTINGS['GEOIP_CITY']) if os.path.isfile(city_db): self._city = geoip2.database.Reader(city_db, mode=cache) self._city_file = city_db elif os.path.isfile(path): # Otherwise, some detective work will be needed to figure out # whether the given database path is for the GeoIP country or city # databases. reader = geoip2.database.Reader(path, mode=cache) db_type = reader.metadata().database_type if db_type.endswith('City'): # GeoLite City database detected. self._city = reader self._city_file = path elif db_type.endswith('Country'): # GeoIP Country database detected. self._country = reader self._country_file = path else: raise GeoIP2Exception('Unable to recognize database edition: %s' % db_type) else: raise GeoIP2Exception('GeoIP path must be a valid file or directory.') @property def _reader(self): if self._country: return self._country else: return self._city @property def _country_or_city(self): if self._country: return self._country.country else: return self._city.city def __del__(self): # Cleanup any GeoIP file handles lying around. if self._reader: self._reader.close() def __repr__(self): meta = self._reader.metadata() version = '[v%s.%s]' % (meta.binary_format_major_version, meta.binary_format_minor_version) return '<%(cls)s %(version)s _country_file="%(country)s", _city_file="%(city)s">' % { 'cls': self.__class__.__name__, 'version': version, 'country': self._country_file, 'city': self._city_file, } def _check_query(self, query, country=False, city=False, city_or_country=False): "Helper routine for checking the query and database availability." # Making sure a string was passed in for the query. if not isinstance(query, six.string_types): raise TypeError('GeoIP query must be a string, not type %s' % type(query).__name__) # Extra checks for the existence of country and city databases. if city_or_country and not (self._country or self._city): raise GeoIP2Exception('Invalid GeoIP country and city data files.') elif country and not self._country: raise GeoIP2Exception('Invalid GeoIP country data file: %s' % self._country_file) elif city and not self._city: raise GeoIP2Exception('Invalid GeoIP city data file: %s' % self._city_file) # Return the query string back to the caller. GeoIP2 only takes IP addresses. if not (ipv4_re.match(query) or is_valid_ipv6_address(query)): query = socket.gethostbyname(query) return query def city(self, query): """ Return a dictionary of city information for the given IP address or Fully Qualified Domain Name (FQDN). Some information in the dictionary may be undefined (None). """ enc_query = self._check_query(query, city=True) return City(self._city.city(enc_query)) def country_code(self, query): "Return the country code for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) return self.country(enc_query)['country_code'] def country_name(self, query): "Return the country name for the given IP Address or FQDN." enc_query = self._check_query(query, city_or_country=True) return self.country(enc_query)['country_name'] def country(self, query): """ Return a dictionary with the country code and name when given an IP address or a Fully Qualified Domain Name (FQDN). For example, both '24.124.1.80' and 'djangoproject.com' are valid parameters. """ # Returning the country code and name enc_query = self._check_query(query, city_or_country=True) return Country(self._country_or_city(enc_query)) # #### Coordinate retrieval routines #### def coords(self, query, ordering=('longitude', 'latitude')): cdict = self.city(query) if cdict is None: return None else: return tuple(cdict[o] for o in ordering) def lon_lat(self, query): "Return a tuple of the (longitude, latitude) for the given query." return self.coords(query) def lat_lon(self, query): "Return a tuple of the (latitude, longitude) for the given query." return self.coords(query, ('latitude', 'longitude')) def geos(self, query): "Return a GEOS Point object for the given query." ll = self.lon_lat(query) if ll: from django.contrib.gis.geos import Point return Point(ll, srid=4326) else: return None # #### GeoIP Database Information Routines #### @property def info(self): "Return information about the GeoIP library and databases in use." meta = self._reader.metadata() return 'GeoIP Library:\n\t%s.%s\n' % (meta.binary_format_major_version, meta.binary_format_minor_version) @classmethod def open(cls, full_path, cache): return GeoIP2(full_path, cache)
gpl-2.0
[ 646, 747, 199, 646, 2838, 199, 199, 646, 8509, 711, 18, 14, 4659, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 11346, 492, 3278, 20, 63, 264, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 365, 63, 1078, 63, 4774, 22, 63, 1562, 199, 199, 504, 1275, 4435, 492, 14753, 12, 19453, 199, 199, 3, 20507, 314, 2202, 2600, 543, 1263, 2202, 12, 340, 4346, 14, 199, 18120, 1772, 63, 13931, 275, 469, 272, 283, 18120, 1772, 63, 3243, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 3243, 297, 488, 395, 272, 283, 18120, 1772, 63, 35, 1922, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 35, 1922, 297, 283, 10748, 19375, 18, 13, 17024, 14, 596, 697, 659, 272, 283, 18120, 1772, 63, 30263, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 30263, 297, 283, 10748, 19375, 18, 13, 17393, 14, 596, 697, 659, 199, 93, 421, 199, 533, 18378, 18, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 18378, 18, 8, 785, 304, 272, 327, 710, 3285, 367, 18378, 4402, 13627, 14, 272, 327, 7649, 27065, 63, 3218, 1282, 63, 2472, 12, 27065, 63, 3218, 1282, 12, 27065, 63, 3817, 315, 626, 1865, 14, 272, 27065, 63, 13883, 275, 378, 272, 327, 3645, 314, 445, 3329, 543, 4402, 2341, 14, 272, 27065, 63, 3218, 1282, 63, 2472, 275, 413, 272, 327, 5574, 687, 4402, 2341, 14, 510, 608, 2018, 14, 272, 27065, 63, 3218, 1282, 275, 499, 272, 327, 5574, 3050, 465, 4465, 570, 14, 510, 608, 2018, 14, 272, 27065, 63, 3817, 275, 841, 272, 327, 7190, 3050, 1901, 4402, 14, 510, 608, 2018, 14, 272, 27065, 63, 19495, 275, 1695, 272, 2581, 63, 1419, 275, 469, 2992, 26, 488, 367, 2450, 315, 334, 16, 12, 413, 12, 499, 12, 841, 12, 1695, 6769, 339, 327, 6912, 83, 370, 314, 14492, 1253, 9023, 3366, 16219, 14, 272, 485, 3690, 63, 493, 275, 2125, 272, 485, 6063, 63, 493, 275, 2125, 339, 327, 21412, 1183, 12, 21116, 370, 18378, 570, 6941, 787, 5962, 14, 272, 485, 3690, 275, 488, 272, 485, 6063, 275, 488, 339, 347, 636, 826, 721, 277, 12, 931, 29, 403, 12, 2581, 29, 16, 12, 9023, 29, 403, 12, 14492, 29, 403, 304, 267, 408, 267, 11578, 314, 18378, 909, 14, 3091, 2633, 787, 1415, 370, 675, 849, 267, 2202, 14, 6431, 2368, 1443, 506, 3032, 315, 370, 17551, 314, 9918, 267, 402, 314, 18378, 13148, 14, 398, 627, 931, 26, 3523, 2082, 370, 2382, 18378, 666, 365, 16180, 503, 314, 2615, 931, 288, 370, 2382, 314, 14492, 503, 9023, 666, 1584, 334, 4856, 596, 697, 9, 787, 16180, 14, 288, 30451, 626, 3865, 314, 14492, 436, 9023, 666, 5951, 787, 16180, 315, 288, 642, 2082, 27, 10580, 314, 21390, 1772, 63, 3243, 4260, 14, 398, 627, 2581, 26, 710, 2581, 2202, 1380, 13618, 1536, 314, 18378, 13148, 14, 10162, 506, 288, 376, 3000, 315, 334, 16, 12, 413, 12, 499, 12, 841, 12, 1695, 9, 5226, 370, 314, 27065, 63, 13883, 12, 288, 27065, 63, 3218, 1282, 63, 2472, 12, 27065, 63, 3218, 1282, 12, 27065, 63, 3817, 12, 436, 27065, 63, 19495, 12, 288, 658, 10748, 41, 1512, 494, 83, 64, 445, 3261, 2202, 12, 221, 17342, 14, 7827, 370, 378, 12, 288, 11150, 27065, 63, 13883, 14, 398, 627, 9023, 26, 710, 536, 402, 314, 18378, 9023, 666, 570, 14, 7827, 370, 288, 283, 10748, 19375, 18, 13, 17393, 14, 596, 697, 13619, 10580, 314, 21390, 1772, 63, 30263, 4260, 14, 398, 627, 14492, 26, 710, 536, 402, 314, 18378, 14492, 666, 570, 14, 7827, 370, 288, 283, 10748, 19375, 18, 13, 17024, 14, 596, 697, 13619, 10580, 314, 21390, 1772, 63, 35, 1922, 4260, 14, 267, 408, 267, 327, 25109, 314, 1627, 2581, 945, 14, 267, 340, 2581, 315, 291, 14, 1637, 63, 1419, 26, 288, 291, 423, 1637, 275, 2581, 267, 587, 26, 288, 746, 18378, 18, 1726, 360, 3364, 18378, 13627, 945, 26, 450, 83, 7, 450, 2581, 9, 398, 327, 20703, 314, 18378, 666, 931, 14, 267, 340, 440, 931, 26, 288, 931, 275, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 3243, 418, 288, 340, 440, 931, 26, 355, 746, 18378, 18, 1726, 360, 28848, 931, 1471, 506, 2741, 4799, 2725, 503, 314, 21390, 1772, 63, 3243, 4260, 2659, 267, 340, 440, 1228, 8, 515, 12, 3816, 14, 875, 63, 1313, 304, 288, 746, 3146, 360, 3364, 931, 730, 26, 450, 83, 7, 450, 730, 8, 515, 2843, 354, 3368, 398, 340, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 327, 9215, 316, 314, 18378, 3050, 6203, 1808, 314, 2202, 288, 327, 2600, 14, 982, 314, 3050, 1584, 367, 314, 8875, 19375, 9023, 288, 327, 436, 15, 269, 14492, 13148, 2187, 12, 2066, 862, 370, 1551, 3062, 14, 288, 9023, 63, 697, 275, 747, 14, 515, 14, 904, 8, 515, 12, 9023, 503, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 30263, 1105, 288, 340, 747, 14, 515, 14, 6292, 8, 6063, 63, 697, 304, 355, 291, 423, 6063, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 6063, 63, 697, 12, 818, 29, 1637, 9, 355, 291, 423, 6063, 63, 493, 275, 9023, 63, 697, 953, 14492, 63, 697, 275, 747, 14, 515, 14, 904, 8, 515, 12, 14492, 503, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 35, 1922, 1105, 288, 340, 747, 14, 515, 14, 6292, 8, 3690, 63, 697, 304, 355, 291, 423, 3690, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 3690, 63, 697, 12, 818, 29, 1637, 9, 355, 291, 423, 3690, 63, 493, 275, 14492, 63, 697, 267, 916, 747, 14, 515, 14, 6292, 8, 515, 304, 288, 327, 6630, 12, 2005, 477, 266, 6648, 1736, 911, 506, 4346, 370, 9658, 734, 288, 327, 3775, 314, 1627, 3050, 931, 365, 367, 314, 18378, 9023, 503, 14492, 288, 327, 16219, 14, 288, 7002, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 515, 12, 818, 29, 1637, 9, 288, 1592, 63, 466, 275, 7002, 14, 2343, 1252, 4659, 63, 466, 953, 340, 1592, 63 ]
[ 747, 199, 646, 2838, 199, 199, 646, 8509, 711, 18, 14, 4659, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 11346, 492, 3278, 20, 63, 264, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 365, 63, 1078, 63, 4774, 22, 63, 1562, 199, 199, 504, 1275, 4435, 492, 14753, 12, 19453, 199, 199, 3, 20507, 314, 2202, 2600, 543, 1263, 2202, 12, 340, 4346, 14, 199, 18120, 1772, 63, 13931, 275, 469, 272, 283, 18120, 1772, 63, 3243, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 3243, 297, 488, 395, 272, 283, 18120, 1772, 63, 35, 1922, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 35, 1922, 297, 283, 10748, 19375, 18, 13, 17024, 14, 596, 697, 659, 272, 283, 18120, 1772, 63, 30263, 356, 2519, 8, 1751, 12, 283, 18120, 1772, 63, 30263, 297, 283, 10748, 19375, 18, 13, 17393, 14, 596, 697, 659, 199, 93, 421, 199, 533, 18378, 18, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 18378, 18, 8, 785, 304, 272, 327, 710, 3285, 367, 18378, 4402, 13627, 14, 272, 327, 7649, 27065, 63, 3218, 1282, 63, 2472, 12, 27065, 63, 3218, 1282, 12, 27065, 63, 3817, 315, 626, 1865, 14, 272, 27065, 63, 13883, 275, 378, 272, 327, 3645, 314, 445, 3329, 543, 4402, 2341, 14, 272, 27065, 63, 3218, 1282, 63, 2472, 275, 413, 272, 327, 5574, 687, 4402, 2341, 14, 510, 608, 2018, 14, 272, 27065, 63, 3218, 1282, 275, 499, 272, 327, 5574, 3050, 465, 4465, 570, 14, 510, 608, 2018, 14, 272, 27065, 63, 3817, 275, 841, 272, 327, 7190, 3050, 1901, 4402, 14, 510, 608, 2018, 14, 272, 27065, 63, 19495, 275, 1695, 272, 2581, 63, 1419, 275, 469, 2992, 26, 488, 367, 2450, 315, 334, 16, 12, 413, 12, 499, 12, 841, 12, 1695, 6769, 339, 327, 6912, 83, 370, 314, 14492, 1253, 9023, 3366, 16219, 14, 272, 485, 3690, 63, 493, 275, 2125, 272, 485, 6063, 63, 493, 275, 2125, 339, 327, 21412, 1183, 12, 21116, 370, 18378, 570, 6941, 787, 5962, 14, 272, 485, 3690, 275, 488, 272, 485, 6063, 275, 488, 339, 347, 636, 826, 721, 277, 12, 931, 29, 403, 12, 2581, 29, 16, 12, 9023, 29, 403, 12, 14492, 29, 403, 304, 267, 408, 267, 11578, 314, 18378, 909, 14, 3091, 2633, 787, 1415, 370, 675, 849, 267, 2202, 14, 6431, 2368, 1443, 506, 3032, 315, 370, 17551, 314, 9918, 267, 402, 314, 18378, 13148, 14, 398, 627, 931, 26, 3523, 2082, 370, 2382, 18378, 666, 365, 16180, 503, 314, 2615, 931, 288, 370, 2382, 314, 14492, 503, 9023, 666, 1584, 334, 4856, 596, 697, 9, 787, 16180, 14, 288, 30451, 626, 3865, 314, 14492, 436, 9023, 666, 5951, 787, 16180, 315, 288, 642, 2082, 27, 10580, 314, 21390, 1772, 63, 3243, 4260, 14, 398, 627, 2581, 26, 710, 2581, 2202, 1380, 13618, 1536, 314, 18378, 13148, 14, 10162, 506, 288, 376, 3000, 315, 334, 16, 12, 413, 12, 499, 12, 841, 12, 1695, 9, 5226, 370, 314, 27065, 63, 13883, 12, 288, 27065, 63, 3218, 1282, 63, 2472, 12, 27065, 63, 3218, 1282, 12, 27065, 63, 3817, 12, 436, 27065, 63, 19495, 12, 288, 658, 10748, 41, 1512, 494, 83, 64, 445, 3261, 2202, 12, 221, 17342, 14, 7827, 370, 378, 12, 288, 11150, 27065, 63, 13883, 14, 398, 627, 9023, 26, 710, 536, 402, 314, 18378, 9023, 666, 570, 14, 7827, 370, 288, 283, 10748, 19375, 18, 13, 17393, 14, 596, 697, 13619, 10580, 314, 21390, 1772, 63, 30263, 4260, 14, 398, 627, 14492, 26, 710, 536, 402, 314, 18378, 14492, 666, 570, 14, 7827, 370, 288, 283, 10748, 19375, 18, 13, 17024, 14, 596, 697, 13619, 10580, 314, 21390, 1772, 63, 35, 1922, 4260, 14, 267, 408, 267, 327, 25109, 314, 1627, 2581, 945, 14, 267, 340, 2581, 315, 291, 14, 1637, 63, 1419, 26, 288, 291, 423, 1637, 275, 2581, 267, 587, 26, 288, 746, 18378, 18, 1726, 360, 3364, 18378, 13627, 945, 26, 450, 83, 7, 450, 2581, 9, 398, 327, 20703, 314, 18378, 666, 931, 14, 267, 340, 440, 931, 26, 288, 931, 275, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 3243, 418, 288, 340, 440, 931, 26, 355, 746, 18378, 18, 1726, 360, 28848, 931, 1471, 506, 2741, 4799, 2725, 503, 314, 21390, 1772, 63, 3243, 4260, 2659, 267, 340, 440, 1228, 8, 515, 12, 3816, 14, 875, 63, 1313, 304, 288, 746, 3146, 360, 3364, 931, 730, 26, 450, 83, 7, 450, 730, 8, 515, 2843, 354, 3368, 398, 340, 747, 14, 515, 14, 6027, 8, 515, 304, 288, 327, 9215, 316, 314, 18378, 3050, 6203, 1808, 314, 2202, 288, 327, 2600, 14, 982, 314, 3050, 1584, 367, 314, 8875, 19375, 9023, 288, 327, 436, 15, 269, 14492, 13148, 2187, 12, 2066, 862, 370, 1551, 3062, 14, 288, 9023, 63, 697, 275, 747, 14, 515, 14, 904, 8, 515, 12, 9023, 503, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 30263, 1105, 288, 340, 747, 14, 515, 14, 6292, 8, 6063, 63, 697, 304, 355, 291, 423, 6063, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 6063, 63, 697, 12, 818, 29, 1637, 9, 355, 291, 423, 6063, 63, 493, 275, 9023, 63, 697, 953, 14492, 63, 697, 275, 747, 14, 515, 14, 904, 8, 515, 12, 14492, 503, 21390, 1772, 63, 13931, 459, 18120, 1772, 63, 35, 1922, 1105, 288, 340, 747, 14, 515, 14, 6292, 8, 3690, 63, 697, 304, 355, 291, 423, 3690, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 3690, 63, 697, 12, 818, 29, 1637, 9, 355, 291, 423, 3690, 63, 493, 275, 14492, 63, 697, 267, 916, 747, 14, 515, 14, 6292, 8, 515, 304, 288, 327, 6630, 12, 2005, 477, 266, 6648, 1736, 911, 506, 4346, 370, 9658, 734, 288, 327, 3775, 314, 1627, 3050, 931, 365, 367, 314, 18378, 9023, 503, 14492, 288, 327, 16219, 14, 288, 7002, 275, 8509, 711, 18, 14, 4659, 14, 5929, 8, 515, 12, 818, 29, 1637, 9, 288, 1592, 63, 466, 275, 7002, 14, 2343, 1252, 4659, 63, 466, 953, 340, 1592, 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, 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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 ]
runekaagaard/django-contrib-locking
tests/utils_tests/test_safestring.py
8
3704
from __future__ import unicode_literals from django.template import Template, Context from django.test import TestCase from django.utils.encoding import force_text, force_bytes from django.utils.functional import lazy from django.utils.safestring import mark_safe, mark_for_escaping, SafeData, EscapeData from django.utils import six from django.utils import text from django.utils import html lazystr = lazy(force_text, six.text_type) lazybytes = lazy(force_bytes, bytes) class customescape(six.text_type): def __html__(self): # implement specific and obviously wrong escaping # in order to be able to tell for sure when it runs return self.replace('<', '<<').replace('>', '>>') class SafeStringTest(TestCase): def assertRenderEqual(self, tpl, expected, **context): context = Context(context) tpl = Template(tpl) self.assertEqual(tpl.render(context), expected) def test_mark_safe(self): s = mark_safe('a&b') self.assertRenderEqual('{{ s }}', 'a&b', s=s) self.assertRenderEqual('{{ s|force_escape }}', 'a&amp;b', s=s) def test_mark_safe_object_implementing_dunder_html(self): e = customescape('<a&b>') s = mark_safe(e) self.assertIs(s, e) self.assertRenderEqual('{{ s }}', '<<a&b>>', s=s) self.assertRenderEqual('{{ s|force_escape }}', '&lt;a&amp;b&gt;', s=s) def test_mark_safe_lazy(self): s = lazystr('a&b') b = lazybytes(b'a&b') self.assertIsInstance(mark_safe(s), SafeData) self.assertIsInstance(mark_safe(b), SafeData) self.assertRenderEqual('{{ s }}', 'a&b', s=mark_safe(s)) def test_mark_safe_object_implementing_dunder_str(self): class Obj(object): def __str__(self): return '<obj>' s = mark_safe(Obj()) self.assertRenderEqual('{{ s }}', '<obj>', s=s) def test_mark_safe_result_implements_dunder_html(self): self.assertEqual(mark_safe('a&b').__html__(), 'a&b') def test_mark_safe_lazy_result_implements_dunder_html(self): self.assertEqual(mark_safe(lazystr('a&b')).__html__(), 'a&b') def test_mark_for_escaping(self): s = mark_for_escaping('a&b') self.assertRenderEqual('{{ s }}', 'a&amp;b', s=s) self.assertRenderEqual('{{ s }}', 'a&amp;b', s=mark_for_escaping(s)) def test_mark_for_escaping_object_implementing_dunder_html(self): e = customescape('<a&b>') s = mark_for_escaping(e) self.assertIs(s, e) self.assertRenderEqual('{{ s }}', '<<a&b>>', s=s) self.assertRenderEqual('{{ s|force_escape }}', '&lt;a&amp;b&gt;', s=s) def test_mark_for_escaping_lazy(self): s = lazystr('a&b') b = lazybytes(b'a&b') self.assertIsInstance(mark_for_escaping(s), EscapeData) self.assertIsInstance(mark_for_escaping(b), EscapeData) self.assertRenderEqual('{% autoescape off %}{{ s }}{% endautoescape %}', 'a&amp;b', s=mark_for_escaping(s)) def test_mark_for_escaping_object_implementing_dunder_str(self): class Obj(object): def __str__(self): return '<obj>' s = mark_for_escaping(Obj()) self.assertRenderEqual('{{ s }}', '&lt;obj&gt;', s=s) def test_add_lazy_safe_text_and_safe_text(self): s = html.escape(lazystr('a')) s += mark_safe('&b') self.assertRenderEqual('{{ s }}', 'a&b', s=s) s = html.escapejs(lazystr('a')) s += mark_safe('&b') self.assertRenderEqual('{{ s }}', 'a&b', s=s) s = text.slugify(lazystr('a')) s += mark_safe('&b') self.assertRenderEqual('{{ s }}', 'a&b', s=s)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1160, 492, 5458, 12, 9470, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 14, 15481, 492, 9617, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 12, 2216, 63, 509, 63, 26306, 12, 14969, 1451, 12, 21067, 1451, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 492, 1318, 199, 504, 1639, 14, 1208, 492, 3517, 199, 199, 6395, 495, 275, 9617, 8, 3990, 63, 505, 12, 3816, 14, 505, 63, 466, 9, 199, 6395, 2394, 275, 9617, 8, 3990, 63, 2394, 12, 2783, 9, 421, 199, 533, 286, 5999, 3588, 8, 4174, 14, 505, 63, 466, 304, 272, 347, 636, 1360, 721, 277, 304, 267, 327, 5669, 2488, 436, 25259, 590, 6835, 21375, 267, 327, 315, 1865, 370, 506, 7688, 370, 11480, 367, 3238, 1380, 652, 7858, 267, 372, 291, 14, 1814, 4827, 297, 27407, 1959, 1814, 360, 4206, 283, 1140, 358, 421, 199, 533, 14969, 1558, 774, 8, 1746, 304, 272, 347, 702, 9216, 591, 8, 277, 12, 20223, 12, 1420, 12, 1011, 1100, 304, 267, 1067, 275, 9470, 8, 1100, 9, 267, 20223, 275, 5458, 8, 15436, 9, 267, 291, 14, 629, 8, 15436, 14, 3352, 8, 1100, 395, 1420, 9, 339, 347, 511, 63, 1657, 63, 3489, 8, 277, 304, 267, 308, 275, 2216, 63, 3489, 360, 65, 6, 66, 358, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 325, 275, 286, 5999, 3588, 4827, 65, 6, 66, 5971, 267, 308, 275, 2216, 63, 3489, 8, 69, 9, 267, 291, 14, 3436, 8, 83, 12, 325, 9, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 27407, 65, 6, 66, 1140, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 7673, 4116, 27, 65, 6, 5282, 27, 66, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 6395, 8, 277, 304, 267, 308, 275, 9617, 495, 360, 65, 6, 66, 358, 267, 330, 275, 9617, 2394, 8, 66, 7, 65, 6, 66, 358, 398, 291, 14, 6926, 8, 1657, 63, 3489, 8, 83, 395, 14969, 1451, 9, 267, 291, 14, 6926, 8, 1657, 63, 3489, 8, 66, 395, 14969, 1451, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 1657, 63, 3489, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 3489, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 495, 8, 277, 304, 267, 1021, 24921, 8, 785, 304, 288, 347, 636, 495, 721, 277, 304, 355, 372, 2650, 1113, 3524, 398, 308, 275, 2216, 63, 3489, 8, 5665, 1012, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 2650, 1113, 4206, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 1099, 63, 24900, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 291, 14, 629, 8, 1657, 63, 3489, 360, 65, 6, 66, 358, 855, 1360, 29709, 283, 65, 6, 66, 358, 339, 347, 511, 63, 1657, 63, 3489, 63, 6395, 63, 1099, 63, 24900, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 291, 14, 629, 8, 1657, 63, 3489, 8, 6395, 495, 360, 65, 6, 66, 358, 2843, 1360, 29709, 283, 65, 6, 66, 358, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 8, 277, 304, 267, 308, 275, 2216, 63, 509, 63, 26306, 360, 65, 6, 66, 358, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 1657, 63, 509, 63, 26306, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 325, 275, 286, 5999, 3588, 4827, 65, 6, 66, 5971, 267, 308, 275, 2216, 63, 509, 63, 26306, 8, 69, 9, 267, 291, 14, 3436, 8, 83, 12, 325, 9, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 27407, 65, 6, 66, 1140, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 7673, 4116, 27, 65, 6, 5282, 27, 66, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 6395, 8, 277, 304, 267, 308, 275, 9617, 495, 360, 65, 6, 66, 358, 267, 330, 275, 9617, 2394, 8, 66, 7, 65, 6, 66, 358, 398, 291, 14, 6926, 8, 1657, 63, 509, 63, 26306, 8, 83, 395, 21067, 1451, 9, 267, 291, 14, 6926, 8, 1657, 63, 509, 63, 26306, 8, 66, 395, 21067, 1451, 9, 267, 291, 14, 479, 9216, 591, 24103, 19102, 2331, 17337, 308, 20104, 1284, 15818, 21610, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 1657, 63, 509, 63, 26306, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 495, 8, 277, 304, 267, 1021, 24921, 8, 785, 304, 288, 347, 636, 495, 721, 277, 304, 355, 372, 2650, 1113, 3524, 398, 308, 275, 2216, 63, 509, 63, 26306, 8, 5665, 1012, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 7673, 4116, 27, 1113, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 3489, 63, 505, 63, 460, 63, 3489, 63, 505, 8, 277, 304, 267, 308, 275, 3517, 14, 3765, 8, 6395, 495, 360, 65, 1333, 267, 308, 847, 2216, 63, 3489, 20040, 66, 358, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 83, 9, 398 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1160, 492, 5458, 12, 9470, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 14, 15481, 492, 9617, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 12, 2216, 63, 509, 63, 26306, 12, 14969, 1451, 12, 21067, 1451, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 492, 1318, 199, 504, 1639, 14, 1208, 492, 3517, 199, 199, 6395, 495, 275, 9617, 8, 3990, 63, 505, 12, 3816, 14, 505, 63, 466, 9, 199, 6395, 2394, 275, 9617, 8, 3990, 63, 2394, 12, 2783, 9, 421, 199, 533, 286, 5999, 3588, 8, 4174, 14, 505, 63, 466, 304, 272, 347, 636, 1360, 721, 277, 304, 267, 327, 5669, 2488, 436, 25259, 590, 6835, 21375, 267, 327, 315, 1865, 370, 506, 7688, 370, 11480, 367, 3238, 1380, 652, 7858, 267, 372, 291, 14, 1814, 4827, 297, 27407, 1959, 1814, 360, 4206, 283, 1140, 358, 421, 199, 533, 14969, 1558, 774, 8, 1746, 304, 272, 347, 702, 9216, 591, 8, 277, 12, 20223, 12, 1420, 12, 1011, 1100, 304, 267, 1067, 275, 9470, 8, 1100, 9, 267, 20223, 275, 5458, 8, 15436, 9, 267, 291, 14, 629, 8, 15436, 14, 3352, 8, 1100, 395, 1420, 9, 339, 347, 511, 63, 1657, 63, 3489, 8, 277, 304, 267, 308, 275, 2216, 63, 3489, 360, 65, 6, 66, 358, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 325, 275, 286, 5999, 3588, 4827, 65, 6, 66, 5971, 267, 308, 275, 2216, 63, 3489, 8, 69, 9, 267, 291, 14, 3436, 8, 83, 12, 325, 9, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 27407, 65, 6, 66, 1140, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 7673, 4116, 27, 65, 6, 5282, 27, 66, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 6395, 8, 277, 304, 267, 308, 275, 9617, 495, 360, 65, 6, 66, 358, 267, 330, 275, 9617, 2394, 8, 66, 7, 65, 6, 66, 358, 398, 291, 14, 6926, 8, 1657, 63, 3489, 8, 83, 395, 14969, 1451, 9, 267, 291, 14, 6926, 8, 1657, 63, 3489, 8, 66, 395, 14969, 1451, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 1657, 63, 3489, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 3489, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 495, 8, 277, 304, 267, 1021, 24921, 8, 785, 304, 288, 347, 636, 495, 721, 277, 304, 355, 372, 2650, 1113, 3524, 398, 308, 275, 2216, 63, 3489, 8, 5665, 1012, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 2650, 1113, 4206, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 3489, 63, 1099, 63, 24900, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 291, 14, 629, 8, 1657, 63, 3489, 360, 65, 6, 66, 358, 855, 1360, 29709, 283, 65, 6, 66, 358, 339, 347, 511, 63, 1657, 63, 3489, 63, 6395, 63, 1099, 63, 24900, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 291, 14, 629, 8, 1657, 63, 3489, 8, 6395, 495, 360, 65, 6, 66, 358, 2843, 1360, 29709, 283, 65, 6, 66, 358, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 8, 277, 304, 267, 308, 275, 2216, 63, 509, 63, 26306, 360, 65, 6, 66, 358, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 1657, 63, 509, 63, 26306, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 1360, 8, 277, 304, 267, 325, 275, 286, 5999, 3588, 4827, 65, 6, 66, 5971, 267, 308, 275, 2216, 63, 509, 63, 26306, 8, 69, 9, 267, 291, 14, 3436, 8, 83, 12, 325, 9, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 27407, 65, 6, 66, 1140, 297, 308, 29, 83, 9, 267, 291, 14, 479, 9216, 591, 18976, 308, 92, 3990, 63, 3765, 23688, 7673, 4116, 27, 65, 6, 5282, 27, 66, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 6395, 8, 277, 304, 267, 308, 275, 9617, 495, 360, 65, 6, 66, 358, 267, 330, 275, 9617, 2394, 8, 66, 7, 65, 6, 66, 358, 398, 291, 14, 6926, 8, 1657, 63, 509, 63, 26306, 8, 83, 395, 21067, 1451, 9, 267, 291, 14, 6926, 8, 1657, 63, 509, 63, 26306, 8, 66, 395, 21067, 1451, 9, 267, 291, 14, 479, 9216, 591, 24103, 19102, 2331, 17337, 308, 20104, 1284, 15818, 21610, 283, 65, 6, 5282, 27, 66, 297, 308, 29, 1657, 63, 509, 63, 26306, 8, 83, 430, 339, 347, 511, 63, 1657, 63, 509, 63, 26306, 63, 785, 63, 21463, 316, 63, 68, 7138, 63, 495, 8, 277, 304, 267, 1021, 24921, 8, 785, 304, 288, 347, 636, 495, 721, 277, 304, 355, 372, 2650, 1113, 3524, 398, 308, 275, 2216, 63, 509, 63, 26306, 8, 5665, 1012, 398, 291, 14, 479, 9216, 591, 18976, 308, 23688, 7673, 4116, 27, 1113, 6, 3308, 10805, 308, 29, 83, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 3489, 63, 505, 63, 460, 63, 3489, 63, 505, 8, 277, 304, 267, 308, 275, 3517, 14, 3765, 8, 6395, 495, 360, 65, 1333, 267, 308, 847, 2216, 63, 3489, 20040, 66, 358, 267, 291, 14, 479, 9216, 591, 18976, 308, 23688, 283, 65, 6, 66, 297, 308, 29, 83, 9, 398, 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,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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 ]
jean/python-docx
features/steps/parfmt.py
6
7800
# encoding: utf-8 """ Step implementations for paragraph format-related features. """ from __future__ import ( absolute_import, division, print_function, unicode_literals ) from behave import given, then, when from docx import Document from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING from docx.shared import Pt from helpers import test_docx # given =================================================== @given('a paragraph format having {prop_name} set {setting}') def given_a_paragraph_format_having_prop_set(context, prop_name, setting): style_name = { 'to inherit': 'Normal', 'On': 'Base', 'Off': 'Citation', }[setting] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format @given('a paragraph format having {setting} line spacing') def given_a_paragraph_format_having_setting_line_spacing(context, setting): style_name = { 'inherited': 'Normal', '14 pt': 'Base', 'double': 'Citation', }[setting] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format @given('a paragraph format having {setting} space {side}') def given_a_paragraph_format_having_setting_spacing(context, setting, side): style_name = 'Normal' if setting == 'inherited' else 'Base' document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format @given('a paragraph format having {type} alignment') def given_a_paragraph_format_having_align_type_alignment(context, type): style_name = { 'inherited': 'Normal', 'center': 'Base', 'right': 'Citation', }[type] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format @given('a paragraph format having {type} indent of {value}') def given_a_paragraph_format_having_type_indent_value(context, type, value): style_name = { 'inherit': 'Normal', '18 pt': 'Base', '17.3 pt': 'Base', '-17.3 pt': 'Citation', '46.1 pt': 'Citation', }[value] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format # when ==================================================== @when('I assign {value} to paragraph_format.line_spacing') def when_I_assign_value_to_paragraph_format_line_spacing(context, value): new_value = { 'Pt(14)': Pt(14), '2': 2, }.get(value) new_value = float(value) if new_value is None else new_value context.paragraph_format.line_spacing = new_value @when('I assign {value} to paragraph_format.line_spacing_rule') def when_I_assign_value_to_paragraph_format_line_rule(context, value): new_value = { 'None': None, 'WD_LINE_SPACING.EXACTLY': WD_LINE_SPACING.EXACTLY, 'WD_LINE_SPACING.MULTIPLE': WD_LINE_SPACING.MULTIPLE, 'WD_LINE_SPACING.SINGLE': WD_LINE_SPACING.SINGLE, 'WD_LINE_SPACING.DOUBLE': WD_LINE_SPACING.DOUBLE, 'WD_LINE_SPACING.AT_LEAST': WD_LINE_SPACING.AT_LEAST, 'WD_LINE_SPACING.ONE_POINT_FIVE': WD_LINE_SPACING.ONE_POINT_FIVE, }[value] paragraph_format = context.paragraph_format paragraph_format.line_spacing_rule = new_value @when('I assign {value} to paragraph_format.alignment') def when_I_assign_value_to_paragraph_format_alignment(context, value): new_value = { 'None': None, 'WD_ALIGN_PARAGRAPH.CENTER': WD_ALIGN_PARAGRAPH.CENTER, 'WD_ALIGN_PARAGRAPH.RIGHT': WD_ALIGN_PARAGRAPH.RIGHT, }[value] paragraph_format = context.paragraph_format paragraph_format.alignment = new_value @when('I assign {value} to paragraph_format.space_{side}') def when_I_assign_value_to_paragraph_format_space(context, value, side): paragraph_format = context.paragraph_format prop_name = 'space_%s' % side new_value = { 'None': None, 'Pt(12)': Pt(12), 'Pt(18)': Pt(18), }[value] setattr(paragraph_format, prop_name, new_value) @when('I assign {value} to paragraph_format.{type_}_indent') def when_I_assign_value_to_paragraph_format_indent(context, value, type_): paragraph_format = context.paragraph_format prop_name = '%s_indent' % type_ value = None if value == 'None' else Pt(float(value.split()[0])) setattr(paragraph_format, prop_name, value) @when('I assign {value} to paragraph_format.{prop_name}') def when_I_assign_value_to_paragraph_format_prop(context, value, prop_name): paragraph_format = context.paragraph_format value = {'None': None, 'True': True, 'False': False}[value] setattr(paragraph_format, prop_name, value) # then ===================================================== @then('paragraph_format.alignment is {value}') def then_paragraph_format_alignment_is_value(context, value): expected_value = { 'None': None, 'WD_ALIGN_PARAGRAPH.LEFT': WD_ALIGN_PARAGRAPH.LEFT, 'WD_ALIGN_PARAGRAPH.CENTER': WD_ALIGN_PARAGRAPH.CENTER, 'WD_ALIGN_PARAGRAPH.RIGHT': WD_ALIGN_PARAGRAPH.RIGHT, }[value] paragraph_format = context.paragraph_format assert paragraph_format.alignment == expected_value @then('paragraph_format.line_spacing is {value}') def then_paragraph_format_line_spacing_is_value(context, value): expected_value = ( None if value == 'None' else float(value) if '.' in value else int(value) ) paragraph_format = context.paragraph_format if expected_value is None or isinstance(expected_value, int): assert paragraph_format.line_spacing == expected_value else: assert abs(paragraph_format.line_spacing - expected_value) < 0.001 @then('paragraph_format.line_spacing_rule is {value}') def then_paragraph_format_line_spacing_rule_is_value(context, value): expected_value = { 'None': None, 'WD_LINE_SPACING.EXACTLY': WD_LINE_SPACING.EXACTLY, 'WD_LINE_SPACING.MULTIPLE': WD_LINE_SPACING.MULTIPLE, 'WD_LINE_SPACING.SINGLE': WD_LINE_SPACING.SINGLE, 'WD_LINE_SPACING.DOUBLE': WD_LINE_SPACING.DOUBLE, 'WD_LINE_SPACING.AT_LEAST': WD_LINE_SPACING.AT_LEAST, 'WD_LINE_SPACING.ONE_POINT_FIVE': WD_LINE_SPACING.ONE_POINT_FIVE, }[value] paragraph_format = context.paragraph_format assert paragraph_format.line_spacing_rule == expected_value @then('paragraph_format.space_{side} is {value}') def then_paragraph_format_space_side_is_value(context, side, value): expected_value = None if value == 'None' else int(value) prop_name = 'space_%s' % side paragraph_format = context.paragraph_format actual_value = getattr(paragraph_format, prop_name) assert actual_value == expected_value @then('paragraph_format.{type_}_indent is {value}') def then_paragraph_format_type_indent_is_value(context, type_, value): expected_value = None if value == 'None' else int(value) prop_name = '%s_indent' % type_ paragraph_format = context.paragraph_format actual_value = getattr(paragraph_format, prop_name) assert actual_value == expected_value @then('paragraph_format.{prop_name} is {value}') def then_paragraph_format_prop_name_is_value(context, prop_name, value): expected_value = {'None': None, 'True': True, 'False': False}[value] paragraph_format = context.paragraph_format actual_value = getattr(paragraph_format, prop_name) assert actual_value == expected_value
mit
[ 3, 2644, 26, 2774, 13, 24, 199, 199, 624, 199, 7801, 12591, 367, 13168, 1475, 13, 2407, 4534, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 334, 272, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 9, 199, 199, 504, 24062, 492, 1627, 12, 2066, 12, 1380, 199, 199, 504, 1382, 88, 492, 7543, 199, 504, 1382, 88, 14, 4869, 14, 505, 492, 644, 36, 63, 15255, 63, 4014, 1254, 50, 21126, 12, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 199, 504, 1382, 88, 14, 5555, 492, 510, 84, 199, 199, 504, 10897, 492, 511, 63, 1301, 88, 421, 199, 3, 1627, 19691, 389, 199, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 4469, 63, 354, 93, 663, 469, 6031, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 4469, 63, 409, 8, 1100, 12, 5931, 63, 354, 12, 4260, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 475, 8287, 356, 283, 6241, 297, 267, 283, 3314, 356, 260, 283, 1563, 297, 267, 283, 5195, 356, 263, 283, 35, 5314, 297, 272, 28439, 6031, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 6031, 93, 1004, 19621, 358, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 6031, 63, 604, 63, 15880, 8, 1100, 12, 4260, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 17571, 356, 283, 6241, 297, 267, 283, 1079, 10063, 356, 258, 283, 1563, 297, 267, 283, 3157, 356, 259, 283, 35, 5314, 297, 272, 28439, 6031, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 6031, 93, 4601, 469, 2441, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 6031, 63, 15880, 8, 1100, 12, 4260, 12, 5366, 304, 272, 3449, 63, 354, 275, 283, 6241, 7, 340, 4260, 508, 283, 17571, 7, 587, 283, 1563, 7, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 466, 93, 13177, 358, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 5743, 63, 466, 63, 13699, 8, 1100, 12, 730, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 17571, 356, 283, 6241, 297, 267, 283, 4218, 356, 259, 283, 1563, 297, 267, 283, 1019, 356, 258, 283, 35, 5314, 297, 272, 28439, 466, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 466, 93, 4363, 402, 469, 585, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 466, 63, 3724, 63, 585, 8, 1100, 12, 730, 12, 574, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 6486, 356, 221, 283, 6241, 297, 267, 283, 1085, 10063, 356, 259, 283, 1563, 297, 267, 283, 1196, 14, 19, 10063, 356, 221, 283, 1563, 297, 267, 2475, 1196, 14, 19, 10063, 356, 283, 35, 5314, 297, 267, 283, 2466, 14, 17, 10063, 356, 221, 283, 35, 5314, 297, 272, 28439, 585, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 3, 1380, 19691, 5918, 199, 199, 32, 6526, 360, 41, 5090, 469, 585, 93, 370, 13168, 63, 908, 14, 604, 63, 15880, 358, 199, 318, 1380, 63, 41, 63, 5038, 63, 585, 63, 475, 63, 12400, 63, 908, 63, 604, 63, 15880, 8, 1100, 12, 574, 304, 272, 892, 63, 585, 275, 469, 267, 283, 19886, 8, 1079, 11862, 510, 84, 8, 1079, 395, 267, 283, 18, 356, 420, 499, 12, 272, 789, 14, 362, 8, 585, 9, 272, 892, 63, 585, 275, 2069, 8, 585, 9, 340, 892, 63, 585, 365, 488, 587, 892, 63, 585, 272, 1067, 14, 12400, 63, 908, 14, 604, 63, 15880, 275, 892, 63, 585, 421, 199, 32, 6526, 360, 41, 5090, 469, 585, 93, 370, 13168, 63, 908, 14, 604, 63, 15880, 63, 2200, 358, 199, 318, 1380, 63, 41, 63, 5038, 63, 585, 63, 475, 63, 12400, 63, 908, 63, 604, 63, 2200, 8, 1100, 12, 574, 304, 272, 892, 63, 585, 275, 469, 267, 283, 403, 356, 13235, 488, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 1438, 3036, 6084, 356, 263, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 1438, 3036, 6084, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 21894, 906, 356, 755, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 21894, 906, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 16425, 356, 260, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 16425, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 14989, 356, 260, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 14989, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 619, 63, 906, 11307, 356, 755, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 619, 63, 906, 11307, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 4817, 63, 7217, 63, 1976, 2524, 356, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 4817, 63, 7217, 63, 1976, 2524, 12, 272, 28439, 585, 61, 272, 13168, 63, 908, 275, 1067, 14, 12400, 63, 908, 272, 13168, 63, 908, 14, 604, 63, 15880, 63, 2200, 275, 892, 63, 585 ]
[ 2644, 26, 2774, 13, 24, 199, 199, 624, 199, 7801, 12591, 367, 13168, 1475, 13, 2407, 4534, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 334, 272, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 9, 199, 199, 504, 24062, 492, 1627, 12, 2066, 12, 1380, 199, 199, 504, 1382, 88, 492, 7543, 199, 504, 1382, 88, 14, 4869, 14, 505, 492, 644, 36, 63, 15255, 63, 4014, 1254, 50, 21126, 12, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 199, 504, 1382, 88, 14, 5555, 492, 510, 84, 199, 199, 504, 10897, 492, 511, 63, 1301, 88, 421, 199, 3, 1627, 19691, 389, 199, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 4469, 63, 354, 93, 663, 469, 6031, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 4469, 63, 409, 8, 1100, 12, 5931, 63, 354, 12, 4260, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 475, 8287, 356, 283, 6241, 297, 267, 283, 3314, 356, 260, 283, 1563, 297, 267, 283, 5195, 356, 263, 283, 35, 5314, 297, 272, 28439, 6031, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 6031, 93, 1004, 19621, 358, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 6031, 63, 604, 63, 15880, 8, 1100, 12, 4260, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 17571, 356, 283, 6241, 297, 267, 283, 1079, 10063, 356, 258, 283, 1563, 297, 267, 283, 3157, 356, 259, 283, 35, 5314, 297, 272, 28439, 6031, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 6031, 93, 4601, 469, 2441, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 6031, 63, 15880, 8, 1100, 12, 4260, 12, 5366, 304, 272, 3449, 63, 354, 275, 283, 6241, 7, 340, 4260, 508, 283, 17571, 7, 587, 283, 1563, 7, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 466, 93, 13177, 358, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 5743, 63, 466, 63, 13699, 8, 1100, 12, 730, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 17571, 356, 283, 6241, 297, 267, 283, 4218, 356, 259, 283, 1563, 297, 267, 283, 1019, 356, 258, 283, 35, 5314, 297, 272, 28439, 466, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 32, 11809, 360, 65, 13168, 1475, 9445, 469, 466, 93, 4363, 402, 469, 585, 12216, 199, 318, 1627, 63, 65, 63, 12400, 63, 908, 63, 31569, 63, 466, 63, 3724, 63, 585, 8, 1100, 12, 730, 12, 574, 304, 272, 3449, 63, 354, 275, 469, 267, 283, 6486, 356, 221, 283, 6241, 297, 267, 283, 1085, 10063, 356, 259, 283, 1563, 297, 267, 283, 1196, 14, 19, 10063, 356, 221, 283, 1563, 297, 267, 2475, 1196, 14, 19, 10063, 356, 283, 35, 5314, 297, 267, 283, 2466, 14, 17, 10063, 356, 221, 283, 35, 5314, 297, 272, 28439, 585, 61, 272, 2213, 275, 7543, 8, 396, 63, 1301, 88, 360, 28352, 13, 3159, 13, 12955, 1333, 272, 1067, 14, 12400, 63, 908, 275, 2213, 14, 12955, 59, 2487, 63, 354, 1055, 12400, 63, 908, 421, 199, 3, 1380, 19691, 5918, 199, 199, 32, 6526, 360, 41, 5090, 469, 585, 93, 370, 13168, 63, 908, 14, 604, 63, 15880, 358, 199, 318, 1380, 63, 41, 63, 5038, 63, 585, 63, 475, 63, 12400, 63, 908, 63, 604, 63, 15880, 8, 1100, 12, 574, 304, 272, 892, 63, 585, 275, 469, 267, 283, 19886, 8, 1079, 11862, 510, 84, 8, 1079, 395, 267, 283, 18, 356, 420, 499, 12, 272, 789, 14, 362, 8, 585, 9, 272, 892, 63, 585, 275, 2069, 8, 585, 9, 340, 892, 63, 585, 365, 488, 587, 892, 63, 585, 272, 1067, 14, 12400, 63, 908, 14, 604, 63, 15880, 275, 892, 63, 585, 421, 199, 32, 6526, 360, 41, 5090, 469, 585, 93, 370, 13168, 63, 908, 14, 604, 63, 15880, 63, 2200, 358, 199, 318, 1380, 63, 41, 63, 5038, 63, 585, 63, 475, 63, 12400, 63, 908, 63, 604, 63, 2200, 8, 1100, 12, 574, 304, 272, 892, 63, 585, 275, 469, 267, 283, 403, 356, 13235, 488, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 1438, 3036, 6084, 356, 263, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 1438, 3036, 6084, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 21894, 906, 356, 755, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 21894, 906, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 16425, 356, 260, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 16425, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 14989, 356, 260, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 14989, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 619, 63, 906, 11307, 356, 755, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 619, 63, 906, 11307, 12, 267, 283, 16698, 63, 6174, 63, 5763, 1348, 1206, 14, 4817, 63, 7217, 63, 1976, 2524, 356, 644, 36, 63, 6174, 63, 5763, 1348, 1206, 14, 4817, 63, 7217, 63, 1976, 2524, 12, 272, 28439, 585, 61, 272, 13168, 63, 908, 275, 1067, 14, 12400, 63, 908, 272, 13168, 63, 908, 14, 604, 63, 15880, 63, 2200, 275, 892, 63, 585, 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, 1 ]
gavinhungry/hashbrowns
hashbrowns.py
1
3014
#!/usr/bin/env python2 # # Name: hashbrowns # Auth: Gavin Lloyd <gavinhungry@gmail.com> # Desc: Provides cryptographic hashes with a minimal UI # import os, sys import pygtk, gtk import hashlib import pango import re class Hashbrowns: def __init__(self, filename): self.hash_algs = ['md5', 'sha1', 'sha256', 'sha512', 'whirlpool'] self.filename = filename # attempt to open the file for reading try: self.fd = open(self.filename, 'rb') except IOError: error = 'File is not readable: ' + self.filename; dlg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=error) dlg.run() sys.exit(error) # with the file opened, setup the window window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title('Hashbrowns: ' + os.path.basename(self.filename)) window.connect('key-press-event', lambda w,e: e.keyval == gtk.keysyms.Escape and gtk.main_quit()) window.connect('destroy', self.quit) window.set_position(gtk.WIN_POS_CENTER) window.set_border_width(5) window.set_resizable(False) vbox = gtk.VBox(homogeneous=False, spacing=5) hboxt = gtk.HBox(homogeneous=False, spacing=5) hboxh = gtk.HBox(homogeneous=False, spacing=5) self.hash_box = gtk.Entry() self.hash_box.modify_font(pango.FontDescription('monospace 8')) self.hash_box.set_editable(False) self.hash_box.set_width_chars(48) hboxt.add(self.hash_box) # create button for each hash for alg in sorted(self.hash_algs): try: hashlib.new(alg) except ValueError: sys.stderr.write(alg + ': not supported, skipping\n') else: # uppercase for algorithms that end with a number, eg: SHA512 # capitalized labels for the rest, eg: Whirlpool label = alg.upper() if re.search("\d$", alg) else alg.capitalize() button = gtk.Button(label) button.connect('clicked', self.get_hash, alg) hboxh.add(button) cbButton = gtk.Button() cbLabel = gtk.Label() cbLabel.set_markup('<b>Copy to Clipboard</b>') cbButton.add(cbLabel) cbButton.connect('clicked', self.copy) hboxh.add(cbButton) vbox.add(hboxt) vbox.add(hboxh) window.add(vbox) window.show_all() gtk.main() # hash file and place output in text box def get_hash(self, button, alg): m = hashlib.new(alg) for data in iter(lambda: self.fd.read(128 * m.block_size), ''): m.update(data) self.fd.seek(0) self.hash = m.hexdigest() self.hash_box.set_text(self.hash) # copy to clipboard def copy(self, button): if (len(self.hash) > 0): clipboard.set_text(self.hash) clipboard.store() def quit(self, window): self.fd.close() gtk.main_quit() if __name__ == '__main__': clipboard = gtk.clipboard_get() if len(sys.argv) != 2: sys.exit('usage: ' + sys.argv[0] + ' FILE') hb = Hashbrowns(sys.argv[1])
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 199, 3, 2812, 26, 2631, 3208, 561, 199, 3, 3590, 26, 598, 1214, 262, 491, 3374, 68, 665, 71, 1214, 17695, 10335, 651, 32, 6799, 14, 957, 30, 199, 3, 8055, 67, 26, 21552, 13230, 9770, 14647, 543, 282, 13460, 14041, 199, 3, 199, 199, 646, 747, 12, 984, 199, 646, 1134, 12275, 12, 8116, 199, 646, 8337, 199, 646, 299, 17771, 199, 646, 295, 199, 199, 533, 16101, 3208, 561, 26, 819, 347, 636, 826, 721, 277, 12, 1788, 304, 272, 291, 14, 2227, 63, 31128, 275, 788, 1064, 21, 297, 283, 4835, 17, 297, 283, 4835, 3912, 297, 283, 4835, 7736, 297, 283, 2191, 723, 76, 2293, 418, 272, 291, 14, 1501, 275, 1788, 339, 327, 7427, 370, 1551, 314, 570, 367, 7664, 272, 862, 26, 489, 291, 14, 2592, 275, 1551, 8, 277, 14, 1501, 12, 283, 4848, 358, 272, 871, 5925, 26, 489, 1125, 275, 283, 1173, 365, 440, 12701, 26, 283, 435, 291, 14, 1501, 27, 489, 19406, 275, 8116, 14, 2209, 5619, 8, 466, 29, 12275, 14, 8272, 63, 3170, 12, 2892, 15766, 29, 12275, 14, 13272, 51, 63, 3593, 12, 2892, 1245, 63, 908, 29, 705, 9, 489, 19406, 14, 1065, 342, 489, 984, 14, 2224, 8, 705, 9, 339, 327, 543, 314, 570, 12123, 12, 3272, 314, 4353, 272, 4353, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 272, 4353, 14, 409, 63, 1213, 360, 3476, 3208, 561, 26, 283, 435, 747, 14, 515, 14, 4846, 8, 277, 14, 1501, 430, 272, 4353, 14, 2242, 360, 498, 13, 2915, 13, 1430, 297, 2400, 336, 12, 69, 26, 673, 325, 14, 31217, 508, 8116, 14, 1612, 89, 706, 14, 10260, 436, 8116, 14, 973, 63, 10589, 1012, 272, 4353, 14, 2242, 360, 7237, 297, 291, 14, 10589, 9, 339, 4353, 14, 409, 63, 3124, 8, 12275, 14, 7941, 63, 9263, 63, 17611, 9, 272, 4353, 14, 409, 63, 8665, 63, 2063, 8, 21, 9, 272, 4353, 14, 409, 63, 264, 5946, 461, 8, 797, 9, 339, 20163, 221, 275, 8116, 14, 54, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 272, 394, 656, 400, 275, 8116, 14, 40, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 272, 24126, 72, 275, 8116, 14, 40, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 339, 291, 14, 2227, 63, 1977, 275, 8116, 14, 3900, 342, 272, 291, 14, 2227, 63, 1977, 14, 8951, 63, 4246, 8, 80, 17771, 14, 6986, 5831, 360, 20954, 1695, 1333, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 10820, 8, 797, 9, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 2063, 63, 6574, 8, 2006, 9, 272, 394, 656, 400, 14, 525, 8, 277, 14, 2227, 63, 1977, 9, 339, 327, 1218, 5528, 367, 1924, 2631, 272, 367, 15760, 315, 3355, 8, 277, 14, 2227, 63, 31128, 304, 489, 862, 26, 267, 8337, 14, 1222, 8, 6731, 9, 489, 871, 1722, 26, 267, 984, 14, 3083, 14, 952, 8, 6731, 435, 7596, 440, 3748, 12, 16068, 60, 78, 358, 489, 587, 26, 267, 327, 22681, 367, 18036, 626, 1284, 543, 282, 1329, 12, 11837, 26, 12002, 7736, 267, 327, 17094, 1759, 3628, 367, 314, 4618, 12, 11837, 26, 2816, 723, 76, 2293, 267, 1768, 275, 15760, 14, 4142, 342, 340, 295, 14, 1733, 4582, 68, 11918, 15760, 9, 587, 15760, 14, 18351, 342, 267, 5528, 275, 8116, 14, 4259, 8, 1302, 9, 398, 5528, 14, 2242, 360, 11276, 297, 291, 14, 362, 63, 2227, 12, 15760, 9, 267, 24126, 72, 14, 525, 8, 3887, 9, 339, 7434, 4259, 275, 8116, 14, 4259, 342, 272, 7434, 4314, 275, 8116, 14, 4314, 342, 272, 7434, 4314, 14, 409, 63, 10131, 4827, 66, 30, 5116, 370, 445, 3587, 3576, 1108, 66, 5971, 272, 7434, 4259, 14, 525, 8, 2894, 4314, 9, 339, 7434, 4259, 14, 2242, 360, 11276, 297, 291, 14, 1574, 9, 272, 24126, 72, 14, 525, 8, 2894, 4259, 9, 339, 20163, 14, 525, 8, 72, 656, 400, 9, 272, 20163, 14, 525, 8, 21453, 72, 9, 339, 4353, 14, 525, 8, 19508, 9, 272, 4353, 14, 2384, 63, 452, 342, 272, 8116, 14, 973, 342, 819, 327, 2631, 570, 436, 4192, 1072, 315, 1318, 5689, 523, 347, 664, 63, 2227, 8, 277, 12, 5528, 12, 15760, 304, 272, 333, 275, 8337, 14, 1222, 8, 6731, 9, 339, 367, 666, 315, 2740, 8, 2734, 26, 291, 14, 2592, 14, 739, 8, 3933, 627, 333, 14, 1457, 63, 890, 395, 21019, 489, 333, 14, 873, 8, 576, 9, 339, 291, 14, 2592, 14, 5507, 8, 16, 9, 272, 291, 14, 2227, 275, 333, 14, 11453, 342, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 505, 8, 277, 14, 2227, 9, 819, 327, 1331, 370, 11353, 3576, 523, 347, 1331, 8, 277, 12, 5528, 304, 272, 340, 334, 552, 8, 277, 14, 2227, 9, 690, 378, 304, 489, 11353, 3576, 14, 409, 63, 505, 8, 277, 14, 2227, 9, 489, 11353, 3576, 14, 1617, 342, 819, 347, 17242, 8, 277, 12, 4353, 304, 272, 291, 14, 2592, 14, 1600, 342, 272, 8116, 14, 973, 63, 10589, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 11353, 3576, 275, 8116, 14, 7548, 3576, 63, 362, 342, 819, 340, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 984, 14, 2224, 360, 3807, 26, 283, 435, 984, 14, 3020, 59, 16, 61, 435, 283, 13024, 358, 819, 394, 66, 275, 16101, 3208, 561, 8, 1274, 14, 3020, 59, 17, 566, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 199, 3, 2812, 26, 2631, 3208, 561, 199, 3, 3590, 26, 598, 1214, 262, 491, 3374, 68, 665, 71, 1214, 17695, 10335, 651, 32, 6799, 14, 957, 30, 199, 3, 8055, 67, 26, 21552, 13230, 9770, 14647, 543, 282, 13460, 14041, 199, 3, 199, 199, 646, 747, 12, 984, 199, 646, 1134, 12275, 12, 8116, 199, 646, 8337, 199, 646, 299, 17771, 199, 646, 295, 199, 199, 533, 16101, 3208, 561, 26, 819, 347, 636, 826, 721, 277, 12, 1788, 304, 272, 291, 14, 2227, 63, 31128, 275, 788, 1064, 21, 297, 283, 4835, 17, 297, 283, 4835, 3912, 297, 283, 4835, 7736, 297, 283, 2191, 723, 76, 2293, 418, 272, 291, 14, 1501, 275, 1788, 339, 327, 7427, 370, 1551, 314, 570, 367, 7664, 272, 862, 26, 489, 291, 14, 2592, 275, 1551, 8, 277, 14, 1501, 12, 283, 4848, 358, 272, 871, 5925, 26, 489, 1125, 275, 283, 1173, 365, 440, 12701, 26, 283, 435, 291, 14, 1501, 27, 489, 19406, 275, 8116, 14, 2209, 5619, 8, 466, 29, 12275, 14, 8272, 63, 3170, 12, 2892, 15766, 29, 12275, 14, 13272, 51, 63, 3593, 12, 2892, 1245, 63, 908, 29, 705, 9, 489, 19406, 14, 1065, 342, 489, 984, 14, 2224, 8, 705, 9, 339, 327, 543, 314, 570, 12123, 12, 3272, 314, 4353, 272, 4353, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 272, 4353, 14, 409, 63, 1213, 360, 3476, 3208, 561, 26, 283, 435, 747, 14, 515, 14, 4846, 8, 277, 14, 1501, 430, 272, 4353, 14, 2242, 360, 498, 13, 2915, 13, 1430, 297, 2400, 336, 12, 69, 26, 673, 325, 14, 31217, 508, 8116, 14, 1612, 89, 706, 14, 10260, 436, 8116, 14, 973, 63, 10589, 1012, 272, 4353, 14, 2242, 360, 7237, 297, 291, 14, 10589, 9, 339, 4353, 14, 409, 63, 3124, 8, 12275, 14, 7941, 63, 9263, 63, 17611, 9, 272, 4353, 14, 409, 63, 8665, 63, 2063, 8, 21, 9, 272, 4353, 14, 409, 63, 264, 5946, 461, 8, 797, 9, 339, 20163, 221, 275, 8116, 14, 54, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 272, 394, 656, 400, 275, 8116, 14, 40, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 272, 24126, 72, 275, 8116, 14, 40, 3532, 8, 526, 23748, 29, 797, 12, 19621, 29, 21, 9, 339, 291, 14, 2227, 63, 1977, 275, 8116, 14, 3900, 342, 272, 291, 14, 2227, 63, 1977, 14, 8951, 63, 4246, 8, 80, 17771, 14, 6986, 5831, 360, 20954, 1695, 1333, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 10820, 8, 797, 9, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 2063, 63, 6574, 8, 2006, 9, 272, 394, 656, 400, 14, 525, 8, 277, 14, 2227, 63, 1977, 9, 339, 327, 1218, 5528, 367, 1924, 2631, 272, 367, 15760, 315, 3355, 8, 277, 14, 2227, 63, 31128, 304, 489, 862, 26, 267, 8337, 14, 1222, 8, 6731, 9, 489, 871, 1722, 26, 267, 984, 14, 3083, 14, 952, 8, 6731, 435, 7596, 440, 3748, 12, 16068, 60, 78, 358, 489, 587, 26, 267, 327, 22681, 367, 18036, 626, 1284, 543, 282, 1329, 12, 11837, 26, 12002, 7736, 267, 327, 17094, 1759, 3628, 367, 314, 4618, 12, 11837, 26, 2816, 723, 76, 2293, 267, 1768, 275, 15760, 14, 4142, 342, 340, 295, 14, 1733, 4582, 68, 11918, 15760, 9, 587, 15760, 14, 18351, 342, 267, 5528, 275, 8116, 14, 4259, 8, 1302, 9, 398, 5528, 14, 2242, 360, 11276, 297, 291, 14, 362, 63, 2227, 12, 15760, 9, 267, 24126, 72, 14, 525, 8, 3887, 9, 339, 7434, 4259, 275, 8116, 14, 4259, 342, 272, 7434, 4314, 275, 8116, 14, 4314, 342, 272, 7434, 4314, 14, 409, 63, 10131, 4827, 66, 30, 5116, 370, 445, 3587, 3576, 1108, 66, 5971, 272, 7434, 4259, 14, 525, 8, 2894, 4314, 9, 339, 7434, 4259, 14, 2242, 360, 11276, 297, 291, 14, 1574, 9, 272, 24126, 72, 14, 525, 8, 2894, 4259, 9, 339, 20163, 14, 525, 8, 72, 656, 400, 9, 272, 20163, 14, 525, 8, 21453, 72, 9, 339, 4353, 14, 525, 8, 19508, 9, 272, 4353, 14, 2384, 63, 452, 342, 272, 8116, 14, 973, 342, 819, 327, 2631, 570, 436, 4192, 1072, 315, 1318, 5689, 523, 347, 664, 63, 2227, 8, 277, 12, 5528, 12, 15760, 304, 272, 333, 275, 8337, 14, 1222, 8, 6731, 9, 339, 367, 666, 315, 2740, 8, 2734, 26, 291, 14, 2592, 14, 739, 8, 3933, 627, 333, 14, 1457, 63, 890, 395, 21019, 489, 333, 14, 873, 8, 576, 9, 339, 291, 14, 2592, 14, 5507, 8, 16, 9, 272, 291, 14, 2227, 275, 333, 14, 11453, 342, 272, 291, 14, 2227, 63, 1977, 14, 409, 63, 505, 8, 277, 14, 2227, 9, 819, 327, 1331, 370, 11353, 3576, 523, 347, 1331, 8, 277, 12, 5528, 304, 272, 340, 334, 552, 8, 277, 14, 2227, 9, 690, 378, 304, 489, 11353, 3576, 14, 409, 63, 505, 8, 277, 14, 2227, 9, 489, 11353, 3576, 14, 1617, 342, 819, 347, 17242, 8, 277, 12, 4353, 304, 272, 291, 14, 2592, 14, 1600, 342, 272, 8116, 14, 973, 63, 10589, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 11353, 3576, 275, 8116, 14, 7548, 3576, 63, 362, 342, 819, 340, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 984, 14, 2224, 360, 3807, 26, 283, 435, 984, 14, 3020, 59, 16, 61, 435, 283, 13024, 358, 819, 394, 66, 275, 16101, 3208, 561, 8, 1274, 14, 3020, 59, 17, 566, 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, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
brianjimenez/lightdock
lightdock/pdbutil/PDBIO.py
1
7384
"""Parses Atomic coordinates entries from PDB files""" import math from lightdock.error.lightdock_errors import PDBParsingError, PDBParsingWarning from lightdock.structure.atom import Atom, HetAtom from lightdock.structure.residue import Residue from lightdock.structure.chain import Chain from lightdock.util.logger import LoggingManager log = LoggingManager.get_logger('pdb') def cstrip(string): """Remove unwanted symbols from string.""" return string.strip(' \t\n\r') def read_atom_line(line, line_type='', atoms_to_ignore=[]): """Parses a PDB file line starting with 'ATOM' or 'HETATM'""" element = cstrip(line[76:78]) try: x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) if math.isnan(x) or math.isnan(y) or math.isnan(z): raise Exception() except: raise PDBParsingError("Wrong coordinates in '%s'" % line) try: atom_number = int(line[6:11]) except ValueError: raise PDBParsingError("Wrong atom number in '%s'" % line) atom_name = cstrip(line[12:16]) atom_alternative = cstrip(line[16]) residue_name = cstrip(line[17:21]) chain_id = cstrip(line[21]) residue_ext = line[26] try: residue_number = int(line[22:26]) except ValueError: raise PDBParsingError("Wrong residue number in '%s'" % line) if ('H' in atoms_to_ignore and atom_name[0] == 'H') or atom_name in atoms_to_ignore: raise PDBParsingWarning("Ignored atom %s.%s.%s %s" % (chain_id, residue_name, residue_number, atom_name)) try: occupancy = float(line[54:60]) except: occupancy = 1.0 try: b_factor = float(line[60:66]) except: b_factor = 0.0 if not line_type: line_type = line[0:6].strip() if line_type == 'ATOM': return Atom(atom_number, atom_name, atom_alternative, chain_id, residue_name, residue_number, residue_ext, x, y, z, occupancy, b_factor, element) else: return HetAtom(atom_number, atom_name, atom_alternative, chain_id, residue_name, residue_number, residue_ext, x, y, z, occupancy, b_factor, element) def parse_complex_from_file(input_file_name, atoms_to_ignore=[], verbose=False): """Reads and parses a given input_file_name PDB file. TODO: Check if chain have been already created and insert it into the first one """ lines = file(input_file_name).readlines() atoms = [] residues = [] chains = [] num_models = 0 last_chain_id = '#' last_residue_name = '#' last_residue_number = '#' current_chain = None current_residue = None for line in lines: # Only first model is going to be read if num_models <= 1: line_type = line[0:6].strip() if line_type == "MODEL": num_models += 1 if num_models > 1: log.warning('Multiple models found in %s. Only first model will be used.' % input_file_name) elif line_type == "ATOM" or line_type == "HETATM": try: atom = read_atom_line(line, line_type, atoms_to_ignore) atoms.append(atom) except PDBParsingWarning, warning: if verbose: print warning continue if last_chain_id != atom.chain_id: last_chain_id = atom.chain_id current_chain = Chain(last_chain_id) chains.append(current_chain) if last_residue_name != atom.residue_name or last_residue_number != atom.residue_number: last_residue_name = atom.residue_name last_residue_number = atom.residue_number current_residue = Residue(atom.residue_name, atom.residue_number) residues.append(current_residue) current_chain.residues.append(current_residue) current_residue.atoms.append(atom) # Set backbone and side-chain atoms for residue in residues: residue.set_backbone_and_sidechain() try: residue.check() except Exception, e: log.warning("Possible problem: %s" % str(e)) return atoms, residues, chains def _format_atom_name(atom_name): """Format ATOM name with correct padding""" if len(atom_name) == 4: return atom_name else: return " %s" % atom_name def write_atom_line(atom, atom_coordinates, output): """Writes a PDB file format line to output.""" if atom.__class__.__name__ == "HetAtom": atom_type = 'HETATM' else: atom_type = 'ATOM ' line = "%6s%5d %-4s%-1s%3s%2s%4d%1s %8.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % (atom_type, atom.number, _format_atom_name(atom.name), atom.alternative, atom.residue_name, atom.chain_id, atom.residue_number, atom.residue_ext, atom_coordinates[atom.index][0], atom_coordinates[atom.index][1], atom_coordinates[atom.index][2], atom.occupancy, atom.b_factor, atom.element) output.write(line) def write_pdb_to_file(molecule, output_file_name, atom_coordinates=None, structure_id=0): """Writes a Complex structure to a file in PDB format.""" output_file = file(output_file_name, "a") for atom in molecule.atoms: if atom_coordinates is not None: write_atom_line(atom, atom_coordinates, output_file) else: write_atom_line(atom, molecule.atom_coordinates[structure_id], output_file) output_file.close() def create_pdb_from_points(pdb_file_name, points, atom_type='H'): """Creates a PDB file which contains an atom_type atom for each point in points list. """ pdb_file = open(pdb_file_name, 'w') for index, point in enumerate(points): line = "ATOM %5d %-4s XXX 1 %8.3f%8.3f%8.3f\n" % (index, atom_type, point[0], point[1], point[2]) pdb_file.write(line) pdb_file.close()
gpl-3.0
[ 624, 23400, 18840, 530, 8983, 4811, 687, 30280, 1584, 624, 199, 199, 646, 3473, 199, 504, 10540, 21103, 14, 705, 14, 4040, 21103, 63, 2550, 492, 30280, 17412, 547, 12, 30280, 17412, 3849, 199, 504, 10540, 21103, 14, 6976, 14, 4188, 492, 18840, 12, 869, 386, 12097, 199, 504, 10540, 21103, 14, 6976, 14, 19581, 310, 492, 799, 4148, 310, 199, 504, 10540, 21103, 14, 6976, 14, 4429, 492, 25384, 199, 504, 10540, 21103, 14, 1974, 14, 2921, 492, 19928, 2988, 199, 199, 793, 275, 19928, 2988, 14, 362, 63, 2921, 360, 10511, 358, 421, 199, 318, 286, 1913, 8, 875, 304, 272, 408, 5587, 625, 19361, 6698, 687, 1059, 1041, 272, 372, 1059, 14, 1913, 360, 971, 84, 60, 78, 60, 82, 358, 421, 199, 318, 1586, 63, 4188, 63, 604, 8, 604, 12, 1004, 63, 466, 4581, 14503, 63, 475, 63, 4247, 17894, 272, 408, 23400, 282, 30280, 570, 1004, 6617, 543, 283, 22479, 7, 503, 283, 40, 775, 619, 45, 26555, 272, 1819, 275, 286, 1913, 8, 604, 59, 2114, 26, 2277, 566, 272, 862, 26, 267, 671, 275, 2069, 8, 604, 59, 1216, 26, 1703, 566, 267, 612, 275, 2069, 8, 604, 59, 1703, 26, 2466, 566, 267, 1315, 275, 2069, 8, 604, 59, 2466, 26, 1477, 566, 2728, 340, 3473, 14, 12936, 8, 88, 9, 503, 3473, 14, 12936, 8, 89, 9, 503, 3473, 14, 12936, 8, 90, 304, 288, 746, 2186, 342, 272, 871, 26, 267, 746, 30280, 17412, 547, 480, 14858, 8983, 315, 1543, 83, 4065, 450, 1004, 9, 339, 862, 26, 267, 6222, 63, 1955, 275, 1109, 8, 604, 59, 22, 26, 845, 566, 272, 871, 1722, 26, 267, 746, 30280, 17412, 547, 480, 14858, 6222, 1329, 315, 1543, 83, 4065, 450, 1004, 9, 2286, 6222, 63, 354, 275, 286, 1913, 8, 604, 59, 713, 26, 975, 566, 272, 6222, 63, 19389, 275, 286, 1913, 8, 604, 59, 975, 566, 272, 23185, 310, 63, 354, 275, 286, 1913, 8, 604, 59, 1196, 26, 2025, 566, 272, 6036, 63, 344, 275, 286, 1913, 8, 604, 59, 2025, 566, 272, 23185, 310, 63, 832, 275, 1004, 59, 1479, 61, 2286, 862, 26, 267, 23185, 310, 63, 1955, 275, 1109, 8, 604, 59, 1081, 26, 1479, 566, 272, 871, 1722, 26, 267, 746, 30280, 17412, 547, 480, 14858, 23185, 310, 1329, 315, 1543, 83, 4065, 450, 1004, 9, 2286, 340, 661, 40, 7, 315, 14503, 63, 475, 63, 4247, 436, 6222, 63, 354, 59, 16, 61, 508, 283, 40, 358, 503, 6222, 63, 354, 315, 14503, 63, 475, 63, 4247, 26, 267, 746, 30280, 17412, 3849, 480, 19399, 2908, 6222, 450, 83, 4111, 83, 4111, 83, 450, 83, 2, 450, 334, 4429, 63, 344, 12, 221, 16854, 23185, 310, 63, 354, 12, 221, 16854, 23185, 310, 63, 1955, 12, 221, 16854, 6222, 63, 354, 430, 339, 862, 26, 267, 26182, 9844, 275, 2069, 8, 604, 59, 1477, 26, 2259, 566, 272, 871, 26, 267, 26182, 9844, 275, 413, 14, 16, 5493, 862, 26, 267, 330, 63, 4778, 275, 2069, 8, 604, 59, 2259, 26, 1272, 566, 272, 871, 26, 267, 330, 63, 4778, 275, 378, 14, 16, 2286, 340, 440, 1004, 63, 466, 26, 267, 1004, 63, 466, 275, 1004, 59, 16, 26, 22, 1055, 1913, 342, 2286, 340, 1004, 63, 466, 508, 283, 22479, 356, 267, 372, 18840, 8, 4188, 63, 1955, 12, 6222, 63, 354, 12, 6222, 63, 19389, 12, 6036, 63, 344, 12, 490, 23185, 310, 63, 354, 12, 23185, 310, 63, 1955, 12, 23185, 310, 63, 832, 12, 15324, 671, 12, 612, 12, 1315, 12, 26182, 9844, 12, 330, 63, 4778, 12, 1819, 9, 272, 587, 26, 267, 372, 869, 386, 12097, 8, 4188, 63, 1955, 12, 6222, 63, 354, 12, 6222, 63, 19389, 12, 6036, 63, 344, 12, 2432, 23185, 310, 63, 354, 12, 23185, 310, 63, 1955, 12, 23185, 310, 63, 832, 12, 221, 2432, 671, 12, 612, 12, 1315, 12, 26182, 9844, 12, 330, 63, 4778, 12, 1819, 9, 421, 199, 318, 2198, 63, 5254, 63, 504, 63, 493, 8, 1210, 63, 493, 63, 354, 12, 14503, 63, 475, 63, 4247, 6034, 3376, 29, 797, 304, 272, 408, 23614, 436, 19953, 282, 1627, 1324, 63, 493, 63, 354, 30280, 570, 14, 2286, 3254, 26, 2670, 340, 6036, 1172, 2757, 2575, 2737, 436, 5518, 652, 1901, 314, 1642, 1373, 272, 408, 272, 2385, 275, 570, 8, 1210, 63, 493, 63, 354, 680, 9684, 342, 272, 14503, 275, 942, 272, 23185, 10138, 275, 942, 272, 30640, 275, 942, 272, 1967, 63, 992, 275, 378, 272, 2061, 63, 4429, 63, 344, 275, 19619, 272, 2061, 63, 19581, 310, 63, 354, 275, 19619, 272, 2061, 63, 19581, 310, 63, 1955, 275, 19619, 272, 1453, 63, 4429, 275, 488, 272, 1453, 63, 19581, 310, 275, 488, 272, 367, 1004, 315, 2385, 26, 267, 327, 5972, 1642, 1402, 365, 9995, 370, 506, 1586, 267, 340, 1967, 63, 992, 2695, 413, 26, 288, 1004, 63, 466, 275, 1004, 59, 16, 26, 22, 1055, 1913, 342, 288, 340, 1004, 63, 466, 508, 298, 11429, 582, 355, 1967, 63, 992, 847, 413, 355, 340, 1967, 63, 992, 690, 413, 26, 490, 943, 14, 3764, 360, 8433, 1709, 1911, 315, 450, 83, 14, 5972, 1642, 1402, 911, 506, 1202, 3530, 450, 1324, 63, 493, 63, 354, 9, 288, 916, 1004, 63, 466, 508, 298, 22479, 2, 503, 1004, 63, 466, 508, 298, 40, 775, 619, 45, 582, 355, 862, 26, 490, 6222, 275, 1586, 63, 4188, 63, 604, 8, 604, 12, 1004, 63, 466, 12, 14503, 63, 475, 63, 4247, 9, 490, 14503, 14, 740, 8, 4188, 9, 355, 871, 30280, 17412, 3849, 12, 5721, 26, 490, 340, 3376, 26, 717, 870, 5721, 490, 1980, 2234, 340, 2061, 63, 4429, 63, 344, 1137, 6222, 14, 4429, 63, 344, 26, 490, 2061, 63, 4429, 63, 344, 275, 6222, 14, 4429, 63, 344, 490, 1453, 63, 4429, 275, 25384, 8, 2019, 63, 4429, 63, 344, 9, 490, 30640, 14, 740, 8, 1818, 63, 4429, 9, 355, 340, 2061, 63, 19581, 310, 63, 354, 1137, 6222, 14, 19581, 310, 63, 354, 503, 2061, 63, 19581, 310, 63, 1955, 1137, 6222, 14, 19581, 310, 63, 1955 ]
[ 23400, 18840, 530, 8983, 4811, 687, 30280, 1584, 624, 199, 199, 646, 3473, 199, 504, 10540, 21103, 14, 705, 14, 4040, 21103, 63, 2550, 492, 30280, 17412, 547, 12, 30280, 17412, 3849, 199, 504, 10540, 21103, 14, 6976, 14, 4188, 492, 18840, 12, 869, 386, 12097, 199, 504, 10540, 21103, 14, 6976, 14, 19581, 310, 492, 799, 4148, 310, 199, 504, 10540, 21103, 14, 6976, 14, 4429, 492, 25384, 199, 504, 10540, 21103, 14, 1974, 14, 2921, 492, 19928, 2988, 199, 199, 793, 275, 19928, 2988, 14, 362, 63, 2921, 360, 10511, 358, 421, 199, 318, 286, 1913, 8, 875, 304, 272, 408, 5587, 625, 19361, 6698, 687, 1059, 1041, 272, 372, 1059, 14, 1913, 360, 971, 84, 60, 78, 60, 82, 358, 421, 199, 318, 1586, 63, 4188, 63, 604, 8, 604, 12, 1004, 63, 466, 4581, 14503, 63, 475, 63, 4247, 17894, 272, 408, 23400, 282, 30280, 570, 1004, 6617, 543, 283, 22479, 7, 503, 283, 40, 775, 619, 45, 26555, 272, 1819, 275, 286, 1913, 8, 604, 59, 2114, 26, 2277, 566, 272, 862, 26, 267, 671, 275, 2069, 8, 604, 59, 1216, 26, 1703, 566, 267, 612, 275, 2069, 8, 604, 59, 1703, 26, 2466, 566, 267, 1315, 275, 2069, 8, 604, 59, 2466, 26, 1477, 566, 2728, 340, 3473, 14, 12936, 8, 88, 9, 503, 3473, 14, 12936, 8, 89, 9, 503, 3473, 14, 12936, 8, 90, 304, 288, 746, 2186, 342, 272, 871, 26, 267, 746, 30280, 17412, 547, 480, 14858, 8983, 315, 1543, 83, 4065, 450, 1004, 9, 339, 862, 26, 267, 6222, 63, 1955, 275, 1109, 8, 604, 59, 22, 26, 845, 566, 272, 871, 1722, 26, 267, 746, 30280, 17412, 547, 480, 14858, 6222, 1329, 315, 1543, 83, 4065, 450, 1004, 9, 2286, 6222, 63, 354, 275, 286, 1913, 8, 604, 59, 713, 26, 975, 566, 272, 6222, 63, 19389, 275, 286, 1913, 8, 604, 59, 975, 566, 272, 23185, 310, 63, 354, 275, 286, 1913, 8, 604, 59, 1196, 26, 2025, 566, 272, 6036, 63, 344, 275, 286, 1913, 8, 604, 59, 2025, 566, 272, 23185, 310, 63, 832, 275, 1004, 59, 1479, 61, 2286, 862, 26, 267, 23185, 310, 63, 1955, 275, 1109, 8, 604, 59, 1081, 26, 1479, 566, 272, 871, 1722, 26, 267, 746, 30280, 17412, 547, 480, 14858, 23185, 310, 1329, 315, 1543, 83, 4065, 450, 1004, 9, 2286, 340, 661, 40, 7, 315, 14503, 63, 475, 63, 4247, 436, 6222, 63, 354, 59, 16, 61, 508, 283, 40, 358, 503, 6222, 63, 354, 315, 14503, 63, 475, 63, 4247, 26, 267, 746, 30280, 17412, 3849, 480, 19399, 2908, 6222, 450, 83, 4111, 83, 4111, 83, 450, 83, 2, 450, 334, 4429, 63, 344, 12, 221, 16854, 23185, 310, 63, 354, 12, 221, 16854, 23185, 310, 63, 1955, 12, 221, 16854, 6222, 63, 354, 430, 339, 862, 26, 267, 26182, 9844, 275, 2069, 8, 604, 59, 1477, 26, 2259, 566, 272, 871, 26, 267, 26182, 9844, 275, 413, 14, 16, 5493, 862, 26, 267, 330, 63, 4778, 275, 2069, 8, 604, 59, 2259, 26, 1272, 566, 272, 871, 26, 267, 330, 63, 4778, 275, 378, 14, 16, 2286, 340, 440, 1004, 63, 466, 26, 267, 1004, 63, 466, 275, 1004, 59, 16, 26, 22, 1055, 1913, 342, 2286, 340, 1004, 63, 466, 508, 283, 22479, 356, 267, 372, 18840, 8, 4188, 63, 1955, 12, 6222, 63, 354, 12, 6222, 63, 19389, 12, 6036, 63, 344, 12, 490, 23185, 310, 63, 354, 12, 23185, 310, 63, 1955, 12, 23185, 310, 63, 832, 12, 15324, 671, 12, 612, 12, 1315, 12, 26182, 9844, 12, 330, 63, 4778, 12, 1819, 9, 272, 587, 26, 267, 372, 869, 386, 12097, 8, 4188, 63, 1955, 12, 6222, 63, 354, 12, 6222, 63, 19389, 12, 6036, 63, 344, 12, 2432, 23185, 310, 63, 354, 12, 23185, 310, 63, 1955, 12, 23185, 310, 63, 832, 12, 221, 2432, 671, 12, 612, 12, 1315, 12, 26182, 9844, 12, 330, 63, 4778, 12, 1819, 9, 421, 199, 318, 2198, 63, 5254, 63, 504, 63, 493, 8, 1210, 63, 493, 63, 354, 12, 14503, 63, 475, 63, 4247, 6034, 3376, 29, 797, 304, 272, 408, 23614, 436, 19953, 282, 1627, 1324, 63, 493, 63, 354, 30280, 570, 14, 2286, 3254, 26, 2670, 340, 6036, 1172, 2757, 2575, 2737, 436, 5518, 652, 1901, 314, 1642, 1373, 272, 408, 272, 2385, 275, 570, 8, 1210, 63, 493, 63, 354, 680, 9684, 342, 272, 14503, 275, 942, 272, 23185, 10138, 275, 942, 272, 30640, 275, 942, 272, 1967, 63, 992, 275, 378, 272, 2061, 63, 4429, 63, 344, 275, 19619, 272, 2061, 63, 19581, 310, 63, 354, 275, 19619, 272, 2061, 63, 19581, 310, 63, 1955, 275, 19619, 272, 1453, 63, 4429, 275, 488, 272, 1453, 63, 19581, 310, 275, 488, 272, 367, 1004, 315, 2385, 26, 267, 327, 5972, 1642, 1402, 365, 9995, 370, 506, 1586, 267, 340, 1967, 63, 992, 2695, 413, 26, 288, 1004, 63, 466, 275, 1004, 59, 16, 26, 22, 1055, 1913, 342, 288, 340, 1004, 63, 466, 508, 298, 11429, 582, 355, 1967, 63, 992, 847, 413, 355, 340, 1967, 63, 992, 690, 413, 26, 490, 943, 14, 3764, 360, 8433, 1709, 1911, 315, 450, 83, 14, 5972, 1642, 1402, 911, 506, 1202, 3530, 450, 1324, 63, 493, 63, 354, 9, 288, 916, 1004, 63, 466, 508, 298, 22479, 2, 503, 1004, 63, 466, 508, 298, 40, 775, 619, 45, 582, 355, 862, 26, 490, 6222, 275, 1586, 63, 4188, 63, 604, 8, 604, 12, 1004, 63, 466, 12, 14503, 63, 475, 63, 4247, 9, 490, 14503, 14, 740, 8, 4188, 9, 355, 871, 30280, 17412, 3849, 12, 5721, 26, 490, 340, 3376, 26, 717, 870, 5721, 490, 1980, 2234, 340, 2061, 63, 4429, 63, 344, 1137, 6222, 14, 4429, 63, 344, 26, 490, 2061, 63, 4429, 63, 344, 275, 6222, 14, 4429, 63, 344,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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 ]
kuwa32/chainer
tests/functions_tests/test_nonparameterized_linear.py
7
2368
import unittest import numpy import chainer from chainer import cuda from chainer import functions from chainer import gradient_check from chainer import testing from chainer.testing import attr from chainer.testing import condition if cuda.available: cuda.init() class TestNonparameterizedLinear(unittest.TestCase): def setUp(self): self.W = numpy.random.uniform( -1, 1, (2, 3)).astype(numpy.float32) self.b = numpy.random.uniform( -1, 1, 2).astype(numpy.float32) self.x = numpy.random.uniform(-1, 1, (4, 3)).astype(numpy.float32) self.gy = numpy.random.uniform(-1, 1, (4, 2)).astype(numpy.float32) self.y = self.x.dot(self.W.T) + self.b def check_forward(self, x_data, W_data, b_data, y_expect): x = chainer.Variable(x_data) W = chainer.Variable(W_data) b = chainer.Variable(b_data) y = functions.linear(x, W, b) gradient_check.assert_allclose(y_expect, y.data) @condition.retry(3) def test_forward_cpu(self): self.check_forward(self.x, self.W, self.b, self.x.dot(self.W.T) + self.b) @attr.gpu @condition.retry(3) def test_forward_gpu(self): self.check_forward( cuda.to_gpu(self.x), cuda.to_gpu(self.W), cuda.to_gpu(self.b), cuda.to_gpu(self.x.dot(self.W.T) + self.b)) def check_backward(self, x_data, W_data, b_data, y_grad): x = chainer.Variable(x_data) W = chainer.Variable(W_data) b = chainer.Variable(b_data) y = functions.linear(x, W, b) y.grad = y_grad y.backward() func = y.creator f = lambda: func.forward((x.data, W.data, b.data)) gx, gW, gb = gradient_check.numerical_grad( f, (x.data, W.data, b.data), (y.grad,), eps=1e-2) gradient_check.assert_allclose(gx, x.grad) gradient_check.assert_allclose(gW, W.grad) gradient_check.assert_allclose(gb, b.grad) @condition.retry(3) def test_backward_cpu(self): self.check_backward(self.x, self.W, self.b, self.gy) @attr.gpu @condition.retry(3) def test_backward_gpu(self): self.check_backward(cuda.to_gpu(self.x), cuda.to_gpu(self.W), cuda.to_gpu(self.b), cuda.to_gpu(self.gy)) testing.run_module(__name__, __file__)
mit
[ 646, 2882, 199, 199, 646, 2680, 199, 199, 646, 20333, 199, 504, 20333, 492, 23123, 199, 504, 20333, 492, 3423, 199, 504, 20333, 492, 6709, 63, 1074, 199, 504, 20333, 492, 5343, 199, 504, 20333, 14, 4776, 492, 1921, 199, 504, 20333, 14, 4776, 492, 5558, 421, 199, 692, 23123, 14, 4561, 26, 272, 23123, 14, 826, 342, 421, 199, 533, 1379, 6932, 25000, 10608, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 55, 275, 2680, 14, 2355, 14, 8830, 8, 288, 446, 17, 12, 413, 12, 334, 18, 12, 650, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 66, 275, 2680, 14, 2355, 14, 8830, 8, 288, 446, 17, 12, 413, 12, 499, 680, 6041, 8, 4714, 14, 1609, 708, 9, 398, 291, 14, 88, 275, 2680, 14, 2355, 14, 8830, 2801, 17, 12, 413, 12, 334, 20, 12, 650, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 4312, 275, 2680, 14, 2355, 14, 8830, 2801, 17, 12, 413, 12, 334, 20, 12, 499, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 89, 275, 291, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 339, 347, 1104, 63, 6688, 8, 277, 12, 671, 63, 576, 12, 644, 63, 576, 12, 330, 63, 576, 12, 612, 63, 4921, 304, 267, 671, 275, 20333, 14, 2773, 8, 88, 63, 576, 9, 267, 644, 275, 20333, 14, 2773, 8, 55, 63, 576, 9, 267, 330, 275, 20333, 14, 2773, 8, 66, 63, 576, 9, 267, 612, 275, 3423, 14, 6676, 8, 88, 12, 644, 12, 330, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 89, 63, 4921, 12, 612, 14, 576, 9, 339, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 6688, 63, 3541, 8, 277, 304, 267, 291, 14, 1074, 63, 6688, 8, 277, 14, 88, 12, 291, 14, 55, 12, 291, 14, 66, 12, 2574, 291, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 9, 339, 768, 962, 14, 6477, 272, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 6688, 63, 6477, 8, 277, 304, 267, 291, 14, 1074, 63, 6688, 8, 288, 23123, 14, 475, 63, 6477, 8, 277, 14, 88, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 55, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 66, 395, 288, 23123, 14, 475, 63, 6477, 8, 277, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 430, 339, 347, 1104, 63, 15457, 8, 277, 12, 671, 63, 576, 12, 644, 63, 576, 12, 330, 63, 576, 12, 612, 63, 6017, 304, 267, 671, 275, 20333, 14, 2773, 8, 88, 63, 576, 9, 267, 644, 275, 20333, 14, 2773, 8, 55, 63, 576, 9, 267, 330, 275, 20333, 14, 2773, 8, 66, 63, 576, 9, 267, 612, 275, 3423, 14, 6676, 8, 88, 12, 644, 12, 330, 9, 267, 612, 14, 6017, 275, 612, 63, 6017, 267, 612, 14, 15457, 342, 398, 2562, 275, 612, 14, 9986, 267, 289, 275, 2400, 26, 2562, 14, 6688, 1332, 88, 14, 576, 12, 644, 14, 576, 12, 330, 14, 576, 430, 267, 486, 88, 12, 486, 55, 12, 25411, 275, 6709, 63, 1074, 14, 10563, 8825, 63, 6017, 8, 288, 289, 12, 334, 88, 14, 576, 12, 644, 14, 576, 12, 330, 14, 576, 395, 334, 89, 14, 6017, 4706, 10245, 29, 17, 69, 13, 18, 9, 398, 6709, 63, 1074, 14, 479, 63, 7520, 8, 20777, 12, 671, 14, 6017, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 71, 55, 12, 644, 14, 6017, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 4908, 12, 330, 14, 6017, 9, 339, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 15457, 63, 3541, 8, 277, 304, 267, 291, 14, 1074, 63, 15457, 8, 277, 14, 88, 12, 291, 14, 55, 12, 291, 14, 66, 12, 291, 14, 4312, 9, 339, 768, 962, 14, 6477, 272, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 15457, 63, 6477, 8, 277, 304, 267, 291, 14, 1074, 63, 15457, 8, 16309, 14, 475, 63, 6477, 8, 277, 14, 88, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 55, 395, 1169, 23123, 14, 475, 63, 6477, 8, 277, 14, 66, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 4312, 430, 421, 199, 4776, 14, 1065, 63, 578, 3460, 354, 3108, 636, 493, 3368, 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 ]
[ 2882, 199, 199, 646, 2680, 199, 199, 646, 20333, 199, 504, 20333, 492, 23123, 199, 504, 20333, 492, 3423, 199, 504, 20333, 492, 6709, 63, 1074, 199, 504, 20333, 492, 5343, 199, 504, 20333, 14, 4776, 492, 1921, 199, 504, 20333, 14, 4776, 492, 5558, 421, 199, 692, 23123, 14, 4561, 26, 272, 23123, 14, 826, 342, 421, 199, 533, 1379, 6932, 25000, 10608, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 55, 275, 2680, 14, 2355, 14, 8830, 8, 288, 446, 17, 12, 413, 12, 334, 18, 12, 650, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 66, 275, 2680, 14, 2355, 14, 8830, 8, 288, 446, 17, 12, 413, 12, 499, 680, 6041, 8, 4714, 14, 1609, 708, 9, 398, 291, 14, 88, 275, 2680, 14, 2355, 14, 8830, 2801, 17, 12, 413, 12, 334, 20, 12, 650, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 4312, 275, 2680, 14, 2355, 14, 8830, 2801, 17, 12, 413, 12, 334, 20, 12, 499, 4992, 6041, 8, 4714, 14, 1609, 708, 9, 267, 291, 14, 89, 275, 291, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 339, 347, 1104, 63, 6688, 8, 277, 12, 671, 63, 576, 12, 644, 63, 576, 12, 330, 63, 576, 12, 612, 63, 4921, 304, 267, 671, 275, 20333, 14, 2773, 8, 88, 63, 576, 9, 267, 644, 275, 20333, 14, 2773, 8, 55, 63, 576, 9, 267, 330, 275, 20333, 14, 2773, 8, 66, 63, 576, 9, 267, 612, 275, 3423, 14, 6676, 8, 88, 12, 644, 12, 330, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 89, 63, 4921, 12, 612, 14, 576, 9, 339, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 6688, 63, 3541, 8, 277, 304, 267, 291, 14, 1074, 63, 6688, 8, 277, 14, 88, 12, 291, 14, 55, 12, 291, 14, 66, 12, 2574, 291, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 9, 339, 768, 962, 14, 6477, 272, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 6688, 63, 6477, 8, 277, 304, 267, 291, 14, 1074, 63, 6688, 8, 288, 23123, 14, 475, 63, 6477, 8, 277, 14, 88, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 55, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 66, 395, 288, 23123, 14, 475, 63, 6477, 8, 277, 14, 88, 14, 3287, 8, 277, 14, 55, 14, 52, 9, 435, 291, 14, 66, 430, 339, 347, 1104, 63, 15457, 8, 277, 12, 671, 63, 576, 12, 644, 63, 576, 12, 330, 63, 576, 12, 612, 63, 6017, 304, 267, 671, 275, 20333, 14, 2773, 8, 88, 63, 576, 9, 267, 644, 275, 20333, 14, 2773, 8, 55, 63, 576, 9, 267, 330, 275, 20333, 14, 2773, 8, 66, 63, 576, 9, 267, 612, 275, 3423, 14, 6676, 8, 88, 12, 644, 12, 330, 9, 267, 612, 14, 6017, 275, 612, 63, 6017, 267, 612, 14, 15457, 342, 398, 2562, 275, 612, 14, 9986, 267, 289, 275, 2400, 26, 2562, 14, 6688, 1332, 88, 14, 576, 12, 644, 14, 576, 12, 330, 14, 576, 430, 267, 486, 88, 12, 486, 55, 12, 25411, 275, 6709, 63, 1074, 14, 10563, 8825, 63, 6017, 8, 288, 289, 12, 334, 88, 14, 576, 12, 644, 14, 576, 12, 330, 14, 576, 395, 334, 89, 14, 6017, 4706, 10245, 29, 17, 69, 13, 18, 9, 398, 6709, 63, 1074, 14, 479, 63, 7520, 8, 20777, 12, 671, 14, 6017, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 71, 55, 12, 644, 14, 6017, 9, 267, 6709, 63, 1074, 14, 479, 63, 7520, 8, 4908, 12, 330, 14, 6017, 9, 339, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 15457, 63, 3541, 8, 277, 304, 267, 291, 14, 1074, 63, 15457, 8, 277, 14, 88, 12, 291, 14, 55, 12, 291, 14, 66, 12, 291, 14, 4312, 9, 339, 768, 962, 14, 6477, 272, 768, 5394, 14, 7154, 8, 19, 9, 272, 347, 511, 63, 15457, 63, 6477, 8, 277, 304, 267, 291, 14, 1074, 63, 15457, 8, 16309, 14, 475, 63, 6477, 8, 277, 14, 88, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 55, 395, 1169, 23123, 14, 475, 63, 6477, 8, 277, 14, 66, 395, 23123, 14, 475, 63, 6477, 8, 277, 14, 4312, 430, 421, 199, 4776, 14, 1065, 63, 578, 3460, 354, 3108, 636, 493, 3368, 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, 0 ]
[ 1, 1, 1, 1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o
addons/base_action_rule/tests/base_action_rule_test.py
395
7455
from openerp import SUPERUSER_ID from openerp.tests import common from .. import test_models class base_action_rule_test(common.TransactionCase): def setUp(self): """*****setUp*****""" super(base_action_rule_test, self).setUp() cr, uid = self.cr, self.uid self.demo = self.registry('ir.model.data').get_object(cr, uid, 'base', 'user_demo').id self.admin = SUPERUSER_ID self.model = self.registry('base.action.rule.lead.test') self.base_action_rule = self.registry('base.action.rule') def create_filter_done(self, cr, uid, context=None): filter_pool = self.registry('ir.filters') return filter_pool.create(cr, uid, { 'name': "Lead is in done state", 'is_default': False, 'model_id': 'base.action.rule.lead.test', 'domain': "[('state','=','done')]", }, context=context) def create_filter_draft(self, cr, uid, context=None): filter_pool = self.registry('ir.filters') return filter_pool.create(cr, uid, { 'name': "Lead is in draft state", 'is_default': False, 'model_id': "base.action.rule.lead.test", 'domain' : "[('state','=','draft')]", }, context=context) def create_lead_test_1(self, cr, uid, context=None): """ Create a new lead_test """ return self.model.create(cr, uid, { 'name': "Lead Test 1", 'user_id': self.admin, }, context=context) def create_rule(self, cr, uid, kind, filter_id=False, filter_pre_id=False, context=None): """ The "Rule 1" says that when a lead goes to the 'draft' state, the responsible for that lead changes to user "demo" """ return self.base_action_rule.create(cr,uid,{ 'name': "Rule 1", 'model_id': self.registry('ir.model').search(cr, uid, [('model','=','base.action.rule.lead.test')], context=context)[0], 'kind': kind, 'filter_pre_id': filter_pre_id, 'filter_id': filter_id, 'act_user_id': self.demo, }, context=context) def delete_rules(self, cr, uid, context=None): """ delete all the rules on model 'base.action.rule.lead.test' """ action_ids = self.base_action_rule.search(cr, uid, [('model', '=', self.model._name)], context=context) return self.base_action_rule.unlink(cr, uid, action_ids, context=context) def test_00_check_to_state_draft_pre(self): """ Check that a new record (with state = draft) doesn't change its responsible when there is a precondition filter which check that the state is draft. """ cr, uid = self.cr, self.uid filter_draft = self.create_filter_draft(cr, uid) self.create_rule(cr, uid, 'on_write', filter_pre_id=filter_draft) new_lead_id = self.create_lead_test_1(cr, uid) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'draft') self.assertEquals(new_lead.user_id.id, self.admin) self.delete_rules(cr, uid) def test_01_check_to_state_draft_post(self): """ Check that a new record changes its responsible when there is a postcondition filter which check that the state is draft. """ cr, uid = self.cr, self.uid filter_draft = self.create_filter_draft(cr, uid) self.create_rule(cr, uid, 'on_create') new_lead_id = self.create_lead_test_1(cr, uid) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'draft') self.assertEquals(new_lead.user_id.id, self.demo) self.delete_rules(cr, uid) def test_02_check_from_draft_to_done_with_steps(self): """ A new record will be created and will goes from draft to done state via the other states (open, pending and cancel) We will create a rule that says in precondition that the record must be in the "draft" state while a postcondition filter says that the record will be done. If the state goes from 'draft' to 'done' the responsible will change. If those two conditions aren't verified, the responsible will stay the same The responsible in that test will never change """ cr, uid = self.cr, self.uid filter_draft = self.create_filter_draft(cr, uid) filter_done = self.create_filter_done(cr, uid) self.create_rule(cr, uid, 'on_write', filter_pre_id=filter_draft, filter_id=filter_done) new_lead_id = self.create_lead_test_1(cr, uid) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'draft') self.assertEquals(new_lead.user_id.id, self.admin) """ change the state of new_lead to open and check that responsible doen't change""" new_lead.write({'state': 'open'}) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'open') self.assertEquals(new_lead.user_id.id, self.admin) """ change the state of new_lead to pending and check that responsible doen't change""" new_lead.write({'state': 'pending'}) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'pending') self.assertEquals(new_lead.user_id.id, self.admin) """ change the state of new_lead to cancel and check that responsible doen't change""" new_lead.write({'state': 'cancel'}) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'cancel') self.assertEquals(new_lead.user_id.id, self.admin) """ change the state of new_lead to done and check that responsible doen't change """ new_lead.write({'state': 'done'}) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'done') self.assertEquals(new_lead.user_id.id, self.admin) self.delete_rules(cr, uid) def test_02_check_from_draft_to_done_without_steps(self): """ A new record will be created and will goes from draft to done in one operation We will create a rule that says in precondition that the record must be in the "draft" state while a postcondition filter says that the record will be done. If the state goes from 'draft' to 'done' the responsible will change. If those two conditions aren't verified, the responsible will stay the same The responsible in that test will change to user "demo" """ cr, uid = self.cr, self.uid filter_draft = self.create_filter_draft(cr, uid) filter_done = self.create_filter_done(cr, uid) self.create_rule(cr, uid, 'on_write', filter_pre_id=filter_draft, filter_id=filter_done) new_lead_id = self.create_lead_test_1(cr, uid) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'draft') self.assertEquals(new_lead.user_id.id, self.admin) """ change the state of new_lead to done and check that responsible change to Demo_user""" new_lead.write({'state': 'done'}) new_lead = self.model.browse(cr, uid, new_lead_id) self.assertEquals(new_lead.state, 'done') self.assertEquals(new_lead.user_id.id, self.demo) self.delete_rules(cr, uid)
agpl-3.0
[ 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 2508, 492, 511, 63, 992, 199, 199, 533, 1300, 63, 1287, 63, 2200, 63, 396, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 408, 1116, 10, 5996, 1116, 10, 624, 267, 1613, 8, 1095, 63, 1287, 63, 2200, 63, 396, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 8768, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 751, 63, 8768, 1959, 344, 267, 291, 14, 2113, 275, 12824, 63, 998, 267, 291, 14, 1238, 275, 291, 14, 5189, 360, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 358, 267, 291, 14, 1095, 63, 1287, 63, 2200, 275, 291, 14, 5189, 360, 1095, 14, 1287, 14, 2200, 358, 339, 347, 1218, 63, 1541, 63, 4456, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2457, 63, 2293, 275, 291, 14, 5189, 360, 723, 14, 4273, 358, 267, 372, 2457, 63, 2293, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 365, 315, 4224, 1174, 401, 288, 283, 374, 63, 885, 356, 756, 12, 288, 283, 1238, 63, 344, 356, 283, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 297, 288, 283, 2261, 356, 7369, 360, 929, 1673, 29511, 4456, 5440, 401, 267, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 1541, 63, 7185, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2457, 63, 2293, 275, 291, 14, 5189, 360, 723, 14, 4273, 358, 267, 372, 2457, 63, 2293, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 365, 315, 11872, 1174, 401, 288, 283, 374, 63, 885, 356, 756, 12, 288, 283, 1238, 63, 344, 356, 298, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 401, 288, 283, 2261, 7, 520, 7369, 360, 929, 1673, 29511, 7185, 5440, 401, 288, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 13799, 63, 396, 63, 17, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 288, 2790, 282, 892, 12690, 63, 396, 267, 408, 267, 372, 291, 14, 1238, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 1379, 413, 401, 288, 283, 751, 63, 344, 356, 291, 14, 2113, 12, 288, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 2200, 8, 277, 12, 2467, 12, 1747, 12, 4928, 12, 2457, 63, 344, 29, 797, 12, 2457, 63, 657, 63, 344, 29, 797, 12, 1067, 29, 403, 304, 267, 408, 288, 710, 298, 5065, 413, 2, 20065, 626, 1380, 282, 12690, 13538, 370, 314, 283, 7185, 7, 1174, 12, 314, 17845, 367, 626, 12690, 4493, 370, 922, 298, 8768, 2, 267, 408, 267, 372, 291, 14, 1095, 63, 1287, 63, 2200, 14, 981, 8, 1556, 12, 1535, 12, 91, 288, 283, 354, 356, 298, 5065, 413, 401, 288, 283, 1238, 63, 344, 356, 291, 14, 5189, 360, 723, 14, 1238, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 1673, 29511, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 2665, 1067, 29, 1100, 2788, 16, 467, 288, 283, 5091, 356, 4928, 12, 288, 283, 1541, 63, 657, 63, 344, 356, 2457, 63, 657, 63, 344, 12, 288, 283, 1541, 63, 344, 356, 2457, 63, 344, 12, 288, 283, 2442, 63, 751, 63, 344, 356, 291, 14, 8768, 12, 288, 1660, 1067, 29, 1100, 9, 339, 347, 3145, 63, 4423, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 3145, 1006, 314, 4713, 641, 1402, 283, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 7, 408, 267, 1595, 63, 1580, 275, 291, 14, 1095, 63, 1287, 63, 2200, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 291, 14, 1238, 423, 354, 4360, 1067, 29, 1100, 9, 267, 372, 291, 14, 1095, 63, 1287, 63, 2200, 14, 7162, 8, 1556, 12, 1747, 12, 1595, 63, 1580, 12, 1067, 29, 1100, 9, 339, 347, 511, 63, 383, 63, 1074, 63, 475, 63, 929, 63, 7185, 63, 657, 8, 277, 304, 267, 408, 267, 2670, 626, 282, 892, 2777, 334, 1045, 1174, 275, 11872, 9, 3181, 1133, 1570, 2399, 17845, 1380, 2337, 365, 282, 876, 5394, 2457, 1314, 1104, 626, 314, 1174, 365, 11872, 14, 267, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 2457, 63, 7185, 275, 291, 14, 981, 63, 1541, 63, 7185, 8, 1556, 12, 1747, 9, 267, 291, 14, 981, 63, 2200, 8, 1556, 12, 1747, 12, 283, 265, 63, 952, 297, 2457, 63, 657, 63, 344, 29, 1541, 63, 7185, 9, 267, 892, 63, 13799, 63, 344, 275, 291, 14, 981, 63, 13799, 63, 396, 63, 17, 8, 1556, 12, 1747, 9, 267, 892, 63, 13799, 275, 291, 14, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 892, 63, 13799, 63, 344, 9, 267, 291, 14, 2947, 8, 1222, 63, 13799, 14, 929, 12, 283, 7185, 358, 267, 291, 14, 2947, 8, 1222, 63, 13799, 14, 751, 63, 344, 14, 344, 12, 291, 14, 2113, 9, 267, 291, 14, 1807, 63, 4423, 8, 1556, 12, 1747, 9, 339, 347, 511, 63, 614, 63, 1074, 63, 475, 63, 929, 63, 7185, 63, 1932, 8, 277, 304, 267, 408, 267, 2670, 626, 282, 892, 2777, 4493, 2399, 17845, 1380, 2337, 365, 282, 2963, 5394, 2457, 1314, 1104, 626, 314, 1174, 365, 11872, 14, 267, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 2457, 63, 7185, 275, 291, 14, 981, 63, 1541, 63, 7185, 8, 1556, 12, 1747, 9, 267, 291, 14, 981, 63, 2200, 8, 1556, 12, 1747, 12, 283, 265, 63, 981, 358, 267, 892, 63, 13799, 63, 344, 275, 291, 14, 981, 63, 13799, 63, 396, 63, 17, 8, 1556, 12, 1747, 9, 267, 892, 63, 13799, 275, 291, 14, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 892, 63, 13799, 63, 344, 9, 267, 291, 14 ]
[ 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 2219, 492, 2863, 199, 504, 2508, 492, 511, 63, 992, 199, 199, 533, 1300, 63, 1287, 63, 2200, 63, 396, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 408, 1116, 10, 5996, 1116, 10, 624, 267, 1613, 8, 1095, 63, 1287, 63, 2200, 63, 396, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 8768, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 751, 63, 8768, 1959, 344, 267, 291, 14, 2113, 275, 12824, 63, 998, 267, 291, 14, 1238, 275, 291, 14, 5189, 360, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 358, 267, 291, 14, 1095, 63, 1287, 63, 2200, 275, 291, 14, 5189, 360, 1095, 14, 1287, 14, 2200, 358, 339, 347, 1218, 63, 1541, 63, 4456, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2457, 63, 2293, 275, 291, 14, 5189, 360, 723, 14, 4273, 358, 267, 372, 2457, 63, 2293, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 365, 315, 4224, 1174, 401, 288, 283, 374, 63, 885, 356, 756, 12, 288, 283, 1238, 63, 344, 356, 283, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 297, 288, 283, 2261, 356, 7369, 360, 929, 1673, 29511, 4456, 5440, 401, 267, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 1541, 63, 7185, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 2457, 63, 2293, 275, 291, 14, 5189, 360, 723, 14, 4273, 358, 267, 372, 2457, 63, 2293, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 365, 315, 11872, 1174, 401, 288, 283, 374, 63, 885, 356, 756, 12, 288, 283, 1238, 63, 344, 356, 298, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 401, 288, 283, 2261, 7, 520, 7369, 360, 929, 1673, 29511, 7185, 5440, 401, 288, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 13799, 63, 396, 63, 17, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 288, 2790, 282, 892, 12690, 63, 396, 267, 408, 267, 372, 291, 14, 1238, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 298, 29006, 1379, 413, 401, 288, 283, 751, 63, 344, 356, 291, 14, 2113, 12, 288, 1660, 1067, 29, 1100, 9, 339, 347, 1218, 63, 2200, 8, 277, 12, 2467, 12, 1747, 12, 4928, 12, 2457, 63, 344, 29, 797, 12, 2457, 63, 657, 63, 344, 29, 797, 12, 1067, 29, 403, 304, 267, 408, 288, 710, 298, 5065, 413, 2, 20065, 626, 1380, 282, 12690, 13538, 370, 314, 283, 7185, 7, 1174, 12, 314, 17845, 367, 626, 12690, 4493, 370, 922, 298, 8768, 2, 267, 408, 267, 372, 291, 14, 1095, 63, 1287, 63, 2200, 14, 981, 8, 1556, 12, 1535, 12, 91, 288, 283, 354, 356, 298, 5065, 413, 401, 288, 283, 1238, 63, 344, 356, 291, 14, 5189, 360, 723, 14, 1238, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 1673, 29511, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 2665, 1067, 29, 1100, 2788, 16, 467, 288, 283, 5091, 356, 4928, 12, 288, 283, 1541, 63, 657, 63, 344, 356, 2457, 63, 657, 63, 344, 12, 288, 283, 1541, 63, 344, 356, 2457, 63, 344, 12, 288, 283, 2442, 63, 751, 63, 344, 356, 291, 14, 8768, 12, 288, 1660, 1067, 29, 1100, 9, 339, 347, 3145, 63, 4423, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 408, 3145, 1006, 314, 4713, 641, 1402, 283, 1095, 14, 1287, 14, 2200, 14, 13799, 14, 396, 7, 408, 267, 1595, 63, 1580, 275, 291, 14, 1095, 63, 1287, 63, 2200, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 291, 14, 1238, 423, 354, 4360, 1067, 29, 1100, 9, 267, 372, 291, 14, 1095, 63, 1287, 63, 2200, 14, 7162, 8, 1556, 12, 1747, 12, 1595, 63, 1580, 12, 1067, 29, 1100, 9, 339, 347, 511, 63, 383, 63, 1074, 63, 475, 63, 929, 63, 7185, 63, 657, 8, 277, 304, 267, 408, 267, 2670, 626, 282, 892, 2777, 334, 1045, 1174, 275, 11872, 9, 3181, 1133, 1570, 2399, 17845, 1380, 2337, 365, 282, 876, 5394, 2457, 1314, 1104, 626, 314, 1174, 365, 11872, 14, 267, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 2457, 63, 7185, 275, 291, 14, 981, 63, 1541, 63, 7185, 8, 1556, 12, 1747, 9, 267, 291, 14, 981, 63, 2200, 8, 1556, 12, 1747, 12, 283, 265, 63, 952, 297, 2457, 63, 657, 63, 344, 29, 1541, 63, 7185, 9, 267, 892, 63, 13799, 63, 344, 275, 291, 14, 981, 63, 13799, 63, 396, 63, 17, 8, 1556, 12, 1747, 9, 267, 892, 63, 13799, 275, 291, 14, 1238, 14, 4570, 8, 1556, 12, 1747, 12, 892, 63, 13799, 63, 344, 9, 267, 291, 14, 2947, 8, 1222, 63, 13799, 14, 929, 12, 283, 7185, 358, 267, 291, 14, 2947, 8, 1222, 63, 13799, 14, 751, 63, 344, 14, 344, 12, 291, 14, 2113, 9, 267, 291, 14, 1807, 63, 4423, 8, 1556, 12, 1747, 9, 339, 347, 511, 63, 614, 63, 1074, 63, 475, 63, 929, 63, 7185, 63, 1932, 8, 277, 304, 267, 408, 267, 2670, 626, 282, 892, 2777, 4493, 2399, 17845, 1380, 2337, 365, 282, 2963, 5394, 2457, 1314, 1104, 626, 314, 1174, 365, 11872, 14, 267, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 2457, 63, 7185, 275, 291, 14, 981, 63, 1541, 63, 7185, 8, 1556, 12, 1747, 9, 267, 291, 14, 981, 63, 2200, 8, 1556, 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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 ]
andrewcbennett/iris
lib/iris/tests/unit/fileformats/netcdf/test__load_aux_factory.py
11
5682
# (C) British Crown Copyright 2014 - 2015, Met Office # # This file is part of Iris. # # Iris 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, either version 3 of the License, or # (at your option) any later version. # # Iris 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 Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Iris. If not, see <http://www.gnu.org/licenses/>. """Unit tests for the `iris.fileformats.netcdf._load_aux_factory` function.""" from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa # Import iris.tests first so that some things can be initialised before # importing anything else. import iris.tests as tests import numpy as np import warnings from iris.coords import DimCoord from iris.cube import Cube from iris.fileformats.netcdf import _load_aux_factory from iris.tests import mock class TestAtmosphereHybridSigmaPressureCoordinate(tests.IrisTest): def setUp(self): standard_name = 'atmosphere_hybrid_sigma_pressure_coordinate' self.requires = dict(formula_type=standard_name) coordinates = [(mock.sentinel.b, 'b'), (mock.sentinel.ps, 'ps')] self.provides = dict(coordinates=coordinates) self.engine = mock.Mock(requires=self.requires, provides=self.provides) self.cube = mock.create_autospec(Cube, spec_set=True, instance=True) # Patch out the check_dependencies functionality. func = 'iris.aux_factory.HybridPressureFactory._check_dependencies' patcher = mock.patch(func) patcher.start() self.addCleanup(patcher.stop) def test_formula_terms_ap(self): self.provides['coordinates'].append((mock.sentinel.ap, 'ap')) self.requires['formula_terms'] = dict(ap='ap', b='b', ps='ps') _load_aux_factory(self.engine, self.cube) # Check cube.add_aux_coord method. self.assertEqual(self.cube.add_aux_coord.call_count, 0) # Check cube.add_aux_factory method. self.assertEqual(self.cube.add_aux_factory.call_count, 1) args, _ = self.cube.add_aux_factory.call_args self.assertEqual(len(args), 1) factory = args[0] self.assertEqual(factory.delta, mock.sentinel.ap) self.assertEqual(factory.sigma, mock.sentinel.b) self.assertEqual(factory.surface_air_pressure, mock.sentinel.ps) def test_formula_terms_a_p0(self): coord_a = DimCoord(np.arange(5), units='Pa') coord_p0 = DimCoord(10, units='1') coord_expected = DimCoord(np.arange(5) * 10, units='Pa', long_name='vertical pressure', var_name='ap') self.provides['coordinates'].extend([(coord_a, 'a'), (coord_p0, 'p0')]) self.requires['formula_terms'] = dict(a='a', b='b', ps='ps', p0='p0') _load_aux_factory(self.engine, self.cube) # Check cube.coord_dims method. self.assertEqual(self.cube.coord_dims.call_count, 1) args, _ = self.cube.coord_dims.call_args self.assertEqual(len(args), 1) self.assertIs(args[0], coord_a) # Check cube.add_aux_coord method. self.assertEqual(self.cube.add_aux_coord.call_count, 1) args, _ = self.cube.add_aux_coord.call_args self.assertEqual(len(args), 2) self.assertEqual(args[0], coord_expected) self.assertIsInstance(args[1], mock.Mock) # Check cube.add_aux_factory method. self.assertEqual(self.cube.add_aux_factory.call_count, 1) args, _ = self.cube.add_aux_factory.call_args self.assertEqual(len(args), 1) factory = args[0] self.assertEqual(factory.delta, coord_expected) self.assertEqual(factory.sigma, mock.sentinel.b) self.assertEqual(factory.surface_air_pressure, mock.sentinel.ps) def test_formula_terms_p0_non_scalar(self): coord_p0 = DimCoord(np.arange(5)) self.provides['coordinates'].append((coord_p0, 'p0')) self.requires['formula_terms'] = dict(p0='p0') with self.assertRaises(ValueError): _load_aux_factory(self.engine, self.cube) def test_formula_terms_p0_bounded(self): coord_a = DimCoord(np.arange(5)) coord_p0 = DimCoord(1, bounds=[0, 2], var_name='p0') self.provides['coordinates'].extend([(coord_a, 'a'), (coord_p0, 'p0')]) self.requires['formula_terms'] = dict(a='a', b='b', ps='ps', p0='p0') with warnings.catch_warnings(record=True) as warn: warnings.simplefilter('always') _load_aux_factory(self.engine, self.cube) self.assertEqual(len(warn), 1) msg = 'Ignoring atmosphere hybrid sigma pressure scalar ' \ 'coordinate {!r} bounds.'.format(coord_p0.name()) self.assertEqual(msg, str(warn[0].message)) def test_formula_terms_ap_missing_coords(self): coordinates = [(mock.sentinel.b, 'b'), (mock.sentinel.ps, 'ps')] self.provides = dict(coordinates=coordinates) self.requires['formula_terms'] = dict(ap='ap', b='b', ps='ps') with mock.patch('warnings.warn') as warn: _load_aux_factory(self.engine, self.cube) warn.assert_called_once_with("Unable to find coordinate for variable " "'ap'") if __name__ == '__main__': tests.main()
gpl-3.0
[ 3, 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 6927, 446, 6900, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 5072, 2295, 367, 314, 658, 11885, 14, 493, 6321, 14, 846, 10790, 423, 912, 63, 10962, 63, 3702, 64, 805, 1041, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 504, 3816, 14, 4912, 492, 334, 1541, 12, 1324, 12, 2341, 12, 1425, 12, 3482, 9, 221, 327, 8151, 199, 199, 3, 3161, 12192, 14, 2219, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 2544, 199, 3, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 504, 12192, 14, 8032, 492, 577, 1017, 14957, 199, 504, 12192, 14, 11477, 492, 445, 3375, 199, 504, 12192, 14, 493, 6321, 14, 846, 10790, 492, 485, 912, 63, 10962, 63, 3702, 199, 504, 12192, 14, 2219, 492, 1683, 421, 199, 533, 1379, 1271, 573, 14980, 21568, 14601, 23394, 14414, 608, 18017, 8, 2219, 14, 41, 5719, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 4465, 63, 354, 275, 283, 292, 573, 14980, 63, 27758, 63, 9412, 63, 21999, 63, 20493, 7, 267, 291, 14, 6537, 275, 1211, 8, 16798, 63, 466, 29, 6807, 63, 354, 9, 267, 8983, 275, 3842, 1805, 14, 13400, 14, 66, 12, 283, 66, 659, 334, 1805, 14, 13400, 14, 1190, 12, 283, 1190, 5440, 267, 291, 14, 20121, 275, 1211, 8, 12924, 29, 12924, 9, 267, 291, 14, 3908, 275, 1683, 14, 3346, 8, 6537, 29, 277, 14, 6537, 12, 6571, 29, 277, 14, 20121, 9, 267, 291, 14, 11477, 275, 1683, 14, 981, 63, 22303, 8, 25043, 12, 3158, 63, 409, 29, 549, 12, 1256, 29, 549, 9, 267, 327, 19292, 734, 314, 1104, 63, 5714, 9330, 14, 267, 2562, 275, 283, 11885, 14, 10962, 63, 3702, 14, 21568, 14601, 14414, 608, 2927, 423, 1074, 63, 5714, 7, 267, 21198, 275, 1683, 14, 2068, 8, 1532, 9, 267, 21198, 14, 928, 342, 267, 291, 14, 12808, 8, 11238, 14, 2379, 9, 339, 347, 511, 63, 16798, 63, 9187, 63, 439, 8, 277, 304, 267, 291, 14, 20121, 459, 12924, 2278, 740, 1332, 1805, 14, 13400, 14, 439, 12, 283, 439, 1333, 267, 291, 14, 6537, 459, 16798, 63, 9187, 418, 275, 1211, 8, 439, 534, 439, 297, 330, 534, 66, 297, 7347, 534, 1190, 358, 267, 485, 912, 63, 10962, 63, 3702, 8, 277, 14, 3908, 12, 291, 14, 11477, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 7988, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 835, 12, 378, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 3702, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 3702, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 525, 63, 10962, 63, 3702, 14, 1250, 63, 589, 267, 291, 14, 629, 8, 552, 8, 589, 395, 413, 9, 267, 6434, 275, 1249, 59, 16, 61, 267, 291, 14, 629, 8, 3702, 14, 3136, 12, 1683, 14, 13400, 14, 439, 9, 267, 291, 14, 629, 8, 3702, 14, 9412, 12, 1683, 14, 13400, 14, 66, 9, 267, 291, 14, 629, 8, 3702, 14, 10992, 63, 8387, 63, 21999, 12, 1683, 14, 13400, 14, 1190, 9, 339, 347, 511, 63, 16798, 63, 9187, 63, 65, 63, 80, 16, 8, 277, 304, 267, 11021, 63, 65, 275, 577, 1017, 14957, 8, 1590, 14, 5605, 8, 21, 395, 6204, 534, 4232, 358, 267, 11021, 63, 80, 16, 275, 577, 1017, 14957, 8, 709, 12, 6204, 534, 17, 358, 267, 11021, 63, 2062, 275, 577, 1017, 14957, 8, 1590, 14, 5605, 8, 21, 9, 627, 1616, 12, 6204, 534, 4232, 297, 3303, 1846, 63, 354, 534, 7870, 25471, 297, 2729, 63, 354, 534, 439, 358, 267, 291, 14, 20121, 459, 12924, 2278, 2880, 7694, 7988, 63, 65, 12, 283, 65, 659, 334, 7988, 63, 80, 16, 12, 283, 80, 16, 2023, 267, 291, 14, 6537, 459, 16798, 63, 9187, 418, 275, 1211, 8, 65, 534, 65, 297, 330, 534, 66, 297, 7347, 534, 1190, 297, 299, 16, 534, 80, 16, 358, 267, 485, 912, 63, 10962, 63, 3702, 8, 277, 14, 3908, 12, 291, 14, 11477, 9, 267, 327, 2670, 15681, 14, 7988, 63, 5380, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 7988, 63, 5380, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 7988, 63, 5380, 14, 1250, 63, 589, 267, 291, 14, 629, 8, 552, 8, 589, 395, 413, 9, 267, 291, 14, 3436, 8, 589, 59, 16, 467, 11021, 63, 65, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 7988, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 589, 267, 291, 14, 629, 8, 552, 8, 589, 395, 499 ]
[ 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 6927, 446, 6900, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 5072, 2295, 367, 314, 658, 11885, 14, 493, 6321, 14, 846, 10790, 423, 912, 63, 10962, 63, 3702, 64, 805, 1041, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 504, 3816, 14, 4912, 492, 334, 1541, 12, 1324, 12, 2341, 12, 1425, 12, 3482, 9, 221, 327, 8151, 199, 199, 3, 3161, 12192, 14, 2219, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 2544, 199, 3, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 504, 12192, 14, 8032, 492, 577, 1017, 14957, 199, 504, 12192, 14, 11477, 492, 445, 3375, 199, 504, 12192, 14, 493, 6321, 14, 846, 10790, 492, 485, 912, 63, 10962, 63, 3702, 199, 504, 12192, 14, 2219, 492, 1683, 421, 199, 533, 1379, 1271, 573, 14980, 21568, 14601, 23394, 14414, 608, 18017, 8, 2219, 14, 41, 5719, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 4465, 63, 354, 275, 283, 292, 573, 14980, 63, 27758, 63, 9412, 63, 21999, 63, 20493, 7, 267, 291, 14, 6537, 275, 1211, 8, 16798, 63, 466, 29, 6807, 63, 354, 9, 267, 8983, 275, 3842, 1805, 14, 13400, 14, 66, 12, 283, 66, 659, 334, 1805, 14, 13400, 14, 1190, 12, 283, 1190, 5440, 267, 291, 14, 20121, 275, 1211, 8, 12924, 29, 12924, 9, 267, 291, 14, 3908, 275, 1683, 14, 3346, 8, 6537, 29, 277, 14, 6537, 12, 6571, 29, 277, 14, 20121, 9, 267, 291, 14, 11477, 275, 1683, 14, 981, 63, 22303, 8, 25043, 12, 3158, 63, 409, 29, 549, 12, 1256, 29, 549, 9, 267, 327, 19292, 734, 314, 1104, 63, 5714, 9330, 14, 267, 2562, 275, 283, 11885, 14, 10962, 63, 3702, 14, 21568, 14601, 14414, 608, 2927, 423, 1074, 63, 5714, 7, 267, 21198, 275, 1683, 14, 2068, 8, 1532, 9, 267, 21198, 14, 928, 342, 267, 291, 14, 12808, 8, 11238, 14, 2379, 9, 339, 347, 511, 63, 16798, 63, 9187, 63, 439, 8, 277, 304, 267, 291, 14, 20121, 459, 12924, 2278, 740, 1332, 1805, 14, 13400, 14, 439, 12, 283, 439, 1333, 267, 291, 14, 6537, 459, 16798, 63, 9187, 418, 275, 1211, 8, 439, 534, 439, 297, 330, 534, 66, 297, 7347, 534, 1190, 358, 267, 485, 912, 63, 10962, 63, 3702, 8, 277, 14, 3908, 12, 291, 14, 11477, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 7988, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 835, 12, 378, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 3702, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 3702, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 525, 63, 10962, 63, 3702, 14, 1250, 63, 589, 267, 291, 14, 629, 8, 552, 8, 589, 395, 413, 9, 267, 6434, 275, 1249, 59, 16, 61, 267, 291, 14, 629, 8, 3702, 14, 3136, 12, 1683, 14, 13400, 14, 439, 9, 267, 291, 14, 629, 8, 3702, 14, 9412, 12, 1683, 14, 13400, 14, 66, 9, 267, 291, 14, 629, 8, 3702, 14, 10992, 63, 8387, 63, 21999, 12, 1683, 14, 13400, 14, 1190, 9, 339, 347, 511, 63, 16798, 63, 9187, 63, 65, 63, 80, 16, 8, 277, 304, 267, 11021, 63, 65, 275, 577, 1017, 14957, 8, 1590, 14, 5605, 8, 21, 395, 6204, 534, 4232, 358, 267, 11021, 63, 80, 16, 275, 577, 1017, 14957, 8, 709, 12, 6204, 534, 17, 358, 267, 11021, 63, 2062, 275, 577, 1017, 14957, 8, 1590, 14, 5605, 8, 21, 9, 627, 1616, 12, 6204, 534, 4232, 297, 3303, 1846, 63, 354, 534, 7870, 25471, 297, 2729, 63, 354, 534, 439, 358, 267, 291, 14, 20121, 459, 12924, 2278, 2880, 7694, 7988, 63, 65, 12, 283, 65, 659, 334, 7988, 63, 80, 16, 12, 283, 80, 16, 2023, 267, 291, 14, 6537, 459, 16798, 63, 9187, 418, 275, 1211, 8, 65, 534, 65, 297, 330, 534, 66, 297, 7347, 534, 1190, 297, 299, 16, 534, 80, 16, 358, 267, 485, 912, 63, 10962, 63, 3702, 8, 277, 14, 3908, 12, 291, 14, 11477, 9, 267, 327, 2670, 15681, 14, 7988, 63, 5380, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 7988, 63, 5380, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 7988, 63, 5380, 14, 1250, 63, 589, 267, 291, 14, 629, 8, 552, 8, 589, 395, 413, 9, 267, 291, 14, 3436, 8, 589, 59, 16, 467, 11021, 63, 65, 9, 267, 327, 2670, 15681, 14, 525, 63, 10962, 63, 7988, 1083, 14, 267, 291, 14, 629, 8, 277, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 835, 12, 413, 9, 267, 1249, 12, 485, 275, 291, 14, 11477, 14, 525, 63, 10962, 63, 7988, 14, 1250, 63, 589, 267, 291,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
user-none/calibre
src/calibre/ebooks/oeb/transforms/guide.py
16
2308
#!/usr/bin/env python2 # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai from __future__ import with_statement __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' class Clean(object): '''Clean up guide, leaving only known values ''' def __call__(self, oeb, opts): self.oeb, self.log, self.opts = oeb, oeb.log, opts if 'cover' not in self.oeb.guide: covers = [] for x in ('other.ms-coverimage-standard', 'coverimagestandard', 'other.ms-titleimage-standard', 'other.ms-titleimage', 'other.ms-coverimage', 'other.ms-thumbimage-standard', 'other.ms-thumbimage', 'thumbimagestandard'): if x in self.oeb.guide: href = self.oeb.guide[x].href try: item = self.oeb.manifest.hrefs[href] except KeyError: continue else: covers.append([self.oeb.guide[x], len(item.data)]) covers.sort(cmp=lambda x,y:cmp(x[1], y[1]), reverse=True) if covers: ref = covers[0][0] if len(covers) > 1: self.log('Choosing %s:%s as the cover'%(ref.type, ref.href)) ref.type = 'cover' self.oeb.guide.refs['cover'] = ref if ('start' in self.oeb.guide and 'text' not in self.oeb.guide): # Prefer text to start as per the OPF 2.0 spec x = self.oeb.guide['start'] self.oeb.guide.add('text', x.title, x.href) self.oeb.guide.remove('start') for x in list(self.oeb.guide): if x.lower() not in { 'cover', 'titlepage', 'masthead', 'toc', 'title-page', 'copyright-page', 'text', 'index', 'glossary', 'acknowledgements', 'bibliography', 'colophon', 'copyright-page', 'dedication', 'epigraph', 'foreword', 'loi', 'lot', 'notes', 'preface'}: item = self.oeb.guide[x] if item.title and item.title.lower() == 'start': continue self.oeb.guide.remove(x)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 8664, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 421, 199, 533, 12762, 8, 785, 304, 272, 1449, 6580, 1536, 22885, 12, 23188, 1454, 6040, 1338, 1449, 339, 347, 636, 1250, 721, 277, 12, 312, 2871, 12, 3999, 304, 267, 291, 14, 79, 2871, 12, 291, 14, 793, 12, 291, 14, 3291, 275, 312, 2871, 12, 312, 2871, 14, 793, 12, 3999, 398, 340, 283, 5899, 7, 440, 315, 291, 14, 79, 2871, 14, 17348, 26, 288, 25858, 275, 942, 288, 367, 671, 315, 661, 1848, 14, 706, 13, 5899, 1569, 13, 6807, 297, 283, 5899, 1569, 6807, 297, 490, 283, 1848, 14, 706, 13, 1213, 1569, 13, 6807, 297, 283, 1848, 14, 706, 13, 1213, 1569, 297, 490, 283, 1848, 14, 706, 13, 5899, 1569, 297, 283, 1848, 14, 706, 13, 16534, 1569, 13, 6807, 297, 490, 283, 1848, 14, 706, 13, 16534, 1569, 297, 283, 16534, 1569, 6807, 735, 355, 340, 671, 315, 291, 14, 79, 2871, 14, 17348, 26, 490, 4369, 275, 291, 14, 79, 2871, 14, 17348, 59, 88, 1055, 6399, 490, 862, 26, 717, 1242, 275, 291, 14, 79, 2871, 14, 6418, 14, 6399, 83, 59, 6399, 61, 490, 871, 4067, 26, 717, 1980, 490, 587, 26, 717, 25858, 14, 740, 779, 277, 14, 79, 2871, 14, 17348, 59, 88, 467, 822, 8, 1053, 14, 576, 3948, 953, 25858, 14, 3191, 8, 5730, 29, 2734, 671, 12, 89, 26, 5730, 8, 88, 59, 17, 467, 612, 59, 17, 2522, 3837, 29, 549, 9, 288, 340, 25858, 26, 355, 2984, 275, 25858, 59, 16, 1527, 16, 61, 355, 340, 822, 8, 5899, 83, 9, 690, 413, 26, 490, 291, 14, 793, 360, 6209, 26056, 450, 83, 2689, 83, 465, 314, 8486, 13328, 1121, 14, 466, 12, 2984, 14, 6399, 430, 355, 2984, 14, 466, 275, 283, 5899, 7, 355, 291, 14, 79, 2871, 14, 17348, 14, 7655, 459, 5899, 418, 275, 2984, 398, 340, 661, 928, 7, 315, 291, 14, 79, 2871, 14, 17348, 436, 283, 505, 7, 440, 315, 291, 14, 79, 2871, 14, 17348, 304, 288, 327, 510, 21928, 1318, 370, 1343, 465, 1126, 314, 9827, 38, 499, 14, 16, 3158, 288, 671, 275, 291, 14, 79, 2871, 14, 17348, 459, 928, 418, 288, 291, 14, 79, 2871, 14, 17348, 14, 525, 360, 505, 297, 671, 14, 1213, 12, 671, 14, 6399, 9, 288, 291, 14, 79, 2871, 14, 17348, 14, 2168, 360, 928, 358, 398, 367, 671, 315, 769, 8, 277, 14, 79, 2871, 14, 17348, 304, 288, 340, 671, 14, 2325, 342, 440, 315, 469, 490, 283, 5899, 297, 283, 1213, 1606, 297, 283, 391, 270, 2993, 297, 283, 13255, 297, 283, 1213, 13, 1606, 297, 490, 283, 7307, 13, 1606, 297, 283, 505, 297, 283, 1080, 297, 283, 71, 4358, 695, 297, 490, 283, 564, 23504, 1470, 297, 283, 8804, 14437, 9773, 297, 283, 331, 320, 838, 265, 297, 490, 283, 7307, 13, 1606, 297, 283, 271, 21171, 297, 283, 1545, 528, 3255, 297, 283, 1707, 1027, 297, 490, 283, 320, 73, 297, 283, 1653, 297, 283, 5983, 297, 283, 657, 1409, 936, 26, 355, 1242, 275, 291, 14, 79, 2871, 14, 17348, 59, 88, 61, 355, 340, 1242, 14, 1213, 436, 1242, 14, 1213, 14, 2325, 342, 508, 283, 928, 356, 490, 1980, 355, 291, 14, 79, 2871, 14, 17348, 14, 2168, 8, 88, 9, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 8664, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 421, 199, 533, 12762, 8, 785, 304, 272, 1449, 6580, 1536, 22885, 12, 23188, 1454, 6040, 1338, 1449, 339, 347, 636, 1250, 721, 277, 12, 312, 2871, 12, 3999, 304, 267, 291, 14, 79, 2871, 12, 291, 14, 793, 12, 291, 14, 3291, 275, 312, 2871, 12, 312, 2871, 14, 793, 12, 3999, 398, 340, 283, 5899, 7, 440, 315, 291, 14, 79, 2871, 14, 17348, 26, 288, 25858, 275, 942, 288, 367, 671, 315, 661, 1848, 14, 706, 13, 5899, 1569, 13, 6807, 297, 283, 5899, 1569, 6807, 297, 490, 283, 1848, 14, 706, 13, 1213, 1569, 13, 6807, 297, 283, 1848, 14, 706, 13, 1213, 1569, 297, 490, 283, 1848, 14, 706, 13, 5899, 1569, 297, 283, 1848, 14, 706, 13, 16534, 1569, 13, 6807, 297, 490, 283, 1848, 14, 706, 13, 16534, 1569, 297, 283, 16534, 1569, 6807, 735, 355, 340, 671, 315, 291, 14, 79, 2871, 14, 17348, 26, 490, 4369, 275, 291, 14, 79, 2871, 14, 17348, 59, 88, 1055, 6399, 490, 862, 26, 717, 1242, 275, 291, 14, 79, 2871, 14, 6418, 14, 6399, 83, 59, 6399, 61, 490, 871, 4067, 26, 717, 1980, 490, 587, 26, 717, 25858, 14, 740, 779, 277, 14, 79, 2871, 14, 17348, 59, 88, 467, 822, 8, 1053, 14, 576, 3948, 953, 25858, 14, 3191, 8, 5730, 29, 2734, 671, 12, 89, 26, 5730, 8, 88, 59, 17, 467, 612, 59, 17, 2522, 3837, 29, 549, 9, 288, 340, 25858, 26, 355, 2984, 275, 25858, 59, 16, 1527, 16, 61, 355, 340, 822, 8, 5899, 83, 9, 690, 413, 26, 490, 291, 14, 793, 360, 6209, 26056, 450, 83, 2689, 83, 465, 314, 8486, 13328, 1121, 14, 466, 12, 2984, 14, 6399, 430, 355, 2984, 14, 466, 275, 283, 5899, 7, 355, 291, 14, 79, 2871, 14, 17348, 14, 7655, 459, 5899, 418, 275, 2984, 398, 340, 661, 928, 7, 315, 291, 14, 79, 2871, 14, 17348, 436, 283, 505, 7, 440, 315, 291, 14, 79, 2871, 14, 17348, 304, 288, 327, 510, 21928, 1318, 370, 1343, 465, 1126, 314, 9827, 38, 499, 14, 16, 3158, 288, 671, 275, 291, 14, 79, 2871, 14, 17348, 459, 928, 418, 288, 291, 14, 79, 2871, 14, 17348, 14, 525, 360, 505, 297, 671, 14, 1213, 12, 671, 14, 6399, 9, 288, 291, 14, 79, 2871, 14, 17348, 14, 2168, 360, 928, 358, 398, 367, 671, 315, 769, 8, 277, 14, 79, 2871, 14, 17348, 304, 288, 340, 671, 14, 2325, 342, 440, 315, 469, 490, 283, 5899, 297, 283, 1213, 1606, 297, 283, 391, 270, 2993, 297, 283, 13255, 297, 283, 1213, 13, 1606, 297, 490, 283, 7307, 13, 1606, 297, 283, 505, 297, 283, 1080, 297, 283, 71, 4358, 695, 297, 490, 283, 564, 23504, 1470, 297, 283, 8804, 14437, 9773, 297, 283, 331, 320, 838, 265, 297, 490, 283, 7307, 13, 1606, 297, 283, 271, 21171, 297, 283, 1545, 528, 3255, 297, 283, 1707, 1027, 297, 490, 283, 320, 73, 297, 283, 1653, 297, 283, 5983, 297, 283, 657, 1409, 936, 26, 355, 1242, 275, 291, 14, 79, 2871, 14, 17348, 59, 88, 61, 355, 340, 1242, 14, 1213, 436, 1242, 14, 1213, 14, 2325, 342, 508, 283, 928, 356, 490, 1980, 355, 291, 14, 79, 2871, 14, 17348, 14, 2168, 8, 88, 9, 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, 0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 0, 0 ]
40223110/w16b_test
static/Brython3.1.1-20150328-091302/Lib/_thread.py
740
4879
"""Drop-in replacement for the thread module. Meant to be used as a brain-dead substitute so that threaded code does not need to be rewritten for when the thread module is not present. Suggested usage is:: try: import _thread except ImportError: import _dummy_thread as _thread """ # Exports only things specified by thread documentation; # skipping obsolete synonyms allocate(), start_new(), exit_thread(). __all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock', 'interrupt_main', 'LockType'] # A dummy value TIMEOUT_MAX = 2**31 # NOTE: this module can be imported early in the extension building process, # and so top level imports of other modules should be avoided. Instead, all # imports are done when needed on a function-by-function basis. Since threads # are disabled, the import lock should not be an issue anyway (??). error = RuntimeError def start_new_thread(function, args, kwargs={}): """Dummy implementation of _thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by _thread.exit()) it is caught and nothing is done; all other exceptions are printed out by using traceback.print_exc(). If the executed function calls interrupt_main the KeyboardInterrupt will be raised when the function returns. """ if type(args) != type(tuple()): raise TypeError("2nd arg must be a tuple") if type(kwargs) != type(dict()): raise TypeError("3rd arg must be a dict") global _main _main = False try: function(*args, **kwargs) except SystemExit: pass except: import traceback traceback.print_exc() _main = True global _interrupt if _interrupt: _interrupt = False raise KeyboardInterrupt def exit(): """Dummy implementation of _thread.exit().""" raise SystemExit def get_ident(): """Dummy implementation of _thread.get_ident(). Since this module should only be used when _threadmodule is not available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned. """ return -1 def allocate_lock(): """Dummy implementation of _thread.allocate_lock().""" return LockType() def stack_size(size=None): """Dummy implementation of _thread.stack_size().""" if size is not None: raise error("setting thread stack size not supported") return 0 class LockType(object): """Class implementing dummy implementation of _thread.LockType. Compatibility is maintained by maintaining self.locked_status which is a boolean that stores the state of the lock. Pickling of the lock, though, should not be done since if the _thread module is then used with an unpickled ``lock()`` from here problems could occur from this class not having atomic methods. """ def __init__(self): self.locked_status = False def acquire(self, waitflag=None, timeout=-1): """Dummy implementation of acquire(). For blocking calls, self.locked_status is automatically set to True and returned appropriately based on value of ``waitflag``. If it is non-blocking, then the value is actually checked and not set if it is already acquired. This is all done so that threading.Condition's assert statements aren't triggered and throw a little fit. """ if waitflag is None or waitflag: self.locked_status = True return True else: if not self.locked_status: self.locked_status = True return True else: if timeout > 0: import time time.sleep(timeout) return False __enter__ = acquire def __exit__(self, typ, val, tb): self.release() def release(self): """Release the dummy lock.""" # XXX Perhaps shouldn't actually bother to test? Could lead # to problems for complex, threaded code. if not self.locked_status: raise error self.locked_status = False return True def locked(self): return self.locked_status # Used to signal that interrupt_main was called in a "thread" _interrupt = False # True when not executing in a "thread" _main = True def interrupt_main(): """Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.""" if _main: raise KeyboardInterrupt else: global _interrupt _interrupt = True # Brython-specific to avoid circular references between threading and _threading_local class _local: pass
agpl-3.0
[ 624, 11070, 13, 262, 8343, 367, 314, 2462, 859, 14, 199, 199, 1352, 867, 370, 506, 1202, 465, 282, 330, 6322, 13, 10957, 23080, 880, 626, 25396, 1233, 1630, 199, 1397, 1929, 370, 506, 28286, 367, 1380, 314, 2462, 859, 365, 440, 3451, 14, 199, 199, 51, 17417, 4503, 365, 447, 339, 862, 26, 267, 492, 485, 2671, 272, 871, 3545, 26, 267, 492, 485, 5869, 63, 2671, 465, 485, 2671, 199, 199, 624, 199, 3, 1316, 5203, 1454, 7645, 2013, 701, 2462, 3794, 27, 199, 3, 16068, 24985, 9560, 5220, 706, 18310, 1062, 1343, 63, 1222, 1062, 4458, 63, 2671, 1252, 199, 363, 452, 363, 275, 788, 705, 297, 283, 928, 63, 1222, 63, 2671, 297, 283, 2224, 297, 283, 362, 63, 5425, 297, 283, 12991, 63, 831, 297, 1779, 283, 20172, 63, 973, 297, 283, 6432, 804, 418, 199, 199, 3, 437, 7283, 574, 199, 8899, 63, 4283, 275, 499, 538, 2192, 199, 199, 3, 6944, 26, 642, 859, 883, 506, 8439, 14670, 315, 314, 3329, 10015, 2112, 12, 199, 3, 436, 880, 2746, 2166, 8925, 402, 1163, 4621, 1077, 506, 2289, 16142, 770, 14, 221, 15345, 12, 1006, 199, 3, 8925, 787, 4224, 1380, 4346, 641, 282, 805, 13, 991, 13, 1593, 5597, 14, 221, 9336, 7183, 199, 3, 787, 6980, 12, 314, 492, 4650, 1077, 440, 506, 376, 4976, 15988, 7558, 31, 680, 199, 199, 705, 275, 6064, 199, 199, 318, 1343, 63, 1222, 63, 2671, 8, 1593, 12, 1249, 12, 2074, 16420, 272, 408, 11324, 4514, 402, 485, 2671, 14, 928, 63, 1222, 63, 2671, 1252, 339, 3599, 5880, 365, 26391, 701, 10663, 3238, 626, 1124, 589, 1040, 365, 282, 272, 2008, 436, 1124, 958, 1040, 365, 282, 2600, 14, 221, 982, 376, 1919, 365, 4915, 272, 436, 652, 365, 14838, 334, 6777, 883, 506, 4224, 701, 485, 2671, 14, 2224, 1012, 652, 365, 272, 15604, 436, 6548, 365, 4224, 27, 1006, 1163, 4967, 787, 12487, 734, 272, 701, 1808, 5190, 14, 1361, 63, 2804, 1252, 339, 982, 314, 7934, 805, 4882, 26791, 63, 973, 314, 13483, 911, 506, 272, 4915, 1380, 314, 805, 2529, 14, 339, 408, 272, 340, 730, 8, 589, 9, 1137, 730, 8, 2960, 5109, 267, 746, 3146, 480, 18, 977, 1680, 1471, 506, 282, 2008, 531, 272, 340, 730, 8, 958, 9, 1137, 730, 8, 807, 5109, 267, 746, 3146, 480, 19, 6883, 1680, 1471, 506, 282, 1211, 531, 272, 2288, 485, 973, 272, 485, 973, 275, 756, 272, 862, 26, 267, 805, 2031, 589, 12, 1011, 958, 9, 272, 871, 14838, 26, 267, 986, 272, 871, 26, 267, 492, 5190, 267, 5190, 14, 1361, 63, 2804, 342, 272, 485, 973, 275, 715, 272, 2288, 485, 20172, 272, 340, 485, 20172, 26, 267, 485, 20172, 275, 756, 267, 746, 13483, 199, 199, 318, 4458, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 2224, 20693, 272, 746, 14838, 199, 199, 318, 664, 63, 5425, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 362, 63, 5425, 1252, 339, 9336, 642, 859, 1077, 1454, 506, 1202, 1380, 485, 2671, 578, 365, 440, 272, 2808, 12, 652, 365, 5048, 370, 5534, 626, 314, 1453, 2112, 365, 314, 272, 1454, 2462, 14, 221, 20227, 282, 4413, 883, 506, 19353, 2138, 14, 272, 408, 272, 372, 446, 17, 199, 199, 318, 18310, 63, 831, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 12991, 63, 831, 20693, 272, 372, 15536, 804, 342, 199, 199, 318, 3464, 63, 890, 8, 890, 29, 403, 304, 272, 408, 11324, 4514, 402, 485, 2671, 14, 2340, 63, 890, 20693, 272, 340, 1568, 365, 440, 488, 26, 267, 746, 1125, 480, 6031, 2462, 3464, 1568, 440, 3748, 531, 272, 372, 378, 199, 199, 533, 15536, 804, 8, 785, 304, 272, 408, 2543, 18234, 7283, 4514, 402, 485, 2671, 14, 6432, 804, 14, 339, 3599, 5880, 365, 26391, 701, 11075, 316, 291, 14, 9325, 63, 1205, 272, 1314, 365, 282, 5046, 626, 14086, 314, 1174, 402, 314, 4650, 14, 221, 16568, 2983, 402, 272, 314, 4650, 12, 10617, 12, 1077, 440, 506, 4224, 3967, 340, 314, 485, 2671, 859, 365, 272, 2066, 1202, 543, 376, 625, 20428, 1124, 831, 8497, 687, 2348, 8826, 4293, 272, 4781, 687, 642, 1021, 440, 9445, 15374, 3102, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9325, 63, 1205, 275, 756, 339, 347, 16919, 8, 277, 12, 3618, 4173, 29, 403, 12, 2653, 4022, 17, 304, 267, 408, 11324, 4514, 402, 16919, 1252, 398, 2104, 14592, 4882, 12, 291, 14, 9325, 63, 1205, 365, 5847, 663, 370, 267, 715, 436, 2138, 22497, 4079, 641, 574, 402, 267, 1124, 2573, 4173, 4345, 221, 982, 652, 365, 2222, 13, 13091, 12, 2066, 314, 574, 365, 267, 5965, 7923, 436, 440, 663, 340, 652, 365, 2575, 28320, 14, 221, 961, 267, 365, 1006, 4224, 880, 626, 5796, 14, 9558, 1159, 702, 9834, 267, 10621, 1133, 15572, 436, 7978, 282, 12050, 5542, 14, 398, 408, 267, 340, 3618, 4173, 365, 488, 503, 3618, 4173, 26, 288, 291, 14, 9325, 63, 1205, 275, 715, 288, 372, 715, 267, 587, 26, 288, 340, 440, 291, 14, 9325, 63, 1205, 26, 355, 291, 14, 9325, 63, 1205, 275, 715, 355, 372, 715, 288, 587, 26, 355, 340, 2653, 690, 378, 26, 490, 492, 900, 490, 900, 14, 4532, 8, 2593, 9, 355, 372, 756, 339, 636, 4200, 363, 275, 16919, 339, 347, 636, 2224, 721, 277, 12, 6211, 12, 1139, 12, 7070, 304, 267, 291, 14, 3221, 342, 339, 347, 4683, 8, 277, 304, 267, 408, 9625, 314, 7283, 4650, 1041, 267, 327, 5787, 3492, 17396, 9296, 1133, 5965, 26962, 370, 511, 31, 221, 18615, 12690, 267, 327, 258, 370, 8826, 367, 6114, 12, 25396, 1233, 14, 267, 340, 440, 291, 14, 9325, 63, 1205, 26, 288, 746, 1125, 267, 291, 14, 9325, 63, 1205, 275, 756, 267, 372, 715, 339, 347, 14233, 8, 277, 304, 267, 372, 291, 14, 9325, 63, 1205, 199, 199, 3, 8051, 370, 4673, 626, 26791, 63, 973, 1990, 2797, 315, 282, 298, 2671, 2, 199, 63, 20172, 275, 756, 199, 3, 715, 1380, 440, 14043, 315, 282, 298, 2671, 2, 199, 63, 973, 275, 715 ]
[ 11070, 13, 262, 8343, 367, 314, 2462, 859, 14, 199, 199, 1352, 867, 370, 506, 1202, 465, 282, 330, 6322, 13, 10957, 23080, 880, 626, 25396, 1233, 1630, 199, 1397, 1929, 370, 506, 28286, 367, 1380, 314, 2462, 859, 365, 440, 3451, 14, 199, 199, 51, 17417, 4503, 365, 447, 339, 862, 26, 267, 492, 485, 2671, 272, 871, 3545, 26, 267, 492, 485, 5869, 63, 2671, 465, 485, 2671, 199, 199, 624, 199, 3, 1316, 5203, 1454, 7645, 2013, 701, 2462, 3794, 27, 199, 3, 16068, 24985, 9560, 5220, 706, 18310, 1062, 1343, 63, 1222, 1062, 4458, 63, 2671, 1252, 199, 363, 452, 363, 275, 788, 705, 297, 283, 928, 63, 1222, 63, 2671, 297, 283, 2224, 297, 283, 362, 63, 5425, 297, 283, 12991, 63, 831, 297, 1779, 283, 20172, 63, 973, 297, 283, 6432, 804, 418, 199, 199, 3, 437, 7283, 574, 199, 8899, 63, 4283, 275, 499, 538, 2192, 199, 199, 3, 6944, 26, 642, 859, 883, 506, 8439, 14670, 315, 314, 3329, 10015, 2112, 12, 199, 3, 436, 880, 2746, 2166, 8925, 402, 1163, 4621, 1077, 506, 2289, 16142, 770, 14, 221, 15345, 12, 1006, 199, 3, 8925, 787, 4224, 1380, 4346, 641, 282, 805, 13, 991, 13, 1593, 5597, 14, 221, 9336, 7183, 199, 3, 787, 6980, 12, 314, 492, 4650, 1077, 440, 506, 376, 4976, 15988, 7558, 31, 680, 199, 199, 705, 275, 6064, 199, 199, 318, 1343, 63, 1222, 63, 2671, 8, 1593, 12, 1249, 12, 2074, 16420, 272, 408, 11324, 4514, 402, 485, 2671, 14, 928, 63, 1222, 63, 2671, 1252, 339, 3599, 5880, 365, 26391, 701, 10663, 3238, 626, 1124, 589, 1040, 365, 282, 272, 2008, 436, 1124, 958, 1040, 365, 282, 2600, 14, 221, 982, 376, 1919, 365, 4915, 272, 436, 652, 365, 14838, 334, 6777, 883, 506, 4224, 701, 485, 2671, 14, 2224, 1012, 652, 365, 272, 15604, 436, 6548, 365, 4224, 27, 1006, 1163, 4967, 787, 12487, 734, 272, 701, 1808, 5190, 14, 1361, 63, 2804, 1252, 339, 982, 314, 7934, 805, 4882, 26791, 63, 973, 314, 13483, 911, 506, 272, 4915, 1380, 314, 805, 2529, 14, 339, 408, 272, 340, 730, 8, 589, 9, 1137, 730, 8, 2960, 5109, 267, 746, 3146, 480, 18, 977, 1680, 1471, 506, 282, 2008, 531, 272, 340, 730, 8, 958, 9, 1137, 730, 8, 807, 5109, 267, 746, 3146, 480, 19, 6883, 1680, 1471, 506, 282, 1211, 531, 272, 2288, 485, 973, 272, 485, 973, 275, 756, 272, 862, 26, 267, 805, 2031, 589, 12, 1011, 958, 9, 272, 871, 14838, 26, 267, 986, 272, 871, 26, 267, 492, 5190, 267, 5190, 14, 1361, 63, 2804, 342, 272, 485, 973, 275, 715, 272, 2288, 485, 20172, 272, 340, 485, 20172, 26, 267, 485, 20172, 275, 756, 267, 746, 13483, 199, 199, 318, 4458, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 2224, 20693, 272, 746, 14838, 199, 199, 318, 664, 63, 5425, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 362, 63, 5425, 1252, 339, 9336, 642, 859, 1077, 1454, 506, 1202, 1380, 485, 2671, 578, 365, 440, 272, 2808, 12, 652, 365, 5048, 370, 5534, 626, 314, 1453, 2112, 365, 314, 272, 1454, 2462, 14, 221, 20227, 282, 4413, 883, 506, 19353, 2138, 14, 272, 408, 272, 372, 446, 17, 199, 199, 318, 18310, 63, 831, 837, 272, 408, 11324, 4514, 402, 485, 2671, 14, 12991, 63, 831, 20693, 272, 372, 15536, 804, 342, 199, 199, 318, 3464, 63, 890, 8, 890, 29, 403, 304, 272, 408, 11324, 4514, 402, 485, 2671, 14, 2340, 63, 890, 20693, 272, 340, 1568, 365, 440, 488, 26, 267, 746, 1125, 480, 6031, 2462, 3464, 1568, 440, 3748, 531, 272, 372, 378, 199, 199, 533, 15536, 804, 8, 785, 304, 272, 408, 2543, 18234, 7283, 4514, 402, 485, 2671, 14, 6432, 804, 14, 339, 3599, 5880, 365, 26391, 701, 11075, 316, 291, 14, 9325, 63, 1205, 272, 1314, 365, 282, 5046, 626, 14086, 314, 1174, 402, 314, 4650, 14, 221, 16568, 2983, 402, 272, 314, 4650, 12, 10617, 12, 1077, 440, 506, 4224, 3967, 340, 314, 485, 2671, 859, 365, 272, 2066, 1202, 543, 376, 625, 20428, 1124, 831, 8497, 687, 2348, 8826, 4293, 272, 4781, 687, 642, 1021, 440, 9445, 15374, 3102, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9325, 63, 1205, 275, 756, 339, 347, 16919, 8, 277, 12, 3618, 4173, 29, 403, 12, 2653, 4022, 17, 304, 267, 408, 11324, 4514, 402, 16919, 1252, 398, 2104, 14592, 4882, 12, 291, 14, 9325, 63, 1205, 365, 5847, 663, 370, 267, 715, 436, 2138, 22497, 4079, 641, 574, 402, 267, 1124, 2573, 4173, 4345, 221, 982, 652, 365, 2222, 13, 13091, 12, 2066, 314, 574, 365, 267, 5965, 7923, 436, 440, 663, 340, 652, 365, 2575, 28320, 14, 221, 961, 267, 365, 1006, 4224, 880, 626, 5796, 14, 9558, 1159, 702, 9834, 267, 10621, 1133, 15572, 436, 7978, 282, 12050, 5542, 14, 398, 408, 267, 340, 3618, 4173, 365, 488, 503, 3618, 4173, 26, 288, 291, 14, 9325, 63, 1205, 275, 715, 288, 372, 715, 267, 587, 26, 288, 340, 440, 291, 14, 9325, 63, 1205, 26, 355, 291, 14, 9325, 63, 1205, 275, 715, 355, 372, 715, 288, 587, 26, 355, 340, 2653, 690, 378, 26, 490, 492, 900, 490, 900, 14, 4532, 8, 2593, 9, 355, 372, 756, 339, 636, 4200, 363, 275, 16919, 339, 347, 636, 2224, 721, 277, 12, 6211, 12, 1139, 12, 7070, 304, 267, 291, 14, 3221, 342, 339, 347, 4683, 8, 277, 304, 267, 408, 9625, 314, 7283, 4650, 1041, 267, 327, 5787, 3492, 17396, 9296, 1133, 5965, 26962, 370, 511, 31, 221, 18615, 12690, 267, 327, 258, 370, 8826, 367, 6114, 12, 25396, 1233, 14, 267, 340, 440, 291, 14, 9325, 63, 1205, 26, 288, 746, 1125, 267, 291, 14, 9325, 63, 1205, 275, 756, 267, 372, 715,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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 ]
savoirfairelinux/odoo
addons/account/project/wizard/account_analytic_chart.py
362
2100
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv class account_analytic_chart(osv.osv_memory): _name = 'account.analytic.chart' _description = 'Account Analytic Chart' _columns = { 'from_date': fields.date('From'), 'to_date': fields.date('To'), } def analytic_account_chart_open_window(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') result_context = {} if context is None: context = {} result = mod_obj.get_object_reference(cr, uid, 'account', 'action_account_analytic_account_tree2') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0] data = self.read(cr, uid, ids, [])[0] if data['from_date']: result_context.update({'from_date': data['from_date']}) if data['to_date']: result_context.update({'to_date': data['to_date']}) result['context'] = str(result_context) return result # 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, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 9782, 63, 9019, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 2048, 14, 9782, 14, 9019, 7, 272, 485, 1802, 275, 283, 6009, 14279, 764, 24874, 7, 339, 485, 3406, 275, 469, 267, 283, 504, 63, 602, 356, 1504, 14, 602, 360, 2532, 659, 267, 283, 475, 63, 602, 356, 1504, 14, 602, 360, 1378, 659, 272, 789, 339, 347, 20705, 63, 2048, 63, 9019, 63, 1490, 63, 3806, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 3413, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 267, 2454, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 2442, 63, 3806, 358, 267, 754, 63, 1100, 275, 1052, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 754, 275, 3413, 63, 1113, 14, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 297, 283, 1287, 63, 2048, 63, 9782, 63, 2048, 63, 2350, 18, 358, 267, 1305, 275, 754, 436, 754, 59, 17, 61, 503, 756, 267, 754, 275, 2454, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 344, 467, 1067, 29, 1100, 2788, 16, 61, 267, 666, 275, 291, 14, 739, 8, 1556, 12, 1747, 12, 2762, 12, 3073, 59, 16, 61, 267, 340, 666, 459, 504, 63, 602, 2565, 288, 754, 63, 1100, 14, 873, 3252, 504, 63, 602, 356, 666, 459, 504, 63, 602, 13678, 267, 340, 666, 459, 475, 63, 602, 2565, 288, 754, 63, 1100, 14, 873, 3252, 475, 63, 602, 356, 666, 459, 475, 63, 602, 13678, 267, 754, 459, 1100, 418, 275, 620, 8, 1099, 63, 1100, 9, 267, 372, 754, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 9782, 63, 9019, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 2048, 14, 9782, 14, 9019, 7, 272, 485, 1802, 275, 283, 6009, 14279, 764, 24874, 7, 339, 485, 3406, 275, 469, 267, 283, 504, 63, 602, 356, 1504, 14, 602, 360, 2532, 659, 267, 283, 475, 63, 602, 356, 1504, 14, 602, 360, 1378, 659, 272, 789, 339, 347, 20705, 63, 2048, 63, 9019, 63, 1490, 63, 3806, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 3413, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 267, 2454, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 2442, 63, 3806, 358, 267, 754, 63, 1100, 275, 1052, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 754, 275, 3413, 63, 1113, 14, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 297, 283, 1287, 63, 2048, 63, 9782, 63, 2048, 63, 2350, 18, 358, 267, 1305, 275, 754, 436, 754, 59, 17, 61, 503, 756, 267, 754, 275, 2454, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 344, 467, 1067, 29, 1100, 2788, 16, 61, 267, 666, 275, 291, 14, 739, 8, 1556, 12, 1747, 12, 2762, 12, 3073, 59, 16, 61, 267, 340, 666, 459, 504, 63, 602, 2565, 288, 754, 63, 1100, 14, 873, 3252, 504, 63, 602, 356, 666, 459, 504, 63, 602, 13678, 267, 340, 666, 459, 475, 63, 602, 2565, 288, 754, 63, 1100, 14, 873, 3252, 475, 63, 602, 356, 666, 459, 475, 63, 602, 13678, 267, 754, 459, 1100, 418, 275, 620, 8, 1099, 63, 1100, 9, 267, 372, 754, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 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 ]
w1ll1am23/home-assistant
tests/components/homekit/test_aidmanager.py
8
22428
"""Tests for the HomeKit AID manager.""" import os from unittest.mock import patch from fnvhash import fnv1a_32 import pytest from homeassistant.components.homekit.aidmanager import ( AccessoryAidStorage, get_aid_storage_filename_for_entry_id, get_system_unique_id, ) from homeassistant.helpers import device_registry from homeassistant.helpers.storage import STORAGE_DIR from tests.common import MockConfigEntry, mock_device_registry, mock_registry @pytest.fixture def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass) @pytest.fixture def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass) async def test_aid_generation(hass, device_reg, entity_reg): """Test generating aids.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")}, ) light_ent = entity_reg.async_get_or_create( "light", "device", "unique_id", device_id=device_entry.id ) light_ent2 = entity_reg.async_get_or_create( "light", "device", "other_unique_id", device_id=device_entry.id ) remote_ent = entity_reg.async_get_or_create( "remote", "device", "unique_id", device_id=device_entry.id ) hass.states.async_set(light_ent.entity_id, "on") hass.states.async_set(light_ent2.entity_id, "on") hass.states.async_set(remote_ent.entity_id, "on") hass.states.async_set("remote.has_no_unique_id", "on") with patch( "homeassistant.components.homekit.aidmanager.AccessoryAidStorage.async_schedule_save" ): aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_initialize() for _ in range(0, 2): assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent.entity_id) == 1953095294 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent2.entity_id) == 1975378727 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id(remote_ent.entity_id) == 3508011530 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id("remote.has_no_unique_id") == 1751603975 ) aid_storage.delete_aid(get_system_unique_id(light_ent)) aid_storage.delete_aid(get_system_unique_id(light_ent2)) aid_storage.delete_aid(get_system_unique_id(remote_ent)) aid_storage.delete_aid("non-existant-one") for _ in range(0, 2): assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent.entity_id) == 1953095294 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent2.entity_id) == 1975378727 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id(remote_ent.entity_id) == 3508011530 ) assert ( aid_storage.get_or_allocate_aid_for_entity_id("remote.has_no_unique_id") == 1751603975 ) async def test_no_aid_collision(hass, device_reg, entity_reg): """Test generating aids.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")}, ) with patch( "homeassistant.components.homekit.aidmanager.AccessoryAidStorage.async_schedule_save" ): aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_initialize() seen_aids = set() for unique_id in range(0, 202): ent = entity_reg.async_get_or_create( "light", "device", unique_id, device_id=device_entry.id ) hass.states.async_set(ent.entity_id, "on") aid = aid_storage.get_or_allocate_aid_for_entity_id(ent.entity_id) assert aid not in seen_aids seen_aids.add(aid) async def test_aid_generation_no_unique_ids_handles_collision( hass, device_reg, entity_reg ): """Test colliding aids is stable.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_initialize() device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")}, ) seen_aids = set() collisions = [] for light_id in range(0, 220): entity_id = f"light.light{light_id}" hass.states.async_set(entity_id, "on") expected_aid = fnv1a_32(entity_id.encode("utf-8")) aid = aid_storage.get_or_allocate_aid_for_entity_id(entity_id) if aid != expected_aid: collisions.append(entity_id) assert aid not in seen_aids seen_aids.add(aid) light_ent = entity_reg.async_get_or_create( "light", "device", "unique_id", device_id=device_entry.id ) hass.states.async_set(light_ent.entity_id, "on") aid_storage.get_or_allocate_aid_for_entity_id(light_ent.entity_id) assert not collisions assert aid_storage.allocations == { "device.light.unique_id": 1953095294, "light.light0": 301577847, "light.light1": 284800228, "light.light10": 2367138236, "light.light100": 2822760292, "light.light101": 2839537911, "light.light102": 2856315530, "light.light103": 2873093149, "light.light104": 2755649816, "light.light105": 2772427435, "light.light106": 2789205054, "light.light107": 2805982673, "light.light108": 2688539340, "light.light109": 2705316959, "light.light11": 2383915855, "light.light110": 776141037, "light.light111": 759363418, "light.light112": 742585799, "light.light113": 725808180, "light.light114": 709030561, "light.light115": 692252942, "light.light116": 675475323, "light.light117": 658697704, "light.light118": 641920085, "light.light119": 625142466, "light.light12": 2400693474, "light.light120": 340070038, "light.light121": 356847657, "light.light122": 306514800, "light.light123": 323292419, "light.light124": 407180514, "light.light125": 423958133, "light.light126": 373625276, "light.light127": 390402895, "light.light128": 474290990, "light.light129": 491068609, "light.light13": 2417471093, "light.light130": 440882847, "light.light131": 424105228, "light.light132": 474438085, "light.light133": 457660466, "light.light134": 373772371, "light.light135": 356994752, "light.light136": 407327609, "light.light137": 390549990, "light.light138": 575103799, "light.light139": 558326180, "light.light14": 2300027760, "light.light140": 271973824, "light.light141": 288751443, "light.light142": 305529062, "light.light143": 322306681, "light.light144": 339084300, "light.light145": 355861919, "light.light146": 372639538, "light.light147": 389417157, "light.light148": 406194776, "light.light149": 422972395, "light.light15": 2316805379, "light.light150": 2520321865, "light.light151": 2503544246, "light.light152": 2486766627, "light.light153": 2469989008, "light.light154": 2587432341, "light.light155": 2570654722, "light.light156": 2553877103, "light.light157": 2537099484, "light.light158": 2654542817, "light.light159": 2637765198, "light.light16": 2333582998, "light.light160": 2621134674, "light.light161": 2637912293, "light.light162": 2587579436, "light.light163": 2604357055, "light.light164": 2554024198, "light.light165": 2570801817, "light.light166": 2520468960, "light.light167": 2537246579, "light.light168": 2755355626, "light.light169": 2772133245, "light.light17": 2350360617, "light.light170": 2721947483, "light.light171": 2705169864, "light.light172": 2755502721, "light.light173": 2738725102, "light.light174": 2789057959, "light.light175": 2772280340, "light.light176": 2822613197, "light.light177": 2805835578, "light.light178": 2587726531, "light.light179": 2570948912, "light.light18": 2501359188, "light.light180": 408166252, "light.light181": 424943871, "light.light182": 441721490, "light.light183": 458499109, "light.light184": 341055776, "light.light185": 357833395, "light.light186": 374611014, "light.light187": 391388633, "light.light188": 542387204, "light.light189": 559164823, "light.light19": 2518136807, "light.light190": 508979061, "light.light191": 492201442, "light.light192": 475423823, "light.light193": 458646204, "light.light194": 441868585, "light.light195": 425090966, "light.light196": 408313347, "light.light197": 391535728, "light.light198": 643200013, "light.light199": 626422394, "light.light2": 335133085, "light.light20": 522144599, "light.light200": 1698935589, "light.light201": 1682157970, "light.light202": 1665380351, "light.light203": 1648602732, "light.light204": 1631825113, "light.light205": 1615047494, "light.light206": 1598269875, "light.light207": 1581492256, "light.light208": 1833156541, "light.light209": 1816378922, "light.light21": 505366980, "light.light210": 1598122780, "light.light211": 1614900399, "light.light212": 1631678018, "light.light213": 1648455637, "light.light214": 1531012304, "light.light215": 1547789923, "light.light216": 1564567542, "light.light217": 1581345161, "light.light218": 1732343732, "light.light219": 1749121351, "light.light22": 555699837, "light.light23": 538922218, "light.light24": 455034123, "light.light25": 438256504, "light.light26": 488589361, "light.light27": 471811742, "light.light28": 387923647, "light.light29": 371146028, "light.light3": 318355466, "light.light30": 421331790, "light.light31": 438109409, "light.light32": 387776552, "light.light33": 404554171, "light.light34": 488442266, "light.light35": 505219885, "light.light36": 454887028, "light.light37": 471664647, "light.light38": 287110838, "light.light39": 303888457, "light.light4": 234467371, "light.light40": 454048385, "light.light41": 437270766, "light.light42": 420493147, "light.light43": 403715528, "light.light44": 521158861, "light.light45": 504381242, "light.light46": 487603623, "light.light47": 470826004, "light.light48": 319827433, "light.light49": 303049814, "light.light5": 217689752, "light.light50": 353235576, "light.light51": 370013195, "light.light52": 386790814, "light.light53": 403568433, "light.light54": 420346052, "light.light55": 437123671, "light.light56": 453901290, "light.light57": 470678909, "light.light58": 219014624, "light.light59": 235792243, "light.light6": 268022609, "light.light60": 2266325427, "light.light61": 2249547808, "light.light62": 2299880665, "light.light63": 2283103046, "light.light64": 2333435903, "light.light65": 2316658284, "light.light66": 2366991141, "light.light67": 2350213522, "light.light68": 2400546379, "light.light69": 2383768760, "light.light7": 251244990, "light.light70": 554861194, "light.light71": 571638813, "light.light72": 521305956, "light.light73": 538083575, "light.light74": 487750718, "light.light75": 504528337, "light.light76": 454195480, "light.light77": 470973099, "light.light78": 420640242, "light.light79": 437417861, "light.light8": 167356895, "light.light80": 2735113021, "light.light81": 2718335402, "light.light82": 2701557783, "light.light83": 2684780164, "light.light84": 2668002545, "light.light85": 2651224926, "light.light86": 2634447307, "light.light87": 2617669688, "light.light88": 2600892069, "light.light89": 2584114450, "light.light9": 150579276, "light.light90": 2634300212, "light.light91": 2651077831, "light.light92": 2667855450, "light.light93": 2684633069, "light.light94": 2567189736, "light.light95": 2583967355, "light.light96": 2600744974, "light.light97": 2617522593, "light.light98": 2500079260, "light.light99": 2516856879, } await aid_storage.async_save() await hass.async_block_till_done() with patch("fnvhash.fnv1a_32", side_effect=Exception): aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_initialize() assert aid_storage.allocations == { "device.light.unique_id": 1953095294, "light.light0": 301577847, "light.light1": 284800228, "light.light10": 2367138236, "light.light100": 2822760292, "light.light101": 2839537911, "light.light102": 2856315530, "light.light103": 2873093149, "light.light104": 2755649816, "light.light105": 2772427435, "light.light106": 2789205054, "light.light107": 2805982673, "light.light108": 2688539340, "light.light109": 2705316959, "light.light11": 2383915855, "light.light110": 776141037, "light.light111": 759363418, "light.light112": 742585799, "light.light113": 725808180, "light.light114": 709030561, "light.light115": 692252942, "light.light116": 675475323, "light.light117": 658697704, "light.light118": 641920085, "light.light119": 625142466, "light.light12": 2400693474, "light.light120": 340070038, "light.light121": 356847657, "light.light122": 306514800, "light.light123": 323292419, "light.light124": 407180514, "light.light125": 423958133, "light.light126": 373625276, "light.light127": 390402895, "light.light128": 474290990, "light.light129": 491068609, "light.light13": 2417471093, "light.light130": 440882847, "light.light131": 424105228, "light.light132": 474438085, "light.light133": 457660466, "light.light134": 373772371, "light.light135": 356994752, "light.light136": 407327609, "light.light137": 390549990, "light.light138": 575103799, "light.light139": 558326180, "light.light14": 2300027760, "light.light140": 271973824, "light.light141": 288751443, "light.light142": 305529062, "light.light143": 322306681, "light.light144": 339084300, "light.light145": 355861919, "light.light146": 372639538, "light.light147": 389417157, "light.light148": 406194776, "light.light149": 422972395, "light.light15": 2316805379, "light.light150": 2520321865, "light.light151": 2503544246, "light.light152": 2486766627, "light.light153": 2469989008, "light.light154": 2587432341, "light.light155": 2570654722, "light.light156": 2553877103, "light.light157": 2537099484, "light.light158": 2654542817, "light.light159": 2637765198, "light.light16": 2333582998, "light.light160": 2621134674, "light.light161": 2637912293, "light.light162": 2587579436, "light.light163": 2604357055, "light.light164": 2554024198, "light.light165": 2570801817, "light.light166": 2520468960, "light.light167": 2537246579, "light.light168": 2755355626, "light.light169": 2772133245, "light.light17": 2350360617, "light.light170": 2721947483, "light.light171": 2705169864, "light.light172": 2755502721, "light.light173": 2738725102, "light.light174": 2789057959, "light.light175": 2772280340, "light.light176": 2822613197, "light.light177": 2805835578, "light.light178": 2587726531, "light.light179": 2570948912, "light.light18": 2501359188, "light.light180": 408166252, "light.light181": 424943871, "light.light182": 441721490, "light.light183": 458499109, "light.light184": 341055776, "light.light185": 357833395, "light.light186": 374611014, "light.light187": 391388633, "light.light188": 542387204, "light.light189": 559164823, "light.light19": 2518136807, "light.light190": 508979061, "light.light191": 492201442, "light.light192": 475423823, "light.light193": 458646204, "light.light194": 441868585, "light.light195": 425090966, "light.light196": 408313347, "light.light197": 391535728, "light.light198": 643200013, "light.light199": 626422394, "light.light2": 335133085, "light.light20": 522144599, "light.light200": 1698935589, "light.light201": 1682157970, "light.light202": 1665380351, "light.light203": 1648602732, "light.light204": 1631825113, "light.light205": 1615047494, "light.light206": 1598269875, "light.light207": 1581492256, "light.light208": 1833156541, "light.light209": 1816378922, "light.light21": 505366980, "light.light210": 1598122780, "light.light211": 1614900399, "light.light212": 1631678018, "light.light213": 1648455637, "light.light214": 1531012304, "light.light215": 1547789923, "light.light216": 1564567542, "light.light217": 1581345161, "light.light218": 1732343732, "light.light219": 1749121351, "light.light22": 555699837, "light.light23": 538922218, "light.light24": 455034123, "light.light25": 438256504, "light.light26": 488589361, "light.light27": 471811742, "light.light28": 387923647, "light.light29": 371146028, "light.light3": 318355466, "light.light30": 421331790, "light.light31": 438109409, "light.light32": 387776552, "light.light33": 404554171, "light.light34": 488442266, "light.light35": 505219885, "light.light36": 454887028, "light.light37": 471664647, "light.light38": 287110838, "light.light39": 303888457, "light.light4": 234467371, "light.light40": 454048385, "light.light41": 437270766, "light.light42": 420493147, "light.light43": 403715528, "light.light44": 521158861, "light.light45": 504381242, "light.light46": 487603623, "light.light47": 470826004, "light.light48": 319827433, "light.light49": 303049814, "light.light5": 217689752, "light.light50": 353235576, "light.light51": 370013195, "light.light52": 386790814, "light.light53": 403568433, "light.light54": 420346052, "light.light55": 437123671, "light.light56": 453901290, "light.light57": 470678909, "light.light58": 219014624, "light.light59": 235792243, "light.light6": 268022609, "light.light60": 2266325427, "light.light61": 2249547808, "light.light62": 2299880665, "light.light63": 2283103046, "light.light64": 2333435903, "light.light65": 2316658284, "light.light66": 2366991141, "light.light67": 2350213522, "light.light68": 2400546379, "light.light69": 2383768760, "light.light7": 251244990, "light.light70": 554861194, "light.light71": 571638813, "light.light72": 521305956, "light.light73": 538083575, "light.light74": 487750718, "light.light75": 504528337, "light.light76": 454195480, "light.light77": 470973099, "light.light78": 420640242, "light.light79": 437417861, "light.light8": 167356895, "light.light80": 2735113021, "light.light81": 2718335402, "light.light82": 2701557783, "light.light83": 2684780164, "light.light84": 2668002545, "light.light85": 2651224926, "light.light86": 2634447307, "light.light87": 2617669688, "light.light88": 2600892069, "light.light89": 2584114450, "light.light9": 150579276, "light.light90": 2634300212, "light.light91": 2651077831, "light.light92": 2667855450, "light.light93": 2684633069, "light.light94": 2567189736, "light.light95": 2583967355, "light.light96": 2600744974, "light.light97": 2617522593, "light.light98": 2500079260, "light.light99": 2516856879, } aidstore = get_aid_storage_filename_for_entry_id(config_entry.entry_id) aid_storage_path = hass.config.path(STORAGE_DIR, aidstore) if await hass.async_add_executor_job(os.path.exists, aid_storage_path): await hass.async_add_executor_job(os.unlink, aid_storage_path)
apache-2.0
[ 624, 2925, 367, 314, 14621, 14591, 437, 998, 5256, 1041, 199, 646, 747, 199, 504, 2882, 14, 1805, 492, 3371, 199, 199, 504, 4325, 86, 2227, 492, 4325, 86, 17, 65, 63, 708, 199, 646, 4613, 199, 199, 504, 8846, 14, 4608, 14, 4219, 6065, 14, 21745, 2609, 492, 334, 272, 11003, 1089, 33, 344, 6408, 12, 272, 664, 63, 21745, 63, 3494, 63, 1501, 63, 509, 63, 2373, 63, 344, 12, 272, 664, 63, 2253, 63, 3235, 63, 344, 12, 199, 9, 199, 504, 8846, 14, 7546, 492, 2243, 63, 5189, 199, 504, 8846, 14, 7546, 14, 3494, 492, 4384, 726, 2962, 63, 3022, 199, 199, 504, 2295, 14, 2330, 492, 4420, 2028, 3900, 12, 1683, 63, 1782, 63, 5189, 12, 1683, 63, 5189, 421, 199, 32, 4462, 14, 5997, 199, 318, 2243, 63, 1135, 8, 5387, 304, 272, 408, 1767, 376, 2701, 12, 6511, 12, 7086, 1041, 272, 372, 1683, 63, 1782, 63, 5189, 8, 5387, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 4642, 63, 1135, 8, 5387, 304, 272, 408, 1767, 376, 2701, 12, 6511, 12, 7086, 1041, 272, 372, 1683, 63, 5189, 8, 5387, 9, 421, 199, 4146, 347, 511, 63, 21745, 63, 15043, 8, 5387, 12, 2243, 63, 1135, 12, 4642, 63, 1135, 304, 272, 408, 774, 12999, 282, 1580, 1041, 272, 1101, 63, 2373, 275, 4420, 2028, 3900, 8, 2261, 628, 396, 401, 666, 21146, 272, 1101, 63, 2373, 14, 525, 63, 475, 63, 5387, 8, 5387, 9, 272, 2243, 63, 2373, 275, 2243, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 1101, 63, 2373, 63, 344, 29, 888, 63, 2373, 14, 2373, 63, 344, 12, 267, 6947, 3126, 8, 1782, 63, 5189, 14, 18389, 63, 14560, 63, 9410, 12, 298, 713, 26, 1082, 26, 1367, 26, 1217, 26, 7695, 26, 14153, 25988, 272, 776, 272, 10540, 63, 484, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 4040, 401, 298, 1782, 401, 298, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 10540, 63, 484, 18, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 4040, 401, 298, 1782, 401, 298, 1848, 63, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 3982, 63, 484, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 3846, 401, 298, 1782, 401, 298, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 4040, 63, 484, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 3846, 63, 484, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 401, 298, 265, 531, 339, 543, 3371, 8, 267, 298, 22799, 14, 4608, 14, 4219, 6065, 14, 21745, 2609, 14, 3946, 1089, 33, 344, 6408, 14, 4146, 63, 7211, 63, 2117, 2, 272, 3461, 267, 23939, 63, 3494, 275, 11003, 1089, 33, 344, 6408, 8, 5387, 12, 1101, 63, 2373, 9, 272, 5517, 23939, 63, 3494, 14, 4146, 63, 8489, 342, 339, 367, 485, 315, 1425, 8, 16, 12, 499, 304, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 413, 2720, 1216, 2720, 10693, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 9, 288, 508, 5851, 2194, 1401, 1555, 1465, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 3846, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 650, 14585, 614, 1046, 1216, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 531, 288, 508, 27306, 8488, 1355, 2194, 267, 776, 339, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 4040, 63, 484, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 4040, 63, 484, 18, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 3846, 63, 484, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 480, 2865, 13, 4494, 867, 13, 368, 531, 339, 367, 485, 315, 1425, 8, 16, 12, 499, 304, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 413, 2720, 1216, 2720, 10693, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 9, 288, 508, 5851, 2194, 1401, 1555, 1465, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 3846, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 650, 14585, 614, 1046, 1216, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 531, 288, 508, 27306, 8488, 1355, 2194, 267, 776, 421, 199, 4146, 347, 511, 63, 889, 63, 21745, 63, 761, 23656, 8, 5387, 12, 2243, 63, 1135, 12, 4642, 63, 1135, 304, 272, 408, 774, 12999, 282, 1580, 1041, 272, 1101, 63, 2373, 275, 4420, 2028, 3900 ]
[ 2925, 367, 314, 14621, 14591, 437, 998, 5256, 1041, 199, 646, 747, 199, 504, 2882, 14, 1805, 492, 3371, 199, 199, 504, 4325, 86, 2227, 492, 4325, 86, 17, 65, 63, 708, 199, 646, 4613, 199, 199, 504, 8846, 14, 4608, 14, 4219, 6065, 14, 21745, 2609, 492, 334, 272, 11003, 1089, 33, 344, 6408, 12, 272, 664, 63, 21745, 63, 3494, 63, 1501, 63, 509, 63, 2373, 63, 344, 12, 272, 664, 63, 2253, 63, 3235, 63, 344, 12, 199, 9, 199, 504, 8846, 14, 7546, 492, 2243, 63, 5189, 199, 504, 8846, 14, 7546, 14, 3494, 492, 4384, 726, 2962, 63, 3022, 199, 199, 504, 2295, 14, 2330, 492, 4420, 2028, 3900, 12, 1683, 63, 1782, 63, 5189, 12, 1683, 63, 5189, 421, 199, 32, 4462, 14, 5997, 199, 318, 2243, 63, 1135, 8, 5387, 304, 272, 408, 1767, 376, 2701, 12, 6511, 12, 7086, 1041, 272, 372, 1683, 63, 1782, 63, 5189, 8, 5387, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 4642, 63, 1135, 8, 5387, 304, 272, 408, 1767, 376, 2701, 12, 6511, 12, 7086, 1041, 272, 372, 1683, 63, 5189, 8, 5387, 9, 421, 199, 4146, 347, 511, 63, 21745, 63, 15043, 8, 5387, 12, 2243, 63, 1135, 12, 4642, 63, 1135, 304, 272, 408, 774, 12999, 282, 1580, 1041, 272, 1101, 63, 2373, 275, 4420, 2028, 3900, 8, 2261, 628, 396, 401, 666, 21146, 272, 1101, 63, 2373, 14, 525, 63, 475, 63, 5387, 8, 5387, 9, 272, 2243, 63, 2373, 275, 2243, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 1101, 63, 2373, 63, 344, 29, 888, 63, 2373, 14, 2373, 63, 344, 12, 267, 6947, 3126, 8, 1782, 63, 5189, 14, 18389, 63, 14560, 63, 9410, 12, 298, 713, 26, 1082, 26, 1367, 26, 1217, 26, 7695, 26, 14153, 25988, 272, 776, 272, 10540, 63, 484, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 4040, 401, 298, 1782, 401, 298, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 10540, 63, 484, 18, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 4040, 401, 298, 1782, 401, 298, 1848, 63, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 3982, 63, 484, 275, 4642, 63, 1135, 14, 4146, 63, 362, 63, 269, 63, 981, 8, 267, 298, 3846, 401, 298, 1782, 401, 298, 3235, 63, 344, 401, 2243, 63, 344, 29, 1782, 63, 2373, 14, 344, 272, 776, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 4040, 63, 484, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 8, 3846, 63, 484, 14, 4502, 63, 344, 12, 298, 265, 531, 272, 6298, 14, 4981, 14, 4146, 63, 409, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 401, 298, 265, 531, 339, 543, 3371, 8, 267, 298, 22799, 14, 4608, 14, 4219, 6065, 14, 21745, 2609, 14, 3946, 1089, 33, 344, 6408, 14, 4146, 63, 7211, 63, 2117, 2, 272, 3461, 267, 23939, 63, 3494, 275, 11003, 1089, 33, 344, 6408, 8, 5387, 12, 1101, 63, 2373, 9, 272, 5517, 23939, 63, 3494, 14, 4146, 63, 8489, 342, 339, 367, 485, 315, 1425, 8, 16, 12, 499, 304, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 413, 2720, 1216, 2720, 10693, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 9, 288, 508, 5851, 2194, 1401, 1555, 1465, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 3846, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 650, 14585, 614, 1046, 1216, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 531, 288, 508, 27306, 8488, 1355, 2194, 267, 776, 339, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 4040, 63, 484, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 4040, 63, 484, 18, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 8, 362, 63, 2253, 63, 3235, 63, 344, 8, 3846, 63, 484, 430, 272, 23939, 63, 3494, 14, 1807, 63, 21745, 480, 2865, 13, 4494, 867, 13, 368, 531, 339, 367, 485, 315, 1425, 8, 16, 12, 499, 304, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 413, 2720, 1216, 2720, 10693, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 4040, 63, 484, 18, 14, 4502, 63, 344, 9, 288, 508, 5851, 2194, 1401, 1555, 1465, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 8, 3846, 63, 484, 14, 4502, 63, 344, 9, 288, 508, 650, 14585, 614, 1046, 1216, 267, 776, 267, 702, 334, 288, 23939, 63, 3494, 14, 362, 63, 269, 63, 12991, 63, 21745, 63, 509, 63, 4502, 63, 344, 480, 3846, 14, 1989, 63, 889, 63, 3235, 63, 344, 531, 288, 508, 27306, 8488, 1355, 2194, 267, 776, 421, 199,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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 ]
badock/nova
nova/api/openstack/compute/contrib/createserverext.py
100
1156
# Copyright 2011 OpenStack Foundation # # 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 nova.api.openstack import extensions class Createserverext(extensions.ExtensionDescriptor): """Extended support to the Create Server v1.1 API.""" name = "Createserverext" alias = "os-create-server-ext" namespace = ("http://docs.openstack.org/compute/ext/" "createserverext/api/v1.1") updated = "2011-07-19T00:00:00Z" def get_resources(self): res = extensions.ResourceExtension('os-create-server-ext', inherits='servers') return [res]
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 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, 5913, 14, 1246, 14, 8512, 492, 5478, 421, 199, 533, 2790, 4909, 264, 400, 8, 5359, 14, 6382, 4311, 304, 272, 408, 14107, 2291, 370, 314, 2790, 7146, 373, 17, 14, 17, 3261, 1041, 339, 536, 275, 298, 2499, 4909, 264, 400, 2, 272, 5162, 275, 298, 736, 13, 981, 13, 1000, 13, 832, 2, 272, 3231, 275, 1689, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 6687, 326, 298, 981, 4909, 264, 400, 15, 1246, 15, 86, 17, 14, 17, 531, 272, 4588, 275, 298, 8128, 13, 1780, 13, 1167, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 522, 275, 5478, 14, 4031, 6382, 360, 736, 13, 981, 13, 1000, 13, 832, 297, 5644, 21592, 534, 5871, 358, 267, 372, 359, 470, 61, 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 ]
[ 1898, 7760, 14260, 2752, 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, 5913, 14, 1246, 14, 8512, 492, 5478, 421, 199, 533, 2790, 4909, 264, 400, 8, 5359, 14, 6382, 4311, 304, 272, 408, 14107, 2291, 370, 314, 2790, 7146, 373, 17, 14, 17, 3261, 1041, 339, 536, 275, 298, 2499, 4909, 264, 400, 2, 272, 5162, 275, 298, 736, 13, 981, 13, 1000, 13, 832, 2, 272, 3231, 275, 1689, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 6687, 326, 298, 981, 4909, 264, 400, 15, 1246, 15, 86, 17, 14, 17, 531, 272, 4588, 275, 298, 8128, 13, 1780, 13, 1167, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 522, 275, 5478, 14, 4031, 6382, 360, 736, 13, 981, 13, 1000, 13, 832, 297, 5644, 21592, 534, 5871, 358, 267, 372, 359, 470, 61, 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, 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,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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 ]
vrkansagara/ultisnips
pythonx/UltiSnips/vim_state.py
22
4763
#!/usr/bin/env python # encoding: utf-8 """Some classes to conserve Vim's state for comparing over time.""" from collections import deque from UltiSnips import _vim from UltiSnips.compatibility import as_unicode, byte2col from UltiSnips.position import Position class VimPosition(Position): """Represents the current position in the buffer, together with some status variables that might change our decisions down the line.""" def __init__(self): pos = _vim.buf.cursor self._mode = _vim.eval('mode()') Position.__init__(self, pos.line, pos.col) @property def mode(self): """Returns the mode() this position was created.""" return self._mode class VimState(object): """Caches some state information from Vim to better guess what editing tasks the user might have done in the last step.""" def __init__(self): self._poss = deque(maxlen=5) self._lvb = None self._text_to_expect = '' self._unnamed_reg_cached = False # We store the cached value of the unnamed register in Vim directly to # avoid any Unicode issues with saving and restoring the unnamed # register across the Python bindings. The unnamed register can contain # data that cannot be coerced to Unicode, and so a simple vim.eval('@"') # fails badly. Keeping the cached value in Vim directly, sidesteps the # problem. _vim.command('let g:_ultisnips_unnamed_reg_cache = ""') def remember_unnamed_register(self, text_to_expect): """Save the unnamed register. 'text_to_expect' is text that we expect to be contained in the register the next time this method is called - this could be text from the tabstop that was selected and might have been overwritten. We will not cache that then. """ self._unnamed_reg_cached = True escaped_text = self._text_to_expect.replace("'", "''") res = int(_vim.eval('@" != ' + "'" + escaped_text + "'")) if res: _vim.command('let g:_ultisnips_unnamed_reg_cache = @"') self._text_to_expect = text_to_expect def restore_unnamed_register(self): """Restores the unnamed register and forgets what we cached.""" if not self._unnamed_reg_cached: return _vim.command('let @" = g:_ultisnips_unnamed_reg_cache') self._unnamed_reg_cached = False def remember_position(self): """Remember the current position as a previous pose.""" self._poss.append(VimPosition()) def remember_buffer(self, to): """Remember the content of the buffer and the position.""" self._lvb = _vim.buf[to.start.line:to.end.line + 1] self._lvb_len = len(_vim.buf) self.remember_position() @property def diff_in_buffer_length(self): """Returns the difference in the length of the current buffer compared to the remembered.""" return len(_vim.buf) - self._lvb_len @property def pos(self): """The last remembered position.""" return self._poss[-1] @property def ppos(self): """The second to last remembered position.""" return self._poss[-2] @property def remembered_buffer(self): """The content of the remembered buffer.""" return self._lvb[:] class VisualContentPreserver(object): """Saves the current visual selection and the selection mode it was done in (e.g. line selection, block selection or regular selection.)""" def __init__(self): self.reset() def reset(self): """Forget the preserved state.""" self._mode = '' self._text = as_unicode('') def conserve(self): """Save the last visual selection ond the mode it was made in.""" sl, sbyte = map(int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map(int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval('visualmode()') _vim_line_with_eol = lambda ln: _vim.buf[ln] + '\n' if sl == el: text = _vim_line_with_eol(sl - 1)[sc:ec + 1] else: text = _vim_line_with_eol(sl - 1)[sc:] for cl in range(sl, el - 1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el - 1)[:ec + 1] self._text = text @property def text(self): """The conserved text.""" return self._text @property def mode(self): """The conserved visualmode().""" return self._mode
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 199, 624, 7700, 3992, 370, 406, 4909, 812, 1017, 1159, 1174, 367, 20234, 1806, 900, 1041, 199, 199, 504, 5055, 492, 15782, 199, 199, 504, 738, 21934, 20821, 6142, 492, 485, 16361, 199, 504, 738, 21934, 20821, 6142, 14, 15390, 492, 465, 63, 2975, 12, 3696, 18, 761, 199, 504, 738, 21934, 20821, 6142, 14, 3124, 492, 15483, 421, 199, 533, 812, 1017, 5625, 8, 5625, 304, 339, 408, 18089, 314, 1453, 3421, 315, 314, 3335, 12, 10451, 543, 2005, 2004, 272, 2860, 626, 5594, 1570, 4154, 12985, 1356, 3224, 314, 1004, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 2086, 275, 485, 16361, 14, 1436, 14, 3937, 267, 291, 423, 632, 275, 485, 16361, 14, 2579, 360, 632, 19004, 267, 15483, 855, 826, 721, 277, 12, 2086, 14, 604, 12, 2086, 14, 761, 9, 339, 768, 1829, 272, 347, 818, 8, 277, 304, 267, 408, 3407, 314, 818, 342, 642, 3421, 1990, 2737, 1041, 267, 372, 291, 423, 632, 421, 199, 533, 812, 1017, 2223, 8, 785, 304, 339, 408, 35, 1225, 397, 2005, 1174, 2556, 687, 812, 1017, 370, 8034, 9519, 4052, 20401, 272, 6527, 314, 922, 5594, 1172, 4224, 315, 314, 2061, 3650, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 555, 385, 275, 15782, 8, 29078, 29, 21, 9, 267, 291, 423, 6371, 66, 275, 488, 398, 291, 423, 505, 63, 475, 63, 4921, 275, 2125, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 756, 398, 327, 2136, 3877, 314, 6328, 574, 402, 314, 625, 4579, 2274, 315, 812, 1017, 5370, 370, 267, 327, 5126, 1263, 6140, 10876, 543, 13369, 436, 4618, 6854, 314, 625, 4579, 267, 327, 2274, 9371, 314, 2018, 17792, 14, 221, 710, 625, 4579, 2274, 883, 1395, 267, 327, 666, 626, 3913, 506, 20650, 6867, 370, 6140, 12, 436, 880, 282, 3486, 6695, 14, 2579, 16591, 9008, 267, 327, 6918, 4875, 590, 14, 221, 1804, 1024, 4073, 314, 6328, 574, 315, 812, 1017, 5370, 12, 5366, 5895, 314, 267, 327, 5160, 14, 267, 485, 16361, 14, 1531, 360, 2723, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 275, 3087, 358, 339, 347, 21027, 63, 9703, 63, 2683, 8, 277, 12, 1318, 63, 475, 63, 4921, 304, 267, 408, 8229, 314, 625, 4579, 2274, 14, 398, 283, 505, 63, 475, 63, 4921, 7, 365, 1318, 626, 781, 4282, 267, 370, 506, 10470, 315, 314, 2274, 314, 2163, 900, 642, 1083, 365, 2797, 446, 267, 642, 4293, 506, 1318, 687, 314, 20849, 626, 1990, 4895, 436, 5594, 1172, 267, 2757, 20200, 14, 2136, 911, 440, 2581, 626, 2066, 14, 398, 408, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 715, 267, 11077, 63, 505, 275, 291, 423, 505, 63, 475, 63, 4921, 14, 1814, 27769, 17172, 531, 267, 522, 275, 1109, 1547, 16361, 14, 2579, 16591, 2, 1137, 283, 435, 21673, 435, 11077, 63, 505, 435, 3546, 2237, 267, 340, 522, 26, 288, 485, 16361, 14, 1531, 360, 2723, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 275, 768, 9008, 267, 291, 423, 505, 63, 475, 63, 4921, 275, 1318, 63, 475, 63, 4921, 339, 347, 9066, 63, 9703, 63, 2683, 8, 277, 304, 267, 408, 13726, 7944, 314, 625, 4579, 2274, 436, 19459, 83, 4052, 781, 6328, 1041, 267, 340, 440, 291, 423, 9703, 63, 1135, 63, 5245, 26, 288, 372, 267, 485, 16361, 14, 1531, 360, 2723, 768, 2, 275, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 358, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 756, 339, 347, 21027, 63, 3124, 8, 277, 304, 267, 408, 497, 1114, 314, 1453, 3421, 465, 282, 4136, 1115, 261, 1041, 267, 291, 423, 555, 385, 14, 740, 8, 54, 1017, 5625, 1012, 339, 347, 21027, 63, 2738, 8, 277, 12, 370, 304, 267, 408, 497, 1114, 314, 1564, 402, 314, 3335, 436, 314, 3421, 1041, 267, 291, 423, 6371, 66, 275, 485, 16361, 14, 1436, 59, 475, 14, 928, 14, 604, 26, 475, 14, 500, 14, 604, 435, 413, 61, 267, 291, 423, 6371, 66, 63, 552, 275, 822, 1547, 16361, 14, 1436, 9, 267, 291, 14, 264, 1114, 63, 3124, 342, 339, 768, 1829, 272, 347, 3915, 63, 262, 63, 2738, 63, 1267, 8, 277, 304, 267, 408, 3407, 314, 8865, 315, 314, 2582, 402, 314, 1453, 3335, 13524, 267, 370, 314, 295, 278, 887, 16179, 1041, 267, 372, 822, 1547, 16361, 14, 1436, 9, 446, 291, 423, 6371, 66, 63, 552, 339, 768, 1829, 272, 347, 2086, 8, 277, 304, 267, 408, 1918, 2061, 295, 278, 887, 16179, 3421, 1041, 267, 372, 291, 423, 555, 385, 1988, 17, 61, 339, 768, 1829, 272, 347, 299, 1712, 8, 277, 304, 267, 408, 1918, 3499, 370, 2061, 295, 278, 887, 16179, 3421, 1041, 267, 372, 291, 423, 555, 385, 1988, 18, 61, 339, 768, 1829, 272, 347, 295, 278, 887, 16179, 63, 2738, 8, 277, 304, 267, 408, 1918, 1564, 402, 314, 295, 278, 887, 16179, 3335, 1041, 267, 372, 291, 423, 6371, 66, 5873, 421, 199, 533, 14702, 2714, 2398, 1000, 8, 785, 304, 339, 408, 51, 7047, 314, 1453, 13104, 7267, 436, 314, 7267, 818, 652, 1990, 4224, 315, 272, 334, 69, 14, 71, 14, 1004, 7267, 12, 1853, 7267, 503, 5578, 7267, 4959, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 1858, 362, 314, 17731, 1174, 1041, 267, 291, 423, 632, 275, 2125, 267, 291, 423, 505, 275, 465, 63, 2975, 8355, 339, 347, 406, 4909, 8, 277, 304, 267, 408, 8229, 314, 2061, 13104, 7267, 641, 68, 314, 818, 652, 1990, 6326, 315, 1041, 267, 5340, 12, 308, 4414, 275, 2341, 8, 442, 12, 717, 6110, 16361, 14, 2579, 4852, 604, 480, 7601, 531, 624, 395, 485, 16361, 14, 2579, 4852, 761, 480, 7601, 531, 624, 1724, 267, 579, 12, 325, 4414, 275, 2341, 8, 442, 12, 717, 6110, 16361, 14, 2579, 4852, 604, 480, 8423, 531, 624, 395, 485, 16361, 14, 2579, 4852, 761, 480, 8423, 531, 624 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 199, 624, 7700, 3992, 370, 406, 4909, 812, 1017, 1159, 1174, 367, 20234, 1806, 900, 1041, 199, 199, 504, 5055, 492, 15782, 199, 199, 504, 738, 21934, 20821, 6142, 492, 485, 16361, 199, 504, 738, 21934, 20821, 6142, 14, 15390, 492, 465, 63, 2975, 12, 3696, 18, 761, 199, 504, 738, 21934, 20821, 6142, 14, 3124, 492, 15483, 421, 199, 533, 812, 1017, 5625, 8, 5625, 304, 339, 408, 18089, 314, 1453, 3421, 315, 314, 3335, 12, 10451, 543, 2005, 2004, 272, 2860, 626, 5594, 1570, 4154, 12985, 1356, 3224, 314, 1004, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 2086, 275, 485, 16361, 14, 1436, 14, 3937, 267, 291, 423, 632, 275, 485, 16361, 14, 2579, 360, 632, 19004, 267, 15483, 855, 826, 721, 277, 12, 2086, 14, 604, 12, 2086, 14, 761, 9, 339, 768, 1829, 272, 347, 818, 8, 277, 304, 267, 408, 3407, 314, 818, 342, 642, 3421, 1990, 2737, 1041, 267, 372, 291, 423, 632, 421, 199, 533, 812, 1017, 2223, 8, 785, 304, 339, 408, 35, 1225, 397, 2005, 1174, 2556, 687, 812, 1017, 370, 8034, 9519, 4052, 20401, 272, 6527, 314, 922, 5594, 1172, 4224, 315, 314, 2061, 3650, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 555, 385, 275, 15782, 8, 29078, 29, 21, 9, 267, 291, 423, 6371, 66, 275, 488, 398, 291, 423, 505, 63, 475, 63, 4921, 275, 2125, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 756, 398, 327, 2136, 3877, 314, 6328, 574, 402, 314, 625, 4579, 2274, 315, 812, 1017, 5370, 370, 267, 327, 5126, 1263, 6140, 10876, 543, 13369, 436, 4618, 6854, 314, 625, 4579, 267, 327, 2274, 9371, 314, 2018, 17792, 14, 221, 710, 625, 4579, 2274, 883, 1395, 267, 327, 666, 626, 3913, 506, 20650, 6867, 370, 6140, 12, 436, 880, 282, 3486, 6695, 14, 2579, 16591, 9008, 267, 327, 6918, 4875, 590, 14, 221, 1804, 1024, 4073, 314, 6328, 574, 315, 812, 1017, 5370, 12, 5366, 5895, 314, 267, 327, 5160, 14, 267, 485, 16361, 14, 1531, 360, 2723, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 275, 3087, 358, 339, 347, 21027, 63, 9703, 63, 2683, 8, 277, 12, 1318, 63, 475, 63, 4921, 304, 267, 408, 8229, 314, 625, 4579, 2274, 14, 398, 283, 505, 63, 475, 63, 4921, 7, 365, 1318, 626, 781, 4282, 267, 370, 506, 10470, 315, 314, 2274, 314, 2163, 900, 642, 1083, 365, 2797, 446, 267, 642, 4293, 506, 1318, 687, 314, 20849, 626, 1990, 4895, 436, 5594, 1172, 267, 2757, 20200, 14, 2136, 911, 440, 2581, 626, 2066, 14, 398, 408, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 715, 267, 11077, 63, 505, 275, 291, 423, 505, 63, 475, 63, 4921, 14, 1814, 27769, 17172, 531, 267, 522, 275, 1109, 1547, 16361, 14, 2579, 16591, 2, 1137, 283, 435, 21673, 435, 11077, 63, 505, 435, 3546, 2237, 267, 340, 522, 26, 288, 485, 16361, 14, 1531, 360, 2723, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 275, 768, 9008, 267, 291, 423, 505, 63, 475, 63, 4921, 275, 1318, 63, 475, 63, 4921, 339, 347, 9066, 63, 9703, 63, 2683, 8, 277, 304, 267, 408, 13726, 7944, 314, 625, 4579, 2274, 436, 19459, 83, 4052, 781, 6328, 1041, 267, 340, 440, 291, 423, 9703, 63, 1135, 63, 5245, 26, 288, 372, 267, 485, 16361, 14, 1531, 360, 2723, 768, 2, 275, 486, 22003, 1141, 5167, 6142, 63, 9703, 63, 1135, 63, 1637, 358, 267, 291, 423, 9703, 63, 1135, 63, 5245, 275, 756, 339, 347, 21027, 63, 3124, 8, 277, 304, 267, 408, 497, 1114, 314, 1453, 3421, 465, 282, 4136, 1115, 261, 1041, 267, 291, 423, 555, 385, 14, 740, 8, 54, 1017, 5625, 1012, 339, 347, 21027, 63, 2738, 8, 277, 12, 370, 304, 267, 408, 497, 1114, 314, 1564, 402, 314, 3335, 436, 314, 3421, 1041, 267, 291, 423, 6371, 66, 275, 485, 16361, 14, 1436, 59, 475, 14, 928, 14, 604, 26, 475, 14, 500, 14, 604, 435, 413, 61, 267, 291, 423, 6371, 66, 63, 552, 275, 822, 1547, 16361, 14, 1436, 9, 267, 291, 14, 264, 1114, 63, 3124, 342, 339, 768, 1829, 272, 347, 3915, 63, 262, 63, 2738, 63, 1267, 8, 277, 304, 267, 408, 3407, 314, 8865, 315, 314, 2582, 402, 314, 1453, 3335, 13524, 267, 370, 314, 295, 278, 887, 16179, 1041, 267, 372, 822, 1547, 16361, 14, 1436, 9, 446, 291, 423, 6371, 66, 63, 552, 339, 768, 1829, 272, 347, 2086, 8, 277, 304, 267, 408, 1918, 2061, 295, 278, 887, 16179, 3421, 1041, 267, 372, 291, 423, 555, 385, 1988, 17, 61, 339, 768, 1829, 272, 347, 299, 1712, 8, 277, 304, 267, 408, 1918, 3499, 370, 2061, 295, 278, 887, 16179, 3421, 1041, 267, 372, 291, 423, 555, 385, 1988, 18, 61, 339, 768, 1829, 272, 347, 295, 278, 887, 16179, 63, 2738, 8, 277, 304, 267, 408, 1918, 1564, 402, 314, 295, 278, 887, 16179, 3335, 1041, 267, 372, 291, 423, 6371, 66, 5873, 421, 199, 533, 14702, 2714, 2398, 1000, 8, 785, 304, 339, 408, 51, 7047, 314, 1453, 13104, 7267, 436, 314, 7267, 818, 652, 1990, 4224, 315, 272, 334, 69, 14, 71, 14, 1004, 7267, 12, 1853, 7267, 503, 5578, 7267, 4959, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 1858, 362, 314, 17731, 1174, 1041, 267, 291, 423, 632, 275, 2125, 267, 291, 423, 505, 275, 465, 63, 2975, 8355, 339, 347, 406, 4909, 8, 277, 304, 267, 408, 8229, 314, 2061, 13104, 7267, 641, 68, 314, 818, 652, 1990, 6326, 315, 1041, 267, 5340, 12, 308, 4414, 275, 2341, 8, 442, 12, 717, 6110, 16361, 14, 2579, 4852, 604, 480, 7601, 531, 624, 395, 485, 16361, 14, 2579, 4852, 761, 480, 7601, 531, 624, 1724, 267, 579, 12, 325, 4414, 275, 2341, 8, 442, 12, 717, 6110, 16361, 14, 2579, 4852, 604, 480, 8423, 531, 624, 395, 485, 16361, 14, 2579, 4852, 761, 480, 8423, 531, 624, 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, 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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 ]
xianggong/m2c_unit_test
test/integer/mad_hi_uchar4uchar4uchar4/compile.py
1861
4430
#!/usr/bin/python import os import subprocess import re def runCommand(command): p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() return iter(p.stdout.readline, b'') def dumpRunCommand(command, dump_file_name, postfix): dumpFile = open(dump_file_name + postfix, "w+") dumpFile.write(command + "\n") for line in runCommand(command.split()): dumpFile.write(line) def rmFile(file_name): cmd = "rm -rf " + file_name runCommand(cmd.split()) def rnm_ir(file_name): # Append all unnamed variable with prefix 'tmp_' ir_file_name = file_name + ".ll" if os.path.isfile(ir_file_name): fo = open(ir_file_name, "rw+") lines = fo.readlines() fo.seek(0) fo.truncate() for line in lines: # Add entry block identifier if "define" in line: line += "entry:\n" # Rename all unnamed variables line = re.sub('\%([0-9]+)', r'%tmp_\1', line.rstrip()) # Also rename branch name line = re.sub('(\;\ \<label\>\:)([0-9]+)', r'tmp_\2:', line.rstrip()) fo.write(line + '\n') def gen_ir(file_name): # Directories root_dir = '../../../' header_dir = root_dir + "inc/" # Headers header = " -I " + header_dir header += " -include " + header_dir + "m2c_buildin_fix.h " header += " -include " + header_dir + "clc/clc.h " header += " -D cl_clang_storage_class_specifiers " gen_ir = "clang -S -emit-llvm -O0 -target r600-- -mcpu=verde " cmd_gen_ir = gen_ir + header + file_name + ".cl" dumpRunCommand(cmd_gen_ir, file_name, ".clang.log") def asm_ir(file_name): if os.path.isfile(file_name + ".ll"): # Command to assemble IR to bitcode gen_bc = "llvm-as " gen_bc_src = file_name + ".ll" gen_bc_dst = file_name + ".bc" cmd_gen_bc = gen_bc + gen_bc_src + " -o " + gen_bc_dst runCommand(cmd_gen_bc.split()) def opt_bc(file_name): if os.path.isfile(file_name + ".bc"): # Command to optmize bitcode opt_bc = "opt --mem2reg " opt_ir_src = file_name + ".bc" opt_ir_dst = file_name + ".opt.bc" cmd_opt_bc = opt_bc + opt_ir_src + " -o " + opt_ir_dst runCommand(cmd_opt_bc.split()) def dis_bc(file_name): if os.path.isfile(file_name + ".bc"): # Command to disassemble bitcode dis_bc = "llvm-dis " dis_ir_src = file_name + ".opt.bc" dis_ir_dst = file_name + ".opt.ll" cmd_dis_bc = dis_bc + dis_ir_src + " -o " + dis_ir_dst runCommand(cmd_dis_bc.split()) def m2c_gen(file_name): if os.path.isfile(file_name + ".opt.bc"): # Command to disassemble bitcode m2c_gen = "m2c --llvm2si " m2c_gen_src = file_name + ".opt.bc" cmd_m2c_gen = m2c_gen + m2c_gen_src dumpRunCommand(cmd_m2c_gen, file_name, ".m2c.llvm2si.log") # Remove file if size is 0 if os.path.isfile(file_name + ".opt.s"): if os.path.getsize(file_name + ".opt.s") == 0: rmFile(file_name + ".opt.s") def m2c_bin(file_name): if os.path.isfile(file_name + ".opt.s"): # Command to disassemble bitcode m2c_bin = "m2c --si2bin " m2c_bin_src = file_name + ".opt.s" cmd_m2c_bin = m2c_bin + m2c_bin_src dumpRunCommand(cmd_m2c_bin, file_name, ".m2c.si2bin.log") def main(): # Commands for file in os.listdir("./"): if file.endswith(".cl"): file_name = os.path.splitext(file)[0] # Execute commands gen_ir(file_name) rnm_ir(file_name) asm_ir(file_name) opt_bc(file_name) dis_bc(file_name) m2c_gen(file_name) m2c_bin(file_name) if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 421, 199, 318, 1255, 3110, 8, 1531, 304, 267, 299, 275, 3873, 14, 7942, 8, 1531, 12, 2490, 3839, 29, 5781, 14, 6089, 12, 2490, 4635, 29, 5781, 14, 13850, 9, 267, 299, 14, 2573, 342, 267, 372, 2740, 8, 80, 14, 2703, 14, 6407, 12, 330, 17483, 421, 199, 318, 5461, 2540, 3110, 8, 1531, 12, 5461, 63, 493, 63, 354, 12, 31478, 304, 267, 5461, 1173, 275, 1551, 8, 2724, 63, 493, 63, 354, 435, 31478, 12, 298, 87, 21425, 267, 5461, 1173, 14, 952, 8, 1531, 435, 1867, 78, 531, 267, 367, 1004, 315, 1255, 3110, 8, 1531, 14, 1294, 5109, 355, 5461, 1173, 14, 952, 8, 604, 9, 421, 199, 318, 14267, 1173, 8, 493, 63, 354, 304, 267, 2088, 275, 298, 5682, 446, 3941, 298, 435, 570, 63, 354, 267, 1255, 3110, 8, 1760, 14, 1294, 1012, 421, 199, 318, 519, 10756, 63, 723, 8, 493, 63, 354, 304, 267, 327, 18726, 1006, 625, 4579, 1750, 543, 2403, 283, 2791, 8650, 267, 8190, 63, 493, 63, 354, 275, 570, 63, 354, 435, 3680, 914, 2, 267, 340, 747, 14, 515, 14, 6292, 8, 723, 63, 493, 63, 354, 304, 355, 7090, 275, 1551, 8, 723, 63, 493, 63, 354, 12, 298, 13057, 21425, 355, 2385, 275, 7090, 14, 9684, 342, 355, 7090, 14, 5507, 8, 16, 9, 355, 7090, 14, 12517, 342, 355, 367, 1004, 315, 2385, 26, 717, 327, 2654, 2397, 1853, 5148, 717, 340, 298, 4640, 2, 315, 1004, 26, 1169, 1004, 847, 298, 2373, 3427, 78, 2, 717, 327, 22756, 1006, 625, 4579, 2860, 717, 1004, 275, 295, 14, 954, 2258, 5, 779, 16, 13, 25, 28798, 4228, 519, 5956, 2791, 18005, 17, 297, 4228, 1004, 14, 6735, 1012, 717, 327, 6121, 11441, 5246, 536, 717, 1004, 275, 295, 14, 954, 360, 2961, 3779, 971, 28, 1302, 60, 3072, 26, 31440, 16, 13, 25, 28798, 4228, 519, 1133, 311, 18005, 18, 6536, 4228, 1004, 14, 6735, 1012, 717, 7090, 14, 952, 8, 604, 435, 1557, 78, 358, 421, 199, 318, 3805, 63, 723, 8, 493, 63, 354, 304, 267, 327, 25596, 4253, 267, 1738, 63, 694, 275, 283, 9707, 703, 4805, 267, 1406, 63, 694, 275, 1738, 63, 694, 435, 298, 6559, 6687, 398, 327, 21391, 267, 1406, 275, 298, 446, 41, 298, 435, 1406, 63, 694, 267, 1406, 847, 298, 446, 2613, 298, 435, 1406, 63, 694, 435, 298, 77, 18, 67, 63, 1506, 262, 63, 970, 14, 72, 298, 267, 1406, 847, 298, 446, 2613, 298, 435, 1406, 63, 694, 435, 298, 23066, 15, 23066, 14, 72, 298, 267, 1406, 847, 298, 446, 36, 824, 63, 16066, 63, 3494, 63, 533, 63, 31659, 298, 398, 3805, 63, 723, 275, 298, 16066, 446, 51, 446, 8159, 13, 29257, 446, 47, 16, 446, 1375, 519, 6683, 306, 446, 77, 3541, 29, 422, 271, 298, 267, 2088, 63, 2268, 63, 723, 275, 3805, 63, 723, 435, 1406, 435, 570, 63, 354, 435, 3680, 429, 2, 267, 5461, 2540, 3110, 8, 1760, 63, 2268, 63, 723, 12, 570, 63, 354, 12, 3680, 16066, 14, 793, 531, 421, 199, 318, 21875, 63, 723, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 914, 2349, 267, 327, 5817, 370, 22931, 473, 50, 370, 4546, 600, 267, 3805, 63, 3776, 275, 298, 29257, 13, 305, 298, 267, 3805, 63, 3776, 63, 2164, 275, 570, 63, 354, 435, 3680, 914, 2, 267, 3805, 63, 3776, 63, 5119, 275, 570, 63, 354, 435, 3680, 3776, 2, 267, 2088, 63, 2268, 63, 3776, 275, 3805, 63, 3776, 435, 3805, 63, 3776, 63, 2164, 435, 298, 446, 79, 298, 435, 3805, 63, 3776, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2268, 63, 3776, 14, 1294, 1012, 421, 199, 318, 2450, 63, 3776, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 3776, 2349, 267, 327, 5817, 370, 2450, 77, 794, 4546, 600, 267, 2450, 63, 3776, 275, 298, 2992, 1553, 5286, 18, 1135, 298, 267, 2450, 63, 723, 63, 2164, 275, 570, 63, 354, 435, 3680, 3776, 2, 267, 2450, 63, 723, 63, 5119, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2088, 63, 2992, 63, 3776, 275, 2450, 63, 3776, 435, 2450, 63, 723, 63, 2164, 435, 298, 446, 79, 298, 435, 2450, 63, 723, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2992, 63, 3776, 14, 1294, 1012, 421, 199, 318, 2153, 63, 3776, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 3776, 2349, 267, 327, 5817, 370, 2153, 21263, 4546, 600, 267, 2153, 63, 3776, 275, 298, 29257, 13, 2297, 298, 267, 2153, 63, 723, 63, 2164, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2153, 63, 723, 63, 5119, 275, 570, 63, 354, 435, 3680, 2992, 14, 914, 2, 267, 2088, 63, 2297, 63, 3776, 275, 2153, 63, 3776, 435, 2153, 63, 723, 63, 2164, 435, 298, 446, 79, 298, 435, 2153, 63, 723, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2297, 63, 3776, 14, 1294, 1012, 421, 199, 318, 333, 18, 67, 63, 2268, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 2992, 14, 3776, 2349, 267, 327, 5817, 370, 2153, 21263, 4546, 600, 267, 333, 18, 67, 63, 2268, 275, 298, 77, 18, 67, 1553, 29257, 18, 338, 298, 267, 333, 18, 67, 63, 2268, 63, 2164, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2088, 63, 77, 18, 67, 63, 2268, 275, 333, 18, 67, 63, 2268, 435, 333, 18, 67, 63, 2268, 63, 2164, 267, 5461, 2540, 3110, 8, 1760, 63, 77, 18, 67, 63, 2268, 12, 570, 63, 354, 12, 3680, 77, 18, 67, 14, 29257, 18, 338, 14, 793, 531, 339, 327, 5852, 570, 340, 1568, 365, 378, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 2992, 14, 83, 2349, 267, 340, 747, 14, 515 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 421, 199, 318, 1255, 3110, 8, 1531, 304, 267, 299, 275, 3873, 14, 7942, 8, 1531, 12, 2490, 3839, 29, 5781, 14, 6089, 12, 2490, 4635, 29, 5781, 14, 13850, 9, 267, 299, 14, 2573, 342, 267, 372, 2740, 8, 80, 14, 2703, 14, 6407, 12, 330, 17483, 421, 199, 318, 5461, 2540, 3110, 8, 1531, 12, 5461, 63, 493, 63, 354, 12, 31478, 304, 267, 5461, 1173, 275, 1551, 8, 2724, 63, 493, 63, 354, 435, 31478, 12, 298, 87, 21425, 267, 5461, 1173, 14, 952, 8, 1531, 435, 1867, 78, 531, 267, 367, 1004, 315, 1255, 3110, 8, 1531, 14, 1294, 5109, 355, 5461, 1173, 14, 952, 8, 604, 9, 421, 199, 318, 14267, 1173, 8, 493, 63, 354, 304, 267, 2088, 275, 298, 5682, 446, 3941, 298, 435, 570, 63, 354, 267, 1255, 3110, 8, 1760, 14, 1294, 1012, 421, 199, 318, 519, 10756, 63, 723, 8, 493, 63, 354, 304, 267, 327, 18726, 1006, 625, 4579, 1750, 543, 2403, 283, 2791, 8650, 267, 8190, 63, 493, 63, 354, 275, 570, 63, 354, 435, 3680, 914, 2, 267, 340, 747, 14, 515, 14, 6292, 8, 723, 63, 493, 63, 354, 304, 355, 7090, 275, 1551, 8, 723, 63, 493, 63, 354, 12, 298, 13057, 21425, 355, 2385, 275, 7090, 14, 9684, 342, 355, 7090, 14, 5507, 8, 16, 9, 355, 7090, 14, 12517, 342, 355, 367, 1004, 315, 2385, 26, 717, 327, 2654, 2397, 1853, 5148, 717, 340, 298, 4640, 2, 315, 1004, 26, 1169, 1004, 847, 298, 2373, 3427, 78, 2, 717, 327, 22756, 1006, 625, 4579, 2860, 717, 1004, 275, 295, 14, 954, 2258, 5, 779, 16, 13, 25, 28798, 4228, 519, 5956, 2791, 18005, 17, 297, 4228, 1004, 14, 6735, 1012, 717, 327, 6121, 11441, 5246, 536, 717, 1004, 275, 295, 14, 954, 360, 2961, 3779, 971, 28, 1302, 60, 3072, 26, 31440, 16, 13, 25, 28798, 4228, 519, 1133, 311, 18005, 18, 6536, 4228, 1004, 14, 6735, 1012, 717, 7090, 14, 952, 8, 604, 435, 1557, 78, 358, 421, 199, 318, 3805, 63, 723, 8, 493, 63, 354, 304, 267, 327, 25596, 4253, 267, 1738, 63, 694, 275, 283, 9707, 703, 4805, 267, 1406, 63, 694, 275, 1738, 63, 694, 435, 298, 6559, 6687, 398, 327, 21391, 267, 1406, 275, 298, 446, 41, 298, 435, 1406, 63, 694, 267, 1406, 847, 298, 446, 2613, 298, 435, 1406, 63, 694, 435, 298, 77, 18, 67, 63, 1506, 262, 63, 970, 14, 72, 298, 267, 1406, 847, 298, 446, 2613, 298, 435, 1406, 63, 694, 435, 298, 23066, 15, 23066, 14, 72, 298, 267, 1406, 847, 298, 446, 36, 824, 63, 16066, 63, 3494, 63, 533, 63, 31659, 298, 398, 3805, 63, 723, 275, 298, 16066, 446, 51, 446, 8159, 13, 29257, 446, 47, 16, 446, 1375, 519, 6683, 306, 446, 77, 3541, 29, 422, 271, 298, 267, 2088, 63, 2268, 63, 723, 275, 3805, 63, 723, 435, 1406, 435, 570, 63, 354, 435, 3680, 429, 2, 267, 5461, 2540, 3110, 8, 1760, 63, 2268, 63, 723, 12, 570, 63, 354, 12, 3680, 16066, 14, 793, 531, 421, 199, 318, 21875, 63, 723, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 914, 2349, 267, 327, 5817, 370, 22931, 473, 50, 370, 4546, 600, 267, 3805, 63, 3776, 275, 298, 29257, 13, 305, 298, 267, 3805, 63, 3776, 63, 2164, 275, 570, 63, 354, 435, 3680, 914, 2, 267, 3805, 63, 3776, 63, 5119, 275, 570, 63, 354, 435, 3680, 3776, 2, 267, 2088, 63, 2268, 63, 3776, 275, 3805, 63, 3776, 435, 3805, 63, 3776, 63, 2164, 435, 298, 446, 79, 298, 435, 3805, 63, 3776, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2268, 63, 3776, 14, 1294, 1012, 421, 199, 318, 2450, 63, 3776, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 3776, 2349, 267, 327, 5817, 370, 2450, 77, 794, 4546, 600, 267, 2450, 63, 3776, 275, 298, 2992, 1553, 5286, 18, 1135, 298, 267, 2450, 63, 723, 63, 2164, 275, 570, 63, 354, 435, 3680, 3776, 2, 267, 2450, 63, 723, 63, 5119, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2088, 63, 2992, 63, 3776, 275, 2450, 63, 3776, 435, 2450, 63, 723, 63, 2164, 435, 298, 446, 79, 298, 435, 2450, 63, 723, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2992, 63, 3776, 14, 1294, 1012, 421, 199, 318, 2153, 63, 3776, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 3776, 2349, 267, 327, 5817, 370, 2153, 21263, 4546, 600, 267, 2153, 63, 3776, 275, 298, 29257, 13, 2297, 298, 267, 2153, 63, 723, 63, 2164, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2153, 63, 723, 63, 5119, 275, 570, 63, 354, 435, 3680, 2992, 14, 914, 2, 267, 2088, 63, 2297, 63, 3776, 275, 2153, 63, 3776, 435, 2153, 63, 723, 63, 2164, 435, 298, 446, 79, 298, 435, 2153, 63, 723, 63, 5119, 267, 1255, 3110, 8, 1760, 63, 2297, 63, 3776, 14, 1294, 1012, 421, 199, 318, 333, 18, 67, 63, 2268, 8, 493, 63, 354, 304, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 2992, 14, 3776, 2349, 267, 327, 5817, 370, 2153, 21263, 4546, 600, 267, 333, 18, 67, 63, 2268, 275, 298, 77, 18, 67, 1553, 29257, 18, 338, 298, 267, 333, 18, 67, 63, 2268, 63, 2164, 275, 570, 63, 354, 435, 3680, 2992, 14, 3776, 2, 267, 2088, 63, 77, 18, 67, 63, 2268, 275, 333, 18, 67, 63, 2268, 435, 333, 18, 67, 63, 2268, 63, 2164, 267, 5461, 2540, 3110, 8, 1760, 63, 77, 18, 67, 63, 2268, 12, 570, 63, 354, 12, 3680, 77, 18, 67, 14, 29257, 18, 338, 14, 793, 531, 339, 327, 5852, 570, 340, 1568, 365, 378, 272, 340, 747, 14, 515, 14, 6292, 8, 493, 63, 354, 435, 3680, 2992, 14, 83, 2349, 267, 340, 747, 14, 515, 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 ]
azaghal/ansible
test/support/integration/plugins/modules/postgresql_db.py
53
23381
#!/usr/bin/python # -*- coding: utf-8 -*- # 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': ['stableinterface'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: postgresql_db short_description: Add or remove PostgreSQL databases from a remote host. description: - Add or remove PostgreSQL databases from a remote host. version_added: '0.6' options: name: description: - Name of the database to add or remove type: str required: true aliases: [ db ] port: description: - Database port to connect (if needed) type: int default: 5432 aliases: - login_port owner: description: - Name of the role to set as owner of the database type: str template: description: - Template used to create the database type: str encoding: description: - Encoding of the database type: str lc_collate: description: - Collation order (LC_COLLATE) to use in the database. Must match collation order of template database unless C(template0) is used as template. type: str lc_ctype: description: - Character classification (LC_CTYPE) to use in the database (e.g. lower, upper, ...) Must match LC_CTYPE of template database unless C(template0) is used as template. type: str session_role: description: - Switch to session_role after connecting. The specified session_role must be a role that the current login_user is a member of. - Permissions checking for SQL commands is carried out as though the session_role were the one that had logged in originally. type: str version_added: '2.8' state: description: - The database state. - C(present) implies that the database should be created if necessary. - C(absent) implies that the database should be removed if present. - C(dump) requires a target definition to which the database will be backed up. (Added in Ansible 2.4) Note that in some PostgreSQL versions of pg_dump, which is an embedded PostgreSQL utility and is used by the module, returns rc 0 even when errors occurred (e.g. the connection is forbidden by pg_hba.conf, etc.), so the module returns changed=True but the dump has not actually been done. Please, be sure that your version of pg_dump returns rc 1 in this case. - C(restore) also requires a target definition from which the database will be restored. (Added in Ansible 2.4) - The format of the backup will be detected based on the target name. - Supported compression formats for dump and restore include C(.pgc), C(.bz2), C(.gz) and C(.xz) - Supported formats for dump and restore include C(.sql) and C(.tar) type: str choices: [ absent, dump, present, restore ] default: present target: description: - File to back up or restore from. - Used when I(state) is C(dump) or C(restore). type: path version_added: '2.4' target_opts: description: - Further arguments for pg_dump or pg_restore. - Used when I(state) is C(dump) or C(restore). type: str version_added: '2.4' maintenance_db: description: - The value specifies the initial database (which is also called as maintenance DB) that Ansible connects to. type: str default: postgres version_added: '2.5' conn_limit: description: - Specifies the database connection limit. type: str version_added: '2.8' tablespace: description: - The tablespace to set for the database U(https://www.postgresql.org/docs/current/sql-alterdatabase.html). - If you want to move the database back to the default tablespace, explicitly set this to pg_default. type: path version_added: '2.9' dump_extra_args: description: - Provides additional arguments when I(state) is C(dump). - Cannot be used with dump-file-format-related arguments like ``--format=d``. type: str version_added: '2.10' seealso: - name: CREATE DATABASE reference description: Complete reference of the CREATE DATABASE command documentation. link: https://www.postgresql.org/docs/current/sql-createdatabase.html - name: DROP DATABASE reference description: Complete reference of the DROP DATABASE command documentation. link: https://www.postgresql.org/docs/current/sql-dropdatabase.html - name: pg_dump reference description: Complete reference of pg_dump documentation. link: https://www.postgresql.org/docs/current/app-pgdump.html - name: pg_restore reference description: Complete reference of pg_restore documentation. link: https://www.postgresql.org/docs/current/app-pgrestore.html - module: postgresql_tablespace - module: postgresql_info - module: postgresql_ping notes: - State C(dump) and C(restore) don't require I(psycopg2) since version 2.8. author: "Ansible Core Team" extends_documentation_fragment: - postgres ''' EXAMPLES = r''' - name: Create a new database with name "acme" postgresql_db: name: acme # Note: If a template different from "template0" is specified, encoding and locale settings must match those of the template. - name: Create a new database with name "acme" and specific encoding and locale # settings. postgresql_db: name: acme encoding: UTF-8 lc_collate: de_DE.UTF-8 lc_ctype: de_DE.UTF-8 template: template0 # Note: Default limit for the number of concurrent connections to a specific database is "-1", which means "unlimited" - name: Create a new database with name "acme" which has a limit of 100 concurrent connections postgresql_db: name: acme conn_limit: "100" - name: Dump an existing database to a file postgresql_db: name: acme state: dump target: /tmp/acme.sql - name: Dump an existing database to a file excluding the test table postgresql_db: name: acme state: dump target: /tmp/acme.sql dump_extra_args: --exclude-table=test - name: Dump an existing database to a file (with compression) postgresql_db: name: acme state: dump target: /tmp/acme.sql.gz - name: Dump a single schema for an existing database postgresql_db: name: acme state: dump target: /tmp/acme.sql target_opts: "-n public" # Note: In the example below, if database foo exists and has another tablespace # the tablespace will be changed to foo. Access to the database will be locked # until the copying of database files is finished. - name: Create a new database called foo in tablespace bar postgresql_db: name: foo tablespace: bar ''' RETURN = r''' executed_commands: description: List of commands which tried to run. returned: always type: list sample: ["CREATE DATABASE acme"] version_added: '2.10' ''' import os import subprocess import traceback try: import psycopg2 import psycopg2.extras except ImportError: HAS_PSYCOPG2 = False else: HAS_PSYCOPG2 = True import ansible.module_utils.postgres as pgutils from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.database import SQLParseError, pg_quote_identifier from ansible.module_utils.six import iteritems from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils._text import to_native executed_commands = [] class NotSupportedError(Exception): pass # =========================================== # PostgreSQL module specific support methods. # def set_owner(cursor, db, owner): query = 'ALTER DATABASE %s OWNER TO "%s"' % ( pg_quote_identifier(db, 'database'), owner) executed_commands.append(query) cursor.execute(query) return True def set_conn_limit(cursor, db, conn_limit): query = "ALTER DATABASE %s CONNECTION LIMIT %s" % ( pg_quote_identifier(db, 'database'), conn_limit) executed_commands.append(query) cursor.execute(query) return True def get_encoding_id(cursor, encoding): query = "SELECT pg_char_to_encoding(%(encoding)s) AS encoding_id;" cursor.execute(query, {'encoding': encoding}) return cursor.fetchone()['encoding_id'] def get_db_info(cursor, db): query = """ SELECT rolname AS owner, pg_encoding_to_char(encoding) AS encoding, encoding AS encoding_id, datcollate AS lc_collate, datctype AS lc_ctype, pg_database.datconnlimit AS conn_limit, spcname AS tablespace FROM pg_database JOIN pg_roles ON pg_roles.oid = pg_database.datdba JOIN pg_tablespace ON pg_tablespace.oid = pg_database.dattablespace WHERE datname = %(db)s """ cursor.execute(query, {'db': db}) return cursor.fetchone() def db_exists(cursor, db): query = "SELECT * FROM pg_database WHERE datname=%(db)s" cursor.execute(query, {'db': db}) return cursor.rowcount == 1 def db_delete(cursor, db): if db_exists(cursor, db): query = "DROP DATABASE %s" % pg_quote_identifier(db, 'database') executed_commands.append(query) cursor.execute(query) return True else: return False def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_limit, tablespace): params = dict(enc=encoding, collate=lc_collate, ctype=lc_ctype, conn_limit=conn_limit, tablespace=tablespace) if not db_exists(cursor, db): query_fragments = ['CREATE DATABASE %s' % pg_quote_identifier(db, 'database')] if owner: query_fragments.append('OWNER "%s"' % owner) if template: query_fragments.append('TEMPLATE %s' % pg_quote_identifier(template, 'database')) if encoding: query_fragments.append('ENCODING %(enc)s') if lc_collate: query_fragments.append('LC_COLLATE %(collate)s') if lc_ctype: query_fragments.append('LC_CTYPE %(ctype)s') if tablespace: query_fragments.append('TABLESPACE %s' % pg_quote_identifier(tablespace, 'tablespace')) if conn_limit: query_fragments.append("CONNECTION LIMIT %(conn_limit)s" % {"conn_limit": conn_limit}) query = ' '.join(query_fragments) executed_commands.append(cursor.mogrify(query, params)) cursor.execute(query, params) return True else: db_info = get_db_info(cursor, db) if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']): raise NotSupportedError( 'Changing database encoding is not supported. ' 'Current encoding: %s' % db_info['encoding'] ) elif lc_collate and lc_collate != db_info['lc_collate']: raise NotSupportedError( 'Changing LC_COLLATE is not supported. ' 'Current LC_COLLATE: %s' % db_info['lc_collate'] ) elif lc_ctype and lc_ctype != db_info['lc_ctype']: raise NotSupportedError( 'Changing LC_CTYPE is not supported.' 'Current LC_CTYPE: %s' % db_info['lc_ctype'] ) else: changed = False if owner and owner != db_info['owner']: changed = set_owner(cursor, db, owner) if conn_limit and conn_limit != str(db_info['conn_limit']): changed = set_conn_limit(cursor, db, conn_limit) if tablespace and tablespace != db_info['tablespace']: changed = set_tablespace(cursor, db, tablespace) return changed def db_matches(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_limit, tablespace): if not db_exists(cursor, db): return False else: db_info = get_db_info(cursor, db) if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']): return False elif lc_collate and lc_collate != db_info['lc_collate']: return False elif lc_ctype and lc_ctype != db_info['lc_ctype']: return False elif owner and owner != db_info['owner']: return False elif conn_limit and conn_limit != str(db_info['conn_limit']): return False elif tablespace and tablespace != db_info['tablespace']: return False else: return True def db_dump(module, target, target_opts="", db=None, dump_extra_args=None, user=None, password=None, host=None, port=None, **kw): flags = login_flags(db, host, port, user, db_prefix=False) cmd = module.get_bin_path('pg_dump', True) comp_prog_path = None if os.path.splitext(target)[-1] == '.tar': flags.append(' --format=t') elif os.path.splitext(target)[-1] == '.pgc': flags.append(' --format=c') if os.path.splitext(target)[-1] == '.gz': if module.get_bin_path('pigz'): comp_prog_path = module.get_bin_path('pigz', True) else: comp_prog_path = module.get_bin_path('gzip', True) elif os.path.splitext(target)[-1] == '.bz2': comp_prog_path = module.get_bin_path('bzip2', True) elif os.path.splitext(target)[-1] == '.xz': comp_prog_path = module.get_bin_path('xz', True) cmd += "".join(flags) if dump_extra_args: cmd += " {0} ".format(dump_extra_args) if target_opts: cmd += " {0} ".format(target_opts) if comp_prog_path: # Use a fifo to be notified of an error in pg_dump # Using shell pipe has no way to return the code of the first command # in a portable way. fifo = os.path.join(module.tmpdir, 'pg_fifo') os.mkfifo(fifo) cmd = '{1} <{3} > {2} & {0} >{3}'.format(cmd, comp_prog_path, shlex_quote(target), fifo) else: cmd = '{0} > {1}'.format(cmd, shlex_quote(target)) return do_with_password(module, cmd, password) def db_restore(module, target, target_opts="", db=None, user=None, password=None, host=None, port=None, **kw): flags = login_flags(db, host, port, user) comp_prog_path = None cmd = module.get_bin_path('psql', True) if os.path.splitext(target)[-1] == '.sql': flags.append(' --file={0}'.format(target)) elif os.path.splitext(target)[-1] == '.tar': flags.append(' --format=Tar') cmd = module.get_bin_path('pg_restore', True) elif os.path.splitext(target)[-1] == '.pgc': flags.append(' --format=Custom') cmd = module.get_bin_path('pg_restore', True) elif os.path.splitext(target)[-1] == '.gz': comp_prog_path = module.get_bin_path('zcat', True) elif os.path.splitext(target)[-1] == '.bz2': comp_prog_path = module.get_bin_path('bzcat', True) elif os.path.splitext(target)[-1] == '.xz': comp_prog_path = module.get_bin_path('xzcat', True) cmd += "".join(flags) if target_opts: cmd += " {0} ".format(target_opts) if comp_prog_path: env = os.environ.copy() if password: env = {"PGPASSWORD": password} p1 = subprocess.Popen([comp_prog_path, target], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p2 = subprocess.Popen(cmd, stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=env) (stdout2, stderr2) = p2.communicate() p1.stdout.close() p1.wait() if p1.returncode != 0: stderr1 = p1.stderr.read() return p1.returncode, '', stderr1, 'cmd: ****' else: return p2.returncode, '', stderr2, 'cmd: ****' else: cmd = '{0} < {1}'.format(cmd, shlex_quote(target)) return do_with_password(module, cmd, password) def login_flags(db, host, port, user, db_prefix=True): """ returns a list of connection argument strings each prefixed with a space and quoted where necessary to later be combined in a single shell string with `"".join(rv)` db_prefix determines if "--dbname" is prefixed to the db argument, since the argument was introduced in 9.3. """ flags = [] if db: if db_prefix: flags.append(' --dbname={0}'.format(shlex_quote(db))) else: flags.append(' {0}'.format(shlex_quote(db))) if host: flags.append(' --host={0}'.format(host)) if port: flags.append(' --port={0}'.format(port)) if user: flags.append(' --username={0}'.format(user)) return flags def do_with_password(module, cmd, password): env = {} if password: env = {"PGPASSWORD": password} executed_commands.append(cmd) rc, stderr, stdout = module.run_command(cmd, use_unsafe_shell=True, environ_update=env) return rc, stderr, stdout, cmd def set_tablespace(cursor, db, tablespace): query = "ALTER DATABASE %s SET TABLESPACE %s" % ( pg_quote_identifier(db, 'database'), pg_quote_identifier(tablespace, 'tablespace')) executed_commands.append(query) cursor.execute(query) return True # =========================================== # Module execution. # def main(): argument_spec = pgutils.postgres_common_argument_spec() argument_spec.update( db=dict(type='str', required=True, aliases=['name']), owner=dict(type='str', default=''), template=dict(type='str', default=''), encoding=dict(type='str', default=''), lc_collate=dict(type='str', default=''), lc_ctype=dict(type='str', default=''), state=dict(type='str', default='present', choices=['absent', 'dump', 'present', 'restore']), target=dict(type='path', default=''), target_opts=dict(type='str', default=''), maintenance_db=dict(type='str', default="postgres"), session_role=dict(type='str'), conn_limit=dict(type='str', default=''), tablespace=dict(type='path', default=''), dump_extra_args=dict(type='str', default=None), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) db = module.params["db"] owner = module.params["owner"] template = module.params["template"] encoding = module.params["encoding"] lc_collate = module.params["lc_collate"] lc_ctype = module.params["lc_ctype"] target = module.params["target"] target_opts = module.params["target_opts"] state = module.params["state"] changed = False maintenance_db = module.params['maintenance_db'] session_role = module.params["session_role"] conn_limit = module.params['conn_limit'] tablespace = module.params['tablespace'] dump_extra_args = module.params['dump_extra_args'] raw_connection = state in ("dump", "restore") if not raw_connection: pgutils.ensure_required_libs(module) # To use defaults values, keyword arguments must be absent, so # check which values are empty and don't include in the **kw # dictionary params_map = { "login_host": "host", "login_user": "user", "login_password": "password", "port": "port", "ssl_mode": "sslmode", "ca_cert": "sslrootcert" } kw = dict((params_map[k], v) for (k, v) in iteritems(module.params) if k in params_map and v != '' and v is not None) # If a login_unix_socket is specified, incorporate it here. is_localhost = "host" not in kw or kw["host"] == "" or kw["host"] == "localhost" if is_localhost and module.params["login_unix_socket"] != "": kw["host"] = module.params["login_unix_socket"] if target == "": target = "{0}/{1}.sql".format(os.getcwd(), db) target = os.path.expanduser(target) if not raw_connection: try: db_connection = psycopg2.connect(database=maintenance_db, **kw) # Enable autocommit so we can create databases if psycopg2.__version__ >= '2.4.2': db_connection.autocommit = True else: db_connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) cursor = db_connection.cursor(cursor_factory=psycopg2.extras.DictCursor) except TypeError as e: if 'sslrootcert' in e.args[0]: module.fail_json(msg='Postgresql server must be at least version 8.4 to support sslrootcert. Exception: {0}'.format(to_native(e)), exception=traceback.format_exc()) module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc()) except Exception as e: module.fail_json(msg="unable to connect to database: %s" % to_native(e), exception=traceback.format_exc()) if session_role: try: cursor.execute('SET ROLE "%s"' % session_role) except Exception as e: module.fail_json(msg="Could not switch role: %s" % to_native(e), exception=traceback.format_exc()) try: if module.check_mode: if state == "absent": changed = db_exists(cursor, db) elif state == "present": changed = not db_matches(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_limit, tablespace) module.exit_json(changed=changed, db=db, executed_commands=executed_commands) if state == "absent": try: changed = db_delete(cursor, db) except SQLParseError as e: module.fail_json(msg=to_native(e), exception=traceback.format_exc()) elif state == "present": try: changed = db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_limit, tablespace) except SQLParseError as e: module.fail_json(msg=to_native(e), exception=traceback.format_exc()) elif state in ("dump", "restore"): method = state == "dump" and db_dump or db_restore try: if state == 'dump': rc, stdout, stderr, cmd = method(module, target, target_opts, db, dump_extra_args, **kw) else: rc, stdout, stderr, cmd = method(module, target, target_opts, db, **kw) if rc != 0: module.fail_json(msg=stderr, stdout=stdout, rc=rc, cmd=cmd) else: module.exit_json(changed=True, msg=stdout, stderr=stderr, rc=rc, cmd=cmd, executed_commands=executed_commands) except SQLParseError as e: module.fail_json(msg=to_native(e), exception=traceback.format_exc()) except NotSupportedError as e: module.fail_json(msg=to_native(e), exception=traceback.format_exc()) except SystemExit: # Avoid catching this on Python 2.4 raise except Exception as e: module.fail_json(msg="Database query failed: %s" % to_native(e), exception=traceback.format_exc()) module.exit_json(changed=changed, db=db, executed_commands=executed_commands) 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, 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, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 25951, 63, 697, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 20175, 16219, 687, 282, 3982, 1591, 14, 199, 1802, 26, 2043, 446, 2654, 503, 2813, 20175, 16219, 687, 282, 3982, 1591, 14, 199, 1023, 63, 3270, 26, 283, 16, 14, 22, 7, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 3050, 370, 1050, 503, 2813, 272, 730, 26, 620, 272, 1415, 26, 2549, 272, 5481, 26, 359, 1592, 1622, 523, 1844, 26, 272, 1369, 26, 489, 446, 8692, 1844, 370, 4907, 334, 692, 4346, 9, 272, 730, 26, 1109, 272, 849, 26, 959, 10657, 272, 5481, 26, 489, 446, 4676, 63, 719, 523, 5771, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4719, 370, 663, 465, 5771, 402, 314, 3050, 272, 730, 26, 620, 523, 1978, 26, 272, 1369, 26, 489, 446, 5458, 1202, 370, 1218, 314, 3050, 272, 730, 26, 620, 523, 2644, 26, 272, 1369, 26, 489, 446, 19694, 402, 314, 3050, 272, 730, 26, 620, 523, 16093, 63, 761, 750, 26, 272, 1369, 26, 489, 446, 3626, 2212, 1865, 334, 7027, 63, 3978, 30064, 9, 370, 675, 315, 314, 3050, 14, 9498, 1336, 1048, 2212, 1865, 402, 1978, 3050, 7444, 445, 8, 1160, 16, 9, 365, 1202, 465, 1978, 14, 272, 730, 26, 620, 523, 16093, 63, 3667, 26, 272, 1369, 26, 489, 446, 17660, 12505, 334, 7027, 63, 7540, 9, 370, 675, 315, 314, 3050, 334, 69, 14, 71, 14, 5117, 12, 7008, 12, 19172, 9498, 1336, 26703, 63, 7540, 402, 1978, 3050, 7444, 445, 8, 1160, 16, 9, 267, 365, 1202, 465, 1978, 14, 272, 730, 26, 620, 523, 2351, 63, 3756, 26, 272, 1369, 26, 272, 446, 17711, 370, 2351, 63, 3756, 2410, 18170, 14, 710, 2013, 2351, 63, 3756, 1471, 506, 282, 4719, 626, 314, 1453, 4676, 63, 751, 365, 282, 3653, 402, 14, 272, 446, 28260, 7907, 367, 5385, 3718, 365, 9590, 18906, 734, 465, 10617, 314, 2351, 63, 3756, 4898, 314, 1373, 626, 10530, 10367, 315, 20657, 14, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 24, 7, 523, 1174, 26, 272, 1369, 26, 272, 446, 710, 3050, 1174, 14, 272, 446, 445, 8, 1881, 9, 22660, 626, 314, 3050, 1077, 506, 2737, 340, 5784, 14, 272, 446, 445, 8, 5575, 9, 22660, 626, 314, 3050, 1077, 506, 4829, 340, 3451, 14, 272, 446, 445, 8, 2724, 9, 5074, 282, 1347, 5492, 370, 1314, 314, 3050, 911, 506, 1771, 379, 1536, 14, 334, 20201, 315, 2622, 499, 14, 20, 9, 489, 3390, 626, 315, 2005, 20175, 5459, 402, 10275, 63, 2724, 12, 1314, 365, 376, 12169, 20175, 11420, 436, 365, 1202, 701, 314, 859, 12, 489, 2529, 4819, 378, 2755, 1380, 2552, 8920, 334, 69, 14, 71, 14, 314, 1950, 365, 24786, 701, 10275, 63, 72, 2470, 14, 2190, 12, 5423, 15631, 489, 880, 314, 859, 2529, 2896, 29, 549, 1325, 314, 5461, 965, 440, 5965, 2757, 4224, 14, 7754, 12, 506, 3238, 626, 2195, 1015, 402, 489, 10275, 63, 2724, 2529, 4819, 413, 315, 642, 1930, 14, 272, 446, 445, 8, 8011, 9, 2597, 5074, 282, 1347, 5492, 687, 1314, 314, 3050, 911, 506, 14429, 14, 334, 20201, 315, 2622, 499, 14, 20, 9, 272, 446, 710, 1475, 402, 314, 6902, 911, 506, 10501, 4079, 641, 314, 1347, 536, 14, 272, 446, 26167, 10291, 6752, 367, 5461, 436, 9066, 2387, 445, 13417, 4198, 67, 395, 445, 13417, 10582, 18, 395, 445, 13417, 6838, 9, 436, 445, 13417, 19196, 9, 272, 446, 26167, 6752, 367, 5461, 436, 9066, 2387, 445, 13417, 3009, 9, 436, 445, 13417, 5369, 9, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 5461, 12, 3451, 12, 9066, 1622, 272, 849, 26, 3451, 523, 1347, 26, 272, 1369, 26, 272, 446, 3814, 370, 1771, 1536, 503, 9066, 687, 14, 272, 446, 8051, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 9, 503, 445, 8, 8011, 680, 272, 730, 26, 931, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 523, 1347, 63, 3291, 26, 272, 1369, 26, 272, 446, 28876, 2368, 367, 10275, 63, 2724, 503, 10275, 63, 8011, 14, 272, 446, 8051, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 9, 503, 445, 8, 8011, 680, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 523, 21964, 63, 697, 26, 272, 1369, 26, 489, 446, 710, 574, 9314, 314, 2536, 3050, 334, 6777, 365, 2597, 2797, 465, 21964, 6249, 9, 626, 2622, 4907, 83, 370, 14, 272, 730, 26, 620, 272, 849, 26, 19533, 272, 1015, 63, 3270, 26, 283, 18, 14, 21, 7, 523, 2557, 63, 3097, 26, 272, 1369, 26, 489, 446, 11015, 314, 3050, 1950, 2304, 14, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 24, 7, 523, 1817, 2638, 26, 272, 1369, 26, 489, 446, 710, 1817, 2638, 370, 663, 367, 314, 3050, 267, 738, 8, 2859, 921, 1544, 14, 15437, 14, 1308, 15, 4757, 15, 1818, 15, 3009, 13, 11858, 4659, 14, 1360, 680, 489, 446, 982, 1265, 2934, 370, 4057, 314, 3050, 1771, 370, 314, 849, 1817, 2638, 12, 267, 7662, 663, 642, 370, 10275, 63, 885, 14, 272, 730, 26, 931, 272, 1015, 63, 3270, 26, 283, 18, 14, 25, 7, 523, 5461, 63, 2911, 63, 589, 26, 272, 1369, 26, 489, 446, 21552, 4722, 2368, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 680, 489 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 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, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 25951, 63, 697, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 20175, 16219, 687, 282, 3982, 1591, 14, 199, 1802, 26, 2043, 446, 2654, 503, 2813, 20175, 16219, 687, 282, 3982, 1591, 14, 199, 1023, 63, 3270, 26, 283, 16, 14, 22, 7, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 3050, 370, 1050, 503, 2813, 272, 730, 26, 620, 272, 1415, 26, 2549, 272, 5481, 26, 359, 1592, 1622, 523, 1844, 26, 272, 1369, 26, 489, 446, 8692, 1844, 370, 4907, 334, 692, 4346, 9, 272, 730, 26, 1109, 272, 849, 26, 959, 10657, 272, 5481, 26, 489, 446, 4676, 63, 719, 523, 5771, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4719, 370, 663, 465, 5771, 402, 314, 3050, 272, 730, 26, 620, 523, 1978, 26, 272, 1369, 26, 489, 446, 5458, 1202, 370, 1218, 314, 3050, 272, 730, 26, 620, 523, 2644, 26, 272, 1369, 26, 489, 446, 19694, 402, 314, 3050, 272, 730, 26, 620, 523, 16093, 63, 761, 750, 26, 272, 1369, 26, 489, 446, 3626, 2212, 1865, 334, 7027, 63, 3978, 30064, 9, 370, 675, 315, 314, 3050, 14, 9498, 1336, 1048, 2212, 1865, 402, 1978, 3050, 7444, 445, 8, 1160, 16, 9, 365, 1202, 465, 1978, 14, 272, 730, 26, 620, 523, 16093, 63, 3667, 26, 272, 1369, 26, 489, 446, 17660, 12505, 334, 7027, 63, 7540, 9, 370, 675, 315, 314, 3050, 334, 69, 14, 71, 14, 5117, 12, 7008, 12, 19172, 9498, 1336, 26703, 63, 7540, 402, 1978, 3050, 7444, 445, 8, 1160, 16, 9, 267, 365, 1202, 465, 1978, 14, 272, 730, 26, 620, 523, 2351, 63, 3756, 26, 272, 1369, 26, 272, 446, 17711, 370, 2351, 63, 3756, 2410, 18170, 14, 710, 2013, 2351, 63, 3756, 1471, 506, 282, 4719, 626, 314, 1453, 4676, 63, 751, 365, 282, 3653, 402, 14, 272, 446, 28260, 7907, 367, 5385, 3718, 365, 9590, 18906, 734, 465, 10617, 314, 2351, 63, 3756, 4898, 314, 1373, 626, 10530, 10367, 315, 20657, 14, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 24, 7, 523, 1174, 26, 272, 1369, 26, 272, 446, 710, 3050, 1174, 14, 272, 446, 445, 8, 1881, 9, 22660, 626, 314, 3050, 1077, 506, 2737, 340, 5784, 14, 272, 446, 445, 8, 5575, 9, 22660, 626, 314, 3050, 1077, 506, 4829, 340, 3451, 14, 272, 446, 445, 8, 2724, 9, 5074, 282, 1347, 5492, 370, 1314, 314, 3050, 911, 506, 1771, 379, 1536, 14, 334, 20201, 315, 2622, 499, 14, 20, 9, 489, 3390, 626, 315, 2005, 20175, 5459, 402, 10275, 63, 2724, 12, 1314, 365, 376, 12169, 20175, 11420, 436, 365, 1202, 701, 314, 859, 12, 489, 2529, 4819, 378, 2755, 1380, 2552, 8920, 334, 69, 14, 71, 14, 314, 1950, 365, 24786, 701, 10275, 63, 72, 2470, 14, 2190, 12, 5423, 15631, 489, 880, 314, 859, 2529, 2896, 29, 549, 1325, 314, 5461, 965, 440, 5965, 2757, 4224, 14, 7754, 12, 506, 3238, 626, 2195, 1015, 402, 489, 10275, 63, 2724, 2529, 4819, 413, 315, 642, 1930, 14, 272, 446, 445, 8, 8011, 9, 2597, 5074, 282, 1347, 5492, 687, 1314, 314, 3050, 911, 506, 14429, 14, 334, 20201, 315, 2622, 499, 14, 20, 9, 272, 446, 710, 1475, 402, 314, 6902, 911, 506, 10501, 4079, 641, 314, 1347, 536, 14, 272, 446, 26167, 10291, 6752, 367, 5461, 436, 9066, 2387, 445, 13417, 4198, 67, 395, 445, 13417, 10582, 18, 395, 445, 13417, 6838, 9, 436, 445, 13417, 19196, 9, 272, 446, 26167, 6752, 367, 5461, 436, 9066, 2387, 445, 13417, 3009, 9, 436, 445, 13417, 5369, 9, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 5461, 12, 3451, 12, 9066, 1622, 272, 849, 26, 3451, 523, 1347, 26, 272, 1369, 26, 272, 446, 3814, 370, 1771, 1536, 503, 9066, 687, 14, 272, 446, 8051, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 9, 503, 445, 8, 8011, 680, 272, 730, 26, 931, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 523, 1347, 63, 3291, 26, 272, 1369, 26, 272, 446, 28876, 2368, 367, 10275, 63, 2724, 503, 10275, 63, 8011, 14, 272, 446, 8051, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 9, 503, 445, 8, 8011, 680, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 523, 21964, 63, 697, 26, 272, 1369, 26, 489, 446, 710, 574, 9314, 314, 2536, 3050, 334, 6777, 365, 2597, 2797, 465, 21964, 6249, 9, 626, 2622, 4907, 83, 370, 14, 272, 730, 26, 620, 272, 849, 26, 19533, 272, 1015, 63, 3270, 26, 283, 18, 14, 21, 7, 523, 2557, 63, 3097, 26, 272, 1369, 26, 489, 446, 11015, 314, 3050, 1950, 2304, 14, 272, 730, 26, 620, 272, 1015, 63, 3270, 26, 283, 18, 14, 24, 7, 523, 1817, 2638, 26, 272, 1369, 26, 489, 446, 710, 1817, 2638, 370, 663, 367, 314, 3050, 267, 738, 8, 2859, 921, 1544, 14, 15437, 14, 1308, 15, 4757, 15, 1818, 15, 3009, 13, 11858, 4659, 14, 1360, 680, 489, 446, 982, 1265, 2934, 370, 4057, 314, 3050, 1771, 370, 314, 849, 1817, 2638, 12, 267, 7662, 663, 642, 370, 10275, 63, 885, 14, 272, 730, 26, 931, 272, 1015, 63, 3270, 26, 283, 18, 14, 25, 7, 523, 5461, 63, 2911, 63, 589, 26, 272, 1369, 26, 489, 446, 21552, 4722, 2368, 1380, 473, 8, 929, 9, 365, 445, 8, 2724, 680, 489, 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,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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 ]
firmlyjin/brython
cgi-bin/upload_results.py
17
1186
#!/usr/bin/env python3 import cgi import sqlite3 import json print('Content-type: text/html') print() _form=cgi.FieldStorage() _data=_form.getvalue('data') _r=json.loads(_data) _conn=sqlite3.connect("brython_speed_results.db") _db=_conn.cursor() try: _db.execute("select count('x') from info") except: _db.execute("""create table info (userAgent text, brython_version text, timestamp datetime)""") try: _db.execute("select count('x') from results") except: _db.execute("""create table results (id int, test_name text, brython_ms int, cpython_ms int)""") _db.execute("""insert into info values (?,?,datetime('now'))""", (_r['userAgent'], _r['brython_version'])) _id=_db.lastrowid for _test in _r['timings']: _t=_r['timings'][_test] _db.execute(""" insert into results values (?,?,?,?)""", (_id, _test, _t['brython'], _t['cpython'])) _conn.commit() _db.close() print("OK")
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 16004, 199, 646, 11723, 19, 199, 646, 2022, 199, 199, 1361, 360, 2714, 13, 466, 26, 1318, 15, 1360, 358, 199, 1361, 342, 199, 199, 63, 964, 29, 13814, 14, 792, 6408, 342, 199, 199, 63, 576, 3699, 964, 14, 7150, 360, 576, 358, 199, 63, 82, 29, 1001, 14, 3640, 1547, 576, 9, 199, 199, 63, 1631, 29, 10659, 19, 14, 2242, 480, 66, 23196, 63, 7625, 63, 2604, 14, 697, 531, 199, 63, 697, 3699, 1631, 14, 3937, 342, 199, 199, 893, 26, 523, 485, 697, 14, 2526, 480, 2416, 2338, 360, 88, 358, 687, 2256, 531, 199, 2590, 26, 523, 485, 697, 14, 2526, 4852, 981, 1817, 2256, 334, 751, 7788, 1318, 12, 330, 23196, 63, 1023, 1318, 12, 2511, 4913, 2197, 9, 6141, 199, 199, 893, 26, 523, 485, 697, 14, 2526, 480, 2416, 2338, 360, 88, 358, 687, 2058, 531, 199, 2590, 26, 523, 485, 697, 14, 2526, 4852, 981, 1817, 2058, 334, 344, 1109, 12, 511, 63, 354, 1318, 12, 4318, 330, 23196, 63, 706, 1109, 12, 4318, 286, 1548, 63, 706, 1109, 9, 6141, 4388, 199, 63, 697, 14, 2526, 4852, 3176, 1901, 2256, 1338, 7558, 12, 22556, 2083, 360, 2131, 1333, 7208, 6110, 82, 459, 751, 7788, 995, 16854, 485, 82, 459, 66, 23196, 63, 1023, 5156, 199, 199, 63, 344, 3699, 697, 14, 2019, 29450, 199, 509, 485, 396, 315, 485, 82, 459, 27337, 2565, 272, 485, 84, 3699, 82, 459, 27337, 3488, 63, 396, 61, 272, 485, 697, 14, 2526, 4852, 5518, 1901, 2058, 1338, 7558, 12, 22556, 22556, 17076, 7208, 6110, 344, 12, 485, 396, 12, 10028, 485, 84, 459, 66, 23196, 995, 221, 10028, 485, 84, 459, 67, 1548, 5156, 199, 199, 63, 1631, 14, 3543, 342, 199, 199, 63, 697, 14, 1600, 342, 199, 199, 1361, 480, 3593, 531, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 646, 16004, 199, 646, 11723, 19, 199, 646, 2022, 199, 199, 1361, 360, 2714, 13, 466, 26, 1318, 15, 1360, 358, 199, 1361, 342, 199, 199, 63, 964, 29, 13814, 14, 792, 6408, 342, 199, 199, 63, 576, 3699, 964, 14, 7150, 360, 576, 358, 199, 63, 82, 29, 1001, 14, 3640, 1547, 576, 9, 199, 199, 63, 1631, 29, 10659, 19, 14, 2242, 480, 66, 23196, 63, 7625, 63, 2604, 14, 697, 531, 199, 63, 697, 3699, 1631, 14, 3937, 342, 199, 199, 893, 26, 523, 485, 697, 14, 2526, 480, 2416, 2338, 360, 88, 358, 687, 2256, 531, 199, 2590, 26, 523, 485, 697, 14, 2526, 4852, 981, 1817, 2256, 334, 751, 7788, 1318, 12, 330, 23196, 63, 1023, 1318, 12, 2511, 4913, 2197, 9, 6141, 199, 199, 893, 26, 523, 485, 697, 14, 2526, 480, 2416, 2338, 360, 88, 358, 687, 2058, 531, 199, 2590, 26, 523, 485, 697, 14, 2526, 4852, 981, 1817, 2058, 334, 344, 1109, 12, 511, 63, 354, 1318, 12, 4318, 330, 23196, 63, 706, 1109, 12, 4318, 286, 1548, 63, 706, 1109, 9, 6141, 4388, 199, 63, 697, 14, 2526, 4852, 3176, 1901, 2256, 1338, 7558, 12, 22556, 2083, 360, 2131, 1333, 7208, 6110, 82, 459, 751, 7788, 995, 16854, 485, 82, 459, 66, 23196, 63, 1023, 5156, 199, 199, 63, 344, 3699, 697, 14, 2019, 29450, 199, 509, 485, 396, 315, 485, 82, 459, 27337, 2565, 272, 485, 84, 3699, 82, 459, 27337, 3488, 63, 396, 61, 272, 485, 697, 14, 2526, 4852, 5518, 1901, 2058, 1338, 7558, 12, 22556, 22556, 17076, 7208, 6110, 344, 12, 485, 396, 12, 10028, 485, 84, 459, 66, 23196, 995, 221, 10028, 485, 84, 459, 67, 1548, 5156, 199, 199, 63, 1631, 14, 3543, 342, 199, 199, 63, 697, 14, 1600, 342, 199, 199, 1361, 480, 3593, 531, 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, 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, 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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 ]
lihui7115/ChromiumGStreamerBackend
build/win/importlibs/create_importlib_win.py
185
6790
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # """Creates an import library from an import description file.""" import ast import logging import optparse import os import os.path import shutil import subprocess import sys import tempfile _USAGE = """\ Usage: %prog [options] [imports-file] Creates an import library from imports-file. Note: this script uses the microsoft assembler (ml.exe) and the library tool (lib.exe), both of which must be in path. """ _ASM_STUB_HEADER = """\ ; This file is autogenerated by create_importlib_win.py, do not edit. .386 .MODEL FLAT, C .CODE ; Stubs to provide mangled names to lib.exe for the ; correct generation of import libs. """ _DEF_STUB_HEADER = """\ ; This file is autogenerated by create_importlib_win.py, do not edit. ; Export declarations for generating import libs. """ _LOGGER = logging.getLogger() class _Error(Exception): pass class _ImportLibraryGenerator(object): def __init__(self, temp_dir): self._temp_dir = temp_dir def _Shell(self, cmd, **kw): ret = subprocess.call(cmd, **kw) _LOGGER.info('Running "%s" returned %d.', cmd, ret) if ret != 0: raise _Error('Command "%s" returned %d.' % (cmd, ret)) def _ReadImportsFile(self, imports_file): # Slurp the imports file. return ast.literal_eval(open(imports_file).read()) def _WriteStubsFile(self, import_names, output_file): output_file.write(_ASM_STUB_HEADER) for name in import_names: output_file.write('%s PROC\n' % name) output_file.write('%s ENDP\n' % name) output_file.write('END\n') def _WriteDefFile(self, dll_name, import_names, output_file): output_file.write(_DEF_STUB_HEADER) output_file.write('NAME %s\n' % dll_name) output_file.write('EXPORTS\n') for name in import_names: name = name.split('@')[0] output_file.write(' %s\n' % name) def _CreateObj(self, dll_name, imports): """Writes an assembly file containing empty declarations. For each imported function of the form: AddClipboardFormatListener@4 PROC AddClipboardFormatListener@4 ENDP The resulting object file is then supplied to lib.exe with a .def file declaring the corresponding non-adorned exports as they appear on the exporting DLL, e.g. EXPORTS AddClipboardFormatListener In combination, the .def file and the .obj file cause lib.exe to generate an x86 import lib with public symbols named like "__imp__AddClipboardFormatListener@4", binding to exports named like "AddClipboardFormatListener". All of this is perpetrated in a temporary directory, as the intermediate artifacts are quick and easy to produce, and of no interest to anyone after the fact.""" # Create an .asm file to provide stdcall-like stub names to lib.exe. asm_name = dll_name + '.asm' _LOGGER.info('Writing asm file "%s".', asm_name) with open(os.path.join(self._temp_dir, asm_name), 'wb') as stubs_file: self._WriteStubsFile(imports, stubs_file) # Invoke on the assembler to compile it to .obj. obj_name = dll_name + '.obj' cmdline = ['ml.exe', '/nologo', '/c', asm_name, '/Fo', obj_name] self._Shell(cmdline, cwd=self._temp_dir, stdout=open(os.devnull)) return obj_name def _CreateImportLib(self, dll_name, imports, architecture, output_file): """Creates an import lib binding imports to dll_name for architecture. On success, writes the import library to output file. """ obj_file = None # For x86 architecture we have to provide an object file for correct # name mangling between the import stubs and the exported functions. if architecture == 'x86': obj_file = self._CreateObj(dll_name, imports) # Create the corresponding .def file. This file has the non stdcall-adorned # names, as exported by the destination DLL. def_name = dll_name + '.def' _LOGGER.info('Writing def file "%s".', def_name) with open(os.path.join(self._temp_dir, def_name), 'wb') as def_file: self._WriteDefFile(dll_name, imports, def_file) # Invoke on lib.exe to create the import library. # We generate everything into the temporary directory, as the .exp export # files will be generated at the same path as the import library, and we # don't want those files potentially gunking the works. dll_base_name, ext = os.path.splitext(dll_name) lib_name = dll_base_name + '.lib' cmdline = ['lib.exe', '/machine:%s' % architecture, '/def:%s' % def_name, '/out:%s' % lib_name] if obj_file: cmdline.append(obj_file) self._Shell(cmdline, cwd=self._temp_dir, stdout=open(os.devnull)) # Copy the .lib file to the output directory. shutil.copyfile(os.path.join(self._temp_dir, lib_name), output_file) _LOGGER.info('Created "%s".', output_file) def CreateImportLib(self, imports_file, output_file): # Read the imports file. imports = self._ReadImportsFile(imports_file) # Creates the requested import library in the output directory. self._CreateImportLib(imports['dll_name'], imports['imports'], imports.get('architecture', 'x86'), output_file) def main(): parser = optparse.OptionParser(usage=_USAGE) parser.add_option('-o', '--output-file', help='Specifies the output file path.') parser.add_option('-k', '--keep-temp-dir', action='store_true', help='Keep the temporary directory.') parser.add_option('-v', '--verbose', action='store_true', help='Verbose logging.') options, args = parser.parse_args() if len(args) != 1: parser.error('You must provide an imports file.') if not options.output_file: parser.error('You must provide an output file.') options.output_file = os.path.abspath(options.output_file) if options.verbose: logging.basicConfig(level=logging.INFO) else: logging.basicConfig(level=logging.WARN) temp_dir = tempfile.mkdtemp() _LOGGER.info('Created temporary directory "%s."', temp_dir) try: # Create a generator and create the import lib. generator = _ImportLibraryGenerator(temp_dir) ret = generator.CreateImportLib(args[0], options.output_file) except Exception, e: _LOGGER.exception('Failed to create import lib.') ret = 1 finally: if not options.keep_temp_dir: shutil.rmtree(temp_dir) _LOGGER.info('Deleted temporary directory "%s."', temp_dir) return ret if __name__ == '__main__': sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 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, 3, 199, 624, 10607, 376, 492, 3555, 687, 376, 492, 1369, 570, 1041, 199, 646, 6073, 199, 646, 2050, 199, 646, 8691, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 63, 20274, 275, 9638, 199, 7692, 26, 450, 6595, 359, 1419, 61, 359, 12775, 13, 493, 61, 199, 199, 10607, 376, 492, 3555, 687, 8925, 13, 493, 14, 199, 199, 7443, 26, 642, 2884, 4440, 314, 333, 9026, 22931, 82, 334, 757, 14, 5803, 9, 436, 314, 3555, 4744, 272, 334, 773, 14, 5803, 395, 3865, 402, 1314, 1471, 506, 315, 931, 14, 199, 624, 421, 199, 63, 27322, 63, 840, 2533, 63, 7311, 275, 9638, 199, 27, 961, 570, 365, 18392, 701, 1218, 63, 25893, 63, 2676, 14, 647, 12, 886, 440, 5283, 14, 199, 14, 8040, 199, 14, 11429, 9821, 619, 12, 445, 199, 14, 6012, 199, 199, 27, 23429, 83, 370, 5647, 333, 22183, 1561, 370, 1973, 14, 5803, 367, 314, 199, 27, 3211, 10152, 402, 492, 20314, 14, 199, 624, 421, 199, 63, 5638, 63, 840, 2533, 63, 7311, 275, 9638, 199, 27, 961, 570, 365, 18392, 701, 1218, 63, 25893, 63, 2676, 14, 647, 12, 886, 440, 5283, 14, 199, 199, 27, 20220, 18707, 367, 12999, 492, 20314, 14, 199, 624, 421, 199, 63, 10186, 275, 2050, 14, 5572, 342, 4388, 199, 533, 485, 547, 8, 1726, 304, 523, 986, 421, 199, 533, 485, 6295, 7424, 7599, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2388, 63, 694, 304, 272, 291, 423, 808, 63, 694, 275, 2388, 63, 694, 819, 347, 485, 8529, 8, 277, 12, 2088, 12, 1011, 829, 304, 272, 2203, 275, 3873, 14, 1250, 8, 1760, 12, 1011, 829, 9, 272, 485, 10186, 14, 815, 360, 9602, 2071, 83, 2, 2138, 450, 68, 3130, 2088, 12, 2203, 9, 272, 340, 2203, 1137, 378, 26, 489, 746, 485, 547, 360, 3110, 2071, 83, 2, 2138, 450, 68, 3530, 450, 334, 1760, 12, 2203, 430, 819, 347, 485, 3284, 32447, 1173, 8, 277, 12, 8925, 63, 493, 304, 272, 327, 428, 76, 300, 80, 314, 8925, 570, 14, 272, 372, 6073, 14, 8939, 63, 2579, 8, 1490, 8, 12775, 63, 493, 680, 739, 1012, 819, 347, 485, 3534, 8067, 83, 1173, 8, 277, 12, 492, 63, 1247, 12, 1072, 63, 493, 304, 272, 1072, 63, 493, 14, 952, 1547, 27322, 63, 840, 2533, 63, 7311, 9, 339, 367, 536, 315, 492, 63, 1247, 26, 489, 1072, 63, 493, 14, 952, 3508, 83, 3611, 35, 60, 78, 7, 450, 536, 9, 489, 1072, 63, 493, 14, 952, 3508, 83, 7729, 48, 60, 78, 7, 450, 536, 9, 339, 1072, 63, 493, 14, 952, 360, 3902, 60, 78, 358, 819, 347, 485, 3534, 6172, 1173, 8, 277, 12, 17112, 63, 354, 12, 492, 63, 1247, 12, 1072, 63, 493, 304, 272, 1072, 63, 493, 14, 952, 1547, 5638, 63, 840, 2533, 63, 7311, 9, 272, 1072, 63, 493, 14, 952, 360, 2339, 450, 83, 60, 78, 7, 450, 17112, 63, 354, 9, 272, 1072, 63, 493, 14, 952, 360, 18341, 51, 60, 78, 358, 272, 367, 536, 315, 492, 63, 1247, 26, 489, 536, 275, 536, 14, 1294, 16591, 5832, 16, 61, 489, 1072, 63, 493, 14, 952, 360, 221, 450, 83, 60, 78, 7, 450, 536, 9, 819, 347, 485, 2499, 5665, 8, 277, 12, 17112, 63, 354, 12, 8925, 304, 272, 408, 20908, 376, 24869, 570, 3035, 2701, 18707, 14, 339, 2104, 1924, 8439, 805, 402, 314, 1824, 26, 339, 2654, 28459, 3484, 10464, 32, 20, 3611, 35, 272, 2654, 28459, 3484, 10464, 32, 20, 7729, 48, 339, 710, 9183, 909, 570, 365, 2066, 6841, 370, 1973, 14, 5803, 543, 282, 1275, 318, 570, 272, 13507, 316, 314, 5226, 2222, 13, 350, 6161, 379, 22609, 465, 2985, 7468, 641, 314, 272, 4843, 316, 577, 4464, 12, 325, 14, 71, 14, 339, 3651, 3657, 51, 489, 2654, 28459, 3484, 10464, 339, 1010, 14665, 12, 314, 1275, 318, 570, 436, 314, 1275, 1113, 570, 7675, 1973, 14, 5803, 370, 3550, 272, 376, 671, 1184, 492, 1973, 543, 4575, 6698, 4310, 2839, 272, 4396, 3236, 363, 1123, 28459, 3484, 10464, 32, 20, 401, 11696, 370, 22609, 4310, 2839, 272, 298, 1123, 28459, 3484, 10464, 1674, 339, 2900, 402, 642, 365, 1126, 321, 454, 972, 315, 282, 7937, 2082, 12, 465, 314, 13197, 272, 27990, 787, 12530, 436, 8837, 370, 7389, 12, 436, 402, 949, 13518, 370, 29165, 272, 2410, 314, 10572, 1041, 339, 327, 2790, 376, 1275, 11374, 570, 370, 5647, 2418, 1250, 13, 2930, 10098, 1561, 370, 1973, 14, 5803, 14, 272, 21875, 63, 354, 275, 17112, 63, 354, 435, 1987, 11374, 7, 272, 485, 10186, 14, 815, 360, 16646, 21875, 570, 2071, 83, 1674, 297, 21875, 63, 354, 9, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 423, 808, 63, 694, 12, 21875, 63, 354, 395, 283, 6603, 358, 465, 22312, 63, 493, 26, 489, 291, 423, 3534, 8067, 83, 1173, 8, 12775, 12, 22312, 63, 493, 9, 339, 327, 31049, 641, 314, 22931, 82, 370, 6555, 652, 370, 1275, 1113, 14, 272, 1559, 63, 354, 275, 17112, 63, 354, 435, 1987, 1113, 7, 272, 21206, 275, 788, 757, 14, 5803, 297, 1994, 889, 9733, 297, 1994, 67, 297, 21875, 63, 354, 12, 1994, 15563, 297, 1559, 63, 354, 61, 272, 291, 423, 8529, 8, 15612, 12, 8288, 29, 277, 423, 808, 63, 694, 12, 3839, 29, 1490, 8, 736, 14, 19778, 430, 339, 372, 1559, 63, 354, 819, 347, 485, 2499, 6295, 4728, 8, 277, 12, 17112, 63, 354, 12, 8925, 12, 15931, 12, 1072, 63, 493, 304, 272, 408, 10607, 376, 492, 1973, 11696, 8925, 370, 17112, 63, 354, 367, 15931, 14, 339, 4068, 3182, 12, 14511, 314, 492, 3555, 370, 1072, 570, 14, 272, 408, 272, 1559, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 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, 3, 199, 624, 10607, 376, 492, 3555, 687, 376, 492, 1369, 570, 1041, 199, 646, 6073, 199, 646, 2050, 199, 646, 8691, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 63, 20274, 275, 9638, 199, 7692, 26, 450, 6595, 359, 1419, 61, 359, 12775, 13, 493, 61, 199, 199, 10607, 376, 492, 3555, 687, 8925, 13, 493, 14, 199, 199, 7443, 26, 642, 2884, 4440, 314, 333, 9026, 22931, 82, 334, 757, 14, 5803, 9, 436, 314, 3555, 4744, 272, 334, 773, 14, 5803, 395, 3865, 402, 1314, 1471, 506, 315, 931, 14, 199, 624, 421, 199, 63, 27322, 63, 840, 2533, 63, 7311, 275, 9638, 199, 27, 961, 570, 365, 18392, 701, 1218, 63, 25893, 63, 2676, 14, 647, 12, 886, 440, 5283, 14, 199, 14, 8040, 199, 14, 11429, 9821, 619, 12, 445, 199, 14, 6012, 199, 199, 27, 23429, 83, 370, 5647, 333, 22183, 1561, 370, 1973, 14, 5803, 367, 314, 199, 27, 3211, 10152, 402, 492, 20314, 14, 199, 624, 421, 199, 63, 5638, 63, 840, 2533, 63, 7311, 275, 9638, 199, 27, 961, 570, 365, 18392, 701, 1218, 63, 25893, 63, 2676, 14, 647, 12, 886, 440, 5283, 14, 199, 199, 27, 20220, 18707, 367, 12999, 492, 20314, 14, 199, 624, 421, 199, 63, 10186, 275, 2050, 14, 5572, 342, 4388, 199, 533, 485, 547, 8, 1726, 304, 523, 986, 421, 199, 533, 485, 6295, 7424, 7599, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2388, 63, 694, 304, 272, 291, 423, 808, 63, 694, 275, 2388, 63, 694, 819, 347, 485, 8529, 8, 277, 12, 2088, 12, 1011, 829, 304, 272, 2203, 275, 3873, 14, 1250, 8, 1760, 12, 1011, 829, 9, 272, 485, 10186, 14, 815, 360, 9602, 2071, 83, 2, 2138, 450, 68, 3130, 2088, 12, 2203, 9, 272, 340, 2203, 1137, 378, 26, 489, 746, 485, 547, 360, 3110, 2071, 83, 2, 2138, 450, 68, 3530, 450, 334, 1760, 12, 2203, 430, 819, 347, 485, 3284, 32447, 1173, 8, 277, 12, 8925, 63, 493, 304, 272, 327, 428, 76, 300, 80, 314, 8925, 570, 14, 272, 372, 6073, 14, 8939, 63, 2579, 8, 1490, 8, 12775, 63, 493, 680, 739, 1012, 819, 347, 485, 3534, 8067, 83, 1173, 8, 277, 12, 492, 63, 1247, 12, 1072, 63, 493, 304, 272, 1072, 63, 493, 14, 952, 1547, 27322, 63, 840, 2533, 63, 7311, 9, 339, 367, 536, 315, 492, 63, 1247, 26, 489, 1072, 63, 493, 14, 952, 3508, 83, 3611, 35, 60, 78, 7, 450, 536, 9, 489, 1072, 63, 493, 14, 952, 3508, 83, 7729, 48, 60, 78, 7, 450, 536, 9, 339, 1072, 63, 493, 14, 952, 360, 3902, 60, 78, 358, 819, 347, 485, 3534, 6172, 1173, 8, 277, 12, 17112, 63, 354, 12, 492, 63, 1247, 12, 1072, 63, 493, 304, 272, 1072, 63, 493, 14, 952, 1547, 5638, 63, 840, 2533, 63, 7311, 9, 272, 1072, 63, 493, 14, 952, 360, 2339, 450, 83, 60, 78, 7, 450, 17112, 63, 354, 9, 272, 1072, 63, 493, 14, 952, 360, 18341, 51, 60, 78, 358, 272, 367, 536, 315, 492, 63, 1247, 26, 489, 536, 275, 536, 14, 1294, 16591, 5832, 16, 61, 489, 1072, 63, 493, 14, 952, 360, 221, 450, 83, 60, 78, 7, 450, 536, 9, 819, 347, 485, 2499, 5665, 8, 277, 12, 17112, 63, 354, 12, 8925, 304, 272, 408, 20908, 376, 24869, 570, 3035, 2701, 18707, 14, 339, 2104, 1924, 8439, 805, 402, 314, 1824, 26, 339, 2654, 28459, 3484, 10464, 32, 20, 3611, 35, 272, 2654, 28459, 3484, 10464, 32, 20, 7729, 48, 339, 710, 9183, 909, 570, 365, 2066, 6841, 370, 1973, 14, 5803, 543, 282, 1275, 318, 570, 272, 13507, 316, 314, 5226, 2222, 13, 350, 6161, 379, 22609, 465, 2985, 7468, 641, 314, 272, 4843, 316, 577, 4464, 12, 325, 14, 71, 14, 339, 3651, 3657, 51, 489, 2654, 28459, 3484, 10464, 339, 1010, 14665, 12, 314, 1275, 318, 570, 436, 314, 1275, 1113, 570, 7675, 1973, 14, 5803, 370, 3550, 272, 376, 671, 1184, 492, 1973, 543, 4575, 6698, 4310, 2839, 272, 4396, 3236, 363, 1123, 28459, 3484, 10464, 32, 20, 401, 11696, 370, 22609, 4310, 2839, 272, 298, 1123, 28459, 3484, 10464, 1674, 339, 2900, 402, 642, 365, 1126, 321, 454, 972, 315, 282, 7937, 2082, 12, 465, 314, 13197, 272, 27990, 787, 12530, 436, 8837, 370, 7389, 12, 436, 402, 949, 13518, 370, 29165, 272, 2410, 314, 10572, 1041, 339, 327, 2790, 376, 1275, 11374, 570, 370, 5647, 2418, 1250, 13, 2930, 10098, 1561, 370, 1973, 14, 5803, 14, 272, 21875, 63, 354, 275, 17112, 63, 354, 435, 1987, 11374, 7, 272, 485, 10186, 14, 815, 360, 16646, 21875, 570, 2071, 83, 1674, 297, 21875, 63, 354, 9, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 423, 808, 63, 694, 12, 21875, 63, 354, 395, 283, 6603, 358, 465, 22312, 63, 493, 26, 489, 291, 423, 3534, 8067, 83, 1173, 8, 12775, 12, 22312, 63, 493, 9, 339, 327, 31049, 641, 314, 22931, 82, 370, 6555, 652, 370, 1275, 1113, 14, 272, 1559, 63, 354, 275, 17112, 63, 354, 435, 1987, 1113, 7, 272, 21206, 275, 788, 757, 14, 5803, 297, 1994, 889, 9733, 297, 1994, 67, 297, 21875, 63, 354, 12, 1994, 15563, 297, 1559, 63, 354, 61, 272, 291, 423, 8529, 8, 15612, 12, 8288, 29, 277, 423, 808, 63, 694, 12, 3839, 29, 1490, 8, 736, 14, 19778, 430, 339, 372, 1559, 63, 354, 819, 347, 485, 2499, 6295, 4728, 8, 277, 12, 17112, 63, 354, 12, 8925, 12, 15931, 12, 1072, 63, 493, 304, 272, 408, 10607, 376, 492, 1973, 11696, 8925, 370, 17112, 63, 354, 367, 15931, 14, 339, 4068, 3182, 12, 14511, 314, 492, 3555, 370, 1072, 570, 14, 272, 408, 272, 1559, 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, 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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 ]
seckcoder/lang-learn
python/sklearn/sklearn/decomposition/tests/test_kernel_pca.py
1
7069
import numpy as np import scipy.sparse as sp from sklearn.utils.testing import assert_array_almost_equal from sklearn.utils.testing import assert_equal from sklearn.utils.testing import assert_raises from sklearn.decomposition import PCA, KernelPCA from sklearn.datasets import make_circles from sklearn.linear_model import Perceptron from sklearn.utils.testing import assert_less from sklearn.pipeline import Pipeline from sklearn.grid_search import GridSearchCV from sklearn.metrics.pairwise import rbf_kernel def test_kernel_pca(): rng = np.random.RandomState(0) X_fit = rng.random_sample((5, 4)) X_pred = rng.random_sample((2, 4)) for eigen_solver in ("auto", "dense", "arpack"): for kernel in ("linear", "rbf", "poly"): # transform fit data kpca = KernelPCA(4, kernel=kernel, eigen_solver=eigen_solver, fit_inverse_transform=True) X_fit_transformed = kpca.fit_transform(X_fit) X_fit_transformed2 = kpca.fit(X_fit).transform(X_fit) assert_array_almost_equal(np.abs(X_fit_transformed), np.abs(X_fit_transformed2)) # transform new data X_pred_transformed = kpca.transform(X_pred) assert_equal(X_pred_transformed.shape[1], X_fit_transformed.shape[1]) # inverse transform X_pred2 = kpca.inverse_transform(X_pred_transformed) assert_equal(X_pred2.shape, X_pred.shape) def test_invalid_parameters(): assert_raises(ValueError, KernelPCA, 10, fit_inverse_transform=True, kernel='precomputed') def test_kernel_pca_sparse(): rng = np.random.RandomState(0) X_fit = sp.csr_matrix(rng.random_sample((5, 4))) X_pred = sp.csr_matrix(rng.random_sample((2, 4))) for eigen_solver in ("auto", "arpack"): for kernel in ("linear", "rbf", "poly"): # transform fit data kpca = KernelPCA(4, kernel=kernel, eigen_solver=eigen_solver, fit_inverse_transform=False) X_fit_transformed = kpca.fit_transform(X_fit) X_fit_transformed2 = kpca.fit(X_fit).transform(X_fit) assert_array_almost_equal(np.abs(X_fit_transformed), np.abs(X_fit_transformed2)) # transform new data X_pred_transformed = kpca.transform(X_pred) assert_equal(X_pred_transformed.shape[1], X_fit_transformed.shape[1]) # inverse transform #X_pred2 = kpca.inverse_transform(X_pred_transformed) #assert_equal(X_pred2.shape, X_pred.shape) def test_kernel_pca_linear_kernel(): rng = np.random.RandomState(0) X_fit = rng.random_sample((5, 4)) X_pred = rng.random_sample((2, 4)) # for a linear kernel, kernel PCA should find the same projection as PCA # modulo the sign (direction) # fit only the first four components: fifth is near zero eigenvalue, so # can be trimmed due to roundoff error assert_array_almost_equal( np.abs(KernelPCA(4).fit(X_fit).transform(X_pred)), np.abs(PCA(4).fit(X_fit).transform(X_pred))) def test_kernel_pca_n_components(): rng = np.random.RandomState(0) X_fit = rng.random_sample((5, 4)) X_pred = rng.random_sample((2, 4)) for eigen_solver in ("dense", "arpack"): for c in [1, 2, 4]: kpca = KernelPCA(n_components=c, eigen_solver=eigen_solver) shape = kpca.fit(X_fit).transform(X_pred).shape assert_equal(shape, (2, c)) def test_kernel_pca_precomputed(): rng = np.random.RandomState(0) X_fit = rng.random_sample((5, 4)) X_pred = rng.random_sample((2, 4)) for eigen_solver in ("dense", "arpack"): X_kpca = KernelPCA(4, eigen_solver=eigen_solver).\ fit(X_fit).transform(X_pred) X_kpca2 = KernelPCA(4, eigen_solver=eigen_solver, kernel='precomputed').fit(np.dot(X_fit, X_fit.T)).transform(np.dot(X_pred, X_fit.T)) X_kpca_train = KernelPCA(4, eigen_solver=eigen_solver, kernel='precomputed').fit_transform(np.dot(X_fit, X_fit.T)) X_kpca_train2 = KernelPCA(4, eigen_solver=eigen_solver, kernel='precomputed').fit(np.dot(X_fit, X_fit.T)).transform(np.dot(X_fit, X_fit.T)) assert_array_almost_equal(np.abs(X_kpca), np.abs(X_kpca2)) assert_array_almost_equal(np.abs(X_kpca_train), np.abs(X_kpca_train2)) def test_kernel_pca_invalid_kernel(): rng = np.random.RandomState(0) X_fit = rng.random_sample((2, 4)) kpca = KernelPCA(kernel="tototiti") assert_raises(ValueError, kpca.fit, X_fit) def test_gridsearch_pipeline(): # Test if we can do a grid-search to find parameters to separate # circles with a perceptron model. X, y = make_circles(n_samples=400, factor=.3, noise=.05, random_state=0) kpca = KernelPCA(kernel="rbf", n_components=2) pipeline = Pipeline([("kernel_pca", kpca), ("Perceptron", Perceptron())]) param_grid = dict(kernel_pca__gamma=2. ** np.arange(-2, 2)) grid_search = GridSearchCV(pipeline, cv=3, param_grid=param_grid) grid_search.fit(X, y) assert_equal(grid_search.best_score_, 1) def test_gridsearch_pipeline_precomputed(): # Test if we can do a grid-search to find parameters to separate # circles with a perceptron model using a precomputed kernel. X, y = make_circles(n_samples=400, factor=.3, noise=.05, random_state=0) kpca = KernelPCA(kernel="precomputed", n_components=2) pipeline = Pipeline([("kernel_pca", kpca), ("Perceptron", Perceptron())]) param_grid = dict(Perceptron__n_iter=np.arange(1, 5)) grid_search = GridSearchCV(pipeline, cv=3, param_grid=param_grid) X_kernel = rbf_kernel(X, gamma=2.) grid_search.fit(X_kernel, y) assert_equal(grid_search.best_score_, 1) def test_nested_circles(): """Test the linear separability of the first 2D KPCA transform""" X, y = make_circles(n_samples=400, factor=.3, noise=.05, random_state=0) # 2D nested circles are not linearly separable train_score = Perceptron().fit(X, y).score(X, y) assert_less(train_score, 0.8) # Project the circles data into the first 2 components of a RBF Kernel # PCA model. # Note that the gamma value is data dependent. If this test breaks # and the gamma value has to be updated, the Kernel PCA example will # have to be updated too. kpca = KernelPCA(kernel="rbf", n_components=2, fit_inverse_transform=True, gamma=2.) X_kpca = kpca.fit_transform(X) # The data is perfectly linearly separable in that space train_score = Perceptron().fit(X_kpca, y).score(X_kpca, y) assert_equal(train_score, 1.0) if __name__ == '__main__': import nose nose.run(argv=['', __file__])
unlicense
[ 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 199, 504, 6357, 14, 31384, 492, 25266, 12, 24901, 23852, 199, 504, 6357, 14, 12281, 492, 1852, 63, 6092, 2978, 199, 504, 6357, 14, 6676, 63, 1238, 492, 3492, 301, 4695, 265, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2003, 199, 504, 6357, 14, 7379, 492, 19090, 199, 504, 6357, 14, 3825, 63, 1733, 492, 32570, 199, 504, 6357, 14, 6759, 14, 25069, 492, 519, 4361, 63, 4989, 421, 199, 318, 511, 63, 4989, 63, 19247, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 367, 11471, 63, 11263, 315, 1689, 2495, 401, 298, 7253, 401, 298, 285, 1389, 2349, 267, 367, 5114, 315, 1689, 6676, 401, 298, 25853, 401, 298, 6023, 2349, 288, 327, 5793, 5542, 666, 288, 1022, 19247, 275, 24901, 23852, 8, 20, 12, 5114, 29, 4989, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 12, 2490, 5542, 63, 11668, 63, 4711, 29, 549, 9, 288, 1323, 63, 3269, 63, 20209, 275, 1022, 19247, 14, 3269, 63, 4711, 8, 56, 63, 3269, 9, 288, 1323, 63, 3269, 63, 20209, 18, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 3269, 9, 288, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1590, 14, 2101, 8, 56, 63, 3269, 63, 20209, 395, 4228, 980, 14, 2101, 8, 56, 63, 3269, 63, 20209, 18, 430, 953, 327, 5793, 892, 666, 288, 1323, 63, 5991, 63, 20209, 275, 1022, 19247, 14, 4711, 8, 56, 63, 5991, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 63, 20209, 14, 1392, 59, 17, 467, 586, 1323, 63, 3269, 63, 20209, 14, 1392, 59, 17, 566, 953, 327, 11484, 5793, 288, 1323, 63, 5991, 18, 275, 1022, 19247, 14, 11668, 63, 4711, 8, 56, 63, 5991, 63, 20209, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 18, 14, 1392, 12, 1323, 63, 5991, 14, 1392, 9, 421, 199, 318, 511, 63, 3197, 63, 3214, 837, 272, 702, 63, 3536, 8, 3393, 12, 24901, 23852, 12, 1616, 12, 5542, 63, 11668, 63, 4711, 29, 549, 12, 2116, 5114, 534, 26596, 358, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 4421, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 2249, 14, 10101, 63, 3642, 8, 12686, 14, 2355, 63, 3271, 1332, 21, 12, 841, 1724, 272, 1323, 63, 5991, 275, 2249, 14, 10101, 63, 3642, 8, 12686, 14, 2355, 63, 3271, 1332, 18, 12, 841, 1724, 339, 367, 11471, 63, 11263, 315, 1689, 2495, 401, 298, 285, 1389, 2349, 267, 367, 5114, 315, 1689, 6676, 401, 298, 25853, 401, 298, 6023, 2349, 288, 327, 5793, 5542, 666, 288, 1022, 19247, 275, 24901, 23852, 8, 20, 12, 5114, 29, 4989, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 12, 2490, 5542, 63, 11668, 63, 4711, 29, 797, 9, 288, 1323, 63, 3269, 63, 20209, 275, 1022, 19247, 14, 3269, 63, 4711, 8, 56, 63, 3269, 9, 288, 1323, 63, 3269, 63, 20209, 18, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 3269, 9, 288, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1590, 14, 2101, 8, 56, 63, 3269, 63, 20209, 395, 4228, 980, 14, 2101, 8, 56, 63, 3269, 63, 20209, 18, 430, 953, 327, 5793, 892, 666, 288, 1323, 63, 5991, 63, 20209, 275, 1022, 19247, 14, 4711, 8, 56, 63, 5991, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 63, 20209, 14, 1392, 59, 17, 467, 490, 1323, 63, 3269, 63, 20209, 14, 1392, 59, 17, 566, 953, 327, 11484, 5793, 288, 327, 56, 63, 5991, 18, 275, 1022, 19247, 14, 11668, 63, 4711, 8, 56, 63, 5991, 63, 20209, 9, 288, 327, 479, 63, 1452, 8, 56, 63, 5991, 18, 14, 1392, 12, 1323, 63, 5991, 14, 1392, 9, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 6676, 63, 4989, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 327, 367, 282, 7798, 5114, 12, 5114, 25266, 1077, 2342, 314, 2011, 14777, 465, 25266, 272, 327, 27656, 314, 2070, 334, 6874, 9, 272, 327, 5542, 1454, 314, 1642, 11648, 7323, 26, 289, 11509, 365, 17429, 4697, 11471, 585, 12, 880, 272, 327, 883, 506, 24196, 7037, 370, 6168, 1997, 1125, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 980, 14, 2101, 8, 14127, 23852, 8, 20, 680, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 1826, 267, 980, 14, 2101, 8, 23852, 8, 20, 680, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 1724, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 78, 63, 4608, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 367, 11471, 63, 11263, 315, 1689, 7253, 401, 298, 285, 1389, 2349, 267, 367, 286, 315, 359, 17, 12, 499, 12, 841, 2189, 288, 1022, 19247, 275, 24901, 23852, 8, 78, 63, 4608, 29, 67, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 9, 288, 2215, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 680, 1392, 953, 702, 63, 1452, 8, 1392, 12, 334, 18, 12, 286, 430, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 26596, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8 ]
[ 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 199, 504, 6357, 14, 31384, 492, 25266, 12, 24901, 23852, 199, 504, 6357, 14, 12281, 492, 1852, 63, 6092, 2978, 199, 504, 6357, 14, 6676, 63, 1238, 492, 3492, 301, 4695, 265, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2003, 199, 504, 6357, 14, 7379, 492, 19090, 199, 504, 6357, 14, 3825, 63, 1733, 492, 32570, 199, 504, 6357, 14, 6759, 14, 25069, 492, 519, 4361, 63, 4989, 421, 199, 318, 511, 63, 4989, 63, 19247, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 367, 11471, 63, 11263, 315, 1689, 2495, 401, 298, 7253, 401, 298, 285, 1389, 2349, 267, 367, 5114, 315, 1689, 6676, 401, 298, 25853, 401, 298, 6023, 2349, 288, 327, 5793, 5542, 666, 288, 1022, 19247, 275, 24901, 23852, 8, 20, 12, 5114, 29, 4989, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 12, 2490, 5542, 63, 11668, 63, 4711, 29, 549, 9, 288, 1323, 63, 3269, 63, 20209, 275, 1022, 19247, 14, 3269, 63, 4711, 8, 56, 63, 3269, 9, 288, 1323, 63, 3269, 63, 20209, 18, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 3269, 9, 288, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1590, 14, 2101, 8, 56, 63, 3269, 63, 20209, 395, 4228, 980, 14, 2101, 8, 56, 63, 3269, 63, 20209, 18, 430, 953, 327, 5793, 892, 666, 288, 1323, 63, 5991, 63, 20209, 275, 1022, 19247, 14, 4711, 8, 56, 63, 5991, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 63, 20209, 14, 1392, 59, 17, 467, 586, 1323, 63, 3269, 63, 20209, 14, 1392, 59, 17, 566, 953, 327, 11484, 5793, 288, 1323, 63, 5991, 18, 275, 1022, 19247, 14, 11668, 63, 4711, 8, 56, 63, 5991, 63, 20209, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 18, 14, 1392, 12, 1323, 63, 5991, 14, 1392, 9, 421, 199, 318, 511, 63, 3197, 63, 3214, 837, 272, 702, 63, 3536, 8, 3393, 12, 24901, 23852, 12, 1616, 12, 5542, 63, 11668, 63, 4711, 29, 549, 12, 2116, 5114, 534, 26596, 358, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 4421, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 2249, 14, 10101, 63, 3642, 8, 12686, 14, 2355, 63, 3271, 1332, 21, 12, 841, 1724, 272, 1323, 63, 5991, 275, 2249, 14, 10101, 63, 3642, 8, 12686, 14, 2355, 63, 3271, 1332, 18, 12, 841, 1724, 339, 367, 11471, 63, 11263, 315, 1689, 2495, 401, 298, 285, 1389, 2349, 267, 367, 5114, 315, 1689, 6676, 401, 298, 25853, 401, 298, 6023, 2349, 288, 327, 5793, 5542, 666, 288, 1022, 19247, 275, 24901, 23852, 8, 20, 12, 5114, 29, 4989, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 12, 2490, 5542, 63, 11668, 63, 4711, 29, 797, 9, 288, 1323, 63, 3269, 63, 20209, 275, 1022, 19247, 14, 3269, 63, 4711, 8, 56, 63, 3269, 9, 288, 1323, 63, 3269, 63, 20209, 18, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 3269, 9, 288, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1590, 14, 2101, 8, 56, 63, 3269, 63, 20209, 395, 4228, 980, 14, 2101, 8, 56, 63, 3269, 63, 20209, 18, 430, 953, 327, 5793, 892, 666, 288, 1323, 63, 5991, 63, 20209, 275, 1022, 19247, 14, 4711, 8, 56, 63, 5991, 9, 288, 702, 63, 1452, 8, 56, 63, 5991, 63, 20209, 14, 1392, 59, 17, 467, 490, 1323, 63, 3269, 63, 20209, 14, 1392, 59, 17, 566, 953, 327, 11484, 5793, 288, 327, 56, 63, 5991, 18, 275, 1022, 19247, 14, 11668, 63, 4711, 8, 56, 63, 5991, 63, 20209, 9, 288, 327, 479, 63, 1452, 8, 56, 63, 5991, 18, 14, 1392, 12, 1323, 63, 5991, 14, 1392, 9, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 6676, 63, 4989, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 327, 367, 282, 7798, 5114, 12, 5114, 25266, 1077, 2342, 314, 2011, 14777, 465, 25266, 272, 327, 27656, 314, 2070, 334, 6874, 9, 272, 327, 5542, 1454, 314, 1642, 11648, 7323, 26, 289, 11509, 365, 17429, 4697, 11471, 585, 12, 880, 272, 327, 883, 506, 24196, 7037, 370, 6168, 1997, 1125, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 980, 14, 2101, 8, 14127, 23852, 8, 20, 680, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 1826, 267, 980, 14, 2101, 8, 23852, 8, 20, 680, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 1724, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 78, 63, 4608, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 63, 3269, 275, 9038, 14, 2355, 63, 3271, 1332, 21, 12, 841, 430, 272, 1323, 63, 5991, 275, 9038, 14, 2355, 63, 3271, 1332, 18, 12, 841, 430, 339, 367, 11471, 63, 11263, 315, 1689, 7253, 401, 298, 285, 1389, 2349, 267, 367, 286, 315, 359, 17, 12, 499, 12, 841, 2189, 288, 1022, 19247, 275, 24901, 23852, 8, 78, 63, 4608, 29, 67, 12, 11471, 63, 11263, 29, 19545, 63, 11263, 9, 288, 2215, 275, 1022, 19247, 14, 3269, 8, 56, 63, 3269, 680, 4711, 8, 56, 63, 5991, 680, 1392, 953, 702, 63, 1452, 8, 1392, 12, 334, 18, 12, 286, 430, 421, 199, 318, 511, 63, 4989, 63, 19247, 63, 26596, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 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,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Public License v3. See license.txt from __future__ import unicode_literals import webnotes from webnotes import session, msgprint from webnotes.utils import today from utilities.transaction_base import TransactionBase class DocType(TransactionBase): def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist def validate(self): if session['user'] != 'Guest' and not self.doc.customer: msgprint("Please select Customer from whom issue is raised", raise_exception=True) if self.doc.status=="Closed" and \ webnotes.conn.get_value("Customer Issue", self.doc.name, "status")!="Closed": self.doc.resolution_date = today() self.doc.resolved_by = webnotes.session.user def on_cancel(self): lst = webnotes.conn.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t2.prevdoc_docname = '%s' and t1.docstatus!=2"%(self.doc.name)) if lst: lst1 = ','.join([x[0] for x in lst]) msgprint("Maintenance Visit No. "+lst1+" already created against this customer issue. So can not be Cancelled") raise Exception else: webnotes.conn.set(self.doc, 'status', 'Cancelled') def on_update(self): pass @webnotes.whitelist() def make_maintenance_visit(source_name, target_doclist=None): from webnotes.model.mapper import get_mapped_doclist visit = webnotes.conn.sql("""select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'""", source_name) if not visit: doclist = get_mapped_doclist("Customer Issue", source_name, { "Customer Issue": { "doctype": "Maintenance Visit", "field_map": { "complaint": "description", "doctype": "prevdoc_doctype", "name": "prevdoc_docname" } } }, target_doclist) return [d.fields for d in doclist]
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 23154, 199, 504, 23154, 492, 2351, 12, 1499, 1361, 199, 504, 23154, 14, 1208, 492, 11168, 2742, 199, 199, 504, 15841, 14, 5945, 63, 1095, 492, 18244, 1563, 199, 199, 533, 5454, 804, 8, 10161, 1563, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1382, 12, 1382, 513, 17894, 507, 198, 277, 14, 1301, 275, 1382, 507, 198, 277, 14, 1301, 513, 275, 1382, 513, 8299, 198, 318, 4107, 8, 277, 304, 507, 198, 692, 2351, 459, 751, 418, 1137, 283, 16022, 7, 436, 440, 291, 14, 1301, 14, 10178, 26, 686, 198, 1328, 1361, 480, 8254, 3504, 22397, 687, 12676, 4976, 365, 4915, 401, 1585, 198, 3730, 63, 1971, 29, 549, 9, 1871, 507, 198, 692, 291, 14, 1301, 14, 1205, 11800, 15190, 2, 436, 971, 686, 198, 30307, 14, 1631, 14, 362, 63, 585, 480, 17025, 13383, 401, 291, 14, 1301, 14, 354, 12, 298, 1205, 531, 1, 628, 15190, 582, 686, 198, 277, 14, 1301, 14, 12588, 63, 602, 275, 11168, 342, 686, 198, 277, 14, 1301, 14, 13697, 63, 991, 275, 23154, 14, 1730, 14, 751, 8299, 198, 318, 641, 63, 6406, 8, 277, 304, 507, 198, 6916, 275, 23154, 14, 1631, 14, 3009, 480, 2416, 307, 17, 14, 354, 687, 658, 2902, 6756, 12182, 29614, 64, 307, 17, 12, 658, 2902, 6756, 12182, 29614, 23177, 4070, 64, 307, 18, 2382, 307, 18, 14, 1708, 275, 307, 17, 14, 354, 436, 307, 18, 14, 5701, 1301, 63, 21828, 275, 1543, 83, 7, 436, 198, 84, 17, 14, 30461, 1111, 18, 14007, 277, 14, 1301, 14, 354, 430, 507, 198, 692, 9877, 26, 686, 198, 6916, 17, 275, 12814, 904, 779, 88, 59, 16, 61, 367, 671, 315, 9877, 566, 686, 198, 1328, 1361, 480, 6756, 12182, 29614, 3091, 14, 7210, 6916, 17, 5207, 2575, 2737, 6169, 642, 15229, 4976, 14, 2002, 883, 440, 506, 28374, 1146, 531, 686, 198, 3730, 2186, 507, 198, 2836, 26, 686, 198, 30307, 14, 1631, 14, 409, 8, 277, 14, 1301, 12, 283, 1205, 297, 283, 22127, 358, 421, 198, 318, 641, 63, 873, 8, 277, 304, 507, 198, 1529, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 1852, 63, 19725, 63, 5427, 8, 1365, 63, 354, 12, 1347, 63, 1301, 513, 29, 403, 304, 199, 198, 504, 23154, 14, 1238, 14, 7153, 492, 664, 63, 11663, 63, 1301, 513, 8299, 198, 5427, 275, 23154, 14, 1631, 14, 3009, 4852, 2416, 307, 17, 14, 354, 11083, 198, 504, 658, 2902, 6756, 12182, 29614, 64, 307, 17, 12, 658, 2902, 6756, 12182, 29614, 23177, 4070, 64, 307, 18, 11083, 198, 4509, 307, 18, 14, 1708, 29, 84, 17, 14, 354, 436, 307, 18, 14, 5701, 1301, 63, 21828, 2458, 83, 11083, 198, 460, 307, 17, 14, 30461, 29, 17, 436, 307, 17, 14, 13207, 63, 1205, 534, 38, 8525, 12515, 471, 7, 7208, 1350, 63, 354, 9, 18118, 198, 692, 440, 5684, 26, 507, 198, 1301, 513, 275, 664, 63, 11663, 63, 1301, 513, 480, 17025, 13383, 401, 1350, 63, 354, 12, 469, 686, 198, 2, 17025, 13383, 582, 469, 1585, 198, 2, 6356, 582, 298, 6756, 12182, 29614, 401, 28932, 198, 2, 698, 63, 1130, 582, 469, 1871, 198, 2, 863, 416, 442, 582, 298, 1802, 401, 221, 1871, 198, 2, 6356, 582, 298, 5701, 1301, 63, 6356, 401, 221, 1871, 198, 2, 354, 582, 298, 5701, 1301, 63, 21828, 2, 1585, 198, 93, 686, 198, 93, 507, 198, 1386, 1347, 63, 1301, 513, 9, 28550, 198, 1107, 359, 68, 14, 955, 367, 366, 315, 1382, 513, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 421, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 23154, 199, 504, 23154, 492, 2351, 12, 1499, 1361, 199, 504, 23154, 14, 1208, 492, 11168, 2742, 199, 199, 504, 15841, 14, 5945, 63, 1095, 492, 18244, 1563, 199, 199, 533, 5454, 804, 8, 10161, 1563, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1382, 12, 1382, 513, 17894, 507, 198, 277, 14, 1301, 275, 1382, 507, 198, 277, 14, 1301, 513, 275, 1382, 513, 8299, 198, 318, 4107, 8, 277, 304, 507, 198, 692, 2351, 459, 751, 418, 1137, 283, 16022, 7, 436, 440, 291, 14, 1301, 14, 10178, 26, 686, 198, 1328, 1361, 480, 8254, 3504, 22397, 687, 12676, 4976, 365, 4915, 401, 1585, 198, 3730, 63, 1971, 29, 549, 9, 1871, 507, 198, 692, 291, 14, 1301, 14, 1205, 11800, 15190, 2, 436, 971, 686, 198, 30307, 14, 1631, 14, 362, 63, 585, 480, 17025, 13383, 401, 291, 14, 1301, 14, 354, 12, 298, 1205, 531, 1, 628, 15190, 582, 686, 198, 277, 14, 1301, 14, 12588, 63, 602, 275, 11168, 342, 686, 198, 277, 14, 1301, 14, 13697, 63, 991, 275, 23154, 14, 1730, 14, 751, 8299, 198, 318, 641, 63, 6406, 8, 277, 304, 507, 198, 6916, 275, 23154, 14, 1631, 14, 3009, 480, 2416, 307, 17, 14, 354, 687, 658, 2902, 6756, 12182, 29614, 64, 307, 17, 12, 658, 2902, 6756, 12182, 29614, 23177, 4070, 64, 307, 18, 2382, 307, 18, 14, 1708, 275, 307, 17, 14, 354, 436, 307, 18, 14, 5701, 1301, 63, 21828, 275, 1543, 83, 7, 436, 198, 84, 17, 14, 30461, 1111, 18, 14007, 277, 14, 1301, 14, 354, 430, 507, 198, 692, 9877, 26, 686, 198, 6916, 17, 275, 12814, 904, 779, 88, 59, 16, 61, 367, 671, 315, 9877, 566, 686, 198, 1328, 1361, 480, 6756, 12182, 29614, 3091, 14, 7210, 6916, 17, 5207, 2575, 2737, 6169, 642, 15229, 4976, 14, 2002, 883, 440, 506, 28374, 1146, 531, 686, 198, 3730, 2186, 507, 198, 2836, 26, 686, 198, 30307, 14, 1631, 14, 409, 8, 277, 14, 1301, 12, 283, 1205, 297, 283, 22127, 358, 421, 198, 318, 641, 63, 873, 8, 277, 304, 507, 198, 1529, 199, 199, 32, 30307, 14, 14189, 342, 199, 318, 1852, 63, 19725, 63, 5427, 8, 1365, 63, 354, 12, 1347, 63, 1301, 513, 29, 403, 304, 199, 198, 504, 23154, 14, 1238, 14, 7153, 492, 664, 63, 11663, 63, 1301, 513, 8299, 198, 5427, 275, 23154, 14, 1631, 14, 3009, 4852, 2416, 307, 17, 14, 354, 11083, 198, 504, 658, 2902, 6756, 12182, 29614, 64, 307, 17, 12, 658, 2902, 6756, 12182, 29614, 23177, 4070, 64, 307, 18, 11083, 198, 4509, 307, 18, 14, 1708, 29, 84, 17, 14, 354, 436, 307, 18, 14, 5701, 1301, 63, 21828, 2458, 83, 11083, 198, 460, 307, 17, 14, 30461, 29, 17, 436, 307, 17, 14, 13207, 63, 1205, 534, 38, 8525, 12515, 471, 7, 7208, 1350, 63, 354, 9, 18118, 198, 692, 440, 5684, 26, 507, 198, 1301, 513, 275, 664, 63, 11663, 63, 1301, 513, 480, 17025, 13383, 401, 1350, 63, 354, 12, 469, 686, 198, 2, 17025, 13383, 582, 469, 1585, 198, 2, 6356, 582, 298, 6756, 12182, 29614, 401, 28932, 198, 2, 698, 63, 1130, 582, 469, 1871, 198, 2, 863, 416, 442, 582, 298, 1802, 401, 221, 1871, 198, 2, 6356, 582, 298, 5701, 1301, 63, 6356, 401, 221, 1871, 198, 2, 354, 582, 298, 5701, 1301, 63, 21828, 2, 1585, 198, 93, 686, 198, 93, 507, 198, 1386, 1347, 63, 1301, 513, 9, 28550, 198, 1107, 359, 68, 14, 955, 367, 366, 315, 1382, 513, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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py
624
1503
from browser import document as doc from browser import window, html, markdown import highlight import time def run(ev): # run the code in the elt after the button ix = ev.target.parent.children.index(ev.target) elt = ev.target.parent.children[ix+1] exec(elt.text) elt.focus() def load(url,target): # fake query string to bypass browser cache qs = '?foo=%s' %time.time() try: mk,scripts = markdown.mark(open(url+qs).read()) except IOError: doc[target].html = "Page %s not found" %url return False doc[target].html = mk for script in scripts: exec(script) for elt in doc[target].get(selector='.exec'): # Python code executed when user clicks on a button elt.contentEditable = True src = elt.text.strip() h = highlight.highlight(src) h.className = "pycode" elt.clear() elt <= h elt.focus() btn = html.BUTTON('▶') btn.bind('click', run) elt.parent.insertBefore(btn, elt) for elt in doc[target].get(selector='.exec_on_load'): # Python code executed on page load src = elt.text.strip() h = highlight.highlight(src) h.className = "pycode" elt.clear() elt <= h exec(src) for elt in doc[target].get(selector='.python'): src = elt.text.strip() h = highlight.highlight(src) h.className = "pycode" elt.clear() elt <= h return False
gpl-3.0
[ 504, 7042, 492, 2213, 465, 1382, 199, 504, 7042, 492, 4353, 12, 3517, 12, 18502, 199, 199, 646, 11850, 199, 199, 646, 900, 199, 199, 318, 1255, 8, 6857, 304, 272, 327, 1255, 314, 1233, 315, 314, 18409, 2410, 314, 5528, 272, 20593, 275, 8145, 14, 1375, 14, 1708, 14, 3223, 14, 1080, 8, 6857, 14, 1375, 9, 272, 18409, 275, 8145, 14, 1375, 14, 1708, 14, 3223, 59, 1148, 11, 17, 61, 272, 2146, 8, 15330, 14, 505, 9, 272, 18409, 14, 12283, 342, 199, 199, 318, 2248, 8, 633, 12, 1375, 304, 272, 327, 4026, 1827, 1059, 370, 21115, 7042, 2581, 272, 6377, 275, 8720, 1421, 2458, 83, 7, 450, 521, 14, 521, 342, 272, 862, 26, 267, 9199, 12, 6429, 275, 18502, 14, 1657, 8, 1490, 8, 633, 11, 6177, 680, 739, 1012, 272, 871, 5925, 26, 267, 1382, 59, 1375, 1055, 1360, 275, 298, 3276, 450, 83, 440, 1911, 2, 450, 633, 267, 372, 756, 272, 1382, 59, 1375, 1055, 1360, 275, 9199, 272, 367, 2884, 315, 10554, 26, 267, 2146, 8, 1579, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1628, 735, 267, 327, 2018, 1233, 7934, 1380, 922, 5053, 5618, 641, 282, 5528, 267, 18409, 14, 1317, 20957, 1224, 275, 715, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 267, 18409, 14, 12283, 342, 267, 19368, 275, 3517, 14, 13272, 360, 11079, 115, 358, 267, 19368, 14, 3409, 360, 4891, 297, 1255, 9, 267, 18409, 14, 1708, 14, 3176, 13569, 8, 9633, 12, 18409, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1628, 63, 265, 63, 912, 735, 267, 327, 2018, 1233, 7934, 641, 2034, 2248, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 267, 2146, 8, 2164, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1548, 735, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 272, 372, 756, 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 ]
[ 7042, 492, 2213, 465, 1382, 199, 504, 7042, 492, 4353, 12, 3517, 12, 18502, 199, 199, 646, 11850, 199, 199, 646, 900, 199, 199, 318, 1255, 8, 6857, 304, 272, 327, 1255, 314, 1233, 315, 314, 18409, 2410, 314, 5528, 272, 20593, 275, 8145, 14, 1375, 14, 1708, 14, 3223, 14, 1080, 8, 6857, 14, 1375, 9, 272, 18409, 275, 8145, 14, 1375, 14, 1708, 14, 3223, 59, 1148, 11, 17, 61, 272, 2146, 8, 15330, 14, 505, 9, 272, 18409, 14, 12283, 342, 199, 199, 318, 2248, 8, 633, 12, 1375, 304, 272, 327, 4026, 1827, 1059, 370, 21115, 7042, 2581, 272, 6377, 275, 8720, 1421, 2458, 83, 7, 450, 521, 14, 521, 342, 272, 862, 26, 267, 9199, 12, 6429, 275, 18502, 14, 1657, 8, 1490, 8, 633, 11, 6177, 680, 739, 1012, 272, 871, 5925, 26, 267, 1382, 59, 1375, 1055, 1360, 275, 298, 3276, 450, 83, 440, 1911, 2, 450, 633, 267, 372, 756, 272, 1382, 59, 1375, 1055, 1360, 275, 9199, 272, 367, 2884, 315, 10554, 26, 267, 2146, 8, 1579, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1628, 735, 267, 327, 2018, 1233, 7934, 1380, 922, 5053, 5618, 641, 282, 5528, 267, 18409, 14, 1317, 20957, 1224, 275, 715, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 267, 18409, 14, 12283, 342, 267, 19368, 275, 3517, 14, 13272, 360, 11079, 115, 358, 267, 19368, 14, 3409, 360, 4891, 297, 1255, 9, 267, 18409, 14, 1708, 14, 3176, 13569, 8, 9633, 12, 18409, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1628, 63, 265, 63, 912, 735, 267, 327, 2018, 1233, 7934, 641, 2034, 2248, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 267, 2146, 8, 2164, 9, 272, 367, 18409, 315, 1382, 59, 1375, 1055, 362, 8, 6662, 15637, 1548, 735, 267, 2928, 275, 18409, 14, 505, 14, 1913, 342, 267, 394, 275, 11850, 14, 14337, 8, 2164, 9, 267, 394, 14, 533, 985, 275, 298, 647, 600, 2, 267, 18409, 14, 3584, 342, 267, 18409, 2695, 394, 272, 372, 756, 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, 0 ]
[ 1, 1, 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suko07/17WarmingUp
py3.6/lib/python3.6/site-packages/pip/_vendor/cachecontrol/heuristics.py
490
4141
import calendar import time from email.utils import formatdate, parsedate, parsedate_tz from datetime import datetime, timedelta TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT" def expire_after(delta, date=None): date = date or datetime.now() return date + delta def datetime_to_header(dt): return formatdate(calendar.timegm(dt.timetuple())) class BaseHeuristic(object): def warning(self, response): """ Return a valid 1xx warning header value describing the cache adjustments. The response is provided too allow warnings like 113 http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need to explicitly say response is over 24 hours old. """ return '110 - "Response is Stale"' def update_headers(self, response): """Update the response headers with any new headers. NOTE: This SHOULD always include some Warning header to signify that the response was cached by the client, not by way of the provided headers. """ return {} def apply(self, response): updated_headers = self.update_headers(response) if updated_headers: response.headers.update(updated_headers) warning_header_value = self.warning(response) if warning_header_value is not None: response.headers.update({'Warning': warning_header_value}) return response class OneDayCache(BaseHeuristic): """ Cache the response by providing an expires 1 day in the future. """ def update_headers(self, response): headers = {} if 'expires' not in response.headers: date = parsedate(response.headers['date']) expires = expire_after(timedelta(days=1), date=datetime(*date[:6])) headers['expires'] = datetime_to_header(expires) headers['cache-control'] = 'public' return headers class ExpiresAfter(BaseHeuristic): """ Cache **all** requests for a defined time period. """ def __init__(self, **kw): self.delta = timedelta(**kw) def update_headers(self, response): expires = expire_after(self.delta) return { 'expires': datetime_to_header(expires), 'cache-control': 'public', } def warning(self, response): tmpl = '110 - Automatically cached for %s. Response might be stale' return tmpl % self.delta class LastModified(BaseHeuristic): """ If there is no Expires header already, fall back on Last-Modified using the heuristic from http://tools.ietf.org/html/rfc7234#section-4.2.2 to calculate a reasonable value. Firefox also does something like this per https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397 Unlike mozilla we limit this to 24-hr. """ cacheable_by_default_statuses = set([ 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501 ]) def update_headers(self, resp): headers = resp.headers if 'expires' in headers: return {} if 'cache-control' in headers and headers['cache-control'] != 'public': return {} if resp.status not in self.cacheable_by_default_statuses: return {} if 'date' not in headers or 'last-modified' not in headers: return {} date = calendar.timegm(parsedate_tz(headers['date'])) last_modified = parsedate(headers['last-modified']) if date is None or last_modified is None: return {} now = time.time() current_age = max(0, now - date) delta = date - calendar.timegm(last_modified) freshness_lifetime = max(0, min(delta / 10, 24 * 3600)) if freshness_lifetime <= current_age: return {} expires = date + freshness_lifetime return {'expires': time.strftime(TIME_FMT, time.gmtime(expires))} def warning(self, resp): return None
mit
[ 646, 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 4588, 63, 2139, 275, 291, 14, 873, 63, 2139, 8, 1310, 9, 398, 340, 4588, 63, 2139, 26, 288, 1177, 14, 2139, 14, 873, 8, 5334, 63, 2139, 9, 288, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 288, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 355, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 398, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721, 8, 277, 12, 3085, 304, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 4588, 63, 2139, 275, 291, 14, 873, 63, 2139, 8, 1310, 9, 398, 340, 4588, 63, 2139, 26, 288, 1177, 14, 2139, 14, 873, 8, 5334, 63, 2139, 9, 288, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 288, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 355, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 398, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721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, 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 ]
jonfoster/pyxb2
tests/drivers/test-po1.py
3
5914
# -*- coding: utf-8 -*- import logging if __name__ == '__main__': logging.basicConfig() _log = logging.getLogger(__name__) import pyxb.binding.generate import pyxb.utils.domutils from xml.dom import Node import os.path schema_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../schemas/po1.xsd')) code = pyxb.binding.generate.GeneratePython(schema_location=schema_path) #open('code.py', 'w').write(code) rv = compile(code, 'test', 'exec') eval(rv) from pyxb.exceptions_ import * from pyxb.utils import domutils def ToDOM (instance, dom_support=None): return instance.toDOM(dom_support).documentElement import unittest class TestPO1 (unittest.TestCase): street_content = '''95 Main St. Anytown, AS 12345-6789''' street_xmlt = u'<street>%s</street>' % (street_content,) street_xmld = street_xmlt.encode('utf-8') street_dom = pyxb.utils.domutils.StringToDOM(street_xmlt).documentElement address1_xmlt = u'<name>Customer</name><street>95 Main St</street>' address2_xmlt = u'<name>Sugar Mama</name><street>24 E. Dearling Ave.</street>' def tearDown (self): pyxb.RequireValidWhenGenerating(True) pyxb.RequireValidWhenParsing(True) def testPythonElementSimpleContent (self): elt = USAddress._ElementMap['street'].elementBinding()(self.street_content) self.assertEqual(self.street_content, elt) self.assertEqual(ToDOM(elt).toxml("utf-8"), self.street_xmld) def testDOMElementSimpleContent (self): elt = USAddress._ElementMap['street'].elementBinding().createFromDOM(self.street_dom) self.assertEqual(ToDOM(elt).toxml("utf-8"), self.street_xmld) def testPythonElementComplexContent_Element (self): addr = USAddress(name='Customer', street='95 Main St') self.assertEqual('95 Main St', addr.street) addr = USAddress('Customer', '95 Main St') self.assertEqual('95 Main St', addr.street) addr.street = '43 West Oak' self.assertEqual('43 West Oak', addr.street) def testDOM_CTD_element (self): # NB: USAddress is a CTD, not an element. xmlt = u'<shipTo>%s</shipTo>' % (self.address1_xmlt,) xmld = xmlt.encode('utf-8') dom = pyxb.utils.domutils.StringToDOM(xmlt) addr2 = USAddress.Factory(_dom_node=dom.documentElement) def testPurchaseOrder (self): po = purchaseOrder(shipTo=USAddress(name='Customer', street='95 Main St'), billTo=USAddress(name='Sugar Mama', street='24 E. Dearling Ave'), comment='Thanks!') xmld = ToDOM(po).toxml("utf-8") xml1t = '<ns1:purchaseOrder xmlns:ns1="http://www.example.com/PO1"><shipTo><name>Customer</name><street>95 Main St</street></shipTo><billTo><name>Sugar Mama</name><street>24 E. Dearling Ave</street></billTo><ns1:comment>Thanks!</ns1:comment></ns1:purchaseOrder>' xml1d = xml1t.encode('utf-8') self.assertEqual(xmld, xml1d) dom = pyxb.utils.domutils.StringToDOM(xmld) po2 = purchaseOrder.createFromDOM(dom.documentElement) self.assertEqual(xml1d, ToDOM(po2).toxml("utf-8")) loc = po2.shipTo._location() self.assertTrue((not isinstance(loc, pyxb.utils.utility.Locatable_mixin)) or (58 == loc.columnNumber)) loc = po2.billTo.name._location() self.assertTrue((not isinstance(loc, pyxb.utils.utility.Locatable_mixin)) or (131 == loc.columnNumber)) po2 = CreateFromDocument(xmld) self.assertEqual(xml1d, ToDOM(po2).toxml("utf-8")) loc = po2.shipTo._location() self.assertTrue((not isinstance(loc, pyxb.utils.utility.Locatable_mixin)) or (58 == loc.columnNumber)) loc = po2.billTo.name._location() self.assertTrue((not isinstance(loc, pyxb.utils.utility.Locatable_mixin)) or (131 == loc.columnNumber)) xml2t = '<purchaseOrder xmlns="http://www.example.com/PO1"><shipTo><name>Customer</name><street>95 Main St</street></shipTo><billTo><name>Sugar Mama</name><street>24 E. Dearling Ave</street></billTo><comment>Thanks!</comment></purchaseOrder>' xml2d = xml2t.encode('utf-8') bds = pyxb.utils.domutils.BindingDOMSupport() bds.setDefaultNamespace(Namespace) self.assertEqual(xml2d, ToDOM(po2, dom_support=bds).toxml("utf-8")) def testGenerationValidation (self): ship_to = USAddress('Robert Smith', 'General Delivery') po = purchaseOrder(ship_to) self.assertEqual('General Delivery', po.shipTo.street) self.assertTrue(po.billTo is None) self.assertTrue(pyxb.RequireValidWhenGenerating()) self.assertRaises(pyxb.IncompleteElementContentError, po.toxml) try: pyxb.RequireValidWhenGenerating(False) self.assertFalse(pyxb.RequireValidWhenGenerating()) xmlt = u'<ns1:purchaseOrder xmlns:ns1="http://www.example.com/PO1"><shipTo><street>General Delivery</street><name>Robert Smith</name></shipTo></ns1:purchaseOrder>' xmlta = u'<ns1:purchaseOrder xmlns:ns1="http://www.example.com/PO1"><shipTo><name>Robert Smith</name><street>General Delivery</street></shipTo></ns1:purchaseOrder>' xmlds = [ _xmlt.encode('utf-8') for _xmlt in (xmlt, xmlta) ] self.assertTrue(po.toxml("utf-8", root_only=True) in xmlds) finally: pyxb.RequireValidWhenGenerating(True) self.assertRaises(pyxb.UnrecognizedContentError, CreateFromDocument, xmlt) self.assertTrue(pyxb.RequireValidWhenParsing()) try: pyxb.RequireValidWhenParsing(False) self.assertFalse(pyxb.RequireValidWhenParsing()) po2 = CreateFromDocument(xmlt) finally: pyxb.RequireValidWhenParsing(True) self.assertEqual('General Delivery', po2.shipTo.street) self.assertTrue(po2.billTo is None) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2050, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2050, 14, 19602, 342, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 646, 27049, 14, 9140, 14, 4208, 199, 646, 27049, 14, 1208, 14, 4556, 1208, 199, 504, 2748, 14, 4556, 492, 5013, 199, 199, 646, 747, 14, 515, 199, 3629, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 9482, 15, 555, 17, 14, 10515, 1333, 199, 600, 275, 27049, 14, 9140, 14, 4208, 14, 6864, 4718, 8, 3629, 63, 1985, 29, 3629, 63, 515, 9, 199, 199, 3, 1490, 360, 600, 14, 647, 297, 283, 87, 1959, 952, 8, 600, 9, 199, 6310, 275, 6555, 8, 600, 12, 283, 396, 297, 283, 1628, 358, 199, 2579, 8, 6310, 9, 199, 199, 504, 27049, 14, 3924, 63, 492, 627, 199, 199, 504, 27049, 14, 1208, 492, 8266, 1208, 199, 199, 318, 4005, 10462, 334, 842, 12, 8266, 63, 4058, 29, 403, 304, 272, 372, 1256, 14, 475, 10462, 8, 4556, 63, 4058, 680, 22464, 199, 199, 646, 2882, 199, 199, 533, 1379, 1512, 17, 334, 2796, 14, 1746, 304, 272, 410, 7936, 63, 1317, 275, 1449, 2720, 11298, 1933, 14, 199, 9874, 16231, 12, 4319, 221, 25538, 13, 1822, 1407, 2344, 272, 410, 7936, 63, 1652, 84, 275, 399, 7601, 20451, 6598, 83, 1108, 20451, 3524, 450, 334, 20451, 63, 1317, 4258, 272, 410, 7936, 63, 1652, 68, 275, 410, 7936, 63, 1652, 84, 14, 2143, 360, 1624, 13, 24, 358, 272, 410, 7936, 63, 4556, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 20451, 63, 1652, 84, 680, 22464, 339, 2287, 17, 63, 1652, 84, 275, 399, 7601, 354, 30, 17025, 1108, 354, 2535, 20451, 30, 2720, 11298, 1933, 1108, 20451, 3524, 272, 2287, 18, 63, 1652, 84, 275, 399, 7601, 354, 30, 51, 21922, 603, 14541, 1108, 354, 2535, 20451, 30, 1194, 662, 14, 1487, 285, 2983, 437, 432, 9758, 20451, 3524, 339, 347, 6766, 334, 277, 304, 267, 27049, 14, 13902, 3490, 11423, 29244, 8, 549, 9, 267, 27049, 14, 13902, 3490, 11423, 17412, 8, 549, 9, 339, 347, 511, 4718, 2162, 3184, 2714, 334, 277, 304, 267, 18409, 275, 19635, 1476, 423, 2162, 2956, 459, 20451, 2278, 2108, 17490, 24851, 277, 14, 20451, 63, 1317, 9, 267, 291, 14, 629, 8, 277, 14, 20451, 63, 1317, 12, 18409, 9, 267, 291, 14, 629, 8, 1378, 10462, 8, 15330, 680, 475, 1652, 480, 1624, 13, 24, 1288, 291, 14, 20451, 63, 1652, 68, 9, 339, 347, 511, 10462, 2162, 3184, 2714, 334, 277, 304, 267, 18409, 275, 19635, 1476, 423, 2162, 2956, 459, 20451, 2278, 2108, 17490, 1252, 981, 2532, 10462, 8, 277, 14, 20451, 63, 4556, 9, 267, 291, 14, 629, 8, 1378, 10462, 8, 15330, 680, 475, 1652, 480, 1624, 13, 24, 1288, 291, 14, 20451, 63, 1652, 68, 9, 339, 347, 511, 4718, 2162, 14500, 2714, 63, 2162, 334, 277, 304, 267, 5552, 275, 19635, 1476, 8, 354, 534, 17025, 297, 410, 7936, 534, 2720, 11298, 1933, 358, 267, 291, 14, 629, 360, 2720, 11298, 1933, 297, 5552, 14, 20451, 9, 267, 5552, 275, 19635, 1476, 360, 17025, 297, 283, 2720, 11298, 1933, 358, 267, 291, 14, 629, 360, 2720, 11298, 1933, 297, 5552, 14, 20451, 9, 267, 5552, 14, 20451, 275, 283, 2824, 644, 597, 593, 1151, 7, 267, 291, 14, 629, 360, 2824, 644, 597, 593, 1151, 297, 5552, 14, 20451, 9, 339, 347, 511, 10462, 63, 1028, 36, 63, 2108, 334, 277, 304, 267, 327, 25377, 26, 19635, 1476, 365, 282, 445, 13449, 12, 440, 376, 1819, 14, 267, 2748, 84, 275, 399, 7601, 3319, 1378, 6598, 83, 1108, 3319, 1378, 3524, 450, 334, 277, 14, 1562, 17, 63, 1652, 84, 4258, 267, 2748, 68, 275, 2748, 84, 14, 2143, 360, 1624, 13, 24, 358, 267, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 84, 9, 267, 5552, 18, 275, 19635, 1476, 14, 2927, 1547, 4556, 63, 932, 29, 4556, 14, 22464, 9, 339, 347, 511, 20486, 4738, 334, 277, 304, 267, 1115, 275, 15932, 4738, 8, 3319, 1378, 29, 1668, 1476, 8, 354, 534, 17025, 297, 410, 7936, 534, 2720, 11298, 1933, 659, 2574, 330, 778, 1378, 29, 1668, 1476, 8, 354, 534, 51, 21922, 603, 14541, 297, 410, 7936, 534, 1194, 662, 14, 1487, 285, 2983, 437, 432, 659, 2574, 3721, 534, 2719, 25088, 10916, 267, 2748, 68, 275, 4005, 10462, 8, 555, 680, 475, 1652, 480, 1624, 13, 24, 531, 267, 2748, 17, 84, 275, 2650, 561, 17, 26, 9533, 4738, 9604, 26, 561, 17, 628, 1014, 921, 1544, 14, 2694, 14, 957, 15, 1512, 17, 8186, 3319, 1378, 2535, 354, 30, 17025, 1108, 354, 2535, 20451, 30, 2720, 11298, 1933, 1108, 20451, 2957, 3319, 1378, 2535, 19815, 1378, 2535, 354, 30, 51, 21922, 603, 14541, 1108, 354, 2535, 20451, 30, 1194, 662, 14, 1487, 285, 2983, 437, 432, 1108, 20451, 2957, 19815, 1378, 2535, 561, 17, 26, 3349, 30, 2719, 25088, 28718, 561, 17, 26, 3349, 2957, 561, 17, 26, 9533, 4738, 3524, 267, 2748, 17, 68, 275, 2748, 17, 84, 14, 2143, 360, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1652, 68, 12, 2748, 17, 68, 9, 398, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 68, 9, 267, 1115, 18, 275, 15932, 4738, 14, 981, 2532, 10462, 8, 4556, 14, 22464, 9, 267, 291, 14, 629, 8, 1652, 17, 68, 12, 4005, 10462, 8, 555, 18, 680, 475, 1652, 480, 1624, 13, 24, 2237, 267, 4355, 275, 1115, 18, 14, 3319, 1378, 423, 1985, 342, 267, 291, 14, 1815, 1332, 1397, 1228, 8, 2102, 12, 27049, 14, 1208, 14, 16877, 14, 3040, 15511, 63, 20406, 430, 503, 334, 2010, 508, 4355, 14, 2301, 3259, 430, 267, 4355, 275, 1115, 18, 14, 19815, 1378, 14, 354, 423, 1985, 342, 267, 291, 14, 1815, 1332, 1397, 1228, 8, 2102, 12, 27049, 14, 1208, 14, 16877, 14, 3040, 15511, 63, 20406, 430, 503, 334 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2050, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2050, 14, 19602, 342, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 646, 27049, 14, 9140, 14, 4208, 199, 646, 27049, 14, 1208, 14, 4556, 1208, 199, 504, 2748, 14, 4556, 492, 5013, 199, 199, 646, 747, 14, 515, 199, 3629, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 9482, 15, 555, 17, 14, 10515, 1333, 199, 600, 275, 27049, 14, 9140, 14, 4208, 14, 6864, 4718, 8, 3629, 63, 1985, 29, 3629, 63, 515, 9, 199, 199, 3, 1490, 360, 600, 14, 647, 297, 283, 87, 1959, 952, 8, 600, 9, 199, 6310, 275, 6555, 8, 600, 12, 283, 396, 297, 283, 1628, 358, 199, 2579, 8, 6310, 9, 199, 199, 504, 27049, 14, 3924, 63, 492, 627, 199, 199, 504, 27049, 14, 1208, 492, 8266, 1208, 199, 199, 318, 4005, 10462, 334, 842, 12, 8266, 63, 4058, 29, 403, 304, 272, 372, 1256, 14, 475, 10462, 8, 4556, 63, 4058, 680, 22464, 199, 199, 646, 2882, 199, 199, 533, 1379, 1512, 17, 334, 2796, 14, 1746, 304, 272, 410, 7936, 63, 1317, 275, 1449, 2720, 11298, 1933, 14, 199, 9874, 16231, 12, 4319, 221, 25538, 13, 1822, 1407, 2344, 272, 410, 7936, 63, 1652, 84, 275, 399, 7601, 20451, 6598, 83, 1108, 20451, 3524, 450, 334, 20451, 63, 1317, 4258, 272, 410, 7936, 63, 1652, 68, 275, 410, 7936, 63, 1652, 84, 14, 2143, 360, 1624, 13, 24, 358, 272, 410, 7936, 63, 4556, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 20451, 63, 1652, 84, 680, 22464, 339, 2287, 17, 63, 1652, 84, 275, 399, 7601, 354, 30, 17025, 1108, 354, 2535, 20451, 30, 2720, 11298, 1933, 1108, 20451, 3524, 272, 2287, 18, 63, 1652, 84, 275, 399, 7601, 354, 30, 51, 21922, 603, 14541, 1108, 354, 2535, 20451, 30, 1194, 662, 14, 1487, 285, 2983, 437, 432, 9758, 20451, 3524, 339, 347, 6766, 334, 277, 304, 267, 27049, 14, 13902, 3490, 11423, 29244, 8, 549, 9, 267, 27049, 14, 13902, 3490, 11423, 17412, 8, 549, 9, 339, 347, 511, 4718, 2162, 3184, 2714, 334, 277, 304, 267, 18409, 275, 19635, 1476, 423, 2162, 2956, 459, 20451, 2278, 2108, 17490, 24851, 277, 14, 20451, 63, 1317, 9, 267, 291, 14, 629, 8, 277, 14, 20451, 63, 1317, 12, 18409, 9, 267, 291, 14, 629, 8, 1378, 10462, 8, 15330, 680, 475, 1652, 480, 1624, 13, 24, 1288, 291, 14, 20451, 63, 1652, 68, 9, 339, 347, 511, 10462, 2162, 3184, 2714, 334, 277, 304, 267, 18409, 275, 19635, 1476, 423, 2162, 2956, 459, 20451, 2278, 2108, 17490, 1252, 981, 2532, 10462, 8, 277, 14, 20451, 63, 4556, 9, 267, 291, 14, 629, 8, 1378, 10462, 8, 15330, 680, 475, 1652, 480, 1624, 13, 24, 1288, 291, 14, 20451, 63, 1652, 68, 9, 339, 347, 511, 4718, 2162, 14500, 2714, 63, 2162, 334, 277, 304, 267, 5552, 275, 19635, 1476, 8, 354, 534, 17025, 297, 410, 7936, 534, 2720, 11298, 1933, 358, 267, 291, 14, 629, 360, 2720, 11298, 1933, 297, 5552, 14, 20451, 9, 267, 5552, 275, 19635, 1476, 360, 17025, 297, 283, 2720, 11298, 1933, 358, 267, 291, 14, 629, 360, 2720, 11298, 1933, 297, 5552, 14, 20451, 9, 267, 5552, 14, 20451, 275, 283, 2824, 644, 597, 593, 1151, 7, 267, 291, 14, 629, 360, 2824, 644, 597, 593, 1151, 297, 5552, 14, 20451, 9, 339, 347, 511, 10462, 63, 1028, 36, 63, 2108, 334, 277, 304, 267, 327, 25377, 26, 19635, 1476, 365, 282, 445, 13449, 12, 440, 376, 1819, 14, 267, 2748, 84, 275, 399, 7601, 3319, 1378, 6598, 83, 1108, 3319, 1378, 3524, 450, 334, 277, 14, 1562, 17, 63, 1652, 84, 4258, 267, 2748, 68, 275, 2748, 84, 14, 2143, 360, 1624, 13, 24, 358, 267, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 84, 9, 267, 5552, 18, 275, 19635, 1476, 14, 2927, 1547, 4556, 63, 932, 29, 4556, 14, 22464, 9, 339, 347, 511, 20486, 4738, 334, 277, 304, 267, 1115, 275, 15932, 4738, 8, 3319, 1378, 29, 1668, 1476, 8, 354, 534, 17025, 297, 410, 7936, 534, 2720, 11298, 1933, 659, 2574, 330, 778, 1378, 29, 1668, 1476, 8, 354, 534, 51, 21922, 603, 14541, 297, 410, 7936, 534, 1194, 662, 14, 1487, 285, 2983, 437, 432, 659, 2574, 3721, 534, 2719, 25088, 10916, 267, 2748, 68, 275, 4005, 10462, 8, 555, 680, 475, 1652, 480, 1624, 13, 24, 531, 267, 2748, 17, 84, 275, 2650, 561, 17, 26, 9533, 4738, 9604, 26, 561, 17, 628, 1014, 921, 1544, 14, 2694, 14, 957, 15, 1512, 17, 8186, 3319, 1378, 2535, 354, 30, 17025, 1108, 354, 2535, 20451, 30, 2720, 11298, 1933, 1108, 20451, 2957, 3319, 1378, 2535, 19815, 1378, 2535, 354, 30, 51, 21922, 603, 14541, 1108, 354, 2535, 20451, 30, 1194, 662, 14, 1487, 285, 2983, 437, 432, 1108, 20451, 2957, 19815, 1378, 2535, 561, 17, 26, 3349, 30, 2719, 25088, 28718, 561, 17, 26, 3349, 2957, 561, 17, 26, 9533, 4738, 3524, 267, 2748, 17, 68, 275, 2748, 17, 84, 14, 2143, 360, 1624, 13, 24, 358, 267, 291, 14, 629, 8, 1652, 68, 12, 2748, 17, 68, 9, 398, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 68, 9, 267, 1115, 18, 275, 15932, 4738, 14, 981, 2532, 10462, 8, 4556, 14, 22464, 9, 267, 291, 14, 629, 8, 1652, 17, 68, 12, 4005, 10462, 8, 555, 18, 680, 475, 1652, 480, 1624, 13, 24, 2237, 267, 4355, 275, 1115, 18, 14, 3319, 1378, 423, 1985, 342, 267, 291, 14, 1815, 1332, 1397, 1228, 8, 2102, 12, 27049, 14, 1208, 14, 16877, 14, 3040, 15511, 63, 20406, 430, 503, 334, 2010, 508, 4355, 14, 2301, 3259, 430, 267, 4355, 275, 1115, 18, 14, 19815, 1378, 14, 354, 423, 1985, 342, 267, 291, 14, 1815, 1332, 1397, 1228, 8, 2102, 12, 27049, 14, 1208, 14, 16877, 14, 3040, 15511, 63, 20406, 430, 503, 334, 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 ]
SUSE/azure-sdk-for-python
azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/operations/job_cancellations_operations.py
2
4214
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError import uuid from .. import models class JobCancellationsOperations(object): """JobCancellationsOperations operations. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An objec model deserializer. :ivar api_version: Client Api Version. Constant value: "2016-12-01". """ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self.api_version = "2016-12-01" self.config = config def trigger( self, vault_name, resource_group_name, job_name, custom_headers=None, raw=False, **operation_config): """Cancels a job. This is an asynchronous operation. To know the status of the cancellation, call GetCancelOperationResult API. :param vault_name: The name of the recovery services vault. :type vault_name: str :param resource_group_name: The name of the resource group where the recovery services vault is present. :type resource_group_name: str :param job_name: Name of the job to cancel. :type job_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = '/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupJobs/{jobName}/cancel' path_format_arguments = { 'vaultName': self._serialize.url("vault_name", vault_name, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'jobName': self._serialize.url("job_name", job_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [202]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 7379, 492, 6810, 28973, 199, 504, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 199, 646, 5377, 199, 199, 504, 2508, 492, 1709, 421, 199, 533, 15057, 9083, 6011, 12929, 8, 785, 304, 272, 408, 6694, 9083, 6011, 12929, 5331, 14, 339, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 1559, 825, 1402, 30237, 14, 272, 520, 7725, 2986, 63, 1023, 26, 6810, 13986, 3394, 14, 19991, 574, 26, 298, 9261, 13, 713, 13, 614, 1674, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 398, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 14, 1246, 63, 1023, 275, 298, 9261, 13, 713, 13, 614, 2, 398, 291, 14, 888, 275, 1101, 339, 347, 6804, 8, 288, 291, 12, 12738, 63, 354, 12, 2073, 63, 923, 63, 354, 12, 3906, 63, 354, 12, 3537, 63, 2139, 29, 403, 12, 3066, 29, 797, 12, 1011, 5735, 63, 888, 304, 267, 408, 35, 554, 478, 282, 3906, 14, 961, 365, 376, 15608, 3439, 14, 4005, 5715, 314, 2004, 402, 267, 314, 9311, 2212, 12, 1240, 2372, 9083, 6044, 2889, 3261, 14, 398, 520, 635, 12738, 63, 354, 26, 710, 536, 402, 314, 24201, 8500, 12738, 14, 267, 520, 466, 12738, 63, 354, 26, 620, 267, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 2382, 314, 268, 24201, 8500, 12738, 365, 3451, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 3906, 63, 354, 26, 2812, 402, 314, 3906, 370, 9311, 14, 267, 520, 466, 3906, 63, 354, 26, 620, 267, 520, 635, 1211, 3537, 63, 2139, 26, 2323, 626, 911, 506, 3483, 370, 314, 1056, 267, 520, 635, 2155, 3066, 26, 2529, 314, 4125, 1177, 3180, 2441, 314, 268, 13256, 1177, 267, 520, 635, 3439, 63, 888, 26, 520, 1121, 1705, 6044, 2897, 268, 10580, 28, 25427, 26, 1419, 509, 8170, 14943, 267, 520, 4500, 26, 488, 267, 520, 4500, 26, 520, 533, 1705, 3041, 28973, 28, 25427, 14, 7379, 14, 3041, 28973, 8637, 268, 340, 3066, 29, 2052, 267, 520, 3536, 26, 520, 533, 1705, 9089, 547, 28, 706, 264, 1207, 7895, 14, 9078, 63, 3924, 14, 9089, 547, 8637, 267, 408, 267, 327, 9215, 2851, 267, 1166, 275, 1994, 19120, 83, 5321, 20505, 5995, 26952, 5321, 22023, 5995, 9710, 15, 12940, 14, 497, 6913, 15803, 15, 10077, 83, 5321, 10077, 985, 5995, 5751, 20578, 5321, 2423, 985, 5995, 6406, 7, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 10077, 985, 356, 291, 423, 3549, 14, 633, 480, 10077, 63, 354, 401, 12738, 63, 354, 12, 283, 495, 659, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 14, 888, 14, 6645, 63, 344, 401, 291, 14, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 288, 283, 2423, 985, 356, 291, 423, 3549, 14, 633, 480, 2423, 63, 354, 401, 3906, 63, 354, 12, 283, 495, 358, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 267, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 277, 14, 1246, 63, 1023, 401, 291, 14, 1246, 63, 1023, 12, 283, 495, 358, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 267, 1406, 63, 3214, 459, 2714, 13, 804, 418, 275, 283, 3578, 15, 1001, 27, 5960, 29, 1624, 13, 24, 7, 267, 340, 291, 14, 888, 14, 4208, 63, 1258, 63, 1069, 63, 344, 26, 288, 1406, 63, 3214, 459, 88, 13, 706, 13, 1258, 13, 1069, 13, 344, 418, 275, 620, 8, 2580, 14, 2580, 17, 1012, 267, 340, 3537, 63, 2139, 26, 288, 1406, 63, 3214, 14, 873, 8, 4229, 63, 2139, 9, 267, 340, 291, 14, 888, 14, 5694, 63, 3671, 365, 440, 488, 26, 288, 1406, 63, 3214, 459, 5694, 13, 3671, 418, 275, 291, 423, 3549, 14, 1291, 480, 277, 14, 888, 14, 5694, 63, 3671, 401, 291, 14, 888, 14, 5694, 63, 3671, 12, 283, 495, 358, 398, 327, 9215, 436, 3222, 1056, 267, 1056, 275, 291, 423, 1258, 14, 1932, 8, 633, 12, 1827, 63, 3214, 9, 267, 1177, 275, 291, 423, 1258, 14, 2254, 8, 1069, 12, 1406, 63, 3214, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 4999, 2189, 288, 1437, 275, 30059, 8, 1310, 9, 288, 1437, 14, 1069, 63, 344, 275, 1177, 14, 2139, 14, 362, 360, 88, 13, 706, 13, 1069, 13, 344, 358, 288, 746, 1437, 398, 340, 3066, 26, 288, 1890, 63, 1773, 63, 1310, 275, 6810, 28973, 8, 403, 12, 1177, 9, 288, 372, 1890, 63, 1773, 63, 1310, 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 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 7379, 492, 6810, 28973, 199, 504, 6605, 264, 1207, 7895, 14, 9078, 63, 3924, 492, 30059, 199, 646, 5377, 199, 199, 504, 2508, 492, 1709, 421, 199, 533, 15057, 9083, 6011, 12929, 8, 785, 304, 272, 408, 6694, 9083, 6011, 12929, 5331, 14, 339, 520, 635, 1890, 26, 6810, 367, 2435, 4145, 14, 272, 520, 635, 1101, 26, 11595, 402, 2435, 1890, 14, 272, 520, 635, 9146, 26, 1626, 909, 1402, 9146, 14, 272, 520, 635, 30237, 26, 1626, 1559, 825, 1402, 30237, 14, 272, 520, 7725, 2986, 63, 1023, 26, 6810, 13986, 3394, 14, 19991, 574, 26, 298, 9261, 13, 713, 13, 614, 1674, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 1101, 12, 9146, 12, 30237, 304, 398, 291, 423, 1258, 275, 1890, 267, 291, 423, 3549, 275, 9146, 267, 291, 423, 11143, 275, 30237, 267, 291, 14, 1246, 63, 1023, 275, 298, 9261, 13, 713, 13, 614, 2, 398, 291, 14, 888, 275, 1101, 339, 347, 6804, 8, 288, 291, 12, 12738, 63, 354, 12, 2073, 63, 923, 63, 354, 12, 3906, 63, 354, 12, 3537, 63, 2139, 29, 403, 12, 3066, 29, 797, 12, 1011, 5735, 63, 888, 304, 267, 408, 35, 554, 478, 282, 3906, 14, 961, 365, 376, 15608, 3439, 14, 4005, 5715, 314, 2004, 402, 267, 314, 9311, 2212, 12, 1240, 2372, 9083, 6044, 2889, 3261, 14, 398, 520, 635, 12738, 63, 354, 26, 710, 536, 402, 314, 24201, 8500, 12738, 14, 267, 520, 466, 12738, 63, 354, 26, 620, 267, 520, 635, 2073, 63, 923, 63, 354, 26, 710, 536, 402, 314, 2073, 1572, 2382, 314, 268, 24201, 8500, 12738, 365, 3451, 14, 267, 520, 466, 2073, 63, 923, 63, 354, 26, 620, 267, 520, 635, 3906, 63, 354, 26, 2812, 402, 314, 3906, 370, 9311, 14, 267, 520, 466, 3906, 63, 354, 26, 620, 267, 520, 635, 1211, 3537, 63, 2139, 26, 2323, 626, 911, 506, 3483, 370, 314, 1056, 267, 520, 635, 2155, 3066, 26, 2529, 314, 4125, 1177, 3180, 2441, 314, 268, 13256, 1177, 267, 520, 635, 3439, 63, 888, 26, 520, 1121, 1705, 6044, 2897, 268, 10580, 28, 25427, 26, 1419, 509, 8170, 14943, 267, 520, 4500, 26, 488, 267, 520, 4500, 26, 520, 533, 1705, 3041, 28973, 28, 25427, 14, 7379, 14, 3041, 28973, 8637, 268, 340, 3066, 29, 2052, 267, 520, 3536, 26, 520, 533, 1705, 9089, 547, 28, 706, 264, 1207, 7895, 14, 9078, 63, 3924, 14, 9089, 547, 8637, 267, 408, 267, 327, 9215, 2851, 267, 1166, 275, 1994, 19120, 83, 5321, 20505, 5995, 26952, 5321, 22023, 5995, 9710, 15, 12940, 14, 497, 6913, 15803, 15, 10077, 83, 5321, 10077, 985, 5995, 5751, 20578, 5321, 2423, 985, 5995, 6406, 7, 267, 931, 63, 908, 63, 4958, 275, 469, 288, 283, 10077, 985, 356, 291, 423, 3549, 14, 633, 480, 10077, 63, 354, 401, 12738, 63, 354, 12, 283, 495, 659, 288, 283, 22023, 356, 291, 423, 3549, 14, 633, 480, 1927, 63, 923, 63, 354, 401, 2073, 63, 923, 63, 354, 12, 283, 495, 659, 288, 283, 20505, 356, 291, 423, 3549, 14, 633, 480, 277, 14, 888, 14, 6645, 63, 344, 401, 291, 14, 888, 14, 6645, 63, 344, 12, 283, 495, 659, 288, 283, 2423, 985, 356, 291, 423, 3549, 14, 633, 480, 2423, 63, 354, 401, 3906, 63, 354, 12, 283, 495, 358, 267, 789, 267, 1166, 275, 291, 423, 1258, 14, 908, 63, 633, 8, 633, 12, 1011, 515, 63, 908, 63, 4958, 9, 398, 327, 9215, 2633, 267, 1827, 63, 3214, 275, 1052, 267, 1827, 63, 3214, 459, 1246, 13, 1023, 418, 275, 291, 423, 3549, 14, 1131, 480, 277, 14, 1246, 63, 1023, 401, 291, 14, 1246, 63, 1023, 12, 283, 495, 358, 398, 327, 9215, 2323, 267, 1406, 63, 3214, 275, 1052, 267, 1406, 63, 3214, 459, 2714, 13, 804, 418, 275, 283, 3578, 15, 1001, 27, 5960, 29, 1624, 13, 24, 7, 267, 340, 291, 14, 888, 14, 4208, 63, 1258, 63, 1069, 63, 344, 26, 288, 1406, 63, 3214, 459, 88, 13, 706, 13, 1258, 13, 1069, 13, 344, 418, 275, 620, 8, 2580, 14, 2580, 17, 1012, 267, 340, 3537, 63, 2139, 26, 288, 1406, 63, 3214, 14, 873, 8, 4229, 63, 2139, 9, 267, 340, 291, 14, 888, 14, 5694, 63, 3671, 365, 440, 488, 26, 288, 1406, 63, 3214, 459, 5694, 13, 3671, 418, 275, 291, 423, 3549, 14, 1291, 480, 277, 14, 888, 14, 5694, 63, 3671, 401, 291, 14, 888, 14, 5694, 63, 3671, 12, 283, 495, 358, 398, 327, 9215, 436, 3222, 1056, 267, 1056, 275, 291, 423, 1258, 14, 1932, 8, 633, 12, 1827, 63, 3214, 9, 267, 1177, 275, 291, 423, 1258, 14, 2254, 8, 1069, 12, 1406, 63, 3214, 12, 1011, 5735, 63, 888, 9, 398, 340, 1177, 14, 1205, 63, 600, 440, 315, 359, 4999, 2189, 288, 1437, 275, 30059, 8, 1310, 9, 288, 1437, 14, 1069, 63, 344, 275, 1177, 14, 2139, 14, 362, 360, 88, 13, 706, 13, 1069, 13, 344, 358, 288, 746, 1437, 398, 340, 3066, 26, 288, 1890, 63, 1773, 63, 1310, 275, 6810, 28973, 8, 403, 12, 1177, 9, 288, 372, 1890, 63, 1773, 63, 1310, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aznrice/l-preview
tools/perf/scripts/python/sched-migration.py
11215
11670
#!/usr/bin/python # # Cpu task migration overview toy # # Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com> # # perf script event handlers have been generated by perf script -g python # # This software is distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. import os import sys from collections import defaultdict from UserList import UserList sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from SchedGui import * threads = { 0 : "idle"} def thread_name(pid): return "%s:%d" % (threads[pid], pid) class RunqueueEventUnknown: @staticmethod def color(): return None def __repr__(self): return "unknown" class RunqueueEventSleep: @staticmethod def color(): return (0, 0, 0xff) def __init__(self, sleeper): self.sleeper = sleeper def __repr__(self): return "%s gone to sleep" % thread_name(self.sleeper) class RunqueueEventWakeup: @staticmethod def color(): return (0xff, 0xff, 0) def __init__(self, wakee): self.wakee = wakee def __repr__(self): return "%s woke up" % thread_name(self.wakee) class RunqueueEventFork: @staticmethod def color(): return (0, 0xff, 0) def __init__(self, child): self.child = child def __repr__(self): return "new forked task %s" % thread_name(self.child) class RunqueueMigrateIn: @staticmethod def color(): return (0, 0xf0, 0xff) def __init__(self, new): self.new = new def __repr__(self): return "task migrated in %s" % thread_name(self.new) class RunqueueMigrateOut: @staticmethod def color(): return (0xff, 0, 0xff) def __init__(self, old): self.old = old def __repr__(self): return "task migrated out %s" % thread_name(self.old) class RunqueueSnapshot: def __init__(self, tasks = [0], event = RunqueueEventUnknown()): self.tasks = tuple(tasks) self.event = event def sched_switch(self, prev, prev_state, next): event = RunqueueEventUnknown() if taskState(prev_state) == "R" and next in self.tasks \ and prev in self.tasks: return self if taskState(prev_state) != "R": event = RunqueueEventSleep(prev) next_tasks = list(self.tasks[:]) if prev in self.tasks: if taskState(prev_state) != "R": next_tasks.remove(prev) elif taskState(prev_state) == "R": next_tasks.append(prev) if next not in next_tasks: next_tasks.append(next) return RunqueueSnapshot(next_tasks, event) def migrate_out(self, old): if old not in self.tasks: return self next_tasks = [task for task in self.tasks if task != old] return RunqueueSnapshot(next_tasks, RunqueueMigrateOut(old)) def __migrate_in(self, new, event): if new in self.tasks: self.event = event return self next_tasks = self.tasks[:] + tuple([new]) return RunqueueSnapshot(next_tasks, event) def migrate_in(self, new): return self.__migrate_in(new, RunqueueMigrateIn(new)) def wake_up(self, new): return self.__migrate_in(new, RunqueueEventWakeup(new)) def wake_up_new(self, new): return self.__migrate_in(new, RunqueueEventFork(new)) def load(self): """ Provide the number of tasks on the runqueue. Don't count idle""" return len(self.tasks) - 1 def __repr__(self): ret = self.tasks.__repr__() ret += self.origin_tostring() return ret class TimeSlice: def __init__(self, start, prev): self.start = start self.prev = prev self.end = start # cpus that triggered the event self.event_cpus = [] if prev is not None: self.total_load = prev.total_load self.rqs = prev.rqs.copy() else: self.rqs = defaultdict(RunqueueSnapshot) self.total_load = 0 def __update_total_load(self, old_rq, new_rq): diff = new_rq.load() - old_rq.load() self.total_load += diff def sched_switch(self, ts_list, prev, prev_state, next, cpu): old_rq = self.prev.rqs[cpu] new_rq = old_rq.sched_switch(prev, prev_state, next) if old_rq is new_rq: return self.rqs[cpu] = new_rq self.__update_total_load(old_rq, new_rq) ts_list.append(self) self.event_cpus = [cpu] def migrate(self, ts_list, new, old_cpu, new_cpu): if old_cpu == new_cpu: return old_rq = self.prev.rqs[old_cpu] out_rq = old_rq.migrate_out(new) self.rqs[old_cpu] = out_rq self.__update_total_load(old_rq, out_rq) new_rq = self.prev.rqs[new_cpu] in_rq = new_rq.migrate_in(new) self.rqs[new_cpu] = in_rq self.__update_total_load(new_rq, in_rq) ts_list.append(self) if old_rq is not out_rq: self.event_cpus.append(old_cpu) self.event_cpus.append(new_cpu) def wake_up(self, ts_list, pid, cpu, fork): old_rq = self.prev.rqs[cpu] if fork: new_rq = old_rq.wake_up_new(pid) else: new_rq = old_rq.wake_up(pid) if new_rq is old_rq: return self.rqs[cpu] = new_rq self.__update_total_load(old_rq, new_rq) ts_list.append(self) self.event_cpus = [cpu] def next(self, t): self.end = t return TimeSlice(t, self) class TimeSliceList(UserList): def __init__(self, arg = []): self.data = arg def get_time_slice(self, ts): if len(self.data) == 0: slice = TimeSlice(ts, TimeSlice(-1, None)) else: slice = self.data[-1].next(ts) return slice def find_time_slice(self, ts): start = 0 end = len(self.data) found = -1 searching = True while searching: if start == end or start == end - 1: searching = False i = (end + start) / 2 if self.data[i].start <= ts and self.data[i].end >= ts: found = i end = i continue if self.data[i].end < ts: start = i elif self.data[i].start > ts: end = i return found def set_root_win(self, win): self.root_win = win def mouse_down(self, cpu, t): idx = self.find_time_slice(t) if idx == -1: return ts = self[idx] rq = ts.rqs[cpu] raw = "CPU: %d\n" % cpu raw += "Last event : %s\n" % rq.event.__repr__() raw += "Timestamp : %d.%06d\n" % (ts.start / (10 ** 9), (ts.start % (10 ** 9)) / 1000) raw += "Duration : %6d us\n" % ((ts.end - ts.start) / (10 ** 6)) raw += "Load = %d\n" % rq.load() for t in rq.tasks: raw += "%s \n" % thread_name(t) self.root_win.update_summary(raw) def update_rectangle_cpu(self, slice, cpu): rq = slice.rqs[cpu] if slice.total_load != 0: load_rate = rq.load() / float(slice.total_load) else: load_rate = 0 red_power = int(0xff - (0xff * load_rate)) color = (0xff, red_power, red_power) top_color = None if cpu in slice.event_cpus: top_color = rq.event.color() self.root_win.paint_rectangle_zone(cpu, color, top_color, slice.start, slice.end) def fill_zone(self, start, end): i = self.find_time_slice(start) if i == -1: return for i in xrange(i, len(self.data)): timeslice = self.data[i] if timeslice.start > end: return for cpu in timeslice.rqs: self.update_rectangle_cpu(timeslice, cpu) def interval(self): if len(self.data) == 0: return (0, 0) return (self.data[0].start, self.data[-1].end) def nr_rectangles(self): last_ts = self.data[-1] max_cpu = 0 for cpu in last_ts.rqs: if cpu > max_cpu: max_cpu = cpu return max_cpu class SchedEventProxy: def __init__(self): self.current_tsk = defaultdict(lambda : -1) self.timeslices = TimeSliceList() def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio): """ Ensure the task we sched out this cpu is really the one we logged. Otherwise we may have missed traces """ on_cpu_task = self.current_tsk[headers.cpu] if on_cpu_task != -1 and on_cpu_task != prev_pid: print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ (headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) threads[prev_pid] = prev_comm threads[next_pid] = next_comm self.current_tsk[headers.cpu] = next_pid ts = self.timeslices.get_time_slice(headers.ts()) ts.sched_switch(self.timeslices, prev_pid, prev_state, next_pid, headers.cpu) def migrate(self, headers, pid, prio, orig_cpu, dest_cpu): ts = self.timeslices.get_time_slice(headers.ts()) ts.migrate(self.timeslices, pid, orig_cpu, dest_cpu) def wake_up(self, headers, comm, pid, success, target_cpu, fork): if success == 0: return ts = self.timeslices.get_time_slice(headers.ts()) ts.wake_up(self.timeslices, pid, target_cpu, fork) def trace_begin(): global parser parser = SchedEventProxy() def trace_end(): app = wx.App(False) timeslices = parser.timeslices frame = RootFrame(timeslices, "Migration") app.MainLoop() def sched__sched_stat_runtime(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, runtime, vruntime): pass def sched__sched_stat_iowait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_stat_sleep(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_stat_wait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, delay): pass def sched__sched_process_fork(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, parent_comm, parent_pid, child_comm, child_pid): pass def sched__sched_process_wait(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_process_exit(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_process_free(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_migrate_task(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, orig_cpu, dest_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.migrate(headers, pid, prio, orig_cpu, dest_cpu) def sched__sched_switch(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state, next_comm, next_pid, next_prio) def sched__sched_wakeup_new(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, success, target_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.wake_up(headers, comm, pid, success, target_cpu, 1) def sched__sched_wakeup(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio, success, target_cpu): headers = EventHeaders(common_cpu, common_secs, common_nsecs, common_pid, common_comm) parser.wake_up(headers, comm, pid, success, target_cpu, 0) def sched__sched_wait_task(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid, prio): pass def sched__sched_kthread_stop_ret(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, ret): pass def sched__sched_kthread_stop(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, comm, pid): pass def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm): pass
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 445, 3165, 2120, 8367, 23503, 31239, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8582, 2884, 1566, 8297, 1172, 2757, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 504, 28639, 492, 28639, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 1274, 14, 515, 14, 740, 360, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 428, 1809, 4324, 492, 627, 421, 199, 6962, 275, 469, 378, 520, 298, 12000, 3570, 199, 199, 318, 2462, 63, 354, 8, 3150, 304, 199, 198, 1107, 2071, 83, 2689, 68, 2, 450, 334, 6962, 59, 3150, 467, 4422, 9, 199, 199, 533, 25406, 5912, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 488, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 5187, 2, 199, 199, 533, 25406, 17306, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 26220, 15033, 304, 507, 198, 277, 14, 23042, 15033, 275, 26220, 15033, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 21737, 370, 9435, 2, 450, 2462, 63, 354, 8, 277, 14, 23042, 15033, 9, 199, 199, 533, 25406, 23424, 384, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 21560, 69, 304, 507, 198, 277, 14, 15181, 69, 275, 21560, 69, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 336, 79, 415, 1536, 2, 450, 2462, 63, 354, 8, 277, 14, 15181, 69, 9, 199, 199, 533, 25406, 1858, 75, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 1982, 304, 507, 198, 277, 14, 1739, 275, 1982, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1222, 14926, 379, 2120, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1739, 9, 199, 199, 533, 17664, 26641, 607, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 1949, 16, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 892, 304, 507, 198, 277, 14, 1222, 275, 892, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 315, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1222, 9, 199, 199, 533, 17664, 26641, 2204, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 2269, 304, 507, 198, 277, 14, 1753, 275, 2269, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 734, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1753, 9, 199, 199, 533, 17664, 12038, 26, 199, 198, 318, 636, 826, 721, 277, 12, 6527, 275, 359, 16, 467, 1566, 275, 25406, 5912, 5109, 507, 198, 277, 14, 5054, 275, 2008, 8, 5054, 9, 507, 198, 277, 14, 1430, 275, 1566, 421, 198, 318, 10286, 63, 5656, 8, 277, 12, 5071, 12, 5071, 63, 929, 12, 2163, 304, 507, 198, 1430, 275, 25406, 5912, 342, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 2, 436, 2163, 315, 291, 14, 5054, 971, 686, 198, 460, 5071, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 686, 198, 1430, 275, 25406, 17306, 8, 5701, 9, 2742, 198, 2184, 63, 5054, 275, 769, 8, 277, 14, 5054, 1491, 566, 507, 198, 692, 5071, 315, 291, 14, 5054, 26, 686, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 1585, 198, 2184, 63, 5054, 14, 2168, 8, 5701, 9, 507, 198, 4164, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 582, 686, 198, 2184, 63, 5054, 14, 740, 8, 5701, 9, 2742, 198, 692, 2163, 440, 315, 2163, 63, 5054, 26, 686, 198, 2184, 63, 5054, 14, 740, 8, 2184, 9, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 548, 8, 277, 12, 2269, 304, 507, 198, 692, 2269, 440, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 359, 1765, 367, 2120, 315, 291, 14, 5054, 340, 2120, 1137, 2269, 61, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 17664, 26641, 2204, 8, 1753, 430, 421, 198, 318, 636, 8462, 63, 262, 8, 277, 12, 892, 12, 1566, 304, 507, 198, 692, 892, 315, 291, 14, 5054, 26, 686, 198, 277, 14, 1430, 275, 1566, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 291, 14, 5054, 5873, 435, 2008, 779, 1222, 566, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 262, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12, 17664, 26641, 607, 8, 1222, 430, 421, 198, 318, 21560, 63, 384, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 445, 3165, 2120, 8367, 23503, 31239, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8582, 2884, 1566, 8297, 1172, 2757, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 646, 747, 199, 646, 984, 199, 199, 504, 5055, 492, 10018, 199, 504, 28639, 492, 28639, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 1274, 14, 515, 14, 740, 360, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 428, 1809, 4324, 492, 627, 421, 199, 6962, 275, 469, 378, 520, 298, 12000, 3570, 199, 199, 318, 2462, 63, 354, 8, 3150, 304, 199, 198, 1107, 2071, 83, 2689, 68, 2, 450, 334, 6962, 59, 3150, 467, 4422, 9, 199, 199, 533, 25406, 5912, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 488, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 5187, 2, 199, 199, 533, 25406, 17306, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 26220, 15033, 304, 507, 198, 277, 14, 23042, 15033, 275, 26220, 15033, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 21737, 370, 9435, 2, 450, 2462, 63, 354, 8, 277, 14, 23042, 15033, 9, 199, 199, 533, 25406, 23424, 384, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 21560, 69, 304, 507, 198, 277, 14, 15181, 69, 275, 21560, 69, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 2071, 83, 336, 79, 415, 1536, 2, 450, 2462, 63, 354, 8, 277, 14, 15181, 69, 9, 199, 199, 533, 25406, 1858, 75, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 3581, 12, 378, 9, 421, 198, 318, 636, 826, 721, 277, 12, 1982, 304, 507, 198, 277, 14, 1739, 275, 1982, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1222, 14926, 379, 2120, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1739, 9, 199, 199, 533, 17664, 26641, 607, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 12, 378, 1949, 16, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 892, 304, 507, 198, 277, 14, 1222, 275, 892, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 315, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1222, 9, 199, 199, 533, 17664, 26641, 2204, 26, 199, 198, 32, 4639, 199, 198, 318, 3164, 837, 507, 198, 1107, 334, 16, 3581, 12, 378, 12, 378, 3581, 9, 421, 198, 318, 636, 826, 721, 277, 12, 2269, 304, 507, 198, 277, 14, 1753, 275, 2269, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 298, 1765, 28322, 734, 450, 83, 2, 450, 2462, 63, 354, 8, 277, 14, 1753, 9, 199, 199, 533, 17664, 12038, 26, 199, 198, 318, 636, 826, 721, 277, 12, 6527, 275, 359, 16, 467, 1566, 275, 25406, 5912, 5109, 507, 198, 277, 14, 5054, 275, 2008, 8, 5054, 9, 507, 198, 277, 14, 1430, 275, 1566, 421, 198, 318, 10286, 63, 5656, 8, 277, 12, 5071, 12, 5071, 63, 929, 12, 2163, 304, 507, 198, 1430, 275, 25406, 5912, 342, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 2, 436, 2163, 315, 291, 14, 5054, 971, 686, 198, 460, 5071, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 2742, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 686, 198, 1430, 275, 25406, 17306, 8, 5701, 9, 2742, 198, 2184, 63, 5054, 275, 769, 8, 277, 14, 5054, 1491, 566, 507, 198, 692, 5071, 315, 291, 14, 5054, 26, 686, 198, 692, 2120, 2223, 8, 5701, 63, 929, 9, 1137, 298, 50, 582, 1585, 198, 2184, 63, 5054, 14, 2168, 8, 5701, 9, 507, 198, 4164, 2120, 2223, 8, 5701, 63, 929, 9, 508, 298, 50, 582, 686, 198, 2184, 63, 5054, 14, 740, 8, 5701, 9, 2742, 198, 692, 2163, 440, 315, 2163, 63, 5054, 26, 686, 198, 2184, 63, 5054, 14, 740, 8, 2184, 9, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 548, 8, 277, 12, 2269, 304, 507, 198, 692, 2269, 440, 315, 291, 14, 5054, 26, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 359, 1765, 367, 2120, 315, 291, 14, 5054, 340, 2120, 1137, 2269, 61, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 17664, 26641, 2204, 8, 1753, 430, 421, 198, 318, 636, 8462, 63, 262, 8, 277, 12, 892, 12, 1566, 304, 507, 198, 692, 892, 315, 291, 14, 5054, 26, 686, 198, 277, 14, 1430, 275, 1566, 686, 198, 1107, 291, 507, 198, 2184, 63, 5054, 275, 291, 14, 5054, 5873, 435, 2008, 779, 1222, 566, 2742, 198, 1107, 17664, 12038, 8, 2184, 63, 5054, 12, 1566, 9, 421, 198, 318, 12810, 63, 262, 8, 277, 12, 892, 304, 507, 198, 1107, 291, 855, 8462, 63, 262, 8, 1222, 12, 17664, 26641, 607, 8, 1222, 430, 421, 198, 318, 21560, 63, 384, 8, 277, 12, 892, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
domino-team/openwrt-cc
package/gli-pub/openwrt-node-packages-master/node/node-v6.9.1/deps/v8_inspector/third_party/jinja2/jinja2/__init__.py
27
2330
# -*- coding: utf-8 -*- """ jinja2 ~~~~~~ Jinja2 is a template engine written in pure Python. It provides a Django inspired non-XML syntax but supports inline expressions and an optional sandboxed environment. Nutshell -------- Here a small example of a Jinja2 template:: {% extends 'base.html' %} {% block title %}Memberlist{% endblock %} {% block content %} <ul> {% for user in users %} <li><a href="{{ user.url }}">{{ user.username }}</a></li> {% endfor %} </ul> {% endblock %} :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ __docformat__ = 'restructuredtext en' __version__ = '2.9.dev' # high level interface from jinja2.environment import Environment, Template # loaders from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \ DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \ ModuleLoader # bytecode caches from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \ MemcachedBytecodeCache # undefined types from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined, \ make_logging_undefined # exceptions from jinja2.exceptions import TemplateError, UndefinedError, \ TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \ TemplateAssertionError # decorators and public utilities from jinja2.filters import environmentfilter, contextfilter, \ evalcontextfilter from jinja2.utils import Markup, escape, clear_caches, \ environmentfunction, evalcontextfunction, contextfunction, \ is_undefined __all__ = [ 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader', 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader', 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache', 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined', 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound', 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError', 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape', 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined', 'evalcontextfilter', 'evalcontextfunction', 'make_logging_undefined', ]
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 272, 221, 2878, 1714, 339, 17300, 18, 365, 282, 1978, 6869, 5313, 315, 15111, 2018, 14, 221, 2779, 6571, 282, 272, 5634, 315, 8721, 581, 2222, 13, 4317, 6302, 1325, 5171, 8308, 8455, 436, 272, 376, 2716, 19699, 379, 3734, 14, 339, 653, 337, 5641, 272, 3001, 339, 11842, 282, 7425, 2893, 402, 282, 17300, 18, 1978, 447, 398, 7749, 16879, 283, 1095, 14, 1360, 7, 3674, 267, 7749, 1853, 2538, 3674, 7021, 513, 3996, 21525, 3674, 267, 7749, 1853, 1564, 3674, 881, 665, 348, 30, 881, 7749, 367, 922, 315, 4390, 3674, 288, 665, 317, 2535, 65, 4369, 628, 3638, 922, 14, 633, 3586, 1743, 3638, 922, 14, 2473, 18519, 65, 2957, 317, 30, 881, 7749, 17273, 3674, 881, 3068, 348, 30, 267, 7749, 21525, 3674, 2378, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 363, 1023, 363, 275, 283, 18, 14, 25, 14, 2374, 7, 199, 199, 3, 4721, 2166, 3217, 199, 504, 10321, 18, 14, 5418, 492, 9711, 12, 5458, 199, 199, 3, 25520, 199, 504, 10321, 18, 14, 16370, 492, 3523, 5455, 12, 23754, 5455, 12, 15665, 5455, 12, 971, 1362, 7448, 5455, 12, 6801, 5455, 12, 25110, 5455, 12, 16053, 5455, 12, 971, 1362, 5673, 5455, 199, 199, 3, 16855, 18014, 199, 504, 10321, 18, 14, 3776, 1637, 492, 20301, 600, 4437, 12, 23754, 4861, 600, 4437, 12, 971, 1362, 30465, 5245, 4861, 600, 4437, 199, 199, 3, 10942, 2943, 199, 504, 10321, 18, 14, 7726, 492, 25868, 12, 14245, 16283, 12, 23052, 16283, 12, 971, 1362, 1852, 63, 4806, 63, 10705, 199, 199, 3, 4967, 199, 504, 10321, 18, 14, 3924, 492, 5458, 547, 12, 25868, 547, 12, 971, 1362, 5458, 4667, 12, 31273, 4667, 12, 17762, 12, 971, 1362, 5458, 14844, 199, 199, 3, 20419, 436, 4575, 15841, 199, 504, 10321, 18, 14, 4273, 492, 3734, 1541, 12, 1067, 1541, 12, 971, 1362, 3468, 1100, 1541, 199, 504, 10321, 18, 14, 1208, 492, 17504, 12, 4772, 12, 5436, 63, 17595, 12, 971, 1362, 3734, 1593, 12, 3468, 1100, 1593, 12, 1067, 1593, 12, 971, 1362, 365, 63, 10705, 199, 199, 363, 452, 363, 275, 359, 272, 283, 8263, 297, 283, 4231, 297, 283, 1563, 5455, 297, 283, 17521, 5455, 297, 272, 283, 8599, 5455, 297, 283, 2141, 5455, 297, 283, 3481, 5455, 297, 283, 4793, 5455, 297, 272, 283, 9054, 5455, 297, 283, 4861, 600, 4437, 297, 283, 17521, 4861, 600, 4437, 297, 272, 283, 14169, 5245, 4861, 600, 4437, 297, 283, 16283, 297, 283, 7084, 16283, 297, 272, 283, 18625, 16283, 297, 283, 4231, 547, 297, 283, 16283, 547, 297, 283, 4231, 4667, 297, 272, 283, 17969, 4667, 297, 283, 20837, 297, 283, 4231, 14844, 297, 272, 283, 2377, 5455, 297, 283, 5418, 1541, 297, 283, 1100, 1541, 297, 283, 23393, 297, 283, 3765, 297, 272, 283, 5418, 1593, 297, 283, 1100, 1593, 297, 283, 3584, 63, 17595, 297, 283, 374, 63, 10705, 297, 272, 283, 2579, 1100, 1541, 297, 283, 2579, 1100, 1593, 297, 283, 1875, 63, 4806, 63, 10705, 297, 199, 61, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 272, 221, 2878, 1714, 339, 17300, 18, 365, 282, 1978, 6869, 5313, 315, 15111, 2018, 14, 221, 2779, 6571, 282, 272, 5634, 315, 8721, 581, 2222, 13, 4317, 6302, 1325, 5171, 8308, 8455, 436, 272, 376, 2716, 19699, 379, 3734, 14, 339, 653, 337, 5641, 272, 3001, 339, 11842, 282, 7425, 2893, 402, 282, 17300, 18, 1978, 447, 398, 7749, 16879, 283, 1095, 14, 1360, 7, 3674, 267, 7749, 1853, 2538, 3674, 7021, 513, 3996, 21525, 3674, 267, 7749, 1853, 1564, 3674, 881, 665, 348, 30, 881, 7749, 367, 922, 315, 4390, 3674, 288, 665, 317, 2535, 65, 4369, 628, 3638, 922, 14, 633, 3586, 1743, 3638, 922, 14, 2473, 18519, 65, 2957, 317, 30, 881, 7749, 17273, 3674, 881, 3068, 348, 30, 267, 7749, 21525, 3674, 2378, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 363, 1023, 363, 275, 283, 18, 14, 25, 14, 2374, 7, 199, 199, 3, 4721, 2166, 3217, 199, 504, 10321, 18, 14, 5418, 492, 9711, 12, 5458, 199, 199, 3, 25520, 199, 504, 10321, 18, 14, 16370, 492, 3523, 5455, 12, 23754, 5455, 12, 15665, 5455, 12, 971, 1362, 7448, 5455, 12, 6801, 5455, 12, 25110, 5455, 12, 16053, 5455, 12, 971, 1362, 5673, 5455, 199, 199, 3, 16855, 18014, 199, 504, 10321, 18, 14, 3776, 1637, 492, 20301, 600, 4437, 12, 23754, 4861, 600, 4437, 12, 971, 1362, 30465, 5245, 4861, 600, 4437, 199, 199, 3, 10942, 2943, 199, 504, 10321, 18, 14, 7726, 492, 25868, 12, 14245, 16283, 12, 23052, 16283, 12, 971, 1362, 1852, 63, 4806, 63, 10705, 199, 199, 3, 4967, 199, 504, 10321, 18, 14, 3924, 492, 5458, 547, 12, 25868, 547, 12, 971, 1362, 5458, 4667, 12, 31273, 4667, 12, 17762, 12, 971, 1362, 5458, 14844, 199, 199, 3, 20419, 436, 4575, 15841, 199, 504, 10321, 18, 14, 4273, 492, 3734, 1541, 12, 1067, 1541, 12, 971, 1362, 3468, 1100, 1541, 199, 504, 10321, 18, 14, 1208, 492, 17504, 12, 4772, 12, 5436, 63, 17595, 12, 971, 1362, 3734, 1593, 12, 3468, 1100, 1593, 12, 1067, 1593, 12, 971, 1362, 365, 63, 10705, 199, 199, 363, 452, 363, 275, 359, 272, 283, 8263, 297, 283, 4231, 297, 283, 1563, 5455, 297, 283, 17521, 5455, 297, 272, 283, 8599, 5455, 297, 283, 2141, 5455, 297, 283, 3481, 5455, 297, 283, 4793, 5455, 297, 272, 283, 9054, 5455, 297, 283, 4861, 600, 4437, 297, 283, 17521, 4861, 600, 4437, 297, 272, 283, 14169, 5245, 4861, 600, 4437, 297, 283, 16283, 297, 283, 7084, 16283, 297, 272, 283, 18625, 16283, 297, 283, 4231, 547, 297, 283, 16283, 547, 297, 283, 4231, 4667, 297, 272, 283, 17969, 4667, 297, 283, 20837, 297, 283, 4231, 14844, 297, 272, 283, 2377, 5455, 297, 283, 5418, 1541, 297, 283, 1100, 1541, 297, 283, 23393, 297, 283, 3765, 297, 272, 283, 5418, 1593, 297, 283, 1100, 1593, 297, 283, 3584, 63, 17595, 297, 283, 374, 63, 10705, 297, 272, 283, 2579, 1100, 1541, 297, 283, 2579, 1100, 1593, 297, 283, 1875, 63, 4806, 63, 10705, 297, 199, 61, 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,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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 ]
Innovahn/cybex
addons/hr_recruitment/wizard/__init__.py
381
1095
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-Today OpenERP (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import hr_recruitment_create_partner_job # 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, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 31982, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 264, 31365, 434, 63, 981, 63, 3899, 63, 2423, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 31982, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 264, 31365, 434, 63, 981, 63, 3899, 63, 2423, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Clever/Diamond
src/collectors/snmpraw/test/testsnmpraw.py
29
1797
#!/usr/bin/python # coding=utf-8 ############################################################################### import time from test import CollectorTestCase from test import get_collector_config from test import unittest from mock import Mock from mock import patch from snmpraw import SNMPRawCollector from diamond.collector import Collector ############################################################################### class TestSNMPRawCollector(CollectorTestCase): def setUp(self): config = get_collector_config('SNMPRawCollector', { }) self.collector = SNMPRawCollector(config, None) def test_import(self): self.assertTrue(SNMPRawCollector) @patch.object(Collector, 'publish_metric') @patch.object(time, 'time', Mock(return_value=1000)) @patch.object(SNMPRawCollector, '_get_value', Mock(return_value=5)) def test_metric(self, collect_mock): test_config = {'devices': {'test': {'oids': {'1.1.1.1': 'test'}}}} self.collector.config.update(test_config) path = '.'.join([self.collector.config['path_prefix'], 'test', self.collector.config['path_suffix'], 'test']) self.collector.collect_snmp('test', None, None, None) metric = collect_mock.call_args[0][0] self.assertEqual(metric.metric_type, 'GAUGE') self.assertEqual(metric.ttl, None) self.assertEqual(metric.value, self.collector._get_value()) self.assertEqual(metric.precision, self.collector._precision(5)) self.assertEqual(metric.host, None) self.assertEqual(metric.path, path) self.assertEqual(metric.timestamp, 1000) ############################################################################### if __name__ == "__main__": unittest.main()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 29, 1624, 13, 24, 199, 11490, 199, 646, 900, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 504, 20143, 1773, 492, 26549, 7963, 12852, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 199, 11490, 421, 199, 533, 1379, 30919, 7963, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 30919, 7963, 12852, 297, 469, 267, 3828, 267, 291, 14, 10946, 275, 26549, 7963, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 30919, 7963, 12852, 9, 339, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 63, 5165, 358, 272, 768, 2068, 14, 785, 8, 521, 12, 283, 521, 297, 4420, 8, 1107, 63, 585, 29, 5279, 430, 272, 768, 2068, 14, 785, 8, 30919, 7963, 12852, 12, 2513, 362, 63, 585, 297, 4420, 8, 1107, 63, 585, 29, 21, 430, 272, 347, 511, 63, 5165, 8, 277, 12, 8775, 63, 1805, 304, 267, 511, 63, 888, 275, 791, 6410, 356, 791, 396, 356, 791, 1170, 83, 356, 791, 17, 14, 17, 14, 17, 14, 17, 356, 283, 396, 936, 4863, 93, 267, 291, 14, 10946, 14, 888, 14, 873, 8, 396, 63, 888, 9, 398, 931, 275, 15671, 904, 779, 277, 14, 10946, 14, 888, 459, 515, 63, 1861, 995, 283, 396, 297, 586, 291, 14, 10946, 14, 888, 459, 515, 63, 4511, 995, 283, 396, 1105, 398, 291, 14, 10946, 14, 7112, 63, 15523, 360, 396, 297, 488, 12, 488, 12, 488, 9, 267, 6370, 275, 8775, 63, 1805, 14, 1250, 63, 589, 59, 16, 1527, 16, 61, 398, 291, 14, 629, 8, 5165, 14, 5165, 63, 466, 12, 283, 39, 9331, 4962, 358, 267, 291, 14, 629, 8, 5165, 14, 12130, 12, 488, 9, 267, 291, 14, 629, 8, 5165, 14, 585, 12, 291, 14, 10946, 423, 362, 63, 585, 1012, 267, 291, 14, 629, 8, 5165, 14, 6833, 12, 291, 14, 10946, 423, 6833, 8, 21, 430, 267, 291, 14, 629, 8, 5165, 14, 1102, 12, 488, 9, 267, 291, 14, 629, 8, 5165, 14, 515, 12, 931, 9, 267, 291, 14, 629, 8, 5165, 14, 3954, 12, 5198, 9, 421, 199, 11490, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2803, 29, 1624, 13, 24, 199, 11490, 199, 646, 900, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 504, 20143, 1773, 492, 26549, 7963, 12852, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 199, 11490, 421, 199, 533, 1379, 30919, 7963, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 30919, 7963, 12852, 297, 469, 267, 3828, 267, 291, 14, 10946, 275, 26549, 7963, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 30919, 7963, 12852, 9, 339, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 63, 5165, 358, 272, 768, 2068, 14, 785, 8, 521, 12, 283, 521, 297, 4420, 8, 1107, 63, 585, 29, 5279, 430, 272, 768, 2068, 14, 785, 8, 30919, 7963, 12852, 12, 2513, 362, 63, 585, 297, 4420, 8, 1107, 63, 585, 29, 21, 430, 272, 347, 511, 63, 5165, 8, 277, 12, 8775, 63, 1805, 304, 267, 511, 63, 888, 275, 791, 6410, 356, 791, 396, 356, 791, 1170, 83, 356, 791, 17, 14, 17, 14, 17, 14, 17, 356, 283, 396, 936, 4863, 93, 267, 291, 14, 10946, 14, 888, 14, 873, 8, 396, 63, 888, 9, 398, 931, 275, 15671, 904, 779, 277, 14, 10946, 14, 888, 459, 515, 63, 1861, 995, 283, 396, 297, 586, 291, 14, 10946, 14, 888, 459, 515, 63, 4511, 995, 283, 396, 1105, 398, 291, 14, 10946, 14, 7112, 63, 15523, 360, 396, 297, 488, 12, 488, 12, 488, 9, 267, 6370, 275, 8775, 63, 1805, 14, 1250, 63, 589, 59, 16, 1527, 16, 61, 398, 291, 14, 629, 8, 5165, 14, 5165, 63, 466, 12, 283, 39, 9331, 4962, 358, 267, 291, 14, 629, 8, 5165, 14, 12130, 12, 488, 9, 267, 291, 14, 629, 8, 5165, 14, 585, 12, 291, 14, 10946, 423, 362, 63, 585, 1012, 267, 291, 14, 629, 8, 5165, 14, 6833, 12, 291, 14, 10946, 423, 6833, 8, 21, 430, 267, 291, 14, 629, 8, 5165, 14, 1102, 12, 488, 9, 267, 291, 14, 629, 8, 5165, 14, 515, 12, 931, 9, 267, 291, 14, 629, 8, 5165, 14, 3954, 12, 5198, 9, 421, 199, 11490, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Freestila/dosage
scripts/order-symlinks.py
3
2039
#!/usr/bin/env python # Copyright (C) 2013 Tobias Gruetzmacher """ This script takes the JSON file created by 'dosage -o json' and uses the metadata to build a symlink farm in the deduced order of the comic. It created those in a subdirectory called 'inorder'. """ from __future__ import print_function import sys import os import codecs import json def jsonFn(d): """Get JSON filename.""" return os.path.join(d, 'dosage.json') def loadJson(d): """Return JSON data.""" with codecs.open(jsonFn(d), 'r', 'utf-8') as f: return json.load(f) def prepare_output(d): """Clean pre-existing links in output directory.""" outDir = os.path.join(d, 'inorder') if not os.path.exists(outDir): os.mkdir(outDir) for f in os.listdir(outDir): f = os.path.join(outDir, f) if os.path.islink(f): os.remove(f) return outDir def create_symlinks(d): """Create new symbolic links in output directory.""" data = loadJson(d) outDir = prepare_output(d) unseen = data["pages"].keys() while len(unseen) > 0: latest = work = unseen[0] while work in unseen: unseen.remove(work) if "prev" in data["pages"][work]: work = data["pages"][work]["prev"] print("Latest page: %s" % (latest)) order = [] work = latest while work in data["pages"]: order.extend(data["pages"][work]["images"].values()) if "prev" in data["pages"][work]: work = data["pages"][work]["prev"] else: work = None order.reverse() for i, img in enumerate(order): os.symlink(os.path.join('..', img), os.path.join(outDir, '%05i_%s' % (i, img))) if __name__ == '__main__': if len(sys.argv) > 1: for d in sys.argv[1:]: if os.path.exists(jsonFn(d)): create_symlinks(d) else: print("No JSON file found in '%s'." % (d)) else: print("Usage: %s comic-dirs" % (os.path.basename(sys.argv[0])))
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 35, 9, 6171, 377, 2873, 2241, 598, 431, 3903, 391, 7641, 199, 624, 199, 2765, 2884, 6181, 314, 4840, 570, 2737, 701, 283, 18339, 474, 446, 79, 2022, 7, 436, 4440, 314, 199, 2343, 370, 1900, 282, 15296, 289, 5362, 315, 314, 477, 16584, 1865, 402, 314, 2414, 530, 14, 2779, 2737, 199, 273, 3362, 315, 282, 25094, 2797, 283, 262, 1648, 1370, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 747, 199, 646, 6010, 199, 646, 2022, 199, 199, 318, 2022, 9656, 8, 68, 304, 272, 408, 1002, 4840, 1788, 1041, 272, 372, 747, 14, 515, 14, 904, 8, 68, 12, 283, 18339, 474, 14, 1001, 358, 199, 199, 318, 2248, 9653, 8, 68, 304, 272, 408, 1767, 4840, 666, 1041, 272, 543, 6010, 14, 1490, 8, 1001, 9656, 8, 68, 395, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 267, 372, 2022, 14, 912, 8, 70, 9, 199, 199, 318, 9275, 63, 1199, 8, 68, 304, 272, 408, 6580, 876, 13, 5952, 6220, 315, 1072, 2082, 1041, 272, 734, 3567, 275, 747, 14, 515, 14, 904, 8, 68, 12, 283, 262, 1648, 358, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 548, 3567, 304, 267, 747, 14, 8215, 8, 548, 3567, 9, 272, 367, 289, 315, 747, 14, 7374, 8, 548, 3567, 304, 267, 289, 275, 747, 14, 515, 14, 904, 8, 548, 3567, 12, 289, 9, 267, 340, 747, 14, 515, 14, 20719, 8, 70, 304, 288, 747, 14, 2168, 8, 70, 9, 272, 372, 734, 3567, 199, 199, 318, 1218, 63, 19522, 8, 68, 304, 272, 408, 2499, 892, 13673, 6220, 315, 1072, 2082, 1041, 272, 666, 275, 2248, 9653, 8, 68, 9, 272, 734, 3567, 275, 9275, 63, 1199, 8, 68, 9, 339, 625, 8606, 275, 666, 905, 5856, 4140, 1612, 342, 272, 1830, 822, 8, 324, 8606, 9, 690, 378, 26, 267, 8839, 275, 1736, 275, 625, 8606, 59, 16, 61, 267, 1830, 1736, 315, 625, 8606, 26, 288, 625, 8606, 14, 2168, 8, 800, 9, 288, 340, 298, 5701, 2, 315, 666, 905, 5856, 9210, 800, 2189, 355, 1736, 275, 666, 905, 5856, 9210, 800, 7541, 5701, 937, 272, 870, 480, 31438, 2034, 26, 450, 83, 2, 450, 334, 7410, 430, 339, 1865, 275, 942, 272, 1736, 275, 8839, 272, 1830, 1736, 315, 666, 905, 5856, 6229, 267, 1865, 14, 2880, 8, 576, 905, 5856, 9210, 800, 7541, 4782, 4140, 1459, 1012, 267, 340, 298, 5701, 2, 315, 666, 905, 5856, 9210, 800, 2189, 288, 1736, 275, 666, 905, 5856, 9210, 800, 7541, 5701, 937, 267, 587, 26, 288, 1736, 275, 488, 272, 1865, 14, 4471, 342, 339, 367, 284, 12, 6050, 315, 3874, 8, 1648, 304, 267, 747, 14, 13380, 8, 736, 14, 515, 14, 904, 24893, 297, 6050, 395, 747, 14, 515, 14, 904, 8, 548, 3567, 12, 1543, 1717, 73, 4970, 83, 7, 450, 334, 73, 12, 6050, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 267, 367, 366, 315, 984, 14, 3020, 59, 17, 10688, 288, 340, 747, 14, 515, 14, 2444, 8, 1001, 9656, 8, 68, 2298, 355, 1218, 63, 19522, 8, 68, 9, 288, 587, 26, 355, 870, 480, 1944, 4840, 570, 1911, 315, 1543, 83, 16669, 450, 334, 68, 430, 272, 587, 26, 267, 870, 480, 7692, 26, 450, 83, 2414, 530, 13, 3220, 2, 450, 334, 736, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 11845, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 35, 9, 6171, 377, 2873, 2241, 598, 431, 3903, 391, 7641, 199, 624, 199, 2765, 2884, 6181, 314, 4840, 570, 2737, 701, 283, 18339, 474, 446, 79, 2022, 7, 436, 4440, 314, 199, 2343, 370, 1900, 282, 15296, 289, 5362, 315, 314, 477, 16584, 1865, 402, 314, 2414, 530, 14, 2779, 2737, 199, 273, 3362, 315, 282, 25094, 2797, 283, 262, 1648, 1370, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 747, 199, 646, 6010, 199, 646, 2022, 199, 199, 318, 2022, 9656, 8, 68, 304, 272, 408, 1002, 4840, 1788, 1041, 272, 372, 747, 14, 515, 14, 904, 8, 68, 12, 283, 18339, 474, 14, 1001, 358, 199, 199, 318, 2248, 9653, 8, 68, 304, 272, 408, 1767, 4840, 666, 1041, 272, 543, 6010, 14, 1490, 8, 1001, 9656, 8, 68, 395, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 289, 26, 267, 372, 2022, 14, 912, 8, 70, 9, 199, 199, 318, 9275, 63, 1199, 8, 68, 304, 272, 408, 6580, 876, 13, 5952, 6220, 315, 1072, 2082, 1041, 272, 734, 3567, 275, 747, 14, 515, 14, 904, 8, 68, 12, 283, 262, 1648, 358, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 548, 3567, 304, 267, 747, 14, 8215, 8, 548, 3567, 9, 272, 367, 289, 315, 747, 14, 7374, 8, 548, 3567, 304, 267, 289, 275, 747, 14, 515, 14, 904, 8, 548, 3567, 12, 289, 9, 267, 340, 747, 14, 515, 14, 20719, 8, 70, 304, 288, 747, 14, 2168, 8, 70, 9, 272, 372, 734, 3567, 199, 199, 318, 1218, 63, 19522, 8, 68, 304, 272, 408, 2499, 892, 13673, 6220, 315, 1072, 2082, 1041, 272, 666, 275, 2248, 9653, 8, 68, 9, 272, 734, 3567, 275, 9275, 63, 1199, 8, 68, 9, 339, 625, 8606, 275, 666, 905, 5856, 4140, 1612, 342, 272, 1830, 822, 8, 324, 8606, 9, 690, 378, 26, 267, 8839, 275, 1736, 275, 625, 8606, 59, 16, 61, 267, 1830, 1736, 315, 625, 8606, 26, 288, 625, 8606, 14, 2168, 8, 800, 9, 288, 340, 298, 5701, 2, 315, 666, 905, 5856, 9210, 800, 2189, 355, 1736, 275, 666, 905, 5856, 9210, 800, 7541, 5701, 937, 272, 870, 480, 31438, 2034, 26, 450, 83, 2, 450, 334, 7410, 430, 339, 1865, 275, 942, 272, 1736, 275, 8839, 272, 1830, 1736, 315, 666, 905, 5856, 6229, 267, 1865, 14, 2880, 8, 576, 905, 5856, 9210, 800, 7541, 4782, 4140, 1459, 1012, 267, 340, 298, 5701, 2, 315, 666, 905, 5856, 9210, 800, 2189, 288, 1736, 275, 666, 905, 5856, 9210, 800, 7541, 5701, 937, 267, 587, 26, 288, 1736, 275, 488, 272, 1865, 14, 4471, 342, 339, 367, 284, 12, 6050, 315, 3874, 8, 1648, 304, 267, 747, 14, 13380, 8, 736, 14, 515, 14, 904, 24893, 297, 6050, 395, 747, 14, 515, 14, 904, 8, 548, 3567, 12, 1543, 1717, 73, 4970, 83, 7, 450, 334, 73, 12, 6050, 1724, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 267, 367, 366, 315, 984, 14, 3020, 59, 17, 10688, 288, 340, 747, 14, 515, 14, 2444, 8, 1001, 9656, 8, 68, 2298, 355, 1218, 63, 19522, 8, 68, 9, 288, 587, 26, 355, 870, 480, 1944, 4840, 570, 1911, 315, 1543, 83, 16669, 450, 334, 68, 430, 272, 587, 26, 267, 870, 480, 7692, 26, 450, 83, 2414, 530, 13, 3220, 2, 450, 334, 736, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 11845, 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, 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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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 ]
ytjiang/django
tests/utils_tests/test_duration.py
364
1677
import datetime import unittest from django.utils.dateparse import parse_duration from django.utils.duration import duration_string class TestDurationString(unittest.TestCase): def test_simple(self): duration = datetime.timedelta(hours=1, minutes=3, seconds=5) self.assertEqual(duration_string(duration), '01:03:05') def test_days(self): duration = datetime.timedelta(days=1, hours=1, minutes=3, seconds=5) self.assertEqual(duration_string(duration), '1 01:03:05') def test_microseconds(self): duration = datetime.timedelta(hours=1, minutes=3, seconds=5, microseconds=12345) self.assertEqual(duration_string(duration), '01:03:05.012345') def test_negative(self): duration = datetime.timedelta(days=-1, hours=1, minutes=3, seconds=5) self.assertEqual(duration_string(duration), '-1 01:03:05') class TestParseDurationRoundtrip(unittest.TestCase): def test_simple(self): duration = datetime.timedelta(hours=1, minutes=3, seconds=5) self.assertEqual(parse_duration(duration_string(duration)), duration) def test_days(self): duration = datetime.timedelta(days=1, hours=1, minutes=3, seconds=5) self.assertEqual(parse_duration(duration_string(duration)), duration) def test_microseconds(self): duration = datetime.timedelta(hours=1, minutes=3, seconds=5, microseconds=12345) self.assertEqual(parse_duration(duration_string(duration)), duration) def test_negative(self): duration = datetime.timedelta(days=-1, hours=1, minutes=3, seconds=5) self.assertEqual(parse_duration(duration_string(duration)), duration)
bsd-3-clause
[ 646, 2197, 199, 646, 2882, 199, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 5553, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 421, 199, 533, 1379, 13283, 1558, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 614, 26, 1644, 26, 1717, 358, 339, 347, 511, 63, 4899, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 29, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 17, 17163, 26, 1644, 26, 1717, 358, 339, 347, 511, 63, 18144, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 12, 21574, 29, 13261, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 614, 26, 1644, 26, 1717, 14, 9461, 21, 358, 339, 347, 511, 63, 7371, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 4022, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 2475, 17, 17163, 26, 1644, 26, 1717, 358, 421, 199, 533, 1379, 4003, 13283, 18579, 7254, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 4899, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 29, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 18144, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 12, 21574, 29, 13261, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 7371, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 4022, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 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 ]
[ 2197, 199, 646, 2882, 199, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 2198, 63, 5553, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 421, 199, 533, 1379, 13283, 1558, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 614, 26, 1644, 26, 1717, 358, 339, 347, 511, 63, 4899, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 29, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 17, 17163, 26, 1644, 26, 1717, 358, 339, 347, 511, 63, 18144, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 12, 21574, 29, 13261, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 283, 614, 26, 1644, 26, 1717, 14, 9461, 21, 358, 339, 347, 511, 63, 7371, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 4022, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 5553, 63, 875, 8, 5553, 395, 2475, 17, 17163, 26, 1644, 26, 1717, 358, 421, 199, 533, 1379, 4003, 13283, 18579, 7254, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 4899, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 29, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 18144, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 8419, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 12, 21574, 29, 13261, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 9, 339, 347, 511, 63, 7371, 8, 277, 304, 267, 7373, 275, 2197, 14, 7473, 8, 4899, 4022, 17, 12, 10857, 29, 17, 12, 9395, 29, 19, 12, 4696, 29, 21, 9, 267, 291, 14, 629, 8, 1122, 63, 5553, 8, 5553, 63, 875, 8, 5553, 1826, 7373, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
spacecaker/android_kernel_acer_swing_msm8960_3.4.6
scripts/gcc-wrapper.py
501
3410
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * 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. # * Neither the name of Code Aurora nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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. # Invoke gcc, looking for warnings, and causing a failure if there are # non-whitelisted warnings. import errno import re import os import sys import subprocess # Note that gcc uses unicode, which may depend on the locale. TODO: # force LANG to be set to en_US.UTF-8 to get consistent warnings. allowed_warnings = set([ "alignment.c:327", "mmu.c:602", "return_address.c:62", ]) # Capture the name of the object file, can find it. ofile = None warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''') def interpret_warning(line): """Decode the message from gcc. The messages we care about have a filename, and a warning""" line = line.rstrip('\n') m = warning_re.match(line) if m and m.group(2) not in allowed_warnings: print "error, forbidden warning:", m.group(2) # If there is a warning, remove any object if it exists. if ofile: try: os.remove(ofile) except OSError: pass sys.exit(1) def run_gcc(): args = sys.argv[1:] # Look for -o try: i = args.index('-o') global ofile ofile = args[i+1] except (ValueError, IndexError): pass compiler = sys.argv[0] try: proc = subprocess.Popen(args, stderr=subprocess.PIPE) for line in proc.stderr: print line, interpret_warning(line) result = proc.wait() except OSError as e: result = e.errno if result == errno.ENOENT: print args[0] + ':',e.strerror print 'Is your PATH set correctly?' else: print ' '.join(args), str(e) return result if __name__ == '__main__': status = run_gcc() sys.exit(status)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 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, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2004, 275, 1255, 63, 13112, 342, 272, 984, 14, 2224, 8, 1205, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 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, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2004, 275, 1255, 63, 13112, 342, 272, 984, 14, 2224, 8, 1205, 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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 0, 0, 0 ]
jlew/Web2Py-Inventory
languages/pl.py
16
4832
# coding: utf8 { '"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"Uaktualnij" jest dodatkowym wyra\xc5\xbceniem postaci "pole1=\'nowawarto\xc5\x9b\xc4\x87\'". Nie mo\xc5\xbcesz uaktualni\xc4\x87 lub usun\xc4\x85\xc4\x87 wynik\xc3\xb3w z JOIN:', '%Y-%m-%d': '%Y-%m-%d', '%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S', '%s rows deleted': 'Wierszy usuni\xc4\x99tych: %s', '%s rows updated': 'Wierszy uaktualnionych: %s', 'Authentication': 'Uwierzytelnienie', 'Available databases and tables': 'Dost\xc4\x99pne bazy danych i tabele', 'Cannot be empty': 'Nie mo\xc5\xbce by\xc4\x87 puste', 'Change Password': 'Zmie\xc5\x84 has\xc5\x82o', 'Check to delete': 'Zaznacz aby usun\xc4\x85\xc4\x87', 'Check to delete:': 'Zaznacz aby usun\xc4\x85\xc4\x87:', 'Client IP': 'IP klienta', 'Controller': 'Kontroler', 'Copyright': 'Copyright', 'Current request': 'Aktualne \xc5\xbc\xc4\x85danie', 'Current response': 'Aktualna odpowied\xc5\xba', 'Current session': 'Aktualna sesja', 'DB Model': 'Model bazy danych', 'Database': 'Baza danych', 'Delete:': 'Usu\xc5\x84:', 'Description': 'Opis', 'E-mail': 'Adres e-mail', 'Edit': 'Edycja', 'Edit Profile': 'Edytuj profil', 'Edit This App': 'Edytuj t\xc4\x99 aplikacj\xc4\x99', 'Edit current record': 'Edytuj obecny rekord', 'First name': 'Imi\xc4\x99', 'Function disabled': 'Funkcja wy\xc5\x82\xc4\x85czona', 'Group ID': 'ID grupy', 'Hello World': 'Witaj \xc5\x9awiecie', 'Import/Export': 'Importuj/eksportuj', 'Index': 'Indeks', 'Internal State': 'Stan wewn\xc4\x99trzny', 'Invalid Query': 'B\xc5\x82\xc4\x99dne zapytanie', 'Invalid email': 'B\xc5\x82\xc4\x99dny adres email', 'Last name': 'Nazwisko', 'Layout': 'Uk\xc5\x82ad', 'Login': 'Zaloguj', 'Logout': 'Wyloguj', 'Lost Password': 'Przypomnij has\xc5\x82o', 'Main Menu': 'Menu g\xc5\x82\xc3\xb3wne', 'Menu Model': 'Model menu', 'Name': 'Nazwa', 'New Record': 'Nowy rekord', 'No databases in this application': 'Brak baz danych w tej aplikacji', 'Origin': '\xc5\xb9r\xc3\xb3d\xc5\x82o', 'Password': 'Has\xc5\x82o', "Password fields don't match": 'Pola has\xc5\x82a nie s\xc4\x85 zgodne ze sob\xc4\x85', 'Powered by': 'Zasilane przez', 'Query:': 'Zapytanie:', 'Record ID': 'ID rekordu', 'Register': 'Zarejestruj', 'Registration key': 'Klucz rejestracji', 'Role': 'Rola', 'Rows in table': 'Wiersze w tabeli', 'Rows selected': 'Wybrane wiersze', 'Stylesheet': 'Arkusz styl\xc3\xb3w', 'Submit': 'Wy\xc5\x9blij', 'Sure you want to delete this object?': 'Czy na pewno chcesz usun\xc4\x85\xc4\x87 ten obiekt?', 'Table name': 'Nazwa tabeli', 'The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.': '"Zapytanie" jest warunkiem postaci "db.tabela1.pole1==\'warto\xc5\x9b\xc4\x87\'". Takie co\xc5\x9b jak "db.tabela1.pole1==db.tabela2.pole2" oznacza SQL JOIN.', 'Timestamp': 'Znacznik czasu', 'Update:': 'Uaktualnij:', 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'U\xc5\xbcyj (...)&(...) jako AND, (...)|(...) jako OR oraz ~(...) jako NOT do tworzenia bardziej skomplikowanych zapyta\xc5\x84.', 'User %(id)s Registered': 'U\xc5\xbcytkownik %(id)s zosta\xc5\x82 zarejestrowany', 'User ID': 'ID u\xc5\xbcytkownika', 'Verify Password': 'Potwierd\xc5\xba has\xc5\x82o', 'View': 'Widok', 'Welcome %s': 'Welcome %s', 'Welcome to web2py': 'Witaj w web2py', 'appadmin is disabled because insecure channel': 'administracja aplikacji wy\xc5\x82\xc4\x85czona z powodu braku bezpiecznego po\xc5\x82\xc4\x85czenia', 'cache': 'cache', 'change password': 'change password', 'click here for online examples': 'Kliknij aby przej\xc5\x9b\xc4\x87 do interaktywnych przyk\xc5\x82ad\xc3\xb3w', 'click here for the administrative interface': 'Kliknij aby przej\xc5\x9b\xc4\x87 do panelu administracyjnego', 'customize me!': 'dostosuj mnie!', 'data uploaded': 'dane wys\xc5\x82ane', 'database': 'baza danych', 'database %s select': 'wyb\xc3\xb3r z bazy danych %s', 'db': 'baza danych', 'design': 'projektuj', 'done!': 'zrobione!', 'edit profile': 'edit profile', 'export as csv file': 'eksportuj jako plik csv', 'insert new': 'wstaw nowy rekord tabeli', 'insert new %s': 'wstaw nowy rekord do tabeli %s', 'invalid request': 'B\xc5\x82\xc4\x99dne \xc5\xbc\xc4\x85danie', 'login': 'login', 'logout': 'logout', 'new record inserted': 'nowy rekord zosta\xc5\x82 wstawiony', 'next 100 rows': 'nast\xc4\x99pne 100 wierszy', 'or import from csv file': 'lub zaimportuj z pliku csv', 'previous 100 rows': 'poprzednie 100 wierszy', 'record': 'rekord', 'record does not exist': 'rekord nie istnieje', 'record id': 'id rekordu', 'register': 'register', 'selected': 'wybranych', 'state': 'stan', 'table': 'tabela', 'unable to parse csv file': 'nie mo\xc5\xbcna sparsowa\xc4\x87 pliku csv', }
gpl-3.0
[ 3, 2803, 26, 2774, 24, 199, 91, 199, 4065, 873, 2, 365, 376, 2716, 3965, 2839, 298, 698, 17, 25641, 1222, 585, 3985, 1674, 2047, 3913, 1678, 503, 3145, 314, 2058, 402, 282, 10593, 356, 5522, 53, 1151, 1688, 78, 7879, 2, 1335, 597, 366, 364, 292, 75, 583, 12828, 336, 89, 345, 60, 1812, 21, 60, 1774, 2497, 1873, 77, 2963, 22832, 298, 25903, 17, 25641, 2131, 65, 3281, 475, 60, 1812, 21, 60, 88, 25, 66, 60, 1812, 20, 60, 88, 1555, 3985, 1674, 653, 1873, 1303, 60, 1812, 21, 60, 1774, 823, 90, 399, 1151, 1688, 8445, 60, 1812, 20, 60, 88, 1555, 634, 456, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 336, 1236, 3258, 60, 1812, 19, 60, 1774, 19, 87, 1315, 10593, 6536, 199, 5956, 57, 3295, 77, 3295, 68, 356, 1543, 57, 3295, 77, 3295, 68, 297, 199, 5956, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 356, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 199, 5956, 83, 4730, 5463, 356, 283, 55, 73, 1192, 3605, 2739, 5411, 60, 1812, 20, 60, 88, 1020, 369, 335, 26, 450, 83, 297, 199, 5956, 83, 4730, 4588, 356, 283, 55, 73, 1192, 3605, 399, 1151, 1688, 78, 1636, 89, 335, 26, 450, 83, 297, 199, 7, 10348, 356, 283, 53, 87, 4446, 3605, 266, 6066, 24555, 1873, 297, 199, 7, 11464, 16219, 436, 6716, 356, 283, 36, 941, 60, 1812, 20, 60, 88, 1020, 80, 685, 19325, 3605, 366, 1629, 335, 284, 5174, 8081, 297, 199, 7, 6612, 506, 2701, 356, 283, 46, 1873, 1303, 60, 1812, 21, 60, 1774, 301, 701, 60, 1812, 20, 60, 88, 1555, 299, 527, 266, 297, 199, 7, 4001, 13635, 356, 283, 26467, 1873, 60, 1812, 21, 60, 88, 1349, 965, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 1799, 370, 3145, 356, 283, 58, 4651, 78, 645, 90, 282, 991, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 297, 199, 7, 1799, 370, 3145, 25156, 283, 58, 4651, 78, 645, 90, 282, 991, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 6536, 199, 7, 3041, 3531, 356, 283, 1772, 1022, 864, 65, 297, 199, 7, 7506, 356, 283, 43, 265, 1374, 1435, 297, 199, 7, 7384, 356, 283, 7384, 297, 199, 7, 5639, 1056, 356, 283, 33, 75, 1688, 685, 971, 1812, 21, 60, 10323, 60, 1812, 20, 60, 88, 2426, 24863, 1873, 297, 199, 7, 5639, 1177, 356, 283, 33, 75, 1688, 3540, 14467, 8278, 5299, 60, 1812, 21, 60, 10539, 297, 199, 7, 5639, 2351, 356, 283, 33, 75, 1688, 3540, 2217, 3387, 297, 199, 7, 2846, 5822, 356, 283, 1685, 19325, 3605, 366, 1629, 335, 297, 199, 7, 7243, 356, 283, 19726, 65, 366, 1629, 335, 297, 199, 7, 5392, 25156, 283, 53, 9648, 60, 1812, 21, 60, 88, 1349, 6536, 199, 7, 5831, 356, 283, 4619, 374, 297, 199, 7, 37, 13, 1198, 356, 283, 2767, 470, 325, 13, 1198, 297, 199, 7, 4685, 356, 283, 37, 8161, 67, 3387, 297, 199, 7, 4685, 14386, 356, 283, 37, 8161, 10963, 74, 557, 1289, 297, 199, 7, 4685, 961, 4693, 356, 283, 37, 8161, 10963, 74, 307, 60, 1812, 20, 60, 88, 1020, 2771, 317, 75, 645, 74, 60, 1812, 20, 60, 88, 1020, 297, 199, 7, 4685, 1453, 2777, 356, 283, 37, 8161, 10963, 74, 2607, 825, 9745, 295, 75, 2181, 297, 199, 7, 7147, 536, 356, 283, 41, 2664, 60, 1812, 20, 60, 88, 1020, 297, 199, 7, 3481, 6980, 356, 283, 38, 1778, 67, 3387, 336, 89, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 2426, 67, 8384, 65, 297, 199, 7, 2448, 2870, 356, 283, 998, 486, 5505, 89, 297, 199, 7, 6257, 13064, 356, 283, 55, 390, 9091, 971, 1812, 21, 60, 88, 25, 10084, 1873, 559, 69, 297, 199, 7, 6295, 15, 11399, 356, 283, 6295, 17189, 15, 5711, 3275, 17189, 297, 199, 7, 2681, 356, 283, 607, 271, 6080, 297, 199, 7, 8405, 8511, 356, 283, 933, 290, 336, 546, 78, 60, 1812, 20, 60, 88, 1020, 454, 90, 9745, 297, 199, 7, 3364, 8133, 356, 283, 34, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 1020, 68, 685, 1315, 439, 89, 12990, 1873, 297, 199, 7, 3364, 3031, 356, 283, 34, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 1020, 4272, 89, 1503, 470, 3031, 297, 199, 7, 6090, 536, 356, 283, 46, 4651, 87, 374, 7697, 297, 199, 7, 4798, 356, 283, 53, 75, 60, 1812, 21, 60, 88, 2564, 350, 297, 199, 7, 8880, 356, 283, 58, 2548, 17189, 297, 199, 7, 2445, 548, 356, 283, 55, 89, 793, 17189, 297, 199, 7, 14074, 13635, 356, 283, 9779, 3605, 555, 10344, 7879, 965, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 6756, 18281, 356, 283, 5977, 486, 60, 1812, 21, 60, 88, 2564, 60, 1812, 19, 60, 1774, 19, 87, 685, 297, 199, 7, 5977, 5822, 356, 283, 1685, 6269, 297, 199, 7, 985, 356, 283, 46, 4651, 758, 297, 199, 7, 4665, 12651, 356, 283, 14351, 89, 295, 75, 2181, 297, 199, 7, 1944, 16219, 315, 642, 4223, 356, 283, 17171, 75, 15507, 366, 1629, 335, 336, 1565, 74, 2771, 317, 75, 645, 8047, 297, 199, 7, 12834, 356, 1557, 1812, 21, 60, 1774, 25, 82, 60, 1812, 19, 60, 1774, 19, 68, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 6139, 356, 283, 6362, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 2, 6139, 1504, 2793, 1133, 1336, 582, 283, 5858, 65, 965, 60, 1812, 21, 60, 88, 2564, 65, 302, 1873, 308, 60, 1812, 20, 60, 88, 2426, 1315, 71, 364, 685, 29986, 880, 66, 60, 1812, 20, 60, 88, 2426, 297, 199, 7, 23432, 16179, 701, 356, 283, 58, 305, 382, 5865, 5448, 806, 90, 297, 199, 7, 3227, 25156, 283, 58, 439, 89, 12990, 1873, 6536, 199, 7, 5433, 2870, 356, 283, 998, 295, 75, 269, 2033, 297, 199, 7, 7099 ]
[ 2803, 26, 2774, 24, 199, 91, 199, 4065, 873, 2, 365, 376, 2716, 3965, 2839, 298, 698, 17, 25641, 1222, 585, 3985, 1674, 2047, 3913, 1678, 503, 3145, 314, 2058, 402, 282, 10593, 356, 5522, 53, 1151, 1688, 78, 7879, 2, 1335, 597, 366, 364, 292, 75, 583, 12828, 336, 89, 345, 60, 1812, 21, 60, 1774, 2497, 1873, 77, 2963, 22832, 298, 25903, 17, 25641, 2131, 65, 3281, 475, 60, 1812, 21, 60, 88, 25, 66, 60, 1812, 20, 60, 88, 1555, 3985, 1674, 653, 1873, 1303, 60, 1812, 21, 60, 1774, 823, 90, 399, 1151, 1688, 8445, 60, 1812, 20, 60, 88, 1555, 634, 456, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 336, 1236, 3258, 60, 1812, 19, 60, 1774, 19, 87, 1315, 10593, 6536, 199, 5956, 57, 3295, 77, 3295, 68, 356, 1543, 57, 3295, 77, 3295, 68, 297, 199, 5956, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 356, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 199, 5956, 83, 4730, 5463, 356, 283, 55, 73, 1192, 3605, 2739, 5411, 60, 1812, 20, 60, 88, 1020, 369, 335, 26, 450, 83, 297, 199, 5956, 83, 4730, 4588, 356, 283, 55, 73, 1192, 3605, 399, 1151, 1688, 78, 1636, 89, 335, 26, 450, 83, 297, 199, 7, 10348, 356, 283, 53, 87, 4446, 3605, 266, 6066, 24555, 1873, 297, 199, 7, 11464, 16219, 436, 6716, 356, 283, 36, 941, 60, 1812, 20, 60, 88, 1020, 80, 685, 19325, 3605, 366, 1629, 335, 284, 5174, 8081, 297, 199, 7, 6612, 506, 2701, 356, 283, 46, 1873, 1303, 60, 1812, 21, 60, 1774, 301, 701, 60, 1812, 20, 60, 88, 1555, 299, 527, 266, 297, 199, 7, 4001, 13635, 356, 283, 26467, 1873, 60, 1812, 21, 60, 88, 1349, 965, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 1799, 370, 3145, 356, 283, 58, 4651, 78, 645, 90, 282, 991, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 297, 199, 7, 1799, 370, 3145, 25156, 283, 58, 4651, 78, 645, 90, 282, 991, 2739, 324, 60, 1812, 20, 60, 88, 2426, 60, 1812, 20, 60, 88, 1555, 6536, 199, 7, 3041, 3531, 356, 283, 1772, 1022, 864, 65, 297, 199, 7, 7506, 356, 283, 43, 265, 1374, 1435, 297, 199, 7, 7384, 356, 283, 7384, 297, 199, 7, 5639, 1056, 356, 283, 33, 75, 1688, 685, 971, 1812, 21, 60, 10323, 60, 1812, 20, 60, 88, 2426, 24863, 1873, 297, 199, 7, 5639, 1177, 356, 283, 33, 75, 1688, 3540, 14467, 8278, 5299, 60, 1812, 21, 60, 10539, 297, 199, 7, 5639, 2351, 356, 283, 33, 75, 1688, 3540, 2217, 3387, 297, 199, 7, 2846, 5822, 356, 283, 1685, 19325, 3605, 366, 1629, 335, 297, 199, 7, 7243, 356, 283, 19726, 65, 366, 1629, 335, 297, 199, 7, 5392, 25156, 283, 53, 9648, 60, 1812, 21, 60, 88, 1349, 6536, 199, 7, 5831, 356, 283, 4619, 374, 297, 199, 7, 37, 13, 1198, 356, 283, 2767, 470, 325, 13, 1198, 297, 199, 7, 4685, 356, 283, 37, 8161, 67, 3387, 297, 199, 7, 4685, 14386, 356, 283, 37, 8161, 10963, 74, 557, 1289, 297, 199, 7, 4685, 961, 4693, 356, 283, 37, 8161, 10963, 74, 307, 60, 1812, 20, 60, 88, 1020, 2771, 317, 75, 645, 74, 60, 1812, 20, 60, 88, 1020, 297, 199, 7, 4685, 1453, 2777, 356, 283, 37, 8161, 10963, 74, 2607, 825, 9745, 295, 75, 2181, 297, 199, 7, 7147, 536, 356, 283, 41, 2664, 60, 1812, 20, 60, 88, 1020, 297, 199, 7, 3481, 6980, 356, 283, 38, 1778, 67, 3387, 336, 89, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 2426, 67, 8384, 65, 297, 199, 7, 2448, 2870, 356, 283, 998, 486, 5505, 89, 297, 199, 7, 6257, 13064, 356, 283, 55, 390, 9091, 971, 1812, 21, 60, 88, 25, 10084, 1873, 559, 69, 297, 199, 7, 6295, 15, 11399, 356, 283, 6295, 17189, 15, 5711, 3275, 17189, 297, 199, 7, 2681, 356, 283, 607, 271, 6080, 297, 199, 7, 8405, 8511, 356, 283, 933, 290, 336, 546, 78, 60, 1812, 20, 60, 88, 1020, 454, 90, 9745, 297, 199, 7, 3364, 8133, 356, 283, 34, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 1020, 68, 685, 1315, 439, 89, 12990, 1873, 297, 199, 7, 3364, 3031, 356, 283, 34, 60, 1812, 21, 60, 88, 2564, 60, 1812, 20, 60, 88, 1020, 4272, 89, 1503, 470, 3031, 297, 199, 7, 6090, 536, 356, 283, 46, 4651, 87, 374, 7697, 297, 199, 7, 4798, 356, 283, 53, 75, 60, 1812, 21, 60, 88, 2564, 350, 297, 199, 7, 8880, 356, 283, 58, 2548, 17189, 297, 199, 7, 2445, 548, 356, 283, 55, 89, 793, 17189, 297, 199, 7, 14074, 13635, 356, 283, 9779, 3605, 555, 10344, 7879, 965, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 6756, 18281, 356, 283, 5977, 486, 60, 1812, 21, 60, 88, 2564, 60, 1812, 19, 60, 1774, 19, 87, 685, 297, 199, 7, 5977, 5822, 356, 283, 1685, 6269, 297, 199, 7, 985, 356, 283, 46, 4651, 758, 297, 199, 7, 4665, 12651, 356, 283, 14351, 89, 295, 75, 2181, 297, 199, 7, 1944, 16219, 315, 642, 4223, 356, 283, 17171, 75, 15507, 366, 1629, 335, 336, 1565, 74, 2771, 317, 75, 645, 8047, 297, 199, 7, 12834, 356, 1557, 1812, 21, 60, 1774, 25, 82, 60, 1812, 19, 60, 1774, 19, 68, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 7, 6139, 356, 283, 6362, 60, 1812, 21, 60, 88, 2564, 79, 297, 199, 2, 6139, 1504, 2793, 1133, 1336, 582, 283, 5858, 65, 965, 60, 1812, 21, 60, 88, 2564, 65, 302, 1873, 308, 60, 1812, 20, 60, 88, 2426, 1315, 71, 364, 685, 29986, 880, 66, 60, 1812, 20, 60, 88, 2426, 297, 199, 7, 23432, 16179, 701, 356, 283, 58, 305, 382, 5865, 5448, 806, 90, 297, 199, 7, 3227, 25156, 283, 58, 439, 89, 12990, 1873, 6536, 199, 7, 5433, 2870, 356, 283, 998, 295, 75, 269, 2033, 297, 199, 7, 7099, 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, 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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 ]
randyli/beauty-cpp
template/cgi-bin/menu.py
1
3251
#!/usr/bin/python # -*- coding:utf-8 -*- import cgi print "Content-Type: text/html\n\n" projects = [ ('/memcached/', 'memcached') ] form = cgi.FieldStorage() directory = '' if form.has_key('dir'): directory = form['dir'].value if directory == '/': print '<ul class="jqueryFileTree" style="display: none;">', print '<li class="directory collapsed"><a href="#" rel="/memcached/">memcached</a></li>' print '</ul>' elif directory == '/memcached/': print '<ul class="jqueryFileTree" style="display: none;">', print '<li class="file ext_h"><a href="/data/__assoc_h.html" rel="/memcached/__assoc_h.html" target="content">assoc.h</a></li>' print '<li class="file ext_c"><a href="/data/assoc_c.html" rel="/memcached/assoc_c.html" target="content">assoc.c</a></li>' print '<li class="file ext_h"><a href="/data/__cache_h.html" rel="/memcached/__cache_h.html" target="content">cache.h</a></li>' print '<li class="file ext_c"><a href="/data/cache_c.html" rel="/memcached/cache_c.html" target="content">cache.c</a></li>' print '<li class="file ext_c"><a href="/data/daemon_c.html" rel="/memcached/daemon_c.html" target="content">daemon.c</a></li>' print '<li class="file ext_h"><a href="/data/__hash_h.html" rel="/memcached/__hash_h.html" target="content">hash.h</a></li>' print '<li class="file ext_c"><a href="/data/hash_c.html" rel="/memcached/hash_c.html" target="content">hash.c</a></li>' print '<li class="file ext_h"><a href="/data/__items_h.html" rel="/memcached/__items_h.html" target="content">items.h</a></li>' print '<li class="file ext_c"><a href="/data/items_c.html" rel="/memcached/items_c.html" target="content">items.c</a></li>' print '<li class="file ext_h"><a href="/data/__memcached_h.html" rel="/memcached/__memcached_h.html" target="content">memcached.h</a></li>' print '<li class="file ext_c"><a href="/data/memcached_c.html" rel="/memcached/memcached_c.html" target="content">memcached.c</a></li>' print '<li class="file ext_c"><a href="/data/sasl_defs_c.html" rel="/memcached/sasl_defs_c.html" target="content">sasl_defs.c</a></li>' print '<li class="file ext_c"><a href="/data/sizes_c.html" rel="/memcached/sizes_c.html" target="content">sizes.c</a></li>' print '<li class="file ext_h"><a href="/data/__slabs_h.html" rel="/memcached/__slabs_h.html" target="content">slabs.h</a></li>' print '<li class="file ext_c"><a href="/data/slabs_c.html" rel="/memcached/slabs_c.html" target="content">slabs.c</a></li>' print '<li class="file ext_h"><a href="/data/__stats_c.html" rel="/memcached/__stats_h.html" target="content">stats.h</a></li>' print '<li class="file ext_c"><a href="/data/stats_c.html" rel="/memcached/stats_c.html" target="content">stats.c</a></li>' print '<li class="file ext_c"><a href="/data/thread_c.html" rel="/memcached/thread_c.html" target="content">thread.c</a></li>' print '<li class="file ext_c"><a href="/data/timed_c.html" rel="/memcached/timedrun_c.html" target="content">timedrun.c</a></li>' print '<li class="file ext_h"><a href="/data/__util_c.html" rel="/memcached/__util_h.html" target="content">util.h</a></li>' print '<li class="file ext_c"><a href="/data/utile_c.html" rel="/memcached/util_c.html" target="content">util.c</a></li>' print '</ul>'
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 1624, 13, 24, 1882, 199, 646, 16004, 199, 1361, 298, 2714, 13, 804, 26, 1318, 15, 1360, 60, 78, 60, 78, 2, 199, 199, 6776, 275, 359, 199, 198, 2336, 32567, 3678, 283, 32567, 358, 199, 61, 199, 199, 964, 275, 16004, 14, 792, 6408, 342, 199, 199, 3619, 275, 2125, 199, 692, 1824, 14, 1989, 63, 498, 360, 694, 735, 199, 198, 3619, 275, 1824, 459, 694, 2278, 585, 9948, 199, 692, 2082, 508, 20549, 523, 870, 2650, 348, 1021, 628, 22324, 1173, 3987, 2, 3449, 628, 2918, 26, 7179, 31328, 297, 523, 870, 2650, 317, 1021, 628, 3619, 31219, 8186, 65, 4369, 13476, 2, 4668, 9555, 32567, 26049, 32567, 1108, 65, 2957, 317, 3524, 523, 870, 11936, 348, 3524, 199, 199, 4164, 2082, 508, 1994, 32567, 25772, 523, 870, 2650, 348, 1021, 628, 22324, 1173, 3987, 2, 3449, 628, 2918, 26, 7179, 31328, 297, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 16824, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 16824, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 16824, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 16824, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 16824, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 16824, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 1637, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 1637, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 1637, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 1637, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 1637, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 1637, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 10824, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 10824, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 10824, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 2227, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 2227, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 2227, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2227, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2227, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2227, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 1744, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 1744, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 1744, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 1744, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 1744, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 1744, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 32567, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 32567, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 32567, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 32567, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 32567, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 32567, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 22601, 76, 63, 8710, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 22601, 76, 63, 8710, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 22601, 76, 63, 8710, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 7723, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 7723, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 7723, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 2482, 2101, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 2482, 2101, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 2482, 2101, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2482, 2101, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2482, 2101, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2482, 2101, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 3200, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 22128, 3200, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 3200, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 3200, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 3200, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 3200, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2671, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2671, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2671, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 26687, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 26687, 1065, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 26687, 1065, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 1624, 13, 24, 1882, 199, 646, 16004, 199, 1361, 298, 2714, 13, 804, 26, 1318, 15, 1360, 60, 78, 60, 78, 2, 199, 199, 6776, 275, 359, 199, 198, 2336, 32567, 3678, 283, 32567, 358, 199, 61, 199, 199, 964, 275, 16004, 14, 792, 6408, 342, 199, 199, 3619, 275, 2125, 199, 692, 1824, 14, 1989, 63, 498, 360, 694, 735, 199, 198, 3619, 275, 1824, 459, 694, 2278, 585, 9948, 199, 692, 2082, 508, 20549, 523, 870, 2650, 348, 1021, 628, 22324, 1173, 3987, 2, 3449, 628, 2918, 26, 7179, 31328, 297, 523, 870, 2650, 317, 1021, 628, 3619, 31219, 8186, 65, 4369, 13476, 2, 4668, 9555, 32567, 26049, 32567, 1108, 65, 2957, 317, 3524, 523, 870, 11936, 348, 3524, 199, 199, 4164, 2082, 508, 1994, 32567, 25772, 523, 870, 2650, 348, 1021, 628, 22324, 1173, 3987, 2, 3449, 628, 2918, 26, 7179, 31328, 297, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 16824, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 16824, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 16824, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 16824, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 16824, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 16824, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 1637, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 1637, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 1637, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 1637, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 1637, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 1637, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 10824, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 10824, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 10824, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 2227, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 2227, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 2227, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2227, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2227, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2227, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 1744, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 1744, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 1744, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 1744, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 1744, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 1744, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 32567, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 32567, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 32567, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 32567, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 32567, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 32567, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 22601, 76, 63, 8710, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 22601, 76, 63, 8710, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 22601, 76, 63, 8710, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 7723, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 7723, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 7723, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 2482, 2101, 63, 72, 14, 1360, 2, 4668, 9555, 32567, 22128, 2482, 2101, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 2482, 2101, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2482, 2101, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2482, 2101, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2482, 2101, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 576, 22128, 3200, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 22128, 3200, 63, 72, 14, 1360, 2, 1347, 628, 1317, 1743, 3200, 14, 72, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 3200, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 3200, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 3200, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 2671, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 2671, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 2671, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 67, 8186, 65, 4369, 9555, 576, 15, 26687, 63, 67, 14, 1360, 2, 4668, 9555, 32567, 15, 26687, 1065, 63, 67, 14, 1360, 2, 1347, 628, 1317, 1743, 26687, 1065, 14, 67, 1108, 65, 2957, 317, 3524, 523, 870, 2650, 317, 1021, 628, 493, 1599, 63, 72, 8186, 65, 4369, 9555, 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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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 ]
chrisdunelm/grpc
src/python/grpcio_tests/tests/unit/beta/_utilities_test.py
22
3382
# Copyright 2015 gRPC authors. # # 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 of grpc.beta.utilities.""" import threading import time import unittest from grpc.beta import implementations from grpc.beta import utilities from grpc.framework.foundation import future from tests.unit.framework.common import test_constants class _Callback(object): def __init__(self): self._condition = threading.Condition() self._value = None def accept_value(self, value): with self._condition: self._value = value self._condition.notify_all() def block_until_called(self): with self._condition: while self._value is None: self._condition.wait() return self._value class ChannelConnectivityTest(unittest.TestCase): def test_lonely_channel_connectivity(self): channel = implementations.insecure_channel('localhost', 12345) callback = _Callback() ready_future = utilities.channel_ready_future(channel) ready_future.add_done_callback(callback.accept_value) with self.assertRaises(future.TimeoutError): ready_future.result(timeout=test_constants.SHORT_TIMEOUT) self.assertFalse(ready_future.cancelled()) self.assertFalse(ready_future.done()) self.assertTrue(ready_future.running()) ready_future.cancel() value_passed_to_callback = callback.block_until_called() self.assertIs(ready_future, value_passed_to_callback) self.assertTrue(ready_future.cancelled()) self.assertTrue(ready_future.done()) self.assertFalse(ready_future.running()) def test_immediately_connectable_channel_connectivity(self): server = implementations.server({}) port = server.add_insecure_port('[::]:0') server.start() channel = implementations.insecure_channel('localhost', port) callback = _Callback() try: ready_future = utilities.channel_ready_future(channel) ready_future.add_done_callback(callback.accept_value) self.assertIsNone( ready_future.result(timeout=test_constants.LONG_TIMEOUT)) value_passed_to_callback = callback.block_until_called() self.assertIs(ready_future, value_passed_to_callback) self.assertFalse(ready_future.cancelled()) self.assertTrue(ready_future.done()) self.assertFalse(ready_future.running()) # Cancellation after maturity has no effect. ready_future.cancel() self.assertFalse(ready_future.cancelled()) self.assertTrue(ready_future.done()) self.assertFalse(ready_future.running()) finally: ready_future.cancel() server.stop(0) if __name__ == '__main__': unittest.main(verbosity=2)
apache-2.0
[ 3, 1898, 6900, 30700, 11462, 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, 402, 19753, 14, 5683, 14, 16355, 1041, 199, 199, 646, 5796, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 19753, 14, 5683, 492, 12591, 199, 504, 19753, 14, 5683, 492, 15841, 199, 504, 19753, 14, 4857, 14, 4214, 425, 492, 6466, 199, 504, 2295, 14, 3248, 14, 4857, 14, 2330, 492, 511, 63, 5559, 421, 199, 533, 485, 2806, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 5394, 275, 5796, 14, 9558, 342, 267, 291, 423, 585, 275, 488, 339, 347, 4729, 63, 585, 8, 277, 12, 574, 304, 267, 543, 291, 423, 5394, 26, 288, 291, 423, 585, 275, 574, 288, 291, 423, 5394, 14, 6814, 63, 452, 342, 339, 347, 1853, 63, 8111, 63, 3527, 8, 277, 304, 267, 543, 291, 423, 5394, 26, 288, 1830, 291, 423, 585, 365, 488, 26, 355, 291, 423, 5394, 14, 2573, 342, 288, 372, 291, 423, 585, 421, 199, 533, 17270, 714, 13498, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 5298, 7742, 63, 2775, 63, 22344, 8, 277, 304, 267, 3623, 275, 12591, 14, 24824, 63, 2775, 360, 5967, 297, 25538, 9, 267, 3233, 275, 485, 2806, 342, 398, 10144, 63, 2443, 275, 15841, 14, 2775, 63, 2179, 63, 2443, 8, 2775, 9, 267, 10144, 63, 2443, 14, 525, 63, 4456, 63, 3058, 8, 3058, 14, 5694, 63, 585, 9, 267, 543, 291, 14, 1855, 8, 2443, 14, 19382, 304, 288, 10144, 63, 2443, 14, 1099, 8, 2593, 29, 396, 63, 5559, 14, 13003, 63, 8899, 9, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 4456, 1012, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 5720, 1012, 267, 10144, 63, 2443, 14, 6406, 342, 267, 574, 63, 12070, 63, 475, 63, 3058, 275, 3233, 14, 1457, 63, 8111, 63, 3527, 342, 267, 291, 14, 3436, 8, 2179, 63, 2443, 12, 574, 63, 12070, 63, 475, 63, 3058, 9, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 21924, 1012, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 339, 347, 511, 63, 20250, 590, 63, 2242, 461, 63, 2775, 63, 22344, 8, 277, 304, 267, 1654, 275, 12591, 14, 1000, 14079, 267, 1844, 275, 1654, 14, 525, 63, 24824, 63, 719, 360, 10345, 2189, 16, 358, 267, 1654, 14, 928, 342, 267, 3623, 275, 12591, 14, 24824, 63, 2775, 360, 5967, 297, 1844, 9, 267, 3233, 275, 485, 2806, 342, 398, 862, 26, 288, 10144, 63, 2443, 275, 15841, 14, 2775, 63, 2179, 63, 2443, 8, 2775, 9, 288, 10144, 63, 2443, 14, 525, 63, 4456, 63, 3058, 8, 3058, 14, 5694, 63, 585, 9, 288, 291, 14, 7702, 8, 355, 10144, 63, 2443, 14, 1099, 8, 2593, 29, 396, 63, 5559, 14, 12375, 63, 8899, 430, 288, 574, 63, 12070, 63, 475, 63, 3058, 275, 3233, 14, 1457, 63, 8111, 63, 3527, 342, 288, 291, 14, 3436, 8, 2179, 63, 2443, 12, 574, 63, 12070, 63, 475, 63, 3058, 9, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 288, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 288, 327, 28374, 2212, 2410, 2530, 5581, 965, 949, 7763, 14, 288, 10144, 63, 2443, 14, 6406, 342, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 288, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 267, 3753, 26, 288, 10144, 63, 2443, 14, 6406, 342, 288, 1654, 14, 2379, 8, 16, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 9833, 29, 18, 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 ]
[ 1898, 6900, 30700, 11462, 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, 402, 19753, 14, 5683, 14, 16355, 1041, 199, 199, 646, 5796, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 19753, 14, 5683, 492, 12591, 199, 504, 19753, 14, 5683, 492, 15841, 199, 504, 19753, 14, 4857, 14, 4214, 425, 492, 6466, 199, 504, 2295, 14, 3248, 14, 4857, 14, 2330, 492, 511, 63, 5559, 421, 199, 533, 485, 2806, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 5394, 275, 5796, 14, 9558, 342, 267, 291, 423, 585, 275, 488, 339, 347, 4729, 63, 585, 8, 277, 12, 574, 304, 267, 543, 291, 423, 5394, 26, 288, 291, 423, 585, 275, 574, 288, 291, 423, 5394, 14, 6814, 63, 452, 342, 339, 347, 1853, 63, 8111, 63, 3527, 8, 277, 304, 267, 543, 291, 423, 5394, 26, 288, 1830, 291, 423, 585, 365, 488, 26, 355, 291, 423, 5394, 14, 2573, 342, 288, 372, 291, 423, 585, 421, 199, 533, 17270, 714, 13498, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 5298, 7742, 63, 2775, 63, 22344, 8, 277, 304, 267, 3623, 275, 12591, 14, 24824, 63, 2775, 360, 5967, 297, 25538, 9, 267, 3233, 275, 485, 2806, 342, 398, 10144, 63, 2443, 275, 15841, 14, 2775, 63, 2179, 63, 2443, 8, 2775, 9, 267, 10144, 63, 2443, 14, 525, 63, 4456, 63, 3058, 8, 3058, 14, 5694, 63, 585, 9, 267, 543, 291, 14, 1855, 8, 2443, 14, 19382, 304, 288, 10144, 63, 2443, 14, 1099, 8, 2593, 29, 396, 63, 5559, 14, 13003, 63, 8899, 9, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 4456, 1012, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 5720, 1012, 267, 10144, 63, 2443, 14, 6406, 342, 267, 574, 63, 12070, 63, 475, 63, 3058, 275, 3233, 14, 1457, 63, 8111, 63, 3527, 342, 267, 291, 14, 3436, 8, 2179, 63, 2443, 12, 574, 63, 12070, 63, 475, 63, 3058, 9, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 21924, 1012, 267, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 267, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 339, 347, 511, 63, 20250, 590, 63, 2242, 461, 63, 2775, 63, 22344, 8, 277, 304, 267, 1654, 275, 12591, 14, 1000, 14079, 267, 1844, 275, 1654, 14, 525, 63, 24824, 63, 719, 360, 10345, 2189, 16, 358, 267, 1654, 14, 928, 342, 267, 3623, 275, 12591, 14, 24824, 63, 2775, 360, 5967, 297, 1844, 9, 267, 3233, 275, 485, 2806, 342, 398, 862, 26, 288, 10144, 63, 2443, 275, 15841, 14, 2775, 63, 2179, 63, 2443, 8, 2775, 9, 288, 10144, 63, 2443, 14, 525, 63, 4456, 63, 3058, 8, 3058, 14, 5694, 63, 585, 9, 288, 291, 14, 7702, 8, 355, 10144, 63, 2443, 14, 1099, 8, 2593, 29, 396, 63, 5559, 14, 12375, 63, 8899, 430, 288, 574, 63, 12070, 63, 475, 63, 3058, 275, 3233, 14, 1457, 63, 8111, 63, 3527, 342, 288, 291, 14, 3436, 8, 2179, 63, 2443, 12, 574, 63, 12070, 63, 475, 63, 3058, 9, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 288, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 288, 327, 28374, 2212, 2410, 2530, 5581, 965, 949, 7763, 14, 288, 10144, 63, 2443, 14, 6406, 342, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 21924, 1012, 288, 291, 14, 1815, 8, 2179, 63, 2443, 14, 4456, 1012, 288, 291, 14, 3334, 8, 2179, 63, 2443, 14, 5720, 1012, 267, 3753, 26, 288, 10144, 63, 2443, 14, 6406, 342, 288, 1654, 14, 2379, 8, 16, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 9833, 29, 18, 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, 0 ]
[ 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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the Lessons content type. """ from zope.interface import implements from Products.Archetypes import atapi from Products.ATContentTypes.content import folder from Products.ATContentTypes.content.schemata import finalizeATCTSchema from eduintelligent.courses.interfaces import ICourseContent from eduintelligent.courses.config import PROJECTNAME from eduintelligent.courses.utility import hideMetadataSchema from eduintelligent.courses import coursesMessageFactory as _ CourseContentSchema = folder.ATFolderSchema.copy() CourseContentSchema['title'].storage = atapi.AnnotationStorage() CourseContentSchema['description'].storage = atapi.AnnotationStorage() finalizeATCTSchema(CourseContentSchema, folderish=True, moveDiscussion=False) hideMetadataSchema(CourseContentSchema, excludeFromNav=True) class CourseContent(folder.ATFolder): """Contains multiple lessons. """ implements(ICourseContent) portal_type = "CourseContent" _at_rename_after_creation = True schema = CourseContentSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') atapi.registerType(CourseContent, PROJECTNAME)
gpl-3.0
[ 624, 10701, 402, 314, 7005, 385, 4654, 1564, 730, 14, 199, 624, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 504, 32411, 14, 1596, 595, 1313, 492, 737, 1246, 199, 199, 504, 32411, 14, 619, 2714, 4100, 14, 1317, 492, 4922, 199, 504, 32411, 14, 619, 2714, 4100, 14, 1317, 14, 83, 24448, 419, 492, 17284, 619, 1028, 6700, 199, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 7436, 492, 473, 6979, 2714, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 888, 492, 21915, 2339, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 16877, 492, 13714, 5142, 6700, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 492, 13588, 2209, 2927, 465, 485, 199, 199, 6979, 2714, 6700, 275, 4922, 14, 619, 7850, 6700, 14, 1574, 342, 199, 199, 6979, 2714, 6700, 459, 1213, 2278, 3494, 275, 737, 1246, 14, 16768, 6408, 342, 199, 6979, 2714, 6700, 459, 1802, 2278, 3494, 275, 737, 1246, 14, 16768, 6408, 342, 199, 199, 14450, 619, 1028, 6700, 8, 6979, 2714, 6700, 12, 1699, 9910, 609, 29, 549, 12, 4057, 31410, 29, 797, 9, 199, 8191, 5142, 6700, 8, 6979, 2714, 6700, 12, 5760, 2532, 31488, 29, 549, 9, 199, 199, 533, 5531, 2714, 8, 3741, 14, 619, 7850, 304, 272, 408, 6906, 3663, 6656, 4654, 14, 272, 408, 272, 9031, 8, 948, 4010, 2714, 9, 2286, 18428, 63, 466, 275, 298, 6979, 2714, 2, 272, 485, 292, 63, 8165, 63, 4399, 63, 8782, 275, 715, 272, 4177, 275, 5531, 2714, 6700, 2286, 2538, 275, 737, 1246, 14, 619, 792, 3697, 360, 1213, 358, 272, 1369, 275, 737, 1246, 14, 619, 792, 3697, 360, 1802, 358, 199, 199, 419, 1038, 14, 2683, 804, 8, 6979, 2714, 12, 21915, 2339, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10701, 402, 314, 7005, 385, 4654, 1564, 730, 14, 199, 624, 199, 199, 504, 20110, 14, 3266, 492, 9031, 199, 199, 504, 32411, 14, 1596, 595, 1313, 492, 737, 1246, 199, 199, 504, 32411, 14, 619, 2714, 4100, 14, 1317, 492, 4922, 199, 504, 32411, 14, 619, 2714, 4100, 14, 1317, 14, 83, 24448, 419, 492, 17284, 619, 1028, 6700, 199, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 7436, 492, 473, 6979, 2714, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 888, 492, 21915, 2339, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 14, 16877, 492, 13714, 5142, 6700, 199, 504, 325, 2033, 5707, 24024, 14, 11653, 492, 13588, 2209, 2927, 465, 485, 199, 199, 6979, 2714, 6700, 275, 4922, 14, 619, 7850, 6700, 14, 1574, 342, 199, 199, 6979, 2714, 6700, 459, 1213, 2278, 3494, 275, 737, 1246, 14, 16768, 6408, 342, 199, 6979, 2714, 6700, 459, 1802, 2278, 3494, 275, 737, 1246, 14, 16768, 6408, 342, 199, 199, 14450, 619, 1028, 6700, 8, 6979, 2714, 6700, 12, 1699, 9910, 609, 29, 549, 12, 4057, 31410, 29, 797, 9, 199, 8191, 5142, 6700, 8, 6979, 2714, 6700, 12, 5760, 2532, 31488, 29, 549, 9, 199, 199, 533, 5531, 2714, 8, 3741, 14, 619, 7850, 304, 272, 408, 6906, 3663, 6656, 4654, 14, 272, 408, 272, 9031, 8, 948, 4010, 2714, 9, 2286, 18428, 63, 466, 275, 298, 6979, 2714, 2, 272, 485, 292, 63, 8165, 63, 4399, 63, 8782, 275, 715, 272, 4177, 275, 5531, 2714, 6700, 2286, 2538, 275, 737, 1246, 14, 619, 792, 3697, 360, 1213, 358, 272, 1369, 275, 737, 1246, 14, 619, 792, 3697, 360, 1802, 358, 199, 199, 419, 1038, 14, 2683, 804, 8, 6979, 2714, 12, 21915, 2339, 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, 32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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 ]
Antiun/project
project_functional_block/__openerp__.py
22
1475
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2010 Akretion LDTA (<http://www.akretion.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## {'name': 'Project requiring functional blocks', 'version': '1.2', 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'www.akretion.com', 'license': 'AGPL-3', 'category': 'Generic Modules', 'description': """ Adds functional blocks to organize the projects tasks. """, 'depends': [ 'project', ], 'data': [ 'security/ir.model.access.csv', 'project_view.xml', ], 'demo': [ 'project_demo.xml', ], 'installable': False, 'application': True, }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7129, 437, 75, 264, 296, 16978, 6166, 8642, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 1445, 354, 356, 283, 4761, 29963, 22380, 5664, 297, 199, 283, 1023, 356, 283, 17, 14, 18, 297, 199, 283, 2502, 356, 298, 33, 75, 264, 296, 12, 47, 16766, 7046, 6639, 24207, 425, 334, 47, 3263, 4186, 199, 283, 7360, 356, 283, 1544, 14, 1151, 264, 296, 14, 957, 297, 199, 283, 1682, 356, 283, 1254, 2749, 13, 19, 297, 199, 283, 3710, 356, 283, 9417, 18167, 297, 199, 283, 1802, 356, 408, 199, 14995, 22380, 5664, 370, 20765, 794, 314, 11336, 6527, 14, 199, 10327, 199, 283, 8912, 356, 359, 1362, 283, 1715, 297, 199, 2156, 199, 283, 576, 356, 359, 1362, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 1362, 283, 1715, 63, 1345, 14, 1652, 297, 199, 2156, 199, 283, 8768, 356, 359, 1362, 283, 1715, 63, 8768, 14, 1652, 297, 199, 2156, 199, 283, 21762, 356, 756, 12, 199, 283, 3578, 356, 715, 12, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7129, 437, 75, 264, 296, 16978, 6166, 8642, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 1445, 354, 356, 283, 4761, 29963, 22380, 5664, 297, 199, 283, 1023, 356, 283, 17, 14, 18, 297, 199, 283, 2502, 356, 298, 33, 75, 264, 296, 12, 47, 16766, 7046, 6639, 24207, 425, 334, 47, 3263, 4186, 199, 283, 7360, 356, 283, 1544, 14, 1151, 264, 296, 14, 957, 297, 199, 283, 1682, 356, 283, 1254, 2749, 13, 19, 297, 199, 283, 3710, 356, 283, 9417, 18167, 297, 199, 283, 1802, 356, 408, 199, 14995, 22380, 5664, 370, 20765, 794, 314, 11336, 6527, 14, 199, 10327, 199, 283, 8912, 356, 359, 1362, 283, 1715, 297, 199, 2156, 199, 283, 576, 356, 359, 1362, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 1362, 283, 1715, 63, 1345, 14, 1652, 297, 199, 2156, 199, 283, 8768, 356, 359, 1362, 283, 1715, 63, 8768, 14, 1652, 297, 199, 2156, 199, 283, 21762, 356, 756, 12, 199, 283, 3578, 356, 715, 12, 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, 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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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 ]
tkelman/utf8rewind
tools/gyp/test/subdirectory/gyptest-SYMROOT-all.py
102
1236
#!/usr/bin/env python # Copyright (c) 2009 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. """ Verifies building a target and a subsidiary dependent target from a .gyp file in a subdirectory, without specifying an explicit output build directory, and using the generated solution or project file at the top of the tree as the entry point. The configuration sets the Xcode SYMROOT variable and uses --depth= to make Xcode behave like the other build tools--that is, put all built targets in a single output build directory at the top of the tree. """ import TestGyp test = TestGyp.TestGyp() test.run_gyp('prog1.gyp', '-Dset_symroot=1', '--depth=.', chdir='src') test.relocate('src', 'relocate/src') # Suppress the test infrastructure's setting SYMROOT on the command line. test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') test.run_built_executable('prog1', stdout="Hello from prog1.c\n", chdir='relocate/src') test.run_built_executable('prog2', stdout="Hello from prog2.c\n", chdir='relocate/src') test.pass_test()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 8937, 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, 624, 199, 21168, 10015, 282, 1347, 436, 282, 1007, 338, 328, 695, 11410, 1347, 687, 282, 199, 14, 6179, 570, 315, 282, 25094, 12, 1928, 9176, 376, 5027, 1072, 1900, 199, 3619, 12, 436, 1808, 314, 4046, 8744, 503, 2199, 570, 737, 314, 2746, 199, 1618, 314, 3123, 465, 314, 2397, 2376, 14, 199, 199, 1918, 2897, 5951, 314, 10602, 10046, 45, 5441, 1750, 436, 4440, 1553, 4631, 29, 199, 475, 1852, 10602, 24062, 2839, 314, 1163, 1900, 7249, 306, 9099, 365, 12, 5324, 1006, 199, 11730, 4545, 315, 282, 2849, 1072, 1900, 2082, 737, 314, 2746, 402, 314, 3123, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2475, 36, 409, 63, 3840, 1231, 29, 17, 297, 2850, 4631, 29, 3130, 13097, 534, 2164, 358, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 511, 14, 1761, 12, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6595, 17, 297, 2079, 3839, 628, 6257, 687, 13205, 17, 14, 67, 60, 78, 401, 2079, 13097, 534, 18919, 15, 2164, 358, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6595, 18, 297, 2079, 3839, 628, 6257, 687, 13205, 18, 14, 67, 60, 78, 401, 2079, 13097, 534, 18919, 15, 2164, 358, 199, 199, 396, 14, 1529, 63, 396, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 1898, 334, 67, 9, 8937, 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, 624, 199, 21168, 10015, 282, 1347, 436, 282, 1007, 338, 328, 695, 11410, 1347, 687, 282, 199, 14, 6179, 570, 315, 282, 25094, 12, 1928, 9176, 376, 5027, 1072, 1900, 199, 3619, 12, 436, 1808, 314, 4046, 8744, 503, 2199, 570, 737, 314, 2746, 199, 1618, 314, 3123, 465, 314, 2397, 2376, 14, 199, 199, 1918, 2897, 5951, 314, 10602, 10046, 45, 5441, 1750, 436, 4440, 1553, 4631, 29, 199, 475, 1852, 10602, 24062, 2839, 314, 1163, 1900, 7249, 306, 9099, 365, 12, 5324, 1006, 199, 11730, 4545, 315, 282, 2849, 1072, 1900, 2082, 737, 314, 2746, 402, 314, 3123, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 396, 275, 25688, 14, 774, 13899, 342, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2475, 36, 409, 63, 3840, 1231, 29, 17, 297, 2850, 4631, 29, 3130, 13097, 534, 2164, 358, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 511, 14, 1761, 12, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6595, 17, 297, 2079, 3839, 628, 6257, 687, 13205, 17, 14, 67, 60, 78, 401, 2079, 13097, 534, 18919, 15, 2164, 358, 199, 396, 14, 1065, 63, 11730, 63, 5904, 360, 6595, 18, 297, 2079, 3839, 628, 6257, 687, 13205, 18, 14, 67, 60, 78, 401, 2079, 13097, 534, 18919, 15, 2164, 358, 199, 199, 396, 14, 1529, 63, 396, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
frankvdp/django
tests/i18n/test_compilation.py
15
7840
import gettext as gettext_module import os import stat import unittest from io import StringIO from subprocess import Popen from unittest import mock from django.core.management import ( CommandError, call_command, execute_from_command_line, ) from django.core.management.commands.makemessages import ( Command as MakeMessagesCommand, ) from django.core.management.utils import find_command from django.test import SimpleTestCase, override_settings from django.test.utils import captured_stderr, captured_stdout from django.utils import translation from django.utils.translation import gettext from .utils import RunInTmpDirMixin, copytree has_msgfmt = find_command('msgfmt') @unittest.skipUnless(has_msgfmt, 'msgfmt is mandatory for compilation tests') class MessageCompilationTests(RunInTmpDirMixin, SimpleTestCase): work_subdir = 'commands' class PoFileTests(MessageCompilationTests): LOCALE = 'es_AR' MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE def test_bom_rejection(self): stderr = StringIO() with self.assertRaisesMessage(CommandError, 'compilemessages generated one or more errors.'): call_command('compilemessages', locale=[self.LOCALE], stdout=StringIO(), stderr=stderr) self.assertIn('file has a BOM (Byte Order Mark)', stderr.getvalue()) self.assertFalse(os.path.exists(self.MO_FILE)) def test_no_write_access(self): mo_file_en = 'locale/en/LC_MESSAGES/django.mo' err_buffer = StringIO() # put file in read-only mode old_mode = os.stat(mo_file_en).st_mode os.chmod(mo_file_en, stat.S_IREAD) try: with self.assertRaisesMessage(CommandError, 'compilemessages generated one or more errors.'): call_command('compilemessages', locale=['en'], stderr=err_buffer, verbosity=0) self.assertIn('not writable location', err_buffer.getvalue()) finally: os.chmod(mo_file_en, old_mode) class PoFileContentsTests(MessageCompilationTests): # Ticket #11240 LOCALE = 'fr' MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE def test_percent_symbol_in_po_file(self): call_command('compilemessages', locale=[self.LOCALE], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE)) class MultipleLocaleCompilationTests(MessageCompilationTests): MO_FILE_HR = None MO_FILE_FR = None def setUp(self): super().setUp() localedir = os.path.join(self.test_dir, 'locale') self.MO_FILE_HR = os.path.join(localedir, 'hr/LC_MESSAGES/django.mo') self.MO_FILE_FR = os.path.join(localedir, 'fr/LC_MESSAGES/django.mo') def test_one_locale(self): with override_settings(LOCALE_PATHS=[os.path.join(self.test_dir, 'locale')]): call_command('compilemessages', locale=['hr'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) def test_multiple_locales(self): with override_settings(LOCALE_PATHS=[os.path.join(self.test_dir, 'locale')]): call_command('compilemessages', locale=['hr', 'fr'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE_HR)) self.assertTrue(os.path.exists(self.MO_FILE_FR)) class ExcludedLocaleCompilationTests(MessageCompilationTests): work_subdir = 'exclude' MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' def setUp(self): super().setUp() copytree('canned_locale', 'locale') def test_command_help(self): with captured_stdout(), captured_stderr(): # `call_command` bypasses the parser; by calling # `execute_from_command_line` with the help subcommand we # ensure that there are no issues with the parser itself. execute_from_command_line(['django-admin', 'help', 'compilemessages']) def test_one_locale_excluded(self): call_command('compilemessages', exclude=['it'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE % 'en')) self.assertTrue(os.path.exists(self.MO_FILE % 'fr')) self.assertFalse(os.path.exists(self.MO_FILE % 'it')) def test_multiple_locales_excluded(self): call_command('compilemessages', exclude=['it', 'fr'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE % 'en')) self.assertFalse(os.path.exists(self.MO_FILE % 'fr')) self.assertFalse(os.path.exists(self.MO_FILE % 'it')) def test_one_locale_excluded_with_locale(self): call_command('compilemessages', locale=['en', 'fr'], exclude=['fr'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE % 'en')) self.assertFalse(os.path.exists(self.MO_FILE % 'fr')) self.assertFalse(os.path.exists(self.MO_FILE % 'it')) def test_multiple_locales_excluded_with_locale(self): call_command('compilemessages', locale=['en', 'fr', 'it'], exclude=['fr', 'it'], stdout=StringIO()) self.assertTrue(os.path.exists(self.MO_FILE % 'en')) self.assertFalse(os.path.exists(self.MO_FILE % 'fr')) self.assertFalse(os.path.exists(self.MO_FILE % 'it')) class CompilationErrorHandling(MessageCompilationTests): def test_error_reported_by_msgfmt(self): # po file contains wrong po formatting. with self.assertRaises(CommandError): call_command('compilemessages', locale=['ja'], verbosity=0, stderr=StringIO()) def test_msgfmt_error_including_non_ascii(self): # po file contains invalid msgstr content (triggers non-ascii error content). # Make sure the output of msgfmt is unaffected by the current locale. env = os.environ.copy() env.update({'LANG': 'C'}) with mock.patch('django.core.management.utils.Popen', lambda *args, **kwargs: Popen(*args, env=env, **kwargs)): cmd = MakeMessagesCommand() if cmd.gettext_version < (0, 18, 3): self.skipTest("python-brace-format is a recent gettext addition.") stderr = StringIO() with self.assertRaisesMessage(CommandError, 'compilemessages generated one or more errors'): call_command('compilemessages', locale=['ko'], stdout=StringIO(), stderr=stderr) self.assertIn("' cannot start a field name", stderr.getvalue()) class ProjectAndAppTests(MessageCompilationTests): LOCALE = 'ru' PROJECT_MO_FILE = 'locale/%s/LC_MESSAGES/django.mo' % LOCALE APP_MO_FILE = 'app_with_locale/locale/%s/LC_MESSAGES/django.mo' % LOCALE class FuzzyTranslationTest(ProjectAndAppTests): def setUp(self): super().setUp() gettext_module._translations = {} # flush cache or test will be useless def test_nofuzzy_compiling(self): with override_settings(LOCALE_PATHS=[os.path.join(self.test_dir, 'locale')]): call_command('compilemessages', locale=[self.LOCALE], stdout=StringIO()) with translation.override(self.LOCALE): self.assertEqual(gettext('Lenin'), 'Ленин') self.assertEqual(gettext('Vodka'), 'Vodka') def test_fuzzy_compiling(self): with override_settings(LOCALE_PATHS=[os.path.join(self.test_dir, 'locale')]): call_command('compilemessages', locale=[self.LOCALE], fuzzy=True, stdout=StringIO()) with translation.override(self.LOCALE): self.assertEqual(gettext('Lenin'), 'Ленин') self.assertEqual(gettext('Vodka'), 'Водка') class AppCompilationTest(ProjectAndAppTests): def test_app_locale_compiled(self): call_command('compilemessages', locale=[self.LOCALE], stdout=StringIO()) self.assertTrue(os.path.exists(self.PROJECT_MO_FILE)) self.assertTrue(os.path.exists(self.APP_MO_FILE))
bsd-3-clause
[ 646, 9796, 465, 9796, 63, 578, 199, 646, 747, 199, 646, 5672, 199, 646, 2882, 199, 504, 5890, 492, 5228, 199, 504, 3873, 492, 13995, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 1018, 14, 8110, 492, 334, 272, 14393, 12, 1240, 63, 1531, 12, 5341, 63, 504, 63, 1531, 63, 604, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 8110, 14, 4405, 14, 1875, 3431, 492, 334, 272, 5817, 465, 4155, 14508, 3110, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1208, 492, 2342, 63, 1531, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 17487, 63, 3083, 12, 17487, 63, 2703, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 14, 6893, 492, 9796, 199, 199, 504, 1275, 1208, 492, 3378, 607, 52, 311, 3567, 4256, 12, 1331, 2350, 199, 199, 1989, 63, 1328, 5045, 275, 2342, 63, 1531, 360, 1328, 5045, 358, 421, 199, 32, 2796, 14, 11278, 8, 1989, 63, 1328, 5045, 12, 283, 1328, 5045, 365, 15230, 367, 18653, 2295, 358, 199, 533, 6430, 2404, 13696, 2925, 8, 2540, 607, 52, 311, 3567, 4256, 12, 24424, 304, 339, 1736, 63, 10622, 275, 283, 4405, 7, 421, 199, 533, 4376, 1173, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 20639, 37, 275, 283, 397, 63, 689, 7, 272, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 450, 20639, 37, 339, 347, 511, 63, 16302, 63, 264, 8923, 8, 277, 304, 267, 4635, 275, 5228, 342, 267, 543, 291, 14, 14638, 8, 31542, 12, 283, 2014, 3431, 4046, 1373, 503, 1655, 2552, 30194, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 1524, 277, 14, 20828, 467, 3839, 29, 6424, 1062, 4635, 29, 3083, 9, 267, 291, 14, 4080, 360, 493, 965, 282, 17720, 334, 4861, 9240, 7173, 3196, 4635, 14, 7150, 1012, 267, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 430, 339, 347, 511, 63, 889, 63, 952, 63, 2732, 8, 277, 304, 267, 1303, 63, 493, 63, 287, 275, 283, 5508, 15, 287, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 267, 2329, 63, 2738, 275, 5228, 342, 267, 327, 5324, 570, 315, 1586, 13, 2118, 818, 267, 2269, 63, 632, 275, 747, 14, 3736, 8, 573, 63, 493, 63, 287, 680, 270, 63, 632, 267, 747, 14, 11693, 8, 573, 63, 493, 63, 287, 12, 5672, 14, 51, 63, 41, 5670, 9, 267, 862, 26, 288, 543, 291, 14, 14638, 8, 31542, 12, 283, 2014, 3431, 4046, 1373, 503, 1655, 2552, 30194, 355, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 287, 995, 4635, 29, 1508, 63, 2738, 12, 8661, 29, 16, 9, 288, 291, 14, 4080, 360, 1397, 17267, 2909, 297, 2329, 63, 2738, 14, 7150, 1012, 267, 3753, 26, 288, 747, 14, 11693, 8, 573, 63, 493, 63, 287, 12, 2269, 63, 632, 9, 421, 199, 533, 4376, 1173, 11383, 2925, 8, 2209, 2404, 13696, 2925, 304, 272, 327, 21932, 327, 6094, 2167, 339, 20639, 37, 275, 283, 4391, 7, 272, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 450, 20639, 37, 339, 347, 511, 63, 7045, 63, 5155, 63, 262, 63, 555, 63, 493, 8, 277, 304, 267, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 1524, 277, 14, 20828, 467, 3839, 29, 6424, 1012, 267, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 430, 421, 199, 533, 14326, 20342, 2404, 13696, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 10362, 63, 3817, 63, 14784, 275, 488, 272, 10362, 63, 3817, 63, 5372, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 5867, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 267, 291, 14, 2679, 63, 3817, 63, 14784, 275, 747, 14, 515, 14, 904, 8, 5508, 694, 12, 283, 6271, 15, 7027, 63, 23229, 15, 1176, 14, 573, 358, 267, 291, 14, 2679, 63, 3817, 63, 5372, 275, 747, 14, 515, 14, 904, 8, 5508, 694, 12, 283, 4391, 15, 7027, 63, 23229, 15, 1176, 14, 573, 358, 339, 347, 511, 63, 368, 63, 5508, 8, 277, 304, 267, 543, 4278, 63, 1751, 8, 20828, 63, 20202, 1524, 736, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 4682, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 6271, 995, 3839, 29, 6424, 1012, 953, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 14784, 430, 339, 347, 511, 63, 6048, 63, 24763, 8, 277, 304, 267, 543, 4278, 63, 1751, 8, 20828, 63, 20202, 1524, 736, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 4682, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 6271, 297, 283, 4391, 995, 3839, 29, 6424, 1012, 953, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 14784, 430, 288, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 5372, 430, 421, 199, 533, 1316, 3331, 20342, 2404, 13696, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 1736, 63, 10622, 275, 283, 5473, 7, 339, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 1331, 2350, 360, 31126, 63, 5508, 297, 283, 5508, 358, 339, 347, 511, 63, 1531, 63, 3437, 8, 277, 304, 267, 543, 17487, 63, 2703, 1062, 17487, 63, 3083, 837, 288, 327, 658, 1250, 63, 1531, 64, 701, 16027, 314, 1798, 27, 701, 6358, 288, 327, 658, 2526, 63, 504, 63, 1531, 63, 604, 64, 543, 314, 1720, 21474, 781, 288, 327, 4868, 626, 2337, 787, 949, 10876, 543, 314, 1798, 6337, 14, 288, 5341, 63, 504, 63, 1531, 63, 604, 2941, 1176, 13, 2113, 297, 283, 3437, 297, 283, 2014 ]
[ 9796, 465, 9796, 63, 578, 199, 646, 747, 199, 646, 5672, 199, 646, 2882, 199, 504, 5890, 492, 5228, 199, 504, 3873, 492, 13995, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 1018, 14, 8110, 492, 334, 272, 14393, 12, 1240, 63, 1531, 12, 5341, 63, 504, 63, 1531, 63, 604, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 8110, 14, 4405, 14, 1875, 3431, 492, 334, 272, 5817, 465, 4155, 14508, 3110, 12, 199, 9, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1208, 492, 2342, 63, 1531, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 17487, 63, 3083, 12, 17487, 63, 2703, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 14, 6893, 492, 9796, 199, 199, 504, 1275, 1208, 492, 3378, 607, 52, 311, 3567, 4256, 12, 1331, 2350, 199, 199, 1989, 63, 1328, 5045, 275, 2342, 63, 1531, 360, 1328, 5045, 358, 421, 199, 32, 2796, 14, 11278, 8, 1989, 63, 1328, 5045, 12, 283, 1328, 5045, 365, 15230, 367, 18653, 2295, 358, 199, 533, 6430, 2404, 13696, 2925, 8, 2540, 607, 52, 311, 3567, 4256, 12, 24424, 304, 339, 1736, 63, 10622, 275, 283, 4405, 7, 421, 199, 533, 4376, 1173, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 20639, 37, 275, 283, 397, 63, 689, 7, 272, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 450, 20639, 37, 339, 347, 511, 63, 16302, 63, 264, 8923, 8, 277, 304, 267, 4635, 275, 5228, 342, 267, 543, 291, 14, 14638, 8, 31542, 12, 283, 2014, 3431, 4046, 1373, 503, 1655, 2552, 30194, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 1524, 277, 14, 20828, 467, 3839, 29, 6424, 1062, 4635, 29, 3083, 9, 267, 291, 14, 4080, 360, 493, 965, 282, 17720, 334, 4861, 9240, 7173, 3196, 4635, 14, 7150, 1012, 267, 291, 14, 3334, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 430, 339, 347, 511, 63, 889, 63, 952, 63, 2732, 8, 277, 304, 267, 1303, 63, 493, 63, 287, 275, 283, 5508, 15, 287, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 267, 2329, 63, 2738, 275, 5228, 342, 267, 327, 5324, 570, 315, 1586, 13, 2118, 818, 267, 2269, 63, 632, 275, 747, 14, 3736, 8, 573, 63, 493, 63, 287, 680, 270, 63, 632, 267, 747, 14, 11693, 8, 573, 63, 493, 63, 287, 12, 5672, 14, 51, 63, 41, 5670, 9, 267, 862, 26, 288, 543, 291, 14, 14638, 8, 31542, 12, 283, 2014, 3431, 4046, 1373, 503, 1655, 2552, 30194, 355, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 287, 995, 4635, 29, 1508, 63, 2738, 12, 8661, 29, 16, 9, 288, 291, 14, 4080, 360, 1397, 17267, 2909, 297, 2329, 63, 2738, 14, 7150, 1012, 267, 3753, 26, 288, 747, 14, 11693, 8, 573, 63, 493, 63, 287, 12, 2269, 63, 632, 9, 421, 199, 533, 4376, 1173, 11383, 2925, 8, 2209, 2404, 13696, 2925, 304, 272, 327, 21932, 327, 6094, 2167, 339, 20639, 37, 275, 283, 4391, 7, 272, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 450, 20639, 37, 339, 347, 511, 63, 7045, 63, 5155, 63, 262, 63, 555, 63, 493, 8, 277, 304, 267, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 1524, 277, 14, 20828, 467, 3839, 29, 6424, 1012, 267, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 430, 421, 199, 533, 14326, 20342, 2404, 13696, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 10362, 63, 3817, 63, 14784, 275, 488, 272, 10362, 63, 3817, 63, 5372, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 5867, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 267, 291, 14, 2679, 63, 3817, 63, 14784, 275, 747, 14, 515, 14, 904, 8, 5508, 694, 12, 283, 6271, 15, 7027, 63, 23229, 15, 1176, 14, 573, 358, 267, 291, 14, 2679, 63, 3817, 63, 5372, 275, 747, 14, 515, 14, 904, 8, 5508, 694, 12, 283, 4391, 15, 7027, 63, 23229, 15, 1176, 14, 573, 358, 339, 347, 511, 63, 368, 63, 5508, 8, 277, 304, 267, 543, 4278, 63, 1751, 8, 20828, 63, 20202, 1524, 736, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 4682, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 6271, 995, 3839, 29, 6424, 1012, 953, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 14784, 430, 339, 347, 511, 63, 6048, 63, 24763, 8, 277, 304, 267, 543, 4278, 63, 1751, 8, 20828, 63, 20202, 1524, 736, 14, 515, 14, 904, 8, 277, 14, 396, 63, 694, 12, 283, 5508, 358, 4682, 288, 1240, 63, 1531, 360, 2014, 3431, 297, 5867, 2968, 6271, 297, 283, 4391, 995, 3839, 29, 6424, 1012, 953, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 14784, 430, 288, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 2679, 63, 3817, 63, 5372, 430, 421, 199, 533, 1316, 3331, 20342, 2404, 13696, 2925, 8, 2209, 2404, 13696, 2925, 304, 339, 1736, 63, 10622, 275, 283, 5473, 7, 339, 10362, 63, 3817, 275, 283, 5508, 3149, 83, 15, 7027, 63, 23229, 15, 1176, 14, 573, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 1331, 2350, 360, 31126, 63, 5508, 297, 283, 5508, 358, 339, 347, 511, 63, 1531, 63, 3437, 8, 277, 304, 267, 543, 17487, 63, 2703, 1062, 17487, 63, 3083, 837, 288, 327, 658, 1250, 63, 1531, 64, 701, 16027, 314, 1798, 27, 701, 6358, 288, 327, 658, 2526, 63, 504, 63, 1531, 63, 604, 64, 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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 ]
pwarren/AGDeviceControl
agdevicecontrol/thirdparty/site-packages/darwin/twisted/python/logfile.py
3
7578
# -*- test-case-name: twisted.test.test_logfile -*- # Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. """ A rotating, browsable log file. """ # System Imports import os, stat, glob, string, time # sibling imports import threadable class BaseLogFile: """The base class for a log file that can be rotated. """ synchronized = ["write", "rotate"] def __init__(self, name, directory, defaultMode=None): self.directory = directory assert os.path.isdir(self.directory) self.name = name self.path = os.path.join(directory, name) if defaultMode is None and os.path.exists(self.path) and hasattr(os, "chmod"): self.defaultMode = os.stat(self.path)[0] else: self.defaultMode = defaultMode self._openFile() def shouldRotate(self): """Override with a method to that returns true if the log should be rotated""" raise NotImplementedError def _openFile(self): """Open the log file.""" self.closed = 0 if os.path.exists(self.path): self._file = open(self.path, "r+", 1) self._file.seek(0, 2) else: self._file = open(self.path, "w+", 1) # set umask to be same as original log file if self.defaultMode is not None: try: os.chmod(self.path, self.defaultMode) except OSError: # Probably /dev/null or something? pass def __getstate__(self): state = self.__dict__.copy() del state["_file"] return state def __setstate__(self, state): self.__dict__ = state self._openFile() def write(self, data): """Write some data to the file.""" if self.shouldRotate(): self.flush() self.rotate() self._file.write(data) def flush(self): """Flush the file.""" self._file.flush() def close(self): """Close the file. The file cannot be used once it has been closed. """ self.closed = 1 self._file.close() self._file = None def getCurrentLog(self): """Return a LogReader for the current log file.""" return LogReader(self.path) class LogFile(BaseLogFile): """A log file that can be rotated. A rotateLength of None disables automatic log rotation. """ def __init__(self, name, directory, rotateLength=1000000, defaultMode=None): BaseLogFile.__init__(self, name, directory, defaultMode) self.rotateLength = rotateLength def _openFile(self): BaseLogFile._openFile(self) self.size = self._file.tell() def shouldRotate(self): """Rotate when the log file size is larger than rotateLength""" return self.rotateLength and self.size >= self.rotateLength def getLog(self, identifier): """Given an integer, return a LogReader for an old log file.""" filename = "%s.%d" % (self.path, identifier) if not os.path.exists(filename): raise ValueError, "no such logfile exists" return LogReader(filename) def write(self, data): """Write some data to the file""" BaseLogFile.write(self, data) self.size += len(data) def rotate(self): """Rotate the file and create a new one. If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. """ if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return logs = self.listLogs() logs.reverse() for i in logs: os.rename("%s.%d" % (self.path, i), "%s.%d" % (self.path, i + 1)) self._file.close() os.rename(self.path, "%s.1" % self.path) self._openFile() def listLogs(self): """Return sorted list of integers - the old logs' identifiers.""" result = [] for name in glob.glob("%s.*" % self.path): try: counter = int(string.split(name, '.')[-1]) if counter: result.append(counter) except ValueError: pass result.sort() return result def __getstate__(self): state = BaseLogFile.__getstate__(self) del state["size"] return state threadable.synchronize(LogFile) class DailyLogFile(BaseLogFile): """A log file that is rotated daily (at or after midnight localtime) """ def _openFile(self): BaseLogFile._openFile(self) self.lastDate = self.toDate(os.stat(self.path)[8]) def shouldRotate(self): """Rotate when the date has changed since last write""" return self.toDate() > self.lastDate def toDate(self, *args): """Convert a unixtime to (year, month, day) localtime tuple, or return the current (year, month, day) localtime tuple. This function primarily exists so you may overload it with gmtime, or some cruft to make unit testing possible. """ # primarily so this can be unit tested easily return time.localtime(*args)[:3] def suffix(self, tupledate): """Return the suffix given a (year, month, day) tuple or unixtime""" try: return '_'.join(map(str, tupledate)) except: # try taking a float unixtime return '_'.join(map(str, self.toDate(tupledate))) def getLog(self, identifier): """Given a unix time, return a LogReader for an old log file.""" if self.toDate(identifier) == self.lastDate: return self.getCurrentLog() filename = "%s.%s" % (self.path, self.suffix(identifier)) if not os.path.exists(filename): raise ValueError, "no such logfile exists" return LogReader(filename) def write(self, data): """Write some data to the log file""" BaseLogFile.write(self, data) # Guard against a corner case where time.time() # could potentially run backwards to yesterday. # Primarily due to network time. self.lastDate = max(self.lastDate, self.toDate()) def rotate(self): """Rotate the file and create a new one. If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. """ if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return newpath = "%s.%s" % (self.path, self.suffix(self.lastDate)) if os.path.exists(newpath): return self._file.close() os.rename(self.path, newpath) self._openFile() def __getstate__(self): state = BaseLogFile.__getstate__(self) del state["lastDate"] return state threadable.synchronize(DailyLogFile) class LogReader: """Read from a log file.""" def __init__(self, name): self._file = open(name, "r") def readLines(self, lines=10): """Read a list of lines from the log file. This doesn't returns all of the files lines - call it multiple times. """ result = [] for i in range(lines): line = self._file.readline() if not line: break result.append(line) return result def close(self): self._file.close()
gpl-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 12804, 1882, 199, 199, 3, 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 33, 7513, 1958, 12, 330, 3838, 461, 943, 570, 14, 199, 624, 199, 199, 3, 6187, 24339, 199, 646, 747, 12, 5672, 12, 5739, 12, 1059, 12, 900, 199, 199, 3, 24238, 8925, 199, 199, 646, 2462, 461, 199, 199, 533, 3523, 19336, 26, 272, 408, 1918, 1300, 1021, 367, 282, 943, 570, 626, 883, 506, 7513, 972, 14, 272, 408, 339, 15354, 1759, 275, 2097, 952, 401, 298, 12873, 937, 2286, 347, 636, 826, 721, 277, 12, 536, 12, 2082, 12, 849, 1385, 29, 403, 304, 267, 291, 14, 3619, 275, 2082, 267, 702, 747, 14, 515, 14, 6027, 8, 277, 14, 3619, 9, 267, 291, 14, 354, 275, 536, 267, 291, 14, 515, 275, 747, 14, 515, 14, 904, 8, 3619, 12, 536, 9, 267, 340, 849, 1385, 365, 488, 436, 747, 14, 515, 14, 2444, 8, 277, 14, 515, 9, 436, 2688, 8, 736, 12, 298, 11693, 2349, 288, 291, 14, 885, 1385, 275, 747, 14, 3736, 8, 277, 14, 515, 2788, 16, 61, 267, 587, 26, 288, 291, 14, 885, 1385, 275, 849, 1385, 267, 291, 423, 1490, 1173, 342, 2286, 347, 1077, 32638, 8, 277, 304, 267, 408, 11954, 543, 282, 1083, 370, 626, 2529, 2549, 340, 314, 943, 4960, 1077, 506, 7513, 972, 624, 267, 746, 4279, 339, 347, 485, 1490, 1173, 8, 277, 304, 267, 408, 4299, 314, 943, 570, 1041, 267, 291, 14, 5938, 275, 378, 267, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 515, 304, 288, 291, 423, 493, 275, 1551, 8, 277, 14, 515, 12, 298, 82, 22758, 413, 9, 288, 291, 423, 493, 14, 5507, 8, 16, 12, 499, 9, 267, 587, 26, 288, 291, 423, 493, 275, 1551, 8, 277, 14, 515, 12, 298, 87, 22758, 413, 9, 267, 327, 663, 29812, 370, 506, 2011, 465, 3379, 943, 570, 267, 340, 291, 14, 885, 1385, 365, 440, 488, 26, 288, 862, 26, 355, 747, 14, 11693, 8, 277, 14, 515, 12, 291, 14, 885, 1385, 9, 288, 871, 6440, 26, 355, 327, 22770, 6665, 1182, 2374, 15, 2307, 503, 6020, 31, 355, 986, 2286, 347, 636, 16011, 721, 277, 304, 267, 1174, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 1174, 18524, 493, 937, 267, 372, 1174, 2286, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 855, 807, 363, 275, 1174, 267, 291, 423, 1490, 1173, 342, 2286, 347, 2218, 8, 277, 12, 666, 304, 267, 408, 3534, 2005, 666, 370, 314, 570, 1041, 267, 340, 291, 14, 5626, 32638, 837, 288, 291, 14, 4939, 342, 288, 291, 14, 12873, 342, 267, 291, 423, 493, 14, 952, 8, 576, 9, 2286, 347, 8976, 8, 277, 304, 267, 408, 20053, 314, 570, 1041, 267, 291, 423, 493, 14, 4939, 342, 2286, 347, 4002, 8, 277, 304, 267, 408, 4724, 314, 570, 14, 2728, 710, 570, 3913, 506, 1202, 5403, 652, 965, 2757, 6876, 14, 267, 408, 267, 291, 14, 5938, 275, 413, 267, 291, 423, 493, 14, 1600, 342, 267, 291, 423, 493, 275, 488, 2286, 347, 664, 5639, 2445, 8, 277, 304, 267, 408, 1767, 282, 5297, 5929, 367, 314, 1453, 943, 570, 1041, 267, 372, 5297, 5929, 8, 277, 14, 515, 9, 1362, 199, 533, 5297, 1173, 8, 1563, 19336, 304, 272, 408, 33, 943, 570, 626, 883, 506, 7513, 972, 14, 2286, 437, 20071, 4625, 402, 488, 28421, 4834, 943, 13038, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2082, 12, 20071, 4625, 29, 22589, 12, 849, 1385, 29, 403, 304, 267, 3523, 19336, 855, 826, 721, 277, 12, 536, 12, 2082, 12, 849, 1385, 9, 267, 291, 14, 12873, 4625, 275, 20071, 4625, 339, 347, 485, 1490, 1173, 8, 277, 304, 267, 3523, 19336, 423, 1490, 1173, 8, 277, 9, 267, 291, 14, 890, 275, 291, 423, 493, 14, 9974, 342, 5493, 347, 1077, 32638, 8, 277, 304, 267, 408, 32638, 1380, 314, 943, 570, 1568, 365, 12142, 2419, 20071, 4625, 624, 267, 372, 291, 14, 12873, 4625, 436, 291, 14, 890, 2356, 291, 14, 12873, 4625, 339, 347, 664, 2445, 8, 277, 12, 5148, 304, 267, 408, 13735, 376, 3000, 12, 372, 282, 5297, 5929, 367, 376, 2269, 943, 570, 1041, 267, 1788, 275, 2071, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 5148, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 746, 1722, 12, 298, 889, 4066, 17251, 3495, 2, 267, 372, 5297, 5929, 8, 1501, 9, 339, 347, 2218, 8, 277, 12, 666, 304, 267, 408, 3534, 2005, 666, 370, 314, 570, 624, 267, 3523, 19336, 14, 952, 8, 277, 12, 666, 9, 267, 291, 14, 890, 847, 822, 8, 576, 9, 339, 347, 20071, 8, 277, 304, 267, 408, 32638, 314, 570, 436, 1218, 282, 892, 1373, 14, 398, 982, 652, 1159, 440, 3962, 370, 1551, 892, 17251, 12, 642, 911, 2449, 18030, 12, 267, 436, 1980, 2050, 370, 2269, 17251, 14, 267, 408, 267, 340, 440, 334, 736, 14, 2732, 8, 277, 14, 3619, 12, 747, 14, 55, 63, 3593, 9, 436, 747, 14, 2732, 8, 277, 14, 515, 12, 747, 14, 55, 63, 3593, 2298, 288, 372, 267, 9610, 275, 291, 14, 513, 16333, 342, 267, 9610, 14, 4471, 342, 267, 367, 284, 315, 9610, 26, 288, 747, 14, 8165, 3647, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 284, 395, 2071, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 284, 435, 413, 430, 267, 291, 423, 493, 14, 1600, 342, 267, 747, 14, 8165, 8, 277, 14, 515, 12, 2071, 83, 14, 17, 2, 450, 291, 14, 515, 9, 267, 291, 423, 1490, 1173, 342, 339, 347, 769, 16333, 8, 277, 304, 267, 408, 1767, 3355, 769, 402, 9446, 446, 314, 2269, 9610, 7, 14154, 1041, 267, 754, 275, 942, 267, 367, 536, 315, 5739, 14, 6463, 3647, 83, 2795, 2, 450, 291, 14, 515, 304, 288, 862, 26, 355, 7055 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 12804, 1882, 199, 199, 3, 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 199, 33, 7513, 1958, 12, 330, 3838, 461, 943, 570, 14, 199, 624, 199, 199, 3, 6187, 24339, 199, 646, 747, 12, 5672, 12, 5739, 12, 1059, 12, 900, 199, 199, 3, 24238, 8925, 199, 199, 646, 2462, 461, 199, 199, 533, 3523, 19336, 26, 272, 408, 1918, 1300, 1021, 367, 282, 943, 570, 626, 883, 506, 7513, 972, 14, 272, 408, 339, 15354, 1759, 275, 2097, 952, 401, 298, 12873, 937, 2286, 347, 636, 826, 721, 277, 12, 536, 12, 2082, 12, 849, 1385, 29, 403, 304, 267, 291, 14, 3619, 275, 2082, 267, 702, 747, 14, 515, 14, 6027, 8, 277, 14, 3619, 9, 267, 291, 14, 354, 275, 536, 267, 291, 14, 515, 275, 747, 14, 515, 14, 904, 8, 3619, 12, 536, 9, 267, 340, 849, 1385, 365, 488, 436, 747, 14, 515, 14, 2444, 8, 277, 14, 515, 9, 436, 2688, 8, 736, 12, 298, 11693, 2349, 288, 291, 14, 885, 1385, 275, 747, 14, 3736, 8, 277, 14, 515, 2788, 16, 61, 267, 587, 26, 288, 291, 14, 885, 1385, 275, 849, 1385, 267, 291, 423, 1490, 1173, 342, 2286, 347, 1077, 32638, 8, 277, 304, 267, 408, 11954, 543, 282, 1083, 370, 626, 2529, 2549, 340, 314, 943, 4960, 1077, 506, 7513, 972, 624, 267, 746, 4279, 339, 347, 485, 1490, 1173, 8, 277, 304, 267, 408, 4299, 314, 943, 570, 1041, 267, 291, 14, 5938, 275, 378, 267, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 515, 304, 288, 291, 423, 493, 275, 1551, 8, 277, 14, 515, 12, 298, 82, 22758, 413, 9, 288, 291, 423, 493, 14, 5507, 8, 16, 12, 499, 9, 267, 587, 26, 288, 291, 423, 493, 275, 1551, 8, 277, 14, 515, 12, 298, 87, 22758, 413, 9, 267, 327, 663, 29812, 370, 506, 2011, 465, 3379, 943, 570, 267, 340, 291, 14, 885, 1385, 365, 440, 488, 26, 288, 862, 26, 355, 747, 14, 11693, 8, 277, 14, 515, 12, 291, 14, 885, 1385, 9, 288, 871, 6440, 26, 355, 327, 22770, 6665, 1182, 2374, 15, 2307, 503, 6020, 31, 355, 986, 2286, 347, 636, 16011, 721, 277, 304, 267, 1174, 275, 291, 855, 807, 4343, 1574, 342, 267, 2150, 1174, 18524, 493, 937, 267, 372, 1174, 2286, 347, 636, 17212, 721, 277, 12, 1174, 304, 267, 291, 855, 807, 363, 275, 1174, 267, 291, 423, 1490, 1173, 342, 2286, 347, 2218, 8, 277, 12, 666, 304, 267, 408, 3534, 2005, 666, 370, 314, 570, 1041, 267, 340, 291, 14, 5626, 32638, 837, 288, 291, 14, 4939, 342, 288, 291, 14, 12873, 342, 267, 291, 423, 493, 14, 952, 8, 576, 9, 2286, 347, 8976, 8, 277, 304, 267, 408, 20053, 314, 570, 1041, 267, 291, 423, 493, 14, 4939, 342, 2286, 347, 4002, 8, 277, 304, 267, 408, 4724, 314, 570, 14, 2728, 710, 570, 3913, 506, 1202, 5403, 652, 965, 2757, 6876, 14, 267, 408, 267, 291, 14, 5938, 275, 413, 267, 291, 423, 493, 14, 1600, 342, 267, 291, 423, 493, 275, 488, 2286, 347, 664, 5639, 2445, 8, 277, 304, 267, 408, 1767, 282, 5297, 5929, 367, 314, 1453, 943, 570, 1041, 267, 372, 5297, 5929, 8, 277, 14, 515, 9, 1362, 199, 533, 5297, 1173, 8, 1563, 19336, 304, 272, 408, 33, 943, 570, 626, 883, 506, 7513, 972, 14, 2286, 437, 20071, 4625, 402, 488, 28421, 4834, 943, 13038, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2082, 12, 20071, 4625, 29, 22589, 12, 849, 1385, 29, 403, 304, 267, 3523, 19336, 855, 826, 721, 277, 12, 536, 12, 2082, 12, 849, 1385, 9, 267, 291, 14, 12873, 4625, 275, 20071, 4625, 339, 347, 485, 1490, 1173, 8, 277, 304, 267, 3523, 19336, 423, 1490, 1173, 8, 277, 9, 267, 291, 14, 890, 275, 291, 423, 493, 14, 9974, 342, 5493, 347, 1077, 32638, 8, 277, 304, 267, 408, 32638, 1380, 314, 943, 570, 1568, 365, 12142, 2419, 20071, 4625, 624, 267, 372, 291, 14, 12873, 4625, 436, 291, 14, 890, 2356, 291, 14, 12873, 4625, 339, 347, 664, 2445, 8, 277, 12, 5148, 304, 267, 408, 13735, 376, 3000, 12, 372, 282, 5297, 5929, 367, 376, 2269, 943, 570, 1041, 267, 1788, 275, 2071, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 5148, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 746, 1722, 12, 298, 889, 4066, 17251, 3495, 2, 267, 372, 5297, 5929, 8, 1501, 9, 339, 347, 2218, 8, 277, 12, 666, 304, 267, 408, 3534, 2005, 666, 370, 314, 570, 624, 267, 3523, 19336, 14, 952, 8, 277, 12, 666, 9, 267, 291, 14, 890, 847, 822, 8, 576, 9, 339, 347, 20071, 8, 277, 304, 267, 408, 32638, 314, 570, 436, 1218, 282, 892, 1373, 14, 398, 982, 652, 1159, 440, 3962, 370, 1551, 892, 17251, 12, 642, 911, 2449, 18030, 12, 267, 436, 1980, 2050, 370, 2269, 17251, 14, 267, 408, 267, 340, 440, 334, 736, 14, 2732, 8, 277, 14, 3619, 12, 747, 14, 55, 63, 3593, 9, 436, 747, 14, 2732, 8, 277, 14, 515, 12, 747, 14, 55, 63, 3593, 2298, 288, 372, 267, 9610, 275, 291, 14, 513, 16333, 342, 267, 9610, 14, 4471, 342, 267, 367, 284, 315, 9610, 26, 288, 747, 14, 8165, 3647, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 284, 395, 2071, 83, 4111, 68, 2, 450, 334, 277, 14, 515, 12, 284, 435, 413, 430, 267, 291, 423, 493, 14, 1600, 342, 267, 747, 14, 8165, 8, 277, 14, 515, 12, 2071, 83, 14, 17, 2, 450, 291, 14, 515, 9, 267, 291, 423, 1490, 1173, 342, 339, 347, 769, 16333, 8, 277, 304, 267, 408, 1767, 3355, 769, 402, 9446, 446, 314, 2269, 9610, 7, 14154, 1041, 267, 754, 275, 942, 267, 367, 536, 315, 5739, 14, 6463, 3647, 83, 2795, 2, 450, 291, 14, 515, 304, 288, 862, 26, 355, 7055, 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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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 ]
Gazzonyx/samba
python/examples/netbios.py
66
1049
#!/usr/bin/env python # Unix SMB/CIFS implementation. # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 # # 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 samba.netbios import Node n = Node() (reply_from, names, addresses) = n.query_name("GANIEDA", "192.168.4.0", timeout=4) print "Received reply from %s:" % (reply_from, ) print "Names: %r" % (names, ) print "Addresses: %r" % (addresses, )
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 13074, 2389, 34, 15, 3553, 7079, 4514, 14, 199, 3, 1898, 334, 35, 9, 1603, 352, 2626, 5444, 889, 79, 7879, 665, 74, 352, 2626, 32, 21693, 14, 1308, 30, 9079, 199, 3, 259, 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, 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, 259, 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, 259, 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, 3, 199, 199, 504, 31710, 14, 846, 29673, 492, 5013, 199, 199, 78, 275, 5013, 342, 199, 8, 8102, 63, 504, 12, 1561, 12, 7149, 9, 275, 302, 14, 1131, 63, 354, 480, 39, 879, 29848, 33, 401, 298, 5756, 14, 6568, 14, 20, 14, 16, 401, 6343, 2653, 29, 20, 9, 199, 199, 1361, 298, 9392, 9351, 687, 450, 83, 5424, 450, 334, 8102, 63, 504, 12, 776, 199, 1361, 298, 5866, 26, 450, 82, 2, 450, 334, 1247, 12, 776, 199, 1361, 298, 20826, 26, 450, 82, 2, 450, 334, 7423, 12, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 13074, 2389, 34, 15, 3553, 7079, 4514, 14, 199, 3, 1898, 334, 35, 9, 1603, 352, 2626, 5444, 889, 79, 7879, 665, 74, 352, 2626, 32, 21693, 14, 1308, 30, 9079, 199, 3, 259, 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, 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, 259, 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, 259, 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, 3, 199, 199, 504, 31710, 14, 846, 29673, 492, 5013, 199, 199, 78, 275, 5013, 342, 199, 8, 8102, 63, 504, 12, 1561, 12, 7149, 9, 275, 302, 14, 1131, 63, 354, 480, 39, 879, 29848, 33, 401, 298, 5756, 14, 6568, 14, 20, 14, 16, 401, 6343, 2653, 29, 20, 9, 199, 199, 1361, 298, 9392, 9351, 687, 450, 83, 5424, 450, 334, 8102, 63, 504, 12, 776, 199, 1361, 298, 5866, 26, 450, 82, 2, 450, 334, 1247, 12, 776, 199, 1361, 298, 20826, 26, 450, 82, 2, 450, 334, 7423, 12, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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GHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Verify that expansion of construction variables whose values are lists works as expected within a $CPPPATH list definition. Previously, the stringification of the expansion of the individual variables would turn a list like ['sub1', 'sub2'] below into "-Isub1 sub2" on the command line. Test case courtesy Daniel Svensson. """ import TestSCons test = TestSCons.TestSCons() test.subdir('sub1', 'sub2', 'sub3', 'sub4') test.write('SConstruct', """\ class _inc_test(object): def __init__(self, name): self.name = name def __call__(self, target, source, env, for_signature): return env.something[self.name] env = Environment() env.something = {} env.something['test'] = ['sub1', 'sub2'] env['INC_PATHS1'] = _inc_test env['INC_PATHS2'] = ['sub3', 'sub4'] env.Append(CPPPATH = ['${INC_PATHS1("test")}', '$INC_PATHS2']) env.Program('test', 'test.c') """) test.write('test.c', """\ #include <stdio.h> #include <stdlib.h> #include "string1.h" #include "string2.h" #include "string3.h" #include "string4.h" int main(int argc, char *argv[]) { argv[argc++] = "--"; printf("test.c\\n"); printf("%s\\n", STRING1); printf("%s\\n", STRING2); printf("%s\\n", STRING3); printf("%s\\n", STRING4); exit (0); } """) test.write(['sub1', 'string1.h'], """\ #define STRING1 "sub1/string1.h" """) test.write(['sub2', 'string2.h'], """\ #define STRING2 "sub2/string2.h" """) test.write(['sub3', 'string3.h'], """\ #define STRING3 "sub3/string3.h" """) test.write(['sub4', 'string4.h'], """\ #define STRING4 "sub4/string4.h" """) test.run() test.up_to_date(arguments = '.') expect = """\ test.c sub1/string1.h sub2/string2.h sub3/string3.h sub4/string4.h """ test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) test.write(['sub2', 'string2.h'], """\ #define STRING2 "sub2/string2.h 2" """) test.not_up_to_date(arguments = '.') expect = """\ test.c sub1/string1.h sub2/string2.h 2 sub3/string3.h sub4/string4.h """ test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) test.pass_test() # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 636, 32324, 5716, 363, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 4396, 3817, 363, 636, 907, 18775, 363, 636, 5390, 363, 636, 1093, 2524, 1484, 4227, 16526, 199, 199, 624, 199, 7496, 626, 14819, 402, 14538, 2860, 7447, 1338, 787, 199, 6717, 5419, 465, 1420, 4453, 282, 2672, 14533, 3243, 769, 5492, 14, 199, 199, 18021, 590, 12, 314, 1059, 7313, 402, 314, 14819, 402, 314, 8212, 199, 3669, 3955, 7485, 282, 769, 2839, 788, 954, 17, 297, 283, 954, 18, 418, 5084, 1901, 3905, 41, 954, 17, 1007, 18, 2, 199, 265, 314, 1414, 1004, 14, 199, 199, 774, 1930, 512, 300, 744, 89, 24747, 14769, 428, 1856, 385, 265, 14, 199, 624, 199, 199, 646, 1379, 18521, 199, 199, 396, 275, 1379, 18521, 14, 774, 18521, 342, 199, 199, 396, 14, 10622, 360, 954, 17, 297, 283, 954, 18, 297, 283, 954, 19, 297, 283, 954, 20, 358, 199, 199, 396, 14, 952, 360, 51, 11493, 297, 9638, 199, 533, 485, 6559, 63, 396, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 636, 1250, 721, 277, 12, 1347, 12, 1350, 12, 2589, 12, 367, 63, 5233, 304, 267, 372, 2589, 14, 10297, 59, 277, 14, 354, 61, 199, 199, 1813, 275, 9711, 342, 199, 199, 1813, 14, 10297, 275, 1052, 199, 1813, 14, 10297, 459, 396, 418, 275, 788, 954, 17, 297, 283, 954, 18, 418, 199, 199, 1813, 459, 25205, 63, 20202, 17, 418, 275, 485, 6559, 63, 396, 199, 199, 1813, 459, 25205, 63, 20202, 18, 418, 275, 788, 954, 19, 297, 283, 954, 20, 418, 199, 199, 1813, 14, 8310, 8, 14533, 3243, 275, 788, 10545, 25205, 63, 20202, 17, 480, 396, 531, 7293, 4505, 25205, 63, 20202, 18, 1105, 199, 1813, 14, 9184, 360, 396, 297, 283, 396, 14, 67, 358, 199, 6141, 199, 199, 396, 14, 952, 360, 396, 14, 67, 297, 9638, 199, 3, 2613, 665, 32011, 14, 72, 30, 199, 3, 2613, 665, 28683, 14, 72, 30, 199, 3, 2613, 298, 875, 17, 14, 72, 2, 199, 3, 2613, 298, 875, 18, 14, 72, 2, 199, 3, 2613, 298, 875, 19, 14, 72, 2, 199, 3, 2613, 298, 875, 20, 14, 72, 2, 199, 199, 442, 199, 973, 8, 442, 1680, 67, 12, 1495, 627, 3020, 59, 566, 199, 91, 267, 9238, 59, 1273, 67, 4176, 61, 275, 4320, 11436, 267, 870, 70, 480, 396, 14, 67, 1103, 78, 3547, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 17, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 18, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 19, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 20, 2736, 267, 4458, 334, 16, 2736, 199, 93, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 17, 297, 283, 875, 17, 14, 72, 995, 9638, 199, 3, 4640, 18661, 17, 298, 954, 17, 15, 875, 17, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 18, 297, 283, 875, 18, 14, 72, 995, 9638, 199, 3, 4640, 18661, 18, 298, 954, 18, 15, 875, 18, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 19, 297, 283, 875, 19, 14, 72, 995, 9638, 199, 3, 4640, 18661, 19, 298, 954, 19, 15, 875, 19, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 20, 297, 283, 875, 20, 14, 72, 995, 9638, 199, 3, 4640, 18661, 20, 298, 954, 20, 15, 875, 20, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 1065, 342, 199, 199, 396, 14, 384, 63, 475, 63, 602, 8, 4958, 275, 20093, 199, 199, 4921, 275, 9638, 199, 396, 14, 67, 199, 954, 17, 15, 875, 17, 14, 72, 199, 954, 18, 15, 875, 18, 14, 72, 199, 954, 19, 15, 875, 19, 14, 72, 199, 954, 20, 15, 875, 20, 14, 72, 199, 624, 199, 199, 396, 14, 1065, 8, 6815, 275, 511, 14, 800, 515, 360, 396, 7, 435, 1379, 18521, 423, 5803, 395, 3839, 29, 4921, 9, 199, 199, 396, 14, 952, 2941, 954, 18, 297, 283, 875, 18, 14, 72, 995, 9638, 199, 3, 4640, 18661, 18, 298, 954, 18, 15, 875, 18, 14, 72, 499, 2, 199, 6141, 199, 199, 396, 14, 1397, 63, 384, 63, 475, 63, 602, 8, 4958, 275, 20093, 199, 199, 4921, 275, 9638, 199, 396, 14, 67, 199, 954, 17, 15, 875, 17, 14, 72, 199, 954, 18, 15, 875, 18, 14, 72, 499, 199, 954, 19, 15, 875, 19, 14, 72, 199, 954, 20, 15, 875, 20, 14, 72, 199, 624, 199, 199, 396, 14, 1065, 8, 6815, 275, 511, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 636, 32324, 5716, 363, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 4396, 3817, 363, 636, 907, 18775, 363, 636, 5390, 363, 636, 1093, 2524, 1484, 4227, 16526, 199, 199, 624, 199, 7496, 626, 14819, 402, 14538, 2860, 7447, 1338, 787, 199, 6717, 5419, 465, 1420, 4453, 282, 2672, 14533, 3243, 769, 5492, 14, 199, 199, 18021, 590, 12, 314, 1059, 7313, 402, 314, 14819, 402, 314, 8212, 199, 3669, 3955, 7485, 282, 769, 2839, 788, 954, 17, 297, 283, 954, 18, 418, 5084, 1901, 3905, 41, 954, 17, 1007, 18, 2, 199, 265, 314, 1414, 1004, 14, 199, 199, 774, 1930, 512, 300, 744, 89, 24747, 14769, 428, 1856, 385, 265, 14, 199, 624, 199, 199, 646, 1379, 18521, 199, 199, 396, 275, 1379, 18521, 14, 774, 18521, 342, 199, 199, 396, 14, 10622, 360, 954, 17, 297, 283, 954, 18, 297, 283, 954, 19, 297, 283, 954, 20, 358, 199, 199, 396, 14, 952, 360, 51, 11493, 297, 9638, 199, 533, 485, 6559, 63, 396, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 636, 1250, 721, 277, 12, 1347, 12, 1350, 12, 2589, 12, 367, 63, 5233, 304, 267, 372, 2589, 14, 10297, 59, 277, 14, 354, 61, 199, 199, 1813, 275, 9711, 342, 199, 199, 1813, 14, 10297, 275, 1052, 199, 1813, 14, 10297, 459, 396, 418, 275, 788, 954, 17, 297, 283, 954, 18, 418, 199, 199, 1813, 459, 25205, 63, 20202, 17, 418, 275, 485, 6559, 63, 396, 199, 199, 1813, 459, 25205, 63, 20202, 18, 418, 275, 788, 954, 19, 297, 283, 954, 20, 418, 199, 199, 1813, 14, 8310, 8, 14533, 3243, 275, 788, 10545, 25205, 63, 20202, 17, 480, 396, 531, 7293, 4505, 25205, 63, 20202, 18, 1105, 199, 1813, 14, 9184, 360, 396, 297, 283, 396, 14, 67, 358, 199, 6141, 199, 199, 396, 14, 952, 360, 396, 14, 67, 297, 9638, 199, 3, 2613, 665, 32011, 14, 72, 30, 199, 3, 2613, 665, 28683, 14, 72, 30, 199, 3, 2613, 298, 875, 17, 14, 72, 2, 199, 3, 2613, 298, 875, 18, 14, 72, 2, 199, 3, 2613, 298, 875, 19, 14, 72, 2, 199, 3, 2613, 298, 875, 20, 14, 72, 2, 199, 199, 442, 199, 973, 8, 442, 1680, 67, 12, 1495, 627, 3020, 59, 566, 199, 91, 267, 9238, 59, 1273, 67, 4176, 61, 275, 4320, 11436, 267, 870, 70, 480, 396, 14, 67, 1103, 78, 3547, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 17, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 18, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 19, 2736, 267, 870, 70, 3647, 83, 1103, 78, 401, 18661, 20, 2736, 267, 4458, 334, 16, 2736, 199, 93, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 17, 297, 283, 875, 17, 14, 72, 995, 9638, 199, 3, 4640, 18661, 17, 298, 954, 17, 15, 875, 17, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 18, 297, 283, 875, 18, 14, 72, 995, 9638, 199, 3, 4640, 18661, 18, 298, 954, 18, 15, 875, 18, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 19, 297, 283, 875, 19, 14, 72, 995, 9638, 199, 3, 4640, 18661, 19, 298, 954, 19, 15, 875, 19, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 952, 2941, 954, 20, 297, 283, 875, 20, 14, 72, 995, 9638, 199, 3, 4640, 18661, 20, 298, 954, 20, 15, 875, 20, 14, 72, 2, 199, 6141, 199, 199, 396, 14, 1065, 342, 199, 199, 396, 14, 384, 63, 475, 63, 602, 8, 4958, 275, 20093, 199, 199, 4921, 275, 9638, 199, 396, 14, 67, 199, 954, 17, 15, 875, 17, 14, 72, 199, 954, 18, 15, 875, 18, 14, 72, 199, 954, 19, 15, 875, 19, 14, 72, 199, 954, 20, 15, 875, 20, 14, 72, 199, 624, 199, 199, 396, 14, 1065, 8, 6815, 275, 511, 14, 800, 515, 360, 396, 7, 435, 1379, 18521, 423, 5803, 395, 3839, 29, 4921, 9, 199, 199, 396, 14, 952, 2941, 954, 18, 297, 283, 875, 18, 14, 72, 995, 9638, 199, 3, 4640, 18661, 18, 298, 954, 18, 15, 875, 18, 14, 72, 499, 2, 199, 6141, 199, 199, 396, 14, 1397, 63, 384, 63, 475, 63, 602, 8, 4958, 275, 20093, 199, 199, 4921, 275, 9638, 199, 396, 14, 67, 199, 954, 17, 15, 875, 17, 14, 72, 199, 954, 18, 15, 875, 18, 14, 72, 499, 199, 954, 19, 15, 875, 19, 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 ]
HELIO-HFC/SDOSS
lib/python/net/pycurl.py
1
1034
#! /usr/bin/env python import sys import subprocess import argparse def pycurl(url, *args, **kwargs): cmd = "curl" if (args): for arg in args: cmd += " "+arg if (kwargs): for k,v in kwargs.iteritems(): if (len(k) == 1): if (v): cmd += " -"+k+" "+v elif (len(k) > 1): if (v): cmd += " --"+k+" "+v cmd += " "+url proc = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE) output, error = proc.communicate() proc.wait() return output, error if (__name__ == "__main__"): parser = argparse.ArgumentParser() parser.add_argument('url',nargs=1,help="url to fetch") Namespace = parser.parse_args() url = Namespace.url[0] del Namespace.url keys = {} for k,v in Namespace.__dict__.items(): keys[k] = v output, error = pycurl(url,**keys) print "output:" print output print "error:" print error
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 7534, 199, 199, 318, 1134, 17096, 8, 633, 12, 627, 589, 12, 1011, 958, 304, 339, 2088, 275, 298, 17096, 2, 2286, 340, 334, 589, 304, 267, 367, 1680, 315, 1249, 26, 2088, 847, 298, 7210, 1273, 2286, 340, 334, 958, 304, 267, 367, 1022, 12, 86, 315, 2074, 14, 4611, 837, 288, 340, 334, 552, 8, 75, 9, 508, 413, 304, 355, 340, 334, 86, 304, 2088, 847, 298, 446, 7709, 75, 5207, 7210, 86, 288, 916, 334, 552, 8, 75, 9, 690, 413, 304, 355, 340, 334, 86, 304, 2088, 847, 298, 1553, 7709, 75, 5207, 7210, 86, 326, 272, 2088, 847, 298, 7210, 633, 339, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 5641, 29, 549, 12, 1169, 3839, 29, 5781, 14, 6089, 12, 3083, 29, 5781, 14, 6089, 9, 272, 1072, 12, 1125, 275, 6499, 14, 10664, 342, 272, 6499, 14, 2573, 342, 272, 372, 1072, 12, 1125, 199, 199, 692, 25373, 354, 363, 508, 4396, 973, 363, 2349, 2286, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 360, 633, 297, 15929, 29, 17, 12, 3437, 628, 633, 370, 5267, 531, 272, 19317, 275, 1798, 14, 1122, 63, 589, 342, 339, 1166, 275, 19317, 14, 633, 59, 16, 61, 272, 2150, 19317, 14, 633, 272, 2883, 275, 1052, 2286, 367, 1022, 12, 86, 315, 19317, 855, 807, 4343, 1744, 837, 2883, 59, 75, 61, 275, 373, 272, 1072, 12, 1125, 275, 1134, 17096, 8, 633, 12663, 1612, 9, 272, 870, 298, 1199, 5424, 272, 870, 1072, 272, 870, 298, 705, 5424, 272, 870, 1125, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 7534, 199, 199, 318, 1134, 17096, 8, 633, 12, 627, 589, 12, 1011, 958, 304, 339, 2088, 275, 298, 17096, 2, 2286, 340, 334, 589, 304, 267, 367, 1680, 315, 1249, 26, 2088, 847, 298, 7210, 1273, 2286, 340, 334, 958, 304, 267, 367, 1022, 12, 86, 315, 2074, 14, 4611, 837, 288, 340, 334, 552, 8, 75, 9, 508, 413, 304, 355, 340, 334, 86, 304, 2088, 847, 298, 446, 7709, 75, 5207, 7210, 86, 288, 916, 334, 552, 8, 75, 9, 690, 413, 304, 355, 340, 334, 86, 304, 2088, 847, 298, 1553, 7709, 75, 5207, 7210, 86, 326, 272, 2088, 847, 298, 7210, 633, 339, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 5641, 29, 549, 12, 1169, 3839, 29, 5781, 14, 6089, 12, 3083, 29, 5781, 14, 6089, 9, 272, 1072, 12, 1125, 275, 6499, 14, 10664, 342, 272, 6499, 14, 2573, 342, 272, 372, 1072, 12, 1125, 199, 199, 692, 25373, 354, 363, 508, 4396, 973, 363, 2349, 2286, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 360, 633, 297, 15929, 29, 17, 12, 3437, 628, 633, 370, 5267, 531, 272, 19317, 275, 1798, 14, 1122, 63, 589, 342, 339, 1166, 275, 19317, 14, 633, 59, 16, 61, 272, 2150, 19317, 14, 633, 272, 2883, 275, 1052, 2286, 367, 1022, 12, 86, 315, 19317, 855, 807, 4343, 1744, 837, 2883, 59, 75, 61, 275, 373, 272, 1072, 12, 1125, 275, 1134, 17096, 8, 633, 12663, 1612, 9, 272, 870, 298, 1199, 5424, 272, 870, 1072, 272, 870, 298, 705, 5424, 272, 870, 1125, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
CloudWareChile/OpenChile
openerp/addons/product/partner.py
9
1587
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from osv import fields, osv class res_partner(osv.osv): _name = 'res.partner' _inherit = 'res.partner' _columns = { 'property_product_pricelist': fields.property( 'product.pricelist', type='many2one', relation='product.pricelist', domain=[('type','=','sale')], string="Sale Pricelist", view_load=True, help="This pricelist will be used, instead of the default one, for sales to the current partner"), } res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 9506, 492, 1504, 12, 9506, 421, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 470, 14, 3899, 7, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 272, 485, 3406, 275, 469, 267, 283, 1829, 63, 2558, 63, 17385, 356, 1504, 14, 1829, 8, 288, 283, 2558, 14, 17385, 297, 288, 730, 534, 3479, 18, 368, 297, 7205, 5850, 534, 2558, 14, 17385, 297, 7205, 2881, 11699, 466, 1673, 29511, 8515, 2665, 288, 1059, 628, 30005, 20276, 513, 401, 7205, 2455, 63, 912, 29, 549, 12, 288, 1720, 628, 2765, 25162, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 367, 21702, 370, 314, 1453, 5854, 1288, 272, 789, 199, 199, 470, 63, 3899, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 9506, 492, 1504, 12, 9506, 421, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 470, 14, 3899, 7, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 272, 485, 3406, 275, 469, 267, 283, 1829, 63, 2558, 63, 17385, 356, 1504, 14, 1829, 8, 288, 283, 2558, 14, 17385, 297, 288, 730, 534, 3479, 18, 368, 297, 7205, 5850, 534, 2558, 14, 17385, 297, 7205, 2881, 11699, 466, 1673, 29511, 8515, 2665, 288, 1059, 628, 30005, 20276, 513, 401, 7205, 2455, 63, 912, 29, 549, 12, 288, 1720, 628, 2765, 25162, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 367, 21702, 370, 314, 1453, 5854, 1288, 272, 789, 199, 199, 470, 63, 3899, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
dmacvicar/spacewalk
backend/server/test/test_leak2.py
2
1127
# # Copyright (c) 2008 Red Hat, Inc. # # This software is licensed to you under the GNU General Public License, # version 2 (GPLv2). There is NO WARRANTY for this software, express or # implied, including the implied warranties of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 # along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. # # Red Hat trademarks are not licensed under GPLv2. No permission is # granted to use or replicate Red Hat trademarks that are incorporated # in this software or its documentation. # import os import sys import time from DCOracle import Connect print os.getpid() dbh = Connect('rhnuser/rhnuser@webdev') h = dbh.prepare("select 1 from dual") start = time.time() i = 0 write = sys.stderr.write while i < 10000: h.execute() if i % 100 == 0: f = open("/proc/self/status") l = f.readlines() vmsize = l[10][10:-1] vmrss = l[12][10:-1] f.close() write("%d %.3f vsz: %s rss: %s \n" % (i, time.time() - start, vmsize, vmrss)) i = i + 1
gpl-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 9079, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 370, 1265, 1334, 314, 1664, 1696, 1684, 844, 12, 199, 3, 1015, 499, 334, 28863, 18, 680, 6006, 365, 4825, 3408, 367, 642, 2032, 12, 4056, 503, 199, 3, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 2047, 1077, 1172, 3086, 282, 1331, 402, 14629, 86, 18, 199, 3, 3180, 543, 642, 2032, 27, 340, 440, 12, 1937, 199, 3, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1753, 13, 2383, 15, 11692, 13, 18, 14, 16, 14, 2424, 14, 199, 3, 199, 3, 9572, 13002, 21032, 10375, 787, 440, 18233, 1334, 14629, 86, 18, 14, 3091, 4983, 365, 199, 3, 10009, 370, 675, 503, 29738, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 199, 3, 315, 642, 2032, 503, 2399, 3794, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 504, 577, 1439, 11743, 492, 15175, 199, 199, 1361, 747, 14, 17829, 342, 199, 697, 72, 275, 15175, 360, 82, 6164, 751, 15, 82, 6164, 751, 32, 2520, 2374, 358, 199, 199, 72, 275, 1592, 72, 14, 6726, 480, 2416, 413, 687, 21164, 531, 199, 199, 928, 275, 900, 14, 521, 342, 199, 73, 275, 378, 199, 952, 275, 984, 14, 3083, 14, 952, 199, 6710, 284, 665, 11630, 26, 272, 394, 14, 2526, 342, 272, 340, 284, 450, 2948, 508, 378, 26, 267, 289, 275, 1551, 4769, 4687, 15, 277, 15, 1205, 531, 267, 634, 275, 289, 14, 9684, 342, 267, 4169, 890, 275, 634, 59, 709, 1527, 709, 6809, 17, 61, 267, 4169, 13614, 275, 634, 59, 713, 1527, 709, 6809, 17, 61, 267, 289, 14, 1600, 342, 267, 2218, 3647, 68, 10536, 19, 70, 8118, 90, 26, 450, 83, 32291, 26, 450, 83, 971, 78, 2, 450, 334, 73, 12, 900, 14, 521, 342, 446, 1343, 12, 4169, 890, 12, 288, 4169, 13614, 430, 272, 284, 275, 284, 435, 413, 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 ]
[ 199, 3, 1898, 334, 67, 9, 9079, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2032, 365, 18233, 370, 1265, 1334, 314, 1664, 1696, 1684, 844, 12, 199, 3, 1015, 499, 334, 28863, 18, 680, 6006, 365, 4825, 3408, 367, 642, 2032, 12, 4056, 503, 199, 3, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 2047, 1077, 1172, 3086, 282, 1331, 402, 14629, 86, 18, 199, 3, 3180, 543, 642, 2032, 27, 340, 440, 12, 1937, 199, 3, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1753, 13, 2383, 15, 11692, 13, 18, 14, 16, 14, 2424, 14, 199, 3, 199, 3, 9572, 13002, 21032, 10375, 787, 440, 18233, 1334, 14629, 86, 18, 14, 3091, 4983, 365, 199, 3, 10009, 370, 675, 503, 29738, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 199, 3, 315, 642, 2032, 503, 2399, 3794, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 504, 577, 1439, 11743, 492, 15175, 199, 199, 1361, 747, 14, 17829, 342, 199, 697, 72, 275, 15175, 360, 82, 6164, 751, 15, 82, 6164, 751, 32, 2520, 2374, 358, 199, 199, 72, 275, 1592, 72, 14, 6726, 480, 2416, 413, 687, 21164, 531, 199, 199, 928, 275, 900, 14, 521, 342, 199, 73, 275, 378, 199, 952, 275, 984, 14, 3083, 14, 952, 199, 6710, 284, 665, 11630, 26, 272, 394, 14, 2526, 342, 272, 340, 284, 450, 2948, 508, 378, 26, 267, 289, 275, 1551, 4769, 4687, 15, 277, 15, 1205, 531, 267, 634, 275, 289, 14, 9684, 342, 267, 4169, 890, 275, 634, 59, 709, 1527, 709, 6809, 17, 61, 267, 4169, 13614, 275, 634, 59, 713, 1527, 709, 6809, 17, 61, 267, 289, 14, 1600, 342, 267, 2218, 3647, 68, 10536, 19, 70, 8118, 90, 26, 450, 83, 32291, 26, 450, 83, 971, 78, 2, 450, 334, 73, 12, 900, 14, 521, 342, 446, 1343, 12, 4169, 890, 12, 288, 4169, 13614, 430, 272, 284, 275, 284, 435, 413, 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, 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,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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 ]
ruiliLaMeilleure/11ad-backhaul
bindings/python/ns3modulegen_core_customizations.py
41
18881
from __future__ import print_function import sys import re from pybindgen.typehandlers import base as typehandlers from pybindgen import ReturnValue, Parameter from pybindgen.cppmethod import CustomCppMethodWrapper, CustomCppConstructorWrapper from pybindgen.typehandlers.codesink import MemoryCodeSink from pybindgen.typehandlers import ctypeparser from pybindgen.typehandlers.base import ForwardWrapperBase from pybindgen import cppclass import warnings from pybindgen.typehandlers.base import CodeGenerationError import sys class SmartPointerTransformation(typehandlers.TypeTransformation): """ This class provides a "type transformation" that tends to support NS-3 smart pointers. Parameters such as "Ptr<Foo> foo" are transformed into something like Parameter.new("Foo*", "foo", transfer_ownership=False). Return values such as Ptr<Foo> are transformed into ReturnValue.new("Foo*", caller_owns_return=False). Since the underlying objects have reference counting, PyBindGen does the right thing. """ def __init__(self): super(SmartPointerTransformation, self).__init__() self.rx = re.compile(r'(ns3::|::ns3::|)Ptr<([^>]+)>\s*$') print("{0!r}".format(self), file=sys.stderr) def _get_untransformed_type_traits(self, name): m = self.rx.match(name) is_const = False if m is None: print("{0!r} did not match".format(name), file=sys.stderr) return None, False else: name1 = m.group(2).strip() if name1.startswith('const '): name1 = name1[len('const '):] is_const = True if name1.endswith(' const'): name1 = name1[:-len(' const')] is_const = True new_name = name1+' *' if new_name.startswith('::'): new_name = new_name[2:] return new_name, is_const def get_untransformed_name(self, name): new_name, dummy_is_const = self._get_untransformed_type_traits(name) return new_name def create_type_handler(self, type_handler, *args, **kwargs): if issubclass(type_handler, Parameter): kwargs['transfer_ownership'] = False elif issubclass(type_handler, ReturnValue): kwargs['caller_owns_return'] = False else: raise AssertionError ## fix the ctype, add ns3:: namespace orig_ctype, is_const = self._get_untransformed_type_traits(args[0]) if is_const: correct_ctype = 'ns3::Ptr< {0} const >'.format(orig_ctype[:-2]) else: correct_ctype = 'ns3::Ptr< {0} >'.format(orig_ctype[:-2]) args = tuple([correct_ctype] + list(args[1:])) handler = type_handler(*args, **kwargs) handler.set_tranformation(self, orig_ctype) return handler def untransform(self, type_handler, declarations, code_block, expression): return 'const_cast<%s> (ns3::PeekPointer (%s))' % (type_handler.untransformed_ctype, expression) def transform(self, type_handler, declarations, code_block, expression): assert type_handler.untransformed_ctype[-1] == '*' return 'ns3::Ptr< %s > (%s)' % (type_handler.untransformed_ctype[:-1], expression) ## register the type transformation transf = SmartPointerTransformation() typehandlers.return_type_matcher.register_transformation(transf) typehandlers.param_type_matcher.register_transformation(transf) del transf class CallbackImplProxyMethod(typehandlers.ReverseWrapperBase): """ Class that generates a proxy virtual method that calls a similarly named python method. """ def __init__(self, return_value, parameters): super(CallbackImplProxyMethod, self).__init__(return_value, parameters) def generate_python_call(self): """code to call the python method""" build_params = self.build_params.get_parameters(force_tuple_creation=True) if build_params[0][0] == '"': build_params[0] = '(char *) ' + build_params[0] args = self.before_call.declare_variable('PyObject*', 'args') self.before_call.write_code('%s = Py_BuildValue(%s);' % (args, ', '.join(build_params))) self.before_call.add_cleanup_code('Py_DECREF(%s);' % args) self.before_call.write_code('py_retval = PyObject_CallObject(m_callback, %s);' % args) self.before_call.write_error_check('py_retval == NULL') self.before_call.add_cleanup_code('Py_DECREF(py_retval);') def register_callback_classes(out, callbacks): for callback_impl_num, template_parameters in enumerate(callbacks): cls_name = "ns3::Callback< %s >" % ', '.join(template_parameters) #print >> sys.stderr, "***** trying to register callback: %r" % cls_name class_name = "PythonCallbackImpl%i" % callback_impl_num class PythonCallbackParameter(Parameter): "Class handlers" CTYPES = [cls_name] print("***** registering callback handler: %r (%r)" % (ctypeparser.normalize_type_string(cls_name), cls_name), file=sys.stderr) DIRECTIONS = [Parameter.DIRECTION_IN] PYTHON_CALLBACK_IMPL_NAME = class_name TEMPLATE_ARGS = template_parameters DISABLED = False def convert_python_to_c(self, wrapper): "parses python args to get C++ value" assert isinstance(wrapper, typehandlers.ForwardWrapperBase) if self.DISABLED: raise CodeGenerationError("wrapper could not be generated") if self.default_value is None: py_callback = wrapper.declarations.declare_variable('PyObject*', self.name) wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name) wrapper.before_call.write_error_check( '!PyCallable_Check(%s)' % py_callback, 'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name) callback_impl = wrapper.declarations.declare_variable( 'ns3::Ptr<%s>' % self.PYTHON_CALLBACK_IMPL_NAME, '%s_cb_impl' % self.name) wrapper.before_call.write_code("%s = ns3::Create<%s> (%s);" % (callback_impl, self.PYTHON_CALLBACK_IMPL_NAME, py_callback)) wrapper.call_params.append( 'ns3::Callback<%s> (%s)' % (', '.join(self.TEMPLATE_ARGS), callback_impl)) else: py_callback = wrapper.declarations.declare_variable('PyObject*', self.name, 'NULL') wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name, optional=True) value = wrapper.declarations.declare_variable( 'ns3::Callback<%s>' % ', '.join(self.TEMPLATE_ARGS), self.name+'_value', self.default_value) wrapper.before_call.write_code("if (%s) {" % (py_callback,)) wrapper.before_call.indent() wrapper.before_call.write_error_check( '!PyCallable_Check(%s)' % py_callback, 'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name) wrapper.before_call.write_code("%s = ns3::Callback<%s> (ns3::Create<%s> (%s));" % (value, ', '.join(self.TEMPLATE_ARGS), self.PYTHON_CALLBACK_IMPL_NAME, py_callback)) wrapper.before_call.unindent() wrapper.before_call.write_code("}") # closes: if (py_callback) { wrapper.call_params.append(value) def convert_c_to_python(self, wrapper): raise typehandlers.NotSupportedError("Reverse wrappers for ns3::Callback<...> types " "(python using callbacks defined in C++) not implemented.") def generate_callback_classes(module, callbacks): out = module.after_forward_declarations for callback_impl_num, template_parameters in enumerate(callbacks): sink = MemoryCodeSink() cls_name = "ns3::Callback< %s >" % ', '.join(template_parameters) #print >> sys.stderr, "***** trying to register callback: %r" % cls_name class_name = "PythonCallbackImpl%i" % callback_impl_num sink.writeln(''' class %s : public ns3::CallbackImpl<%s> { public: PyObject *m_callback; %s(PyObject *callback) { Py_INCREF(callback); m_callback = callback; } virtual ~%s() { PyGILState_STATE __py_gil_state; __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); Py_DECREF(m_callback); m_callback = NULL; PyGILState_Release(__py_gil_state); } virtual bool IsEqual(ns3::Ptr<const ns3::CallbackImplBase> other_base) const { const %s *other = dynamic_cast<const %s*> (ns3::PeekPointer (other_base)); if (other != NULL) return (other->m_callback == m_callback); else return false; } ''' % (class_name, ', '.join(template_parameters), class_name, class_name, class_name, class_name)) sink.indent() callback_return = template_parameters[0] return_ctype = ctypeparser.parse_type(callback_return) if ('const' in return_ctype.remove_modifiers()): kwargs = {'is_const': True} else: kwargs = {} try: return_type = ReturnValue.new(str(return_ctype), **kwargs) except (typehandlers.TypeLookupError, typehandlers.TypeConfigurationError) as ex: warnings.warn("***** Unable to register callback; Return value '%s' error (used in %s): %r" % (callback_return, cls_name, ex), Warning) continue arguments = [] ok = True callback_parameters = [arg for arg in template_parameters[1:] if arg != 'ns3::empty'] for arg_num, arg_type in enumerate(callback_parameters): arg_name = 'arg%i' % (arg_num+1) param_ctype = ctypeparser.parse_type(arg_type) if ('const' in param_ctype.remove_modifiers()): kwargs = {'is_const': True} else: kwargs = {} try: arguments.append(Parameter.new(str(param_ctype), arg_name, **kwargs)) except (typehandlers.TypeLookupError, typehandlers.TypeConfigurationError) as ex: warnings.warn("***** Unable to register callback; parameter '%s %s' error (used in %s): %r" % (arg_type, arg_name, cls_name, ex), Warning) ok = False if not ok: try: typehandlers.return_type_matcher.lookup(cls_name)[0].DISABLED = True except typehandlers.TypeLookupError: pass try: typehandlers.param_type_matcher.lookup(cls_name)[0].DISABLED = True except typehandlers.TypeLookupError: pass continue wrapper = CallbackImplProxyMethod(return_type, arguments) wrapper.generate(sink, 'operator()', decl_modifiers=[]) sink.unindent() sink.writeln('};\n') print("Flushing to ", out, file=sys.stderr) sink.flush_to(out) # def write_preamble(out): # pybindgen.write_preamble(out) # out.writeln("#include \"ns3/everything.h\"") def Simulator_customizations(module): Simulator = module['ns3::Simulator'] ## Simulator::Schedule(delay, callback, ...user..args...) Simulator.add_custom_method_wrapper("Schedule", "_wrap_Simulator_Schedule", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) ## Simulator::ScheduleNow(callback, ...user..args...) Simulator.add_custom_method_wrapper("ScheduleNow", "_wrap_Simulator_ScheduleNow", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) ## Simulator::ScheduleDestroy(callback, ...user..args...) Simulator.add_custom_method_wrapper("ScheduleDestroy", "_wrap_Simulator_ScheduleDestroy", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) Simulator.add_custom_method_wrapper("Run", "_wrap_Simulator_Run", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) def CommandLine_customizations(module): CommandLine = module['ns3::CommandLine'] CommandLine.add_method('Parse', None, [ArgvParam(None, 'argv')], is_static=False) CommandLine.add_custom_method_wrapper("AddValue", "_wrap_CommandLine_AddValue", flags=["METH_VARARGS", "METH_KEYWORDS"]) def Object_customizations(module): ## --------------------------------------------------------------------- ## Here we generate custom constructor code for all classes that ## derive from ns3::Object. The custom constructors are needed in ## order to support kwargs only and to translate kwargs into ns3 ## attributes, etc. ## --------------------------------------------------------------------- try: Object = module['ns3::Object'] except KeyError: return ## add a GetTypeId method to all generatd helper classes def helper_class_hook(helper_class): decl = """ static ns3::TypeId GetTypeId (void) { static ns3::TypeId tid = ns3::TypeId ("%s") .SetParent< %s > () ; return tid; }""" % (helper_class.name, helper_class.class_.full_name) helper_class.add_custom_method(decl) helper_class.add_post_generation_code( "NS_OBJECT_ENSURE_REGISTERED (%s);" % helper_class.name) Object.add_helper_class_hook(helper_class_hook) def ns3_object_instance_creation_function(cpp_class, code_block, lvalue, parameters, construct_type_name): assert lvalue assert not lvalue.startswith('None') if cpp_class.cannot_be_constructed: raise CodeGenerationError("%s cannot be constructed (%s)" % cpp_class.full_name) if cpp_class.incomplete_type: raise CodeGenerationError("%s cannot be constructed (incomplete type)" % cpp_class.full_name) code_block.write_code("%s = new %s(%s);" % (lvalue, construct_type_name, parameters)) code_block.write_code("%s->Ref ();" % (lvalue)) def ns3_object_post_instance_creation_function(cpp_class, code_block, lvalue, parameters, construct_type_name): code_block.write_code("ns3::CompleteConstruct(%s);" % (lvalue, )) Object.set_instance_creation_function(ns3_object_instance_creation_function) Object.set_post_instance_creation_function(ns3_object_post_instance_creation_function) def Attribute_customizations(module): # Fix up for the "const AttributeValue &v = EmptyAttribute()" # case, as used extensively by helper classes. # Here's why we need to do this: pybindgen.gccxmlscanner, when # scanning parameter default values, is only provided with the # value as a simple C expression string. (py)gccxml does not # report the type of the default value. # As a workaround, here we iterate over all parameters of all # methods of all classes and tell pybindgen what is the type of # the default value for attributes. for cls in module.classes: for meth in cls.get_all_methods(): for param in meth.parameters: if isinstance(param, cppclass.CppClassRefParameter): if param.cpp_class.name == 'AttributeValue' \ and param.default_value is not None \ and param.default_value_type is None: param.default_value_type = 'ns3::EmptyAttributeValue' def TypeId_customizations(module): TypeId = module['ns3::TypeId'] TypeId.add_custom_method_wrapper("LookupByNameFailSafe", "_wrap_TypeId_LookupByNameFailSafe", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) def add_std_ofstream(module): module.add_include('<fstream>') ostream = module.add_class('ostream', foreign_cpp_namespace='::std') ostream.set_cannot_be_constructed("abstract base class") ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream) ofstream.add_enum('openmode', [ ('app', 'std::ios_base::app'), ('ate', 'std::ios_base::ate'), ('binary', 'std::ios_base::binary'), ('in', 'std::ios_base::in'), ('out', 'std::ios_base::out'), ('trunc', 'std::ios_base::trunc'), ]) ofstream.add_constructor([Parameter.new("const char *", 'filename'), Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")]) ofstream.add_method('close', None, []) add_std_ios_openmode(module) class IosOpenmodeParam(Parameter): DIRECTIONS = [Parameter.DIRECTION_IN] CTYPES = ['std::ios::openmode', 'std::_Ios_Openmode'] def convert_c_to_python(self, wrapper): assert isinstance(wrapper, ReverseWrapperBase) wrapper.build_params.add_parameter('i', [self.value]) def convert_python_to_c(self, wrapper): assert isinstance(wrapper, ForwardWrapperBase) name = wrapper.declarations.declare_variable("std::ios::openmode", self.name, self.default_value) wrapper.parse_params.add_parameter('i', ['&'+name], self.name, optional=bool(self.default_value)) wrapper.call_params.append(name) def add_std_ios_openmode(module): for flag in 'in', 'out', 'ate', 'app', 'trunc', 'binary': module.after_init.write_code('PyModule_AddIntConstant(m, (char *) "STD_IOS_%s", std::ios::%s);' % (flag.upper(), flag)) def add_ipv4_address_tp_hash(module): module.body.writeln(''' long _ns3_Ipv4Address_tp_hash (PyObject *obj) { PyNs3Ipv4Address *addr = reinterpret_cast<PyNs3Ipv4Address *> (obj); return static_cast<long> (ns3::Ipv4AddressHash () (*addr->obj)); } ''') module.header.writeln('long _ns3_Ipv4Address_tp_hash (PyObject *obj);') module['Ipv4Address'].pytype.slots['tp_hash'] = "_ns3_Ipv4Address_tp_hash"
gpl-2.0
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 295, 199, 199, 504, 1134, 31297, 14, 466, 5586, 492, 1300, 465, 14330, 199, 504, 1134, 31297, 492, 1432, 1110, 12, 12009, 199, 504, 1134, 31297, 14, 5910, 765, 492, 8388, 19705, 3767, 4590, 12, 8388, 19705, 11447, 4590, 199, 504, 1134, 31297, 14, 466, 5586, 14, 6021, 2292, 492, 15825, 3034, 17111, 199, 504, 1134, 31297, 14, 466, 5586, 492, 16360, 2087, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 22536, 4590, 1563, 199, 504, 1134, 31297, 492, 7246, 533, 199, 646, 3598, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 5495, 3139, 5263, 199, 199, 646, 984, 199, 199, 533, 26017, 12190, 26283, 8, 466, 5586, 14, 804, 26283, 304, 272, 408, 272, 961, 1021, 6571, 282, 298, 466, 13315, 2, 626, 16685, 795, 370, 2291, 272, 9380, 13, 19, 11179, 21116, 14, 221, 3897, 4066, 465, 298, 2115, 28, 5686, 30, 3925, 2, 787, 272, 14834, 1901, 6020, 2839, 12009, 14, 1222, 480, 5686, 14421, 298, 1421, 401, 272, 9307, 63, 22495, 29, 797, 680, 221, 1432, 1338, 4066, 465, 20636, 28, 5686, 30, 787, 272, 14834, 1901, 1432, 1110, 14, 1222, 480, 5686, 14421, 272, 8025, 63, 23311, 63, 1107, 29, 797, 680, 221, 9336, 314, 8793, 2251, 1172, 272, 3659, 23190, 12, 1611, 8198, 8168, 1630, 314, 2451, 8377, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 29111, 12190, 26283, 12, 291, 2843, 826, 4533, 267, 291, 14, 6872, 275, 295, 14, 2014, 8, 82, 6774, 561, 19, 447, 92, 447, 561, 19, 447, 92, 9, 2115, 28, 7059, 30, 11896, 3072, 83, 10, 9988, 267, 870, 13076, 16, 1, 82, 5469, 908, 8, 277, 395, 570, 29, 1274, 14, 3083, 9, 339, 347, 485, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 277, 12, 536, 304, 267, 333, 275, 291, 14, 6872, 14, 1431, 8, 354, 9, 267, 365, 63, 1297, 275, 756, 267, 340, 333, 365, 488, 26, 288, 870, 13076, 16, 1, 82, 93, 8103, 440, 1336, 1674, 908, 8, 354, 395, 570, 29, 1274, 14, 3083, 9, 288, 372, 488, 12, 756, 267, 587, 26, 288, 536, 17, 275, 333, 14, 923, 8, 18, 680, 1913, 342, 288, 340, 536, 17, 14, 2460, 360, 1297, 18927, 355, 536, 17, 275, 536, 17, 59, 552, 360, 1297, 283, 15405, 355, 365, 63, 1297, 275, 715, 288, 340, 536, 17, 14, 4130, 360, 950, 735, 355, 536, 17, 275, 536, 17, 4439, 552, 360, 950, 5440, 355, 365, 63, 1297, 275, 715, 288, 892, 63, 354, 275, 536, 17, 4786, 627, 7, 953, 340, 892, 63, 354, 14, 2460, 6176, 23117, 355, 892, 63, 354, 275, 892, 63, 354, 59, 18, 2938, 288, 372, 892, 63, 354, 12, 365, 63, 1297, 339, 347, 664, 63, 324, 20209, 63, 354, 8, 277, 12, 536, 304, 267, 892, 63, 354, 12, 7283, 63, 374, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 354, 9, 267, 372, 892, 63, 354, 339, 347, 1218, 63, 466, 63, 2232, 8, 277, 12, 730, 63, 2232, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 11602, 8, 466, 63, 2232, 12, 12009, 304, 288, 2074, 459, 9609, 63, 22495, 418, 275, 756, 267, 916, 11602, 8, 466, 63, 2232, 12, 1432, 1110, 304, 288, 2074, 459, 11219, 63, 23311, 63, 1107, 418, 275, 756, 267, 587, 26, 288, 746, 9070, 398, 925, 5325, 314, 16360, 12, 1050, 700, 19, 447, 3231, 267, 2306, 63, 3667, 12, 365, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 589, 59, 16, 566, 267, 340, 365, 63, 1297, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 950, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 587, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 1249, 275, 2008, 779, 4525, 63, 3667, 61, 435, 769, 8, 589, 59, 17, 16720, 398, 3016, 275, 730, 63, 2232, 2031, 589, 12, 1011, 958, 9, 267, 3016, 14, 409, 63, 3936, 1869, 8, 277, 12, 2306, 63, 3667, 9, 267, 372, 3016, 339, 347, 625, 4711, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 372, 283, 1297, 63, 2931, 21110, 83, 30, 334, 561, 19, 447, 17093, 12190, 4366, 83, 23089, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 12, 3965, 9, 339, 347, 5793, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 702, 730, 63, 2232, 14, 324, 20209, 63, 3667, 1988, 17, 61, 508, 13626, 267, 372, 283, 561, 19, 447, 2115, 28, 450, 83, 690, 4366, 83, 3171, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 4439, 17, 467, 3965, 9, 199, 199, 309, 2274, 314, 730, 13315, 199, 1515, 70, 275, 26017, 12190, 26283, 342, 199, 466, 5586, 14, 1107, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 466, 5586, 14, 635, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 2264, 28183, 421, 199, 533, 17555, 4748, 4936, 3767, 8, 466, 5586, 14, 14987, 4590, 1563, 304, 272, 408, 272, 8089, 626, 12821, 282, 4566, 5791, 1083, 626, 4882, 282, 8545, 590, 4310, 2366, 1083, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 372, 63, 585, 12, 2633, 304, 267, 1613, 8, 8415, 4936, 3767, 12, 291, 2843, 826, 721, 1107, 63, 585, 12, 2633, 9, 339, 347, 3550, 63, 1548, 63, 1250, 8, 277, 304, 267, 408, 600, 370, 1240, 314, 2366, 1083, 624, 267, 1900, 63, 1162, 275, 291, 14, 1506, 63, 1162, 14, 362, 63, 3214, 8, 3990, 63, 2960, 63, 8782, 29, 549, 9, 267, 340, 1900, 63, 1162, 59, 16, 1527, 16, 61, 508, 24536, 288, 1900, 63, 1162, 59, 16, 61, 275, 8189, 1560, 24104, 283, 435, 1900, 63, 1162, 59, 16, 61, 267, 1249 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 295, 199, 199, 504, 1134, 31297, 14, 466, 5586, 492, 1300, 465, 14330, 199, 504, 1134, 31297, 492, 1432, 1110, 12, 12009, 199, 504, 1134, 31297, 14, 5910, 765, 492, 8388, 19705, 3767, 4590, 12, 8388, 19705, 11447, 4590, 199, 504, 1134, 31297, 14, 466, 5586, 14, 6021, 2292, 492, 15825, 3034, 17111, 199, 504, 1134, 31297, 14, 466, 5586, 492, 16360, 2087, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 22536, 4590, 1563, 199, 504, 1134, 31297, 492, 7246, 533, 199, 646, 3598, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 5495, 3139, 5263, 199, 199, 646, 984, 199, 199, 533, 26017, 12190, 26283, 8, 466, 5586, 14, 804, 26283, 304, 272, 408, 272, 961, 1021, 6571, 282, 298, 466, 13315, 2, 626, 16685, 795, 370, 2291, 272, 9380, 13, 19, 11179, 21116, 14, 221, 3897, 4066, 465, 298, 2115, 28, 5686, 30, 3925, 2, 787, 272, 14834, 1901, 6020, 2839, 12009, 14, 1222, 480, 5686, 14421, 298, 1421, 401, 272, 9307, 63, 22495, 29, 797, 680, 221, 1432, 1338, 4066, 465, 20636, 28, 5686, 30, 787, 272, 14834, 1901, 1432, 1110, 14, 1222, 480, 5686, 14421, 272, 8025, 63, 23311, 63, 1107, 29, 797, 680, 221, 9336, 314, 8793, 2251, 1172, 272, 3659, 23190, 12, 1611, 8198, 8168, 1630, 314, 2451, 8377, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 29111, 12190, 26283, 12, 291, 2843, 826, 4533, 267, 291, 14, 6872, 275, 295, 14, 2014, 8, 82, 6774, 561, 19, 447, 92, 447, 561, 19, 447, 92, 9, 2115, 28, 7059, 30, 11896, 3072, 83, 10, 9988, 267, 870, 13076, 16, 1, 82, 5469, 908, 8, 277, 395, 570, 29, 1274, 14, 3083, 9, 339, 347, 485, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 277, 12, 536, 304, 267, 333, 275, 291, 14, 6872, 14, 1431, 8, 354, 9, 267, 365, 63, 1297, 275, 756, 267, 340, 333, 365, 488, 26, 288, 870, 13076, 16, 1, 82, 93, 8103, 440, 1336, 1674, 908, 8, 354, 395, 570, 29, 1274, 14, 3083, 9, 288, 372, 488, 12, 756, 267, 587, 26, 288, 536, 17, 275, 333, 14, 923, 8, 18, 680, 1913, 342, 288, 340, 536, 17, 14, 2460, 360, 1297, 18927, 355, 536, 17, 275, 536, 17, 59, 552, 360, 1297, 283, 15405, 355, 365, 63, 1297, 275, 715, 288, 340, 536, 17, 14, 4130, 360, 950, 735, 355, 536, 17, 275, 536, 17, 4439, 552, 360, 950, 5440, 355, 365, 63, 1297, 275, 715, 288, 892, 63, 354, 275, 536, 17, 4786, 627, 7, 953, 340, 892, 63, 354, 14, 2460, 6176, 23117, 355, 892, 63, 354, 275, 892, 63, 354, 59, 18, 2938, 288, 372, 892, 63, 354, 12, 365, 63, 1297, 339, 347, 664, 63, 324, 20209, 63, 354, 8, 277, 12, 536, 304, 267, 892, 63, 354, 12, 7283, 63, 374, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 354, 9, 267, 372, 892, 63, 354, 339, 347, 1218, 63, 466, 63, 2232, 8, 277, 12, 730, 63, 2232, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 11602, 8, 466, 63, 2232, 12, 12009, 304, 288, 2074, 459, 9609, 63, 22495, 418, 275, 756, 267, 916, 11602, 8, 466, 63, 2232, 12, 1432, 1110, 304, 288, 2074, 459, 11219, 63, 23311, 63, 1107, 418, 275, 756, 267, 587, 26, 288, 746, 9070, 398, 925, 5325, 314, 16360, 12, 1050, 700, 19, 447, 3231, 267, 2306, 63, 3667, 12, 365, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 589, 59, 16, 566, 267, 340, 365, 63, 1297, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 950, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 587, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 1249, 275, 2008, 779, 4525, 63, 3667, 61, 435, 769, 8, 589, 59, 17, 16720, 398, 3016, 275, 730, 63, 2232, 2031, 589, 12, 1011, 958, 9, 267, 3016, 14, 409, 63, 3936, 1869, 8, 277, 12, 2306, 63, 3667, 9, 267, 372, 3016, 339, 347, 625, 4711, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 372, 283, 1297, 63, 2931, 21110, 83, 30, 334, 561, 19, 447, 17093, 12190, 4366, 83, 23089, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 12, 3965, 9, 339, 347, 5793, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 702, 730, 63, 2232, 14, 324, 20209, 63, 3667, 1988, 17, 61, 508, 13626, 267, 372, 283, 561, 19, 447, 2115, 28, 450, 83, 690, 4366, 83, 3171, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 4439, 17, 467, 3965, 9, 199, 199, 309, 2274, 314, 730, 13315, 199, 1515, 70, 275, 26017, 12190, 26283, 342, 199, 466, 5586, 14, 1107, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 466, 5586, 14, 635, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 2264, 28183, 421, 199, 533, 17555, 4748, 4936, 3767, 8, 466, 5586, 14, 14987, 4590, 1563, 304, 272, 408, 272, 8089, 626, 12821, 282, 4566, 5791, 1083, 626, 4882, 282, 8545, 590, 4310, 2366, 1083, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 372, 63, 585, 12, 2633, 304, 267, 1613, 8, 8415, 4936, 3767, 12, 291, 2843, 826, 721, 1107, 63, 585, 12, 2633, 9, 339, 347, 3550, 63, 1548, 63, 1250, 8, 277, 304, 267, 408, 600, 370, 1240, 314, 2366, 1083, 624, 267, 1900, 63, 1162, 275, 291, 14, 1506, 63, 1162, 14, 362, 63, 3214, 8, 3990, 63, 2960, 63, 8782, 29, 549, 9, 267, 340, 1900, 63, 1162, 59, 16, 1527, 16, 61, 508, 24536, 288, 1900, 63, 1162, 59, 16, 61, 275, 8189, 1560, 24104, 283, 435, 1900, 63, 1162, 59, 16, 61, 267, 1249, 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, 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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 ]
jehiah/tornado
tornado/test/asyncio_test.py
24
4766
# 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 __future__ import absolute_import, division, print_function from tornado import gen from tornado.testing import AsyncTestCase, gen_test from tornado.test.util import unittest, skipBefore33, skipBefore35, exec_test try: from tornado.platform.asyncio import asyncio except ImportError: asyncio = None else: from tornado.platform.asyncio import AsyncIOLoop, to_asyncio_future # This is used in dynamically-evaluated code, so silence pyflakes. to_asyncio_future @unittest.skipIf(asyncio is None, "asyncio module not present") class AsyncIOLoopTest(AsyncTestCase): def get_new_ioloop(self): io_loop = AsyncIOLoop() asyncio.set_event_loop(io_loop.asyncio_loop) return io_loop def test_asyncio_callback(self): # Basic test that the asyncio loop is set up correctly. asyncio.get_event_loop().call_soon(self.stop) self.wait() @gen_test def test_asyncio_future(self): # Test that we can yield an asyncio future from a tornado coroutine. # Without 'yield from', we must wrap coroutines in ensure_future, # which was introduced during Python 3.4, deprecating the prior "async". if hasattr(asyncio, 'ensure_future'): ensure_future = asyncio.ensure_future else: ensure_future = asyncio.async x = yield ensure_future( asyncio.get_event_loop().run_in_executor(None, lambda: 42)) self.assertEqual(x, 42) @skipBefore33 @gen_test def test_asyncio_yield_from(self): # Test that we can use asyncio coroutines with 'yield from' # instead of asyncio.async(). This requires python 3.3 syntax. namespace = exec_test(globals(), locals(), """ @gen.coroutine def f(): event_loop = asyncio.get_event_loop() x = yield from event_loop.run_in_executor(None, lambda: 42) return x """) result = yield namespace['f']() self.assertEqual(result, 42) @skipBefore35 def test_asyncio_adapter(self): # This test demonstrates that when using the asyncio coroutine # runner (i.e. run_until_complete), the to_asyncio_future # adapter is needed. No adapter is needed in the other direction, # as demonstrated by other tests in the package. @gen.coroutine def tornado_coroutine(): yield gen.Task(self.io_loop.add_callback) raise gen.Return(42) native_coroutine_without_adapter = exec_test(globals(), locals(), """ async def native_coroutine_without_adapter(): return await tornado_coroutine() """)["native_coroutine_without_adapter"] native_coroutine_with_adapter = exec_test(globals(), locals(), """ async def native_coroutine_with_adapter(): return await to_asyncio_future(tornado_coroutine()) """)["native_coroutine_with_adapter"] # Use the adapter, but two degrees from the tornado coroutine. native_coroutine_with_adapter2 = exec_test(globals(), locals(), """ async def native_coroutine_with_adapter2(): return await to_asyncio_future(native_coroutine_without_adapter()) """)["native_coroutine_with_adapter2"] # Tornado supports native coroutines both with and without adapters self.assertEqual( self.io_loop.run_sync(native_coroutine_without_adapter), 42) self.assertEqual( self.io_loop.run_sync(native_coroutine_with_adapter), 42) self.assertEqual( self.io_loop.run_sync(native_coroutine_with_adapter2), 42) # Asyncio only supports coroutines that yield asyncio-compatible # Futures. with self.assertRaises(RuntimeError): asyncio.get_event_loop().run_until_complete( native_coroutine_without_adapter()) self.assertEqual( asyncio.get_event_loop().run_until_complete( native_coroutine_with_adapter()), 42) self.assertEqual( asyncio.get_event_loop().run_until_complete( native_coroutine_with_adapter2()), 42)
apache-2.0
[ 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, 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, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 504, 12148, 492, 3805, 199, 504, 12148, 14, 4776, 492, 15223, 1746, 12, 3805, 63, 396, 199, 504, 12148, 14, 396, 14, 1974, 492, 2882, 12, 3372, 13569, 1153, 12, 3372, 13569, 1276, 12, 2146, 63, 396, 199, 199, 893, 26, 272, 687, 12148, 14, 3246, 14, 19343, 492, 16195, 199, 2590, 3545, 26, 272, 16195, 275, 488, 199, 2836, 26, 272, 687, 12148, 14, 3246, 14, 19343, 492, 15223, 23152, 12, 370, 63, 19343, 63, 2443, 272, 327, 961, 365, 1202, 315, 18774, 13, 2579, 23130, 1233, 12, 880, 9767, 21225, 1134, 29677, 14, 272, 370, 63, 19343, 63, 2443, 421, 199, 32, 2796, 14, 15118, 8, 19343, 365, 488, 12, 298, 19343, 859, 440, 3451, 531, 199, 533, 15223, 23152, 774, 8, 12807, 1746, 304, 272, 347, 664, 63, 1222, 63, 27212, 8, 277, 304, 267, 5890, 63, 3813, 275, 15223, 23152, 342, 267, 16195, 14, 409, 63, 1430, 63, 3813, 8, 2308, 63, 3813, 14, 19343, 63, 3813, 9, 267, 372, 5890, 63, 3813, 339, 347, 511, 63, 19343, 63, 3058, 8, 277, 304, 267, 327, 10082, 511, 626, 314, 16195, 4438, 365, 663, 1536, 6657, 14, 267, 16195, 14, 362, 63, 1430, 63, 3813, 1252, 1250, 63, 1152, 265, 8, 277, 14, 2379, 9, 267, 291, 14, 2573, 342, 339, 768, 2268, 63, 396, 272, 347, 511, 63, 19343, 63, 2443, 8, 277, 304, 267, 327, 1379, 626, 781, 883, 1995, 376, 16195, 6466, 687, 282, 12148, 1970, 13242, 14, 267, 327, 23952, 283, 11481, 687, 297, 781, 1471, 4816, 1970, 548, 3746, 315, 4868, 63, 2443, 12, 267, 327, 1314, 1990, 21399, 5309, 2018, 650, 14, 20, 12, 477, 9218, 1958, 314, 6791, 298, 4146, 1674, 267, 340, 2688, 8, 19343, 12, 283, 7505, 63, 2443, 735, 288, 4868, 63, 2443, 275, 16195, 14, 7505, 63, 2443, 267, 587, 26, 288, 4868, 63, 2443, 275, 16195, 14, 4146, 398, 671, 275, 1995, 4868, 63, 2443, 8, 288, 16195, 14, 362, 63, 1430, 63, 3813, 1252, 1065, 63, 262, 63, 13471, 8, 403, 12, 2400, 26, 5685, 430, 267, 291, 14, 629, 8, 88, 12, 5685, 9, 339, 768, 2759, 13569, 1153, 272, 768, 2268, 63, 396, 272, 347, 511, 63, 19343, 63, 11481, 63, 504, 8, 277, 304, 267, 327, 1379, 626, 781, 883, 675, 16195, 1970, 548, 3746, 543, 283, 11481, 687, 7, 267, 327, 3140, 402, 16195, 14, 4146, 1252, 961, 5074, 2366, 650, 14, 19, 6302, 14, 267, 3231, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 768, 2268, 14, 16675, 267, 347, 289, 837, 288, 1566, 63, 3813, 275, 16195, 14, 362, 63, 1430, 63, 3813, 342, 288, 671, 275, 1995, 687, 1566, 63, 3813, 14, 1065, 63, 262, 63, 13471, 8, 403, 12, 2400, 26, 5685, 9, 288, 372, 671, 267, 7857, 267, 754, 275, 1995, 3231, 459, 70, 418, 342, 267, 291, 14, 629, 8, 1099, 12, 5685, 9, 339, 768, 2759, 13569, 1276, 272, 347, 511, 63, 19343, 63, 10394, 8, 277, 304, 267, 327, 961, 511, 23789, 31216, 626, 1380, 1808, 314, 16195, 1970, 13242, 267, 327, 7876, 334, 73, 14, 69, 14, 1255, 63, 8111, 63, 4883, 395, 314, 370, 63, 19343, 63, 2443, 267, 327, 12146, 365, 4346, 14, 3091, 12146, 365, 4346, 315, 314, 1163, 7581, 12, 267, 327, 465, 23789, 495, 972, 701, 1163, 2295, 315, 314, 2559, 14, 267, 768, 2268, 14, 16675, 267, 347, 12148, 63, 16675, 837, 288, 1995, 3805, 14, 4476, 8, 277, 14, 2308, 63, 3813, 14, 525, 63, 3058, 9, 288, 746, 3805, 14, 1767, 8, 2260, 9, 267, 5438, 63, 16675, 63, 7395, 63, 10394, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 7395, 63, 10394, 837, 288, 372, 5517, 12148, 63, 16675, 342, 267, 7857, 905, 6106, 63, 16675, 63, 7395, 63, 10394, 937, 398, 5438, 63, 16675, 63, 1045, 63, 10394, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 1045, 63, 10394, 837, 288, 372, 5517, 370, 63, 19343, 63, 2443, 8, 18443, 63, 16675, 1012, 267, 7857, 905, 6106, 63, 16675, 63, 1045, 63, 10394, 937, 398, 327, 3645, 314, 12146, 12, 1325, 2877, 14358, 687, 314, 12148, 1970, 13242, 14, 267, 5438, 63, 16675, 63, 1045, 63, 10394, 18, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 1045, 63, 10394, 18, 837, 288, 372, 5517, 370, 63, 19343, 63, 2443, 8, 6106, 63, 16675, 63, 7395, 63, 10394, 1012, 267, 7857, 905, 6106, 63, 16675, 63, 1045, 63, 10394, 18, 937, 398, 327, 377, 8622, 5171, 5438, 1970, 548, 3746, 3865, 543, 436, 1928, 1503, 12552, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 7395, 63, 10394, 395, 288, 5685, 9, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 1045, 63, 10394, 395, 288, 5685, 9, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 1045, 63, 10394, 18, 395, 288, 5685, 9, 398, 327, 3709, 11706, 1454, 5171, 1970, 548, 3746, 626, 1995, 16195 ]
[ 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, 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, 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, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 504, 12148, 492, 3805, 199, 504, 12148, 14, 4776, 492, 15223, 1746, 12, 3805, 63, 396, 199, 504, 12148, 14, 396, 14, 1974, 492, 2882, 12, 3372, 13569, 1153, 12, 3372, 13569, 1276, 12, 2146, 63, 396, 199, 199, 893, 26, 272, 687, 12148, 14, 3246, 14, 19343, 492, 16195, 199, 2590, 3545, 26, 272, 16195, 275, 488, 199, 2836, 26, 272, 687, 12148, 14, 3246, 14, 19343, 492, 15223, 23152, 12, 370, 63, 19343, 63, 2443, 272, 327, 961, 365, 1202, 315, 18774, 13, 2579, 23130, 1233, 12, 880, 9767, 21225, 1134, 29677, 14, 272, 370, 63, 19343, 63, 2443, 421, 199, 32, 2796, 14, 15118, 8, 19343, 365, 488, 12, 298, 19343, 859, 440, 3451, 531, 199, 533, 15223, 23152, 774, 8, 12807, 1746, 304, 272, 347, 664, 63, 1222, 63, 27212, 8, 277, 304, 267, 5890, 63, 3813, 275, 15223, 23152, 342, 267, 16195, 14, 409, 63, 1430, 63, 3813, 8, 2308, 63, 3813, 14, 19343, 63, 3813, 9, 267, 372, 5890, 63, 3813, 339, 347, 511, 63, 19343, 63, 3058, 8, 277, 304, 267, 327, 10082, 511, 626, 314, 16195, 4438, 365, 663, 1536, 6657, 14, 267, 16195, 14, 362, 63, 1430, 63, 3813, 1252, 1250, 63, 1152, 265, 8, 277, 14, 2379, 9, 267, 291, 14, 2573, 342, 339, 768, 2268, 63, 396, 272, 347, 511, 63, 19343, 63, 2443, 8, 277, 304, 267, 327, 1379, 626, 781, 883, 1995, 376, 16195, 6466, 687, 282, 12148, 1970, 13242, 14, 267, 327, 23952, 283, 11481, 687, 297, 781, 1471, 4816, 1970, 548, 3746, 315, 4868, 63, 2443, 12, 267, 327, 1314, 1990, 21399, 5309, 2018, 650, 14, 20, 12, 477, 9218, 1958, 314, 6791, 298, 4146, 1674, 267, 340, 2688, 8, 19343, 12, 283, 7505, 63, 2443, 735, 288, 4868, 63, 2443, 275, 16195, 14, 7505, 63, 2443, 267, 587, 26, 288, 4868, 63, 2443, 275, 16195, 14, 4146, 398, 671, 275, 1995, 4868, 63, 2443, 8, 288, 16195, 14, 362, 63, 1430, 63, 3813, 1252, 1065, 63, 262, 63, 13471, 8, 403, 12, 2400, 26, 5685, 430, 267, 291, 14, 629, 8, 88, 12, 5685, 9, 339, 768, 2759, 13569, 1153, 272, 768, 2268, 63, 396, 272, 347, 511, 63, 19343, 63, 11481, 63, 504, 8, 277, 304, 267, 327, 1379, 626, 781, 883, 675, 16195, 1970, 548, 3746, 543, 283, 11481, 687, 7, 267, 327, 3140, 402, 16195, 14, 4146, 1252, 961, 5074, 2366, 650, 14, 19, 6302, 14, 267, 3231, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 768, 2268, 14, 16675, 267, 347, 289, 837, 288, 1566, 63, 3813, 275, 16195, 14, 362, 63, 1430, 63, 3813, 342, 288, 671, 275, 1995, 687, 1566, 63, 3813, 14, 1065, 63, 262, 63, 13471, 8, 403, 12, 2400, 26, 5685, 9, 288, 372, 671, 267, 7857, 267, 754, 275, 1995, 3231, 459, 70, 418, 342, 267, 291, 14, 629, 8, 1099, 12, 5685, 9, 339, 768, 2759, 13569, 1276, 272, 347, 511, 63, 19343, 63, 10394, 8, 277, 304, 267, 327, 961, 511, 23789, 31216, 626, 1380, 1808, 314, 16195, 1970, 13242, 267, 327, 7876, 334, 73, 14, 69, 14, 1255, 63, 8111, 63, 4883, 395, 314, 370, 63, 19343, 63, 2443, 267, 327, 12146, 365, 4346, 14, 3091, 12146, 365, 4346, 315, 314, 1163, 7581, 12, 267, 327, 465, 23789, 495, 972, 701, 1163, 2295, 315, 314, 2559, 14, 267, 768, 2268, 14, 16675, 267, 347, 12148, 63, 16675, 837, 288, 1995, 3805, 14, 4476, 8, 277, 14, 2308, 63, 3813, 14, 525, 63, 3058, 9, 288, 746, 3805, 14, 1767, 8, 2260, 9, 267, 5438, 63, 16675, 63, 7395, 63, 10394, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 7395, 63, 10394, 837, 288, 372, 5517, 12148, 63, 16675, 342, 267, 7857, 905, 6106, 63, 16675, 63, 7395, 63, 10394, 937, 398, 5438, 63, 16675, 63, 1045, 63, 10394, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 1045, 63, 10394, 837, 288, 372, 5517, 370, 63, 19343, 63, 2443, 8, 18443, 63, 16675, 1012, 267, 7857, 905, 6106, 63, 16675, 63, 1045, 63, 10394, 937, 398, 327, 3645, 314, 12146, 12, 1325, 2877, 14358, 687, 314, 12148, 1970, 13242, 14, 267, 5438, 63, 16675, 63, 1045, 63, 10394, 18, 275, 2146, 63, 396, 8, 8473, 1062, 9480, 1062, 408, 267, 5316, 347, 5438, 63, 16675, 63, 1045, 63, 10394, 18, 837, 288, 372, 5517, 370, 63, 19343, 63, 2443, 8, 6106, 63, 16675, 63, 7395, 63, 10394, 1012, 267, 7857, 905, 6106, 63, 16675, 63, 1045, 63, 10394, 18, 937, 398, 327, 377, 8622, 5171, 5438, 1970, 548, 3746, 3865, 543, 436, 1928, 1503, 12552, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 7395, 63, 10394, 395, 288, 5685, 9, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 1045, 63, 10394, 395, 288, 5685, 9, 267, 291, 14, 629, 8, 288, 291, 14, 2308, 63, 3813, 14, 1065, 63, 5186, 8, 6106, 63, 16675, 63, 1045, 63, 10394, 18, 395, 288, 5685, 9, 398, 327, 3709, 11706, 1454, 5171, 1970, 548, 3746, 626, 1995, 16195, 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,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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 ]
rfhk/awo-custom
sale_line_quant_extended/models/stock_move.py
1
10584
# -*- coding: utf-8 -*- # Copyright 2015-2017 Quartile Limted # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api, _ class StockMove(models.Model): _inherit = "stock.move" pick_partner_id = fields.Many2one( related='picking_id.partner_id', store=True, readonly=True, string='Pick Partner' ) picking_type_code = fields.Selection( related='picking_type_id.code', store=True, readonly=True, string='Picking Type Code' ) quant_lot_id = fields.Many2one( 'stock.production.lot', compute='_get_quant_info', store=True, readonly=True, string='Case No.' ) quant_owner_id = fields.Many2one( 'res.partner', compute='_get_quant_info', store=True, readonly=True, string='Owner' ) so_id = fields.Many2one( 'sale.order', compute='_get_vals', store=True, readonly=True, string='SO' ) po_id = fields.Many2one( 'purchase.order', compute='_get_vals', store=True, readonly=True, string='PO' ) is_mto = fields.Boolean('Make to Order', compute='_compute_mto', store=True, ) @api.multi def name_get(self): res = [] for line in self: name = line.location_id.name + ' > ' + line.location_dest_id.name if line.product_id.code: name = line.product_id.code + ': ' + name if line.picking_id.origin: pick_rec = self.env['stock.picking'].search( [('name','=',line.picking_id.origin)]) if pick_rec.picking_type_id.code == 'incoming': name = line.picking_id.name + '/ ' + name else: name = line.picking_id.origin + '/ ' + name res.append((line.id, name)) return res @api.multi @api.depends('quant_ids', 'reserved_quant_ids', 'lot_id') def _get_quant_info(self): for m in self: if m.quant_ids: m.quant_lot_id = m.quant_ids[0].lot_id and \ m.quant_ids[0].lot_id.id m.quant_owner_id = m.quant_ids[0].owner_id and \ m.quant_ids[0].owner_id.id elif m.reserved_quant_ids: m.quant_lot_id = m.reserved_quant_ids[0].lot_id and \ m.reserved_quant_ids[0].lot_id.id m.quant_owner_id = m.reserved_quant_ids[0].owner_id and \ m.reserved_quant_ids[0].owner_id.id else: m.quant_lot_id = m.lot_id.id # below part does not work since quant is generated after # this step # if m.lot_id.quant_ids: # m.quant_owner_id = m.lot_id.quant_ids[-1].owner_id and \ # m.lot_id.quant_ids[-1].owner_id.owner_id.id def _get_quant_info_init(self, cr, uid): # update quant info when installing/upgrading cr.execute(""" update stock_move m1 set quant_lot_id = lot, quant_owner_id = owner from (select q.lot_id as lot, q.owner_id as owner, m2.id as id from stock_quant q join stock_move m2 on q.reservation_id = m2.id) as subq where m1.id = subq.id and quant_lot_id is null """) @api.multi @api.depends('origin') def _get_vals(self): SO = self.env['sale.order'] PO = self.env['purchase.order'] for m in self: m.so_id, m.po_id = 0, 0 if m.purchase_line_id: m.po_id = m.purchase_line_id.order_id.id elif m.procurement_id and m.procurement_id.sale_line_id: m.so_id = m.procurement_id.sale_line_id.order_id.id @api.one @api.depends('procurement_id', 'purchase_line_id') def _compute_mto(self): if self.code == 'outgoing' and self.procurement_id and \ self.procurement_id.sale_line_id: self.is_mto = self.procurement_id.sale_line_id.mto elif self.code == 'incoming' and self.purchase_line_id: self.is_mto = self.purchase_line_id.mto # def init(self, cr): # move_ids = self.search(cr, SUPERUSER_ID, []) # for m in self.browse(cr, SUPERUSER_ID, move_ids): # m.pick_partner_id = m.picking_id.partner_id and m.picking_id.partner_id.id # if m.quant_ids: # m.quant_lot_id = m.quant_ids[0].lot_id and m.quant_ids[0].lot_id.id # m.quant_owner_id = m.quant_ids[0].owner_id and m.quant_ids[0].owner_id.id @api.model def _prepare_picking_assign(self, move): res = super(StockMove, self)._prepare_picking_assign(move) res['is_mto'] = move.is_mto return res def action_assign(self, cr, uid, ids, context=None): # NEED TO OVERRIDE COMPLETE METHOD SINCE LOGIC WAS IN BETWEEN THE # LINES. SEE #oscg TAG FOR CHANGES DONE ON THIS METHOD. """ Checks the product type and accordingly writes the state. """ context = context or {} quant_obj = self.pool.get("stock.quant") to_assign_moves = [] main_domain = {} todo_moves = [] operations = set() for move in self.browse(cr, uid, ids, context=context): if move.state not in ('confirmed', 'waiting', 'assigned'): continue if move.location_id.usage in ('supplier', 'inventory', 'production'): to_assign_moves.append(move.id) #in case the move is returned, we want to try to find quants before forcing the assignment if not move.origin_returned_move_id: continue if move.product_id.type == 'consu': to_assign_moves.append(move.id) continue else: todo_moves.append(move) #we always keep the quants already assigned and try to find the remaining quantity on quants not assigned only main_domain[move.id] = [('reservation_id', '=', False), ('qty', '>', 0)] # oscg add # this is to prevent reserving quants that are taken by # quotations for supplier return outgoing move if move.location_dest_id.usage == 'supplier': main_domain[move.id] += [('sale_id', '=', False)] #if the move is preceeded, restrict the choice of quants in the ones moved previously in original move ancestors = self.find_move_ancestors(cr, uid, move, context=context) if move.state == 'waiting' and not ancestors: #if the waiting move hasn't yet any ancestor (PO/MO not confirmed yet), don't find any quant available in stock main_domain[move.id] += [('id', '=', False)] elif ancestors: main_domain[move.id] += [('history_ids', 'in', ancestors)] #if the move is returned from another, restrict the choice of quants to the ones that follow the returned move if move.origin_returned_move_id: main_domain[move.id] += [('history_ids', 'in', move.origin_returned_move_id.id)] for link in move.linked_move_operation_ids: operations.add(link.operation_id) # Check all ops and sort them: we want to process first the packages, then operations with lot then the rest operations = list(operations) operations.sort(key=lambda x: ((x.package_id and not x.product_id) and -4 or 0) + (x.package_id and -2 or 0) + (x.lot_id and -1 or 0)) for ops in operations: #first try to find quants based on specific domains given by linked operations for record in ops.linked_move_operation_ids: move = record.move_id if move.id in main_domain: domain = main_domain[move.id] + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context) qty = record.qty if qty: # add a serial number field in SO line, which should be passed to delivery order # to reserve a quant of the selected serial number if record.move_id.quant_id: #oscg quants = [(record.move_id.quant_id, record.move_id.quant_id.qty)] #oscg else: #oscg quants = quant_obj.quants_get_prefered_domain(cr, uid, ops.location_id, move.product_id, qty, domain=domain, prefered_domain_list=[], restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.\ id, context=context) #oscg quant_obj.quants_reserve(cr, uid, quants, move, record, context=context) for move in todo_moves: if move.linked_move_operation_ids: continue # then if the move isn't totally assigned, try to find quants without any specific domain if move.state != 'assigned': qty_already_assigned = move.reserved_availability qty = move.product_qty - qty_already_assigned # add a serial number field in SO line, which should be passed to delivery order # to reserve a quant of the selected serial number if move.quant_id: #oscg quants = [(move.quant_id, qty)] #oscg else: #oscg quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, qty, domain=main_domain[move.id], prefered_domain_list=[], restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context) #oscg quant_obj.quants_reserve(cr, uid, quants, move, context=context) #force assignation of consumable products and incoming from supplier/inventory/production if to_assign_moves: self.force_assign(cr, uid, to_assign_moves, context=context)
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6900, 13, 10680, 5843, 285, 7172, 14620, 471, 199, 3, 844, 437, 12006, 13, 19, 14, 16, 503, 2945, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 14, 1360, 680, 199, 199, 504, 5166, 492, 1709, 12, 1504, 12, 2986, 12, 485, 421, 199, 533, 28406, 10370, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 298, 6088, 14, 1185, 2, 339, 3732, 63, 3899, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 4048, 534, 11463, 63, 344, 14, 3899, 63, 344, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 8587, 31351, 7, 272, 776, 272, 12433, 63, 466, 63, 600, 275, 1504, 14, 7713, 8, 267, 4048, 534, 11463, 63, 466, 63, 344, 14, 600, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 8587, 316, 2434, 5495, 7, 272, 776, 272, 15381, 63, 1653, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 6088, 14, 10777, 14, 1653, 297, 267, 4526, 17574, 362, 63, 13603, 63, 815, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 1538, 3091, 3530, 272, 776, 272, 15381, 63, 4597, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 470, 14, 3899, 297, 267, 4526, 17574, 362, 63, 13603, 63, 815, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 14919, 7, 272, 776, 272, 880, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 8515, 14, 1648, 297, 267, 4526, 17574, 362, 63, 3643, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 4118, 7, 272, 776, 272, 1115, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 9533, 14, 1648, 297, 267, 4526, 17574, 362, 63, 3643, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 1512, 7, 272, 776, 272, 365, 63, 77, 475, 275, 1504, 14, 4082, 360, 5483, 370, 9240, 297, 267, 4526, 17574, 3357, 63, 77, 475, 297, 267, 3877, 29, 549, 12, 272, 776, 2378, 768, 1246, 14, 3029, 272, 347, 536, 63, 362, 8, 277, 304, 267, 522, 275, 942, 267, 367, 1004, 315, 291, 26, 288, 536, 275, 1004, 14, 1985, 63, 344, 14, 354, 435, 283, 690, 283, 435, 1004, 14, 1985, 63, 2614, 63, 344, 14, 354, 288, 340, 1004, 14, 2558, 63, 344, 14, 600, 26, 355, 536, 275, 1004, 14, 2558, 63, 344, 14, 600, 435, 7596, 283, 435, 536, 288, 340, 1004, 14, 11463, 63, 344, 14, 6493, 26, 355, 3732, 63, 2761, 275, 291, 14, 1813, 459, 6088, 14, 11463, 2278, 1733, 8, 717, 4274, 354, 18937, 604, 14, 11463, 63, 344, 14, 6493, 3948, 355, 340, 3732, 63, 2761, 14, 11463, 63, 466, 63, 344, 14, 600, 508, 283, 15994, 356, 490, 536, 275, 1004, 14, 11463, 63, 344, 14, 354, 435, 1994, 283, 435, 536, 355, 587, 26, 490, 536, 275, 1004, 14, 11463, 63, 344, 14, 6493, 435, 1994, 283, 435, 536, 288, 522, 14, 740, 1332, 604, 14, 344, 12, 536, 430, 267, 372, 522, 339, 768, 1246, 14, 3029, 272, 768, 1246, 14, 8912, 360, 13603, 63, 1580, 297, 283, 10421, 63, 13603, 63, 1580, 297, 283, 1653, 63, 344, 358, 272, 347, 485, 362, 63, 13603, 63, 815, 8, 277, 304, 267, 367, 333, 315, 291, 26, 288, 340, 333, 14, 13603, 63, 1580, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 436, 971, 490, 333, 14, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 14, 344, 355, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 436, 971, 490, 333, 14, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 14, 344, 288, 916, 333, 14, 10421, 63, 13603, 63, 1580, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 436, 971, 490, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 14, 344, 355, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 436, 971, 490, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 14, 344, 288, 587, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 1653, 63, 344, 14, 344, 355, 327, 5084, 1777, 1630, 440, 1736, 3967, 15381, 365, 4046, 2410, 355, 327, 642, 3650, 199, 3, 463, 340, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 26, 199, 3, 9326, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 1988, 17, 1055, 4597, 63, 344, 436, 971, 199, 3, 12793, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 1988, 17, 1055, 4597, 63, 344, 14, 4597, 63, 344, 14, 344, 339, 347, 485, 362, 63, 13603, 63, 815, 63, 826, 8, 277, 12, 2467, 12, 1747, 304, 267, 327, 1678, 15381, 2256, 1380, 22200, 15, 384, 16050, 267, 2467, 14, 2526, 4852, 288, 1678, 10952, 63, 1185, 333, 17, 288, 663, 15381, 63, 1653, 63, 344, 275, 13918, 12, 15381, 63, 4597, 63, 344, 275, 5771, 288, 687, 334, 2416, 1894, 14, 1653, 63, 344, 465, 13918, 12, 1894, 14, 4597, 63, 344, 465, 5771, 12, 333, 18, 14, 344, 465, 1305, 2116, 687, 10952, 63, 13603, 1894, 2116, 4263, 10952, 63, 1185, 333, 18, 641, 1894, 14, 20522, 63, 344, 275, 333, 18, 14, 344, 9, 465, 1007, 81, 288, 2382, 333, 17, 14, 344, 275, 1007, 81, 14, 344, 288, 436, 15381, 63, 1653, 63, 344, 365, 2973, 267, 7857, 339, 768, 1246, 14, 3029, 272, 768, 1246, 14, 8912, 360, 6493, 358, 272, 347, 485, 362, 63, 3643, 8, 277, 304, 267, 3562, 275, 291, 14, 1813, 459, 8515, 14, 1648, 418, 267, 3625, 275, 291, 14, 1813 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6900, 13, 10680, 5843, 285, 7172, 14620, 471, 199, 3, 844, 437, 12006, 13, 19, 14, 16, 503, 2945, 334, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 643, 1168, 14, 1360, 680, 199, 199, 504, 5166, 492, 1709, 12, 1504, 12, 2986, 12, 485, 421, 199, 533, 28406, 10370, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 298, 6088, 14, 1185, 2, 339, 3732, 63, 3899, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 4048, 534, 11463, 63, 344, 14, 3899, 63, 344, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 8587, 31351, 7, 272, 776, 272, 12433, 63, 466, 63, 600, 275, 1504, 14, 7713, 8, 267, 4048, 534, 11463, 63, 466, 63, 344, 14, 600, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 8587, 316, 2434, 5495, 7, 272, 776, 272, 15381, 63, 1653, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 6088, 14, 10777, 14, 1653, 297, 267, 4526, 17574, 362, 63, 13603, 63, 815, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 1538, 3091, 3530, 272, 776, 272, 15381, 63, 4597, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 470, 14, 3899, 297, 267, 4526, 17574, 362, 63, 13603, 63, 815, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 14919, 7, 272, 776, 272, 880, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 8515, 14, 1648, 297, 267, 4526, 17574, 362, 63, 3643, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 4118, 7, 272, 776, 272, 1115, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 9533, 14, 1648, 297, 267, 4526, 17574, 362, 63, 3643, 297, 267, 3877, 29, 549, 12, 267, 6863, 29, 549, 12, 267, 1059, 534, 1512, 7, 272, 776, 272, 365, 63, 77, 475, 275, 1504, 14, 4082, 360, 5483, 370, 9240, 297, 267, 4526, 17574, 3357, 63, 77, 475, 297, 267, 3877, 29, 549, 12, 272, 776, 2378, 768, 1246, 14, 3029, 272, 347, 536, 63, 362, 8, 277, 304, 267, 522, 275, 942, 267, 367, 1004, 315, 291, 26, 288, 536, 275, 1004, 14, 1985, 63, 344, 14, 354, 435, 283, 690, 283, 435, 1004, 14, 1985, 63, 2614, 63, 344, 14, 354, 288, 340, 1004, 14, 2558, 63, 344, 14, 600, 26, 355, 536, 275, 1004, 14, 2558, 63, 344, 14, 600, 435, 7596, 283, 435, 536, 288, 340, 1004, 14, 11463, 63, 344, 14, 6493, 26, 355, 3732, 63, 2761, 275, 291, 14, 1813, 459, 6088, 14, 11463, 2278, 1733, 8, 717, 4274, 354, 18937, 604, 14, 11463, 63, 344, 14, 6493, 3948, 355, 340, 3732, 63, 2761, 14, 11463, 63, 466, 63, 344, 14, 600, 508, 283, 15994, 356, 490, 536, 275, 1004, 14, 11463, 63, 344, 14, 354, 435, 1994, 283, 435, 536, 355, 587, 26, 490, 536, 275, 1004, 14, 11463, 63, 344, 14, 6493, 435, 1994, 283, 435, 536, 288, 522, 14, 740, 1332, 604, 14, 344, 12, 536, 430, 267, 372, 522, 339, 768, 1246, 14, 3029, 272, 768, 1246, 14, 8912, 360, 13603, 63, 1580, 297, 283, 10421, 63, 13603, 63, 1580, 297, 283, 1653, 63, 344, 358, 272, 347, 485, 362, 63, 13603, 63, 815, 8, 277, 304, 267, 367, 333, 315, 291, 26, 288, 340, 333, 14, 13603, 63, 1580, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 436, 971, 490, 333, 14, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 14, 344, 355, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 436, 971, 490, 333, 14, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 14, 344, 288, 916, 333, 14, 10421, 63, 13603, 63, 1580, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 436, 971, 490, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 1653, 63, 344, 14, 344, 355, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 436, 971, 490, 333, 14, 10421, 63, 13603, 63, 1580, 59, 16, 1055, 4597, 63, 344, 14, 344, 288, 587, 26, 355, 333, 14, 13603, 63, 1653, 63, 344, 275, 333, 14, 1653, 63, 344, 14, 344, 355, 327, 5084, 1777, 1630, 440, 1736, 3967, 15381, 365, 4046, 2410, 355, 327, 642, 3650, 199, 3, 463, 340, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 26, 199, 3, 9326, 333, 14, 13603, 63, 4597, 63, 344, 275, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 1988, 17, 1055, 4597, 63, 344, 436, 971, 199, 3, 12793, 333, 14, 1653, 63, 344, 14, 13603, 63, 1580, 1988, 17, 1055, 4597, 63, 344, 14, 4597, 63, 344, 14, 344, 339, 347, 485, 362, 63, 13603, 63, 815, 63, 826, 8, 277, 12, 2467, 12, 1747, 304, 267, 327, 1678, 15381, 2256, 1380, 22200, 15, 384, 16050, 267, 2467, 14, 2526, 4852, 288, 1678, 10952, 63, 1185, 333, 17, 288, 663, 15381, 63, 1653, 63, 344, 275, 13918, 12, 15381, 63, 4597, 63, 344, 275, 5771, 288, 687, 334, 2416, 1894, 14, 1653, 63, 344, 465, 13918, 12, 1894, 14, 4597, 63, 344, 465, 5771, 12, 333, 18, 14, 344, 465, 1305, 2116, 687, 10952, 63, 13603, 1894, 2116, 4263, 10952, 63, 1185, 333, 18, 641, 1894, 14, 20522, 63, 344, 275, 333, 18, 14, 344, 9, 465, 1007, 81, 288, 2382, 333, 17, 14, 344, 275, 1007, 81, 14, 344, 288, 436, 15381, 63, 1653, 63, 344, 365, 2973, 267, 7857, 339, 768, 1246, 14, 3029, 272, 768, 1246, 14, 8912, 360, 6493, 358, 272, 347, 485, 362, 63, 3643, 8, 277, 304, 267, 3562, 275, 291, 14, 1813, 459, 8515, 14, 1648, 418, 267, 3625, 275, 291, 14, 1813, 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, 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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 ]
fzalkow/scikit-learn
sklearn/linear_model/tests/test_omp.py
272
7752
# Author: Vlad Niculae # Licence: BSD 3 clause import numpy as np from sklearn.utils.testing import assert_raises from sklearn.utils.testing import assert_true from sklearn.utils.testing import assert_equal from sklearn.utils.testing import assert_array_equal from sklearn.utils.testing import assert_array_almost_equal from sklearn.utils.testing import assert_warns from sklearn.utils.testing import ignore_warnings from sklearn.linear_model import (orthogonal_mp, orthogonal_mp_gram, OrthogonalMatchingPursuit, OrthogonalMatchingPursuitCV, LinearRegression) from sklearn.utils import check_random_state from sklearn.datasets import make_sparse_coded_signal n_samples, n_features, n_nonzero_coefs, n_targets = 20, 30, 5, 3 y, X, gamma = make_sparse_coded_signal(n_targets, n_features, n_samples, n_nonzero_coefs, random_state=0) G, Xy = np.dot(X.T, X), np.dot(X.T, y) # this makes X (n_samples, n_features) # and y (n_samples, 3) def test_correct_shapes(): assert_equal(orthogonal_mp(X, y[:, 0], n_nonzero_coefs=5).shape, (n_features,)) assert_equal(orthogonal_mp(X, y, n_nonzero_coefs=5).shape, (n_features, 3)) def test_correct_shapes_gram(): assert_equal(orthogonal_mp_gram(G, Xy[:, 0], n_nonzero_coefs=5).shape, (n_features,)) assert_equal(orthogonal_mp_gram(G, Xy, n_nonzero_coefs=5).shape, (n_features, 3)) def test_n_nonzero_coefs(): assert_true(np.count_nonzero(orthogonal_mp(X, y[:, 0], n_nonzero_coefs=5)) <= 5) assert_true(np.count_nonzero(orthogonal_mp(X, y[:, 0], n_nonzero_coefs=5, precompute=True)) <= 5) def test_tol(): tol = 0.5 gamma = orthogonal_mp(X, y[:, 0], tol=tol) gamma_gram = orthogonal_mp(X, y[:, 0], tol=tol, precompute=True) assert_true(np.sum((y[:, 0] - np.dot(X, gamma)) ** 2) <= tol) assert_true(np.sum((y[:, 0] - np.dot(X, gamma_gram)) ** 2) <= tol) def test_with_without_gram(): assert_array_almost_equal( orthogonal_mp(X, y, n_nonzero_coefs=5), orthogonal_mp(X, y, n_nonzero_coefs=5, precompute=True)) def test_with_without_gram_tol(): assert_array_almost_equal( orthogonal_mp(X, y, tol=1.), orthogonal_mp(X, y, tol=1., precompute=True)) def test_unreachable_accuracy(): assert_array_almost_equal( orthogonal_mp(X, y, tol=0), orthogonal_mp(X, y, n_nonzero_coefs=n_features)) assert_array_almost_equal( assert_warns(RuntimeWarning, orthogonal_mp, X, y, tol=0, precompute=True), orthogonal_mp(X, y, precompute=True, n_nonzero_coefs=n_features)) def test_bad_input(): assert_raises(ValueError, orthogonal_mp, X, y, tol=-1) assert_raises(ValueError, orthogonal_mp, X, y, n_nonzero_coefs=-1) assert_raises(ValueError, orthogonal_mp, X, y, n_nonzero_coefs=n_features + 1) assert_raises(ValueError, orthogonal_mp_gram, G, Xy, tol=-1) assert_raises(ValueError, orthogonal_mp_gram, G, Xy, n_nonzero_coefs=-1) assert_raises(ValueError, orthogonal_mp_gram, G, Xy, n_nonzero_coefs=n_features + 1) def test_perfect_signal_recovery(): idx, = gamma[:, 0].nonzero() gamma_rec = orthogonal_mp(X, y[:, 0], 5) gamma_gram = orthogonal_mp_gram(G, Xy[:, 0], 5) assert_array_equal(idx, np.flatnonzero(gamma_rec)) assert_array_equal(idx, np.flatnonzero(gamma_gram)) assert_array_almost_equal(gamma[:, 0], gamma_rec, decimal=2) assert_array_almost_equal(gamma[:, 0], gamma_gram, decimal=2) def test_estimator(): omp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_nonzero_coefs) omp.fit(X, y[:, 0]) assert_equal(omp.coef_.shape, (n_features,)) assert_equal(omp.intercept_.shape, ()) assert_true(np.count_nonzero(omp.coef_) <= n_nonzero_coefs) omp.fit(X, y) assert_equal(omp.coef_.shape, (n_targets, n_features)) assert_equal(omp.intercept_.shape, (n_targets,)) assert_true(np.count_nonzero(omp.coef_) <= n_targets * n_nonzero_coefs) omp.set_params(fit_intercept=False, normalize=False) omp.fit(X, y[:, 0]) assert_equal(omp.coef_.shape, (n_features,)) assert_equal(omp.intercept_, 0) assert_true(np.count_nonzero(omp.coef_) <= n_nonzero_coefs) omp.fit(X, y) assert_equal(omp.coef_.shape, (n_targets, n_features)) assert_equal(omp.intercept_, 0) assert_true(np.count_nonzero(omp.coef_) <= n_targets * n_nonzero_coefs) def test_identical_regressors(): newX = X.copy() newX[:, 1] = newX[:, 0] gamma = np.zeros(n_features) gamma[0] = gamma[1] = 1. newy = np.dot(newX, gamma) assert_warns(RuntimeWarning, orthogonal_mp, newX, newy, 2) def test_swapped_regressors(): gamma = np.zeros(n_features) # X[:, 21] should be selected first, then X[:, 0] selected second, # which will take X[:, 21]'s place in case the algorithm does # column swapping for optimization (which is the case at the moment) gamma[21] = 1.0 gamma[0] = 0.5 new_y = np.dot(X, gamma) new_Xy = np.dot(X.T, new_y) gamma_hat = orthogonal_mp(X, new_y, 2) gamma_hat_gram = orthogonal_mp_gram(G, new_Xy, 2) assert_array_equal(np.flatnonzero(gamma_hat), [0, 21]) assert_array_equal(np.flatnonzero(gamma_hat_gram), [0, 21]) def test_no_atoms(): y_empty = np.zeros_like(y) Xy_empty = np.dot(X.T, y_empty) gamma_empty = ignore_warnings(orthogonal_mp)(X, y_empty, 1) gamma_empty_gram = ignore_warnings(orthogonal_mp)(G, Xy_empty, 1) assert_equal(np.all(gamma_empty == 0), True) assert_equal(np.all(gamma_empty_gram == 0), True) def test_omp_path(): path = orthogonal_mp(X, y, n_nonzero_coefs=5, return_path=True) last = orthogonal_mp(X, y, n_nonzero_coefs=5, return_path=False) assert_equal(path.shape, (n_features, n_targets, 5)) assert_array_almost_equal(path[:, :, -1], last) path = orthogonal_mp_gram(G, Xy, n_nonzero_coefs=5, return_path=True) last = orthogonal_mp_gram(G, Xy, n_nonzero_coefs=5, return_path=False) assert_equal(path.shape, (n_features, n_targets, 5)) assert_array_almost_equal(path[:, :, -1], last) def test_omp_return_path_prop_with_gram(): path = orthogonal_mp(X, y, n_nonzero_coefs=5, return_path=True, precompute=True) last = orthogonal_mp(X, y, n_nonzero_coefs=5, return_path=False, precompute=True) assert_equal(path.shape, (n_features, n_targets, 5)) assert_array_almost_equal(path[:, :, -1], last) def test_omp_cv(): y_ = y[:, 0] gamma_ = gamma[:, 0] ompcv = OrthogonalMatchingPursuitCV(normalize=True, fit_intercept=False, max_iter=10, cv=5) ompcv.fit(X, y_) assert_equal(ompcv.n_nonzero_coefs_, n_nonzero_coefs) assert_array_almost_equal(ompcv.coef_, gamma_) omp = OrthogonalMatchingPursuit(normalize=True, fit_intercept=False, n_nonzero_coefs=ompcv.n_nonzero_coefs_) omp.fit(X, y_) assert_array_almost_equal(ompcv.coef_, omp.coef_) def test_omp_reaches_least_squares(): # Use small simple data; it's a sanity check but OMP can stop early rng = check_random_state(0) n_samples, n_features = (10, 8) n_targets = 3 X = rng.randn(n_samples, n_features) Y = rng.randn(n_samples, n_targets) omp = OrthogonalMatchingPursuit(n_nonzero_coefs=n_features) lstsq = LinearRegression() omp.fit(X, Y) lstsq.fit(X, Y) assert_array_almost_equal(omp.coef_, lstsq.coef_)
bsd-3-clause
[ 3, 6529, 26, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 491, 530, 4894, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 199, 504, 6357, 14, 1208, 14, 4776, 492, 3686, 63, 5451, 421, 199, 504, 6357, 14, 6676, 63, 1238, 492, 334, 11297, 19133, 63, 311, 12, 29069, 63, 311, 63, 1679, 12, 3303, 4236, 273, 19133, 14215, 14959, 83, 4993, 12, 3303, 4236, 273, 19133, 14215, 14959, 83, 4993, 12847, 12, 3303, 12489, 13013, 9, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 6357, 14, 12281, 492, 1852, 63, 4421, 63, 15282, 63, 4653, 199, 199, 78, 63, 3356, 12, 302, 63, 3179, 12, 302, 63, 10262, 63, 22892, 12, 302, 63, 4684, 275, 3388, 12, 4233, 12, 959, 12, 650, 199, 89, 12, 1323, 12, 10169, 275, 1852, 63, 4421, 63, 15282, 63, 4653, 8, 78, 63, 4684, 12, 302, 63, 3179, 12, 302, 63, 3356, 12, 4318, 302, 63, 10262, 63, 22892, 12, 2196, 63, 929, 29, 16, 9, 199, 39, 12, 1323, 89, 275, 980, 14, 3287, 8, 56, 14, 52, 12, 1323, 395, 980, 14, 3287, 8, 56, 14, 52, 12, 612, 9, 199, 3, 642, 7704, 1323, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 199, 3, 436, 612, 334, 78, 63, 3356, 12, 650, 9, 421, 199, 318, 511, 63, 4525, 63, 9069, 837, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 4641, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 12, 650, 430, 421, 199, 318, 511, 63, 4525, 63, 9069, 63, 1679, 837, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 63, 1679, 8, 39, 12, 1323, 89, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 4641, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 63, 1679, 8, 39, 12, 1323, 89, 12, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 12, 650, 430, 421, 199, 318, 511, 63, 78, 63, 10262, 63, 22892, 837, 272, 702, 63, 2052, 8, 1590, 14, 835, 63, 10262, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 639, 302, 63, 10262, 63, 22892, 29, 21, 430, 2695, 959, 9, 272, 702, 63, 2052, 8, 1590, 14, 835, 63, 10262, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 12, 6901, 876, 3357, 29, 549, 430, 2695, 959, 9, 421, 199, 318, 511, 63, 6896, 837, 272, 9561, 275, 378, 14, 21, 272, 10169, 275, 29069, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 9561, 29, 6896, 9, 272, 10169, 63, 1679, 275, 29069, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 9561, 29, 6896, 12, 876, 3357, 29, 549, 9, 272, 702, 63, 2052, 8, 1590, 14, 1838, 1332, 89, 3981, 378, 61, 446, 980, 14, 3287, 8, 56, 12, 10169, 430, 1011, 499, 9, 2695, 9561, 9, 272, 702, 63, 2052, 8, 1590, 14, 1838, 1332, 89, 3981, 378, 61, 446, 980, 14, 3287, 8, 56, 12, 10169, 63, 1679, 430, 1011, 499, 9, 2695, 9561, 9, 421, 199, 318, 511, 63, 1045, 63, 7395, 63, 1679, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 12, 876, 3357, 29, 549, 430, 421, 199, 318, 511, 63, 1045, 63, 7395, 63, 1679, 63, 6896, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 17, 15631, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 17, 2020, 876, 3357, 29, 549, 430, 421, 199, 318, 511, 63, 26522, 63, 13374, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 16, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 430, 339, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 702, 63, 19811, 8, 14357, 3849, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 9561, 29, 16, 12, 2151, 876, 3357, 29, 549, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 876, 3357, 29, 549, 12, 1993, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 430, 421, 199, 318, 511, 63, 4087, 63, 1210, 837, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 9561, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 302, 63, 10262, 63, 22892, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 2116, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 435, 413, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 9561, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 302, 63, 10262, 63, 22892, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 2116, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 435, 413 ]
[ 6529, 26, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 491, 530, 4894, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 199, 504, 6357, 14, 1208, 14, 4776, 492, 3686, 63, 5451, 421, 199, 504, 6357, 14, 6676, 63, 1238, 492, 334, 11297, 19133, 63, 311, 12, 29069, 63, 311, 63, 1679, 12, 3303, 4236, 273, 19133, 14215, 14959, 83, 4993, 12, 3303, 4236, 273, 19133, 14215, 14959, 83, 4993, 12847, 12, 3303, 12489, 13013, 9, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 199, 504, 6357, 14, 12281, 492, 1852, 63, 4421, 63, 15282, 63, 4653, 199, 199, 78, 63, 3356, 12, 302, 63, 3179, 12, 302, 63, 10262, 63, 22892, 12, 302, 63, 4684, 275, 3388, 12, 4233, 12, 959, 12, 650, 199, 89, 12, 1323, 12, 10169, 275, 1852, 63, 4421, 63, 15282, 63, 4653, 8, 78, 63, 4684, 12, 302, 63, 3179, 12, 302, 63, 3356, 12, 4318, 302, 63, 10262, 63, 22892, 12, 2196, 63, 929, 29, 16, 9, 199, 39, 12, 1323, 89, 275, 980, 14, 3287, 8, 56, 14, 52, 12, 1323, 395, 980, 14, 3287, 8, 56, 14, 52, 12, 612, 9, 199, 3, 642, 7704, 1323, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 199, 3, 436, 612, 334, 78, 63, 3356, 12, 650, 9, 421, 199, 318, 511, 63, 4525, 63, 9069, 837, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 4641, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 12, 650, 430, 421, 199, 318, 511, 63, 4525, 63, 9069, 63, 1679, 837, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 63, 1679, 8, 39, 12, 1323, 89, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 4641, 272, 702, 63, 1452, 8, 11297, 19133, 63, 311, 63, 1679, 8, 39, 12, 1323, 89, 12, 302, 63, 10262, 63, 22892, 29, 21, 680, 1392, 12, 326, 334, 78, 63, 3179, 12, 650, 430, 421, 199, 318, 511, 63, 78, 63, 10262, 63, 22892, 837, 272, 702, 63, 2052, 8, 1590, 14, 835, 63, 10262, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 639, 302, 63, 10262, 63, 22892, 29, 21, 430, 2695, 959, 9, 272, 702, 63, 2052, 8, 1590, 14, 835, 63, 10262, 8, 11297, 19133, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 302, 63, 10262, 63, 22892, 29, 21, 12, 6901, 876, 3357, 29, 549, 430, 2695, 959, 9, 421, 199, 318, 511, 63, 6896, 837, 272, 9561, 275, 378, 14, 21, 272, 10169, 275, 29069, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 9561, 29, 6896, 9, 272, 10169, 63, 1679, 275, 29069, 63, 311, 8, 56, 12, 612, 3981, 378, 467, 9561, 29, 6896, 12, 876, 3357, 29, 549, 9, 272, 702, 63, 2052, 8, 1590, 14, 1838, 1332, 89, 3981, 378, 61, 446, 980, 14, 3287, 8, 56, 12, 10169, 430, 1011, 499, 9, 2695, 9561, 9, 272, 702, 63, 2052, 8, 1590, 14, 1838, 1332, 89, 3981, 378, 61, 446, 980, 14, 3287, 8, 56, 12, 10169, 63, 1679, 430, 1011, 499, 9, 2695, 9561, 9, 421, 199, 318, 511, 63, 1045, 63, 7395, 63, 1679, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 21, 12, 876, 3357, 29, 549, 430, 421, 199, 318, 511, 63, 1045, 63, 7395, 63, 1679, 63, 6896, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 17, 15631, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 17, 2020, 876, 3357, 29, 549, 430, 421, 199, 318, 511, 63, 26522, 63, 13374, 837, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 9561, 29, 16, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 430, 339, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 702, 63, 19811, 8, 14357, 3849, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 9561, 29, 16, 12, 2151, 876, 3357, 29, 549, 395, 267, 29069, 63, 311, 8, 56, 12, 612, 12, 876, 3357, 29, 549, 12, 1993, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 430, 421, 199, 318, 511, 63, 4087, 63, 1210, 837, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 9561, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 302, 63, 10262, 63, 22892, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 12, 1323, 12, 612, 12, 2116, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 435, 413, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 9561, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 302, 63, 10262, 63, 22892, 4022, 17, 9, 272, 702, 63, 3536, 8, 3393, 12, 29069, 63, 311, 63, 1679, 12, 598, 12, 1323, 89, 12, 2116, 302, 63, 10262, 63, 22892, 29, 78, 63, 3179, 435, 413, 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, 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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 ]
mikebenfield/scipy
tools/gh_lists.py
99
4195
#!/usr/bin/env python # -*- encoding:utf-8 -*- """ gh_lists.py MILESTONE Functions for Github API requests. """ from __future__ import print_function, division, absolute_import import os import re import sys import json import collections import argparse from urllib2 import urlopen Issue = collections.namedtuple('Issue', ('id', 'title', 'url')) def main(): p = argparse.ArgumentParser(usage=__doc__.lstrip()) p.add_argument('--project', default='scipy/scipy') p.add_argument('milestone') args = p.parse_args() getter = CachedGet('gh_cache.json') try: milestones = get_milestones(getter, args.project) if args.milestone not in milestones: msg = "Milestone {0} not available. Available milestones: {1}" msg = msg.format(args.milestone, u", ".join(sorted(milestones))) p.error(msg) issues = get_issues(getter, args.project, args.milestone) issues.sort() finally: getter.save() prs = [x for x in issues if u'/pull/' in x.url] issues = [x for x in issues if x not in prs] def print_list(title, items): print() print(title) print("-"*len(title)) print() for issue in items: msg = u"- `#{0} <{1}>`__: {2}" title = re.sub(u"\s+", u" ", issue.title.strip()) if len(title) > 60: remainder = re.sub(u"\s.*$", u"...", title[60:]) if len(remainder) > 20: remainder = title[:80] + u"..." else: title = title[:60] + remainder msg = msg.format(issue.id, issue.url, title) print(msg) print() msg = u"Issues closed for {0}".format(args.milestone) print_list(msg, issues) msg = u"Pull requests for {0}".format(args.milestone) print_list(msg, prs) return 0 def get_milestones(getter, project): url = "https://api.github.com/repos/{project}/milestones".format(project=project) raw_data, info = getter.get(url) data = json.loads(raw_data) milestones = {} for ms in data: milestones[ms[u'title']] = ms[u'number'] return milestones def get_issues(getter, project, milestone): milestones = get_milestones(getter, project) mid = milestones[milestone] url = "https://api.github.com/repos/{project}/issues?milestone={mid}&state=closed&sort=created&direction=asc" url = url.format(project=project, mid=mid) raw_datas = [] while True: raw_data, info = getter.get(url) raw_datas.append(raw_data) if 'link' not in info: break m = re.search('<(.*?)>; rel="next"', info['link']) if m: url = m.group(1) continue break issues = [] for raw_data in raw_datas: data = json.loads(raw_data) for issue_data in data: issues.append(Issue(issue_data[u'number'], issue_data[u'title'], issue_data[u'html_url'])) return issues class CachedGet(object): def __init__(self, filename): self.filename = filename if os.path.isfile(filename): print("[gh_lists] using {0} as cache (remove it if you want fresh data)".format(filename), file=sys.stderr) with open(filename, 'rb') as f: self.cache = json.load(f) else: self.cache = {} def get(self, url): url = unicode(url) if url not in self.cache: print("[gh_lists] get:", url, file=sys.stderr) req = urlopen(url) if req.getcode() != 200: raise RuntimeError() data = req.read() info = dict(req.info()) self.cache[url] = (data, info) req.close() else: print("[gh_lists] get (cached):", url, file=sys.stderr) return self.cache[url] def save(self): tmp = self.filename + ".new" with open(tmp, 'wb') as f: json.dump(self.cache, f) os.rename(tmp, self.filename) if __name__ == "__main__": sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2644, 26, 1624, 13, 24, 1882, 199, 624, 199, 3561, 63, 6717, 14, 647, 603, 1193, 1719, 4817, 199, 199, 13967, 367, 598, 4049, 3261, 4145, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2022, 199, 646, 5055, 199, 646, 7534, 199, 199, 504, 4011, 18, 492, 18279, 421, 199, 17106, 275, 5055, 14, 18921, 360, 17106, 297, 661, 344, 297, 283, 1213, 297, 283, 633, 1333, 421, 199, 318, 2446, 837, 272, 299, 275, 7534, 14, 10730, 8, 3807, 18971, 1301, 4343, 10124, 1012, 272, 299, 14, 525, 63, 2094, 4517, 1715, 297, 849, 534, 14248, 15, 14248, 358, 272, 299, 14, 525, 63, 2094, 360, 25324, 358, 272, 1249, 275, 299, 14, 1122, 63, 589, 342, 339, 15917, 275, 445, 4583, 1002, 360, 3561, 63, 1637, 14, 1001, 358, 272, 862, 26, 267, 333, 24156, 275, 664, 63, 77, 24156, 8, 7416, 12, 1249, 14, 1715, 9, 267, 340, 1249, 14, 25324, 440, 315, 333, 24156, 26, 288, 1499, 275, 298, 45, 18072, 469, 16, 93, 440, 2808, 14, 23840, 333, 24156, 26, 469, 17, 7063, 288, 1499, 275, 1499, 14, 908, 8, 589, 14, 25324, 12, 399, 401, 3680, 904, 8, 5917, 8, 77, 24156, 1724, 288, 299, 14, 705, 8, 1328, 9, 267, 10876, 275, 664, 63, 10115, 8, 7416, 12, 1249, 14, 1715, 12, 1249, 14, 25324, 9, 267, 10876, 14, 3191, 342, 272, 3753, 26, 267, 15917, 14, 2117, 342, 339, 299, 2393, 275, 359, 88, 367, 671, 315, 10876, 340, 399, 9807, 9302, 4805, 315, 671, 14, 633, 61, 272, 10876, 275, 359, 88, 367, 671, 315, 10876, 340, 671, 440, 315, 299, 2393, 61, 339, 347, 870, 63, 513, 8, 1213, 12, 2974, 304, 267, 870, 342, 267, 870, 8, 1213, 9, 267, 870, 6096, 31761, 552, 8, 1213, 430, 267, 870, 342, 398, 367, 4976, 315, 2974, 26, 288, 1499, 275, 399, 32095, 658, 3, 91, 16, 93, 665, 91, 17, 93, 8637, 10651, 469, 18, 7063, 288, 2538, 275, 295, 14, 954, 8, 85, 3212, 83, 22758, 399, 2, 3872, 4976, 14, 1213, 14, 1913, 1012, 288, 340, 822, 8, 1213, 9, 690, 5212, 26, 355, 15748, 275, 295, 14, 954, 8, 85, 3212, 83, 2795, 11918, 399, 2, 23966, 2538, 59, 2259, 5728, 355, 340, 822, 8, 23850, 9, 690, 3388, 26, 490, 15748, 275, 2538, 1491, 1257, 61, 435, 399, 2, 11500, 355, 587, 26, 490, 2538, 275, 2538, 1491, 2259, 61, 435, 15748, 288, 1499, 275, 1499, 14, 908, 8, 5237, 14, 344, 12, 4976, 14, 633, 12, 2538, 9, 288, 870, 8, 1328, 9, 267, 870, 342, 339, 1499, 275, 399, 2, 17106, 83, 6876, 367, 469, 16, 5469, 908, 8, 589, 14, 25324, 9, 272, 870, 63, 513, 8, 1328, 12, 10876, 9, 2286, 1499, 275, 399, 2, 27318, 4145, 367, 469, 16, 5469, 908, 8, 589, 14, 25324, 9, 272, 870, 63, 513, 8, 1328, 12, 299, 2393, 9, 339, 372, 378, 421, 199, 318, 664, 63, 77, 24156, 8, 7416, 12, 2199, 304, 272, 1166, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 5321, 1715, 5995, 77, 24156, 1674, 908, 8, 1715, 29, 1715, 9, 272, 3066, 63, 576, 12, 2256, 275, 15917, 14, 362, 8, 633, 9, 272, 666, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 339, 333, 24156, 275, 1052, 272, 367, 6605, 315, 666, 26, 267, 333, 24156, 59, 706, 59, 85, 1133, 5776, 6538, 275, 6605, 59, 85, 7, 1955, 418, 272, 372, 333, 24156, 421, 199, 318, 664, 63, 10115, 8, 7416, 12, 2199, 12, 333, 18072, 304, 272, 333, 24156, 275, 664, 63, 77, 24156, 8, 7416, 12, 2199, 9, 272, 10887, 275, 333, 24156, 59, 25324, 61, 339, 1166, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 5321, 1715, 5995, 10115, 31, 25324, 3126, 8523, 93, 6, 929, 29, 5938, 6, 3191, 29, 3966, 6, 6874, 29, 10125, 2, 272, 1166, 275, 1166, 14, 908, 8, 1715, 29, 1715, 12, 10887, 29, 8523, 9, 339, 3066, 63, 11563, 275, 942, 272, 1830, 715, 26, 267, 3066, 63, 576, 12, 2256, 275, 15917, 14, 362, 8, 633, 9, 267, 3066, 63, 11563, 14, 740, 8, 1773, 63, 576, 9, 267, 340, 283, 1073, 7, 440, 315, 2256, 26, 288, 2059, 267, 333, 275, 295, 14, 1733, 4827, 17140, 13032, 27, 4668, 628, 2184, 6949, 2256, 459, 1073, 1105, 267, 340, 333, 26, 288, 1166, 275, 333, 14, 923, 8, 17, 9, 288, 1980, 267, 2059, 339, 10876, 275, 942, 339, 367, 3066, 63, 576, 315, 3066, 63, 11563, 26, 267, 666, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 267, 367, 4976, 63, 576, 315, 666, 26, 288, 10876, 14, 740, 8, 17106, 8, 5237, 63, 576, 59, 85, 7, 1955, 995, 1816, 4976, 63, 576, 59, 85, 1133, 5776, 995, 1816, 4976, 63, 576, 59, 85, 7, 1360, 63, 633, 5156, 272, 372, 10876, 421, 199, 533, 445, 4583, 1002, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1788, 304, 267, 291, 14, 1501, 275, 1788, 267, 340, 747, 14, 515, 14, 6292, 8, 1501, 304, 288, 870, 10994, 3561, 63, 6717, 61, 1808, 469, 16, 93, 465, 2581, 334, 2168, 652, 340, 1265, 2934, 17480, 666, 30351, 908, 8, 1501, 395, 2116, 570, 29, 1274, 14, 3083, 9, 288, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 355, 291, 14, 1637, 275, 2022, 14, 912, 8, 70, 9, 267, 587, 26, 288, 291, 14, 1637, 275, 1052, 339, 347, 664, 8, 277, 12, 1166, 304, 267, 1166, 275, 2649, 8, 633, 9, 267, 340, 1166, 440, 315, 291, 14, 1637, 26, 288, 870, 10994, 3561, 63, 6717, 61, 664, 6783, 1166, 12, 570, 29, 1274, 14, 3083, 9, 288, 2648, 275, 18279, 8, 633, 9, 288, 340, 2648, 14, 362, 600, 342, 1137, 1926, 26, 355, 746, 6064, 342, 288, 666, 275, 2648, 14, 739, 342, 288, 2256, 275, 1211, 8, 2103, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2644, 26, 1624, 13, 24, 1882, 199, 624, 199, 3561, 63, 6717, 14, 647, 603, 1193, 1719, 4817, 199, 199, 13967, 367, 598, 4049, 3261, 4145, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2022, 199, 646, 5055, 199, 646, 7534, 199, 199, 504, 4011, 18, 492, 18279, 421, 199, 17106, 275, 5055, 14, 18921, 360, 17106, 297, 661, 344, 297, 283, 1213, 297, 283, 633, 1333, 421, 199, 318, 2446, 837, 272, 299, 275, 7534, 14, 10730, 8, 3807, 18971, 1301, 4343, 10124, 1012, 272, 299, 14, 525, 63, 2094, 4517, 1715, 297, 849, 534, 14248, 15, 14248, 358, 272, 299, 14, 525, 63, 2094, 360, 25324, 358, 272, 1249, 275, 299, 14, 1122, 63, 589, 342, 339, 15917, 275, 445, 4583, 1002, 360, 3561, 63, 1637, 14, 1001, 358, 272, 862, 26, 267, 333, 24156, 275, 664, 63, 77, 24156, 8, 7416, 12, 1249, 14, 1715, 9, 267, 340, 1249, 14, 25324, 440, 315, 333, 24156, 26, 288, 1499, 275, 298, 45, 18072, 469, 16, 93, 440, 2808, 14, 23840, 333, 24156, 26, 469, 17, 7063, 288, 1499, 275, 1499, 14, 908, 8, 589, 14, 25324, 12, 399, 401, 3680, 904, 8, 5917, 8, 77, 24156, 1724, 288, 299, 14, 705, 8, 1328, 9, 267, 10876, 275, 664, 63, 10115, 8, 7416, 12, 1249, 14, 1715, 12, 1249, 14, 25324, 9, 267, 10876, 14, 3191, 342, 272, 3753, 26, 267, 15917, 14, 2117, 342, 339, 299, 2393, 275, 359, 88, 367, 671, 315, 10876, 340, 399, 9807, 9302, 4805, 315, 671, 14, 633, 61, 272, 10876, 275, 359, 88, 367, 671, 315, 10876, 340, 671, 440, 315, 299, 2393, 61, 339, 347, 870, 63, 513, 8, 1213, 12, 2974, 304, 267, 870, 342, 267, 870, 8, 1213, 9, 267, 870, 6096, 31761, 552, 8, 1213, 430, 267, 870, 342, 398, 367, 4976, 315, 2974, 26, 288, 1499, 275, 399, 32095, 658, 3, 91, 16, 93, 665, 91, 17, 93, 8637, 10651, 469, 18, 7063, 288, 2538, 275, 295, 14, 954, 8, 85, 3212, 83, 22758, 399, 2, 3872, 4976, 14, 1213, 14, 1913, 1012, 288, 340, 822, 8, 1213, 9, 690, 5212, 26, 355, 15748, 275, 295, 14, 954, 8, 85, 3212, 83, 2795, 11918, 399, 2, 23966, 2538, 59, 2259, 5728, 355, 340, 822, 8, 23850, 9, 690, 3388, 26, 490, 15748, 275, 2538, 1491, 1257, 61, 435, 399, 2, 11500, 355, 587, 26, 490, 2538, 275, 2538, 1491, 2259, 61, 435, 15748, 288, 1499, 275, 1499, 14, 908, 8, 5237, 14, 344, 12, 4976, 14, 633, 12, 2538, 9, 288, 870, 8, 1328, 9, 267, 870, 342, 339, 1499, 275, 399, 2, 17106, 83, 6876, 367, 469, 16, 5469, 908, 8, 589, 14, 25324, 9, 272, 870, 63, 513, 8, 1328, 12, 10876, 9, 2286, 1499, 275, 399, 2, 27318, 4145, 367, 469, 16, 5469, 908, 8, 589, 14, 25324, 9, 272, 870, 63, 513, 8, 1328, 12, 299, 2393, 9, 339, 372, 378, 421, 199, 318, 664, 63, 77, 24156, 8, 7416, 12, 2199, 304, 272, 1166, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 5321, 1715, 5995, 77, 24156, 1674, 908, 8, 1715, 29, 1715, 9, 272, 3066, 63, 576, 12, 2256, 275, 15917, 14, 362, 8, 633, 9, 272, 666, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 339, 333, 24156, 275, 1052, 272, 367, 6605, 315, 666, 26, 267, 333, 24156, 59, 706, 59, 85, 1133, 5776, 6538, 275, 6605, 59, 85, 7, 1955, 418, 272, 372, 333, 24156, 421, 199, 318, 664, 63, 10115, 8, 7416, 12, 2199, 12, 333, 18072, 304, 272, 333, 24156, 275, 664, 63, 77, 24156, 8, 7416, 12, 2199, 9, 272, 10887, 275, 333, 24156, 59, 25324, 61, 339, 1166, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 5321, 1715, 5995, 10115, 31, 25324, 3126, 8523, 93, 6, 929, 29, 5938, 6, 3191, 29, 3966, 6, 6874, 29, 10125, 2, 272, 1166, 275, 1166, 14, 908, 8, 1715, 29, 1715, 12, 10887, 29, 8523, 9, 339, 3066, 63, 11563, 275, 942, 272, 1830, 715, 26, 267, 3066, 63, 576, 12, 2256, 275, 15917, 14, 362, 8, 633, 9, 267, 3066, 63, 11563, 14, 740, 8, 1773, 63, 576, 9, 267, 340, 283, 1073, 7, 440, 315, 2256, 26, 288, 2059, 267, 333, 275, 295, 14, 1733, 4827, 17140, 13032, 27, 4668, 628, 2184, 6949, 2256, 459, 1073, 1105, 267, 340, 333, 26, 288, 1166, 275, 333, 14, 923, 8, 17, 9, 288, 1980, 267, 2059, 339, 10876, 275, 942, 339, 367, 3066, 63, 576, 315, 3066, 63, 11563, 26, 267, 666, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 267, 367, 4976, 63, 576, 315, 666, 26, 288, 10876, 14, 740, 8, 17106, 8, 5237, 63, 576, 59, 85, 7, 1955, 995, 1816, 4976, 63, 576, 59, 85, 1133, 5776, 995, 1816, 4976, 63, 576, 59, 85, 7, 1360, 63, 633, 5156, 272, 372, 10876, 421, 199, 533, 445, 4583, 1002, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1788, 304, 267, 291, 14, 1501, 275, 1788, 267, 340, 747, 14, 515, 14, 6292, 8, 1501, 304, 288, 870, 10994, 3561, 63, 6717, 61, 1808, 469, 16, 93, 465, 2581, 334, 2168, 652, 340, 1265, 2934, 17480, 666, 30351, 908, 8, 1501, 395, 2116, 570, 29, 1274, 14, 3083, 9, 288, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 355, 291, 14, 1637, 275, 2022, 14, 912, 8, 70, 9, 267, 587, 26, 288, 291, 14, 1637, 275, 1052, 339, 347, 664, 8, 277, 12, 1166, 304, 267, 1166, 275, 2649, 8, 633, 9, 267, 340, 1166, 440, 315, 291, 14, 1637, 26, 288, 870, 10994, 3561, 63, 6717, 61, 664, 6783, 1166, 12, 570, 29, 1274, 14, 3083, 9, 288, 2648, 275, 18279, 8, 633, 9, 288, 340, 2648, 14, 362, 600, 342, 1137, 1926, 26, 355, 746, 6064, 342, 288, 666, 275, 2648, 14, 739, 342, 288, 2256, 275, 1211, 8, 2103, 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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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 ]
run2/citytour
4symantec/Lib/site-packages/numpy-1.9.2-py2.7-win-amd64.egg/numpy/lib/tests/test_polynomial.py
32
4748
from __future__ import division, absolute_import, print_function ''' >>> p = np.poly1d([1.,2,3]) >>> p poly1d([ 1., 2., 3.]) >>> print(p) 2 1 x + 2 x + 3 >>> q = np.poly1d([3.,2,1]) >>> q poly1d([ 3., 2., 1.]) >>> print(q) 2 3 x + 2 x + 1 >>> print(np.poly1d([1.89999+2j, -3j, -5.12345678, 2+1j])) 3 2 (1.9 + 2j) x - 3j x - 5.123 x + (2 + 1j) >>> print(np.poly1d([-3, -2, -1])) 2 -3 x - 2 x - 1 >>> p(0) 3.0 >>> p(5) 38.0 >>> q(0) 1.0 >>> q(5) 86.0 >>> p * q poly1d([ 3., 8., 14., 8., 3.]) >>> p / q (poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])) >>> p + q poly1d([ 4., 4., 4.]) >>> p - q poly1d([-2., 0., 2.]) >>> p ** 4 poly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.]) >>> p(q) poly1d([ 9., 12., 16., 8., 6.]) >>> q(p) poly1d([ 3., 12., 32., 40., 34.]) >>> np.asarray(p) array([ 1., 2., 3.]) >>> len(p) 2 >>> p[0], p[1], p[2], p[3] (3.0, 2.0, 1.0, 0) >>> p.integ() poly1d([ 0.33333333, 1. , 3. , 0. ]) >>> p.integ(1) poly1d([ 0.33333333, 1. , 3. , 0. ]) >>> p.integ(5) poly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. , 0. , 0. , 0. ]) >>> p.deriv() poly1d([ 2., 2.]) >>> p.deriv(2) poly1d([ 2.]) >>> q = np.poly1d([1.,2,3], variable='y') >>> print(q) 2 1 y + 2 y + 3 >>> q = np.poly1d([1.,2,3], variable='lambda') >>> print(q) 2 1 lambda + 2 lambda + 3 >>> np.polydiv(np.poly1d([1,0,-1]), np.poly1d([1,1])) (poly1d([ 1., -1.]), poly1d([ 0.])) ''' import numpy as np from numpy.testing import ( run_module_suite, TestCase, assert_, assert_equal, assert_array_equal, assert_almost_equal, rundocs ) class TestDocs(TestCase): def test_doctests(self): return rundocs() def test_roots(self): assert_array_equal(np.roots([1, 0, 0]), [0, 0]) def test_str_leading_zeros(self): p = np.poly1d([4, 3, 2, 1]) p[3] = 0 assert_equal(str(p), " 2\n" "3 x + 2 x + 1") p = np.poly1d([1, 2]) p[0] = 0 p[1] = 0 assert_equal(str(p), " \n0") def test_polyfit(self): c = np.array([3., 2., 1.]) x = np.linspace(0, 2, 7) y = np.polyval(c, x) err = [1, -1, 1, -1, 1, -1, 1] weights = np.arange(8, 1, -1)**2/7.0 # check 1D case m, cov = np.polyfit(x, y+err, 2, cov=True) est = [3.8571, 0.2857, 1.619] assert_almost_equal(est, m, decimal=4) val0 = [[2.9388, -5.8776, 1.6327], [-5.8776, 12.7347, -4.2449], [1.6327, -4.2449, 2.3220]] assert_almost_equal(val0, cov, decimal=4) m2, cov2 = np.polyfit(x, y+err, 2, w=weights, cov=True) assert_almost_equal([4.8927, -1.0177, 1.7768], m2, decimal=4) val = [[8.7929, -10.0103, 0.9756], [-10.0103, 13.6134, -1.8178], [0.9756, -1.8178, 0.6674]] assert_almost_equal(val, cov2, decimal=4) # check 2D (n,1) case y = y[:, np.newaxis] c = c[:, np.newaxis] assert_almost_equal(c, np.polyfit(x, y, 2)) # check 2D (n,2) case yy = np.concatenate((y, y), axis=1) cc = np.concatenate((c, c), axis=1) assert_almost_equal(cc, np.polyfit(x, yy, 2)) m, cov = np.polyfit(x, yy + np.array(err)[:, np.newaxis], 2, cov=True) assert_almost_equal(est, m[:, 0], decimal=4) assert_almost_equal(est, m[:, 1], decimal=4) assert_almost_equal(val0, cov[:, :, 0], decimal=4) assert_almost_equal(val0, cov[:, :, 1], decimal=4) def test_objects(self): from decimal import Decimal p = np.poly1d([Decimal('4.0'), Decimal('3.0'), Decimal('2.0')]) p2 = p * Decimal('1.333333333333333') assert_(p2[1] == Decimal("3.9999999999999990")) p2 = p.deriv() assert_(p2[1] == Decimal('8.0')) p2 = p.integ() assert_(p2[3] == Decimal("1.333333333333333333333333333")) assert_(p2[2] == Decimal('1.5')) assert_(np.issubdtype(p2.coeffs.dtype, np.object_)) def test_complex(self): p = np.poly1d([3j, 2j, 1j]) p2 = p.integ() assert_((p2.coeffs == [1j, 1j, 1j, 0]).all()) p2 = p.deriv() assert_((p2.coeffs == [6j, 2j]).all()) def test_integ_coeffs(self): p = np.poly1d([3, 2, 1]) p2 = p.integ(3, k=[9, 7, 6]) assert_( (p2.coeffs == [1/4./5., 1/3./4., 1/2./3., 9/1./2., 7, 6]).all()) def test_zero_dims(self): try: np.poly(np.zeros((0, 0))) except ValueError: pass if __name__ == "__main__": run_module_suite()
mit
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 2344, 199, 6071, 299, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 566, 199, 6071, 299, 199, 6023, 17, 68, 779, 413, 2020, 221, 499, 2020, 221, 650, 14444, 199, 6071, 870, 8, 80, 9, 2043, 499, 199, 17, 671, 435, 499, 671, 435, 650, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 19, 2020, 18, 12, 17, 566, 199, 6071, 1894, 199, 6023, 17, 68, 779, 650, 2020, 221, 499, 2020, 221, 413, 14444, 199, 6071, 870, 8, 81, 9, 2043, 499, 199, 19, 671, 435, 499, 671, 435, 413, 199, 6071, 870, 8, 1590, 14, 6023, 17, 68, 779, 17, 14, 24, 5008, 11, 18, 74, 12, 446, 19, 74, 12, 446, 21, 14, 19542, 12, 499, 11, 17, 74, 2459, 288, 650, 420, 499, 199, 8, 17, 14, 25, 435, 499, 74, 9, 671, 446, 650, 74, 671, 446, 959, 14, 4288, 671, 435, 334, 18, 435, 413, 74, 9, 199, 6071, 870, 8, 1590, 14, 6023, 17, 68, 11468, 19, 12, 446, 18, 12, 446, 17, 2459, 272, 499, 199, 13, 19, 671, 446, 499, 671, 446, 413, 199, 199, 6071, 299, 8, 16, 9, 199, 19, 14, 16, 199, 6071, 299, 8, 21, 9, 199, 1703, 14, 16, 199, 6071, 1894, 8, 16, 9, 199, 17, 14, 16, 199, 6071, 1894, 8, 21, 9, 199, 1184, 14, 16, 199, 199, 6071, 299, 627, 1894, 199, 6023, 17, 68, 779, 221, 650, 2020, 257, 1695, 2020, 221, 4329, 2020, 257, 1695, 2020, 257, 650, 14444, 199, 6071, 299, 1182, 1894, 199, 8, 6023, 17, 68, 779, 378, 14, 15093, 2522, 8446, 17, 68, 779, 413, 14, 15093, 12, 221, 499, 14, 6997, 30303, 2459, 199, 6071, 299, 435, 1894, 199, 6023, 17, 68, 779, 841, 2020, 221, 841, 2020, 221, 841, 14444, 199, 6071, 299, 446, 1894, 199, 6023, 17, 68, 11468, 18, 2020, 221, 378, 2020, 221, 499, 14444, 199, 6071, 299, 1011, 841, 199, 6023, 17, 68, 779, 257, 413, 2020, 259, 1695, 2020, 257, 8780, 2020, 221, 21083, 2020, 221, 21237, 2020, 221, 650, 713, 2020, 221, 650, 1194, 2020, 221, 30630, 2020, 257, 19071, 14444, 199, 199, 6071, 299, 8, 81, 9, 199, 6023, 17, 68, 779, 221, 1749, 2020, 221, 3144, 2020, 221, 3193, 2020, 257, 1695, 2020, 257, 1227, 14444, 199, 6071, 1894, 8, 80, 9, 199, 6023, 17, 68, 779, 221, 650, 2020, 221, 3144, 2020, 221, 4337, 2020, 221, 6335, 2020, 221, 8177, 14444, 199, 199, 6071, 980, 14, 8748, 8, 80, 9, 199, 1144, 779, 413, 2020, 221, 499, 2020, 221, 650, 14444, 199, 6071, 822, 8, 80, 9, 199, 18, 199, 199, 6071, 299, 59, 16, 467, 299, 59, 17, 467, 299, 59, 18, 467, 299, 59, 19, 61, 199, 8, 19, 14, 16, 12, 499, 14, 16, 12, 413, 14, 16, 12, 378, 9, 199, 199, 6071, 299, 14, 5707, 71, 342, 199, 6023, 17, 68, 779, 378, 14, 15093, 12, 221, 413, 14, 263, 2360, 221, 650, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 5707, 71, 8, 17, 9, 199, 6023, 17, 68, 779, 378, 14, 15093, 12, 221, 413, 14, 263, 2360, 221, 650, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 5707, 71, 8, 21, 9, 199, 6023, 17, 68, 779, 378, 14, 1493, 1355, 25689, 12, 221, 378, 14, 7432, 1138, 16156, 12, 221, 378, 14, 18823, 258, 2360, 221, 378, 14, 263, 2360, 221, 378, 14, 263, 2360, 267, 378, 14, 263, 2360, 221, 378, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 17922, 342, 199, 6023, 17, 68, 779, 499, 2020, 221, 499, 14444, 199, 6071, 299, 14, 17922, 8, 18, 9, 199, 6023, 17, 68, 779, 499, 14444, 199, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 467, 1750, 534, 89, 358, 199, 6071, 870, 8, 81, 9, 2043, 499, 199, 17, 612, 435, 499, 612, 435, 650, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 467, 1750, 534, 2734, 358, 199, 6071, 870, 8, 81, 9, 267, 499, 199, 17, 2400, 435, 499, 2400, 435, 650, 199, 199, 6071, 980, 14, 6023, 3015, 8, 1590, 14, 6023, 17, 68, 779, 17, 12, 16, 3057, 17, 2522, 980, 14, 6023, 17, 68, 779, 17, 12, 17, 2459, 199, 8, 6023, 17, 68, 779, 413, 2020, 446, 17, 14, 2522, 8446, 17, 68, 779, 378, 14, 2459, 199, 199, 2344, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 7640, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 272, 702, 63, 4398, 63, 1452, 12, 519, 725, 14851, 272, 776, 421, 199, 533, 1379, 27858, 8, 1746, 304, 272, 347, 511, 63, 1301, 2219, 8, 277, 304, 267, 372, 519, 725, 14851, 342, 339, 347, 511, 63, 12065, 8, 277, 304, 267, 702, 63, 1144, 63, 1452, 8, 1590, 14, 12065, 779, 17, 12, 378, 12, 378, 2522, 359, 16, 12, 378, 566, 339, 347, 511, 63, 495, 63, 16812, 63, 4250, 8, 277, 304, 267, 299, 275, 980, 14, 6023, 17, 68, 779, 20, 12, 650, 12, 499, 12, 413, 566, 267, 299, 59, 19, 61, 275, 378, 267, 702, 63, 1452, 8, 495, 8, 80, 395, 2151, 298, 257, 499, 60, 78, 2, 2151, 298, 19, 671, 435, 499, 671, 435, 413, 531, 398, 299, 275, 980, 14, 6023, 17, 68, 779, 17, 12, 499, 566, 267, 299, 59, 16, 61, 275, 378, 267, 299, 59, 17, 61, 275, 378, 267, 702, 63, 1452, 8, 495, 8, 80, 395, 298, 971, 78, 16, 531, 339, 347, 511, 63, 6023, 3269, 8, 277, 304, 267, 286, 275, 980, 14, 1144, 779, 19, 2020, 499, 2020, 413, 14444, 267, 671, 275, 980, 14, 11649, 8, 16, 12, 499, 12, 1520, 9, 267, 612, 275, 980, 14, 6023, 637, 8, 67, 12, 671, 9, 267, 2329, 275, 359, 17, 12 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 2344, 199, 6071, 299, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 566, 199, 6071, 299, 199, 6023, 17, 68, 779, 413, 2020, 221, 499, 2020, 221, 650, 14444, 199, 6071, 870, 8, 80, 9, 2043, 499, 199, 17, 671, 435, 499, 671, 435, 650, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 19, 2020, 18, 12, 17, 566, 199, 6071, 1894, 199, 6023, 17, 68, 779, 650, 2020, 221, 499, 2020, 221, 413, 14444, 199, 6071, 870, 8, 81, 9, 2043, 499, 199, 19, 671, 435, 499, 671, 435, 413, 199, 6071, 870, 8, 1590, 14, 6023, 17, 68, 779, 17, 14, 24, 5008, 11, 18, 74, 12, 446, 19, 74, 12, 446, 21, 14, 19542, 12, 499, 11, 17, 74, 2459, 288, 650, 420, 499, 199, 8, 17, 14, 25, 435, 499, 74, 9, 671, 446, 650, 74, 671, 446, 959, 14, 4288, 671, 435, 334, 18, 435, 413, 74, 9, 199, 6071, 870, 8, 1590, 14, 6023, 17, 68, 11468, 19, 12, 446, 18, 12, 446, 17, 2459, 272, 499, 199, 13, 19, 671, 446, 499, 671, 446, 413, 199, 199, 6071, 299, 8, 16, 9, 199, 19, 14, 16, 199, 6071, 299, 8, 21, 9, 199, 1703, 14, 16, 199, 6071, 1894, 8, 16, 9, 199, 17, 14, 16, 199, 6071, 1894, 8, 21, 9, 199, 1184, 14, 16, 199, 199, 6071, 299, 627, 1894, 199, 6023, 17, 68, 779, 221, 650, 2020, 257, 1695, 2020, 221, 4329, 2020, 257, 1695, 2020, 257, 650, 14444, 199, 6071, 299, 1182, 1894, 199, 8, 6023, 17, 68, 779, 378, 14, 15093, 2522, 8446, 17, 68, 779, 413, 14, 15093, 12, 221, 499, 14, 6997, 30303, 2459, 199, 6071, 299, 435, 1894, 199, 6023, 17, 68, 779, 841, 2020, 221, 841, 2020, 221, 841, 14444, 199, 6071, 299, 446, 1894, 199, 6023, 17, 68, 11468, 18, 2020, 221, 378, 2020, 221, 499, 14444, 199, 6071, 299, 1011, 841, 199, 6023, 17, 68, 779, 257, 413, 2020, 259, 1695, 2020, 257, 8780, 2020, 221, 21083, 2020, 221, 21237, 2020, 221, 650, 713, 2020, 221, 650, 1194, 2020, 221, 30630, 2020, 257, 19071, 14444, 199, 199, 6071, 299, 8, 81, 9, 199, 6023, 17, 68, 779, 221, 1749, 2020, 221, 3144, 2020, 221, 3193, 2020, 257, 1695, 2020, 257, 1227, 14444, 199, 6071, 1894, 8, 80, 9, 199, 6023, 17, 68, 779, 221, 650, 2020, 221, 3144, 2020, 221, 4337, 2020, 221, 6335, 2020, 221, 8177, 14444, 199, 199, 6071, 980, 14, 8748, 8, 80, 9, 199, 1144, 779, 413, 2020, 221, 499, 2020, 221, 650, 14444, 199, 6071, 822, 8, 80, 9, 199, 18, 199, 199, 6071, 299, 59, 16, 467, 299, 59, 17, 467, 299, 59, 18, 467, 299, 59, 19, 61, 199, 8, 19, 14, 16, 12, 499, 14, 16, 12, 413, 14, 16, 12, 378, 9, 199, 199, 6071, 299, 14, 5707, 71, 342, 199, 6023, 17, 68, 779, 378, 14, 15093, 12, 221, 413, 14, 263, 2360, 221, 650, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 5707, 71, 8, 17, 9, 199, 6023, 17, 68, 779, 378, 14, 15093, 12, 221, 413, 14, 263, 2360, 221, 650, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 5707, 71, 8, 21, 9, 199, 6023, 17, 68, 779, 378, 14, 1493, 1355, 25689, 12, 221, 378, 14, 7432, 1138, 16156, 12, 221, 378, 14, 18823, 258, 2360, 221, 378, 14, 263, 2360, 221, 378, 14, 263, 2360, 267, 378, 14, 263, 2360, 221, 378, 14, 263, 2360, 221, 378, 14, 263, 4794, 199, 6071, 299, 14, 17922, 342, 199, 6023, 17, 68, 779, 499, 2020, 221, 499, 14444, 199, 6071, 299, 14, 17922, 8, 18, 9, 199, 6023, 17, 68, 779, 499, 14444, 199, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 467, 1750, 534, 89, 358, 199, 6071, 870, 8, 81, 9, 2043, 499, 199, 17, 612, 435, 499, 612, 435, 650, 199, 6071, 1894, 275, 980, 14, 6023, 17, 68, 779, 17, 2020, 18, 12, 19, 467, 1750, 534, 2734, 358, 199, 6071, 870, 8, 81, 9, 267, 499, 199, 17, 2400, 435, 499, 2400, 435, 650, 199, 199, 6071, 980, 14, 6023, 3015, 8, 1590, 14, 6023, 17, 68, 779, 17, 12, 16, 3057, 17, 2522, 980, 14, 6023, 17, 68, 779, 17, 12, 17, 2459, 199, 8, 6023, 17, 68, 779, 413, 2020, 446, 17, 14, 2522, 8446, 17, 68, 779, 378, 14, 2459, 199, 199, 2344, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 334, 272, 1255, 63, 578, 63, 5768, 12, 7640, 12, 702, 3131, 702, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 272, 702, 63, 4398, 63, 1452, 12, 519, 725, 14851, 272, 776, 421, 199, 533, 1379, 27858, 8, 1746, 304, 272, 347, 511, 63, 1301, 2219, 8, 277, 304, 267, 372, 519, 725, 14851, 342, 339, 347, 511, 63, 12065, 8, 277, 304, 267, 702, 63, 1144, 63, 1452, 8, 1590, 14, 12065, 779, 17, 12, 378, 12, 378, 2522, 359, 16, 12, 378, 566, 339, 347, 511, 63, 495, 63, 16812, 63, 4250, 8, 277, 304, 267, 299, 275, 980, 14, 6023, 17, 68, 779, 20, 12, 650, 12, 499, 12, 413, 566, 267, 299, 59, 19, 61, 275, 378, 267, 702, 63, 1452, 8, 495, 8, 80, 395, 2151, 298, 257, 499, 60, 78, 2, 2151, 298, 19, 671, 435, 499, 671, 435, 413, 531, 398, 299, 275, 980, 14, 6023, 17, 68, 779, 17, 12, 499, 566, 267, 299, 59, 16, 61, 275, 378, 267, 299, 59, 17, 61, 275, 378, 267, 702, 63, 1452, 8, 495, 8, 80, 395, 298, 971, 78, 16, 531, 339, 347, 511, 63, 6023, 3269, 8, 277, 304, 267, 286, 275, 980, 14, 1144, 779, 19, 2020, 499, 2020, 413, 14444, 267, 671, 275, 980, 14, 11649, 8, 16, 12, 499, 12, 1520, 9, 267, 612, 275, 980, 14, 6023, 637, 8, 67, 12, 671, 9, 267, 2329, 275, 359, 17, 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, 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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 ]
iobond/aib
share/qt/extract_strings_qt.py
33
2717
#!/usr/bin/python # Copyright (c) 2012-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' Extract _("...") strings for translation and convert to Qt stringdefs so that they can be picked up by Qt linguist. ''' from __future__ import division,print_function,unicode_literals from subprocess import Popen, PIPE import glob import operator import os import sys OUT_CPP="qt/bitcoinstrings.cpp" EMPTY=['""'] def parse_po(text): """ Parse 'po' format produced by xgettext. Return a list of (msgid,msgstr) tuples. """ messages = [] msgid = [] msgstr = [] in_msgid = False in_msgstr = False for line in text.split('\n'): line = line.rstrip('\r') if line.startswith('msgid '): if in_msgstr: messages.append((msgid, msgstr)) in_msgstr = False # message start in_msgid = True msgid = [line[6:]] elif line.startswith('msgstr '): in_msgid = False in_msgstr = True msgstr = [line[7:]] elif line.startswith('"'): if in_msgid: msgid.append(line) if in_msgstr: msgstr.append(line) if in_msgstr: messages.append((msgid, msgstr)) return messages files = sys.argv[1:] # xgettext -n --keyword=_ $FILES XGETTEXT=os.getenv('XGETTEXT', 'xgettext') if not XGETTEXT: print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr) print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr) exit(1) child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE) (out, err) = child.communicate() messages = parse_po(out.decode('utf-8')) f = open(OUT_CPP, 'w') f.write(""" #include <QtGlobal> // Automatically generated by extract_strings_qt.py #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else #define UNUSED #endif """) f.write('static const char UNUSED *bitcoin_strings[] = {\n') f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('PACKAGE_NAME'),)) f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS'),)) if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'): f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),)) messages.sort(key=operator.itemgetter(0)) for (msgid, msgstr) in messages: if msgid != EMPTY: f.write('QT_TRANSLATE_NOOP("bitcoin-core", %s),\n' % ('\n'.join(msgid))) f.write('};\n') f.close()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 6029, 13, 9261, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 12, 1361, 63, 1593, 12, 2975, 63, 5955, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 5739, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 953, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 692, 440, 1323, 2970, 3876, 26, 272, 870, 360, 6612, 5536, 3326, 26, 671, 5152, 11420, 365, 440, 4903, 503, 440, 7526, 3130, 493, 29, 1274, 14, 3083, 9, 272, 870, 360, 8254, 3907, 2559, 298, 5152, 2, 436, 295, 13, 1065, 971, 1370, 15, 6472, 60, 1370, 297, 493, 29, 1274, 14, 3083, 9, 272, 4458, 8, 17, 9, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 14, 2708, 360, 1624, 13, 24, 1333, 199, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 63, 8440, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 19265, 63, 2339, 659, 430, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 659, 430, 199, 692, 747, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 358, 1137, 747, 14, 12959, 360, 19265, 63, 2339, 735, 272, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 659, 430, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 6029, 13, 9261, 710, 21158, 11672, 19782, 199, 3, 17484, 1334, 314, 10697, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 4629, 12, 1361, 63, 1593, 12, 2975, 63, 5955, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 5739, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 953, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 692, 440, 1323, 2970, 3876, 26, 272, 870, 360, 6612, 5536, 3326, 26, 671, 5152, 11420, 365, 440, 4903, 503, 440, 7526, 3130, 493, 29, 1274, 14, 3083, 9, 272, 870, 360, 8254, 3907, 2559, 298, 5152, 2, 436, 295, 13, 1065, 971, 1370, 15, 6472, 60, 1370, 297, 493, 29, 1274, 14, 3083, 9, 272, 4458, 8, 17, 9, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 14, 2708, 360, 1624, 13, 24, 1333, 199, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 63, 8440, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 19265, 63, 2339, 659, 430, 199, 70, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 659, 430, 199, 692, 747, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 358, 1137, 747, 14, 12959, 360, 19265, 63, 2339, 735, 272, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 2071, 83, 1288, 60, 78, 7, 450, 334, 736, 14, 12959, 360, 32324, 5716, 63, 40, 5104, 3960, 63, 6348, 8821, 27129, 659, 430, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 22816, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
BT-ojossen/odoo
addons/account_budget/report/analytic_account_budget_report.py
360
7589
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from openerp.osv import osv from openerp.report import report_sxw class analytic_account_budget_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(analytic_account_budget_report, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'funct': self.funct, 'funct_total': self.funct_total, 'time': time, }) self.context = context def funct(self, object, form, ids=None, done=None, level=1): if ids is None: ids = {} if not ids: ids = self.ids if not done: done = {} global tot tot = { 'theo':0.00, 'pln':0.00, 'prac':0.00, 'perc':0.00 } result = [] accounts = self.pool.get('account.analytic.account').browse(self.cr, self.uid, [object.id], self.context.copy()) c_b_lines_obj = self.pool.get('crossovered.budget.lines') obj_c_budget = self.pool.get('crossovered.budget') for account_id in accounts: res = {} b_line_ids = [] for line in account_id.crossovered_budget_line: b_line_ids.append(line.id) if not b_line_ids: return [] d_from = form['date_from'] d_to = form['date_to'] self.cr.execute('SELECT DISTINCT(crossovered_budget_id) FROM crossovered_budget_lines WHERE id =ANY(%s)',(b_line_ids,)) budget_ids = self.cr.fetchall() context = {'wizard_date_from':d_from,'wizard_date_to':d_to} for i in range(0, len(budget_ids)): budget_name = obj_c_budget.browse(self.cr, self.uid, [budget_ids[i][0]]) res= { 'b_id':'-1', 'a_id':'-1', 'name':budget_name[0].name, 'status':1, 'theo':0.00, 'pln':0.00, 'prac':0.00, 'perc':0.00 } result.append(res) line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', b_line_ids), ('crossovered_budget_id','=',budget_ids[i][0])]) line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids) tot_theo = tot_pln = tot_prac = tot_perc = 0 done_budget = [] for line in line_id: if line.id in b_line_ids: theo = pract = 0.00 theo = c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id], context)[line.id] pract = c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id], context)[line.id] if line.general_budget_id.id in done_budget: for record in result: if record['b_id'] == line.general_budget_id.id and record['a_id'] == line.analytic_account_id.id: record['theo'] += theo record['pln'] += line.planned_amount record['prac'] += pract record['perc'] += line.percentage tot_theo += theo tot_pln += line.planned_amount tot_prac += pract tot_perc += line.percentage else: res1 = { 'b_id': line.general_budget_id.id, 'a_id': line.analytic_account_id.id, 'name': line.general_budget_id.name, 'status': 2, 'theo': theo, 'pln': line.planned_amount, 'prac': pract, 'perc': line.percentage } tot_theo += theo tot_pln += line.planned_amount tot_prac += pract tot_perc += line.percentage result.append(res1) done_budget.append(line.general_budget_id.id) else: if line.general_budget_id.id in done_budget: continue else: res1={ 'b_id': line.general_budget_id.id, 'a_id': line.analytic_account_id.id, 'name': line.general_budget_id.name, 'status': 2, 'theo': 0.00, 'pln': 0.00, 'prac': 0.00, 'perc': 0.00 } result.append(res1) done_budget.append(line.general_budget_id.id) if tot_theo == 0.00: tot_perc = 0.00 else: tot_perc = float(tot_prac / tot_theo) * 100 result[-(len(done_budget) +1)]['theo'] = tot_theo tot['theo'] +=tot_theo result[-(len(done_budget) +1)]['pln'] = tot_pln tot['pln'] +=tot_pln result[-(len(done_budget) +1)]['prac'] = tot_prac tot['prac'] +=tot_prac result[-(len(done_budget) +1)]['perc'] = tot_perc if tot['theo'] == 0.00: tot['perc'] = 0.00 else: tot['perc'] = float(tot['prac'] / tot['theo']) * 100 return result def funct_total(self, form): result = [] res = {} res = { 'tot_theo': tot['theo'], 'tot_pln': tot['pln'], 'tot_prac': tot['prac'], 'tot_perc': tot['perc'] } result.append(res) return result class report_analyticaccountbudget(osv.AbstractModel): _name = 'report.account_budget.report_analyticaccountbudget' _inherit = 'report.abstract_report' _template = 'account_budget.report_analyticaccountbudget' _wrapped_report_class = analytic_account_budget_report # 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, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 20705, 63, 2048, 63, 16501, 63, 3070, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 272, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 9782, 63, 2048, 63, 16501, 63, 3070, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 17886, 14, 873, 8, 469, 288, 283, 31939, 356, 291, 14, 31939, 12, 288, 283, 31939, 63, 2923, 356, 291, 14, 31939, 63, 2923, 12, 288, 283, 521, 356, 900, 12, 267, 3828, 267, 291, 14, 1100, 275, 1067, 339, 347, 289, 4638, 8, 277, 12, 909, 12, 1824, 12, 2762, 29, 403, 12, 4224, 29, 403, 12, 2166, 29, 17, 304, 267, 340, 2762, 365, 488, 26, 288, 2762, 275, 1052, 267, 340, 440, 2762, 26, 288, 2762, 275, 291, 14, 1580, 267, 340, 440, 4224, 26, 288, 4224, 275, 1052, 398, 2288, 12657, 267, 12657, 275, 469, 288, 283, 1589, 79, 356, 16, 14, 383, 12, 288, 283, 1168, 78, 356, 16, 14, 383, 12, 288, 283, 80, 6457, 356, 16, 14, 383, 12, 288, 283, 27293, 356, 16, 14, 383, 267, 789, 267, 754, 275, 942, 267, 12639, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 785, 14, 344, 467, 291, 14, 1100, 14, 1574, 1012, 267, 286, 63, 66, 63, 1278, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 7925, 79, 10050, 14, 16501, 14, 1278, 358, 267, 1559, 63, 67, 63, 16501, 275, 291, 14, 2293, 14, 362, 360, 7925, 79, 10050, 14, 16501, 358, 398, 367, 2933, 63, 344, 315, 12639, 26, 288, 522, 275, 1052, 288, 330, 63, 604, 63, 1580, 275, 942, 288, 367, 1004, 315, 2933, 63, 344, 14, 7925, 79, 10050, 63, 16501, 63, 604, 26, 355, 330, 63, 604, 63, 1580, 14, 740, 8, 604, 14, 344, 9, 288, 340, 440, 330, 63, 604, 63, 1580, 26, 355, 372, 942, 288, 366, 63, 504, 275, 1824, 459, 602, 63, 504, 418, 288, 366, 63, 475, 275, 1824, 459, 602, 63, 475, 418, 953, 291, 14, 1556, 14, 2526, 360, 4859, 28424, 28437, 8, 7925, 79, 10050, 63, 16501, 63, 344, 9, 4442, 8059, 79, 10050, 63, 16501, 63, 1278, 6038, 1305, 275, 8974, 4042, 83, 3196, 8, 66, 63, 604, 63, 1580, 4641, 288, 1032, 14080, 63, 1580, 275, 291, 14, 1556, 14, 10174, 342, 953, 1067, 275, 791, 9819, 63, 602, 63, 504, 356, 68, 63, 504, 2584, 9819, 63, 602, 63, 475, 356, 68, 63, 475, 93, 288, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 16501, 63, 1580, 2298, 355, 1032, 14080, 63, 354, 275, 1559, 63, 67, 63, 16501, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 16501, 63, 1580, 59, 73, 1527, 16, 3934, 355, 522, 29, 469, 2151, 283, 66, 63, 344, 5242, 13, 17, 297, 2151, 283, 65, 63, 344, 5242, 13, 17, 297, 2151, 283, 354, 356, 16501, 63, 354, 59, 16, 1055, 354, 12, 2151, 283, 1205, 356, 17, 12, 2151, 283, 1589, 79, 356, 16, 14, 383, 12, 2151, 283, 1168, 78, 356, 16, 14, 383, 12, 2151, 283, 80, 6457, 356, 16, 14, 383, 12, 2151, 283, 27293, 356, 16, 14, 383, 355, 789, 355, 754, 14, 740, 8, 470, 9, 2234, 1004, 63, 1580, 275, 286, 63, 66, 63, 1278, 63, 1113, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 344, 297, 283, 262, 297, 330, 63, 604, 63, 1580, 395, 661, 7925, 79, 10050, 63, 16501, 63, 344, 18937, 16501, 63, 1580, 59, 73, 1527, 16, 24310, 355, 1004, 63, 344, 275, 286, 63, 66, 63, 1278, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 1004, 63, 1580, 9, 355, 12657, 63, 1589, 79, 275, 12657, 63, 1168, 78, 275, 12657, 63, 80, 6457, 275, 12657, 63, 27293, 275, 378, 2234, 4224, 63, 16501, 275, 942, 355, 367, 1004, 315, 1004, 63, 344, 26, 490, 340, 1004, 14, 344, 315, 330, 63, 604, 63, 1580, 26, 717, 314, 79, 275, 299, 1957, 275, 378, 14, 383, 717, 314, 79, 275, 286, 63, 66, 63, 1278, 63, 1113, 423, 1589, 79, 63, 19582, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 604, 14, 344, 467, 1067, 2788, 604, 14, 344, 61, 717, 299, 1957, 275, 286, 63, 66, 63, 1278, 63, 1113, 423, 80, 6457, 63, 19582, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 604, 14, 344, 467, 1067, 2788, 604, 14, 344, 61, 717, 340, 1004, 14, 10706, 63, 16501, 63, 344, 14, 344, 315, 4224, 63, 16501, 26, 1169, 367, 2777, 315, 754 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 20705, 63, 2048, 63, 16501, 63, 3070, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 272, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 9782, 63, 2048, 63, 16501, 63, 3070, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 17886, 14, 873, 8, 469, 288, 283, 31939, 356, 291, 14, 31939, 12, 288, 283, 31939, 63, 2923, 356, 291, 14, 31939, 63, 2923, 12, 288, 283, 521, 356, 900, 12, 267, 3828, 267, 291, 14, 1100, 275, 1067, 339, 347, 289, 4638, 8, 277, 12, 909, 12, 1824, 12, 2762, 29, 403, 12, 4224, 29, 403, 12, 2166, 29, 17, 304, 267, 340, 2762, 365, 488, 26, 288, 2762, 275, 1052, 267, 340, 440, 2762, 26, 288, 2762, 275, 291, 14, 1580, 267, 340, 440, 4224, 26, 288, 4224, 275, 1052, 398, 2288, 12657, 267, 12657, 275, 469, 288, 283, 1589, 79, 356, 16, 14, 383, 12, 288, 283, 1168, 78, 356, 16, 14, 383, 12, 288, 283, 80, 6457, 356, 16, 14, 383, 12, 288, 283, 27293, 356, 16, 14, 383, 267, 789, 267, 754, 275, 942, 267, 12639, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 9782, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 785, 14, 344, 467, 291, 14, 1100, 14, 1574, 1012, 267, 286, 63, 66, 63, 1278, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 7925, 79, 10050, 14, 16501, 14, 1278, 358, 267, 1559, 63, 67, 63, 16501, 275, 291, 14, 2293, 14, 362, 360, 7925, 79, 10050, 14, 16501, 358, 398, 367, 2933, 63, 344, 315, 12639, 26, 288, 522, 275, 1052, 288, 330, 63, 604, 63, 1580, 275, 942, 288, 367, 1004, 315, 2933, 63, 344, 14, 7925, 79, 10050, 63, 16501, 63, 604, 26, 355, 330, 63, 604, 63, 1580, 14, 740, 8, 604, 14, 344, 9, 288, 340, 440, 330, 63, 604, 63, 1580, 26, 355, 372, 942, 288, 366, 63, 504, 275, 1824, 459, 602, 63, 504, 418, 288, 366, 63, 475, 275, 1824, 459, 602, 63, 475, 418, 953, 291, 14, 1556, 14, 2526, 360, 4859, 28424, 28437, 8, 7925, 79, 10050, 63, 16501, 63, 344, 9, 4442, 8059, 79, 10050, 63, 16501, 63, 1278, 6038, 1305, 275, 8974, 4042, 83, 3196, 8, 66, 63, 604, 63, 1580, 4641, 288, 1032, 14080, 63, 1580, 275, 291, 14, 1556, 14, 10174, 342, 953, 1067, 275, 791, 9819, 63, 602, 63, 504, 356, 68, 63, 504, 2584, 9819, 63, 602, 63, 475, 356, 68, 63, 475, 93, 288, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 16501, 63, 1580, 2298, 355, 1032, 14080, 63, 354, 275, 1559, 63, 67, 63, 16501, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 16501, 63, 1580, 59, 73, 1527, 16, 3934, 355, 522, 29, 469, 2151, 283, 66, 63, 344, 5242, 13, 17, 297, 2151, 283, 65, 63, 344, 5242, 13, 17, 297, 2151, 283, 354, 356, 16501, 63, 354, 59, 16, 1055, 354, 12, 2151, 283, 1205, 356, 17, 12, 2151, 283, 1589, 79, 356, 16, 14, 383, 12, 2151, 283, 1168, 78, 356, 16, 14, 383, 12, 2151, 283, 80, 6457, 356, 16, 14, 383, 12, 2151, 283, 27293, 356, 16, 14, 383, 355, 789, 355, 754, 14, 740, 8, 470, 9, 2234, 1004, 63, 1580, 275, 286, 63, 66, 63, 1278, 63, 1113, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 344, 297, 283, 262, 297, 330, 63, 604, 63, 1580, 395, 661, 7925, 79, 10050, 63, 16501, 63, 344, 18937, 16501, 63, 1580, 59, 73, 1527, 16, 24310, 355, 1004, 63, 344, 275, 286, 63, 66, 63, 1278, 63, 1113, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 1004, 63, 1580, 9, 355, 12657, 63, 1589, 79, 275, 12657, 63, 1168, 78, 275, 12657, 63, 80, 6457, 275, 12657, 63, 27293, 275, 378, 2234, 4224, 63, 16501, 275, 942, 355, 367, 1004, 315, 1004, 63, 344, 26, 490, 340, 1004, 14, 344, 315, 330, 63, 604, 63, 1580, 26, 717, 314, 79, 275, 299, 1957, 275, 378, 14, 383, 717, 314, 79, 275, 286, 63, 66, 63, 1278, 63, 1113, 423, 1589, 79, 63, 19582, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 604, 14, 344, 467, 1067, 2788, 604, 14, 344, 61, 717, 299, 1957, 275, 286, 63, 66, 63, 1278, 63, 1113, 423, 80, 6457, 63, 19582, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 359, 604, 14, 344, 467, 1067, 2788, 604, 14, 344, 61, 717, 340, 1004, 14, 10706, 63, 16501, 63, 344, 14, 344, 315, 4224, 63, 16501, 26, 1169, 367, 2777, 315, 754, 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, 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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 ]
plepers/three.js
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/__init__.py
6
18004
# ##### BEGIN GPL LICENSE BLOCK ##### # # 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. # # ##### END GPL LICENSE BLOCK ##### # ################################################################ # Init # ################################################################ bl_info = { "name": "three.js format", "author": "mrdoob, kikko, alteredq, remoe, pxf, n3tfr34k, crobi", "version": (1, 5, 0), "blender": (2, 7, 0), "location": "File > Import-Export", "description": "Import-Export three.js meshes", "warning": "", "wiki_url": "https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender", "tracker_url": "https://github.com/mrdoob/three.js/issues", "category": "Import-Export"} # To support reload properly, try to access a package var, # if it's there, reload everything import bpy if "bpy" in locals(): import imp if "export_threejs" in locals(): imp.reload(export_threejs) if "import_threejs" in locals(): imp.reload(import_threejs) from bpy.props import * from bpy_extras.io_utils import ExportHelper, ImportHelper # ################################################################ # Custom properties # ################################################################ bpy.types.Object.THREE_castShadow = bpy.props.BoolProperty() bpy.types.Object.THREE_receiveShadow = bpy.props.BoolProperty() bpy.types.Object.THREE_doubleSided = bpy.props.BoolProperty() bpy.types.Object.THREE_exportGeometry = bpy.props.BoolProperty(default = True) bpy.types.Object.THREE_visible = bpy.props.BoolProperty(default = True) bpy.types.Material.THREE_useVertexColors = bpy.props.BoolProperty() bpy.types.Material.THREE_depthWrite = bpy.props.BoolProperty(default = True) bpy.types.Material.THREE_depthTest = bpy.props.BoolProperty(default = True) THREE_material_types = [("Basic", "Basic", "Basic"), ("Phong", "Phong", "Phong"), ("Lambert", "Lambert", "Lambert")] bpy.types.Material.THREE_materialType = EnumProperty(name = "Material type", description = "Material type", items = THREE_material_types, default = "Lambert") THREE_blending_types = [("NoBlending", "NoBlending", "NoBlending"), ("NormalBlending", "NormalBlending", "NormalBlending"), ("AdditiveBlending", "AdditiveBlending", "AdditiveBlending"), ("SubtractiveBlending", "SubtractiveBlending", "SubtractiveBlending"), ("MultiplyBlending", "MultiplyBlending", "MultiplyBlending"), ("AdditiveAlphaBlending", "AdditiveAlphaBlending", "AdditiveAlphaBlending")] bpy.types.Material.THREE_blendingType = EnumProperty(name = "Blending type", description = "Blending type", items = THREE_blending_types, default = "NormalBlending") class OBJECT_PT_hello( bpy.types.Panel ): bl_label = "THREE" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "object" def draw(self, context): layout = self.layout obj = context.object row = layout.row() row.label(text="Selected object: " + obj.name ) row = layout.row() row.prop( obj, "THREE_exportGeometry", text="Export geometry" ) row = layout.row() row.prop( obj, "THREE_castShadow", text="Casts shadow" ) row = layout.row() row.prop( obj, "THREE_receiveShadow", text="Receives shadow" ) row = layout.row() row.prop( obj, "THREE_doubleSided", text="Double sided" ) row = layout.row() row.prop( obj, "THREE_visible", text="Visible" ) class MATERIAL_PT_hello( bpy.types.Panel ): bl_label = "THREE" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "material" def draw(self, context): layout = self.layout mat = context.material row = layout.row() row.label(text="Selected material: " + mat.name ) row = layout.row() row.prop( mat, "THREE_materialType", text="Material type" ) row = layout.row() row.prop( mat, "THREE_blendingType", text="Blending type" ) row = layout.row() row.prop( mat, "THREE_useVertexColors", text="Use vertex colors" ) row = layout.row() row.prop( mat, "THREE_depthWrite", text="Enable depth writing" ) row = layout.row() row.prop( mat, "THREE_depthTest", text="Enable depth testing" ) # ################################################################ # Importer # ################################################################ class ImportTHREEJS(bpy.types.Operator, ImportHelper): '''Load a Three.js ASCII JSON model''' bl_idname = "import.threejs" bl_label = "Import Three.js" filename_ext = ".json" filter_glob = StringProperty(default="*.json", options={'HIDDEN'}) option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True) recalculate_normals = BoolProperty(name="Recalculate normals", description="Recalculate vertex normals", default=True) option_worker = BoolProperty(name="Worker", description="Old format using workers", default=False) def execute(self, context): import io_mesh_threejs.import_threejs return io_mesh_threejs.import_threejs.load(self, context, **self.properties) def draw(self, context): layout = self.layout row = layout.row() row.prop(self.properties, "option_flip_yz") row = layout.row() row.prop(self.properties, "recalculate_normals") row = layout.row() row.prop(self.properties, "option_worker") # ################################################################ # Exporter - settings # ################################################################ SETTINGS_FILE_EXPORT = "threejs_settings_export.js" import os import json def file_exists(filename): """Return true if file exists and accessible for reading. Should be safer than just testing for existence due to links and permissions magic on Unix filesystems. @rtype: boolean """ try: f = open(filename, 'r') f.close() return True except IOError: return False def get_settings_fullpath(): return os.path.join(bpy.app.tempdir, SETTINGS_FILE_EXPORT) def save_settings_export(properties): settings = { "option_export_scene" : properties.option_export_scene, "option_embed_meshes" : properties.option_embed_meshes, "option_url_base_html" : properties.option_url_base_html, "option_copy_textures" : properties.option_copy_textures, "option_lights" : properties.option_lights, "option_cameras" : properties.option_cameras, "option_animation_morph" : properties.option_animation_morph, "option_animation_skeletal" : properties.option_animation_skeletal, "option_frame_index_as_time" : properties.option_frame_index_as_time, "option_frame_step" : properties.option_frame_step, "option_all_meshes" : properties.option_all_meshes, "option_flip_yz" : properties.option_flip_yz, "option_materials" : properties.option_materials, "option_normals" : properties.option_normals, "option_colors" : properties.option_colors, "option_uv_coords" : properties.option_uv_coords, "option_faces" : properties.option_faces, "option_vertices" : properties.option_vertices, "option_skinning" : properties.option_skinning, "option_bones" : properties.option_bones, "option_vertices_truncate" : properties.option_vertices_truncate, "option_scale" : properties.option_scale, "align_model" : properties.align_model } fname = get_settings_fullpath() f = open(fname, "w") json.dump(settings, f) def restore_settings_export(properties): settings = {} fname = get_settings_fullpath() if file_exists(fname): f = open(fname, "r") settings = json.load(f) properties.option_vertices = settings.get("option_vertices", True) properties.option_vertices_truncate = settings.get("option_vertices_truncate", False) properties.option_faces = settings.get("option_faces", True) properties.option_normals = settings.get("option_normals", True) properties.option_colors = settings.get("option_colors", True) properties.option_uv_coords = settings.get("option_uv_coords", True) properties.option_materials = settings.get("option_materials", True) properties.option_skinning = settings.get("option_skinning", True) properties.option_bones = settings.get("option_bones", True) properties.align_model = settings.get("align_model", "None") properties.option_scale = settings.get("option_scale", 1.0) properties.option_flip_yz = settings.get("option_flip_yz", True) properties.option_export_scene = settings.get("option_export_scene", False) properties.option_embed_meshes = settings.get("option_embed_meshes", True) properties.option_url_base_html = settings.get("option_url_base_html", False) properties.option_copy_textures = settings.get("option_copy_textures", False) properties.option_lights = settings.get("option_lights", False) properties.option_cameras = settings.get("option_cameras", False) properties.option_animation_morph = settings.get("option_animation_morph", False) properties.option_animation_skeletal = settings.get("option_animation_skeletal", False) properties.option_frame_index_as_time = settings.get("option_frame_index_as_time", False) properties.option_frame_step = settings.get("option_frame_step", 1) properties.option_all_meshes = settings.get("option_all_meshes", True) # ################################################################ # Exporter # ################################################################ class ExportTHREEJS(bpy.types.Operator, ExportHelper): '''Export selected object / scene for Three.js (ASCII JSON format).''' bl_idname = "export.threejs" bl_label = "Export Three.js" filename_ext = ".json" option_vertices = BoolProperty(name = "Vertices", description = "Export vertices", default = True) option_vertices_deltas = BoolProperty(name = "Deltas", description = "Delta vertices", default = False) option_vertices_truncate = BoolProperty(name = "Truncate", description = "Truncate vertices", default = False) option_faces = BoolProperty(name = "Faces", description = "Export faces", default = True) option_faces_deltas = BoolProperty(name = "Deltas", description = "Delta faces", default = False) option_normals = BoolProperty(name = "Normals", description = "Export normals", default = True) option_colors = BoolProperty(name = "Colors", description = "Export vertex colors", default = True) option_uv_coords = BoolProperty(name = "UVs", description = "Export texture coordinates", default = True) option_materials = BoolProperty(name = "Materials", description = "Export materials", default = True) option_skinning = BoolProperty(name = "Skinning", description = "Export skin data", default = True) option_bones = BoolProperty(name = "Bones", description = "Export bones", default = True) align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")] align_model = EnumProperty(name = "Align model", description = "Align model", items = align_types, default = "None") option_scale = FloatProperty(name = "Scale", description = "Scale vertices", min = 0.01, max = 1000.0, soft_min = 0.01, soft_max = 1000.0, default = 1.0) option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True) option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False) option_embed_meshes = BoolProperty(name = "Embed meshes", description = "Embed meshes", default = True) option_copy_textures = BoolProperty(name = "Copy textures", description = "Copy textures", default = False) option_url_base_html = BoolProperty(name = "HTML as url base", description = "Use HTML as url base ", default = False) option_lights = BoolProperty(name = "Lights", description = "Export default scene lights", default = False) option_cameras = BoolProperty(name = "Cameras", description = "Export default scene cameras", default = False) option_animation_morph = BoolProperty(name = "Morph animation", description = "Export animation (morphs)", default = False) option_animation_skeletal = BoolProperty(name = "Skeletal animation", description = "Export animation (skeletal)", default = False) option_frame_index_as_time = BoolProperty(name = "Frame index as time", description = "Use (original) frame index as frame time", default = False) option_frame_step = IntProperty(name = "Frame step", description = "Animation frame step", min = 1, max = 1000, soft_min = 1, soft_max = 1000, default = 1) option_all_meshes = BoolProperty(name = "All meshes", description = "All meshes (merged)", default = True) def invoke(self, context, event): restore_settings_export(self.properties) return ExportHelper.invoke(self, context, event) @classmethod def poll(cls, context): return context.active_object != None def execute(self, context): print("Selected: " + context.active_object.name) if not self.properties.filepath: raise Exception("filename not set") save_settings_export(self.properties) filepath = self.filepath import io_mesh_threejs.export_threejs return io_mesh_threejs.export_threejs.save(self, context, **self.properties) def draw(self, context): layout = self.layout row = layout.row() row.label(text="Geometry:") row = layout.row() row.prop(self.properties, "option_vertices") # row = layout.row() # row.enabled = self.properties.option_vertices # row.prop(self.properties, "option_vertices_deltas") row.prop(self.properties, "option_vertices_truncate") layout.separator() row = layout.row() row.prop(self.properties, "option_faces") row = layout.row() row.enabled = self.properties.option_faces # row.prop(self.properties, "option_faces_deltas") layout.separator() row = layout.row() row.prop(self.properties, "option_normals") layout.separator() row = layout.row() row.prop(self.properties, "option_bones") row.prop(self.properties, "option_skinning") layout.separator() row = layout.row() row.label(text="Materials:") row = layout.row() row.prop(self.properties, "option_uv_coords") row.prop(self.properties, "option_colors") row = layout.row() row.prop(self.properties, "option_materials") layout.separator() row = layout.row() row.label(text="Settings:") row = layout.row() row.prop(self.properties, "align_model") row = layout.row() row.prop(self.properties, "option_flip_yz") row.prop(self.properties, "option_scale") layout.separator() row = layout.row() row.label(text="--------- Experimental ---------") layout.separator() row = layout.row() row.label(text="Scene:") row = layout.row() row.prop(self.properties, "option_export_scene") row.prop(self.properties, "option_embed_meshes") row = layout.row() row.prop(self.properties, "option_lights") row.prop(self.properties, "option_cameras") layout.separator() row = layout.row() row.label(text="Animation:") row = layout.row() row.prop(self.properties, "option_animation_morph") row = layout.row() row.prop(self.properties, "option_animation_skeletal") row = layout.row() row.prop(self.properties, "option_frame_index_as_time") row = layout.row() row.prop(self.properties, "option_frame_step") layout.separator() row = layout.row() row.label(text="Settings:") row = layout.row() row.prop(self.properties, "option_all_meshes") row = layout.row() row.prop(self.properties, "option_copy_textures") row = layout.row() row.prop(self.properties, "option_url_base_html") layout.separator() # ################################################################ # Common # ################################################################ def menu_func_export(self, context): default_path = bpy.data.filepath.replace(".blend", ".json") self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.json)").filepath = default_path def menu_func_import(self, context): self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.json)") def register(): bpy.utils.register_module(__name__) bpy.types.INFO_MT_file_export.append(menu_func_export) bpy.types.INFO_MT_file_import.append(menu_func_import) def unregister(): bpy.utils.unregister_module(__name__) bpy.types.INFO_MT_file_export.remove(menu_func_export) bpy.types.INFO_MT_file_import.remove(menu_func_import) if __name__ == "__main__": register()
mit
[ 3, 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 199, 3, 15779, 199, 3, 21026, 199, 3, 15779, 421, 199, 3345, 63, 815, 275, 469, 272, 298, 354, 582, 298, 10480, 14, 3596, 1475, 401, 272, 298, 2502, 582, 298, 13118, 1117, 2873, 12, 1022, 3258, 7697, 12, 29815, 81, 12, 32178, 69, 12, 299, 1949, 12, 302, 19, 3249, 82, 1082, 75, 12, 286, 293, 4492, 401, 272, 298, 1023, 582, 334, 17, 12, 959, 12, 378, 395, 272, 298, 66, 24912, 582, 334, 18, 12, 1520, 12, 378, 395, 272, 298, 1985, 582, 298, 1173, 690, 3161, 13, 11399, 401, 272, 298, 1802, 582, 298, 6295, 13, 11399, 7795, 14, 3596, 9364, 397, 401, 272, 298, 3764, 582, 4873, 272, 298, 6797, 63, 633, 582, 298, 2859, 921, 5031, 14, 957, 15, 13118, 1117, 2873, 15, 10480, 14, 3596, 15, 2350, 15, 4133, 15, 1208, 15, 1474, 27568, 15, 66, 24912, 401, 272, 298, 8877, 63, 633, 582, 298, 2859, 921, 5031, 14, 957, 15, 13118, 1117, 2873, 15, 10480, 14, 3596, 15, 10115, 401, 272, 298, 3710, 582, 298, 6295, 13, 11399, 3570, 199, 199, 3, 4005, 2291, 13101, 7684, 12, 862, 370, 2879, 282, 2559, 2729, 12, 199, 3, 340, 652, 1159, 2337, 12, 13101, 8137, 199, 199, 646, 20575, 199, 199, 692, 298, 66, 647, 2, 315, 9480, 837, 272, 492, 1742, 272, 340, 298, 3790, 63, 10480, 3596, 2, 315, 9480, 837, 267, 1742, 14, 9233, 8, 3790, 63, 10480, 3596, 9, 272, 340, 298, 646, 63, 10480, 3596, 2, 315, 9480, 837, 267, 1742, 14, 9233, 8, 646, 63, 10480, 3596, 9, 199, 199, 504, 20575, 14, 6750, 492, 627, 199, 504, 20575, 63, 9975, 14, 2308, 63, 1208, 492, 20220, 4433, 12, 3161, 4433, 199, 199, 3, 15779, 199, 3, 8388, 4382, 199, 3, 15779, 199, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 2931, 23574, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 9391, 23574, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 3157, 18934, 770, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 3790, 6831, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 6604, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 1180, 9787, 20094, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 4631, 3534, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 4631, 774, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 199, 2080, 5271, 63, 9820, 63, 1313, 275, 10003, 6845, 401, 298, 6845, 401, 298, 6845, 1288, 1689, 5663, 951, 401, 298, 5663, 951, 401, 298, 5663, 951, 1288, 1689, 44, 455, 12504, 401, 298, 44, 455, 12504, 401, 298, 44, 455, 12504, 11323, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 9820, 804, 275, 11305, 3697, 8, 354, 275, 298, 15787, 730, 401, 1369, 275, 298, 15787, 730, 401, 2974, 275, 16296, 63, 9820, 63, 1313, 12, 849, 275, 298, 44, 455, 12504, 531, 199, 199, 2080, 5271, 63, 66, 552, 1098, 63, 1313, 275, 10003, 1944, 34, 552, 1098, 401, 298, 1944, 34, 552, 1098, 401, 298, 1944, 34, 552, 1098, 1288, 1689, 6241, 34, 552, 1098, 401, 298, 6241, 34, 552, 1098, 401, 298, 6241, 34, 552, 1098, 1288, 717, 1689, 2767, 30844, 34, 552, 1098, 401, 298, 2767, 30844, 34, 552, 1098, 401, 298, 2767, 30844, 34, 552, 1098, 1288, 1689, 2610, 1239, 6648, 34, 552, 1098, 401, 298, 2610, 1239, 6648, 34, 552, 1098, 401, 298, 2610, 1239, 6648, 34, 552, 1098, 1288, 717, 1689, 25314, 590, 34, 552, 1098, 401, 298, 25314, 590, 34, 552, 1098, 401, 298, 25314, 590, 34, 552, 1098, 1288, 1689, 2767, 30844, 16192, 34, 552, 1098, 401, 298, 2767, 30844, 16192, 34, 552, 1098, 401, 298, 2767, 30844, 16192, 34, 552, 1098, 11323, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 66, 552, 1098, 804, 275, 11305, 3697, 8, 354, 275, 298, 34, 552, 1098, 730, 401, 1369, 275, 298, 34, 552, 1098, 730, 401, 2974, 275, 16296, 63, 66, 552, 1098, 63, 1313, 12, 849, 275, 298, 6241, 34, 552, 1098, 531, 199, 199, 533, 28652, 5550, 63, 4189, 63, 5006, 8, 20575, 14, 1313, 14, 10185, 3461, 339, 6826, 63, 1302, 275, 298, 2080, 5271, 2, 272, 6826, 63, 2638, 63, 466, 275, 298, 18858, 29807, 2, 272, 6826, 63, 4551, 63, 466, 275, 298, 15480, 2, 272, 6826, 63, 1100, 275, 298, 785, 2, 339, 347, 5954, 8, 277, 12, 1067, 304, 267, 7054, 275, 291, 14, 4209 ]
[ 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 199, 3, 15779, 199, 3, 21026, 199, 3, 15779, 421, 199, 3345, 63, 815, 275, 469, 272, 298, 354, 582, 298, 10480, 14, 3596, 1475, 401, 272, 298, 2502, 582, 298, 13118, 1117, 2873, 12, 1022, 3258, 7697, 12, 29815, 81, 12, 32178, 69, 12, 299, 1949, 12, 302, 19, 3249, 82, 1082, 75, 12, 286, 293, 4492, 401, 272, 298, 1023, 582, 334, 17, 12, 959, 12, 378, 395, 272, 298, 66, 24912, 582, 334, 18, 12, 1520, 12, 378, 395, 272, 298, 1985, 582, 298, 1173, 690, 3161, 13, 11399, 401, 272, 298, 1802, 582, 298, 6295, 13, 11399, 7795, 14, 3596, 9364, 397, 401, 272, 298, 3764, 582, 4873, 272, 298, 6797, 63, 633, 582, 298, 2859, 921, 5031, 14, 957, 15, 13118, 1117, 2873, 15, 10480, 14, 3596, 15, 2350, 15, 4133, 15, 1208, 15, 1474, 27568, 15, 66, 24912, 401, 272, 298, 8877, 63, 633, 582, 298, 2859, 921, 5031, 14, 957, 15, 13118, 1117, 2873, 15, 10480, 14, 3596, 15, 10115, 401, 272, 298, 3710, 582, 298, 6295, 13, 11399, 3570, 199, 199, 3, 4005, 2291, 13101, 7684, 12, 862, 370, 2879, 282, 2559, 2729, 12, 199, 3, 340, 652, 1159, 2337, 12, 13101, 8137, 199, 199, 646, 20575, 199, 199, 692, 298, 66, 647, 2, 315, 9480, 837, 272, 492, 1742, 272, 340, 298, 3790, 63, 10480, 3596, 2, 315, 9480, 837, 267, 1742, 14, 9233, 8, 3790, 63, 10480, 3596, 9, 272, 340, 298, 646, 63, 10480, 3596, 2, 315, 9480, 837, 267, 1742, 14, 9233, 8, 646, 63, 10480, 3596, 9, 199, 199, 504, 20575, 14, 6750, 492, 627, 199, 504, 20575, 63, 9975, 14, 2308, 63, 1208, 492, 20220, 4433, 12, 3161, 4433, 199, 199, 3, 15779, 199, 3, 8388, 4382, 199, 3, 15779, 199, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 2931, 23574, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 9391, 23574, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 3157, 18934, 770, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 3790, 6831, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 66, 647, 14, 1313, 14, 1692, 14, 2080, 5271, 63, 6604, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 1180, 9787, 20094, 275, 20575, 14, 6750, 14, 10349, 3697, 342, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 4631, 3534, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 4631, 774, 275, 20575, 14, 6750, 14, 10349, 3697, 8, 885, 275, 715, 9, 199, 199, 2080, 5271, 63, 9820, 63, 1313, 275, 10003, 6845, 401, 298, 6845, 401, 298, 6845, 1288, 1689, 5663, 951, 401, 298, 5663, 951, 401, 298, 5663, 951, 1288, 1689, 44, 455, 12504, 401, 298, 44, 455, 12504, 401, 298, 44, 455, 12504, 11323, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 9820, 804, 275, 11305, 3697, 8, 354, 275, 298, 15787, 730, 401, 1369, 275, 298, 15787, 730, 401, 2974, 275, 16296, 63, 9820, 63, 1313, 12, 849, 275, 298, 44, 455, 12504, 531, 199, 199, 2080, 5271, 63, 66, 552, 1098, 63, 1313, 275, 10003, 1944, 34, 552, 1098, 401, 298, 1944, 34, 552, 1098, 401, 298, 1944, 34, 552, 1098, 1288, 1689, 6241, 34, 552, 1098, 401, 298, 6241, 34, 552, 1098, 401, 298, 6241, 34, 552, 1098, 1288, 717, 1689, 2767, 30844, 34, 552, 1098, 401, 298, 2767, 30844, 34, 552, 1098, 401, 298, 2767, 30844, 34, 552, 1098, 1288, 1689, 2610, 1239, 6648, 34, 552, 1098, 401, 298, 2610, 1239, 6648, 34, 552, 1098, 401, 298, 2610, 1239, 6648, 34, 552, 1098, 1288, 717, 1689, 25314, 590, 34, 552, 1098, 401, 298, 25314, 590, 34, 552, 1098, 401, 298, 25314, 590, 34, 552, 1098, 1288, 1689, 2767, 30844, 16192, 34, 552, 1098, 401, 298, 2767, 30844, 16192, 34, 552, 1098, 401, 298, 2767, 30844, 16192, 34, 552, 1098, 11323, 199, 66, 647, 14, 1313, 14, 15787, 14, 2080, 5271, 63, 66, 552, 1098, 804, 275, 11305, 3697, 8, 354, 275, 298, 34, 552, 1098, 730, 401, 1369, 275, 298, 34, 552, 1098, 730, 401, 2974, 275, 16296, 63, 66, 552, 1098, 63, 1313, 12, 849, 275, 298, 6241, 34, 552, 1098, 531, 199, 199, 533, 28652, 5550, 63, 4189, 63, 5006, 8, 20575, 14, 1313, 14, 10185, 3461, 339, 6826, 63, 1302, 275, 298, 2080, 5271, 2, 272, 6826, 63, 2638, 63, 466, 275, 298, 18858, 29807, 2, 272, 6826, 63, 4551, 63, 466, 275, 298, 15480, 2, 272, 6826, 63, 1100, 275, 298, 785, 2, 339, 347, 5954, 8, 277, 12, 1067, 304, 267, 7054, 275, 291, 14, 4209, 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,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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 ]
isc-projects/forge
tests/dhcpv4/ddns/test_ddns_tsig_release.py
1
12902
"""DDNS without TSIG""" # pylint: disable=invalid-name,line-too-long import pytest import misc import srv_control import srv_msg @pytest.mark.v4 @pytest.mark.ddns @pytest.mark.tsig @pytest.mark.forward_reverse_remove def test_ddns4_tsig_sha1_forw_and_rev_release(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(21) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count(1, 'server_id') srv_msg.client_add_saved_option_count(1) srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_save_option('server_id') srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.client_add_saved_option_count(1) srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) @pytest.mark.v4 @pytest.mark.ddns @pytest.mark.tsig @pytest.mark.forward_reverse_remove def test_ddns4_tsig_forw_and_rev_release_notenabled(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(21) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count(1, 'server_id') srv_msg.client_add_saved_option_count(1) srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_save_option('server_id') srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_control.start_srv('DHCP', 'stopped') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', False) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_add_saved_option_count(1) srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') @pytest.mark.v4 @pytest.mark.ddns @pytest.mark.tsig @pytest.mark.reverse_remove def test_ddns4_tsig_sha1_rev_release(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(21) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count(1, 'server_id') srv_msg.client_add_saved_option_count(1) srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_save_option('server_id') srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.client_add_saved_option_count(1) srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False)
isc
[ 624, 5745, 2709, 1928, 377, 7864, 624, 199, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 12, 604, 13, 7354, 13, 2809, 199, 199, 646, 4613, 199, 199, 646, 18576, 199, 646, 20006, 63, 2785, 199, 646, 20006, 63, 1328, 421, 199, 32, 4462, 14, 1657, 14, 86, 20, 199, 32, 4462, 14, 1657, 14, 617, 561, 199, 32, 4462, 14, 1657, 14, 84, 4093, 199, 32, 4462, 14, 1657, 14, 6688, 63, 4471, 63, 2168, 199, 318, 511, 63, 617, 561, 20, 63, 84, 4093, 63, 4835, 17, 63, 509, 87, 63, 460, 63, 4964, 63, 3221, 837, 339, 18576, 14, 396, 63, 2758, 342, 272, 20006, 63, 2785, 14, 888, 63, 15165, 63, 5327, 360, 5756, 14, 6568, 14, 1400, 14, 16, 15, 1194, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 13, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 360, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2481, 4587, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 4296, 13, 7618, 297, 715, 9, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 10176, 13, 1861, 297, 283, 13672, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 537, 2021, 316, 13, 4511, 297, 283, 2694, 14, 957, 358, 272, 20006, 63, 2785, 14, 525, 63, 6688, 63, 617, 561, 360, 13672, 14, 2694, 14, 957, 3130, 283, 16677, 14, 4835, 17, 14, 498, 358, 272, 20006, 63, 2785, 14, 525, 63, 4471, 63, 617, 561, 360, 1400, 14, 6568, 14, 5756, 14, 262, 13, 2697, 14, 285, 387, 3130, 283, 16677, 14, 4835, 17, 14, 498, 358, 272, 20006, 63, 2785, 14, 525, 63, 1612, 360, 16677, 14, 4835, 17, 14, 498, 297, 283, 23034, 13, 8461, 17, 297, 283, 9060, 20, 88, 43, 58, 15, 74, 2585, 66, 9249, 320, 20, 82, 2700, 2760, 87, 18900, 272, 20006, 63, 2785, 14, 1506, 63, 460, 63, 2254, 63, 888, 63, 1725, 342, 272, 20006, 63, 2785, 14, 928, 63, 15165, 360, 29977, 297, 283, 8924, 358, 339, 20006, 63, 2785, 14, 1180, 63, 5797, 63, 409, 63, 1955, 8, 2025, 9, 272, 20006, 63, 2785, 14, 928, 63, 15165, 360, 12323, 297, 283, 8924, 358, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 5797, 63, 4790, 63, 3059, 360, 2158, 14, 13672, 14, 2694, 14, 957, 297, 283, 33, 297, 283, 568, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 5797, 63, 1131, 342, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1131, 360, 45, 7698, 358, 272, 20006, 63, 1328, 14, 5797, 63, 1422, 360, 5622, 12018, 297, 4282, 63, 2613, 29, 797, 9, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 6615, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 1328, 360, 6178, 19052, 358, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1188, 360, 45, 7698, 297, 283, 7517, 540, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1317, 360, 21643, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 17, 12, 283, 585, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 358, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 2117, 63, 1422, 63, 835, 8, 17, 12, 283, 1000, 63, 344, 358, 272, 20006, 63, 1328, 14, 1258, 63, 525, 63, 8420, 63, 1422, 63, 835, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 9105, 63, 2613, 63, 1045, 63, 585, 360, 11151, 63, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1258, 63, 6615, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 2193, 63, 585, 360, 3041, 297, 283, 27629, 10872, 63, 2261, 63, 354, 297, 283, 2158, 14, 13672, 14, 2694, 14, 957, 2659, 272, 20006, 63, 1328, 14, 1258, 63, 2193, 63, 585, 360, 3041, 297, 283, 27629, 10872, 63, 2469, 297, 283, 51, 358, 272, 20006, 63, 1328, 14, 1258, 63, 9105, 63, 2613, 360, 3041, 297, 283, 18364, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 1328, 360, 6780, 358, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1188, 360, 45, 7698, 297, 283, 3099, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1317, 360, 21643, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 17, 12, 283, 585, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 2835, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 2835, 12, 283, 2469, 297, 413, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 2835, 12, 283, 18364, 297, 283, 2158, 14, 13672, 14, 2694, 14, 957, 2659, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 2117, 63, 1422, 360, 1000, 63, 344, 358, 272, 20006, 63, 1328, 14, 5797, 63, 4790, 63, 3059, 360, 2158, 14, 13672, 14, 2694, 14, 957, 297, 283, 33, 297, 283, 568, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 5797, 63, 1131, 342, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1131, 360, 45, 7698, 358, 272, 20006, 63, 1328, 14, 5797, 63, 1422, 360, 5622, 12018, 358, 272, 20006, 63, 1328, 14, 5797 ]
[ 5745, 2709, 1928, 377, 7864, 624, 199, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 12, 604, 13, 7354, 13, 2809, 199, 199, 646, 4613, 199, 199, 646, 18576, 199, 646, 20006, 63, 2785, 199, 646, 20006, 63, 1328, 421, 199, 32, 4462, 14, 1657, 14, 86, 20, 199, 32, 4462, 14, 1657, 14, 617, 561, 199, 32, 4462, 14, 1657, 14, 84, 4093, 199, 32, 4462, 14, 1657, 14, 6688, 63, 4471, 63, 2168, 199, 318, 511, 63, 617, 561, 20, 63, 84, 4093, 63, 4835, 17, 63, 509, 87, 63, 460, 63, 4964, 63, 3221, 837, 339, 18576, 14, 396, 63, 2758, 342, 272, 20006, 63, 2785, 14, 888, 63, 15165, 63, 5327, 360, 5756, 14, 6568, 14, 1400, 14, 16, 15, 1194, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 13, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 360, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2481, 4587, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 4296, 13, 7618, 297, 715, 9, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 10176, 13, 1861, 297, 283, 13672, 358, 272, 20006, 63, 2785, 14, 525, 63, 617, 561, 63, 1000, 63, 1419, 360, 537, 2021, 316, 13, 4511, 297, 283, 2694, 14, 957, 358, 272, 20006, 63, 2785, 14, 525, 63, 6688, 63, 617, 561, 360, 13672, 14, 2694, 14, 957, 3130, 283, 16677, 14, 4835, 17, 14, 498, 358, 272, 20006, 63, 2785, 14, 525, 63, 4471, 63, 617, 561, 360, 1400, 14, 6568, 14, 5756, 14, 262, 13, 2697, 14, 285, 387, 3130, 283, 16677, 14, 4835, 17, 14, 498, 358, 272, 20006, 63, 2785, 14, 525, 63, 1612, 360, 16677, 14, 4835, 17, 14, 498, 297, 283, 23034, 13, 8461, 17, 297, 283, 9060, 20, 88, 43, 58, 15, 74, 2585, 66, 9249, 320, 20, 82, 2700, 2760, 87, 18900, 272, 20006, 63, 2785, 14, 1506, 63, 460, 63, 2254, 63, 888, 63, 1725, 342, 272, 20006, 63, 2785, 14, 928, 63, 15165, 360, 29977, 297, 283, 8924, 358, 339, 20006, 63, 2785, 14, 1180, 63, 5797, 63, 409, 63, 1955, 8, 2025, 9, 272, 20006, 63, 2785, 14, 928, 63, 15165, 360, 12323, 297, 283, 8924, 358, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 5797, 63, 4790, 63, 3059, 360, 2158, 14, 13672, 14, 2694, 14, 957, 297, 283, 33, 297, 283, 568, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 5797, 63, 1131, 342, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1131, 360, 45, 7698, 358, 272, 20006, 63, 1328, 14, 5797, 63, 1422, 360, 5622, 12018, 297, 4282, 63, 2613, 29, 797, 9, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 6615, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 1328, 360, 6178, 19052, 358, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1188, 360, 45, 7698, 297, 283, 7517, 540, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1317, 360, 21643, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 17, 12, 283, 585, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 358, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 2117, 63, 1422, 63, 835, 8, 17, 12, 283, 1000, 63, 344, 358, 272, 20006, 63, 1328, 14, 1258, 63, 525, 63, 8420, 63, 1422, 63, 835, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 9105, 63, 2613, 63, 1045, 63, 585, 360, 11151, 63, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1258, 63, 6615, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1258, 63, 2193, 63, 585, 360, 3041, 297, 283, 27629, 10872, 63, 2261, 63, 354, 297, 283, 2158, 14, 13672, 14, 2694, 14, 957, 2659, 272, 20006, 63, 1328, 14, 1258, 63, 2193, 63, 585, 360, 3041, 297, 283, 27629, 10872, 63, 2469, 297, 283, 51, 358, 272, 20006, 63, 1328, 14, 1258, 63, 9105, 63, 2613, 360, 3041, 297, 283, 18364, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 1328, 360, 6780, 358, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1188, 360, 45, 7698, 297, 283, 3099, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1317, 360, 21643, 2697, 297, 283, 5756, 14, 6568, 14, 1400, 14, 709, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 17, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 17, 12, 283, 585, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 358, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 2613, 63, 1422, 8, 2835, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 2835, 12, 283, 2469, 297, 413, 9, 272, 20006, 63, 1328, 14, 1310, 63, 1074, 63, 1422, 63, 1317, 8, 2835, 12, 283, 18364, 297, 283, 2158, 14, 13672, 14, 2694, 14, 957, 2659, 339, 18576, 14, 396, 63, 21978, 342, 272, 20006, 63, 1328, 14, 1258, 63, 2117, 63, 1422, 360, 1000, 63, 344, 358, 272, 20006, 63, 1328, 14, 5797, 63, 4790, 63, 3059, 360, 2158, 14, 13672, 14, 2694, 14, 957, 297, 283, 33, 297, 283, 568, 358, 272, 20006, 63, 1328, 14, 1258, 63, 2254, 63, 5797, 63, 1131, 342, 339, 18576, 14, 1529, 63, 20525, 342, 272, 20006, 63, 1328, 14, 2254, 63, 2573, 63, 509, 63, 1131, 360, 45, 7698, 358, 272, 20006, 63, 1328, 14, 5797, 63, 1422, 360, 5622, 12018, 358, 272, 20006, 63, 1328, 14, 5797, 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 ]
andnovar/networkx
networkx/algorithms/community/tests/test_kclique.py
94
2152
#!/usr/bin/env python from nose.tools import * import networkx as nx from itertools import combinations from networkx import k_clique_communities def test_overlaping_K5(): G = nx.Graph() G.add_edges_from(combinations(range(5), 2)) # Add a five clique G.add_edges_from(combinations(range(2,7), 2)) # Add another five clique c = list(nx.k_clique_communities(G, 4)) assert_equal(c,[frozenset([0, 1, 2, 3, 4, 5, 6])]) c= list(nx.k_clique_communities(G, 5)) assert_equal(set(c),set([frozenset([0,1,2,3,4]),frozenset([2,3,4,5,6])])) def test_isolated_K5(): G = nx.Graph() G.add_edges_from(combinations(range(0,5), 2)) # Add a five clique G.add_edges_from(combinations(range(5,10), 2)) # Add another five clique c= list(nx.k_clique_communities(G, 5)) assert_equal(set(c),set([frozenset([0,1,2,3,4]),frozenset([5,6,7,8,9])])) def test_zachary(): z = nx.karate_club_graph() # clique percolation with k=2 is just connected components zachary_k2_ground_truth = set([frozenset(z.nodes())]) zachary_k3_ground_truth = set([frozenset([0, 1, 2, 3, 7, 8, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 26, 27, 28, 29, 30, 31, 32, 33]), frozenset([0, 4, 5, 6, 10, 16]), frozenset([24, 25, 31])]) zachary_k4_ground_truth = set([frozenset([0, 1, 2, 3, 7, 13]), frozenset([8, 32, 30, 33]), frozenset([32, 33, 29, 23])]) zachary_k5_ground_truth = set([frozenset([0, 1, 2, 3, 7, 13])]) zachary_k6_ground_truth = set([]) assert set(k_clique_communities(z, 2)) == zachary_k2_ground_truth assert set(k_clique_communities(z, 3)) == zachary_k3_ground_truth assert set(k_clique_communities(z, 4)) == zachary_k4_ground_truth assert set(k_clique_communities(z, 5)) == zachary_k5_ground_truth assert set(k_clique_communities(z, 6)) == zachary_k6_ground_truth @raises(nx.NetworkXError) def test_bad_k(): c = list(k_clique_communities(nx.Graph(),1))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 11354, 14, 2537, 492, 627, 199, 646, 24313, 465, 8484, 199, 504, 7975, 492, 15821, 199, 504, 24313, 492, 1022, 63, 2764, 544, 63, 1404, 22047, 199, 199, 318, 511, 63, 1883, 416, 4073, 63, 43, 21, 837, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 21, 395, 499, 430, 327, 2654, 282, 24187, 5053, 544, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 18, 12, 23, 395, 499, 430, 327, 2654, 4573, 24187, 5053, 544, 272, 286, 275, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 841, 430, 272, 702, 63, 1452, 8, 67, 14343, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 24310, 272, 286, 29, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 959, 430, 272, 702, 63, 1452, 8, 409, 8, 67, 395, 409, 779, 21362, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 2522, 21362, 779, 18, 12, 19, 12, 20, 12, 21, 12, 22, 566, 2459, 199, 199, 318, 511, 63, 21748, 63, 43, 21, 837, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 16, 12, 21, 395, 499, 430, 327, 2654, 282, 24187, 5053, 544, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 21, 12, 709, 395, 499, 430, 327, 2654, 4573, 24187, 5053, 544, 272, 286, 29, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 959, 430, 272, 702, 63, 1452, 8, 409, 8, 67, 395, 409, 779, 21362, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 2522, 21362, 779, 21, 12, 22, 12, 23, 12, 24, 12, 25, 566, 2459, 199, 199, 318, 511, 63, 90, 1225, 695, 837, 272, 1315, 275, 8484, 14, 75, 285, 323, 63, 429, 456, 63, 2180, 342, 272, 327, 5053, 544, 1126, 331, 2212, 543, 1022, 29, 18, 365, 2951, 8539, 7323, 272, 1315, 1225, 695, 63, 75, 18, 63, 3928, 63, 17167, 275, 663, 779, 21362, 8, 90, 14, 2415, 30719, 272, 1315, 1225, 695, 63, 75, 19, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 1695, 12, 3144, 12, 4944, 12, 4329, 12, 221, 6343, 4114, 12, 5557, 12, 6155, 12, 5851, 12, 3388, 12, 7829, 12, 6928, 12, 6546, 12, 221, 6343, 7875, 12, 8087, 12, 7294, 12, 7349, 12, 4233, 12, 7105, 12, 4337, 12, 9404, 2522, 3521, 9522, 779, 16, 12, 841, 12, 959, 12, 1227, 12, 1616, 12, 3193, 2522, 3521, 9522, 779, 1194, 12, 5661, 12, 7105, 24310, 272, 1315, 1225, 695, 63, 75, 20, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 4944, 2522, 3521, 9522, 779, 24, 12, 4337, 12, 4233, 12, 9404, 2522, 3521, 9522, 779, 708, 12, 9404, 12, 7349, 12, 6546, 24310, 272, 1315, 1225, 695, 63, 75, 21, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 4944, 24310, 272, 1315, 1225, 695, 63, 75, 22, 63, 3928, 63, 17167, 275, 663, 4157, 339, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 499, 430, 508, 1315, 1225, 695, 63, 75, 18, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 650, 430, 508, 1315, 1225, 695, 63, 75, 19, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 841, 430, 508, 1315, 1225, 695, 63, 75, 20, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 959, 430, 508, 1315, 1225, 695, 63, 75, 21, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 1227, 430, 508, 1315, 1225, 695, 63, 75, 22, 63, 3928, 63, 17167, 199, 199, 32, 3536, 8, 7343, 14, 4491, 29356, 9, 199, 318, 511, 63, 4087, 63, 75, 837, 272, 286, 275, 769, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 7343, 14, 4578, 1062, 17, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 11354, 14, 2537, 492, 627, 199, 646, 24313, 465, 8484, 199, 504, 7975, 492, 15821, 199, 504, 24313, 492, 1022, 63, 2764, 544, 63, 1404, 22047, 199, 199, 318, 511, 63, 1883, 416, 4073, 63, 43, 21, 837, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 21, 395, 499, 430, 327, 2654, 282, 24187, 5053, 544, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 18, 12, 23, 395, 499, 430, 327, 2654, 4573, 24187, 5053, 544, 272, 286, 275, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 841, 430, 272, 702, 63, 1452, 8, 67, 14343, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 24310, 272, 286, 29, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 959, 430, 272, 702, 63, 1452, 8, 409, 8, 67, 395, 409, 779, 21362, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 2522, 21362, 779, 18, 12, 19, 12, 20, 12, 21, 12, 22, 566, 2459, 199, 199, 318, 511, 63, 21748, 63, 43, 21, 837, 272, 598, 275, 8484, 14, 4578, 342, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 16, 12, 21, 395, 499, 430, 327, 2654, 282, 24187, 5053, 544, 272, 598, 14, 525, 63, 6929, 63, 504, 8, 18026, 8, 1842, 8, 21, 12, 709, 395, 499, 430, 327, 2654, 4573, 24187, 5053, 544, 272, 286, 29, 769, 8, 7343, 14, 75, 63, 2764, 544, 63, 1404, 22047, 8, 39, 12, 959, 430, 272, 702, 63, 1452, 8, 409, 8, 67, 395, 409, 779, 21362, 779, 16, 12, 17, 12, 18, 12, 19, 12, 20, 2522, 21362, 779, 21, 12, 22, 12, 23, 12, 24, 12, 25, 566, 2459, 199, 199, 318, 511, 63, 90, 1225, 695, 837, 272, 1315, 275, 8484, 14, 75, 285, 323, 63, 429, 456, 63, 2180, 342, 272, 327, 5053, 544, 1126, 331, 2212, 543, 1022, 29, 18, 365, 2951, 8539, 7323, 272, 1315, 1225, 695, 63, 75, 18, 63, 3928, 63, 17167, 275, 663, 779, 21362, 8, 90, 14, 2415, 30719, 272, 1315, 1225, 695, 63, 75, 19, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 1695, 12, 3144, 12, 4944, 12, 4329, 12, 221, 6343, 4114, 12, 5557, 12, 6155, 12, 5851, 12, 3388, 12, 7829, 12, 6928, 12, 6546, 12, 221, 6343, 7875, 12, 8087, 12, 7294, 12, 7349, 12, 4233, 12, 7105, 12, 4337, 12, 9404, 2522, 3521, 9522, 779, 16, 12, 841, 12, 959, 12, 1227, 12, 1616, 12, 3193, 2522, 3521, 9522, 779, 1194, 12, 5661, 12, 7105, 24310, 272, 1315, 1225, 695, 63, 75, 20, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 4944, 2522, 3521, 9522, 779, 24, 12, 4337, 12, 4233, 12, 9404, 2522, 3521, 9522, 779, 708, 12, 9404, 12, 7349, 12, 6546, 24310, 272, 1315, 1225, 695, 63, 75, 21, 63, 3928, 63, 17167, 275, 663, 779, 21362, 779, 16, 12, 413, 12, 499, 12, 650, 12, 1520, 12, 4944, 24310, 272, 1315, 1225, 695, 63, 75, 22, 63, 3928, 63, 17167, 275, 663, 4157, 339, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 499, 430, 508, 1315, 1225, 695, 63, 75, 18, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 650, 430, 508, 1315, 1225, 695, 63, 75, 19, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 841, 430, 508, 1315, 1225, 695, 63, 75, 20, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 959, 430, 508, 1315, 1225, 695, 63, 75, 21, 63, 3928, 63, 17167, 272, 702, 663, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 90, 12, 1227, 430, 508, 1315, 1225, 695, 63, 75, 22, 63, 3928, 63, 17167, 199, 199, 32, 3536, 8, 7343, 14, 4491, 29356, 9, 199, 318, 511, 63, 4087, 63, 75, 837, 272, 286, 275, 769, 8, 75, 63, 2764, 544, 63, 1404, 22047, 8, 7343, 14, 4578, 1062, 17, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
HighwindONE/android_kernel_lge_msm8226
tools/perf/util/setup.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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MackZxh/OCA-Choice
project/sale_order_project/models/sale.py
19
2400
# -*- coding: utf-8 -*- ############################################################################### # # Module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com). # Copyright (C) 2010-2013 Akretion LDTA (<http://www.akretion.com>) # @author Sébastien BEAU <sebastien.beau@akretion.com> # @author Benoît GUILLOT <benoit.guillot@akretion.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################### from openerp import api, fields, models from datetime import date class SaleOrder(models.Model): _inherit = "sale.order" @api.one @api.depends('project_id') def _compute_related_project_id(self): self.related_project_id = ( self.project_id.use_tasks and self.env['project.project'].search( [('analytic_account_id', '=', self.project_id.id)], limit=1)[:1]) related_project_id = fields.Many2one( comodel_name='project.project', string='Project', compute='_compute_related_project_id') @api.model def _prepare_project_vals(self, order): name = u" %s - %s - %s" % ( order.partner_id.name, date.today().year, order.name) return { 'user_id': order.user_id.id, 'name': name, 'partner_id': order.partner_id.id, } @api.multi def action_create_project(self): project_obj = self.env['project.project'] for order in self: vals = self._prepare_project_vals(order) project = project_obj.create(vals) order.write({ 'project_id': project.analytic_account_id.id }) return True
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 199, 3, 257, 5673, 367, 7653, 199, 3, 257, 1898, 334, 35, 9, 6927, 437, 75, 264, 296, 334, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 680, 199, 3, 257, 1898, 334, 35, 9, 7129, 13, 6965, 437, 75, 264, 296, 16978, 6166, 8642, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 18956, 199, 3, 257, 768, 2502, 428, 5741, 66, 1810, 24555, 6262, 9331, 665, 261, 66, 1810, 24555, 14, 1235, 3844, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 257, 768, 2502, 26844, 79, 128, 107, 84, 598, 53, 14961, 1387, 665, 18486, 79, 390, 14, 6051, 382, 1653, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 257, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 257, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 11490, 199, 199, 504, 5166, 492, 2986, 12, 1504, 12, 1709, 199, 504, 2197, 492, 1434, 421, 199, 533, 428, 1895, 4738, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 298, 8515, 14, 1648, 2, 339, 768, 1246, 14, 368, 272, 768, 1246, 14, 8912, 360, 1715, 63, 344, 358, 272, 347, 485, 3357, 63, 2407, 63, 1715, 63, 344, 8, 277, 304, 267, 291, 14, 2407, 63, 1715, 63, 344, 275, 334, 288, 291, 14, 1715, 63, 344, 14, 1180, 63, 5054, 436, 288, 291, 14, 1813, 459, 1715, 14, 1715, 2278, 1733, 8, 355, 4274, 9782, 63, 2048, 63, 344, 297, 6291, 291, 14, 1715, 63, 344, 14, 344, 4360, 355, 2304, 29, 17, 18562, 17, 566, 339, 4048, 63, 1715, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 512, 1238, 63, 354, 534, 1715, 14, 1715, 297, 1059, 534, 4761, 297, 267, 4526, 17574, 3357, 63, 2407, 63, 1715, 63, 344, 358, 339, 768, 1246, 14, 1238, 272, 347, 485, 6726, 63, 1715, 63, 3643, 8, 277, 12, 1865, 304, 267, 536, 275, 399, 2, 450, 83, 446, 450, 83, 446, 450, 83, 2, 450, 334, 288, 1865, 14, 3899, 63, 344, 14, 354, 12, 288, 1434, 14, 8136, 1252, 3403, 12, 288, 1865, 14, 354, 9, 267, 372, 469, 288, 283, 751, 63, 344, 356, 1865, 14, 751, 63, 344, 14, 344, 12, 288, 283, 354, 356, 536, 12, 288, 283, 3899, 63, 344, 356, 1865, 14, 3899, 63, 344, 14, 344, 12, 267, 789, 339, 768, 1246, 14, 3029, 272, 347, 1595, 63, 981, 63, 1715, 8, 277, 304, 267, 2199, 63, 1113, 275, 291, 14, 1813, 459, 1715, 14, 1715, 418, 267, 367, 1865, 315, 291, 26, 288, 5322, 275, 291, 423, 6726, 63, 1715, 63, 3643, 8, 1648, 9, 288, 2199, 275, 2199, 63, 1113, 14, 981, 8, 3643, 9, 288, 1865, 14, 952, 2561, 355, 283, 1715, 63, 344, 356, 2199, 14, 9782, 63, 2048, 63, 344, 14, 344, 288, 3828, 267, 372, 715, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 199, 3, 257, 5673, 367, 7653, 199, 3, 257, 1898, 334, 35, 9, 6927, 437, 75, 264, 296, 334, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 680, 199, 3, 257, 1898, 334, 35, 9, 7129, 13, 6965, 437, 75, 264, 296, 16978, 6166, 8642, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 18956, 199, 3, 257, 768, 2502, 428, 5741, 66, 1810, 24555, 6262, 9331, 665, 261, 66, 1810, 24555, 14, 1235, 3844, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 257, 768, 2502, 26844, 79, 128, 107, 84, 598, 53, 14961, 1387, 665, 18486, 79, 390, 14, 6051, 382, 1653, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 257, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 257, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 11490, 199, 199, 504, 5166, 492, 2986, 12, 1504, 12, 1709, 199, 504, 2197, 492, 1434, 421, 199, 533, 428, 1895, 4738, 8, 992, 14, 1685, 304, 272, 485, 6486, 275, 298, 8515, 14, 1648, 2, 339, 768, 1246, 14, 368, 272, 768, 1246, 14, 8912, 360, 1715, 63, 344, 358, 272, 347, 485, 3357, 63, 2407, 63, 1715, 63, 344, 8, 277, 304, 267, 291, 14, 2407, 63, 1715, 63, 344, 275, 334, 288, 291, 14, 1715, 63, 344, 14, 1180, 63, 5054, 436, 288, 291, 14, 1813, 459, 1715, 14, 1715, 2278, 1733, 8, 355, 4274, 9782, 63, 2048, 63, 344, 297, 6291, 291, 14, 1715, 63, 344, 14, 344, 4360, 355, 2304, 29, 17, 18562, 17, 566, 339, 4048, 63, 1715, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 512, 1238, 63, 354, 534, 1715, 14, 1715, 297, 1059, 534, 4761, 297, 267, 4526, 17574, 3357, 63, 2407, 63, 1715, 63, 344, 358, 339, 768, 1246, 14, 1238, 272, 347, 485, 6726, 63, 1715, 63, 3643, 8, 277, 12, 1865, 304, 267, 536, 275, 399, 2, 450, 83, 446, 450, 83, 446, 450, 83, 2, 450, 334, 288, 1865, 14, 3899, 63, 344, 14, 354, 12, 288, 1434, 14, 8136, 1252, 3403, 12, 288, 1865, 14, 354, 9, 267, 372, 469, 288, 283, 751, 63, 344, 356, 1865, 14, 751, 63, 344, 14, 344, 12, 288, 283, 354, 356, 536, 12, 288, 283, 3899, 63, 344, 356, 1865, 14, 3899, 63, 344, 14, 344, 12, 267, 789, 339, 768, 1246, 14, 3029, 272, 347, 1595, 63, 981, 63, 1715, 8, 277, 304, 267, 2199, 63, 1113, 275, 291, 14, 1813, 459, 1715, 14, 1715, 418, 267, 367, 1865, 315, 291, 26, 288, 5322, 275, 291, 423, 6726, 63, 1715, 63, 3643, 8, 1648, 9, 288, 2199, 275, 2199, 63, 1113, 14, 981, 8, 3643, 9, 288, 1865, 14, 952, 2561, 355, 283, 1715, 63, 344, 356, 2199, 14, 9782, 63, 2048, 63, 344, 14, 344, 288, 3828, 267, 372, 715, 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, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
alejo8591/culttume2
venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connection.py
187
5659
# urllib3/connection.py # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) # # This module is part of urllib3 and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php import socket from socket import timeout as SocketTimeout try: # Python 3 from http.client import HTTPConnection as _HTTPConnection, HTTPException except ImportError: from httplib import HTTPConnection as _HTTPConnection, HTTPException class DummyConnection(object): "Used to detect a failed ConnectionCls import." pass try: # Compiled with SSL? ssl = None HTTPSConnection = DummyConnection class BaseSSLError(BaseException): pass try: # Python 3 from http.client import HTTPSConnection as _HTTPSConnection except ImportError: from httplib import HTTPSConnection as _HTTPSConnection import ssl BaseSSLError = ssl.SSLError except (ImportError, AttributeError): # Platform-specific: No SSL. pass from .exceptions import ( ConnectTimeoutError, ) from .packages.ssl_match_hostname import match_hostname from .util import ( assert_fingerprint, resolve_cert_reqs, resolve_ssl_version, ssl_wrap_socket, ) port_by_scheme = { 'http': 80, 'https': 443, } class HTTPConnection(_HTTPConnection, object): default_port = port_by_scheme['http'] # By default, disable Nagle's Algorithm. tcp_nodelay = 1 def _new_conn(self): """ Establish a socket connection and set nodelay settings on it :return: a new socket connection """ try: conn = socket.create_connection( (self.host, self.port), self.timeout, self.source_address, ) except AttributeError: # Python 2.6 conn = socket.create_connection( (self.host, self.port), self.timeout, ) conn.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, self.tcp_nodelay) return conn def _prepare_conn(self, conn): self.sock = conn if self._tunnel_host: # TODO: Fix tunnel so it doesn't depend on self.sock state. self._tunnel() def connect(self): conn = self._new_conn() self._prepare_conn(conn) class HTTPSConnection(HTTPConnection): default_port = port_by_scheme['https'] def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None): try: HTTPConnection.__init__(self, host, port, strict, timeout, source_address) except TypeError: # Python 2.6 HTTPConnection.__init__(self, host, port, strict, timeout) self.key_file = key_file self.cert_file = cert_file def connect(self): conn = self._new_conn() self._prepare_conn(conn) self.sock = ssl.wrap_socket(conn, self.key_file, self.cert_file) class VerifiedHTTPSConnection(HTTPSConnection): """ Based on httplib.HTTPSConnection but wraps the socket with SSL certification. """ cert_reqs = None ca_certs = None ssl_version = None def set_cert(self, key_file=None, cert_file=None, cert_reqs=None, ca_certs=None, assert_hostname=None, assert_fingerprint=None): self.key_file = key_file self.cert_file = cert_file self.cert_reqs = cert_reqs self.ca_certs = ca_certs self.assert_hostname = assert_hostname self.assert_fingerprint = assert_fingerprint def connect(self): # Add certificate verification try: sock = socket.create_connection( address=(self.host, self.port), timeout=self.timeout, ) except SocketTimeout: raise ConnectTimeoutError( self, "Connection to %s timed out. (connect timeout=%s)" % (self.host, self.timeout)) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, self.tcp_nodelay) resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs) resolved_ssl_version = resolve_ssl_version(self.ssl_version) # the _tunnel_host attribute was added in python 2.6.3 (via # http://hg.python.org/cpython/rev/0f57b30a152f) so pythons 2.6(0-2) do # not have them. if getattr(self, '_tunnel_host', None): self.sock = sock # Calls self._set_hostport(), so self.host is # self._tunnel_host below. self._tunnel() # Wrap socket using verification with the root certs in # trusted_root_certs self.sock = ssl_wrap_socket(sock, self.key_file, self.cert_file, cert_reqs=resolved_cert_reqs, ca_certs=self.ca_certs, server_hostname=self.host, ssl_version=resolved_ssl_version) if resolved_cert_reqs != ssl.CERT_NONE: if self.assert_fingerprint: assert_fingerprint(self.sock.getpeercert(binary_form=True), self.assert_fingerprint) elif self.assert_hostname is not False: match_hostname(self.sock.getpeercert(), self.assert_hostname or self.host) if ssl: # Make a copy for testing. UnverifiedHTTPSConnection = HTTPSConnection HTTPSConnection = VerifiedHTTPSConnection
mit
[ 3, 4011, 19, 15, 2105, 14, 647, 199, 3, 1898, 9079, 13, 6965, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 646, 2838, 199, 504, 2838, 492, 2653, 465, 17766, 6372, 199, 199, 893, 26, 327, 2018, 650, 272, 687, 1455, 14, 1258, 492, 3101, 3225, 465, 485, 19114, 12, 28185, 199, 2590, 3545, 26, 272, 687, 8809, 492, 3101, 3225, 465, 485, 19114, 12, 28185, 199, 199, 533, 9762, 3225, 8, 785, 304, 272, 298, 9167, 370, 9696, 282, 3405, 8113, 24342, 492, 2122, 272, 986, 199, 199, 893, 26, 327, 3599, 1672, 543, 7799, 31, 272, 6149, 275, 488, 272, 14147, 3225, 275, 9762, 3225, 339, 1021, 3523, 27102, 8, 29900, 304, 267, 986, 339, 862, 26, 327, 2018, 650, 267, 687, 1455, 14, 1258, 492, 14147, 3225, 465, 485, 27945, 272, 871, 3545, 26, 267, 687, 8809, 492, 14147, 3225, 465, 485, 27945, 339, 492, 6149, 272, 3523, 27102, 275, 6149, 14, 27102, 199, 199, 2590, 334, 17825, 12, 4281, 304, 327, 16078, 13, 6100, 26, 3091, 7799, 14, 272, 986, 199, 199, 504, 1275, 3924, 492, 334, 272, 15175, 19382, 12, 199, 9, 199, 504, 1275, 5154, 14, 4266, 63, 1431, 63, 4269, 492, 1336, 63, 4269, 199, 504, 1275, 1974, 492, 334, 272, 702, 63, 15077, 12, 272, 7512, 63, 4736, 63, 12720, 12, 272, 7512, 63, 4266, 63, 1023, 12, 272, 6149, 63, 3823, 63, 3450, 12, 199, 9, 421, 199, 719, 63, 991, 63, 5512, 275, 469, 272, 283, 1014, 356, 5939, 12, 272, 283, 2859, 356, 23865, 12, 199, 93, 421, 199, 533, 3101, 3225, 1547, 19114, 12, 909, 304, 272, 849, 63, 719, 275, 1844, 63, 991, 63, 5512, 459, 1014, 418, 339, 327, 4885, 849, 12, 3507, 653, 643, 274, 1159, 23823, 14, 272, 14719, 63, 932, 817, 275, 413, 339, 347, 485, 1222, 63, 1631, 8, 277, 304, 267, 408, 15896, 13306, 282, 2838, 1950, 436, 663, 1031, 817, 2202, 641, 652, 398, 520, 1107, 26, 282, 892, 2838, 1950, 267, 408, 267, 862, 26, 288, 2557, 275, 2838, 14, 981, 63, 2105, 8, 355, 334, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 291, 14, 2593, 12, 355, 291, 14, 1365, 63, 1562, 12, 288, 776, 267, 871, 4281, 26, 327, 2018, 499, 14, 22, 288, 2557, 275, 2838, 14, 981, 63, 2105, 8, 355, 334, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 291, 14, 2593, 12, 288, 776, 267, 2557, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 717, 291, 14, 8815, 63, 932, 817, 9, 267, 372, 2557, 339, 347, 485, 6726, 63, 1631, 8, 277, 12, 2557, 304, 267, 291, 14, 5096, 275, 2557, 267, 340, 291, 423, 15360, 63, 1102, 26, 288, 327, 3254, 26, 14811, 21496, 880, 652, 3181, 1133, 11687, 641, 291, 14, 5096, 1174, 14, 288, 291, 423, 15360, 342, 339, 347, 4907, 8, 277, 304, 267, 2557, 275, 291, 423, 1222, 63, 1631, 342, 267, 291, 423, 6726, 63, 1631, 8, 1631, 9, 421, 199, 533, 14147, 3225, 8, 19114, 304, 272, 849, 63, 719, 275, 1844, 63, 991, 63, 5512, 459, 2859, 418, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 29, 403, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 326, 7478, 29, 403, 12, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 326, 1350, 63, 1562, 29, 403, 304, 267, 862, 26, 288, 3101, 3225, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 2653, 12, 1350, 63, 1562, 9, 267, 871, 3146, 26, 327, 2018, 499, 14, 22, 288, 3101, 3225, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 2653, 9, 267, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 339, 347, 4907, 8, 277, 304, 267, 2557, 275, 291, 423, 1222, 63, 1631, 342, 267, 291, 423, 6726, 63, 1631, 8, 1631, 9, 267, 291, 14, 5096, 275, 6149, 14, 3823, 63, 3450, 8, 1631, 12, 291, 14, 498, 63, 493, 12, 291, 14, 4736, 63, 493, 9, 421, 199, 533, 5444, 4541, 27945, 8, 27945, 304, 272, 408, 272, 21311, 641, 8809, 14, 27945, 1325, 14018, 314, 2838, 543, 272, 7799, 3361, 3793, 14, 272, 408, 272, 6250, 63, 12720, 275, 488, 272, 1704, 63, 8356, 275, 488, 272, 6149, 63, 1023, 275, 488, 339, 347, 663, 63, 4736, 8, 277, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 326, 6250, 63, 12720, 29, 403, 12, 1704, 63, 8356, 29, 403, 12, 326, 702, 63, 4269, 29, 403, 12, 702, 63, 15077, 29, 403, 304, 398, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 267, 291, 14, 4736, 63, 12720, 275, 6250, 63, 12720, 267, 291, 14, 696, 63, 8356, 275, 1704, 63, 8356, 267, 291, 14, 479, 63, 4269, 275, 702, 63, 4269, 267, 291, 14, 479, 63, 15077, 275, 702, 63, 15077, 339, 347, 4907, 8, 277, 304, 267, 327, 2654, 5897, 14786, 267, 862, 26, 288, 6771, 275, 2838, 14, 981, 63, 2105, 8, 355, 2287, 2687, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 2653, 29, 277, 14, 2593, 12, 288, 776, 267, 871, 17766, 6372, 26, 288, 746, 15175, 19382, 8, 355, 291, 12, 298, 3225, 370, 450, 83, 18590, 734, 14, 334, 2242, 2653, 2458, 83, 2924, 450, 355, 334, 277, 14, 1102, 12, 291, 14, 2593, 430, 398, 6771, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 717, 291, 14, 8815, 63, 932, 817, 9, 398, 12152, 63, 4736, 63, 12720, 275, 7512, 63, 4736, 63, 12720, 8, 277, 14, 4736, 63, 12720, 9, 267, 12152, 63, 4266, 63, 1023, 275, 7512, 63, 4266, 63, 1023, 8 ]
[ 4011, 19, 15, 2105, 14, 647, 199, 3, 1898, 9079, 13, 6965, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 646, 2838, 199, 504, 2838, 492, 2653, 465, 17766, 6372, 199, 199, 893, 26, 327, 2018, 650, 272, 687, 1455, 14, 1258, 492, 3101, 3225, 465, 485, 19114, 12, 28185, 199, 2590, 3545, 26, 272, 687, 8809, 492, 3101, 3225, 465, 485, 19114, 12, 28185, 199, 199, 533, 9762, 3225, 8, 785, 304, 272, 298, 9167, 370, 9696, 282, 3405, 8113, 24342, 492, 2122, 272, 986, 199, 199, 893, 26, 327, 3599, 1672, 543, 7799, 31, 272, 6149, 275, 488, 272, 14147, 3225, 275, 9762, 3225, 339, 1021, 3523, 27102, 8, 29900, 304, 267, 986, 339, 862, 26, 327, 2018, 650, 267, 687, 1455, 14, 1258, 492, 14147, 3225, 465, 485, 27945, 272, 871, 3545, 26, 267, 687, 8809, 492, 14147, 3225, 465, 485, 27945, 339, 492, 6149, 272, 3523, 27102, 275, 6149, 14, 27102, 199, 199, 2590, 334, 17825, 12, 4281, 304, 327, 16078, 13, 6100, 26, 3091, 7799, 14, 272, 986, 199, 199, 504, 1275, 3924, 492, 334, 272, 15175, 19382, 12, 199, 9, 199, 504, 1275, 5154, 14, 4266, 63, 1431, 63, 4269, 492, 1336, 63, 4269, 199, 504, 1275, 1974, 492, 334, 272, 702, 63, 15077, 12, 272, 7512, 63, 4736, 63, 12720, 12, 272, 7512, 63, 4266, 63, 1023, 12, 272, 6149, 63, 3823, 63, 3450, 12, 199, 9, 421, 199, 719, 63, 991, 63, 5512, 275, 469, 272, 283, 1014, 356, 5939, 12, 272, 283, 2859, 356, 23865, 12, 199, 93, 421, 199, 533, 3101, 3225, 1547, 19114, 12, 909, 304, 272, 849, 63, 719, 275, 1844, 63, 991, 63, 5512, 459, 1014, 418, 339, 327, 4885, 849, 12, 3507, 653, 643, 274, 1159, 23823, 14, 272, 14719, 63, 932, 817, 275, 413, 339, 347, 485, 1222, 63, 1631, 8, 277, 304, 267, 408, 15896, 13306, 282, 2838, 1950, 436, 663, 1031, 817, 2202, 641, 652, 398, 520, 1107, 26, 282, 892, 2838, 1950, 267, 408, 267, 862, 26, 288, 2557, 275, 2838, 14, 981, 63, 2105, 8, 355, 334, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 291, 14, 2593, 12, 355, 291, 14, 1365, 63, 1562, 12, 288, 776, 267, 871, 4281, 26, 327, 2018, 499, 14, 22, 288, 2557, 275, 2838, 14, 981, 63, 2105, 8, 355, 334, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 291, 14, 2593, 12, 288, 776, 267, 2557, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 717, 291, 14, 8815, 63, 932, 817, 9, 267, 372, 2557, 339, 347, 485, 6726, 63, 1631, 8, 277, 12, 2557, 304, 267, 291, 14, 5096, 275, 2557, 267, 340, 291, 423, 15360, 63, 1102, 26, 288, 327, 3254, 26, 14811, 21496, 880, 652, 3181, 1133, 11687, 641, 291, 14, 5096, 1174, 14, 288, 291, 423, 15360, 342, 339, 347, 4907, 8, 277, 304, 267, 2557, 275, 291, 423, 1222, 63, 1631, 342, 267, 291, 423, 6726, 63, 1631, 8, 1631, 9, 421, 199, 533, 14147, 3225, 8, 19114, 304, 272, 849, 63, 719, 275, 1844, 63, 991, 63, 5512, 459, 2859, 418, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 29, 403, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 326, 7478, 29, 403, 12, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 326, 1350, 63, 1562, 29, 403, 304, 267, 862, 26, 288, 3101, 3225, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 2653, 12, 1350, 63, 1562, 9, 267, 871, 3146, 26, 327, 2018, 499, 14, 22, 288, 3101, 3225, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 2653, 9, 267, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 339, 347, 4907, 8, 277, 304, 267, 2557, 275, 291, 423, 1222, 63, 1631, 342, 267, 291, 423, 6726, 63, 1631, 8, 1631, 9, 267, 291, 14, 5096, 275, 6149, 14, 3823, 63, 3450, 8, 1631, 12, 291, 14, 498, 63, 493, 12, 291, 14, 4736, 63, 493, 9, 421, 199, 533, 5444, 4541, 27945, 8, 27945, 304, 272, 408, 272, 21311, 641, 8809, 14, 27945, 1325, 14018, 314, 2838, 543, 272, 7799, 3361, 3793, 14, 272, 408, 272, 6250, 63, 12720, 275, 488, 272, 1704, 63, 8356, 275, 488, 272, 6149, 63, 1023, 275, 488, 339, 347, 663, 63, 4736, 8, 277, 12, 790, 63, 493, 29, 403, 12, 6250, 63, 493, 29, 403, 12, 326, 6250, 63, 12720, 29, 403, 12, 1704, 63, 8356, 29, 403, 12, 326, 702, 63, 4269, 29, 403, 12, 702, 63, 15077, 29, 403, 304, 398, 291, 14, 498, 63, 493, 275, 790, 63, 493, 267, 291, 14, 4736, 63, 493, 275, 6250, 63, 493, 267, 291, 14, 4736, 63, 12720, 275, 6250, 63, 12720, 267, 291, 14, 696, 63, 8356, 275, 1704, 63, 8356, 267, 291, 14, 479, 63, 4269, 275, 702, 63, 4269, 267, 291, 14, 479, 63, 15077, 275, 702, 63, 15077, 339, 347, 4907, 8, 277, 304, 267, 327, 2654, 5897, 14786, 267, 862, 26, 288, 6771, 275, 2838, 14, 981, 63, 2105, 8, 355, 2287, 2687, 277, 14, 1102, 12, 291, 14, 719, 395, 355, 2653, 29, 277, 14, 2593, 12, 288, 776, 267, 871, 17766, 6372, 26, 288, 746, 15175, 19382, 8, 355, 291, 12, 298, 3225, 370, 450, 83, 18590, 734, 14, 334, 2242, 2653, 2458, 83, 2924, 450, 355, 334, 277, 14, 1102, 12, 291, 14, 2593, 430, 398, 6771, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 2838, 14, 9735, 63, 2826, 18616, 12, 717, 291, 14, 8815, 63, 932, 817, 9, 398, 12152, 63, 4736, 63, 12720, 275, 7512, 63, 4736, 63, 12720, 8, 277, 14, 4736, 63, 12720, 9, 267, 12152, 63, 4266, 63, 1023, 275, 7512, 63, 4266, 63, 1023, 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, 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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 ]
tuxfux-hlp-notes/python-batches
archieves/batch-64/09-modules/myenv/lib/python2.7/site-packages/django/contrib/admin/validation.py
82
23810
from django.contrib.admin.utils import NotRelationField, get_fields_from_path from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured from django.db import models from django.forms.models import ( BaseModelForm, BaseModelFormSet, _get_foreign_key, ) """ Does basic ModelAdmin option validation. Calls custom validation classmethod in the end if it is provided in cls. The signature of the custom validation classmethod should be: def validate(cls, model). """ __all__ = ['BaseValidator', 'InlineValidator'] class BaseValidator(object): def validate(self, cls, model): for m in dir(self): if m.startswith('validate_'): getattr(self, m)(cls, model) def check_field_spec(self, cls, model, flds, label): """ Validate the fields specification in `flds` from a ModelAdmin subclass `cls` for the `model` model. Use `label` for reporting problems to the user. The fields specification can be a ``fields`` option or a ``fields`` sub-option from a ``fieldsets`` option component. """ for fields in flds: # The entry in fields might be a tuple. If it is a standalone # field, make it into a tuple to make processing easier. if type(fields) != tuple: fields = (fields,) for field in fields: if field in cls.readonly_fields: # Stuff can be put in fields that isn't actually a # model field if it's in readonly_fields, # readonly_fields will handle the validation of such # things. continue try: f = model._meta.get_field(field) except FieldDoesNotExist: # If we can't find a field on the model that matches, it could be an # extra field on the form; nothing to check so move on to the next field. continue if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created: raise ImproperlyConfigured("'%s.%s' " "can't include the ManyToManyField field '%s' because " "'%s' manually specifies a 'through' model." % ( cls.__name__, label, field, field)) def validate_raw_id_fields(self, cls, model): " Validate that raw_id_fields only contains field names that are listed on the model. " if hasattr(cls, 'raw_id_fields'): check_isseq(cls, 'raw_id_fields', cls.raw_id_fields) for idx, field in enumerate(cls.raw_id_fields): f = get_field(cls, model, 'raw_id_fields', field) if not isinstance(f, (models.ForeignKey, models.ManyToManyField)): raise ImproperlyConfigured("'%s.raw_id_fields[%d]', '%s' must " "be either a ForeignKey or ManyToManyField." % (cls.__name__, idx, field)) def validate_fields(self, cls, model): " Validate that fields only refer to existing fields, doesn't contain duplicates. " # fields if cls.fields: # default value is None check_isseq(cls, 'fields', cls.fields) self.check_field_spec(cls, model, cls.fields, 'fields') if cls.fieldsets: raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__) if len(cls.fields) > len(set(cls.fields)): raise ImproperlyConfigured('There are duplicate field(s) in %s.fields' % cls.__name__) def validate_fieldsets(self, cls, model): " Validate that fieldsets is properly formatted and doesn't contain duplicates. " from django.contrib.admin.options import flatten_fieldsets if cls.fieldsets: # default value is None check_isseq(cls, 'fieldsets', cls.fieldsets) for idx, fieldset in enumerate(cls.fieldsets): check_isseq(cls, 'fieldsets[%d]' % idx, fieldset) if len(fieldset) != 2: raise ImproperlyConfigured("'%s.fieldsets[%d]' does not " "have exactly two elements." % (cls.__name__, idx)) check_isdict(cls, 'fieldsets[%d][1]' % idx, fieldset[1]) if 'fields' not in fieldset[1]: raise ImproperlyConfigured("'fields' key is required in " "%s.fieldsets[%d][1] field options dict." % (cls.__name__, idx)) self.check_field_spec(cls, model, fieldset[1]['fields'], "fieldsets[%d][1]['fields']" % idx) flattened_fieldsets = flatten_fieldsets(cls.fieldsets) if len(flattened_fieldsets) > len(set(flattened_fieldsets)): raise ImproperlyConfigured('There are duplicate field(s) in %s.fieldsets' % cls.__name__) def validate_exclude(self, cls, model): " Validate that exclude is a sequence without duplicates. " if cls.exclude: # default value is None check_isseq(cls, 'exclude', cls.exclude) if len(cls.exclude) > len(set(cls.exclude)): raise ImproperlyConfigured('There are duplicate field(s) in %s.exclude' % cls.__name__) def validate_form(self, cls, model): " Validate that form subclasses BaseModelForm. " if hasattr(cls, 'form') and not issubclass(cls.form, BaseModelForm): raise ImproperlyConfigured("%s.form does not inherit from " "BaseModelForm." % cls.__name__) def validate_filter_vertical(self, cls, model): " Validate that filter_vertical is a sequence of field names. " if hasattr(cls, 'filter_vertical'): check_isseq(cls, 'filter_vertical', cls.filter_vertical) for idx, field in enumerate(cls.filter_vertical): f = get_field(cls, model, 'filter_vertical', field) if not isinstance(f, models.ManyToManyField): raise ImproperlyConfigured("'%s.filter_vertical[%d]' must be " "a ManyToManyField." % (cls.__name__, idx)) def validate_filter_horizontal(self, cls, model): " Validate that filter_horizontal is a sequence of field names. " if hasattr(cls, 'filter_horizontal'): check_isseq(cls, 'filter_horizontal', cls.filter_horizontal) for idx, field in enumerate(cls.filter_horizontal): f = get_field(cls, model, 'filter_horizontal', field) if not isinstance(f, models.ManyToManyField): raise ImproperlyConfigured("'%s.filter_horizontal[%d]' must be " "a ManyToManyField." % (cls.__name__, idx)) def validate_radio_fields(self, cls, model): " Validate that radio_fields is a dictionary of choice or foreign key fields. " from django.contrib.admin.options import HORIZONTAL, VERTICAL if hasattr(cls, 'radio_fields'): check_isdict(cls, 'radio_fields', cls.radio_fields) for field, val in cls.radio_fields.items(): f = get_field(cls, model, 'radio_fields', field) if not (isinstance(f, models.ForeignKey) or f.choices): raise ImproperlyConfigured("'%s.radio_fields['%s']' " "is neither an instance of ForeignKey nor does " "have choices set." % (cls.__name__, field)) if val not in (HORIZONTAL, VERTICAL): raise ImproperlyConfigured("'%s.radio_fields['%s']' " "is neither admin.HORIZONTAL nor admin.VERTICAL." % (cls.__name__, field)) def validate_prepopulated_fields(self, cls, model): " Validate that prepopulated_fields if a dictionary containing allowed field types. " # prepopulated_fields if hasattr(cls, 'prepopulated_fields'): check_isdict(cls, 'prepopulated_fields', cls.prepopulated_fields) for field, val in cls.prepopulated_fields.items(): f = get_field(cls, model, 'prepopulated_fields', field) if isinstance(f, (models.DateTimeField, models.ForeignKey, models.ManyToManyField)): raise ImproperlyConfigured("'%s.prepopulated_fields['%s']' " "is either a DateTimeField, ForeignKey or " "ManyToManyField. This isn't allowed." % (cls.__name__, field)) check_isseq(cls, "prepopulated_fields['%s']" % field, val) for idx, f in enumerate(val): get_field(cls, model, "prepopulated_fields['%s'][%d]" % (field, idx), f) def validate_view_on_site_url(self, cls, model): if hasattr(cls, 'view_on_site'): if not callable(cls.view_on_site) and not isinstance(cls.view_on_site, bool): raise ImproperlyConfigured("%s.view_on_site is not a callable or a boolean value." % cls.__name__) def validate_ordering(self, cls, model): " Validate that ordering refers to existing fields or is random. " # ordering = None if cls.ordering: check_isseq(cls, 'ordering', cls.ordering) for idx, field in enumerate(cls.ordering): if field == '?' and len(cls.ordering) != 1: raise ImproperlyConfigured("'%s.ordering' has the random " "ordering marker '?', but contains other fields as " "well. Please either remove '?' or the other fields." % cls.__name__) if field == '?': continue if field.startswith('-'): field = field[1:] # Skip ordering in the format field1__field2 (FIXME: checking # this format would be nice, but it's a little fiddly). if '__' in field: continue get_field(cls, model, 'ordering[%d]' % idx, field) def validate_readonly_fields(self, cls, model): " Validate that readonly_fields refers to proper attribute or field. " if hasattr(cls, "readonly_fields"): check_isseq(cls, "readonly_fields", cls.readonly_fields) for idx, field in enumerate(cls.readonly_fields): if not callable(field): if not hasattr(cls, field): if not hasattr(model, field): try: model._meta.get_field(field) except FieldDoesNotExist: raise ImproperlyConfigured( "%s.readonly_fields[%d], %r is not a callable or " "an attribute of %r or found in the model %r." % (cls.__name__, idx, field, cls.__name__, model._meta.object_name) ) class ModelAdminValidator(BaseValidator): def validate_save_as(self, cls, model): " Validate save_as is a boolean. " check_type(cls, 'save_as', bool) def validate_save_on_top(self, cls, model): " Validate save_on_top is a boolean. " check_type(cls, 'save_on_top', bool) def validate_inlines(self, cls, model): " Validate inline model admin classes. " from django.contrib.admin.options import BaseModelAdmin if hasattr(cls, 'inlines'): check_isseq(cls, 'inlines', cls.inlines) for idx, inline in enumerate(cls.inlines): if not issubclass(inline, BaseModelAdmin): raise ImproperlyConfigured("'%s.inlines[%d]' does not inherit " "from BaseModelAdmin." % (cls.__name__, idx)) if not inline.model: raise ImproperlyConfigured("'model' is a required attribute " "of '%s.inlines[%d]'." % (cls.__name__, idx)) if not issubclass(inline.model, models.Model): raise ImproperlyConfigured("'%s.inlines[%d].model' does not " "inherit from models.Model." % (cls.__name__, idx)) inline.validate(inline.model) self.check_inline(inline, model) def check_inline(self, cls, parent_model): " Validate inline class's fk field is not excluded. " fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True) if hasattr(cls, 'exclude') and cls.exclude: if fk and fk.name in cls.exclude: raise ImproperlyConfigured("%s cannot exclude the field " "'%s' - this is the foreign key to the parent model " "%s.%s." % (cls.__name__, fk.name, parent_model._meta.app_label, parent_model.__name__)) def validate_list_display(self, cls, model): " Validate that list_display only contains fields or usable attributes. " if hasattr(cls, 'list_display'): check_isseq(cls, 'list_display', cls.list_display) for idx, field in enumerate(cls.list_display): if not callable(field): if not hasattr(cls, field): if not hasattr(model, field): try: model._meta.get_field(field) except FieldDoesNotExist: raise ImproperlyConfigured( "%s.list_display[%d], %r is not a callable or " "an attribute of %r or found in the model %r." % (cls.__name__, idx, field, cls.__name__, model._meta.object_name) ) else: # getattr(model, field) could be an X_RelatedObjectsDescriptor f = fetch_attr(cls, model, "list_display[%d]" % idx, field) if isinstance(f, models.ManyToManyField): raise ImproperlyConfigured( "'%s.list_display[%d]', '%s' is a ManyToManyField " "which is not supported." % (cls.__name__, idx, field) ) def validate_list_display_links(self, cls, model): " Validate that list_display_links either is None or a unique subset of list_display." if hasattr(cls, 'list_display_links'): if cls.list_display_links is None: return check_isseq(cls, 'list_display_links', cls.list_display_links) for idx, field in enumerate(cls.list_display_links): if field not in cls.list_display: raise ImproperlyConfigured("'%s.list_display_links[%d]' " "refers to '%s' which is not defined in 'list_display'." % (cls.__name__, idx, field)) def validate_list_filter(self, cls, model): """ Validate that list_filter is a sequence of one of three options: 1: 'field' - a basic field filter, possibly w/ relationships (eg, 'field__rel') 2: ('field', SomeFieldListFilter) - a field-based list filter class 3: SomeListFilter - a non-field list filter class """ from django.contrib.admin import ListFilter, FieldListFilter if hasattr(cls, 'list_filter'): check_isseq(cls, 'list_filter', cls.list_filter) for idx, item in enumerate(cls.list_filter): if callable(item) and not isinstance(item, models.Field): # If item is option 3, it should be a ListFilter... if not issubclass(item, ListFilter): raise ImproperlyConfigured("'%s.list_filter[%d]' is '%s'" " which is not a descendant of ListFilter." % (cls.__name__, idx, item.__name__)) # ... but not a FieldListFilter. if issubclass(item, FieldListFilter): raise ImproperlyConfigured("'%s.list_filter[%d]' is '%s'" " which is of type FieldListFilter but is not" " associated with a field name." % (cls.__name__, idx, item.__name__)) else: if isinstance(item, (tuple, list)): # item is option #2 field, list_filter_class = item if not issubclass(list_filter_class, FieldListFilter): raise ImproperlyConfigured("'%s.list_filter[%d][1]'" " is '%s' which is not of type FieldListFilter." % (cls.__name__, idx, list_filter_class.__name__)) else: # item is option #1 field = item # Validate the field string try: get_fields_from_path(model, field) except (NotRelationField, FieldDoesNotExist): raise ImproperlyConfigured("'%s.list_filter[%d]' refers to '%s'" " which does not refer to a Field." % (cls.__name__, idx, field)) def validate_list_select_related(self, cls, model): " Validate that list_select_related is a boolean, a list or a tuple. " list_select_related = getattr(cls, 'list_select_related', None) if list_select_related: types = (bool, tuple, list) if not isinstance(list_select_related, types): raise ImproperlyConfigured("'%s.list_select_related' should be " "either a bool, a tuple or a list" % cls.__name__) def validate_list_per_page(self, cls, model): " Validate that list_per_page is an integer. " check_type(cls, 'list_per_page', int) def validate_list_max_show_all(self, cls, model): " Validate that list_max_show_all is an integer. " check_type(cls, 'list_max_show_all', int) def validate_list_editable(self, cls, model): """ Validate that list_editable is a sequence of editable fields from list_display without first element. """ if hasattr(cls, 'list_editable') and cls.list_editable: check_isseq(cls, 'list_editable', cls.list_editable) for idx, field_name in enumerate(cls.list_editable): try: field = model._meta.get_field(field_name) except FieldDoesNotExist: raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a " "field, '%s', not defined on %s.%s." % (cls.__name__, idx, field_name, model._meta.app_label, model.__name__)) if field_name not in cls.list_display: raise ImproperlyConfigured("'%s.list_editable[%d]' refers to " "'%s' which is not defined in 'list_display'." % (cls.__name__, idx, field_name)) if cls.list_display_links is not None: if field_name in cls.list_display_links: raise ImproperlyConfigured("'%s' cannot be in both '%s.list_editable'" " and '%s.list_display_links'" % (field_name, cls.__name__, cls.__name__)) if not cls.list_display_links and cls.list_display[0] in cls.list_editable: raise ImproperlyConfigured("'%s.list_editable[%d]' refers to" " the first field in list_display, '%s', which can't be" " used unless list_display_links is set." % (cls.__name__, idx, cls.list_display[0])) if not field.editable: raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a " "field, '%s', which isn't editable through the admin." % (cls.__name__, idx, field_name)) def validate_search_fields(self, cls, model): " Validate search_fields is a sequence. " if hasattr(cls, 'search_fields'): check_isseq(cls, 'search_fields', cls.search_fields) def validate_date_hierarchy(self, cls, model): " Validate that date_hierarchy refers to DateField or DateTimeField. " if cls.date_hierarchy: f = get_field(cls, model, 'date_hierarchy', cls.date_hierarchy) if not isinstance(f, (models.DateField, models.DateTimeField)): raise ImproperlyConfigured("'%s.date_hierarchy is " "neither an instance of DateField nor DateTimeField." % cls.__name__) class InlineValidator(BaseValidator): def validate_fk_name(self, cls, model): " Validate that fk_name refers to a ForeignKey. " if cls.fk_name: # default value is None f = get_field(cls, model, 'fk_name', cls.fk_name) if not isinstance(f, models.ForeignKey): raise ImproperlyConfigured("'%s.fk_name is not an instance of " "models.ForeignKey." % cls.__name__) def validate_extra(self, cls, model): " Validate that extra is an integer. " check_type(cls, 'extra', int) def validate_max_num(self, cls, model): " Validate that max_num is an integer. " check_type(cls, 'max_num', int) def validate_formset(self, cls, model): " Validate formset is a subclass of BaseModelFormSet. " if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet): raise ImproperlyConfigured("'%s.formset' does not inherit from " "BaseModelFormSet." % cls.__name__) def check_type(cls, attr, type_): if getattr(cls, attr, None) is not None and not isinstance(getattr(cls, attr), type_): raise ImproperlyConfigured("'%s.%s' should be a %s." % (cls.__name__, attr, type_.__name__)) def check_isseq(cls, label, obj): if not isinstance(obj, (list, tuple)): raise ImproperlyConfigured("'%s.%s' must be a list or tuple." % (cls.__name__, label)) def check_isdict(cls, label, obj): if not isinstance(obj, dict): raise ImproperlyConfigured("'%s.%s' must be a dictionary." % (cls.__name__, label)) def get_field(cls, model, label, field): try: return model._meta.get_field(field) except FieldDoesNotExist: raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s.%s'." % (cls.__name__, label, field, model._meta.app_label, model.__name__)) def fetch_attr(cls, model, label, field): try: return model._meta.get_field(field) except FieldDoesNotExist: pass try: return getattr(model, field) except AttributeError: raise ImproperlyConfigured( "'%s.%s' refers to '%s' that is neither a field, method or " "property of model '%s.%s'." % (cls.__name__, label, field, model._meta.app_label, model.__name__) )
gpl-3.0
[ 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 2832, 12617, 792, 12, 664, 63, 955, 63, 504, 63, 515, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 12, 11897, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 3351, 14, 992, 492, 334, 272, 3523, 15937, 12, 3523, 1685, 14736, 12, 485, 362, 63, 6846, 63, 498, 12, 199, 9, 199, 199, 624, 199, 6586, 5678, 30093, 945, 6411, 14, 28055, 3537, 6411, 199, 3744, 315, 314, 1284, 340, 652, 365, 2741, 315, 843, 14, 710, 4955, 402, 314, 199, 4229, 6411, 18990, 1077, 506, 26, 347, 4107, 8, 1886, 12, 1402, 680, 199, 624, 199, 199, 363, 452, 363, 275, 788, 1563, 8640, 297, 283, 10307, 8640, 418, 421, 199, 533, 3523, 8640, 8, 785, 304, 339, 347, 4107, 8, 277, 12, 843, 12, 1402, 304, 267, 367, 333, 315, 2935, 8, 277, 304, 288, 340, 333, 14, 2460, 360, 3502, 25865, 355, 2519, 8, 277, 12, 333, 5130, 1886, 12, 1402, 9, 339, 347, 1104, 63, 698, 63, 1650, 8, 277, 12, 843, 12, 1402, 12, 2717, 795, 12, 1768, 304, 267, 408, 267, 12134, 314, 1504, 8929, 315, 658, 2327, 795, 64, 687, 282, 30093, 5516, 267, 658, 1886, 64, 367, 314, 658, 1238, 64, 1402, 14, 3645, 658, 1302, 64, 367, 17290, 8826, 370, 314, 922, 14, 398, 710, 1504, 8929, 883, 506, 282, 1124, 955, 1040, 945, 503, 282, 1124, 955, 1040, 267, 1007, 13, 1422, 687, 282, 1124, 23501, 1040, 945, 3931, 14, 267, 408, 267, 367, 1504, 315, 2717, 795, 26, 288, 327, 710, 2397, 315, 1504, 5594, 506, 282, 2008, 14, 982, 652, 365, 282, 18042, 288, 327, 901, 12, 1852, 652, 1901, 282, 2008, 370, 1852, 6661, 14905, 14, 288, 340, 730, 8, 955, 9, 1137, 2008, 26, 355, 1504, 275, 334, 955, 4258, 288, 367, 901, 315, 1504, 26, 355, 340, 901, 315, 843, 14, 6753, 63, 955, 26, 490, 327, 1933, 3043, 883, 506, 5324, 315, 1504, 626, 5712, 1133, 5965, 282, 490, 327, 1402, 901, 340, 652, 1159, 315, 6863, 63, 955, 12, 490, 327, 6863, 63, 955, 911, 2429, 314, 6411, 402, 4066, 490, 327, 7645, 14, 490, 1980, 355, 862, 26, 490, 289, 275, 1402, 423, 2024, 14, 362, 63, 698, 8, 698, 9, 355, 871, 29994, 26, 490, 327, 982, 781, 883, 1133, 2342, 282, 901, 641, 314, 1402, 626, 4450, 12, 652, 4293, 506, 376, 490, 327, 2402, 901, 641, 314, 1824, 27, 6548, 370, 1104, 880, 4057, 641, 370, 314, 2163, 901, 14, 490, 1980, 355, 340, 1228, 8, 70, 12, 1709, 14, 7624, 9, 436, 440, 289, 14, 3369, 14, 8304, 423, 2024, 14, 2495, 63, 3966, 26, 490, 746, 11897, 21065, 83, 4111, 83, 7, 298, 717, 298, 2425, 1133, 2387, 314, 28409, 901, 1543, 83, 7, 2952, 298, 717, 17648, 83, 7, 10250, 9314, 282, 283, 8304, 7, 1402, 2122, 450, 334, 1169, 843, 855, 354, 3108, 1768, 12, 901, 12, 901, 430, 339, 347, 4107, 63, 1773, 63, 344, 63, 955, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 3066, 63, 344, 63, 955, 1454, 3509, 901, 1561, 626, 787, 10532, 641, 314, 1402, 14, 298, 267, 340, 2688, 8, 1886, 12, 283, 1773, 63, 344, 63, 955, 735, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 1773, 63, 344, 63, 955, 297, 843, 14, 1773, 63, 344, 63, 955, 9, 288, 367, 4280, 12, 901, 315, 3874, 8, 1886, 14, 1773, 63, 344, 63, 955, 304, 355, 289, 275, 664, 63, 698, 8, 1886, 12, 1402, 12, 283, 1773, 63, 344, 63, 955, 297, 901, 9, 355, 340, 440, 1228, 8, 70, 12, 334, 992, 14, 3190, 12, 1709, 14, 7624, 2298, 490, 746, 11897, 21065, 83, 14, 1773, 63, 344, 63, 955, 9722, 68, 4300, 1543, 83, 7, 1471, 298, 1169, 298, 1235, 1902, 282, 12718, 503, 28409, 2122, 1169, 450, 334, 1886, 855, 354, 3108, 4280, 12, 901, 430, 339, 347, 4107, 63, 955, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 1504, 1454, 10618, 370, 3411, 1504, 12, 3181, 1133, 1395, 15755, 14, 298, 267, 327, 1504, 267, 340, 843, 14, 955, 26, 221, 327, 849, 574, 365, 488, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 955, 297, 843, 14, 955, 9, 288, 291, 14, 1074, 63, 698, 63, 1650, 8, 1886, 12, 1402, 12, 843, 14, 955, 12, 283, 955, 358, 288, 340, 843, 14, 23501, 26, 355, 746, 11897, 360, 18088, 901, 2193, 436, 1504, 787, 2013, 315, 450, 83, 3530, 450, 843, 855, 354, 3368, 288, 340, 822, 8, 1886, 14, 955, 9, 690, 822, 8, 409, 8, 1886, 14, 955, 2298, 355, 746, 11897, 360, 10924, 787, 9250, 901, 8, 83, 9, 315, 450, 83, 14, 955, 7, 450, 843, 855, 354, 3368, 339, 347, 4107, 63, 23501, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 901, 2193, 365, 7684, 7871, 436, 3181, 1133, 1395, 15755, 14, 298, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 9378, 63, 23501, 267, 340, 843, 14, 23501, 26, 221, 327, 849, 574, 365, 488, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 23501, 297, 843, 14, 23501, 9, 288, 367, 4280, 12, 901, 409, 315, 3874, 8, 1886, 14, 23501, 304, 355, 1104, 63, 374, 3610, 8, 1886, 12, 283, 23501, 9722, 68, 6616, 450, 4280, 12, 901, 409, 9, 355, 340, 822, 8, 698, 409, 9, 1137, 499, 26, 490, 746, 11897, 21065, 83, 14, 23501, 9722, 68, 6616, 1630, 440, 298, 1169, 298, 7804, 8840, 2877, 4008, 2122, 450, 334, 1886, 855, 354, 3108, 4280, 430, 355, 1104, 63, 374, 807, 8, 1886, 12, 283, 23501, 9722, 68, 1527, 17, 6616, 450, 4280, 12, 901, 409, 59, 17, 566, 355, 340, 283, 955, 7, 440, 315, 901, 409, 59, 17, 2189, 490, 746, 11897, 15587, 955, 7, 790, 365, 1415, 315, 298, 1169, 2071, 83, 14, 23501, 9722, 68, 1527, 17, 61, 901, 1511, 1211, 2122, 1169, 450, 334, 1886, 855, 354, 3108, 4280, 430, 355, 291, 14, 1074, 63, 698, 63, 1650, 8, 1886, 12, 1402 ]
[ 1639, 14, 2828, 14, 2113, 14, 1208, 492, 2832, 12617, 792, 12, 664, 63, 955, 63, 504, 63, 515, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 12, 11897, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 3351, 14, 992, 492, 334, 272, 3523, 15937, 12, 3523, 1685, 14736, 12, 485, 362, 63, 6846, 63, 498, 12, 199, 9, 199, 199, 624, 199, 6586, 5678, 30093, 945, 6411, 14, 28055, 3537, 6411, 199, 3744, 315, 314, 1284, 340, 652, 365, 2741, 315, 843, 14, 710, 4955, 402, 314, 199, 4229, 6411, 18990, 1077, 506, 26, 347, 4107, 8, 1886, 12, 1402, 680, 199, 624, 199, 199, 363, 452, 363, 275, 788, 1563, 8640, 297, 283, 10307, 8640, 418, 421, 199, 533, 3523, 8640, 8, 785, 304, 339, 347, 4107, 8, 277, 12, 843, 12, 1402, 304, 267, 367, 333, 315, 2935, 8, 277, 304, 288, 340, 333, 14, 2460, 360, 3502, 25865, 355, 2519, 8, 277, 12, 333, 5130, 1886, 12, 1402, 9, 339, 347, 1104, 63, 698, 63, 1650, 8, 277, 12, 843, 12, 1402, 12, 2717, 795, 12, 1768, 304, 267, 408, 267, 12134, 314, 1504, 8929, 315, 658, 2327, 795, 64, 687, 282, 30093, 5516, 267, 658, 1886, 64, 367, 314, 658, 1238, 64, 1402, 14, 3645, 658, 1302, 64, 367, 17290, 8826, 370, 314, 922, 14, 398, 710, 1504, 8929, 883, 506, 282, 1124, 955, 1040, 945, 503, 282, 1124, 955, 1040, 267, 1007, 13, 1422, 687, 282, 1124, 23501, 1040, 945, 3931, 14, 267, 408, 267, 367, 1504, 315, 2717, 795, 26, 288, 327, 710, 2397, 315, 1504, 5594, 506, 282, 2008, 14, 982, 652, 365, 282, 18042, 288, 327, 901, 12, 1852, 652, 1901, 282, 2008, 370, 1852, 6661, 14905, 14, 288, 340, 730, 8, 955, 9, 1137, 2008, 26, 355, 1504, 275, 334, 955, 4258, 288, 367, 901, 315, 1504, 26, 355, 340, 901, 315, 843, 14, 6753, 63, 955, 26, 490, 327, 1933, 3043, 883, 506, 5324, 315, 1504, 626, 5712, 1133, 5965, 282, 490, 327, 1402, 901, 340, 652, 1159, 315, 6863, 63, 955, 12, 490, 327, 6863, 63, 955, 911, 2429, 314, 6411, 402, 4066, 490, 327, 7645, 14, 490, 1980, 355, 862, 26, 490, 289, 275, 1402, 423, 2024, 14, 362, 63, 698, 8, 698, 9, 355, 871, 29994, 26, 490, 327, 982, 781, 883, 1133, 2342, 282, 901, 641, 314, 1402, 626, 4450, 12, 652, 4293, 506, 376, 490, 327, 2402, 901, 641, 314, 1824, 27, 6548, 370, 1104, 880, 4057, 641, 370, 314, 2163, 901, 14, 490, 1980, 355, 340, 1228, 8, 70, 12, 1709, 14, 7624, 9, 436, 440, 289, 14, 3369, 14, 8304, 423, 2024, 14, 2495, 63, 3966, 26, 490, 746, 11897, 21065, 83, 4111, 83, 7, 298, 717, 298, 2425, 1133, 2387, 314, 28409, 901, 1543, 83, 7, 2952, 298, 717, 17648, 83, 7, 10250, 9314, 282, 283, 8304, 7, 1402, 2122, 450, 334, 1169, 843, 855, 354, 3108, 1768, 12, 901, 12, 901, 430, 339, 347, 4107, 63, 1773, 63, 344, 63, 955, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 3066, 63, 344, 63, 955, 1454, 3509, 901, 1561, 626, 787, 10532, 641, 314, 1402, 14, 298, 267, 340, 2688, 8, 1886, 12, 283, 1773, 63, 344, 63, 955, 735, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 1773, 63, 344, 63, 955, 297, 843, 14, 1773, 63, 344, 63, 955, 9, 288, 367, 4280, 12, 901, 315, 3874, 8, 1886, 14, 1773, 63, 344, 63, 955, 304, 355, 289, 275, 664, 63, 698, 8, 1886, 12, 1402, 12, 283, 1773, 63, 344, 63, 955, 297, 901, 9, 355, 340, 440, 1228, 8, 70, 12, 334, 992, 14, 3190, 12, 1709, 14, 7624, 2298, 490, 746, 11897, 21065, 83, 14, 1773, 63, 344, 63, 955, 9722, 68, 4300, 1543, 83, 7, 1471, 298, 1169, 298, 1235, 1902, 282, 12718, 503, 28409, 2122, 1169, 450, 334, 1886, 855, 354, 3108, 4280, 12, 901, 430, 339, 347, 4107, 63, 955, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 1504, 1454, 10618, 370, 3411, 1504, 12, 3181, 1133, 1395, 15755, 14, 298, 267, 327, 1504, 267, 340, 843, 14, 955, 26, 221, 327, 849, 574, 365, 488, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 955, 297, 843, 14, 955, 9, 288, 291, 14, 1074, 63, 698, 63, 1650, 8, 1886, 12, 1402, 12, 843, 14, 955, 12, 283, 955, 358, 288, 340, 843, 14, 23501, 26, 355, 746, 11897, 360, 18088, 901, 2193, 436, 1504, 787, 2013, 315, 450, 83, 3530, 450, 843, 855, 354, 3368, 288, 340, 822, 8, 1886, 14, 955, 9, 690, 822, 8, 409, 8, 1886, 14, 955, 2298, 355, 746, 11897, 360, 10924, 787, 9250, 901, 8, 83, 9, 315, 450, 83, 14, 955, 7, 450, 843, 855, 354, 3368, 339, 347, 4107, 63, 23501, 8, 277, 12, 843, 12, 1402, 304, 267, 298, 12134, 626, 901, 2193, 365, 7684, 7871, 436, 3181, 1133, 1395, 15755, 14, 298, 267, 687, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 9378, 63, 23501, 267, 340, 843, 14, 23501, 26, 221, 327, 849, 574, 365, 488, 288, 1104, 63, 374, 3610, 8, 1886, 12, 283, 23501, 297, 843, 14, 23501, 9, 288, 367, 4280, 12, 901, 409, 315, 3874, 8, 1886, 14, 23501, 304, 355, 1104, 63, 374, 3610, 8, 1886, 12, 283, 23501, 9722, 68, 6616, 450, 4280, 12, 901, 409, 9, 355, 340, 822, 8, 698, 409, 9, 1137, 499, 26, 490, 746, 11897, 21065, 83, 14, 23501, 9722, 68, 6616, 1630, 440, 298, 1169, 298, 7804, 8840, 2877, 4008, 2122, 450, 334, 1886, 855, 354, 3108, 4280, 430, 355, 1104, 63, 374, 807, 8, 1886, 12, 283, 23501, 9722, 68, 1527, 17, 6616, 450, 4280, 12, 901, 409, 59, 17, 566, 355, 340, 283, 955, 7, 440, 315, 901, 409, 59, 17, 2189, 490, 746, 11897, 15587, 955, 7, 790, 365, 1415, 315, 298, 1169, 2071, 83, 14, 23501, 9722, 68, 1527, 17, 61, 901, 1511, 1211, 2122, 1169, 450, 334, 1886, 855, 354, 3108, 4280, 430, 355, 291, 14, 1074, 63, 698, 63, 1650, 8, 1886, 12, 1402, 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 ]
laiqiqi886/kbengine
kbe/res/scripts/common/Lib/test/test_codecencodings_jp.py
88
4981
# # test_codecencodings_jp.py # Codec encoding tests for Japanese encodings. # from test import support from test import multibytecodec_support import unittest class Test_CP932(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'cp932' tstring = multibytecodec_support.load_teststring('shift_jis') codectests = ( # invalid bytes (b"abc\x81\x00\x81\x00\x82\x84", "strict", None), (b"abc\xf8", "strict", None), (b"abc\x81\x00\x82\x84", "replace", "abc\ufffd\x00\uff44"), (b"abc\x81\x00\x82\x84\x88", "replace", "abc\ufffd\x00\uff44\ufffd"), (b"abc\x81\x00\x82\x84", "ignore", "abc\x00\uff44"), (b"ab\xEBxy", "replace", "ab\uFFFDxy"), (b"ab\xF0\x39xy", "replace", "ab\uFFFD9xy"), (b"ab\xEA\xF0xy", "replace", 'ab\ufffd\ue038y'), # sjis vs cp932 (b"\\\x7e", "replace", "\\\x7e"), (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\uff3c\u2225\uff0d"), ) euc_commontests = ( # invalid bytes (b"abc\x80\x80\xc1\xc4", "strict", None), (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\u7956"), (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u7956\ufffd"), (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"), (b"abc\xc8", "strict", None), (b"abc\x8f\x83\x83", "replace", "abc\ufffd\ufffd\ufffd"), (b"\x82\xFCxy", "replace", "\ufffd\ufffdxy"), (b"\xc1\x64", "strict", None), (b"\xa1\xc0", "strict", "\uff3c"), (b"\xa1\xc0\\", "strict", "\uff3c\\"), (b"\x8eXY", "replace", "\ufffdXY"), ) class Test_EUC_JIS_2004(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'euc_jis_2004' tstring = multibytecodec_support.load_teststring('euc_jisx0213') codectests = euc_commontests xmlcharnametest = ( "\xab\u211c\xbb = \u2329\u1234\u232a", b"\xa9\xa8&real;\xa9\xb2 = &lang;&#4660;&rang;" ) class Test_EUC_JISX0213(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'euc_jisx0213' tstring = multibytecodec_support.load_teststring('euc_jisx0213') codectests = euc_commontests xmlcharnametest = ( "\xab\u211c\xbb = \u2329\u1234\u232a", b"\xa9\xa8&real;\xa9\xb2 = &lang;&#4660;&rang;" ) class Test_EUC_JP_COMPAT(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'euc_jp' tstring = multibytecodec_support.load_teststring('euc_jp') codectests = euc_commontests + ( ("\xa5", "strict", b"\x5c"), ("\u203e", "strict", b"\x7e"), ) shiftjis_commonenctests = ( (b"abc\x80\x80\x82\x84", "strict", None), (b"abc\xf8", "strict", None), (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"), ) class Test_SJIS_COMPAT(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'shift_jis' tstring = multibytecodec_support.load_teststring('shift_jis') codectests = shiftjis_commonenctests + ( (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\ufffd\uff44"), (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\ufffd\uff44\ufffd"), (b"\\\x7e", "strict", "\\\x7e"), (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\uff3c\u2016\u2212"), (b"abc\x81\x39", "replace", "abc\ufffd9"), (b"abc\xEA\xFC", "replace", "abc\ufffd\ufffd"), (b"abc\xFF\x58", "replace", "abc\ufffdX"), ) class Test_SJIS_2004(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'shift_jis_2004' tstring = multibytecodec_support.load_teststring('shift_jis') codectests = shiftjis_commonenctests + ( (b"\\\x7e", "strict", "\xa5\u203e"), (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\\\u2016\u2212"), (b"abc\xEA\xFC", "strict", "abc\u64bf"), (b"\x81\x39xy", "replace", "\ufffd9xy"), (b"\xFF\x58xy", "replace", "\ufffdXxy"), (b"\x80\x80\x82\x84xy", "replace", "\ufffd\ufffd\uff44xy"), (b"\x80\x80\x82\x84\x88xy", "replace", "\ufffd\ufffd\uff44\u5864y"), (b"\xFC\xFBxy", "replace", '\ufffd\u95b4y'), ) xmlcharnametest = ( "\xab\u211c\xbb = \u2329\u1234\u232a", b"\x85G&real;\x85Q = &lang;&#4660;&rang;" ) class Test_SJISX0213(multibytecodec_support.TestBase, unittest.TestCase): encoding = 'shift_jisx0213' tstring = multibytecodec_support.load_teststring('shift_jisx0213') codectests = shiftjis_commonenctests + ( (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\ufffd\uff44"), (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\ufffd\uff44\ufffd"), # sjis vs cp932 (b"\\\x7e", "replace", "\xa5\u203e"), (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\x5c\u2016\u2212"), ) xmlcharnametest = ( "\xab\u211c\xbb = \u2329\u1234\u232a", b"\x85G&real;\x85Q = &lang;&#4660;&rang;" ) def test_main(): support.run_unittest(__name__) if __name__ == "__main__": test_main()
lgpl-3.0
[ 3, 199, 3, 511, 63, 600, 2497, 9611, 63, 11538, 14, 647, 199, 3, 257, 13732, 2644, 2295, 367, 1603, 30699, 14134, 14, 199, 3, 199, 199, 504, 511, 492, 2291, 199, 504, 511, 492, 3510, 4414, 9276, 63, 4058, 199, 646, 2882, 199, 199, 533, 1379, 63, 2890, 27251, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 2882, 14, 1746, 304, 272, 2644, 275, 283, 1850, 27251, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 4723, 63, 18941, 358, 272, 9076, 2219, 275, 334, 267, 327, 3866, 2783, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 4768, 401, 221, 488, 395, 267, 334, 66, 2, 3175, 60, 1949, 24, 401, 298, 4768, 401, 221, 488, 395, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 88, 383, 60, 3043, 1602, 1288, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 60, 88, 1299, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 88, 383, 60, 3043, 1602, 60, 3043, 2592, 1288, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 4247, 401, 221, 298, 3175, 60, 88, 383, 60, 3043, 1602, 1288, 267, 334, 66, 2, 371, 60, 6991, 34, 1702, 401, 298, 1814, 401, 298, 371, 60, 24815, 1702, 1288, 267, 334, 66, 2, 371, 60, 6287, 16, 60, 88, 1355, 1702, 401, 298, 1814, 401, 298, 371, 60, 24815, 25, 1702, 1288, 267, 334, 66, 2, 371, 60, 6991, 33, 60, 6287, 16, 1702, 401, 298, 1814, 401, 283, 371, 60, 3043, 2592, 60, 310, 14273, 89, 659, 267, 327, 308, 18941, 8118, 7667, 27251, 267, 334, 66, 2, 9780, 88, 23, 69, 401, 298, 1814, 401, 298, 9780, 88, 23, 69, 1288, 267, 334, 66, 3212, 88, 2835, 60, 88, 21, 70, 60, 88, 2835, 60, 88, 2976, 60, 88, 2835, 60, 88, 23, 67, 401, 298, 1814, 401, 1867, 3043, 19, 67, 60, 85, 1081, 821, 60, 3043, 16, 68, 1288, 272, 776, 199, 199, 15149, 63, 2330, 2219, 275, 334, 272, 327, 3866, 2783, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 4768, 401, 221, 488, 395, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 85, 1965, 1367, 1288, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 60, 1812, 24, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 85, 1965, 1367, 60, 3043, 2592, 1288, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 4247, 401, 221, 298, 3175, 60, 85, 1965, 1367, 1288, 272, 334, 66, 2, 3175, 60, 1812, 24, 401, 298, 4768, 401, 221, 488, 395, 272, 334, 66, 2, 3175, 60, 88, 24, 70, 60, 88, 2658, 60, 88, 2658, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 3043, 2592, 1288, 272, 334, 66, 3212, 88, 2564, 60, 23234, 1702, 401, 298, 1814, 401, 1867, 3043, 2592, 60, 3043, 2592, 1702, 1288, 272, 334, 66, 3212, 1812, 17, 60, 88, 772, 401, 298, 4768, 401, 488, 395, 272, 334, 66, 3212, 1800, 17, 60, 1812, 16, 401, 298, 4768, 401, 1867, 3043, 19, 67, 1288, 272, 334, 66, 3212, 1800, 17, 60, 1812, 16, 1103, 401, 298, 4768, 401, 1867, 3043, 19, 67, 1103, 1288, 272, 334, 66, 3212, 88, 24, 69, 8195, 401, 298, 1814, 401, 1867, 3043, 2592, 8195, 1288, 199, 9, 199, 199, 533, 1379, 63, 37, 13371, 63, 22290, 63, 15431, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 717, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 18941, 63, 15431, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 18941, 88, 996, 969, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 272, 2748, 1560, 354, 396, 275, 334, 267, 1867, 10097, 60, 85, 12832, 67, 60, 9932, 275, 971, 85, 8001, 25, 60, 85, 4321, 60, 85, 8001, 65, 401, 267, 330, 3212, 1800, 25, 60, 1800, 24, 6, 3093, 3779, 1800, 25, 60, 1774, 18, 275, 1253, 4159, 14328, 20, 15268, 15337, 82, 621, 9426, 272, 776, 199, 199, 533, 1379, 63, 37, 13371, 63, 22290, 56, 996, 969, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 717, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 18941, 88, 996, 969, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 18941, 88, 996, 969, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 272, 2748, 1560, 354, 396, 275, 334, 267, 1867, 10097, 60, 85, 12832, 67, 60, 9932, 275, 971, 85, 8001, 25, 60, 85, 4321, 60, 85, 8001, 65, 401, 267, 330, 3212, 1800, 25, 60, 1800, 24, 6, 3093, 3779, 1800, 25, 60, 1774, 18, 275, 1253, 4159, 14328, 20, 15268, 15337, 82, 621, 9426, 272, 776, 199, 199, 533, 1379, 63, 37, 13371, 63, 15819, 63, 29720, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 586, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 11538, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 11538, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 435, 334, 267, 25381, 1800, 21, 401, 298, 4768, 401, 330, 3212, 88, 21, 67, 1288, 267, 25381, 85, 11341, 69, 401, 298, 4768, 401, 330, 3212, 88, 23, 69, 1288, 272, 776, 199, 199, 4723, 18941, 63, 2330, 10945, 2219, 275, 334, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 88 ]
[ 199, 3, 511, 63, 600, 2497, 9611, 63, 11538, 14, 647, 199, 3, 257, 13732, 2644, 2295, 367, 1603, 30699, 14134, 14, 199, 3, 199, 199, 504, 511, 492, 2291, 199, 504, 511, 492, 3510, 4414, 9276, 63, 4058, 199, 646, 2882, 199, 199, 533, 1379, 63, 2890, 27251, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 2882, 14, 1746, 304, 272, 2644, 275, 283, 1850, 27251, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 4723, 63, 18941, 358, 272, 9076, 2219, 275, 334, 267, 327, 3866, 2783, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 4768, 401, 221, 488, 395, 267, 334, 66, 2, 3175, 60, 1949, 24, 401, 298, 4768, 401, 221, 488, 395, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 88, 383, 60, 3043, 1602, 1288, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 60, 88, 1299, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 88, 383, 60, 3043, 1602, 60, 3043, 2592, 1288, 267, 334, 66, 2, 3175, 60, 88, 2835, 60, 88, 383, 60, 88, 2564, 60, 88, 1349, 401, 298, 4247, 401, 221, 298, 3175, 60, 88, 383, 60, 3043, 1602, 1288, 267, 334, 66, 2, 371, 60, 6991, 34, 1702, 401, 298, 1814, 401, 298, 371, 60, 24815, 1702, 1288, 267, 334, 66, 2, 371, 60, 6287, 16, 60, 88, 1355, 1702, 401, 298, 1814, 401, 298, 371, 60, 24815, 25, 1702, 1288, 267, 334, 66, 2, 371, 60, 6991, 33, 60, 6287, 16, 1702, 401, 298, 1814, 401, 283, 371, 60, 3043, 2592, 60, 310, 14273, 89, 659, 267, 327, 308, 18941, 8118, 7667, 27251, 267, 334, 66, 2, 9780, 88, 23, 69, 401, 298, 1814, 401, 298, 9780, 88, 23, 69, 1288, 267, 334, 66, 3212, 88, 2835, 60, 88, 21, 70, 60, 88, 2835, 60, 88, 2976, 60, 88, 2835, 60, 88, 23, 67, 401, 298, 1814, 401, 1867, 3043, 19, 67, 60, 85, 1081, 821, 60, 3043, 16, 68, 1288, 272, 776, 199, 199, 15149, 63, 2330, 2219, 275, 334, 272, 327, 3866, 2783, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 4768, 401, 221, 488, 395, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 85, 1965, 1367, 1288, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 60, 1812, 24, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 85, 1965, 1367, 60, 3043, 2592, 1288, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 1812, 17, 60, 1812, 20, 401, 298, 4247, 401, 221, 298, 3175, 60, 85, 1965, 1367, 1288, 272, 334, 66, 2, 3175, 60, 1812, 24, 401, 298, 4768, 401, 221, 488, 395, 272, 334, 66, 2, 3175, 60, 88, 24, 70, 60, 88, 2658, 60, 88, 2658, 401, 298, 1814, 401, 298, 3175, 60, 3043, 2592, 60, 3043, 2592, 60, 3043, 2592, 1288, 272, 334, 66, 3212, 88, 2564, 60, 23234, 1702, 401, 298, 1814, 401, 1867, 3043, 2592, 60, 3043, 2592, 1702, 1288, 272, 334, 66, 3212, 1812, 17, 60, 88, 772, 401, 298, 4768, 401, 488, 395, 272, 334, 66, 3212, 1800, 17, 60, 1812, 16, 401, 298, 4768, 401, 1867, 3043, 19, 67, 1288, 272, 334, 66, 3212, 1800, 17, 60, 1812, 16, 1103, 401, 298, 4768, 401, 1867, 3043, 19, 67, 1103, 1288, 272, 334, 66, 3212, 88, 24, 69, 8195, 401, 298, 1814, 401, 1867, 3043, 2592, 8195, 1288, 199, 9, 199, 199, 533, 1379, 63, 37, 13371, 63, 22290, 63, 15431, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 717, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 18941, 63, 15431, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 18941, 88, 996, 969, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 272, 2748, 1560, 354, 396, 275, 334, 267, 1867, 10097, 60, 85, 12832, 67, 60, 9932, 275, 971, 85, 8001, 25, 60, 85, 4321, 60, 85, 8001, 65, 401, 267, 330, 3212, 1800, 25, 60, 1800, 24, 6, 3093, 3779, 1800, 25, 60, 1774, 18, 275, 1253, 4159, 14328, 20, 15268, 15337, 82, 621, 9426, 272, 776, 199, 199, 533, 1379, 63, 37, 13371, 63, 22290, 56, 996, 969, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 717, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 18941, 88, 996, 969, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 18941, 88, 996, 969, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 272, 2748, 1560, 354, 396, 275, 334, 267, 1867, 10097, 60, 85, 12832, 67, 60, 9932, 275, 971, 85, 8001, 25, 60, 85, 4321, 60, 85, 8001, 65, 401, 267, 330, 3212, 1800, 25, 60, 1800, 24, 6, 3093, 3779, 1800, 25, 60, 1774, 18, 275, 1253, 4159, 14328, 20, 15268, 15337, 82, 621, 9426, 272, 776, 199, 199, 533, 1379, 63, 37, 13371, 63, 15819, 63, 29720, 8, 3029, 4414, 9276, 63, 4058, 14, 14440, 12, 586, 2882, 14, 1746, 304, 272, 2644, 275, 283, 15149, 63, 11538, 7, 272, 307, 875, 275, 3510, 4414, 9276, 63, 4058, 14, 912, 63, 396, 875, 360, 15149, 63, 11538, 358, 272, 9076, 2219, 275, 325, 947, 63, 2330, 2219, 435, 334, 267, 25381, 1800, 21, 401, 298, 4768, 401, 330, 3212, 88, 21, 67, 1288, 267, 25381, 85, 11341, 69, 401, 298, 4768, 401, 330, 3212, 88, 23, 69, 1288, 272, 776, 199, 199, 4723, 18941, 63, 2330, 10945, 2219, 275, 334, 272, 334, 66, 2, 3175, 60, 88, 1257, 60, 88, 1257, 60, 88, 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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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 ]
openfun/edx-platform
lms/djangoapps/mobile_api/social_facebook/friends/views.py
85
2439
""" Views for friends info API """ from rest_framework import generics, status from rest_framework.response import Response from opaque_keys.edx.keys import CourseKey from student.models import CourseEnrollment from ...utils import mobile_view from ..utils import get_friends_from_facebook, get_linked_edx_accounts, share_with_facebook_friends from lms.djangoapps.mobile_api.social_facebook.friends import serializers @mobile_view() class FriendsInCourse(generics.ListAPIView): """ **Use Case** API endpoint that returns all the users friends that are in the course specified. Note that only friends that allow their courses to be shared will be included. **Example request**: GET /api/mobile/v0.5/social/facebook/friends/course/<course_id> where course_id is in the form of /edX/DemoX/Demo_Course **Response Values** { "friends": [ { "name": "test", "id": "12345", }, ... ] } """ serializer_class = serializers.FriendsInCourseSerializer def list(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.GET, files=request.FILES) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) # Get all the user's FB friends result = get_friends_from_facebook(serializer) if not isinstance(result, list): return result def is_member(friend, course_key): """ Return true if friend is a member of the course specified by the course_key """ return CourseEnrollment.objects.filter( course_id=course_key, user_id=friend['edX_id'] ).count() == 1 # For each friend check if they are a linked edX user friends_with_edx_users = get_linked_edx_accounts(result) # Filter by sharing preferences and enrollment in course course_key = CourseKey.from_string(kwargs['course_id']) friends_with_sharing_in_course = [ {'id': friend['id'], 'name': friend['name']} for friend in friends_with_edx_users if share_with_facebook_friends(friend) and is_member(friend, course_key) ] return Response({'friends': friends_with_sharing_in_course})
agpl-3.0
[ 624, 272, 10935, 83, 367, 26157, 2256, 3261, 199, 624, 199, 199, 504, 4618, 63, 4857, 492, 1519, 2932, 12, 2004, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 2263, 1208, 492, 21305, 63, 1345, 199, 504, 2508, 1208, 492, 664, 63, 18024, 63, 504, 63, 16652, 12, 664, 63, 12751, 63, 8268, 63, 8370, 12, 8663, 63, 1045, 63, 16652, 63, 18024, 199, 504, 21577, 14, 16432, 14, 11375, 63, 1246, 14, 13574, 63, 16652, 14, 18024, 492, 12506, 421, 199, 32, 11375, 63, 1345, 342, 199, 533, 481, 13010, 607, 6979, 8, 2038, 2932, 14, 1296, 25778, 304, 272, 408, 272, 1011, 6119, 12425, 538, 398, 3261, 6037, 626, 2529, 1006, 314, 4390, 26157, 626, 787, 315, 314, 2518, 2013, 14, 267, 3390, 626, 1454, 26157, 626, 2040, 3932, 13588, 370, 506, 5709, 911, 506, 5120, 14, 339, 1011, 9846, 1056, 26742, 398, 9576, 1182, 1246, 15, 11375, 15, 86, 16, 14, 21, 15, 13574, 15, 16652, 15, 18024, 15, 1972, 8316, 1972, 63, 344, 30, 398, 2382, 2518, 63, 344, 365, 315, 314, 1824, 402, 1182, 24852, 15, 21493, 56, 15, 21493, 63, 6979, 339, 1011, 2364, 13468, 538, 398, 469, 288, 298, 18024, 582, 359, 355, 469, 490, 298, 354, 582, 298, 396, 401, 490, 298, 344, 582, 298, 13261, 401, 355, 1660, 355, 2263, 288, 1622, 267, 789, 272, 408, 272, 9146, 63, 533, 275, 12506, 14, 38, 13010, 607, 6979, 7299, 339, 347, 769, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 9146, 275, 291, 14, 362, 63, 8349, 8, 576, 29, 1069, 14, 2970, 12, 1584, 29, 1069, 14, 9472, 9, 267, 340, 440, 9146, 14, 374, 63, 1078, 837, 288, 372, 7232, 8, 8349, 14, 2550, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 327, 2372, 1006, 314, 922, 1159, 481, 34, 26157, 267, 754, 275, 664, 63, 18024, 63, 504, 63, 16652, 8, 8349, 9, 267, 340, 440, 1228, 8, 1099, 12, 769, 304, 288, 372, 754, 398, 347, 365, 63, 1114, 8, 23472, 12, 2518, 63, 498, 304, 288, 408, 288, 1432, 2549, 340, 32506, 365, 282, 3653, 402, 314, 2518, 2013, 701, 314, 2518, 63, 498, 288, 408, 288, 372, 18946, 14, 1462, 14, 1541, 8, 355, 2518, 63, 344, 29, 1972, 63, 498, 12, 355, 922, 63, 344, 29, 23472, 459, 24852, 63, 344, 418, 288, 7092, 835, 342, 508, 413, 398, 327, 2104, 1924, 32506, 1104, 340, 2985, 787, 282, 10632, 3988, 56, 922, 267, 26157, 63, 1045, 63, 8268, 63, 3707, 275, 664, 63, 12751, 63, 8268, 63, 8370, 8, 1099, 9, 398, 327, 9388, 701, 26994, 23453, 436, 14869, 315, 2518, 267, 2518, 63, 498, 275, 22574, 14, 504, 63, 875, 8, 958, 459, 1972, 63, 344, 1105, 267, 26157, 63, 1045, 63, 29122, 63, 262, 63, 1972, 275, 359, 288, 791, 344, 356, 32506, 459, 344, 995, 283, 354, 356, 32506, 459, 354, 12074, 288, 367, 32506, 315, 26157, 63, 1045, 63, 8268, 63, 3707, 288, 340, 8663, 63, 1045, 63, 16652, 63, 18024, 8, 23472, 9, 436, 365, 63, 1114, 8, 23472, 12, 2518, 63, 498, 9, 267, 1622, 267, 372, 7232, 3252, 18024, 356, 26157, 63, 1045, 63, 29122, 63, 262, 63, 1972, 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 ]
[ 272, 10935, 83, 367, 26157, 2256, 3261, 199, 624, 199, 199, 504, 4618, 63, 4857, 492, 1519, 2932, 12, 2004, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 2263, 1208, 492, 21305, 63, 1345, 199, 504, 2508, 1208, 492, 664, 63, 18024, 63, 504, 63, 16652, 12, 664, 63, 12751, 63, 8268, 63, 8370, 12, 8663, 63, 1045, 63, 16652, 63, 18024, 199, 504, 21577, 14, 16432, 14, 11375, 63, 1246, 14, 13574, 63, 16652, 14, 18024, 492, 12506, 421, 199, 32, 11375, 63, 1345, 342, 199, 533, 481, 13010, 607, 6979, 8, 2038, 2932, 14, 1296, 25778, 304, 272, 408, 272, 1011, 6119, 12425, 538, 398, 3261, 6037, 626, 2529, 1006, 314, 4390, 26157, 626, 787, 315, 314, 2518, 2013, 14, 267, 3390, 626, 1454, 26157, 626, 2040, 3932, 13588, 370, 506, 5709, 911, 506, 5120, 14, 339, 1011, 9846, 1056, 26742, 398, 9576, 1182, 1246, 15, 11375, 15, 86, 16, 14, 21, 15, 13574, 15, 16652, 15, 18024, 15, 1972, 8316, 1972, 63, 344, 30, 398, 2382, 2518, 63, 344, 365, 315, 314, 1824, 402, 1182, 24852, 15, 21493, 56, 15, 21493, 63, 6979, 339, 1011, 2364, 13468, 538, 398, 469, 288, 298, 18024, 582, 359, 355, 469, 490, 298, 354, 582, 298, 396, 401, 490, 298, 344, 582, 298, 13261, 401, 355, 1660, 355, 2263, 288, 1622, 267, 789, 272, 408, 272, 9146, 63, 533, 275, 12506, 14, 38, 13010, 607, 6979, 7299, 339, 347, 769, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 9146, 275, 291, 14, 362, 63, 8349, 8, 576, 29, 1069, 14, 2970, 12, 1584, 29, 1069, 14, 9472, 9, 267, 340, 440, 9146, 14, 374, 63, 1078, 837, 288, 372, 7232, 8, 8349, 14, 2550, 12, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9, 398, 327, 2372, 1006, 314, 922, 1159, 481, 34, 26157, 267, 754, 275, 664, 63, 18024, 63, 504, 63, 16652, 8, 8349, 9, 267, 340, 440, 1228, 8, 1099, 12, 769, 304, 288, 372, 754, 398, 347, 365, 63, 1114, 8, 23472, 12, 2518, 63, 498, 304, 288, 408, 288, 1432, 2549, 340, 32506, 365, 282, 3653, 402, 314, 2518, 2013, 701, 314, 2518, 63, 498, 288, 408, 288, 372, 18946, 14, 1462, 14, 1541, 8, 355, 2518, 63, 344, 29, 1972, 63, 498, 12, 355, 922, 63, 344, 29, 23472, 459, 24852, 63, 344, 418, 288, 7092, 835, 342, 508, 413, 398, 327, 2104, 1924, 32506, 1104, 340, 2985, 787, 282, 10632, 3988, 56, 922, 267, 26157, 63, 1045, 63, 8268, 63, 3707, 275, 664, 63, 12751, 63, 8268, 63, 8370, 8, 1099, 9, 398, 327, 9388, 701, 26994, 23453, 436, 14869, 315, 2518, 267, 2518, 63, 498, 275, 22574, 14, 504, 63, 875, 8, 958, 459, 1972, 63, 344, 1105, 267, 26157, 63, 1045, 63, 29122, 63, 262, 63, 1972, 275, 359, 288, 791, 344, 356, 32506, 459, 344, 995, 283, 354, 356, 32506, 459, 354, 12074, 288, 367, 32506, 315, 26157, 63, 1045, 63, 8268, 63, 3707, 288, 340, 8663, 63, 1045, 63, 16652, 63, 18024, 8, 23472, 9, 436, 365, 63, 1114, 8, 23472, 12, 2518, 63, 498, 9, 267, 1622, 267, 372, 7232, 3252, 18024, 356, 26157, 63, 1045, 63, 29122, 63, 262, 63, 1972, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
madan96/sympy
sympy/integrals/rde.py
91
26625
""" Algorithms for solving the Risch differential equation. Given a differential field K of characteristic 0 that is a simple monomial extension of a base field k and f, g in K, the Risch Differential Equation problem is to decide if there exist y in K such that Dy + f*y == g and to find one if there are some. If t is a monomial over k and the coefficients of f and g are in k(t), then y is in k(t), and the outline of the algorithm here is given as: 1. Compute the normal part n of the denominator of y. The problem is then reduced to finding y' in k<t>, where y == y'/n. 2. Compute the special part s of the denominator of y. The problem is then reduced to finding y'' in k[t], where y == y''/(n*s) 3. Bound the degree of y''. 4. Reduce the equation Dy + f*y == g to a similar equation with f, g in k[t]. 5. Find the solutions in k[t] of bounded degree of the reduced equation. See Chapter 6 of "Symbolic Integration I: Transcendental Functions" by Manuel Bronstein. See also the docstring of risch.py. """ from __future__ import print_function, division from operator import mul from sympy.core import oo from sympy.core.compatibility import reduce from sympy.core.symbol import Dummy from sympy.polys import Poly, gcd, ZZ, cancel from sympy.integrals.risch import (gcdex_diophantine, frac_in, derivation, splitfactor, NonElementaryIntegralException, DecrementLevel) # TODO: Add messages to NonElementaryIntegralException errors def order_at(a, p, t): """ Computes the order of a at p, with respect to t. For a, p in k[t], the order of a at p is defined as nu_p(a) = max({n in Z+ such that p**n|a}), where a != 0. If a == 0, nu_p(a) = +oo. To compute the order at a rational function, a/b, use the fact that nu_p(a/b) == nu_p(a) - nu_p(b). """ if a.is_zero: return oo if p == Poly(t, t): return a.as_poly(t).ET()[0][0] # Uses binary search for calculating the power. power_list collects the tuples # (p^k,k) where each k is some power of 2. After deciding the largest k # such that k is power of 2 and p^k|a the loop iteratively calculates # the actual power. power_list = [] p1 = p r = a.rem(p1) tracks_power = 1 while r.is_zero: power_list.append((p1,tracks_power)) p1 = p1*p1 tracks_power *= 2 r = a.rem(p1) n = 0 product = Poly(1, t) while len(power_list) != 0: final = power_list.pop() productf = product*final[0] r = a.rem(productf) if r.is_zero: n += final[1] product = productf return n def order_at_oo(a, d, t): """ Computes the order of a/d at oo (infinity), with respect to t. For f in k(t), the order or f at oo is defined as deg(d) - deg(a), where f == a/d. """ if a.is_zero: return oo return d.degree(t) - a.degree(t) def weak_normalizer(a, d, DE, z=None): """ Weak normalization. Given a derivation D on k[t] and f == a/d in k(t), return q in k[t] such that f - Dq/q is weakly normalized with respect to t. f in k(t) is said to be "weakly normalized" with respect to t if residue_p(f) is not a positive integer for any normal irreducible p in k[t] such that f is in R_p (Definition 6.1.1). If f has an elementary integral, this is equivalent to no logarithm of integral(f) whose argument depends on t has a positive integer coefficient, where the arguments of the logarithms not in k(t) are in k[t]. Returns (q, f - Dq/q) """ z = z or Dummy('z') dn, ds = splitfactor(d, DE) # Compute d1, where dn == d1*d2**2*...*dn**n is a square-free # factorization of d. g = gcd(dn, dn.diff(DE.t)) d_sqf_part = dn.quo(g) d1 = d_sqf_part.quo(gcd(d_sqf_part, g)) a1, b = gcdex_diophantine(d.quo(d1).as_poly(DE.t), d1.as_poly(DE.t), a.as_poly(DE.t)) r = (a - Poly(z, DE.t)*derivation(d1, DE)).as_poly(DE.t).resultant( d1.as_poly(DE.t)) r = Poly(r, z) if not r.has(z): return (Poly(1, DE.t), (a, d)) N = [i for i in r.real_roots() if i in ZZ and i > 0] q = reduce(mul, [gcd(a - Poly(n, DE.t)*derivation(d1, DE), d1) for n in N], Poly(1, DE.t)) dq = derivation(q, DE) sn = q*a - d*dq sd = q*d sn, sd = sn.cancel(sd, include=True) return (q, (sn, sd)) def normal_denom(fa, fd, ga, gd, DE): """ Normal part of the denominator. Given a derivation D on k[t] and f, g in k(t) with f weakly normalized with respect to t, either raise NonElementaryIntegralException, in which case the equation Dy + f*y == g has no solution in k(t), or the quadruplet (a, b, c, h) such that a, h in k[t], b, c in k<t>, and for any solution y in k(t) of Dy + f*y == g, q = y*h in k<t> satisfies a*Dq + b*q == c. This constitutes step 1 in the outline given in the rde.py docstring. """ dn, ds = splitfactor(fd, DE) en, es = splitfactor(gd, DE) p = dn.gcd(en) h = en.gcd(en.diff(DE.t)).quo(p.gcd(p.diff(DE.t))) a = dn*h c = a*h if c.div(en)[1]: # en does not divide dn*h**2 raise NonElementaryIntegralException ca = c*ga ca, cd = ca.cancel(gd, include=True) ba = a*fa - dn*derivation(h, DE)*fd ba, bd = ba.cancel(fd, include=True) # (dn*h, dn*h*f - dn*Dh, dn*h**2*g, h) return (a, (ba, bd), (ca, cd), h) def special_denom(a, ba, bd, ca, cd, DE, case='auto'): """ Special part of the denominator. case is one of {'exp', 'tan', 'primitive'} for the hyperexponential, hypertangent, and primitive cases, respectively. For the hyperexponential (resp. hypertangent) case, given a derivation D on k[t] and a in k[t], b, c, in k<t> with Dt/t in k (resp. Dt/(t**2 + 1) in k, sqrt(-1) not in k), a != 0, and gcd(a, t) == 1 (resp. gcd(a, t**2 + 1) == 1), return the quadruplet (A, B, C, 1/h) such that A, B, C, h in k[t] and for any solution q in k<t> of a*Dq + b*q == c, r = qh in k[t] satisfies A*Dr + B*r == C. For case == 'primitive', k<t> == k[t], so it returns (a, b, c, 1) in this case. This constitutes step 2 of the outline given in the rde.py docstring. """ from sympy.integrals.prde import parametric_log_deriv # TODO: finish writing this and write tests if case == 'auto': case = DE.case if case == 'exp': p = Poly(DE.t, DE.t) elif case == 'tan': p = Poly(DE.t**2 + 1, DE.t) elif case in ['primitive', 'base']: B = ba.to_field().quo(bd) C = ca.to_field().quo(cd) return (a, B, C, Poly(1, DE.t)) else: raise ValueError("case must be one of {'exp', 'tan', 'primitive', " "'base'}, not %s." % case) nb = order_at(ba, p, DE.t) - order_at(bd, p, DE.t) nc = order_at(ca, p, DE.t) - order_at(cd, p, DE.t) n = min(0, nc - min(0, nb)) if not nb: # Possible cancellation. if case == 'exp': dcoeff = DE.d.quo(Poly(DE.t, DE.t)) with DecrementLevel(DE): # We are guaranteed to not have problems, # because case != 'base'. alphaa, alphad = frac_in(-ba.eval(0)/bd.eval(0)/a.eval(0), DE.t) etaa, etad = frac_in(dcoeff, DE.t) A = parametric_log_deriv(alphaa, alphad, etaa, etad, DE) if A is not None: a, m, z = A if a == 1: n = min(n, m) elif case == 'tan': dcoeff = DE.d.quo(Poly(DE.t**2+1, DE.t)) with DecrementLevel(DE): # We are guaranteed to not have problems, # because case != 'base'. alphaa, alphad = frac_in(im(-ba.eval(sqrt(-1))/bd.eval(sqrt(-1))/a.eval(sqrt(-1))), DE.t) betaa, betad = frac_in(re(-ba.eval(sqrt(-1))/bd.eval(sqrt(-1))/a.eval(sqrt(-1))), DE.t) etaa, etad = frac_in(dcoeff, DE.t) if recognize_log_derivative(2*betaa, betad, DE): A = parametric_log_deriv(alphaa*sqrt(-1)*betad+alphad*betaa, alphad*betad, etaa, etad, DE) if A is not None: a, m, z = A if a == 1: n = min(n, m) N = max(0, -nb, n - nc) pN = p**N pn = p**-n A = a*pN B = ba*pN.quo(bd) + Poly(n, DE.t)*a*derivation(p, DE).quo(p)*pN C = (ca*pN*pn).quo(cd) h = pn # (a*p**N, (b + n*a*Dp/p)*p**N, c*p**(N - n), p**-n) return (A, B, C, h) def bound_degree(a, b, cQ, DE, case='auto', parametric=False): """ Bound on polynomial solutions. Given a derivation D on k[t] and a, b, c in k[t] with a != 0, return n in ZZ such that deg(q) <= n for any solution q in k[t] of a*Dq + b*q == c, when parametric=False, or deg(q) <= n for any solution c1, ..., cm in Const(k) and q in k[t] of a*Dq + b*q == Sum(ci*gi, (i, 1, m)) when parametric=True. For parametric=False, cQ is c, a Poly; for parametric=True, cQ is Q == [q1, ..., qm], a list of Polys. This constitutes step 3 of the outline given in the rde.py docstring. """ from sympy.integrals.prde import (parametric_log_deriv, limited_integrate, is_log_deriv_k_t_radical_in_field) # TODO: finish writing this and write tests if case == 'auto': case = DE.case da = a.degree(DE.t) db = b.degree(DE.t) # The parametric and regular cases are identical, except for this part if parametric: dc = max([i.degree(DE.t) for i in cQ]) else: dc = cQ.degree(DE.t) alpha = cancel(-b.as_poly(DE.t).LC().as_expr()/ a.as_poly(DE.t).LC().as_expr()) if case == 'base': n = max(0, dc - max(db, da - 1)) if db == da - 1 and alpha.is_Integer: n = max(0, alpha, dc - db) elif case == 'primitive': if db > da: n = max(0, dc - db) else: n = max(0, dc - da + 1) etaa, etad = frac_in(DE.d, DE.T[DE.level - 1]) t1 = DE.t with DecrementLevel(DE): alphaa, alphad = frac_in(alpha, DE.t) if db == da - 1: # if alpha == m*Dt + Dz for z in k and m in ZZ: try: (za, zd), m = limited_integrate(alphaa, alphad, [(etaa, etad)], DE) except NonElementaryIntegralException: pass else: if len(m) != 1: raise ValueError("Length of m should be 1") n = max(n, m[0]) elif db == da: # if alpha == Dz/z for z in k*: # beta = -lc(a*Dz + b*z)/(z*lc(a)) # if beta == m*Dt + Dw for w in k and m in ZZ: # n = max(n, m) A = is_log_deriv_k_t_radical_in_field(alphaa, alphad, DE) if A is not None: aa, z = A if aa == 1: beta = -(a*derivation(z, DE).as_poly(t1) + b*z.as_poly(t1)).LC()/(z.as_expr()*a.LC()) betaa, betad = frac_in(beta, DE.t) try: (za, zd), m = limited_integrate(betaa, betad, [(etaa, etad)], DE) except NonElementaryIntegralException: pass else: if len(m) != 1: raise ValueError("Length of m should be 1") n = max(n, m[0]) elif case == 'exp': n = max(0, dc - max(db, da)) if da == db: etaa, etad = frac_in(DE.d.quo(Poly(DE.t, DE.t)), DE.T[DE.level - 1]) with DecrementLevel(DE): alphaa, alphad = frac_in(alpha, DE.t) A = parametric_log_deriv(alphaa, alphad, etaa, etad, DE) if A is not None: # if alpha == m*Dt/t + Dz/z for z in k* and m in ZZ: # n = max(n, m) a, m, z = A if a == 1: n = max(n, m) elif case in ['tan', 'other_nonlinear']: delta = DE.d.degree(DE.t) lam = DE.d.LC() alpha = cancel(alpha/lam) n = max(0, dc - max(da + delta - 1, db)) if db == da + delta - 1 and alpha.is_Integer: n = max(0, alpha, dc - db) else: raise ValueError("case must be one of {'exp', 'tan', 'primitive', " "'other_nonlinear', 'base'}, not %s." % case) return n def spde(a, b, c, n, DE): """ Rothstein's Special Polynomial Differential Equation algorithm. Given a derivation D on k[t], an integer n and a, b, c in k[t] with a != 0, either raise NonElementaryIntegralException, in which case the equation a*Dq + b*q == c has no solution of degree at most n in k[t], or return the tuple (B, C, m, alpha, beta) such that B, C, alpha, beta in k[t], m in ZZ, and any solution q in k[t] of degree at most n of a*Dq + b*q == c must be of the form q == alpha*h + beta, where h in k[t], deg(h) <= m, and Dh + B*h == C. This constitutes step 4 of the outline given in the rde.py docstring. """ zero = Poly(0, DE.t) alpha = Poly(1, DE.t) beta = Poly(0, DE.t) while True: if c.is_zero: return (zero, zero, 0, zero, beta) # -1 is more to the point if (n < 0) is True: raise NonElementaryIntegralException g = a.gcd(b) if not c.rem(g).is_zero: # g does not divide c raise NonElementaryIntegralException a, b, c = a.quo(g), b.quo(g), c.quo(g) if a.degree(DE.t) == 0: b = b.to_field().quo(a) c = c.to_field().quo(a) return (b, c, n, alpha, beta) r, z = gcdex_diophantine(b, a, c) b += derivation(a, DE) c = z - derivation(r, DE) n -= a.degree(DE.t) beta += alpha * r alpha *= a def no_cancel_b_large(b, c, n, DE): """ Poly Risch Differential Equation - No cancellation: deg(b) large enough. Given a derivation D on k[t], n either an integer or +oo, and b, c in k[t] with b != 0 and either D == d/dt or deg(b) > max(0, deg(D) - 1), either raise NonElementaryIntegralException, in which case the equation Dq + b*q == c has no solution of degree at most n in k[t], or a solution q in k[t] of this equation with deg(q) < n. """ q = Poly(0, DE.t) while not c.is_zero: m = c.degree(DE.t) - b.degree(DE.t) if not 0 <= m <= n: # n < 0 or m < 0 or m > n raise NonElementaryIntegralException p = Poly(c.as_poly(DE.t).LC()/b.as_poly(DE.t).LC()*DE.t**m, DE.t, expand=False) q = q + p n = m - 1 c = c - derivation(p, DE) - b*p return q def no_cancel_b_small(b, c, n, DE): """ Poly Risch Differential Equation - No cancellation: deg(b) small enough. Given a derivation D on k[t], n either an integer or +oo, and b, c in k[t] with deg(b) < deg(D) - 1 and either D == d/dt or deg(D) >= 2, either raise NonElementaryIntegralException, in which case the equation Dq + b*q == c has no solution of degree at most n in k[t], or a solution q in k[t] of this equation with deg(q) <= n, or the tuple (h, b0, c0) such that h in k[t], b0, c0, in k, and for any solution q in k[t] of degree at most n of Dq + bq == c, y == q - h is a solution in k of Dy + b0*y == c0. """ q = Poly(0, DE.t) while not c.is_zero: if n == 0: m = 0 else: m = c.degree(DE.t) - DE.d.degree(DE.t) + 1 if not 0 <= m <= n: # n < 0 or m < 0 or m > n raise NonElementaryIntegralException if m > 0: p = Poly(c.as_poly(DE.t).LC()/(m*DE.d.as_poly(DE.t).LC())*DE.t**m, DE.t, expand=False) else: if b.degree(DE.t) != c.degree(DE.t): raise NonElementaryIntegralException if b.degree(DE.t) == 0: return (q, b.as_poly(DE.T[DE.level - 1]), c.as_poly(DE.T[DE.level - 1])) p = Poly(c.as_poly(DE.t).LC()/b.as_poly(DE.t).LC(), DE.t, expand=False) q = q + p n = m - 1 c = c - derivation(p, DE) - b*p return q # TODO: better name for this function def no_cancel_equal(b, c, n, DE): """ Poly Risch Differential Equation - No cancellation: deg(b) == deg(D) - 1 Given a derivation D on k[t] with deg(D) >= 2, n either an integer or +oo, and b, c in k[t] with deg(b) == deg(D) - 1, either raise NonElementaryIntegralException, in which case the equation Dq + b*q == c has no solution of degree at most n in k[t], or a solution q in k[t] of this equation with deg(q) <= n, or the tuple (h, m, C) such that h in k[t], m in ZZ, and C in k[t], and for any solution q in k[t] of degree at most n of Dq + b*q == c, y == q - h is a solution in k[t] of degree at most m of Dy + b*y == C. """ q = Poly(0, DE.t) lc = cancel(-b.as_poly(DE.t).LC()/DE.d.as_poly(DE.t).LC()) if lc.is_Integer and lc.is_positive: M = lc else: M = -1 while not c.is_zero: m = max(M, c.degree(DE.t) - DE.d.degree(DE.t) + 1) if not 0 <= m <= n: # n < 0 or m < 0 or m > n raise NonElementaryIntegralException u = cancel(m*DE.d.as_poly(DE.t).LC() + b.as_poly(DE.t).LC()) if u.is_zero: return (q, m, c) if m > 0: p = Poly(c.as_poly(DE.t).LC()/u*DE.t**m, DE.t, expand=False) else: if c.degree(DE.t) != DE.d.degree(DE.t) - 1: raise NonElementaryIntegralException else: p = c.as_poly(DE.t).LC()/b.as_poly(DE.t).LC() q = q + p n = m - 1 c = c - derivation(p, DE) - b*p return q def cancel_primitive(b, c, n, DE): """ Poly Risch Differential Equation - Cancellation: Primitive case. Given a derivation D on k[t], n either an integer or +oo, b in k, and c in k[t] with Dt in k and b != 0, either raise NonElementaryIntegralException, in which case the equation Dq + b*q == c has no solution of degree at most n in k[t], or a solution q in k[t] of this equation with deg(q) <= n. """ from sympy.integrals.prde import is_log_deriv_k_t_radical_in_field with DecrementLevel(DE): ba, bd = frac_in(b, DE.t) A = is_log_deriv_k_t_radical_in_field(ba, bd, DE) if A is not None: n, z = A if n == 1: # b == Dz/z raise NotImplementedError("is_deriv_in_field() is required to " " solve this problem.") # if z*c == Dp for p in k[t] and deg(p) <= n: # return p/z # else: # raise NonElementaryIntegralException if c.is_zero: return c # return 0 if n < c.degree(DE.t): raise NonElementaryIntegralException q = Poly(0, DE.t) while not c.is_zero: m = c.degree(DE.t) if n < m: raise NonElementaryIntegralException with DecrementLevel(DE): a2a, a2d = frac_in(c.LC(), DE.t) sa, sd = rischDE(ba, bd, a2a, a2d, DE) stm = Poly(sa.as_expr()/sd.as_expr()*DE.t**m, DE.t, expand=False) q += stm n = m - 1 c -= b*stm + derivation(stm, DE) return q def cancel_exp(b, c, n, DE): """ Poly Risch Differential Equation - Cancellation: Hyperexponential case. Given a derivation D on k[t], n either an integer or +oo, b in k, and c in k[t] with Dt/t in k and b != 0, either raise NonElementaryIntegralException, in which case the equation Dq + b*q == c has no solution of degree at most n in k[t], or a solution q in k[t] of this equation with deg(q) <= n. """ from sympy.integrals.prde import parametric_log_deriv eta = DE.d.quo(Poly(DE.t, DE.t)).as_expr() with DecrementLevel(DE): etaa, etad = frac_in(eta, DE.t) ba, bd = frac_in(b, DE.t) A = parametric_log_deriv(ba, bd, etaa, etad, DE) if A is not None: a, m, z = A if a == 1: raise NotImplementedError("is_deriv_in_field() is required to " "solve this problem.") # if c*z*t**m == Dp for p in k<t> and q = p/(z*t**m) in k[t] and # deg(q) <= n: # return q # else: # raise NonElementaryIntegralException if c.is_zero: return c # return 0 if n < c.degree(DE.t): raise NonElementaryIntegralException q = Poly(0, DE.t) while not c.is_zero: m = c.degree(DE.t) if n < m: raise NonElementaryIntegralException # a1 = b + m*Dt/t a1 = b.as_expr() with DecrementLevel(DE): # TODO: Write a dummy function that does this idiom a1a, a1d = frac_in(a1, DE.t) a1a = a1a*etad + etaa*a1d*Poly(m, DE.t) a1d = a1d*etad a2a, a2d = frac_in(c.LC(), DE.t) sa, sd = rischDE(a1a, a1d, a2a, a2d, DE) stm = Poly(sa.as_expr()/sd.as_expr()*DE.t**m, DE.t, expand=False) q += stm n = m - 1 c -= b*stm + derivation(stm, DE) # deg(c) becomes smaller return q def solve_poly_rde(b, cQ, n, DE, parametric=False): """ Solve a Polynomial Risch Differential Equation with degree bound n. This constitutes step 4 of the outline given in the rde.py docstring. For parametric=False, cQ is c, a Poly; for parametric=True, cQ is Q == [q1, ..., qm], a list of Polys. """ from sympy.integrals.prde import (prde_no_cancel_b_large, prde_no_cancel_b_small) # No cancellation if not b.is_zero and (DE.case == 'base' or b.degree(DE.t) > max(0, DE.d.degree(DE.t) - 1)): if parametric: return prde_no_cancel_b_large(b, cQ, n, DE) return no_cancel_b_large(b, cQ, n, DE) elif (b.is_zero or b.degree(DE.t) < DE.d.degree(DE.t) - 1) and \ (DE.case == 'base' or DE.d.degree(DE.t) >= 2): if parametric: return prde_no_cancel_b_small(b, cQ, n, DE) R = no_cancel_b_small(b, cQ, n, DE) if isinstance(R, Poly): return R else: # XXX: Might k be a field? (pg. 209) h, b0, c0 = R with DecrementLevel(DE): b0, c0 = b0.as_poly(DE.t), c0.as_poly(DE.t) if b0 is None: # See above comment raise ValueError("b0 should be a non-Null value") if c0 is None: raise ValueError("c0 should be a non-Null value") y = solve_poly_rde(b0, c0, n, DE).as_poly(DE.t) return h + y elif DE.d.degree(DE.t) >= 2 and b.degree(DE.t) == DE.d.degree(DE.t) - 1 and \ n > -b.as_poly(DE.t).LC()/DE.d.as_poly(DE.t).LC(): # TODO: Is this check necessary, and if so, what should it do if it fails? # b comes from the first element returned from spde() if not b.as_poly(DE.t).LC().is_number: raise TypeError("Result should be a number") if parametric: raise NotImplementedError("prde_no_cancel_b_equal() is not yet " "implemented.") R = no_cancel_equal(b, cQ, n, DE) if isinstance(R, Poly): return R else: h, m, C = R # XXX: Or should it be rischDE()? y = solve_poly_rde(b, C, m, DE) return h + y else: # Cancellation if b.is_zero: raise NotImplementedError("Remaining cases for Poly (P)RDE are " "not yet implemented (is_deriv_in_field() required).") else: if DE.case == 'exp': if parametric: raise NotImplementedError("Parametric RDE cancellation " "hyperexponential case is not yet implemented.") return cancel_exp(b, cQ, n, DE) elif DE.case == 'primitive': if parametric: raise NotImplementedError("Parametric RDE cancellation " "primitive case is not yet implemented.") return cancel_primitive(b, cQ, n, DE) else: raise NotImplementedError("Other Poly (P)RDE cancellation " "cases are not yet implemented (%s)." % case) if parametric: raise NotImplementedError("Remaining cases for Poly PRDE not yet " "implemented.") raise NotImplementedError("Remaining cases for Poly RDE not yet " "implemented.") def rischDE(fa, fd, ga, gd, DE): """ Solve a Risch Differential Equation: Dy + f*y == g. See the outline in the docstring of rde.py for more information about the procedure used. Either raise NonElementaryIntegralException, in which case there is no solution y in the given differential field, or return y in k(t) satisfying Dy + f*y == g, or raise NotImplementedError, in which case, the algorithms necessary to solve the given Risch Differential Equation have not yet been implemented. """ _, (fa, fd) = weak_normalizer(fa, fd, DE) a, (ba, bd), (ca, cd), hn = normal_denom(fa, fd, ga, gd, DE) A, B, C, hs = special_denom(a, ba, bd, ca, cd, DE) try: # Until this is fully implemented, use oo. Note that this will almost # certainly cause non-termination in spde() (unless A == 1), and # *might* lead to non-termination in the next step for a nonelementary # integral (I don't know for certain yet). Fortunately, spde() is # currently written recursively, so this will just give # RuntimeError: maximum recursion depth exceeded. n = bound_degree(A, B, C, DE) except NotImplementedError: # Useful for debugging: # import warnings # warnings.warn("rischDE: Proceeding with n = oo; may cause " # "non-termination.") n = oo B, C, m, alpha, beta = spde(A, B, C, n, DE) if C.is_zero: y = C else: y = solve_poly_rde(B, C, m, DE) return (alpha*y + beta, hn*hs)
bsd-3-clause
[ 624, 199, 2439, 12719, 367, 8597, 4007, 314, 820, 374, 335, 31605, 18649, 14, 199, 199, 13735, 282, 31605, 901, 1804, 402, 2735, 6236, 11108, 378, 626, 365, 282, 3486, 199, 2106, 6471, 3329, 402, 282, 1300, 901, 1022, 436, 289, 12, 486, 315, 1804, 12, 314, 820, 374, 335, 199, 16384, 27257, 662, 392, 425, 5160, 365, 370, 19822, 340, 2337, 2187, 612, 315, 1804, 4066, 199, 9099, 577, 89, 435, 289, 10, 89, 508, 486, 436, 370, 2342, 1373, 340, 2337, 787, 2005, 14, 221, 982, 307, 365, 282, 199, 2106, 6471, 1806, 1022, 436, 314, 12343, 402, 289, 436, 486, 787, 315, 1022, 8, 84, 395, 2066, 612, 365, 199, 262, 1022, 8, 84, 395, 436, 314, 17964, 402, 314, 5563, 2348, 365, 1627, 465, 26, 199, 199, 17, 14, 8354, 314, 3293, 1777, 302, 402, 314, 21859, 402, 612, 14, 221, 710, 5160, 365, 199, 12726, 14953, 370, 17196, 612, 7, 315, 1022, 28, 84, 6244, 2382, 612, 508, 612, 9807, 78, 14, 199, 18, 14, 8354, 314, 4539, 1777, 308, 402, 314, 21859, 402, 612, 14, 257, 710, 5160, 365, 199, 12726, 14953, 370, 17196, 612, 891, 315, 1022, 59, 84, 467, 2382, 612, 508, 612, 891, 7985, 78, 10, 83, 9, 199, 19, 14, 21972, 314, 13666, 402, 612, 17067, 199, 20, 14, 30778, 314, 18649, 577, 89, 435, 289, 10, 89, 508, 486, 370, 282, 8545, 18649, 543, 289, 12, 486, 315, 199, 75, 59, 84, 1055, 199, 21, 14, 6668, 314, 24886, 315, 1022, 59, 84, 61, 402, 1234, 4585, 13666, 402, 314, 14953, 18649, 14, 199, 199, 9295, 2799, 4185, 1227, 402, 298, 16594, 9670, 27561, 473, 26, 19894, 10845, 1326, 279, 17471, 2, 701, 199, 2395, 13086, 699, 2641, 1597, 262, 14, 221, 1666, 2597, 314, 9214, 402, 221, 5719, 335, 14, 647, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 4182, 492, 19207, 199, 199, 504, 5840, 14, 1018, 492, 16390, 199, 504, 5840, 14, 1018, 14, 15390, 492, 7114, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 199, 199, 504, 5840, 14, 15743, 492, 16869, 12, 486, 2866, 12, 11739, 12, 9311, 199, 199, 504, 5840, 14, 25323, 2551, 14, 5719, 335, 492, 334, 9493, 731, 63, 328, 24316, 867, 1132, 12, 25028, 63, 262, 12, 5405, 4255, 12, 272, 3715, 4778, 12, 10172, 2162, 695, 18949, 1726, 12, 13966, 264, 434, 4670, 9, 199, 199, 3, 3254, 26, 2654, 3788, 370, 10172, 2162, 695, 18949, 1726, 2552, 421, 199, 318, 1865, 63, 292, 8, 65, 12, 299, 12, 307, 304, 272, 408, 272, 28040, 314, 1865, 402, 282, 737, 299, 12, 543, 14021, 370, 307, 14, 339, 2104, 282, 12, 299, 315, 1022, 59, 84, 467, 314, 1865, 402, 282, 737, 299, 365, 3247, 465, 15699, 63, 80, 8, 65, 9, 275, 1390, 2561, 78, 272, 315, 3107, 11, 4066, 626, 299, 538, 78, 92, 65, 8688, 2382, 282, 1137, 378, 14, 221, 982, 282, 508, 378, 12, 15699, 63, 80, 8, 65, 9, 275, 435, 1534, 14, 339, 4005, 4526, 314, 1865, 737, 282, 30239, 805, 12, 282, 15, 66, 12, 675, 314, 10572, 626, 272, 15699, 63, 80, 8, 65, 15, 66, 9, 508, 15699, 63, 80, 8, 65, 9, 446, 15699, 63, 80, 8, 66, 680, 272, 408, 272, 340, 282, 14, 374, 63, 4262, 26, 267, 372, 16390, 272, 340, 299, 508, 16869, 8, 84, 12, 307, 304, 267, 372, 282, 14, 305, 63, 6023, 8, 84, 680, 775, 3430, 16, 1527, 16, 61, 339, 327, 14911, 3366, 2754, 367, 26079, 314, 7074, 14, 7074, 63, 513, 8775, 83, 314, 6346, 272, 327, 334, 80, 62, 75, 12, 75, 9, 2382, 1924, 1022, 365, 2005, 7074, 402, 499, 14, 12836, 477, 7504, 316, 314, 17451, 1022, 272, 327, 4066, 626, 1022, 365, 7074, 402, 499, 436, 299, 62, 75, 92, 65, 314, 4438, 4826, 9462, 6966, 2335, 272, 327, 314, 3503, 7074, 14, 272, 7074, 63, 513, 275, 942, 272, 299, 17, 275, 299, 272, 519, 275, 282, 14, 13179, 8, 80, 17, 9, 272, 18917, 63, 5652, 275, 413, 272, 1830, 519, 14, 374, 63, 4262, 26, 267, 7074, 63, 513, 14, 740, 1332, 80, 17, 12, 16274, 63, 5652, 430, 267, 299, 17, 275, 299, 17, 10, 80, 17, 267, 18917, 63, 5652, 9000, 499, 267, 519, 275, 282, 14, 13179, 8, 80, 17, 9, 272, 302, 275, 378, 272, 3336, 275, 16869, 8, 17, 12, 307, 9, 272, 1830, 822, 8, 5652, 63, 513, 9, 1137, 378, 26, 267, 4242, 275, 7074, 63, 513, 14, 1935, 342, 267, 3336, 70, 275, 3336, 10, 5094, 59, 16, 61, 267, 519, 275, 282, 14, 13179, 8, 2558, 70, 9, 267, 340, 519, 14, 374, 63, 4262, 26, 288, 302, 847, 4242, 59, 17, 61, 288, 3336, 275, 3336, 70, 272, 372, 302, 421, 199, 318, 1865, 63, 292, 63, 1534, 8, 65, 12, 366, 12, 307, 304, 272, 408, 272, 28040, 314, 1865, 402, 282, 15, 68, 737, 16390, 334, 262, 9693, 395, 543, 14021, 370, 307, 14, 339, 2104, 289, 315, 1022, 8, 84, 395, 314, 1865, 503, 289, 737, 16390, 365, 3247, 465, 7926, 8, 68, 9, 446, 7926, 8, 65, 395, 2382, 272, 289, 508, 282, 15, 68, 14, 272, 408, 272, 340, 282, 14, 374, 63, 4262, 26, 267, 372, 16390, 272, 372, 366, 14, 10956, 8, 84, 9, 446, 282, 14, 10956, 8, 84, 9, 421, 199, 318, 9282, 63, 3302, 1793, 8, 65, 12, 366, 12, 3265, 12, 1315, 29, 403, 304, 272, 408, 272, 28224, 16973, 14, 339, 9138, 282, 5405, 4255, 577, 641, 1022, 59, 84, 61, 436, 289, 508, 282, 15, 68, 315, 1022, 8, 84, 395, 372, 1894, 315, 1022, 59, 84, 61, 272, 4066, 626, 289, 446, 577, 81, 15, 81, 365, 9282, 590, 9657, 543, 14021, 370, 307, 14, 339, 289, 315, 1022, 8, 84, 9, 365, 25097, 370, 506, 298, 10350, 590, 9657, 2, 543, 14021, 370, 307, 340, 272, 23185, 310, 63, 80, 8, 70, 9, 365, 440, 282, 7317, 3000, 367, 1263, 3293, 8190, 19493, 559, 830, 299, 272, 315, 1022 ]
[ 199, 2439, 12719, 367, 8597, 4007, 314, 820, 374, 335, 31605, 18649, 14, 199, 199, 13735, 282, 31605, 901, 1804, 402, 2735, 6236, 11108, 378, 626, 365, 282, 3486, 199, 2106, 6471, 3329, 402, 282, 1300, 901, 1022, 436, 289, 12, 486, 315, 1804, 12, 314, 820, 374, 335, 199, 16384, 27257, 662, 392, 425, 5160, 365, 370, 19822, 340, 2337, 2187, 612, 315, 1804, 4066, 199, 9099, 577, 89, 435, 289, 10, 89, 508, 486, 436, 370, 2342, 1373, 340, 2337, 787, 2005, 14, 221, 982, 307, 365, 282, 199, 2106, 6471, 1806, 1022, 436, 314, 12343, 402, 289, 436, 486, 787, 315, 1022, 8, 84, 395, 2066, 612, 365, 199, 262, 1022, 8, 84, 395, 436, 314, 17964, 402, 314, 5563, 2348, 365, 1627, 465, 26, 199, 199, 17, 14, 8354, 314, 3293, 1777, 302, 402, 314, 21859, 402, 612, 14, 221, 710, 5160, 365, 199, 12726, 14953, 370, 17196, 612, 7, 315, 1022, 28, 84, 6244, 2382, 612, 508, 612, 9807, 78, 14, 199, 18, 14, 8354, 314, 4539, 1777, 308, 402, 314, 21859, 402, 612, 14, 257, 710, 5160, 365, 199, 12726, 14953, 370, 17196, 612, 891, 315, 1022, 59, 84, 467, 2382, 612, 508, 612, 891, 7985, 78, 10, 83, 9, 199, 19, 14, 21972, 314, 13666, 402, 612, 17067, 199, 20, 14, 30778, 314, 18649, 577, 89, 435, 289, 10, 89, 508, 486, 370, 282, 8545, 18649, 543, 289, 12, 486, 315, 199, 75, 59, 84, 1055, 199, 21, 14, 6668, 314, 24886, 315, 1022, 59, 84, 61, 402, 1234, 4585, 13666, 402, 314, 14953, 18649, 14, 199, 199, 9295, 2799, 4185, 1227, 402, 298, 16594, 9670, 27561, 473, 26, 19894, 10845, 1326, 279, 17471, 2, 701, 199, 2395, 13086, 699, 2641, 1597, 262, 14, 221, 1666, 2597, 314, 9214, 402, 221, 5719, 335, 14, 647, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 4182, 492, 19207, 199, 199, 504, 5840, 14, 1018, 492, 16390, 199, 504, 5840, 14, 1018, 14, 15390, 492, 7114, 199, 504, 5840, 14, 1018, 14, 5155, 492, 9762, 199, 199, 504, 5840, 14, 15743, 492, 16869, 12, 486, 2866, 12, 11739, 12, 9311, 199, 199, 504, 5840, 14, 25323, 2551, 14, 5719, 335, 492, 334, 9493, 731, 63, 328, 24316, 867, 1132, 12, 25028, 63, 262, 12, 5405, 4255, 12, 272, 3715, 4778, 12, 10172, 2162, 695, 18949, 1726, 12, 13966, 264, 434, 4670, 9, 199, 199, 3, 3254, 26, 2654, 3788, 370, 10172, 2162, 695, 18949, 1726, 2552, 421, 199, 318, 1865, 63, 292, 8, 65, 12, 299, 12, 307, 304, 272, 408, 272, 28040, 314, 1865, 402, 282, 737, 299, 12, 543, 14021, 370, 307, 14, 339, 2104, 282, 12, 299, 315, 1022, 59, 84, 467, 314, 1865, 402, 282, 737, 299, 365, 3247, 465, 15699, 63, 80, 8, 65, 9, 275, 1390, 2561, 78, 272, 315, 3107, 11, 4066, 626, 299, 538, 78, 92, 65, 8688, 2382, 282, 1137, 378, 14, 221, 982, 282, 508, 378, 12, 15699, 63, 80, 8, 65, 9, 275, 435, 1534, 14, 339, 4005, 4526, 314, 1865, 737, 282, 30239, 805, 12, 282, 15, 66, 12, 675, 314, 10572, 626, 272, 15699, 63, 80, 8, 65, 15, 66, 9, 508, 15699, 63, 80, 8, 65, 9, 446, 15699, 63, 80, 8, 66, 680, 272, 408, 272, 340, 282, 14, 374, 63, 4262, 26, 267, 372, 16390, 272, 340, 299, 508, 16869, 8, 84, 12, 307, 304, 267, 372, 282, 14, 305, 63, 6023, 8, 84, 680, 775, 3430, 16, 1527, 16, 61, 339, 327, 14911, 3366, 2754, 367, 26079, 314, 7074, 14, 7074, 63, 513, 8775, 83, 314, 6346, 272, 327, 334, 80, 62, 75, 12, 75, 9, 2382, 1924, 1022, 365, 2005, 7074, 402, 499, 14, 12836, 477, 7504, 316, 314, 17451, 1022, 272, 327, 4066, 626, 1022, 365, 7074, 402, 499, 436, 299, 62, 75, 92, 65, 314, 4438, 4826, 9462, 6966, 2335, 272, 327, 314, 3503, 7074, 14, 272, 7074, 63, 513, 275, 942, 272, 299, 17, 275, 299, 272, 519, 275, 282, 14, 13179, 8, 80, 17, 9, 272, 18917, 63, 5652, 275, 413, 272, 1830, 519, 14, 374, 63, 4262, 26, 267, 7074, 63, 513, 14, 740, 1332, 80, 17, 12, 16274, 63, 5652, 430, 267, 299, 17, 275, 299, 17, 10, 80, 17, 267, 18917, 63, 5652, 9000, 499, 267, 519, 275, 282, 14, 13179, 8, 80, 17, 9, 272, 302, 275, 378, 272, 3336, 275, 16869, 8, 17, 12, 307, 9, 272, 1830, 822, 8, 5652, 63, 513, 9, 1137, 378, 26, 267, 4242, 275, 7074, 63, 513, 14, 1935, 342, 267, 3336, 70, 275, 3336, 10, 5094, 59, 16, 61, 267, 519, 275, 282, 14, 13179, 8, 2558, 70, 9, 267, 340, 519, 14, 374, 63, 4262, 26, 288, 302, 847, 4242, 59, 17, 61, 288, 3336, 275, 3336, 70, 272, 372, 302, 421, 199, 318, 1865, 63, 292, 63, 1534, 8, 65, 12, 366, 12, 307, 304, 272, 408, 272, 28040, 314, 1865, 402, 282, 15, 68, 737, 16390, 334, 262, 9693, 395, 543, 14021, 370, 307, 14, 339, 2104, 289, 315, 1022, 8, 84, 395, 314, 1865, 503, 289, 737, 16390, 365, 3247, 465, 7926, 8, 68, 9, 446, 7926, 8, 65, 395, 2382, 272, 289, 508, 282, 15, 68, 14, 272, 408, 272, 340, 282, 14, 374, 63, 4262, 26, 267, 372, 16390, 272, 372, 366, 14, 10956, 8, 84, 9, 446, 282, 14, 10956, 8, 84, 9, 421, 199, 318, 9282, 63, 3302, 1793, 8, 65, 12, 366, 12, 3265, 12, 1315, 29, 403, 304, 272, 408, 272, 28224, 16973, 14, 339, 9138, 282, 5405, 4255, 577, 641, 1022, 59, 84, 61, 436, 289, 508, 282, 15, 68, 315, 1022, 8, 84, 395, 372, 1894, 315, 1022, 59, 84, 61, 272, 4066, 626, 289, 446, 577, 81, 15, 81, 365, 9282, 590, 9657, 543, 14021, 370, 307, 14, 339, 289, 315, 1022, 8, 84, 9, 365, 25097, 370, 506, 298, 10350, 590, 9657, 2, 543, 14021, 370, 307, 340, 272, 23185, 310, 63, 80, 8, 70, 9, 365, 440, 282, 7317, 3000, 367, 1263, 3293, 8190, 19493, 559, 830, 299, 272, 315, 1022, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Lamecarlate/gourmet
gourmet/recindex.py
6
30248
#!/usr/bin/env python from ImageExtras import get_pixbuf_from_jpg from gdebug import debug from gettext import gettext as _, ngettext from gglobals import REC_ATTRS, INT_REC_ATTRS, DEFAULT_HIDDEN_COLUMNS from gtk_extras import WidgetSaver, ratingWidget, cb_extras as cb, \ mnemonic_manager, pageable_store, treeview_extras as te import convert import Undo import gobject import gtk import gtk.gdk import pango class RecIndex: """We handle the 'index view' of recipes, which puts a recipe model into a tree and allows it to be searched and sorted. We're a separate class from the main recipe program so that we can be created again (e.g. in the recSelector dialog called from a recipe card.""" default_searches = [{'column':'deleted','operator':'=','search':False}] def __init__ (self, ui, rd, rg, editable=False): #self.visible = 1 # can equal 1 or 2 self.editable=editable self.selected = True self.rtcols=rg.rtcols self.rtcolsdic=rg.rtcolsdic self.rtwidgdic=rg.rtwidgdic self.prefs=rg.prefs self.ui = ui self.rd = rd self.rg = rg self.searchByDic = { unicode(_('anywhere')):'anywhere', unicode(_('title')):'title', unicode(_('ingredient')):'ingredient', unicode(_('instructions')):'instructions', unicode(_('notes')):'modifications', unicode(_('category')):'category', unicode(_('cuisine')):'cuisine', #_('rating'):'rating', unicode(_('source')):'source', } self.searchByList = [_('anywhere'), _('title'), _('ingredient'), _('category'), _('cuisine'), #_('rating'), _('source'), _('instructions'), _('notes'), ] # ACK, this breaks internationalization! #self.SEARCH_KEY_DICT = { # "t":_("title"), # "i":_("ingredient"), # "c":_("category"), # "u":_("cuisine"), # 's':_("source"), # } self.setup_search_actions() self.setup_widgets() def setup_widgets (self): self.srchentry=self.ui.get_object('rlistSearchbox') self.limitButton = self.ui.get_object('rlAddButton') # Don't # allow for special keybindings #self.srchentry.connect('key_press_event',self.srchentry_keypressCB) self.SEARCH_MENU_KEY = "b" self.srchLimitBar = self.ui.get_object('srchLimitBar') assert(self.srchLimitBar) self.srchLimitBar.hide() self.srchLimitLabel=self.ui.get_object('srchLimitLabel') self.srchLimitClearButton = self.ui.get_object('srchLimitClear') self.srchLimitText=self.srchLimitLabel.get_text() self.srchLimitDefaultText=self.srchLimitText self.searchButton = self.ui.get_object('searchButton') self.rSearchByMenu = self.ui.get_object('rlistSearchByMenu') cb.set_model_from_list(self.rSearchByMenu, self.searchByList, expand=False) cb.setup_typeahead(self.rSearchByMenu) self.rSearchByMenu.set_active(0) self.rSearchByMenu.connect('changed',self.search_as_you_type) self.sautTog = self.ui.get_object('searchAsYouTypeToggle') self.search_actions.get_action('toggleSearchAsYouType').connect_proxy(self.sautTog) self.regexpTog = self.ui.get_object('regexpTog') self.searchOptionsBox = self.ui.get_object('searchOptionsBox') self.search_actions.get_action('toggleShowSearchOptions').connect_proxy( self.ui.get_object('searchOptionsToggle') ) self.search_actions.get_action('toggleRegexp').connect_proxy(self.regexpTog) self.rectree = self.ui.get_object('recTree') self.sw = self.ui.get_object('scrolledwindow') self.rectree.connect('start-interactive-search',lambda *args: self.srchentry.grab_focus()) self.prev_button = self.ui.get_object('prevButton') self.next_button = self.ui.get_object('nextButton') self.first_button = self.ui.get_object('firstButton') self.last_button = self.ui.get_object('lastButton') self.showing_label = self.ui.get_object('showingLabel') self.stat = self.ui.get_object('statusbar') self.contid = self.stat.get_context_id('main') self.setup_search_views() self.setup_rectree() self.prev_button.connect('clicked',lambda *args: self.rmodel.prev_page()) self.next_button.connect('clicked',lambda *args: self.rmodel.next_page()) self.first_button.connect('clicked',lambda *args: self.rmodel.goto_first_page()) self.last_button.connect('clicked',lambda *args: self.rmodel.goto_last_page()) self.ui.connect_signals({ 'rlistSearch': self.search_as_you_type, 'ingredientSearch' : lambda *args: self.set_search_by('ingredient'), 'titleSearch' : lambda *args: self.set_search_by('title'), 'ratingSearch' : lambda *args: self.set_search_by('rating'), 'categorySearch' : lambda *args: self.set_search_by('category'), 'cuisineSearch' : lambda *args: self.set_search_by('cuisine'), 'search' : self.search, 'searchBoxActivatedCB':self.search_entry_activate_cb, 'rlistReset' : self.reset_search, 'rlistLimit' : self.limit_search, 'search_as_you_type_toggle' : self.toggleTypeSearchCB,}) self.toggleTypeSearchCB(self.sautTog) # this has to come after the type toggle is connected! self.rg.conf.append(WidgetSaver.WidgetSaver( self.sautTog, self.prefs.get('sautTog', {'active':self.sautTog.get_active()}), ['toggled'])) self.rg.conf.append(WidgetSaver.WidgetSaver( self.regexpTog, self.prefs.get('regexpTog', {'active':self.regexpTog.get_active()}), ['toggled'])) # and we update our count with each deletion. self.rd.delete_hooks.append(self.set_reccount) # setup a history self.uim=self.ui.get_object('undo_menu_item') self.rim=self.ui.get_object('redo_menu_item') self.raim=self.ui.get_object('reapply_menu_item') self.history = Undo.UndoHistoryList(self.uim,self.rim,self.raim) # Fix up our mnemonics with some heavenly magic self.mm = mnemonic_manager.MnemonicManager() self.mm.sacred_cows.append("search for") # Don't touch _Search for: self.mm.add_builder(self.ui) self.mm.add_treeview(self.rectree) self.mm.fix_conflicts_peacefully() def setup_search_actions (self): self.search_actions = gtk.ActionGroup('SearchActions') self.search_actions.add_toggle_actions([ ('toggleRegexp',None,_('Use regular expressions in search'), None,_('Use regular expressions (an advanced search language) in text search'), self.toggleRegexpCB,False), ('toggleSearchAsYouType',None,_('Search as you type'),None, _('Search as you type (turn off if search is too slow).'), self.toggleTypeSearchCB, True ), ('toggleShowSearchOptions', None, _('Show Search _Options'), None, _('Show advanced searching options'), self.toggleShowSearchOptions), ]) def setup_search_views (self): """Setup our views of the database.""" self.last_search = {} #self.rvw = self.rd.fetch_all(self.rd.recipe_table,deleted=False) self.searches = self.default_searches[0:] self.sort_by = [] self.rvw = self.rd.search_recipes(self.searches,sort_by=self.sort_by) def make_rec_visible (self, *args): """Make sure recipe REC shows up in our index.""" #if not self.rg.wait_to_filter: #self.setup_search_views() self.redo_search() #debug('make_rec_visible',0) #self.visible.append(rec.id) #if not self.rg.wait_to_filter: # self.rmodel_filter.refilter() def search_entry_activate_cb (self, *args): if self.rmodel._get_length_()==1: self.rec_tree_select_rec() elif self.srchentry.get_text(): if not self.search_as_you_type: self.search() gobject.idle_add(lambda *args: self.limit_search()) else: self.limit_search() def rmodel_page_changed_cb (self, rmodel): if rmodel.page==0: self.prev_button.set_sensitive(False) self.first_button.set_sensitive(False) else: self.prev_button.set_sensitive(True) self.first_button.set_sensitive(True) if rmodel.get_last_page()==rmodel.page: self.next_button.set_sensitive(False) self.last_button.set_sensitive(False) else: self.next_button.set_sensitive(True) self.last_button.set_sensitive(True) self.set_reccount() def rmodel_sort_cb (self, rmodel, sorts): self.sort_by = sorts self.last_search = {} self.search() #self.do_search(None,None) def create_rmodel (self, vw): self.rmodel = RecipeModel(vw,self.rd,per_page=self.prefs.get('recipes_per_page',12)) #self.set_reccount() # This will be called by the rmodel_page_changed_cb def setup_rectree (self): """Create our recipe treemodel.""" self.create_rmodel(self.rvw) self.rmodel.connect('page-changed',self.rmodel_page_changed_cb) self.rmodel.connect('view-changed',self.rmodel_page_changed_cb) self.rmodel.connect('view-sort',self.rmodel_sort_cb) # and call our handler once to update our prev/next buttons + label self.rmodel_page_changed_cb(self.rmodel) # and hook up our model self.rectree.set_model(self.rmodel) self.rectree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.selection_changed() self.setup_reccolumns() # this has to come after columns are added or else adding columns resets out column order! self.rectree_conf=te.TreeViewConf(self.rectree, hidden=self.prefs.get('rectree_hidden_columns',DEFAULT_HIDDEN_COLUMNS), order=self.prefs.get('rectree_column_order',{})) self.rectree_conf.apply_column_order() self.rectree_conf.apply_visibility() self.rectree.connect("row-activated",self.rec_tree_select_rec) self.rectree.connect('key-press-event',self.tree_keypress_cb) self.rectree.get_selection().connect("changed",self.selection_changedCB) self.rectree.set_property('rules-hint',True) # stripes! self.rectree.expand_all() self.rectree.show() def set_reccount (self, *args): """Display the count of currently visible recipes.""" debug("set_reccount (self, *args):",5) self.count = self.rmodel._get_length_() bottom,top,total = self.rmodel.showing() if top >= total and bottom==1: lab = ngettext('%s recipe','%s recipes',top)%top for b in self.first_button,self.prev_button,self.next_button,self.last_button: b.hide() else: for b in self.first_button,self.prev_button,self.next_button,self.last_button: b.show() # Do not translate bottom, top and total -- I use these fancy formatting # strings in case your language needs the order changed! lab = _('Showing recipes %(bottom)s to %(top)s of %(total)s')%locals() self.showing_label.set_markup('<i>' + lab + '</i>') if self.count == 1: sel = self.rectree.get_selection() if sel: sel.select_path((0,)) def setup_reccolumns (self): """Setup the columns of our recipe index TreeView""" renderer = gtk.CellRendererPixbuf() cssu=pageable_store.ColumnSortSetterUpper(self.rmodel) col = gtk.TreeViewColumn("",renderer,pixbuf=1) col.set_min_width(-1) self.rectree.append_column(col) n = 2 _title_to_num_ = {} for c in self.rtcols: if c=='rating': # special case -- for ratings we set up our lovely # star widget twsm = ratingWidget.TreeWithStarMaker( self.rectree, self.rg.star_generator, data_col=n, col_title='_%s'%self.rtcolsdic[c], handlers=[self.star_change_cb], properties={'reorderable':True, 'resizable':True}, ) cssu.set_sort_column_id(twsm.col,twsm.data_col) n += 1 twsm.col.set_min_width(110) continue # And we also special case our time column elif c in ['preptime','cooktime']: _title_to_num_[self.rtcolsdic[c]]=n renderer=gtk.CellRendererText() renderer.set_property('editable',True) renderer.connect('edited',self.rtree_time_edited_cb,n,c) def get_colnum (tc): try: t = tc.get_title() if t: return _title_to_num_[t.replace('_','')] else: print 'wtf, no title for ',tc return -1 except: print 'problem with ',tc raise ncols = self.rectree.insert_column_with_data_func( -1, '_%s'%self.rtcolsdic[c], renderer, lambda tc,cell,mod,titr: \ cell.set_property( 'text', convert.seconds_to_timestring(mod.get_value( titr, get_colnum(tc), #_title_to_num_[tc.get_title().replace('_','')], )) ) ) col=self.rectree.get_column(ncols-1) cssu.set_sort_column_id(col,n) col.set_property('reorderable',True) col.set_property('resizable',True) n+=1 continue elif self.editable and self.rtwidgdic[c]=='Combo': renderer = gtk.CellRendererCombo() model = gtk.ListStore(str) if c=='category': map(lambda i: model.append([i]),self.rg.rd.get_unique_values(c,self.rg.rd.categories_table) ) else: map(lambda i: model.append([i]),self.rg.rd.get_unique_values(c)) renderer.set_property('model',model) renderer.set_property('text-column',0) else: renderer = gtk.CellRendererText() if c=='link': renderer.set_property('ellipsize',pango.ELLIPSIZE_END) else: renderer.get_property('wrap-width') renderer.set_property('wrap-mode',pango.WRAP_WORD) if c == 'title': renderer.set_property('wrap-width',200) else: renderer.set_property('wrap-width',150) renderer.set_property('editable',self.editable) renderer.connect('edited',self.rtree_edited_cb,n, c) titl = self.rtcolsdic[c] col = gtk.TreeViewColumn('_%s'%titl,renderer, text=n) # Ensure that the columns aren't really narrow on initialising. #if c=='title': # Adjust these two to be even bigger # col.set_min_width(200) #else: # col.set_min_width(60) if c=='title': col.set_property('expand',True) col.set_reorderable(True) col.set_resizable(True) col.set_clickable(True) #col.connect('clicked', self.column_sort) self.rectree.append_column(col) cssu.set_sort_column_id(col,n) debug("Column %s is %s->%s"%(n,c,self.rtcolsdic[c]),5) n += 1 def toggleTypeSearchCB (self, widget): """Toggle search-as-you-type option.""" if widget.get_active(): self.search_as_you_type=True self.searchButton.hide() else: self.search_as_you_type=False self.searchButton.show() def toggleRegexpCB (self, widget): """Toggle search-with-regexp option.""" #if widget.get_active(): # self.message('Advanced searching (regular expressions) turned on') #else: # self.message('Advanced searching off') pass def toggleShowSearchOptions (self, widget): if widget.get_active(): self.searchOptionsBox.show() else: self.searchOptionsBox.hide() def regexpp (self): """Return True if we're using regexps""" if self.regexpTog.get_active(): return True else: return False def search_as_you_type (self, *args): """If we're searching-as-we-type, search.""" if self.search_as_you_type: self.search() def set_search_by (self, str): """Manually set the search by label to str""" debug('set_search_by',1) #self.rSearchByMenu.get_children()[0].set_text(str) cb.cb_set_active_text(self.rSearchByMenu, str) self.search() def redo_search (self, *args): self.last_search = {} self.search() def search (self, *args): debug("search (self, *args):",5) txt = self.srchentry.get_text() searchBy = cb.cb_get_active_text(self.rSearchByMenu) searchBy = self.searchByDic[unicode(searchBy)] if self.limitButton: self.limitButton.set_sensitive(txt!='') if self.make_search_dic(txt,searchBy) == self.last_search: debug("Same search!",1) return # Get window if self.srchentry: parent = self.srchentry.parent while parent and not (isinstance(parent,gtk.Window)): parent = parent.parent parent.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) debug('Doing new search for %s, last search was %s'%(self.make_search_dic(txt,searchBy),self.last_search),1) gobject.idle_add(lambda *args: (self.do_search(txt, searchBy) or parent.window.set_cursor(None))) else: gobject.idle_add(lambda *args: self.do_search(txt, searchBy)) def make_search_dic (self, txt, searchBy): srch = {'column':searchBy} if self.regexpp(): srch['operator'] = 'REGEXP' srch['search'] = txt.replace(' %s '%_('or'), # or operator for searches '|') else: srch['operator']='LIKE' srch['search'] = '%' + txt.replace('%','%%')+'%' return srch def do_search (self, txt, searchBy): if txt and searchBy: srch = self.make_search_dic(txt,searchBy) self.last_search = srch.copy() self.update_rmodel(self.rd.search_recipes( self.searches + [srch], sort_by=self.sort_by) ) elif self.searches: self.update_rmodel(self.rd.search_recipes( self.searches, sort_by=self.sort_by) ) else: self.update_rmodel(self.rd.fetch_all(self.recipe_table,deleted=False,sort_by=self.sort_by)) def limit_search (self, *args): debug("limit_search (self, *args):",5) self.search() # make sure we've done the search... self.searches.append(self.last_search) last_col = self.last_search['column'] self.srchLimitBar.show() if last_col != _('anywhere'): newtext = ' ' + _('%s in %s')%(self.srchentry.get_text(),last_col) else: newtext = ' ' + self.srchentry.get_text() if self.srchLimitDefaultText!=self.srchLimitLabel.get_text(): newtext = ',' + newtext self.srchLimitText="%s%s"%(self.srchLimitLabel.get_text(),newtext) self.srchLimitLabel.set_markup("<i>%s</i>"%self.srchLimitText) self.srchentry.set_text("") def reset_search (self, *args): debug("reset_search (self, *args):",5) self.srchLimitLabel.set_text(self.srchLimitDefaultText) self.srchLimitText=self.srchLimitDefaultText self.srchLimitBar.hide() self.searches = self.default_searches[0:] self.last_search={} # reset search so we redo it self.search() def get_rec_from_iter (self, iter): debug("get_rec_from_iter (self, iter): %s"%iter,5) obj=self.rectree.get_model().get_value(iter,0) retval=self.rd.get_rec(obj.id) return retval def rtree_time_edited_cb (self, renderer, path_string, text, colnum, attribute): if not text: secs = 0 else: secs = self.rg.conv.timestring_to_seconds(text) if not secs: #self.message(_("Unable to recognize %s as a time."%text)) return indices = path_string.split(':') path = tuple( map(int, indices)) store = self.rectree.get_model() iter = store.get_iter(path) #self.rmodel.set_value(iter,colnum,secs) rec = self.get_rec_from_iter(iter) if convert.seconds_to_timestring(getattr(rec,attribute))!=text: self.rd.undoable_modify_rec(rec, {attribute:secs}, self.history, get_current_rec_method=lambda *args: self.get_selected_recs_from_rec_tree()[0], ) self.update_modified_recipe(rec,attribute,secs) # Is this really stupid? I don't know, but I did it before so # perhaps I had a reason. #self.rmodel.row_changed(path,iter) self.rmodel.update_iter(iter) self.rd.save() def rtree_edited_cb (self, renderer, path_string, text, colnum, attribute): debug("rtree_edited_cb (self, renderer, path_string, text, colnum, attribute):",5) indices = path_string.split(':') path = tuple( map(int, indices)) store = self.rectree.get_model() iter = store.get_iter(path) if not iter: return #self.rmodel.set_value(iter, colnum, text) rec=self.get_rec_from_iter(iter) if attribute=='category': val = ", ".join(self.rd.get_cats(rec)) else: val = "%s"%getattr(rec,attribute) if val!=text: # only bother with this if the value has actually changed! self.rd.undoable_modify_rec(rec, {attribute:text}, self.history, get_current_rec_method=lambda *args: self.get_selected_recs_from_rec_tree()[0], ) self.update_modified_recipe(rec,attribute,text) self.rmodel.update_iter(iter) self.rd.save() def tree_keypress_cb (self, widget, event): keyname = gtk.gdk.keyval_name(event.keyval) if keyname in ['Page_Up','Page_Down']: sb = self.sw.get_vscrollbar() adj = self.sw.get_vscrollbar().get_adjustment() val = adj.get_value(); upper = adj.get_upper() if keyname == 'Page_Up': if val > 0: return None self.rmodel.prev_page() sb.set_value(upper) return True if keyname == 'Page_Down': if val < (upper - adj.page_size): return None self.rmodel.next_page() sb.set_value(0) return True if keyname == 'Home': self.rmodel.goto_first_page() self.sw.get_vscrollbar().set_value(0) return True if keyname == 'End': self.rmodel.goto_last_page() sb = self.sw.get_vscrollbar() sb.set_value(sb.get_adjustment().get_upper()) return True def star_change_cb (self, value, model, treeiter, column_number): #itr = model.convert_iter_to_child_iter(None,treeiter) #self.rmodel.set_value(treeiter,column_number,value) rec = self.get_rec_from_iter(treeiter) if getattr(rec,'rating')!=value: self.rd.undoable_modify_rec( rec, {'rating':value}, self.history, get_current_rec_method = lambda *args: self.get_selected_recs_from_rec_tree()[0], ) #self.rmodel.row_changed(self.rmodel.get_path(treeiter),treeiter) self.rmodel.update_iter(treeiter) def update_modified_recipe(self,rec,attribute,text): """Update a modified recipe. Subclasses can use this to update other widgets duplicating the information in the index view.""" pass def rec_tree_select_rec (self, *args): raise NotImplementedError def get_selected_recs_from_rec_tree (self): debug("get_selected_recs_from_rec_tree (self):",5) def foreach(model,path,iter,recs): debug("foreach(model,path,iter,recs):",5) try: recs.append(model[path][0]) #recs.append(self.get_rec_from_iter(iter)) except: debug("DEBUG: There was a problem with iter: %s path: %s"%(iter,path),1) recs=[] sel = self.rectree.get_selection() if sel: sel.selected_foreach(foreach,recs) return recs else: return [] def selection_changedCB (self, *args): """We pass along true or false to selection_changed to say whether there is a selection or not.""" debug("selection_changed (self, *args):",5) v=self.rectree.get_selection().get_selected_rows()[1] if v: selected=True else: selected=False self.selection_changed(v) def selection_changed (self, selected=False): """This is a way to act whenever the selection changes.""" pass def visibility_fun (self, model, iter): try: if (model.get_value(iter,0) and not model.get_value(iter,0).deleted and model.get_value(iter, 0).id in self.visible): return True else: return False except: debug('something bizaare just happened in visibility_fun',1) return False def update_rmodel (self, recipe_table): self.rmodel.change_view(recipe_table) self.set_reccount() class RecipeModel (pageable_store.PageableViewStore): """A ListStore to hold our recipes in 'pages' so we don't load our whole database at a time. """ per_page = 12 page = 0 columns_and_types = [('rec',gobject.TYPE_PYOBJECT,), ('thumb',gtk.gdk.Pixbuf), ] for n in [r[0] for r in REC_ATTRS]: if n in INT_REC_ATTRS: columns_and_types.append((n,int)) else: columns_and_types.append((n,str)) columns = [c[0] for c in columns_and_types] column_types = [c[1] for c in columns_and_types] def __init__ (self, vw, rd, per_page=None): self.rd = rd pageable_store.PageableViewStore.__init__(self, vw, columns=self.columns, column_types=self.column_types, per_page=per_page) self.made_categories = False def _get_slice_ (self,bottom,top): try: return [[self._get_value_(r,col) for col in self.columns] for r in self.view[bottom:top]] except: print '_get_slice_ failed with',bottom,top raise def _get_value_ (self, row, attr): if attr=='category': cats = self.rd.get_cats(row) if cats: return ", ".join(cats) else: return "" elif attr=='rec': return row elif attr=='thumb': if row.thumb: return get_pixbuf_from_jpg(row.thumb) else: return None elif attr in INT_REC_ATTRS: return getattr(row,attr) or 0 else: val = getattr(row,attr) if val: return str(val) else: return None #else: # # return str(getattr(row,attr)) def update_recipe (self, recipe): """Handed a recipe (or a recipe ID), we update its display if visible.""" debug('Updating recipe %s'%recipe.title,3) if type(recipe)!=int: recipe=recipe.id # make recipe == id for n,row in enumerate(self): debug('Looking at row',3) if row[0].id==recipe: indx = int(n + (self.page * self.per_page)) # update parent self.parent_list[indx] = self.rd.fetch_one(self.rd.recipe_table, id=recipe) # update self self.update_iter(row.iter) debug('updated row -- breaking',3) break
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 6047, 4942, 6360, 492, 664, 63, 25740, 63, 504, 63, 8476, 199, 504, 486, 1757, 492, 3105, 199, 504, 9796, 492, 9796, 465, 5501, 29793, 199, 504, 486, 8473, 492, 19461, 63, 27356, 12, 16429, 63, 9481, 63, 27356, 12, 6186, 63, 40, 22436, 63, 28427, 199, 504, 8116, 63, 9975, 492, 16905, 20829, 12, 18360, 3339, 12, 7434, 63, 9975, 465, 7434, 12, 971, 272, 18250, 16082, 63, 2609, 12, 2034, 461, 63, 1617, 12, 3123, 1345, 63, 9975, 465, 1565, 199, 646, 3957, 199, 646, 738, 21175, 199, 646, 25595, 199, 646, 8116, 199, 646, 8116, 14, 24697, 199, 646, 299, 17771, 199, 199, 533, 799, 67, 2681, 26, 272, 408, 6004, 2429, 314, 283, 1080, 2455, 7, 402, 17121, 83, 12, 1314, 27000, 272, 282, 17121, 1402, 1901, 282, 3123, 436, 6127, 652, 370, 506, 17543, 272, 436, 3355, 14, 2136, 3984, 282, 7396, 1021, 687, 314, 2446, 17121, 272, 2240, 880, 626, 781, 883, 506, 2737, 4020, 334, 69, 14, 71, 14, 315, 314, 6488, 11212, 272, 9592, 2797, 687, 282, 17121, 12564, 1041, 339, 849, 63, 1733, 397, 275, 9016, 2301, 5242, 6062, 1673, 3856, 5242, 29511, 1733, 356, 797, 11049, 2286, 347, 636, 826, 363, 334, 277, 12, 8574, 12, 11517, 12, 23136, 12, 14783, 29, 797, 304, 267, 327, 277, 14, 6604, 275, 413, 327, 883, 4472, 413, 503, 499, 267, 291, 14, 10820, 29, 10820, 267, 291, 14, 5511, 275, 715, 18418, 291, 14, 2591, 4574, 29, 12430, 14, 2591, 4574, 267, 291, 14, 2591, 4574, 5000, 29, 12430, 14, 2591, 4574, 5000, 267, 291, 14, 2591, 19686, 71, 5000, 29, 12430, 14, 2591, 19686, 71, 5000, 267, 291, 14, 17253, 29, 12430, 14, 17253, 267, 291, 14, 1907, 275, 8574, 267, 291, 14, 6883, 275, 11517, 267, 291, 14, 12430, 275, 23136, 267, 291, 14, 1733, 2175, 36, 530, 275, 469, 288, 2649, 6723, 1629, 4509, 8109, 7, 1629, 4509, 297, 288, 2649, 6723, 1213, 8109, 7, 1213, 297, 288, 2649, 6723, 316, 264, 3766, 8109, 7, 316, 264, 3766, 297, 288, 2649, 6723, 20718, 8109, 7, 20718, 297, 288, 2649, 6723, 5983, 8109, 7, 20945, 83, 297, 288, 2649, 6723, 3710, 8109, 7, 3710, 297, 288, 2649, 6723, 15140, 374, 1132, 8109, 7, 15140, 374, 1132, 297, 288, 327, 11252, 10417, 735, 7, 10417, 297, 288, 2649, 6723, 1365, 8109, 7, 1365, 297, 288, 789, 267, 291, 14, 1733, 2175, 1296, 275, 359, 11252, 1629, 4509, 659, 2490, 4018, 1213, 659, 2490, 4018, 316, 264, 3766, 659, 2490, 4018, 3710, 659, 2490, 4018, 15140, 374, 1132, 659, 2490, 327, 11252, 10417, 659, 2490, 4018, 1365, 659, 2490, 4018, 20718, 659, 2490, 4018, 5983, 659, 2490, 1622, 267, 327, 20709, 12, 642, 18277, 10757, 6279, 2072, 1, 267, 327, 277, 14, 15962, 63, 3078, 63, 12511, 275, 469, 267, 327, 259, 298, 84, 582, 14332, 1213, 1288, 267, 327, 259, 298, 73, 582, 14332, 316, 264, 3766, 1288, 267, 327, 259, 298, 67, 582, 14332, 3710, 1288, 267, 327, 259, 298, 85, 582, 14332, 15140, 374, 1132, 1288, 267, 327, 259, 283, 83, 356, 14332, 1365, 1288, 267, 327, 259, 789, 18418, 291, 14, 2758, 63, 1733, 63, 3723, 342, 267, 291, 14, 2758, 63, 8583, 342, 339, 347, 3272, 63, 8583, 334, 277, 304, 267, 291, 14, 5474, 335, 2373, 29, 277, 14, 1907, 14, 362, 63, 785, 360, 82, 513, 5278, 1977, 358, 267, 291, 14, 3097, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 4308, 1123, 4259, 358, 267, 327, 7529, 1133, 327, 2040, 367, 4539, 790, 10880, 267, 327, 277, 14, 5474, 335, 2373, 14, 2242, 360, 498, 63, 2915, 63, 1430, 297, 277, 14, 5474, 335, 2373, 63, 498, 2915, 9956, 9, 18418, 291, 14, 15962, 63, 18223, 63, 3078, 275, 298, 66, 2, 267, 291, 14, 5474, 335, 8407, 5281, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 5281, 358, 267, 702, 8, 277, 14, 5474, 335, 8407, 5281, 9, 267, 291, 14, 5474, 335, 8407, 5281, 14, 8191, 342, 267, 291, 14, 5474, 335, 8407, 4314, 29, 277, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 4314, 358, 267, 291, 14, 5474, 335, 8407, 9721, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 9721, 358, 267, 291, 14, 5474, 335, 8407, 1872, 29, 277, 14, 5474, 335, 8407, 4314, 14, 362, 63, 505, 342, 267, 291, 14, 5474, 335, 8407, 2698, 1872, 29, 277, 14, 5474, 335, 8407, 1872, 267, 291, 14, 1733, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4259, 358, 267, 291, 14, 82, 5278, 2175, 5977, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 82, 513, 5278, 2175, 5977, 358, 267, 7434, 14, 409, 63, 1238, 63, 504, 63, 513, 8, 277, 14, 82, 5278, 2175, 5977, 12, 291, 14, 1733, 2175, 1296, 12, 6544, 29, 797, 9, 267, 7434, 14, 2758, 63, 466, 10938, 8, 277, 14, 82, 5278, 2175, 5977, 9, 267, 291, 14, 82, 5278, 2175, 5977, 14, 409, 63, 2682, 8, 16, 9, 267, 291, 14, 82, 5278, 2175, 5977, 14, 2242, 360, 2489, 297, 277, 14, 1733, 63, 305, 63, 13297, 63, 466, 9, 267, 291, 14, 2231, 337, 52, 974, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 2822, 5556, 804, 24743, 358, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 5278, 2822, 5556, 804, 1959, 2242, 63, 3280, 8, 277, 14, 2231, 337, 52, 974, 9, 267, 291, 14, 11191, 52, 974, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 11191, 52, 974, 358, 267, 291, 14, 1733, 4558, 3532, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4558, 3532, 358, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 6824, 5278, 4558, 1959, 2242, 63, 3280, 8, 288, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4558, 24743, 358, 288, 776, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 8357, 1959, 2242, 63, 3280, 8, 277, 14, 11191, 52, 974, 9, 267, 291 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 6047, 4942, 6360, 492, 664, 63, 25740, 63, 504, 63, 8476, 199, 504, 486, 1757, 492, 3105, 199, 504, 9796, 492, 9796, 465, 5501, 29793, 199, 504, 486, 8473, 492, 19461, 63, 27356, 12, 16429, 63, 9481, 63, 27356, 12, 6186, 63, 40, 22436, 63, 28427, 199, 504, 8116, 63, 9975, 492, 16905, 20829, 12, 18360, 3339, 12, 7434, 63, 9975, 465, 7434, 12, 971, 272, 18250, 16082, 63, 2609, 12, 2034, 461, 63, 1617, 12, 3123, 1345, 63, 9975, 465, 1565, 199, 646, 3957, 199, 646, 738, 21175, 199, 646, 25595, 199, 646, 8116, 199, 646, 8116, 14, 24697, 199, 646, 299, 17771, 199, 199, 533, 799, 67, 2681, 26, 272, 408, 6004, 2429, 314, 283, 1080, 2455, 7, 402, 17121, 83, 12, 1314, 27000, 272, 282, 17121, 1402, 1901, 282, 3123, 436, 6127, 652, 370, 506, 17543, 272, 436, 3355, 14, 2136, 3984, 282, 7396, 1021, 687, 314, 2446, 17121, 272, 2240, 880, 626, 781, 883, 506, 2737, 4020, 334, 69, 14, 71, 14, 315, 314, 6488, 11212, 272, 9592, 2797, 687, 282, 17121, 12564, 1041, 339, 849, 63, 1733, 397, 275, 9016, 2301, 5242, 6062, 1673, 3856, 5242, 29511, 1733, 356, 797, 11049, 2286, 347, 636, 826, 363, 334, 277, 12, 8574, 12, 11517, 12, 23136, 12, 14783, 29, 797, 304, 267, 327, 277, 14, 6604, 275, 413, 327, 883, 4472, 413, 503, 499, 267, 291, 14, 10820, 29, 10820, 267, 291, 14, 5511, 275, 715, 18418, 291, 14, 2591, 4574, 29, 12430, 14, 2591, 4574, 267, 291, 14, 2591, 4574, 5000, 29, 12430, 14, 2591, 4574, 5000, 267, 291, 14, 2591, 19686, 71, 5000, 29, 12430, 14, 2591, 19686, 71, 5000, 267, 291, 14, 17253, 29, 12430, 14, 17253, 267, 291, 14, 1907, 275, 8574, 267, 291, 14, 6883, 275, 11517, 267, 291, 14, 12430, 275, 23136, 267, 291, 14, 1733, 2175, 36, 530, 275, 469, 288, 2649, 6723, 1629, 4509, 8109, 7, 1629, 4509, 297, 288, 2649, 6723, 1213, 8109, 7, 1213, 297, 288, 2649, 6723, 316, 264, 3766, 8109, 7, 316, 264, 3766, 297, 288, 2649, 6723, 20718, 8109, 7, 20718, 297, 288, 2649, 6723, 5983, 8109, 7, 20945, 83, 297, 288, 2649, 6723, 3710, 8109, 7, 3710, 297, 288, 2649, 6723, 15140, 374, 1132, 8109, 7, 15140, 374, 1132, 297, 288, 327, 11252, 10417, 735, 7, 10417, 297, 288, 2649, 6723, 1365, 8109, 7, 1365, 297, 288, 789, 267, 291, 14, 1733, 2175, 1296, 275, 359, 11252, 1629, 4509, 659, 2490, 4018, 1213, 659, 2490, 4018, 316, 264, 3766, 659, 2490, 4018, 3710, 659, 2490, 4018, 15140, 374, 1132, 659, 2490, 327, 11252, 10417, 659, 2490, 4018, 1365, 659, 2490, 4018, 20718, 659, 2490, 4018, 5983, 659, 2490, 1622, 267, 327, 20709, 12, 642, 18277, 10757, 6279, 2072, 1, 267, 327, 277, 14, 15962, 63, 3078, 63, 12511, 275, 469, 267, 327, 259, 298, 84, 582, 14332, 1213, 1288, 267, 327, 259, 298, 73, 582, 14332, 316, 264, 3766, 1288, 267, 327, 259, 298, 67, 582, 14332, 3710, 1288, 267, 327, 259, 298, 85, 582, 14332, 15140, 374, 1132, 1288, 267, 327, 259, 283, 83, 356, 14332, 1365, 1288, 267, 327, 259, 789, 18418, 291, 14, 2758, 63, 1733, 63, 3723, 342, 267, 291, 14, 2758, 63, 8583, 342, 339, 347, 3272, 63, 8583, 334, 277, 304, 267, 291, 14, 5474, 335, 2373, 29, 277, 14, 1907, 14, 362, 63, 785, 360, 82, 513, 5278, 1977, 358, 267, 291, 14, 3097, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 4308, 1123, 4259, 358, 267, 327, 7529, 1133, 327, 2040, 367, 4539, 790, 10880, 267, 327, 277, 14, 5474, 335, 2373, 14, 2242, 360, 498, 63, 2915, 63, 1430, 297, 277, 14, 5474, 335, 2373, 63, 498, 2915, 9956, 9, 18418, 291, 14, 15962, 63, 18223, 63, 3078, 275, 298, 66, 2, 267, 291, 14, 5474, 335, 8407, 5281, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 5281, 358, 267, 702, 8, 277, 14, 5474, 335, 8407, 5281, 9, 267, 291, 14, 5474, 335, 8407, 5281, 14, 8191, 342, 267, 291, 14, 5474, 335, 8407, 4314, 29, 277, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 4314, 358, 267, 291, 14, 5474, 335, 8407, 9721, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 5474, 335, 8407, 9721, 358, 267, 291, 14, 5474, 335, 8407, 1872, 29, 277, 14, 5474, 335, 8407, 4314, 14, 362, 63, 505, 342, 267, 291, 14, 5474, 335, 8407, 2698, 1872, 29, 277, 14, 5474, 335, 8407, 1872, 267, 291, 14, 1733, 4259, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4259, 358, 267, 291, 14, 82, 5278, 2175, 5977, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 82, 513, 5278, 2175, 5977, 358, 267, 7434, 14, 409, 63, 1238, 63, 504, 63, 513, 8, 277, 14, 82, 5278, 2175, 5977, 12, 291, 14, 1733, 2175, 1296, 12, 6544, 29, 797, 9, 267, 7434, 14, 2758, 63, 466, 10938, 8, 277, 14, 82, 5278, 2175, 5977, 9, 267, 291, 14, 82, 5278, 2175, 5977, 14, 409, 63, 2682, 8, 16, 9, 267, 291, 14, 82, 5278, 2175, 5977, 14, 2242, 360, 2489, 297, 277, 14, 1733, 63, 305, 63, 13297, 63, 466, 9, 267, 291, 14, 2231, 337, 52, 974, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 2822, 5556, 804, 24743, 358, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 5278, 2822, 5556, 804, 1959, 2242, 63, 3280, 8, 277, 14, 2231, 337, 52, 974, 9, 267, 291, 14, 11191, 52, 974, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 11191, 52, 974, 358, 267, 291, 14, 1733, 4558, 3532, 275, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4558, 3532, 358, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 6824, 5278, 4558, 1959, 2242, 63, 3280, 8, 288, 291, 14, 1907, 14, 362, 63, 785, 360, 1733, 4558, 24743, 358, 288, 776, 267, 291, 14, 1733, 63, 3723, 14, 362, 63, 1287, 360, 13396, 8357, 1959, 2242, 63, 3280, 8, 277, 14, 11191, 52, 974, 9, 267, 291, 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,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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 ]
mohamedhagag/connector
connector/unit/synchronizer.py
18
3407
# -*- coding: utf-8 -*- ############################################################################## # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from ..connector import ConnectorUnit from .mapper import Mapper, ImportMapper, ExportMapper from .backend_adapter import BackendAdapter class Synchronizer(ConnectorUnit): """ Base class for synchronizers """ # implement in sub-classes _model_name = None _base_mapper = Mapper _base_backend_adapter = BackendAdapter def __init__(self, connector_env): super(Synchronizer, self).__init__(connector_env) self._backend_adapter = None self._binder = None self._mapper = None def run(self): """ Run the synchronization """ raise NotImplementedError @property def mapper(self): """ Return an instance of ``Mapper`` for the synchronization. The instanciation is delayed because some synchronisations do not need such an unit and the unit may not exist. :rtype: :py:class:`connector.unit.mapper.Mapper` """ if self._mapper is None: self._mapper = self.unit_for(self._base_mapper) return self._mapper @property def binder(self): """ Return an instance of ``Binder`` for the synchronization. The instanciation is delayed because some synchronisations do not need such an unit and the unit may not exist. :rtype: :py:class:`connector.unit.binder.Binder` """ if self._binder is None: self._binder = self.binder_for() return self._binder @property def backend_adapter(self): """ Return an instance of ``BackendAdapter`` for the synchronization. The instanciation is delayed because some synchronisations do not need such an unit and the unit may not exist. :rtype: :py:class:`connector.unit.backend_adapter.BackendAdapter` """ if self._backend_adapter is None: self._backend_adapter = self.unit_for(self._base_backend_adapter) return self._backend_adapter class Exporter(Synchronizer): """ Synchronizer for exporting data from OpenERP to a backend """ _base_mapper = ExportMapper ExportSynchronizer = Exporter # deprecated class Importer(Synchronizer): """ Synchronizer for importing data from a backend to OpenERP """ _base_mapper = ImportMapper ImportSynchronizer = Importer # deprecated class Deleter(Synchronizer): """ Synchronizer for deleting a record on the backend """ DeleteSynchronizer = Deleter # deprecated
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 6529, 26, 598, 310, 87, 287, 699, 65, 1631, 4446, 199, 3, 259, 1898, 6171, 24569, 475, 20290, 13950, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2508, 11815, 492, 13482, 2406, 5072, 199, 504, 1275, 7153, 492, 9672, 529, 12, 3161, 11880, 12, 20220, 11880, 199, 504, 1275, 4620, 63, 10394, 492, 25674, 10200, 421, 199, 533, 428, 6030, 1793, 8, 20476, 5072, 304, 272, 408, 3523, 1021, 367, 15354, 6315, 408, 339, 327, 5669, 315, 1007, 13, 2888, 272, 485, 1238, 63, 354, 275, 488, 339, 485, 1095, 63, 7153, 275, 9672, 529, 272, 485, 1095, 63, 4620, 63, 10394, 275, 25674, 10200, 339, 347, 636, 826, 721, 277, 12, 13252, 63, 1813, 304, 267, 1613, 8, 21814, 1793, 12, 291, 2843, 826, 721, 11815, 63, 1813, 9, 267, 291, 423, 4620, 63, 10394, 275, 488, 267, 291, 423, 1393, 424, 275, 488, 267, 291, 423, 7153, 275, 488, 339, 347, 1255, 8, 277, 304, 267, 408, 3378, 314, 29509, 408, 267, 746, 4279, 339, 768, 1829, 272, 347, 7796, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 11880, 1040, 367, 314, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 7153, 14, 11880, 64, 267, 408, 267, 340, 291, 423, 7153, 365, 488, 26, 288, 291, 423, 7153, 275, 291, 14, 3248, 63, 509, 8, 277, 423, 1095, 63, 7153, 9, 267, 372, 291, 423, 7153, 339, 768, 1829, 272, 347, 2517, 424, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 34, 5755, 1040, 367, 314, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 1393, 424, 14, 34, 5755, 64, 267, 408, 267, 340, 291, 423, 1393, 424, 365, 488, 26, 288, 291, 423, 1393, 424, 275, 291, 14, 1393, 424, 63, 509, 342, 267, 372, 291, 423, 1393, 424, 339, 768, 1829, 272, 347, 4865, 63, 10394, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 8447, 10200, 1040, 367, 314, 267, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 4620, 63, 10394, 14, 8447, 10200, 64, 267, 408, 267, 340, 291, 423, 4620, 63, 10394, 365, 488, 26, 288, 291, 423, 4620, 63, 10394, 275, 291, 14, 3248, 63, 509, 8, 277, 423, 1095, 63, 4620, 63, 10394, 9, 267, 372, 291, 423, 4620, 63, 10394, 421, 199, 533, 7910, 3968, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 4843, 316, 666, 687, 7653, 370, 282, 4865, 408, 339, 485, 1095, 63, 7153, 275, 20220, 11880, 421, 199, 11399, 21814, 1793, 275, 7910, 3968, 221, 327, 5906, 421, 199, 533, 8362, 3968, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 16306, 666, 687, 282, 4865, 370, 7653, 408, 339, 485, 1095, 63, 7153, 275, 3161, 11880, 421, 199, 6295, 21814, 1793, 275, 8362, 3968, 221, 327, 5906, 421, 199, 533, 12035, 351, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 13794, 282, 2777, 641, 314, 4865, 408, 421, 199, 5392, 21814, 1793, 275, 12035, 351, 221, 327, 5906, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 6529, 26, 598, 310, 87, 287, 699, 65, 1631, 4446, 199, 3, 259, 1898, 6171, 24569, 475, 20290, 13950, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2508, 11815, 492, 13482, 2406, 5072, 199, 504, 1275, 7153, 492, 9672, 529, 12, 3161, 11880, 12, 20220, 11880, 199, 504, 1275, 4620, 63, 10394, 492, 25674, 10200, 421, 199, 533, 428, 6030, 1793, 8, 20476, 5072, 304, 272, 408, 3523, 1021, 367, 15354, 6315, 408, 339, 327, 5669, 315, 1007, 13, 2888, 272, 485, 1238, 63, 354, 275, 488, 339, 485, 1095, 63, 7153, 275, 9672, 529, 272, 485, 1095, 63, 4620, 63, 10394, 275, 25674, 10200, 339, 347, 636, 826, 721, 277, 12, 13252, 63, 1813, 304, 267, 1613, 8, 21814, 1793, 12, 291, 2843, 826, 721, 11815, 63, 1813, 9, 267, 291, 423, 4620, 63, 10394, 275, 488, 267, 291, 423, 1393, 424, 275, 488, 267, 291, 423, 7153, 275, 488, 339, 347, 1255, 8, 277, 304, 267, 408, 3378, 314, 29509, 408, 267, 746, 4279, 339, 768, 1829, 272, 347, 7796, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 11880, 1040, 367, 314, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 7153, 14, 11880, 64, 267, 408, 267, 340, 291, 423, 7153, 365, 488, 26, 288, 291, 423, 7153, 275, 291, 14, 3248, 63, 509, 8, 277, 423, 1095, 63, 7153, 9, 267, 372, 291, 423, 7153, 339, 768, 1829, 272, 347, 2517, 424, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 34, 5755, 1040, 367, 314, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 1393, 424, 14, 34, 5755, 64, 267, 408, 267, 340, 291, 423, 1393, 424, 365, 488, 26, 288, 291, 423, 1393, 424, 275, 291, 14, 1393, 424, 63, 509, 342, 267, 372, 291, 423, 1393, 424, 339, 768, 1829, 272, 347, 4865, 63, 10394, 8, 277, 304, 267, 408, 1432, 376, 1256, 402, 1124, 8447, 10200, 1040, 367, 314, 267, 29509, 14, 398, 710, 2727, 290, 559, 425, 365, 24725, 2952, 2005, 15354, 374, 1298, 886, 267, 440, 1929, 4066, 376, 4137, 436, 314, 4137, 1443, 440, 2187, 14, 398, 520, 4500, 26, 520, 647, 26, 533, 1705, 11815, 14, 3248, 14, 4620, 63, 10394, 14, 8447, 10200, 64, 267, 408, 267, 340, 291, 423, 4620, 63, 10394, 365, 488, 26, 288, 291, 423, 4620, 63, 10394, 275, 291, 14, 3248, 63, 509, 8, 277, 423, 1095, 63, 4620, 63, 10394, 9, 267, 372, 291, 423, 4620, 63, 10394, 421, 199, 533, 7910, 3968, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 4843, 316, 666, 687, 7653, 370, 282, 4865, 408, 339, 485, 1095, 63, 7153, 275, 20220, 11880, 421, 199, 11399, 21814, 1793, 275, 7910, 3968, 221, 327, 5906, 421, 199, 533, 8362, 3968, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 16306, 666, 687, 282, 4865, 370, 7653, 408, 339, 485, 1095, 63, 7153, 275, 3161, 11880, 421, 199, 6295, 21814, 1793, 275, 8362, 3968, 221, 327, 5906, 421, 199, 533, 12035, 351, 8, 21814, 1793, 304, 272, 408, 428, 6030, 1793, 367, 13794, 282, 2777, 641, 314, 4865, 408, 421, 199, 5392, 21814, 1793, 275, 12035, 351, 221, 327, 5906, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
paris-saclay-cds/ramp-workflow
rampwf/score_types/soft_accuracy.py
1
1665
"""A generalization of the classification accuracy with cross-class scores. Soften the accuracy score by giving scores through certain misclassifications defined by the score matrix. For example, in ordinal regression we may want not to penalize too much misclassifications to neighbor classes. The score also generalizes RMSE-like regression scores for ordinal regression (when true and predicted output levels are coming from a fixed set) by allowing to define arbitrary misclassification scores. """ from __future__ import division import numpy as np from .base import BaseScoreType class SoftAccuracy(BaseScoreType): is_lower_the_better = False minimum = 0.0 def __init__(self, score_matrix, name='soft precision', precision=2): self.name = name self.precision = precision self.maximum = np.max(score_matrix) self.score_matrix = score_matrix def __call__(self, y_true_proba, y_proba): # Clip negative probas y_proba_positive = np.clip(y_proba, 0, 1) # normalize rows y_proba_normalized = y_proba_positive / np.sum( y_proba_positive, axis=1, keepdims=True) # Smooth true probabilities with score_matrix y_true_smoothed = y_true_proba.dot(self.score_matrix) # Compute dot product between the predicted probabilities and # the smoothed true "probabilites" ("" because it does not sum to 1) scores = np.sum(y_proba_normalized * y_true_smoothed, axis=1) scores = np.nan_to_num(scores) score = np.mean(scores) # to pick up all zero probabilities score = np.nan_to_num(score) return score
bsd-3-clause
[ 624, 33, 8605, 2072, 402, 314, 12505, 12862, 543, 8059, 13, 533, 9342, 14, 199, 199, 51, 1618, 724, 314, 12862, 5396, 701, 15131, 9342, 4012, 9842, 3201, 14368, 83, 199, 4037, 701, 314, 5396, 3634, 14, 2104, 2893, 12, 315, 24943, 10864, 781, 1443, 2934, 199, 1397, 370, 12374, 279, 794, 4634, 8298, 3201, 14368, 83, 370, 15503, 3992, 14, 710, 5396, 2597, 199, 10706, 6491, 820, 45, 899, 13, 2930, 10864, 9342, 367, 24943, 10864, 334, 6526, 2549, 436, 199, 21118, 1072, 11106, 787, 17262, 687, 282, 6317, 663, 9, 701, 17266, 370, 5627, 199, 285, 8734, 3201, 14368, 9342, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 504, 1275, 1095, 492, 3523, 12642, 804, 421, 199, 533, 27238, 1945, 7933, 8, 1563, 12642, 804, 304, 272, 365, 63, 2325, 63, 1589, 63, 9549, 351, 275, 756, 272, 7481, 275, 378, 14, 16, 339, 347, 636, 826, 721, 277, 12, 5396, 63, 3642, 12, 536, 534, 4617, 7151, 297, 7151, 29, 18, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 6833, 275, 7151, 267, 291, 14, 11555, 275, 980, 14, 988, 8, 3397, 63, 3642, 9, 267, 291, 14, 3397, 63, 3642, 275, 5396, 63, 3642, 339, 347, 636, 1250, 721, 277, 12, 612, 63, 2052, 63, 14417, 12, 612, 63, 14417, 304, 267, 327, 445, 3587, 6946, 5128, 305, 267, 612, 63, 14417, 63, 8965, 275, 980, 14, 7548, 8, 89, 63, 14417, 12, 378, 12, 413, 9, 267, 327, 7666, 4730, 267, 612, 63, 14417, 63, 12916, 275, 612, 63, 14417, 63, 8965, 1182, 980, 14, 1838, 8, 288, 612, 63, 14417, 63, 8965, 12, 3114, 29, 17, 12, 18492, 29, 549, 9, 267, 327, 428, 11607, 2549, 19555, 543, 5396, 63, 3642, 267, 612, 63, 2052, 63, 19169, 379, 275, 612, 63, 2052, 63, 14417, 14, 3287, 8, 277, 14, 3397, 63, 3642, 9, 267, 327, 8354, 6308, 3336, 3382, 314, 14746, 19555, 436, 267, 327, 314, 19608, 379, 2549, 298, 6101, 25007, 744, 2, 334, 341, 2952, 652, 1630, 440, 3089, 370, 413, 9, 267, 9342, 275, 980, 14, 1838, 8, 89, 63, 14417, 63, 12916, 627, 612, 63, 2052, 63, 19169, 379, 12, 3114, 29, 17, 9, 267, 9342, 275, 980, 14, 4304, 63, 475, 63, 1507, 8, 7107, 9, 267, 5396, 275, 980, 14, 3670, 8, 7107, 9, 267, 327, 370, 3732, 1536, 1006, 4697, 19555, 267, 5396, 275, 980, 14, 4304, 63, 475, 63, 1507, 8, 3397, 9, 267, 372, 5396, 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 ]
[ 33, 8605, 2072, 402, 314, 12505, 12862, 543, 8059, 13, 533, 9342, 14, 199, 199, 51, 1618, 724, 314, 12862, 5396, 701, 15131, 9342, 4012, 9842, 3201, 14368, 83, 199, 4037, 701, 314, 5396, 3634, 14, 2104, 2893, 12, 315, 24943, 10864, 781, 1443, 2934, 199, 1397, 370, 12374, 279, 794, 4634, 8298, 3201, 14368, 83, 370, 15503, 3992, 14, 710, 5396, 2597, 199, 10706, 6491, 820, 45, 899, 13, 2930, 10864, 9342, 367, 24943, 10864, 334, 6526, 2549, 436, 199, 21118, 1072, 11106, 787, 17262, 687, 282, 6317, 663, 9, 701, 17266, 370, 5627, 199, 285, 8734, 3201, 14368, 9342, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 504, 1275, 1095, 492, 3523, 12642, 804, 421, 199, 533, 27238, 1945, 7933, 8, 1563, 12642, 804, 304, 272, 365, 63, 2325, 63, 1589, 63, 9549, 351, 275, 756, 272, 7481, 275, 378, 14, 16, 339, 347, 636, 826, 721, 277, 12, 5396, 63, 3642, 12, 536, 534, 4617, 7151, 297, 7151, 29, 18, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 6833, 275, 7151, 267, 291, 14, 11555, 275, 980, 14, 988, 8, 3397, 63, 3642, 9, 267, 291, 14, 3397, 63, 3642, 275, 5396, 63, 3642, 339, 347, 636, 1250, 721, 277, 12, 612, 63, 2052, 63, 14417, 12, 612, 63, 14417, 304, 267, 327, 445, 3587, 6946, 5128, 305, 267, 612, 63, 14417, 63, 8965, 275, 980, 14, 7548, 8, 89, 63, 14417, 12, 378, 12, 413, 9, 267, 327, 7666, 4730, 267, 612, 63, 14417, 63, 12916, 275, 612, 63, 14417, 63, 8965, 1182, 980, 14, 1838, 8, 288, 612, 63, 14417, 63, 8965, 12, 3114, 29, 17, 12, 18492, 29, 549, 9, 267, 327, 428, 11607, 2549, 19555, 543, 5396, 63, 3642, 267, 612, 63, 2052, 63, 19169, 379, 275, 612, 63, 2052, 63, 14417, 14, 3287, 8, 277, 14, 3397, 63, 3642, 9, 267, 327, 8354, 6308, 3336, 3382, 314, 14746, 19555, 436, 267, 327, 314, 19608, 379, 2549, 298, 6101, 25007, 744, 2, 334, 341, 2952, 652, 1630, 440, 3089, 370, 413, 9, 267, 9342, 275, 980, 14, 1838, 8, 89, 63, 14417, 63, 12916, 627, 612, 63, 2052, 63, 19169, 379, 12, 3114, 29, 17, 9, 267, 9342, 275, 980, 14, 4304, 63, 475, 63, 1507, 8, 7107, 9, 267, 5396, 275, 980, 14, 3670, 8, 7107, 9, 267, 327, 370, 3732, 1536, 1006, 4697, 19555, 267, 5396, 275, 980, 14, 4304, 63, 475, 63, 1507, 8, 3397, 9, 267, 372, 5396, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GinnyN/Team-Fortress-RPG-Generators
django/core/management/commands/startproject.py
201
1323
from django.core.management.base import CommandError from django.core.management.templates import TemplateCommand from django.utils.crypto import get_random_string from django.utils.importlib import import_module class Command(TemplateCommand): help = ("Creates a Django project directory structure for the given " "project name in the current directory or optionally in the " "given directory.") def handle(self, project_name=None, target=None, *args, **options): if project_name is None: raise CommandError("you must provide a project name") # Check that the project_name cannot be imported. try: import_module(project_name) except ImportError: pass else: raise CommandError("%r conflicts with the name of an existing " "Python module and cannot be used as a " "project name. Please try another name." % project_name) # Create a random SECRET_KEY hash to put it in the main settings. chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' options['secret_key'] = get_random_string(50, chars) super(Command, self).handle('project', project_name, target, **options)
bsd-3-clause
[ 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 14393, 199, 504, 1639, 14, 1018, 14, 8110, 14, 5876, 492, 5458, 3110, 199, 504, 1639, 14, 1208, 14, 10316, 492, 664, 63, 2355, 63, 875, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 421, 199, 533, 5817, 8, 4231, 3110, 304, 272, 1720, 275, 1689, 10607, 282, 5634, 2199, 2082, 5523, 367, 314, 1627, 298, 288, 298, 1715, 536, 315, 314, 1453, 2082, 503, 14190, 315, 314, 298, 288, 298, 11809, 2082, 2685, 339, 347, 2429, 8, 277, 12, 2199, 63, 354, 29, 403, 12, 1347, 29, 403, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 2199, 63, 354, 365, 488, 26, 288, 746, 14393, 480, 13297, 1471, 5647, 282, 2199, 536, 531, 398, 327, 2670, 626, 314, 2199, 63, 354, 3913, 506, 8439, 14, 267, 862, 26, 288, 492, 63, 578, 8, 1715, 63, 354, 9, 267, 871, 3545, 26, 288, 986, 267, 587, 26, 288, 746, 14393, 3647, 82, 18511, 543, 314, 536, 402, 376, 3411, 298, 3044, 298, 4718, 859, 436, 3913, 506, 1202, 465, 282, 298, 3044, 298, 1715, 536, 14, 7754, 862, 4573, 536, 2122, 450, 3044, 2199, 63, 354, 9, 398, 327, 2790, 282, 2196, 5795, 11771, 63, 3078, 2631, 370, 5324, 652, 315, 314, 2446, 2202, 14, 267, 8365, 275, 283, 23459, 11371, 1, 32, 3, 22074, 62, 6, 27436, 10683, 29600, 267, 1511, 459, 4731, 63, 498, 418, 275, 664, 63, 2355, 63, 875, 8, 1400, 12, 8365, 9, 398, 1613, 8, 3110, 12, 291, 680, 2479, 360, 1715, 297, 2199, 63, 354, 12, 1347, 12, 1011, 1419, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14, 8110, 14, 1095, 492, 14393, 199, 504, 1639, 14, 1018, 14, 8110, 14, 5876, 492, 5458, 3110, 199, 504, 1639, 14, 1208, 14, 10316, 492, 664, 63, 2355, 63, 875, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 421, 199, 533, 5817, 8, 4231, 3110, 304, 272, 1720, 275, 1689, 10607, 282, 5634, 2199, 2082, 5523, 367, 314, 1627, 298, 288, 298, 1715, 536, 315, 314, 1453, 2082, 503, 14190, 315, 314, 298, 288, 298, 11809, 2082, 2685, 339, 347, 2429, 8, 277, 12, 2199, 63, 354, 29, 403, 12, 1347, 29, 403, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 2199, 63, 354, 365, 488, 26, 288, 746, 14393, 480, 13297, 1471, 5647, 282, 2199, 536, 531, 398, 327, 2670, 626, 314, 2199, 63, 354, 3913, 506, 8439, 14, 267, 862, 26, 288, 492, 63, 578, 8, 1715, 63, 354, 9, 267, 871, 3545, 26, 288, 986, 267, 587, 26, 288, 746, 14393, 3647, 82, 18511, 543, 314, 536, 402, 376, 3411, 298, 3044, 298, 4718, 859, 436, 3913, 506, 1202, 465, 282, 298, 3044, 298, 1715, 536, 14, 7754, 862, 4573, 536, 2122, 450, 3044, 2199, 63, 354, 9, 398, 327, 2790, 282, 2196, 5795, 11771, 63, 3078, 2631, 370, 5324, 652, 315, 314, 2446, 2202, 14, 267, 8365, 275, 283, 23459, 11371, 1, 32, 3, 22074, 62, 6, 27436, 10683, 29600, 267, 1511, 459, 4731, 63, 498, 418, 275, 664, 63, 2355, 63, 875, 8, 1400, 12, 8365, 9, 398, 1613, 8, 3110, 12, 291, 680, 2479, 360, 1715, 297, 2199, 63, 354, 12, 1347, 12, 1011, 1419, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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', # 0x03 'byuss', # 0x04 'byung', # 0x05 'byuj', # 0x06 'byuc', # 0x07 'byuk', # 0x08 'byut', # 0x09 'byup', # 0x0a 'byuh', # 0x0b 'beu', # 0x0c 'beug', # 0x0d 'beugg', # 0x0e 'beugs', # 0x0f 'beun', # 0x10 'beunj', # 0x11 'beunh', # 0x12 'beud', # 0x13 'beul', # 0x14 'beulg', # 0x15 'beulm', # 0x16 'beulb', # 0x17 'beuls', # 0x18 'beult', # 0x19 'beulp', # 0x1a 'beulh', # 0x1b 'beum', # 0x1c 'beub', # 0x1d 'beubs', # 0x1e 'beus', # 0x1f 'beuss', # 0x20 'beung', # 0x21 'beuj', # 0x22 'beuc', # 0x23 'beuk', # 0x24 'beut', # 0x25 'beup', # 0x26 'beuh', # 0x27 'byi', # 0x28 'byig', # 0x29 'byigg', # 0x2a 'byigs', # 0x2b 'byin', # 0x2c 'byinj', # 0x2d 'byinh', # 0x2e 'byid', # 0x2f 'byil', # 0x30 'byilg', # 0x31 'byilm', # 0x32 'byilb', # 0x33 'byils', # 0x34 'byilt', # 0x35 'byilp', # 0x36 'byilh', # 0x37 'byim', # 0x38 'byib', # 0x39 'byibs', # 0x3a 'byis', # 0x3b 'byiss', # 0x3c 'bying', # 0x3d 'byij', # 0x3e 'byic', # 0x3f 'byik', # 0x40 'byit', # 0x41 'byip', # 0x42 'byih', # 0x43 'bi', # 0x44 'big', # 0x45 'bigg', # 0x46 'bigs', # 0x47 'bin', # 0x48 'binj', # 0x49 'binh', # 0x4a 'bid', # 0x4b 'bil', # 0x4c 'bilg', # 0x4d 'bilm', # 0x4e 'bilb', # 0x4f 'bils', # 0x50 'bilt', # 0x51 'bilp', # 0x52 'bilh', # 0x53 'bim', # 0x54 'bib', # 0x55 'bibs', # 0x56 'bis', # 0x57 'biss', # 0x58 'bing', # 0x59 'bij', # 0x5a 'bic', # 0x5b 'bik', # 0x5c 'bit', # 0x5d 'bip', # 0x5e 'bih', # 0x5f 'bba', # 0x60 'bbag', # 0x61 'bbagg', # 0x62 'bbags', # 0x63 'bban', # 0x64 'bbanj', # 0x65 'bbanh', # 0x66 'bbad', # 0x67 'bbal', # 0x68 'bbalg', # 0x69 'bbalm', # 0x6a 'bbalb', # 0x6b 'bbals', # 0x6c 'bbalt', # 0x6d 'bbalp', # 0x6e 'bbalh', # 0x6f 'bbam', # 0x70 'bbab', # 0x71 'bbabs', # 0x72 'bbas', # 0x73 'bbass', # 0x74 'bbang', # 0x75 'bbaj', # 0x76 'bbac', # 0x77 'bbak', # 0x78 'bbat', # 0x79 'bbap', # 0x7a 'bbah', # 0x7b 'bbae', # 0x7c 'bbaeg', # 0x7d 'bbaegg', # 0x7e 'bbaegs', # 0x7f 'bbaen', # 0x80 'bbaenj', # 0x81 'bbaenh', # 0x82 'bbaed', # 0x83 'bbael', # 0x84 'bbaelg', # 0x85 'bbaelm', # 0x86 'bbaelb', # 0x87 'bbaels', # 0x88 'bbaelt', # 0x89 'bbaelp', # 0x8a 'bbaelh', # 0x8b 'bbaem', # 0x8c 'bbaeb', # 0x8d 'bbaebs', # 0x8e 'bbaes', # 0x8f 'bbaess', # 0x90 'bbaeng', # 0x91 'bbaej', # 0x92 'bbaec', # 0x93 'bbaek', # 0x94 'bbaet', # 0x95 'bbaep', # 0x96 'bbaeh', # 0x97 'bbya', # 0x98 'bbyag', # 0x99 'bbyagg', # 0x9a 'bbyags', # 0x9b 'bbyan', # 0x9c 'bbyanj', # 0x9d 'bbyanh', # 0x9e 'bbyad', # 0x9f 'bbyal', # 0xa0 'bbyalg', # 0xa1 'bbyalm', # 0xa2 'bbyalb', # 0xa3 'bbyals', # 0xa4 'bbyalt', # 0xa5 'bbyalp', # 0xa6 'bbyalh', # 0xa7 'bbyam', # 0xa8 'bbyab', # 0xa9 'bbyabs', # 0xaa 'bbyas', # 0xab 'bbyass', # 0xac 'bbyang', # 0xad 'bbyaj', # 0xae 'bbyac', # 0xaf 'bbyak', # 0xb0 'bbyat', # 0xb1 'bbyap', # 0xb2 'bbyah', # 0xb3 'bbyae', # 0xb4 'bbyaeg', # 0xb5 'bbyaegg', # 0xb6 'bbyaegs', # 0xb7 'bbyaen', # 0xb8 'bbyaenj', # 0xb9 'bbyaenh', # 0xba 'bbyaed', # 0xbb 'bbyael', # 0xbc 'bbyaelg', # 0xbd 'bbyaelm', # 0xbe 'bbyaelb', # 0xbf 'bbyaels', # 0xc0 'bbyaelt', # 0xc1 'bbyaelp', # 0xc2 'bbyaelh', # 0xc3 'bbyaem', # 0xc4 'bbyaeb', # 0xc5 'bbyaebs', # 0xc6 'bbyaes', # 0xc7 'bbyaess', # 0xc8 'bbyaeng', # 0xc9 'bbyaej', # 0xca 'bbyaec', # 0xcb 'bbyaek', # 0xcc 'bbyaet', # 0xcd 'bbyaep', # 0xce 'bbyaeh', # 0xcf 'bbeo', # 0xd0 'bbeog', # 0xd1 'bbeogg', # 0xd2 'bbeogs', # 0xd3 'bbeon', # 0xd4 'bbeonj', # 0xd5 'bbeonh', # 0xd6 'bbeod', # 0xd7 'bbeol', # 0xd8 'bbeolg', # 0xd9 'bbeolm', # 0xda 'bbeolb', # 0xdb 'bbeols', # 0xdc 'bbeolt', # 0xdd 'bbeolp', # 0xde 'bbeolh', # 0xdf 'bbeom', # 0xe0 'bbeob', # 0xe1 'bbeobs', # 0xe2 'bbeos', # 0xe3 'bbeoss', # 0xe4 'bbeong', # 0xe5 'bbeoj', # 0xe6 'bbeoc', # 0xe7 'bbeok', # 0xe8 'bbeot', # 0xe9 'bbeop', # 0xea 'bbeoh', # 0xeb 'bbe', # 0xec 'bbeg', # 0xed 'bbegg', # 0xee 'bbegs', # 0xef 'bben', # 0xf0 'bbenj', # 0xf1 'bbenh', # 0xf2 'bbed', # 0xf3 'bbel', # 0xf4 'bbelg', # 0xf5 'bbelm', # 0xf6 'bbelb', # 0xf7 'bbels', # 0xf8 'bbelt', # 0xf9 'bbelp', # 0xfa 'bbelh', # 0xfb 'bbem', # 0xfc 'bbeb', # 0xfd 'bbebs', # 0xfe 'bbes', # 0xff )
gpl-3.0
[ 576, 275, 334, 199, 7, 991, 453, 297, 259, 327, 378, 88, 383, 199, 7, 991, 456, 297, 259, 327, 378, 88, 614, 199, 7, 991, 30327, 297, 259, 327, 378, 88, 996, 199, 7, 991, 527, 297, 259, 327, 378, 88, 1644, 199, 7, 991, 27678, 297, 259, 327, 378, 88, 966, 199, 7, 991, 10335, 297, 259, 327, 378, 88, 1717, 199, 7, 991, 17189, 297, 259, 327, 378, 88, 1690, 199, 7, 991, 947, 297, 259, 327, 378, 88, 1780, 199, 7, 991, 3210, 297, 259, 327, 378, 88, 2036, 199, 7, 991, 337, 297, 259, 327, 378, 88, 1643, 199, 7, 991, 384, 297, 259, 327, 378, 88, 16, 65, 199, 7, 991, 22451, 297, 259, 327, 378, 88, 16, 66, 199, 7, 1235, 85, 297, 259, 327, 378, 88, 16, 67, 199, 7, 1235, 1518, 297, 259, 327, 378, 88, 16, 68, 199, 7, 1235, 1518, 71, 297, 259, 327, 378, 88, 16, 69, 199, 7, 1235, 85, 458, 297, 259, 327, 378, 88, 16, 70, 199, 7, 1235, 324, 297, 259, 327, 378, 88, 709, 199, 7, 1235, 324, 74, 297, 259, 327, 378, 88, 845, 199, 7, 1235, 324, 72, 297, 259, 327, 378, 88, 713, 199, 7, 1235, 1181, 297, 259, 327, 378, 88, 969, 199, 7, 1235, 348, 297, 259, 327, 378, 88, 1079, 199, 7, 1235, 27092, 297, 259, 327, 378, 88, 1046, 199, 7, 1235, 348, 77, 297, 259, 327, 378, 88, 975, 199, 7, 1235, 348, 66, 297, 259, 327, 378, 88, 1196, 199, 7, 1235, 348, 83, 297, 259, 327, 378, 88, 1085, 199, 7, 1235, 427, 297, 259, 327, 378, 88, 1167, 199, 7, 1235, 15513, 297, 259, 327, 378, 88, 17, 65, 199, 7, 1235, 348, 72, 297, 259, 327, 378, 88, 17, 66, 199, 7, 1235, 453, 297, 259, 327, 378, 88, 17, 67, 199, 7, 1235, 456, 297, 259, 327, 378, 88, 17, 68, 199, 7, 1235, 30327, 297, 259, 327, 378, 88, 17, 69, 199, 7, 1235, 527, 297, 259, 327, 378, 88, 17, 70, 199, 7, 1235, 27678, 297, 259, 327, 378, 88, 1165, 199, 7, 1235, 10335, 297, 259, 327, 378, 88, 2025, 199, 7, 1235, 17189, 297, 259, 327, 378, 88, 1081, 199, 7, 1235, 947, 297, 259, 327, 378, 88, 1789, 199, 7, 1235, 3210, 297, 259, 327, 378, 88, 1194, 199, 7, 1235, 337, 297, 259, 327, 378, 88, 821, 199, 7, 1235, 384, 297, 259, 327, 378, 88, 1479, 199, 7, 1235, 22451, 297, 259, 327, 378, 88, 1465, 199, 7, 991, 73, 297, 259, 327, 378, 88, 1651, 199, 7, 991, 528, 297, 259, 327, 378, 88, 1398, 199, 7, 991, 528, 71, 297, 259, 327, 378, 88, 18, 65, 199, 7, 991, 73, 458, 297, 259, 327, 378, 88, 18, 66, 199, 7, 991, 262, 297, 259, 327, 378, 88, 18, 67, 199, 7, 991, 262, 74, 297, 259, 327, 378, 88, 18, 68, 199, 7, 991, 17695, 297, 259, 327, 378, 88, 18, 69, 199, 7, 991, 344, 297, 259, 327, 378, 88, 18, 70, 199, 7, 991, 382, 297, 259, 327, 378, 88, 1216, 199, 7, 991, 382, 71, 297, 259, 327, 378, 88, 2192, 199, 7, 991, 382, 77, 297, 259, 327, 378, 88, 708, 199, 7, 991, 382, 66, 297, 259, 327, 378, 88, 1153, 199, 7, 991, 17841, 297, 259, 327, 378, 88, 1082, 199, 7, 991, 4803, 297, 259, 327, 378, 88, 1276, 199, 7, 991, 382, 80, 297, 259, 327, 378, 88, 1344, 199, 7, 991, 382, 72, 297, 259, 327, 378, 88, 1401, 199, 7, 991, 1017, 297, 259, 327, 378, 88, 1703, 199, 7, 991, 1892, 297, 259, 327, 378, 88, 1355, 199, 7, 991, 73, 1533, 297, 259, 327, 378, 88, 19, 65, 199, 7, 991, 374, 297, 259, 327, 378, 88, 19, 66, 199, 7, 991, 19857, 297, 259, 327, 378, 88, 19, 67, 199, 7, 991, 316, 297, 259, 327, 378, 88, 19, 68, 199, 7, 991, 7879, 297, 259, 327, 378, 88, 19, 69, 199, 7, 991, 530, 297, 259, 327, 378, 88, 19, 70, 199, 7, 991, 3258, 297, 259, 327, 378, 88, 2167, 199, 7, 991, 390, 297, 259, 327, 378, 88, 2953, 199, 7, 991, 711, 297, 259, 327, 378, 88, 2260, 199, 7, 991, 24278, 297, 259, 327, 378, 88, 2824, 199, 7, 4492, 297, 259, 327, 378, 88, 1602, 199, 7, 5076, 297, 259, 327, 378, 88, 2322, 199, 7, 5076, 71, 297, 259, 327, 378, 88, 2466, 199, 7, 4492, 458, 297, 259, 327, 378, 88, 2417, 199, 7, 1393, 297, 259, 327, 378, 88, 2006, 199, 7, 1393, 74, 297, 259, 327, 378, 88, 1887, 199, 7, 1393, 72, 297, 259, 327, 378, 88, 20, 65, 199, 7, 17949, 297, 259, 327, 378, 88, 20, 66, 199, 7, 66, 382, 297, 259, 327, 378, 88, 20, 67, 199, 7, 66, 382, 71, 297, 259, 327, 378, 88, 20, 68, 199, 7, 66, 382, 77, 297, 259, 327, 378, 88, 20, 69, 199, 7, 66, 382, 66, 297, 259, 327, 378, 88, 20, 70, 199, 7, 66, 17841, 297, 259, 327, 378, 88, 1400, 199, 7, 66, 4803, 297, 259, 327, 378, 88, 2869, 199, 7, 66, 382, 80, 297, 259, 327, 378, 88, 2528, 199, 7, 66, 382, 72, 297, 259, 327, 378, 88, 2481, 199, 7, 66, 1017, 297, 259, 327, 378, 88, 1477, 199, 7, 8804, 297, 259, 327, 378, 88, 1229, 199, 7, 4492, 1533, 297, 259, 327, 378, 88, 1367, 199, 7, 18797, 297, 259, 327, 378, 88, 1641, 199, 7, 18797, 83, 297, 259, 327, 378, 88, 2010, 199, 7, 10911, 297, 259, 327, 378, 88, 1427, 199, 7, 4492, 74, 297, 259, 327, 378, 88, 21, 65, 199, 7, 30435, 297, 259, 327, 378, 88, 21, 66, 199, 7, 66, 3258, 297, 259, 327, 378, 88, 21, 67, 199, 7, 2075, 297, 259, 327, 378, 88, 21, 68, 199, 7, 27566, 297, 259, 327, 378, 88, 21, 69, 199, 7, 4492, 72, 297, 259, 327, 378, 88, 21, 70, 199, 7, 32703, 297, 259, 327, 378, 88, 2259, 199, 7, 2501, 643 ]
[ 275, 334, 199, 7, 991, 453, 297, 259, 327, 378, 88, 383, 199, 7, 991, 456, 297, 259, 327, 378, 88, 614, 199, 7, 991, 30327, 297, 259, 327, 378, 88, 996, 199, 7, 991, 527, 297, 259, 327, 378, 88, 1644, 199, 7, 991, 27678, 297, 259, 327, 378, 88, 966, 199, 7, 991, 10335, 297, 259, 327, 378, 88, 1717, 199, 7, 991, 17189, 297, 259, 327, 378, 88, 1690, 199, 7, 991, 947, 297, 259, 327, 378, 88, 1780, 199, 7, 991, 3210, 297, 259, 327, 378, 88, 2036, 199, 7, 991, 337, 297, 259, 327, 378, 88, 1643, 199, 7, 991, 384, 297, 259, 327, 378, 88, 16, 65, 199, 7, 991, 22451, 297, 259, 327, 378, 88, 16, 66, 199, 7, 1235, 85, 297, 259, 327, 378, 88, 16, 67, 199, 7, 1235, 1518, 297, 259, 327, 378, 88, 16, 68, 199, 7, 1235, 1518, 71, 297, 259, 327, 378, 88, 16, 69, 199, 7, 1235, 85, 458, 297, 259, 327, 378, 88, 16, 70, 199, 7, 1235, 324, 297, 259, 327, 378, 88, 709, 199, 7, 1235, 324, 74, 297, 259, 327, 378, 88, 845, 199, 7, 1235, 324, 72, 297, 259, 327, 378, 88, 713, 199, 7, 1235, 1181, 297, 259, 327, 378, 88, 969, 199, 7, 1235, 348, 297, 259, 327, 378, 88, 1079, 199, 7, 1235, 27092, 297, 259, 327, 378, 88, 1046, 199, 7, 1235, 348, 77, 297, 259, 327, 378, 88, 975, 199, 7, 1235, 348, 66, 297, 259, 327, 378, 88, 1196, 199, 7, 1235, 348, 83, 297, 259, 327, 378, 88, 1085, 199, 7, 1235, 427, 297, 259, 327, 378, 88, 1167, 199, 7, 1235, 15513, 297, 259, 327, 378, 88, 17, 65, 199, 7, 1235, 348, 72, 297, 259, 327, 378, 88, 17, 66, 199, 7, 1235, 453, 297, 259, 327, 378, 88, 17, 67, 199, 7, 1235, 456, 297, 259, 327, 378, 88, 17, 68, 199, 7, 1235, 30327, 297, 259, 327, 378, 88, 17, 69, 199, 7, 1235, 527, 297, 259, 327, 378, 88, 17, 70, 199, 7, 1235, 27678, 297, 259, 327, 378, 88, 1165, 199, 7, 1235, 10335, 297, 259, 327, 378, 88, 2025, 199, 7, 1235, 17189, 297, 259, 327, 378, 88, 1081, 199, 7, 1235, 947, 297, 259, 327, 378, 88, 1789, 199, 7, 1235, 3210, 297, 259, 327, 378, 88, 1194, 199, 7, 1235, 337, 297, 259, 327, 378, 88, 821, 199, 7, 1235, 384, 297, 259, 327, 378, 88, 1479, 199, 7, 1235, 22451, 297, 259, 327, 378, 88, 1465, 199, 7, 991, 73, 297, 259, 327, 378, 88, 1651, 199, 7, 991, 528, 297, 259, 327, 378, 88, 1398, 199, 7, 991, 528, 71, 297, 259, 327, 378, 88, 18, 65, 199, 7, 991, 73, 458, 297, 259, 327, 378, 88, 18, 66, 199, 7, 991, 262, 297, 259, 327, 378, 88, 18, 67, 199, 7, 991, 262, 74, 297, 259, 327, 378, 88, 18, 68, 199, 7, 991, 17695, 297, 259, 327, 378, 88, 18, 69, 199, 7, 991, 344, 297, 259, 327, 378, 88, 18, 70, 199, 7, 991, 382, 297, 259, 327, 378, 88, 1216, 199, 7, 991, 382, 71, 297, 259, 327, 378, 88, 2192, 199, 7, 991, 382, 77, 297, 259, 327, 378, 88, 708, 199, 7, 991, 382, 66, 297, 259, 327, 378, 88, 1153, 199, 7, 991, 17841, 297, 259, 327, 378, 88, 1082, 199, 7, 991, 4803, 297, 259, 327, 378, 88, 1276, 199, 7, 991, 382, 80, 297, 259, 327, 378, 88, 1344, 199, 7, 991, 382, 72, 297, 259, 327, 378, 88, 1401, 199, 7, 991, 1017, 297, 259, 327, 378, 88, 1703, 199, 7, 991, 1892, 297, 259, 327, 378, 88, 1355, 199, 7, 991, 73, 1533, 297, 259, 327, 378, 88, 19, 65, 199, 7, 991, 374, 297, 259, 327, 378, 88, 19, 66, 199, 7, 991, 19857, 297, 259, 327, 378, 88, 19, 67, 199, 7, 991, 316, 297, 259, 327, 378, 88, 19, 68, 199, 7, 991, 7879, 297, 259, 327, 378, 88, 19, 69, 199, 7, 991, 530, 297, 259, 327, 378, 88, 19, 70, 199, 7, 991, 3258, 297, 259, 327, 378, 88, 2167, 199, 7, 991, 390, 297, 259, 327, 378, 88, 2953, 199, 7, 991, 711, 297, 259, 327, 378, 88, 2260, 199, 7, 991, 24278, 297, 259, 327, 378, 88, 2824, 199, 7, 4492, 297, 259, 327, 378, 88, 1602, 199, 7, 5076, 297, 259, 327, 378, 88, 2322, 199, 7, 5076, 71, 297, 259, 327, 378, 88, 2466, 199, 7, 4492, 458, 297, 259, 327, 378, 88, 2417, 199, 7, 1393, 297, 259, 327, 378, 88, 2006, 199, 7, 1393, 74, 297, 259, 327, 378, 88, 1887, 199, 7, 1393, 72, 297, 259, 327, 378, 88, 20, 65, 199, 7, 17949, 297, 259, 327, 378, 88, 20, 66, 199, 7, 66, 382, 297, 259, 327, 378, 88, 20, 67, 199, 7, 66, 382, 71, 297, 259, 327, 378, 88, 20, 68, 199, 7, 66, 382, 77, 297, 259, 327, 378, 88, 20, 69, 199, 7, 66, 382, 66, 297, 259, 327, 378, 88, 20, 70, 199, 7, 66, 17841, 297, 259, 327, 378, 88, 1400, 199, 7, 66, 4803, 297, 259, 327, 378, 88, 2869, 199, 7, 66, 382, 80, 297, 259, 327, 378, 88, 2528, 199, 7, 66, 382, 72, 297, 259, 327, 378, 88, 2481, 199, 7, 66, 1017, 297, 259, 327, 378, 88, 1477, 199, 7, 8804, 297, 259, 327, 378, 88, 1229, 199, 7, 4492, 1533, 297, 259, 327, 378, 88, 1367, 199, 7, 18797, 297, 259, 327, 378, 88, 1641, 199, 7, 18797, 83, 297, 259, 327, 378, 88, 2010, 199, 7, 10911, 297, 259, 327, 378, 88, 1427, 199, 7, 4492, 74, 297, 259, 327, 378, 88, 21, 65, 199, 7, 30435, 297, 259, 327, 378, 88, 21, 66, 199, 7, 66, 3258, 297, 259, 327, 378, 88, 21, 67, 199, 7, 2075, 297, 259, 327, 378, 88, 21, 68, 199, 7, 27566, 297, 259, 327, 378, 88, 21, 69, 199, 7, 4492, 72, 297, 259, 327, 378, 88, 21, 70, 199, 7, 32703, 297, 259, 327, 378, 88, 2259, 199, 7, 2501, 643, 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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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 ]
python-recsys/mrec
mrec/evaluation/metrics.py
1
5143
""" Metrics to evaluate recommendations: * with hit rate, following e.g. Karypis lab SLIM and FISM papers * with prec@k and MRR """ import numpy as np from collections import defaultdict # classes to access known items for each test user class get_known_items_from_dict(object): def __init__(self,data): self.data = data def __call__(self,u): return self.data[u] class get_known_items_from_csr_matrix(object): def __init__(self,data): self.data = data def __call__(self,u): return self.data[u].indices class get_known_items_from_thresholded_csr_matrix(object): def __init__(self,data,min_value): self.data = data self.min_value = min_value def __call__(self,u): items = self.data[u].toarray().flatten() items[items<self.min_value] = 0 return items.nonzero() # methods to refit a model to a new training dataset def retrain_recommender(model,dataset): model.fit(dataset) # methods for metric computation itself def run_evaluation(models,retrain,get_split,num_runs,evaluation_func): """ This is the main entry point to run an evaluation. Supply functions to retrain model, to get a new split of data on each run, to get known items from the test set, and to compute the metrics you want: retrain(model,dataset) should retrain model get_split() should return train_data,test_users,test_data evaluation_func(model,users,test) should return a dict of metrics A number of suitable functions are already available in the module. """ metrics = [defaultdict(list) for m in models] for _ in xrange(num_runs): train,users,test = get_split() for i,model in enumerate(models): retrain(model,train) run_metrics = evaluation_func(model,train,users,test) for m,val in run_metrics.iteritems(): print m,val metrics[i][m].append(val) return metrics def generate_metrics(get_known_items,compute_metrics): def evaluation_func(model,train,users,test): return evaluate(model,train,users,get_known_items(test),compute_metrics) return evaluation_func def sort_metrics_by_name(names): # group by name and number in "@n" prefix2val = defaultdict(list) for name in names: parts = name.split('@') name = parts[0] if len(parts) > 1: val = int(parts[1]) prefix2val[name].append(val) else: prefix2val[name] = [] for name,vals in prefix2val.iteritems(): prefix2val[name] = sorted(vals) ret = [] for name,vals in prefix2val.iteritems(): if vals: for val in vals: ret.append('{0}@{1}'.format(name,val)) else: ret.append(name) return ret def print_report(models,metrics): """ Call this to print out the metrics returned by run_evaluation(). """ for model,results in zip(models,metrics): print model if hasattr(model,'similarity_matrix'): nnz = model.similarity_matrix.nnz num_items = model.similarity_matrix.shape[0] density = float(model.similarity_matrix.nnz)/num_items**2 print 'similarity matrix nnz = {0} (density {1:.3f})'.format(nnz,density) for m in sort_metrics_by_name(results.keys()): vals = results[m] mean = np.mean(vals) std = np.std(vals) stderr = std/len(vals)**0.5 print '{0}{1:.4f} +/- {2:.4f}'.format(m.ljust(15),mean,stderr) def evaluate(model,train,users,get_known_items,compute_metrics): avg_metrics = defaultdict(float) count = 0 for u in users: recommended = [r for r,_ in model.recommend_items(train,u,max_items=20)] metrics = compute_metrics(recommended,get_known_items(u)) if metrics: for m,val in metrics.iteritems(): avg_metrics[m] += val count += 1 for m in avg_metrics: avg_metrics[m] /= float(count) return avg_metrics # collections of metrics def compute_main_metrics(recommended,known): if not known: return None return {'prec@5':prec(recommended,known,5), 'prec@10':prec(recommended,known,10), 'prec@15':prec(recommended,known,15), 'prec@20':prec(recommended,known,20), 'mrr':mrr(recommended,known)} def compute_hit_rate(recommended,known): if not known: return None return {'hit rate@10':hit_rate(recommended,known,10)} # individual metrics def prec(predicted,true,k): if not predicted: return 0 correct = len(set(predicted[:k]).intersection(set(true))) return float(correct)/len(predicted[:k]) def hit_rate(predicted,true,k): assert(len(true)==1) return int(true[0] in predicted[:k]) #return int(len(set(predicted[:k]).intersection(set(true)))>0) def mrr(predicted,true): # TODO: NB we'll under report this as our predictions are truncated for i,x in enumerate(predicted): if x in true: return 1.0/(i+1) return 0
bsd-3-clause
[ 624, 199, 17213, 370, 9352, 27747, 1298, 26, 199, 10, 543, 9793, 6634, 12, 2569, 325, 14, 71, 14, 1804, 695, 80, 374, 19888, 428, 44, 1469, 436, 481, 1311, 45, 299, 439, 1192, 199, 10, 543, 13826, 32, 75, 436, 603, 13381, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 5055, 492, 10018, 199, 199, 3, 3992, 370, 2879, 6040, 2974, 367, 1924, 511, 922, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 807, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 304, 267, 291, 14, 576, 275, 666, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 372, 291, 14, 576, 59, 85, 61, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 10101, 63, 3642, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 304, 267, 291, 14, 576, 275, 666, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 372, 291, 14, 576, 59, 85, 1055, 4108, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 14898, 393, 770, 63, 10101, 63, 3642, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 12, 827, 63, 585, 304, 267, 291, 14, 576, 275, 666, 267, 291, 14, 827, 63, 585, 275, 1748, 63, 585, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 2974, 275, 291, 14, 576, 59, 85, 1055, 18993, 1252, 8487, 342, 267, 2974, 59, 1744, 28, 277, 14, 827, 63, 585, 61, 275, 378, 267, 372, 2974, 14, 10262, 342, 199, 199, 3, 3102, 370, 295, 3269, 282, 1402, 370, 282, 892, 6093, 4789, 199, 199, 318, 295, 2834, 63, 264, 9847, 424, 8, 1238, 12, 5214, 304, 272, 1402, 14, 3269, 8, 5214, 9, 199, 199, 3, 3102, 367, 6370, 14009, 6337, 199, 199, 318, 1255, 63, 19154, 8, 992, 12, 264, 2834, 12, 362, 63, 1294, 12, 1507, 63, 10802, 12, 19154, 63, 1532, 304, 272, 408, 272, 961, 365, 314, 2446, 2397, 2376, 370, 1255, 376, 11735, 14, 339, 6820, 19786, 3423, 370, 295, 2834, 1402, 12, 370, 664, 282, 892, 3715, 402, 666, 641, 272, 1924, 1255, 12, 370, 664, 6040, 2974, 687, 314, 511, 663, 12, 436, 370, 4526, 314, 272, 7186, 1265, 2934, 26, 489, 295, 2834, 8, 1238, 12, 5214, 9, 1077, 295, 2834, 1402, 489, 664, 63, 1294, 342, 1077, 372, 3560, 63, 576, 12, 396, 63, 3707, 12, 396, 63, 576, 489, 11735, 63, 1532, 8, 1238, 12, 3707, 12, 396, 9, 1077, 372, 282, 1211, 402, 7186, 272, 437, 1329, 402, 11233, 3423, 787, 2575, 2808, 315, 314, 859, 14, 272, 408, 272, 7186, 275, 359, 21501, 8, 513, 9, 367, 333, 315, 1709, 61, 272, 367, 485, 315, 4945, 8, 1507, 63, 10802, 304, 267, 3560, 12, 3707, 12, 396, 275, 664, 63, 1294, 342, 267, 367, 284, 12, 1238, 315, 3874, 8, 992, 304, 288, 295, 2834, 8, 1238, 12, 2834, 9, 288, 1255, 63, 6759, 275, 11735, 63, 1532, 8, 1238, 12, 2834, 12, 3707, 12, 396, 9, 288, 367, 333, 12, 637, 315, 1255, 63, 6759, 14, 4611, 837, 355, 870, 333, 12, 637, 355, 7186, 59, 73, 1527, 77, 1055, 740, 8, 637, 9, 272, 372, 7186, 199, 199, 318, 3550, 63, 6759, 8, 362, 63, 3159, 63, 1744, 12, 3357, 63, 6759, 304, 272, 347, 11735, 63, 1532, 8, 1238, 12, 2834, 12, 3707, 12, 396, 304, 267, 372, 9352, 8, 1238, 12, 2834, 12, 3707, 12, 362, 63, 3159, 63, 1744, 8, 396, 395, 3357, 63, 6759, 9, 272, 372, 11735, 63, 1532, 199, 199, 318, 4069, 63, 6759, 63, 991, 63, 354, 8, 1247, 304, 272, 327, 1572, 701, 536, 436, 1329, 315, 9244, 78, 2, 272, 2403, 18, 637, 275, 10018, 8, 513, 9, 272, 367, 536, 315, 1561, 26, 267, 4184, 275, 536, 14, 1294, 16591, 358, 267, 536, 275, 4184, 59, 16, 61, 267, 340, 822, 8, 4181, 9, 690, 413, 26, 288, 1139, 275, 1109, 8, 4181, 59, 17, 566, 288, 2403, 18, 637, 59, 354, 1055, 740, 8, 637, 9, 267, 587, 26, 288, 2403, 18, 637, 59, 354, 61, 275, 942, 272, 367, 536, 12, 3643, 315, 2403, 18, 637, 14, 4611, 837, 267, 2403, 18, 637, 59, 354, 61, 275, 3355, 8, 3643, 9, 272, 2203, 275, 942, 272, 367, 536, 12, 3643, 315, 2403, 18, 637, 14, 4611, 837, 267, 340, 5322, 26, 288, 367, 1139, 315, 5322, 26, 355, 2203, 14, 740, 11117, 16, 93, 32, 91, 17, 5285, 908, 8, 354, 12, 637, 430, 267, 587, 26, 288, 2203, 14, 740, 8, 354, 9, 272, 372, 2203, 199, 199, 318, 870, 63, 3070, 8, 992, 12, 6759, 304, 272, 408, 272, 6523, 642, 370, 870, 734, 314, 7186, 2138, 701, 1255, 63, 19154, 1252, 272, 408, 272, 367, 1402, 12, 2604, 315, 3482, 8, 992, 12, 6759, 304, 267, 870, 1402, 267, 340, 2688, 8, 1238, 2584, 21965, 63, 3642, 735, 288, 11542, 90, 275, 1402, 14, 21965, 63, 3642, 14, 28339, 288, 1967, 63, 1744, 275, 1402, 14, 21965, 63, 3642, 14, 1392, 59, 16, 61, 288, 13650, 275, 2069, 8, 1238, 14, 21965, 63, 3642, 14, 28339, 2447, 1507, 63, 1744, 538, 18, 288, 870, 283, 21965, 3634, 11542, 90, 275, 469, 16, 93, 334, 15669, 469, 17, 14010, 19, 70, 25885, 908, 8, 28339, 12, 15669, 9, 267, 367, 333, 315, 4069, 63, 6759, 63, 991, 63, 354, 8, 2604, 14, 1612, 5109, 288, 5322, 275, 2058, 59, 77, 61, 288, 4615, 275, 980, 14, 3670, 8, 3643, 9, 288, 2418, 275, 980, 14, 1516, 8, 3643, 9, 288, 4635, 275, 2418, 15, 552, 8, 3643, 6422, 16, 14, 21, 288, 870, 5041, 16, 8847, 17, 14010, 20, 70, 93, 435, 22551, 469, 18, 14010, 20, 70, 5285, 908, 8, 77, 14, 19996, 8, 1046, 395, 3670, 12, 3083, 9, 199, 199, 318, 9352, 8, 1238, 12, 2834, 12, 3707, 12, 362, 63, 3159, 63, 1744, 12, 3357, 63, 6759, 304, 272, 12402, 63, 6759, 275, 10018, 8, 1609, 9, 272, 2338, 275, 378, 272, 367, 399, 315, 4390, 26, 267, 14318, 275, 359, 82, 367, 519 ]
[ 199, 17213, 370, 9352, 27747, 1298, 26, 199, 10, 543, 9793, 6634, 12, 2569, 325, 14, 71, 14, 1804, 695, 80, 374, 19888, 428, 44, 1469, 436, 481, 1311, 45, 299, 439, 1192, 199, 10, 543, 13826, 32, 75, 436, 603, 13381, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 5055, 492, 10018, 199, 199, 3, 3992, 370, 2879, 6040, 2974, 367, 1924, 511, 922, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 807, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 304, 267, 291, 14, 576, 275, 666, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 372, 291, 14, 576, 59, 85, 61, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 10101, 63, 3642, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 304, 267, 291, 14, 576, 275, 666, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 372, 291, 14, 576, 59, 85, 1055, 4108, 199, 199, 533, 664, 63, 3159, 63, 1744, 63, 504, 63, 14898, 393, 770, 63, 10101, 63, 3642, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 576, 12, 827, 63, 585, 304, 267, 291, 14, 576, 275, 666, 267, 291, 14, 827, 63, 585, 275, 1748, 63, 585, 339, 347, 636, 1250, 721, 277, 12, 85, 304, 267, 2974, 275, 291, 14, 576, 59, 85, 1055, 18993, 1252, 8487, 342, 267, 2974, 59, 1744, 28, 277, 14, 827, 63, 585, 61, 275, 378, 267, 372, 2974, 14, 10262, 342, 199, 199, 3, 3102, 370, 295, 3269, 282, 1402, 370, 282, 892, 6093, 4789, 199, 199, 318, 295, 2834, 63, 264, 9847, 424, 8, 1238, 12, 5214, 304, 272, 1402, 14, 3269, 8, 5214, 9, 199, 199, 3, 3102, 367, 6370, 14009, 6337, 199, 199, 318, 1255, 63, 19154, 8, 992, 12, 264, 2834, 12, 362, 63, 1294, 12, 1507, 63, 10802, 12, 19154, 63, 1532, 304, 272, 408, 272, 961, 365, 314, 2446, 2397, 2376, 370, 1255, 376, 11735, 14, 339, 6820, 19786, 3423, 370, 295, 2834, 1402, 12, 370, 664, 282, 892, 3715, 402, 666, 641, 272, 1924, 1255, 12, 370, 664, 6040, 2974, 687, 314, 511, 663, 12, 436, 370, 4526, 314, 272, 7186, 1265, 2934, 26, 489, 295, 2834, 8, 1238, 12, 5214, 9, 1077, 295, 2834, 1402, 489, 664, 63, 1294, 342, 1077, 372, 3560, 63, 576, 12, 396, 63, 3707, 12, 396, 63, 576, 489, 11735, 63, 1532, 8, 1238, 12, 3707, 12, 396, 9, 1077, 372, 282, 1211, 402, 7186, 272, 437, 1329, 402, 11233, 3423, 787, 2575, 2808, 315, 314, 859, 14, 272, 408, 272, 7186, 275, 359, 21501, 8, 513, 9, 367, 333, 315, 1709, 61, 272, 367, 485, 315, 4945, 8, 1507, 63, 10802, 304, 267, 3560, 12, 3707, 12, 396, 275, 664, 63, 1294, 342, 267, 367, 284, 12, 1238, 315, 3874, 8, 992, 304, 288, 295, 2834, 8, 1238, 12, 2834, 9, 288, 1255, 63, 6759, 275, 11735, 63, 1532, 8, 1238, 12, 2834, 12, 3707, 12, 396, 9, 288, 367, 333, 12, 637, 315, 1255, 63, 6759, 14, 4611, 837, 355, 870, 333, 12, 637, 355, 7186, 59, 73, 1527, 77, 1055, 740, 8, 637, 9, 272, 372, 7186, 199, 199, 318, 3550, 63, 6759, 8, 362, 63, 3159, 63, 1744, 12, 3357, 63, 6759, 304, 272, 347, 11735, 63, 1532, 8, 1238, 12, 2834, 12, 3707, 12, 396, 304, 267, 372, 9352, 8, 1238, 12, 2834, 12, 3707, 12, 362, 63, 3159, 63, 1744, 8, 396, 395, 3357, 63, 6759, 9, 272, 372, 11735, 63, 1532, 199, 199, 318, 4069, 63, 6759, 63, 991, 63, 354, 8, 1247, 304, 272, 327, 1572, 701, 536, 436, 1329, 315, 9244, 78, 2, 272, 2403, 18, 637, 275, 10018, 8, 513, 9, 272, 367, 536, 315, 1561, 26, 267, 4184, 275, 536, 14, 1294, 16591, 358, 267, 536, 275, 4184, 59, 16, 61, 267, 340, 822, 8, 4181, 9, 690, 413, 26, 288, 1139, 275, 1109, 8, 4181, 59, 17, 566, 288, 2403, 18, 637, 59, 354, 1055, 740, 8, 637, 9, 267, 587, 26, 288, 2403, 18, 637, 59, 354, 61, 275, 942, 272, 367, 536, 12, 3643, 315, 2403, 18, 637, 14, 4611, 837, 267, 2403, 18, 637, 59, 354, 61, 275, 3355, 8, 3643, 9, 272, 2203, 275, 942, 272, 367, 536, 12, 3643, 315, 2403, 18, 637, 14, 4611, 837, 267, 340, 5322, 26, 288, 367, 1139, 315, 5322, 26, 355, 2203, 14, 740, 11117, 16, 93, 32, 91, 17, 5285, 908, 8, 354, 12, 637, 430, 267, 587, 26, 288, 2203, 14, 740, 8, 354, 9, 272, 372, 2203, 199, 199, 318, 870, 63, 3070, 8, 992, 12, 6759, 304, 272, 408, 272, 6523, 642, 370, 870, 734, 314, 7186, 2138, 701, 1255, 63, 19154, 1252, 272, 408, 272, 367, 1402, 12, 2604, 315, 3482, 8, 992, 12, 6759, 304, 267, 870, 1402, 267, 340, 2688, 8, 1238, 2584, 21965, 63, 3642, 735, 288, 11542, 90, 275, 1402, 14, 21965, 63, 3642, 14, 28339, 288, 1967, 63, 1744, 275, 1402, 14, 21965, 63, 3642, 14, 1392, 59, 16, 61, 288, 13650, 275, 2069, 8, 1238, 14, 21965, 63, 3642, 14, 28339, 2447, 1507, 63, 1744, 538, 18, 288, 870, 283, 21965, 3634, 11542, 90, 275, 469, 16, 93, 334, 15669, 469, 17, 14010, 19, 70, 25885, 908, 8, 28339, 12, 15669, 9, 267, 367, 333, 315, 4069, 63, 6759, 63, 991, 63, 354, 8, 2604, 14, 1612, 5109, 288, 5322, 275, 2058, 59, 77, 61, 288, 4615, 275, 980, 14, 3670, 8, 3643, 9, 288, 2418, 275, 980, 14, 1516, 8, 3643, 9, 288, 4635, 275, 2418, 15, 552, 8, 3643, 6422, 16, 14, 21, 288, 870, 5041, 16, 8847, 17, 14010, 20, 70, 93, 435, 22551, 469, 18, 14010, 20, 70, 5285, 908, 8, 77, 14, 19996, 8, 1046, 395, 3670, 12, 3083, 9, 199, 199, 318, 9352, 8, 1238, 12, 2834, 12, 3707, 12, 362, 63, 3159, 63, 1744, 12, 3357, 63, 6759, 304, 272, 12402, 63, 6759, 275, 10018, 8, 1609, 9, 272, 2338, 275, 378, 272, 367, 399, 315, 4390, 26, 267, 14318, 275, 359, 82, 367, 519, 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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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 ]
usakhelo/FreeCAD
src/Mod/Fem/Init.py
2
3004
# FreeCAD init script of the Fem module # (c) 2001 Juergen Riegel # *************************************************************************** # * (c) Juergen Riegel (juergen.riegel@web.de) 2002 * # * * # * This file is part of the FreeCAD CAx development system. * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * # * as published by the Free Software Foundation; either version 2 of * # * the License, or (at your option) any later version. * # * for detail see the LICENCE text file. * # * * # * FreeCAD 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 Lesser General Public License for more details. * # * * # * You should have received a copy of the GNU Library General Public * # * License along with FreeCAD; if not, write to the Free Software * # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * # * USA * # * * # * Juergen Riegel 2002 * # ***************************************************************************/ import FreeCAD FreeCAD.addExportType("TetGen file (*.poly)", "convert2TetGen") FreeCAD.addImportType("FEM formats (*.unv *.med *.dat *.bdf)", "Fem") if("BUILD_FEM_VTK" in FreeCAD.__cmake__): FreeCAD.addImportType("FEM CFD Unstructure Mesh (*.vtk *.vtu)", "Fem") FreeCAD.addExportType("FEM CFD Unstructure Mesh (*.vtk *.vtu)", "Fem") FreeCAD.addImportType("FEM results (*.vtk *.vtu)", "importVTKResults") FreeCAD.addExportType("FEM CFD Result in VTK format (*.vtk *.vtu)", "importVTKResults") FreeCAD.addExportType("FEM formats (*.unv *.med *.dat *.inp)", "Fem") FreeCAD.addImportType("CalculiX result (*.frd)", "importCcxFrdResults") FreeCAD.addImportType("Fenics mesh file (*.xml)", "importFenicsMesh") FreeCAD.addExportType("Fenics mesh file (*.xml)", "importFenicsMesh") FreeCAD.addImportType("Mesh from Calculix/Abaqus input file (*.inp)", "importInpMesh") FreeCAD.addImportType("Z88 mesh file (*.txt)", "importZ88Mesh") FreeCAD.addExportType("Z88 mesh file (*.txt)", "importZ88Mesh") FreeCAD.addImportType("Z88 displacement (o2) result file (*.txt)", "importZ88O2Results")
lgpl-2.1
[ 3, 20914, 4205, 2884, 402, 314, 481, 5633, 859, 202, 199, 3, 334, 67, 9, 12521, 1603, 14262, 2268, 820, 1873, 24920, 2999, 199, 3, 1011, 14355, 10, 202, 199, 3, 627, 257, 334, 67, 9, 1603, 14262, 2268, 820, 1873, 24920, 334, 74, 14262, 2268, 14, 11317, 24920, 32, 2520, 14, 271, 9, 14790, 9668, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 961, 570, 365, 1777, 402, 314, 20914, 7240, 88, 16367, 2656, 14, 4519, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 202, 199, 3, 627, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 202, 199, 3, 627, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 202, 199, 3, 627, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 202, 199, 3, 627, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 20914, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 3322, 627, 202, 199, 3, 627, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 202, 199, 3, 627, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 202, 199, 3, 627, 257, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 7861, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 202, 199, 3, 627, 257, 844, 3180, 543, 20914, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 263, 627, 202, 199, 3, 627, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 202, 199, 3, 627, 257, 8217, 6208, 257, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 1603, 14262, 2268, 820, 1873, 24920, 14790, 2476, 7861, 627, 202, 199, 3, 1011, 14355, 15870, 2999, 199, 646, 20914, 2999, 199, 10146, 17238, 14, 525, 11399, 804, 480, 52, 386, 8168, 570, 334, 4856, 6023, 4186, 298, 3916, 18, 52, 386, 8168, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 38, 2769, 6752, 334, 4856, 324, 86, 23588, 3594, 23588, 4616, 23588, 66, 1587, 4186, 298, 3456, 77, 531, 202, 199, 692, 480, 8248, 63, 38, 2769, 63, 8156, 43, 2, 315, 20914, 855, 16472, 18580, 1128, 20914, 14, 525, 6295, 804, 480, 38, 2769, 6035, 36, 1910, 6976, 603, 10613, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 3456, 77, 531, 1128, 20914, 14, 525, 11399, 804, 480, 38, 2769, 6035, 36, 1910, 6976, 603, 10613, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 3456, 77, 531, 1128, 20914, 14, 525, 6295, 804, 480, 38, 2769, 2058, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 646, 8156, 43, 6579, 531, 1128, 20914, 14, 525, 11399, 804, 480, 38, 2769, 6035, 36, 10695, 315, 812, 15263, 1475, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 646, 8156, 43, 6579, 531, 2999, 199, 10146, 17238, 14, 525, 11399, 804, 480, 38, 2769, 6752, 334, 4856, 324, 86, 23588, 3594, 23588, 4616, 23588, 11416, 4186, 298, 3456, 77, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 19511, 13987, 56, 754, 334, 4856, 4391, 68, 4186, 298, 646, 21426, 6287, 6883, 6579, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 38, 287, 2932, 9364, 570, 334, 4856, 1652, 4186, 298, 646, 38, 287, 2932, 12241, 531, 202, 199, 10146, 17238, 14, 525, 11399, 804, 480, 38, 287, 2932, 9364, 570, 334, 4856, 1652, 4186, 298, 646, 38, 287, 2932, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 12241, 687, 8256, 67, 13987, 88, 15, 33, 2470, 392, 83, 1324, 570, 334, 4856, 11416, 4186, 298, 646, 607, 80, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 58, 1299, 9364, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 12241, 531, 202, 199, 10146, 17238, 14, 525, 11399, 804, 480, 58, 1299, 9364, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 58, 1299, 9628, 27350, 334, 79, 18, 9, 754, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 47, 18, 6579, 531, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20914, 4205, 2884, 402, 314, 481, 5633, 859, 202, 199, 3, 334, 67, 9, 12521, 1603, 14262, 2268, 820, 1873, 24920, 2999, 199, 3, 1011, 14355, 10, 202, 199, 3, 627, 257, 334, 67, 9, 1603, 14262, 2268, 820, 1873, 24920, 334, 74, 14262, 2268, 14, 11317, 24920, 32, 2520, 14, 271, 9, 14790, 9668, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 961, 570, 365, 1777, 402, 314, 20914, 7240, 88, 16367, 2656, 14, 4519, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 202, 199, 3, 627, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 202, 199, 3, 627, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 202, 199, 3, 627, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 202, 199, 3, 627, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 20914, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 3322, 627, 202, 199, 3, 627, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 202, 199, 3, 627, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 202, 199, 3, 627, 257, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 7861, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 202, 199, 3, 627, 257, 844, 3180, 543, 20914, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 263, 627, 202, 199, 3, 627, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 202, 199, 3, 627, 257, 8217, 6208, 257, 627, 202, 199, 3, 627, 17997, 627, 202, 199, 3, 627, 257, 1603, 14262, 2268, 820, 1873, 24920, 14790, 2476, 7861, 627, 202, 199, 3, 1011, 14355, 15870, 2999, 199, 646, 20914, 2999, 199, 10146, 17238, 14, 525, 11399, 804, 480, 52, 386, 8168, 570, 334, 4856, 6023, 4186, 298, 3916, 18, 52, 386, 8168, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 38, 2769, 6752, 334, 4856, 324, 86, 23588, 3594, 23588, 4616, 23588, 66, 1587, 4186, 298, 3456, 77, 531, 202, 199, 692, 480, 8248, 63, 38, 2769, 63, 8156, 43, 2, 315, 20914, 855, 16472, 18580, 1128, 20914, 14, 525, 6295, 804, 480, 38, 2769, 6035, 36, 1910, 6976, 603, 10613, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 3456, 77, 531, 1128, 20914, 14, 525, 11399, 804, 480, 38, 2769, 6035, 36, 1910, 6976, 603, 10613, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 3456, 77, 531, 1128, 20914, 14, 525, 6295, 804, 480, 38, 2769, 2058, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 646, 8156, 43, 6579, 531, 1128, 20914, 14, 525, 11399, 804, 480, 38, 2769, 6035, 36, 10695, 315, 812, 15263, 1475, 334, 4856, 11919, 23588, 5941, 85, 4186, 298, 646, 8156, 43, 6579, 531, 2999, 199, 10146, 17238, 14, 525, 11399, 804, 480, 38, 2769, 6752, 334, 4856, 324, 86, 23588, 3594, 23588, 4616, 23588, 11416, 4186, 298, 3456, 77, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 19511, 13987, 56, 754, 334, 4856, 4391, 68, 4186, 298, 646, 21426, 6287, 6883, 6579, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 38, 287, 2932, 9364, 570, 334, 4856, 1652, 4186, 298, 646, 38, 287, 2932, 12241, 531, 202, 199, 10146, 17238, 14, 525, 11399, 804, 480, 38, 287, 2932, 9364, 570, 334, 4856, 1652, 4186, 298, 646, 38, 287, 2932, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 12241, 687, 8256, 67, 13987, 88, 15, 33, 2470, 392, 83, 1324, 570, 334, 4856, 11416, 4186, 298, 646, 607, 80, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 58, 1299, 9364, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 12241, 531, 202, 199, 10146, 17238, 14, 525, 11399, 804, 480, 58, 1299, 9364, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 12241, 531, 202, 199, 10146, 17238, 14, 525, 6295, 804, 480, 58, 1299, 9628, 27350, 334, 79, 18, 9, 754, 570, 334, 4856, 2424, 4186, 298, 646, 58, 1299, 47, 18, 6579, 531, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
davehunt/bedrock
bedrock/newsletter/utils.py
26
2669
from hashlib import md5 from django.conf import settings from django.core.cache import cache import basket import commonware.log log = commonware.log.getLogger('b.newsletter') NEWSLETTERS_CACHE_KEY = "newsletter-data" NEWSLETTERS_CACHE_TIMEOUT = 3600 # 1 hour def get_newsletters(): """Return a dictionary with our information about newsletters. Keys are the internal keys we use to designate newsletters to basket. Values are dictionaries with the remaining newsletter information. If we cannot get through to basket, return a default set of newsletters from settings.DEFAULT_NEWSLETTERS """ # Get the newsletter data from basket - it's a dictionary of dictionaries # Cache it for a little while (300 secs = 5 minutes) data = cache.get(NEWSLETTERS_CACHE_KEY) if data is None: try: data = basket.get_newsletters() except basket.BasketException: log.exception("Error getting newsletters from basket") return settings.DEFAULT_NEWSLETTERS # Cache for an hour - newsletters very rarely change cache.set(NEWSLETTERS_CACHE_KEY, data, NEWSLETTERS_CACHE_TIMEOUT) return data def get_languages_for_newsletters(newsletters=None): """Return a set of language codes supported by the newsletters. If no newsletters are provided, it will return language codes supported by all newsletters. These are 2-letter language codes and `do not` include the country part, even if the newsletter languages list does. E.g. this returns 'pt', not 'pt-Br' """ cache_key = 'newsletter:languages:' + md5(repr(newsletters)).hexdigest() langs = cache.get(cache_key) if langs is None: all_newsletters = get_newsletters() if newsletters is None: newsletters = all_newsletters.values() else: if isinstance(newsletters, basestring): newsletters = [nl.strip() for nl in newsletters.split(',')] newsletters = [all_newsletters.get(nl, {}) for nl in newsletters] langs = set() for newsletter in newsletters: langs.update(lang[:2].lower() for lang in newsletter.get('languages', [])) cache.set(cache_key, langs, NEWSLETTERS_CACHE_TIMEOUT) return langs def custom_unsub_reason(token, reason): """Call basket. Pass along their reason for unsubscribing. This is calling a basket API that's custom to Mozilla, that's why there's not a helper in the basket-client package.""" data = { 'token': token, 'reason': reason, } return basket.request('post', 'custom_unsub_reason', data=data)
mpl-2.0
[ 504, 8337, 492, 6128, 21, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 199, 646, 22812, 199, 646, 2863, 1068, 14, 793, 199, 199, 793, 275, 2863, 1068, 14, 793, 14, 5572, 360, 66, 14, 13224, 9269, 358, 199, 199, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 275, 298, 13224, 9269, 13, 576, 2, 199, 11365, 4929, 1573, 51, 63, 8677, 63, 8899, 275, 15751, 221, 327, 413, 6925, 421, 199, 318, 664, 63, 13224, 16415, 837, 272, 408, 1767, 282, 2600, 543, 4154, 2556, 3595, 19497, 16415, 14, 272, 17276, 787, 314, 5007, 2883, 781, 675, 370, 12899, 323, 19497, 16415, 370, 22812, 14, 272, 13468, 787, 11196, 543, 314, 7971, 19497, 9269, 2556, 14, 339, 982, 781, 3913, 664, 4012, 370, 22812, 12, 372, 282, 849, 663, 402, 19497, 16415, 272, 687, 2202, 14, 3472, 63, 11365, 4929, 1573, 51, 272, 408, 339, 327, 2372, 314, 19497, 9269, 666, 687, 22812, 446, 652, 1159, 282, 2600, 402, 11196, 272, 327, 11977, 652, 367, 282, 12050, 1830, 334, 5863, 20091, 275, 959, 9395, 9, 272, 666, 275, 2581, 14, 362, 8, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 9, 272, 340, 666, 365, 488, 26, 267, 862, 26, 288, 666, 275, 22812, 14, 362, 63, 13224, 16415, 342, 267, 871, 22812, 14, 34, 12351, 1726, 26, 288, 943, 14, 1971, 480, 547, 10232, 19497, 16415, 687, 22812, 531, 288, 372, 2202, 14, 3472, 63, 11365, 4929, 1573, 51, 267, 327, 11977, 367, 376, 6925, 446, 19497, 16415, 7437, 24063, 590, 1570, 267, 2581, 14, 409, 8, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 12, 666, 12, 18689, 4929, 1573, 51, 63, 8677, 63, 8899, 9, 272, 372, 666, 421, 199, 318, 664, 63, 13209, 63, 509, 63, 13224, 16415, 8, 13224, 16415, 29, 403, 304, 272, 408, 1767, 282, 663, 402, 2637, 9479, 3748, 701, 314, 19497, 16415, 14, 339, 982, 949, 19497, 16415, 787, 2741, 12, 652, 911, 372, 2637, 9479, 272, 3748, 701, 1006, 19497, 16415, 14, 339, 5723, 787, 499, 13, 9269, 2637, 9479, 436, 658, 1117, 440, 64, 2387, 314, 9023, 1777, 12, 272, 2755, 340, 314, 19497, 9269, 10815, 769, 1630, 14, 221, 662, 14, 71, 14, 642, 2529, 283, 541, 297, 272, 440, 283, 541, 13, 12771, 7, 272, 408, 272, 2581, 63, 498, 275, 283, 13224, 9269, 26, 13209, 4881, 435, 6128, 21, 8, 2722, 8, 13224, 16415, 4992, 11453, 342, 339, 31769, 275, 2581, 14, 362, 8, 1637, 63, 498, 9, 272, 340, 31769, 365, 488, 26, 267, 1006, 63, 13224, 16415, 275, 664, 63, 13224, 16415, 342, 267, 340, 19497, 16415, 365, 488, 26, 288, 19497, 16415, 275, 1006, 63, 13224, 16415, 14, 1459, 342, 267, 587, 26, 288, 340, 1228, 8, 13224, 16415, 12, 7116, 304, 355, 19497, 16415, 275, 359, 7530, 14, 1913, 342, 367, 12992, 315, 19497, 16415, 14, 1294, 29972, 288, 19497, 16415, 275, 359, 452, 63, 13224, 16415, 14, 362, 8, 7530, 12, 5009, 367, 12992, 315, 19497, 16415, 61, 398, 31769, 275, 663, 342, 267, 367, 19497, 9269, 315, 19497, 16415, 26, 288, 31769, 14, 873, 8, 4159, 1491, 18, 1055, 2325, 342, 367, 6339, 315, 19497, 9269, 14, 362, 360, 13209, 297, 15927, 398, 2581, 14, 409, 8, 1637, 63, 498, 12, 31769, 12, 18689, 4929, 1573, 51, 63, 8677, 63, 8899, 9, 339, 372, 31769, 421, 199, 318, 3537, 63, 324, 954, 63, 5764, 8, 1418, 12, 4499, 304, 272, 408, 2176, 22812, 14, 8325, 3180, 3932, 4499, 367, 625, 954, 729, 10911, 14, 339, 961, 365, 6358, 282, 22812, 3261, 626, 1159, 3537, 370, 17728, 12, 626, 1159, 272, 10842, 2337, 1159, 440, 282, 5922, 315, 314, 22812, 13, 1258, 2559, 1041, 272, 666, 275, 469, 267, 283, 1418, 356, 1526, 12, 267, 283, 5764, 356, 4499, 12, 272, 789, 272, 372, 22812, 14, 1069, 360, 1932, 297, 283, 4229, 63, 324, 954, 63, 5764, 297, 666, 29, 576, 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 ]
[ 8337, 492, 6128, 21, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 199, 646, 22812, 199, 646, 2863, 1068, 14, 793, 199, 199, 793, 275, 2863, 1068, 14, 793, 14, 5572, 360, 66, 14, 13224, 9269, 358, 199, 199, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 275, 298, 13224, 9269, 13, 576, 2, 199, 11365, 4929, 1573, 51, 63, 8677, 63, 8899, 275, 15751, 221, 327, 413, 6925, 421, 199, 318, 664, 63, 13224, 16415, 837, 272, 408, 1767, 282, 2600, 543, 4154, 2556, 3595, 19497, 16415, 14, 272, 17276, 787, 314, 5007, 2883, 781, 675, 370, 12899, 323, 19497, 16415, 370, 22812, 14, 272, 13468, 787, 11196, 543, 314, 7971, 19497, 9269, 2556, 14, 339, 982, 781, 3913, 664, 4012, 370, 22812, 12, 372, 282, 849, 663, 402, 19497, 16415, 272, 687, 2202, 14, 3472, 63, 11365, 4929, 1573, 51, 272, 408, 339, 327, 2372, 314, 19497, 9269, 666, 687, 22812, 446, 652, 1159, 282, 2600, 402, 11196, 272, 327, 11977, 652, 367, 282, 12050, 1830, 334, 5863, 20091, 275, 959, 9395, 9, 272, 666, 275, 2581, 14, 362, 8, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 9, 272, 340, 666, 365, 488, 26, 267, 862, 26, 288, 666, 275, 22812, 14, 362, 63, 13224, 16415, 342, 267, 871, 22812, 14, 34, 12351, 1726, 26, 288, 943, 14, 1971, 480, 547, 10232, 19497, 16415, 687, 22812, 531, 288, 372, 2202, 14, 3472, 63, 11365, 4929, 1573, 51, 267, 327, 11977, 367, 376, 6925, 446, 19497, 16415, 7437, 24063, 590, 1570, 267, 2581, 14, 409, 8, 11365, 4929, 1573, 51, 63, 8677, 63, 3078, 12, 666, 12, 18689, 4929, 1573, 51, 63, 8677, 63, 8899, 9, 272, 372, 666, 421, 199, 318, 664, 63, 13209, 63, 509, 63, 13224, 16415, 8, 13224, 16415, 29, 403, 304, 272, 408, 1767, 282, 663, 402, 2637, 9479, 3748, 701, 314, 19497, 16415, 14, 339, 982, 949, 19497, 16415, 787, 2741, 12, 652, 911, 372, 2637, 9479, 272, 3748, 701, 1006, 19497, 16415, 14, 339, 5723, 787, 499, 13, 9269, 2637, 9479, 436, 658, 1117, 440, 64, 2387, 314, 9023, 1777, 12, 272, 2755, 340, 314, 19497, 9269, 10815, 769, 1630, 14, 221, 662, 14, 71, 14, 642, 2529, 283, 541, 297, 272, 440, 283, 541, 13, 12771, 7, 272, 408, 272, 2581, 63, 498, 275, 283, 13224, 9269, 26, 13209, 4881, 435, 6128, 21, 8, 2722, 8, 13224, 16415, 4992, 11453, 342, 339, 31769, 275, 2581, 14, 362, 8, 1637, 63, 498, 9, 272, 340, 31769, 365, 488, 26, 267, 1006, 63, 13224, 16415, 275, 664, 63, 13224, 16415, 342, 267, 340, 19497, 16415, 365, 488, 26, 288, 19497, 16415, 275, 1006, 63, 13224, 16415, 14, 1459, 342, 267, 587, 26, 288, 340, 1228, 8, 13224, 16415, 12, 7116, 304, 355, 19497, 16415, 275, 359, 7530, 14, 1913, 342, 367, 12992, 315, 19497, 16415, 14, 1294, 29972, 288, 19497, 16415, 275, 359, 452, 63, 13224, 16415, 14, 362, 8, 7530, 12, 5009, 367, 12992, 315, 19497, 16415, 61, 398, 31769, 275, 663, 342, 267, 367, 19497, 9269, 315, 19497, 16415, 26, 288, 31769, 14, 873, 8, 4159, 1491, 18, 1055, 2325, 342, 367, 6339, 315, 19497, 9269, 14, 362, 360, 13209, 297, 15927, 398, 2581, 14, 409, 8, 1637, 63, 498, 12, 31769, 12, 18689, 4929, 1573, 51, 63, 8677, 63, 8899, 9, 339, 372, 31769, 421, 199, 318, 3537, 63, 324, 954, 63, 5764, 8, 1418, 12, 4499, 304, 272, 408, 2176, 22812, 14, 8325, 3180, 3932, 4499, 367, 625, 954, 729, 10911, 14, 339, 961, 365, 6358, 282, 22812, 3261, 626, 1159, 3537, 370, 17728, 12, 626, 1159, 272, 10842, 2337, 1159, 440, 282, 5922, 315, 314, 22812, 13, 1258, 2559, 1041, 272, 666, 275, 469, 267, 283, 1418, 356, 1526, 12, 267, 283, 5764, 356, 4499, 12, 272, 789, 272, 372, 22812, 14, 1069, 360, 1932, 297, 283, 4229, 63, 324, 954, 63, 5764, 297, 666, 29, 576, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mining/mining
mining/models/cube.py
4
3819
# -*- coding: utf-8 -*- import gc import pandas from datetime import datetime from pandas import DataFrame from sqlalchemy import create_engine from sqlalchemy.sql import text from sqlalchemy.orm import sessionmaker from mining.utils import conf, log_it from mining.utils._pandas import fix_render from mining.db import DataWarehouse from bottle.ext.mongo import MongoPlugin class Cube(object): def __init__(self, _cube): log_it("START: {}".format(_cube['slug']), "bin-mining") self.mongo = MongoPlugin( uri=conf("mongodb")["uri"], db=conf("mongodb")["db"], json_mongo=True).get_mongo() try: del _cube['_id'] except KeyError: pass self.cube = _cube self.slug = self.cube['slug'] def load(self): self.cube['run'] = 'run' self.mongo['cube'].update({'slug': self.slug}, self.cube) self.cube['start_process'] = datetime.now() _sql = self.cube['sql'] if _sql[-1] == ';': _sql = _sql[:-1] self.sql = u"""SELECT * FROM ({}) AS CUBE;""".format(_sql) self.connection = self.mongo['connection'].find_one({ 'slug': self.cube['connection']})['connection'] log_it("CONNECT IN RELATION DATA BASE: {}".format(self.slug), "bin-mining") if 'sqlite' in self.connection: e = create_engine(self.connection) else: e = create_engine(self.connection, **conf('openmining')['sql_conn_params']) Session = sessionmaker(bind=e) session = Session() resoverall = session.execute(text(self.sql)) self.data = resoverall.fetchall() self.keys = resoverall.keys() def environment(self, t): if t not in ['relational']: self.sql = t def _data(self, data): self.data = data def _keys(self, keys): if type(keys) == list: self.keys = keys self.keys = list(keys) def frame(self, data_type=None): log_it("LOAD DATA ON DATAWAREHOUSE via {}: {}".format( data_type or 'dict', self.slug), "bin-mining") if data_type: self.df = getattr(pandas, "read_{}".format(data_type))(self.data) else: self.df = DataFrame(self.data) if self.df.empty: self.pdict = {} log_it('[warning]Empty cube: {}!!'.format(self.cube), "bin-mining") return try: self.df.columns = self.keys except AttributeError: self._keys(self.df.columns.tolist()) # If the OML is active, it renders the script that there is if conf("oml").get("on") and self.cube.get("oml"): from oml import RunTime self.df.columns = self.keys df = RunTime(conf("oml").get("language", "lua"), self.df.to_dict(orient='records'), self.cube.get("oml"), conf("oml").get("class", {"OML": "oml.base.OMLBase"})) self.df = DataFrame(df) self._keys(self.df.columns.tolist()) self.df.head() self.pdict = map(fix_render, self.df.to_dict(orient='records')) def save(self): log_it("SAVE DATA (JSON) ON DATA WAREHOUSE: {}".format(self.slug), "bin-mining") data = {'data': self.pdict, 'columns': self.keys} DW = DataWarehouse() DW.save(self.slug, data) self.cube['status'] = True self.cube['lastupdate'] = datetime.now() self.cube['run'] = True self.mongo['cube'].update({'slug': self.cube['slug']}, self.cube) log_it("CLEAN MEMORY: {}".format(self.slug), "bin-mining") gc.collect()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 9486, 199, 646, 10634, 199, 504, 2197, 492, 2197, 199, 199, 504, 10634, 492, 10071, 199, 199, 504, 8335, 492, 1218, 63, 3908, 199, 504, 8335, 14, 3009, 492, 1318, 199, 504, 8335, 14, 1025, 492, 2351, 14367, 199, 199, 504, 1748, 316, 14, 1208, 492, 3743, 12, 943, 63, 390, 199, 504, 1748, 316, 14, 1208, 423, 15718, 492, 5325, 63, 3352, 199, 504, 1748, 316, 14, 697, 492, 3918, 55, 11499, 199, 199, 504, 5888, 1118, 14, 832, 14, 9217, 492, 13503, 5061, 421, 199, 533, 445, 3375, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 485, 11477, 304, 398, 943, 63, 390, 480, 7363, 26, 8352, 908, 1547, 11477, 459, 5464, 3815, 298, 1393, 13, 827, 316, 531, 398, 291, 14, 9217, 275, 13503, 5061, 8, 288, 5108, 29, 2190, 480, 22130, 13152, 531, 905, 2302, 2255, 288, 1592, 29, 2190, 480, 22130, 13152, 531, 905, 697, 2255, 288, 2022, 63, 9217, 29, 549, 680, 362, 63, 9217, 342, 398, 862, 26, 288, 2150, 485, 11477, 8680, 344, 418, 267, 871, 4067, 26, 288, 986, 267, 291, 14, 11477, 275, 485, 11477, 267, 291, 14, 5464, 275, 291, 14, 11477, 459, 5464, 418, 339, 347, 2248, 8, 277, 304, 267, 291, 14, 11477, 459, 1065, 418, 275, 283, 1065, 7, 267, 291, 14, 9217, 459, 11477, 2278, 873, 3252, 5464, 356, 291, 14, 5464, 1386, 291, 14, 11477, 9, 398, 291, 14, 11477, 459, 928, 63, 1412, 418, 275, 2197, 14, 2131, 342, 398, 485, 3009, 275, 291, 14, 11477, 459, 3009, 418, 267, 340, 485, 3009, 1988, 17, 61, 508, 283, 6015, 288, 485, 3009, 275, 485, 3009, 4439, 17, 61, 267, 291, 14, 3009, 275, 399, 624, 4859, 627, 4442, 11459, 1552, 4319, 445, 21857, 27, 23045, 908, 1547, 3009, 9, 398, 291, 14, 2105, 275, 291, 14, 9217, 459, 2105, 2278, 1623, 63, 368, 2561, 288, 283, 5464, 356, 291, 14, 11477, 459, 2105, 13678, 459, 2105, 418, 398, 943, 63, 390, 480, 14657, 1621, 820, 2901, 2594, 7126, 19721, 26, 8352, 908, 8, 277, 14, 5464, 395, 2049, 298, 1393, 13, 827, 316, 531, 267, 340, 283, 10659, 7, 315, 291, 14, 2105, 26, 288, 325, 275, 1218, 63, 3908, 8, 277, 14, 2105, 9, 267, 587, 26, 288, 325, 275, 1218, 63, 3908, 8, 277, 14, 2105, 12, 2892, 1011, 2190, 360, 1490, 827, 316, 24211, 3009, 63, 1631, 63, 1162, 1105, 267, 8596, 275, 2351, 14367, 8, 3409, 29, 69, 9, 267, 2351, 275, 8596, 342, 398, 522, 1883, 452, 275, 2351, 14, 2526, 8, 505, 8, 277, 14, 3009, 430, 267, 291, 14, 576, 275, 522, 1883, 452, 14, 10174, 342, 267, 291, 14, 1612, 275, 522, 1883, 452, 14, 1612, 342, 339, 347, 3734, 8, 277, 12, 307, 304, 267, 340, 307, 440, 315, 788, 5690, 279, 2565, 288, 291, 14, 3009, 275, 307, 339, 347, 485, 576, 8, 277, 12, 666, 304, 267, 291, 14, 576, 275, 666, 339, 347, 485, 1612, 8, 277, 12, 2883, 304, 267, 340, 730, 8, 1612, 9, 508, 769, 26, 288, 291, 14, 1612, 275, 2883, 267, 291, 14, 1612, 275, 769, 8, 1612, 9, 339, 347, 2787, 8, 277, 12, 666, 63, 466, 29, 403, 304, 267, 943, 63, 390, 480, 7405, 7126, 5258, 7126, 3695, 2979, 4701, 4799, 24702, 8352, 908, 8, 288, 666, 63, 466, 503, 283, 807, 297, 291, 14, 5464, 395, 298, 1393, 13, 827, 316, 531, 267, 340, 666, 63, 466, 26, 288, 291, 14, 1587, 275, 2519, 8, 15718, 12, 298, 739, 63, 13536, 908, 8, 576, 63, 466, 430, 8, 277, 14, 576, 9, 267, 587, 26, 288, 291, 14, 1587, 275, 10071, 8, 277, 14, 576, 9, 398, 340, 291, 14, 1587, 14, 1667, 26, 288, 291, 14, 80, 807, 275, 1052, 288, 943, 63, 390, 11894, 3764, 61, 4699, 15681, 26, 1052, 3480, 1370, 908, 8, 277, 14, 11477, 395, 673, 298, 1393, 13, 827, 316, 531, 288, 372, 398, 862, 26, 288, 291, 14, 1587, 14, 3406, 275, 291, 14, 1612, 267, 871, 4281, 26, 288, 291, 423, 1612, 8, 277, 14, 1587, 14, 3406, 14, 13633, 1012, 398, 327, 982, 314, 593, 1698, 365, 4702, 12, 652, 3795, 83, 314, 2884, 626, 2337, 365, 267, 340, 3743, 480, 676, 76, 3471, 362, 480, 265, 531, 436, 291, 14, 11477, 14, 362, 480, 676, 76, 2349, 288, 687, 312, 757, 492, 3378, 1366, 288, 291, 14, 1587, 14, 3406, 275, 291, 14, 1612, 288, 4051, 275, 3378, 1366, 8, 2190, 480, 676, 76, 3471, 362, 480, 3671, 401, 298, 76, 1458, 1288, 586, 291, 14, 1587, 14, 475, 63, 807, 8, 19676, 534, 6502, 659, 586, 291, 14, 11477, 14, 362, 480, 676, 76, 1288, 586, 3743, 480, 676, 76, 3471, 362, 480, 533, 401, 2420, 47, 1698, 582, 298, 676, 76, 14, 1095, 14, 47, 1698, 1563, 3570, 430, 288, 291, 14, 1587, 275, 10071, 8, 1587, 9, 288, 291, 423, 1612, 8, 277, 14, 1587, 14, 3406, 14, 13633, 1012, 398, 291, 14, 1587, 14, 2993, 342, 267, 291, 14, 80, 807, 275, 2341, 8, 970, 63, 3352, 12, 291, 14, 1587, 14, 475, 63, 807, 8, 19676, 534, 6502, 1333, 339, 347, 3354, 8, 277, 304, 267, 943, 63, 390, 480, 19318, 7126, 334, 6243, 9, 5258, 7126, 644, 8693, 2979, 4701, 26, 8352, 908, 8, 277, 14, 5464, 395, 2049, 298, 1393, 13, 827, 316, 531, 267, 666, 275, 791, 576, 356, 291, 14, 80, 807, 12, 283, 3406, 356, 291, 14, 1612, 93, 267, 577, 55, 275, 3918, 55, 11499, 342, 267, 577, 55, 14, 2117, 8, 277, 14, 5464, 12, 666, 9, 398, 291, 14, 11477, 459, 1205, 418, 275, 715, 267, 291, 14, 11477, 459, 2019, 873, 418, 275, 2197, 14, 2131, 342, 267, 291, 14, 11477, 459, 1065, 418, 275, 715, 267, 291, 14, 9217, 459, 11477, 2278, 873, 3252, 5464, 356, 291, 14, 11477, 459, 5464, 14949, 291, 14, 11477, 9, 398, 943, 63, 390, 480, 28663, 31424, 5347, 26, 8352, 908, 8, 277, 14, 5464, 395, 298, 1393, 13, 827, 316, 531, 267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 9486, 199, 646, 10634, 199, 504, 2197, 492, 2197, 199, 199, 504, 10634, 492, 10071, 199, 199, 504, 8335, 492, 1218, 63, 3908, 199, 504, 8335, 14, 3009, 492, 1318, 199, 504, 8335, 14, 1025, 492, 2351, 14367, 199, 199, 504, 1748, 316, 14, 1208, 492, 3743, 12, 943, 63, 390, 199, 504, 1748, 316, 14, 1208, 423, 15718, 492, 5325, 63, 3352, 199, 504, 1748, 316, 14, 697, 492, 3918, 55, 11499, 199, 199, 504, 5888, 1118, 14, 832, 14, 9217, 492, 13503, 5061, 421, 199, 533, 445, 3375, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 485, 11477, 304, 398, 943, 63, 390, 480, 7363, 26, 8352, 908, 1547, 11477, 459, 5464, 3815, 298, 1393, 13, 827, 316, 531, 398, 291, 14, 9217, 275, 13503, 5061, 8, 288, 5108, 29, 2190, 480, 22130, 13152, 531, 905, 2302, 2255, 288, 1592, 29, 2190, 480, 22130, 13152, 531, 905, 697, 2255, 288, 2022, 63, 9217, 29, 549, 680, 362, 63, 9217, 342, 398, 862, 26, 288, 2150, 485, 11477, 8680, 344, 418, 267, 871, 4067, 26, 288, 986, 267, 291, 14, 11477, 275, 485, 11477, 267, 291, 14, 5464, 275, 291, 14, 11477, 459, 5464, 418, 339, 347, 2248, 8, 277, 304, 267, 291, 14, 11477, 459, 1065, 418, 275, 283, 1065, 7, 267, 291, 14, 9217, 459, 11477, 2278, 873, 3252, 5464, 356, 291, 14, 5464, 1386, 291, 14, 11477, 9, 398, 291, 14, 11477, 459, 928, 63, 1412, 418, 275, 2197, 14, 2131, 342, 398, 485, 3009, 275, 291, 14, 11477, 459, 3009, 418, 267, 340, 485, 3009, 1988, 17, 61, 508, 283, 6015, 288, 485, 3009, 275, 485, 3009, 4439, 17, 61, 267, 291, 14, 3009, 275, 399, 624, 4859, 627, 4442, 11459, 1552, 4319, 445, 21857, 27, 23045, 908, 1547, 3009, 9, 398, 291, 14, 2105, 275, 291, 14, 9217, 459, 2105, 2278, 1623, 63, 368, 2561, 288, 283, 5464, 356, 291, 14, 11477, 459, 2105, 13678, 459, 2105, 418, 398, 943, 63, 390, 480, 14657, 1621, 820, 2901, 2594, 7126, 19721, 26, 8352, 908, 8, 277, 14, 5464, 395, 2049, 298, 1393, 13, 827, 316, 531, 267, 340, 283, 10659, 7, 315, 291, 14, 2105, 26, 288, 325, 275, 1218, 63, 3908, 8, 277, 14, 2105, 9, 267, 587, 26, 288, 325, 275, 1218, 63, 3908, 8, 277, 14, 2105, 12, 2892, 1011, 2190, 360, 1490, 827, 316, 24211, 3009, 63, 1631, 63, 1162, 1105, 267, 8596, 275, 2351, 14367, 8, 3409, 29, 69, 9, 267, 2351, 275, 8596, 342, 398, 522, 1883, 452, 275, 2351, 14, 2526, 8, 505, 8, 277, 14, 3009, 430, 267, 291, 14, 576, 275, 522, 1883, 452, 14, 10174, 342, 267, 291, 14, 1612, 275, 522, 1883, 452, 14, 1612, 342, 339, 347, 3734, 8, 277, 12, 307, 304, 267, 340, 307, 440, 315, 788, 5690, 279, 2565, 288, 291, 14, 3009, 275, 307, 339, 347, 485, 576, 8, 277, 12, 666, 304, 267, 291, 14, 576, 275, 666, 339, 347, 485, 1612, 8, 277, 12, 2883, 304, 267, 340, 730, 8, 1612, 9, 508, 769, 26, 288, 291, 14, 1612, 275, 2883, 267, 291, 14, 1612, 275, 769, 8, 1612, 9, 339, 347, 2787, 8, 277, 12, 666, 63, 466, 29, 403, 304, 267, 943, 63, 390, 480, 7405, 7126, 5258, 7126, 3695, 2979, 4701, 4799, 24702, 8352, 908, 8, 288, 666, 63, 466, 503, 283, 807, 297, 291, 14, 5464, 395, 298, 1393, 13, 827, 316, 531, 267, 340, 666, 63, 466, 26, 288, 291, 14, 1587, 275, 2519, 8, 15718, 12, 298, 739, 63, 13536, 908, 8, 576, 63, 466, 430, 8, 277, 14, 576, 9, 267, 587, 26, 288, 291, 14, 1587, 275, 10071, 8, 277, 14, 576, 9, 398, 340, 291, 14, 1587, 14, 1667, 26, 288, 291, 14, 80, 807, 275, 1052, 288, 943, 63, 390, 11894, 3764, 61, 4699, 15681, 26, 1052, 3480, 1370, 908, 8, 277, 14, 11477, 395, 673, 298, 1393, 13, 827, 316, 531, 288, 372, 398, 862, 26, 288, 291, 14, 1587, 14, 3406, 275, 291, 14, 1612, 267, 871, 4281, 26, 288, 291, 423, 1612, 8, 277, 14, 1587, 14, 3406, 14, 13633, 1012, 398, 327, 982, 314, 593, 1698, 365, 4702, 12, 652, 3795, 83, 314, 2884, 626, 2337, 365, 267, 340, 3743, 480, 676, 76, 3471, 362, 480, 265, 531, 436, 291, 14, 11477, 14, 362, 480, 676, 76, 2349, 288, 687, 312, 757, 492, 3378, 1366, 288, 291, 14, 1587, 14, 3406, 275, 291, 14, 1612, 288, 4051, 275, 3378, 1366, 8, 2190, 480, 676, 76, 3471, 362, 480, 3671, 401, 298, 76, 1458, 1288, 586, 291, 14, 1587, 14, 475, 63, 807, 8, 19676, 534, 6502, 659, 586, 291, 14, 11477, 14, 362, 480, 676, 76, 1288, 586, 3743, 480, 676, 76, 3471, 362, 480, 533, 401, 2420, 47, 1698, 582, 298, 676, 76, 14, 1095, 14, 47, 1698, 1563, 3570, 430, 288, 291, 14, 1587, 275, 10071, 8, 1587, 9, 288, 291, 423, 1612, 8, 277, 14, 1587, 14, 3406, 14, 13633, 1012, 398, 291, 14, 1587, 14, 2993, 342, 267, 291, 14, 80, 807, 275, 2341, 8, 970, 63, 3352, 12, 291, 14, 1587, 14, 475, 63, 807, 8, 19676, 534, 6502, 1333, 339, 347, 3354, 8, 277, 304, 267, 943, 63, 390, 480, 19318, 7126, 334, 6243, 9, 5258, 7126, 644, 8693, 2979, 4701, 26, 8352, 908, 8, 277, 14, 5464, 395, 2049, 298, 1393, 13, 827, 316, 531, 267, 666, 275, 791, 576, 356, 291, 14, 80, 807, 12, 283, 3406, 356, 291, 14, 1612, 93, 267, 577, 55, 275, 3918, 55, 11499, 342, 267, 577, 55, 14, 2117, 8, 277, 14, 5464, 12, 666, 9, 398, 291, 14, 11477, 459, 1205, 418, 275, 715, 267, 291, 14, 11477, 459, 2019, 873, 418, 275, 2197, 14, 2131, 342, 267, 291, 14, 11477, 459, 1065, 418, 275, 715, 267, 291, 14, 9217, 459, 11477, 2278, 873, 3252, 5464, 356, 291, 14, 11477, 459, 5464, 14949, 291, 14, 11477, 9, 398, 943, 63, 390, 480, 28663, 31424, 5347, 26, 8352, 908, 8, 277, 14, 5464, 395, 298, 1393, 13, 827, 316, 531, 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,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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 ]
leafclick/intellij-community
python/helpers/py2only/docutils/parsers/rst/languages/zh_cn.py
128
4007
# -*- coding: utf-8 -*- # $Id: zh_cn.py 7119 2011-09-02 13:00:23Z milde $ # Author: Panjunyong <panjy@zopechina.com> # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please # read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. """ Simplified Chinese language mappings for language-dependent features of reStructuredText. """ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed u'注意': 'attention', u'小心': 'caution', u'code (translation required)': 'code', u'危险': 'danger', u'错误': 'error', u'提示': 'hint', u'重要': 'important', u'注解': 'note', u'技巧': 'tip', u'警告': 'warning', u'忠告': 'admonition', u'侧框': 'sidebar', u'主题': 'topic', u'line-block (translation required)': 'line-block', u'parsed-literal (translation required)': 'parsed-literal', u'醒目': 'rubric', u'铭文': 'epigraph', u'要点': 'highlights', u'pull-quote (translation required)': 'pull-quote', u'复合': 'compound', u'容器': 'container', #u'questions (translation required)': 'questions', u'表格': 'table', u'csv表格': 'csv-table', u'列表表格': 'list-table', #u'qa (translation required)': 'questions', #u'faq (translation required)': 'questions', u'元数据': 'meta', u'math (translation required)': 'math', #u'imagemap (translation required)': 'imagemap', u'图片': 'image', u'图例': 'figure', u'包含': 'include', u'原文': 'raw', u'代替': 'replace', u'统一码': 'unicode', u'日期': 'date', u'类型': 'class', u'角色': 'role', u'默认角色': 'default-role', u'标题': 'title', u'目录': 'contents', u'章节序号': 'sectnum', u'题头': 'header', u'页脚': 'footer', #u'footnotes (translation required)': 'footnotes', #u'citations (translation required)': 'citations', u'target-notes (translation required)': 'target-notes', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Simplified Chinese name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed u'缩写': 'abbreviation', u'简称': 'acronym', u'code (translation required)': 'code', u'index (translation required)': 'index', u'i (translation required)': 'index', u'下标': 'subscript', u'上标': 'superscript', u'title-reference (translation required)': 'title-reference', u'title (translation required)': 'title-reference', u't (translation required)': 'title-reference', u'pep-reference (translation required)': 'pep-reference', u'pep (translation required)': 'pep-reference', u'rfc-reference (translation required)': 'rfc-reference', u'rfc (translation required)': 'rfc-reference', u'强调': 'emphasis', u'加粗': 'strong', u'字面': 'literal', u'math (translation required)': 'math', u'named-reference (translation required)': 'named-reference', u'anonymous-reference (translation required)': 'anonymous-reference', u'footnote-reference (translation required)': 'footnote-reference', u'citation-reference (translation required)': 'citation-reference', u'substitution-reference (translation required)': 'substitution-reference', u'target (translation required)': 'target', u'uri-reference (translation required)': 'uri-reference', u'uri (translation required)': 'uri-reference', u'url (translation required)': 'uri-reference', u'raw (translation required)': 'raw',} """Mapping of Simplified Chinese role names to canonical role names for interpreted text."""
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2672, 1304, 26, 1315, 72, 63, 6413, 14, 647, 1520, 7119, 7760, 13, 1643, 13, 996, 4944, 26, 383, 26, 1789, 58, 333, 24446, 2672, 199, 3, 6529, 26, 510, 290, 74, 324, 89, 951, 665, 10384, 24589, 32, 90, 13458, 335, 13765, 14, 957, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 51, 3236, 30200, 2799, 26883, 2637, 13546, 367, 2637, 13, 7106, 4534, 402, 199, 264, 27486, 1872, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 421, 199, 23216, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 399, 7, 20021, 102, 163, 227, 238, 356, 283, 22393, 297, 489, 399, 7, 15348, 238, 16989, 226, 356, 283, 696, 2206, 297, 489, 399, 7, 600, 334, 6893, 1415, 11862, 283, 600, 297, 489, 399, 7, 10450, 110, 17087, 103, 356, 283, 68, 12974, 297, 489, 399, 7, 32064, 356, 283, 705, 297, 489, 399, 7, 22843, 239, 29875, 119, 356, 283, 6479, 297, 489, 399, 7, 10770, 236, 22274, 356, 283, 19559, 297, 489, 399, 7, 20021, 102, 21482, 97, 356, 283, 4610, 297, 489, 399, 7, 11825, 223, 18189, 101, 356, 283, 8996, 297, 489, 399, 7, 165, 256, 100, 19580, 233, 356, 283, 3764, 297, 489, 399, 7, 16989, 255, 19580, 233, 356, 283, 350, 31722, 297, 489, 399, 7, 25439, 101, 31333, 229, 356, 283, 27372, 297, 489, 399, 7, 4344, 120, 21262, 247, 356, 283, 5746, 297, 489, 399, 7, 604, 13, 1457, 334, 6893, 1415, 11862, 283, 604, 13, 1457, 297, 489, 399, 7, 6751, 13, 8939, 334, 6893, 1415, 11862, 283, 6751, 13, 8939, 297, 489, 399, 7, 166, 229, 241, 31869, 356, 283, 21586, 297, 489, 399, 7, 17747, 256, 20918, 356, 283, 1545, 528, 3255, 297, 489, 399, 7, 22274, 164, 225, 118, 356, 283, 14337, 83, 297, 489, 399, 7, 9302, 13, 3513, 334, 6893, 1415, 11862, 283, 9302, 13, 3513, 297, 489, 399, 7, 11546, 236, 16803, 356, 283, 15278, 297, 489, 399, 7, 10270, 118, 162, 248, 102, 356, 283, 3600, 297, 489, 327, 85, 7, 16069, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 399, 7, 23243, 13750, 121, 356, 283, 1224, 297, 489, 399, 7, 4737, 23243, 13750, 121, 356, 283, 4737, 13, 1224, 297, 489, 399, 7, 32551, 23243, 23243, 13750, 121, 356, 283, 513, 13, 1224, 297, 489, 327, 85, 7, 7096, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 327, 85, 7, 667, 81, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 399, 7, 8379, 226, 22730, 356, 283, 2024, 297, 489, 399, 6704, 1619, 334, 6893, 1415, 11862, 283, 3442, 297, 489, 327, 85, 7, 1569, 1130, 334, 6893, 1415, 11862, 283, 1569, 1130, 297, 489, 399, 7, 14339, 123, 19431, 230, 356, 283, 1569, 297, 489, 399, 7, 14339, 123, 25439, 234, 356, 283, 8941, 297, 489, 399, 7, 21018, 228, 8197, 105, 356, 283, 2613, 297, 489, 399, 7, 29708, 254, 20918, 356, 283, 1773, 297, 489, 399, 7, 10192, 24520, 124, 356, 283, 1814, 297, 489, 399, 7, 9360, 254, 9372, 8967, 356, 283, 2975, 297, 489, 399, 7, 31502, 356, 283, 602, 297, 489, 399, 7, 10278, 356, 283, 533, 297, 489, 399, 7, 21482, 241, 165, 232, 111, 356, 283, 3756, 297, 489, 399, 7, 28931, 247, 14082, 98, 21482, 241, 165, 232, 111, 356, 283, 885, 13, 3756, 297, 489, 399, 7, 20767, 21262, 247, 356, 283, 1213, 297, 489, 399, 7, 31869, 22918, 244, 356, 283, 4407, 297, 489, 399, 7, 21341, 255, 165, 233, 225, 15013, 238, 12937, 356, 283, 8519, 1507, 297, 489, 399, 7, 21262, 247, 11546, 113, 356, 283, 1291, 297, 489, 399, 7, 27513, 114, 165, 227, 249, 356, 283, 12781, 297, 489, 327, 85, 7, 11407, 5983, 334, 6893, 1415, 11862, 283, 11407, 5983, 297, 489, 327, 85, 7, 14422, 1298, 334, 6893, 1415, 11862, 283, 14422, 1298, 297, 489, 399, 1133, 839, 13, 5983, 334, 6893, 1415, 11862, 283, 1375, 13, 5983, 297, 489, 399, 3984, 26305, 13, 396, 13, 15047, 356, 283, 26854, 13, 396, 13, 15047, 936, 199, 624, 51, 3236, 30200, 2799, 26883, 536, 370, 7264, 334, 262, 13502, 22128, 826, 4343, 647, 9, 199, 15047, 536, 4412, 1041, 199, 199, 8050, 275, 469, 272, 327, 2637, 13, 7106, 26, 6317, 272, 399, 7, 16505, 103, 17950, 248, 356, 283, 371, 30369, 297, 272, 399, 7, 16716, 223, 19012, 109, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 600, 334, 6893, 1415, 11862, 283, 600, 297, 272, 399, 7, 1080, 334, 6893, 1415, 11862, 283, 1080, 297, 272, 399, 7, 73, 334, 6893, 1415, 11862, 283, 1080, 297, 272, 399, 7, 24233, 20767, 356, 283, 30907, 297, 272, 399, 7, 22661, 20767, 356, 283, 4792, 1579, 297, 272, 399, 1133, 5776, 13, 4443, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 1133, 5776, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 1133, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 7, 12636, 13, 4443, 334, 6893, 1415, 11862, 283, 12636, 13, 4443, 297, 272, 399, 7, 12636, 334, 6893, 1415, 11862, 283, 12636, 13, 4443, 297, 272, 399, 7, 8973, 13, 4443, 334, 6893, 1415, 11862, 283, 8973, 13, 4443, 297, 272, 399, 7, 8973, 334, 6893, 1415, 11862, 283, 8973, 13, 4443, 297, 272, 399, 7, 12586, 119, 165, 109, 226, 356, 283, 28907, 297, 272, 399, 7, 28990, 164, 111, 246, 356, 283, 9370, 297, 272, 399, 7, 26032, 26398, 96, 356, 283, 8939, 297, 272, 399, 6704, 1619, 334, 6893, 1415, 11862, 283, 3442, 297, 272 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2672, 1304, 26, 1315, 72, 63, 6413, 14, 647, 1520, 7119, 7760, 13, 1643, 13, 996, 4944, 26, 383, 26, 1789, 58, 333, 24446, 2672, 199, 3, 6529, 26, 510, 290, 74, 324, 89, 951, 665, 10384, 24589, 32, 90, 13458, 335, 13765, 14, 957, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 51, 3236, 30200, 2799, 26883, 2637, 13546, 367, 2637, 13, 7106, 4534, 402, 199, 264, 27486, 1872, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 421, 199, 23216, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 399, 7, 20021, 102, 163, 227, 238, 356, 283, 22393, 297, 489, 399, 7, 15348, 238, 16989, 226, 356, 283, 696, 2206, 297, 489, 399, 7, 600, 334, 6893, 1415, 11862, 283, 600, 297, 489, 399, 7, 10450, 110, 17087, 103, 356, 283, 68, 12974, 297, 489, 399, 7, 32064, 356, 283, 705, 297, 489, 399, 7, 22843, 239, 29875, 119, 356, 283, 6479, 297, 489, 399, 7, 10770, 236, 22274, 356, 283, 19559, 297, 489, 399, 7, 20021, 102, 21482, 97, 356, 283, 4610, 297, 489, 399, 7, 11825, 223, 18189, 101, 356, 283, 8996, 297, 489, 399, 7, 165, 256, 100, 19580, 233, 356, 283, 3764, 297, 489, 399, 7, 16989, 255, 19580, 233, 356, 283, 350, 31722, 297, 489, 399, 7, 25439, 101, 31333, 229, 356, 283, 27372, 297, 489, 399, 7, 4344, 120, 21262, 247, 356, 283, 5746, 297, 489, 399, 7, 604, 13, 1457, 334, 6893, 1415, 11862, 283, 604, 13, 1457, 297, 489, 399, 7, 6751, 13, 8939, 334, 6893, 1415, 11862, 283, 6751, 13, 8939, 297, 489, 399, 7, 166, 229, 241, 31869, 356, 283, 21586, 297, 489, 399, 7, 17747, 256, 20918, 356, 283, 1545, 528, 3255, 297, 489, 399, 7, 22274, 164, 225, 118, 356, 283, 14337, 83, 297, 489, 399, 7, 9302, 13, 3513, 334, 6893, 1415, 11862, 283, 9302, 13, 3513, 297, 489, 399, 7, 11546, 236, 16803, 356, 283, 15278, 297, 489, 399, 7, 10270, 118, 162, 248, 102, 356, 283, 3600, 297, 489, 327, 85, 7, 16069, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 399, 7, 23243, 13750, 121, 356, 283, 1224, 297, 489, 399, 7, 4737, 23243, 13750, 121, 356, 283, 4737, 13, 1224, 297, 489, 399, 7, 32551, 23243, 23243, 13750, 121, 356, 283, 513, 13, 1224, 297, 489, 327, 85, 7, 7096, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 327, 85, 7, 667, 81, 334, 6893, 1415, 11862, 283, 16069, 297, 489, 399, 7, 8379, 226, 22730, 356, 283, 2024, 297, 489, 399, 6704, 1619, 334, 6893, 1415, 11862, 283, 3442, 297, 489, 327, 85, 7, 1569, 1130, 334, 6893, 1415, 11862, 283, 1569, 1130, 297, 489, 399, 7, 14339, 123, 19431, 230, 356, 283, 1569, 297, 489, 399, 7, 14339, 123, 25439, 234, 356, 283, 8941, 297, 489, 399, 7, 21018, 228, 8197, 105, 356, 283, 2613, 297, 489, 399, 7, 29708, 254, 20918, 356, 283, 1773, 297, 489, 399, 7, 10192, 24520, 124, 356, 283, 1814, 297, 489, 399, 7, 9360, 254, 9372, 8967, 356, 283, 2975, 297, 489, 399, 7, 31502, 356, 283, 602, 297, 489, 399, 7, 10278, 356, 283, 533, 297, 489, 399, 7, 21482, 241, 165, 232, 111, 356, 283, 3756, 297, 489, 399, 7, 28931, 247, 14082, 98, 21482, 241, 165, 232, 111, 356, 283, 885, 13, 3756, 297, 489, 399, 7, 20767, 21262, 247, 356, 283, 1213, 297, 489, 399, 7, 31869, 22918, 244, 356, 283, 4407, 297, 489, 399, 7, 21341, 255, 165, 233, 225, 15013, 238, 12937, 356, 283, 8519, 1507, 297, 489, 399, 7, 21262, 247, 11546, 113, 356, 283, 1291, 297, 489, 399, 7, 27513, 114, 165, 227, 249, 356, 283, 12781, 297, 489, 327, 85, 7, 11407, 5983, 334, 6893, 1415, 11862, 283, 11407, 5983, 297, 489, 327, 85, 7, 14422, 1298, 334, 6893, 1415, 11862, 283, 14422, 1298, 297, 489, 399, 1133, 839, 13, 5983, 334, 6893, 1415, 11862, 283, 1375, 13, 5983, 297, 489, 399, 3984, 26305, 13, 396, 13, 15047, 356, 283, 26854, 13, 396, 13, 15047, 936, 199, 624, 51, 3236, 30200, 2799, 26883, 536, 370, 7264, 334, 262, 13502, 22128, 826, 4343, 647, 9, 199, 15047, 536, 4412, 1041, 199, 199, 8050, 275, 469, 272, 327, 2637, 13, 7106, 26, 6317, 272, 399, 7, 16505, 103, 17950, 248, 356, 283, 371, 30369, 297, 272, 399, 7, 16716, 223, 19012, 109, 356, 283, 645, 2641, 12828, 297, 272, 399, 7, 600, 334, 6893, 1415, 11862, 283, 600, 297, 272, 399, 7, 1080, 334, 6893, 1415, 11862, 283, 1080, 297, 272, 399, 7, 73, 334, 6893, 1415, 11862, 283, 1080, 297, 272, 399, 7, 24233, 20767, 356, 283, 30907, 297, 272, 399, 7, 22661, 20767, 356, 283, 4792, 1579, 297, 272, 399, 1133, 5776, 13, 4443, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 1133, 5776, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 1133, 334, 6893, 1415, 11862, 283, 1213, 13, 4443, 297, 272, 399, 7, 12636, 13, 4443, 334, 6893, 1415, 11862, 283, 12636, 13, 4443, 297, 272, 399, 7, 12636, 334, 6893, 1415, 11862, 283, 12636, 13, 4443, 297, 272, 399, 7, 8973, 13, 4443, 334, 6893, 1415, 11862, 283, 8973, 13, 4443, 297, 272, 399, 7, 8973, 334, 6893, 1415, 11862, 283, 8973, 13, 4443, 297, 272, 399, 7, 12586, 119, 165, 109, 226, 356, 283, 28907, 297, 272, 399, 7, 28990, 164, 111, 246, 356, 283, 9370, 297, 272, 399, 7, 26032, 26398, 96, 356, 283, 8939, 297, 272, 399, 6704, 1619, 334, 6893, 1415, 11862, 283, 3442, 297, 272, 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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