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
Vixionar/django
tests/model_forms/models.py
135
14126
""" XX. Generating HTML forms from models This is mostly just a reworking of the ``form_for_model``/``form_for_instance`` tests to use ``ModelForm``. As such, the text may not make sense in all cases, and the examples are probably a poor fit for the ``ModelForm`` syntax. In other words, most of these tests should be rewritten. """ from __future__ import unicode_literals import datetime import os import tempfile import uuid from django.core import validators from django.core.exceptions import ValidationError from django.core.files.storage import FileSystemStorage from django.db import models from django.utils import six from django.utils._os import upath from django.utils.encoding import python_2_unicode_compatible from django.utils.six.moves import range temp_storage_dir = tempfile.mkdtemp() temp_storage = FileSystemStorage(temp_storage_dir) ARTICLE_STATUS = ( (1, 'Draft'), (2, 'Pending'), (3, 'Live'), ) ARTICLE_STATUS_CHAR = ( ('d', 'Draft'), ('p', 'Pending'), ('l', 'Live'), ) class Person(models.Model): name = models.CharField(max_length=100) @python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) slug = models.SlugField(max_length=20) url = models.CharField('The URL', max_length=40) def __str__(self): return self.name def __repr__(self): return self.__str__() @python_2_unicode_compatible class Writer(models.Model): name = models.CharField(max_length=50, help_text='Use both first and last names.') class Meta: ordering = ('name',) def __str__(self): return self.name @python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=50) slug = models.SlugField() pub_date = models.DateField() created = models.DateField(editable=False) writer = models.ForeignKey(Writer, models.CASCADE) article = models.TextField() categories = models.ManyToManyField(Category, blank=True) status = models.PositiveIntegerField(choices=ARTICLE_STATUS, blank=True, null=True) def save(self, *args, **kwargs): if not self.id: self.created = datetime.date.today() return super(Article, self).save(*args, **kwargs) def __str__(self): return self.headline class ImprovedArticle(models.Model): article = models.OneToOneField(Article, models.CASCADE) class ImprovedArticleWithParentLink(models.Model): article = models.OneToOneField(Article, models.CASCADE, parent_link=True) class BetterWriter(Writer): score = models.IntegerField() @python_2_unicode_compatible class Publication(models.Model): title = models.CharField(max_length=30) date_published = models.DateField() def __str__(self): return self.title def default_mode(): return 'di' def default_category(): return 3 class PublicationDefaults(models.Model): MODE_CHOICES = (('di', 'direct'), ('de', 'delayed')) CATEGORY_CHOICES = ((1, 'Games'), (2, 'Comics'), (3, 'Novel')) title = models.CharField(max_length=30) date_published = models.DateField(default=datetime.date.today) mode = models.CharField(max_length=2, choices=MODE_CHOICES, default=default_mode) category = models.IntegerField(choices=CATEGORY_CHOICES, default=default_category) class Author(models.Model): publication = models.OneToOneField(Publication, models.SET_NULL, null=True, blank=True) full_name = models.CharField(max_length=255) class Author1(models.Model): publication = models.OneToOneField(Publication, models.SET_NULL, null=False) full_name = models.CharField(max_length=255) @python_2_unicode_compatible class WriterProfile(models.Model): writer = models.OneToOneField(Writer, models.CASCADE, primary_key=True) age = models.PositiveIntegerField() def __str__(self): return "%s is %s" % (self.writer, self.age) class Document(models.Model): myfile = models.FileField(upload_to='unused', blank=True) @python_2_unicode_compatible class TextFile(models.Model): description = models.CharField(max_length=20) file = models.FileField(storage=temp_storage, upload_to='tests', max_length=15) def __str__(self): return self.description class CustomFileField(models.FileField): def save_form_data(self, instance, data): been_here = getattr(self, 'been_saved', False) assert not been_here, "save_form_data called more than once" setattr(self, 'been_saved', True) class CustomFF(models.Model): f = CustomFileField(upload_to='unused', blank=True) class FilePathModel(models.Model): path = models.FilePathField(path=os.path.dirname(upath(__file__)), match=".*\.py$", blank=True) try: from PIL import Image # NOQA: detect if Pillow is installed test_images = True @python_2_unicode_compatible class ImageFile(models.Model): def custom_upload_path(self, filename): path = self.path or 'tests' return '%s/%s' % (path, filename) description = models.CharField(max_length=20) # Deliberately put the image field *after* the width/height fields to # trigger the bug in #10404 with width/height not getting assigned. width = models.IntegerField(editable=False) height = models.IntegerField(editable=False) image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path, width_field='width', height_field='height') path = models.CharField(max_length=16, blank=True, default='') def __str__(self): return self.description @python_2_unicode_compatible class OptionalImageFile(models.Model): def custom_upload_path(self, filename): path = self.path or 'tests' return '%s/%s' % (path, filename) description = models.CharField(max_length=20) image = models.ImageField(storage=temp_storage, upload_to=custom_upload_path, width_field='width', height_field='height', blank=True, null=True) width = models.IntegerField(editable=False, null=True) height = models.IntegerField(editable=False, null=True) path = models.CharField(max_length=16, blank=True, default='') def __str__(self): return self.description except ImportError: test_images = False @python_2_unicode_compatible class CommaSeparatedInteger(models.Model): field = models.CommaSeparatedIntegerField(max_length=20) def __str__(self): return self.field class Homepage(models.Model): url = models.URLField() @python_2_unicode_compatible class Product(models.Model): slug = models.SlugField(unique=True) def __str__(self): return self.slug @python_2_unicode_compatible class Price(models.Model): price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField() def __str__(self): return "%s for %s" % (self.quantity, self.price) class Meta: unique_together = (('price', 'quantity'),) class Triple(models.Model): left = models.IntegerField() middle = models.IntegerField() right = models.IntegerField() class Meta: unique_together = (('left', 'middle'), ('middle', 'right')) class ArticleStatus(models.Model): status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True) @python_2_unicode_compatible class Inventory(models.Model): barcode = models.PositiveIntegerField(unique=True) parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True) name = models.CharField(blank=False, max_length=20) class Meta: ordering = ('name',) def __str__(self): return self.name def __repr__(self): return self.__str__() class Book(models.Model): title = models.CharField(max_length=40) author = models.ForeignKey(Writer, models.SET_NULL, blank=True, null=True) special_id = models.IntegerField(blank=True, null=True, unique=True) class Meta: unique_together = ('title', 'author') class BookXtra(models.Model): isbn = models.CharField(max_length=16, unique=True) suffix1 = models.IntegerField(blank=True, default=0) suffix2 = models.IntegerField(blank=True, default=0) class Meta: unique_together = (('suffix1', 'suffix2')) abstract = True class DerivedBook(Book, BookXtra): pass @python_2_unicode_compatible class ExplicitPK(models.Model): key = models.CharField(max_length=20, primary_key=True) desc = models.CharField(max_length=20, blank=True, unique=True) class Meta: unique_together = ('key', 'desc') def __str__(self): return self.key @python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateField() def __str__(self): return self.title @python_2_unicode_compatible class DateTimePost(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateTimeField(editable=False) def __str__(self): return self.title class DerivedPost(Post): pass @python_2_unicode_compatible class BigInt(models.Model): biggie = models.BigIntegerField() def __str__(self): return six.text_type(self.biggie) class MarkupField(models.CharField): def __init__(self, *args, **kwargs): kwargs["max_length"] = 20 super(MarkupField, self).__init__(*args, **kwargs) def formfield(self, **kwargs): # don't allow this field to be used in form (real use-case might be # that you know the markup will always be X, but it is among an app # that allows the user to say it could be something else) # regressed at r10062 return None class CustomFieldForExclusionModel(models.Model): name = models.CharField(max_length=10) markup = MarkupField() class FlexibleDatePost(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateField(blank=True, null=True) @python_2_unicode_compatible class Colour(models.Model): name = models.CharField(max_length=50) def __iter__(self): for number in range(5): yield number def __str__(self): return self.name class ColourfulItem(models.Model): name = models.CharField(max_length=50) colours = models.ManyToManyField(Colour) class CustomErrorMessage(models.Model): name1 = models.CharField(max_length=50, validators=[validators.validate_slug], error_messages={'invalid': 'Model custom error message.'}) name2 = models.CharField(max_length=50, validators=[validators.validate_slug], error_messages={'invalid': 'Model custom error message.'}) def clean(self): if self.name1 == 'FORBIDDEN_VALUE': raise ValidationError({'name1': [ValidationError('Model.clean() error messages.')]}) elif self.name1 == 'FORBIDDEN_VALUE2': raise ValidationError({'name1': 'Model.clean() error messages (simpler syntax).'}) elif self.name1 == 'GLOBAL_ERROR': raise ValidationError("Global error message.") def today_callable_dict(): return {"last_action__gte": datetime.datetime.today()} def today_callable_q(): return models.Q(last_action__gte=datetime.datetime.today()) class Character(models.Model): username = models.CharField(max_length=100) last_action = models.DateTimeField() class StumpJoke(models.Model): most_recently_fooled = models.ForeignKey( Character, models.CASCADE, limit_choices_to=today_callable_dict, related_name="+", ) has_fooled_today = models.ManyToManyField(Character, limit_choices_to=today_callable_q, related_name="+") # Model for #13776 class Student(models.Model): character = models.ForeignKey(Character, models.CASCADE) study = models.CharField(max_length=30) # Model for #639 class Photo(models.Model): title = models.CharField(max_length=30) image = models.FileField(storage=temp_storage, upload_to='tests') # Support code for the tests; this keeps track of how many times save() # gets called on each instance. def __init__(self, *args, **kwargs): super(Photo, self).__init__(*args, **kwargs) self._savecount = 0 def save(self, force_insert=False, force_update=False): super(Photo, self).save(force_insert, force_update) self._savecount += 1 class UUIDPK(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=30) # Models for #24706 class StrictAssignmentFieldSpecific(models.Model): title = models.CharField(max_length=30) _should_error = False def __setattr__(self, key, value): if self._should_error is True: raise ValidationError(message={key: "Cannot set attribute"}, code='invalid') super(StrictAssignmentFieldSpecific, self).__setattr__(key, value) class StrictAssignmentAll(models.Model): title = models.CharField(max_length=30) _should_error = False def __setattr__(self, key, value): if self._should_error is True: raise ValidationError(message="Cannot set attribute", code='invalid') super(StrictAssignmentAll, self).__setattr__(key, value)
bsd-3-clause
[ 624, 199, 2483, 14, 1464, 1958, 4163, 4513, 687, 1709, 199, 199, 2765, 365, 19762, 2951, 282, 295, 9818, 402, 314, 1124, 964, 63, 509, 63, 1238, 1040, 15, 1040, 964, 63, 509, 63, 842, 1040, 199, 2219, 370, 675, 1124, 15937, 4345, 3709, 4066, 12, 314, 1318, 1443, 440, 1852, 12249, 315, 1006, 5560, 12, 199, 460, 314, 7251, 787, 8646, 282, 1115, 269, 5542, 367, 314, 1124, 15937, 1040, 6302, 14, 1010, 1163, 199, 3148, 12, 4750, 402, 3520, 2295, 1077, 506, 28286, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 5549, 199, 646, 5377, 199, 199, 504, 1639, 14, 1018, 492, 14370, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 808, 63, 3494, 63, 694, 275, 5549, 14, 11983, 342, 199, 808, 63, 3494, 275, 23754, 6408, 8, 808, 63, 3494, 63, 694, 9, 199, 199, 2294, 948, 906, 63, 6305, 275, 334, 272, 334, 17, 12, 283, 18332, 659, 272, 334, 18, 12, 283, 15960, 659, 272, 334, 19, 12, 283, 17458, 659, 199, 9, 199, 199, 2294, 948, 906, 63, 6305, 63, 5901, 275, 334, 272, 661, 68, 297, 283, 18332, 659, 272, 661, 80, 297, 283, 15960, 659, 272, 661, 76, 297, 283, 17458, 659, 199, 9, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 13573, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 8889, 275, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1165, 9, 272, 1166, 275, 1709, 14, 2183, 360, 1918, 2851, 297, 1390, 63, 1267, 29, 2167, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24441, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 1720, 63, 505, 534, 6119, 3865, 1642, 436, 2061, 1561, 2659, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 21250, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 8889, 275, 1709, 14, 17315, 342, 272, 7974, 63, 602, 275, 1709, 14, 14071, 342, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 272, 7060, 275, 1709, 14, 3190, 8, 6261, 12, 1709, 14, 10855, 9, 272, 9772, 275, 1709, 14, 6254, 342, 272, 9695, 275, 1709, 14, 7624, 8, 7841, 12, 4596, 29, 549, 9, 272, 2004, 275, 1709, 14, 8591, 8, 4577, 29, 2294, 948, 906, 63, 6305, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 14, 344, 26, 288, 291, 14, 3966, 275, 2197, 14, 602, 14, 8136, 342, 267, 372, 1613, 8, 7221, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 11268, 421, 199, 533, 8362, 26429, 7221, 8, 992, 14, 1685, 304, 272, 9772, 275, 1709, 14, 14298, 8, 7221, 12, 1709, 14, 10855, 9, 421, 199, 533, 8362, 26429, 7221, 3007, 6652, 3834, 8, 992, 14, 1685, 304, 272, 9772, 275, 1709, 14, 14298, 8, 7221, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 421, 199, 533, 31535, 351, 6261, 8, 6261, 304, 272, 5396, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 1684, 425, 8, 992, 14, 1685, 304, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 1434, 63, 8987, 275, 1709, 14, 14071, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 318, 849, 63, 632, 837, 272, 372, 283, 328, 7, 421, 199, 318, 849, 63, 3710, 837, 272, 372, 650, 421, 199, 533, 1684, 425, 16986, 8, 992, 14, 1685, 304, 272, 27065, 63, 16236, 275, 13636, 328, 297, 283, 2275, 659, 661, 271, 297, 283, 21830, 1333, 272, 24004, 63, 16236, 275, 3666, 17, 12, 283, 11454, 83, 659, 334, 18, 12, 283, 4373, 2932, 659, 334, 19, 12, 283, 1944, 1090, 1333, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 1434, 63, 8987, 275, 1709, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 9, 272, 818, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 12, 3415, 29, 6963, 63, 16236, 12, 849, 29, 885, 63, 632, 9, 272, 4637, 275, 1709, 14, 3901, 8, 4577, 29, 22690, 63, 16236, 12, 849, 29, 885, 63, 3710, 9, 421, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 31997, 275, 1709, 14, 14298, 8, 27283, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 2615, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 421, 199, 533, 6529, 17, 8, 992, 14, 1685, 304, 272, 31997, 275, 1709, 14, 14298, 8, 27283, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 797, 9, 272, 2615, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24441, 5736, 8, 992, 14, 1685, 304, 272, 7060, 275, 1709, 14, 14298, 8, 6261, 12, 1709, 14, 10855, 12, 5062, 63 ]
[ 199, 2483, 14, 1464, 1958, 4163, 4513, 687, 1709, 199, 199, 2765, 365, 19762, 2951, 282, 295, 9818, 402, 314, 1124, 964, 63, 509, 63, 1238, 1040, 15, 1040, 964, 63, 509, 63, 842, 1040, 199, 2219, 370, 675, 1124, 15937, 4345, 3709, 4066, 12, 314, 1318, 1443, 440, 1852, 12249, 315, 1006, 5560, 12, 199, 460, 314, 7251, 787, 8646, 282, 1115, 269, 5542, 367, 314, 1124, 15937, 1040, 6302, 14, 1010, 1163, 199, 3148, 12, 4750, 402, 3520, 2295, 1077, 506, 28286, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 5549, 199, 646, 5377, 199, 199, 504, 1639, 14, 1018, 492, 14370, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 808, 63, 3494, 63, 694, 275, 5549, 14, 11983, 342, 199, 808, 63, 3494, 275, 23754, 6408, 8, 808, 63, 3494, 63, 694, 9, 199, 199, 2294, 948, 906, 63, 6305, 275, 334, 272, 334, 17, 12, 283, 18332, 659, 272, 334, 18, 12, 283, 15960, 659, 272, 334, 19, 12, 283, 17458, 659, 199, 9, 199, 199, 2294, 948, 906, 63, 6305, 63, 5901, 275, 334, 272, 661, 68, 297, 283, 18332, 659, 272, 661, 80, 297, 283, 15960, 659, 272, 661, 76, 297, 283, 17458, 659, 199, 9, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 13573, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 8889, 275, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1165, 9, 272, 1166, 275, 1709, 14, 2183, 360, 1918, 2851, 297, 1390, 63, 1267, 29, 2167, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24441, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 1720, 63, 505, 534, 6119, 3865, 1642, 436, 2061, 1561, 2659, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 21250, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 8889, 275, 1709, 14, 17315, 342, 272, 7974, 63, 602, 275, 1709, 14, 14071, 342, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 272, 7060, 275, 1709, 14, 3190, 8, 6261, 12, 1709, 14, 10855, 9, 272, 9772, 275, 1709, 14, 6254, 342, 272, 9695, 275, 1709, 14, 7624, 8, 7841, 12, 4596, 29, 549, 9, 272, 2004, 275, 1709, 14, 8591, 8, 4577, 29, 2294, 948, 906, 63, 6305, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 14, 344, 26, 288, 291, 14, 3966, 275, 2197, 14, 602, 14, 8136, 342, 267, 372, 1613, 8, 7221, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 11268, 421, 199, 533, 8362, 26429, 7221, 8, 992, 14, 1685, 304, 272, 9772, 275, 1709, 14, 14298, 8, 7221, 12, 1709, 14, 10855, 9, 421, 199, 533, 8362, 26429, 7221, 3007, 6652, 3834, 8, 992, 14, 1685, 304, 272, 9772, 275, 1709, 14, 14298, 8, 7221, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 421, 199, 533, 31535, 351, 6261, 8, 6261, 304, 272, 5396, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 1684, 425, 8, 992, 14, 1685, 304, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 1434, 63, 8987, 275, 1709, 14, 14071, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 318, 849, 63, 632, 837, 272, 372, 283, 328, 7, 421, 199, 318, 849, 63, 3710, 837, 272, 372, 650, 421, 199, 533, 1684, 425, 16986, 8, 992, 14, 1685, 304, 272, 27065, 63, 16236, 275, 13636, 328, 297, 283, 2275, 659, 661, 271, 297, 283, 21830, 1333, 272, 24004, 63, 16236, 275, 3666, 17, 12, 283, 11454, 83, 659, 334, 18, 12, 283, 4373, 2932, 659, 334, 19, 12, 283, 1944, 1090, 1333, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 1434, 63, 8987, 275, 1709, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 9, 272, 818, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 12, 3415, 29, 6963, 63, 16236, 12, 849, 29, 885, 63, 632, 9, 272, 4637, 275, 1709, 14, 3901, 8, 4577, 29, 22690, 63, 16236, 12, 849, 29, 885, 63, 3710, 9, 421, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 31997, 275, 1709, 14, 14298, 8, 27283, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 2615, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 421, 199, 533, 6529, 17, 8, 992, 14, 1685, 304, 272, 31997, 275, 1709, 14, 14298, 8, 27283, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 797, 9, 272, 2615, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24441, 5736, 8, 992, 14, 1685, 304, 272, 7060, 275, 1709, 14, 14298, 8, 6261, 12, 1709, 14, 10855, 12, 5062, 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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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 ]
redondomarco/useradm
doc/pykadm5/setup.py
2
1039
include_dirs = ['/usr/include'] library_dirs = ['/usr/lib'] runtime_library_dirs = ['/usr/lib'] libraries = ['kadm5clnt', 'com_err'] define_macros = [('NO_DEBUG', 1)] from distutils.core import setup, Extension setup(name='pykadm5', version='0.2', py_modules=['pykadm5'], ext_modules=[Extension('_pykadm5', ['wrap_pykadm5.c', 'err.c'], include_dirs=include_dirs, library_dirs=library_dirs, runtime_library_dirs=runtime_library_dirs, libraries=libraries, define_macros=define_macros)], description='Kerberos5 Admin function', author='Josef Boleininger', author_email='iosif69@googlemail.com', url='http://pykadm5.googlecode.com/svn', long_description = \ """pykadm5 is a C extension module to perform some administrative function using Kerberos 5 Admin. It requires the MIT library""", )
gpl-3.0
[ 2613, 63, 3220, 275, 3515, 18744, 2647, 15, 2613, 418, 199, 4342, 63, 3220, 275, 3515, 18744, 2647, 15, 773, 418, 199, 7726, 63, 4342, 63, 3220, 275, 221, 18744, 2647, 15, 773, 418, 199, 10159, 275, 3777, 788, 75, 14464, 21, 429, 343, 297, 283, 957, 63, 1508, 418, 199, 4640, 63, 16358, 275, 260, 4274, 2826, 63, 5287, 297, 413, 1874, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 199, 2758, 8, 354, 534, 647, 75, 14464, 21, 297, 489, 1015, 534, 16, 14, 18, 297, 489, 1134, 63, 3112, 2968, 647, 75, 14464, 21, 995, 489, 1599, 63, 3112, 1524, 6382, 6412, 647, 75, 14464, 21, 297, 788, 3823, 63, 647, 75, 14464, 21, 14, 67, 297, 283, 1508, 14, 67, 995, 2490, 2387, 63, 3220, 29, 2613, 63, 3220, 12, 2490, 3555, 63, 3220, 29, 4342, 63, 3220, 12, 2490, 8836, 63, 4342, 63, 3220, 29, 7726, 63, 4342, 63, 3220, 12, 2490, 8363, 29, 10159, 12, 2490, 5627, 63, 16358, 29, 4640, 63, 16358, 4360, 489, 1369, 534, 43, 281, 23920, 21, 9516, 805, 297, 489, 4132, 534, 42, 3362, 70, 5088, 274, 262, 7886, 297, 489, 4132, 63, 2123, 534, 2308, 338, 70, 1876, 32, 3098, 1198, 14, 957, 297, 489, 1166, 534, 1014, 921, 647, 75, 14464, 21, 14, 31864, 14, 957, 15, 6836, 297, 489, 1846, 63, 1802, 275, 971, 489, 408, 647, 75, 14464, 21, 365, 282, 445, 3329, 859, 370, 5147, 2005, 4628, 25124, 805, 1808, 1804, 281, 23920, 959, 9516, 14, 489, 2779, 5074, 314, 10697, 3555, 7208, 489, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 63, 3220, 275, 3515, 18744, 2647, 15, 2613, 418, 199, 4342, 63, 3220, 275, 3515, 18744, 2647, 15, 773, 418, 199, 7726, 63, 4342, 63, 3220, 275, 221, 18744, 2647, 15, 773, 418, 199, 10159, 275, 3777, 788, 75, 14464, 21, 429, 343, 297, 283, 957, 63, 1508, 418, 199, 4640, 63, 16358, 275, 260, 4274, 2826, 63, 5287, 297, 413, 1874, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 199, 2758, 8, 354, 534, 647, 75, 14464, 21, 297, 489, 1015, 534, 16, 14, 18, 297, 489, 1134, 63, 3112, 2968, 647, 75, 14464, 21, 995, 489, 1599, 63, 3112, 1524, 6382, 6412, 647, 75, 14464, 21, 297, 788, 3823, 63, 647, 75, 14464, 21, 14, 67, 297, 283, 1508, 14, 67, 995, 2490, 2387, 63, 3220, 29, 2613, 63, 3220, 12, 2490, 3555, 63, 3220, 29, 4342, 63, 3220, 12, 2490, 8836, 63, 4342, 63, 3220, 29, 7726, 63, 4342, 63, 3220, 12, 2490, 8363, 29, 10159, 12, 2490, 5627, 63, 16358, 29, 4640, 63, 16358, 4360, 489, 1369, 534, 43, 281, 23920, 21, 9516, 805, 297, 489, 4132, 534, 42, 3362, 70, 5088, 274, 262, 7886, 297, 489, 4132, 63, 2123, 534, 2308, 338, 70, 1876, 32, 3098, 1198, 14, 957, 297, 489, 1166, 534, 1014, 921, 647, 75, 14464, 21, 14, 31864, 14, 957, 15, 6836, 297, 489, 1846, 63, 1802, 275, 971, 489, 408, 647, 75, 14464, 21, 365, 282, 445, 3329, 859, 370, 5147, 2005, 4628, 25124, 805, 1808, 1804, 281, 23920, 959, 9516, 14, 489, 2779, 5074, 314, 10697, 3555, 7208, 489, 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, 32768, 32768, 32768, 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, 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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 ]
stevenwudi/Kernelized_Correlation_Filter
pyhog/pyhog.py
2
1030
import numpy as np import features_pedro_py try: from scipy.misc import imrotate imrotate_available = True except ImportError: imrotate_available = False def features_pedro(img, sbin): imgf = img.copy('F') hogf = features_pedro_py.process(imgf, sbin) return hogf def hog_picture(w, bs=20): """ Visualize positive HOG weights. ported to numpy from https://github.com/CSAILVision/ihog/blob/master/showHOG.m """ if not imrotate_available: raise RuntimeError('This function requires scipy') bim1 = np.zeros((bs, bs)) bim1[:,round(bs/2)-1:round(bs/2)] = 1 bim = np.zeros((9,)+bim1.shape) for i in xrange(9): bim[i] = imrotate(bim1, -i*20)/255.0 s = w.shape w = w.copy() w[w < 0] = 0 im = np.zeros((bs*s[0], bs*s[1])) for i in xrange(s[0]): iis = slice( i*bs, (i+1)*bs ) for j in xrange(s[1]): jjs = slice( j*bs, (j+1)*bs ) for k in xrange(9): im[iis,jjs] += bim[k] * w[i,j,k+18] return im/np.max(w)
gpl-3.0
[ 199, 646, 2680, 465, 980, 199, 646, 4534, 63, 1915, 293, 63, 647, 199, 199, 893, 26, 272, 687, 7026, 14, 9923, 492, 3416, 12873, 272, 3416, 12873, 63, 4561, 275, 715, 199, 2590, 3545, 26, 272, 3416, 12873, 63, 4561, 275, 756, 199, 199, 318, 4534, 63, 1915, 293, 8, 4060, 12, 308, 1393, 304, 272, 6050, 70, 275, 6050, 14, 1574, 360, 38, 358, 272, 394, 974, 70, 275, 4534, 63, 1915, 293, 63, 647, 14, 1412, 8, 4060, 70, 12, 308, 1393, 9, 272, 372, 394, 974, 70, 199, 199, 318, 394, 974, 63, 12538, 8, 87, 12, 9922, 29, 1165, 304, 272, 408, 14702, 794, 7317, 7781, 39, 4931, 14, 272, 299, 1376, 370, 2680, 687, 4178, 921, 5031, 14, 957, 15, 3298, 6593, 2201, 438, 15, 73, 526, 71, 15, 6582, 15, 4133, 15, 2384, 2979, 39, 14, 77, 272, 408, 272, 340, 440, 3416, 12873, 63, 4561, 26, 267, 746, 6064, 360, 2765, 805, 5074, 7026, 358, 272, 330, 1017, 17, 275, 980, 14, 4250, 1332, 1533, 12, 9922, 430, 272, 330, 1017, 17, 3981, 2363, 8, 1533, 15, 18, 7216, 17, 26, 2363, 8, 1533, 15, 18, 1874, 275, 413, 272, 330, 1017, 275, 980, 14, 4250, 1332, 25, 4258, 11, 66, 1017, 17, 14, 1392, 9, 272, 367, 284, 315, 4945, 8, 25, 304, 489, 330, 1017, 59, 73, 61, 275, 3416, 12873, 8, 66, 1017, 17, 12, 446, 73, 10, 1165, 2447, 2299, 14, 16, 272, 308, 275, 336, 14, 1392, 272, 336, 275, 336, 14, 1574, 342, 272, 336, 59, 87, 665, 378, 61, 275, 378, 272, 3416, 275, 980, 14, 4250, 1332, 1533, 10, 83, 59, 16, 467, 9922, 10, 83, 59, 17, 2459, 272, 367, 284, 315, 4945, 8, 83, 59, 16, 4682, 489, 284, 374, 275, 6014, 8, 284, 10, 1533, 12, 334, 73, 11, 17, 3342, 1533, 776, 489, 367, 1335, 315, 4945, 8, 83, 59, 17, 4682, 267, 1335, 3596, 275, 6014, 8, 1335, 10, 1533, 12, 334, 74, 11, 17, 3342, 1533, 776, 267, 367, 1022, 315, 4945, 8, 25, 304, 881, 3416, 59, 73, 374, 12, 74, 3596, 61, 847, 330, 1017, 59, 75, 61, 627, 336, 59, 73, 12, 74, 12, 75, 11, 1085, 61, 272, 372, 3416, 15, 1590, 14, 988, 8, 87, 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 ]
[ 646, 2680, 465, 980, 199, 646, 4534, 63, 1915, 293, 63, 647, 199, 199, 893, 26, 272, 687, 7026, 14, 9923, 492, 3416, 12873, 272, 3416, 12873, 63, 4561, 275, 715, 199, 2590, 3545, 26, 272, 3416, 12873, 63, 4561, 275, 756, 199, 199, 318, 4534, 63, 1915, 293, 8, 4060, 12, 308, 1393, 304, 272, 6050, 70, 275, 6050, 14, 1574, 360, 38, 358, 272, 394, 974, 70, 275, 4534, 63, 1915, 293, 63, 647, 14, 1412, 8, 4060, 70, 12, 308, 1393, 9, 272, 372, 394, 974, 70, 199, 199, 318, 394, 974, 63, 12538, 8, 87, 12, 9922, 29, 1165, 304, 272, 408, 14702, 794, 7317, 7781, 39, 4931, 14, 272, 299, 1376, 370, 2680, 687, 4178, 921, 5031, 14, 957, 15, 3298, 6593, 2201, 438, 15, 73, 526, 71, 15, 6582, 15, 4133, 15, 2384, 2979, 39, 14, 77, 272, 408, 272, 340, 440, 3416, 12873, 63, 4561, 26, 267, 746, 6064, 360, 2765, 805, 5074, 7026, 358, 272, 330, 1017, 17, 275, 980, 14, 4250, 1332, 1533, 12, 9922, 430, 272, 330, 1017, 17, 3981, 2363, 8, 1533, 15, 18, 7216, 17, 26, 2363, 8, 1533, 15, 18, 1874, 275, 413, 272, 330, 1017, 275, 980, 14, 4250, 1332, 25, 4258, 11, 66, 1017, 17, 14, 1392, 9, 272, 367, 284, 315, 4945, 8, 25, 304, 489, 330, 1017, 59, 73, 61, 275, 3416, 12873, 8, 66, 1017, 17, 12, 446, 73, 10, 1165, 2447, 2299, 14, 16, 272, 308, 275, 336, 14, 1392, 272, 336, 275, 336, 14, 1574, 342, 272, 336, 59, 87, 665, 378, 61, 275, 378, 272, 3416, 275, 980, 14, 4250, 1332, 1533, 10, 83, 59, 16, 467, 9922, 10, 83, 59, 17, 2459, 272, 367, 284, 315, 4945, 8, 83, 59, 16, 4682, 489, 284, 374, 275, 6014, 8, 284, 10, 1533, 12, 334, 73, 11, 17, 3342, 1533, 776, 489, 367, 1335, 315, 4945, 8, 83, 59, 17, 4682, 267, 1335, 3596, 275, 6014, 8, 1335, 10, 1533, 12, 334, 74, 11, 17, 3342, 1533, 776, 267, 367, 1022, 315, 4945, 8, 25, 304, 881, 3416, 59, 73, 374, 12, 74, 3596, 61, 847, 330, 1017, 59, 75, 61, 627, 336, 59, 73, 12, 74, 12, 75, 11, 1085, 61, 272, 372, 3416, 15, 1590, 14, 988, 8, 87, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
JFriel/honours_project
networkx/build/lib/networkx/algorithms/__init__.py
16
3109
from networkx.algorithms.assortativity import * from networkx.algorithms.block import * from networkx.algorithms.boundary import * from networkx.algorithms.centrality import * from networkx.algorithms.cluster import * from networkx.algorithms.clique import * from networkx.algorithms.community import * from networkx.algorithms.components import * from networkx.algorithms.coloring import * from networkx.algorithms.core import * from networkx.algorithms.cycles import * from networkx.algorithms.dag import * from networkx.algorithms.distance_measures import * from networkx.algorithms.dominance import * from networkx.algorithms.dominating import * from networkx.algorithms.hierarchy import * from networkx.algorithms.hybrid import * from networkx.algorithms.matching import * from networkx.algorithms.minors import * from networkx.algorithms.mis import * from networkx.algorithms.mst import * from networkx.algorithms.link_analysis import * from networkx.algorithms.link_prediction import * from networkx.algorithms.operators import * from networkx.algorithms.shortest_paths import * from networkx.algorithms.smetric import * from networkx.algorithms.triads import * from networkx.algorithms.traversal import * from networkx.algorithms.isolate import * from networkx.algorithms.euler import * from networkx.algorithms.vitality import * from networkx.algorithms.chordal import * from networkx.algorithms.richclub import * from networkx.algorithms.distance_regular import * from networkx.algorithms.swap import * from networkx.algorithms.graphical import * from networkx.algorithms.simple_paths import * import networkx.algorithms.assortativity import networkx.algorithms.bipartite import networkx.algorithms.centrality import networkx.algorithms.cluster import networkx.algorithms.clique import networkx.algorithms.components import networkx.algorithms.connectivity import networkx.algorithms.coloring import networkx.algorithms.flow import networkx.algorithms.isomorphism import networkx.algorithms.link_analysis import networkx.algorithms.shortest_paths import networkx.algorithms.traversal import networkx.algorithms.chordal import networkx.algorithms.operators import networkx.algorithms.tree # bipartite from networkx.algorithms.bipartite import (projected_graph, project, is_bipartite, complete_bipartite_graph) # connectivity from networkx.algorithms.connectivity import (minimum_edge_cut, minimum_node_cut, average_node_connectivity, edge_connectivity, node_connectivity, stoer_wagner, all_pairs_node_connectivity, all_node_cuts, k_components) # isomorphism from networkx.algorithms.isomorphism import (is_isomorphic, could_be_isomorphic, fast_could_be_isomorphic, faster_could_be_isomorphic) # flow from networkx.algorithms.flow import (maximum_flow, maximum_flow_value, minimum_cut, minimum_cut_value, capacity_scaling, network_simplex, min_cost_flow_cost, max_flow_min_cost, min_cost_flow, cost_of_flow) from .tree.recognition import * from .tree.branchings import ( maximum_branching, minimum_branching, maximum_spanning_arborescence, minimum_spanning_arborescence )
gpl-3.0
[ 504, 24313, 14, 24365, 14, 405, 361, 2159, 18936, 492, 627, 199, 504, 24313, 14, 24365, 14, 1457, 492, 627, 199, 504, 24313, 14, 24365, 14, 9891, 492, 627, 199, 504, 24313, 14, 24365, 14, 2497, 28602, 492, 627, 199, 504, 24313, 14, 24365, 14, 4201, 492, 627, 199, 504, 24313, 14, 24365, 14, 2764, 544, 492, 627, 199, 504, 24313, 14, 24365, 14, 9387, 492, 627, 199, 504, 24313, 14, 24365, 14, 4608, 492, 627, 199, 504, 24313, 14, 24365, 14, 2326, 316, 492, 627, 199, 504, 24313, 14, 24365, 14, 1018, 492, 627, 199, 504, 24313, 14, 24365, 14, 23356, 492, 627, 199, 504, 24313, 14, 24365, 14, 7406, 492, 627, 199, 504, 24313, 14, 24365, 14, 5590, 63, 19116, 1482, 492, 627, 199, 504, 24313, 14, 24365, 14, 4556, 262, 554, 492, 627, 199, 504, 24313, 14, 24365, 14, 4556, 262, 1958, 492, 627, 199, 504, 24313, 14, 24365, 14, 14861, 492, 627, 199, 504, 24313, 14, 24365, 14, 27758, 492, 627, 199, 504, 24313, 14, 24365, 14, 9467, 492, 627, 199, 504, 24313, 14, 24365, 14, 827, 1384, 492, 627, 199, 504, 24313, 14, 24365, 14, 1292, 492, 627, 199, 504, 24313, 14, 24365, 14, 77, 270, 492, 627, 199, 504, 24313, 14, 24365, 14, 1073, 63, 10466, 492, 627, 199, 504, 24313, 14, 24365, 14, 1073, 63, 14845, 492, 627, 199, 504, 24313, 14, 24365, 14, 12688, 492, 627, 199, 504, 24313, 14, 24365, 14, 20695, 396, 63, 3771, 492, 627, 199, 504, 24313, 14, 24365, 14, 83, 5165, 492, 627, 199, 504, 24313, 14, 24365, 14, 599, 9402, 492, 627, 199, 504, 24313, 14, 24365, 14, 1239, 16222, 492, 627, 199, 504, 24313, 14, 24365, 14, 31188, 492, 627, 199, 504, 24313, 14, 24365, 14, 69, 19345, 492, 627, 199, 504, 24313, 14, 24365, 14, 86, 390, 6712, 492, 627, 199, 504, 24313, 14, 24365, 14, 335, 2181, 279, 492, 627, 199, 504, 24313, 14, 24365, 14, 10399, 429, 456, 492, 627, 199, 504, 24313, 14, 24365, 14, 5590, 63, 7898, 492, 627, 199, 504, 24313, 14, 24365, 14, 9286, 492, 627, 199, 504, 24313, 14, 24365, 14, 2180, 2652, 492, 627, 199, 504, 24313, 14, 24365, 14, 4129, 63, 3771, 492, 627, 199, 199, 646, 24313, 14, 24365, 14, 405, 361, 2159, 18936, 199, 646, 24313, 14, 24365, 14, 4492, 30623, 199, 646, 24313, 14, 24365, 14, 2497, 28602, 199, 646, 24313, 14, 24365, 14, 4201, 199, 646, 24313, 14, 24365, 14, 2764, 544, 199, 646, 24313, 14, 24365, 14, 4608, 199, 646, 24313, 14, 24365, 14, 22344, 199, 646, 24313, 14, 24365, 14, 2326, 316, 199, 646, 24313, 14, 24365, 14, 1659, 199, 646, 24313, 14, 24365, 14, 374, 25456, 19185, 199, 646, 24313, 14, 24365, 14, 1073, 63, 10466, 199, 646, 24313, 14, 24365, 14, 20695, 396, 63, 3771, 199, 646, 24313, 14, 24365, 14, 1239, 16222, 199, 646, 24313, 14, 24365, 14, 335, 2181, 279, 199, 646, 24313, 14, 24365, 14, 12688, 199, 646, 24313, 14, 24365, 14, 2350, 199, 199, 3, 12111, 30623, 199, 504, 24313, 14, 24365, 14, 4492, 30623, 492, 334, 25554, 63, 2180, 12, 2199, 12, 365, 63, 4492, 30623, 12, 272, 4890, 63, 4492, 30623, 63, 2180, 9, 199, 3, 20170, 199, 504, 24313, 14, 24365, 14, 22344, 492, 334, 10700, 63, 5173, 63, 5919, 12, 7481, 63, 932, 63, 5919, 12, 272, 8095, 63, 932, 63, 22344, 12, 6275, 63, 22344, 12, 1031, 63, 22344, 12, 272, 26123, 281, 63, 30412, 1372, 12, 1006, 63, 7322, 63, 932, 63, 22344, 12, 1006, 63, 932, 63, 12946, 12, 1022, 63, 4608, 9, 199, 3, 365, 25456, 19185, 199, 504, 24313, 14, 24365, 14, 374, 25456, 19185, 492, 334, 374, 63, 374, 25456, 530, 12, 4293, 63, 1235, 63, 374, 25456, 530, 12, 272, 7377, 63, 15153, 63, 1235, 63, 374, 25456, 530, 12, 12930, 63, 15153, 63, 1235, 63, 374, 25456, 530, 9, 199, 3, 6369, 199, 504, 24313, 14, 24365, 14, 1659, 492, 334, 11555, 63, 1659, 12, 5696, 63, 1659, 63, 585, 12, 272, 7481, 63, 5919, 12, 7481, 63, 5919, 63, 585, 12, 14893, 63, 12153, 12, 2784, 63, 4129, 88, 12, 272, 1748, 63, 6336, 63, 1659, 63, 6336, 12, 1390, 63, 1659, 63, 827, 63, 6336, 12, 1748, 63, 6336, 63, 1659, 12, 7918, 63, 1618, 63, 1659, 9, 199, 199, 504, 1275, 2350, 14, 29324, 15415, 492, 627, 199, 504, 1275, 2350, 14, 4694, 780, 492, 334, 199, 198, 11555, 63, 4694, 316, 12, 7481, 63, 4694, 316, 12, 199, 198, 11555, 63, 681, 11495, 63, 285, 656, 470, 2497, 301, 12, 7481, 63, 681, 11495, 63, 285, 656, 470, 2497, 301, 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 ]
[ 24313, 14, 24365, 14, 405, 361, 2159, 18936, 492, 627, 199, 504, 24313, 14, 24365, 14, 1457, 492, 627, 199, 504, 24313, 14, 24365, 14, 9891, 492, 627, 199, 504, 24313, 14, 24365, 14, 2497, 28602, 492, 627, 199, 504, 24313, 14, 24365, 14, 4201, 492, 627, 199, 504, 24313, 14, 24365, 14, 2764, 544, 492, 627, 199, 504, 24313, 14, 24365, 14, 9387, 492, 627, 199, 504, 24313, 14, 24365, 14, 4608, 492, 627, 199, 504, 24313, 14, 24365, 14, 2326, 316, 492, 627, 199, 504, 24313, 14, 24365, 14, 1018, 492, 627, 199, 504, 24313, 14, 24365, 14, 23356, 492, 627, 199, 504, 24313, 14, 24365, 14, 7406, 492, 627, 199, 504, 24313, 14, 24365, 14, 5590, 63, 19116, 1482, 492, 627, 199, 504, 24313, 14, 24365, 14, 4556, 262, 554, 492, 627, 199, 504, 24313, 14, 24365, 14, 4556, 262, 1958, 492, 627, 199, 504, 24313, 14, 24365, 14, 14861, 492, 627, 199, 504, 24313, 14, 24365, 14, 27758, 492, 627, 199, 504, 24313, 14, 24365, 14, 9467, 492, 627, 199, 504, 24313, 14, 24365, 14, 827, 1384, 492, 627, 199, 504, 24313, 14, 24365, 14, 1292, 492, 627, 199, 504, 24313, 14, 24365, 14, 77, 270, 492, 627, 199, 504, 24313, 14, 24365, 14, 1073, 63, 10466, 492, 627, 199, 504, 24313, 14, 24365, 14, 1073, 63, 14845, 492, 627, 199, 504, 24313, 14, 24365, 14, 12688, 492, 627, 199, 504, 24313, 14, 24365, 14, 20695, 396, 63, 3771, 492, 627, 199, 504, 24313, 14, 24365, 14, 83, 5165, 492, 627, 199, 504, 24313, 14, 24365, 14, 599, 9402, 492, 627, 199, 504, 24313, 14, 24365, 14, 1239, 16222, 492, 627, 199, 504, 24313, 14, 24365, 14, 31188, 492, 627, 199, 504, 24313, 14, 24365, 14, 69, 19345, 492, 627, 199, 504, 24313, 14, 24365, 14, 86, 390, 6712, 492, 627, 199, 504, 24313, 14, 24365, 14, 335, 2181, 279, 492, 627, 199, 504, 24313, 14, 24365, 14, 10399, 429, 456, 492, 627, 199, 504, 24313, 14, 24365, 14, 5590, 63, 7898, 492, 627, 199, 504, 24313, 14, 24365, 14, 9286, 492, 627, 199, 504, 24313, 14, 24365, 14, 2180, 2652, 492, 627, 199, 504, 24313, 14, 24365, 14, 4129, 63, 3771, 492, 627, 199, 199, 646, 24313, 14, 24365, 14, 405, 361, 2159, 18936, 199, 646, 24313, 14, 24365, 14, 4492, 30623, 199, 646, 24313, 14, 24365, 14, 2497, 28602, 199, 646, 24313, 14, 24365, 14, 4201, 199, 646, 24313, 14, 24365, 14, 2764, 544, 199, 646, 24313, 14, 24365, 14, 4608, 199, 646, 24313, 14, 24365, 14, 22344, 199, 646, 24313, 14, 24365, 14, 2326, 316, 199, 646, 24313, 14, 24365, 14, 1659, 199, 646, 24313, 14, 24365, 14, 374, 25456, 19185, 199, 646, 24313, 14, 24365, 14, 1073, 63, 10466, 199, 646, 24313, 14, 24365, 14, 20695, 396, 63, 3771, 199, 646, 24313, 14, 24365, 14, 1239, 16222, 199, 646, 24313, 14, 24365, 14, 335, 2181, 279, 199, 646, 24313, 14, 24365, 14, 12688, 199, 646, 24313, 14, 24365, 14, 2350, 199, 199, 3, 12111, 30623, 199, 504, 24313, 14, 24365, 14, 4492, 30623, 492, 334, 25554, 63, 2180, 12, 2199, 12, 365, 63, 4492, 30623, 12, 272, 4890, 63, 4492, 30623, 63, 2180, 9, 199, 3, 20170, 199, 504, 24313, 14, 24365, 14, 22344, 492, 334, 10700, 63, 5173, 63, 5919, 12, 7481, 63, 932, 63, 5919, 12, 272, 8095, 63, 932, 63, 22344, 12, 6275, 63, 22344, 12, 1031, 63, 22344, 12, 272, 26123, 281, 63, 30412, 1372, 12, 1006, 63, 7322, 63, 932, 63, 22344, 12, 1006, 63, 932, 63, 12946, 12, 1022, 63, 4608, 9, 199, 3, 365, 25456, 19185, 199, 504, 24313, 14, 24365, 14, 374, 25456, 19185, 492, 334, 374, 63, 374, 25456, 530, 12, 4293, 63, 1235, 63, 374, 25456, 530, 12, 272, 7377, 63, 15153, 63, 1235, 63, 374, 25456, 530, 12, 12930, 63, 15153, 63, 1235, 63, 374, 25456, 530, 9, 199, 3, 6369, 199, 504, 24313, 14, 24365, 14, 1659, 492, 334, 11555, 63, 1659, 12, 5696, 63, 1659, 63, 585, 12, 272, 7481, 63, 5919, 12, 7481, 63, 5919, 63, 585, 12, 14893, 63, 12153, 12, 2784, 63, 4129, 88, 12, 272, 1748, 63, 6336, 63, 1659, 63, 6336, 12, 1390, 63, 1659, 63, 827, 63, 6336, 12, 1748, 63, 6336, 63, 1659, 12, 7918, 63, 1618, 63, 1659, 9, 199, 199, 504, 1275, 2350, 14, 29324, 15415, 492, 627, 199, 504, 1275, 2350, 14, 4694, 780, 492, 334, 199, 198, 11555, 63, 4694, 316, 12, 7481, 63, 4694, 316, 12, 199, 198, 11555, 63, 681, 11495, 63, 285, 656, 470, 2497, 301, 12, 7481, 63, 681, 11495, 63, 285, 656, 470, 2497, 301, 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, 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, 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 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 ]
stableShip/shadowsocks
shadowsocks/encrypt.py
990
5180
#!/usr/bin/env python # # Copyright 2012-2015 clowwindy # # 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, \ with_statement import os import sys import hashlib import logging from shadowsocks import common from shadowsocks.crypto import rc4_md5, openssl, sodium, table method_supported = {} method_supported.update(rc4_md5.ciphers) method_supported.update(openssl.ciphers) method_supported.update(sodium.ciphers) method_supported.update(table.ciphers) def random_string(length): return os.urandom(length) cached_keys = {} def try_cipher(key, method=None): Encryptor(key, method) def EVP_BytesToKey(password, key_len, iv_len): # equivalent to OpenSSL's EVP_BytesToKey() with count 1 # so that we make the same key and iv as nodejs version cached_key = '%s-%d-%d' % (password, key_len, iv_len) r = cached_keys.get(cached_key, None) if r: return r m = [] i = 0 while len(b''.join(m)) < (key_len + iv_len): md5 = hashlib.md5() data = password if i > 0: data = m[i - 1] + password md5.update(data) m.append(md5.digest()) i += 1 ms = b''.join(m) key = ms[:key_len] iv = ms[key_len:key_len + iv_len] cached_keys[cached_key] = (key, iv) return key, iv class Encryptor(object): def __init__(self, key, method): self.key = key self.method = method self.iv = None self.iv_sent = False self.cipher_iv = b'' self.decipher = None method = method.lower() self._method_info = self.get_method_info(method) if self._method_info: self.cipher = self.get_cipher(key, method, 1, random_string(self._method_info[1])) else: logging.error('method %s not supported' % method) sys.exit(1) def get_method_info(self, method): method = method.lower() m = method_supported.get(method) return m def iv_len(self): return len(self.cipher_iv) def get_cipher(self, password, method, op, iv): password = common.to_bytes(password) m = self._method_info if m[0] > 0: key, iv_ = EVP_BytesToKey(password, m[0], m[1]) else: # key_length == 0 indicates we should use the key directly key, iv = password, b'' iv = iv[:m[1]] if op == 1: # this iv is for cipher not decipher self.cipher_iv = iv[:m[1]] return m[2](method, key, iv, op) def encrypt(self, buf): if len(buf) == 0: return buf if self.iv_sent: return self.cipher.update(buf) else: self.iv_sent = True return self.cipher_iv + self.cipher.update(buf) def decrypt(self, buf): if len(buf) == 0: return buf if self.decipher is None: decipher_iv_len = self._method_info[1] decipher_iv = buf[:decipher_iv_len] self.decipher = self.get_cipher(self.key, self.method, 0, iv=decipher_iv) buf = buf[decipher_iv_len:] if len(buf) == 0: return buf return self.decipher.update(buf) def encrypt_all(password, method, op, data): result = [] method = method.lower() (key_len, iv_len, m) = method_supported[method] if key_len > 0: key, _ = EVP_BytesToKey(password, key_len, iv_len) else: key = password if op: iv = random_string(iv_len) result.append(iv) else: iv = data[:iv_len] data = data[iv_len:] cipher = m(method, key, iv, op) result.append(cipher.update(data)) return b''.join(result) CIPHERS_TO_TEST = [ 'aes-128-cfb', 'aes-256-cfb', 'rc4-md5', 'salsa20', 'chacha20', 'table', ] def test_encryptor(): from os import urandom plain = urandom(10240) for method in CIPHERS_TO_TEST: logging.warn(method) encryptor = Encryptor(b'key', method) decryptor = Encryptor(b'key', method) cipher = encryptor.encrypt(plain) plain2 = decryptor.decrypt(cipher) assert plain == plain2 def test_encrypt_all(): from os import urandom plain = urandom(10240) for method in CIPHERS_TO_TEST: logging.warn(method) cipher = encrypt_all(b'key', method, 1, plain) plain2 = encrypt_all(b'key', method, 0, cipher) assert plain == plain2 if __name__ == '__main__': test_encrypt_all() test_encryptor()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 13, 7806, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 747, 199, 646, 984, 199, 646, 8337, 199, 646, 2050, 199, 199, 504, 15084, 21234, 492, 2863, 199, 504, 15084, 21234, 14, 10316, 492, 4819, 20, 63, 1064, 21, 12, 1551, 4266, 12, 880, 12980, 12, 1817, 421, 199, 765, 63, 4946, 275, 1052, 199, 765, 63, 4946, 14, 873, 8, 1195, 20, 63, 1064, 21, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 14837, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 1152, 12980, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 1224, 14, 27426, 9, 421, 199, 318, 2196, 63, 875, 8, 1267, 304, 272, 372, 747, 14, 22776, 8, 1267, 9, 421, 199, 5245, 63, 1612, 275, 1052, 421, 199, 318, 862, 63, 9231, 8, 498, 12, 1083, 29, 403, 304, 272, 3447, 4997, 269, 8, 498, 12, 1083, 9, 421, 199, 318, 662, 14159, 63, 5571, 1378, 1197, 8, 2060, 12, 790, 63, 552, 12, 18831, 63, 552, 304, 272, 327, 7353, 370, 14296, 1159, 662, 14159, 63, 5571, 1378, 1197, 342, 543, 2338, 413, 272, 327, 880, 626, 781, 1852, 314, 2011, 790, 436, 18831, 465, 1031, 3596, 1015, 272, 6328, 63, 498, 275, 1543, 83, 3295, 68, 3295, 68, 7, 450, 334, 2060, 12, 790, 63, 552, 12, 18831, 63, 552, 9, 272, 519, 275, 6328, 63, 1612, 14, 362, 8, 5245, 63, 498, 12, 488, 9, 272, 340, 519, 26, 267, 372, 519, 272, 333, 275, 942, 272, 284, 275, 378, 272, 1830, 822, 8, 66, 17067, 904, 8, 77, 430, 665, 334, 498, 63, 552, 435, 18831, 63, 552, 304, 267, 6128, 21, 275, 8337, 14, 1064, 21, 342, 267, 666, 275, 2505, 267, 340, 284, 690, 378, 26, 288, 666, 275, 333, 59, 73, 446, 413, 61, 435, 2505, 267, 6128, 21, 14, 873, 8, 576, 9, 267, 333, 14, 740, 8, 1064, 21, 14, 5671, 1012, 267, 284, 847, 413, 272, 6605, 275, 330, 17067, 904, 8, 77, 9, 272, 790, 275, 6605, 1491, 498, 63, 552, 61, 272, 18831, 275, 6605, 59, 498, 63, 552, 26, 498, 63, 552, 435, 18831, 63, 552, 61, 272, 6328, 63, 1612, 59, 5245, 63, 498, 61, 275, 334, 498, 12, 18831, 9, 272, 372, 790, 12, 18831, 421, 199, 533, 3447, 4997, 269, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 790, 12, 1083, 304, 267, 291, 14, 498, 275, 790, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 1003, 275, 488, 267, 291, 14, 1003, 63, 1150, 275, 756, 267, 291, 14, 9231, 63, 1003, 275, 330, 891, 267, 291, 14, 271, 9231, 275, 488, 267, 1083, 275, 1083, 14, 2325, 342, 267, 291, 423, 765, 63, 815, 275, 291, 14, 362, 63, 765, 63, 815, 8, 765, 9, 267, 340, 291, 423, 765, 63, 815, 26, 288, 291, 14, 9231, 275, 291, 14, 362, 63, 9231, 8, 498, 12, 1083, 12, 413, 12, 5101, 2196, 63, 875, 8, 277, 423, 765, 63, 815, 59, 17, 2459, 267, 587, 26, 288, 2050, 14, 705, 360, 765, 450, 83, 440, 3748, 7, 450, 1083, 9, 288, 984, 14, 2224, 8, 17, 9, 339, 347, 664, 63, 765, 63, 815, 8, 277, 12, 1083, 304, 267, 1083, 275, 1083, 14, 2325, 342, 267, 333, 275, 1083, 63, 4946, 14, 362, 8, 765, 9, 267, 372, 333, 339, 347, 18831, 63, 552, 8, 277, 304, 267, 372, 822, 8, 277, 14, 9231, 63, 1003, 9, 339, 347, 664, 63, 9231, 8, 277, 12, 2505, 12, 1083, 12, 1687, 12, 18831, 304, 267, 2505, 275, 2863, 14, 475, 63, 2394, 8, 2060, 9, 267, 333, 275, 291, 423, 765, 63, 815, 267, 340, 333, 59, 16, 61, 690, 378, 26, 288, 790, 12, 18831, 63, 275, 662, 14159, 63, 5571, 1378, 1197, 8, 2060, 12, 333, 59, 16, 467, 333, 59, 17, 566, 267, 587, 26, 288, 327, 790, 63, 1267, 508, 378, 9126, 781, 1077, 675, 314, 790, 5370, 288, 790, 12, 18831, 275, 2505, 12, 330, 891, 398, 18831, 275, 18831, 1491, 77, 59, 17, 2677, 267, 340, 1687, 508, 413, 26, 288, 327, 642, 18831, 365, 367, 10830, 440, 477, 9231, 288, 291, 14, 9231, 63, 1003, 275, 18831, 1491, 77, 59, 17, 2677, 267, 372, 333, 59, 18, 8738, 765, 12, 790, 12, 18831, 12, 1687, 9, 339, 347, 14645, 8, 277, 12, 4123, 304, 267, 340, 822, 8, 1436, 9, 508, 378, 26, 288, 372, 4123, 267, 340, 291, 14, 1003, 63, 1150, 26, 288, 372, 291, 14, 9231, 14, 873, 8, 1436, 9, 267, 587, 26, 288, 291, 14, 1003, 63, 1150, 275, 715, 288, 372, 291, 14, 9231, 63, 1003, 435, 291, 14, 9231, 14, 873, 8, 1436, 9, 339, 347, 20090, 8, 277, 12, 4123, 304, 267, 340, 822, 8, 1436, 9, 508, 378, 26, 288, 372, 4123, 267, 340, 291, 14, 271, 9231, 365, 488, 26, 288, 477, 9231, 63, 1003, 63, 552, 275, 291, 423, 765, 63, 815, 59, 17, 61, 288, 477, 9231, 63, 1003, 275, 4123, 1491, 271, 9231, 63, 1003, 63, 552, 61, 288, 291, 14, 271, 9231, 275, 291, 14, 362 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 13, 7806, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 747, 199, 646, 984, 199, 646, 8337, 199, 646, 2050, 199, 199, 504, 15084, 21234, 492, 2863, 199, 504, 15084, 21234, 14, 10316, 492, 4819, 20, 63, 1064, 21, 12, 1551, 4266, 12, 880, 12980, 12, 1817, 421, 199, 765, 63, 4946, 275, 1052, 199, 765, 63, 4946, 14, 873, 8, 1195, 20, 63, 1064, 21, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 14837, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 1152, 12980, 14, 27426, 9, 199, 765, 63, 4946, 14, 873, 8, 1224, 14, 27426, 9, 421, 199, 318, 2196, 63, 875, 8, 1267, 304, 272, 372, 747, 14, 22776, 8, 1267, 9, 421, 199, 5245, 63, 1612, 275, 1052, 421, 199, 318, 862, 63, 9231, 8, 498, 12, 1083, 29, 403, 304, 272, 3447, 4997, 269, 8, 498, 12, 1083, 9, 421, 199, 318, 662, 14159, 63, 5571, 1378, 1197, 8, 2060, 12, 790, 63, 552, 12, 18831, 63, 552, 304, 272, 327, 7353, 370, 14296, 1159, 662, 14159, 63, 5571, 1378, 1197, 342, 543, 2338, 413, 272, 327, 880, 626, 781, 1852, 314, 2011, 790, 436, 18831, 465, 1031, 3596, 1015, 272, 6328, 63, 498, 275, 1543, 83, 3295, 68, 3295, 68, 7, 450, 334, 2060, 12, 790, 63, 552, 12, 18831, 63, 552, 9, 272, 519, 275, 6328, 63, 1612, 14, 362, 8, 5245, 63, 498, 12, 488, 9, 272, 340, 519, 26, 267, 372, 519, 272, 333, 275, 942, 272, 284, 275, 378, 272, 1830, 822, 8, 66, 17067, 904, 8, 77, 430, 665, 334, 498, 63, 552, 435, 18831, 63, 552, 304, 267, 6128, 21, 275, 8337, 14, 1064, 21, 342, 267, 666, 275, 2505, 267, 340, 284, 690, 378, 26, 288, 666, 275, 333, 59, 73, 446, 413, 61, 435, 2505, 267, 6128, 21, 14, 873, 8, 576, 9, 267, 333, 14, 740, 8, 1064, 21, 14, 5671, 1012, 267, 284, 847, 413, 272, 6605, 275, 330, 17067, 904, 8, 77, 9, 272, 790, 275, 6605, 1491, 498, 63, 552, 61, 272, 18831, 275, 6605, 59, 498, 63, 552, 26, 498, 63, 552, 435, 18831, 63, 552, 61, 272, 6328, 63, 1612, 59, 5245, 63, 498, 61, 275, 334, 498, 12, 18831, 9, 272, 372, 790, 12, 18831, 421, 199, 533, 3447, 4997, 269, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 790, 12, 1083, 304, 267, 291, 14, 498, 275, 790, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 1003, 275, 488, 267, 291, 14, 1003, 63, 1150, 275, 756, 267, 291, 14, 9231, 63, 1003, 275, 330, 891, 267, 291, 14, 271, 9231, 275, 488, 267, 1083, 275, 1083, 14, 2325, 342, 267, 291, 423, 765, 63, 815, 275, 291, 14, 362, 63, 765, 63, 815, 8, 765, 9, 267, 340, 291, 423, 765, 63, 815, 26, 288, 291, 14, 9231, 275, 291, 14, 362, 63, 9231, 8, 498, 12, 1083, 12, 413, 12, 5101, 2196, 63, 875, 8, 277, 423, 765, 63, 815, 59, 17, 2459, 267, 587, 26, 288, 2050, 14, 705, 360, 765, 450, 83, 440, 3748, 7, 450, 1083, 9, 288, 984, 14, 2224, 8, 17, 9, 339, 347, 664, 63, 765, 63, 815, 8, 277, 12, 1083, 304, 267, 1083, 275, 1083, 14, 2325, 342, 267, 333, 275, 1083, 63, 4946, 14, 362, 8, 765, 9, 267, 372, 333, 339, 347, 18831, 63, 552, 8, 277, 304, 267, 372, 822, 8, 277, 14, 9231, 63, 1003, 9, 339, 347, 664, 63, 9231, 8, 277, 12, 2505, 12, 1083, 12, 1687, 12, 18831, 304, 267, 2505, 275, 2863, 14, 475, 63, 2394, 8, 2060, 9, 267, 333, 275, 291, 423, 765, 63, 815, 267, 340, 333, 59, 16, 61, 690, 378, 26, 288, 790, 12, 18831, 63, 275, 662, 14159, 63, 5571, 1378, 1197, 8, 2060, 12, 333, 59, 16, 467, 333, 59, 17, 566, 267, 587, 26, 288, 327, 790, 63, 1267, 508, 378, 9126, 781, 1077, 675, 314, 790, 5370, 288, 790, 12, 18831, 275, 2505, 12, 330, 891, 398, 18831, 275, 18831, 1491, 77, 59, 17, 2677, 267, 340, 1687, 508, 413, 26, 288, 327, 642, 18831, 365, 367, 10830, 440, 477, 9231, 288, 291, 14, 9231, 63, 1003, 275, 18831, 1491, 77, 59, 17, 2677, 267, 372, 333, 59, 18, 8738, 765, 12, 790, 12, 18831, 12, 1687, 9, 339, 347, 14645, 8, 277, 12, 4123, 304, 267, 340, 822, 8, 1436, 9, 508, 378, 26, 288, 372, 4123, 267, 340, 291, 14, 1003, 63, 1150, 26, 288, 372, 291, 14, 9231, 14, 873, 8, 1436, 9, 267, 587, 26, 288, 291, 14, 1003, 63, 1150, 275, 715, 288, 372, 291, 14, 9231, 63, 1003, 435, 291, 14, 9231, 14, 873, 8, 1436, 9, 339, 347, 20090, 8, 277, 12, 4123, 304, 267, 340, 822, 8, 1436, 9, 508, 378, 26, 288, 372, 4123, 267, 340, 291, 14, 271, 9231, 365, 488, 26, 288, 477, 9231, 63, 1003, 63, 552, 275, 291, 423, 765, 63, 815, 59, 17, 61, 288, 477, 9231, 63, 1003, 275, 4123, 1491, 271, 9231, 63, 1003, 63, 552, 61, 288, 291, 14, 271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, 1, 1, 1, 1, 1, 1, 1, 1 ]
tomkun/stem
test/integ/descriptor/reader.py
4
18413
""" Integration tests for stem.descriptor.reader. """ import getpass import os import signal import sys import tarfile import time import unittest import stem.descriptor.reader import test.mocking import test.runner from stem.util import system BASIC_LISTING = """ /tmp 123 /bin/grep 4567 /file with spaces/and \\ stuff 890 """ my_dir = os.path.dirname(__file__) DESCRIPTOR_TEST_DATA = os.path.join(my_dir, "data") TAR_DESCRIPTORS = None def _get_processed_files_path(): return test.runner.get_runner().get_test_dir("descriptor_processed_files") def _make_processed_files_listing(contents): """ Writes the given 'processed file' listing to disk, returning the path where it is located. """ test_listing_path = _get_processed_files_path() test_listing_file = open(test_listing_path, "w") test_listing_file.write(contents) test_listing_file.close() return test_listing_path def _get_raw_tar_descriptors(): global TAR_DESCRIPTORS if not TAR_DESCRIPTORS: test_path = os.path.join(DESCRIPTOR_TEST_DATA, "descriptor_archive.tar") raw_descriptors = [] # TODO: revert to using the 'with' keyword for this when dropping python # 2.6 support tar_file = None try: tar_file = tarfile.open(test_path) for tar_entry in tar_file: if tar_entry.isfile(): entry = tar_file.extractfile(tar_entry) entry.readline() # strip header raw_descriptors.append(entry.read().decode("utf-8", "replace")) entry.close() finally: if tar_file: tar_file.close() TAR_DESCRIPTORS = raw_descriptors return TAR_DESCRIPTORS class SkipListener: def __init__(self): self.results = [] # (path, exception) tuples that we've received def listener(self, path, exception): self.results.append((path, exception)) class TestDescriptorReader(unittest.TestCase): def tearDown(self): test.mocking.revert_mocking() # cleans up 'processed file' listings that we made test_listing_path = _get_processed_files_path() if os.path.exists(test_listing_path): os.remove(test_listing_path) def test_load_processed_files(self): """ Basic sanity test for loading a processed files listing from disk. """ test_listing_path = _make_processed_files_listing(BASIC_LISTING) loaded_listing = stem.descriptor.reader.load_processed_files(test_listing_path) expected_listing = { "/tmp": 123, "/bin/grep": 4567, "/file with spaces/and \\ stuff": 890, } self.assertEquals(expected_listing, loaded_listing) def test_load_processed_files_missing(self): """ Tests the load_processed_files() function with a file that doesn't exist. """ self.assertRaises(IOError, stem.descriptor.reader.load_processed_files, "/non-existant/path") def test_load_processed_files_permissions(self): """ Tests the load_processed_files() function with a file that can't be read due to permissions. """ # test relies on being unable to read a file if getpass.getuser() == 'root': test.runner.skip(self, "(running as root)") return # Skip the test on windows, since you can only set the file's # read-only flag with os.chmod(). For more information see... # http://docs.python.org/library/os.html#os.chmod if system.is_windows(): test.runner.skip(self, "(chmod not functional)") test_listing_path = _make_processed_files_listing(BASIC_LISTING) os.chmod(test_listing_path, 0077) # remove read permissions self.assertRaises(IOError, stem.descriptor.reader.load_processed_files, test_listing_path) def test_save_processed_files(self): """ Basic sanity test for persisting files listings to disk. """ initial_listing = { "/tmp": 123, "/bin/grep": 4567, "/file with spaces/and \\ stuff": 890, } # saves the initial_listing to a file then reloads it test_listing_path = _get_processed_files_path() stem.descriptor.reader.save_processed_files(test_listing_path, initial_listing) loaded_listing = stem.descriptor.reader.load_processed_files(test_listing_path) self.assertEquals(initial_listing, loaded_listing) def test_save_processed_files_malformed(self): """ Tests the save_processed_files() function with malformed data. """ missing_filename = {"": 123} relative_filename = {"foobar": 123} string_timestamp = {"/tmp": "123a"} for listing in (missing_filename, relative_filename, string_timestamp): self.assertRaises(TypeError, stem.descriptor.reader.save_processed_files, "/tmp/foo", listing) # Though our attempts to save the processed files fail we'll write an empty # file. Cleaning it up. try: os.remove("/tmp/foo") except: pass def test_basic_example(self): """ Exercises something similar to the first example in the header documentation, checking that some of the contents match what we'd expect. """ # snag some of the plaintext descriptors so we can later make sure that we # iterate over them descriptor_entries = [] descriptor_path = os.path.join(DESCRIPTOR_TEST_DATA, "example_descriptor") with open(descriptor_path) as descriptor_file: descriptor_file.readline() # strip header descriptor_entries.append(descriptor_file.read()) # running this test multiple times to flush out concurrency issues for _ in xrange(15): remaining_entries = list(descriptor_entries) with stem.descriptor.reader.DescriptorReader(descriptor_path) as reader: for descriptor in reader: descriptor_str = str(descriptor) if descriptor_str in remaining_entries: remaining_entries.remove(descriptor_str) else: # iterator is providing output that we didn't expect self.fail() # check that we've seen all of the descriptor_entries self.assertTrue(len(remaining_entries) == 0) def test_multiple_runs(self): """ Runs a DescriptorReader instance multiple times over the same content, making sure that it can be used repeatedly. """ descriptor_path = os.path.join(DESCRIPTOR_TEST_DATA, "example_descriptor") reader = stem.descriptor.reader.DescriptorReader(descriptor_path) with reader: self.assertEquals(1, len(list(reader))) # run it a second time, this shouldn't provide any descriptors because we # have already read it with reader: self.assertEquals(0, len(list(reader))) # clear the DescriptorReader's memory of seeing the file and run it again reader.set_processed_files([]) with reader: self.assertEquals(1, len(list(reader))) def test_buffer_size(self): """ Checks that we can process sets of descriptors larger than our buffer size, that we don't exceed it, and that we can still stop midway through reading them. """ reader = stem.descriptor.reader.DescriptorReader(DESCRIPTOR_TEST_DATA, buffer_size = 2) with reader: self.assertTrue(reader.get_buffered_descriptor_count() <= 2) time.sleep(0.01) self.assertTrue(reader.get_buffered_descriptor_count() <= 2) def test_persistence_path(self): """ Check that the persistence_path argument loads and saves a a processed files listing. """ persistence_path = _get_processed_files_path() descriptor_path = os.path.join(DESCRIPTOR_TEST_DATA, "example_descriptor") # First run where the persistence_path doesn't yet exist. This just tests # the saving functionality. reader = stem.descriptor.reader.DescriptorReader(descriptor_path, persistence_path = persistence_path) with reader: self.assertEqual(1, len(list(reader))) # check that we've saved reading example_descriptor self.assertTrue(os.path.exists(persistence_path)) with open(persistence_path) as persistence_file: persistance_file_contents = persistence_file.read() self.assertTrue(persistance_file_contents.startswith(descriptor_path)) # Try running again with a new reader but the same persistance path, if it # reads and takes the persistence_path into account then it won't read the # descriptor file. This in essence just tests its loading functionality. reader = stem.descriptor.reader.DescriptorReader(descriptor_path, persistence_path = persistence_path) with reader: self.assertEqual(0, len(list(reader))) def test_archived_paths(self): """ Checks the get_path() and get_archive_path() for a tarball. """ expected_archive_paths = ( "descriptor_archive/0/2/02c311d3d789f3f55c0880b5c85f3c196343552c", "descriptor_archive/1/b/1bb798cae15e21479db0bc700767eee4733e9d4a", "descriptor_archive/1/b/1ef75fef564180d8b3f72c6f8635ff0cd855f92c", ) test_path = os.path.join(DESCRIPTOR_TEST_DATA, "descriptor_archive.tar") with stem.descriptor.reader.DescriptorReader(test_path) as reader: for desc in reader: self.assertEqual(test_path, desc.get_path()) self.assertTrue(desc.get_archive_path() in expected_archive_paths) def test_archived_uncompressed(self): """ Checks that we can read descriptors from an uncompressed archive. """ expected_results = _get_raw_tar_descriptors() test_path = os.path.join(DESCRIPTOR_TEST_DATA, "descriptor_archive.tar") with stem.descriptor.reader.DescriptorReader(test_path) as reader: read_descriptors = [str(desc) for desc in list(reader)] self.assertEquals(expected_results, read_descriptors) def test_archived_gzip(self): """ Checks that we can read descriptors from a gzipped archive. """ expected_results = _get_raw_tar_descriptors() test_path = os.path.join(DESCRIPTOR_TEST_DATA, "descriptor_archive.tar.gz") with stem.descriptor.reader.DescriptorReader(test_path) as reader: read_descriptors = [str(desc) for desc in list(reader)] self.assertEquals(expected_results, read_descriptors) def test_archived_bz2(self): """ Checks that we can read descriptors from an bzipped archive. """ expected_results = _get_raw_tar_descriptors() test_path = os.path.join(DESCRIPTOR_TEST_DATA, "descriptor_archive.tar.bz2") with stem.descriptor.reader.DescriptorReader(test_path) as reader: read_descriptors = [str(desc) for desc in list(reader)] self.assertEquals(expected_results, read_descriptors) def test_stop(self): """ Runs a DescriptorReader over the root directory, then checks that calling stop() makes it terminate in a timely fashion. """ # Skip on windows since SIGALRM is unavailable if system.is_windows(): test.runner.skip(self, "(SIGALRM unavailable)") is_test_running = True reader = stem.descriptor.reader.DescriptorReader("/usr") # Fails the test after a couple seconds if we don't finish successfully. # Depending on what we're blocked on this might not work when the test # fails, requiring that we give a manual kill to the test. def timeout_handler(signum, frame): if is_test_running: self.fail() signal.signal(signal.SIGALRM, timeout_handler) signal.alarm(2) reader.start() time.sleep(0.1) reader.stop() is_test_running = False def test_get_processed_files(self): """ Checks that get_processed_files() provides the expected results after iterating over our test data. """ expected_results = {} for root, _, files in os.walk(DESCRIPTOR_TEST_DATA): for filename in files: path = os.path.join(root, filename) last_modified = int(os.stat(path).st_mtime) expected_results[path] = last_modified reader = stem.descriptor.reader.DescriptorReader(DESCRIPTOR_TEST_DATA) with reader: list(reader) # iterates over all of the descriptors self.assertEquals(expected_results, reader.get_processed_files()) def test_skip_nondescriptor_contents(self): """ Checks that the reader properly reports when it skips both binary and plaintext non-descriptor files. """ test.mocking.mock_method(stem.descriptor.server_descriptor.RelayDescriptor, '_validate_content', test.mocking.no_op()) skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(DESCRIPTOR_TEST_DATA) reader.register_skip_listener(skip_listener.listener) expected_skip_files = ("riddle", "tiny.png", "vote", "new_metrics_type") with reader: list(reader) # iterates over all of the descriptors # strip anything with a .swp suffix (vim tmp files) skip_listener.results = [(path, exc) for (path, exc) in skip_listener.results if not path.endswith(".swp")] if len(skip_listener.results) != len(expected_skip_files): expected_label = ",\n ".join(expected_skip_files) results_label = ",\n ".join(["%s (%s)" % (path, exc) for (path, exc) in skip_listener.results]) self.fail("Skipped files that we should have been able to parse.\n\nExpected:\n %s\n\nResult:\n %s" % (expected_label, results_label)) for skip_path, skip_exception in skip_listener.results: if not os.path.basename(skip_path) in expected_skip_files: self.fail("Unexpected non-descriptor content: %s" % skip_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.UnrecognizedType)) def test_skip_listener_already_read(self): """ Checks that calling set_processed_files() prior to reading makes us skip those files. This also doubles for testing that skip listeners are notified of files that we've already read. """ # path that we want the DescriptorReader to skip test_path = os.path.join(DESCRIPTOR_TEST_DATA, "example_descriptor") initial_processed_files = {test_path: sys.maxint} skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(test_path) reader.register_skip_listener(skip_listener.listener) reader.set_processed_files(initial_processed_files) self.assertEquals(initial_processed_files, reader.get_processed_files()) with reader: list(reader) # iterates over all of the descriptors self.assertEquals(1, len(skip_listener.results)) skipped_path, skip_exception = skip_listener.results[0] self.assertEqual(test_path, skipped_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.AlreadyRead)) self.assertEqual(sys.maxint, skip_exception.last_modified_when_read) def test_skip_listener_unrecognized_type(self): """ Listens for a file that's skipped because its file type isn't recognized. """ # types are solely based on file extensions so making something that looks # like an png image test_path = test.runner.get_runner().get_test_dir("test.png") try: test_file = open(test_path, "w") test_file.write("test data for test_skip_listener_unrecognized_type()") test_file.close() skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(test_path) reader.register_skip_listener(skip_listener.listener) with reader: list(reader) # iterates over all of the descriptors self.assertEqual(1, len(skip_listener.results)) skipped_path, skip_exception = skip_listener.results[0] self.assertEqual(test_path, skipped_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.UnrecognizedType)) self.assertTrue(skip_exception.mime_type in (("image/png", None), ("image/x-png", None))) finally: if os.path.exists(test_path): os.remove(test_path) def test_skip_listener_read_failure(self): """ Listens for a file that's skipped because we lack read permissions. """ # test relies on being unable to read a file if getpass.getuser() == 'root': test.runner.skip(self, "(running as root)") return elif system.is_windows(): test.runner.skip(self, "(chmod not functional)") return test_path = test.runner.get_runner().get_test_dir("secret_file") try: test_file = open(test_path, "w") test_file.write("test data for test_skip_listener_unrecognized_type()") test_file.close() os.chmod(test_path, 0077) # remove read permissions skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(test_path) reader.register_skip_listener(skip_listener.listener) with reader: list(reader) # iterates over all of the descriptors self.assertEqual(1, len(skip_listener.results)) skipped_path, skip_exception = skip_listener.results[0] self.assertEqual(test_path, skipped_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.ReadFailed)) self.assertTrue(isinstance(skip_exception.exception, IOError)) finally: if os.path.exists(test_path): os.remove(test_path) def test_skip_listener_file_missing(self): """ Listens for a file that's skipped because the file doesn't exist. """ test_path = "/non-existant/path" skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(test_path) reader.register_skip_listener(skip_listener.listener) with reader: list(reader) # iterates over all of the descriptors self.assertEqual(1, len(skip_listener.results)) skipped_path, skip_exception = skip_listener.results[0] self.assertEqual(test_path, skipped_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.FileMissing)) def test_unrecognized_metrics_type(self): """ Parses a file that has a valid metrics header, but an unrecognized type. """ test_path = test.integ.descriptor.get_resource("new_metrics_type") skip_listener = SkipListener() reader = stem.descriptor.reader.DescriptorReader(test_path) reader.register_skip_listener(skip_listener.listener) with reader: list(reader) # iterates over all of the descriptors self.assertEqual(1, len(skip_listener.results)) skipped_path, skip_exception = skip_listener.results[0] self.assertEqual(test_path, skipped_path) self.assertTrue(isinstance(skip_exception, stem.descriptor.reader.UnrecognizedType)) self.assertEqual((None, None), skip_exception.mime_type)
lgpl-3.0
[ 624, 199, 20405, 2295, 367, 17408, 14, 4120, 14, 5503, 14, 199, 624, 199, 199, 646, 18354, 199, 646, 747, 199, 646, 4673, 199, 646, 984, 199, 646, 13608, 199, 646, 900, 199, 646, 2882, 199, 199, 646, 17408, 14, 4120, 14, 5503, 199, 646, 511, 14, 1805, 316, 199, 646, 511, 14, 5933, 199, 199, 504, 17408, 14, 1974, 492, 2656, 199, 199, 27271, 63, 4924, 1206, 275, 408, 199, 15, 2791, 11869, 199, 15, 1393, 15, 25914, 841, 5308, 199, 15, 493, 543, 7883, 15, 460, 8522, 8292, 221, 13173, 199, 624, 199, 199, 1662, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 7580, 63, 2864, 63, 3998, 275, 747, 14, 515, 14, 904, 8, 1662, 63, 694, 12, 298, 576, 531, 199, 199, 52, 689, 63, 6597, 4149, 275, 488, 421, 199, 318, 485, 362, 63, 7292, 63, 1725, 63, 515, 837, 523, 372, 511, 14, 5933, 14, 362, 63, 5933, 1252, 362, 63, 396, 63, 694, 480, 4120, 63, 7292, 63, 1725, 531, 421, 199, 318, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 4407, 304, 523, 408, 523, 30753, 314, 1627, 283, 7292, 570, 7, 13778, 370, 4543, 12, 8152, 314, 931, 2382, 523, 652, 365, 16180, 14, 523, 408, 819, 511, 63, 16115, 63, 515, 275, 485, 362, 63, 7292, 63, 1725, 63, 515, 342, 819, 511, 63, 16115, 63, 493, 275, 1551, 8, 396, 63, 16115, 63, 515, 12, 298, 87, 531, 523, 511, 63, 16115, 63, 493, 14, 952, 8, 4407, 9, 523, 511, 63, 16115, 63, 493, 14, 1600, 342, 819, 372, 511, 63, 16115, 63, 515, 421, 199, 318, 485, 362, 63, 1773, 63, 5369, 63, 17752, 837, 523, 2288, 377, 689, 63, 6597, 4149, 819, 340, 440, 377, 689, 63, 6597, 4149, 26, 272, 511, 63, 515, 275, 747, 14, 515, 14, 904, 8, 7580, 63, 2864, 63, 3998, 12, 298, 4120, 63, 6404, 14, 5369, 531, 272, 3066, 63, 17752, 275, 942, 339, 327, 3254, 26, 23347, 370, 1808, 314, 283, 1045, 7, 4252, 367, 642, 1380, 366, 20148, 2366, 272, 327, 499, 14, 22, 2291, 339, 5330, 63, 493, 275, 488, 339, 862, 26, 489, 5330, 63, 493, 275, 13608, 14, 1490, 8, 396, 63, 515, 9, 2541, 367, 5330, 63, 2373, 315, 5330, 63, 493, 26, 267, 340, 5330, 63, 2373, 14, 6292, 837, 881, 2397, 275, 5330, 63, 493, 14, 5005, 493, 8, 5369, 63, 2373, 9, 881, 2397, 14, 6407, 342, 221, 327, 6202, 1406, 881, 3066, 63, 17752, 14, 740, 8, 2373, 14, 739, 1252, 2708, 480, 1624, 13, 24, 401, 298, 1814, 2237, 881, 2397, 14, 1600, 342, 272, 3753, 26, 489, 340, 5330, 63, 493, 26, 267, 5330, 63, 493, 14, 1600, 342, 339, 377, 689, 63, 6597, 4149, 275, 3066, 63, 17752, 819, 372, 377, 689, 63, 6597, 4149, 421, 199, 533, 8232, 10464, 26, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 2604, 275, 942, 221, 327, 334, 515, 12, 1919, 9, 6346, 626, 781, 9064, 3086, 819, 347, 11647, 8, 277, 12, 931, 12, 1919, 304, 272, 291, 14, 2604, 14, 740, 1332, 515, 12, 1919, 430, 421, 199, 533, 1379, 4311, 5929, 8, 2796, 14, 1746, 304, 523, 347, 6766, 8, 277, 304, 272, 511, 14, 1805, 316, 14, 19092, 63, 1805, 316, 342, 339, 327, 15158, 796, 1536, 283, 7292, 570, 7, 769, 780, 626, 781, 6326, 272, 511, 63, 16115, 63, 515, 275, 485, 362, 63, 7292, 63, 1725, 63, 515, 342, 339, 340, 747, 14, 515, 14, 2444, 8, 396, 63, 16115, 63, 515, 304, 489, 747, 14, 2168, 8, 396, 63, 16115, 63, 515, 9, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 8, 277, 304, 272, 408, 272, 10082, 16740, 511, 367, 8697, 282, 7686, 1584, 13778, 687, 4543, 14, 272, 408, 339, 511, 63, 16115, 63, 515, 275, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 27271, 63, 4924, 1206, 9, 272, 6511, 63, 16115, 275, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 8, 396, 63, 16115, 63, 515, 9, 339, 1420, 63, 16115, 275, 469, 489, 3286, 2791, 582, 11869, 12, 489, 3286, 1393, 15, 25914, 582, 841, 5308, 12, 489, 3286, 493, 543, 7883, 15, 460, 8522, 8292, 582, 221, 13173, 12, 272, 789, 339, 291, 14, 2947, 8, 2062, 63, 16115, 12, 6511, 63, 16115, 9, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 63, 4752, 8, 277, 304, 272, 408, 272, 6496, 314, 2248, 63, 7292, 63, 1725, 342, 805, 543, 282, 570, 626, 3181, 1133, 2187, 14, 272, 408, 339, 291, 14, 1855, 8, 13760, 12, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 12, 3286, 2865, 13, 4494, 867, 15, 515, 531, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 63, 6060, 8, 277, 304, 272, 408, 272, 6496, 314, 2248, 63, 7292, 63, 1725, 342, 805, 543, 282, 570, 626, 883, 1133, 506, 1586, 272, 7037, 370, 3443, 14, 272, 408, 339, 327, 511, 25749, 641, 3769, 17329, 370, 1586, 282, 570, 339, 340, 18354, 14, 362, 751, 342, 508, 283, 1231, 356, 489, 511, 14, 5933, 14, 2759, 8, 277, 12, 7340, 5720, 465, 1738, 6320, 489, 372, 339, 327, 8232, 314, 511, 641, 10061, 12, 3967, 1265, 883, 1454, 663, 314, 570, 1159, 272, 327, 1586, 13, 2118, 3305, 543, 747, 14, 11693, 1252, 2104, 1655, 2556, 1937, 1396, 272, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 736, 14, 1360, 3, 736, 14, 11693, 339, 340, 2656, 14, 374, 63, 8258, 837, 489, 511, 14, 5933, 14, 2759, 8, 277, 12, 7340, 11693, 440, 22380, 6320, 339, 511, 63, 16115, 63, 515, 275, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 27271, 63, 4924, 1206, 9, 272, 747, 14, 11693, 8, 396, 63, 16115, 63, 515, 12, 8733, 1138, 9, 221, 327, 2813, 1586, 3443, 272, 291, 14, 1855, 8, 13760, 12, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 12, 511, 63, 16115, 63, 515, 9, 819, 347, 511, 63, 2117, 63, 7292, 63, 1725, 8, 277, 304, 272 ]
[ 199, 20405, 2295, 367, 17408, 14, 4120, 14, 5503, 14, 199, 624, 199, 199, 646, 18354, 199, 646, 747, 199, 646, 4673, 199, 646, 984, 199, 646, 13608, 199, 646, 900, 199, 646, 2882, 199, 199, 646, 17408, 14, 4120, 14, 5503, 199, 646, 511, 14, 1805, 316, 199, 646, 511, 14, 5933, 199, 199, 504, 17408, 14, 1974, 492, 2656, 199, 199, 27271, 63, 4924, 1206, 275, 408, 199, 15, 2791, 11869, 199, 15, 1393, 15, 25914, 841, 5308, 199, 15, 493, 543, 7883, 15, 460, 8522, 8292, 221, 13173, 199, 624, 199, 199, 1662, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 7580, 63, 2864, 63, 3998, 275, 747, 14, 515, 14, 904, 8, 1662, 63, 694, 12, 298, 576, 531, 199, 199, 52, 689, 63, 6597, 4149, 275, 488, 421, 199, 318, 485, 362, 63, 7292, 63, 1725, 63, 515, 837, 523, 372, 511, 14, 5933, 14, 362, 63, 5933, 1252, 362, 63, 396, 63, 694, 480, 4120, 63, 7292, 63, 1725, 531, 421, 199, 318, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 4407, 304, 523, 408, 523, 30753, 314, 1627, 283, 7292, 570, 7, 13778, 370, 4543, 12, 8152, 314, 931, 2382, 523, 652, 365, 16180, 14, 523, 408, 819, 511, 63, 16115, 63, 515, 275, 485, 362, 63, 7292, 63, 1725, 63, 515, 342, 819, 511, 63, 16115, 63, 493, 275, 1551, 8, 396, 63, 16115, 63, 515, 12, 298, 87, 531, 523, 511, 63, 16115, 63, 493, 14, 952, 8, 4407, 9, 523, 511, 63, 16115, 63, 493, 14, 1600, 342, 819, 372, 511, 63, 16115, 63, 515, 421, 199, 318, 485, 362, 63, 1773, 63, 5369, 63, 17752, 837, 523, 2288, 377, 689, 63, 6597, 4149, 819, 340, 440, 377, 689, 63, 6597, 4149, 26, 272, 511, 63, 515, 275, 747, 14, 515, 14, 904, 8, 7580, 63, 2864, 63, 3998, 12, 298, 4120, 63, 6404, 14, 5369, 531, 272, 3066, 63, 17752, 275, 942, 339, 327, 3254, 26, 23347, 370, 1808, 314, 283, 1045, 7, 4252, 367, 642, 1380, 366, 20148, 2366, 272, 327, 499, 14, 22, 2291, 339, 5330, 63, 493, 275, 488, 339, 862, 26, 489, 5330, 63, 493, 275, 13608, 14, 1490, 8, 396, 63, 515, 9, 2541, 367, 5330, 63, 2373, 315, 5330, 63, 493, 26, 267, 340, 5330, 63, 2373, 14, 6292, 837, 881, 2397, 275, 5330, 63, 493, 14, 5005, 493, 8, 5369, 63, 2373, 9, 881, 2397, 14, 6407, 342, 221, 327, 6202, 1406, 881, 3066, 63, 17752, 14, 740, 8, 2373, 14, 739, 1252, 2708, 480, 1624, 13, 24, 401, 298, 1814, 2237, 881, 2397, 14, 1600, 342, 272, 3753, 26, 489, 340, 5330, 63, 493, 26, 267, 5330, 63, 493, 14, 1600, 342, 339, 377, 689, 63, 6597, 4149, 275, 3066, 63, 17752, 819, 372, 377, 689, 63, 6597, 4149, 421, 199, 533, 8232, 10464, 26, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 2604, 275, 942, 221, 327, 334, 515, 12, 1919, 9, 6346, 626, 781, 9064, 3086, 819, 347, 11647, 8, 277, 12, 931, 12, 1919, 304, 272, 291, 14, 2604, 14, 740, 1332, 515, 12, 1919, 430, 421, 199, 533, 1379, 4311, 5929, 8, 2796, 14, 1746, 304, 523, 347, 6766, 8, 277, 304, 272, 511, 14, 1805, 316, 14, 19092, 63, 1805, 316, 342, 339, 327, 15158, 796, 1536, 283, 7292, 570, 7, 769, 780, 626, 781, 6326, 272, 511, 63, 16115, 63, 515, 275, 485, 362, 63, 7292, 63, 1725, 63, 515, 342, 339, 340, 747, 14, 515, 14, 2444, 8, 396, 63, 16115, 63, 515, 304, 489, 747, 14, 2168, 8, 396, 63, 16115, 63, 515, 9, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 8, 277, 304, 272, 408, 272, 10082, 16740, 511, 367, 8697, 282, 7686, 1584, 13778, 687, 4543, 14, 272, 408, 339, 511, 63, 16115, 63, 515, 275, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 27271, 63, 4924, 1206, 9, 272, 6511, 63, 16115, 275, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 8, 396, 63, 16115, 63, 515, 9, 339, 1420, 63, 16115, 275, 469, 489, 3286, 2791, 582, 11869, 12, 489, 3286, 1393, 15, 25914, 582, 841, 5308, 12, 489, 3286, 493, 543, 7883, 15, 460, 8522, 8292, 582, 221, 13173, 12, 272, 789, 339, 291, 14, 2947, 8, 2062, 63, 16115, 12, 6511, 63, 16115, 9, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 63, 4752, 8, 277, 304, 272, 408, 272, 6496, 314, 2248, 63, 7292, 63, 1725, 342, 805, 543, 282, 570, 626, 3181, 1133, 2187, 14, 272, 408, 339, 291, 14, 1855, 8, 13760, 12, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 12, 3286, 2865, 13, 4494, 867, 15, 515, 531, 819, 347, 511, 63, 912, 63, 7292, 63, 1725, 63, 6060, 8, 277, 304, 272, 408, 272, 6496, 314, 2248, 63, 7292, 63, 1725, 342, 805, 543, 282, 570, 626, 883, 1133, 506, 1586, 272, 7037, 370, 3443, 14, 272, 408, 339, 327, 511, 25749, 641, 3769, 17329, 370, 1586, 282, 570, 339, 340, 18354, 14, 362, 751, 342, 508, 283, 1231, 356, 489, 511, 14, 5933, 14, 2759, 8, 277, 12, 7340, 5720, 465, 1738, 6320, 489, 372, 339, 327, 8232, 314, 511, 641, 10061, 12, 3967, 1265, 883, 1454, 663, 314, 570, 1159, 272, 327, 1586, 13, 2118, 3305, 543, 747, 14, 11693, 1252, 2104, 1655, 2556, 1937, 1396, 272, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 736, 14, 1360, 3, 736, 14, 11693, 339, 340, 2656, 14, 374, 63, 8258, 837, 489, 511, 14, 5933, 14, 2759, 8, 277, 12, 7340, 11693, 440, 22380, 6320, 339, 511, 63, 16115, 63, 515, 275, 485, 1875, 63, 7292, 63, 1725, 63, 16115, 8, 27271, 63, 4924, 1206, 9, 272, 747, 14, 11693, 8, 396, 63, 16115, 63, 515, 12, 8733, 1138, 9, 221, 327, 2813, 1586, 3443, 272, 291, 14, 1855, 8, 13760, 12, 17408, 14, 4120, 14, 5503, 14, 912, 63, 7292, 63, 1725, 12, 511, 63, 16115, 63, 515, 9, 819, 347, 511, 63, 2117, 63, 7292, 63, 1725, 8, 277, 304,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1, 1, 1, 1 ]
ZhaoCJ/django
tests/defer_regress/tests.py
6
11237
from __future__ import unicode_literals from operator import attrgetter from django.contrib.contenttypes.models import ContentType from django.contrib.sessions.backends.db import SessionStore from django.db.models import Count from django.db.models.loading import cache from django.test import TestCase from django.test.utils import override_settings from .models import ( ResolveThis, Item, RelatedItem, Child, Leaf, Proxy, SimpleItem, Feature, ItemAndSimpleItem, OneToOneItem, SpecialFeature, Location, Request) class DeferRegressionTest(TestCase): def test_basic(self): # Deferred fields should really be deferred and not accidentally use # the field's default value just because they aren't passed to __init__ Item.objects.create(name="first", value=42) obj = Item.objects.only("name", "other_value").get(name="first") # Accessing "name" doesn't trigger a new database query. Accessing # "value" or "text" should. with self.assertNumQueries(0): self.assertEqual(obj.name, "first") self.assertEqual(obj.other_value, 0) with self.assertNumQueries(1): self.assertEqual(obj.value, 42) with self.assertNumQueries(1): self.assertEqual(obj.text, "xyzzy") with self.assertNumQueries(0): self.assertEqual(obj.text, "xyzzy") # Regression test for #10695. Make sure different instances don't # inadvertently share data in the deferred descriptor objects. i = Item.objects.create(name="no I'm first", value=37) items = Item.objects.only("value").order_by("-value") self.assertEqual(items[0].name, "first") self.assertEqual(items[1].name, "no I'm first") RelatedItem.objects.create(item=i) r = RelatedItem.objects.defer("item").get() self.assertEqual(r.item_id, i.id) self.assertEqual(r.item, i) # Some further checks for select_related() and inherited model # behavior (regression for #10710). c1 = Child.objects.create(name="c1", value=42) c2 = Child.objects.create(name="c2", value=37) Leaf.objects.create(name="l1", child=c1, second_child=c2) obj = Leaf.objects.only("name", "child").select_related()[0] self.assertEqual(obj.child.name, "c1") self.assertQuerysetEqual( Leaf.objects.select_related().only("child__name", "second_child__name"), [ "l1", ], attrgetter("name") ) # Models instances with deferred fields should still return the same # content types as their non-deferred versions (bug #10738). ctype = ContentType.objects.get_for_model c1 = ctype(Item.objects.all()[0]) c2 = ctype(Item.objects.defer("name")[0]) c3 = ctype(Item.objects.only("name")[0]) self.assertTrue(c1 is c2 is c3) # Regression for #10733 - only() can be used on a model with two # foreign keys. results = Leaf.objects.only("name", "child", "second_child").select_related() self.assertEqual(results[0].child.name, "c1") self.assertEqual(results[0].second_child.name, "c2") results = Leaf.objects.only( "name", "child", "second_child", "child__name", "second_child__name" ).select_related() self.assertEqual(results[0].child.name, "c1") self.assertEqual(results[0].second_child.name, "c2") # Regression for #16409 - make sure defer() and only() work with annotate() self.assertIsInstance( list(SimpleItem.objects.annotate(Count('feature')).defer('name')), list) self.assertIsInstance( list(SimpleItem.objects.annotate(Count('feature')).only('name')), list) def test_ticket_11936(self): # Regression for #11936 - loading.get_models should not return deferred # models by default. # Run a couple of defer queries so that app-cache must contain some # deferred classes. It might contain a lot more classes depending on # the order the tests are ran. list(Item.objects.defer("name")) list(Child.objects.defer("value")) klasses = set( map( attrgetter("__name__"), cache.get_models(cache.get_app("defer_regress")) ) ) self.assertIn("Child", klasses) self.assertIn("Item", klasses) self.assertNotIn("Child_Deferred_value", klasses) self.assertNotIn("Item_Deferred_name", klasses) self.assertFalse(any( k._deferred for k in cache.get_models(cache.get_app("defer_regress")))) klasses_with_deferred = set( map( attrgetter("__name__"), cache.get_models( cache.get_app("defer_regress"), include_deferred=True ), ) ) self.assertIn("Child", klasses_with_deferred) self.assertIn("Item", klasses_with_deferred) self.assertIn("Child_Deferred_value", klasses_with_deferred) self.assertIn("Item_Deferred_name", klasses_with_deferred) self.assertTrue(any( k._deferred for k in cache.get_models( cache.get_app("defer_regress"), include_deferred=True)) ) @override_settings(SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer') def test_ticket_12163(self): # Test for #12163 - Pickling error saving session with unsaved model # instances. SESSION_KEY = '2b1189a188b44ad18c35e1baac6ceead' item = Item() item._deferred = False s = SessionStore(SESSION_KEY) s.clear() s["item"] = item s.save() s = SessionStore(SESSION_KEY) s.modified = True s.save() i2 = s["item"] self.assertFalse(i2._deferred) def test_ticket_16409(self): # Regression for #16409 - make sure defer() and only() work with annotate() self.assertIsInstance( list(SimpleItem.objects.annotate(Count('feature')).defer('name')), list) self.assertIsInstance( list(SimpleItem.objects.annotate(Count('feature')).only('name')), list) def test_only_and_defer_usage_on_proxy_models(self): # Regression for #15790 - only() broken for proxy models proxy = Proxy.objects.create(name="proxy", value=42) msg = 'QuerySet.only() return bogus results with proxy models' dp = Proxy.objects.only('other_value').get(pk=proxy.pk) self.assertEqual(dp.name, proxy.name, msg=msg) self.assertEqual(dp.value, proxy.value, msg=msg) # also test things with .defer() msg = 'QuerySet.defer() return bogus results with proxy models' dp = Proxy.objects.defer('name', 'text', 'value').get(pk=proxy.pk) self.assertEqual(dp.name, proxy.name, msg=msg) self.assertEqual(dp.value, proxy.value, msg=msg) def test_resolve_columns(self): ResolveThis.objects.create(num=5.0, name='Foobar') qs = ResolveThis.objects.defer('num') self.assertEqual(1, qs.count()) self.assertEqual('Foobar', qs[0].name) def test_reverse_one_to_one_relations(self): # Refs #14694. Test reverse relations which are known unique (reverse # side has o2ofield or unique FK) - the o2o case item = Item.objects.create(name="first", value=42) o2o = OneToOneItem.objects.create(item=item, name="second") self.assertEqual(len(Item.objects.defer('one_to_one_item__name')), 1) self.assertEqual(len(Item.objects.select_related('one_to_one_item')), 1) self.assertEqual(len(Item.objects.select_related( 'one_to_one_item').defer('one_to_one_item__name')), 1) self.assertEqual(len(Item.objects.select_related('one_to_one_item').defer('value')), 1) # Make sure that `only()` doesn't break when we pass in a unique relation, # rather than a field on the relation. self.assertEqual(len(Item.objects.only('one_to_one_item')), 1) with self.assertNumQueries(1): i = Item.objects.select_related('one_to_one_item')[0] self.assertEqual(i.one_to_one_item.pk, o2o.pk) self.assertEqual(i.one_to_one_item.name, "second") with self.assertNumQueries(1): i = Item.objects.select_related('one_to_one_item').defer( 'value', 'one_to_one_item__name')[0] self.assertEqual(i.one_to_one_item.pk, o2o.pk) self.assertEqual(i.name, "first") with self.assertNumQueries(1): self.assertEqual(i.one_to_one_item.name, "second") with self.assertNumQueries(1): self.assertEqual(i.value, 42) def test_defer_with_select_related(self): item1 = Item.objects.create(name="first", value=47) item2 = Item.objects.create(name="second", value=42) simple = SimpleItem.objects.create(name="simple", value="23") ItemAndSimpleItem.objects.create(item=item1, simple=simple) obj = ItemAndSimpleItem.objects.defer('item').select_related('simple').get() self.assertEqual(obj.item, item1) self.assertEqual(obj.item_id, item1.id) obj.item = item2 obj.save() obj = ItemAndSimpleItem.objects.defer('item').select_related('simple').get() self.assertEqual(obj.item, item2) self.assertEqual(obj.item_id, item2.id) def test_only_with_select_related(self): # Test for #17485. item = SimpleItem.objects.create(name='first', value=47) feature = Feature.objects.create(item=item) SpecialFeature.objects.create(feature=feature) qs = Feature.objects.only('item__name').select_related('item') self.assertEqual(len(qs), 1) qs = SpecialFeature.objects.only('feature__item__name').select_related('feature__item') self.assertEqual(len(qs), 1) def test_deferred_class_factory(self): from django.db.models.query_utils import deferred_class_factory new_class = deferred_class_factory( Item, ('this_is_some_very_long_attribute_name_so_modelname_truncation_is_triggered',)) self.assertEqual( new_class.__name__, 'Item_Deferred_this_is_some_very_long_attribute_nac34b1f495507dad6b02e2cb235c875e') class DeferAnnotateSelectRelatedTest(TestCase): def test_defer_annotate_select_related(self): location = Location.objects.create() Request.objects.create(location=location) self.assertIsInstance(list(Request.objects .annotate(Count('items')).select_related('profile', 'location') .only('profile', 'location')), list) self.assertIsInstance(list(Request.objects .annotate(Count('items')).select_related('profile', 'location') .only('profile__profile1', 'location__location1')), list) self.assertIsInstance(list(Request.objects .annotate(Count('items')).select_related('profile', 'location') .defer('request1', 'request2', 'request3', 'request4')), list)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 697, 492, 8596, 5502, 199, 504, 1639, 14, 697, 14, 992, 492, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 2581, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 199, 504, 1275, 992, 492, 334, 272, 31096, 2765, 12, 7020, 12, 20116, 2081, 12, 12988, 12, 27836, 12, 12373, 12, 5870, 2081, 12, 13407, 12, 272, 7020, 3325, 3184, 2081, 12, 7309, 10939, 2081, 12, 12568, 5968, 12, 12625, 12, 4784, 9, 421, 199, 533, 1487, 2412, 13013, 774, 8, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 327, 17448, 1504, 1077, 7710, 506, 12309, 436, 440, 24634, 1183, 675, 267, 327, 314, 901, 1159, 849, 574, 2951, 2952, 2985, 10621, 1133, 3032, 370, 636, 826, 363, 398, 7020, 14, 1462, 14, 981, 8, 354, 628, 2246, 401, 574, 29, 2260, 9, 267, 1559, 275, 7020, 14, 1462, 14, 2118, 480, 354, 401, 298, 1848, 63, 585, 3471, 362, 8, 354, 628, 2246, 531, 267, 327, 11003, 316, 298, 354, 2, 3181, 1133, 6804, 282, 892, 3050, 1827, 14, 11003, 316, 267, 327, 298, 585, 2, 503, 298, 505, 2, 1077, 14, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 1113, 14, 354, 12, 298, 2246, 531, 288, 291, 14, 629, 8, 1113, 14, 1848, 63, 585, 12, 378, 9, 398, 543, 291, 14, 16463, 8, 17, 304, 288, 291, 14, 629, 8, 1113, 14, 585, 12, 5685, 9, 398, 543, 291, 14, 16463, 8, 17, 304, 288, 291, 14, 629, 8, 1113, 14, 505, 12, 298, 8568, 3605, 531, 398, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 1113, 14, 505, 12, 298, 8568, 3605, 531, 398, 327, 13262, 511, 367, 327, 709, 20017, 14, 4155, 3238, 3365, 4454, 2793, 1133, 267, 327, 315, 350, 422, 767, 590, 8663, 666, 315, 314, 12309, 5872, 2251, 14, 267, 284, 275, 7020, 14, 1462, 14, 981, 8, 354, 628, 889, 473, 6704, 1642, 401, 574, 29, 1401, 9, 267, 2974, 275, 7020, 14, 1462, 14, 2118, 480, 585, 3471, 1648, 63, 991, 6096, 585, 531, 267, 291, 14, 629, 8, 1744, 59, 16, 1055, 354, 12, 298, 2246, 531, 267, 291, 14, 629, 8, 1744, 59, 17, 1055, 354, 12, 298, 889, 473, 6704, 1642, 531, 398, 20116, 2081, 14, 1462, 14, 981, 8, 1053, 29, 73, 9, 267, 519, 275, 20116, 2081, 14, 1462, 14, 11610, 480, 1053, 3471, 362, 342, 267, 291, 14, 629, 8, 82, 14, 1053, 63, 344, 12, 284, 14, 344, 9, 267, 291, 14, 629, 8, 82, 14, 1053, 12, 284, 9, 398, 327, 6601, 9848, 5920, 367, 3504, 63, 2407, 342, 436, 12623, 1402, 267, 327, 5953, 334, 12513, 367, 327, 7555, 709, 680, 267, 286, 17, 275, 12988, 14, 1462, 14, 981, 8, 354, 628, 67, 17, 401, 574, 29, 2260, 9, 267, 286, 18, 275, 12988, 14, 1462, 14, 981, 8, 354, 628, 67, 18, 401, 574, 29, 1401, 9, 267, 27836, 14, 1462, 14, 981, 8, 354, 628, 76, 17, 401, 1982, 29, 67, 17, 12, 3499, 63, 1739, 29, 67, 18, 9, 398, 1559, 275, 27836, 14, 1462, 14, 2118, 480, 354, 401, 298, 1739, 3471, 2416, 63, 2407, 3430, 16, 61, 267, 291, 14, 629, 8, 1113, 14, 1739, 14, 354, 12, 298, 67, 17, 531, 398, 291, 14, 7108, 8, 288, 27836, 14, 1462, 14, 2416, 63, 2407, 1252, 2118, 480, 1739, 363, 354, 401, 298, 4375, 63, 1739, 363, 354, 1288, 359, 355, 298, 76, 17, 401, 288, 2156, 288, 21829, 480, 354, 531, 267, 776, 398, 327, 29941, 4454, 543, 12309, 1504, 1077, 5139, 372, 314, 2011, 267, 327, 1564, 2943, 465, 3932, 2222, 13, 12116, 5459, 334, 1266, 327, 7555, 1703, 680, 267, 16360, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 267, 286, 17, 275, 16360, 8, 2081, 14, 1462, 14, 452, 3430, 16, 566, 267, 286, 18, 275, 16360, 8, 2081, 14, 1462, 14, 11610, 480, 354, 9981, 16, 566, 267, 286, 19, 275, 16360, 8, 2081, 14, 1462, 14, 2118, 480, 354, 9981, 16, 566, 267, 291, 14, 1815, 8, 67, 17, 365, 286, 18, 365, 286, 19, 9, 398, 327, 13262, 367, 327, 7555, 1153, 446, 1454, 342, 883, 506, 1202, 641, 282, 1402, 543, 2877, 267, 327, 11608, 2883, 14, 267, 2058, 275, 27836, 14, 1462, 14, 2118, 480, 354, 401, 298, 1739, 401, 298, 4375, 63, 1739, 3471, 2416, 63, 2407, 342, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 1739, 14, 354, 12, 298, 67, 17, 531, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 4375, 63, 1739, 14, 354, 12, 298, 67, 18, 531, 398, 2058, 275, 27836, 14, 1462, 14, 2118, 8, 288, 298, 354, 401, 298, 1739, 401, 298, 4375, 63, 1739, 401, 298, 1739, 363, 354, 401, 298, 4375, 63, 1739, 363, 354, 2, 267, 7092, 2416, 63, 2407, 342, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 1739, 14, 354, 12, 298, 67, 17, 531, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 4375, 63, 1739, 14, 354, 12, 298, 67, 18, 531, 398, 327, 13262, 367, 327, 8982, 1643, 446, 1852, 3238, 10133, 342, 436, 1454, 342, 1736, 543, 28987, 342, 267, 291, 14, 6926, 8, 288, 769, 8, 3184, 2081, 14, 1462, 14, 10898, 8, 2353, 360, 4445, 11103, 11610, 360, 354, 3855, 288, 769, 9, 267, 291, 14, 6926, 8, 288, 769, 8, 3184, 2081, 14, 1462, 14, 10898, 8, 2353, 360, 4445, 11103, 2118, 360, 354, 3855, 288, 769, 9, 339, 347, 511, 63, 9201, 63, 7119, 1344, 8, 277, 304, 267, 327, 13262, 367, 327, 7119, 1344, 446, 8697, 14, 362, 63, 992, 1077, 440, 372, 12309, 267, 327, 1709, 701, 849, 14, 267, 327, 3378, 282, 17535, 402, 10133, 9212, 880, 626, 1145, 13, 1637, 1471, 1395, 2005, 267, 327, 12309, 3992, 14 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 4182, 492, 21829, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 697, 492, 8596, 5502, 199, 504, 1639, 14, 697, 14, 992, 492, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 8786, 492, 2581, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 199, 504, 1275, 992, 492, 334, 272, 31096, 2765, 12, 7020, 12, 20116, 2081, 12, 12988, 12, 27836, 12, 12373, 12, 5870, 2081, 12, 13407, 12, 272, 7020, 3325, 3184, 2081, 12, 7309, 10939, 2081, 12, 12568, 5968, 12, 12625, 12, 4784, 9, 421, 199, 533, 1487, 2412, 13013, 774, 8, 1746, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 327, 17448, 1504, 1077, 7710, 506, 12309, 436, 440, 24634, 1183, 675, 267, 327, 314, 901, 1159, 849, 574, 2951, 2952, 2985, 10621, 1133, 3032, 370, 636, 826, 363, 398, 7020, 14, 1462, 14, 981, 8, 354, 628, 2246, 401, 574, 29, 2260, 9, 267, 1559, 275, 7020, 14, 1462, 14, 2118, 480, 354, 401, 298, 1848, 63, 585, 3471, 362, 8, 354, 628, 2246, 531, 267, 327, 11003, 316, 298, 354, 2, 3181, 1133, 6804, 282, 892, 3050, 1827, 14, 11003, 316, 267, 327, 298, 585, 2, 503, 298, 505, 2, 1077, 14, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 1113, 14, 354, 12, 298, 2246, 531, 288, 291, 14, 629, 8, 1113, 14, 1848, 63, 585, 12, 378, 9, 398, 543, 291, 14, 16463, 8, 17, 304, 288, 291, 14, 629, 8, 1113, 14, 585, 12, 5685, 9, 398, 543, 291, 14, 16463, 8, 17, 304, 288, 291, 14, 629, 8, 1113, 14, 505, 12, 298, 8568, 3605, 531, 398, 543, 291, 14, 16463, 8, 16, 304, 288, 291, 14, 629, 8, 1113, 14, 505, 12, 298, 8568, 3605, 531, 398, 327, 13262, 511, 367, 327, 709, 20017, 14, 4155, 3238, 3365, 4454, 2793, 1133, 267, 327, 315, 350, 422, 767, 590, 8663, 666, 315, 314, 12309, 5872, 2251, 14, 267, 284, 275, 7020, 14, 1462, 14, 981, 8, 354, 628, 889, 473, 6704, 1642, 401, 574, 29, 1401, 9, 267, 2974, 275, 7020, 14, 1462, 14, 2118, 480, 585, 3471, 1648, 63, 991, 6096, 585, 531, 267, 291, 14, 629, 8, 1744, 59, 16, 1055, 354, 12, 298, 2246, 531, 267, 291, 14, 629, 8, 1744, 59, 17, 1055, 354, 12, 298, 889, 473, 6704, 1642, 531, 398, 20116, 2081, 14, 1462, 14, 981, 8, 1053, 29, 73, 9, 267, 519, 275, 20116, 2081, 14, 1462, 14, 11610, 480, 1053, 3471, 362, 342, 267, 291, 14, 629, 8, 82, 14, 1053, 63, 344, 12, 284, 14, 344, 9, 267, 291, 14, 629, 8, 82, 14, 1053, 12, 284, 9, 398, 327, 6601, 9848, 5920, 367, 3504, 63, 2407, 342, 436, 12623, 1402, 267, 327, 5953, 334, 12513, 367, 327, 7555, 709, 680, 267, 286, 17, 275, 12988, 14, 1462, 14, 981, 8, 354, 628, 67, 17, 401, 574, 29, 2260, 9, 267, 286, 18, 275, 12988, 14, 1462, 14, 981, 8, 354, 628, 67, 18, 401, 574, 29, 1401, 9, 267, 27836, 14, 1462, 14, 981, 8, 354, 628, 76, 17, 401, 1982, 29, 67, 17, 12, 3499, 63, 1739, 29, 67, 18, 9, 398, 1559, 275, 27836, 14, 1462, 14, 2118, 480, 354, 401, 298, 1739, 3471, 2416, 63, 2407, 3430, 16, 61, 267, 291, 14, 629, 8, 1113, 14, 1739, 14, 354, 12, 298, 67, 17, 531, 398, 291, 14, 7108, 8, 288, 27836, 14, 1462, 14, 2416, 63, 2407, 1252, 2118, 480, 1739, 363, 354, 401, 298, 4375, 63, 1739, 363, 354, 1288, 359, 355, 298, 76, 17, 401, 288, 2156, 288, 21829, 480, 354, 531, 267, 776, 398, 327, 29941, 4454, 543, 12309, 1504, 1077, 5139, 372, 314, 2011, 267, 327, 1564, 2943, 465, 3932, 2222, 13, 12116, 5459, 334, 1266, 327, 7555, 1703, 680, 267, 16360, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 267, 286, 17, 275, 16360, 8, 2081, 14, 1462, 14, 452, 3430, 16, 566, 267, 286, 18, 275, 16360, 8, 2081, 14, 1462, 14, 11610, 480, 354, 9981, 16, 566, 267, 286, 19, 275, 16360, 8, 2081, 14, 1462, 14, 2118, 480, 354, 9981, 16, 566, 267, 291, 14, 1815, 8, 67, 17, 365, 286, 18, 365, 286, 19, 9, 398, 327, 13262, 367, 327, 7555, 1153, 446, 1454, 342, 883, 506, 1202, 641, 282, 1402, 543, 2877, 267, 327, 11608, 2883, 14, 267, 2058, 275, 27836, 14, 1462, 14, 2118, 480, 354, 401, 298, 1739, 401, 298, 4375, 63, 1739, 3471, 2416, 63, 2407, 342, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 1739, 14, 354, 12, 298, 67, 17, 531, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 4375, 63, 1739, 14, 354, 12, 298, 67, 18, 531, 398, 2058, 275, 27836, 14, 1462, 14, 2118, 8, 288, 298, 354, 401, 298, 1739, 401, 298, 4375, 63, 1739, 401, 298, 1739, 363, 354, 401, 298, 4375, 63, 1739, 363, 354, 2, 267, 7092, 2416, 63, 2407, 342, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 1739, 14, 354, 12, 298, 67, 17, 531, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 4375, 63, 1739, 14, 354, 12, 298, 67, 18, 531, 398, 327, 13262, 367, 327, 8982, 1643, 446, 1852, 3238, 10133, 342, 436, 1454, 342, 1736, 543, 28987, 342, 267, 291, 14, 6926, 8, 288, 769, 8, 3184, 2081, 14, 1462, 14, 10898, 8, 2353, 360, 4445, 11103, 11610, 360, 354, 3855, 288, 769, 9, 267, 291, 14, 6926, 8, 288, 769, 8, 3184, 2081, 14, 1462, 14, 10898, 8, 2353, 360, 4445, 11103, 2118, 360, 354, 3855, 288, 769, 9, 339, 347, 511, 63, 9201, 63, 7119, 1344, 8, 277, 304, 267, 327, 13262, 367, 327, 7119, 1344, 446, 8697, 14, 362, 63, 992, 1077, 440, 372, 12309, 267, 327, 1709, 701, 849, 14, 267, 327, 3378, 282, 17535, 402, 10133, 9212, 880, 626, 1145, 13, 1637, 1471, 1395, 2005, 267, 327, 12309, 3992, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
unnikrishnankgs/va
venv/lib/python3.5/site-packages/tensorflow/models/object_detection/utils/test_utils_test.py
23
2678
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for object_detection.utils.test_utils.""" import numpy as np import tensorflow as tf from object_detection.utils import test_utils class TestUtilsTest(tf.test.TestCase): def test_diagonal_gradient_image(self): """Tests if a good pyramid image is created.""" pyramid_image = test_utils.create_diagonal_gradient_image(3, 4, 2) # Test which is easy to understand. expected_first_channel = np.array([[3, 2, 1, 0], [4, 3, 2, 1], [5, 4, 3, 2]], dtype=np.float32) self.assertAllEqual(np.squeeze(pyramid_image[:, :, 0]), expected_first_channel) # Actual test. expected_image = np.array([[[3, 30], [2, 20], [1, 10], [0, 0]], [[4, 40], [3, 30], [2, 20], [1, 10]], [[5, 50], [4, 40], [3, 30], [2, 20]]], dtype=np.float32) self.assertAllEqual(pyramid_image, expected_image) def test_random_boxes(self): """Tests if valid random boxes are created.""" num_boxes = 1000 max_height = 3 max_width = 5 boxes = test_utils.create_random_boxes(num_boxes, max_height, max_width) true_column = np.ones(shape=(num_boxes)) == 1 self.assertAllEqual(boxes[:, 0] < boxes[:, 2], true_column) self.assertAllEqual(boxes[:, 1] < boxes[:, 3], true_column) self.assertTrue(boxes[:, 0].min() >= 0) self.assertTrue(boxes[:, 1].min() >= 0) self.assertTrue(boxes[:, 2].max() <= max_height) self.assertTrue(boxes[:, 3].max() <= max_width) if __name__ == '__main__': tf.test.main()
bsd-2-clause
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 909, 63, 11934, 14, 1208, 14, 396, 63, 1208, 1041, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 909, 63, 11934, 14, 1208, 492, 511, 63, 1208, 421, 199, 533, 1379, 7535, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 63, 20057, 63, 7490, 63, 1569, 8, 277, 304, 272, 408, 2925, 340, 282, 6954, 30704, 1834, 365, 2737, 1041, 272, 30704, 63, 1569, 275, 511, 63, 1208, 14, 981, 63, 20057, 63, 7490, 63, 1569, 8, 19, 12, 841, 12, 499, 9, 339, 327, 1379, 1314, 365, 8837, 370, 20647, 14, 272, 1420, 63, 2246, 63, 2775, 275, 980, 14, 1144, 4038, 19, 12, 499, 12, 413, 12, 378, 467, 4318, 359, 20, 12, 650, 12, 499, 12, 413, 467, 4318, 359, 21, 12, 841, 12, 650, 12, 499, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 14, 7069, 8, 1590, 14, 16597, 8, 647, 20785, 63, 1569, 3981, 13785, 378, 2522, 717, 1420, 63, 2246, 63, 2775, 9, 339, 327, 18982, 1061, 511, 14, 272, 1420, 63, 1569, 275, 980, 14, 1144, 23930, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 467, 1816, 359, 17, 12, 1616, 467, 1816, 359, 16, 12, 378, 2365, 3044, 3474, 20, 12, 6335, 467, 1816, 359, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 467, 1816, 359, 17, 12, 1616, 2365, 3044, 3474, 21, 12, 5238, 467, 1816, 359, 20, 12, 6335, 467, 1816, 359, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 15559, 2152, 29, 1590, 14, 1609, 708, 9, 339, 291, 14, 7069, 8, 647, 20785, 63, 1569, 12, 1420, 63, 1569, 9, 819, 347, 511, 63, 2355, 63, 12922, 8, 277, 304, 272, 408, 2925, 340, 1686, 2196, 17193, 787, 2737, 1041, 272, 1967, 63, 12922, 275, 5198, 272, 1390, 63, 3333, 275, 650, 272, 1390, 63, 2063, 275, 959, 272, 17193, 275, 511, 63, 1208, 14, 981, 63, 2355, 63, 12922, 8, 1507, 63, 12922, 12, 5644, 1390, 63, 3333, 12, 5644, 1390, 63, 2063, 9, 339, 2549, 63, 2301, 275, 980, 14, 4548, 8, 1392, 2687, 1507, 63, 12922, 430, 508, 413, 272, 291, 14, 7069, 8, 12922, 3981, 378, 61, 665, 17193, 3981, 499, 467, 2549, 63, 2301, 9, 272, 291, 14, 7069, 8, 12922, 3981, 413, 61, 665, 17193, 3981, 650, 467, 2549, 63, 2301, 9, 339, 291, 14, 1815, 8, 12922, 3981, 378, 1055, 827, 342, 2356, 378, 9, 272, 291, 14, 1815, 8, 12922, 3981, 413, 1055, 827, 342, 2356, 378, 9, 272, 291, 14, 1815, 8, 12922, 3981, 499, 1055, 988, 342, 2695, 1390, 63, 3333, 9, 272, 291, 14, 1815, 8, 12922, 3981, 650, 1055, 988, 342, 2695, 1390, 63, 2063, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 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 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 909, 63, 11934, 14, 1208, 14, 396, 63, 1208, 1041, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 909, 63, 11934, 14, 1208, 492, 511, 63, 1208, 421, 199, 533, 1379, 7535, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 63, 20057, 63, 7490, 63, 1569, 8, 277, 304, 272, 408, 2925, 340, 282, 6954, 30704, 1834, 365, 2737, 1041, 272, 30704, 63, 1569, 275, 511, 63, 1208, 14, 981, 63, 20057, 63, 7490, 63, 1569, 8, 19, 12, 841, 12, 499, 9, 339, 327, 1379, 1314, 365, 8837, 370, 20647, 14, 272, 1420, 63, 2246, 63, 2775, 275, 980, 14, 1144, 4038, 19, 12, 499, 12, 413, 12, 378, 467, 4318, 359, 20, 12, 650, 12, 499, 12, 413, 467, 4318, 359, 21, 12, 841, 12, 650, 12, 499, 2365, 2152, 29, 1590, 14, 1609, 708, 9, 272, 291, 14, 7069, 8, 1590, 14, 16597, 8, 647, 20785, 63, 1569, 3981, 13785, 378, 2522, 717, 1420, 63, 2246, 63, 2775, 9, 339, 327, 18982, 1061, 511, 14, 272, 1420, 63, 1569, 275, 980, 14, 1144, 23930, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 467, 1816, 359, 17, 12, 1616, 467, 1816, 359, 16, 12, 378, 2365, 3044, 3474, 20, 12, 6335, 467, 1816, 359, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 467, 1816, 359, 17, 12, 1616, 2365, 3044, 3474, 21, 12, 5238, 467, 1816, 359, 20, 12, 6335, 467, 1816, 359, 19, 12, 4233, 467, 1816, 359, 18, 12, 3388, 15559, 2152, 29, 1590, 14, 1609, 708, 9, 339, 291, 14, 7069, 8, 647, 20785, 63, 1569, 12, 1420, 63, 1569, 9, 819, 347, 511, 63, 2355, 63, 12922, 8, 277, 304, 272, 408, 2925, 340, 1686, 2196, 17193, 787, 2737, 1041, 272, 1967, 63, 12922, 275, 5198, 272, 1390, 63, 3333, 275, 650, 272, 1390, 63, 2063, 275, 959, 272, 17193, 275, 511, 63, 1208, 14, 981, 63, 2355, 63, 12922, 8, 1507, 63, 12922, 12, 5644, 1390, 63, 3333, 12, 5644, 1390, 63, 2063, 9, 339, 2549, 63, 2301, 275, 980, 14, 4548, 8, 1392, 2687, 1507, 63, 12922, 430, 508, 413, 272, 291, 14, 7069, 8, 12922, 3981, 378, 61, 665, 17193, 3981, 499, 467, 2549, 63, 2301, 9, 272, 291, 14, 7069, 8, 12922, 3981, 413, 61, 665, 17193, 3981, 650, 467, 2549, 63, 2301, 9, 339, 291, 14, 1815, 8, 12922, 3981, 378, 1055, 827, 342, 2356, 378, 9, 272, 291, 14, 1815, 8, 12922, 3981, 413, 1055, 827, 342, 2356, 378, 9, 272, 291, 14, 1815, 8, 12922, 3981, 499, 1055, 988, 342, 2695, 1390, 63, 3333, 9, 272, 291, 14, 1815, 8, 12922, 3981, 650, 1055, 988, 342, 2695, 1390, 63, 2063, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 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, 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, 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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 ]
hoosteeno/mozillians
vendor-local/lib/python/tablib/formats/_tsv.py
6
1288
# -*- coding: utf-8 -*- """ Tablib - TSV (Tab Separated Values) Support. """ from tablib.compat import is_py3, csv, StringIO title = 'tsv' extentions = ('tsv',) DEFAULT_ENCODING = 'utf-8' def export_set(dataset): """Returns a TSV representation of Dataset.""" stream = StringIO() if is_py3: _tsv = csv.writer(stream, delimiter='\t') else: _tsv = csv.writer(stream, encoding=DEFAULT_ENCODING, delimiter='\t') for row in dataset._package(dicts=False): _tsv.writerow(row) return stream.getvalue() def import_set(dset, in_stream, headers=True): """Returns dataset from TSV stream.""" dset.wipe() if is_py3: rows = csv.reader(in_stream.split('\r\n'), delimiter='\t') else: rows = csv.reader(in_stream.split('\r\n'), delimiter='\t', encoding=DEFAULT_ENCODING) for i, row in enumerate(rows): # Skip empty rows if not row: continue if (i == 0) and (headers): dset.headers = row else: dset.append(row) def detect(stream): """Returns True if given stream is valid TSV.""" try: csv.Sniffer().sniff(stream, delimiters='\t') return True except csv.Error: return False
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 23159, 773, 446, 377, 4985, 334, 7690, 27504, 972, 13468, 9, 12502, 14, 199, 624, 199, 199, 504, 5174, 773, 14, 5819, 492, 365, 63, 647, 19, 12, 7392, 12, 5228, 4388, 199, 1213, 275, 283, 29362, 7, 199, 1614, 852, 275, 661, 29362, 9538, 199, 199, 3472, 63, 16314, 275, 283, 1624, 13, 24, 7, 199, 199, 318, 4843, 63, 409, 8, 5214, 304, 272, 408, 3407, 282, 377, 4985, 6025, 402, 20284, 1041, 339, 2547, 275, 5228, 342, 339, 340, 365, 63, 647, 19, 26, 267, 485, 29362, 275, 7392, 14, 5491, 8, 1745, 12, 11172, 17115, 84, 358, 272, 587, 26, 267, 485, 29362, 275, 7392, 14, 5491, 8, 1745, 12, 2644, 29, 3472, 63, 16314, 12, 11172, 17115, 84, 358, 339, 367, 1962, 315, 4789, 423, 2491, 8, 7892, 29, 797, 304, 267, 485, 29362, 14, 22686, 8, 1143, 9, 339, 372, 2547, 14, 7150, 342, 421, 199, 318, 492, 63, 409, 8, 68, 409, 12, 315, 63, 1745, 12, 2323, 29, 549, 304, 272, 408, 3407, 4789, 687, 377, 4985, 2547, 1041, 339, 366, 409, 14, 87, 3662, 342, 339, 340, 365, 63, 647, 19, 26, 267, 4730, 275, 7392, 14, 5503, 8, 262, 63, 1745, 14, 1294, 2258, 82, 60, 78, 659, 11172, 17115, 84, 358, 272, 587, 26, 267, 4730, 275, 7392, 14, 5503, 8, 262, 63, 1745, 14, 1294, 2258, 82, 60, 78, 659, 11172, 17115, 84, 297, 2079, 2644, 29, 3472, 63, 16314, 9, 339, 367, 284, 12, 1962, 315, 3874, 8, 3838, 304, 267, 327, 8232, 2701, 4730, 267, 340, 440, 1962, 26, 288, 1980, 398, 340, 334, 73, 508, 378, 9, 436, 334, 2139, 304, 288, 366, 409, 14, 2139, 275, 1962, 267, 587, 26, 288, 366, 409, 14, 740, 8, 1143, 9, 421, 199, 318, 9696, 8, 1745, 304, 272, 408, 3407, 715, 340, 1627, 2547, 365, 1686, 377, 4985, 1041, 272, 862, 26, 267, 7392, 14, 51, 8445, 1260, 1252, 5167, 15126, 8, 1745, 12, 26968, 17115, 84, 358, 267, 372, 715, 272, 871, 7392, 14, 547, 26, 267, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 624, 23159, 773, 446, 377, 4985, 334, 7690, 27504, 972, 13468, 9, 12502, 14, 199, 624, 199, 199, 504, 5174, 773, 14, 5819, 492, 365, 63, 647, 19, 12, 7392, 12, 5228, 4388, 199, 1213, 275, 283, 29362, 7, 199, 1614, 852, 275, 661, 29362, 9538, 199, 199, 3472, 63, 16314, 275, 283, 1624, 13, 24, 7, 199, 199, 318, 4843, 63, 409, 8, 5214, 304, 272, 408, 3407, 282, 377, 4985, 6025, 402, 20284, 1041, 339, 2547, 275, 5228, 342, 339, 340, 365, 63, 647, 19, 26, 267, 485, 29362, 275, 7392, 14, 5491, 8, 1745, 12, 11172, 17115, 84, 358, 272, 587, 26, 267, 485, 29362, 275, 7392, 14, 5491, 8, 1745, 12, 2644, 29, 3472, 63, 16314, 12, 11172, 17115, 84, 358, 339, 367, 1962, 315, 4789, 423, 2491, 8, 7892, 29, 797, 304, 267, 485, 29362, 14, 22686, 8, 1143, 9, 339, 372, 2547, 14, 7150, 342, 421, 199, 318, 492, 63, 409, 8, 68, 409, 12, 315, 63, 1745, 12, 2323, 29, 549, 304, 272, 408, 3407, 4789, 687, 377, 4985, 2547, 1041, 339, 366, 409, 14, 87, 3662, 342, 339, 340, 365, 63, 647, 19, 26, 267, 4730, 275, 7392, 14, 5503, 8, 262, 63, 1745, 14, 1294, 2258, 82, 60, 78, 659, 11172, 17115, 84, 358, 272, 587, 26, 267, 4730, 275, 7392, 14, 5503, 8, 262, 63, 1745, 14, 1294, 2258, 82, 60, 78, 659, 11172, 17115, 84, 297, 2079, 2644, 29, 3472, 63, 16314, 9, 339, 367, 284, 12, 1962, 315, 3874, 8, 3838, 304, 267, 327, 8232, 2701, 4730, 267, 340, 440, 1962, 26, 288, 1980, 398, 340, 334, 73, 508, 378, 9, 436, 334, 2139, 304, 288, 366, 409, 14, 2139, 275, 1962, 267, 587, 26, 288, 366, 409, 14, 740, 8, 1143, 9, 421, 199, 318, 9696, 8, 1745, 304, 272, 408, 3407, 715, 340, 1627, 2547, 365, 1686, 377, 4985, 1041, 272, 862, 26, 267, 7392, 14, 51, 8445, 1260, 1252, 5167, 15126, 8, 1745, 12, 26968, 17115, 84, 358, 267, 372, 715, 272, 871, 7392, 14, 547, 26, 267, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
BellScurry/gem5-fault-injection
tests/configs/simple-timing-mp-ruby.py
28
3570
# Copyright (c) 2006-2007 The Regents of The University of Michigan # 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 the copyright holders 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 AND FITNESS FOR # A PARTICULAR PURPOSE 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. # # Authors: Ron Dreslinski import m5 from m5.objects import * from m5.defines import buildEnv from m5.util import addToPath import os, optparse, sys # Get paths we might need config_path = os.path.dirname(os.path.abspath(__file__)) config_root = os.path.dirname(config_path) m5_root = os.path.dirname(config_root) addToPath(config_root+'/configs/common') addToPath(config_root+'/configs/ruby') addToPath(config_root+'/configs/topologies') import Options import Ruby parser = optparse.OptionParser() Options.addCommonOptions(parser) # Add the ruby specific and protocol specific options Ruby.define_options(parser) (options, args) = parser.parse_args() # # Set the default cache size and associativity to be very small to encourage # races between requests and writebacks. # options.l1d_size="256B" options.l1i_size="256B" options.l2_size="512B" options.l3_size="1kB" options.l1d_assoc=2 options.l1i_assoc=2 options.l2_assoc=2 options.l3_assoc=2 nb_cores = 4 cpus = [ TimingSimpleCPU(cpu_id=i) for i in xrange(nb_cores) ] # overwrite the num_cpus to equal nb_cores options.num_cpus = nb_cores # system simulated system = System(cpu = cpus, clk_domain = SrcClockDomain(clock = '1GHz')) # Create a seperate clock domain for components that should run at # CPUs frequency system.cpu.clk_domain = SrcClockDomain(clock = '2GHz') Ruby.create_system(options, False, system) # Create a separate clock domain for Ruby system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock) assert(options.num_cpus == len(system.ruby._cpu_ports)) for (i, cpu) in enumerate(system.cpu): # create the interrupt controller cpu.createInterruptController() # # Tie the cpu ports to the ruby cpu ports # cpu.connectAllPorts(system.ruby._cpu_ports[i]) # ----------------------- # run simulation # ----------------------- root = Root( full_system=False, system = system ) root.system.mem_mode = 'timing' # Not much point in this being higher than the L1 latency m5.ticks.setGlobalFrequency('1ns')
bsd-3-clause
[ 3, 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 32472, 577, 470, 472, 10728, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1974, 492, 1050, 1378, 2042, 199, 646, 747, 12, 8691, 12, 984, 199, 199, 3, 2372, 3792, 781, 5594, 1929, 199, 888, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 888, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 515, 9, 199, 77, 21, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 1231, 9, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 2330, 358, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 21952, 358, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 16851, 15241, 358, 199, 199, 646, 8394, 199, 646, 820, 10972, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 4558, 14, 525, 7844, 4558, 8, 2087, 9, 199, 199, 3, 2654, 314, 31855, 2488, 436, 4113, 2488, 1511, 199, 50, 10972, 14, 4640, 63, 1419, 8, 2087, 9, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 199, 3, 2494, 314, 849, 2581, 1568, 436, 4035, 2159, 18936, 370, 506, 7437, 7425, 370, 655, 25715, 474, 199, 3, 660, 823, 3382, 4145, 436, 2218, 894, 83, 14, 199, 3, 199, 1419, 14, 76, 17, 68, 63, 890, 628, 3912, 34, 2, 199, 1419, 14, 76, 17, 73, 63, 890, 628, 3912, 34, 2, 199, 1419, 14, 76, 18, 63, 890, 628, 7736, 34, 2, 199, 1419, 14, 76, 19, 63, 890, 628, 17, 75, 34, 2, 199, 1419, 14, 76, 17, 68, 63, 16824, 29, 18, 199, 1419, 14, 76, 17, 73, 63, 16824, 29, 18, 199, 1419, 14, 76, 18, 63, 16824, 29, 18, 199, 1419, 14, 76, 19, 63, 16824, 29, 18, 199, 199, 4994, 63, 4630, 275, 841, 199, 8896, 275, 359, 26244, 316, 3184, 11011, 8, 3541, 63, 344, 29, 73, 9, 367, 284, 315, 4945, 8, 4994, 63, 4630, 9, 1622, 199, 199, 3, 8970, 314, 1967, 63, 8896, 370, 4472, 8526, 63, 4630, 199, 1419, 14, 1507, 63, 8896, 275, 8526, 63, 4630, 199, 199, 3, 2656, 4389, 8097, 199, 2253, 275, 6187, 8, 3541, 275, 24174, 12, 824, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 17, 39, 13026, 1333, 199, 199, 3, 2790, 282, 542, 529, 323, 12516, 2881, 367, 7323, 626, 1077, 1255, 737, 199, 3, 28504, 9857, 199, 2253, 14, 3541, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 18, 39, 13026, 358, 199, 199, 50, 10972, 14, 981, 63, 2253, 8, 1419, 12, 756, 12, 2656, 9, 199, 199, 3, 2790, 282, 7396, 12516, 2881, 367, 820, 10972, 199, 2253, 14, 21952, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 1511, 14, 21952, 63, 9597, 9, 199, 199, 479, 8, 1419, 14, 1507, 63, 8896, 508, 822, 8, 2253, 14, 21952, 423, 3541, 63, 5203, 430, 199, 199, 509, 334, 73, 12, 5033, 9, 315, 3874, 8, 2253, 14, 3541, 304, 272, 327, 1218, 314, 26791, 7614, 272, 5033, 14, 981, 10647, 7506, 342, 339, 327, 272, 327, 377, 1873, 314, 5033, 8873, 370, 314, 31855, 5033, 8873, 272, 327, 272, 5033, 14, 2242, 2422, 25573, 8, 2253, 14, 21952, 423, 3541, 63, 5203, 59, 73, 566, 199, 199, 3, 10652, 12797, 199, 3, 1255, 17625, 199, 3, 10652, 12797, 199, 199, 1231, 275, 12826, 8, 2615, 63, 2253, 29, 797, 12, 2656, 275, 2656, 776, 199, 1231, 14, 2253, 14, 5286, 63, 632, 275, 283, 14639, 7, 199, 199, 3, 2832, 8298, 2376, 315, 642, 3769, 10948, 2419, 314, 491, 17, 23967, 199, 77, 21, 14, 10406, 14, 409, 7025, 18285, 360, 17, 561, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 32472, 577, 470, 472, 10728, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1974, 492, 1050, 1378, 2042, 199, 646, 747, 12, 8691, 12, 984, 199, 199, 3, 2372, 3792, 781, 5594, 1929, 199, 888, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 888, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 515, 9, 199, 77, 21, 63, 1231, 275, 747, 14, 515, 14, 3475, 8, 888, 63, 1231, 9, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 2330, 358, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 21952, 358, 199, 525, 1378, 2042, 8, 888, 63, 1231, 23164, 7532, 15, 16851, 15241, 358, 199, 199, 646, 8394, 199, 646, 820, 10972, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 4558, 14, 525, 7844, 4558, 8, 2087, 9, 199, 199, 3, 2654, 314, 31855, 2488, 436, 4113, 2488, 1511, 199, 50, 10972, 14, 4640, 63, 1419, 8, 2087, 9, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 199, 3, 2494, 314, 849, 2581, 1568, 436, 4035, 2159, 18936, 370, 506, 7437, 7425, 370, 655, 25715, 474, 199, 3, 660, 823, 3382, 4145, 436, 2218, 894, 83, 14, 199, 3, 199, 1419, 14, 76, 17, 68, 63, 890, 628, 3912, 34, 2, 199, 1419, 14, 76, 17, 73, 63, 890, 628, 3912, 34, 2, 199, 1419, 14, 76, 18, 63, 890, 628, 7736, 34, 2, 199, 1419, 14, 76, 19, 63, 890, 628, 17, 75, 34, 2, 199, 1419, 14, 76, 17, 68, 63, 16824, 29, 18, 199, 1419, 14, 76, 17, 73, 63, 16824, 29, 18, 199, 1419, 14, 76, 18, 63, 16824, 29, 18, 199, 1419, 14, 76, 19, 63, 16824, 29, 18, 199, 199, 4994, 63, 4630, 275, 841, 199, 8896, 275, 359, 26244, 316, 3184, 11011, 8, 3541, 63, 344, 29, 73, 9, 367, 284, 315, 4945, 8, 4994, 63, 4630, 9, 1622, 199, 199, 3, 8970, 314, 1967, 63, 8896, 370, 4472, 8526, 63, 4630, 199, 1419, 14, 1507, 63, 8896, 275, 8526, 63, 4630, 199, 199, 3, 2656, 4389, 8097, 199, 2253, 275, 6187, 8, 3541, 275, 24174, 12, 824, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 17, 39, 13026, 1333, 199, 199, 3, 2790, 282, 542, 529, 323, 12516, 2881, 367, 7323, 626, 1077, 1255, 737, 199, 3, 28504, 9857, 199, 2253, 14, 3541, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 18, 39, 13026, 358, 199, 199, 50, 10972, 14, 981, 63, 2253, 8, 1419, 12, 756, 12, 2656, 9, 199, 199, 3, 2790, 282, 7396, 12516, 2881, 367, 820, 10972, 199, 2253, 14, 21952, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 1511, 14, 21952, 63, 9597, 9, 199, 199, 479, 8, 1419, 14, 1507, 63, 8896, 508, 822, 8, 2253, 14, 21952, 423, 3541, 63, 5203, 430, 199, 199, 509, 334, 73, 12, 5033, 9, 315, 3874, 8, 2253, 14, 3541, 304, 272, 327, 1218, 314, 26791, 7614, 272, 5033, 14, 981, 10647, 7506, 342, 339, 327, 272, 327, 377, 1873, 314, 5033, 8873, 370, 314, 31855, 5033, 8873, 272, 327, 272, 5033, 14, 2242, 2422, 25573, 8, 2253, 14, 21952, 423, 3541, 63, 5203, 59, 73, 566, 199, 199, 3, 10652, 12797, 199, 3, 1255, 17625, 199, 3, 10652, 12797, 199, 199, 1231, 275, 12826, 8, 2615, 63, 2253, 29, 797, 12, 2656, 275, 2656, 776, 199, 1231, 14, 2253, 14, 5286, 63, 632, 275, 283, 14639, 7, 199, 199, 3, 2832, 8298, 2376, 315, 642, 3769, 10948, 2419, 314, 491, 17, 23967, 199, 77, 21, 14, 10406, 14, 409, 7025, 18285, 360, 17, 561, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 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 ]
MalloyPower/parsing-python
front-end/testsuite-python-lib/Python-3.5.0/Lib/test/test_docxmlrpc.py
7
8523
from xmlrpc.server import DocXMLRPCServer import http.client import sys from test import support threading = support.import_module('threading') import time import socket import unittest PORT = None def make_request_and_skipIf(condition, reason): # If we skip the test, we have to make a request because # the server created in setUp blocks expecting one to come in. if not condition: return lambda func: func def decorator(func): def make_request_and_skip(self): self.client.request("GET", "/") self.client.getresponse() raise unittest.SkipTest(reason) return make_request_and_skip return decorator def server(evt, numrequests): serv = DocXMLRPCServer(("localhost", 0), logRequests=False) try: global PORT PORT = serv.socket.getsockname()[1] # Add some documentation serv.set_server_title("DocXMLRPCServer Test Documentation") serv.set_server_name("DocXMLRPCServer Test Docs") serv.set_server_documentation( "This is an XML-RPC server's documentation, but the server " "can be used by POSTing to /RPC2. Try self.add, too.") # Create and register classes and functions class TestClass(object): def test_method(self, arg): """Test method's docs. This method truly does very little.""" self.arg = arg serv.register_introspection_functions() serv.register_instance(TestClass()) def add(x, y): """Add two instances together. This follows PEP008, but has nothing to do with RFC1952. Case should matter: pEp008 and rFC1952. Things that start with http and ftp should be auto-linked, too: http://google.com. """ return x + y def annotation(x: int): """ Use function annotations. """ return x class ClassWithAnnotation: def method_annotation(self, x: bytes): return x.decode() serv.register_function(add) serv.register_function(lambda x, y: x-y) serv.register_function(annotation) serv.register_instance(ClassWithAnnotation()) while numrequests > 0: serv.handle_request() numrequests -= 1 except socket.timeout: pass finally: serv.server_close() PORT = None evt.set() class DocXMLRPCHTTPGETServer(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() # Enable server feedback DocXMLRPCServer._send_traceback_header = True self.evt = threading.Event() threading.Thread(target=server, args=(self.evt, 1)).start() # wait for port to be assigned deadline = time.monotonic() + 10.0 while PORT is None: time.sleep(0.010) if time.monotonic() > deadline: break self.client = http.client.HTTPConnection("localhost:%d" % PORT) def tearDown(self): self.client.close() self.evt.wait() # Disable server feedback DocXMLRPCServer._send_traceback_header = False support.threading_cleanup(*self._threads) def test_valid_get_response(self): self.client.request("GET", "/") response = self.client.getresponse() self.assertEqual(response.status, 200) self.assertEqual(response.getheader("Content-type"), "text/html") # Server raises an exception if we don't start to read the data response.read() def test_invalid_get_response(self): self.client.request("GET", "/spam") response = self.client.getresponse() self.assertEqual(response.status, 404) self.assertEqual(response.getheader("Content-type"), "text/plain") response.read() def test_lambda(self): """Test that lambda functionality stays the same. The output produced currently is, I suspect invalid because of the unencoded brackets in the HTML, "<lambda>". The subtraction lambda method is tested. """ self.client.request("GET", "/") response = self.client.getresponse() self.assertIn((b'<dl><dt><a name="-&lt;lambda&gt;"><strong>' b'&lt;lambda&gt;</strong></a>(x, y)</dt></dl>'), response.read()) @make_request_and_skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_autolinking(self): """Test that the server correctly automatically wraps references to PEPS and RFCs with links, and that it linkifies text starting with http or ftp protocol prefixes. The documentation for the "add" method contains the test material. """ self.client.request("GET", "/") response = self.client.getresponse().read() self.assertIn( (b'<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>' b'<tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;' b'follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">' b'PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>\nto&nbsp;do&nbsp;' b'with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">' b'RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;' b'and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>\nthat&nbsp;start&nbsp;' b'with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;' b'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">' b'http://google.com</a>.</tt></dd></dl>'), response) @make_request_and_skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_system_methods(self): """Test the precense of three consecutive system.* methods. This also tests their use of parameter type recognition and the systems related to that process. """ self.client.request("GET", "/") response = self.client.getresponse().read() self.assertIn( (b'<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp' b'</strong></a>(method_name)</dt><dd><tt><a href="#-system.method' b'Help">system.methodHelp</a>(\'add\')&nbsp;=&gt;&nbsp;"Adds&nbsp;' b'two&nbsp;integers&nbsp;together"<br>\n&nbsp;<br>\nReturns&nbsp;a' b'&nbsp;string&nbsp;containing&nbsp;documentation&nbsp;for&nbsp;' b'the&nbsp;specified&nbsp;method.</tt></dd></dl>\n<dl><dt><a name' b'="-system.methodSignature"><strong>system.methodSignature</strong>' b'</a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">' b'system.methodSignature</a>(\'add\')&nbsp;=&gt;&nbsp;[double,&nbsp;' b'int,&nbsp;int]<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;list&nbsp;' b'describing&nbsp;the&nbsp;signature&nbsp;of&nbsp;the&nbsp;method.' b'&nbsp;In&nbsp;the<br>\nabove&nbsp;example,&nbsp;the&nbsp;add&nbsp;' b'method&nbsp;takes&nbsp;two&nbsp;integers&nbsp;as&nbsp;arguments' b'<br>\nand&nbsp;returns&nbsp;a&nbsp;double&nbsp;result.<br>\n&nbsp;' b'<br>\nThis&nbsp;server&nbsp;does&nbsp;NOT&nbsp;support&nbsp;system' b'.methodSignature.</tt></dd></dl>'), response) def test_autolink_dotted_methods(self): """Test that selfdot values are made strong automatically in the documentation.""" self.client.request("GET", "/") response = self.client.getresponse() self.assertIn(b"""Try&nbsp;self.<strong>add</strong>,&nbsp;too.""", response.read()) def test_annotations(self): """ Test that annotations works as expected """ self.client.request("GET", "/") response = self.client.getresponse() docstring = (b'' if sys.flags.optimize >= 2 else b'<dd><tt>Use&nbsp;function&nbsp;annotations.</tt></dd>') self.assertIn( (b'<dl><dt><a name="-annotation"><strong>annotation</strong></a>' b'(x: int)</dt>' + docstring + b'</dl>\n' b'<dl><dt><a name="-method_annotation"><strong>' b'method_annotation</strong></a>(x: bytes)</dt></dl>'), response.read()) if __name__ == '__main__': unittest.main()
mit
[ 504, 15432, 14, 1000, 492, 5454, 27026, 3120, 199, 646, 1455, 14, 1258, 199, 646, 984, 199, 504, 511, 492, 2291, 199, 12562, 275, 2291, 14, 646, 63, 578, 360, 12562, 358, 199, 646, 900, 199, 646, 2838, 199, 646, 2882, 199, 199, 3657, 275, 488, 199, 199, 318, 1852, 63, 1069, 63, 460, 63, 15118, 8, 5394, 12, 4499, 304, 272, 327, 982, 781, 3372, 314, 511, 12, 781, 1172, 370, 1852, 282, 1056, 2952, 272, 327, 314, 1654, 2737, 315, 3613, 5664, 21055, 1373, 370, 11492, 315, 14, 272, 340, 440, 5558, 26, 267, 372, 2400, 2562, 26, 2562, 272, 347, 7531, 8, 1532, 304, 267, 347, 1852, 63, 1069, 63, 460, 63, 2759, 8, 277, 304, 288, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 288, 291, 14, 1258, 14, 25006, 342, 288, 746, 2882, 14, 25755, 8, 5764, 9, 267, 372, 1852, 63, 1069, 63, 460, 63, 2759, 272, 372, 7531, 421, 199, 318, 1654, 8, 19296, 12, 1967, 6615, 304, 272, 27415, 275, 5454, 27026, 3120, 9313, 5967, 401, 378, 395, 943, 16272, 29, 797, 9, 339, 862, 26, 267, 2288, 25562, 267, 25562, 275, 27415, 14, 3450, 14, 27886, 3430, 17, 61, 398, 327, 2654, 2005, 3794, 267, 27415, 14, 409, 63, 1000, 63, 1213, 480, 3768, 27026, 3120, 1379, 15249, 531, 267, 27415, 14, 409, 63, 1000, 63, 354, 480, 3768, 27026, 3120, 1379, 5454, 83, 531, 267, 27415, 14, 409, 63, 1000, 63, 9970, 8, 288, 298, 2765, 365, 376, 4692, 13, 8171, 1654, 1159, 3794, 12, 1325, 314, 1654, 298, 288, 298, 2425, 506, 1202, 701, 8761, 316, 370, 1182, 8171, 18, 14, 7649, 291, 14, 525, 12, 4634, 2685, 398, 327, 2790, 436, 2274, 3992, 436, 3423, 267, 1021, 1379, 2543, 8, 785, 304, 288, 347, 511, 63, 765, 8, 277, 12, 1680, 304, 355, 408, 774, 1083, 1159, 9149, 14, 961, 1083, 5651, 21797, 1630, 7437, 12050, 1041, 355, 291, 14, 1273, 275, 1680, 398, 27415, 14, 2683, 63, 21627, 63, 5777, 342, 267, 27415, 14, 2683, 63, 842, 8, 22009, 1012, 398, 347, 1050, 8, 88, 12, 612, 304, 288, 408, 1123, 2877, 4454, 10451, 14, 961, 11924, 13663, 8662, 12, 1325, 965, 6548, 288, 370, 886, 543, 7329, 1167, 2528, 14, 12425, 1077, 17247, 26, 299, 14057, 8662, 436, 519, 4161, 1167, 2528, 14, 221, 3868, 780, 288, 626, 1343, 543, 1455, 436, 14904, 1077, 506, 2599, 13, 12751, 12, 4634, 26, 288, 1455, 921, 3098, 14, 957, 14, 288, 408, 288, 372, 671, 435, 612, 398, 347, 11262, 8, 88, 26, 1109, 304, 288, 408, 3645, 805, 15538, 14, 408, 288, 372, 671, 398, 1021, 8089, 3007, 16768, 26, 288, 347, 1083, 63, 9340, 8, 277, 12, 671, 26, 2783, 304, 355, 372, 671, 14, 2708, 342, 398, 27415, 14, 2683, 63, 1593, 8, 525, 9, 267, 27415, 14, 2683, 63, 1593, 8, 2734, 671, 12, 612, 26, 671, 13, 89, 9, 267, 27415, 14, 2683, 63, 1593, 8, 9340, 9, 267, 27415, 14, 2683, 63, 842, 8, 2543, 3007, 16768, 1012, 398, 1830, 1967, 6615, 690, 378, 26, 288, 27415, 14, 2479, 63, 1069, 342, 288, 1967, 6615, 4862, 413, 272, 871, 2838, 14, 2593, 26, 267, 986, 272, 3753, 26, 267, 27415, 14, 1000, 63, 1600, 342, 267, 25562, 275, 488, 267, 16330, 14, 409, 342, 199, 199, 533, 5454, 4317, 18612, 1244, 1878, 2970, 3120, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 6962, 275, 2291, 14, 12562, 63, 2758, 342, 267, 327, 12030, 1654, 17145, 267, 5454, 27026, 3120, 423, 2254, 63, 6894, 63, 1291, 275, 715, 398, 291, 14, 19296, 275, 5796, 14, 2390, 342, 267, 5796, 14, 4436, 8, 1375, 29, 1000, 12, 1249, 2687, 277, 14, 19296, 12, 413, 4992, 928, 342, 398, 327, 3618, 367, 1844, 370, 506, 7943, 267, 23081, 275, 900, 14, 2106, 18692, 342, 435, 1616, 14, 16, 267, 1830, 25562, 365, 488, 26, 288, 900, 14, 4532, 8, 16, 14, 9523, 9, 288, 340, 900, 14, 2106, 18692, 342, 690, 23081, 26, 355, 2059, 398, 291, 14, 1258, 275, 1455, 14, 1258, 14, 19114, 480, 5967, 2689, 68, 2, 450, 25562, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1258, 14, 1600, 342, 398, 291, 14, 19296, 14, 2573, 342, 398, 327, 17534, 1654, 17145, 267, 5454, 27026, 3120, 423, 2254, 63, 6894, 63, 1291, 275, 756, 267, 2291, 14, 12562, 63, 7661, 2031, 277, 423, 6962, 9, 339, 347, 511, 63, 1078, 63, 362, 63, 1310, 8, 277, 304, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 629, 8, 1310, 14, 1205, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 19958, 480, 2714, 13, 466, 1288, 298, 505, 15, 1360, 531, 398, 327, 7146, 6534, 376, 1919, 340, 781, 2793, 1133, 1343, 370, 1586, 314, 666, 267, 1177, 14, 739, 342, 339, 347, 511, 63, 3197, 63, 362, 63, 1310, 8, 277, 304, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 8283, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 629, 8, 1310, 14, 1205, 12, 7901, 9, 267, 291, 14, 629, 8, 1310, 14, 19958, 480, 2714, 13, 466, 1288, 298, 505, 15, 6104, 531, 398, 1177, 14, 739, 342, 339, 347, 511, 63, 2734, 8, 277, 304, 267, 408, 774, 626, 2400, 9330, 2612, 588, 314, 2011, 14, 221, 710, 1072, 13584, 267, 5544, 365, 12, 473, 308, 527, 1764, 3866, 2952, 402, 314, 625, 8167, 21873, 315, 314, 267, 4163, 12, 3886, 2734, 23167, 398, 710, 1007, 26137, 2400, 1083, 365, 12470, 14, 267, 408, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 4080, 1332, 66, 7601, 5030, 2535, 3583, 2535, 65, 536, 27295, 6, 4116, 27, 2734, 6, 3308, 27, 8186, 9370, 3524, 2432, 330, 21840, 4116, 27, 2734, 6, 3308, 12279, 9370, 2957, 65, 13661, 88, 12, 612, 15939, 3583, 2957, 5030, 25642, 1993, 1177, 14, 739, 1012, 339, 768, 1875, 63, 1069 ]
[ 15432, 14, 1000, 492, 5454, 27026, 3120, 199, 646, 1455, 14, 1258, 199, 646, 984, 199, 504, 511, 492, 2291, 199, 12562, 275, 2291, 14, 646, 63, 578, 360, 12562, 358, 199, 646, 900, 199, 646, 2838, 199, 646, 2882, 199, 199, 3657, 275, 488, 199, 199, 318, 1852, 63, 1069, 63, 460, 63, 15118, 8, 5394, 12, 4499, 304, 272, 327, 982, 781, 3372, 314, 511, 12, 781, 1172, 370, 1852, 282, 1056, 2952, 272, 327, 314, 1654, 2737, 315, 3613, 5664, 21055, 1373, 370, 11492, 315, 14, 272, 340, 440, 5558, 26, 267, 372, 2400, 2562, 26, 2562, 272, 347, 7531, 8, 1532, 304, 267, 347, 1852, 63, 1069, 63, 460, 63, 2759, 8, 277, 304, 288, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 288, 291, 14, 1258, 14, 25006, 342, 288, 746, 2882, 14, 25755, 8, 5764, 9, 267, 372, 1852, 63, 1069, 63, 460, 63, 2759, 272, 372, 7531, 421, 199, 318, 1654, 8, 19296, 12, 1967, 6615, 304, 272, 27415, 275, 5454, 27026, 3120, 9313, 5967, 401, 378, 395, 943, 16272, 29, 797, 9, 339, 862, 26, 267, 2288, 25562, 267, 25562, 275, 27415, 14, 3450, 14, 27886, 3430, 17, 61, 398, 327, 2654, 2005, 3794, 267, 27415, 14, 409, 63, 1000, 63, 1213, 480, 3768, 27026, 3120, 1379, 15249, 531, 267, 27415, 14, 409, 63, 1000, 63, 354, 480, 3768, 27026, 3120, 1379, 5454, 83, 531, 267, 27415, 14, 409, 63, 1000, 63, 9970, 8, 288, 298, 2765, 365, 376, 4692, 13, 8171, 1654, 1159, 3794, 12, 1325, 314, 1654, 298, 288, 298, 2425, 506, 1202, 701, 8761, 316, 370, 1182, 8171, 18, 14, 7649, 291, 14, 525, 12, 4634, 2685, 398, 327, 2790, 436, 2274, 3992, 436, 3423, 267, 1021, 1379, 2543, 8, 785, 304, 288, 347, 511, 63, 765, 8, 277, 12, 1680, 304, 355, 408, 774, 1083, 1159, 9149, 14, 961, 1083, 5651, 21797, 1630, 7437, 12050, 1041, 355, 291, 14, 1273, 275, 1680, 398, 27415, 14, 2683, 63, 21627, 63, 5777, 342, 267, 27415, 14, 2683, 63, 842, 8, 22009, 1012, 398, 347, 1050, 8, 88, 12, 612, 304, 288, 408, 1123, 2877, 4454, 10451, 14, 961, 11924, 13663, 8662, 12, 1325, 965, 6548, 288, 370, 886, 543, 7329, 1167, 2528, 14, 12425, 1077, 17247, 26, 299, 14057, 8662, 436, 519, 4161, 1167, 2528, 14, 221, 3868, 780, 288, 626, 1343, 543, 1455, 436, 14904, 1077, 506, 2599, 13, 12751, 12, 4634, 26, 288, 1455, 921, 3098, 14, 957, 14, 288, 408, 288, 372, 671, 435, 612, 398, 347, 11262, 8, 88, 26, 1109, 304, 288, 408, 3645, 805, 15538, 14, 408, 288, 372, 671, 398, 1021, 8089, 3007, 16768, 26, 288, 347, 1083, 63, 9340, 8, 277, 12, 671, 26, 2783, 304, 355, 372, 671, 14, 2708, 342, 398, 27415, 14, 2683, 63, 1593, 8, 525, 9, 267, 27415, 14, 2683, 63, 1593, 8, 2734, 671, 12, 612, 26, 671, 13, 89, 9, 267, 27415, 14, 2683, 63, 1593, 8, 9340, 9, 267, 27415, 14, 2683, 63, 842, 8, 2543, 3007, 16768, 1012, 398, 1830, 1967, 6615, 690, 378, 26, 288, 27415, 14, 2479, 63, 1069, 342, 288, 1967, 6615, 4862, 413, 272, 871, 2838, 14, 2593, 26, 267, 986, 272, 3753, 26, 267, 27415, 14, 1000, 63, 1600, 342, 267, 25562, 275, 488, 267, 16330, 14, 409, 342, 199, 199, 533, 5454, 4317, 18612, 1244, 1878, 2970, 3120, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 423, 6962, 275, 2291, 14, 12562, 63, 2758, 342, 267, 327, 12030, 1654, 17145, 267, 5454, 27026, 3120, 423, 2254, 63, 6894, 63, 1291, 275, 715, 398, 291, 14, 19296, 275, 5796, 14, 2390, 342, 267, 5796, 14, 4436, 8, 1375, 29, 1000, 12, 1249, 2687, 277, 14, 19296, 12, 413, 4992, 928, 342, 398, 327, 3618, 367, 1844, 370, 506, 7943, 267, 23081, 275, 900, 14, 2106, 18692, 342, 435, 1616, 14, 16, 267, 1830, 25562, 365, 488, 26, 288, 900, 14, 4532, 8, 16, 14, 9523, 9, 288, 340, 900, 14, 2106, 18692, 342, 690, 23081, 26, 355, 2059, 398, 291, 14, 1258, 275, 1455, 14, 1258, 14, 19114, 480, 5967, 2689, 68, 2, 450, 25562, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1258, 14, 1600, 342, 398, 291, 14, 19296, 14, 2573, 342, 398, 327, 17534, 1654, 17145, 267, 5454, 27026, 3120, 423, 2254, 63, 6894, 63, 1291, 275, 756, 267, 2291, 14, 12562, 63, 7661, 2031, 277, 423, 6962, 9, 339, 347, 511, 63, 1078, 63, 362, 63, 1310, 8, 277, 304, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 629, 8, 1310, 14, 1205, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 19958, 480, 2714, 13, 466, 1288, 298, 505, 15, 1360, 531, 398, 327, 7146, 6534, 376, 1919, 340, 781, 2793, 1133, 1343, 370, 1586, 314, 666, 267, 1177, 14, 739, 342, 339, 347, 511, 63, 3197, 63, 362, 63, 1310, 8, 277, 304, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 8283, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 629, 8, 1310, 14, 1205, 12, 7901, 9, 267, 291, 14, 629, 8, 1310, 14, 19958, 480, 2714, 13, 466, 1288, 298, 505, 15, 6104, 531, 398, 1177, 14, 739, 342, 339, 347, 511, 63, 2734, 8, 277, 304, 267, 408, 774, 626, 2400, 9330, 2612, 588, 314, 2011, 14, 221, 710, 1072, 13584, 267, 5544, 365, 12, 473, 308, 527, 1764, 3866, 2952, 402, 314, 625, 8167, 21873, 315, 314, 267, 4163, 12, 3886, 2734, 23167, 398, 710, 1007, 26137, 2400, 1083, 365, 12470, 14, 267, 408, 267, 291, 14, 1258, 14, 1069, 480, 2970, 401, 3286, 531, 267, 1177, 275, 291, 14, 1258, 14, 25006, 342, 398, 291, 14, 4080, 1332, 66, 7601, 5030, 2535, 3583, 2535, 65, 536, 27295, 6, 4116, 27, 2734, 6, 3308, 27, 8186, 9370, 3524, 2432, 330, 21840, 4116, 27, 2734, 6, 3308, 12279, 9370, 2957, 65, 13661, 88, 12, 612, 15939, 3583, 2957, 5030, 25642, 1993, 1177, 14, 739, 1012, 339, 768, 1875, 63, 1069, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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/>. DOCUMENTATION = """ --- module: elasticache short_description: Manage cache clusters in Amazon Elasticache. description: - Manage cache clusters in Amazon Elasticache. - Returns information about the specified cache cluster. version_added: "1.4" author: "Jim Dalton (@jsdalton)" options: state: description: - C(absent) or C(present) are idempotent actions that will create or destroy a cache cluster as needed. C(rebooted) will reboot the cluster, resulting in a momentary outage. choices: ['present', 'absent', 'rebooted'] required: true name: description: - The cache cluster identifier required: true engine: description: - Name of the cache engine to be used (memcached or redis) required: false default: memcached cache_engine_version: description: - The version number of the cache engine required: false default: none node_type: description: - The compute and memory capacity of the nodes in the cache cluster required: false default: cache.m1.small num_nodes: description: - The initial number of cache nodes that the cache cluster will have required: false cache_port: description: - The port number on which each of the cache nodes will accept connections required: false default: none cache_subnet_group: description: - The subnet group name to associate with. Only use if inside a vpc. Required if inside a vpc required: conditional default: None version_added: "2.0" security_group_ids: description: - A list of vpc security group names to associate with this cache cluster. Only use if inside a vpc required: false default: ['default'] version_added: "1.6" cache_security_groups: description: - A list of cache security group names to associate with this cache cluster. Must be an empty list if inside a vpc required: false default: ['default'] zone: description: - The EC2 Availability Zone in which the cache cluster will be created required: false default: None wait: description: - Wait for cache cluster result before returning required: false default: yes choices: [ "yes", "no" ] hard_modify: description: - Whether to destroy and recreate an existing cache cluster if necessary in order to modify its state required: false default: no choices: [ "yes", "no" ] region: description: - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. required: true default: null aliases: ['aws_region', 'ec2_region'] extends_documentation_fragment: aws """ EXAMPLES = """ # Note: None of these examples set aws_access_key, aws_secret_key, or region. # It is assumed that their matching environment variables are set. # Basic example - elasticache: name: "test-please-delete" state: present engine: memcached cache_engine_version: 1.4.14 node_type: cache.m1.small num_nodes: 1 cache_port: 11211 cache_security_groups: - default zone: us-east-1d # Ensure cache cluster is gone - elasticache: name: "test-please-delete" state: absent # Reboot cache cluster - elasticache: name: "test-please-delete" state: rebooted """ import sys import time try: import boto from boto.elasticache.layer1 import ElastiCacheConnection from boto.regioninfo import RegionInfo HAS_BOTO = True except ImportError: HAS_BOTO = False class ElastiCacheManager(object): """Handles elasticache creation and destruction""" EXIST_STATUSES = ['available', 'creating', 'rebooting', 'modifying'] def __init__(self, module, name, engine, cache_engine_version, node_type, num_nodes, cache_port, cache_subnet_group, cache_security_groups, security_group_ids, zone, wait, hard_modify, region, **aws_connect_kwargs): self.module = module self.name = name self.engine = engine self.cache_engine_version = cache_engine_version self.node_type = node_type self.num_nodes = num_nodes self.cache_port = cache_port self.cache_subnet_group = cache_subnet_group self.cache_security_groups = cache_security_groups self.security_group_ids = security_group_ids self.zone = zone self.wait = wait self.hard_modify = hard_modify self.region = region self.aws_connect_kwargs = aws_connect_kwargs self.changed = False self.data = None self.status = 'gone' self.conn = self._get_elasticache_connection() self._refresh_data() def ensure_present(self): """Ensure cache cluster exists or create it if not""" if self.exists(): self.sync() else: self.create() def ensure_absent(self): """Ensure cache cluster is gone or delete it if not""" self.delete() def ensure_rebooted(self): """Ensure cache cluster is gone or delete it if not""" self.reboot() def exists(self): """Check if cache cluster exists""" return self.status in self.EXIST_STATUSES def create(self): """Create an ElastiCache cluster""" if self.status == 'available': return if self.status in ['creating', 'rebooting', 'modifying']: if self.wait: self._wait_for_status('available') return if self.status == 'deleting': if self.wait: self._wait_for_status('gone') else: msg = "'%s' is currently deleting. Cannot create." self.module.fail_json(msg=msg % self.name) try: response = self.conn.create_cache_cluster(cache_cluster_id=self.name, num_cache_nodes=self.num_nodes, cache_node_type=self.node_type, engine=self.engine, engine_version=self.cache_engine_version, cache_security_group_names=self.cache_security_groups, security_group_ids=self.security_group_ids, cache_subnet_group_name=self.cache_subnet_group, preferred_availability_zone=self.zone, port=self.cache_port) except boto.exception.BotoServerError, e: self.module.fail_json(msg=e.message) cache_cluster_data = response['CreateCacheClusterResponse']['CreateCacheClusterResult']['CacheCluster'] self._refresh_data(cache_cluster_data) self.changed = True if self.wait: self._wait_for_status('available') return True def delete(self): """Destroy an ElastiCache cluster""" if self.status == 'gone': return if self.status == 'deleting': if self.wait: self._wait_for_status('gone') return if self.status in ['creating', 'rebooting', 'modifying']: if self.wait: self._wait_for_status('available') else: msg = "'%s' is currently %s. Cannot delete." self.module.fail_json(msg=msg % (self.name, self.status)) try: response = self.conn.delete_cache_cluster(cache_cluster_id=self.name) except boto.exception.BotoServerError, e: self.module.fail_json(msg=e.message) cache_cluster_data = response['DeleteCacheClusterResponse']['DeleteCacheClusterResult']['CacheCluster'] self._refresh_data(cache_cluster_data) self.changed = True if self.wait: self._wait_for_status('gone') def sync(self): """Sync settings to cluster if required""" if not self.exists(): msg = "'%s' is %s. Cannot sync." self.module.fail_json(msg=msg % (self.name, self.status)) if self.status in ['creating', 'rebooting', 'modifying']: if self.wait: self._wait_for_status('available') else: # Cluster can only be synced if available. If we can't wait # for this, then just be done. return if self._requires_destroy_and_create(): if not self.hard_modify: msg = "'%s' requires destructive modification. 'hard_modify' must be set to true to proceed." self.module.fail_json(msg=msg % self.name) if not self.wait: msg = "'%s' requires destructive modification. 'wait' must be set to true." self.module.fail_json(msg=msg % self.name) self.delete() self.create() return if self._requires_modification(): self.modify() def modify(self): """Modify the cache cluster. Note it's only possible to modify a few select options.""" nodes_to_remove = self._get_nodes_to_remove() try: response = self.conn.modify_cache_cluster(cache_cluster_id=self.name, num_cache_nodes=self.num_nodes, cache_node_ids_to_remove=nodes_to_remove, cache_security_group_names=self.cache_security_groups, security_group_ids=self.security_group_ids, apply_immediately=True, engine_version=self.cache_engine_version) except boto.exception.BotoServerError, e: self.module.fail_json(msg=e.message) cache_cluster_data = response['ModifyCacheClusterResponse']['ModifyCacheClusterResult']['CacheCluster'] self._refresh_data(cache_cluster_data) self.changed = True if self.wait: self._wait_for_status('available') def reboot(self): """Reboot the cache cluster""" if not self.exists(): msg = "'%s' is %s. Cannot reboot." self.module.fail_json(msg=msg % (self.name, self.status)) if self.status == 'rebooting': return if self.status in ['creating', 'modifying']: if self.wait: self._wait_for_status('available') else: msg = "'%s' is currently %s. Cannot reboot." self.module.fail_json(msg=msg % (self.name, self.status)) # Collect ALL nodes for reboot cache_node_ids = [cn['CacheNodeId'] for cn in self.data['CacheNodes']] try: response = self.conn.reboot_cache_cluster(cache_cluster_id=self.name, cache_node_ids_to_reboot=cache_node_ids) except boto.exception.BotoServerError, e: self.module.fail_json(msg=e.message) cache_cluster_data = response['RebootCacheClusterResponse']['RebootCacheClusterResult']['CacheCluster'] self._refresh_data(cache_cluster_data) self.changed = True if self.wait: self._wait_for_status('available') def get_info(self): """Return basic info about the cache cluster""" info = { 'name': self.name, 'status': self.status } if self.data: info['data'] = self.data return info def _wait_for_status(self, awaited_status): """Wait for status to change from present status to awaited_status""" status_map = { 'creating': 'available', 'rebooting': 'available', 'modifying': 'available', 'deleting': 'gone' } if self.status == awaited_status: # No need to wait, we're already done return if status_map[self.status] != awaited_status: msg = "Invalid awaited status. '%s' cannot transition to '%s'" self.module.fail_json(msg=msg % (self.status, awaited_status)) if awaited_status not in set(status_map.values()): msg = "'%s' is not a valid awaited status." self.module.fail_json(msg=msg % awaited_status) while True: time.sleep(1) self._refresh_data() if self.status == awaited_status: break def _requires_modification(self): """Check if cluster requires (nondestructive) modification""" # Check modifiable data attributes modifiable_data = { 'NumCacheNodes': self.num_nodes, 'EngineVersion': self.cache_engine_version } for key, value in modifiable_data.iteritems(): if self.data[key] != value: return True # Check cache security groups cache_security_groups = [] for sg in self.data['CacheSecurityGroups']: cache_security_groups.append(sg['CacheSecurityGroupName']) if set(cache_security_groups) - set(self.cache_security_groups): return True # check vpc security groups vpc_security_groups = [] security_groups = self.data['SecurityGroups'] or [] for sg in security_groups: vpc_security_groups.append(sg['SecurityGroupId']) if set(vpc_security_groups) - set(self.security_group_ids): return True return False def _requires_destroy_and_create(self): """ Check whether a destroy and create is required to synchronize cluster. """ unmodifiable_data = { 'node_type': self.data['CacheNodeType'], 'engine': self.data['Engine'], 'cache_port': self._get_port() } # Only check for modifications if zone is specified if self.zone is not None: unmodifiable_data['zone'] = self.data['PreferredAvailabilityZone'] for key, value in unmodifiable_data.iteritems(): if getattr(self, key) != value: return True return False def _get_elasticache_connection(self): """Get an elasticache connection""" try: endpoint = "elasticache.%s.amazonaws.com" % self.region connect_region = RegionInfo(name=self.region, endpoint=endpoint) return ElastiCacheConnection( region=connect_region, **self.aws_connect_kwargs ) except boto.exception.NoAuthHandlerFound, e: self.module.fail_json(msg=e.message) def _get_port(self): """Get the port. Where this information is retrieved from is engine dependent.""" if self.data['Engine'] == 'memcached': return self.data['ConfigurationEndpoint']['Port'] elif self.data['Engine'] == 'redis': # Redis only supports a single node (presently) so just use # the first and only return self.data['CacheNodes'][0]['Endpoint']['Port'] def _refresh_data(self, cache_cluster_data=None): """Refresh data about this cache cluster""" if cache_cluster_data is None: try: response = self.conn.describe_cache_clusters(cache_cluster_id=self.name, show_cache_node_info=True) except boto.exception.BotoServerError: self.data = None self.status = 'gone' return cache_cluster_data = response['DescribeCacheClustersResponse']['DescribeCacheClustersResult']['CacheClusters'][0] self.data = cache_cluster_data self.status = self.data['CacheClusterStatus'] # The documentation for elasticache lies -- status on rebooting is set # to 'rebooting cache cluster nodes' instead of 'rebooting'. Fix it # here to make status checks etc. more sane. if self.status == 'rebooting cache cluster nodes': self.status = 'rebooting' def _get_nodes_to_remove(self): """If there are nodes to remove, it figures out which need to be removed""" num_nodes_to_remove = self.data['NumCacheNodes'] - self.num_nodes if num_nodes_to_remove <= 0: return None if not self.hard_modify: msg = "'%s' requires removal of cache nodes. 'hard_modify' must be set to true to proceed." self.module.fail_json(msg=msg % self.name) cache_node_ids = [cn['CacheNodeId'] for cn in self.data['CacheNodes']] return cache_node_ids[-num_nodes_to_remove:] def main(): argument_spec = ec2_argument_spec() default = object() argument_spec.update(dict( state={'required': True, 'choices': ['present', 'absent', 'rebooted']}, name={'required': True}, engine={'required': False, 'default': 'memcached'}, cache_engine_version={'required': False}, node_type={'required': False, 'default': 'cache.m1.small'}, num_nodes={'required': False, 'default': None, 'type': 'int'}, cache_port={'required': False, 'type': 'int'}, cache_subnet_group={'required': False, 'default': None}, cache_security_groups={'required': False, 'default': [default], 'type': 'list'}, security_group_ids={'required': False, 'default': [], 'type': 'list'}, zone={'required': False, 'default': None}, wait={'required': False, 'type' : 'bool', 'default': True}, hard_modify={'required': False, 'type': 'bool', 'default': False} ) ) module = AnsibleModule( argument_spec=argument_spec, ) if not HAS_BOTO: module.fail_json(msg='boto required for this module') region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) name = module.params['name'] state = module.params['state'] engine = module.params['engine'] cache_engine_version = module.params['cache_engine_version'] node_type = module.params['node_type'] num_nodes = module.params['num_nodes'] cache_port = module.params['cache_port'] cache_subnet_group = module.params['cache_subnet_group'] cache_security_groups = module.params['cache_security_groups'] security_group_ids = module.params['security_group_ids'] zone = module.params['zone'] wait = module.params['wait'] hard_modify = module.params['hard_modify'] if cache_subnet_group and cache_security_groups == [default]: cache_security_groups = [] if cache_subnet_group and cache_security_groups: module.fail_json(msg="Can't specify both cache_subnet_group and cache_security_groups") if cache_security_groups == [default]: cache_security_groups = ['default'] if state == 'present' and not num_nodes: module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0") if not region: module.fail_json(msg=str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set.")) elasticache_manager = ElastiCacheManager(module, name, engine, cache_engine_version, node_type, num_nodes, cache_port, cache_subnet_group, cache_security_groups, security_group_ids, zone, wait, hard_modify, region, **aws_connect_kwargs) if state == 'present': elasticache_manager.ensure_present() elif state == 'absent': elasticache_manager.ensure_absent() elif state == 'rebooted': elasticache_manager.ensure_rebooted() facts_result = dict(changed=elasticache_manager.changed, elasticache=elasticache_manager.get_info()) module.exit_json(**facts_result) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.ec2 import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 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, 8948, 275, 408, 199, 2595, 199, 578, 26, 24380, 21481, 199, 3612, 63, 1802, 26, 14944, 2581, 13865, 315, 14347, 19509, 21481, 14, 199, 1802, 26, 523, 446, 14944, 2581, 13865, 315, 14347, 19509, 21481, 14, 523, 446, 1803, 2556, 3595, 314, 2013, 2581, 4350, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 20, 2, 199, 2502, 26, 298, 42, 1017, 577, 279, 1860, 8593, 3596, 12390, 1860, 2924, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 445, 8, 5575, 9, 503, 445, 8, 1881, 9, 787, 32122, 5445, 626, 911, 1218, 503, 11972, 282, 2581, 4350, 465, 4346, 14, 445, 8, 264, 656, 5731, 9, 911, 19457, 314, 4350, 12, 9183, 315, 282, 12427, 695, 734, 474, 14, 272, 3415, 26, 788, 1881, 297, 283, 5575, 297, 283, 264, 656, 5731, 418, 272, 1415, 26, 2549, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 2581, 4350, 5148, 272, 1415, 26, 2549, 523, 6869, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2581, 6869, 370, 506, 1202, 334, 32567, 503, 16967, 9, 272, 1415, 26, 3055, 272, 849, 26, 7573, 5245, 523, 2581, 63, 3908, 63, 1023, 26, 272, 1369, 26, 489, 446, 710, 1015, 1329, 402, 314, 2581, 6869, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 1031, 63, 466, 26, 272, 1369, 26, 489, 446, 710, 4526, 436, 4402, 14893, 402, 314, 3380, 315, 314, 2581, 4350, 272, 1415, 26, 3055, 272, 849, 26, 2581, 14, 77, 17, 14, 7241, 523, 1967, 63, 2415, 26, 272, 1369, 26, 489, 446, 710, 2536, 1329, 402, 2581, 3380, 626, 314, 2581, 4350, 911, 1172, 272, 1415, 26, 3055, 523, 2581, 63, 719, 26, 272, 1369, 26, 489, 446, 710, 1844, 1329, 641, 1314, 1924, 402, 314, 2581, 3380, 911, 4729, 6947, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 2581, 63, 5327, 63, 923, 26, 272, 1369, 26, 489, 446, 710, 6303, 1572, 536, 370, 20133, 543, 14, 5972, 675, 340, 6272, 282, 12830, 14, 11105, 340, 6272, 282, 12830, 272, 1415, 26, 12303, 272, 849, 26, 488, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 6391, 63, 923, 63, 1580, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 12830, 6391, 1572, 1561, 370, 20133, 543, 642, 2581, 4350, 14, 5972, 675, 340, 6272, 282, 12830, 272, 1415, 26, 3055, 272, 849, 26, 788, 885, 418, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 2581, 63, 4416, 63, 2634, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2581, 6391, 1572, 1561, 370, 20133, 543, 642, 2581, 4350, 14, 9498, 506, 376, 2701, 769, 340, 6272, 282, 12830, 272, 1415, 26, 3055, 272, 849, 26, 788, 885, 418, 523, 5718, 26, 272, 1369, 26, 489, 446, 710, 15352, 18, 16599, 7615, 22518, 315, 1314, 314, 2581, 4350, 911, 506, 2737, 272, 1415, 26, 3055, 272, 849, 26, 488, 523, 3618, 26, 272, 1369, 26, 489, 446, 13144, 367, 2581, 4350, 754, 2544, 8152, 272, 1415, 26, 3055, 272, 849, 26, 9456, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 7508, 63, 8951, 26, 272, 1369, 26, 489, 446, 7480, 370, 11972, 436, 23959, 376, 3411, 2581, 4350, 340, 5784, 315, 1865, 370, 2811, 2399, 1174, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 10168, 63, 23030, 503, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 418, 199, 11036, 63, 9970, 63, 7677, 26, 11488, 199, 624, 199, 199, 8918, 275, 408, 199, 3, 3390, 26, 488, 402, 3520, 7251, 663, 11488, 63, 2732, 63, 498, 12, 11488, 63, 4731, 63, 498, 12, 503, 4897, 14, 199, 3, 2779, 365, 10826, 626, 3932, 4877, 3734, 2860, 787, 663, 14, 199, 199, 3, 10082, 2893, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 3451, 272, 6869, 26, 7573, 5245, 272, 2581, 63, 3908, 63, 1023, 26, 413, 14, 20, 14, 1079, 272, 1031, 63, 466, 26, 2581, 14, 77, 17, 14, 7241, 272, 1967, 63, 2415, 26, 413, 272, 2581, 63, 719, 26, 20240, 845, 272, 2581, 63, 4416, 63, 2634, 26, 489, 446, 849, 272, 5718, 26, 2739, 13, 14346, 13, 17, 68, 421, 199, 3, 7523, 2581, 4350, 365, 21737, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 9552, 199, 199, 3, 799, 4930, 2581, 4350, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 295, 656, 5731, 199, 199, 624, 199, 199, 646, 984, 199, 646, 900, 199, 199, 893, 26, 272, 492, 6055, 272, 687, 6055, 14, 15565, 21481, 14, 1897, 17, 492, 662, 2019, 73, 4437, 3225, 272, 687, 6055, 14, 4551, 815, 492, 22240, 2354, 272, 7509, 63, 21373 ]
[ 2647, 15, 1393, 15, 1548, 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, 8948, 275, 408, 199, 2595, 199, 578, 26, 24380, 21481, 199, 3612, 63, 1802, 26, 14944, 2581, 13865, 315, 14347, 19509, 21481, 14, 199, 1802, 26, 523, 446, 14944, 2581, 13865, 315, 14347, 19509, 21481, 14, 523, 446, 1803, 2556, 3595, 314, 2013, 2581, 4350, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 20, 2, 199, 2502, 26, 298, 42, 1017, 577, 279, 1860, 8593, 3596, 12390, 1860, 2924, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 445, 8, 5575, 9, 503, 445, 8, 1881, 9, 787, 32122, 5445, 626, 911, 1218, 503, 11972, 282, 2581, 4350, 465, 4346, 14, 445, 8, 264, 656, 5731, 9, 911, 19457, 314, 4350, 12, 9183, 315, 282, 12427, 695, 734, 474, 14, 272, 3415, 26, 788, 1881, 297, 283, 5575, 297, 283, 264, 656, 5731, 418, 272, 1415, 26, 2549, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 2581, 4350, 5148, 272, 1415, 26, 2549, 523, 6869, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2581, 6869, 370, 506, 1202, 334, 32567, 503, 16967, 9, 272, 1415, 26, 3055, 272, 849, 26, 7573, 5245, 523, 2581, 63, 3908, 63, 1023, 26, 272, 1369, 26, 489, 446, 710, 1015, 1329, 402, 314, 2581, 6869, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 1031, 63, 466, 26, 272, 1369, 26, 489, 446, 710, 4526, 436, 4402, 14893, 402, 314, 3380, 315, 314, 2581, 4350, 272, 1415, 26, 3055, 272, 849, 26, 2581, 14, 77, 17, 14, 7241, 523, 1967, 63, 2415, 26, 272, 1369, 26, 489, 446, 710, 2536, 1329, 402, 2581, 3380, 626, 314, 2581, 4350, 911, 1172, 272, 1415, 26, 3055, 523, 2581, 63, 719, 26, 272, 1369, 26, 489, 446, 710, 1844, 1329, 641, 1314, 1924, 402, 314, 2581, 3380, 911, 4729, 6947, 272, 1415, 26, 3055, 272, 849, 26, 7179, 523, 2581, 63, 5327, 63, 923, 26, 272, 1369, 26, 489, 446, 710, 6303, 1572, 536, 370, 20133, 543, 14, 5972, 675, 340, 6272, 282, 12830, 14, 11105, 340, 6272, 282, 12830, 272, 1415, 26, 12303, 272, 849, 26, 488, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 6391, 63, 923, 63, 1580, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 12830, 6391, 1572, 1561, 370, 20133, 543, 642, 2581, 4350, 14, 5972, 675, 340, 6272, 282, 12830, 272, 1415, 26, 3055, 272, 849, 26, 788, 885, 418, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 523, 2581, 63, 4416, 63, 2634, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2581, 6391, 1572, 1561, 370, 20133, 543, 642, 2581, 4350, 14, 9498, 506, 376, 2701, 769, 340, 6272, 282, 12830, 272, 1415, 26, 3055, 272, 849, 26, 788, 885, 418, 523, 5718, 26, 272, 1369, 26, 489, 446, 710, 15352, 18, 16599, 7615, 22518, 315, 1314, 314, 2581, 4350, 911, 506, 2737, 272, 1415, 26, 3055, 272, 849, 26, 488, 523, 3618, 26, 272, 1369, 26, 489, 446, 13144, 367, 2581, 4350, 754, 2544, 8152, 272, 1415, 26, 3055, 272, 849, 26, 9456, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 7508, 63, 8951, 26, 272, 1369, 26, 489, 446, 7480, 370, 11972, 436, 23959, 376, 3411, 2581, 4350, 340, 5784, 315, 1865, 370, 2811, 2399, 1174, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 10168, 63, 23030, 503, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 788, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 418, 199, 11036, 63, 9970, 63, 7677, 26, 11488, 199, 624, 199, 199, 8918, 275, 408, 199, 3, 3390, 26, 488, 402, 3520, 7251, 663, 11488, 63, 2732, 63, 498, 12, 11488, 63, 4731, 63, 498, 12, 503, 4897, 14, 199, 3, 2779, 365, 10826, 626, 3932, 4877, 3734, 2860, 787, 663, 14, 199, 199, 3, 10082, 2893, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 3451, 272, 6869, 26, 7573, 5245, 272, 2581, 63, 3908, 63, 1023, 26, 413, 14, 20, 14, 1079, 272, 1031, 63, 466, 26, 2581, 14, 77, 17, 14, 7241, 272, 1967, 63, 2415, 26, 413, 272, 2581, 63, 719, 26, 20240, 845, 272, 2581, 63, 4416, 63, 2634, 26, 489, 446, 849, 272, 5718, 26, 2739, 13, 14346, 13, 17, 68, 421, 199, 3, 7523, 2581, 4350, 365, 21737, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 9552, 199, 199, 3, 799, 4930, 2581, 4350, 199, 13, 24380, 21481, 26, 272, 536, 26, 298, 396, 13, 27567, 13, 1807, 2, 272, 1174, 26, 295, 656, 5731, 199, 199, 624, 199, 199, 646, 984, 199, 646, 900, 199, 199, 893, 26, 272, 492, 6055, 272, 687, 6055, 14, 15565, 21481, 14, 1897, 17, 492, 662, 2019, 73, 4437, 3225, 272, 687, 6055, 14, 4551, 815, 492, 22240, 2354, 272, 7509, 63, 21373, 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, 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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 ]
zzhi191/easyleveldb
node_modules/leveldown/node_modules/prebuild/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py
395
12634
#!/usr/bin/env python # Copyright (c) 2012 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. """Utility functions for Windows builds. These functions are executed via gyp-win-tool when using the ninja generator. """ import os import re import shutil import subprocess import stat import string import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # A regex matching an argument corresponding to the output filename passed to # link.exe. _LINK_EXE_OUT_ARG = re.compile('/OUT:(?P<out>.+)$', re.IGNORECASE) def main(args): executor = WinTool() exit_code = executor.Dispatch(args) if exit_code is not None: sys.exit(exit_code) class WinTool(object): """This class performs all the Windows tooling steps. The methods can either be executed directly, or dispatched from an argument list.""" def _UseSeparateMspdbsrv(self, env, args): """Allows to use a unique instance of mspdbsrv.exe per linker instead of a shared one.""" if len(args) < 1: raise Exception("Not enough arguments") if args[0] != 'link.exe': return # Use the output filename passed to the linker to generate an endpoint name # for mspdbsrv.exe. endpoint_name = None for arg in args: m = _LINK_EXE_OUT_ARG.match(arg) if m: endpoint_name = re.sub(r'\W+', '', '%s_%d' % (m.group('out'), os.getpid())) break if endpoint_name is None: return # Adds the appropriate environment variable. This will be read by link.exe # to know which instance of mspdbsrv.exe it should connect to (if it's # not set then the default endpoint is used). env['_MSPDBSRV_ENDPOINT_'] = endpoint_name def Dispatch(self, args): """Dispatches a string command to a method.""" if len(args) < 1: raise Exception("Not enough arguments") method = "Exec%s" % self._CommandifyName(args[0]) return getattr(self, method)(*args[1:]) def _CommandifyName(self, name_string): """Transforms a tool name like recursive-mirror to RecursiveMirror.""" return name_string.title().replace('-', '') def _GetEnv(self, arch): """Gets the saved environment from a file for a given architecture.""" # The environment is saved as an "environment block" (see CreateProcess # and msvs_emulation for details). We convert to a dict here. # Drop last 2 NULs, one for list terminator, one for trailing vs. separator. pairs = open(arch).read()[:-2].split('\0') kvs = [item.split('=', 1) for item in pairs] return dict(kvs) def ExecStamp(self, path): """Simple stamp command.""" open(path, 'w').close() def ExecRecursiveMirror(self, source, dest): """Emulation of rm -rf out && cp -af in out.""" if os.path.exists(dest): if os.path.isdir(dest): def _on_error(fn, path, excinfo): # The operation failed, possibly because the file is set to # read-only. If that's why, make it writable and try the op again. if not os.access(path, os.W_OK): os.chmod(path, stat.S_IWRITE) fn(path) shutil.rmtree(dest, onerror=_on_error) else: if not os.access(dest, os.W_OK): # Attempt to make the file writable before deleting it. os.chmod(dest, stat.S_IWRITE) os.unlink(dest) if os.path.isdir(source): shutil.copytree(source, dest) else: shutil.copy2(source, dest) def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args): """Filter diagnostic output from link that looks like: ' Creating library ui.dll.lib and object ui.dll.exp' This happens when there are exports from the dll or exe. """ env = self._GetEnv(arch) if use_separate_mspdbsrv == 'True': self._UseSeparateMspdbsrv(env, args) link = subprocess.Popen([args[0].replace('/', '\\')] + list(args[1:]), shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = link.communicate() for line in out.splitlines(): if not line.startswith(' Creating library '): print line return link.returncode def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, mt, rc, intermediate_manifest, *manifests): """A wrapper for handling creating a manifest resource and then executing a link command.""" # The 'normal' way to do manifests is to have link generate a manifest # based on gathering dependencies from the object files, then merge that # manifest with other manifests supplied as sources, convert the merged # manifest to a resource, and then *relink*, including the compiled # version of the manifest resource. This breaks incremental linking, and # is generally overly complicated. Instead, we merge all the manifests # provided (along with one that includes what would normally be in the # linker-generated one, see msvs_emulation.py), and include that into the # first and only link. We still tell link to generate a manifest, but we # only use that to assert that our simpler process did not miss anything. variables = { 'python': sys.executable, 'arch': arch, 'out': out, 'ldcmd': ldcmd, 'resname': resname, 'mt': mt, 'rc': rc, 'intermediate_manifest': intermediate_manifest, 'manifests': ' '.join(manifests), } add_to_ld = '' if manifests: subprocess.check_call( '%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo ' '-manifest %(manifests)s -out:%(out)s.manifest' % variables) if embed_manifest == 'True': subprocess.check_call( '%(python)s gyp-win-tool manifest-to-rc %(arch)s %(out)s.manifest' ' %(out)s.manifest.rc %(resname)s' % variables) subprocess.check_call( '%(python)s gyp-win-tool rc-wrapper %(arch)s %(rc)s ' '%(out)s.manifest.rc' % variables) add_to_ld = ' %(out)s.manifest.res' % variables subprocess.check_call(ldcmd + add_to_ld) # Run mt.exe on the theoretically complete manifest we generated, merging # it with the one the linker generated to confirm that the linker # generated one does not add anything. This is strictly unnecessary for # correctness, it's only to verify that e.g. /MANIFESTDEPENDENCY was not # used in a #pragma comment. if manifests: # Merge the intermediate one with ours to .assert.manifest, then check # that .assert.manifest is identical to ours. subprocess.check_call( '%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo ' '-manifest %(out)s.manifest %(intermediate_manifest)s ' '-out:%(out)s.assert.manifest' % variables) assert_manifest = '%(out)s.assert.manifest' % variables our_manifest = '%(out)s.manifest' % variables # Load and normalize the manifests. mt.exe sometimes removes whitespace, # and sometimes doesn't unfortunately. with open(our_manifest, 'rb') as our_f: with open(assert_manifest, 'rb') as assert_f: our_data = our_f.read().translate(None, string.whitespace) assert_data = assert_f.read().translate(None, string.whitespace) if our_data != assert_data: os.unlink(out) def dump(filename): sys.stderr.write('%s\n-----\n' % filename) with open(filename, 'rb') as f: sys.stderr.write(f.read() + '\n-----\n') dump(intermediate_manifest) dump(our_manifest) dump(assert_manifest) sys.stderr.write( 'Linker generated manifest "%s" added to final manifest "%s" ' '(result in "%s"). ' 'Were /MANIFEST switches used in #pragma statements? ' % ( intermediate_manifest, our_manifest, assert_manifest)) return 1 def ExecManifestWrapper(self, arch, *args): """Run manifest tool with environment set. Strip out undesirable warning (some XML blocks are recognized by the OS loader, but not the manifest tool).""" env = self._GetEnv(arch) popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = popen.communicate() for line in out.splitlines(): if line and 'manifest authoring warning 81010002' not in line: print line return popen.returncode def ExecManifestToRc(self, arch, *args): """Creates a resource file pointing a SxS assembly manifest. |args| is tuple containing path to resource file, path to manifest file and resource name which can be "1" (for executables) or "2" (for DLLs).""" manifest_path, resource_path, resource_name = args with open(resource_path, 'wb') as output: output.write('#include <windows.h>\n%s RT_MANIFEST "%s"' % ( resource_name, os.path.abspath(manifest_path).replace('\\', '/'))) def ExecMidlWrapper(self, arch, outdir, tlb, h, dlldata, iid, proxy, idl, *flags): """Filter noisy filenames output from MIDL compile step that isn't quietable via command line flags. """ args = ['midl', '/nologo'] + list(flags) + [ '/out', outdir, '/tlb', tlb, '/h', h, '/dlldata', dlldata, '/iid', iid, '/proxy', proxy, idl] env = self._GetEnv(arch) popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = popen.communicate() # Filter junk out of stdout, and write filtered versions. Output we want # to filter is pairs of lines that look like this: # Processing C:\Program Files (x86)\Microsoft SDKs\...\include\objidl.idl # objidl.idl lines = out.splitlines() prefixes = ('Processing ', '64 bit Processing ') processing = set(os.path.basename(x) for x in lines if x.startswith(prefixes)) for line in lines: if not line.startswith(prefixes) and line not in processing: print line return popen.returncode def ExecAsmWrapper(self, arch, *args): """Filter logo banner from invocations of asm.exe.""" env = self._GetEnv(arch) popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = popen.communicate() for line in out.splitlines(): if (not line.startswith('Copyright (C) Microsoft Corporation') and not line.startswith('Microsoft (R) Macro Assembler') and not line.startswith(' Assembling: ') and line): print line return popen.returncode def ExecRcWrapper(self, arch, *args): """Filter logo banner from invocations of rc.exe. Older versions of RC don't support the /nologo flag.""" env = self._GetEnv(arch) popen = subprocess.Popen(args, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = popen.communicate() for line in out.splitlines(): if (not line.startswith('Microsoft (R) Windows (R) Resource Compiler') and not line.startswith('Copyright (C) Microsoft Corporation') and line): print line return popen.returncode def ExecActionWrapper(self, arch, rspfile, *dir): """Runs an action command line from a response file using the environment for |arch|. If |dir| is supplied, use that as the working directory.""" env = self._GetEnv(arch) # TODO(scottmg): This is a temporary hack to get some specific variables # through to actions that are set after gyp-time. http://crbug.com/333738. for k, v in os.environ.iteritems(): if k not in env: env[k] = v args = open(rspfile).read() dir = dir[0] if dir else None return subprocess.call(args, shell=True, env=env, cwd=dir) def ExecClCompile(self, project_dir, selected_files): """Executed by msvs-ninja projects when the 'ClCompile' target is used to build selected C/C++ files.""" project_dir = os.path.relpath(project_dir, BASE_DIR) selected_files = selected_files.split(';') ninja_targets = [os.path.join(project_dir, filename) + '^^' for filename in selected_files] cmd = ['ninja.exe'] cmd.extend(ninja_targets) return subprocess.call(cmd, shell=True, cwd=BASE_DIR) if __name__ == '__main__': sys.exit(main(sys.argv[1:]))
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 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, 17505, 3423, 367, 5417, 14723, 14, 199, 199, 20676, 3423, 787, 7934, 4799, 4902, 13, 2676, 13, 3557, 1380, 1808, 314, 14822, 4306, 14, 199, 624, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 5672, 199, 646, 1059, 199, 646, 984, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 199, 3, 437, 5163, 4877, 376, 1423, 5226, 370, 314, 1072, 1788, 3032, 370, 199, 3, 2142, 14, 5803, 14, 199, 63, 7916, 63, 23017, 63, 1877, 63, 11611, 275, 295, 14, 2014, 2336, 1877, 26, 2229, 48, 28, 548, 31411, 29150, 295, 14, 15434, 9, 199, 199, 318, 2446, 8, 589, 304, 523, 13270, 275, 13036, 5157, 342, 523, 4458, 63, 600, 275, 13270, 14, 20628, 8, 589, 9, 523, 340, 4458, 63, 600, 365, 440, 488, 26, 272, 984, 14, 2224, 8, 2224, 63, 600, 9, 421, 199, 533, 13036, 5157, 8, 785, 304, 523, 408, 2765, 1021, 18628, 1006, 314, 5417, 4744, 316, 7124, 14, 710, 3102, 883, 1902, 523, 506, 7934, 5370, 12, 503, 7634, 379, 687, 376, 1423, 769, 1041, 819, 347, 485, 6119, 12653, 323, 45, 681, 697, 15165, 8, 277, 12, 2589, 12, 1249, 304, 272, 408, 19780, 370, 675, 282, 3747, 1256, 402, 333, 681, 697, 15165, 14, 5803, 1126, 17261, 3140, 402, 282, 272, 5709, 1373, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 340, 1249, 59, 16, 61, 1137, 283, 1073, 14, 5803, 356, 489, 372, 339, 327, 3645, 314, 1072, 1788, 3032, 370, 314, 17261, 370, 3550, 376, 6037, 536, 272, 327, 367, 333, 681, 697, 15165, 14, 5803, 14, 272, 6037, 63, 354, 275, 488, 272, 367, 1680, 315, 1249, 26, 489, 333, 275, 485, 7916, 63, 23017, 63, 1877, 63, 11611, 14, 1431, 8, 1273, 9, 489, 340, 333, 26, 267, 6037, 63, 354, 275, 295, 14, 954, 8, 82, 1154, 55, 7386, 3260, 288, 1543, 83, 4970, 68, 7, 450, 334, 77, 14, 923, 360, 548, 659, 747, 14, 17829, 4059, 267, 2059, 339, 340, 6037, 63, 354, 365, 488, 26, 489, 372, 339, 327, 15747, 314, 5827, 3734, 1750, 14, 961, 911, 506, 1586, 701, 2142, 14, 5803, 272, 327, 370, 5715, 1314, 1256, 402, 333, 681, 697, 15165, 14, 5803, 652, 1077, 4907, 370, 334, 692, 652, 1159, 272, 327, 440, 663, 2066, 314, 849, 6037, 365, 1202, 680, 272, 2589, 8680, 3053, 32641, 31546, 63, 21054, 63, 418, 275, 6037, 63, 354, 819, 347, 28626, 8, 277, 12, 1249, 304, 272, 408, 2825, 11350, 282, 1059, 1414, 370, 282, 1083, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 1083, 275, 298, 4858, 5, 83, 2, 450, 291, 423, 5150, 290, 29552, 985, 8, 589, 59, 16, 566, 272, 372, 2519, 8, 277, 12, 1083, 25967, 589, 59, 17, 5728, 819, 347, 485, 5150, 290, 29552, 985, 8, 277, 12, 536, 63, 875, 304, 272, 408, 3188, 3351, 282, 4744, 536, 2839, 9133, 13, 12324, 370, 18306, 3398, 28034, 1041, 272, 372, 536, 63, 875, 14, 1213, 1252, 1814, 13858, 4074, 819, 347, 485, 1002, 7744, 8, 277, 12, 3819, 304, 272, 408, 14426, 314, 6290, 3734, 687, 282, 570, 367, 282, 1627, 15931, 1041, 272, 327, 710, 3734, 365, 6290, 465, 376, 298, 5418, 1853, 2, 334, 3239, 2790, 3498, 272, 327, 436, 13795, 63, 20526, 367, 2436, 680, 2136, 3957, 370, 282, 1211, 2348, 14, 272, 327, 18110, 2061, 499, 653, 1293, 83, 12, 1373, 367, 769, 31298, 12, 1373, 367, 8520, 8118, 14, 9432, 14, 272, 6342, 275, 1551, 8, 1047, 680, 739, 342, 4439, 18, 1055, 1294, 2258, 16, 358, 272, 1022, 3122, 275, 359, 1053, 14, 1294, 25283, 413, 9, 367, 1242, 315, 6342, 61, 272, 372, 1211, 8, 30862, 9, 819, 347, 9434, 16649, 8, 277, 12, 931, 304, 272, 408, 3184, 16206, 1414, 1041, 272, 1551, 8, 515, 12, 283, 87, 1959, 1600, 342, 819, 347, 9434, 25122, 28034, 8, 277, 12, 1350, 12, 2053, 304, 272, 408, 15754, 402, 14267, 446, 3941, 734, 10883, 7667, 446, 2756, 315, 734, 1041, 272, 340, 747, 14, 515, 14, 2444, 8, 2614, 304, 489, 340, 747, 14, 515, 14, 6027, 8, 2614, 304, 267, 347, 485, 265, 63, 705, 8, 2324, 12, 931, 12, 21596, 304, 881, 327, 710, 3439, 3405, 12, 12570, 2952, 314, 570, 365, 663, 370, 881, 327, 1586, 13, 2118, 14, 982, 626, 1159, 10842, 12, 1852, 652, 17267, 436, 862, 314, 1687, 4020, 14, 881, 340, 440, 747, 14, 2732, 8, 515, 12, 747, 14, 55, 63, 3593, 304, 288, 747, 14, 11693, 8, 515, 12, 5672, 14, 51, 63, 41, 10387, 9, 881, 4325, 8, 515, 9, 267, 5145, 14, 9242, 8, 2614, 12, 22852, 3699, 265, 63, 705, 9, 489, 587, 26, 267, 340, 440, 747, 14, 2732, 8, 2614, 12, 747, 14, 55, 63, 3593, 304, 881, 327, 23115, 370, 1852, 314, 570, 17267, 2544, 13794, 652, 14, 881, 747, 14, 11693, 8, 2614, 12, 5672, 14, 51, 63, 41, 10387, 9, 267, 747, 14, 7162, 8, 2614, 9, 339, 340, 747, 14, 515, 14, 6027, 8, 1365, 304, 489, 5145, 14, 29296, 8, 1365, 12, 2053, 9, 272, 587, 26, 489, 5145, 14, 1574, 18, 8, 1365, 12, 2053, 9, 819, 347, 9434, 3834, 4590, 8, 277, 12, 3819, 12, 675, 63, 24904, 63, 77, 681, 697, 15165, 12, 627, 589, 304, 272, 408, 4131, 8348, 19075, 1072, 687, 2142, 626, 10734, 2839, 26, 272, 283, 257, 20507, 3555, 8574, 14, 9259, 14, 773, 436, 909, 8574, 14, 9259, 14, 1474, 7, 272, 961, 10986, 1380, 2337, 787, 22609, 687, 314, 17112, 503, 14778, 14, 272, 408, 272, 2589, 275, 291, 423 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 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, 17505, 3423, 367, 5417, 14723, 14, 199, 199, 20676, 3423, 787, 7934, 4799, 4902, 13, 2676, 13, 3557, 1380, 1808, 314, 14822, 4306, 14, 199, 624, 199, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 5672, 199, 646, 1059, 199, 646, 984, 199, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 199, 199, 3, 437, 5163, 4877, 376, 1423, 5226, 370, 314, 1072, 1788, 3032, 370, 199, 3, 2142, 14, 5803, 14, 199, 63, 7916, 63, 23017, 63, 1877, 63, 11611, 275, 295, 14, 2014, 2336, 1877, 26, 2229, 48, 28, 548, 31411, 29150, 295, 14, 15434, 9, 199, 199, 318, 2446, 8, 589, 304, 523, 13270, 275, 13036, 5157, 342, 523, 4458, 63, 600, 275, 13270, 14, 20628, 8, 589, 9, 523, 340, 4458, 63, 600, 365, 440, 488, 26, 272, 984, 14, 2224, 8, 2224, 63, 600, 9, 421, 199, 533, 13036, 5157, 8, 785, 304, 523, 408, 2765, 1021, 18628, 1006, 314, 5417, 4744, 316, 7124, 14, 710, 3102, 883, 1902, 523, 506, 7934, 5370, 12, 503, 7634, 379, 687, 376, 1423, 769, 1041, 819, 347, 485, 6119, 12653, 323, 45, 681, 697, 15165, 8, 277, 12, 2589, 12, 1249, 304, 272, 408, 19780, 370, 675, 282, 3747, 1256, 402, 333, 681, 697, 15165, 14, 5803, 1126, 17261, 3140, 402, 282, 272, 5709, 1373, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 340, 1249, 59, 16, 61, 1137, 283, 1073, 14, 5803, 356, 489, 372, 339, 327, 3645, 314, 1072, 1788, 3032, 370, 314, 17261, 370, 3550, 376, 6037, 536, 272, 327, 367, 333, 681, 697, 15165, 14, 5803, 14, 272, 6037, 63, 354, 275, 488, 272, 367, 1680, 315, 1249, 26, 489, 333, 275, 485, 7916, 63, 23017, 63, 1877, 63, 11611, 14, 1431, 8, 1273, 9, 489, 340, 333, 26, 267, 6037, 63, 354, 275, 295, 14, 954, 8, 82, 1154, 55, 7386, 3260, 288, 1543, 83, 4970, 68, 7, 450, 334, 77, 14, 923, 360, 548, 659, 747, 14, 17829, 4059, 267, 2059, 339, 340, 6037, 63, 354, 365, 488, 26, 489, 372, 339, 327, 15747, 314, 5827, 3734, 1750, 14, 961, 911, 506, 1586, 701, 2142, 14, 5803, 272, 327, 370, 5715, 1314, 1256, 402, 333, 681, 697, 15165, 14, 5803, 652, 1077, 4907, 370, 334, 692, 652, 1159, 272, 327, 440, 663, 2066, 314, 849, 6037, 365, 1202, 680, 272, 2589, 8680, 3053, 32641, 31546, 63, 21054, 63, 418, 275, 6037, 63, 354, 819, 347, 28626, 8, 277, 12, 1249, 304, 272, 408, 2825, 11350, 282, 1059, 1414, 370, 282, 1083, 1041, 272, 340, 822, 8, 589, 9, 665, 413, 26, 489, 746, 2186, 480, 1763, 8321, 2368, 531, 339, 1083, 275, 298, 4858, 5, 83, 2, 450, 291, 423, 5150, 290, 29552, 985, 8, 589, 59, 16, 566, 272, 372, 2519, 8, 277, 12, 1083, 25967, 589, 59, 17, 5728, 819, 347, 485, 5150, 290, 29552, 985, 8, 277, 12, 536, 63, 875, 304, 272, 408, 3188, 3351, 282, 4744, 536, 2839, 9133, 13, 12324, 370, 18306, 3398, 28034, 1041, 272, 372, 536, 63, 875, 14, 1213, 1252, 1814, 13858, 4074, 819, 347, 485, 1002, 7744, 8, 277, 12, 3819, 304, 272, 408, 14426, 314, 6290, 3734, 687, 282, 570, 367, 282, 1627, 15931, 1041, 272, 327, 710, 3734, 365, 6290, 465, 376, 298, 5418, 1853, 2, 334, 3239, 2790, 3498, 272, 327, 436, 13795, 63, 20526, 367, 2436, 680, 2136, 3957, 370, 282, 1211, 2348, 14, 272, 327, 18110, 2061, 499, 653, 1293, 83, 12, 1373, 367, 769, 31298, 12, 1373, 367, 8520, 8118, 14, 9432, 14, 272, 6342, 275, 1551, 8, 1047, 680, 739, 342, 4439, 18, 1055, 1294, 2258, 16, 358, 272, 1022, 3122, 275, 359, 1053, 14, 1294, 25283, 413, 9, 367, 1242, 315, 6342, 61, 272, 372, 1211, 8, 30862, 9, 819, 347, 9434, 16649, 8, 277, 12, 931, 304, 272, 408, 3184, 16206, 1414, 1041, 272, 1551, 8, 515, 12, 283, 87, 1959, 1600, 342, 819, 347, 9434, 25122, 28034, 8, 277, 12, 1350, 12, 2053, 304, 272, 408, 15754, 402, 14267, 446, 3941, 734, 10883, 7667, 446, 2756, 315, 734, 1041, 272, 340, 747, 14, 515, 14, 2444, 8, 2614, 304, 489, 340, 747, 14, 515, 14, 6027, 8, 2614, 304, 267, 347, 485, 265, 63, 705, 8, 2324, 12, 931, 12, 21596, 304, 881, 327, 710, 3439, 3405, 12, 12570, 2952, 314, 570, 365, 663, 370, 881, 327, 1586, 13, 2118, 14, 982, 626, 1159, 10842, 12, 1852, 652, 17267, 436, 862, 314, 1687, 4020, 14, 881, 340, 440, 747, 14, 2732, 8, 515, 12, 747, 14, 55, 63, 3593, 304, 288, 747, 14, 11693, 8, 515, 12, 5672, 14, 51, 63, 41, 10387, 9, 881, 4325, 8, 515, 9, 267, 5145, 14, 9242, 8, 2614, 12, 22852, 3699, 265, 63, 705, 9, 489, 587, 26, 267, 340, 440, 747, 14, 2732, 8, 2614, 12, 747, 14, 55, 63, 3593, 304, 881, 327, 23115, 370, 1852, 314, 570, 17267, 2544, 13794, 652, 14, 881, 747, 14, 11693, 8, 2614, 12, 5672, 14, 51, 63, 41, 10387, 9, 267, 747, 14, 7162, 8, 2614, 9, 339, 340, 747, 14, 515, 14, 6027, 8, 1365, 304, 489, 5145, 14, 29296, 8, 1365, 12, 2053, 9, 272, 587, 26, 489, 5145, 14, 1574, 18, 8, 1365, 12, 2053, 9, 819, 347, 9434, 3834, 4590, 8, 277, 12, 3819, 12, 675, 63, 24904, 63, 77, 681, 697, 15165, 12, 627, 589, 304, 272, 408, 4131, 8348, 19075, 1072, 687, 2142, 626, 10734, 2839, 26, 272, 283, 257, 20507, 3555, 8574, 14, 9259, 14, 773, 436, 909, 8574, 14, 9259, 14, 1474, 7, 272, 961, 10986, 1380, 2337, 787, 22609, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gundalow/ansible
lib/ansible/galaxy/collection/__init__.py
11
55418
# -*- coding: utf-8 -*- # Copyright: (c) 2019-2021, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """Installed collections management package.""" from __future__ import (absolute_import, division, print_function) __metaclass__ = type import errno import fnmatch import functools import json import os import shutil import stat import sys import tarfile import tempfile import threading import time import yaml from collections import namedtuple from contextlib import contextmanager from ansible.module_utils.compat.version import LooseVersion from hashlib import sha256 from io import BytesIO from itertools import chain from yaml.error import YAMLError # NOTE: Adding type ignores is a hack for mypy to shut up wrt bug #1153 try: import queue # type: ignore[import] except ImportError: # Python 2 import Queue as queue # type: ignore[import,no-redef] try: # NOTE: It's in Python 3 stdlib and can be installed on Python 2 # NOTE: via `pip install typing`. Unnecessary in runtime. # NOTE: `TYPE_CHECKING` is True during mypy-typecheck-time. from typing import TYPE_CHECKING except ImportError: TYPE_CHECKING = False if TYPE_CHECKING: from typing import Dict, Iterable, List, Optional, Text, Union if sys.version_info[:2] >= (3, 8): from typing import Literal else: # Python 2 + Python 3.4-3.7 from typing_extensions import Literal from ansible.galaxy.api import GalaxyAPI from ansible.galaxy.collection.concrete_artifact_manager import ( ConcreteArtifactsManager, ) ManifestKeysType = Literal[ 'collection_info', 'file_manifest_file', 'format', ] FileMetaKeysType = Literal[ 'name', 'ftype', 'chksum_type', 'chksum_sha256', 'format', ] CollectionInfoKeysType = Literal[ # collection meta: 'namespace', 'name', 'version', 'authors', 'readme', 'tags', 'description', 'license', 'license_file', 'dependencies', 'repository', 'documentation', 'homepage', 'issues', # files meta: FileMetaKeysType, ] ManifestValueType = Dict[ CollectionInfoKeysType, Optional[ Union[ int, str, # scalars, like name/ns, schema version List[str], # lists of scalars, like tags Dict[str, str], # deps map ], ], ] CollectionManifestType = Dict[ManifestKeysType, ManifestValueType] FileManifestEntryType = Dict[FileMetaKeysType, Optional[Union[str, int]]] FilesManifestType = Dict[ Literal['files', 'format'], Union[List[FileManifestEntryType], int], ] import ansible.constants as C from ansible.errors import AnsibleError from ansible.galaxy import get_collections_galaxy_meta_info from ansible.galaxy.collection.concrete_artifact_manager import ( _consume_file, _download_file, _get_json_from_installed_dir, _get_meta_from_src_dir, _tarfile_extract, ) from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy from ansible.galaxy.dependency_resolution import ( build_collection_dependency_resolver, ) from ansible.galaxy.dependency_resolution.dataclasses import ( Candidate, Requirement, _is_installed_collection_dir, ) from ansible.galaxy.dependency_resolution.errors import ( CollectionDependencyResolutionImpossible, ) from ansible.galaxy.dependency_resolution.versioning import meets_requirements from ansible.module_utils.six import raise_from from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.module_utils.common.yaml import yaml_dump from ansible.utils.collection_loader import AnsibleCollectionRef from ansible.utils.display import Display from ansible.utils.hashing import secure_hash, secure_hash_s from ansible.utils.version import SemanticVersion display = Display() MANIFEST_FORMAT = 1 MANIFEST_FILENAME = 'MANIFEST.json' ModifiedContent = namedtuple('ModifiedContent', ['filename', 'expected', 'installed']) # FUTURE: expose actual verify result details for a collection on this object, maybe reimplement as dataclass on py3.8+ class CollectionVerifyResult: def __init__(self, collection_name): # type: (str) -> None self.collection_name = collection_name # type: str self.success = True # type: bool def verify_local_collection( local_collection, remote_collection, artifacts_manager, ): # type: (Candidate, Optional[Candidate], ConcreteArtifactsManager) -> CollectionVerifyResult """Verify integrity of the locally installed collection. :param local_collection: Collection being checked. :param remote_collection: Upstream collection (optional, if None, only verify local artifact) :param artifacts_manager: Artifacts manager. :return: a collection verify result object. """ result = CollectionVerifyResult(local_collection.fqcn) b_collection_path = to_bytes( local_collection.src, errors='surrogate_or_strict', ) display.display("Verifying '{coll!s}'.".format(coll=local_collection)) display.display( u"Installed collection found at '{path!s}'". format(path=to_text(local_collection.src)), ) modified_content = [] # type: List[ModifiedContent] verify_local_only = remote_collection is None if verify_local_only: # partial away the local FS detail so we can just ask generically during validation get_json_from_validation_source = functools.partial(_get_json_from_installed_dir, b_collection_path) get_hash_from_validation_source = functools.partial(_get_file_hash, b_collection_path) # since we're not downloading this, just seed it with the value from disk manifest_hash = get_hash_from_validation_source(MANIFEST_FILENAME) else: # fetch remote b_temp_tar_path = ( # NOTE: AnsibleError is raised on URLError artifacts_manager.get_artifact_path if remote_collection.is_concrete_artifact else artifacts_manager.get_galaxy_artifact_path )(remote_collection) display.vvv( u"Remote collection cached as '{path!s}'".format(path=to_text(b_temp_tar_path)) ) # partial away the tarball details so we can just ask generically during validation get_json_from_validation_source = functools.partial(_get_json_from_tar_file, b_temp_tar_path) get_hash_from_validation_source = functools.partial(_get_tar_file_hash, b_temp_tar_path) # Compare installed version versus requirement version if local_collection.ver != remote_collection.ver: err = ( "{local_fqcn!s} has the version '{local_ver!s}' but " "is being compared to '{remote_ver!s}'".format( local_fqcn=local_collection.fqcn, local_ver=local_collection.ver, remote_ver=remote_collection.ver, ) ) display.display(err) result.success = False return result # Verify the downloaded manifest hash matches the installed copy before verifying the file manifest manifest_hash = get_hash_from_validation_source(MANIFEST_FILENAME) _verify_file_hash(b_collection_path, MANIFEST_FILENAME, manifest_hash, modified_content) display.display('MANIFEST.json hash: {manifest_hash}'.format(manifest_hash=manifest_hash)) manifest = get_json_from_validation_source(MANIFEST_FILENAME) # Use the manifest to verify the file manifest checksum file_manifest_data = manifest['file_manifest_file'] file_manifest_filename = file_manifest_data['name'] expected_hash = file_manifest_data['chksum_%s' % file_manifest_data['chksum_type']] # Verify the file manifest before using it to verify individual files _verify_file_hash(b_collection_path, file_manifest_filename, expected_hash, modified_content) file_manifest = get_json_from_validation_source(file_manifest_filename) # Use the file manifest to verify individual file checksums for manifest_data in file_manifest['files']: if manifest_data['ftype'] == 'file': expected_hash = manifest_data['chksum_%s' % manifest_data['chksum_type']] _verify_file_hash(b_collection_path, manifest_data['name'], expected_hash, modified_content) if modified_content: result.success = False display.display( 'Collection {fqcn!s} contains modified content ' 'in the following files:'. format(fqcn=to_text(local_collection.fqcn)), ) for content_change in modified_content: display.display(' %s' % content_change.filename) display.v(" Expected: %s\n Found: %s" % (content_change.expected, content_change.installed)) else: what = "are internally consistent with its manifest" if verify_local_only else "match the remote collection" display.display( "Successfully verified that checksums for '{coll!s}' {what!s}.". format(coll=local_collection, what=what), ) return result def build_collection(u_collection_path, u_output_path, force): # type: (Text, Text, bool) -> Text """Creates the Ansible collection artifact in a .tar.gz file. :param u_collection_path: The path to the collection to build. This should be the directory that contains the galaxy.yml file. :param u_output_path: The path to create the collection build artifact. This should be a directory. :param force: Whether to overwrite an existing collection build artifact or fail. :return: The path to the collection build artifact. """ b_collection_path = to_bytes(u_collection_path, errors='surrogate_or_strict') try: collection_meta = _get_meta_from_src_dir(b_collection_path) except LookupError as lookup_err: raise_from(AnsibleError(to_native(lookup_err)), lookup_err) collection_manifest = _build_manifest(**collection_meta) file_manifest = _build_files_manifest( b_collection_path, collection_meta['namespace'], # type: ignore[arg-type] collection_meta['name'], # type: ignore[arg-type] collection_meta['build_ignore'], # type: ignore[arg-type] ) artifact_tarball_file_name = '{ns!s}-{name!s}-{ver!s}.tar.gz'.format( name=collection_meta['name'], ns=collection_meta['namespace'], ver=collection_meta['version'], ) b_collection_output = os.path.join( to_bytes(u_output_path), to_bytes(artifact_tarball_file_name, errors='surrogate_or_strict'), ) if os.path.exists(b_collection_output): if os.path.isdir(b_collection_output): raise AnsibleError("The output collection artifact '%s' already exists, " "but is a directory - aborting" % to_native(b_collection_output)) elif not force: raise AnsibleError("The file '%s' already exists. You can use --force to re-create " "the collection artifact." % to_native(b_collection_output)) collection_output = _build_collection_tar(b_collection_path, b_collection_output, collection_manifest, file_manifest) return collection_output def download_collections( collections, # type: Iterable[Requirement] output_path, # type: str apis, # type: Iterable[GalaxyAPI] no_deps, # type: bool allow_pre_release, # type: bool artifacts_manager, # type: ConcreteArtifactsManager ): # type: (...) -> None """Download Ansible collections as their tarball from a Galaxy server to the path specified and creates a requirements file of the downloaded requirements to be used for an install. :param collections: The collections to download, should be a list of tuples with (name, requirement, Galaxy Server). :param output_path: The path to download the collections to. :param apis: A list of GalaxyAPIs to query when search for a collection. :param validate_certs: Whether to validate the certificate if downloading a tarball from a non-Galaxy host. :param no_deps: Ignore any collection dependencies and only download the base requirements. :param allow_pre_release: Do not ignore pre-release versions when selecting the latest. """ with _display_progress("Process download dependency map"): dep_map = _resolve_depenency_map( set(collections), galaxy_apis=apis, preferred_candidates=None, concrete_artifacts_manager=artifacts_manager, no_deps=no_deps, allow_pre_release=allow_pre_release, upgrade=False, ) b_output_path = to_bytes(output_path, errors='surrogate_or_strict') requirements = [] with _display_progress( "Starting collection download process to '{path!s}'". format(path=output_path), ): for fqcn, concrete_coll_pin in dep_map.copy().items(): # FIXME: move into the provider if concrete_coll_pin.is_virtual: display.display( 'Virtual collection {coll!s} is not downloadable'. format(coll=to_text(concrete_coll_pin)), ) continue display.display( u"Downloading collection '{coll!s}' to '{path!s}'". format(coll=to_text(concrete_coll_pin), path=to_text(b_output_path)), ) b_src_path = ( artifacts_manager.get_artifact_path if concrete_coll_pin.is_concrete_artifact else artifacts_manager.get_galaxy_artifact_path )(concrete_coll_pin) b_dest_path = os.path.join( b_output_path, os.path.basename(b_src_path), ) if concrete_coll_pin.is_dir: b_dest_path = to_bytes( build_collection( to_text(b_src_path, errors='surrogate_or_strict'), to_text(output_path, errors='surrogate_or_strict'), force=True, ), errors='surrogate_or_strict', ) else: shutil.copy(to_native(b_src_path), to_native(b_dest_path)) display.display( "Collection '{coll!s}' was downloaded successfully". format(coll=concrete_coll_pin), ) requirements.append({ # FIXME: Consider using a more specific upgraded format # FIXME: having FQCN in the name field, with src field # FIXME: pointing to the file path, and explicitly set # FIXME: type. If version and name are set, it'd # FIXME: perform validation against the actual metadata # FIXME: in the artifact src points at. 'name': to_native(os.path.basename(b_dest_path)), 'version': concrete_coll_pin.ver, }) requirements_path = os.path.join(output_path, 'requirements.yml') b_requirements_path = to_bytes( requirements_path, errors='surrogate_or_strict', ) display.display( u'Writing requirements.yml file of downloaded collections ' "to '{path!s}'".format(path=to_text(requirements_path)), ) yaml_bytes = to_bytes( yaml_dump({'collections': requirements}), errors='surrogate_or_strict', ) with open(b_requirements_path, mode='wb') as req_fd: req_fd.write(yaml_bytes) def publish_collection(collection_path, api, wait, timeout): """Publish an Ansible collection tarball into an Ansible Galaxy server. :param collection_path: The path to the collection tarball to publish. :param api: A GalaxyAPI to publish the collection to. :param wait: Whether to wait until the import process is complete. :param timeout: The time in seconds to wait for the import process to finish, 0 is indefinite. """ import_uri = api.publish_collection(collection_path) if wait: # Galaxy returns a url fragment which differs between v2 and v3. The second to last entry is # always the task_id, though. # v2: {"task": "https://galaxy-dev.ansible.com/api/v2/collection-imports/35573/"} # v3: {"task": "/api/automation-hub/v3/imports/collections/838d1308-a8f4-402c-95cb-7823f3806cd8/"} task_id = None for path_segment in reversed(import_uri.split('/')): if path_segment: task_id = path_segment break if not task_id: raise AnsibleError("Publishing the collection did not return valid task info. Cannot wait for task status. Returned task info: '%s'" % import_uri) with _display_progress( "Collection has been published to the Galaxy server " "{api.name!s} {api.api_server!s}".format(api=api), ): api.wait_import_task(task_id, timeout) display.display("Collection has been successfully published and imported to the Galaxy server %s %s" % (api.name, api.api_server)) else: display.display("Collection has been pushed to the Galaxy server %s %s, not waiting until import has " "completed due to --no-wait being set. Import task results can be found at %s" % (api.name, api.api_server, import_uri)) def install_collections( collections, # type: Iterable[Requirement] output_path, # type: str apis, # type: Iterable[GalaxyAPI] ignore_errors, # type: bool no_deps, # type: bool force, # type: bool force_deps, # type: bool upgrade, # type: bool allow_pre_release, # type: bool artifacts_manager, # type: ConcreteArtifactsManager ): # type: (...) -> None """Install Ansible collections to the path specified. :param collections: The collections to install. :param output_path: The path to install the collections to. :param apis: A list of GalaxyAPIs to query when searching for a collection. :param validate_certs: Whether to validate the certificates if downloading a tarball. :param ignore_errors: Whether to ignore any errors when installing the collection. :param no_deps: Ignore any collection dependencies and only install the base requirements. :param force: Re-install a collection if it has already been installed. :param force_deps: Re-install a collection as well as its dependencies if they have already been installed. """ existing_collections = { Requirement(coll.fqcn, coll.ver, coll.src, coll.type) for coll in find_existing_collections(output_path, artifacts_manager) } unsatisfied_requirements = set( chain.from_iterable( ( Requirement.from_dir_path(sub_coll, artifacts_manager) for sub_coll in ( artifacts_manager. get_direct_collection_dependencies(install_req). keys() ) ) if install_req.is_subdirs else (install_req, ) for install_req in collections ), ) requested_requirements_names = {req.fqcn for req in unsatisfied_requirements} # NOTE: Don't attempt to reevaluate already installed deps # NOTE: unless `--force` or `--force-with-deps` is passed unsatisfied_requirements -= set() if force or force_deps else { req for req in unsatisfied_requirements for exs in existing_collections if req.fqcn == exs.fqcn and meets_requirements(exs.ver, req.ver) } if not unsatisfied_requirements and not upgrade: display.display( 'Nothing to do. All requested collections are already ' 'installed. If you want to reinstall them, ' 'consider using `--force`.' ) return # FIXME: This probably needs to be improved to # FIXME: properly match differing src/type. existing_non_requested_collections = { coll for coll in existing_collections if coll.fqcn not in requested_requirements_names } preferred_requirements = ( [] if force_deps else existing_non_requested_collections if force else existing_collections ) preferred_collections = { Candidate(coll.fqcn, coll.ver, coll.src, coll.type) for coll in preferred_requirements } with _display_progress("Process install dependency map"): dependency_map = _resolve_depenency_map( collections, galaxy_apis=apis, preferred_candidates=preferred_collections, concrete_artifacts_manager=artifacts_manager, no_deps=no_deps, allow_pre_release=allow_pre_release, upgrade=upgrade, ) with _display_progress("Starting collection install process"): for fqcn, concrete_coll_pin in dependency_map.items(): if concrete_coll_pin.is_virtual: display.vvvv( "'{coll!s}' is virtual, skipping.". format(coll=to_text(concrete_coll_pin)), ) continue if concrete_coll_pin in preferred_collections: display.display( "'{coll!s}' is already installed, skipping.". format(coll=to_text(concrete_coll_pin)), ) continue try: install(concrete_coll_pin, output_path, artifacts_manager) except AnsibleError as err: if ignore_errors: display.warning( 'Failed to install collection {coll!s} but skipping ' 'due to --ignore-errors being set. Error: {error!s}'. format( coll=to_text(concrete_coll_pin), error=to_text(err), ) ) else: raise # NOTE: imported in ansible.cli.galaxy def validate_collection_name(name): # type: (str) -> str """Validates the collection name as an input from the user or a requirements file fit the requirements. :param name: The input name with optional range specifier split by ':'. :return: The input value, required for argparse validation. """ collection, dummy, dummy = name.partition(':') if AnsibleCollectionRef.is_valid_collection_name(collection): return name raise AnsibleError("Invalid collection name '%s', " "name must be in the format <namespace>.<collection>. \n" "Please make sure namespace and collection name contains " "characters from [a-zA-Z0-9_] only." % name) # NOTE: imported in ansible.cli.galaxy def validate_collection_path(collection_path): # type: (str) -> str """Ensure a given path ends with 'ansible_collections' :param collection_path: The path that should end in 'ansible_collections' :return: collection_path ending in 'ansible_collections' if it does not already. """ if os.path.split(collection_path)[1] != 'ansible_collections': return os.path.join(collection_path, 'ansible_collections') return collection_path def verify_collections( collections, # type: Iterable[Requirement] search_paths, # type: Iterable[str] apis, # type: Iterable[GalaxyAPI] ignore_errors, # type: bool local_verify_only, # type: bool artifacts_manager, # type: ConcreteArtifactsManager ): # type: (...) -> List[CollectionVerifyResult] r"""Verify the integrity of locally installed collections. :param collections: The collections to check. :param search_paths: Locations for the local collection lookup. :param apis: A list of GalaxyAPIs to query when searching for a collection. :param ignore_errors: Whether to ignore any errors when verifying the collection. :param local_verify_only: When True, skip downloads and only verify local manifests. :param artifacts_manager: Artifacts manager. :return: list of CollectionVerifyResult objects describing the results of each collection verification """ results = [] # type: List[CollectionVerifyResult] api_proxy = MultiGalaxyAPIProxy(apis, artifacts_manager) with _display_progress(): for collection in collections: try: if collection.is_concrete_artifact: raise AnsibleError( message="'{coll_type!s}' type is not supported. " 'The format namespace.name is expected.'. format(coll_type=collection.type) ) # NOTE: Verify local collection exists before # NOTE: downloading its source artifact from # NOTE: a galaxy server. default_err = 'Collection %s is not installed in any of the collection paths.' % collection.fqcn for search_path in search_paths: b_search_path = to_bytes( os.path.join( search_path, collection.namespace, collection.name, ), errors='surrogate_or_strict', ) if not os.path.isdir(b_search_path): continue if not _is_installed_collection_dir(b_search_path): default_err = ( "Collection %s does not have a MANIFEST.json. " "A MANIFEST.json is expected if the collection has been built " "and installed via ansible-galaxy" % collection.fqcn ) continue local_collection = Candidate.from_dir_path( b_search_path, artifacts_manager, ) break else: raise AnsibleError(message=default_err) if local_verify_only: remote_collection = None else: remote_collection = Candidate( collection.fqcn, collection.ver if collection.ver != '*' else local_collection.ver, None, 'galaxy', ) # Download collection on a galaxy server for comparison try: # NOTE: Trigger the lookup. If found, it'll cache # NOTE: download URL and token in artifact manager. api_proxy.get_collection_version_metadata( remote_collection, ) except AnsibleError as e: # FIXME: does this actually emit any errors? # FIXME: extract the actual message and adjust this: expected_error_msg = ( 'Failed to find collection {coll.fqcn!s}:{coll.ver!s}'. format(coll=collection) ) if e.message == expected_error_msg: raise AnsibleError( 'Failed to find remote collection ' "'{coll!s}' on any of the galaxy servers". format(coll=collection) ) raise result = verify_local_collection( local_collection, remote_collection, artifacts_manager, ) results.append(result) except AnsibleError as err: if ignore_errors: display.warning( "Failed to verify collection '{coll!s}' but skipping " 'due to --ignore-errors being set. ' 'Error: {err!s}'. format(coll=collection, err=to_text(err)), ) else: raise return results @contextmanager def _tempdir(): b_temp_path = tempfile.mkdtemp(dir=to_bytes(C.DEFAULT_LOCAL_TMP, errors='surrogate_or_strict')) try: yield b_temp_path finally: shutil.rmtree(b_temp_path) @contextmanager def _display_progress(msg=None): config_display = C.GALAXY_DISPLAY_PROGRESS display_wheel = sys.stdout.isatty() if config_display is None else config_display global display if msg is not None: display.display(msg) if not display_wheel: yield return def progress(display_queue, actual_display): actual_display.debug("Starting display_progress display thread") t = threading.current_thread() while True: for c in "|/-\\": actual_display.display(c + "\b", newline=False) time.sleep(0.1) # Display a message from the main thread while True: try: method, args, kwargs = display_queue.get(block=False, timeout=0.1) except queue.Empty: break else: func = getattr(actual_display, method) func(*args, **kwargs) if getattr(t, "finish", False): actual_display.debug("Received end signal for display_progress display thread") return class DisplayThread(object): def __init__(self, display_queue): self.display_queue = display_queue def __getattr__(self, attr): def call_display(*args, **kwargs): self.display_queue.put((attr, args, kwargs)) return call_display # Temporary override the global display class with our own which add the calls to a queue for the thread to call. old_display = display try: display_queue = queue.Queue() display = DisplayThread(display_queue) t = threading.Thread(target=progress, args=(display_queue, old_display)) t.daemon = True t.start() try: yield finally: t.finish = True t.join() except Exception: # The exception is re-raised so we can sure the thread is finished and not using the display anymore raise finally: display = old_display def _verify_file_hash(b_path, filename, expected_hash, error_queue): b_file_path = to_bytes(os.path.join(to_text(b_path), filename), errors='surrogate_or_strict') if not os.path.isfile(b_file_path): actual_hash = None else: with open(b_file_path, mode='rb') as file_object: actual_hash = _consume_file(file_object) if expected_hash != actual_hash: error_queue.append(ModifiedContent(filename=filename, expected=expected_hash, installed=actual_hash)) def _build_files_manifest(b_collection_path, namespace, name, ignore_patterns): # type: (bytes, str, str, List[str]) -> FilesManifestType # We always ignore .pyc and .retry files as well as some well known version control directories. The ignore # patterns can be extended by the build_ignore key in galaxy.yml b_ignore_patterns = [ b'galaxy.yml', b'galaxy.yaml', b'.git', b'*.pyc', b'*.retry', b'tests/output', # Ignore ansible-test result output directory. to_bytes('{0}-{1}-*.tar.gz'.format(namespace, name)), # Ignores previously built artifacts in the root dir. ] b_ignore_patterns += [to_bytes(p) for p in ignore_patterns] b_ignore_dirs = frozenset([b'CVS', b'.bzr', b'.hg', b'.git', b'.svn', b'__pycache__', b'.tox']) entry_template = { 'name': None, 'ftype': None, 'chksum_type': None, 'chksum_sha256': None, 'format': MANIFEST_FORMAT } manifest = { 'files': [ { 'name': '.', 'ftype': 'dir', 'chksum_type': None, 'chksum_sha256': None, 'format': MANIFEST_FORMAT, }, ], 'format': MANIFEST_FORMAT, } # type: FilesManifestType def _walk(b_path, b_top_level_dir): for b_item in os.listdir(b_path): b_abs_path = os.path.join(b_path, b_item) b_rel_base_dir = b'' if b_path == b_top_level_dir else b_path[len(b_top_level_dir) + 1:] b_rel_path = os.path.join(b_rel_base_dir, b_item) rel_path = to_text(b_rel_path, errors='surrogate_or_strict') if os.path.isdir(b_abs_path): if any(b_item == b_path for b_path in b_ignore_dirs) or \ any(fnmatch.fnmatch(b_rel_path, b_pattern) for b_pattern in b_ignore_patterns): display.vvv("Skipping '%s' for collection build" % to_text(b_abs_path)) continue if os.path.islink(b_abs_path): b_link_target = os.path.realpath(b_abs_path) if not _is_child_path(b_link_target, b_top_level_dir): display.warning("Skipping '%s' as it is a symbolic link to a directory outside the collection" % to_text(b_abs_path)) continue manifest_entry = entry_template.copy() manifest_entry['name'] = rel_path manifest_entry['ftype'] = 'dir' manifest['files'].append(manifest_entry) if not os.path.islink(b_abs_path): _walk(b_abs_path, b_top_level_dir) else: if any(fnmatch.fnmatch(b_rel_path, b_pattern) for b_pattern in b_ignore_patterns): display.vvv("Skipping '%s' for collection build" % to_text(b_abs_path)) continue # Handling of file symlinks occur in _build_collection_tar, the manifest for a symlink is the same for # a normal file. manifest_entry = entry_template.copy() manifest_entry['name'] = rel_path manifest_entry['ftype'] = 'file' manifest_entry['chksum_type'] = 'sha256' manifest_entry['chksum_sha256'] = secure_hash(b_abs_path, hash_func=sha256) manifest['files'].append(manifest_entry) _walk(b_collection_path, b_collection_path) return manifest # FIXME: accept a dict produced from `galaxy.yml` instead of separate args def _build_manifest(namespace, name, version, authors, readme, tags, description, license_file, dependencies, repository, documentation, homepage, issues, **kwargs): manifest = { 'collection_info': { 'namespace': namespace, 'name': name, 'version': version, 'authors': authors, 'readme': readme, 'tags': tags, 'description': description, 'license': kwargs['license'], 'license_file': license_file or None, # Handle galaxy.yml having an empty string (None) 'dependencies': dependencies, 'repository': repository, 'documentation': documentation, 'homepage': homepage, 'issues': issues, }, 'file_manifest_file': { 'name': 'FILES.json', 'ftype': 'file', 'chksum_type': 'sha256', 'chksum_sha256': None, # Filled out in _build_collection_tar 'format': MANIFEST_FORMAT }, 'format': MANIFEST_FORMAT, } return manifest def _build_collection_tar( b_collection_path, # type: bytes b_tar_path, # type: bytes collection_manifest, # type: CollectionManifestType file_manifest, # type: FilesManifestType ): # type: (...) -> Text """Build a tar.gz collection artifact from the manifest data.""" files_manifest_json = to_bytes(json.dumps(file_manifest, indent=True), errors='surrogate_or_strict') collection_manifest['file_manifest_file']['chksum_sha256'] = secure_hash_s(files_manifest_json, hash_func=sha256) collection_manifest_json = to_bytes(json.dumps(collection_manifest, indent=True), errors='surrogate_or_strict') with _tempdir() as b_temp_path: b_tar_filepath = os.path.join(b_temp_path, os.path.basename(b_tar_path)) with tarfile.open(b_tar_filepath, mode='w:gz') as tar_file: # Add the MANIFEST.json and FILES.json file to the archive for name, b in [(MANIFEST_FILENAME, collection_manifest_json), ('FILES.json', files_manifest_json)]: b_io = BytesIO(b) tar_info = tarfile.TarInfo(name) tar_info.size = len(b) tar_info.mtime = int(time.time()) tar_info.mode = 0o0644 tar_file.addfile(tarinfo=tar_info, fileobj=b_io) for file_info in file_manifest['files']: # type: ignore[union-attr] if file_info['name'] == '.': continue # arcname expects a native string, cannot be bytes filename = to_native(file_info['name'], errors='surrogate_or_strict') b_src_path = os.path.join(b_collection_path, to_bytes(filename, errors='surrogate_or_strict')) def reset_stat(tarinfo): if tarinfo.type != tarfile.SYMTYPE: existing_is_exec = tarinfo.mode & stat.S_IXUSR tarinfo.mode = 0o0755 if existing_is_exec or tarinfo.isdir() else 0o0644 tarinfo.uid = tarinfo.gid = 0 tarinfo.uname = tarinfo.gname = '' return tarinfo if os.path.islink(b_src_path): b_link_target = os.path.realpath(b_src_path) if _is_child_path(b_link_target, b_collection_path): b_rel_path = os.path.relpath(b_link_target, start=os.path.dirname(b_src_path)) tar_info = tarfile.TarInfo(filename) tar_info.type = tarfile.SYMTYPE tar_info.linkname = to_native(b_rel_path, errors='surrogate_or_strict') tar_info = reset_stat(tar_info) tar_file.addfile(tarinfo=tar_info) continue # Dealing with a normal file, just add it by name. tar_file.add( to_native(os.path.realpath(b_src_path)), arcname=filename, recursive=False, filter=reset_stat, ) shutil.copy(to_native(b_tar_filepath), to_native(b_tar_path)) collection_name = "%s.%s" % (collection_manifest['collection_info']['namespace'], collection_manifest['collection_info']['name']) tar_path = to_text(b_tar_path) display.display(u'Created collection for %s at %s' % (collection_name, tar_path)) return tar_path def _build_collection_dir(b_collection_path, b_collection_output, collection_manifest, file_manifest): """Build a collection directory from the manifest data. This should follow the same pattern as _build_collection_tar. """ os.makedirs(b_collection_output, mode=0o0755) files_manifest_json = to_bytes(json.dumps(file_manifest, indent=True), errors='surrogate_or_strict') collection_manifest['file_manifest_file']['chksum_sha256'] = secure_hash_s(files_manifest_json, hash_func=sha256) collection_manifest_json = to_bytes(json.dumps(collection_manifest, indent=True), errors='surrogate_or_strict') # Write contents to the files for name, b in [(MANIFEST_FILENAME, collection_manifest_json), ('FILES.json', files_manifest_json)]: b_path = os.path.join(b_collection_output, to_bytes(name, errors='surrogate_or_strict')) with open(b_path, 'wb') as file_obj, BytesIO(b) as b_io: shutil.copyfileobj(b_io, file_obj) os.chmod(b_path, 0o0644) base_directories = [] for file_info in file_manifest['files']: if file_info['name'] == '.': continue src_file = os.path.join(b_collection_path, to_bytes(file_info['name'], errors='surrogate_or_strict')) dest_file = os.path.join(b_collection_output, to_bytes(file_info['name'], errors='surrogate_or_strict')) if any(src_file.startswith(directory) for directory in base_directories): continue existing_is_exec = os.stat(src_file).st_mode & stat.S_IXUSR mode = 0o0755 if existing_is_exec else 0o0644 if os.path.isdir(src_file): mode = 0o0755 base_directories.append(src_file) shutil.copytree(src_file, dest_file) else: shutil.copyfile(src_file, dest_file) os.chmod(dest_file, mode) collection_output = to_text(b_collection_output) return collection_output def find_existing_collections(path, artifacts_manager): """Locate all collections under a given path. :param path: Collection dirs layout search path. :param artifacts_manager: Artifacts manager. """ b_path = to_bytes(path, errors='surrogate_or_strict') # FIXME: consider using `glob.glob()` to simplify looping for b_namespace in os.listdir(b_path): b_namespace_path = os.path.join(b_path, b_namespace) if os.path.isfile(b_namespace_path): continue # FIXME: consider feeding b_namespace_path to Candidate.from_dir_path to get subdirs automatically for b_collection in os.listdir(b_namespace_path): b_collection_path = os.path.join(b_namespace_path, b_collection) if not os.path.isdir(b_collection_path): continue try: req = Candidate.from_dir_path_as_unknown( b_collection_path, artifacts_manager, ) except ValueError as val_err: raise_from(AnsibleError(val_err), val_err) display.vvv( u"Found installed collection {coll!s} at '{path!s}'". format(coll=to_text(req), path=to_text(req.src)) ) yield req def install(collection, path, artifacts_manager): # FIXME: mv to dataclasses? # type: (Candidate, str, ConcreteArtifactsManager) -> None """Install a collection under a given path. :param collection: Collection to be installed. :param path: Collection dirs layout path. :param artifacts_manager: Artifacts manager. """ b_artifact_path = ( artifacts_manager.get_artifact_path if collection.is_concrete_artifact else artifacts_manager.get_galaxy_artifact_path )(collection) collection_path = os.path.join(path, collection.namespace, collection.name) b_collection_path = to_bytes(collection_path, errors='surrogate_or_strict') display.display( u"Installing '{coll!s}' to '{path!s}'". format(coll=to_text(collection), path=collection_path), ) if os.path.exists(b_collection_path): shutil.rmtree(b_collection_path) if collection.is_dir: install_src(collection, b_artifact_path, b_collection_path, artifacts_manager) else: install_artifact(b_artifact_path, b_collection_path, artifacts_manager._b_working_directory) display.display( '{coll!s} was installed successfully'. format(coll=to_text(collection)), ) def install_artifact(b_coll_targz_path, b_collection_path, b_temp_path): """Install a collection from tarball under a given path. :param b_coll_targz_path: Collection tarball to be installed. :param b_collection_path: Collection dirs layout path. :param b_temp_path: Temporary dir path. """ try: with tarfile.open(b_coll_targz_path, mode='r') as collection_tar: files_member_obj = collection_tar.getmember('FILES.json') with _tarfile_extract(collection_tar, files_member_obj) as (dummy, files_obj): files = json.loads(to_text(files_obj.read(), errors='surrogate_or_strict')) _extract_tar_file(collection_tar, MANIFEST_FILENAME, b_collection_path, b_temp_path) _extract_tar_file(collection_tar, 'FILES.json', b_collection_path, b_temp_path) for file_info in files['files']: file_name = file_info['name'] if file_name == '.': continue if file_info['ftype'] == 'file': _extract_tar_file(collection_tar, file_name, b_collection_path, b_temp_path, expected_hash=file_info['chksum_sha256']) else: _extract_tar_dir(collection_tar, file_name, b_collection_path) except Exception: # Ensure we don't leave the dir behind in case of a failure. shutil.rmtree(b_collection_path) b_namespace_path = os.path.dirname(b_collection_path) if not os.listdir(b_namespace_path): os.rmdir(b_namespace_path) raise def install_src( collection, b_collection_path, b_collection_output_path, artifacts_manager, ): r"""Install the collection from source control into given dir. Generates the Ansible collection artifact data from a galaxy.yml and installs the artifact to a directory. This should follow the same pattern as build_collection, but instead of creating an artifact, install it. :param collection: Collection to be installed. :param b_collection_path: Collection dirs layout path. :param b_collection_output_path: The installation directory for the \ collection artifact. :param artifacts_manager: Artifacts manager. :raises AnsibleError: If no collection metadata found. """ collection_meta = artifacts_manager.get_direct_collection_meta(collection) if 'build_ignore' not in collection_meta: # installed collection, not src # FIXME: optimize this? use a different process? copy instead of build? collection_meta['build_ignore'] = [] collection_manifest = _build_manifest(**collection_meta) file_manifest = _build_files_manifest( b_collection_path, collection_meta['namespace'], collection_meta['name'], collection_meta['build_ignore'], ) collection_output_path = _build_collection_dir( b_collection_path, b_collection_output_path, collection_manifest, file_manifest, ) display.display( 'Created collection for {coll!s} at {path!s}'. format(coll=collection, path=collection_output_path) ) def _extract_tar_dir(tar, dirname, b_dest): """ Extracts a directory from a collection tar. """ member_names = [to_native(dirname, errors='surrogate_or_strict')] # Create list of members with and without trailing separator if not member_names[-1].endswith(os.path.sep): member_names.append(member_names[-1] + os.path.sep) # Try all of the member names and stop on the first one that are able to successfully get for member in member_names: try: tar_member = tar.getmember(member) except KeyError: continue break else: # If we still can't find the member, raise a nice error. raise AnsibleError("Unable to extract '%s' from collection" % to_native(member, errors='surrogate_or_strict')) b_dir_path = os.path.join(b_dest, to_bytes(dirname, errors='surrogate_or_strict')) b_parent_path = os.path.dirname(b_dir_path) try: os.makedirs(b_parent_path, mode=0o0755) except OSError as e: if e.errno != errno.EEXIST: raise if tar_member.type == tarfile.SYMTYPE: b_link_path = to_bytes(tar_member.linkname, errors='surrogate_or_strict') if not _is_child_path(b_link_path, b_dest, link_name=b_dir_path): raise AnsibleError("Cannot extract symlink '%s' in collection: path points to location outside of " "collection '%s'" % (to_native(dirname), b_link_path)) os.symlink(b_link_path, b_dir_path) else: if not os.path.isdir(b_dir_path): os.mkdir(b_dir_path, 0o0755) def _extract_tar_file(tar, filename, b_dest, b_temp_path, expected_hash=None): """ Extracts a file from a collection tar. """ with _get_tar_file_member(tar, filename) as (tar_member, tar_obj): if tar_member.type == tarfile.SYMTYPE: actual_hash = _consume_file(tar_obj) else: with tempfile.NamedTemporaryFile(dir=b_temp_path, delete=False) as tmpfile_obj: actual_hash = _consume_file(tar_obj, tmpfile_obj) if expected_hash and actual_hash != expected_hash: raise AnsibleError("Checksum mismatch for '%s' inside collection at '%s'" % (to_native(filename, errors='surrogate_or_strict'), to_native(tar.name))) b_dest_filepath = os.path.abspath(os.path.join(b_dest, to_bytes(filename, errors='surrogate_or_strict'))) b_parent_dir = os.path.dirname(b_dest_filepath) if not _is_child_path(b_parent_dir, b_dest): raise AnsibleError("Cannot extract tar entry '%s' as it will be placed outside the collection directory" % to_native(filename, errors='surrogate_or_strict')) if not os.path.exists(b_parent_dir): # Seems like Galaxy does not validate if all file entries have a corresponding dir ftype entry. This check # makes sure we create the parent directory even if it wasn't set in the metadata. os.makedirs(b_parent_dir, mode=0o0755) if tar_member.type == tarfile.SYMTYPE: b_link_path = to_bytes(tar_member.linkname, errors='surrogate_or_strict') if not _is_child_path(b_link_path, b_dest, link_name=b_dest_filepath): raise AnsibleError("Cannot extract symlink '%s' in collection: path points to location outside of " "collection '%s'" % (to_native(filename), b_link_path)) os.symlink(b_link_path, b_dest_filepath) else: shutil.move(to_bytes(tmpfile_obj.name, errors='surrogate_or_strict'), b_dest_filepath) # Default to rw-r--r-- and only add execute if the tar file has execute. tar_member = tar.getmember(to_native(filename, errors='surrogate_or_strict')) new_mode = 0o644 if stat.S_IMODE(tar_member.mode) & stat.S_IXUSR: new_mode |= 0o0111 os.chmod(b_dest_filepath, new_mode) def _get_tar_file_member(tar, filename): n_filename = to_native(filename, errors='surrogate_or_strict') try: member = tar.getmember(n_filename) except KeyError: raise AnsibleError("Collection tar at '%s' does not contain the expected file '%s'." % ( to_native(tar.name), n_filename)) return _tarfile_extract(tar, member) def _get_json_from_tar_file(b_path, filename): file_contents = '' with tarfile.open(b_path, mode='r') as collection_tar: with _get_tar_file_member(collection_tar, filename) as (dummy, tar_obj): bufsize = 65536 data = tar_obj.read(bufsize) while data: file_contents += to_text(data) data = tar_obj.read(bufsize) return json.loads(file_contents) def _get_tar_file_hash(b_path, filename): with tarfile.open(b_path, mode='r') as collection_tar: with _get_tar_file_member(collection_tar, filename) as (dummy, tar_obj): return _consume_file(tar_obj) def _get_file_hash(b_path, filename): # type: (bytes, str) -> str filepath = os.path.join(b_path, to_bytes(filename, errors='surrogate_or_strict')) with open(filepath, 'rb') as fp: return _consume_file(fp) def _is_child_path(path, parent_path, link_name=None): """ Checks that path is a path within the parent_path specified. """ b_path = to_bytes(path, errors='surrogate_or_strict') if link_name and not os.path.isabs(b_path): # If link_name is specified, path is the source of the link and we need to resolve the absolute path. b_link_dir = os.path.dirname(to_bytes(link_name, errors='surrogate_or_strict')) b_path = os.path.abspath(os.path.join(b_link_dir, b_path)) b_parent_path = to_bytes(parent_path, errors='surrogate_or_strict') return b_path == b_parent_path or b_path.startswith(b_parent_path + to_bytes(os.path.sep)) def _resolve_depenency_map( requested_requirements, # type: Iterable[Requirement] galaxy_apis, # type: Iterable[GalaxyAPI] concrete_artifacts_manager, # type: ConcreteArtifactsManager preferred_candidates, # type: Optional[Iterable[Candidate]] no_deps, # type: bool allow_pre_release, # type: bool upgrade, # type: bool ): # type: (...) -> Dict[str, Candidate] """Return the resolved dependency map.""" collection_dep_resolver = build_collection_dependency_resolver( galaxy_apis=galaxy_apis, concrete_artifacts_manager=concrete_artifacts_manager, user_requirements=requested_requirements, preferred_candidates=preferred_candidates, with_deps=not no_deps, with_pre_releases=allow_pre_release, upgrade=upgrade, ) try: return collection_dep_resolver.resolve( requested_requirements, max_rounds=2000000, # NOTE: same constant pip uses ).mapping except CollectionDependencyResolutionImpossible as dep_exc: conflict_causes = ( '* {req.fqcn!s}:{req.ver!s} ({dep_origin!s})'.format( req=req_inf.requirement, dep_origin='direct request' if req_inf.parent is None else 'dependency of {parent!s}'. format(parent=req_inf.parent), ) for req_inf in dep_exc.causes ) error_msg_lines = chain( ( 'Failed to resolve the requested ' 'dependencies map. Could not satisfy the following ' 'requirements:', ), conflict_causes, ) raise raise_from( # NOTE: Leading "raise" is a hack for mypy bug #9717 AnsibleError('\n'.join(error_msg_lines)), dep_exc, )
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 26, 334, 67, 9, 20312, 13, 22150, 12, 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, 624, 21268, 5055, 10041, 2559, 1041, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 7554, 199, 646, 15951, 199, 646, 9143, 199, 646, 2022, 199, 646, 747, 199, 646, 5145, 199, 646, 5672, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 5796, 199, 646, 900, 199, 646, 8864, 199, 199, 504, 5055, 492, 12863, 199, 504, 15502, 492, 27608, 199, 504, 3242, 14, 578, 63, 1208, 14, 5819, 14, 1023, 492, 18462, 199, 504, 8337, 492, 7793, 3912, 199, 504, 5890, 492, 11808, 199, 504, 7975, 492, 6036, 199, 504, 8864, 14, 705, 492, 18916, 547, 199, 199, 3, 6944, 26, 12934, 730, 24010, 365, 282, 11176, 367, 3002, 647, 370, 24761, 1536, 23105, 6519, 327, 845, 2481, 199, 893, 26, 272, 492, 4126, 221, 327, 730, 26, 3686, 59, 646, 61, 199, 2590, 3545, 26, 221, 327, 2018, 499, 272, 492, 10703, 465, 4126, 221, 327, 730, 26, 3686, 59, 646, 12, 889, 13, 264, 318, 61, 199, 199, 893, 26, 272, 327, 6944, 26, 2779, 1159, 315, 2018, 650, 26678, 436, 883, 506, 4903, 641, 2018, 499, 272, 327, 6944, 26, 4799, 658, 9983, 3907, 14090, 2313, 1910, 17927, 315, 8836, 14, 272, 327, 6944, 26, 658, 2711, 63, 8936, 1206, 64, 365, 715, 5309, 3002, 647, 13, 466, 1074, 13, 521, 14, 272, 687, 14090, 492, 11511, 63, 8936, 1206, 199, 2590, 3545, 26, 272, 11511, 63, 8936, 1206, 275, 756, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 687, 14090, 492, 7448, 12, 19937, 12, 3820, 12, 4879, 12, 4516, 12, 15961, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 1695, 304, 267, 687, 14090, 492, 18271, 272, 587, 26, 221, 327, 2018, 499, 435, 2018, 650, 14, 20, 13, 19, 14, 23, 267, 687, 14090, 63, 5359, 492, 18271, 339, 687, 3242, 14, 24806, 14, 1246, 492, 598, 15914, 3735, 272, 687, 3242, 14, 24806, 14, 3627, 14, 13455, 63, 16154, 63, 2609, 492, 334, 267, 1448, 7564, 1596, 17530, 2988, 12, 272, 776, 339, 4688, 3944, 6340, 804, 275, 18271, 59, 267, 283, 3627, 63, 815, 297, 283, 493, 63, 6418, 63, 493, 297, 283, 908, 297, 272, 1622, 272, 3814, 3396, 6340, 804, 275, 18271, 59, 267, 283, 354, 297, 267, 283, 10386, 297, 267, 283, 14823, 1838, 63, 466, 297, 267, 283, 14823, 1838, 63, 4835, 3912, 297, 267, 283, 908, 297, 272, 1622, 272, 18003, 2354, 6340, 804, 275, 18271, 59, 267, 327, 3245, 3404, 26, 267, 283, 3251, 297, 283, 354, 297, 283, 1023, 297, 267, 283, 8149, 297, 283, 32709, 297, 267, 283, 2969, 297, 283, 1802, 297, 267, 283, 1682, 297, 283, 1682, 63, 493, 297, 267, 283, 5714, 297, 267, 283, 8421, 297, 283, 9970, 297, 267, 283, 25539, 297, 283, 10115, 297, 398, 327, 1584, 3404, 26, 267, 3814, 3396, 6340, 804, 12, 272, 1622, 272, 4688, 3944, 1110, 804, 275, 7448, 59, 267, 18003, 2354, 6340, 804, 12, 267, 4879, 59, 288, 15961, 59, 355, 1109, 12, 620, 12, 221, 327, 19945, 12, 2839, 536, 15, 561, 12, 4177, 1015, 355, 3820, 59, 495, 467, 221, 327, 5548, 402, 19945, 12, 2839, 3762, 355, 7448, 59, 495, 12, 620, 467, 221, 327, 10140, 2341, 288, 2156, 267, 2156, 272, 1622, 272, 18003, 11038, 804, 275, 7448, 59, 11038, 6340, 804, 12, 4688, 3944, 1110, 804, 61, 272, 3814, 11038, 3900, 804, 275, 7448, 59, 1173, 3396, 6340, 804, 12, 4879, 59, 15540, 59, 495, 12, 1109, 20737, 272, 16920, 11038, 804, 275, 7448, 59, 267, 18271, 459, 1725, 297, 283, 908, 995, 267, 15961, 59, 1296, 59, 1173, 11038, 3900, 804, 467, 1109, 467, 272, 1622, 199, 199, 646, 3242, 14, 5559, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 24806, 492, 664, 63, 7882, 63, 24806, 63, 2024, 63, 815, 199, 504, 3242, 14, 24806, 14, 3627, 14, 13455, 63, 16154, 63, 2609, 492, 334, 272, 485, 10235, 63, 493, 12, 272, 485, 4249, 63, 493, 12, 272, 485, 362, 63, 1001, 63, 504, 63, 7657, 63, 694, 12, 272, 485, 362, 63, 2024, 63, 504, 63, 2164, 63, 694, 12, 272, 485, 19862, 63, 5005, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 3627, 14, 24806, 63, 1246, 63, 3280, 492, 6879, 39, 15914, 3735, 4936, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 492, 334, 272, 1900, 63, 3627, 63, 8575, 63, 7717, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 576, 2888, 492, 334, 272, 6855, 5168, 12, 25013, 12, 485, 374, 63, 7657, 63, 3627, 63, 694, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 2550, 492, 334, 272, 18003, 14403, 18508, 8499, 12716, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 30968, 492, 562, 8716, 63, 7538, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 746, 63, 504, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 5963, 492, 8864, 63, 2724, 199, 504, 3242, 14, 1208, 14, 3627, 63, 3422, 492, 2622, 7768, 2891, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 2227, 316, 492, 11153, 63, 2227, 12, 11153, 63, 2227, 63, 83, 199, 504, 3242, 14, 1208, 14, 1023, 492, 3240, 23127, 3353, 421, 199, 2918, 275, 12175, 342, 199, 199, 24067, 63, 4807, 275, 413, 199, 24067, 63, 15440, 275, 283, 24067, 14, 1001, 7, 199, 199, 11911, 2714, 275, 12863, 360, 11911, 2714, 297, 788, 1501, 297, 283, 2062, 297, 283 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 26, 334, 67, 9, 20312, 13, 22150, 12, 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, 624, 21268, 5055, 10041, 2559, 1041, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 7554, 199, 646, 15951, 199, 646, 9143, 199, 646, 2022, 199, 646, 747, 199, 646, 5145, 199, 646, 5672, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 5796, 199, 646, 900, 199, 646, 8864, 199, 199, 504, 5055, 492, 12863, 199, 504, 15502, 492, 27608, 199, 504, 3242, 14, 578, 63, 1208, 14, 5819, 14, 1023, 492, 18462, 199, 504, 8337, 492, 7793, 3912, 199, 504, 5890, 492, 11808, 199, 504, 7975, 492, 6036, 199, 504, 8864, 14, 705, 492, 18916, 547, 199, 199, 3, 6944, 26, 12934, 730, 24010, 365, 282, 11176, 367, 3002, 647, 370, 24761, 1536, 23105, 6519, 327, 845, 2481, 199, 893, 26, 272, 492, 4126, 221, 327, 730, 26, 3686, 59, 646, 61, 199, 2590, 3545, 26, 221, 327, 2018, 499, 272, 492, 10703, 465, 4126, 221, 327, 730, 26, 3686, 59, 646, 12, 889, 13, 264, 318, 61, 199, 199, 893, 26, 272, 327, 6944, 26, 2779, 1159, 315, 2018, 650, 26678, 436, 883, 506, 4903, 641, 2018, 499, 272, 327, 6944, 26, 4799, 658, 9983, 3907, 14090, 2313, 1910, 17927, 315, 8836, 14, 272, 327, 6944, 26, 658, 2711, 63, 8936, 1206, 64, 365, 715, 5309, 3002, 647, 13, 466, 1074, 13, 521, 14, 272, 687, 14090, 492, 11511, 63, 8936, 1206, 199, 2590, 3545, 26, 272, 11511, 63, 8936, 1206, 275, 756, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 687, 14090, 492, 7448, 12, 19937, 12, 3820, 12, 4879, 12, 4516, 12, 15961, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 1695, 304, 267, 687, 14090, 492, 18271, 272, 587, 26, 221, 327, 2018, 499, 435, 2018, 650, 14, 20, 13, 19, 14, 23, 267, 687, 14090, 63, 5359, 492, 18271, 339, 687, 3242, 14, 24806, 14, 1246, 492, 598, 15914, 3735, 272, 687, 3242, 14, 24806, 14, 3627, 14, 13455, 63, 16154, 63, 2609, 492, 334, 267, 1448, 7564, 1596, 17530, 2988, 12, 272, 776, 339, 4688, 3944, 6340, 804, 275, 18271, 59, 267, 283, 3627, 63, 815, 297, 283, 493, 63, 6418, 63, 493, 297, 283, 908, 297, 272, 1622, 272, 3814, 3396, 6340, 804, 275, 18271, 59, 267, 283, 354, 297, 267, 283, 10386, 297, 267, 283, 14823, 1838, 63, 466, 297, 267, 283, 14823, 1838, 63, 4835, 3912, 297, 267, 283, 908, 297, 272, 1622, 272, 18003, 2354, 6340, 804, 275, 18271, 59, 267, 327, 3245, 3404, 26, 267, 283, 3251, 297, 283, 354, 297, 283, 1023, 297, 267, 283, 8149, 297, 283, 32709, 297, 267, 283, 2969, 297, 283, 1802, 297, 267, 283, 1682, 297, 283, 1682, 63, 493, 297, 267, 283, 5714, 297, 267, 283, 8421, 297, 283, 9970, 297, 267, 283, 25539, 297, 283, 10115, 297, 398, 327, 1584, 3404, 26, 267, 3814, 3396, 6340, 804, 12, 272, 1622, 272, 4688, 3944, 1110, 804, 275, 7448, 59, 267, 18003, 2354, 6340, 804, 12, 267, 4879, 59, 288, 15961, 59, 355, 1109, 12, 620, 12, 221, 327, 19945, 12, 2839, 536, 15, 561, 12, 4177, 1015, 355, 3820, 59, 495, 467, 221, 327, 5548, 402, 19945, 12, 2839, 3762, 355, 7448, 59, 495, 12, 620, 467, 221, 327, 10140, 2341, 288, 2156, 267, 2156, 272, 1622, 272, 18003, 11038, 804, 275, 7448, 59, 11038, 6340, 804, 12, 4688, 3944, 1110, 804, 61, 272, 3814, 11038, 3900, 804, 275, 7448, 59, 1173, 3396, 6340, 804, 12, 4879, 59, 15540, 59, 495, 12, 1109, 20737, 272, 16920, 11038, 804, 275, 7448, 59, 267, 18271, 459, 1725, 297, 283, 908, 995, 267, 15961, 59, 1296, 59, 1173, 11038, 3900, 804, 467, 1109, 467, 272, 1622, 199, 199, 646, 3242, 14, 5559, 465, 445, 199, 504, 3242, 14, 2550, 492, 13358, 199, 504, 3242, 14, 24806, 492, 664, 63, 7882, 63, 24806, 63, 2024, 63, 815, 199, 504, 3242, 14, 24806, 14, 3627, 14, 13455, 63, 16154, 63, 2609, 492, 334, 272, 485, 10235, 63, 493, 12, 272, 485, 4249, 63, 493, 12, 272, 485, 362, 63, 1001, 63, 504, 63, 7657, 63, 694, 12, 272, 485, 362, 63, 2024, 63, 504, 63, 2164, 63, 694, 12, 272, 485, 19862, 63, 5005, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 3627, 14, 24806, 63, 1246, 63, 3280, 492, 6879, 39, 15914, 3735, 4936, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 492, 334, 272, 1900, 63, 3627, 63, 8575, 63, 7717, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 576, 2888, 492, 334, 272, 6855, 5168, 12, 25013, 12, 485, 374, 63, 7657, 63, 3627, 63, 694, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 2550, 492, 334, 272, 18003, 14403, 18508, 8499, 12716, 12, 199, 9, 199, 504, 3242, 14, 24806, 14, 8575, 63, 12588, 14, 30968, 492, 562, 8716, 63, 7538, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 746, 63, 504, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 2394, 12, 370, 63, 6106, 12, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 14, 5963, 492, 8864, 63, 2724, 199, 504, 3242, 14, 1208, 14, 3627, 63, 3422, 492, 2622, 7768, 2891, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 2227, 316, 492, 11153, 63, 2227, 12, 11153, 63, 2227, 63, 83, 199, 504, 3242, 14, 1208, 14, 1023, 492, 3240, 23127, 3353, 421, 199, 2918, 275, 12175, 342, 199, 199, 24067, 63, 4807, 275, 413, 199, 24067, 63, 15440, 275, 283, 24067, 14, 1001, 7, 199, 199, 11911, 2714, 275, 12863, 360, 11911, 2714,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
timohtey/mediadrop_copy
mediacore_env/Lib/encodings/iso8859_2.py
593
13660
""" Python Character Mapping Codec iso8859_2 generated from 'MAPPINGS/ISO8859/8859-2.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='iso8859-2', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\x80' # 0x80 -> <control> u'\x81' # 0x81 -> <control> u'\x82' # 0x82 -> <control> u'\x83' # 0x83 -> <control> u'\x84' # 0x84 -> <control> u'\x85' # 0x85 -> <control> u'\x86' # 0x86 -> <control> u'\x87' # 0x87 -> <control> u'\x88' # 0x88 -> <control> u'\x89' # 0x89 -> <control> u'\x8a' # 0x8A -> <control> u'\x8b' # 0x8B -> <control> u'\x8c' # 0x8C -> <control> u'\x8d' # 0x8D -> <control> u'\x8e' # 0x8E -> <control> u'\x8f' # 0x8F -> <control> u'\x90' # 0x90 -> <control> u'\x91' # 0x91 -> <control> u'\x92' # 0x92 -> <control> u'\x93' # 0x93 -> <control> u'\x94' # 0x94 -> <control> u'\x95' # 0x95 -> <control> u'\x96' # 0x96 -> <control> u'\x97' # 0x97 -> <control> u'\x98' # 0x98 -> <control> u'\x99' # 0x99 -> <control> u'\x9a' # 0x9A -> <control> u'\x9b' # 0x9B -> <control> u'\x9c' # 0x9C -> <control> u'\x9d' # 0x9D -> <control> u'\x9e' # 0x9E -> <control> u'\x9f' # 0x9F -> <control> u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK u'\u02d8' # 0xA2 -> BREVE u'\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE u'\xa4' # 0xA4 -> CURRENCY SIGN u'\u013d' # 0xA5 -> LATIN CAPITAL LETTER L WITH CARON u'\u015a' # 0xA6 -> LATIN CAPITAL LETTER S WITH ACUTE u'\xa7' # 0xA7 -> SECTION SIGN u'\xa8' # 0xA8 -> DIAERESIS u'\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON u'\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA u'\u0164' # 0xAB -> LATIN CAPITAL LETTER T WITH CARON u'\u0179' # 0xAC -> LATIN CAPITAL LETTER Z WITH ACUTE u'\xad' # 0xAD -> SOFT HYPHEN u'\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE u'\xb0' # 0xB0 -> DEGREE SIGN u'\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK u'\u02db' # 0xB2 -> OGONEK u'\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE u'\xb4' # 0xB4 -> ACUTE ACCENT u'\u013e' # 0xB5 -> LATIN SMALL LETTER L WITH CARON u'\u015b' # 0xB6 -> LATIN SMALL LETTER S WITH ACUTE u'\u02c7' # 0xB7 -> CARON u'\xb8' # 0xB8 -> CEDILLA u'\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON u'\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA u'\u0165' # 0xBB -> LATIN SMALL LETTER T WITH CARON u'\u017a' # 0xBC -> LATIN SMALL LETTER Z WITH ACUTE u'\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT u'\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE u'\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE u'\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS u'\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX u'\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE u'\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX u'\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xd7' # 0xD7 -> MULTIPLICATION SIGN u'\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON u'\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE u'\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE u'\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S u'\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS u'\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE u'\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS u'\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX u'\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE u'\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX u'\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS u'\xf7' # 0xF7 -> DIVISION SIGN u'\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON u'\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE u'\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE u'\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA u'\u02d9' # 0xFF -> DOT ABOVE ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-3.0
[ 624, 2018, 17660, 12340, 13732, 11601, 4830, 63, 18, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 18, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 18, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 221 ]
[ 2018, 17660, 12340, 13732, 11601, 4830, 63, 18, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 18, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 4830, 13, 18, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88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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 ]
lollipopi9000/android_kernel_samsung_aries
arch/ia64/scripts/unwcheck.py
13143
1714
#!/usr/bin/python # # Usage: unwcheck.py FILE # # This script checks the unwind info of each function in file FILE # and verifies that the sum of the region-lengths matches the total # length of the function. # # Based on a shell/awk script originally written by Harish Patil, # which was converted to Perl by Matthew Chapman, which was converted # to Python by David Mosberger. # import os import re import sys if len(sys.argv) != 2: print "Usage: %s FILE" % sys.argv[0] sys.exit(2) readelf = os.getenv("READELF", "readelf") start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]") rlen_pattern = re.compile(".*rlen=([0-9]+)") def check_func (func, slots, rlen_sum): if slots != rlen_sum: global num_errors num_errors += 1 if not func: func = "[%#x-%#x]" % (start, end) print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum) return num_funcs = 0 num_errors = 0 func = False slots = 0 rlen_sum = 0 for line in os.popen("%s -u %s" % (readelf, sys.argv[1])): m = start_pattern.match(line) if m: check_func(func, slots, rlen_sum) func = m.group(1) start = long(m.group(2), 16) end = long(m.group(3), 16) slots = 3 * (end - start) / 16 rlen_sum = 0L num_funcs += 1 else: m = rlen_pattern.match(line) if m: rlen_sum += long(m.group(1)) check_func(func, slots, rlen_sum) if num_errors == 0: print "No errors detected in %u functions." % num_funcs else: if num_errors > 1: err="errors" else: err="error" print "%u %s detected in %u functions." % (num_errors, err, num_funcs) sys.exit(1)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
maxamillion/product-definition-center
pdc/apps/common/viewsets.py
5
8185
# # Copyright (c) 2015 Red Hat # Licensed under The MIT License (MIT) # http://opensource.org/licenses/MIT # import re import json from django.contrib.contenttypes.models import ContentType from django.shortcuts import get_object_or_404 from django.core.exceptions import FieldError from django.http import Http404 from django.conf import settings from contrib import drf_introspection from rest_framework import mixins, status, viewsets from rest_framework.response import Response class NoSetattrInPreSaveMixin(object): """ Skip all `setattr`s in pre_save intentionally, as they modify the object to be saved by resetting all fields present in URL. """ def pre_save(self, obj): if hasattr(obj, 'full_clean'): obj.full_clean() class ChangeSetCreateModelMixin(mixins.CreateModelMixin): """ Wrapper around CreateModelMixin that logs the change. """ def perform_create(self, serializer): obj = serializer.save() self.object = obj if not isinstance(obj, list): obj = [obj] for item in obj: model_name = ContentType.objects.get_for_model(item).model self.request.changeset.add(model_name, item.id, 'null', json.dumps(item.export())) class NoEmptyPatchMixin(object): """ This mixin checks request data on PATCH request and returns an error response if the body is empty. This is useful as some software (notable `python-requests`) may remove the request body on redirect, which would lead to successful update with no changes performed.. """ def update(self, request, *args, **kwargs): if kwargs.get('partial', False) and not request.data: return NoEmptyPatchMixin.make_response() return super(NoEmptyPatchMixin, self).update(request, *args, **kwargs) def partial_update(self, request, *args, **kwargs): if not request.data: return NoEmptyPatchMixin.make_response() return super(NoEmptyPatchMixin, self).partial_update(request, *args, **kwargs) @classmethod def make_response(self): """ Use this method to build a descriptive error response for the empty PATCH request situation. """ return Response( status=status.HTTP_400_BAD_REQUEST, data=settings.EMPTY_PATCH_ERROR_RESPONSE ) class ChangeSetUpdateModelMixin(NoSetattrInPreSaveMixin, NoEmptyPatchMixin, mixins.UpdateModelMixin): """ Wrapper around UpdateModelMixin that logs the change. """ # NOTE(xchu): As Lubomir Sedlar pointed out that saving the old value in # pre_save is actually too late because there are some # modifications done before this hook is fired. # His solution was to save the object the first time # `get_object()` was called. def get_object(self): obj = super(ChangeSetUpdateModelMixin, self).get_object() self.origin_obj = getattr(self, 'origin_obj', obj.export()) return obj def perform_update(self, serializer): obj = serializer.save() self.object = obj model_name = ContentType.objects.get_for_model(obj).model self.request.changeset.add(model_name, obj.id, json.dumps(self.origin_obj), json.dumps(obj.export())) del self.origin_obj class ChangeSetDestroyModelMixin(mixins.DestroyModelMixin): """ Wrapper around DestroyModelMixin that logs the change. """ def perform_destroy(self, obj): model_name = ContentType.objects.get_for_model(obj).model obj_id = obj.id obj_content = json.dumps(obj.export()) super(ChangeSetDestroyModelMixin, self).perform_destroy(obj) self.request.changeset.add(model_name, obj_id, obj_content, 'null') class ChangeSetModelMixin(ChangeSetCreateModelMixin, ChangeSetUpdateModelMixin, ChangeSetDestroyModelMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin): """ Model viewset that provides default `list()`, `retrieve()`, with logging the changes in `create`, `update()`, `partial_update()` and `destroy()` actions. """ pass class StrictQueryParamMixin(object): """ This mixin will make a viewset strict in what query string parameters it accepts. If an unknown parameter is used, a 400 BAD REQUEST response will be sent (through the global exception handler). The list of allowed parameters is obtained from multiple sources: * filter set class * filter_fields attribute * extra_query_params attribute (which should be a list/tuple of strings) * paginate_by_param attribute The serializer can define what query parameters it uses by defining a `query_params` class attribute on the serializer. Note that this should only include the parameters that are passed via URL query string, not request body fields. """ def initial(self, request, *args, **kwargs): super(StrictQueryParamMixin, self).initial(request, *args, **kwargs) # We should not raise the exception if there is no handler for the # requested method, as it is better to return 405 METHOD NOT ALLOWED in # such case even if there are extra query parameters. if (request.method.lower() not in self.http_method_names or not hasattr(self, request.method.lower())): return allowed_keys = drf_introspection.get_allowed_query_params(self) extra_keys = set(request.query_params.keys()) - allowed_keys if extra_keys: raise FieldError('Unknown query params: %s.' % ', '.join(sorted(extra_keys))) class PDCModelViewSet(StrictQueryParamMixin, ChangeSetModelMixin, viewsets.GenericViewSet): """ PDC common ModelViewSet. With `StrictQueryParam`, `ProtectOnDelete` and `ChangeSetModel` """ pass class MultiLookupFieldMixin(object): """ This mixin allows using multiple lookup fields in URL. The viewset using this mixin must define `lookup_fields` class attribute as a list (or tuple) of two-tuples. Each element of the list corresponds to a single lookup field. First element in the inner tuple is the name of the field, second element is a regular expression describing what the value in URL should look like. The field names are used in `get_object` to retrieve the specified instance. They should be given in the format usable for `get` method on a queryset and all the fields together should be enough to uniquely identify a single object. """ lookup_field = 'composite_field' def __init__(self, *args, **kwargs): if not hasattr(self, 'lookup_fields'): raise Exception('The "lookup_fields" attribute must be included."') super(MultiLookupFieldMixin, self).__init__(*args, **kwargs) def _populate_kwargs(self): """ This methods makes sure kwargs contain the detailed fields. (This is necessary for bulk operations to function correctly.) """ m = re.match(self.lookup_value_regex, self.kwargs[self.lookup_field]) if not m: raise Http404('Provided identifier fields do not match expected format.') self.kwargs.update(m.groupdict()) def get_object(self): queryset = self.get_queryset() self._populate_kwargs() filters = {} for field_name, _ in self.lookup_fields: filters[field_name] = self.kwargs[field_name] obj = get_object_or_404(queryset, **filters) self.check_object_permissions(self.request, obj) return obj
mit
[ 3, 199, 3, 1898, 334, 67, 9, 6900, 9572, 13002, 199, 3, 3909, 1334, 710, 10697, 844, 334, 13965, 9, 199, 3, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 13965, 199, 3, 199, 646, 295, 199, 646, 2022, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 5914, 492, 366, 3941, 63, 21627, 199, 199, 504, 4618, 63, 4857, 492, 13667, 3617, 12, 2004, 12, 2455, 2193, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 421, 199, 533, 3091, 1084, 962, 607, 2398, 8229, 4256, 8, 785, 304, 272, 408, 272, 8232, 1006, 658, 10202, 64, 83, 315, 876, 63, 2117, 32005, 12, 465, 2985, 2811, 314, 272, 909, 370, 506, 6290, 701, 5305, 1337, 1006, 1504, 3451, 315, 2851, 14, 272, 408, 272, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 340, 2688, 8, 1113, 12, 283, 2861, 63, 3118, 735, 288, 1559, 14, 2861, 63, 3118, 342, 421, 199, 533, 7743, 1084, 14907, 4256, 8, 30192, 14, 14907, 4256, 304, 272, 408, 272, 21947, 6818, 2790, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 347, 5147, 63, 981, 8, 277, 12, 9146, 304, 267, 1559, 275, 9146, 14, 2117, 342, 267, 291, 14, 785, 275, 1559, 267, 340, 440, 1228, 8, 1113, 12, 769, 304, 288, 1559, 275, 359, 1113, 61, 267, 367, 1242, 315, 1559, 26, 288, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1053, 680, 1238, 288, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 4318, 1242, 14, 344, 12, 4318, 283, 2307, 297, 4318, 2022, 14, 4180, 8, 1053, 14, 3790, 4059, 421, 199, 533, 3091, 4699, 11173, 4256, 8, 785, 304, 272, 408, 272, 961, 20048, 5920, 1056, 666, 641, 510, 8078, 1056, 436, 2529, 376, 1125, 272, 1177, 340, 314, 2396, 365, 2701, 14, 961, 365, 2997, 465, 2005, 2032, 334, 1397, 461, 272, 658, 1548, 13, 6615, 10522, 1443, 2813, 314, 1056, 2396, 641, 4660, 12, 1314, 3955, 272, 12690, 370, 9512, 1678, 543, 949, 4493, 10585, 703, 272, 408, 272, 347, 1678, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 6672, 297, 756, 9, 436, 440, 1056, 14, 576, 26, 288, 372, 3091, 4699, 11173, 4256, 14, 1875, 63, 1310, 342, 267, 372, 1613, 8, 1944, 4699, 11173, 4256, 12, 291, 680, 873, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7417, 63, 873, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 1056, 14, 576, 26, 288, 372, 3091, 4699, 11173, 4256, 14, 1875, 63, 1310, 342, 267, 372, 1613, 8, 1944, 4699, 11173, 4256, 12, 291, 680, 6672, 63, 873, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 1852, 63, 1310, 8, 277, 304, 267, 408, 267, 3645, 642, 1083, 370, 1900, 282, 30262, 1125, 1177, 367, 314, 2701, 267, 510, 8078, 1056, 25781, 14, 267, 408, 267, 372, 7232, 8, 288, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 12, 288, 666, 29, 1751, 14, 13993, 63, 17073, 63, 3170, 63, 12801, 267, 776, 421, 199, 533, 7743, 1084, 4152, 1685, 4256, 8, 1944, 1084, 962, 607, 2398, 8229, 4256, 12, 1816, 3091, 4699, 11173, 4256, 12, 1816, 13667, 3617, 14, 4152, 1685, 4256, 304, 272, 408, 272, 21947, 6818, 6162, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 327, 6944, 8, 88, 335, 85, 304, 3709, 491, 456, 676, 723, 428, 379, 9828, 32031, 734, 626, 13369, 314, 2269, 574, 315, 272, 327, 3777, 876, 63, 2117, 365, 5965, 4634, 2465, 2952, 2337, 787, 2005, 272, 327, 3777, 23070, 4224, 2544, 642, 5759, 365, 31974, 14, 272, 327, 3777, 869, 374, 8744, 1990, 370, 3354, 314, 909, 314, 1642, 900, 272, 327, 3777, 658, 362, 63, 785, 11995, 1990, 2797, 14, 272, 347, 664, 63, 785, 8, 277, 304, 267, 1559, 275, 1613, 8, 4001, 1084, 4152, 1685, 4256, 12, 291, 680, 362, 63, 785, 342, 267, 291, 14, 6493, 63, 1113, 275, 2519, 8, 277, 12, 283, 6493, 63, 1113, 297, 1559, 14, 3790, 1012, 267, 372, 1559, 339, 347, 5147, 63, 873, 8, 277, 12, 9146, 304, 267, 1559, 275, 9146, 14, 2117, 342, 267, 291, 14, 785, 275, 1559, 398, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 680, 1238, 267, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 3521, 1559, 14, 344, 12, 3521, 2022, 14, 4180, 8, 277, 14, 6493, 63, 1113, 395, 3521, 2022, 14, 4180, 8, 1113, 14, 3790, 4059, 267, 2150, 291, 14, 6493, 63, 1113, 421, 199, 533, 7743, 1084, 14704, 1685, 4256, 8, 30192, 14, 14704, 1685, 4256, 304, 272, 408, 272, 21947, 6818, 20547, 4813, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 347, 5147, 63, 7237, 8, 277, 12, 1559, 304, 267, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 680, 1238, 267, 1559, 63, 344, 275, 1559, 14, 344, 267, 1559, 63, 1317, 275, 2022, 14, 4180, 8, 1113, 14, 3790, 1012, 267, 1613, 8, 4001, 1084, 14704, 1685, 4256, 12, 291, 680, 15795, 63, 7237, 8, 1113, 9, 267, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 3521, 1559, 63, 344, 12, 3521, 1559, 63, 1317, 12, 3521, 283, 2307, 358, 421, 199, 533, 7743, 1084, 1685, 4256, 8, 4001, 1084, 14907, 4256, 12, 2079, 7743, 1084, 4152, 1685, 4256, 12, 2079, 7743, 1084, 14704, 1685, 4256, 12, 2079, 13667, 3617, 14, 15310, 1685, 4256, 12, 2079, 13667, 3617, 14, 1296, 1685, 4256, 304, 272, 408, 272, 5822, 2455, 409, 626, 6571, 849, 658, 513, 342, 3559, 658, 14270, 342, 3559, 272, 543, 2050, 314, 4493, 315, 658, 981, 3559, 658, 873, 342, 3559, 658 ]
[ 199, 3, 1898, 334, 67, 9, 6900, 9572, 13002, 199, 3, 3909, 1334, 710, 10697, 844, 334, 13965, 9, 199, 3, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 13965, 199, 3, 199, 646, 295, 199, 646, 2022, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 5914, 492, 366, 3941, 63, 21627, 199, 199, 504, 4618, 63, 4857, 492, 13667, 3617, 12, 2004, 12, 2455, 2193, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 421, 199, 533, 3091, 1084, 962, 607, 2398, 8229, 4256, 8, 785, 304, 272, 408, 272, 8232, 1006, 658, 10202, 64, 83, 315, 876, 63, 2117, 32005, 12, 465, 2985, 2811, 314, 272, 909, 370, 506, 6290, 701, 5305, 1337, 1006, 1504, 3451, 315, 2851, 14, 272, 408, 272, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 340, 2688, 8, 1113, 12, 283, 2861, 63, 3118, 735, 288, 1559, 14, 2861, 63, 3118, 342, 421, 199, 533, 7743, 1084, 14907, 4256, 8, 30192, 14, 14907, 4256, 304, 272, 408, 272, 21947, 6818, 2790, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 347, 5147, 63, 981, 8, 277, 12, 9146, 304, 267, 1559, 275, 9146, 14, 2117, 342, 267, 291, 14, 785, 275, 1559, 267, 340, 440, 1228, 8, 1113, 12, 769, 304, 288, 1559, 275, 359, 1113, 61, 267, 367, 1242, 315, 1559, 26, 288, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1053, 680, 1238, 288, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 4318, 1242, 14, 344, 12, 4318, 283, 2307, 297, 4318, 2022, 14, 4180, 8, 1053, 14, 3790, 4059, 421, 199, 533, 3091, 4699, 11173, 4256, 8, 785, 304, 272, 408, 272, 961, 20048, 5920, 1056, 666, 641, 510, 8078, 1056, 436, 2529, 376, 1125, 272, 1177, 340, 314, 2396, 365, 2701, 14, 961, 365, 2997, 465, 2005, 2032, 334, 1397, 461, 272, 658, 1548, 13, 6615, 10522, 1443, 2813, 314, 1056, 2396, 641, 4660, 12, 1314, 3955, 272, 12690, 370, 9512, 1678, 543, 949, 4493, 10585, 703, 272, 408, 272, 347, 1678, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 2074, 14, 362, 360, 6672, 297, 756, 9, 436, 440, 1056, 14, 576, 26, 288, 372, 3091, 4699, 11173, 4256, 14, 1875, 63, 1310, 342, 267, 372, 1613, 8, 1944, 4699, 11173, 4256, 12, 291, 680, 873, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 7417, 63, 873, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 1056, 14, 576, 26, 288, 372, 3091, 4699, 11173, 4256, 14, 1875, 63, 1310, 342, 267, 372, 1613, 8, 1944, 4699, 11173, 4256, 12, 291, 680, 6672, 63, 873, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 1852, 63, 1310, 8, 277, 304, 267, 408, 267, 3645, 642, 1083, 370, 1900, 282, 30262, 1125, 1177, 367, 314, 2701, 267, 510, 8078, 1056, 25781, 14, 267, 408, 267, 372, 7232, 8, 288, 2004, 29, 1205, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 12, 288, 666, 29, 1751, 14, 13993, 63, 17073, 63, 3170, 63, 12801, 267, 776, 421, 199, 533, 7743, 1084, 4152, 1685, 4256, 8, 1944, 1084, 962, 607, 2398, 8229, 4256, 12, 1816, 3091, 4699, 11173, 4256, 12, 1816, 13667, 3617, 14, 4152, 1685, 4256, 304, 272, 408, 272, 21947, 6818, 6162, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 327, 6944, 8, 88, 335, 85, 304, 3709, 491, 456, 676, 723, 428, 379, 9828, 32031, 734, 626, 13369, 314, 2269, 574, 315, 272, 327, 3777, 876, 63, 2117, 365, 5965, 4634, 2465, 2952, 2337, 787, 2005, 272, 327, 3777, 23070, 4224, 2544, 642, 5759, 365, 31974, 14, 272, 327, 3777, 869, 374, 8744, 1990, 370, 3354, 314, 909, 314, 1642, 900, 272, 327, 3777, 658, 362, 63, 785, 11995, 1990, 2797, 14, 272, 347, 664, 63, 785, 8, 277, 304, 267, 1559, 275, 1613, 8, 4001, 1084, 4152, 1685, 4256, 12, 291, 680, 362, 63, 785, 342, 267, 291, 14, 6493, 63, 1113, 275, 2519, 8, 277, 12, 283, 6493, 63, 1113, 297, 1559, 14, 3790, 1012, 267, 372, 1559, 339, 347, 5147, 63, 873, 8, 277, 12, 9146, 304, 267, 1559, 275, 9146, 14, 2117, 342, 267, 291, 14, 785, 275, 1559, 398, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 680, 1238, 267, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 3521, 1559, 14, 344, 12, 3521, 2022, 14, 4180, 8, 277, 14, 6493, 63, 1113, 395, 3521, 2022, 14, 4180, 8, 1113, 14, 3790, 4059, 267, 2150, 291, 14, 6493, 63, 1113, 421, 199, 533, 7743, 1084, 14704, 1685, 4256, 8, 30192, 14, 14704, 1685, 4256, 304, 272, 408, 272, 21947, 6818, 20547, 4813, 1685, 4256, 626, 9610, 314, 1570, 14, 272, 408, 272, 347, 5147, 63, 7237, 8, 277, 12, 1559, 304, 267, 1402, 63, 354, 275, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1113, 680, 1238, 267, 1559, 63, 344, 275, 1559, 14, 344, 267, 1559, 63, 1317, 275, 2022, 14, 4180, 8, 1113, 14, 3790, 1012, 267, 1613, 8, 4001, 1084, 14704, 1685, 4256, 12, 291, 680, 15795, 63, 7237, 8, 1113, 9, 267, 291, 14, 1069, 14, 26027, 14, 525, 8, 1238, 63, 354, 12, 3521, 1559, 63, 344, 12, 3521, 1559, 63, 1317, 12, 3521, 283, 2307, 358, 421, 199, 533, 7743, 1084, 1685, 4256, 8, 4001, 1084, 14907, 4256, 12, 2079, 7743, 1084, 4152, 1685, 4256, 12, 2079, 7743, 1084, 14704, 1685, 4256, 12, 2079, 13667, 3617, 14, 15310, 1685, 4256, 12, 2079, 13667, 3617, 14, 1296, 1685, 4256, 304, 272, 408, 272, 5822, 2455, 409, 626, 6571, 849, 658, 513, 342, 3559, 658, 14270, 342, 3559, 272, 543, 2050, 314, 4493, 315, 658, 981, 3559, 658, 873, 342, 3559, 658, 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,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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 ]
nickleefly/youtube-dl
youtube_dl/extractor/nowtv.py
34
9503
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, determine_ext, int_or_none, parse_iso8601, parse_duration, remove_start, ) class NowTVBaseIE(InfoExtractor): _VIDEO_FIELDS = ( 'id', 'title', 'free', 'geoblocked', 'articleLong', 'articleShort', 'broadcastStartDate', 'seoUrl', 'duration', 'files', 'format.defaultImage169Format', 'format.defaultImage169Logo') def _extract_video(self, info, display_id=None): video_id = compat_str(info['id']) files = info['files'] if not files: if info.get('geoblocked', False): raise ExtractorError( 'Video %s is not available from your location due to geo restriction' % video_id, expected=True) if not info.get('free', True): raise ExtractorError( 'Video %s is not available for free' % video_id, expected=True) formats = [] for item in files['items']: if determine_ext(item['path']) != 'f4v': continue app, play_path = remove_start(item['path'], '/').split('/', 1) formats.append({ 'url': 'rtmpe://fms.rtl.de', 'app': app, 'play_path': 'mp4:%s' % play_path, 'ext': 'flv', 'page_url': 'http://rtlnow.rtl.de', 'player_url': 'http://cdn.static-fra.de/now/vodplayer.swf', 'tbr': int_or_none(item.get('bitrate')), }) self._sort_formats(formats) title = info['title'] description = info.get('articleLong') or info.get('articleShort') timestamp = parse_iso8601(info.get('broadcastStartDate'), ' ') duration = parse_duration(info.get('duration')) f = info.get('format', {}) thumbnail = f.get('defaultImage169Format') or f.get('defaultImage169Logo') return { 'id': video_id, 'display_id': display_id or info.get('seoUrl'), 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'duration': duration, 'formats': formats, } class NowTVIE(NowTVBaseIE): _WORKING = False _VALID_URL = r'https?://(?:www\.)?nowtv\.(?:de|at|ch)/(?:rtl|rtl2|rtlnitro|superrtl|ntv|vox)/(?P<show_id>[^/]+)/(?:(?:list/[^/]+|jahr/\d{4}/\d{1,2})/)?(?P<id>[^/]+)/(?:player|preview)' _TESTS = [{ # rtl 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/player', 'info_dict': { 'id': '203519', 'display_id': 'bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit', 'ext': 'flv', 'title': 'Inka Bause stellt die neuen Bauern vor', 'description': 'md5:e234e1ed6d63cf06be5c070442612e7e', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1432580700, 'upload_date': '20150525', 'duration': 2786, }, 'params': { # rtmp download 'skip_download': True, }, }, { # rtl2 'url': 'http://www.nowtv.de/rtl2/berlin-tag-nacht/berlin-tag-nacht-folge-934/player', 'info_dict': { 'id': '203481', 'display_id': 'berlin-tag-nacht/berlin-tag-nacht-folge-934', 'ext': 'flv', 'title': 'Berlin - Tag & Nacht (Folge 934)', 'description': 'md5:c85e88c2e36c552dfe63433bc9506dd0', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1432666800, 'upload_date': '20150526', 'duration': 2641, }, 'params': { # rtmp download 'skip_download': True, }, }, { # rtlnitro 'url': 'http://www.nowtv.de/rtlnitro/alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00/player', 'info_dict': { 'id': '165780', 'display_id': 'alarm-fuer-cobra-11-die-autobahnpolizei/hals-und-beinbruch-2014-08-23-21-10-00', 'ext': 'flv', 'title': 'Hals- und Beinbruch', 'description': 'md5:b50d248efffe244e6f56737f0911ca57', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1432415400, 'upload_date': '20150523', 'duration': 2742, }, 'params': { # rtmp download 'skip_download': True, }, }, { # superrtl 'url': 'http://www.nowtv.de/superrtl/medicopter-117/angst/player', 'info_dict': { 'id': '99205', 'display_id': 'medicopter-117/angst', 'ext': 'flv', 'title': 'Angst!', 'description': 'md5:30cbc4c0b73ec98bcd73c9f2a8c17c4e', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1222632900, 'upload_date': '20080928', 'duration': 3025, }, 'params': { # rtmp download 'skip_download': True, }, }, { # ntv 'url': 'http://www.nowtv.de/ntv/ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch/player', 'info_dict': { 'id': '203521', 'display_id': 'ratgeber-geld/thema-ua-der-erste-blick-die-apple-watch', 'ext': 'flv', 'title': 'Thema u.a.: Der erste Blick: Die Apple Watch', 'description': 'md5:4312b6c9d839ffe7d8caf03865a531af', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1432751700, 'upload_date': '20150527', 'duration': 1083, }, 'params': { # rtmp download 'skip_download': True, }, }, { # vox 'url': 'http://www.nowtv.de/vox/der-hundeprofi/buero-fall-chihuahua-joel/player', 'info_dict': { 'id': '128953', 'display_id': 'der-hundeprofi/buero-fall-chihuahua-joel', 'ext': 'flv', 'title': "Büro-Fall / Chihuahua 'Joel'", 'description': 'md5:e62cb6bf7c3cc669179d4f1eb279ad8d', 'thumbnail': 're:^https?://.*\.jpg$', 'timestamp': 1432408200, 'upload_date': '20150523', 'duration': 3092, }, 'params': { # rtmp download 'skip_download': True, }, }, { 'url': 'http://www.nowtv.de/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/preview', 'only_matching': True, }, { 'url': 'http://www.nowtv.at/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit/preview?return=/rtl/bauer-sucht-frau/die-neuen-bauern-und-eine-hochzeit', 'only_matching': True, }, { 'url': 'http://www.nowtv.de/rtl2/echtzeit/list/aktuell/schnelles-geld-am-ende-der-welt/player', 'only_matching': True, }, { 'url': 'http://www.nowtv.de/rtl2/zuhause-im-glueck/jahr/2015/11/eine-erschuetternde-diagnose/player', 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) display_id = '%s/%s' % (mobj.group('show_id'), mobj.group('id')) info = self._download_json( 'https://api.nowtv.de/v3/movies/%s?fields=%s' % (display_id, ','.join(self._VIDEO_FIELDS)), display_id) return self._extract_video(info, display_id) class NowTVListIE(NowTVBaseIE): _VALID_URL = r'https?://(?:www\.)?nowtv\.(?:de|at|ch)/(?:rtl|rtl2|rtlnitro|superrtl|ntv|vox)/(?P<show_id>[^/]+)/list/(?P<id>[^?/#&]+)$' _SHOW_FIELDS = ('title', ) _SEASON_FIELDS = ('id', 'headline', 'seoheadline', ) _TESTS = [{ 'url': 'http://www.nowtv.at/rtl/stern-tv/list/aktuell', 'info_dict': { 'id': '17006', 'title': 'stern TV - Aktuell', }, 'playlist_count': 1, }, { 'url': 'http://www.nowtv.at/rtl/das-supertalent/list/free-staffel-8', 'info_dict': { 'id': '20716', 'title': 'Das Supertalent - FREE Staffel 8', }, 'playlist_count': 14, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) show_id = mobj.group('show_id') season_id = mobj.group('id') fields = [] fields.extend(self._SHOW_FIELDS) fields.extend('formatTabs.%s' % field for field in self._SEASON_FIELDS) fields.extend( 'formatTabs.formatTabPages.container.movies.%s' % field for field in self._VIDEO_FIELDS) list_info = self._download_json( 'https://api.nowtv.de/v3/formats/seo?fields=%s&name=%s.php' % (','.join(fields), show_id), season_id) season = next( season for season in list_info['formatTabs']['items'] if season.get('seoheadline') == season_id) title = '%s - %s' % (list_info['title'], season['headline']) entries = [] for container in season['formatTabPages']['items']: for info in ((container.get('container') or {}).get('movies') or {}).get('items') or []: entries.append(self._extract_video(info)) return self.playlist_result( entries, compat_str(season.get('id') or season_id), title)
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 8434, 63, 495, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 6705, 63, 832, 12, 272, 1109, 63, 269, 63, 3592, 12, 272, 2198, 63, 4595, 15363, 12, 272, 2198, 63, 5553, 12, 272, 2813, 63, 928, 12, 199, 9, 421, 199, 533, 7356, 12764, 1563, 4332, 8, 18283, 304, 272, 485, 20142, 63, 12767, 275, 334, 267, 283, 344, 297, 283, 1213, 297, 283, 4624, 297, 283, 6721, 17726, 297, 283, 6934, 9551, 297, 283, 6934, 10039, 297, 267, 283, 10786, 3162, 2506, 297, 283, 261, 79, 6417, 297, 283, 5553, 297, 283, 1725, 297, 267, 283, 908, 14, 885, 3491, 10143, 3484, 297, 283, 908, 14, 885, 3491, 10143, 2445, 79, 358, 339, 347, 485, 5005, 63, 3722, 8, 277, 12, 2256, 12, 2929, 63, 344, 29, 403, 304, 267, 3991, 63, 344, 275, 8434, 63, 495, 8, 815, 459, 344, 1105, 398, 1584, 275, 2256, 459, 1725, 418, 267, 340, 440, 1584, 26, 288, 340, 2256, 14, 362, 360, 6721, 17726, 297, 756, 304, 355, 746, 19783, 8, 490, 283, 9166, 450, 83, 365, 440, 2808, 687, 2195, 2909, 7037, 370, 8509, 10588, 7, 450, 3991, 63, 344, 12, 490, 1420, 29, 549, 9, 288, 340, 440, 2256, 14, 362, 360, 4624, 297, 715, 304, 355, 746, 19783, 8, 490, 283, 9166, 450, 83, 365, 440, 2808, 367, 2867, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 6752, 275, 942, 267, 367, 1242, 315, 1584, 459, 1744, 2565, 288, 340, 6705, 63, 832, 8, 1053, 459, 515, 1105, 1137, 283, 70, 20, 86, 356, 355, 1980, 288, 1145, 12, 5232, 63, 515, 275, 2813, 63, 928, 8, 1053, 459, 515, 995, 1994, 1959, 1294, 10998, 413, 9, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 283, 29649, 69, 921, 70, 706, 14, 25011, 14, 271, 297, 355, 283, 571, 356, 1145, 12, 355, 283, 2802, 63, 515, 356, 283, 311, 20, 2689, 83, 7, 450, 5232, 63, 515, 12, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1606, 63, 633, 356, 283, 1014, 921, 25011, 2131, 14, 25011, 14, 271, 297, 355, 283, 6147, 63, 633, 356, 283, 1014, 921, 23982, 14, 1986, 13, 21844, 14, 271, 15, 2131, 15, 86, 364, 6147, 14, 20426, 297, 355, 283, 84, 3289, 356, 1109, 63, 269, 63, 3592, 8, 1053, 14, 362, 360, 24484, 3855, 288, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 2538, 275, 2256, 459, 1213, 418, 267, 1369, 275, 2256, 14, 362, 360, 6934, 9551, 358, 503, 2256, 14, 362, 360, 6934, 10039, 358, 267, 4913, 275, 2198, 63, 4595, 15363, 8, 815, 14, 362, 360, 10786, 3162, 2506, 659, 283, 5320, 267, 7373, 275, 2198, 63, 5553, 8, 815, 14, 362, 360, 5553, 1333, 398, 289, 275, 2256, 14, 362, 360, 908, 297, 5009, 267, 10062, 275, 289, 14, 362, 360, 885, 3491, 10143, 3484, 358, 503, 289, 14, 362, 360, 885, 3491, 10143, 2445, 79, 358, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 503, 2256, 14, 362, 360, 261, 79, 6417, 659, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 421, 199, 533, 7356, 12764, 4332, 8, 14351, 12764, 1563, 4332, 304, 272, 485, 8406, 1206, 275, 756, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 2131, 6993, 4537, 5169, 271, 92, 292, 92, 335, 2447, 5169, 25011, 92, 25011, 18, 92, 2591, 6066, 12691, 92, 1961, 1508, 5019, 92, 343, 86, 92, 2392, 88, 2447, 2229, 48, 28, 2384, 63, 344, 26906, 2447, 5169, 5169, 513, 15, 26285, 92, 3387, 6271, 6307, 68, 91, 20, 5995, 60, 68, 91, 17, 12, 18, 1552, 15, 5547, 2229, 48, 28, 344, 26906, 2447, 5169, 6147, 92, 7780, 3171, 339, 485, 7569, 275, 8910, 267, 327, 519, 5019, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 2131, 6993, 14, 271, 15, 25011, 15, 2470, 14262, 13, 10180, 84, 13, 21844, 85, 15, 15130, 13, 685, 85, 287, 13, 2470, 14262, 78, 13, 725, 13, 69, 1132, 13, 526, 335, 806, 390, 15, 6147, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1165, 1276, 1167, 297, 288, 283, 2918, 63, 344, 356, 283, 2470, 14262, 13, 10180, 84, 13, 21844, 85, 15, 15130, 13, 685, 85, 287, 13, 2470, 14262, 78, 13, 725, 13, 69, 1132, 13, 526, 335, 806, 390, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 607, 7351, 699, 65, 1180, 308, 9974, 84, 18833, 1279, 85, 287, 699, 3844, 27569, 373, 269, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 69, 5533, 69, 17, 379, 22, 68, 2766, 2177, 1690, 1235, 21, 67, 1780, 9111, 1479, 713, 69, 23, 69, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 4268, 288, 283, 3954, 356, 4329, 13288, 11369, 383, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13938, 821, 297, 288, 283, 5553, 356, 8087, 1184, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 519, 2791, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 519, 5019, 18, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 2131, 6993, 14, 271, 15, 25011, 18, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 13, 5900, 303, 13, 30391, 15, 6147, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1165, 1082, 2835, 297, 288, 283, 2918, 63, 344, 356, 283, 605, 472, 13, 1450, 13, 78, 1225, 84, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 13, 5900, 303, 13, 30391, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 8434, 63, 495, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 6705, 63, 832, 12, 272, 1109, 63, 269, 63, 3592, 12, 272, 2198, 63, 4595, 15363, 12, 272, 2198, 63, 5553, 12, 272, 2813, 63, 928, 12, 199, 9, 421, 199, 533, 7356, 12764, 1563, 4332, 8, 18283, 304, 272, 485, 20142, 63, 12767, 275, 334, 267, 283, 344, 297, 283, 1213, 297, 283, 4624, 297, 283, 6721, 17726, 297, 283, 6934, 9551, 297, 283, 6934, 10039, 297, 267, 283, 10786, 3162, 2506, 297, 283, 261, 79, 6417, 297, 283, 5553, 297, 283, 1725, 297, 267, 283, 908, 14, 885, 3491, 10143, 3484, 297, 283, 908, 14, 885, 3491, 10143, 2445, 79, 358, 339, 347, 485, 5005, 63, 3722, 8, 277, 12, 2256, 12, 2929, 63, 344, 29, 403, 304, 267, 3991, 63, 344, 275, 8434, 63, 495, 8, 815, 459, 344, 1105, 398, 1584, 275, 2256, 459, 1725, 418, 267, 340, 440, 1584, 26, 288, 340, 2256, 14, 362, 360, 6721, 17726, 297, 756, 304, 355, 746, 19783, 8, 490, 283, 9166, 450, 83, 365, 440, 2808, 687, 2195, 2909, 7037, 370, 8509, 10588, 7, 450, 3991, 63, 344, 12, 490, 1420, 29, 549, 9, 288, 340, 440, 2256, 14, 362, 360, 4624, 297, 715, 304, 355, 746, 19783, 8, 490, 283, 9166, 450, 83, 365, 440, 2808, 367, 2867, 7, 450, 3991, 63, 344, 12, 1420, 29, 549, 9, 398, 6752, 275, 942, 267, 367, 1242, 315, 1584, 459, 1744, 2565, 288, 340, 6705, 63, 832, 8, 1053, 459, 515, 1105, 1137, 283, 70, 20, 86, 356, 355, 1980, 288, 1145, 12, 5232, 63, 515, 275, 2813, 63, 928, 8, 1053, 459, 515, 995, 1994, 1959, 1294, 10998, 413, 9, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 283, 29649, 69, 921, 70, 706, 14, 25011, 14, 271, 297, 355, 283, 571, 356, 1145, 12, 355, 283, 2802, 63, 515, 356, 283, 311, 20, 2689, 83, 7, 450, 5232, 63, 515, 12, 355, 283, 832, 356, 283, 22753, 297, 355, 283, 1606, 63, 633, 356, 283, 1014, 921, 25011, 2131, 14, 25011, 14, 271, 297, 355, 283, 6147, 63, 633, 356, 283, 1014, 921, 23982, 14, 1986, 13, 21844, 14, 271, 15, 2131, 15, 86, 364, 6147, 14, 20426, 297, 355, 283, 84, 3289, 356, 1109, 63, 269, 63, 3592, 8, 1053, 14, 362, 360, 24484, 3855, 288, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 2538, 275, 2256, 459, 1213, 418, 267, 1369, 275, 2256, 14, 362, 360, 6934, 9551, 358, 503, 2256, 14, 362, 360, 6934, 10039, 358, 267, 4913, 275, 2198, 63, 4595, 15363, 8, 815, 14, 362, 360, 10786, 3162, 2506, 659, 283, 5320, 267, 7373, 275, 2198, 63, 5553, 8, 815, 14, 362, 360, 5553, 1333, 398, 289, 275, 2256, 14, 362, 360, 908, 297, 5009, 267, 10062, 275, 289, 14, 362, 360, 885, 3491, 10143, 3484, 358, 503, 289, 14, 362, 360, 885, 3491, 10143, 2445, 79, 358, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 503, 2256, 14, 362, 360, 261, 79, 6417, 659, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 421, 199, 533, 7356, 12764, 4332, 8, 14351, 12764, 1563, 4332, 304, 272, 485, 8406, 1206, 275, 756, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 2131, 6993, 4537, 5169, 271, 92, 292, 92, 335, 2447, 5169, 25011, 92, 25011, 18, 92, 2591, 6066, 12691, 92, 1961, 1508, 5019, 92, 343, 86, 92, 2392, 88, 2447, 2229, 48, 28, 2384, 63, 344, 26906, 2447, 5169, 5169, 513, 15, 26285, 92, 3387, 6271, 6307, 68, 91, 20, 5995, 60, 68, 91, 17, 12, 18, 1552, 15, 5547, 2229, 48, 28, 344, 26906, 2447, 5169, 6147, 92, 7780, 3171, 339, 485, 7569, 275, 8910, 267, 327, 519, 5019, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 2131, 6993, 14, 271, 15, 25011, 15, 2470, 14262, 13, 10180, 84, 13, 21844, 85, 15, 15130, 13, 685, 85, 287, 13, 2470, 14262, 78, 13, 725, 13, 69, 1132, 13, 526, 335, 806, 390, 15, 6147, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1165, 1276, 1167, 297, 288, 283, 2918, 63, 344, 356, 283, 2470, 14262, 13, 10180, 84, 13, 21844, 85, 15, 15130, 13, 685, 85, 287, 13, 2470, 14262, 78, 13, 725, 13, 69, 1132, 13, 526, 335, 806, 390, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 607, 7351, 699, 65, 1180, 308, 9974, 84, 18833, 1279, 85, 287, 699, 3844, 27569, 373, 269, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 69, 5533, 69, 17, 379, 22, 68, 2766, 2177, 1690, 1235, 21, 67, 1780, 9111, 1479, 713, 69, 23, 69, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 4268, 288, 283, 3954, 356, 4329, 13288, 11369, 383, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13938, 821, 297, 288, 283, 5553, 356, 8087, 1184, 12, 267, 1660, 267, 283, 1162, 356, 469, 288, 327, 519, 2791, 5235, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 1660, 469, 267, 327, 519, 5019, 18, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 2131, 6993, 14, 271, 15, 25011, 18, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 13, 5900, 303, 13, 30391, 15, 6147, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1165, 1082, 2835, 297, 288, 283, 2918, 63, 344, 356, 283, 605, 472, 13, 1450, 13, 78, 1225, 84, 15, 605, 472, 13, 1450, 13, 78, 1225, 84, 13, 5900, 303, 13, 30391, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 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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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 ]
20c/xbahn
xbahn/connection/memory.py
1
1497
from xbahn.connection import ( register, Poller as BasePoller, Receiver as BaseReceiver, Sender as BaseSender ) receivers = {} senders = {} class Poller(BasePoller): def __init__(self, name): super(Poller, self).__init__() self.name = name class Receiver(BaseReceiver): can_send = True def __init__(self, name): super(Receiver, self).__init__() receivers[name] = self self.name = name def send(self, data): for sender in senders.get(self.name, []): sender.receive(data, eventOrigin=self) def close(self): try: del senders[self.name] del receivers[self.name] except KeyError: pass class Sender(BaseSender): can_receive = True responder = True def __init__(self, name): super(Sender, self).__init__() if name not in senders: senders[name] = [] senders[name].append(self) self.name = name @property def receiver(self): return receivers.get(self.name) def send(self, data): self.receiver.receive(data, eventOrigin=self) def respond(self, data): self.receive(data, eventOrigin=self) def close(self): senders[self.name].remove(self) @register('memory') def sender(u): return Sender(u.hostname) @register('memory') def receiver(u): return Receiver(u.hostname) @register('memory') def poller(u): return Poller(u.hostname)
apache-2.0
[ 504, 671, 2470, 6164, 14, 2105, 492, 334, 272, 2274, 12, 272, 8467, 1435, 465, 3523, 21160, 12, 272, 799, 6594, 465, 3523, 21800, 12, 272, 428, 13747, 465, 3523, 28002, 199, 9, 199, 199, 29494, 275, 1052, 199, 2464, 7735, 275, 1052, 199, 199, 533, 8467, 1435, 8, 1563, 21160, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 21160, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 536, 199, 199, 533, 799, 6594, 8, 1563, 21800, 304, 272, 883, 63, 2254, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 21800, 12, 291, 2843, 826, 4533, 267, 13035, 83, 59, 354, 61, 275, 291, 267, 291, 14, 354, 275, 536, 339, 347, 3222, 8, 277, 12, 666, 304, 267, 367, 8904, 315, 4334, 7735, 14, 362, 8, 277, 14, 354, 12, 12319, 288, 8904, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 4002, 8, 277, 304, 267, 862, 26, 288, 2150, 4334, 7735, 59, 277, 14, 354, 61, 288, 2150, 13035, 83, 59, 277, 14, 354, 61, 267, 871, 4067, 26, 288, 986, 199, 199, 533, 428, 13747, 8, 1563, 28002, 304, 272, 883, 63, 9391, 275, 715, 272, 9163, 424, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 28002, 12, 291, 2843, 826, 4533, 267, 340, 536, 440, 315, 4334, 7735, 26, 288, 4334, 7735, 59, 354, 61, 275, 942, 267, 4334, 7735, 59, 354, 1055, 740, 8, 277, 9, 267, 291, 14, 354, 275, 536, 339, 768, 1829, 272, 347, 13035, 8, 277, 304, 267, 372, 13035, 83, 14, 362, 8, 277, 14, 354, 9, 339, 347, 3222, 8, 277, 12, 666, 304, 267, 291, 14, 10244, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 22722, 8, 277, 12, 666, 304, 267, 291, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 4002, 8, 277, 304, 267, 4334, 7735, 59, 277, 14, 354, 1055, 2168, 8, 277, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 8904, 8, 85, 304, 272, 372, 428, 13747, 8, 85, 14, 4269, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 13035, 8, 85, 304, 272, 372, 799, 6594, 8, 85, 14, 4269, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 28073, 8, 85, 304, 272, 372, 8467, 1435, 8, 85, 14, 4269, 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 ]
[ 671, 2470, 6164, 14, 2105, 492, 334, 272, 2274, 12, 272, 8467, 1435, 465, 3523, 21160, 12, 272, 799, 6594, 465, 3523, 21800, 12, 272, 428, 13747, 465, 3523, 28002, 199, 9, 199, 199, 29494, 275, 1052, 199, 2464, 7735, 275, 1052, 199, 199, 533, 8467, 1435, 8, 1563, 21160, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 21160, 12, 291, 2843, 826, 4533, 267, 291, 14, 354, 275, 536, 199, 199, 533, 799, 6594, 8, 1563, 21800, 304, 272, 883, 63, 2254, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 21800, 12, 291, 2843, 826, 4533, 267, 13035, 83, 59, 354, 61, 275, 291, 267, 291, 14, 354, 275, 536, 339, 347, 3222, 8, 277, 12, 666, 304, 267, 367, 8904, 315, 4334, 7735, 14, 362, 8, 277, 14, 354, 12, 12319, 288, 8904, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 4002, 8, 277, 304, 267, 862, 26, 288, 2150, 4334, 7735, 59, 277, 14, 354, 61, 288, 2150, 13035, 83, 59, 277, 14, 354, 61, 267, 871, 4067, 26, 288, 986, 199, 199, 533, 428, 13747, 8, 1563, 28002, 304, 272, 883, 63, 9391, 275, 715, 272, 9163, 424, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 1613, 8, 28002, 12, 291, 2843, 826, 4533, 267, 340, 536, 440, 315, 4334, 7735, 26, 288, 4334, 7735, 59, 354, 61, 275, 942, 267, 4334, 7735, 59, 354, 1055, 740, 8, 277, 9, 267, 291, 14, 354, 275, 536, 339, 768, 1829, 272, 347, 13035, 8, 277, 304, 267, 372, 13035, 83, 14, 362, 8, 277, 14, 354, 9, 339, 347, 3222, 8, 277, 12, 666, 304, 267, 291, 14, 10244, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 22722, 8, 277, 12, 666, 304, 267, 291, 14, 9391, 8, 576, 12, 1566, 12834, 29, 277, 9, 339, 347, 4002, 8, 277, 304, 267, 4334, 7735, 59, 277, 14, 354, 1055, 2168, 8, 277, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 8904, 8, 85, 304, 272, 372, 428, 13747, 8, 85, 14, 4269, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 13035, 8, 85, 304, 272, 372, 799, 6594, 8, 85, 14, 4269, 9, 199, 199, 32, 2683, 360, 4844, 358, 199, 318, 28073, 8, 85, 304, 272, 372, 8467, 1435, 8, 85, 14, 4269, 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, 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 ]
mtholder/bootstrap-open-tree-software
open_tree_env.py
1
5325
#!/usr/bin/env python '''Wraps common operations on settings and environmental variables needed during build. ''' import os _DEF_OPEN_TREE_VERSION = '0.0.1' _build_env_var_list = ['OPEN_TREE_USER_SETTINGS_DIR', 'OPEN_TREE_INSTALL_DIR', 'OPEN_TREE_VERSION', 'OPEN_TREE_BIN_DIR', 'OPEN_TREE_LIB_DIR', 'OPEN_TREE_PKG_SHARE', 'OPEN_TREE_TAXONOMY_DIR', 'OPEN_TREE_SOURCE_DIR', 'OPEN_TREE_DEPENDENCY_DIR', 'OPEN_TREE_BUILD_TOOL_PREFIX', 'OPEN_TREE_BUILD_TOOL_BIN_DIR', 'OPEN_TREE_DOWNLOAD_DEV_RESOURCE_CFG', 'OPEN_TREE_BUILD_TAG', ] def get_otol_build_env(var): '''Checks the environment for `var` and substitutes an appropriate default value if it is not found (or None if `var` is not recognized) ''' val = os.environ.get(var) if val is not None: return val if var == 'OPEN_TREE_USER_SETTINGS_DIR': return os.path.expanduser(os.path.join('~', '.open_tree')) if var == 'OPEN_TREE_INSTALL_DIR': return os.path.expanduser(os.path.join('~', 'open_tree_install')) if var == 'OPEN_TREE_BIN_DIR': install_dir = get_otol_build_env('OPEN_TREE_INSTALL_DIR') return os.path.join(install_dir, 'bin') if var == 'OPEN_TREE_LIB_DIR': install_dir = get_otol_build_env('OPEN_TREE_INSTALL_DIR') return os.path.join(install_dir, 'lib') if var == 'OPEN_TREE_VERSION': return _DEF_OPEN_TREE_VERSION if var == 'OPEN_TREE_PKG_SHARE': install_dir = get_otol_build_env('OPEN_TREE_INSTALL_DIR') version_str = get_otol_build_env('OPEN_TREE_VERSION') return os.path.join(install_dir, 'share', 'open-tree-' + version_str) if var == 'OPEN_TREE_TAXONOMY_DIR': share_dir = get_otol_build_env('OPEN_TREE_PKG_SHARE') return os.path.join(share_dir, 'taxonomy') if var == 'OPEN_TREE_SOURCE_DIR': d = os.path.abspath(get_otol_build_env('OPEN_TREE_DEPENDENCY_DIR')) p = os.path.dirname(d) if p: return os.path.abspath(p) return d if var == 'OPEN_TREE_DEPENDENCY_DIR': p = os.path.dirname(__file__) return os.path.abspath(p) if var == 'OPEN_TREE_BUILD_TOOL_PREFIX': p = get_otol_build_env('OPEN_TREE_DEPENDENCY_DIR') return os.path.join(p, 'tools') if var == 'OPEN_TREE_BUILD_TOOL_BIN_DIR': dep_dir = get_otol_build_env('OPEN_TREE_BUILD_TOOL_PREFIX') return os.path.join(dep_dir, 'bin') if var == 'OPEN_TREE_DOWNLOAD_DEV_RESOURCE_CFG': p = get_otol_build_env('OPEN_TREE_USER_SETTINGS_DIR') return os.path.join(p, 'download-dev-resource.cfg') if var == 'OPEN_TREE_BUILD_TAG': return 'release' return None def put_otol_build_env_into_env(): '''Assures that all of the OPEN_TREE_... variables are in the os.environ.''' for k in _build_env_var_list: v = get_otol_build_env(k) os.environ[k] = v def abbreviate_path(p): var_list = [] for a in _build_env_var_list: v = get_otol_build_env(a) var_list.append([a, v]) longest_prefix = '' longest_prefix_key = '' for s_el in var_list: s_v = s_el[1] if p.startswith(s_v) and len(s_v) > len(longest_prefix): longest_prefix = s_v longest_prefix_key = s_el[0] if longest_prefix: pref = longest_prefix_key suff = p[len(longest_prefix):] return '${%s}%s' % (pref, suff) return p if __name__ == '__main__': import sys v_list = sys.argv[1:] no_args = False if not v_list: no_args = True v_list = _build_env_var_list var_list = [] for a in _build_env_var_list: v = get_otol_build_env(a) var_list.append([a, v, []]) # attempt to find the tersest abbreviations if no_args: for n, el in enumerate(var_list): value = el[1] subst = el[2] longest_prefix = '' longest_prefix_key = '' for s_el in var_list[:n]: s_v = s_el[1] if value.startswith(s_v) and len(s_v) > len(longest_prefix): longest_prefix = s_v longest_prefix_key = s_el[0] if longest_prefix: subst = el[2] del subst[:] subst.append(longest_prefix_key) subst.append(value[len(longest_prefix):]) for var_entry in var_list: a, v = var_entry[:2] if v is None: sys.stdout.write('unset %s\n' % a ) else: subst = var_entry[2] if subst: v = '${%s}%s' % (subst[0], subst[1]) sys.stdout.write('export %s="%s"\n' % (a, v)) if no_args: sys.stdout.write('export PATH="${OPEN_TREE_BIN_DIR}:${OPEN_TREE_BUILD_TOOL_BIN_DIR}:${PATH}"\n') import platform if platform.system().lower() == 'darwin': lib_var = 'DYLD_LIBRARY_PATH' else: lib_var = 'LD_LIBRARY_PATH' sys.stdout.write('export %s="${OPEN_TREE_LIB_DIR}:${%s}"\n' % (lib_var, lib_var))
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 55, 8146, 2863, 5331, 641, 2202, 436, 3734, 279, 2860, 4346, 199, 27868, 1900, 14, 199, 2344, 199, 646, 747, 199, 63, 5638, 63, 9935, 63, 22841, 63, 4612, 275, 283, 16, 14, 16, 14, 17, 7, 199, 63, 1506, 63, 1813, 63, 1391, 63, 513, 275, 788, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 16811, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 4612, 297, 1993, 283, 9935, 63, 22841, 63, 9431, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 5617, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 18150, 63, 31220, 297, 1993, 283, 9935, 63, 22841, 63, 13110, 615, 7474, 57, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 10187, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 9431, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 24930, 63, 13260, 63, 14110, 63, 10118, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 6967, 297, 1993, 1622, 199, 199, 318, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 1391, 304, 272, 1449, 11834, 314, 3734, 367, 658, 1391, 64, 436, 10004, 3862, 376, 5827, 849, 272, 574, 340, 652, 365, 440, 1911, 334, 269, 488, 340, 658, 1391, 64, 365, 440, 18054, 9, 272, 1449, 272, 1139, 275, 747, 14, 2314, 14, 362, 8, 1391, 9, 272, 340, 1139, 365, 440, 488, 26, 267, 372, 1139, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 356, 267, 372, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 21114, 297, 1987, 1490, 63, 2350, 1333, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 16811, 63, 3022, 356, 267, 372, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 21114, 297, 283, 1490, 63, 2350, 63, 3174, 1333, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 9431, 63, 3022, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 1393, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 5617, 63, 3022, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 773, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 4612, 356, 267, 372, 485, 5638, 63, 9935, 63, 22841, 63, 4612, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 18150, 63, 31220, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 1015, 63, 495, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 4612, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 6251, 297, 283, 1490, 13, 2350, 15668, 435, 1015, 63, 495, 9, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 13110, 615, 7474, 57, 63, 3022, 356, 267, 8663, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 18150, 63, 31220, 358, 267, 372, 747, 14, 515, 14, 904, 8, 6251, 63, 694, 12, 283, 20243, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 10187, 63, 3022, 356, 267, 366, 275, 747, 14, 515, 14, 4832, 8, 362, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 1333, 267, 299, 275, 747, 14, 515, 14, 3475, 8, 68, 9, 267, 340, 299, 26, 288, 372, 747, 14, 515, 14, 4832, 8, 80, 9, 267, 372, 366, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 356, 267, 299, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 267, 372, 747, 14, 515, 14, 4832, 8, 80, 9, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 356, 267, 299, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 80, 12, 283, 2537, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 9431, 63, 3022, 356, 267, 2657, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 358, 267, 372, 747, 14, 515, 14, 904, 8, 2601, 63, 694, 12, 283, 1393, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 24930, 63, 13260, 63, 14110, 63, 10118, 356, 267, 299, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 80, 12, 283, 4249, 13, 2374, 13, 1927, 14, 4128, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 6967, 356, 267, 372, 283, 3221, 7, 272, 372, 488, 199, 199, 318, 5324, 63, 357, 393, 63, 1506, 63, 1813, 63, 9924, 63, 1813, 837, 272, 1449, 9824, 1482, 626, 1006, 402, 314, 24164, 63, 22841, 63, 1396, 2860, 787, 315, 314, 747, 14, 2314, 10595, 272, 367, 1022, 315, 485, 1506, 63, 1813, 63, 1391, 63, 513, 26, 267, 373, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 75, 9, 267, 747, 14, 2314, 59, 75, 61, 275, 373, 199, 199, 318, 2236, 23988, 323, 63, 515, 8, 80, 304, 272, 2729, 63, 513, 275, 942, 272, 367, 282, 315, 485, 1506, 63, 1813, 63, 1391, 63, 513, 26, 267, 373, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 65, 9, 267, 2729, 63, 513, 14, 740, 779, 65, 12, 373, 566, 272, 21303, 63, 1861, 275, 2125, 272, 21303, 63, 1861, 63, 498, 275, 2125 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 55, 8146, 2863, 5331, 641, 2202, 436, 3734, 279, 2860, 4346, 199, 27868, 1900, 14, 199, 2344, 199, 646, 747, 199, 63, 5638, 63, 9935, 63, 22841, 63, 4612, 275, 283, 16, 14, 16, 14, 17, 7, 199, 63, 1506, 63, 1813, 63, 1391, 63, 513, 275, 788, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 16811, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 4612, 297, 1993, 283, 9935, 63, 22841, 63, 9431, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 5617, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 18150, 63, 31220, 297, 1993, 283, 9935, 63, 22841, 63, 13110, 615, 7474, 57, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 10187, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 9431, 63, 3022, 297, 1993, 283, 9935, 63, 22841, 63, 24930, 63, 13260, 63, 14110, 63, 10118, 297, 1993, 283, 9935, 63, 22841, 63, 8248, 63, 6967, 297, 1993, 1622, 199, 199, 318, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 1391, 304, 272, 1449, 11834, 314, 3734, 367, 658, 1391, 64, 436, 10004, 3862, 376, 5827, 849, 272, 574, 340, 652, 365, 440, 1911, 334, 269, 488, 340, 658, 1391, 64, 365, 440, 18054, 9, 272, 1449, 272, 1139, 275, 747, 14, 2314, 14, 362, 8, 1391, 9, 272, 340, 1139, 365, 440, 488, 26, 267, 372, 1139, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 356, 267, 372, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 21114, 297, 1987, 1490, 63, 2350, 1333, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 16811, 63, 3022, 356, 267, 372, 747, 14, 515, 14, 12131, 8, 736, 14, 515, 14, 904, 21114, 297, 283, 1490, 63, 2350, 63, 3174, 1333, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 9431, 63, 3022, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 1393, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 5617, 63, 3022, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 773, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 4612, 356, 267, 372, 485, 5638, 63, 9935, 63, 22841, 63, 4612, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 18150, 63, 31220, 356, 267, 3907, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 16811, 63, 3022, 358, 267, 1015, 63, 495, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 4612, 358, 267, 372, 747, 14, 515, 14, 904, 8, 3174, 63, 694, 12, 283, 6251, 297, 283, 1490, 13, 2350, 15668, 435, 1015, 63, 495, 9, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 13110, 615, 7474, 57, 63, 3022, 356, 267, 8663, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 18150, 63, 31220, 358, 267, 372, 747, 14, 515, 14, 904, 8, 6251, 63, 694, 12, 283, 20243, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 10187, 63, 3022, 356, 267, 366, 275, 747, 14, 515, 14, 4832, 8, 362, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 1333, 267, 299, 275, 747, 14, 515, 14, 3475, 8, 68, 9, 267, 340, 299, 26, 288, 372, 747, 14, 515, 14, 4832, 8, 80, 9, 267, 372, 366, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 356, 267, 299, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 267, 372, 747, 14, 515, 14, 4832, 8, 80, 9, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 356, 267, 299, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 25743, 17059, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 80, 12, 283, 2537, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 9431, 63, 3022, 356, 267, 2657, 63, 694, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 8248, 63, 9731, 63, 6351, 358, 267, 372, 747, 14, 515, 14, 904, 8, 2601, 63, 694, 12, 283, 1393, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 24930, 63, 13260, 63, 14110, 63, 10118, 356, 267, 299, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 360, 9935, 63, 22841, 63, 3791, 63, 13931, 63, 3022, 358, 267, 372, 747, 14, 515, 14, 904, 8, 80, 12, 283, 4249, 13, 2374, 13, 1927, 14, 4128, 358, 272, 340, 2729, 508, 283, 9935, 63, 22841, 63, 8248, 63, 6967, 356, 267, 372, 283, 3221, 7, 272, 372, 488, 199, 199, 318, 5324, 63, 357, 393, 63, 1506, 63, 1813, 63, 9924, 63, 1813, 837, 272, 1449, 9824, 1482, 626, 1006, 402, 314, 24164, 63, 22841, 63, 1396, 2860, 787, 315, 314, 747, 14, 2314, 10595, 272, 367, 1022, 315, 485, 1506, 63, 1813, 63, 1391, 63, 513, 26, 267, 373, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 75, 9, 267, 747, 14, 2314, 59, 75, 61, 275, 373, 199, 199, 318, 2236, 23988, 323, 63, 515, 8, 80, 304, 272, 2729, 63, 513, 275, 942, 272, 367, 282, 315, 485, 1506, 63, 1813, 63, 1391, 63, 513, 26, 267, 373, 275, 664, 63, 357, 393, 63, 1506, 63, 1813, 8, 65, 9, 267, 2729, 63, 513, 14, 740, 779, 65, 12, 373, 566, 272, 21303, 63, 1861, 275, 2125, 272, 21303, 63, 1861, 63, 498, 275, 2125, 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, 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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 ]
zhujzhuo/openstack-trove
trove/guestagent/db/models.py
4
16889
# Copyright (c) 2011 OpenStack Foundation # 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. import re import string import netaddr from trove.common import cfg from trove.common.i18n import _ CONF = cfg.CONF class Base(object): def serialize(self): return self.__dict__ def deserialize(self, o): self.__dict__ = o class MySQLDatabase(Base): """Represents a Database and its properties.""" _ignore_dbs = CONF.ignore_dbs # Defaults __charset__ = "utf8" __collation__ = "utf8_general_ci" dbname = re.compile("^[A-Za-z0-9_-]+[\s\?\#\@]*[A-Za-z0-9_-]+$") # Complete list of acceptable values charset = {"big5": ["big5_chinese_ci", "big5_bin"], "dec8": ["dec8_swedish_ci", "dec8_bin"], "cp850": ["cp850_general_ci", "cp850_bin"], "hp8": ["hp8_english_ci", "hp8_bin"], "koi8r": ["koi8r_general_ci", "koi8r_bin"], "latin1": ["latin1_swedish_ci", "latin1_german1_ci", "latin1_danish_ci", "latin1_german2_ci", "latin1_bin", "latin1_general_ci", "latin1_general_cs", "latin1_spanish_ci"], "latin2": ["latin2_general_ci", "latin2_czech_cs", "latin2_hungarian_ci", "latin2_croatian_ci", "latin2_bin"], "swe7": ["swe7_swedish_ci", "swe7_bin"], "ascii": ["ascii_general_ci", "ascii_bin"], "ujis": ["ujis_japanese_ci", "ujis_bin"], "sjis": ["sjis_japanese_ci", "sjis_bin"], "hebrew": ["hebrew_general_ci", "hebrew_bin"], "tis620": ["tis620_thai_ci", "tis620_bin"], "euckr": ["euckr_korean_ci", "euckr_bin"], "koi8u": ["koi8u_general_ci", "koi8u_bin"], "gb2312": ["gb2312_chinese_ci", "gb2312_bin"], "greek": ["greek_general_ci", "greek_bin"], "cp1250": ["cp1250_general_ci", "cp1250_czech_cs", "cp1250_croatian_ci", "cp1250_bin", "cp1250_polish_ci"], "gbk": ["gbk_chinese_ci", "gbk_bin"], "latin5": ["latin5_turkish_ci", "latin5_bin"], "armscii8": ["armscii8_general_ci", "armscii8_bin"], "utf8": ["utf8_general_ci", "utf8_bin", "utf8_unicode_ci", "utf8_icelandic_ci", "utf8_latvian_ci", "utf8_romanian_ci", "utf8_slovenian_ci", "utf8_polish_ci", "utf8_estonian_ci", "utf8_spanish_ci", "utf8_swedish_ci", "utf8_turkish_ci", "utf8_czech_ci", "utf8_danish_ci", "utf8_lithuanian_ci", "utf8_slovak_ci", "utf8_spanish2_ci", "utf8_roman_ci", "utf8_persian_ci", "utf8_esperanto_ci", "utf8_hungarian_ci"], "ucs2": ["ucs2_general_ci", "ucs2_bin", "ucs2_unicode_ci", "ucs2_icelandic_ci", "ucs2_latvian_ci", "ucs2_romanian_ci", "ucs2_slovenian_ci", "ucs2_polish_ci", "ucs2_estonian_ci", "ucs2_spanish_ci", "ucs2_swedish_ci", "ucs2_turkish_ci", "ucs2_czech_ci", "ucs2_danish_ci", "ucs2_lithuanian_ci", "ucs2_slovak_ci", "ucs2_spanish2_ci", "ucs2_roman_ci", "ucs2_persian_ci", "ucs2_esperanto_ci", "ucs2_hungarian_ci"], "cp866": ["cp866_general_ci", "cp866_bin"], "keybcs2": ["keybcs2_general_ci", "keybcs2_bin"], "macce": ["macce_general_ci", "macce_bin"], "macroman": ["macroman_general_ci", "macroman_bin"], "cp852": ["cp852_general_ci", "cp852_bin"], "latin7": ["latin7_general_ci", "latin7_estonian_cs", "latin7_general_cs", "latin7_bin"], "cp1251": ["cp1251_general_ci", "cp1251_bulgarian_ci", "cp1251_ukrainian_ci", "cp1251_bin", "cp1251_general_cs"], "cp1256": ["cp1256_general_ci", "cp1256_bin"], "cp1257": ["cp1257_general_ci", "cp1257_lithuanian_ci", "cp1257_bin"], "binary": ["binary"], "geostd8": ["geostd8_general_ci", "geostd8_bin"], "cp932": ["cp932_japanese_ci", "cp932_bin"], "eucjpms": ["eucjpms_japanese_ci", "eucjpms_bin"]} collation = {"big5_chinese_ci": "big5", "big5_bin": "big5", "dec8_swedish_ci": "dec8", "dec8_bin": "dec8", "cp850_general_ci": "cp850", "cp850_bin": "cp850", "hp8_english_ci": "hp8", "hp8_bin": "hp8", "koi8r_general_ci": "koi8r", "koi8r_bin": "koi8r", "latin1_german1_ci": "latin1", "latin1_swedish_ci": "latin1", "latin1_danish_ci": "latin1", "latin1_german2_ci": "latin1", "latin1_bin": "latin1", "latin1_general_ci": "latin1", "latin1_general_cs": "latin1", "latin1_spanish_ci": "latin1", "latin2_czech_cs": "latin2", "latin2_general_ci": "latin2", "latin2_hungarian_ci": "latin2", "latin2_croatian_ci": "latin2", "latin2_bin": "latin2", "swe7_swedish_ci": "swe7", "swe7_bin": "swe7", "ascii_general_ci": "ascii", "ascii_bin": "ascii", "ujis_japanese_ci": "ujis", "ujis_bin": "ujis", "sjis_japanese_ci": "sjis", "sjis_bin": "sjis", "hebrew_general_ci": "hebrew", "hebrew_bin": "hebrew", "tis620_thai_ci": "tis620", "tis620_bin": "tis620", "euckr_korean_ci": "euckr", "euckr_bin": "euckr", "koi8u_general_ci": "koi8u", "koi8u_bin": "koi8u", "gb2312_chinese_ci": "gb2312", "gb2312_bin": "gb2312", "greek_general_ci": "greek", "greek_bin": "greek", "cp1250_general_ci": "cp1250", "cp1250_czech_cs": "cp1250", "cp1250_croatian_ci": "cp1250", "cp1250_bin": "cp1250", "cp1250_polish_ci": "cp1250", "gbk_chinese_ci": "gbk", "gbk_bin": "gbk", "latin5_turkish_ci": "latin5", "latin5_bin": "latin5", "armscii8_general_ci": "armscii8", "armscii8_bin": "armscii8", "utf8_general_ci": "utf8", "utf8_bin": "utf8", "utf8_unicode_ci": "utf8", "utf8_icelandic_ci": "utf8", "utf8_latvian_ci": "utf8", "utf8_romanian_ci": "utf8", "utf8_slovenian_ci": "utf8", "utf8_polish_ci": "utf8", "utf8_estonian_ci": "utf8", "utf8_spanish_ci": "utf8", "utf8_swedish_ci": "utf8", "utf8_turkish_ci": "utf8", "utf8_czech_ci": "utf8", "utf8_danish_ci": "utf8", "utf8_lithuanian_ci": "utf8", "utf8_slovak_ci": "utf8", "utf8_spanish2_ci": "utf8", "utf8_roman_ci": "utf8", "utf8_persian_ci": "utf8", "utf8_esperanto_ci": "utf8", "utf8_hungarian_ci": "utf8", "ucs2_general_ci": "ucs2", "ucs2_bin": "ucs2", "ucs2_unicode_ci": "ucs2", "ucs2_icelandic_ci": "ucs2", "ucs2_latvian_ci": "ucs2", "ucs2_romanian_ci": "ucs2", "ucs2_slovenian_ci": "ucs2", "ucs2_polish_ci": "ucs2", "ucs2_estonian_ci": "ucs2", "ucs2_spanish_ci": "ucs2", "ucs2_swedish_ci": "ucs2", "ucs2_turkish_ci": "ucs2", "ucs2_czech_ci": "ucs2", "ucs2_danish_ci": "ucs2", "ucs2_lithuanian_ci": "ucs2", "ucs2_slovak_ci": "ucs2", "ucs2_spanish2_ci": "ucs2", "ucs2_roman_ci": "ucs2", "ucs2_persian_ci": "ucs2", "ucs2_esperanto_ci": "ucs2", "ucs2_hungarian_ci": "ucs2", "cp866_general_ci": "cp866", "cp866_bin": "cp866", "keybcs2_general_ci": "keybcs2", "keybcs2_bin": "keybcs2", "macce_general_ci": "macce", "macce_bin": "macce", "macroman_general_ci": "macroman", "macroman_bin": "macroman", "cp852_general_ci": "cp852", "cp852_bin": "cp852", "latin7_estonian_cs": "latin7", "latin7_general_ci": "latin7", "latin7_general_cs": "latin7", "latin7_bin": "latin7", "cp1251_bulgarian_ci": "cp1251", "cp1251_ukrainian_ci": "cp1251", "cp1251_bin": "cp1251", "cp1251_general_ci": "cp1251", "cp1251_general_cs": "cp1251", "cp1256_general_ci": "cp1256", "cp1256_bin": "cp1256", "cp1257_lithuanian_ci": "cp1257", "cp1257_bin": "cp1257", "cp1257_general_ci": "cp1257", "binary": "binary", "geostd8_general_ci": "geostd8", "geostd8_bin": "geostd8", "cp932_japanese_ci": "cp932", "cp932_bin": "cp932", "eucjpms_japanese_ci": "eucjpms", "eucjpms_bin": "eucjpms"} def __init__(self): self._name = None self._collate = None self._character_set = None @property def name(self): return self._name def _is_valid(self, value): return value.lower() not in self._ignore_dbs @name.setter def name(self, value): self._name = value @property def collate(self): """Get the appropriate collate value.""" if not self._collate and not self._character_set: return self.__collation__ elif not self._collate: return self.charset[self._character_set][0] else: return self._collate @collate.setter def collate(self, value): """Validate the collation and set it.""" if not value: pass elif self._character_set: if value not in self.charset[self._character_set]: msg = (_("%(val)s not a valid collation for charset %(char)s.") % {'val': value, 'char': self._character_set}) raise ValueError(msg) self._collate = value else: if value not in self.collation: raise ValueError(_("'%s' not a valid collation.") % value) self._collate = value self._character_set = self.collation[value] @property def character_set(self): """Get the appropriate character set value.""" if not self._character_set: return self.__charset__ else: return self._character_set @character_set.setter def character_set(self, value): """Validate the character set and set it.""" if not value: pass elif not value in self.charset: raise ValueError(_("'%s' not a valid character set.") % value) else: self._character_set = value class ValidatedMySQLDatabase(MySQLDatabase): @MySQLDatabase.name.setter def name(self, value): if any([not value, not self._is_valid(value), not self.dbname.match(value), string.find("%r" % value, "\\") != -1]): raise ValueError(_("'%s' is not a valid database name.") % value) elif len(value) > 64: msg = _("Database name '%s' is too long. Max length = 64.") raise ValueError(msg % value) else: self._name = value class MySQLUser(Base): """Represents a MySQL User and its associated properties.""" not_supported_chars = re.compile("^\s|\s$|'|\"|;|`|,|/|\\\\") _ignore_users = CONF.ignore_users def __init__(self): self._name = None self._host = None self._password = None self._databases = [] def _is_valid(self, value): if (not value or self.not_supported_chars.search(value) or string.find("%r" % value, "\\") != -1): return False else: return True def _is_valid_user_name(self, value): if (self._is_valid(value) and value.lower() not in self._ignore_users): return True return False def _is_valid_host_name(self, value): if value in [None, "%"]: # % is MySQL shorthand for "everywhere". Always permitted. # Null host defaults to % anyway. return True if CONF.hostname_require_valid_ip: try: # '%' works as a MySQL wildcard, but it is not a valid # part of an IPAddress netaddr.IPAddress(value.replace('%', '1')) except (ValueError, netaddr.AddrFormatError): return False else: return True else: # If it wasn't required, anything else goes. return True @property def name(self): return self._name @name.setter def name(self, value): if not self._is_valid_user_name(value): raise ValueError(_("'%s' is not a valid user name.") % value) elif len(value) > 16: raise ValueError(_("User name '%s' is too long. Max length = 16.") % value) else: self._name = value @property def password(self): return self._password @password.setter def password(self, value): if not self._is_valid(value): raise ValueError(_("'%s' is not a valid password.") % value) else: self._password = value @property def databases(self): return self._databases @databases.setter def databases(self, value): mydb = ValidatedMySQLDatabase() mydb.name = value self._databases.append(mydb.serialize()) @property def host(self): if self._host is None: return '%' return self._host @host.setter def host(self, value): if not self._is_valid_host_name(value): raise ValueError(_("'%s' is not a valid hostname.") % value) else: self._host = value class RootUser(MySQLUser): """Overrides _ignore_users from the MySQLUser class.""" _ignore_users = []
apache-2.0
[ 3, 1898, 334, 67, 9, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 1059, 199, 199, 646, 25798, 199, 199, 504, 307, 11750, 14, 2330, 492, 4810, 199, 504, 307, 11750, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 533, 3523, 8, 785, 304, 272, 347, 8437, 8, 277, 304, 267, 372, 291, 855, 807, 363, 339, 347, 22920, 8, 277, 12, 312, 304, 267, 291, 855, 807, 363, 275, 312, 421, 199, 533, 11200, 7243, 8, 1563, 304, 272, 408, 18089, 282, 8692, 436, 2399, 4382, 1041, 339, 485, 4247, 63, 30764, 275, 6392, 14, 4247, 63, 30764, 339, 327, 7827, 272, 636, 6043, 363, 275, 298, 1624, 24, 2, 272, 636, 761, 2212, 363, 275, 298, 1624, 24, 63, 10706, 63, 559, 2, 272, 21842, 275, 295, 14, 2014, 18523, 59, 33, 13, 13163, 13, 90, 16, 13, 25, 63, 20253, 7023, 83, 60, 8995, 20262, 32, 3672, 59, 33, 13, 13163, 13, 90, 16, 13, 25, 63, 20253, 22550, 339, 327, 28393, 769, 402, 14712, 1338, 272, 5960, 275, 2420, 5076, 21, 582, 2097, 5076, 21, 63, 4419, 261, 63, 559, 401, 298, 5076, 21, 63, 1393, 2255, 2049, 298, 7778, 24, 582, 2097, 7778, 24, 63, 83, 1129, 29159, 63, 559, 401, 298, 7778, 24, 63, 1393, 2255, 2049, 298, 1850, 21419, 582, 2097, 1850, 21419, 63, 10706, 63, 559, 401, 298, 1850, 21419, 63, 1393, 2255, 2049, 298, 12025, 24, 582, 2097, 12025, 24, 63, 17872, 63, 559, 401, 298, 12025, 24, 63, 1393, 2255, 2049, 298, 7697, 73, 24, 82, 582, 2097, 7697, 73, 24, 82, 63, 10706, 63, 559, 401, 298, 7697, 73, 24, 82, 63, 1393, 2255, 2049, 298, 10378, 17, 582, 2097, 10378, 17, 63, 83, 1129, 29159, 63, 559, 401, 2079, 298, 10378, 17, 63, 836, 1237, 17, 63, 559, 401, 2079, 298, 10378, 17, 63, 24863, 2453, 63, 559, 401, 2079, 298, 10378, 17, 63, 836, 1237, 18, 63, 559, 401, 2079, 298, 10378, 17, 63, 1393, 401, 2079, 298, 10378, 17, 63, 10706, 63, 559, 401, 2079, 298, 10378, 17, 63, 10706, 63, 1259, 401, 2079, 298, 10378, 17, 63, 3751, 2453, 63, 559, 2255, 2049, 298, 10378, 18, 582, 2097, 10378, 18, 63, 10706, 63, 559, 401, 2079, 298, 10378, 18, 63, 67, 806, 335, 63, 1259, 401, 2079, 298, 10378, 18, 63, 72, 25364, 63, 559, 401, 2079, 298, 10378, 18, 63, 67, 293, 2159, 290, 63, 559, 401, 2079, 298, 10378, 18, 63, 1393, 2255, 2049, 298, 83, 1129, 23, 582, 2097, 83, 1129, 23, 63, 83, 1129, 29159, 63, 559, 401, 298, 83, 1129, 23, 63, 1393, 2255, 2049, 298, 4371, 582, 2097, 4371, 63, 10706, 63, 559, 401, 298, 4371, 63, 1393, 2255, 2049, 298, 17189, 374, 582, 2097, 17189, 374, 63, 74, 30699, 63, 559, 401, 298, 17189, 374, 63, 1393, 2255, 2049, 298, 83, 18941, 582, 2097, 83, 18941, 63, 74, 30699, 63, 559, 401, 298, 83, 18941, 63, 1393, 2255, 2049, 298, 14557, 582, 2097, 14557, 63, 10706, 63, 559, 401, 298, 14557, 63, 1393, 2255, 2049, 298, 16753, 22085, 582, 2097, 16753, 22085, 63, 24825, 63, 559, 401, 298, 16753, 22085, 63, 1393, 2255, 2049, 298, 69, 10112, 82, 582, 2097, 69, 10112, 82, 63, 19496, 63, 559, 401, 298, 69, 10112, 82, 63, 1393, 2255, 2049, 298, 7697, 73, 24, 85, 582, 2097, 7697, 73, 24, 85, 63, 10706, 63, 559, 401, 298, 7697, 73, 24, 85, 63, 1393, 2255, 2049, 298, 4908, 16909, 582, 2097, 4908, 16909, 63, 4419, 261, 63, 559, 401, 298, 4908, 16909, 63, 1393, 2255, 2049, 298, 32007, 582, 2097, 32007, 63, 10706, 63, 559, 401, 298, 32007, 63, 1393, 2255, 2049, 298, 1850, 26572, 582, 2097, 1850, 26572, 63, 10706, 63, 559, 401, 2079, 298, 1850, 26572, 63, 67, 806, 335, 63, 1259, 401, 2079, 298, 1850, 26572, 63, 67, 293, 2159, 290, 63, 559, 401, 2079, 298, 1850, 26572, 63, 1393, 401, 2079, 298, 1850, 26572, 63, 555, 1891, 63, 559, 2255, 2049, 298, 4908, 75, 582, 2097, 4908, 75, 63, 4419, 261, 63, 559, 401, 298, 4908, 75, 63, 1393, 2255, 2049, 298, 10378, 21, 582, 2097, 10378, 21, 63, 16218, 75, 2453, 63, 559, 401, 298, 10378, 21, 63, 1393, 2255, 2049, 298, 5362, 551, 5908, 24, 582, 2097, 5362, 551, 5908, 24, 63, 10706, 63, 559, 401, 298, 5362, 551, 5908, 24, 63, 1393, 2255, 2049, 298, 1624, 24, 582, 2097, 1624, 24, 63, 10706, 63, 559, 401, 717, 298, 1624, 24, 63, 1393, 401, 717, 298, 1624, 24, 63, 2975, 63, 559, 401, 717, 298, 1624, 24, 63, 1885, 1502, 5000, 63, 559, 401, 717, 298, 1624, 24, 63, 4452, 433, 290, 63, 559, 401, 717, 298, 1624, 24, 63, 20971, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 83, 320, 1856, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 555, 1891, 63, 559, 401, 717, 298, 1624, 24, 63, 597, 265, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 3751, 2453, 63, 559, 401, 717, 298, 1624, 24, 63, 83, 1129, 29159, 63, 559, 401, 717, 298, 1624, 24, 63, 16218, 75, 2453, 63, 559, 401, 717, 298, 1624, 24, 63, 67, 806, 335, 63, 559, 401, 717, 298, 1624, 24, 63 ]
[ 1898, 334, 67, 9, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 1059, 199, 199, 646, 25798, 199, 199, 504, 307, 11750, 14, 2330, 492, 4810, 199, 504, 307, 11750, 14, 2330, 14, 73, 1085, 78, 492, 485, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 533, 3523, 8, 785, 304, 272, 347, 8437, 8, 277, 304, 267, 372, 291, 855, 807, 363, 339, 347, 22920, 8, 277, 12, 312, 304, 267, 291, 855, 807, 363, 275, 312, 421, 199, 533, 11200, 7243, 8, 1563, 304, 272, 408, 18089, 282, 8692, 436, 2399, 4382, 1041, 339, 485, 4247, 63, 30764, 275, 6392, 14, 4247, 63, 30764, 339, 327, 7827, 272, 636, 6043, 363, 275, 298, 1624, 24, 2, 272, 636, 761, 2212, 363, 275, 298, 1624, 24, 63, 10706, 63, 559, 2, 272, 21842, 275, 295, 14, 2014, 18523, 59, 33, 13, 13163, 13, 90, 16, 13, 25, 63, 20253, 7023, 83, 60, 8995, 20262, 32, 3672, 59, 33, 13, 13163, 13, 90, 16, 13, 25, 63, 20253, 22550, 339, 327, 28393, 769, 402, 14712, 1338, 272, 5960, 275, 2420, 5076, 21, 582, 2097, 5076, 21, 63, 4419, 261, 63, 559, 401, 298, 5076, 21, 63, 1393, 2255, 2049, 298, 7778, 24, 582, 2097, 7778, 24, 63, 83, 1129, 29159, 63, 559, 401, 298, 7778, 24, 63, 1393, 2255, 2049, 298, 1850, 21419, 582, 2097, 1850, 21419, 63, 10706, 63, 559, 401, 298, 1850, 21419, 63, 1393, 2255, 2049, 298, 12025, 24, 582, 2097, 12025, 24, 63, 17872, 63, 559, 401, 298, 12025, 24, 63, 1393, 2255, 2049, 298, 7697, 73, 24, 82, 582, 2097, 7697, 73, 24, 82, 63, 10706, 63, 559, 401, 298, 7697, 73, 24, 82, 63, 1393, 2255, 2049, 298, 10378, 17, 582, 2097, 10378, 17, 63, 83, 1129, 29159, 63, 559, 401, 2079, 298, 10378, 17, 63, 836, 1237, 17, 63, 559, 401, 2079, 298, 10378, 17, 63, 24863, 2453, 63, 559, 401, 2079, 298, 10378, 17, 63, 836, 1237, 18, 63, 559, 401, 2079, 298, 10378, 17, 63, 1393, 401, 2079, 298, 10378, 17, 63, 10706, 63, 559, 401, 2079, 298, 10378, 17, 63, 10706, 63, 1259, 401, 2079, 298, 10378, 17, 63, 3751, 2453, 63, 559, 2255, 2049, 298, 10378, 18, 582, 2097, 10378, 18, 63, 10706, 63, 559, 401, 2079, 298, 10378, 18, 63, 67, 806, 335, 63, 1259, 401, 2079, 298, 10378, 18, 63, 72, 25364, 63, 559, 401, 2079, 298, 10378, 18, 63, 67, 293, 2159, 290, 63, 559, 401, 2079, 298, 10378, 18, 63, 1393, 2255, 2049, 298, 83, 1129, 23, 582, 2097, 83, 1129, 23, 63, 83, 1129, 29159, 63, 559, 401, 298, 83, 1129, 23, 63, 1393, 2255, 2049, 298, 4371, 582, 2097, 4371, 63, 10706, 63, 559, 401, 298, 4371, 63, 1393, 2255, 2049, 298, 17189, 374, 582, 2097, 17189, 374, 63, 74, 30699, 63, 559, 401, 298, 17189, 374, 63, 1393, 2255, 2049, 298, 83, 18941, 582, 2097, 83, 18941, 63, 74, 30699, 63, 559, 401, 298, 83, 18941, 63, 1393, 2255, 2049, 298, 14557, 582, 2097, 14557, 63, 10706, 63, 559, 401, 298, 14557, 63, 1393, 2255, 2049, 298, 16753, 22085, 582, 2097, 16753, 22085, 63, 24825, 63, 559, 401, 298, 16753, 22085, 63, 1393, 2255, 2049, 298, 69, 10112, 82, 582, 2097, 69, 10112, 82, 63, 19496, 63, 559, 401, 298, 69, 10112, 82, 63, 1393, 2255, 2049, 298, 7697, 73, 24, 85, 582, 2097, 7697, 73, 24, 85, 63, 10706, 63, 559, 401, 298, 7697, 73, 24, 85, 63, 1393, 2255, 2049, 298, 4908, 16909, 582, 2097, 4908, 16909, 63, 4419, 261, 63, 559, 401, 298, 4908, 16909, 63, 1393, 2255, 2049, 298, 32007, 582, 2097, 32007, 63, 10706, 63, 559, 401, 298, 32007, 63, 1393, 2255, 2049, 298, 1850, 26572, 582, 2097, 1850, 26572, 63, 10706, 63, 559, 401, 2079, 298, 1850, 26572, 63, 67, 806, 335, 63, 1259, 401, 2079, 298, 1850, 26572, 63, 67, 293, 2159, 290, 63, 559, 401, 2079, 298, 1850, 26572, 63, 1393, 401, 2079, 298, 1850, 26572, 63, 555, 1891, 63, 559, 2255, 2049, 298, 4908, 75, 582, 2097, 4908, 75, 63, 4419, 261, 63, 559, 401, 298, 4908, 75, 63, 1393, 2255, 2049, 298, 10378, 21, 582, 2097, 10378, 21, 63, 16218, 75, 2453, 63, 559, 401, 298, 10378, 21, 63, 1393, 2255, 2049, 298, 5362, 551, 5908, 24, 582, 2097, 5362, 551, 5908, 24, 63, 10706, 63, 559, 401, 298, 5362, 551, 5908, 24, 63, 1393, 2255, 2049, 298, 1624, 24, 582, 2097, 1624, 24, 63, 10706, 63, 559, 401, 717, 298, 1624, 24, 63, 1393, 401, 717, 298, 1624, 24, 63, 2975, 63, 559, 401, 717, 298, 1624, 24, 63, 1885, 1502, 5000, 63, 559, 401, 717, 298, 1624, 24, 63, 4452, 433, 290, 63, 559, 401, 717, 298, 1624, 24, 63, 20971, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 83, 320, 1856, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 555, 1891, 63, 559, 401, 717, 298, 1624, 24, 63, 597, 265, 5653, 63, 559, 401, 717, 298, 1624, 24, 63, 3751, 2453, 63, 559, 401, 717, 298, 1624, 24, 63, 83, 1129, 29159, 63, 559, 401, 717, 298, 1624, 24, 63, 16218, 75, 2453, 63, 559, 401, 717, 298, 1624, 24, 63, 67, 806, 335, 63, 559, 401, 717, 298, 1624, 24, 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, 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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 ]
awkspace/ansible
lib/ansible/modules/storage/netapp/na_ontap_cifs_server.py
10
11343
#!/usr/bin/python """ this is cifs_server module (c) 2018, NetApp, 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 ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified' } DOCUMENTATION = ''' --- module: na_ontap_cifs_server short_description: NetApp ONTAP CIFS server configuration extends_documentation_fragment: - netapp.na_ontap version_added: '2.6' author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> description: - Creating / deleting and modifying the CIFS server . options: state: description: - Whether the specified cifs_server should exist or not. default: present choices: ['present', 'absent'] service_state: description: - CIFS Server Administrative Status. choices: ['stopped', 'started'] name: description: - Specifies the cifs_server name. required: true aliases: ['cifs_server_name'] admin_user_name: description: - Specifies the cifs server admin username. admin_password: description: - Specifies the cifs server admin password. domain: description: - The Fully Qualified Domain Name of the Windows Active Directory this CIFS server belongs to. workgroup: description: - The NetBIOS name of the domain or workgroup this CIFS server belongs to. ou: description: - The Organizational Unit (OU) within the Windows Active Directory this CIFS server belongs to. version_added: '2.7' force: type: bool description: - If this is set and a machine account with the same name as specified in 'cifs_server_name' exists in the Active Directory, it will be overwritten and reused. version_added: '2.7' vserver: description: - The name of the vserver to use. required: true ''' EXAMPLES = ''' - name: Create cifs_server na_ontap_cifs_server: state: present vserver: svm1 hostname: "{{ netapp_hostname }}" username: "{{ netapp_username }}" password: "{{ netapp_password }}" - name: Delete cifs_server na_ontap_cifs_server: state: absent cifs_server_name: data2 vserver: svm1 hostname: "{{ netapp_hostname }}" username: "{{ netapp_username }}" password: "{{ netapp_password }}" ''' RETURN = ''' ''' import traceback from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native import ansible.module_utils.netapp as netapp_utils HAS_NETAPP_LIB = netapp_utils.has_netapp_lib() class NetAppOntapcifsServer(object): """ object to describe cifs_server info """ def __init__(self): self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=['present', 'absent'], default='present'), service_state=dict(required=False, choices=['stopped', 'started']), name=dict(required=True, type='str', aliases=['cifs_server_name']), workgroup=dict(required=False, type='str', default=None), domain=dict(required=False, type='str'), admin_user_name=dict(required=False, type='str'), admin_password=dict(required=False, type='str', no_log=True), ou=dict(required=False, type='str'), force=dict(required=False, type='bool'), vserver=dict(required=True, type='str'), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) params = self.module.params # set up state variables self.state = params['state'] self.cifs_server_name = params['cifs_server_name'] self.workgroup = params['workgroup'] self.domain = params['domain'] self.vserver = params['vserver'] self.service_state = params['service_state'] self.admin_user_name = params['admin_user_name'] self.admin_password = params['admin_password'] self.ou = params['ou'] self.force = params['force'] if HAS_NETAPP_LIB is False: self.module.fail_json(msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=self.vserver) def get_cifs_server(self): """ Return details about the CIFS-server :param: name : Name of the name of the cifs_server :return: Details about the cifs_server. None if not found. :rtype: dict """ cifs_server_info = netapp_utils.zapi.NaElement('cifs-server-get-iter') cifs_server_attributes = netapp_utils.zapi.NaElement('cifs-server-config') cifs_server_attributes.add_new_child('cifs-server', self.cifs_server_name) query = netapp_utils.zapi.NaElement('query') query.add_child_elem(cifs_server_attributes) cifs_server_info.add_child_elem(query) result = self.server.invoke_successfully(cifs_server_info, True) return_value = None if result.get_child_by_name('num-records') and \ int(result.get_child_content('num-records')) >= 1: cifs_server_attributes = result.get_child_by_name('attributes-list').\ get_child_by_name('cifs-server-config') return_value = { 'cifs_server_name': self.cifs_server_name, 'administrative-status': cifs_server_attributes.get_child_content('administrative-status') } return return_value def create_cifs_server(self): """ calling zapi to create cifs_server """ options = {'cifs-server': self.cifs_server_name, 'administrative-status': 'up' if self.service_state == 'started' else 'down'} if self.workgroup is not None: options['workgroup'] = self.workgroup if self.domain is not None: options['domain'] = self.domain if self.admin_user_name is not None: options['admin-username'] = self.admin_user_name if self.admin_password is not None: options['admin-password'] = self.admin_password if self.ou is not None: options['organizational-unit'] = self.ou if self.force is not None: options['force-account-overwrite'] = str(self.force).lower() cifs_server_create = netapp_utils.zapi.NaElement.create_node_with_children( 'cifs-server-create', **options) try: self.server.invoke_successfully(cifs_server_create, enable_tunneling=True) except netapp_utils.zapi.NaApiError as exc: self.module.fail_json(msg='Error Creating cifs_server %s: %s' % (self.cifs_server_name, to_native(exc)), exception=traceback.format_exc()) def delete_cifs_server(self): """ calling zapi to create cifs_server """ if self.cifs_server_name == 'up': self.modify_cifs_server(admin_status='down') cifs_server_delete = netapp_utils.zapi.NaElement.create_node_with_children('cifs-server-delete') try: self.server.invoke_successfully(cifs_server_delete, enable_tunneling=True) except netapp_utils.zapi.NaApiError as exc: self.module.fail_json(msg='Error deleting cifs_server %s: %s' % (self.cifs_server_name, to_native(exc)), exception=traceback.format_exc()) def modify_cifs_server(self, admin_status): """ RModify the cifs_server. """ cifs_server_modify = netapp_utils.zapi.NaElement.create_node_with_children( 'cifs-server-modify', **{'cifs-server': self.cifs_server_name, 'administrative-status': admin_status, 'vserver': self.vserver}) try: self.server.invoke_successfully(cifs_server_modify, enable_tunneling=True) except netapp_utils.zapi.NaApiError as e: self.module.fail_json(msg='Error modifying cifs_server %s: %s' % (self.cifs_server_name, to_native(e)), exception=traceback.format_exc()) def start_cifs_server(self): """ RModify the cifs_server. """ cifs_server_modify = netapp_utils.zapi.NaElement.create_node_with_children( 'cifs-server-start') try: self.server.invoke_successfully(cifs_server_modify, enable_tunneling=True) except netapp_utils.zapi.NaApiError as e: self.module.fail_json(msg='Error modifying cifs_server %s: %s' % (self.cifs_server_name, to_native(e)), exception=traceback.format_exc()) def stop_cifs_server(self): """ RModify the cifs_server. """ cifs_server_modify = netapp_utils.zapi.NaElement.create_node_with_children( 'cifs-server-stop') try: self.server.invoke_successfully(cifs_server_modify, enable_tunneling=True) except netapp_utils.zapi.NaApiError as e: self.module.fail_json(msg='Error modifying cifs_server %s: %s' % (self.cifs_server_name, to_native(e)), exception=traceback.format_exc()) def apply(self): """ calling all cifs_server features """ changed = False cifs_server_exists = False netapp_utils.ems_log_event("na_ontap_cifs_server", self.server) cifs_server_detail = self.get_cifs_server() if cifs_server_detail: cifs_server_exists = True if self.state == 'present': administrative_status = cifs_server_detail['administrative-status'] if self.service_state == 'started' and administrative_status == 'down': changed = True if self.service_state == 'stopped' and administrative_status == 'up': changed = True else: # we will delete the CIFs server changed = True else: if self.state == 'present': changed = True if changed: if self.module.check_mode: pass else: if self.state == 'present': if not cifs_server_exists: self.create_cifs_server() elif self.service_state == 'stopped': self.stop_cifs_server() elif self.service_state == 'started': self.start_cifs_server() elif self.state == 'absent': self.delete_cifs_server() self.module.exit_json(changed=changed) def main(): cifs_server = NetAppOntapcifsServer() cifs_server.apply() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 642, 365, 286, 20985, 63, 1000, 859, 421, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 327, 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, 624, 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, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 2247, 8981, 7, 199, 93, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 199, 3612, 63, 1802, 26, 28076, 5258, 52, 1282, 445, 4656, 51, 1654, 2897, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 3540, 63, 1888, 439, 199, 1023, 63, 3270, 26, 283, 18, 14, 22, 7, 199, 2502, 26, 28076, 2622, 11682, 8593, 67, 1047, 73, 24, 647, 9, 665, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 30, 199, 199, 1802, 26, 272, 446, 20507, 1182, 13794, 436, 24662, 314, 445, 4656, 51, 1654, 1275, 199, 199, 1419, 26, 819, 1174, 26, 272, 1369, 26, 272, 446, 7480, 314, 2013, 286, 20985, 63, 1000, 1077, 2187, 503, 440, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 819, 2435, 63, 929, 26, 272, 1369, 26, 272, 446, 445, 4656, 51, 7146, 9516, 25124, 9795, 14, 272, 3415, 26, 788, 14661, 297, 283, 8924, 418, 819, 536, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 63, 1000, 536, 14, 272, 1415, 26, 2549, 272, 5481, 26, 788, 559, 2319, 63, 1000, 63, 354, 418, 819, 4628, 63, 751, 63, 354, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 1654, 4628, 3434, 14, 819, 4628, 63, 2060, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 1654, 4628, 2505, 14, 819, 2881, 26, 272, 1369, 26, 272, 446, 710, 481, 8525, 19933, 4541, 14061, 2812, 402, 314, 5417, 23241, 15191, 642, 445, 4656, 51, 1654, 15006, 370, 14, 819, 1736, 923, 26, 272, 1369, 26, 272, 446, 221, 710, 5365, 34, 13532, 536, 402, 314, 2881, 503, 1736, 923, 642, 445, 4656, 51, 1654, 15006, 370, 14, 819, 29934, 26, 272, 1369, 26, 272, 446, 710, 18863, 279, 12008, 334, 22050, 9, 4453, 314, 5417, 23241, 15191, 489, 642, 445, 4656, 51, 1654, 15006, 370, 14, 272, 1015, 63, 3270, 26, 283, 18, 14, 23, 7, 819, 3542, 26, 272, 730, 26, 2155, 272, 1369, 26, 272, 446, 982, 642, 365, 663, 436, 282, 6844, 2933, 543, 314, 2011, 536, 465, 489, 2013, 315, 283, 559, 2319, 63, 1000, 63, 354, 7, 3495, 315, 314, 23241, 15191, 12, 652, 489, 911, 506, 20200, 436, 24826, 14, 272, 1015, 63, 3270, 26, 283, 18, 14, 23, 7, 819, 32398, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 32398, 370, 675, 14, 272, 1415, 26, 2549, 199, 199, 2344, 199, 199, 8918, 275, 1449, 272, 446, 536, 26, 2790, 286, 20985, 63, 1000, 489, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 26, 267, 1174, 26, 3451, 267, 32398, 26, 23044, 17, 267, 6246, 26, 7370, 15742, 63, 4269, 7820, 267, 3434, 26, 7370, 15742, 63, 2473, 7820, 267, 2505, 26, 7370, 15742, 63, 2060, 7820, 339, 446, 536, 26, 8496, 286, 20985, 63, 1000, 489, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 26, 267, 1174, 26, 9552, 267, 286, 20985, 63, 1000, 63, 354, 26, 666, 18, 267, 32398, 26, 23044, 17, 267, 6246, 26, 7370, 15742, 63, 4269, 7820, 267, 3434, 26, 7370, 15742, 63, 2473, 7820, 267, 2505, 26, 7370, 15742, 63, 2060, 7820, 199, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2344, 199, 199, 646, 5190, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 7278, 7121, 63, 5617, 275, 15742, 63, 1208, 14, 1989, 63, 25830, 63, 773, 342, 421, 199, 533, 28076, 47, 343, 439, 559, 2319, 3120, 8, 785, 304, 272, 408, 272, 909, 370, 13743, 221, 286, 20985, 63, 1000, 2256, 272, 408, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 3540, 63, 1888, 439, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 288, 2435, 63, 929, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 14661, 297, 283, 8924, 3815, 288, 536, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 297, 5481, 2968, 559, 2319, 63, 1000, 63, 354, 3815, 288, 1736, 923, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 297, 849, 29, 403, 395, 288, 2881, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 4628, 63, 751, 63, 354, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 4628, 63, 2060, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 297, 949, 63, 793, 29, 549, 395, 288, 29934, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 3542, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 2245, 659, 288, 32398, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 1862, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 1862, 459, 929, 418, 267, 291, 14, 559, 2319, 63, 1000, 63, 354, 275, 1862, 459, 559, 2319, 63, 1000, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 642, 365, 286, 20985, 63, 1000, 859, 421, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 327, 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, 624, 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, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 2247, 8981, 7, 199, 93, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 199, 3612, 63, 1802, 26, 28076, 5258, 52, 1282, 445, 4656, 51, 1654, 2897, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 3540, 63, 1888, 439, 199, 1023, 63, 3270, 26, 283, 18, 14, 22, 7, 199, 2502, 26, 28076, 2622, 11682, 8593, 67, 1047, 73, 24, 647, 9, 665, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 30, 199, 199, 1802, 26, 272, 446, 20507, 1182, 13794, 436, 24662, 314, 445, 4656, 51, 1654, 1275, 199, 199, 1419, 26, 819, 1174, 26, 272, 1369, 26, 272, 446, 7480, 314, 2013, 286, 20985, 63, 1000, 1077, 2187, 503, 440, 14, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 819, 2435, 63, 929, 26, 272, 1369, 26, 272, 446, 445, 4656, 51, 7146, 9516, 25124, 9795, 14, 272, 3415, 26, 788, 14661, 297, 283, 8924, 418, 819, 536, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 63, 1000, 536, 14, 272, 1415, 26, 2549, 272, 5481, 26, 788, 559, 2319, 63, 1000, 63, 354, 418, 819, 4628, 63, 751, 63, 354, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 1654, 4628, 3434, 14, 819, 4628, 63, 2060, 26, 272, 1369, 26, 272, 446, 11015, 314, 286, 20985, 1654, 4628, 2505, 14, 819, 2881, 26, 272, 1369, 26, 272, 446, 710, 481, 8525, 19933, 4541, 14061, 2812, 402, 314, 5417, 23241, 15191, 642, 445, 4656, 51, 1654, 15006, 370, 14, 819, 1736, 923, 26, 272, 1369, 26, 272, 446, 221, 710, 5365, 34, 13532, 536, 402, 314, 2881, 503, 1736, 923, 642, 445, 4656, 51, 1654, 15006, 370, 14, 819, 29934, 26, 272, 1369, 26, 272, 446, 710, 18863, 279, 12008, 334, 22050, 9, 4453, 314, 5417, 23241, 15191, 489, 642, 445, 4656, 51, 1654, 15006, 370, 14, 272, 1015, 63, 3270, 26, 283, 18, 14, 23, 7, 819, 3542, 26, 272, 730, 26, 2155, 272, 1369, 26, 272, 446, 982, 642, 365, 663, 436, 282, 6844, 2933, 543, 314, 2011, 536, 465, 489, 2013, 315, 283, 559, 2319, 63, 1000, 63, 354, 7, 3495, 315, 314, 23241, 15191, 12, 652, 489, 911, 506, 20200, 436, 24826, 14, 272, 1015, 63, 3270, 26, 283, 18, 14, 23, 7, 819, 32398, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 32398, 370, 675, 14, 272, 1415, 26, 2549, 199, 199, 2344, 199, 199, 8918, 275, 1449, 272, 446, 536, 26, 2790, 286, 20985, 63, 1000, 489, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 26, 267, 1174, 26, 3451, 267, 32398, 26, 23044, 17, 267, 6246, 26, 7370, 15742, 63, 4269, 7820, 267, 3434, 26, 7370, 15742, 63, 2473, 7820, 267, 2505, 26, 7370, 15742, 63, 2060, 7820, 339, 446, 536, 26, 8496, 286, 20985, 63, 1000, 489, 11802, 63, 1888, 439, 63, 559, 2319, 63, 1000, 26, 267, 1174, 26, 9552, 267, 286, 20985, 63, 1000, 63, 354, 26, 666, 18, 267, 32398, 26, 23044, 17, 267, 6246, 26, 7370, 15742, 63, 4269, 7820, 267, 3434, 26, 7370, 15742, 63, 2473, 7820, 267, 2505, 26, 7370, 15742, 63, 2060, 7820, 199, 199, 2344, 199, 199, 9677, 275, 1449, 199, 2344, 199, 199, 646, 5190, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 7278, 7121, 63, 5617, 275, 15742, 63, 1208, 14, 1989, 63, 25830, 63, 773, 342, 421, 199, 533, 28076, 47, 343, 439, 559, 2319, 3120, 8, 785, 304, 272, 408, 272, 909, 370, 13743, 221, 286, 20985, 63, 1000, 2256, 272, 408, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 3540, 63, 1888, 439, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 849, 534, 1881, 659, 288, 2435, 63, 929, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 14661, 297, 283, 8924, 3815, 288, 536, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 297, 5481, 2968, 559, 2319, 63, 1000, 63, 354, 3815, 288, 1736, 923, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 297, 849, 29, 403, 395, 288, 2881, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 4628, 63, 751, 63, 354, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 4628, 63, 2060, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 297, 949, 63, 793, 29, 549, 395, 288, 29934, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 495, 659, 288, 3542, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 2245, 659, 288, 32398, 29, 807, 8, 2427, 29, 549, 12, 730, 534, 495, 659, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 1862, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 1862, 459, 929, 418, 267, 291, 14, 559, 2319, 63, 1000, 63, 354, 275, 1862, 459, 559, 2319, 63, 1000, 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, 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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 ]
ipramono/therejectedbot
oauth2client/contrib/_metadata.py
20
4477
# Copyright 2016 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Provides helper methods for talking to the Compute Engine metadata server. See https://cloud.google.com/compute/docs/metadata """ import datetime import json import httplib2 from six.moves import http_client from six.moves.urllib import parse as urlparse from oauth2client import _helpers from oauth2client import client from oauth2client import util METADATA_ROOT = 'http://metadata.google.internal/computeMetadata/v1/' METADATA_HEADERS = {'Metadata-Flavor': 'Google'} def get(http_request, path, root=METADATA_ROOT, recursive=None): """Fetch a resource from the metadata server. Args: path: A string indicating the resource to retrieve. For example, 'instance/service-accounts/defualt' http_request: A callable that matches the method signature of httplib2.Http.request. Used to make the request to the metadataserver. root: A string indicating the full path to the metadata server root. recursive: A boolean indicating whether to do a recursive query of metadata. See https://cloud.google.com/compute/docs/metadata#aggcontents Returns: A dictionary if the metadata server returns JSON, otherwise a string. Raises: httplib2.Httplib2Error if an error corrured while retrieving metadata. """ url = urlparse.urljoin(root, path) url = util._add_query_parameter(url, 'recursive', recursive) response, content = http_request( url, headers=METADATA_HEADERS ) if response.status == http_client.OK: decoded = _helpers._from_bytes(content) if response['content-type'] == 'application/json': return json.loads(decoded) else: return decoded else: raise httplib2.HttpLib2Error( 'Failed to retrieve {0} from the Google Compute Engine' 'metadata service. Response:\n{1}'.format(url, response)) def get_service_account_info(http_request, service_account='default'): """Get information about a service account from the metadata server. Args: service_account: An email specifying the service account for which to look up information. Default will be information for the "default" service account of the current compute engine instance. http_request: A callable that matches the method signature of httplib2.Http.request. Used to make the request to the metadata server. Returns: A dictionary with information about the specified service account, for example: { 'email': '...', 'scopes': ['scope', ...], 'aliases': ['default', '...'] } """ return get( http_request, 'instance/service-accounts/{0}/'.format(service_account), recursive=True) def get_token(http_request, service_account='default'): """Fetch an oauth token for the Args: service_account: An email specifying the service account this token should represent. Default will be a token for the "default" service account of the current compute engine instance. http_request: A callable that matches the method signature of httplib2.Http.request. Used to make the request to the metadataserver. Returns: A tuple of (access token, token expiration), where access token is the access token as a string and token expiration is a datetime object that indicates when the access token will expire. """ token_json = get( http_request, 'instance/service-accounts/{0}/token'.format(service_account)) token_expiry = client._UTCNOW() + datetime.timedelta( seconds=token_json['expires_in']) return token_json['access_token'], token_expiry
apache-2.0
[ 3, 1898, 7800, 4475, 3277, 14, 2900, 4481, 4644, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 17473, 5922, 3102, 367, 22811, 316, 370, 314, 8354, 12580, 3341, 1654, 14, 199, 199, 9295, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2343, 199, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 199, 646, 8809, 18, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 9725, 18, 1258, 492, 485, 7546, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 492, 4884, 421, 199, 8314, 63, 5441, 275, 283, 1014, 921, 2343, 14, 3098, 14, 4672, 15, 3357, 5142, 15, 86, 17, 4805, 199, 8314, 63, 21178, 275, 791, 5142, 13, 16739, 356, 283, 13266, 936, 421, 199, 318, 664, 8, 1014, 63, 1069, 12, 931, 12, 1738, 29, 8314, 63, 5441, 12, 9133, 29, 403, 304, 272, 408, 11135, 282, 2073, 687, 314, 3341, 1654, 14, 339, 3033, 26, 267, 931, 26, 437, 1059, 9297, 314, 2073, 370, 8044, 14, 2104, 2893, 12, 288, 283, 842, 15, 1364, 13, 8370, 15, 318, 1061, 84, 7, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1000, 14, 267, 1738, 26, 437, 1059, 9297, 314, 2615, 931, 370, 314, 3341, 1654, 1738, 14, 267, 9133, 26, 437, 5046, 9297, 3775, 370, 886, 282, 9133, 1827, 402, 288, 3341, 14, 1666, 288, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2343, 3, 13452, 4407, 339, 1803, 26, 267, 437, 2600, 340, 314, 3341, 1654, 2529, 4840, 12, 4257, 282, 1059, 14, 339, 6218, 26, 267, 8809, 18, 14, 5779, 773, 18, 547, 340, 376, 1125, 25948, 3297, 1830, 23812, 3341, 14, 272, 408, 272, 1166, 275, 7097, 14, 17755, 8, 1231, 12, 931, 9, 272, 1166, 275, 4884, 423, 525, 63, 1131, 63, 5329, 8, 633, 12, 283, 9931, 297, 9133, 9, 339, 1177, 12, 1564, 275, 1455, 63, 1069, 8, 267, 1166, 12, 267, 2323, 29, 8314, 63, 21178, 272, 776, 339, 340, 1177, 14, 1205, 508, 1455, 63, 1258, 14, 3593, 26, 267, 11203, 275, 485, 7546, 423, 504, 63, 2394, 8, 1317, 9, 267, 340, 1177, 459, 1317, 13, 466, 418, 508, 283, 3578, 15, 1001, 356, 288, 372, 2022, 14, 3640, 8, 16167, 9, 267, 587, 26, 288, 372, 11203, 272, 587, 26, 267, 746, 8809, 18, 14, 5779, 4728, 18, 547, 8, 288, 283, 4276, 370, 8044, 469, 16, 93, 687, 314, 4475, 8354, 12580, 7, 288, 283, 2343, 2435, 14, 7232, 3427, 78, 91, 17, 5285, 908, 8, 633, 12, 1177, 430, 421, 199, 318, 664, 63, 1364, 63, 2048, 63, 815, 8, 1014, 63, 1069, 12, 2435, 63, 2048, 534, 885, 735, 272, 408, 1002, 2556, 3595, 282, 2435, 2933, 687, 314, 3341, 1654, 14, 339, 3033, 26, 267, 2435, 63, 2048, 26, 1626, 3031, 9176, 314, 2435, 2933, 367, 1314, 370, 288, 3648, 1536, 2556, 14, 3758, 911, 506, 2556, 367, 314, 298, 885, 2, 288, 2435, 2933, 402, 314, 1453, 4526, 6869, 1256, 14, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1654, 14, 272, 1803, 26, 268, 437, 2600, 543, 2556, 3595, 314, 2013, 2435, 2933, 12, 268, 367, 2893, 26, 953, 469, 355, 283, 2123, 356, 283, 20833, 355, 283, 14129, 356, 788, 2645, 297, 2263, 467, 355, 283, 8602, 356, 788, 885, 297, 24352, 418, 288, 789, 272, 408, 272, 372, 664, 8, 267, 1455, 63, 1069, 12, 267, 283, 842, 15, 1364, 13, 8370, 5321, 16, 5995, 1370, 908, 8, 1364, 63, 2048, 395, 267, 9133, 29, 549, 9, 421, 199, 318, 664, 63, 1418, 8, 1014, 63, 1069, 12, 2435, 63, 2048, 534, 885, 735, 272, 408, 11135, 376, 9725, 1526, 367, 314, 339, 3033, 26, 267, 2435, 63, 2048, 26, 1626, 3031, 9176, 314, 2435, 2933, 642, 1526, 288, 1077, 2954, 14, 3758, 911, 506, 282, 1526, 367, 314, 298, 885, 2, 2435, 288, 2933, 402, 314, 1453, 4526, 6869, 1256, 14, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1000, 14, 339, 1803, 26, 268, 437, 2008, 402, 334, 2732, 1526, 12, 1526, 15399, 395, 2382, 2879, 1526, 365, 314, 268, 2879, 1526, 465, 282, 1059, 436, 1526, 15399, 365, 282, 2197, 909, 268, 626, 9126, 1380, 314, 2879, 1526, 911, 16667, 14, 272, 408, 272, 1526, 63, 1001, 275, 664, 8, 267, 1455, 63, 1069, 12, 267, 283, 842, 15, 1364, 13, 8370, 5321, 16, 5995, 1418, 1370, 908, 8, 1364, 63, 2048, 430, 272, 1526, 63, 16844, 275, 1890, 423, 11288, 14283, 342, 435, 2197, 14, 7473, 8, 267, 4696, 29, 1418, 63, 1001, 459, 12342, 63, 262, 1105, 272, 372, 1526, 63, 1001, 459, 2732, 63, 1418, 995, 1526, 63, 16844, 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 ]
[ 1898, 7800, 4475, 3277, 14, 2900, 4481, 4644, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 17473, 5922, 3102, 367, 22811, 316, 370, 314, 8354, 12580, 3341, 1654, 14, 199, 199, 9295, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2343, 199, 624, 199, 199, 646, 2197, 199, 646, 2022, 199, 199, 646, 8809, 18, 199, 504, 3816, 14, 4912, 492, 1455, 63, 1258, 199, 504, 3816, 14, 4912, 14, 4078, 492, 2198, 465, 7097, 199, 199, 504, 9725, 18, 1258, 492, 485, 7546, 199, 504, 9725, 18, 1258, 492, 1890, 199, 504, 9725, 18, 1258, 492, 4884, 421, 199, 8314, 63, 5441, 275, 283, 1014, 921, 2343, 14, 3098, 14, 4672, 15, 3357, 5142, 15, 86, 17, 4805, 199, 8314, 63, 21178, 275, 791, 5142, 13, 16739, 356, 283, 13266, 936, 421, 199, 318, 664, 8, 1014, 63, 1069, 12, 931, 12, 1738, 29, 8314, 63, 5441, 12, 9133, 29, 403, 304, 272, 408, 11135, 282, 2073, 687, 314, 3341, 1654, 14, 339, 3033, 26, 267, 931, 26, 437, 1059, 9297, 314, 2073, 370, 8044, 14, 2104, 2893, 12, 288, 283, 842, 15, 1364, 13, 8370, 15, 318, 1061, 84, 7, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1000, 14, 267, 1738, 26, 437, 1059, 9297, 314, 2615, 931, 370, 314, 3341, 1654, 1738, 14, 267, 9133, 26, 437, 5046, 9297, 3775, 370, 886, 282, 9133, 1827, 402, 288, 3341, 14, 1666, 288, 4178, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 2343, 3, 13452, 4407, 339, 1803, 26, 267, 437, 2600, 340, 314, 3341, 1654, 2529, 4840, 12, 4257, 282, 1059, 14, 339, 6218, 26, 267, 8809, 18, 14, 5779, 773, 18, 547, 340, 376, 1125, 25948, 3297, 1830, 23812, 3341, 14, 272, 408, 272, 1166, 275, 7097, 14, 17755, 8, 1231, 12, 931, 9, 272, 1166, 275, 4884, 423, 525, 63, 1131, 63, 5329, 8, 633, 12, 283, 9931, 297, 9133, 9, 339, 1177, 12, 1564, 275, 1455, 63, 1069, 8, 267, 1166, 12, 267, 2323, 29, 8314, 63, 21178, 272, 776, 339, 340, 1177, 14, 1205, 508, 1455, 63, 1258, 14, 3593, 26, 267, 11203, 275, 485, 7546, 423, 504, 63, 2394, 8, 1317, 9, 267, 340, 1177, 459, 1317, 13, 466, 418, 508, 283, 3578, 15, 1001, 356, 288, 372, 2022, 14, 3640, 8, 16167, 9, 267, 587, 26, 288, 372, 11203, 272, 587, 26, 267, 746, 8809, 18, 14, 5779, 4728, 18, 547, 8, 288, 283, 4276, 370, 8044, 469, 16, 93, 687, 314, 4475, 8354, 12580, 7, 288, 283, 2343, 2435, 14, 7232, 3427, 78, 91, 17, 5285, 908, 8, 633, 12, 1177, 430, 421, 199, 318, 664, 63, 1364, 63, 2048, 63, 815, 8, 1014, 63, 1069, 12, 2435, 63, 2048, 534, 885, 735, 272, 408, 1002, 2556, 3595, 282, 2435, 2933, 687, 314, 3341, 1654, 14, 339, 3033, 26, 267, 2435, 63, 2048, 26, 1626, 3031, 9176, 314, 2435, 2933, 367, 1314, 370, 288, 3648, 1536, 2556, 14, 3758, 911, 506, 2556, 367, 314, 298, 885, 2, 288, 2435, 2933, 402, 314, 1453, 4526, 6869, 1256, 14, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1654, 14, 272, 1803, 26, 268, 437, 2600, 543, 2556, 3595, 314, 2013, 2435, 2933, 12, 268, 367, 2893, 26, 953, 469, 355, 283, 2123, 356, 283, 20833, 355, 283, 14129, 356, 788, 2645, 297, 2263, 467, 355, 283, 8602, 356, 788, 885, 297, 24352, 418, 288, 789, 272, 408, 272, 372, 664, 8, 267, 1455, 63, 1069, 12, 267, 283, 842, 15, 1364, 13, 8370, 5321, 16, 5995, 1370, 908, 8, 1364, 63, 2048, 395, 267, 9133, 29, 549, 9, 421, 199, 318, 664, 63, 1418, 8, 1014, 63, 1069, 12, 2435, 63, 2048, 534, 885, 735, 272, 408, 11135, 376, 9725, 1526, 367, 314, 339, 3033, 26, 267, 2435, 63, 2048, 26, 1626, 3031, 9176, 314, 2435, 2933, 642, 1526, 288, 1077, 2954, 14, 3758, 911, 506, 282, 1526, 367, 314, 298, 885, 2, 2435, 288, 2933, 402, 314, 1453, 4526, 6869, 1256, 14, 267, 1455, 63, 1069, 26, 437, 4550, 626, 4450, 314, 1083, 288, 4955, 402, 8809, 18, 14, 5779, 14, 1069, 14, 8051, 370, 1852, 314, 1056, 370, 314, 288, 3341, 1000, 14, 339, 1803, 26, 268, 437, 2008, 402, 334, 2732, 1526, 12, 1526, 15399, 395, 2382, 2879, 1526, 365, 314, 268, 2879, 1526, 465, 282, 1059, 436, 1526, 15399, 365, 282, 2197, 909, 268, 626, 9126, 1380, 314, 2879, 1526, 911, 16667, 14, 272, 408, 272, 1526, 63, 1001, 275, 664, 8, 267, 1455, 63, 1069, 12, 267, 283, 842, 15, 1364, 13, 8370, 5321, 16, 5995, 1418, 1370, 908, 8, 1364, 63, 2048, 430, 272, 1526, 63, 16844, 275, 1890, 423, 11288, 14283, 342, 435, 2197, 14, 7473, 8, 267, 4696, 29, 1418, 63, 1001, 459, 12342, 63, 262, 1105, 272, 372, 1526, 63, 1001, 459, 2732, 63, 1418, 995, 1526, 63, 16844, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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_passwordless ~~~~~~~~~~~~~~~~~ Passwordless tests """ import time import pytest from flask import Flask from flask_security.core import UserMixin from flask_security.signals import login_instructions_sent from flask_security.utils import capture_passwordless_login_requests, string_types from utils import logout pytestmark = pytest.mark.passwordless() def test_trackable_flag(app, client, get_message): recorded = [] @login_instructions_sent.connect_via(app) def on_instructions_sent(app, user, login_token): assert isinstance(app, Flask) assert isinstance(user, UserMixin) assert isinstance(login_token, string_types) recorded.append(user) # Test disabled account response = client.post('/login', data=dict(email='tiya@lp.com'), follow_redirects=True) assert get_message('DISABLED_ACCOUNT') in response.data # Test login with json and valid email data = '{"email": "matt@lp.com", "password": "password"}' response = client.post('/login', data=data, headers={'Content-Type': 'application/json'}) assert response.status_code == 200 assert len(recorded) == 1 # Test login with json and invalid email data = '{"email": "nobody@lp.com", "password": "password"}' response = client.post('/login', data=data, headers={'Content-Type': 'application/json'}) assert b'errors' in response.data # Test sends email and shows appropriate response with capture_passwordless_login_requests() as requests: with app.mail.record_messages() as outbox: response = client.post('/login', data=dict(email='matt@lp.com'), follow_redirects=True) assert len(recorded) == 2 assert len(requests) == 1 assert len(outbox) == 1 assert 'user' in requests[0] assert 'login_token' in requests[0] user = requests[0]['user'] assert get_message('LOGIN_EMAIL_SENT', email=user.email) in response.data token = requests[0]['login_token'] response = client.get('/login/' + token, follow_redirects=True) assert get_message('PASSWORDLESS_LOGIN_SUCCESSFUL') in response.data # Test already authenticated response = client.get('/login/' + token, follow_redirects=True) assert get_message('PASSWORDLESS_LOGIN_SUCCESSFUL') not in response.data logout(client) # Test invalid token response = client.get('/login/bogus', follow_redirects=True) assert get_message('INVALID_LOGIN_TOKEN') in response.data # Test login request with invalid email response = client.post('/login', data=dict(email='bogus@bogus.com')) assert get_message('USER_DOES_NOT_EXIST') in response.data @pytest.mark.settings(login_within='1 milliseconds') def test_expired_login_token(client, app, get_message): e = 'matt@lp.com' with capture_passwordless_login_requests() as requests: client.post('/login', data=dict(email=e), follow_redirects=True) token = requests[0]['login_token'] user = requests[0]['user'] time.sleep(1) response = client.get('/login/' + token, follow_redirects=True) assert get_message('LOGIN_EXPIRED', within='1 milliseconds', email=user.email) in response.data
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 511, 63, 2060, 2003, 272, 18294, 94, 339, 13635, 2003, 2295, 199, 624, 199, 199, 646, 900, 199, 199, 646, 4613, 199, 199, 504, 7209, 492, 16704, 199, 504, 7209, 63, 4416, 14, 1018, 492, 2876, 4256, 199, 504, 7209, 63, 4416, 14, 10458, 492, 4676, 63, 20718, 63, 1150, 199, 504, 7209, 63, 4416, 14, 1208, 492, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 12, 1059, 63, 1313, 199, 199, 504, 3778, 492, 22079, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 2060, 2003, 342, 421, 199, 318, 511, 63, 3885, 461, 63, 4173, 8, 571, 12, 1890, 12, 664, 63, 1188, 304, 272, 18894, 275, 942, 339, 768, 2886, 63, 20718, 63, 1150, 14, 2242, 63, 12897, 8, 571, 9, 272, 347, 641, 63, 20718, 63, 1150, 8, 571, 12, 922, 12, 4676, 63, 1418, 304, 267, 702, 1228, 8, 571, 12, 16704, 9, 267, 702, 1228, 8, 751, 12, 2876, 4256, 9, 267, 702, 1228, 8, 2886, 63, 1418, 12, 1059, 63, 1313, 9, 267, 18894, 14, 740, 8, 751, 9, 339, 327, 1379, 6980, 2933, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 280, 11552, 32, 10343, 14, 957, 659, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 16205, 63, 18928, 358, 315, 1177, 14, 576, 339, 327, 1379, 4676, 543, 2022, 436, 1686, 3031, 272, 666, 275, 17137, 2123, 582, 298, 569, 84, 32, 10343, 14, 957, 401, 298, 2060, 582, 298, 2060, 3570, 7, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 576, 12, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 3071, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 702, 822, 8, 264, 15402, 9, 508, 413, 339, 327, 1379, 4676, 543, 2022, 436, 3866, 3031, 272, 666, 275, 17137, 2123, 582, 298, 889, 2030, 32, 10343, 14, 957, 401, 298, 2060, 582, 298, 2060, 3570, 7, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 576, 12, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 3071, 272, 702, 330, 7, 2550, 7, 315, 1177, 14, 576, 339, 327, 1379, 16178, 3031, 436, 13703, 5827, 1177, 272, 543, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 342, 465, 4145, 26, 267, 543, 1145, 14, 1198, 14, 3059, 63, 3431, 342, 465, 734, 1977, 26, 288, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 569, 84, 32, 10343, 14, 957, 659, 2035, 63, 13607, 29, 549, 9, 339, 702, 822, 8, 264, 15402, 9, 508, 499, 272, 702, 822, 8, 6615, 9, 508, 413, 272, 702, 822, 8, 17244, 9, 508, 413, 272, 702, 283, 751, 7, 315, 4145, 59, 16, 61, 272, 702, 283, 2886, 63, 1418, 7, 315, 4145, 59, 16, 61, 339, 922, 275, 4145, 59, 16, 2733, 751, 418, 272, 702, 664, 63, 1188, 360, 17208, 63, 10089, 63, 32173, 297, 3031, 29, 751, 14, 2123, 9, 315, 1177, 14, 576, 339, 1526, 275, 4145, 59, 16, 2733, 2886, 63, 1418, 418, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9032, 30928, 63, 17208, 63, 12779, 38, 1293, 358, 315, 1177, 14, 576, 339, 327, 1379, 2575, 15082, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9032, 30928, 63, 17208, 63, 12779, 38, 1293, 358, 440, 315, 1177, 14, 576, 339, 22079, 8, 1258, 9, 339, 327, 1379, 3866, 1526, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 15, 18665, 297, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9692, 63, 17208, 63, 8803, 358, 315, 1177, 14, 576, 339, 327, 1379, 4676, 1056, 543, 3866, 3031, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 18665, 32, 18665, 14, 957, 1333, 272, 702, 664, 63, 1188, 360, 3791, 63, 1649, 654, 63, 4609, 63, 13301, 358, 315, 1177, 14, 576, 421, 199, 32, 4462, 14, 1657, 14, 1751, 8, 2886, 63, 12541, 534, 17, 21131, 358, 199, 318, 511, 63, 16340, 63, 2886, 63, 1418, 8, 1258, 12, 1145, 12, 664, 63, 1188, 304, 272, 325, 275, 283, 569, 84, 32, 10343, 14, 957, 7, 339, 543, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 342, 465, 4145, 26, 267, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 29, 69, 395, 2035, 63, 13607, 29, 549, 9, 339, 1526, 275, 4145, 59, 16, 2733, 2886, 63, 1418, 418, 272, 922, 275, 4145, 59, 16, 2733, 751, 418, 339, 900, 14, 4532, 8, 17, 9, 339, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 17208, 63, 25632, 7387, 297, 4453, 534, 17, 21131, 297, 3031, 29, 751, 14, 2123, 9, 315, 1177, 14, 576, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 511, 63, 2060, 2003, 272, 18294, 94, 339, 13635, 2003, 2295, 199, 624, 199, 199, 646, 900, 199, 199, 646, 4613, 199, 199, 504, 7209, 492, 16704, 199, 504, 7209, 63, 4416, 14, 1018, 492, 2876, 4256, 199, 504, 7209, 63, 4416, 14, 10458, 492, 4676, 63, 20718, 63, 1150, 199, 504, 7209, 63, 4416, 14, 1208, 492, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 12, 1059, 63, 1313, 199, 199, 504, 3778, 492, 22079, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 2060, 2003, 342, 421, 199, 318, 511, 63, 3885, 461, 63, 4173, 8, 571, 12, 1890, 12, 664, 63, 1188, 304, 272, 18894, 275, 942, 339, 768, 2886, 63, 20718, 63, 1150, 14, 2242, 63, 12897, 8, 571, 9, 272, 347, 641, 63, 20718, 63, 1150, 8, 571, 12, 922, 12, 4676, 63, 1418, 304, 267, 702, 1228, 8, 571, 12, 16704, 9, 267, 702, 1228, 8, 751, 12, 2876, 4256, 9, 267, 702, 1228, 8, 2886, 63, 1418, 12, 1059, 63, 1313, 9, 267, 18894, 14, 740, 8, 751, 9, 339, 327, 1379, 6980, 2933, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 280, 11552, 32, 10343, 14, 957, 659, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 16205, 63, 18928, 358, 315, 1177, 14, 576, 339, 327, 1379, 4676, 543, 2022, 436, 1686, 3031, 272, 666, 275, 17137, 2123, 582, 298, 569, 84, 32, 10343, 14, 957, 401, 298, 2060, 582, 298, 2060, 3570, 7, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 576, 12, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 3071, 272, 702, 1177, 14, 1205, 63, 600, 508, 1926, 272, 702, 822, 8, 264, 15402, 9, 508, 413, 339, 327, 1379, 4676, 543, 2022, 436, 3866, 3031, 272, 666, 275, 17137, 2123, 582, 298, 889, 2030, 32, 10343, 14, 957, 401, 298, 2060, 582, 298, 2060, 3570, 7, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 576, 12, 2323, 3713, 2714, 13, 804, 356, 283, 3578, 15, 1001, 3071, 272, 702, 330, 7, 2550, 7, 315, 1177, 14, 576, 339, 327, 1379, 16178, 3031, 436, 13703, 5827, 1177, 272, 543, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 342, 465, 4145, 26, 267, 543, 1145, 14, 1198, 14, 3059, 63, 3431, 342, 465, 734, 1977, 26, 288, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 569, 84, 32, 10343, 14, 957, 659, 2035, 63, 13607, 29, 549, 9, 339, 702, 822, 8, 264, 15402, 9, 508, 499, 272, 702, 822, 8, 6615, 9, 508, 413, 272, 702, 822, 8, 17244, 9, 508, 413, 272, 702, 283, 751, 7, 315, 4145, 59, 16, 61, 272, 702, 283, 2886, 63, 1418, 7, 315, 4145, 59, 16, 61, 339, 922, 275, 4145, 59, 16, 2733, 751, 418, 272, 702, 664, 63, 1188, 360, 17208, 63, 10089, 63, 32173, 297, 3031, 29, 751, 14, 2123, 9, 315, 1177, 14, 576, 339, 1526, 275, 4145, 59, 16, 2733, 2886, 63, 1418, 418, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9032, 30928, 63, 17208, 63, 12779, 38, 1293, 358, 315, 1177, 14, 576, 339, 327, 1379, 2575, 15082, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9032, 30928, 63, 17208, 63, 12779, 38, 1293, 358, 440, 315, 1177, 14, 576, 339, 22079, 8, 1258, 9, 339, 327, 1379, 3866, 1526, 272, 1177, 275, 1890, 14, 362, 2336, 2886, 15, 18665, 297, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 9692, 63, 17208, 63, 8803, 358, 315, 1177, 14, 576, 339, 327, 1379, 4676, 1056, 543, 3866, 3031, 272, 1177, 275, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 534, 18665, 32, 18665, 14, 957, 1333, 272, 702, 664, 63, 1188, 360, 3791, 63, 1649, 654, 63, 4609, 63, 13301, 358, 315, 1177, 14, 576, 421, 199, 32, 4462, 14, 1657, 14, 1751, 8, 2886, 63, 12541, 534, 17, 21131, 358, 199, 318, 511, 63, 16340, 63, 2886, 63, 1418, 8, 1258, 12, 1145, 12, 664, 63, 1188, 304, 272, 325, 275, 283, 569, 84, 32, 10343, 14, 957, 7, 339, 543, 12296, 63, 2060, 2003, 63, 2886, 63, 6615, 342, 465, 4145, 26, 267, 1890, 14, 1932, 2336, 2886, 297, 666, 29, 807, 8, 2123, 29, 69, 395, 2035, 63, 13607, 29, 549, 9, 339, 1526, 275, 4145, 59, 16, 2733, 2886, 63, 1418, 418, 272, 922, 275, 4145, 59, 16, 2733, 751, 418, 339, 900, 14, 4532, 8, 17, 9, 339, 1177, 275, 1890, 14, 362, 2336, 2886, 4805, 435, 1526, 12, 2035, 63, 13607, 29, 549, 9, 272, 702, 664, 63, 1188, 360, 17208, 63, 25632, 7387, 297, 4453, 534, 17, 21131, 297, 3031, 29, 751, 14, 2123, 9, 315, 1177, 14, 576, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mrquim/repository.mrquim
repo/script.module.nanscrapers/lib/nanscrapers/modules/js2py/legecy_translators/nparser.py
96
99391
# JUST FOR NOW, later I will write my own - much faster and better. # Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com> # Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com> # Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com> # Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be> # Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl> # Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com> # Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com> # Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com> # Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com> # # 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. # # 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 AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> 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. # -*- coding: latin-1 -*- from __future__ import print_function import re def typeof(t): if t is None: return 'undefined' elif isinstance(t, bool): return 'boolean' elif isinstance(t, str): return 'string' elif isinstance(t, int) or isinstance(t, float): return 'number' elif hasattr(t, '__call__'): return 'function' else: return 'object' def list_indexOf(l, v): try: return l.index(v) except: return -1 parseFloat = float parseInt = int class jsdict(object): def __init__(self, d): self.__dict__.update(d) def __getitem__(self, name): if name in self.__dict__: return self.__dict__[name] else: return None def __setitem__(self, name, value): self.__dict__[name] = value return value def __getattr__(self, name): try: return getattr(self, name) except: return None def __setattr__(self, name, value): self[name] = value return value def __contains__(self, name): return name in self.__dict__ def __repr__(self): return str(self.__dict__) class RegExp(object): def __init__(self, pattern, flags=''): self.flags = flags pyflags = 0 | re.M if 'm' in flags else 0 | re.I if 'i' in flags else 0 self.source = pattern self.pattern = re.compile(pattern, pyflags) def test(self, s): return self.pattern.search(s) is not None console = jsdict({"log":print}) def __temp__42(object=None, body=None): return jsdict({ "type": Syntax.WithStatement, "object": object, "body": body, }) def __temp__41(test=None, body=None): return jsdict({ "type": Syntax.WhileStatement, "test": test, "body": body, }) def __temp__40(id=None, init=None): return jsdict({ "type": Syntax.VariableDeclarator, "id": id, "init": init, }) def __temp__39(declarations=None, kind=None): return jsdict({ "type": Syntax.VariableDeclaration, "declarations": declarations, "kind": kind, }) def __temp__38(operator=None, argument=None): if (operator == "++") or (operator == "--"): return jsdict({ "type": Syntax.UpdateExpression, "operator": operator, "argument": argument, "prefix": True, }) return jsdict({ "type": Syntax.UnaryExpression, "operator": operator, "argument": argument, "prefix": True, }) def __temp__37(block=None, guardedHandlers=None, handlers=None, finalizer=None): return jsdict({ "type": Syntax.TryStatement, "block": block, "guardedHandlers": guardedHandlers, "handlers": handlers, "finalizer": finalizer, }) def __temp__36(argument=None): return jsdict({ "type": Syntax.ThrowStatement, "argument": argument, }) def __temp__35(): return jsdict({ "type": Syntax.ThisExpression, }) def __temp__34(discriminant=None, cases=None): return jsdict({ "type": Syntax.SwitchStatement, "discriminant": discriminant, "cases": cases, }) def __temp__33(test=None, consequent=None): return jsdict({ "type": Syntax.SwitchCase, "test": test, "consequent": consequent, }) def __temp__32(expressions=None): return jsdict({ "type": Syntax.SequenceExpression, "expressions": expressions, }) def __temp__31(argument=None): return jsdict({ "type": Syntax.ReturnStatement, "argument": argument, }) def __temp__30(kind=None, key=None, value=None): return jsdict({ "type": Syntax.Property, "key": key, "value": value, "kind": kind, }) def __temp__29(body=None): return jsdict({ "type": Syntax.Program, "body": body, }) def __temp__28(operator=None, argument=None): return jsdict({ "type": Syntax.UpdateExpression, "operator": operator, "argument": argument, "prefix": False, }) def __temp__27(properties=None): return jsdict({ "type": Syntax.ObjectExpression, "properties": properties, }) def __temp__26(callee=None, args=None): return jsdict({ "type": Syntax.NewExpression, "callee": callee, "arguments": args, }) def __temp__25(accessor=None, object=None, property=None): return jsdict({ "type": Syntax.MemberExpression, "computed": accessor == "[", "object": object, "property": property, }) def __temp__24(token=None): return jsdict({ "type": Syntax.Literal, "value": token.value, "raw": source[token.range[0]:token.range[1]], }) def __temp__23(label=None, body=None): return jsdict({ "type": Syntax.LabeledStatement, "label": label, "body": body, }) def __temp__22(test=None, consequent=None, alternate=None): return jsdict({ "type": Syntax.IfStatement, "test": test, "consequent": consequent, "alternate": alternate, }) def __temp__21(name=None): return jsdict({ "type": Syntax.Identifier, "name": name, }) def __temp__20(id=None, params=None, defaults=None, body=None): return jsdict({ "type": Syntax.FunctionExpression, "id": id, "params": params, "defaults": defaults, "body": body, "rest": None, "generator": False, "expression": False, }) def __temp__19(id=None, params=None, defaults=None, body=None): return jsdict({ "type": Syntax.FunctionDeclaration, "id": id, "params": params, "defaults": defaults, "body": body, "rest": None, "generator": False, "expression": False, }) def __temp__18(left=None, right=None, body=None): return jsdict({ "type": Syntax.ForInStatement, "left": left, "right": right, "body": body, "each": False, }) def __temp__17(init=None, test=None, update=None, body=None): return jsdict({ "type": Syntax.ForStatement, "init": init, "test": test, "update": update, "body": body, }) def __temp__16(expression=None): return jsdict({ "type": Syntax.ExpressionStatement, "expression": expression, }) def __temp__15(): return jsdict({ "type": Syntax.EmptyStatement, }) def __temp__14(body=None, test=None): return jsdict({ "type": Syntax.DoWhileStatement, "body": body, "test": test, }) def __temp__13(): return jsdict({ "type": Syntax.DebuggerStatement, }) def __temp__12(label=None): return jsdict({ "type": Syntax.ContinueStatement, "label": label, }) def __temp__11(test=None, consequent=None, alternate=None): return jsdict({ "type": Syntax.ConditionalExpression, "test": test, "consequent": consequent, "alternate": alternate, }) def __temp__10(param=None, body=None): return jsdict({ "type": Syntax.CatchClause, "param": param, "body": body, }) def __temp__9(callee=None, args=None): return jsdict({ "type": Syntax.CallExpression, "callee": callee, "arguments": args, }) def __temp__8(label=None): return jsdict({ "type": Syntax.BreakStatement, "label": label, }) def __temp__7(body=None): return jsdict({ "type": Syntax.BlockStatement, "body": body, }) def __temp__6(operator=None, left=None, right=None): type = (Syntax.LogicalExpression if (operator == "||") or (operator == "&&") else Syntax.BinaryExpression) return jsdict({ "type": type, "operator": operator, "left": left, "right": right, }) def __temp__5(operator=None, left=None, right=None): return jsdict({ "type": Syntax.AssignmentExpression, "operator": operator, "left": left, "right": right, }) def __temp__4(elements=None): return jsdict({ "type": Syntax.ArrayExpression, "elements": elements, }) def __temp__3(node=None): if extra.source: node.loc.source = extra.source return node def __temp__2(node=None): if node.range or node.loc: if extra.loc: state.markerStack.pop() state.markerStack.pop() if extra.range: state.markerStack.pop() else: SyntaxTreeDelegate.markEnd(node) return node def __temp__1(node=None): if extra.range: node.range = [state.markerStack.pop(), index] if extra.loc: node.loc = jsdict({ "start": jsdict({ "line": state.markerStack.pop(), "column": state.markerStack.pop(), }), "end": jsdict({ "line": lineNumber, "column": index - lineStart, }), }) SyntaxTreeDelegate.postProcess(node) return node def __temp__0(): if extra.loc: state.markerStack.append(index - lineStart) state.markerStack.append(lineNumber) if extra.range: state.markerStack.append(index) Token = None TokenName = None FnExprTokens = None Syntax = None PropertyKind = None Messages = None Regex = None SyntaxTreeDelegate = None source = None strict = None index = None lineNumber = None lineStart = None length = None delegate = None lookahead = None state = None extra = None Token = jsdict({ "BooleanLiteral": 1, "EOF": 2, "Identifier": 3, "Keyword": 4, "NullLiteral": 5, "NumericLiteral": 6, "Punctuator": 7, "StringLiteral": 8, "RegularExpression": 9, }) TokenName = jsdict({ }) TokenName[Token.BooleanLiteral] = "Boolean" TokenName[Token.EOF] = "<end>" TokenName[Token.Identifier] = "Identifier" TokenName[Token.Keyword] = "Keyword" TokenName[Token.NullLiteral] = "Null" TokenName[Token.NumericLiteral] = "Numeric" TokenName[Token.Punctuator] = "Punctuator" TokenName[Token.StringLiteral] = "String" TokenName[Token.RegularExpression] = "RegularExpression" FnExprTokens = ["(", "{", "[", "in", "typeof", "instanceof", "new", "return", "case", "delete", "throw", "void", "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "&=", "|=", "^=", ",", "+", "-", "*", "/", "%", "++", "--", "<<", ">>", ">>>", "&", "|", "^", "!", "~", "&&", "||", "?", ":", "===", "==", ">=", "<=", "<", ">", "!=", "!=="] Syntax = jsdict({ "AssignmentExpression": "AssignmentExpression", "ArrayExpression": "ArrayExpression", "BlockStatement": "BlockStatement", "BinaryExpression": "BinaryExpression", "BreakStatement": "BreakStatement", "CallExpression": "CallExpression", "CatchClause": "CatchClause", "ConditionalExpression": "ConditionalExpression", "ContinueStatement": "ContinueStatement", "DoWhileStatement": "DoWhileStatement", "DebuggerStatement": "DebuggerStatement", "EmptyStatement": "EmptyStatement", "ExpressionStatement": "ExpressionStatement", "ForStatement": "ForStatement", "ForInStatement": "ForInStatement", "FunctionDeclaration": "FunctionDeclaration", "FunctionExpression": "FunctionExpression", "Identifier": "Identifier", "IfStatement": "IfStatement", "Literal": "Literal", "LabeledStatement": "LabeledStatement", "LogicalExpression": "LogicalExpression", "MemberExpression": "MemberExpression", "NewExpression": "NewExpression", "ObjectExpression": "ObjectExpression", "Program": "Program", "Property": "Property", "ReturnStatement": "ReturnStatement", "SequenceExpression": "SequenceExpression", "SwitchStatement": "SwitchStatement", "SwitchCase": "SwitchCase", "ThisExpression": "ThisExpression", "ThrowStatement": "ThrowStatement", "TryStatement": "TryStatement", "UnaryExpression": "UnaryExpression", "UpdateExpression": "UpdateExpression", "VariableDeclaration": "VariableDeclaration", "VariableDeclarator": "VariableDeclarator", "WhileStatement": "WhileStatement", "WithStatement": "WithStatement", }) PropertyKind = jsdict({ "Data": 1, "Get": 2, "Set": 4, }) Messages = jsdict({ "UnexpectedToken": "Unexpected token %0", "UnexpectedNumber": "Unexpected number", "UnexpectedString": "Unexpected string", "UnexpectedIdentifier": "Unexpected identifier", "UnexpectedReserved": "Unexpected reserved word", "UnexpectedEOS": "Unexpected end of input", "NewlineAfterThrow": "Illegal newline after throw", "InvalidRegExp": "Invalid regular expression", "UnterminatedRegExp": "Invalid regular expression: missing /", "InvalidLHSInAssignment": "Invalid left-hand side in assignment", "InvalidLHSInForIn": "Invalid left-hand side in for-in", "MultipleDefaultsInSwitch": "More than one default clause in switch statement", "NoCatchOrFinally": "Missing catch or finally after try", "UnknownLabel": "Undefined label '%0'", "Redeclaration": "%0 '%1' has already been declared", "IllegalContinue": "Illegal continue statement", "IllegalBreak": "Illegal break statement", "IllegalReturn": "Illegal return statement", "StrictModeWith": "Strict mode code may not include a with statement", "StrictCatchVariable": "Catch variable may not be eval or arguments in strict mode", "StrictVarName": "Variable name may not be eval or arguments in strict mode", "StrictParamName": "Parameter name eval or arguments is not allowed in strict mode", "StrictParamDupe": "Strict mode function may not have duplicate parameter names", "StrictFunctionName": "Function name may not be eval or arguments in strict mode", "StrictOctalLiteral": "Octal literals are not allowed in strict mode.", "StrictDelete": "Delete of an unqualified identifier in strict mode.", "StrictDuplicateProperty": "Duplicate data property in object literal not allowed in strict mode", "AccessorDataProperty": "Object literal may not have data and accessor property with the same name", "AccessorGetSet": "Object literal may not have multiple get/set accessors with the same name", "StrictLHSAssignment": "Assignment to eval or arguments is not allowed in strict mode", "StrictLHSPostfix": "Postfix increment/decrement may not have eval or arguments operand in strict mode", "StrictLHSPrefix": "Prefix increment/decrement may not have eval or arguments operand in strict mode", "StrictReservedWord": "Use of future reserved word in strict mode", }) Regex = jsdict({ "NonAsciiIdentifierStart": RegExp(u"[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]"), "NonAsciiIdentifierPart": RegExp(u"[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]"), }) def assert__py__(condition=None, message=None): if not condition: raise RuntimeError("ASSERT: " + message) def isDecimalDigit(ch=None): return (ch >= 48) and (ch <= 57) def isHexDigit(ch=None): return "0123456789abcdefABCDEF".find(ch) >= 0 def isOctalDigit(ch=None): return "01234567".find(ch) >= 0 def isWhiteSpace(ch=None): return (((((ch == 32) or (ch == 9)) or (ch == 11)) or (ch == 12)) or (ch == 160)) or ((ch >= 5760) and (u"\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\ufeff".find(unichr(ch)) > 0)) def isLineTerminator(ch=None): return (((ch == 10) or (ch == 13)) or (ch == 8232)) or (ch == 8233) def isIdentifierStart(ch=None): return (((((ch == 36) or (ch == 95)) or ((ch >= 65) and (ch <= 90))) or ((ch >= 97) and (ch <= 122))) or (ch == 92)) or ((ch >= 128) and Regex.NonAsciiIdentifierStart.test(unichr(ch))) def isIdentifierPart(ch=None): return ((((((ch == 36) or (ch == 95)) or ((ch >= 65) and (ch <= 90))) or ((ch >= 97) and (ch <= 122))) or ((ch >= 48) and (ch <= 57))) or (ch == 92)) or ((ch >= 128) and Regex.NonAsciiIdentifierPart.test(unichr(ch))) def isFutureReservedWord(id=None): while 1: if (id == "super") or ((id == "import") or ((id == "extends") or ((id == "export") or ((id == "enum") or (id == "class"))))): return True else: return False break def isStrictModeReservedWord(id=None): while 1: if (id == "let") or ((id == "yield") or ((id == "static") or ((id == "public") or ((id == "protected") or ((id == "private") or ((id == "package") or ((id == "interface") or (id == "implements")))))))): return True else: return False break def isRestrictedWord(id=None): return (id == "eval") or (id == "arguments") def isKeyword(id=None): if strict and isStrictModeReservedWord(id): return True while 1: if len(id) == 2: return ((id == "if") or (id == "in")) or (id == "do") elif len(id) == 3: return ((((id == "var") or (id == "for")) or (id == "new")) or (id == "try")) or (id == "let") elif len(id) == 4: return (((((id == "this") or (id == "else")) or (id == "case")) or (id == "void")) or (id == "with")) or (id == "enum") elif len(id) == 5: return (((((((id == "while") or (id == "break")) or (id == "catch")) or (id == "throw")) or (id == "const")) or (id == "yield")) or (id == "class")) or (id == "super") elif len(id) == 6: return (((((id == "return") or (id == "typeof")) or (id == "delete")) or (id == "switch")) or (id == "export")) or (id == "import") elif len(id) == 7: return ((id == "default") or (id == "finally")) or (id == "extends") elif len(id) == 8: return ((id == "function") or (id == "continue")) or (id == "debugger") elif len(id) == 10: return id == "instanceof" else: return False break def addComment(type=None, value=None, start=None, end=None, loc=None): comment = None assert__py__(('undefined' if not 'start' in locals() else typeof(start)) == "number", "Comment must have valid position") if state.lastCommentStart >= start: return state.lastCommentStart = start comment = jsdict({ "type": type, "value": value, }) if extra.range: comment.range = [start, end] if extra.loc: comment.loc = loc extra.comments.append(comment) def skipSingleLineComment(): global index, lineNumber, lineStart start = None loc = None ch = None comment = None start = index - 2 loc = jsdict({ "start": jsdict({ "line": lineNumber, "column": (index - lineStart) - 2, }), }) while index < length: ch = (ord(source[index]) if index < len(source) else None) index += 1 index if isLineTerminator(ch): if extra.comments: comment = source[(start + 2):(index - 1)] loc.end = jsdict({ "line": lineNumber, "column": (index - lineStart) - 1, }) addComment("Line", comment, start, index - 1, loc) if (ch == 13) and ((ord(source[index]) if index < len(source) else None) == 10): index += 1 index lineNumber += 1 lineNumber lineStart = index return if extra.comments: comment = source[(start + 2):index] loc.end = jsdict({ "line": lineNumber, "column": index - lineStart, }) addComment("Line", comment, start, index, loc) def skipMultiLineComment(): global index, lineNumber, lineStart start = None loc = None ch = None comment = None if extra.comments: start = index - 2 loc = jsdict({ "start": jsdict({ "line": lineNumber, "column": (index - lineStart) - 2, }), }) while index < length: ch = (ord(source[index]) if index < len(source) else None) if isLineTerminator(ch): if (ch == 13) and ((ord(source[index + 1]) if (index + 1) < len(source) else None) == 10): index += 1 index lineNumber += 1 lineNumber index += 1 index lineStart = index if index >= length: throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") elif ch == 42: if (ord(source[index + 1]) if (index + 1) < len(source) else None) == 47: index += 1 index index += 1 index if extra.comments: comment = source[(start + 2):(index - 2)] loc.end = jsdict({ "line": lineNumber, "column": index - lineStart, }) addComment("Block", comment, start, index, loc) return index += 1 index else: index += 1 index throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") def skipComment(): global index, lineNumber, lineStart ch = None while index < length: ch = (ord(source[index]) if index < len(source) else None) if isWhiteSpace(ch): index += 1 index elif isLineTerminator(ch): index += 1 index if (ch == 13) and ((ord(source[index]) if index < len(source) else None) == 10): index += 1 index lineNumber += 1 lineNumber lineStart = index elif ch == 47: ch = (ord(source[index + 1]) if (index + 1) < len(source) else None) if ch == 47: index += 1 index index += 1 index skipSingleLineComment() elif ch == 42: index += 1 index index += 1 index skipMultiLineComment() else: break else: break def scanHexEscape(prefix=None): global len__py__, index i = None len__py__ = None ch = None code = 0 len__py__ = (4 if prefix == "u" else 2) i = 0 while 1: if not (i < len__py__): break if (index < length) and isHexDigit(source[index]): index += 1 ch = source[index - 1] code = (code * 16) + "0123456789abcdef".find(ch.lower()) else: return "" i += 1 return unichr(code) def getEscapedIdentifier(): global index ch = None id = None index += 1 index += 1 ch = (ord(source[index - 1]) if index - 1 < len(source) else None) id = unichr(ch) if ch == 92: if (ord(source[index]) if index < len(source) else None) != 117: throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") index += 1 index ch = scanHexEscape("u") if ((not ch) or (ch == "\\")) or (not isIdentifierStart((ord(ch[0]) if 0 < len(ch) else None))): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") id = ch while index < length: ch = (ord(source[index]) if index < len(source) else None) if not isIdentifierPart(ch): break index += 1 index id += unichr(ch) if ch == 92: id = id[0:(0 + (len(id) - 1))] if (ord(source[index]) if index < len(source) else None) != 117: throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") index += 1 index ch = scanHexEscape("u") if ((not ch) or (ch == "\\")) or (not isIdentifierPart((ord(ch[0]) if 0 < len(ch) else None))): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") id += ch return id def getIdentifier(): global index start = None ch = None index += 1 start = index - 1 while index < length: ch = (ord(source[index]) if index < len(source) else None) if ch == 92: index = start return getEscapedIdentifier() if isIdentifierPart(ch): index += 1 index else: break return source[start:index] def scanIdentifier(): start = None id = None type = None start = index id = (getEscapedIdentifier() if (ord(source[index]) if index < len(source) else None) == 92 else getIdentifier()) if len(id) == 1: type = Token.Identifier elif isKeyword(id): type = Token.Keyword elif id == "null": type = Token.NullLiteral elif (id == "true") or (id == "false"): type = Token.BooleanLiteral else: type = Token.Identifier return jsdict({ "type": type, "value": id, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) def scanPunctuator(): global index start = index code = (ord(source[index]) if index < len(source) else None) code2 = None ch1 = source[index] ch2 = None ch3 = None ch4 = None while 1: if (code == 126) or ((code == 63) or ((code == 58) or ((code == 93) or ((code == 91) or ((code == 125) or ((code == 123) or ((code == 44) or ((code == 59) or ((code == 41) or ((code == 40) or (code == 46))))))))))): index += 1 index if extra.tokenize: if code == 40: extra.openParenToken = len(extra.tokens) elif code == 123: extra.openCurlyToken = len(extra.tokens) return jsdict({ "type": Token.Punctuator, "value": unichr(code), "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) else: code2 = (ord(source[index + 1]) if (index + 1) < len(source) else None) if code2 == 61: while 1: if (code == 124) or ((code == 94) or ((code == 62) or ((code == 60) or ((code == 47) or ((code == 45) or ((code == 43) or ((code == 42) or ((code == 38) or (code == 37))))))))): index += 2 return jsdict({ "type": Token.Punctuator, "value": unichr(code) + unichr(code2), "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) elif (code == 61) or (code == 33): index += 2 if (ord(source[index]) if index < len(source) else None) == 61: index += 1 index return jsdict({ "type": Token.Punctuator, "value": source[start:index], "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) else: break break break break ch2 = source[index + 1] if index + 1 < len(source) else None ch3 = source[index + 2] if index + 2 < len(source) else None ch4 = source[index + 3] if index + 3 < len(source) else None if ((ch1 == ">") and (ch2 == ">")) and (ch3 == ">"): if ch4 == "=": index += 4 return jsdict({ "type": Token.Punctuator, "value": ">>>=", "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) if ((ch1 == ">") and (ch2 == ">")) and (ch3 == ">"): index += 3 return jsdict({ "type": Token.Punctuator, "value": ">>>", "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) if ((ch1 == "<") and (ch2 == "<")) and (ch3 == "="): index += 3 return jsdict({ "type": Token.Punctuator, "value": "<<=", "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) if ((ch1 == ">") and (ch2 == ">")) and (ch3 == "="): index += 3 return jsdict({ "type": Token.Punctuator, "value": ">>=", "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) if (ch1 == ch2) and ("+-<>&|".find(ch1) >= 0): index += 2 return jsdict({ "type": Token.Punctuator, "value": ch1 + ch2, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) if "<>=!+-*%&|^/".find(ch1) >= 0: index += 1 index return jsdict({ "type": Token.Punctuator, "value": ch1, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") def scanHexLiteral(start=None): global index number = "" while index < length: if not isHexDigit(source[index]): break index += 1 number += source[index - 1] if len(number) == 0: throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") if isIdentifierStart((ord(source[index]) if index < len(source) else None)): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") return jsdict({ "type": Token.NumericLiteral, "value": parseInt("0x" + number, 16), "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) def scanOctalLiteral(start=None): global index index += 1 number = "0" + source[index - 1] while index < length: if not isOctalDigit(source[index]): break index += 1 number += source[index - 1] if isIdentifierStart((ord(source[index]) if index < len(source) else None)) or isDecimalDigit((ord(source[index]) if index < len(source) else None)): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") return jsdict({ "type": Token.NumericLiteral, "value": parseInt(number, 8), "octal": True, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) def scanNumericLiteral(): global index number = None start = None ch = None ch = source[index] assert__py__(isDecimalDigit((ord(ch[0]) if 0 < len(ch) else None)) or (ch == "."), "Numeric literal must start with a decimal digit or a decimal point") start = index number = "" if ch != ".": index += 1 number = source[index - 1] ch = source[index] if index < len(source) else None if number == "0": if (ch == "x") or (ch == "X"): index += 1 index return scanHexLiteral(start) if isOctalDigit(ch): return scanOctalLiteral(start) if ch and isDecimalDigit((ord(ch[0]) if 0 < len(ch) else None)): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") while isDecimalDigit((ord(source[index]) if index < len(source) else None)): index += 1 number += source[index - 1] ch = source[index] if index < len(source) else None if ch == ".": index += 1 number += source[index - 1] while isDecimalDigit((ord(source[index]) if index < len(source) else None)): index += 1 number += source[index - 1] ch = source[index] if (ch == "e") or (ch == "E"): index += 1 number += source[index - 1] ch = source[index] if (ch == "+") or (ch == "-"): index += 1 number += source[index - 1] if isDecimalDigit((ord(source[index]) if index < len(source) else None)): while isDecimalDigit((ord(source[index]) if index < len(source) else None)): index += 1 number += source[index - 1] else: throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") if isIdentifierStart((ord(source[index]) if index < len(source) else None)): throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") return jsdict({ "type": Token.NumericLiteral, "value": parseFloat(number), "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) def scanStringLiteral(): global index, lineNumber str = "" quote = None start = None ch = None code = None unescaped = None restore = None octal = False quote = source[index] assert__py__((quote == "'") or (quote == "\""), "String literal must starts with a quote") start = index index += 1 index while index < length: index += 1 ch = source[index - 1] if ch == quote: quote = "" break elif ch == "\\": index += 1 ch = source[index - 1] if (not ch) or (not isLineTerminator((ord(ch[0]) if 0 < len(ch) else None))): while 1: if ch == "n": str += u"\x0a" break elif ch == "r": str += u"\x0d" break elif ch == "t": str += u"\x09" break elif (ch == "x") or (ch == "u"): restore = index unescaped = scanHexEscape(ch) if unescaped: str += unescaped else: index = restore str += ch break elif ch == "b": str += u"\x08" break elif ch == "f": str += u"\x0c" break elif ch == "v": str += u"\x0b" break else: if isOctalDigit(ch): code = "01234567".find(ch) if code != 0: octal = True if (index < length) and isOctalDigit(source[index]): octal = True index += 1 code = (code * 8) + "01234567".find(source[index - 1]) if (("0123".find(ch) >= 0) and (index < length)) and isOctalDigit(source[index]): index += 1 code = (code * 8) + "01234567".find(source[index - 1]) str += unichr(code) else: str += ch break break else: lineNumber += 1 lineNumber if (ch == u"\x0d") and (source[index] == u"\x0a"): index += 1 index elif isLineTerminator((ord(ch[0]) if 0 < len(ch) else None)): break else: str += ch if quote != "": throwError(jsdict({ }), Messages.UnexpectedToken, "ILLEGAL") return jsdict({ "type": Token.StringLiteral, "value": str, "octal": octal, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) def scanRegExp(): global lookahead, index str = None ch = None start = None pattern = None flags = None value = None classMarker = False restore = None terminated = False lookahead = None skipComment() start = index ch = source[index] assert__py__(ch == "/", "Regular expression literal must start with a slash") index += 1 str = source[index - 1] while index < length: index += 1 ch = source[index - 1] str += ch if classMarker: if ch == "]": classMarker = False else: if ch == "\\": index += 1 ch = source[index - 1] if isLineTerminator((ord(ch[0]) if 0 < len(ch) else None)): throwError(jsdict({ }), Messages.UnterminatedRegExp) str += ch elif ch == "/": terminated = True break elif ch == "[": classMarker = True elif isLineTerminator((ord(ch[0]) if 0 < len(ch) else None)): throwError(jsdict({ }), Messages.UnterminatedRegExp) if not terminated: throwError(jsdict({ }), Messages.UnterminatedRegExp) pattern = str[1:(1 + (len(str) - 2))] flags = "" while index < length: ch = source[index] if not isIdentifierPart((ord(ch[0]) if 0 < len(ch) else None)): break index += 1 index if (ch == "\\") and (index < length): ch = source[index] if ch == "u": index += 1 index restore = index ch = scanHexEscape("u") if ch: flags += ch str += "\\u" while 1: if not (restore < index): break str += source[restore] restore += 1 else: index = restore flags += "u" str += "\\u" else: str += "\\" else: flags += ch str += ch try: value = RegExp(pattern, flags) except Exception as e: throwError(jsdict({ }), Messages.InvalidRegExp) peek() if extra.tokenize: return jsdict({ "type": Token.RegularExpression, "value": value, "lineNumber": lineNumber, "lineStart": lineStart, "range": [start, index], }) return jsdict({ "literal": str, "value": value, "range": [start, index], }) def isIdentifierName(token=None): return (((token.type == Token.Identifier) or (token.type == Token.Keyword)) or (token.type == Token.BooleanLiteral)) or (token.type == Token.NullLiteral) def advanceSlash(): prevToken = None checkToken = None prevToken = extra.tokens[len(extra.tokens) - 1] if not prevToken: return scanRegExp() if prevToken.type == "Punctuator": if prevToken.value == ")": checkToken = extra.tokens[extra.openParenToken - 1] if (checkToken and (checkToken.type == "Keyword")) and ((((checkToken.value == "if") or (checkToken.value == "while")) or (checkToken.value == "for")) or (checkToken.value == "with")): return scanRegExp() return scanPunctuator() if prevToken.value == "}": if extra.tokens[extra.openCurlyToken - 3] and (extra.tokens[extra.openCurlyToken - 3].type == "Keyword"): checkToken = extra.tokens[extra.openCurlyToken - 4] if not checkToken: return scanPunctuator() elif extra.tokens[extra.openCurlyToken - 4] and (extra.tokens[extra.openCurlyToken - 4].type == "Keyword"): checkToken = extra.tokens[extra.openCurlyToken - 5] if not checkToken: return scanRegExp() else: return scanPunctuator() if FnExprTokens.indexOf(checkToken.value) >= 0: return scanPunctuator() return scanRegExp() return scanRegExp() if prevToken.type == "Keyword": return scanRegExp() return scanPunctuator() def advance(): ch = None skipComment() if index >= length: return jsdict({ "type": Token.EOF, "lineNumber": lineNumber, "lineStart": lineStart, "range": [index, index], }) ch = (ord(source[index]) if index < len(source) else None) if ((ch == 40) or (ch == 41)) or (ch == 58): return scanPunctuator() if (ch == 39) or (ch == 34): return scanStringLiteral() if isIdentifierStart(ch): return scanIdentifier() if ch == 46: if isDecimalDigit((ord(source[index + 1]) if (index + 1) < len(source) else None)): return scanNumericLiteral() return scanPunctuator() if isDecimalDigit(ch): return scanNumericLiteral() if extra.tokenize and (ch == 47): return advanceSlash() return scanPunctuator() def lex(): global index, lineNumber, lineStart, lookahead token = None token = lookahead index = token.range[1] lineNumber = token.lineNumber lineStart = token.lineStart lookahead = advance() index = token.range[1] lineNumber = token.lineNumber lineStart = token.lineStart return token def peek(): global lookahead, index, lineNumber, lineStart pos = None line = None start = None pos = index line = lineNumber start = lineStart lookahead = advance() index = pos lineNumber = line lineStart = start SyntaxTreeDelegate = jsdict({ "name": "SyntaxTree", "markStart": __temp__0, "markEnd": __temp__1, "markEndIf": __temp__2, "postProcess": __temp__3, "createArrayExpression": __temp__4, "createAssignmentExpression": __temp__5, "createBinaryExpression": __temp__6, "createBlockStatement": __temp__7, "createBreakStatement": __temp__8, "createCallExpression": __temp__9, "createCatchClause": __temp__10, "createConditionalExpression": __temp__11, "createContinueStatement": __temp__12, "createDebuggerStatement": __temp__13, "createDoWhileStatement": __temp__14, "createEmptyStatement": __temp__15, "createExpressionStatement": __temp__16, "createForStatement": __temp__17, "createForInStatement": __temp__18, "createFunctionDeclaration": __temp__19, "createFunctionExpression": __temp__20, "createIdentifier": __temp__21, "createIfStatement": __temp__22, "createLabeledStatement": __temp__23, "createLiteral": __temp__24, "createMemberExpression": __temp__25, "createNewExpression": __temp__26, "createObjectExpression": __temp__27, "createPostfixExpression": __temp__28, "createProgram": __temp__29, "createProperty": __temp__30, "createReturnStatement": __temp__31, "createSequenceExpression": __temp__32, "createSwitchCase": __temp__33, "createSwitchStatement": __temp__34, "createThisExpression": __temp__35, "createThrowStatement": __temp__36, "createTryStatement": __temp__37, "createUnaryExpression": __temp__38, "createVariableDeclaration": __temp__39, "createVariableDeclarator": __temp__40, "createWhileStatement": __temp__41, "createWithStatement": __temp__42, }) def peekLineTerminator(): global index, lineNumber, lineStart pos = None line = None start = None found = None pos = index line = lineNumber start = lineStart skipComment() found = lineNumber != line index = pos lineNumber = line lineStart = start return found def throwError(token=None, messageFormat=None, a=None): def __temp__43(whole=None, index=None): assert__py__(index < len(args), "Message reference must be in range") return args[index] error = None args = Array.prototype.slice.call(arguments, 2) msg = messageFormat.replace(RegExp(r'%(\d)'), __temp__43) if ('undefined' if not ('lineNumber' in token) else typeof(token.lineNumber)) == "number": error = RuntimeError((("Line " + token.lineNumber) + ": ") + msg) error.index = token.range[0] error.lineNumber = token.lineNumber error.column = (token.range[0] - lineStart) + 1 else: error = RuntimeError((("Line " + lineNumber) + ": ") + msg) error.index = index error.lineNumber = lineNumber error.column = (index - lineStart) + 1 error.description = msg raise error def throwErrorTolerant(): try: throwError.apply(None, arguments) except Exception as e: if extra.errors: extra.errors.append(e) else: raise def throwUnexpected(token=None): if token.type == Token.EOF: throwError(token, Messages.UnexpectedEOS) if token.type == Token.NumericLiteral: throwError(token, Messages.UnexpectedNumber) if token.type == Token.StringLiteral: throwError(token, Messages.UnexpectedString) if token.type == Token.Identifier: throwError(token, Messages.UnexpectedIdentifier) if token.type == Token.Keyword: if isFutureReservedWord(token.value): throwError(token, Messages.UnexpectedReserved) elif strict and isStrictModeReservedWord(token.value): throwErrorTolerant(token, Messages.StrictReservedWord) return throwError(token, Messages.UnexpectedToken, token.value) throwError(token, Messages.UnexpectedToken, token.value) def expect(value=None): token = lex() if (token.type != Token.Punctuator) or (token.value != value): throwUnexpected(token) def expectKeyword(keyword=None): token = lex() if (token.type != Token.Keyword) or (token.value != keyword): throwUnexpected(token) def match(value=None): return (lookahead.type == Token.Punctuator) and (lookahead.value == value) def matchKeyword(keyword=None): return (lookahead.type == Token.Keyword) and (lookahead.value == keyword) def matchAssign(): op = None if lookahead.type != Token.Punctuator: return False op = lookahead.value return (((((((((((op == "=") or (op == "*=")) or (op == "/=")) or (op == "%=")) or (op == "+=")) or (op == "-=")) or (op == "<<=")) or (op == ">>=")) or (op == ">>>=")) or (op == "&=")) or (op == "^=")) or (op == "|=") def consumeSemicolon(): line = None if (ord(source[index]) if index < len(source) else None) == 59: lex() return line = lineNumber skipComment() if lineNumber != line: return if match(";"): lex() return if (lookahead.type != Token.EOF) and (not match("}")): throwUnexpected(lookahead) def isLeftHandSide(expr=None): return (expr.type == Syntax.Identifier) or (expr.type == Syntax.MemberExpression) def parseArrayInitialiser(): elements = [] expect("[") while not match("]"): if match(","): lex() elements.append(None) else: elements.append(parseAssignmentExpression()) if not match("]"): expect(",") expect("]") return delegate.createArrayExpression(elements) def parsePropertyFunction(param=None, first=None): global strict previousStrict = None body = None previousStrict = strict skipComment() delegate.markStart() body = parseFunctionSourceElements() if (first and strict) and isRestrictedWord(param[0].name): throwErrorTolerant(first, Messages.StrictParamName) strict = previousStrict return delegate.markEnd(delegate.createFunctionExpression(None, param, [], body)) def parseObjectPropertyKey(): token = None skipComment() delegate.markStart() token = lex() if (token.type == Token.StringLiteral) or (token.type == Token.NumericLiteral): if strict and token.octal: throwErrorTolerant(token, Messages.StrictOctalLiteral) return delegate.markEnd(delegate.createLiteral(token)) return delegate.markEnd(delegate.createIdentifier(token.value)) def parseObjectProperty(): token = None key = None id = None value = None param = None token = lookahead skipComment() delegate.markStart() if token.type == Token.Identifier: id = parseObjectPropertyKey() if (token.value == "get") and (not match(":")): key = parseObjectPropertyKey() expect("(") expect(")") value = parsePropertyFunction([]) return delegate.markEnd(delegate.createProperty("get", key, value)) if (token.value == "set") and (not match(":")): key = parseObjectPropertyKey() expect("(") token = lookahead if token.type != Token.Identifier: expect(")") throwErrorTolerant(token, Messages.UnexpectedToken, token.value) value = parsePropertyFunction([]) else: param = [parseVariableIdentifier()] expect(")") value = parsePropertyFunction(param, token) return delegate.markEnd(delegate.createProperty("set", key, value)) expect(":") value = parseAssignmentExpression() return delegate.markEnd(delegate.createProperty("init", id, value)) if (token.type == Token.EOF) or (token.type == Token.Punctuator): throwUnexpected(token) else: key = parseObjectPropertyKey() expect(":") value = parseAssignmentExpression() return delegate.markEnd(delegate.createProperty("init", key, value)) def parseObjectInitialiser(): properties = [] property = None name = None key = None kind = None map = jsdict({ }) toString = str expect("{") while not match("}"): property = parseObjectProperty() if property.key.type == Syntax.Identifier: name = property.key.name else: name = toString(property.key.value) kind = (PropertyKind.Data if property.kind == "init" else (PropertyKind.Get if property.kind == "get" else PropertyKind.Set)) key = "$" + name if key in map: if map[key] == PropertyKind.Data: if strict and (kind == PropertyKind.Data): throwErrorTolerant(jsdict({ }), Messages.StrictDuplicateProperty) elif kind != PropertyKind.Data: throwErrorTolerant(jsdict({ }), Messages.AccessorDataProperty) else: if kind == PropertyKind.Data: throwErrorTolerant(jsdict({ }), Messages.AccessorDataProperty) elif map[key] & kind: throwErrorTolerant(jsdict({ }), Messages.AccessorGetSet) map[key] |= kind else: map[key] = kind properties.append(property) if not match("}"): expect(",") expect("}") return delegate.createObjectExpression(properties) def parseGroupExpression(): expr = None expect("(") expr = parseExpression() expect(")") return expr def parsePrimaryExpression(): type = None token = None expr = None if match("("): return parseGroupExpression() type = lookahead.type delegate.markStart() if type == Token.Identifier: expr = delegate.createIdentifier(lex().value) elif (type == Token.StringLiteral) or (type == Token.NumericLiteral): if strict and lookahead.octal: throwErrorTolerant(lookahead, Messages.StrictOctalLiteral) expr = delegate.createLiteral(lex()) elif type == Token.Keyword: if matchKeyword("this"): lex() expr = delegate.createThisExpression() elif matchKeyword("function"): expr = parseFunctionExpression() elif type == Token.BooleanLiteral: token = lex() token.value = token.value == "true" expr = delegate.createLiteral(token) elif type == Token.NullLiteral: token = lex() token.value = None expr = delegate.createLiteral(token) elif match("["): expr = parseArrayInitialiser() elif match("{"): expr = parseObjectInitialiser() elif match("/") or match("/="): expr = delegate.createLiteral(scanRegExp()) if expr: return delegate.markEnd(expr) throwUnexpected(lex()) def parseArguments(): args = [] expect("(") if not match(")"): while index < length: args.append(parseAssignmentExpression()) if match(")"): break expect(",") expect(")") return args def parseNonComputedProperty(): token = None delegate.markStart() token = lex() if not isIdentifierName(token): throwUnexpected(token) return delegate.markEnd(delegate.createIdentifier(token.value)) def parseNonComputedMember(): expect(".") return parseNonComputedProperty() def parseComputedMember(): expr = None expect("[") expr = parseExpression() expect("]") return expr def parseNewExpression(): callee = None args = None delegate.markStart() expectKeyword("new") callee = parseLeftHandSideExpression() args = (parseArguments() if match("(") else []) return delegate.markEnd(delegate.createNewExpression(callee, args)) def parseLeftHandSideExpressionAllowCall(): marker = None expr = None args = None property = None marker = createLocationMarker() expr = (parseNewExpression() if matchKeyword("new") else parsePrimaryExpression()) while (match(".") or match("[")) or match("("): if match("("): args = parseArguments() expr = delegate.createCallExpression(expr, args) elif match("["): property = parseComputedMember() expr = delegate.createMemberExpression("[", expr, property) else: property = parseNonComputedMember() expr = delegate.createMemberExpression(".", expr, property) if marker: marker.end() marker.apply(expr) return expr def parseLeftHandSideExpression(): marker = None expr = None property = None marker = createLocationMarker() expr = (parseNewExpression() if matchKeyword("new") else parsePrimaryExpression()) while match(".") or match("["): if match("["): property = parseComputedMember() expr = delegate.createMemberExpression("[", expr, property) else: property = parseNonComputedMember() expr = delegate.createMemberExpression(".", expr, property) if marker: marker.end() marker.apply(expr) return expr def parsePostfixExpression(): expr = None token = None delegate.markStart() expr = parseLeftHandSideExpressionAllowCall() if lookahead.type == Token.Punctuator: if (match("++") or match("--")) and (not peekLineTerminator()): if (strict and (expr.type == Syntax.Identifier)) and isRestrictedWord(expr.name): throwErrorTolerant(jsdict({ }), Messages.StrictLHSPostfix) if not isLeftHandSide(expr): throwError(jsdict({ }), Messages.InvalidLHSInAssignment) token = lex() expr = delegate.createPostfixExpression(token.value, expr) return delegate.markEndIf(expr) def parseUnaryExpression(): token = None expr = None delegate.markStart() if (lookahead.type != Token.Punctuator) and (lookahead.type != Token.Keyword): expr = parsePostfixExpression() elif match("++") or match("--"): token = lex() expr = parseUnaryExpression() if (strict and (expr.type == Syntax.Identifier)) and isRestrictedWord(expr.name): throwErrorTolerant(jsdict({ }), Messages.StrictLHSPrefix) if not isLeftHandSide(expr): throwError(jsdict({ }), Messages.InvalidLHSInAssignment) expr = delegate.createUnaryExpression(token.value, expr) elif ((match("+") or match("-")) or match("~")) or match("!"): token = lex() expr = parseUnaryExpression() expr = delegate.createUnaryExpression(token.value, expr) elif (matchKeyword("delete") or matchKeyword("void")) or matchKeyword("typeof"): token = lex() expr = parseUnaryExpression() expr = delegate.createUnaryExpression(token.value, expr) if (strict and (expr.operator == "delete")) and (expr.argument.type == Syntax.Identifier): throwErrorTolerant(jsdict({ }), Messages.StrictDelete) else: expr = parsePostfixExpression() return delegate.markEndIf(expr) def binaryPrecedence(token=None, allowIn=None): prec = 0 if (token.type != Token.Punctuator) and (token.type != Token.Keyword): return 0 while 1: if token.value == "||": prec = 1 break elif token.value == "&&": prec = 2 break elif token.value == "|": prec = 3 break elif token.value == "^": prec = 4 break elif token.value == "&": prec = 5 break elif (token.value == "!==") or ((token.value == "===") or ((token.value == "!=") or (token.value == "=="))): prec = 6 break elif (token.value == "instanceof") or ((token.value == ">=") or ((token.value == "<=") or ((token.value == ">") or (token.value == "<")))): prec = 7 break elif token.value == "in": prec = (7 if allowIn else 0) break elif (token.value == ">>>") or ((token.value == ">>") or (token.value == "<<")): prec = 8 break elif (token.value == "-") or (token.value == "+"): prec = 9 break elif (token.value == "%") or ((token.value == "/") or (token.value == "*")): prec = 11 break else: break break return prec def parseBinaryExpression(): marker = None markers = None expr = None token = None prec = None previousAllowIn = None stack = None right = None operator = None left = None i = None previousAllowIn = state.allowIn state.allowIn = True marker = createLocationMarker() left = parseUnaryExpression() token = lookahead prec = binaryPrecedence(token, previousAllowIn) if prec == 0: return left token.prec = prec lex() markers = [marker, createLocationMarker()] right = parseUnaryExpression() stack = [left, token, right] prec = binaryPrecedence(lookahead, previousAllowIn) while prec > 0: while (len(stack) > 2) and (prec <= stack[len(stack) - 2].prec): right = stack.pop() operator = stack.pop().value left = stack.pop() expr = delegate.createBinaryExpression(operator, left, right) markers.pop() marker = markers.pop() if marker: marker.end() marker.apply(expr) stack.append(expr) markers.append(marker) token = lex() token.prec = prec stack.append(token) markers.append(createLocationMarker()) expr = parseUnaryExpression() stack.append(expr) prec = binaryPrecedence(lookahead, previousAllowIn) state.allowIn = previousAllowIn i = len(stack) - 1 expr = stack[i] markers.pop() while i > 1: expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr) i -= 2 marker = markers.pop() if marker: marker.end() marker.apply(expr) return expr def parseConditionalExpression(): expr = None previousAllowIn = None consequent = None alternate = None delegate.markStart() expr = parseBinaryExpression() if match("?"): lex() previousAllowIn = state.allowIn state.allowIn = True consequent = parseAssignmentExpression() state.allowIn = previousAllowIn expect(":") alternate = parseAssignmentExpression() expr = delegate.markEnd(delegate.createConditionalExpression(expr, consequent, alternate)) else: delegate.markEnd(jsdict({ })) return expr def parseAssignmentExpression(): token = None left = None right = None node = None token = lookahead delegate.markStart() left = parseConditionalExpression() node = left if matchAssign(): if not isLeftHandSide(left): throwError(jsdict({ }), Messages.InvalidLHSInAssignment) if (strict and (left.type == Syntax.Identifier)) and isRestrictedWord(left.name): throwErrorTolerant(token, Messages.StrictLHSAssignment) token = lex() right = parseAssignmentExpression() node = delegate.createAssignmentExpression(token.value, left, right) return delegate.markEndIf(node) def parseExpression(): expr = None delegate.markStart() expr = parseAssignmentExpression() if match(","): expr = delegate.createSequenceExpression([expr]) while index < length: if not match(","): break lex() expr.expressions.append(parseAssignmentExpression()) return delegate.markEndIf(expr) def parseStatementList(): list__py__ = [] statement = None while index < length: if match("}"): break statement = parseSourceElement() if ('undefined' if not 'statement' in locals() else typeof(statement)) == "undefined": break list__py__.append(statement) return list__py__ def parseBlock(): block = None skipComment() delegate.markStart() expect("{") block = parseStatementList() expect("}") return delegate.markEnd(delegate.createBlockStatement(block)) def parseVariableIdentifier(): token = None skipComment() delegate.markStart() token = lex() if token.type != Token.Identifier: throwUnexpected(token) return delegate.markEnd(delegate.createIdentifier(token.value)) def parseVariableDeclaration(kind=None): init = None id = None skipComment() delegate.markStart() id = parseVariableIdentifier() if strict and isRestrictedWord(id.name): throwErrorTolerant(jsdict({ }), Messages.StrictVarName) if kind == "const": expect("=") init = parseAssignmentExpression() elif match("="): lex() init = parseAssignmentExpression() return delegate.markEnd(delegate.createVariableDeclarator(id, init)) def parseVariableDeclarationList(kind=None): list__py__ = [] while 1: list__py__.append(parseVariableDeclaration(kind)) if not match(","): break lex() if not (index < length): break return list__py__ def parseVariableStatement(): declarations = None expectKeyword("var") declarations = parseVariableDeclarationList() consumeSemicolon() return delegate.createVariableDeclaration(declarations, "var") def parseConstLetDeclaration(kind=None): declarations = None skipComment() delegate.markStart() expectKeyword(kind) declarations = parseVariableDeclarationList(kind) consumeSemicolon() return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind)) def parseEmptyStatement(): expect(";") return delegate.createEmptyStatement() def parseExpressionStatement(): expr = parseExpression() consumeSemicolon() return delegate.createExpressionStatement(expr) def parseIfStatement(): test = None consequent = None alternate = None expectKeyword("if") expect("(") test = parseExpression() expect(")") consequent = parseStatement() if matchKeyword("else"): lex() alternate = parseStatement() else: alternate = None return delegate.createIfStatement(test, consequent, alternate) def parseDoWhileStatement(): body = None test = None oldInIteration = None expectKeyword("do") oldInIteration = state.inIteration state.inIteration = True body = parseStatement() state.inIteration = oldInIteration expectKeyword("while") expect("(") test = parseExpression() expect(")") if match(";"): lex() return delegate.createDoWhileStatement(body, test) def parseWhileStatement(): test = None body = None oldInIteration = None expectKeyword("while") expect("(") test = parseExpression() expect(")") oldInIteration = state.inIteration state.inIteration = True body = parseStatement() state.inIteration = oldInIteration return delegate.createWhileStatement(test, body) def parseForVariableDeclaration(): token = None declarations = None delegate.markStart() token = lex() declarations = parseVariableDeclarationList() return delegate.markEnd(delegate.createVariableDeclaration(declarations, token.value)) def parseForStatement(): init = None test = None update = None left = None right = None body = None oldInIteration = None update = None test = update init = test expectKeyword("for") expect("(") if match(";"): lex() else: if matchKeyword("var") or matchKeyword("let"): state.allowIn = False init = parseForVariableDeclaration() state.allowIn = True if (len(init.declarations) == 1) and matchKeyword("in"): lex() left = init right = parseExpression() init = None else: state.allowIn = False init = parseExpression() state.allowIn = True if matchKeyword("in"): if not isLeftHandSide(init): throwError(jsdict({ }), Messages.InvalidLHSInForIn) lex() left = init right = parseExpression() init = None if ('undefined' if not 'left' in locals() else typeof(left)) == "undefined": expect(";") if ('undefined' if not 'left' in locals() else typeof(left)) == "undefined": if not match(";"): test = parseExpression() expect(";") if not match(")"): update = parseExpression() expect(")") oldInIteration = state.inIteration state.inIteration = True body = parseStatement() state.inIteration = oldInIteration return (delegate.createForStatement(init, test, update, body) if ('undefined' if not 'left' in locals() else typeof(left)) == "undefined" else delegate.createForInStatement(left, right, body)) def parseContinueStatement(): label = None key = None expectKeyword("continue") if (ord(source[index]) if index < len(source) else None) == 59: lex() if not state.inIteration: throwError(jsdict({ }), Messages.IllegalContinue) return delegate.createContinueStatement(None) if peekLineTerminator(): if not state.inIteration: throwError(jsdict({ }), Messages.IllegalContinue) return delegate.createContinueStatement(None) if lookahead.type == Token.Identifier: label = parseVariableIdentifier() key = "$" + label.name if not (key in state.labelSet): throwError(jsdict({ }), Messages.UnknownLabel, label.name) consumeSemicolon() if (label == None) and (not state.inIteration): throwError(jsdict({ }), Messages.IllegalContinue) return delegate.createContinueStatement(label) def parseBreakStatement(): label = None key = None expectKeyword("break") if (ord(source[index]) if index < len(source) else None) == 59: lex() if not (state.inIteration or state.inSwitch): throwError(jsdict({ }), Messages.IllegalBreak) return delegate.createBreakStatement(None) if peekLineTerminator(): if not (state.inIteration or state.inSwitch): throwError(jsdict({ }), Messages.IllegalBreak) return delegate.createBreakStatement(None) if lookahead.type == Token.Identifier: label = parseVariableIdentifier() key = "$" + label.name if not (key in state.labelSet): throwError(jsdict({ }), Messages.UnknownLabel, label.name) consumeSemicolon() if (label == None) and (not (state.inIteration or state.inSwitch)): throwError(jsdict({ }), Messages.IllegalBreak) return delegate.createBreakStatement(label) def parseReturnStatement(): argument = None expectKeyword("return") if not state.inFunctionBody: throwErrorTolerant(jsdict({ }), Messages.IllegalReturn) if (ord(source[index]) if index < len(source) else None) == 32: if isIdentifierStart((ord(source[index + 1]) if (index + 1) < len(source) else None)): argument = parseExpression() consumeSemicolon() return delegate.createReturnStatement(argument) if peekLineTerminator(): return delegate.createReturnStatement(None) if not match(";"): if (not match("}")) and (lookahead.type != Token.EOF): argument = parseExpression() consumeSemicolon() return delegate.createReturnStatement(argument) def parseWithStatement(): object = None body = None if strict: throwErrorTolerant(jsdict({ }), Messages.StrictModeWith) expectKeyword("with") expect("(") object = parseExpression() expect(")") body = parseStatement() return delegate.createWithStatement(object, body) def parseSwitchCase(): test = None consequent = [] statement = None skipComment() delegate.markStart() if matchKeyword("default"): lex() test = None else: expectKeyword("case") test = parseExpression() expect(":") while index < length: if (match("}") or matchKeyword("default")) or matchKeyword("case"): break statement = parseStatement() consequent.append(statement) return delegate.markEnd(delegate.createSwitchCase(test, consequent)) def parseSwitchStatement(): discriminant = None cases = None clause = None oldInSwitch = None defaultFound = None expectKeyword("switch") expect("(") discriminant = parseExpression() expect(")") expect("{") if match("}"): lex() return delegate.createSwitchStatement(discriminant) cases = [] oldInSwitch = state.inSwitch state.inSwitch = True defaultFound = False while index < length: if match("}"): break clause = parseSwitchCase() if clause.test == None: if defaultFound: throwError(jsdict({ }), Messages.MultipleDefaultsInSwitch) defaultFound = True cases.append(clause) state.inSwitch = oldInSwitch expect("}") return delegate.createSwitchStatement(discriminant, cases) def parseThrowStatement(): argument = None expectKeyword("throw") if peekLineTerminator(): throwError(jsdict({ }), Messages.NewlineAfterThrow) argument = parseExpression() consumeSemicolon() return delegate.createThrowStatement(argument) def parseCatchClause(): param = None body = None skipComment() delegate.markStart() expectKeyword("catch") expect("(") if match(")"): throwUnexpected(lookahead) param = parseVariableIdentifier() if strict and isRestrictedWord(param.name): throwErrorTolerant(jsdict({ }), Messages.StrictCatchVariable) expect(")") body = parseBlock() return delegate.markEnd(delegate.createCatchClause(param, body)) def parseTryStatement(): block = None handlers = [] finalizer = None expectKeyword("try") block = parseBlock() if matchKeyword("catch"): handlers.append(parseCatchClause()) if matchKeyword("finally"): lex() finalizer = parseBlock() if (len(handlers) == 0) and (not finalizer): throwError(jsdict({ }), Messages.NoCatchOrFinally) return delegate.createTryStatement(block, [], handlers, finalizer) def parseDebuggerStatement(): expectKeyword("debugger") consumeSemicolon() return delegate.createDebuggerStatement() def parseStatement(): type = lookahead.type expr = None labeledBody = None key = None if type == Token.EOF: throwUnexpected(lookahead) skipComment() delegate.markStart() if type == Token.Punctuator: while 1: if lookahead.value == ";": return delegate.markEnd(parseEmptyStatement()) elif lookahead.value == "{": return delegate.markEnd(parseBlock()) elif lookahead.value == "(": return delegate.markEnd(parseExpressionStatement()) else: break break if type == Token.Keyword: while 1: if lookahead.value == "break": return delegate.markEnd(parseBreakStatement()) elif lookahead.value == "continue": return delegate.markEnd(parseContinueStatement()) elif lookahead.value == "debugger": return delegate.markEnd(parseDebuggerStatement()) elif lookahead.value == "do": return delegate.markEnd(parseDoWhileStatement()) elif lookahead.value == "for": return delegate.markEnd(parseForStatement()) elif lookahead.value == "function": return delegate.markEnd(parseFunctionDeclaration()) elif lookahead.value == "if": return delegate.markEnd(parseIfStatement()) elif lookahead.value == "return": return delegate.markEnd(parseReturnStatement()) elif lookahead.value == "switch": return delegate.markEnd(parseSwitchStatement()) elif lookahead.value == "throw": return delegate.markEnd(parseThrowStatement()) elif lookahead.value == "try": return delegate.markEnd(parseTryStatement()) elif lookahead.value == "var": return delegate.markEnd(parseVariableStatement()) elif lookahead.value == "while": return delegate.markEnd(parseWhileStatement()) elif lookahead.value == "with": return delegate.markEnd(parseWithStatement()) else: break break expr = parseExpression() if (expr.type == Syntax.Identifier) and match(":"): lex() key = "$" + expr.name if key in state.labelSet: throwError(jsdict({ }), Messages.Redeclaration, "Label", expr.name) state.labelSet[key] = True labeledBody = parseStatement() del state.labelSet[key] return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody)) consumeSemicolon() return delegate.markEnd(delegate.createExpressionStatement(expr)) def parseFunctionSourceElements(): global strict sourceElement = None sourceElements = [] token = None directive = None firstRestricted = None oldLabelSet = None oldInIteration = None oldInSwitch = None oldInFunctionBody = None skipComment() delegate.markStart() expect("{") while index < length: if lookahead.type != Token.StringLiteral: break token = lookahead sourceElement = parseSourceElement() sourceElements.append(sourceElement) if sourceElement.expression.type != Syntax.Literal: break directive = source[(token.range[0] + 1):(token.range[1] - 1)] if directive == "use strict": strict = True if firstRestricted: throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral) else: if (not firstRestricted) and token.octal: firstRestricted = token oldLabelSet = state.labelSet oldInIteration = state.inIteration oldInSwitch = state.inSwitch oldInFunctionBody = state.inFunctionBody state.labelSet = jsdict({ }) state.inIteration = False state.inSwitch = False state.inFunctionBody = True while index < length: if match("}"): break sourceElement = parseSourceElement() if ('undefined' if not 'sourceElement' in locals() else typeof(sourceElement)) == "undefined": break sourceElements.append(sourceElement) expect("}") state.labelSet = oldLabelSet state.inIteration = oldInIteration state.inSwitch = oldInSwitch state.inFunctionBody = oldInFunctionBody return delegate.markEnd(delegate.createBlockStatement(sourceElements)) def parseParams(firstRestricted=None): param = None params = [] token = None stricted = None paramSet = None key = None message = None expect("(") if not match(")"): paramSet = jsdict({ }) while index < length: token = lookahead param = parseVariableIdentifier() key = "$" + token.value if strict: if isRestrictedWord(token.value): stricted = token message = Messages.StrictParamName if key in paramSet: stricted = token message = Messages.StrictParamDupe elif not firstRestricted: if isRestrictedWord(token.value): firstRestricted = token message = Messages.StrictParamName elif isStrictModeReservedWord(token.value): firstRestricted = token message = Messages.StrictReservedWord elif key in paramSet: firstRestricted = token message = Messages.StrictParamDupe params.append(param) paramSet[key] = True if match(")"): break expect(",") expect(")") return jsdict({ "params": params, "stricted": stricted, "firstRestricted": firstRestricted, "message": message, }) def parseFunctionDeclaration(): global strict id = None params = [] body = None token = None stricted = None tmp = None firstRestricted = None message = None previousStrict = None skipComment() delegate.markStart() expectKeyword("function") token = lookahead id = parseVariableIdentifier() if strict: if isRestrictedWord(token.value): throwErrorTolerant(token, Messages.StrictFunctionName) else: if isRestrictedWord(token.value): firstRestricted = token message = Messages.StrictFunctionName elif isStrictModeReservedWord(token.value): firstRestricted = token message = Messages.StrictReservedWord tmp = parseParams(firstRestricted) params = tmp.params stricted = tmp.stricted firstRestricted = tmp.firstRestricted if tmp.message: message = tmp.message previousStrict = strict body = parseFunctionSourceElements() if strict and firstRestricted: throwError(firstRestricted, message) if strict and stricted: throwErrorTolerant(stricted, message) strict = previousStrict return delegate.markEnd(delegate.createFunctionDeclaration(id, params, [], body)) def parseFunctionExpression(): global strict token = None id = None stricted = None firstRestricted = None message = None tmp = None params = [] body = None previousStrict = None delegate.markStart() expectKeyword("function") if not match("("): token = lookahead id = parseVariableIdentifier() if strict: if isRestrictedWord(token.value): throwErrorTolerant(token, Messages.StrictFunctionName) else: if isRestrictedWord(token.value): firstRestricted = token message = Messages.StrictFunctionName elif isStrictModeReservedWord(token.value): firstRestricted = token message = Messages.StrictReservedWord tmp = parseParams(firstRestricted) params = tmp.params stricted = tmp.stricted firstRestricted = tmp.firstRestricted if tmp.message: message = tmp.message previousStrict = strict body = parseFunctionSourceElements() if strict and firstRestricted: throwError(firstRestricted, message) if strict and stricted: throwErrorTolerant(stricted, message) strict = previousStrict return delegate.markEnd(delegate.createFunctionExpression(id, params, [], body)) def parseSourceElement(): if lookahead.type == Token.Keyword: while 1: if (lookahead.value == "let") or (lookahead.value == "const"): return parseConstLetDeclaration(lookahead.value) elif lookahead.value == "function": return parseFunctionDeclaration() else: return parseStatement() break if lookahead.type != Token.EOF: return parseStatement() def parseSourceElements(): global strict sourceElement = None sourceElements = [] token = None directive = None firstRestricted = None while index < length: token = lookahead if token.type != Token.StringLiteral: break sourceElement = parseSourceElement() sourceElements.append(sourceElement) if sourceElement.expression.type != Syntax.Literal: break directive = source[(token.range[0] + 1):(token.range[1] - 1)] if directive == "use strict": strict = True if firstRestricted: throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral) else: if (not firstRestricted) and token.octal: firstRestricted = token while index < length: sourceElement = parseSourceElement() if ('undefined' if not 'sourceElement' in locals() else typeof(sourceElement)) == "undefined": break sourceElements.append(sourceElement) return sourceElements def parseProgram(): global strict body = None skipComment() delegate.markStart() strict = False peek() body = parseSourceElements() return delegate.markEnd(delegate.createProgram(body)) def collectToken(): start = None loc = None token = None range = None value = None skipComment() start = index loc = jsdict({ "start": jsdict({ "line": lineNumber, "column": index - lineStart, }), }) token = extra.advance() loc.end = jsdict({ "line": lineNumber, "column": index - lineStart, }) if token.type != Token.EOF: range = [token.range[0], token.range[1]] value = source[token.range[0]:token.range[1]] extra.tokens.append(jsdict({ "type": TokenName[token.type], "value": value, "range": range, "loc": loc, })) return token def collectRegex(): pos = None loc = None regex = None token = None skipComment() pos = index loc = jsdict({ "start": jsdict({ "line": lineNumber, "column": index - lineStart, }), }) regex = extra.scanRegExp() loc.end = jsdict({ "line": lineNumber, "column": index - lineStart, }) if not extra.tokenize: if len(extra.tokens) > 0: token = extra.tokens[len(extra.tokens) - 1] if (token.range[0] == pos) and (token.type == "Punctuator"): if (token.value == "/") or (token.value == "/="): extra.tokens.pop() extra.tokens.append(jsdict({ "type": "RegularExpression", "value": regex.literal, "range": [pos, index], "loc": loc, })) return regex def filterTokenLocation(): i = None entry = None token = None tokens = [] i = 0 while 1: if not (i < len(extra.tokens)): break entry = extra.tokens[i] token = jsdict({ "type": entry.type, "value": entry.value, }) if extra.range: token.range = entry.range if extra.loc: token.loc = entry.loc tokens.append(token) i += 1 extra.tokens = tokens class LocationMarker(object): def __init__(self=None): self.marker = [index, lineNumber, index - lineStart, 0, 0, 0] def end(self=None): self.marker[3] = index self.marker[4] = lineNumber self.marker[5] = index - lineStart def apply(self=None, node=None): if extra.range: node.range = [self.marker[0], self.marker[3]] if extra.loc: node.loc = jsdict({ "start": jsdict({ "line": self.marker[1], "column": self.marker[2], }), "end": jsdict({ "line": self.marker[4], "column": self.marker[5], }), }) node = delegate.postProcess(node) def createLocationMarker(): if (not extra.loc) and (not extra.range): return None skipComment() return LocationMarker() def patch(): global advance, scanRegExp if ('undefined' if not ('tokens' in extra) else typeof(extra.tokens)) != "undefined": extra.advance = advance extra.scanRegExp = scanRegExp advance = collectToken scanRegExp = collectRegex def unpatch(): global advance, scanRegExp if ('undefined' if not ('scanRegExp' in extra) else typeof(extra.scanRegExp)) == "function": advance = extra.advance scanRegExp = extra.scanRegExp def tokenize(code, **options): global delegate, source, index, lineNumber, lineStart, length, lookahead, state, extra options = jsdict(options) toString = None token = None tokens = None toString = str if (('undefined' if not 'code' in locals() else typeof(code)) != "string") and (not isinstance(code, str)): code = toString(code) delegate = SyntaxTreeDelegate source = code index = 0 lineNumber = (1 if len(source) > 0 else 0) lineStart = 0 length = len(source) lookahead = None state = jsdict({ "allowIn": True, "labelSet": jsdict({ }), "inFunctionBody": False, "inIteration": False, "inSwitch": False, "lastCommentStart": -1, }) extra = jsdict({ }) options = options or jsdict({ }) options.tokens = True extra.tokens = [] extra.tokenize = True extra.openParenToken = -1 extra.openCurlyToken = -1 extra.range = (('undefined' if not ('range' in options) else typeof(options.range)) == "boolean") and options.range extra.loc = (('undefined' if not ('loc' in options) else typeof(options.loc)) == "boolean") and options.loc if (('undefined' if not ('comment' in options) else typeof(options.comment)) == "boolean") and options.comment: extra.comments = [] if (('undefined' if not ('tolerant' in options) else typeof(options.tolerant)) == "boolean") and options.tolerant: extra.errors = [] if length > 0: if (typeof(source[0])) == "undefined": if isinstance(code, str): source = code.valueOf() patch() try: peek() if lookahead.type == Token.EOF: return extra.tokens token = lex() while lookahead.type != Token.EOF: try: token = lex() except Exception as lexError: token = lookahead if extra.errors: extra.errors.append(lexError) break else: raise filterTokenLocation() tokens = extra.tokens if ('undefined' if not ('comments' in extra) else typeof(extra.comments)) != "undefined": tokens.comments = extra.comments if ('undefined' if not ('errors' in extra) else typeof(extra.errors)) != "undefined": tokens.errors = extra.errors except Exception as e: raise finally: unpatch() extra = jsdict({ }) return tokens def parse(code, **options): global delegate, source, index, lineNumber, lineStart, length, lookahead, state, extra options = jsdict(options) program = None toString = None toString = str if (('undefined' if not 'code' in locals() else typeof(code)) != "string") and (not isinstance(code, str)): code = toString(code) delegate = SyntaxTreeDelegate source = code index = 0 lineNumber = (1 if len(source) > 0 else 0) lineStart = 0 length = len(source) lookahead = None state = jsdict({ "allowIn": True, "labelSet": jsdict({ }), "inFunctionBody": False, "inIteration": False, "inSwitch": False, "lastCommentStart": -1, "markerStack": [], }) extra = jsdict({ }) if ('undefined' if not 'options' in locals() else typeof(options)) != "undefined": extra.range = (('undefined' if not ('range' in options) else typeof(options.range)) == "boolean") and options.range extra.loc = (('undefined' if not ('loc' in options) else typeof(options.loc)) == "boolean") and options.loc if (extra.loc and (options.source != None)) and (options.source != undefined): extra.source = toString(options.source) if (('undefined' if not ('tokens' in options) else typeof(options.tokens)) == "boolean") and options.tokens: extra.tokens = [] if (('undefined' if not ('comment' in options) else typeof(options.comment)) == "boolean") and options.comment: extra.comments = [] if (('undefined' if not ('tolerant' in options) else typeof(options.tolerant)) == "boolean") and options.tolerant: extra.errors = [] if length > 0: if (typeof(source[0])) == "undefined": if isinstance(code, str): source = code.valueOf() patch() try: program = parseProgram() if ('undefined' if not ('comments' in extra) else typeof(extra.comments)) != "undefined": program.comments = extra.comments if ('undefined' if not ('tokens' in extra) else typeof(extra.tokens)) != "undefined": filterTokenLocation() program.tokens = extra.tokens if ('undefined' if not ('errors' in extra) else typeof(extra.errors)) != "undefined": program.errors = extra.errors except Exception as e: raise finally: unpatch() extra = jsdict({ }) return program parse('var = 490 \n a=4;')
gpl-2.0
[ 3, 1603, 7698, 2381, 4825, 55, 12, 2945, 473, 911, 2218, 3002, 5705, 446, 8298, 12930, 436, 8034, 14, 199, 199, 3, 221, 1898, 334, 35, 9, 6171, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6171, 3868, 350, 11192, 377, 89, 76, 665, 273, 350, 11192, 14, 369, 76, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 21066, 2241, 699, 1236, 8764, 665, 3442, 2241, 32, 23104, 14249, 14, 1235, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 7135, 941, 13, 55, 1017, 5088, 5711, 397, 266, 7879, 78, 665, 743, 941, 13, 87, 1017, 32, 656, 5711, 397, 266, 7879, 78, 14, 7530, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1804, 5719, 1804, 583, 279, 665, 75, 5719, 14, 75, 583, 279, 32, 559, 88, 285, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1488, 527, 85, 415, 428, 9494, 3210, 73, 665, 337, 292, 5865, 14, 266, 65, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1952, 6226, 699, 1384, 736, 665, 285, 6226, 14, 66, 1384, 736, 32, 3098, 1198, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 7760, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 420, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 221, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 221, 9315, 9706, 14, 1621, 4825, 6461, 7000, 665, 32324, 5716, 29785, 30, 6262, 7024, 2381, 1821, 199, 3, 221, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 221, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 221, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 221, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 221, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 199, 3, 221, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 1882, 2803, 26, 16899, 13, 17, 1882, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 295, 199, 318, 730, 1618, 8, 84, 304, 272, 340, 307, 365, 488, 26, 372, 283, 10705, 7, 272, 916, 1228, 8, 84, 12, 2155, 304, 372, 283, 4871, 7, 272, 916, 1228, 8, 84, 12, 620, 304, 372, 283, 875, 7, 272, 916, 1228, 8, 84, 12, 1109, 9, 503, 1228, 8, 84, 12, 2069, 304, 372, 283, 1955, 7, 272, 916, 2688, 8, 84, 12, 2560, 1250, 12168, 372, 283, 1593, 7, 272, 587, 26, 372, 283, 785, 7, 199, 199, 318, 769, 63, 31397, 8, 76, 12, 373, 304, 272, 862, 26, 267, 372, 634, 14, 1080, 8, 86, 9, 272, 871, 26, 267, 372, 446, 17, 199, 199, 1122, 5136, 275, 2069, 199, 1122, 3241, 275, 1109, 199, 199, 533, 8586, 807, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 366, 304, 267, 291, 855, 807, 4343, 873, 8, 68, 9, 272, 347, 636, 6095, 721, 277, 12, 536, 304, 267, 340, 536, 315, 291, 855, 807, 10651, 881, 372, 291, 855, 807, 12298, 354, 61, 267, 587, 26, 881, 372, 488, 272, 347, 636, 8617, 721, 277, 12, 536, 12, 574, 304, 267, 291, 855, 807, 12298, 354, 61, 275, 574, 267, 372, 574, 272, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 12, 536, 9, 267, 871, 26, 288, 372, 488, 272, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 291, 59, 354, 61, 275, 574, 267, 372, 574, 272, 347, 636, 6134, 721, 277, 12, 536, 304, 267, 372, 536, 315, 291, 855, 807, 363, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 620, 8, 277, 855, 807, 3368, 199, 199, 533, 5044, 4527, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3851, 12, 3285, 9280, 267, 291, 14, 2469, 275, 3285, 267, 1134, 2469, 275, 378, 1204, 295, 14, 45, 340, 283, 77, 7, 315, 3285, 587, 378, 1204, 295, 14, 41, 340, 283, 73, 7, 315, 3285, 587, 378, 267, 291, 14, 1365, 275, 3851, 267, 291, 14, 3401, 275, 295, 14, 2014, 8, 3401, 12, 1134, 2469, 9, 272, 347, 511, 8, 277, 12, 308, 304, 267, 372, 291, 14, 3401, 14, 1733, 8, 83, 9, 365, 440, 488, 199, 199, 6614, 275, 8586, 807, 6333, 793, 582, 1361, 1552, 199, 199, 318, 636, 808, 363, 2260, 8, 785, 29, 403, 12, 2396, 29, 403, 304, 272, 372, 8586, 807, 2561, 199, 2, 466, 582, 18377, 14, 3007, 15173, 12, 199, 2, 785, 582, 909, 12, 199, 2, 2030, 582, 2396, 12, 199, 1552, 199, 199, 318, 636, 808, 363, 2953, 8, 396, 29, 403, 12, 2396, 29, 403, 304, 272, 372, 8586, 807, 2561, 199, 2, 466, 582, 18377, 14, 25215, 15173, 12, 199, 2, 396, 582 ]
[ 1603, 7698, 2381, 4825, 55, 12, 2945, 473, 911, 2218, 3002, 5705, 446, 8298, 12930, 436, 8034, 14, 199, 199, 3, 221, 1898, 334, 35, 9, 6171, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6171, 3868, 350, 11192, 377, 89, 76, 665, 273, 350, 11192, 14, 369, 76, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 21066, 2241, 699, 1236, 8764, 665, 3442, 2241, 32, 23104, 14249, 14, 1235, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 7135, 941, 13, 55, 1017, 5088, 5711, 397, 266, 7879, 78, 665, 743, 941, 13, 87, 1017, 32, 656, 5711, 397, 266, 7879, 78, 14, 7530, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1804, 5719, 1804, 583, 279, 665, 75, 5719, 14, 75, 583, 279, 32, 559, 88, 285, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1488, 527, 85, 415, 428, 9494, 3210, 73, 665, 337, 292, 5865, 14, 266, 65, 32, 6799, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 6029, 1952, 6226, 699, 1384, 736, 665, 285, 6226, 14, 66, 1384, 736, 32, 3098, 1198, 14, 957, 30, 199, 3, 221, 1898, 334, 35, 9, 7760, 31153, 11552, 869, 344, 1187, 292, 665, 759, 11552, 14, 18209, 1187, 292, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 420, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 221, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 221, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 221, 9315, 9706, 14, 1621, 4825, 6461, 7000, 665, 32324, 5716, 29785, 30, 6262, 7024, 2381, 1821, 199, 3, 221, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 221, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 221, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 221, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 221, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 199, 3, 221, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 1882, 2803, 26, 16899, 13, 17, 1882, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 295, 199, 318, 730, 1618, 8, 84, 304, 272, 340, 307, 365, 488, 26, 372, 283, 10705, 7, 272, 916, 1228, 8, 84, 12, 2155, 304, 372, 283, 4871, 7, 272, 916, 1228, 8, 84, 12, 620, 304, 372, 283, 875, 7, 272, 916, 1228, 8, 84, 12, 1109, 9, 503, 1228, 8, 84, 12, 2069, 304, 372, 283, 1955, 7, 272, 916, 2688, 8, 84, 12, 2560, 1250, 12168, 372, 283, 1593, 7, 272, 587, 26, 372, 283, 785, 7, 199, 199, 318, 769, 63, 31397, 8, 76, 12, 373, 304, 272, 862, 26, 267, 372, 634, 14, 1080, 8, 86, 9, 272, 871, 26, 267, 372, 446, 17, 199, 199, 1122, 5136, 275, 2069, 199, 1122, 3241, 275, 1109, 199, 199, 533, 8586, 807, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 366, 304, 267, 291, 855, 807, 4343, 873, 8, 68, 9, 272, 347, 636, 6095, 721, 277, 12, 536, 304, 267, 340, 536, 315, 291, 855, 807, 10651, 881, 372, 291, 855, 807, 12298, 354, 61, 267, 587, 26, 881, 372, 488, 272, 347, 636, 8617, 721, 277, 12, 536, 12, 574, 304, 267, 291, 855, 807, 12298, 354, 61, 275, 574, 267, 372, 574, 272, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 12, 536, 9, 267, 871, 26, 288, 372, 488, 272, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 291, 59, 354, 61, 275, 574, 267, 372, 574, 272, 347, 636, 6134, 721, 277, 12, 536, 304, 267, 372, 536, 315, 291, 855, 807, 363, 272, 347, 636, 2722, 721, 277, 304, 267, 372, 620, 8, 277, 855, 807, 3368, 199, 199, 533, 5044, 4527, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 3851, 12, 3285, 9280, 267, 291, 14, 2469, 275, 3285, 267, 1134, 2469, 275, 378, 1204, 295, 14, 45, 340, 283, 77, 7, 315, 3285, 587, 378, 1204, 295, 14, 41, 340, 283, 73, 7, 315, 3285, 587, 378, 267, 291, 14, 1365, 275, 3851, 267, 291, 14, 3401, 275, 295, 14, 2014, 8, 3401, 12, 1134, 2469, 9, 272, 347, 511, 8, 277, 12, 308, 304, 267, 372, 291, 14, 3401, 14, 1733, 8, 83, 9, 365, 440, 488, 199, 199, 6614, 275, 8586, 807, 6333, 793, 582, 1361, 1552, 199, 199, 318, 636, 808, 363, 2260, 8, 785, 29, 403, 12, 2396, 29, 403, 304, 272, 372, 8586, 807, 2561, 199, 2, 466, 582, 18377, 14, 3007, 15173, 12, 199, 2, 785, 582, 909, 12, 199, 2, 2030, 582, 2396, 12, 199, 1552, 199, 199, 318, 636, 808, 363, 2953, 8, 396, 29, 403, 12, 2396, 29, 403, 304, 272, 372, 8586, 807, 2561, 199, 2, 466, 582, 18377, 14, 25215, 15173, 12, 199, 2, 396, 582, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
krelbel/ALttPLinkSpriteSwapper
Main.py
1
4488
import logging import argparse import os __version__ = '0.1-dev' #Usage: python Main.py --write --sprite zelda.spr --rom lttpromtobepatched.sfc #generates zelda_lttpromtobepatched.sfc # python Main.py --read --sprite zelda.spr --rom lttpromtobescanned.sfc #generates zelda.spr #General rom patching logic copied from https://github.com/LLCoolDave/ALttPEntranceRandomizer def write_byte(rom, address, value): rom[address] = value def write_bytes(rom, startaddress, values): for i, value in enumerate(values): write_byte(rom, startaddress + i, value) def patch_rom(args, rom, sprite, palette): write_bytes(rom, 0x80000, sprite) write_bytes(rom, 0xdd308, palette) # Frame advance logic copied from https://www.zeldix.net/t242-dummied-out-frame-control-in-zelda-lttp if args.frameadvance: rom[0x39] = 0xEA rom[0x3A] = 0xEA return rom def create_sprite(args): logger = logging.getLogger('') logger.info('Creating sprite file.') rom = bytearray(open(args.rom, 'rb').read()) sprite = bytearray(28672+120) #copy spritesheet for i in range(28672): sprite[i] = rom[0x80000+i] #copy palette for i in range(120): sprite[28672+i] = rom[0xdd308+i] outfilename = '%s' % (args.sprite) with open('%s' % outfilename, 'wb') as outfile: outfile.write(sprite) logger.info('Done.') return sprite def create_patched_rom(args): logger = logging.getLogger('') logger.info('Patching ROM.') spritesheet = bytearray(open(args.sprite, 'rb').read()) rom = bytearray(open(args.rom, 'rb').read()) sprite = bytearray(28672) palette = bytearray(120) for i in range(28672): sprite[i] = spritesheet[i] for i in range(120): palette[i] = spritesheet[28672+i] patched_rom = patch_rom(args, rom, sprite, palette) outfilename = '%s_%s' % (os.path.basename(args.sprite).replace(".spr",""), os.path.basename(args.rom)) with open('%s' % outfilename, 'wb') as outfile: outfile.write(patched_rom) logger.info('Done.') return patched_rom def main(args): if args.write: create_patched_rom(args) return if args.read: create_sprite(args) return if __name__ == '__main__': parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--loglevel', default='info', const='info', nargs='?', choices=['error', 'info', 'warning', 'debug'], help='Select level of logging for output.') parser.add_argument('--sprite', help='Path to a sprite sheet to use for Link. Needs to be in binary format and have a length of 0x7000 (28672) (sprite) followed by 0x78 (120) (palette) bytes.') parser.add_argument('--rom', help='Path to a lttp rom to be patched.') parser.add_argument('--write', help='Patches rom with provided sprite file', action='store_true') parser.add_argument('--read', help='Creates sprite file from provided rom', action='store_true') parser.add_argument('--frameadvance', help='Patches rom with the frame advance feature for sprite work (press L to freeze, R to advance a single frame, L to resume) (default: off)', action='store_true') args = parser.parse_args() if (args.read and args.write) or ((args.read != True) and (args.write != True)): input('Need to specify whether to read or write sprite. Please run with -h to see help for further information. \nPress Enter to exit.') exit(1) if args.rom is None: input('No rom specified. Please run with -h to see help for further information. \nPress Enter to exit.') exit(1) if args.sprite is None: input('No sprite specified. Please run with -h to see help for further information. \nPress Enter to exit.') exit(1) if not os.path.isfile(args.rom): input('Could not find valid rom for patching at path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom) exit(1) if not os.path.isfile(args.rom): input('Could not find link sprite sheet at path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.sprite) exit(1) # set up logger loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel] logging.basicConfig(format='%(message)s', level=loglevel) main(args)
mit
[ 646, 2050, 199, 646, 7534, 199, 646, 747, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 13, 2374, 7, 199, 199, 3, 7692, 26, 2366, 11298, 14, 647, 1553, 952, 1553, 15972, 1315, 457, 65, 14, 681, 82, 1553, 417, 634, 3370, 417, 475, 1235, 22631, 14, 83, 3003, 327, 2038, 2335, 1315, 457, 65, 63, 76, 3370, 417, 475, 1235, 22631, 14, 83, 3003, 199, 3, 755, 2366, 11298, 14, 647, 1553, 739, 1553, 15972, 1315, 457, 65, 14, 681, 82, 1553, 417, 634, 3370, 417, 475, 11562, 31126, 14, 83, 3003, 327, 2038, 2335, 1315, 457, 65, 14, 681, 82, 199, 3, 14109, 221, 417, 3371, 316, 9661, 8876, 687, 4178, 921, 5031, 14, 957, 15, 4464, 967, 393, 36, 811, 15, 748, 6215, 1510, 343, 31331, 3883, 1793, 199, 199, 318, 2218, 63, 4414, 8, 417, 12, 2287, 12, 574, 304, 272, 221, 417, 59, 1562, 61, 275, 574, 199, 199, 318, 2218, 63, 2394, 8, 417, 12, 1343, 1562, 12, 1338, 304, 272, 367, 284, 12, 574, 315, 3874, 8, 1459, 304, 267, 2218, 63, 4414, 8, 417, 12, 1343, 1562, 435, 284, 12, 574, 9, 199, 199, 318, 3371, 63, 417, 8, 589, 12, 221, 417, 12, 17325, 12, 17986, 304, 272, 2218, 63, 2394, 8, 417, 12, 378, 88, 24, 993, 12, 17325, 9, 272, 2218, 63, 2394, 8, 417, 12, 378, 11110, 12127, 12, 17986, 9, 339, 327, 11726, 18695, 9661, 8876, 687, 4178, 921, 1544, 14, 90, 352, 19299, 14, 846, 15, 84, 13212, 13, 27512, 2664, 379, 13, 548, 13, 1943, 13, 2785, 13, 262, 13, 90, 457, 65, 13, 76, 3370, 272, 340, 1249, 14, 1943, 21195, 26, 267, 221, 417, 59, 16, 88, 1355, 61, 275, 378, 6991, 33, 267, 221, 417, 59, 16, 88, 19, 33, 61, 275, 378, 6991, 33, 339, 372, 221, 417, 199, 199, 318, 1218, 63, 15972, 8, 589, 304, 272, 2512, 275, 2050, 14, 5572, 8355, 339, 2512, 14, 815, 360, 14380, 17325, 570, 2659, 339, 221, 417, 275, 11640, 8, 1490, 8, 589, 14, 417, 12, 283, 4848, 1959, 739, 1012, 339, 17325, 275, 11640, 8, 11125, 2819, 11, 6708, 9, 339, 327, 1574, 25328, 3797, 272, 367, 284, 315, 1425, 8, 11125, 2819, 304, 267, 17325, 59, 73, 61, 275, 221, 417, 59, 16, 88, 24, 993, 11, 73, 61, 339, 327, 1574, 17986, 272, 367, 284, 315, 1425, 8, 6708, 304, 267, 17325, 59, 11125, 2819, 11, 73, 61, 275, 221, 417, 59, 16, 11110, 12127, 11, 73, 61, 339, 734, 1501, 275, 1543, 83, 7, 450, 334, 589, 14, 15972, 9, 339, 543, 1551, 3508, 83, 7, 450, 734, 1501, 12, 283, 6603, 358, 465, 4386, 26, 267, 4386, 14, 952, 8, 15972, 9, 339, 2512, 14, 815, 360, 10759, 2659, 339, 372, 17325, 199, 199, 318, 1218, 63, 22631, 63, 417, 8, 589, 304, 272, 2512, 275, 2050, 14, 5572, 8355, 339, 2512, 14, 815, 360, 11173, 316, 820, 7474, 2659, 339, 25328, 3797, 275, 11640, 8, 1490, 8, 589, 14, 15972, 12, 283, 4848, 1959, 739, 1012, 339, 221, 417, 275, 11640, 8, 1490, 8, 589, 14, 417, 12, 283, 4848, 1959, 739, 1012, 339, 17325, 275, 11640, 8, 11125, 2819, 9, 339, 17986, 275, 11640, 8, 6708, 9, 339, 367, 284, 315, 1425, 8, 11125, 2819, 304, 267, 17325, 59, 73, 61, 275, 25328, 3797, 59, 73, 61, 339, 367, 284, 315, 1425, 8, 6708, 304, 267, 17986, 59, 73, 61, 275, 25328, 3797, 59, 11125, 2819, 11, 73, 61, 339, 19483, 63, 417, 275, 3371, 63, 417, 8, 589, 12, 221, 417, 12, 17325, 12, 17986, 9, 339, 734, 1501, 275, 1543, 83, 4970, 83, 7, 450, 334, 736, 14, 515, 14, 4846, 8, 589, 14, 15972, 680, 1814, 9520, 681, 82, 401, 341, 395, 747, 14, 515, 14, 4846, 8, 589, 14, 417, 430, 339, 543, 1551, 3508, 83, 7, 450, 734, 1501, 12, 283, 6603, 358, 465, 4386, 26, 267, 4386, 14, 952, 8, 22631, 63, 417, 9, 339, 2512, 14, 815, 360, 10759, 2659, 339, 372, 19483, 63, 417, 199, 199, 318, 2446, 8, 589, 304, 272, 340, 1249, 14, 952, 26, 267, 1218, 63, 22631, 63, 417, 8, 589, 9, 267, 372, 339, 340, 1249, 14, 739, 26, 267, 1218, 63, 15972, 8, 589, 9, 267, 372, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1798, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 272, 1798, 14, 525, 63, 2094, 4517, 26629, 297, 849, 534, 815, 297, 950, 534, 815, 297, 9237, 31468, 3415, 2968, 705, 297, 283, 815, 297, 283, 3764, 297, 283, 1757, 995, 1720, 534, 5446, 2166, 402, 2050, 367, 1072, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 15972, 297, 1720, 534, 2042, 370, 282, 17325, 12083, 370, 675, 367, 10967, 14, 29613, 370, 506, 315, 3366, 1475, 436, 1172, 282, 2582, 402, 378, 88, 23, 1493, 334, 11125, 2819, 9, 334, 15972, 9, 9437, 701, 378, 88, 2277, 334, 6708, 9, 334, 16506, 9, 2783, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 417, 297, 1720, 534, 2042, 370, 282, 634, 3370, 221, 417, 370, 506, 19483, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 952, 297, 1720, 534, 11173, 397, 221, 417, 543, 2741, 17325, 570, 297, 1595, 534, 1617, 63, 2052, 358, 272, 1798, 14, 525, 63, 2094, 4517, 739, 297, 1720, 534, 10607, 17325, 570, 687, 2741, 221, 417, 297, 1595, 534, 1617, 63, 2052, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1943, 21195, 297, 1720, 534, 11173, 397, 221, 417, 543, 314, 2787, 18695, 3878, 367, 17325, 1736, 334, 2915, 491, 370, 22778, 12, 820, 370, 18695, 282, 2849, 2787, 12, 491, 370, 14604, 9, 334, 885, 26, 2331, 3196, 1595, 534, 1617, 63, 2052, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 334, 589, 14, 739, 436, 1249, 14, 952, 9, 503, 3666, 589, 14, 739, 1137, 715, 9, 436, 334, 589, 14, 952, 1137, 715, 2298, 267, 1324, 360, 17809, 370, 4165, 3775, 370, 1586, 503, 2218, 17325, 14, 7754, 1255, 543, 446, 72, 370, 1937, 1720 ]
[ 2050, 199, 646, 7534, 199, 646, 747, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 13, 2374, 7, 199, 199, 3, 7692, 26, 2366, 11298, 14, 647, 1553, 952, 1553, 15972, 1315, 457, 65, 14, 681, 82, 1553, 417, 634, 3370, 417, 475, 1235, 22631, 14, 83, 3003, 327, 2038, 2335, 1315, 457, 65, 63, 76, 3370, 417, 475, 1235, 22631, 14, 83, 3003, 199, 3, 755, 2366, 11298, 14, 647, 1553, 739, 1553, 15972, 1315, 457, 65, 14, 681, 82, 1553, 417, 634, 3370, 417, 475, 11562, 31126, 14, 83, 3003, 327, 2038, 2335, 1315, 457, 65, 14, 681, 82, 199, 3, 14109, 221, 417, 3371, 316, 9661, 8876, 687, 4178, 921, 5031, 14, 957, 15, 4464, 967, 393, 36, 811, 15, 748, 6215, 1510, 343, 31331, 3883, 1793, 199, 199, 318, 2218, 63, 4414, 8, 417, 12, 2287, 12, 574, 304, 272, 221, 417, 59, 1562, 61, 275, 574, 199, 199, 318, 2218, 63, 2394, 8, 417, 12, 1343, 1562, 12, 1338, 304, 272, 367, 284, 12, 574, 315, 3874, 8, 1459, 304, 267, 2218, 63, 4414, 8, 417, 12, 1343, 1562, 435, 284, 12, 574, 9, 199, 199, 318, 3371, 63, 417, 8, 589, 12, 221, 417, 12, 17325, 12, 17986, 304, 272, 2218, 63, 2394, 8, 417, 12, 378, 88, 24, 993, 12, 17325, 9, 272, 2218, 63, 2394, 8, 417, 12, 378, 11110, 12127, 12, 17986, 9, 339, 327, 11726, 18695, 9661, 8876, 687, 4178, 921, 1544, 14, 90, 352, 19299, 14, 846, 15, 84, 13212, 13, 27512, 2664, 379, 13, 548, 13, 1943, 13, 2785, 13, 262, 13, 90, 457, 65, 13, 76, 3370, 272, 340, 1249, 14, 1943, 21195, 26, 267, 221, 417, 59, 16, 88, 1355, 61, 275, 378, 6991, 33, 267, 221, 417, 59, 16, 88, 19, 33, 61, 275, 378, 6991, 33, 339, 372, 221, 417, 199, 199, 318, 1218, 63, 15972, 8, 589, 304, 272, 2512, 275, 2050, 14, 5572, 8355, 339, 2512, 14, 815, 360, 14380, 17325, 570, 2659, 339, 221, 417, 275, 11640, 8, 1490, 8, 589, 14, 417, 12, 283, 4848, 1959, 739, 1012, 339, 17325, 275, 11640, 8, 11125, 2819, 11, 6708, 9, 339, 327, 1574, 25328, 3797, 272, 367, 284, 315, 1425, 8, 11125, 2819, 304, 267, 17325, 59, 73, 61, 275, 221, 417, 59, 16, 88, 24, 993, 11, 73, 61, 339, 327, 1574, 17986, 272, 367, 284, 315, 1425, 8, 6708, 304, 267, 17325, 59, 11125, 2819, 11, 73, 61, 275, 221, 417, 59, 16, 11110, 12127, 11, 73, 61, 339, 734, 1501, 275, 1543, 83, 7, 450, 334, 589, 14, 15972, 9, 339, 543, 1551, 3508, 83, 7, 450, 734, 1501, 12, 283, 6603, 358, 465, 4386, 26, 267, 4386, 14, 952, 8, 15972, 9, 339, 2512, 14, 815, 360, 10759, 2659, 339, 372, 17325, 199, 199, 318, 1218, 63, 22631, 63, 417, 8, 589, 304, 272, 2512, 275, 2050, 14, 5572, 8355, 339, 2512, 14, 815, 360, 11173, 316, 820, 7474, 2659, 339, 25328, 3797, 275, 11640, 8, 1490, 8, 589, 14, 15972, 12, 283, 4848, 1959, 739, 1012, 339, 221, 417, 275, 11640, 8, 1490, 8, 589, 14, 417, 12, 283, 4848, 1959, 739, 1012, 339, 17325, 275, 11640, 8, 11125, 2819, 9, 339, 17986, 275, 11640, 8, 6708, 9, 339, 367, 284, 315, 1425, 8, 11125, 2819, 304, 267, 17325, 59, 73, 61, 275, 25328, 3797, 59, 73, 61, 339, 367, 284, 315, 1425, 8, 6708, 304, 267, 17986, 59, 73, 61, 275, 25328, 3797, 59, 11125, 2819, 11, 73, 61, 339, 19483, 63, 417, 275, 3371, 63, 417, 8, 589, 12, 221, 417, 12, 17325, 12, 17986, 9, 339, 734, 1501, 275, 1543, 83, 4970, 83, 7, 450, 334, 736, 14, 515, 14, 4846, 8, 589, 14, 15972, 680, 1814, 9520, 681, 82, 401, 341, 395, 747, 14, 515, 14, 4846, 8, 589, 14, 417, 430, 339, 543, 1551, 3508, 83, 7, 450, 734, 1501, 12, 283, 6603, 358, 465, 4386, 26, 267, 4386, 14, 952, 8, 22631, 63, 417, 9, 339, 2512, 14, 815, 360, 10759, 2659, 339, 372, 19483, 63, 417, 199, 199, 318, 2446, 8, 589, 304, 272, 340, 1249, 14, 952, 26, 267, 1218, 63, 22631, 63, 417, 8, 589, 9, 267, 372, 339, 340, 1249, 14, 739, 26, 267, 1218, 63, 15972, 8, 589, 9, 267, 372, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1798, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 272, 1798, 14, 525, 63, 2094, 4517, 26629, 297, 849, 534, 815, 297, 950, 534, 815, 297, 9237, 31468, 3415, 2968, 705, 297, 283, 815, 297, 283, 3764, 297, 283, 1757, 995, 1720, 534, 5446, 2166, 402, 2050, 367, 1072, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 15972, 297, 1720, 534, 2042, 370, 282, 17325, 12083, 370, 675, 367, 10967, 14, 29613, 370, 506, 315, 3366, 1475, 436, 1172, 282, 2582, 402, 378, 88, 23, 1493, 334, 11125, 2819, 9, 334, 15972, 9, 9437, 701, 378, 88, 2277, 334, 6708, 9, 334, 16506, 9, 2783, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 417, 297, 1720, 534, 2042, 370, 282, 634, 3370, 221, 417, 370, 506, 19483, 2659, 272, 1798, 14, 525, 63, 2094, 4517, 952, 297, 1720, 534, 11173, 397, 221, 417, 543, 2741, 17325, 570, 297, 1595, 534, 1617, 63, 2052, 358, 272, 1798, 14, 525, 63, 2094, 4517, 739, 297, 1720, 534, 10607, 17325, 570, 687, 2741, 221, 417, 297, 1595, 534, 1617, 63, 2052, 358, 272, 1798, 14, 525, 63, 2094, 4517, 1943, 21195, 297, 1720, 534, 11173, 397, 221, 417, 543, 314, 2787, 18695, 3878, 367, 17325, 1736, 334, 2915, 491, 370, 22778, 12, 820, 370, 18695, 282, 2849, 2787, 12, 491, 370, 14604, 9, 334, 885, 26, 2331, 3196, 1595, 534, 1617, 63, 2052, 358, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 334, 589, 14, 739, 436, 1249, 14, 952, 9, 503, 3666, 589, 14, 739, 1137, 715, 9, 436, 334, 589, 14, 952, 1137, 715, 2298, 267, 1324, 360, 17809, 370, 4165, 3775, 370, 1586, 503, 2218, 17325, 14, 7754, 1255, 543, 446, 72, 370, 1937, 1720, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ceph/ceph-deploy
ceph_deploy/tests/parser/test_install.py
4
6383
import pytest from ceph_deploy.cli import get_parser from ceph_deploy.tests.util import assert_too_few_arguments COMP_FLAGS = [ 'mon', 'mds', 'rgw', 'osd', 'common', 'all' ] class TestParserInstall(object): def setup(self): self.parser = get_parser() def test_install_help(self, capsys): with pytest.raises(SystemExit): self.parser.parse_args('install --help'.split()) out, err = capsys.readouterr() assert 'usage: ceph-deploy install' in out assert 'positional arguments:' in out assert 'optional arguments:' in out def test_install_host_required(self, capsys): with pytest.raises(SystemExit): self.parser.parse_args('install'.split()) out, err = capsys.readouterr() assert_too_few_arguments(err) def test_install_one_host(self): args = self.parser.parse_args('install host1'.split()) assert args.host == ['host1'] def test_install_multiple_hosts(self): hostnames = ['host1', 'host2', 'host3'] args = self.parser.parse_args(['install'] + hostnames) assert frozenset(args.host) == frozenset(hostnames) def test_install_release_default_is_none(self): args = self.parser.parse_args('install host1'.split()) assert args.release is None assert args.version_kind == "stable" def test_install_release(self): args = self.parser.parse_args('install --release hammer host1'.split()) assert args.release == "hammer" assert args.version_kind == "stable" @pytest.mark.skipif(reason="No release name sanity checking yet") def test_install_release_bad_codename(self): args = self.parser.parse_args('install --release cephalopod host1'.split()) assert args.release != "cephalopod" def test_install_testing_default_is_none(self): args = self.parser.parse_args('install host1'.split()) assert args.testing is None assert args.version_kind == "stable" def test_install_testing_true(self): args = self.parser.parse_args('install --testing host1'.split()) assert len(args.testing) == 0 assert args.version_kind == "testing" def test_install_dev_disabled_by_default(self): args = self.parser.parse_args('install host1'.split()) # dev defaults to master, but version_kind nullifies it assert args.dev == "master" assert args.version_kind == "stable" def test_install_dev_custom_version(self): args = self.parser.parse_args('install --dev v0.80.8 host1'.split()) assert args.dev == "v0.80.8" assert args.version_kind == "dev" @pytest.mark.skipif(reason="test reflects desire, but not code reality") def test_install_dev_option_default_is_master(self): # I don't think this is the way argparse works. args = self.parser.parse_args('install --dev host1'.split()) assert args.dev == "master" assert args.version_kind == "dev" def test_install_release_testing_mutex(self, capsys): with pytest.raises(SystemExit): self.parser.parse_args('install --release hammer --testing host1'.split()) out, err = capsys.readouterr() assert 'not allowed with argument' in err def test_install_release_dev_mutex(self, capsys): with pytest.raises(SystemExit): self.parser.parse_args('install --release hammer --dev master host1'.split()) out, err = capsys.readouterr() assert 'not allowed with argument' in err def test_install_testing_dev_mutex(self, capsys): with pytest.raises(SystemExit): self.parser.parse_args('install --testing --dev master host1'.split()) out, err = capsys.readouterr() assert 'not allowed with argument' in err @pytest.mark.parametrize('comp', COMP_FLAGS) def test_install_component_default_is_false(self, comp): args = self.parser.parse_args('install host1'.split()) assert getattr(args, 'install_%s' % comp) is False @pytest.mark.parametrize('comp', COMP_FLAGS) def test_install_component_true(self, comp): args = self.parser.parse_args(('install --%s host1' % comp).split()) assert getattr(args, 'install_%s' % comp) is True def test_install_multi_component(self): args = self.parser.parse_args(('install --mon --rgw host1').split()) assert args.install_mon assert args.install_rgw def test_install_adjust_repos_default_is_true(self): args = self.parser.parse_args('install host1'.split()) assert args.adjust_repos def test_install_adjust_repos_false(self): args = self.parser.parse_args('install --no-adjust-repos host1'.split()) assert not args.adjust_repos def test_install_adjust_repos_false_with_custom_release(self): args = self.parser.parse_args('install --release firefly --no-adjust-repos host1'.split()) assert args.release == "firefly" assert not args.adjust_repos def test_install_repo_default_is_false(self): args = self.parser.parse_args('install host1'.split()) assert not args.repo def test_install_repo_true(self): args = self.parser.parse_args('install --repo host1'.split()) assert args.repo def test_install_local_mirror_default_is_none(self): args = self.parser.parse_args('install host1'.split()) assert args.local_mirror is None def test_install_local_mirror_custom_path(self): args = self.parser.parse_args('install --local-mirror /mnt/mymirror host1'.split()) assert args.local_mirror == "/mnt/mymirror" def test_install_repo_url_default_is_none(self): args = self.parser.parse_args('install host1'.split()) assert args.repo_url is None def test_install_repo_url_custom_path(self): args = self.parser.parse_args('install --repo-url https://ceph.com host1'.split()) assert args.repo_url == "https://ceph.com" def test_install_gpg_url_default_is_none(self): args = self.parser.parse_args('install host1'.split()) assert args.gpg_url is None def test_install_gpg_url_custom_path(self): args = self.parser.parse_args('install --gpg-url https://ceph.com/key host1'.split()) assert args.gpg_url == "https://ceph.com/key"
mit
[ 646, 4613, 199, 199, 504, 27316, 63, 11060, 14, 2764, 492, 664, 63, 2087, 199, 504, 27316, 63, 11060, 14, 2219, 14, 1974, 492, 702, 63, 7354, 63, 70, 546, 63, 4958, 199, 199, 6790, 63, 4831, 275, 359, 272, 283, 2106, 297, 283, 77, 795, 297, 283, 82, 8392, 297, 283, 736, 68, 297, 283, 2330, 297, 283, 452, 7, 199, 61, 421, 199, 533, 1379, 2842, 8154, 8, 785, 304, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 2087, 275, 664, 63, 2087, 342, 339, 347, 511, 63, 3174, 63, 3437, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3437, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 3807, 26, 27316, 13, 11060, 3907, 7, 315, 734, 267, 702, 283, 17867, 2368, 4881, 315, 734, 267, 702, 283, 4144, 2368, 4881, 315, 734, 339, 347, 511, 63, 3174, 63, 1102, 63, 2427, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 63, 7354, 63, 70, 546, 63, 4958, 8, 1508, 9, 339, 347, 511, 63, 3174, 63, 368, 63, 1102, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 1102, 508, 788, 1102, 17, 418, 339, 347, 511, 63, 3174, 63, 6048, 63, 5146, 8, 277, 304, 267, 1591, 1247, 275, 788, 1102, 17, 297, 283, 1102, 18, 297, 283, 1102, 19, 418, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 2941, 3174, 418, 435, 1591, 1247, 9, 267, 702, 9522, 8, 589, 14, 1102, 9, 508, 9522, 8, 1102, 1247, 9, 339, 347, 511, 63, 3174, 63, 3221, 63, 885, 63, 374, 63, 3592, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 365, 488, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 3221, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 508, 298, 10670, 2626, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 768, 4462, 14, 1657, 14, 22696, 8, 5764, 628, 1944, 4683, 536, 16740, 7907, 5966, 531, 272, 347, 511, 63, 3174, 63, 3221, 63, 4087, 63, 11879, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 27316, 279, 411, 364, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 1137, 298, 20266, 279, 411, 364, 2, 339, 347, 511, 63, 3174, 63, 4776, 63, 885, 63, 374, 63, 3592, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 4776, 365, 488, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 4776, 63, 2052, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 4776, 1591, 17, 1370, 1294, 1012, 267, 702, 822, 8, 589, 14, 4776, 9, 508, 378, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 4776, 2, 339, 347, 511, 63, 3174, 63, 2374, 63, 7011, 63, 991, 63, 885, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 327, 4866, 4243, 370, 5288, 12, 1325, 1015, 63, 5091, 302, 22733, 5604, 652, 267, 702, 1249, 14, 2374, 508, 298, 4133, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 2374, 63, 4229, 63, 1023, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 2374, 373, 16, 14, 1257, 14, 24, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 2374, 508, 298, 86, 16, 14, 1257, 14, 24, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 2374, 2, 339, 768, 4462, 14, 1657, 14, 22696, 8, 5764, 628, 396, 16806, 83, 477, 338, 264, 12, 1325, 440, 1233, 3363, 1209, 531, 272, 347, 511, 63, 3174, 63, 2374, 63, 1422, 63, 885, 63, 374, 63, 4133, 8, 277, 304, 267, 327, 473, 2793, 1133, 13516, 642, 365, 314, 4340, 7534, 5419, 14, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 2374, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 2374, 508, 298, 4133, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 2374, 2, 339, 347, 511, 63, 3174, 63, 3221, 63, 4776, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1553, 4776, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 347, 511, 63, 3174, 63, 3221, 63, 2374, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1553, 2374, 5288, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 347, 511, 63, 3174, 63, 4776, 63, 2374, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 4776, 1553, 2374, 5288, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 768 ]
[ 4613, 199, 199, 504, 27316, 63, 11060, 14, 2764, 492, 664, 63, 2087, 199, 504, 27316, 63, 11060, 14, 2219, 14, 1974, 492, 702, 63, 7354, 63, 70, 546, 63, 4958, 199, 199, 6790, 63, 4831, 275, 359, 272, 283, 2106, 297, 283, 77, 795, 297, 283, 82, 8392, 297, 283, 736, 68, 297, 283, 2330, 297, 283, 452, 7, 199, 61, 421, 199, 533, 1379, 2842, 8154, 8, 785, 304, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 2087, 275, 664, 63, 2087, 342, 339, 347, 511, 63, 3174, 63, 3437, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3437, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 3807, 26, 27316, 13, 11060, 3907, 7, 315, 734, 267, 702, 283, 17867, 2368, 4881, 315, 734, 267, 702, 283, 4144, 2368, 4881, 315, 734, 339, 347, 511, 63, 3174, 63, 1102, 63, 2427, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 63, 7354, 63, 70, 546, 63, 4958, 8, 1508, 9, 339, 347, 511, 63, 3174, 63, 368, 63, 1102, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 1102, 508, 788, 1102, 17, 418, 339, 347, 511, 63, 3174, 63, 6048, 63, 5146, 8, 277, 304, 267, 1591, 1247, 275, 788, 1102, 17, 297, 283, 1102, 18, 297, 283, 1102, 19, 418, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 2941, 3174, 418, 435, 1591, 1247, 9, 267, 702, 9522, 8, 589, 14, 1102, 9, 508, 9522, 8, 1102, 1247, 9, 339, 347, 511, 63, 3174, 63, 3221, 63, 885, 63, 374, 63, 3592, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 365, 488, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 3221, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 508, 298, 10670, 2626, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 768, 4462, 14, 1657, 14, 22696, 8, 5764, 628, 1944, 4683, 536, 16740, 7907, 5966, 531, 272, 347, 511, 63, 3174, 63, 3221, 63, 4087, 63, 11879, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 27316, 279, 411, 364, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 3221, 1137, 298, 20266, 279, 411, 364, 2, 339, 347, 511, 63, 3174, 63, 4776, 63, 885, 63, 374, 63, 3592, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 4776, 365, 488, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 4776, 63, 2052, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 4776, 1591, 17, 1370, 1294, 1012, 267, 702, 822, 8, 589, 14, 4776, 9, 508, 378, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 4776, 2, 339, 347, 511, 63, 3174, 63, 2374, 63, 7011, 63, 991, 63, 885, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1591, 17, 1370, 1294, 1012, 267, 327, 4866, 4243, 370, 5288, 12, 1325, 1015, 63, 5091, 302, 22733, 5604, 652, 267, 702, 1249, 14, 2374, 508, 298, 4133, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 11989, 2, 339, 347, 511, 63, 3174, 63, 2374, 63, 4229, 63, 1023, 8, 277, 304, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 2374, 373, 16, 14, 1257, 14, 24, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 2374, 508, 298, 86, 16, 14, 1257, 14, 24, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 2374, 2, 339, 768, 4462, 14, 1657, 14, 22696, 8, 5764, 628, 396, 16806, 83, 477, 338, 264, 12, 1325, 440, 1233, 3363, 1209, 531, 272, 347, 511, 63, 3174, 63, 2374, 63, 1422, 63, 885, 63, 374, 63, 4133, 8, 277, 304, 267, 327, 473, 2793, 1133, 13516, 642, 365, 314, 4340, 7534, 5419, 14, 267, 1249, 275, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 2374, 1591, 17, 1370, 1294, 1012, 267, 702, 1249, 14, 2374, 508, 298, 4133, 2, 267, 702, 1249, 14, 1023, 63, 5091, 508, 298, 2374, 2, 339, 347, 511, 63, 3174, 63, 3221, 63, 4776, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1553, 4776, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 347, 511, 63, 3174, 63, 3221, 63, 2374, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 3221, 24868, 2626, 1553, 2374, 5288, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 347, 511, 63, 3174, 63, 4776, 63, 2374, 63, 19078, 8, 277, 12, 4021, 1274, 304, 267, 543, 4613, 14, 3536, 8, 24738, 304, 288, 291, 14, 2087, 14, 1122, 63, 589, 360, 3174, 1553, 4776, 1553, 2374, 5288, 1591, 17, 1370, 1294, 1012, 267, 734, 12, 2329, 275, 4021, 1274, 14, 739, 7837, 82, 342, 267, 702, 283, 1397, 4370, 543, 1423, 7, 315, 2329, 339, 768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
abretaud/tools-iuc
tools/heinz/heinz_scoring.py
21
3661
#!/usr/bin/env python """Calculate scores for Heinz. This script transform a p-value into a score: 1. Use alpha and lambda to calculate a threshold P-value. 2. Calculate a score based on each P-value by alpha and the threshold. For more details, please refer to the paper doi:10.1093/bioinformatics/btn161 Input: P-values from DESeq2 result: first column: names, second column P-values Output: Scores, which will be used as the input of Heinz. First column: names, second column: scores. Python 3 is required. """ # Implemented by: Chao (Cico) Zhang # Homepage: https://Hi-IT.org # Date: 14 Mar 2017 # Last modified: 23 May 2018 import argparse import sys import numpy as np import pandas as pd parser = argparse.ArgumentParser(description='Transform a P-value into a ' 'score which can be used as the input of ' 'Heinz') parser.add_argument('-n', '--node', required=True, dest='nodes', metavar='nodes_pvalue.txt', type=str, help='Input file of nodes with P-values') parser.add_argument('-f', '--fdr', required=True, dest='fdr', metavar='0.007', type=float, help='Choose a value of FDR') parser.add_argument('-m', '--model', required=False, dest='param_file', metavar='param.txt', type=str, help='A txt file contains model params as input') parser.add_argument('-a', '--alpha', required=False, dest='alpha', metavar='0.234', type=float, default=0.5, help='Single parameter alpha as input if txt input is ' 'not provided') parser.add_argument('-l', '--lambda', required=False, dest='lam', metavar='0.345', type=float, default=0.5, help='Single parameter lambda as input if txt input is ' 'not provided') parser.add_argument('-o', '--output', required=True, dest='output', metavar='scores.txt', type=str, help='The output file to store the calculated scores') args = parser.parse_args() # Check if the parameters are complete if args.output is None: sys.exit('Output file is not designated.') if args.nodes is None: sys.exit('Nodes with p-values must be provided.') if args.fdr is None: sys.exit('FDR must be provided') if args.fdr >= 1 or args.fdr <= 0: sys.exit('FDR must greater than 0 and smaller than 1') # run heinz-print according to the input type if args.param_file is not None: # if BUM output is provided with open(args.param_file) as p: params = p.readlines() lam = float(params[0]) # Maybe this is a bug alpha = float(params[1]) # Maybe this is a bug # if BUM output is not provided elif args.alpha is not None and args.lam is not None: lam = args.lam alpha = args.alpha else: # The input is not complete sys.exit('The parameters of the model are incomplete.') # Calculate the threshold P-value pie = lam + (1 - lam) * alpha p_threshold = np.power((pie - lam * args.fdr) / (args.fdr - lam * args.fdr), 1 / (alpha - 1)) print(p_threshold) # Calculate the scores input_pvalues = pd.read_csv(args.nodes, sep='\t', names=['node', 'pvalue']) input_pvalues.loc[:, 'score'] = input_pvalues.pvalue.apply(lambda x: (alpha - 1) * (np.log(x) - np.log(p_threshold))) # print(input_pvalues.loc[:, ['node', 'score']]) input_pvalues.loc[:, ['node', 'score']].to_csv(args.output, sep='\t', index=False, header=False)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 14860, 9342, 367, 5311, 262, 90, 14, 199, 199, 2765, 2884, 5793, 282, 299, 13, 585, 1901, 282, 5396, 26, 272, 413, 14, 3645, 5131, 436, 2400, 370, 8671, 282, 8765, 510, 13, 585, 14, 272, 499, 14, 12707, 282, 5396, 4079, 641, 1924, 510, 13, 585, 701, 5131, 436, 314, 8765, 14, 199, 199, 1858, 1655, 2436, 12, 8749, 10618, 370, 314, 15220, 886, 73, 26, 709, 14, 709, 3129, 15, 17614, 262, 509, 3889, 83, 15, 9633, 12285, 199, 199, 3205, 26, 272, 510, 13, 1459, 687, 11758, 4077, 18, 754, 26, 1642, 2763, 26, 1561, 12, 3499, 2763, 510, 13, 1459, 199, 2959, 26, 272, 428, 4630, 12, 1314, 911, 506, 1202, 465, 314, 1324, 402, 5311, 262, 90, 14, 272, 7758, 2763, 26, 1561, 12, 3499, 2763, 26, 9342, 14, 199, 199, 4718, 650, 365, 1415, 14, 199, 624, 199, 3, 11794, 2509, 701, 26, 445, 2411, 79, 334, 35, 12802, 9, 3107, 27304, 199, 3, 14621, 1606, 26, 4178, 921, 16106, 13, 649, 14, 1308, 199, 3, 6148, 26, 4329, 16794, 9708, 199, 3, 15237, 6042, 26, 6546, 10162, 14894, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 421, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 534, 6939, 282, 510, 13, 585, 1901, 282, 283, 639, 283, 3397, 1314, 883, 506, 1202, 465, 314, 1324, 402, 283, 639, 283, 1966, 262, 90, 358, 199, 2087, 14, 525, 63, 2094, 3654, 78, 297, 2850, 932, 297, 1415, 29, 549, 12, 2053, 534, 2415, 297, 490, 8214, 534, 2415, 63, 80, 585, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 3205, 570, 402, 3380, 543, 510, 13, 1459, 358, 199, 2087, 14, 525, 63, 2094, 3654, 70, 297, 2850, 2592, 82, 297, 1415, 29, 549, 12, 2053, 534, 2592, 82, 297, 490, 8214, 534, 16, 14, 8255, 297, 730, 29, 1609, 12, 1720, 534, 23932, 282, 574, 402, 481, 4564, 358, 199, 2087, 14, 525, 63, 2094, 3654, 77, 297, 2850, 1238, 297, 1415, 29, 797, 12, 2053, 534, 635, 63, 493, 297, 490, 8214, 534, 635, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 33, 9444, 570, 3509, 1402, 1862, 465, 1324, 358, 199, 2087, 14, 525, 63, 2094, 3654, 65, 297, 2850, 4468, 297, 1415, 29, 797, 12, 2053, 534, 4468, 297, 490, 8214, 534, 16, 14, 5533, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 490, 1720, 534, 7200, 2725, 5131, 465, 1324, 340, 9444, 1324, 365, 283, 490, 283, 1397, 2741, 358, 199, 2087, 14, 525, 63, 2094, 3654, 76, 297, 2850, 2734, 297, 1415, 29, 797, 12, 2053, 534, 17984, 297, 490, 8214, 534, 16, 14, 9908, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 490, 1720, 534, 7200, 2725, 2400, 465, 1324, 340, 9444, 1324, 365, 283, 490, 283, 1397, 2741, 358, 199, 2087, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 297, 1415, 29, 549, 12, 2053, 534, 1199, 297, 490, 8214, 534, 7107, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 1918, 1072, 570, 370, 3877, 314, 12950, 9342, 358, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 2670, 340, 314, 2633, 787, 4890, 199, 692, 1249, 14, 1199, 365, 488, 26, 272, 984, 14, 2224, 360, 2959, 570, 365, 440, 12899, 972, 2659, 199, 199, 692, 1249, 14, 2415, 365, 488, 26, 272, 984, 14, 2224, 360, 6300, 543, 299, 13, 1459, 1471, 506, 2741, 2659, 199, 199, 692, 1249, 14, 2592, 82, 365, 488, 26, 272, 984, 14, 2224, 360, 38, 4564, 1471, 506, 2741, 358, 199, 199, 692, 1249, 14, 2592, 82, 2356, 413, 503, 1249, 14, 2592, 82, 2695, 378, 26, 272, 984, 14, 2224, 360, 38, 4564, 1471, 8932, 2419, 378, 436, 12700, 2419, 413, 358, 199, 199, 3, 1255, 946, 262, 90, 13, 1361, 7182, 370, 314, 1324, 730, 199, 692, 1249, 14, 635, 63, 493, 365, 440, 488, 26, 221, 327, 340, 699, 2639, 1072, 365, 2741, 272, 543, 1551, 8, 589, 14, 635, 63, 493, 9, 465, 299, 26, 267, 1862, 275, 299, 14, 9684, 342, 267, 25917, 275, 2069, 8, 1162, 59, 16, 566, 221, 327, 23038, 642, 365, 282, 6519, 267, 5131, 275, 2069, 8, 1162, 59, 17, 566, 221, 327, 23038, 642, 365, 282, 6519, 199, 3, 340, 699, 2639, 1072, 365, 440, 2741, 199, 4164, 1249, 14, 4468, 365, 440, 488, 436, 1249, 14, 17984, 365, 440, 488, 26, 272, 25917, 275, 1249, 14, 17984, 272, 5131, 275, 1249, 14, 4468, 199, 2836, 26, 221, 327, 710, 1324, 365, 440, 4890, 272, 984, 14, 2224, 360, 1918, 2633, 402, 314, 1402, 787, 17110, 2659, 199, 199, 3, 12707, 314, 8765, 510, 13, 585, 199, 9890, 275, 25917, 435, 334, 17, 446, 25917, 9, 627, 5131, 199, 80, 63, 7227, 275, 980, 14, 5652, 1332, 9890, 446, 25917, 627, 1249, 14, 2592, 82, 9, 1182, 334, 589, 14, 2592, 82, 446, 25917, 627, 1249, 14, 2592, 82, 395, 2432, 413, 1182, 334, 4468, 446, 413, 430, 199, 1361, 8, 80, 63, 7227, 9, 199, 3, 12707, 314, 9342, 199, 1210, 63, 80, 1459, 275, 6454, 14, 739, 63, 4737, 8, 589, 14, 2415, 12, 7375, 17115, 84, 297, 1561, 2968, 932, 297, 283, 80, 585, 1105, 199, 1210, 63, 80, 1459, 14, 2102, 3981, 283, 3397, 418, 275, 1324, 63, 80, 1459, 14, 80, 585, 14, 4998, 8, 2734, 671, 26, 15491, 334, 4468, 446, 413, 9, 627, 334, 1590, 14, 793, 8, 88, 9, 446, 980, 14, 793, 8, 80, 63, 7227, 1724, 199, 3, 870, 8, 1210, 63, 80, 1459, 14, 2102, 3981, 788, 932, 297, 283, 3397, 12121, 199, 1210, 63, 80, 1459, 14, 2102, 3981, 788, 932, 297, 283, 3397, 418, 1055, 475, 63, 4737, 8, 589, 14, 1199, 12, 7375, 17115, 84, 297, 6901, 1478, 29, 797, 12, 1406, 29, 797, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 14860, 9342, 367, 5311, 262, 90, 14, 199, 199, 2765, 2884, 5793, 282, 299, 13, 585, 1901, 282, 5396, 26, 272, 413, 14, 3645, 5131, 436, 2400, 370, 8671, 282, 8765, 510, 13, 585, 14, 272, 499, 14, 12707, 282, 5396, 4079, 641, 1924, 510, 13, 585, 701, 5131, 436, 314, 8765, 14, 199, 199, 1858, 1655, 2436, 12, 8749, 10618, 370, 314, 15220, 886, 73, 26, 709, 14, 709, 3129, 15, 17614, 262, 509, 3889, 83, 15, 9633, 12285, 199, 199, 3205, 26, 272, 510, 13, 1459, 687, 11758, 4077, 18, 754, 26, 1642, 2763, 26, 1561, 12, 3499, 2763, 510, 13, 1459, 199, 2959, 26, 272, 428, 4630, 12, 1314, 911, 506, 1202, 465, 314, 1324, 402, 5311, 262, 90, 14, 272, 7758, 2763, 26, 1561, 12, 3499, 2763, 26, 9342, 14, 199, 199, 4718, 650, 365, 1415, 14, 199, 624, 199, 3, 11794, 2509, 701, 26, 445, 2411, 79, 334, 35, 12802, 9, 3107, 27304, 199, 3, 14621, 1606, 26, 4178, 921, 16106, 13, 649, 14, 1308, 199, 3, 6148, 26, 4329, 16794, 9708, 199, 3, 15237, 6042, 26, 6546, 10162, 14894, 199, 199, 646, 7534, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 421, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 534, 6939, 282, 510, 13, 585, 1901, 282, 283, 639, 283, 3397, 1314, 883, 506, 1202, 465, 314, 1324, 402, 283, 639, 283, 1966, 262, 90, 358, 199, 2087, 14, 525, 63, 2094, 3654, 78, 297, 2850, 932, 297, 1415, 29, 549, 12, 2053, 534, 2415, 297, 490, 8214, 534, 2415, 63, 80, 585, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 3205, 570, 402, 3380, 543, 510, 13, 1459, 358, 199, 2087, 14, 525, 63, 2094, 3654, 70, 297, 2850, 2592, 82, 297, 1415, 29, 549, 12, 2053, 534, 2592, 82, 297, 490, 8214, 534, 16, 14, 8255, 297, 730, 29, 1609, 12, 1720, 534, 23932, 282, 574, 402, 481, 4564, 358, 199, 2087, 14, 525, 63, 2094, 3654, 77, 297, 2850, 1238, 297, 1415, 29, 797, 12, 2053, 534, 635, 63, 493, 297, 490, 8214, 534, 635, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 33, 9444, 570, 3509, 1402, 1862, 465, 1324, 358, 199, 2087, 14, 525, 63, 2094, 3654, 65, 297, 2850, 4468, 297, 1415, 29, 797, 12, 2053, 534, 4468, 297, 490, 8214, 534, 16, 14, 5533, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 490, 1720, 534, 7200, 2725, 5131, 465, 1324, 340, 9444, 1324, 365, 283, 490, 283, 1397, 2741, 358, 199, 2087, 14, 525, 63, 2094, 3654, 76, 297, 2850, 2734, 297, 1415, 29, 797, 12, 2053, 534, 17984, 297, 490, 8214, 534, 16, 14, 9908, 297, 730, 29, 1609, 12, 849, 29, 16, 14, 21, 12, 490, 1720, 534, 7200, 2725, 2400, 465, 1324, 340, 9444, 1324, 365, 283, 490, 283, 1397, 2741, 358, 199, 2087, 14, 525, 63, 2094, 3654, 79, 297, 2850, 1199, 297, 1415, 29, 549, 12, 2053, 534, 1199, 297, 490, 8214, 534, 7107, 14, 2424, 297, 730, 29, 495, 12, 490, 1720, 534, 1918, 1072, 570, 370, 3877, 314, 12950, 9342, 358, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 2670, 340, 314, 2633, 787, 4890, 199, 692, 1249, 14, 1199, 365, 488, 26, 272, 984, 14, 2224, 360, 2959, 570, 365, 440, 12899, 972, 2659, 199, 199, 692, 1249, 14, 2415, 365, 488, 26, 272, 984, 14, 2224, 360, 6300, 543, 299, 13, 1459, 1471, 506, 2741, 2659, 199, 199, 692, 1249, 14, 2592, 82, 365, 488, 26, 272, 984, 14, 2224, 360, 38, 4564, 1471, 506, 2741, 358, 199, 199, 692, 1249, 14, 2592, 82, 2356, 413, 503, 1249, 14, 2592, 82, 2695, 378, 26, 272, 984, 14, 2224, 360, 38, 4564, 1471, 8932, 2419, 378, 436, 12700, 2419, 413, 358, 199, 199, 3, 1255, 946, 262, 90, 13, 1361, 7182, 370, 314, 1324, 730, 199, 692, 1249, 14, 635, 63, 493, 365, 440, 488, 26, 221, 327, 340, 699, 2639, 1072, 365, 2741, 272, 543, 1551, 8, 589, 14, 635, 63, 493, 9, 465, 299, 26, 267, 1862, 275, 299, 14, 9684, 342, 267, 25917, 275, 2069, 8, 1162, 59, 16, 566, 221, 327, 23038, 642, 365, 282, 6519, 267, 5131, 275, 2069, 8, 1162, 59, 17, 566, 221, 327, 23038, 642, 365, 282, 6519, 199, 3, 340, 699, 2639, 1072, 365, 440, 2741, 199, 4164, 1249, 14, 4468, 365, 440, 488, 436, 1249, 14, 17984, 365, 440, 488, 26, 272, 25917, 275, 1249, 14, 17984, 272, 5131, 275, 1249, 14, 4468, 199, 2836, 26, 221, 327, 710, 1324, 365, 440, 4890, 272, 984, 14, 2224, 360, 1918, 2633, 402, 314, 1402, 787, 17110, 2659, 199, 199, 3, 12707, 314, 8765, 510, 13, 585, 199, 9890, 275, 25917, 435, 334, 17, 446, 25917, 9, 627, 5131, 199, 80, 63, 7227, 275, 980, 14, 5652, 1332, 9890, 446, 25917, 627, 1249, 14, 2592, 82, 9, 1182, 334, 589, 14, 2592, 82, 446, 25917, 627, 1249, 14, 2592, 82, 395, 2432, 413, 1182, 334, 4468, 446, 413, 430, 199, 1361, 8, 80, 63, 7227, 9, 199, 3, 12707, 314, 9342, 199, 1210, 63, 80, 1459, 275, 6454, 14, 739, 63, 4737, 8, 589, 14, 2415, 12, 7375, 17115, 84, 297, 1561, 2968, 932, 297, 283, 80, 585, 1105, 199, 1210, 63, 80, 1459, 14, 2102, 3981, 283, 3397, 418, 275, 1324, 63, 80, 1459, 14, 80, 585, 14, 4998, 8, 2734, 671, 26, 15491, 334, 4468, 446, 413, 9, 627, 334, 1590, 14, 793, 8, 88, 9, 446, 980, 14, 793, 8, 80, 63, 7227, 1724, 199, 3, 870, 8, 1210, 63, 80, 1459, 14, 2102, 3981, 788, 932, 297, 283, 3397, 12121, 199, 1210, 63, 80, 1459, 14, 2102, 3981, 788, 932, 297, 283, 3397, 418, 1055, 475, 63, 4737, 8, 589, 14, 1199, 12, 7375, 17115, 84, 297, 6901, 1478, 29, 797, 12, 1406, 29, 797, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rogerfan/simpleml
simpleml/metrics.py
1
1076
''' Metric functions. ''' import numpy as np import numexpr as ne __all__ = ('entropy', 'gini', 'misclass', 'tanh', 'logistic') # Purity measures for binary variables. def entropy(prop): return ne.evaluate('where((prop != 0) & (prop != 1),' '-prop*log(prop) - (1-prop)*log(1-prop), 0)') def gini(prop): return prop*(1-prop) def misclass(prop): if hasattr(prop, '__len__') and len(prop) > 5000: return ne.evaluate('where(prop <= 0.5, prop, 1-prop)') else: # Numexpr is slower for small arrays (tested on i7-3770) return np.where(prop <= 0.5, prop, 1-prop) # Sigmoid functions with derivatives class tanh: def f(self, x): return np.tanh(x) def d(self, x): return 1. - np.tanh(x)**2 tanh = tanh() class logistic: def f(self, x): return 1. / (1. + np.exp(-x)) def d(self, x): f = self.f(x) return f*(1.-f) logistic = logistic() # Norm functions def norm(x, y): return np.linalg.norm(np.atleast_2d(x-y), axis=1) def cat_noteq(a, b): return int(a != b)
mpl-2.0
[ 2344, 199, 11119, 3423, 14, 199, 2344, 199, 646, 2680, 465, 980, 199, 646, 10330, 31149, 465, 1279, 199, 199, 363, 452, 363, 275, 661, 10435, 297, 283, 903, 73, 297, 283, 1292, 533, 297, 283, 21468, 297, 283, 23452, 358, 421, 199, 3, 510, 5581, 17616, 1482, 367, 3366, 2860, 14, 199, 318, 19490, 8, 4469, 304, 272, 372, 1279, 14, 7383, 360, 4509, 1332, 4469, 1137, 378, 9, 1253, 334, 4469, 1137, 413, 26582, 2432, 2475, 4469, 10, 793, 8, 4469, 9, 446, 334, 17, 13, 4469, 3342, 793, 8, 17, 13, 4469, 395, 378, 5942, 199, 199, 318, 486, 2730, 8, 4469, 304, 272, 372, 5931, 5830, 17, 13, 4469, 9, 199, 199, 318, 3201, 533, 8, 4469, 304, 272, 340, 2688, 8, 4469, 12, 2560, 552, 13766, 436, 822, 8, 4469, 9, 690, 22369, 26, 267, 372, 1279, 14, 7383, 360, 4509, 8, 4469, 2695, 378, 14, 21, 12, 5931, 12, 413, 13, 4469, 5942, 272, 587, 26, 221, 327, 653, 940, 31149, 365, 26200, 367, 7425, 6572, 334, 10453, 641, 284, 23, 13, 7332, 16, 9, 267, 372, 980, 14, 4509, 8, 4469, 2695, 378, 14, 21, 12, 5931, 12, 413, 13, 4469, 9, 199, 199, 3, 14625, 14356, 3423, 543, 28059, 199, 533, 20162, 72, 26, 272, 347, 289, 8, 277, 12, 671, 304, 267, 372, 980, 14, 21468, 8, 88, 9, 272, 347, 366, 8, 277, 12, 671, 304, 267, 372, 413, 14, 446, 980, 14, 21468, 8, 88, 6422, 18, 199, 21468, 275, 20162, 72, 342, 199, 199, 533, 30360, 26, 272, 347, 289, 8, 277, 12, 671, 304, 267, 372, 413, 14, 1182, 334, 17, 14, 435, 980, 14, 1474, 2801, 88, 430, 272, 347, 366, 8, 277, 12, 671, 304, 267, 289, 275, 291, 14, 70, 8, 88, 9, 267, 372, 289, 5830, 17, 23683, 70, 9, 199, 23452, 275, 30360, 342, 199, 199, 3, 20800, 3423, 199, 318, 6316, 8, 88, 12, 612, 304, 272, 372, 980, 14, 10096, 14, 4791, 8, 1590, 14, 22900, 63, 18, 68, 8, 88, 13, 89, 395, 3114, 29, 17, 9, 199, 199, 318, 6230, 63, 4610, 81, 8, 65, 12, 330, 304, 272, 372, 1109, 8, 65, 1137, 330, 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 ]
[ 199, 11119, 3423, 14, 199, 2344, 199, 646, 2680, 465, 980, 199, 646, 10330, 31149, 465, 1279, 199, 199, 363, 452, 363, 275, 661, 10435, 297, 283, 903, 73, 297, 283, 1292, 533, 297, 283, 21468, 297, 283, 23452, 358, 421, 199, 3, 510, 5581, 17616, 1482, 367, 3366, 2860, 14, 199, 318, 19490, 8, 4469, 304, 272, 372, 1279, 14, 7383, 360, 4509, 1332, 4469, 1137, 378, 9, 1253, 334, 4469, 1137, 413, 26582, 2432, 2475, 4469, 10, 793, 8, 4469, 9, 446, 334, 17, 13, 4469, 3342, 793, 8, 17, 13, 4469, 395, 378, 5942, 199, 199, 318, 486, 2730, 8, 4469, 304, 272, 372, 5931, 5830, 17, 13, 4469, 9, 199, 199, 318, 3201, 533, 8, 4469, 304, 272, 340, 2688, 8, 4469, 12, 2560, 552, 13766, 436, 822, 8, 4469, 9, 690, 22369, 26, 267, 372, 1279, 14, 7383, 360, 4509, 8, 4469, 2695, 378, 14, 21, 12, 5931, 12, 413, 13, 4469, 5942, 272, 587, 26, 221, 327, 653, 940, 31149, 365, 26200, 367, 7425, 6572, 334, 10453, 641, 284, 23, 13, 7332, 16, 9, 267, 372, 980, 14, 4509, 8, 4469, 2695, 378, 14, 21, 12, 5931, 12, 413, 13, 4469, 9, 199, 199, 3, 14625, 14356, 3423, 543, 28059, 199, 533, 20162, 72, 26, 272, 347, 289, 8, 277, 12, 671, 304, 267, 372, 980, 14, 21468, 8, 88, 9, 272, 347, 366, 8, 277, 12, 671, 304, 267, 372, 413, 14, 446, 980, 14, 21468, 8, 88, 6422, 18, 199, 21468, 275, 20162, 72, 342, 199, 199, 533, 30360, 26, 272, 347, 289, 8, 277, 12, 671, 304, 267, 372, 413, 14, 1182, 334, 17, 14, 435, 980, 14, 1474, 2801, 88, 430, 272, 347, 366, 8, 277, 12, 671, 304, 267, 289, 275, 291, 14, 70, 8, 88, 9, 267, 372, 289, 5830, 17, 23683, 70, 9, 199, 23452, 275, 30360, 342, 199, 199, 3, 20800, 3423, 199, 318, 6316, 8, 88, 12, 612, 304, 272, 372, 980, 14, 10096, 14, 4791, 8, 1590, 14, 22900, 63, 18, 68, 8, 88, 13, 89, 395, 3114, 29, 17, 9, 199, 199, 318, 6230, 63, 4610, 81, 8, 65, 12, 330, 304, 272, 372, 1109, 8, 65, 1137, 330, 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, 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,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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 ]
xuhdev/nikola
nikola/plugins/task/__init__.py
4
1166
# -*- coding: utf-8 -*- # Copyright © 2012-2017 Roberto Alsina and others. # 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. """Tasks for Nikola."""
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 22405, 103, 6029, 13, 10680, 6848, 605, 475, 437, 478, 13765, 436, 11789, 14, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 199, 3, 4954, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 199, 3, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 199, 3, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 3, 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, 199, 3, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 10989, 506, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 199, 3, 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, 199, 3, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 199, 3, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 199, 3, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 199, 3, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 199, 3, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 624, 19295, 367, 653, 3258, 22205, 1041, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 22405, 103, 6029, 13, 10680, 6848, 605, 475, 437, 478, 13765, 436, 11789, 14, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 199, 3, 4954, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 199, 3, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 199, 3, 2290, 1928, 10588, 12, 5893, 1928, 12305, 199, 3, 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, 199, 3, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 10989, 506, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 199, 3, 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, 199, 3, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 199, 3, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 199, 3, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 199, 3, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 199, 3, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 624, 19295, 367, 653, 3258, 22205, 1041, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jasonwee/asus-rt-n14uhp-mrtg
tmp/ve_asus-rt-n14uhp-mrtg/lib/python3.4/site-packages/setuptools/command/upload_docs.py
20
7037
# -*- coding: utf-8 -*- """upload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to PyPI's pythonhosted.org). """ from base64 import standard_b64encode from distutils import log from distutils.errors import DistutilsOptionError import os import socket import zipfile import tempfile import shutil import itertools import functools from setuptools.extern import six from setuptools.extern.six.moves import http_client, urllib from pkg_resources import iter_entry_points from .upload import upload def _encode(s): errors = 'surrogateescape' if six.PY3 else 'strict' return s.encode('utf-8', errors) class upload_docs(upload): description = 'Upload documentation to PyPI' user_options = [ ('repository=', 'r', "url of repository [default: %s]" % upload.DEFAULT_REPOSITORY), ('show-response', None, 'display full response text from server'), ('upload-dir=', None, 'directory to upload'), ] boolean_options = upload.boolean_options def has_sphinx(self): if self.upload_dir is None: for ep in iter_entry_points('distutils.commands', 'build_sphinx'): return True sub_commands = [('build_sphinx', has_sphinx)] def initialize_options(self): upload.initialize_options(self) self.upload_dir = None self.target_dir = None def finalize_options(self): upload.finalize_options(self) if self.upload_dir is None: if self.has_sphinx(): build_sphinx = self.get_finalized_command('build_sphinx') self.target_dir = build_sphinx.builder_target_dir else: build = self.get_finalized_command('build') self.target_dir = os.path.join(build.build_base, 'docs') else: self.ensure_dirname('upload_dir') self.target_dir = self.upload_dir self.announce('Using upload directory %s' % self.target_dir) def create_zipfile(self, filename): zip_file = zipfile.ZipFile(filename, "w") try: self.mkpath(self.target_dir) # just in case for root, dirs, files in os.walk(self.target_dir): if root == self.target_dir and not files: raise DistutilsOptionError( "no files found in upload directory '%s'" % self.target_dir) for name in files: full = os.path.join(root, name) relative = root[len(self.target_dir):].lstrip(os.path.sep) dest = os.path.join(relative, name) zip_file.write(full, dest) finally: zip_file.close() def run(self): # Run sub commands for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) tmp_dir = tempfile.mkdtemp() name = self.distribution.metadata.get_name() zip_file = os.path.join(tmp_dir, "%s.zip" % name) try: self.create_zipfile(zip_file) self.upload_file(zip_file) finally: shutil.rmtree(tmp_dir) @staticmethod def _build_part(item, sep_boundary): key, values = item title = '\nContent-Disposition: form-data; name="%s"' % key # handle multiple entries for the same name if not isinstance(values, list): values = [values] for value in values: if type(value) is tuple: title += '; filename="%s"' % value[0] value = value[1] else: value = _encode(value) yield sep_boundary yield _encode(title) yield b"\n\n" yield value if value and value[-1:] == b'\r': yield b'\n' # write an extra newline (lurve Macs) @classmethod def _build_multipart(cls, data): """ Build up the MIME payload for the POST data """ boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' sep_boundary = b'\n--' + boundary end_boundary = sep_boundary + b'--' end_items = end_boundary, b"\n", builder = functools.partial( cls._build_part, sep_boundary=sep_boundary, ) part_groups = map(builder, data.items()) parts = itertools.chain.from_iterable(part_groups) body_items = itertools.chain(parts, end_items) content_type = 'multipart/form-data; boundary=%s' % boundary return b''.join(body_items), content_type def upload_file(self, filename): with open(filename, 'rb') as f: content = f.read() meta = self.distribution.metadata data = { ':action': 'doc_upload', 'name': meta.get_name(), 'content': (os.path.basename(filename), content), } # set up the authentication credentials = _encode(self.username + ':' + self.password) credentials = standard_b64encode(credentials) if six.PY3: credentials = credentials.decode('ascii') auth = "Basic " + credentials body, ct = self._build_multipart(data) self.announce("Submitting documentation to %s" % (self.repository), log.INFO) # build the Request # We can't use urllib2 since we need to send the Basic # auth right with the first request schema, netloc, url, params, query, fragments = \ urllib.parse.urlparse(self.repository) assert not params and not query and not fragments if schema == 'http': conn = http_client.HTTPConnection(netloc) elif schema == 'https': conn = http_client.HTTPSConnection(netloc) else: raise AssertionError("unsupported schema " + schema) data = '' try: conn.connect() conn.putrequest("POST", url) content_type = ct conn.putheader('Content-type', content_type) conn.putheader('Content-length', str(len(body))) conn.putheader('Authorization', auth) conn.endheaders() conn.send(body) except socket.error as e: self.announce(str(e), log.ERROR) return r = conn.getresponse() if r.status == 200: self.announce('Server response (%s): %s' % (r.status, r.reason), log.INFO) elif r.status == 301: location = r.getheader('Location') if location is None: location = 'https://pythonhosted.org/%s/' % meta.get_name() self.announce('Upload successful. Visit %s' % location, log.INFO) else: self.announce('Upload failed (%s): %s' % (r.status, r.reason), log.ERROR) if self.show_response: print('-' * 75, r.read(), '-' * 75)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 5064, 63, 4757, 199, 199, 29452, 282, 12577, 283, 5064, 63, 4757, 7, 21474, 334, 5064, 3794, 370, 199, 2713, 2252, 1159, 2366, 24127, 14, 1308, 680, 199, 624, 199, 199, 504, 1300, 772, 492, 4465, 63, 66, 772, 2143, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 31484, 199, 646, 747, 199, 646, 2838, 199, 646, 10392, 199, 646, 5549, 199, 646, 5145, 199, 646, 7975, 199, 646, 9143, 199, 199, 504, 9116, 14, 18587, 492, 3816, 199, 504, 9116, 14, 18587, 14, 4174, 14, 4912, 492, 1455, 63, 1258, 12, 4011, 199, 199, 504, 5496, 63, 4435, 492, 2740, 63, 2373, 63, 3438, 199, 504, 1275, 5064, 492, 5802, 421, 199, 318, 485, 2143, 8, 83, 304, 272, 2552, 275, 283, 16380, 3765, 7, 340, 3816, 14, 4521, 19, 587, 283, 4768, 7, 272, 372, 308, 14, 2143, 360, 1624, 13, 24, 297, 2552, 9, 421, 199, 533, 5802, 63, 4757, 8, 5064, 304, 272, 1369, 275, 283, 10301, 3794, 370, 24330, 7, 339, 922, 63, 1419, 275, 359, 267, 661, 8421, 4009, 283, 82, 297, 268, 298, 633, 402, 7611, 359, 885, 26, 450, 83, 8480, 450, 5802, 14, 3472, 63, 907, 27998, 5347, 395, 267, 661, 2384, 13, 1310, 297, 488, 12, 268, 283, 2918, 2615, 1177, 1318, 687, 1654, 659, 267, 661, 5064, 13, 694, 4009, 488, 12, 283, 3619, 370, 5802, 659, 272, 1622, 272, 5046, 63, 1419, 275, 5802, 14, 4871, 63, 1419, 339, 347, 965, 63, 8008, 8, 277, 304, 267, 340, 291, 14, 5064, 63, 694, 365, 488, 26, 288, 367, 5442, 315, 2740, 63, 2373, 63, 3438, 360, 13350, 14, 4405, 297, 283, 1506, 63, 8008, 735, 355, 372, 715, 339, 1007, 63, 4405, 275, 4274, 1506, 63, 8008, 297, 965, 63, 8008, 1874, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 5802, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 5064, 63, 694, 275, 488, 267, 291, 14, 1375, 63, 694, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 5802, 14, 14450, 63, 1419, 8, 277, 9, 267, 340, 291, 14, 5064, 63, 694, 365, 488, 26, 288, 340, 291, 14, 1989, 63, 8008, 837, 355, 1900, 63, 8008, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 63, 8008, 358, 355, 291, 14, 1375, 63, 694, 275, 1900, 63, 8008, 14, 5649, 63, 1375, 63, 694, 288, 587, 26, 355, 1900, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 358, 355, 291, 14, 1375, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1506, 14, 1506, 63, 1095, 12, 283, 4757, 358, 267, 587, 26, 288, 291, 14, 7505, 63, 3475, 360, 5064, 63, 694, 358, 288, 291, 14, 1375, 63, 694, 275, 291, 14, 5064, 63, 694, 267, 291, 14, 17803, 360, 10369, 5802, 2082, 450, 83, 7, 450, 291, 14, 1375, 63, 694, 9, 339, 347, 1218, 63, 18717, 8, 277, 12, 1788, 304, 267, 3482, 63, 493, 275, 10392, 14, 15016, 8, 1501, 12, 298, 87, 531, 267, 862, 26, 288, 291, 14, 3880, 515, 8, 277, 14, 1375, 63, 694, 9, 221, 327, 2951, 315, 1930, 288, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 277, 14, 1375, 63, 694, 304, 355, 340, 1738, 508, 291, 14, 1375, 63, 694, 436, 440, 1584, 26, 490, 746, 31484, 8, 717, 298, 889, 1584, 1911, 315, 5802, 2082, 1543, 83, 4065, 717, 450, 291, 14, 1375, 63, 694, 9, 355, 367, 536, 315, 1584, 26, 490, 2615, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 490, 3847, 275, 1738, 59, 552, 8, 277, 14, 1375, 63, 694, 304, 1055, 10124, 8, 736, 14, 515, 14, 4127, 9, 490, 2053, 275, 747, 14, 515, 14, 904, 8, 6188, 12, 536, 9, 490, 3482, 63, 493, 14, 952, 8, 2861, 12, 2053, 9, 267, 3753, 26, 288, 3482, 63, 493, 14, 1600, 342, 339, 347, 1255, 8, 277, 304, 267, 327, 3378, 1007, 3718, 267, 367, 2088, 63, 354, 315, 291, 14, 362, 63, 954, 63, 4405, 837, 288, 291, 14, 1065, 63, 1531, 8, 1760, 63, 354, 9, 398, 3529, 63, 694, 275, 5549, 14, 11983, 342, 267, 536, 275, 291, 14, 4972, 14, 2343, 14, 362, 63, 354, 342, 267, 3482, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 2071, 83, 14, 3065, 2, 450, 536, 9, 267, 862, 26, 288, 291, 14, 981, 63, 18717, 8, 3065, 63, 493, 9, 288, 291, 14, 5064, 63, 493, 8, 3065, 63, 493, 9, 267, 3753, 26, 288, 5145, 14, 9242, 8, 2791, 63, 694, 9, 339, 768, 4639, 272, 347, 485, 1506, 63, 2064, 8, 1053, 12, 7375, 63, 9891, 304, 267, 790, 12, 1338, 275, 1242, 267, 2538, 275, 1557, 78, 2714, 13, 15954, 26, 1824, 13, 576, 27, 536, 5961, 83, 4507, 450, 790, 267, 327, 2429, 3663, 4811, 367, 314, 2011, 536, 267, 340, 440, 1228, 8, 1459, 12, 769, 304, 288, 1338, 275, 359, 1459, 61, 267, 367, 574, 315, 1338, 26, 288, 340, 730, 8, 585, 9, 365, 2008, 26, 355, 2538, 847, 14289, 1788, 5961, 83, 4507, 450, 574, 59, 16, 61, 355, 574, 275, 574, 59, 17, 61, 288, 587, 26, 355, 574, 275, 485, 2143, 8, 585, 9, 288, 1995, 7375, 63, 9891, 288, 1995, 485, 2143, 8, 1213, 9, 288, 1995, 330, 3212, 78, 60, 78, 2, 288, 1995, 574, 288, 340, 574, 436, 574, 1988, 17, 2938, 508, 330, 1154, 82, 356, 355, 1995, 330, 1154, 78, 7, 221, 327, 2218, 376, 2402, 8057, 334, 76, 300, 432, 10444, 83, 9, 339, 768, 3744, 272, 347, 485, 1506, 63, 10123, 8, 1886, 12, 666, 304, 267, 408, 267, 6516, 1536, 314, 14735, 4886, 367, 314, 8761, 666, 267, 408, 267, 8424, 275, 330, 7, 10965, 31916, 8656, 38, 42, 8045, 39, 3177, 13332, 19, 38, 24100, 32259, 907, 2194, 772, 1465, 1367, 1342, 708, 1477, 7, 267, 7375, 63, 9891, 275, 330, 1154, 78, 306, 7, 435, 8424, 267, 1284, 63, 9891, 275, 7375, 63, 9891, 435, 330 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 5064, 63, 4757, 199, 199, 29452, 282, 12577, 283, 5064, 63, 4757, 7, 21474, 334, 5064, 3794, 370, 199, 2713, 2252, 1159, 2366, 24127, 14, 1308, 680, 199, 624, 199, 199, 504, 1300, 772, 492, 4465, 63, 66, 772, 2143, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 31484, 199, 646, 747, 199, 646, 2838, 199, 646, 10392, 199, 646, 5549, 199, 646, 5145, 199, 646, 7975, 199, 646, 9143, 199, 199, 504, 9116, 14, 18587, 492, 3816, 199, 504, 9116, 14, 18587, 14, 4174, 14, 4912, 492, 1455, 63, 1258, 12, 4011, 199, 199, 504, 5496, 63, 4435, 492, 2740, 63, 2373, 63, 3438, 199, 504, 1275, 5064, 492, 5802, 421, 199, 318, 485, 2143, 8, 83, 304, 272, 2552, 275, 283, 16380, 3765, 7, 340, 3816, 14, 4521, 19, 587, 283, 4768, 7, 272, 372, 308, 14, 2143, 360, 1624, 13, 24, 297, 2552, 9, 421, 199, 533, 5802, 63, 4757, 8, 5064, 304, 272, 1369, 275, 283, 10301, 3794, 370, 24330, 7, 339, 922, 63, 1419, 275, 359, 267, 661, 8421, 4009, 283, 82, 297, 268, 298, 633, 402, 7611, 359, 885, 26, 450, 83, 8480, 450, 5802, 14, 3472, 63, 907, 27998, 5347, 395, 267, 661, 2384, 13, 1310, 297, 488, 12, 268, 283, 2918, 2615, 1177, 1318, 687, 1654, 659, 267, 661, 5064, 13, 694, 4009, 488, 12, 283, 3619, 370, 5802, 659, 272, 1622, 272, 5046, 63, 1419, 275, 5802, 14, 4871, 63, 1419, 339, 347, 965, 63, 8008, 8, 277, 304, 267, 340, 291, 14, 5064, 63, 694, 365, 488, 26, 288, 367, 5442, 315, 2740, 63, 2373, 63, 3438, 360, 13350, 14, 4405, 297, 283, 1506, 63, 8008, 735, 355, 372, 715, 339, 1007, 63, 4405, 275, 4274, 1506, 63, 8008, 297, 965, 63, 8008, 1874, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 5802, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 5064, 63, 694, 275, 488, 267, 291, 14, 1375, 63, 694, 275, 488, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 5802, 14, 14450, 63, 1419, 8, 277, 9, 267, 340, 291, 14, 5064, 63, 694, 365, 488, 26, 288, 340, 291, 14, 1989, 63, 8008, 837, 355, 1900, 63, 8008, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 63, 8008, 358, 355, 291, 14, 1375, 63, 694, 275, 1900, 63, 8008, 14, 5649, 63, 1375, 63, 694, 288, 587, 26, 355, 1900, 275, 291, 14, 362, 63, 19231, 63, 1531, 360, 1506, 358, 355, 291, 14, 1375, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1506, 14, 1506, 63, 1095, 12, 283, 4757, 358, 267, 587, 26, 288, 291, 14, 7505, 63, 3475, 360, 5064, 63, 694, 358, 288, 291, 14, 1375, 63, 694, 275, 291, 14, 5064, 63, 694, 267, 291, 14, 17803, 360, 10369, 5802, 2082, 450, 83, 7, 450, 291, 14, 1375, 63, 694, 9, 339, 347, 1218, 63, 18717, 8, 277, 12, 1788, 304, 267, 3482, 63, 493, 275, 10392, 14, 15016, 8, 1501, 12, 298, 87, 531, 267, 862, 26, 288, 291, 14, 3880, 515, 8, 277, 14, 1375, 63, 694, 9, 221, 327, 2951, 315, 1930, 288, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 277, 14, 1375, 63, 694, 304, 355, 340, 1738, 508, 291, 14, 1375, 63, 694, 436, 440, 1584, 26, 490, 746, 31484, 8, 717, 298, 889, 1584, 1911, 315, 5802, 2082, 1543, 83, 4065, 717, 450, 291, 14, 1375, 63, 694, 9, 355, 367, 536, 315, 1584, 26, 490, 2615, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 490, 3847, 275, 1738, 59, 552, 8, 277, 14, 1375, 63, 694, 304, 1055, 10124, 8, 736, 14, 515, 14, 4127, 9, 490, 2053, 275, 747, 14, 515, 14, 904, 8, 6188, 12, 536, 9, 490, 3482, 63, 493, 14, 952, 8, 2861, 12, 2053, 9, 267, 3753, 26, 288, 3482, 63, 493, 14, 1600, 342, 339, 347, 1255, 8, 277, 304, 267, 327, 3378, 1007, 3718, 267, 367, 2088, 63, 354, 315, 291, 14, 362, 63, 954, 63, 4405, 837, 288, 291, 14, 1065, 63, 1531, 8, 1760, 63, 354, 9, 398, 3529, 63, 694, 275, 5549, 14, 11983, 342, 267, 536, 275, 291, 14, 4972, 14, 2343, 14, 362, 63, 354, 342, 267, 3482, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 2071, 83, 14, 3065, 2, 450, 536, 9, 267, 862, 26, 288, 291, 14, 981, 63, 18717, 8, 3065, 63, 493, 9, 288, 291, 14, 5064, 63, 493, 8, 3065, 63, 493, 9, 267, 3753, 26, 288, 5145, 14, 9242, 8, 2791, 63, 694, 9, 339, 768, 4639, 272, 347, 485, 1506, 63, 2064, 8, 1053, 12, 7375, 63, 9891, 304, 267, 790, 12, 1338, 275, 1242, 267, 2538, 275, 1557, 78, 2714, 13, 15954, 26, 1824, 13, 576, 27, 536, 5961, 83, 4507, 450, 790, 267, 327, 2429, 3663, 4811, 367, 314, 2011, 536, 267, 340, 440, 1228, 8, 1459, 12, 769, 304, 288, 1338, 275, 359, 1459, 61, 267, 367, 574, 315, 1338, 26, 288, 340, 730, 8, 585, 9, 365, 2008, 26, 355, 2538, 847, 14289, 1788, 5961, 83, 4507, 450, 574, 59, 16, 61, 355, 574, 275, 574, 59, 17, 61, 288, 587, 26, 355, 574, 275, 485, 2143, 8, 585, 9, 288, 1995, 7375, 63, 9891, 288, 1995, 485, 2143, 8, 1213, 9, 288, 1995, 330, 3212, 78, 60, 78, 2, 288, 1995, 574, 288, 340, 574, 436, 574, 1988, 17, 2938, 508, 330, 1154, 82, 356, 355, 1995, 330, 1154, 78, 7, 221, 327, 2218, 376, 2402, 8057, 334, 76, 300, 432, 10444, 83, 9, 339, 768, 3744, 272, 347, 485, 1506, 63, 10123, 8, 1886, 12, 666, 304, 267, 408, 267, 6516, 1536, 314, 14735, 4886, 367, 314, 8761, 666, 267, 408, 267, 8424, 275, 330, 7, 10965, 31916, 8656, 38, 42, 8045, 39, 3177, 13332, 19, 38, 24100, 32259, 907, 2194, 772, 1465, 1367, 1342, 708, 1477, 7, 267, 7375, 63, 9891, 275, 330, 1154, 78, 306, 7, 435, 8424, 267, 1284, 63, 9891, 275, 7375, 63, 9891, 435, 330, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
willingc/oh-mainline
vendor/packages/whoosh/tests/test_matching.py
16
13944
from __future__ import with_statement from random import randint, choice, sample from nose.tools import assert_equal, assert_not_equal #@UnresolvedImport from whoosh import fields, matching, query from whoosh.compat import u from whoosh.filedb.filestore import RamStorage from whoosh.query import And, Term from whoosh.util import make_binary_tree, permutations def _keys(searcher, docnums): return sorted([searcher.stored_fields(docnum)['key'] for docnum in docnums]) def test_nullmatcher(): nm = matching.NullMatcher() assert not nm.is_active() assert_equal(list(nm.all_ids()), []) def test_listmatcher(): ids = [1, 2, 5, 9, 10] lm = matching.ListMatcher(ids) ls = [] while lm.is_active(): ls.append((lm.id(), lm.score())) lm.next() assert_equal(ls, [(1, 1.0), (2, 1.0), (5, 1.0), (9, 1.0), (10, 1.0)]) lm = matching.ListMatcher(ids) assert_equal(list(lm.all_ids()), ids) lm = matching.ListMatcher(ids, position=3) ls = [] while lm.is_active(): ls.append(lm.id()) lm.next() assert_equal(ls, [9, 10]) lm = matching.ListMatcher(ids) for _ in xrange(3): lm.next() lm = lm.copy() ls = [] while lm.is_active(): ls.append(lm.id()) lm.next() assert_equal(ls, [9, 10]) def test_wrapper(): wm = matching.WrappingMatcher(matching.ListMatcher([1, 2, 5, 9, 10]), boost=2.0) ls = [] while wm.is_active(): ls.append((wm.id(), wm.score())) wm.next() assert_equal(ls, [(1, 2.0), (2, 2.0), (5, 2.0), (9, 2.0), (10, 2.0)]) ids = [1, 2, 5, 9, 10] wm = matching.WrappingMatcher(matching.ListMatcher(ids), boost=2.0) assert_equal(list(wm.all_ids()), ids) def test_filter(): lm = lambda: matching.ListMatcher(list(range(2, 10))) fm = matching.FilterMatcher(lm(), frozenset([3, 9])) assert_equal(list(fm.all_ids()), [3, 9]) fm = matching.FilterMatcher(lm(), frozenset([1, 5, 9, 13])) assert_equal(list(fm.all_ids()), [5, 9]) def test_exclude(): em = matching.FilterMatcher(matching.ListMatcher([1, 2, 5, 9, 10]), frozenset([2, 9]), exclude=True) assert_equal(list(em.all_ids()), [1, 5, 10]) em = matching.FilterMatcher(matching.ListMatcher([1, 2, 5, 9, 10]), frozenset([2, 9]), exclude=True) assert_equal(list(em.all_ids()), [1, 5, 10]) em = matching.FilterMatcher(matching.ListMatcher([1, 2, 5, 9, 10]), frozenset([2, 9]), exclude=True) em.next() em.next() em = em.copy() ls = [] while em.is_active(): ls.append(em.id()) em.next() assert_equal(ls, [10]) def test_simple_union(): lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) um = matching.UnionMatcher(lm1, lm2) ls = [] while um.is_active(): ls.append((um.id(), um.score())) um.next() assert_equal(ls, [(0, 1.0), (1, 1.0), (4, 2.0), (10, 1.0), (20, 2.0), (90, 1.0)]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) um = matching.UnionMatcher(lm1, lm2) assert_equal(list(um.all_ids()), [0, 1, 4, 10, 20, 90]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) um = matching.UnionMatcher(lm1, lm2) um.next() um.next() um = um.copy() ls = [] while um.is_active(): ls.append(um.id()) um.next() assert_equal(ls, [4, 10, 20, 90]) def test_simple_intersection(): lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) im = matching.IntersectionMatcher(lm1, lm2) ls = [] while im.is_active(): ls.append((im.id(), im.score())) im.next() assert_equal(ls, [(4, 2.0), (20, 2.0)]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) im = matching.IntersectionMatcher(lm1, lm2) assert_equal(list(im.all_ids()), [4, 20]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) im = matching.IntersectionMatcher(lm1, lm2) im.next() im.next() im = im.copy() ls = [] while im.is_active(): ls.append(im.id()) im.next() assert_equal(ls, []) def test_andnot(): lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) anm = matching.AndNotMatcher(lm1, lm2) ls = [] while anm.is_active(): ls.append((anm.id(), anm.score())) anm.next() assert_equal(ls, [(1, 1.0), (10, 1.0), (90, 1.0)]) echo_lm = matching.ListMatcher([0, 1, 2, 3, 4]) bravo_lm = matching.ListMatcher([0, 1]) anm = matching.AndNotMatcher(echo_lm, bravo_lm) assert_equal(list(anm.all_ids()), [2, 3, 4]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) anm = matching.AndNotMatcher(lm1, lm2) assert_equal(list(anm.all_ids()), [1, 10, 90]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) anm = matching.AndNotMatcher(lm1, lm2) anm.next() anm.next() anm = anm.copy() ls = [] while anm.is_active(): ls.append(anm.id()) anm.next() assert_equal(ls, [90]) def test_require(): lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) rm = matching.RequireMatcher(lm1, lm2) ls = [] while rm.is_active(): ls.append((rm.id(), rm.score())) rm.next() assert_equal(ls, [(4, 1.0), (20, 1.0)]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) rm = matching.RequireMatcher(lm1, lm2) assert_equal(list(rm.all_ids()), [4, 20]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) rm = matching.RequireMatcher(lm1, lm2) rm.next() rm.next() rm = rm.copy() ls = [] while rm.is_active(): ls.append(rm.id()) rm.next() assert_equal(ls, []) def test_andmaybe(): lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) amm = matching.AndMaybeMatcher(lm1, lm2) ls = [] while amm.is_active(): ls.append((amm.id(), amm.score())) amm.next() assert_equal(ls, [(1, 1.0), (4, 2.0), (10, 1.0), (20, 2.0), (90, 1.0)]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) amm = matching.AndMaybeMatcher(lm1, lm2) assert_equal(list(amm.all_ids()), [1, 4, 10, 20, 90]) lm1 = matching.ListMatcher([1, 4, 10, 20, 90]) lm2 = matching.ListMatcher([0, 4, 20]) amm = matching.AndMaybeMatcher(lm1, lm2) amm.next() amm.next() amm = amm.copy() ls = [] while amm.is_active(): ls.append(amm.id()) amm.next() assert_equal(ls, [10, 20, 90]) def test_intersection(): schema = fields.Schema(key = fields.ID(stored=True), value = fields.TEXT(stored=True)) st = RamStorage() ix = st.create_index(schema) w = ix.writer() w.add_document(key=u("a"), value=u("alpha bravo charlie delta")) w.add_document(key=u("b"), value=u("echo foxtrot alpha bravo")) w.add_document(key=u("c"), value=u("charlie delta golf hotel")) w.commit() w = ix.writer() w.add_document(key=u("d"), value=u("india alpha bravo charlie")) w.add_document(key=u("e"), value=u("delta bravo india bravo")) w.commit() with ix.searcher() as s: q = And([Term("value", u("bravo")), Term("value", u("delta"))]) m = q.matcher(s) assert_equal(_keys(s, m.all_ids()), ["a", "e"]) q = And([Term("value", u("bravo")), Term("value", u("alpha"))]) m = q.matcher(s) assert_equal(_keys(s, m.all_ids()), ["a", "b", "d"]) def test_random_intersections(): domain = [u("alpha"), u("bravo"), u("charlie"), u("delta"), u("echo"), u("foxtrot"), u("golf"), u("hotel"), u("india"), u("juliet"), u("kilo"), u("lima"), u("mike")] segments = 5 docsperseg = 50 fieldlimits = (3, 10) documents = [] schema = fields.Schema(key=fields.STORED, value=fields.TEXT(stored=True)) st = RamStorage() ix = st.create_index(schema) # Create docsperseg * segments documents containing random words from # the domain list. Add the documents to the index, but also keep them # in the "documents" list for the sanity check for i in xrange(segments): w = ix.writer() for j in xrange(docsperseg): docnum = i * docsperseg + j # Create a string of random words doc = u(" ").join(choice(domain) for _ in xrange(randint(*fieldlimits))) # Add the string to the index w.add_document(key=docnum, value=doc) # Add a (docnum, string) tuple to the documents list documents.append((docnum, doc)) w.commit() assert_not_equal(len(ix._segments()), 1) testcount = 20 testlimits = (2, 5) with ix.searcher() as s: for i in xrange(s.doc_count_all()): assert_not_equal(s.stored_fields(i).get("key"), None) for _ in xrange(testcount): # Create a random list of words and manually do an intersection of # items in "documents" that contain the words ("target"). words = sample(domain, randint(*testlimits)) target = [] for docnum, doc in documents: if all((doc.find(w) > -1) for w in words): target.append(docnum) target.sort() # Create a query from the list of words and get two matchers from # it. q = And([Term("value", w) for w in words]) m1 = q.matcher(s) m2 = q.matcher(s) # Try getting the list of IDs from all_ids() ids1 = list(m1.all_ids()) # Try getting the list of IDs using id()/next() ids2 = [] while m2.is_active(): ids2.append(m2.id()) m2.next() # Check that the two methods return the same list assert_equal(ids1, ids2) # Check that the IDs match the ones we manually calculated assert_equal(_keys(s, ids1), target) def test_union(): s1 = matching.ListMatcher([1, 2, 3, 4, 5, 6, 7, 8]) s2 = matching.ListMatcher([2, 4, 8, 10, 20, 30]) s3 = matching.ListMatcher([10, 100, 200]) target = [1, 2, 3, 4, 5, 6, 7, 8, 10, 20, 30, 100, 200] um = matching.UnionMatcher(s1, matching.UnionMatcher(s2, s3)) assert_equal(target, list(um.all_ids())) def test_union_scores(): s1 = matching.ListMatcher([1, 2, 3]) s2 = matching.ListMatcher([2, 4, 8]) s3 = matching.ListMatcher([2, 3, 8]) target = [(1, 1.0), (2, 3.0), (3, 2.0), (4, 1.0), (8, 2.0)] um = matching.UnionMatcher(s1, matching.UnionMatcher(s2, s3)) result = [] while um.is_active(): result.append((um.id(), um.score())) um.next() assert_equal(target, result) def test_random_union(): testcount = 100 rangelimits = (2, 10) clauselimits = (2, 10) vals = list(range(100)) for _ in xrange(testcount): target = set() matchers = [] for _ in xrange(randint(*clauselimits)): nums = sample(vals, randint(*rangelimits)) target = target.union(nums) matchers.append(matching.ListMatcher(sorted(nums))) target = sorted(target) um = make_binary_tree(matching.UnionMatcher, matchers) assert_equal(list(um.all_ids()), target) def test_inverse(): s = matching.ListMatcher([1, 5, 10, 11, 13]) inv = matching.InverseMatcher(s, 15) ids = [] while inv.is_active(): ids.append(inv.id()) inv.next() assert_equal(ids, [0, 2, 3, 4, 6, 7, 8, 9, 12, 14]) def test_inverse_skip(): s = matching.ListMatcher([1, 5, 10, 11, 13]) inv = matching.InverseMatcher(s, 15) inv.skip_to(8) ids = [] while inv.is_active(): ids.append(inv.id()) inv.next() assert_equal([8, 9, 12, 14], ids) def test_empty_andnot(): pos = matching.NullMatcher() neg = matching.NullMatcher() anm = matching.AndNotMatcher(pos, neg) assert not anm.is_active() assert_equal(list(anm.all_ids()), []) pos = matching.ListMatcher([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) neg = matching.NullMatcher() ans = matching.AndNotMatcher(pos, neg) ids = list(ans.all_ids()) assert_equal(ids, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) def test_random_andnot(): testcount = 100 rangesize = 100 rng = list(range(rangesize)) for _ in xrange(testcount): negs = sorted(sample(rng, randint(0, rangesize-1))) negset = frozenset(negs) matched = [n for n in rng if n not in negset] pos = matching.ListMatcher(rng) neg = matching.ListMatcher(negs) anm = matching.AndNotMatcher(pos, neg) ids = list(anm.all_ids()) assert_equal(ids, matched) def test_current_terms(): domain = u("alfa bravo charlie delta").split() schema = fields.Schema(text=fields.TEXT(stored=True)) ix = RamStorage().create_index(schema) w = ix.writer() for ls in permutations(domain, 3): w.add_document(text=" ".join(ls), _stored_text=ls) w.commit() with ix.searcher() as s: q = query.And([query.Term("text", "alfa"), query.Term("text", "charlie")]) m = q.matcher(s) while m.is_active(): assert_equal(sorted(m.matching_terms()), [("text", "alfa"), ("text", "charlie")]) m.next()
agpl-3.0
[ 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 2196, 492, 29722, 12, 7141, 12, 2690, 199, 199, 504, 11354, 14, 2537, 492, 702, 63, 1452, 12, 702, 63, 1397, 63, 1452, 221, 9213, 1358, 13697, 6295, 199, 199, 504, 3963, 22267, 492, 1504, 12, 4877, 12, 1827, 199, 504, 3963, 22267, 14, 5819, 492, 399, 199, 504, 3963, 22267, 14, 493, 697, 14, 493, 1617, 492, 820, 455, 6408, 199, 504, 3963, 22267, 14, 1131, 492, 6061, 12, 13861, 77, 199, 504, 3963, 22267, 14, 1974, 492, 1852, 63, 3008, 63, 2350, 12, 26899, 421, 199, 318, 485, 1612, 8, 24994, 12, 1382, 16084, 304, 272, 372, 3355, 779, 24994, 14, 16431, 63, 955, 8, 1301, 1507, 11820, 498, 418, 367, 1382, 1507, 315, 1382, 16084, 566, 199, 199, 318, 511, 63, 2307, 16135, 837, 272, 16751, 275, 4877, 14, 8849, 16073, 342, 272, 702, 440, 16751, 14, 374, 63, 2682, 342, 272, 702, 63, 1452, 8, 513, 8, 10756, 14, 452, 63, 1580, 4000, 3073, 199, 199, 318, 511, 63, 513, 16135, 837, 272, 2762, 275, 359, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 61, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 14344, 14, 344, 1062, 24546, 14, 3397, 4059, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 17, 12, 413, 14, 16, 395, 334, 18, 12, 413, 14, 16, 395, 334, 21, 12, 413, 14, 16, 395, 334, 25, 12, 413, 14, 16, 395, 334, 709, 12, 413, 14, 16, 3948, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 702, 63, 1452, 8, 513, 8, 14344, 14, 452, 63, 1580, 4000, 2762, 9, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 12, 3421, 29, 19, 9, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 14344, 14, 344, 1012, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 25, 12, 1616, 566, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 367, 485, 315, 4945, 8, 19, 304, 267, 24546, 14, 2184, 342, 272, 24546, 275, 24546, 14, 1574, 342, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 14344, 14, 344, 1012, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 25, 12, 1616, 566, 199, 199, 318, 511, 63, 5029, 837, 272, 29835, 275, 4877, 14, 55, 15521, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 20198, 29, 18, 14, 16, 9, 272, 9100, 275, 942, 272, 1830, 29835, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 16240, 14, 344, 1062, 29835, 14, 3397, 4059, 267, 29835, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 17, 12, 499, 14, 16, 395, 334, 18, 12, 499, 14, 16, 395, 334, 21, 12, 499, 14, 16, 395, 334, 25, 12, 499, 14, 16, 395, 334, 709, 12, 499, 14, 16, 3948, 2286, 2762, 275, 359, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 61, 272, 29835, 275, 4877, 14, 55, 15521, 16073, 8, 9467, 14, 1296, 16073, 8, 1580, 395, 20198, 29, 18, 14, 16, 9, 272, 702, 63, 1452, 8, 513, 8, 16240, 14, 452, 63, 1580, 4000, 2762, 9, 199, 199, 318, 511, 63, 1541, 837, 272, 24546, 275, 2400, 26, 4877, 14, 1296, 16073, 8, 513, 8, 1842, 8, 18, 12, 1616, 1724, 2286, 20831, 275, 4877, 14, 4131, 16073, 8, 14344, 1062, 9522, 779, 19, 12, 1749, 2459, 272, 702, 63, 1452, 8, 513, 8, 10886, 14, 452, 63, 1580, 4000, 359, 19, 12, 1749, 566, 2286, 20831, 275, 4877, 14, 4131, 16073, 8, 14344, 1062, 9522, 779, 17, 12, 959, 12, 1749, 12, 4944, 2459, 272, 702, 63, 1452, 8, 513, 8, 10886, 14, 452, 63, 1580, 4000, 359, 21, 12, 1749, 566, 199, 199, 318, 511, 63, 5473, 837, 272, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 702, 63, 1452, 8, 513, 8, 5633, 14, 452, 63, 1580, 4000, 359, 17, 12, 959, 12, 1616, 566, 2286, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 702, 63, 1452, 8, 513, 8, 5633, 14, 452, 63, 1580, 4000, 359, 17, 12, 959, 12, 1616, 566, 2286, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 18564, 14, 2184, 342, 272, 18564, 14, 2184, 342, 272, 18564, 275, 18564, 14, 1574, 342, 272, 9100, 275, 942, 272, 1830, 18564, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 5633, 14, 344, 1012, 267, 18564, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 709, 566, 199, 199, 318, 511, 63, 4129, 63, 8888, 837, 272, 24546, 17, 275, 4877, 14, 1296, 16073, 779, 17, 12, 841, 12, 1616, 12, 3388, 12, 9137, 566, 272, 24546, 18, 275, 4877, 14, 1296, 16073, 779, 16, 12, 841, 12, 3388, 566, 272, 28236, 275, 4877, 14, 15540, 16073, 8, 14344, 17, 12, 24546, 18, 9, 272, 9100, 275, 942, 272, 1830, 28236, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 453, 14, 344, 1062, 28236, 14, 3397, 4059, 267, 28236, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 16, 12, 413, 14, 16, 395, 334, 17, 12, 413, 14, 16, 395, 334, 20, 12, 499, 14, 16, 395, 334, 709, 12, 413, 14, 16, 395, 334, 1165, 12, 499, 14, 16, 395, 334, 2710, 12, 413, 14, 16, 3948, 2286, 24546, 17, 275, 4877, 14, 1296, 16073, 779, 17, 12, 841, 12, 1616, 12 ]
[ 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 2196, 492, 29722, 12, 7141, 12, 2690, 199, 199, 504, 11354, 14, 2537, 492, 702, 63, 1452, 12, 702, 63, 1397, 63, 1452, 221, 9213, 1358, 13697, 6295, 199, 199, 504, 3963, 22267, 492, 1504, 12, 4877, 12, 1827, 199, 504, 3963, 22267, 14, 5819, 492, 399, 199, 504, 3963, 22267, 14, 493, 697, 14, 493, 1617, 492, 820, 455, 6408, 199, 504, 3963, 22267, 14, 1131, 492, 6061, 12, 13861, 77, 199, 504, 3963, 22267, 14, 1974, 492, 1852, 63, 3008, 63, 2350, 12, 26899, 421, 199, 318, 485, 1612, 8, 24994, 12, 1382, 16084, 304, 272, 372, 3355, 779, 24994, 14, 16431, 63, 955, 8, 1301, 1507, 11820, 498, 418, 367, 1382, 1507, 315, 1382, 16084, 566, 199, 199, 318, 511, 63, 2307, 16135, 837, 272, 16751, 275, 4877, 14, 8849, 16073, 342, 272, 702, 440, 16751, 14, 374, 63, 2682, 342, 272, 702, 63, 1452, 8, 513, 8, 10756, 14, 452, 63, 1580, 4000, 3073, 199, 199, 318, 511, 63, 513, 16135, 837, 272, 2762, 275, 359, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 61, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 14344, 14, 344, 1062, 24546, 14, 3397, 4059, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 17, 12, 413, 14, 16, 395, 334, 18, 12, 413, 14, 16, 395, 334, 21, 12, 413, 14, 16, 395, 334, 25, 12, 413, 14, 16, 395, 334, 709, 12, 413, 14, 16, 3948, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 702, 63, 1452, 8, 513, 8, 14344, 14, 452, 63, 1580, 4000, 2762, 9, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 12, 3421, 29, 19, 9, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 14344, 14, 344, 1012, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 25, 12, 1616, 566, 2286, 24546, 275, 4877, 14, 1296, 16073, 8, 1580, 9, 272, 367, 485, 315, 4945, 8, 19, 304, 267, 24546, 14, 2184, 342, 272, 24546, 275, 24546, 14, 1574, 342, 272, 9100, 275, 942, 272, 1830, 24546, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 14344, 14, 344, 1012, 267, 24546, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 25, 12, 1616, 566, 199, 199, 318, 511, 63, 5029, 837, 272, 29835, 275, 4877, 14, 55, 15521, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 20198, 29, 18, 14, 16, 9, 272, 9100, 275, 942, 272, 1830, 29835, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 16240, 14, 344, 1062, 29835, 14, 3397, 4059, 267, 29835, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 17, 12, 499, 14, 16, 395, 334, 18, 12, 499, 14, 16, 395, 334, 21, 12, 499, 14, 16, 395, 334, 25, 12, 499, 14, 16, 395, 334, 709, 12, 499, 14, 16, 3948, 2286, 2762, 275, 359, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 61, 272, 29835, 275, 4877, 14, 55, 15521, 16073, 8, 9467, 14, 1296, 16073, 8, 1580, 395, 20198, 29, 18, 14, 16, 9, 272, 702, 63, 1452, 8, 513, 8, 16240, 14, 452, 63, 1580, 4000, 2762, 9, 199, 199, 318, 511, 63, 1541, 837, 272, 24546, 275, 2400, 26, 4877, 14, 1296, 16073, 8, 513, 8, 1842, 8, 18, 12, 1616, 1724, 2286, 20831, 275, 4877, 14, 4131, 16073, 8, 14344, 1062, 9522, 779, 19, 12, 1749, 2459, 272, 702, 63, 1452, 8, 513, 8, 10886, 14, 452, 63, 1580, 4000, 359, 19, 12, 1749, 566, 2286, 20831, 275, 4877, 14, 4131, 16073, 8, 14344, 1062, 9522, 779, 17, 12, 959, 12, 1749, 12, 4944, 2459, 272, 702, 63, 1452, 8, 513, 8, 10886, 14, 452, 63, 1580, 4000, 359, 21, 12, 1749, 566, 199, 199, 318, 511, 63, 5473, 837, 272, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 702, 63, 1452, 8, 513, 8, 5633, 14, 452, 63, 1580, 4000, 359, 17, 12, 959, 12, 1616, 566, 2286, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 702, 63, 1452, 8, 513, 8, 5633, 14, 452, 63, 1580, 4000, 359, 17, 12, 959, 12, 1616, 566, 2286, 18564, 275, 4877, 14, 4131, 16073, 8, 9467, 14, 1296, 16073, 779, 17, 12, 499, 12, 959, 12, 1749, 12, 1616, 2522, 9522, 779, 18, 12, 1749, 2522, 5760, 29, 549, 9, 272, 18564, 14, 2184, 342, 272, 18564, 14, 2184, 342, 272, 18564, 275, 18564, 14, 1574, 342, 272, 9100, 275, 942, 272, 1830, 18564, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 8, 5633, 14, 344, 1012, 267, 18564, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 359, 709, 566, 199, 199, 318, 511, 63, 4129, 63, 8888, 837, 272, 24546, 17, 275, 4877, 14, 1296, 16073, 779, 17, 12, 841, 12, 1616, 12, 3388, 12, 9137, 566, 272, 24546, 18, 275, 4877, 14, 1296, 16073, 779, 16, 12, 841, 12, 3388, 566, 272, 28236, 275, 4877, 14, 15540, 16073, 8, 14344, 17, 12, 24546, 18, 9, 272, 9100, 275, 942, 272, 1830, 28236, 14, 374, 63, 2682, 837, 267, 9100, 14, 740, 1332, 453, 14, 344, 1062, 28236, 14, 3397, 4059, 267, 28236, 14, 2184, 342, 272, 702, 63, 1452, 8, 478, 12, 3842, 16, 12, 413, 14, 16, 395, 334, 17, 12, 413, 14, 16, 395, 334, 20, 12, 499, 14, 16, 395, 334, 709, 12, 413, 14, 16, 395, 334, 1165, 12, 499, 14, 16, 395, 334, 2710, 12, 413, 14, 16, 3948, 2286, 24546, 17, 275, 4877, 14, 1296, 16073, 779, 17, 12, 841, 12, 1616, 12, 0 ]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 1 ]
Avinash-Raj/appengine-django-skeleton
lib/django/contrib/gis/db/backends/oracle/models.py
475
2275
""" The GeometryColumns and SpatialRefSys models for the Oracle spatial backend. It should be noted that Oracle Spatial does not have database tables named according to the OGC standard, so the closest analogs are used. For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model. """ from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class OracleGeometryColumns(models.Model): "Maps to the Oracle USER_SDO_GEOM_METADATA table." table_name = models.CharField(max_length=32) column_name = models.CharField(max_length=1024) srid = models.IntegerField(primary_key=True) # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY). class Meta: app_label = 'gis' db_table = 'USER_SDO_GEOM_METADATA' managed = False @classmethod def table_name_col(cls): """ Returns the name of the metadata column used to store the feature table name. """ return 'table_name' @classmethod def geom_col_name(cls): """ Returns the name of the metadata column used to store the feature geometry column. """ return 'column_name' def __str__(self): return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid) class OracleSpatialRefSys(models.Model, SpatialRefSysMixin): "Maps to the Oracle MDSYS.CS_SRS table." cs_name = models.CharField(max_length=68) srid = models.IntegerField(primary_key=True) auth_srid = models.IntegerField() auth_name = models.CharField(max_length=256) wktext = models.CharField(max_length=2046) # Optional geometry representing the bounds of this coordinate # system. By default, all are NULL in the table. cs_bounds = models.PolygonField(null=True) objects = models.GeoManager() class Meta: app_label = 'gis' db_table = 'CS_SRS' managed = False @property def wkt(self): return self.wktext @classmethod def wkt_col(cls): return 'wktext'
bsd-3-clause
[ 624, 199, 710, 10579, 15086, 436, 13423, 2891, 11319, 1709, 367, 314, 15309, 11469, 199, 4865, 14, 421, 2779, 1077, 506, 949, 471, 626, 15309, 13423, 1630, 440, 1172, 3050, 6716, 199, 4310, 7182, 370, 314, 593, 7484, 4465, 12, 880, 314, 18284, 376, 18238, 787, 1202, 14, 199, 2104, 2893, 12, 314, 658, 3791, 63, 24399, 63, 31080, 63, 8314, 64, 365, 1202, 367, 314, 10579, 15086, 199, 1402, 436, 314, 658, 24399, 63, 21901, 63, 8279, 63, 13326, 64, 365, 1202, 367, 314, 13423, 2891, 11319, 1402, 14, 199, 624, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 7765, 14, 1095, 14, 992, 492, 13423, 2891, 11319, 4256, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 15309, 6831, 15086, 8, 992, 14, 1685, 304, 272, 298, 24995, 370, 314, 15309, 13044, 63, 24399, 63, 31080, 63, 8314, 1817, 2122, 272, 1817, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 9, 272, 2763, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 7727, 9, 272, 15627, 275, 1709, 14, 3901, 8, 3327, 63, 498, 29, 549, 9, 272, 327, 3254, 26, 2654, 2291, 367, 658, 3572, 815, 64, 2763, 334, 466, 603, 3177, 20238, 14, 24399, 63, 19080, 63, 12322, 680, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 5668, 7, 267, 1592, 63, 1224, 275, 283, 3791, 63, 24399, 63, 31080, 63, 8314, 7, 267, 12883, 275, 756, 339, 768, 3744, 272, 347, 1817, 63, 354, 63, 761, 8, 1886, 304, 267, 408, 267, 1803, 314, 536, 402, 314, 3341, 2763, 1202, 370, 3877, 314, 3878, 1817, 267, 536, 14, 267, 408, 267, 372, 283, 1224, 63, 354, 7, 339, 768, 3744, 272, 347, 9671, 63, 761, 63, 354, 8, 1886, 304, 267, 408, 267, 1803, 314, 536, 402, 314, 3341, 2763, 1202, 370, 3877, 314, 3878, 267, 3400, 2763, 14, 267, 408, 267, 372, 283, 2301, 63, 354, 7, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 334, 5943, 998, 26, 450, 83, 3171, 450, 334, 277, 14, 1224, 63, 354, 12, 291, 14, 2301, 63, 354, 12, 291, 14, 10498, 9, 421, 199, 533, 15309, 18075, 2891, 11319, 8, 992, 14, 1685, 12, 13423, 2891, 11319, 4256, 304, 272, 298, 24995, 370, 314, 15309, 603, 3177, 20238, 14, 3298, 63, 5943, 51, 1817, 2122, 272, 7117, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2333, 9, 272, 15627, 275, 1709, 14, 3901, 8, 3327, 63, 498, 29, 549, 9, 272, 1790, 63, 10498, 275, 1709, 14, 3901, 342, 272, 1790, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 3912, 9, 272, 336, 75, 505, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 6686, 22, 9, 272, 327, 4879, 3400, 6144, 314, 10461, 402, 642, 10021, 272, 327, 2656, 14, 221, 4885, 849, 12, 1006, 787, 5962, 315, 314, 1817, 14, 272, 7117, 63, 9632, 275, 1709, 14, 12367, 792, 8, 2307, 29, 549, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 5668, 7, 267, 1592, 63, 1224, 275, 283, 3298, 63, 5943, 51, 7, 267, 12883, 275, 756, 339, 768, 1829, 272, 347, 21992, 8, 277, 304, 267, 372, 291, 14, 14947, 505, 339, 768, 3744, 272, 347, 21992, 63, 761, 8, 1886, 304, 267, 372, 283, 14947, 505, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 710, 10579, 15086, 436, 13423, 2891, 11319, 1709, 367, 314, 15309, 11469, 199, 4865, 14, 421, 2779, 1077, 506, 949, 471, 626, 15309, 13423, 1630, 440, 1172, 3050, 6716, 199, 4310, 7182, 370, 314, 593, 7484, 4465, 12, 880, 314, 18284, 376, 18238, 787, 1202, 14, 199, 2104, 2893, 12, 314, 658, 3791, 63, 24399, 63, 31080, 63, 8314, 64, 365, 1202, 367, 314, 10579, 15086, 199, 1402, 436, 314, 658, 24399, 63, 21901, 63, 8279, 63, 13326, 64, 365, 1202, 367, 314, 13423, 2891, 11319, 1402, 14, 199, 624, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 7765, 14, 1095, 14, 992, 492, 13423, 2891, 11319, 4256, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 15309, 6831, 15086, 8, 992, 14, 1685, 304, 272, 298, 24995, 370, 314, 15309, 13044, 63, 24399, 63, 31080, 63, 8314, 1817, 2122, 272, 1817, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 9, 272, 2763, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 7727, 9, 272, 15627, 275, 1709, 14, 3901, 8, 3327, 63, 498, 29, 549, 9, 272, 327, 3254, 26, 2654, 2291, 367, 658, 3572, 815, 64, 2763, 334, 466, 603, 3177, 20238, 14, 24399, 63, 19080, 63, 12322, 680, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 5668, 7, 267, 1592, 63, 1224, 275, 283, 3791, 63, 24399, 63, 31080, 63, 8314, 7, 267, 12883, 275, 756, 339, 768, 3744, 272, 347, 1817, 63, 354, 63, 761, 8, 1886, 304, 267, 408, 267, 1803, 314, 536, 402, 314, 3341, 2763, 1202, 370, 3877, 314, 3878, 1817, 267, 536, 14, 267, 408, 267, 372, 283, 1224, 63, 354, 7, 339, 768, 3744, 272, 347, 9671, 63, 761, 63, 354, 8, 1886, 304, 267, 408, 267, 1803, 314, 536, 402, 314, 3341, 2763, 1202, 370, 3877, 314, 3878, 267, 3400, 2763, 14, 267, 408, 267, 372, 283, 2301, 63, 354, 7, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 334, 5943, 998, 26, 450, 83, 3171, 450, 334, 277, 14, 1224, 63, 354, 12, 291, 14, 2301, 63, 354, 12, 291, 14, 10498, 9, 421, 199, 533, 15309, 18075, 2891, 11319, 8, 992, 14, 1685, 12, 13423, 2891, 11319, 4256, 304, 272, 298, 24995, 370, 314, 15309, 603, 3177, 20238, 14, 3298, 63, 5943, 51, 1817, 2122, 272, 7117, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2333, 9, 272, 15627, 275, 1709, 14, 3901, 8, 3327, 63, 498, 29, 549, 9, 272, 1790, 63, 10498, 275, 1709, 14, 3901, 342, 272, 1790, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 3912, 9, 272, 336, 75, 505, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 6686, 22, 9, 272, 327, 4879, 3400, 6144, 314, 10461, 402, 642, 10021, 272, 327, 2656, 14, 221, 4885, 849, 12, 1006, 787, 5962, 315, 314, 1817, 14, 272, 7117, 63, 9632, 275, 1709, 14, 12367, 792, 8, 2307, 29, 549, 9, 272, 2251, 275, 1709, 14, 10748, 2988, 342, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 283, 5668, 7, 267, 1592, 63, 1224, 275, 283, 3298, 63, 5943, 51, 7, 267, 12883, 275, 756, 339, 768, 1829, 272, 347, 21992, 8, 277, 304, 267, 372, 291, 14, 14947, 505, 339, 768, 3744, 272, 347, 21992, 63, 761, 8, 1886, 304, 267, 372, 283, 14947, 505, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
KohlsTechnology/ansible
lib/ansible/modules/windows/win_timezone.py
52
1808
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2015, Phil Schwartz <schwartzmx@gmail.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: win_timezone version_added: '2.1' short_description: Sets Windows machine timezone description: - Sets machine time to the specified timezone. options: timezone: description: - Timezone to set to. - 'Example: Central Standard Time' required: yes notes: - The module will check if the provided timezone is supported on the machine. - A list of possible timezones is available from C(tzutil.exe /l) and from U(https://msdn.microsoft.com/en-us/library/ms912391.aspx) - If running on Server 2008 the hotfix U(https://support.microsoft.com/en-us/help/2556308/tzutil-command-line-tool-is-added-to-windows-vista-and-to-windows-server-2008) needs to be installed to be able to run this module. author: - Phil Schwartz (@schwartzmx) ''' EXAMPLES = r''' - name: Set timezone to 'Romance Standard Time' (GMT+01:00) win_timezone: timezone: Romance Standard Time - name: Set timezone to 'GMT Standard Time' (GMT) win_timezone: timezone: GMT Standard Time - name: Set timezone to 'Central Standard Time' (GMT-06:00) win_timezone: timezone: Central Standard Time ''' RETURN = r''' previous_timezone: description: The previous timezone if it was changed, otherwise the existing timezone returned: success type: string sample: Central Standard Time timezone: description: The current timezone (possibly changed) returned: success type: string sample: Central Standard Time '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 11308, 382, 22985, 87, 28124, 665, 15820, 87, 28124, 9457, 32, 6799, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 7145, 199, 1023, 63, 3270, 26, 283, 18, 14, 17, 7, 199, 3612, 63, 1802, 26, 10729, 5417, 6844, 7137, 199, 1802, 26, 199, 13, 10729, 6844, 900, 370, 314, 2013, 7137, 14, 199, 1419, 26, 523, 7137, 26, 272, 1369, 26, 272, 446, 4703, 2619, 370, 663, 370, 14, 272, 446, 283, 9846, 26, 32267, 9117, 9739, 4703, 7, 272, 1415, 26, 9456, 199, 5983, 26, 199, 13, 710, 859, 911, 1104, 340, 314, 2741, 7137, 365, 3748, 641, 314, 6844, 14, 199, 13, 437, 769, 402, 3962, 7137, 83, 365, 2808, 687, 445, 8, 3903, 1974, 14, 5803, 1182, 76, 9, 436, 687, 523, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 706, 25874, 16959, 14, 26146, 9, 199, 13, 982, 3879, 641, 7146, 9079, 314, 18469, 970, 523, 738, 8, 2859, 921, 4058, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 3437, 15, 821, 1367, 12127, 15, 3903, 1974, 13, 1531, 13, 604, 13, 3557, 13, 374, 13, 3270, 13, 475, 13, 8258, 13, 433, 1207, 13, 460, 13, 475, 13, 8258, 13, 1000, 13, 9300, 9, 523, 4839, 370, 506, 4903, 370, 506, 7688, 370, 1255, 642, 859, 14, 199, 2502, 26, 199, 13, 11308, 382, 22985, 87, 28124, 8593, 15820, 87, 28124, 9457, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 7137, 370, 283, 50, 676, 554, 9739, 4703, 7, 334, 17274, 11, 614, 26, 383, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 820, 676, 554, 9739, 4703, 199, 199, 13, 536, 26, 2494, 7137, 370, 283, 17274, 9739, 4703, 7, 334, 17274, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 19152, 9739, 4703, 199, 199, 13, 536, 26, 2494, 7137, 370, 283, 25290, 9739, 4703, 7, 334, 17274, 13, 1690, 26, 383, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 32267, 9117, 9739, 4703, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 6352, 63, 7145, 26, 272, 1369, 26, 710, 4136, 7137, 340, 652, 1990, 2896, 12, 4257, 314, 3411, 7137, 272, 2138, 26, 3182, 272, 730, 26, 1059, 272, 2690, 26, 32267, 9117, 9739, 4703, 199, 7145, 26, 272, 1369, 26, 710, 1453, 7137, 334, 19614, 2896, 9, 272, 2138, 26, 3182, 272, 730, 26, 1059, 272, 2690, 26, 32267, 9117, 9739, 4703, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 11308, 382, 22985, 87, 28124, 665, 15820, 87, 28124, 9457, 32, 6799, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 7145, 199, 1023, 63, 3270, 26, 283, 18, 14, 17, 7, 199, 3612, 63, 1802, 26, 10729, 5417, 6844, 7137, 199, 1802, 26, 199, 13, 10729, 6844, 900, 370, 314, 2013, 7137, 14, 199, 1419, 26, 523, 7137, 26, 272, 1369, 26, 272, 446, 4703, 2619, 370, 663, 370, 14, 272, 446, 283, 9846, 26, 32267, 9117, 9739, 4703, 7, 272, 1415, 26, 9456, 199, 5983, 26, 199, 13, 710, 859, 911, 1104, 340, 314, 2741, 7137, 365, 3748, 641, 314, 6844, 14, 199, 13, 437, 769, 402, 3962, 7137, 83, 365, 2808, 687, 445, 8, 3903, 1974, 14, 5803, 1182, 76, 9, 436, 687, 523, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 706, 25874, 16959, 14, 26146, 9, 199, 13, 982, 3879, 641, 7146, 9079, 314, 18469, 970, 523, 738, 8, 2859, 921, 4058, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 3437, 15, 821, 1367, 12127, 15, 3903, 1974, 13, 1531, 13, 604, 13, 3557, 13, 374, 13, 3270, 13, 475, 13, 8258, 13, 433, 1207, 13, 460, 13, 475, 13, 8258, 13, 1000, 13, 9300, 9, 523, 4839, 370, 506, 4903, 370, 506, 7688, 370, 1255, 642, 859, 14, 199, 2502, 26, 199, 13, 11308, 382, 22985, 87, 28124, 8593, 15820, 87, 28124, 9457, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2494, 7137, 370, 283, 50, 676, 554, 9739, 4703, 7, 334, 17274, 11, 614, 26, 383, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 820, 676, 554, 9739, 4703, 199, 199, 13, 536, 26, 2494, 7137, 370, 283, 17274, 9739, 4703, 7, 334, 17274, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 19152, 9739, 4703, 199, 199, 13, 536, 26, 2494, 7137, 370, 283, 25290, 9739, 4703, 7, 334, 17274, 13, 1690, 26, 383, 9, 523, 4747, 63, 7145, 26, 272, 7137, 26, 32267, 9117, 9739, 4703, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 6352, 63, 7145, 26, 272, 1369, 26, 710, 4136, 7137, 340, 652, 1990, 2896, 12, 4257, 314, 3411, 7137, 272, 2138, 26, 3182, 272, 730, 26, 1059, 272, 2690, 26, 32267, 9117, 9739, 4703, 199, 7145, 26, 272, 1369, 26, 710, 1453, 7137, 334, 19614, 2896, 9, 272, 2138, 26, 3182, 272, 730, 26, 1059, 272, 2690, 26, 32267, 9117, 9739, 4703, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
OndrejIT/pyload
module/PullEvents.py
41
3688
# -*- coding: utf-8 -*- """ 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/>. @author: mkaay """ from time import time from module.utils import uniqify class PullManager(): def __init__(self, core): self.core = core self.clients = [] def newClient(self, uuid): self.clients.append(Client(uuid)) def clean(self): for n, client in enumerate(self.clients): if client.lastActive + 30 < time(): del self.clients[n] def getEvents(self, uuid): events = [] validUuid = False for client in self.clients: if client.uuid == uuid: client.lastActive = time() validUuid = True while client.newEvents(): events.append(client.popEvent().toList()) break if not validUuid: self.newClient(uuid) events = [ReloadAllEvent("queue").toList(), ReloadAllEvent("collector").toList()] return uniqify(events, repr) def addEvent(self, event): for client in self.clients: client.addEvent(event) class Client(): def __init__(self, uuid): self.uuid = uuid self.lastActive = time() self.events = [] def newEvents(self): return len(self.events) > 0 def popEvent(self): if not len(self.events): return None return self.events.pop(0) def addEvent(self, event): self.events.append(event) class UpdateEvent(): def __init__(self, itype, iid, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" self.type = itype self.id = iid self.destination = destination def toList(self): return ["update", self.destination, self.type, self.id] class RemoveEvent(): def __init__(self, itype, iid, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" self.type = itype self.id = iid self.destination = destination def toList(self): return ["remove", self.destination, self.type, self.id] class InsertEvent(): def __init__(self, itype, iid, after, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" self.type = itype self.id = iid self.after = after self.destination = destination def toList(self): return ["insert", self.destination, self.type, self.id, self.after] class ReloadAllEvent(): def __init__(self, destination): assert destination == "queue" or destination == "collector" self.destination = destination def toList(self): return ["reload", self.destination] class AccountUpdateEvent(): def toList(self): return ["account"] class ConfigUpdateEvent(): def toList(self): return ["config"]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 272, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 272, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 2286, 768, 2502, 26, 333, 7351, 1187, 199, 624, 199, 199, 504, 900, 492, 900, 199, 504, 859, 14, 1208, 492, 625, 9962, 2021, 199, 199, 533, 27705, 2988, 837, 272, 347, 636, 826, 721, 277, 12, 6170, 304, 267, 291, 14, 1018, 275, 6170, 267, 291, 14, 14555, 275, 942, 2286, 347, 892, 3041, 8, 277, 12, 5377, 304, 267, 291, 14, 14555, 14, 740, 8, 3041, 8, 2580, 430, 2286, 347, 3633, 8, 277, 304, 267, 367, 302, 12, 1890, 315, 3874, 8, 277, 14, 14555, 304, 288, 340, 1890, 14, 2019, 7472, 435, 4233, 665, 900, 837, 355, 2150, 291, 14, 14555, 59, 78, 61, 2286, 347, 664, 11770, 8, 277, 12, 5377, 304, 267, 4474, 275, 942, 267, 1686, 19557, 275, 756, 267, 367, 1890, 315, 291, 14, 14555, 26, 288, 340, 1890, 14, 2580, 508, 5377, 26, 355, 1890, 14, 2019, 7472, 275, 900, 342, 355, 1686, 19557, 275, 715, 355, 1830, 1890, 14, 1222, 11770, 837, 490, 4474, 14, 740, 8, 1258, 14, 1935, 2390, 1252, 475, 1296, 1012, 355, 2059, 267, 340, 440, 1686, 19557, 26, 288, 291, 14, 1222, 3041, 8, 2580, 9, 288, 4474, 275, 359, 30590, 2422, 2390, 480, 1825, 3471, 475, 1296, 1062, 799, 912, 2422, 2390, 480, 10946, 3471, 475, 1296, 5106, 267, 372, 625, 9962, 2021, 8, 4368, 12, 4700, 9, 2286, 347, 1050, 2390, 8, 277, 12, 1566, 304, 267, 367, 1890, 315, 291, 14, 14555, 26, 288, 1890, 14, 525, 2390, 8, 1430, 9, 199, 199, 533, 6810, 837, 272, 347, 636, 826, 721, 277, 12, 5377, 304, 267, 291, 14, 2580, 275, 5377, 267, 291, 14, 2019, 7472, 275, 900, 342, 267, 291, 14, 4368, 275, 942, 2286, 347, 892, 11770, 8, 277, 304, 267, 372, 822, 8, 277, 14, 4368, 9, 690, 378, 2286, 347, 4560, 2390, 8, 277, 304, 267, 340, 440, 822, 8, 277, 14, 4368, 304, 288, 372, 488, 267, 372, 291, 14, 4368, 14, 1935, 8, 16, 9, 2286, 347, 1050, 2390, 8, 277, 12, 1566, 304, 267, 291, 14, 4368, 14, 740, 8, 1430, 9, 199, 199, 533, 6162, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 873, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 61, 199, 199, 533, 5852, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 2168, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 61, 199, 199, 533, 15496, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 2410, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 4399, 275, 2410, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 3176, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 12, 291, 14, 4399, 61, 199, 199, 533, 799, 912, 2422, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 5724, 304, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 6881, 275, 5724, 5493, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 9233, 401, 291, 14, 6881, 61, 199, 199, 533, 9973, 4152, 2390, 837, 272, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 2048, 937, 199, 199, 533, 4094, 4152, 2390, 837, 272, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 888, 937, 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, 199, 624, 272, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 272, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 272, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 2286, 768, 2502, 26, 333, 7351, 1187, 199, 624, 199, 199, 504, 900, 492, 900, 199, 504, 859, 14, 1208, 492, 625, 9962, 2021, 199, 199, 533, 27705, 2988, 837, 272, 347, 636, 826, 721, 277, 12, 6170, 304, 267, 291, 14, 1018, 275, 6170, 267, 291, 14, 14555, 275, 942, 2286, 347, 892, 3041, 8, 277, 12, 5377, 304, 267, 291, 14, 14555, 14, 740, 8, 3041, 8, 2580, 430, 2286, 347, 3633, 8, 277, 304, 267, 367, 302, 12, 1890, 315, 3874, 8, 277, 14, 14555, 304, 288, 340, 1890, 14, 2019, 7472, 435, 4233, 665, 900, 837, 355, 2150, 291, 14, 14555, 59, 78, 61, 2286, 347, 664, 11770, 8, 277, 12, 5377, 304, 267, 4474, 275, 942, 267, 1686, 19557, 275, 756, 267, 367, 1890, 315, 291, 14, 14555, 26, 288, 340, 1890, 14, 2580, 508, 5377, 26, 355, 1890, 14, 2019, 7472, 275, 900, 342, 355, 1686, 19557, 275, 715, 355, 1830, 1890, 14, 1222, 11770, 837, 490, 4474, 14, 740, 8, 1258, 14, 1935, 2390, 1252, 475, 1296, 1012, 355, 2059, 267, 340, 440, 1686, 19557, 26, 288, 291, 14, 1222, 3041, 8, 2580, 9, 288, 4474, 275, 359, 30590, 2422, 2390, 480, 1825, 3471, 475, 1296, 1062, 799, 912, 2422, 2390, 480, 10946, 3471, 475, 1296, 5106, 267, 372, 625, 9962, 2021, 8, 4368, 12, 4700, 9, 2286, 347, 1050, 2390, 8, 277, 12, 1566, 304, 267, 367, 1890, 315, 291, 14, 14555, 26, 288, 1890, 14, 525, 2390, 8, 1430, 9, 199, 199, 533, 6810, 837, 272, 347, 636, 826, 721, 277, 12, 5377, 304, 267, 291, 14, 2580, 275, 5377, 267, 291, 14, 2019, 7472, 275, 900, 342, 267, 291, 14, 4368, 275, 942, 2286, 347, 892, 11770, 8, 277, 304, 267, 372, 822, 8, 277, 14, 4368, 9, 690, 378, 2286, 347, 4560, 2390, 8, 277, 304, 267, 340, 440, 822, 8, 277, 14, 4368, 304, 288, 372, 488, 267, 372, 291, 14, 4368, 14, 1935, 8, 16, 9, 2286, 347, 1050, 2390, 8, 277, 12, 1566, 304, 267, 291, 14, 4368, 14, 740, 8, 1430, 9, 199, 199, 533, 6162, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 873, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 61, 199, 199, 533, 5852, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 2168, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 61, 199, 199, 533, 15496, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 284, 466, 12, 284, 344, 12, 2410, 12, 5724, 304, 267, 702, 284, 466, 508, 298, 1389, 2, 503, 284, 466, 508, 298, 493, 2, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 466, 275, 284, 466, 267, 291, 14, 344, 275, 284, 344, 267, 291, 14, 4399, 275, 2410, 267, 291, 14, 6881, 275, 5724, 2286, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 3176, 401, 291, 14, 6881, 12, 291, 14, 466, 12, 291, 14, 344, 12, 291, 14, 4399, 61, 199, 199, 533, 799, 912, 2422, 2390, 837, 272, 347, 636, 826, 721, 277, 12, 5724, 304, 267, 702, 5724, 508, 298, 1825, 2, 503, 5724, 508, 298, 10946, 2, 267, 291, 14, 6881, 275, 5724, 5493, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 9233, 401, 291, 14, 6881, 61, 199, 199, 533, 9973, 4152, 2390, 837, 272, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 2048, 937, 199, 199, 533, 4094, 4152, 2390, 837, 272, 347, 370, 1296, 8, 277, 304, 267, 372, 2097, 888, 937, 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, 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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 ]
Rashminadig/SDN
ryu/tests/unit/packet/test_packet.py
7
51295
# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation. # # 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. # vim: tabstop=4 shiftwidth=4 softtabstop=4 import unittest import logging import struct import array import inspect from nose.tools import * from nose.plugins.skip import Skip, SkipTest from ryu.ofproto import ether, inet from ryu.lib.packet import * from ryu.lib import addrconv LOG = logging.getLogger('test_packet') class TestPacket(unittest.TestCase): """ Test case for packet """ dst_mac = 'aa:aa:aa:aa:aa:aa' src_mac = 'bb:bb:bb:bb:bb:bb' dst_mac_bin = addrconv.mac.text_to_bin(dst_mac) src_mac_bin = addrconv.mac.text_to_bin(src_mac) dst_ip = '192.168.128.10' src_ip = '192.168.122.20' dst_ip_bin = addrconv.ipv4.text_to_bin(dst_ip) src_port = 50001 dst_port = 50002 src_ip_bin = addrconv.ipv4.text_to_bin(src_ip) payload = '\x06\x06\x47\x50\x00\x00\x00\x00' \ + '\xcd\xc5\x00\x00\x00\x00\x00\x00' \ + '\x10\x11\x12\x13\x14\x15\x16\x17' \ + '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' def get_protocols(self, pkt): protocols = {} for p in pkt: if hasattr(p, 'protocol_name'): protocols[p.protocol_name] = p else: protocols['payload'] = p return protocols def setUp(self): pass def tearDown(self): pass def test_arp(self): # buid packet e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_ARP) a = arp.arp(1, ether.ETH_TYPE_IP, 6, 4, 2, self.src_mac, self.src_ip, self.dst_mac, self.dst_ip) p = packet.Packet() p.add_protocol(e) p.add_protocol(a) p.serialize() # ethernet !6s6sH e_buf = self.dst_mac_bin \ + self.src_mac_bin \ + '\x08\x06' # arp !HHBBH6sI6sI a_buf = '\x00\x01' \ + '\x08\x00' \ + '\x06' \ + '\x04' \ + '\x00\x02' \ + self.src_mac_bin \ + self.src_ip_bin \ + self.dst_mac_bin \ + self.dst_ip_bin buf = e_buf + a_buf eq_(buf, p.data) # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_arp = protocols['arp'] # ethernet ok_(p_eth) eq_(self.dst_mac, p_eth.dst) eq_(self.src_mac, p_eth.src) eq_(ether.ETH_TYPE_ARP, p_eth.ethertype) # arp ok_(p_arp) eq_(1, p_arp.hwtype) eq_(ether.ETH_TYPE_IP, p_arp.proto) eq_(6, p_arp.hlen) eq_(4, p_arp.plen) eq_(2, p_arp.opcode) eq_(self.src_mac, p_arp.src_mac) eq_(self.src_ip, p_arp.src_ip) eq_(self.dst_mac, p_arp.dst_mac) eq_(self.dst_ip, p_arp.dst_ip) # to string eth_values = {'dst': self.dst_mac, 'src': self.src_mac, 'ethertype': ether.ETH_TYPE_ARP} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) arp_values = {'hwtype': 1, 'proto': ether.ETH_TYPE_IP, 'hlen': 6, 'plen': 4, 'opcode': 2, 'src_mac': self.src_mac, 'dst_mac': self.dst_mac, 'src_ip': self.src_ip, 'dst_ip': self.dst_ip} _arp_str = ','.join(['%s=%s' % (k, repr(arp_values[k])) for k, v in inspect.getmembers(p_arp) if k in arp_values]) arp_str = '%s(%s)' % (arp.arp.__name__, _arp_str) pkt_str = '%s, %s' % (eth_str, arp_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(arp_str, str(p_arp)) eq_(arp_str, repr(p_arp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_vlan_arp(self): # buid packet e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_8021Q) v = vlan.vlan(0b111, 0b1, 3, ether.ETH_TYPE_ARP) a = arp.arp(1, ether.ETH_TYPE_IP, 6, 4, 2, self.src_mac, self.src_ip, self.dst_mac, self.dst_ip) p = packet.Packet() p.add_protocol(e) p.add_protocol(v) p.add_protocol(a) p.serialize() # ethernet !6s6sH e_buf = self.dst_mac_bin \ + self.src_mac_bin \ + '\x81\x00' # vlan !HH v_buf = '\xF0\x03' \ + '\x08\x06' # arp !HHBBH6sI6sI a_buf = '\x00\x01' \ + '\x08\x00' \ + '\x06' \ + '\x04' \ + '\x00\x02' \ + self.src_mac_bin \ + self.src_ip_bin \ + self.dst_mac_bin \ + self.dst_ip_bin buf = e_buf + v_buf + a_buf eq_(buf, p.data) # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_vlan = protocols['vlan'] p_arp = protocols['arp'] # ethernet ok_(p_eth) eq_(self.dst_mac, p_eth.dst) eq_(self.src_mac, p_eth.src) eq_(ether.ETH_TYPE_8021Q, p_eth.ethertype) # vlan ok_(p_vlan) eq_(0b111, p_vlan.pcp) eq_(0b1, p_vlan.cfi) eq_(3, p_vlan.vid) eq_(ether.ETH_TYPE_ARP, p_vlan.ethertype) # arp ok_(p_arp) eq_(1, p_arp.hwtype) eq_(ether.ETH_TYPE_IP, p_arp.proto) eq_(6, p_arp.hlen) eq_(4, p_arp.plen) eq_(2, p_arp.opcode) eq_(self.src_mac, p_arp.src_mac) eq_(self.src_ip, p_arp.src_ip) eq_(self.dst_mac, p_arp.dst_mac) eq_(self.dst_ip, p_arp.dst_ip) # to string eth_values = {'dst': self.dst_mac, 'src': self.src_mac, 'ethertype': ether.ETH_TYPE_8021Q} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) vlan_values = {'pcp': 0b111, 'cfi': 0b1, 'vid': 3, 'ethertype': ether.ETH_TYPE_ARP} _vlan_str = ','.join(['%s=%s' % (k, repr(vlan_values[k])) for k, v in inspect.getmembers(p_vlan) if k in vlan_values]) vlan_str = '%s(%s)' % (vlan.vlan.__name__, _vlan_str) arp_values = {'hwtype': 1, 'proto': ether.ETH_TYPE_IP, 'hlen': 6, 'plen': 4, 'opcode': 2, 'src_mac': self.src_mac, 'dst_mac': self.dst_mac, 'src_ip': self.src_ip, 'dst_ip': self.dst_ip} _arp_str = ','.join(['%s=%s' % (k, repr(arp_values[k])) for k, v in inspect.getmembers(p_arp) if k in arp_values]) arp_str = '%s(%s)' % (arp.arp.__name__, _arp_str) pkt_str = '%s, %s, %s' % (eth_str, vlan_str, arp_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(vlan_str, str(p_vlan)) eq_(vlan_str, repr(p_vlan)) eq_(arp_str, str(p_arp)) eq_(arp_str, repr(p_arp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv4_udp(self): # buid packet e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IP) ip = ipv4.ipv4(4, 5, 1, 0, 3, 1, 4, 64, inet.IPPROTO_UDP, 0, self.src_ip, self.dst_ip) u = udp.udp(0x190F, 0x1F90, 0, 0) p = packet.Packet() p.add_protocol(e) p.add_protocol(ip) p.add_protocol(u) p.add_protocol(self.payload) p.serialize() # ethernet !6s6sH e_buf = self.dst_mac_bin \ + self.src_mac_bin \ + '\x08\x00' # ipv4 !BBHHHBBHII ip_buf = '\x45' \ + '\x01' \ + '\x00\x3C' \ + '\x00\x03' \ + '\x20\x04' \ + '\x40' \ + '\x11' \ + '\x00\x00' \ + self.src_ip_bin \ + self.dst_ip_bin # udp !HHHH u_buf = '\x19\x0F' \ + '\x1F\x90' \ + '\x00\x28' \ + '\x00\x00' buf = e_buf + ip_buf + u_buf + self.payload # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv4 = protocols['ipv4'] p_udp = protocols['udp'] # ethernet ok_(p_eth) eq_(self.dst_mac, p_eth.dst) eq_(self.src_mac, p_eth.src) eq_(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 ok_(p_ipv4) eq_(4, p_ipv4.version) eq_(5, p_ipv4.header_length) eq_(1, p_ipv4.tos) l = len(ip_buf) + len(u_buf) + len(self.payload) eq_(l, p_ipv4.total_length) eq_(3, p_ipv4.identification) eq_(1, p_ipv4.flags) eq_(64, p_ipv4.ttl) eq_(inet.IPPROTO_UDP, p_ipv4.proto) eq_(self.src_ip, p_ipv4.src) eq_(self.dst_ip, p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) eq_(packet_utils.checksum(t), 0) # udp ok_(p_udp) eq_(0x190f, p_udp.src_port) eq_(0x1F90, p_udp.dst_port) eq_(len(u_buf) + len(self.payload), p_udp.total_length) eq_(0x77b2, p_udp.csum) t = bytearray(u_buf) struct.pack_into('!H', t, 6, p_udp.csum) ph = struct.pack('!4s4sBBH', self.src_ip_bin, self.dst_ip_bin, 0, 17, len(u_buf) + len(self.payload)) t = ph + t + self.payload eq_(packet_utils.checksum(t), 0) # payload ok_('payload' in protocols) eq_(self.payload, protocols['payload'].tostring()) # to string eth_values = {'dst': self.dst_mac, 'src': self.src_mac, 'ethertype': ether.ETH_TYPE_IP} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv4_values = {'version': 4, 'header_length': 5, 'tos': 1, 'total_length': l, 'identification': 3, 'flags': 1, 'offset': p_ipv4.offset, 'ttl': 64, 'proto': inet.IPPROTO_UDP, 'csum': p_ipv4.csum, 'src': self.src_ip, 'dst': self.dst_ip, 'option': None} _ipv4_str = ','.join(['%s=%s' % (k, repr(ipv4_values[k])) for k, v in inspect.getmembers(p_ipv4) if k in ipv4_values]) ipv4_str = '%s(%s)' % (ipv4.ipv4.__name__, _ipv4_str) udp_values = {'src_port': 0x190f, 'dst_port': 0x1F90, 'total_length': len(u_buf) + len(self.payload), 'csum': 0x77b2} _udp_str = ','.join(['%s=%s' % (k, repr(udp_values[k])) for k, v in inspect.getmembers(p_udp) if k in udp_values]) udp_str = '%s(%s)' % (udp.udp.__name__, _udp_str) pkt_str = '%s, %s, %s, %s' % (eth_str, ipv4_str, udp_str, repr(protocols['payload'])) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv4_str, str(p_ipv4)) eq_(ipv4_str, repr(p_ipv4)) eq_(udp_str, str(p_udp)) eq_(udp_str, repr(p_udp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv4_tcp(self): # buid packet e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IP) ip = ipv4.ipv4(4, 5, 0, 0, 0, 0, 0, 64, inet.IPPROTO_TCP, 0, self.src_ip, self.dst_ip) t = tcp.tcp(0x190F, 0x1F90, 0x123, 1, 6, 0b101010, 2048, 0, 0x6f, '\x01\x02') p = packet.Packet() p.add_protocol(e) p.add_protocol(ip) p.add_protocol(t) p.add_protocol(self.payload) p.serialize() # ethernet !6s6sH e_buf = self.dst_mac_bin \ + self.src_mac_bin \ + '\x08\x00' # ipv4 !BBHHHBBHII ip_buf = '\x45' \ + '\x00' \ + '\x00\x4C' \ + '\x00\x00' \ + '\x00\x00' \ + '\x40' \ + '\x06' \ + '\x00\x00' \ + self.src_ip_bin \ + self.dst_ip_bin # tcp !HHIIBBHHH + option t_buf = '\x19\x0F' \ + '\x1F\x90' \ + '\x00\x00\x01\x23' \ + '\x00\x00\x00\x01' \ + '\x60' \ + '\x2A' \ + '\x08\x00' \ + '\x00\x00' \ + '\x00\x6F' \ + '\x01\x02\x00\x00' buf = e_buf + ip_buf + t_buf + self.payload # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv4 = protocols['ipv4'] p_tcp = protocols['tcp'] # ethernet ok_(p_eth) eq_(self.dst_mac, p_eth.dst) eq_(self.src_mac, p_eth.src) eq_(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 ok_(p_ipv4) eq_(4, p_ipv4.version) eq_(5, p_ipv4.header_length) eq_(0, p_ipv4.tos) l = len(ip_buf) + len(t_buf) + len(self.payload) eq_(l, p_ipv4.total_length) eq_(0, p_ipv4.identification) eq_(0, p_ipv4.flags) eq_(64, p_ipv4.ttl) eq_(inet.IPPROTO_TCP, p_ipv4.proto) eq_(self.src_ip, p_ipv4.src) eq_(self.dst_ip, p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) eq_(packet_utils.checksum(t), 0) # tcp ok_(p_tcp) eq_(0x190f, p_tcp.src_port) eq_(0x1F90, p_tcp.dst_port) eq_(0x123, p_tcp.seq) eq_(1, p_tcp.ack) eq_(6, p_tcp.offset) eq_(0b101010, p_tcp.bits) eq_(2048, p_tcp.window_size) eq_(0x6f, p_tcp.urgent) eq_(len(t_buf), len(p_tcp)) t = bytearray(t_buf) struct.pack_into('!H', t, 16, p_tcp.csum) ph = struct.pack('!4s4sBBH', self.src_ip_bin, self.dst_ip_bin, 0, 6, len(t_buf) + len(self.payload)) t = ph + t + self.payload eq_(packet_utils.checksum(t), 0) # payload ok_('payload' in protocols) eq_(self.payload, protocols['payload'].tostring()) # to string eth_values = {'dst': self.dst_mac, 'src': self.src_mac, 'ethertype': ether.ETH_TYPE_IP} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv4_values = {'version': 4, 'header_length': 5, 'tos': 0, 'total_length': l, 'identification': 0, 'flags': 0, 'offset': p_ipv4.offset, 'ttl': 64, 'proto': inet.IPPROTO_TCP, 'csum': p_ipv4.csum, 'src': self.src_ip, 'dst': self.dst_ip, 'option': None} _ipv4_str = ','.join(['%s=%s' % (k, repr(ipv4_values[k])) for k, v in inspect.getmembers(p_ipv4) if k in ipv4_values]) ipv4_str = '%s(%s)' % (ipv4.ipv4.__name__, _ipv4_str) tcp_values = {'src_port': 0x190f, 'dst_port': 0x1F90, 'seq': 0x123, 'ack': 1, 'offset': 6, 'bits': 0b101010, 'window_size': 2048, 'csum': p_tcp.csum, 'urgent': 0x6f, 'option': p_tcp.option} _tcp_str = ','.join(['%s=%s' % (k, repr(tcp_values[k])) for k, v in inspect.getmembers(p_tcp) if k in tcp_values]) tcp_str = '%s(%s)' % (tcp.tcp.__name__, _tcp_str) pkt_str = '%s, %s, %s, %s' % (eth_str, ipv4_str, tcp_str, repr(protocols['payload'])) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv4_str, str(p_ipv4)) eq_(ipv4_str, repr(p_ipv4)) eq_(tcp_str, str(p_tcp)) eq_(tcp_str, repr(p_tcp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv4_sctp(self): # build packet e = ethernet.ethernet() ip = ipv4.ipv4(proto=inet.IPPROTO_SCTP) s = sctp.sctp(chunks=[sctp.chunk_data(payload_data=self.payload)]) p = e/ip/s p.serialize() ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x08\x00' # ipv4 !BBHHHBBHII ip_buf = '\x45' \ + '\x00' \ + '\x00\x50' \ + '\x00\x00' \ + '\x00\x00' \ + '\xff' \ + '\x84' \ + '\x00\x00' \ + ipaddr \ + ipaddr # sctp !HHII + chunk_data !BBHIHHI + payload s_buf = '\x00\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00' \ + '\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + self.payload buf = e_buf + ip_buf + s_buf # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv4 = protocols['ipv4'] p_sctp = protocols['sctp'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 ok_(p_ipv4) eq_(4, p_ipv4.version) eq_(5, p_ipv4.header_length) eq_(0, p_ipv4.tos) l = len(ip_buf) + len(s_buf) eq_(l, p_ipv4.total_length) eq_(0, p_ipv4.identification) eq_(0, p_ipv4.flags) eq_(255, p_ipv4.ttl) eq_(inet.IPPROTO_SCTP, p_ipv4.proto) eq_('0.0.0.0', p_ipv4.src) eq_('0.0.0.0', p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) eq_(packet_utils.checksum(t), 0) # sctp ok_(p_sctp) eq_(0, p_sctp.src_port) eq_(0, p_sctp.dst_port) eq_(0, p_sctp.vtag) assert isinstance(p_sctp.chunks[0], sctp.chunk_data) eq_(0, p_sctp.chunks[0]._type) eq_(0, p_sctp.chunks[0].unordered) eq_(0, p_sctp.chunks[0].begin) eq_(0, p_sctp.chunks[0].end) eq_(16 + len(self.payload), p_sctp.chunks[0].length) eq_(0, p_sctp.chunks[0].tsn) eq_(0, p_sctp.chunks[0].sid) eq_(0, p_sctp.chunks[0].seq) eq_(0, p_sctp.chunks[0].payload_id) eq_(self.payload, p_sctp.chunks[0].payload_data) eq_(len(s_buf), len(p_sctp)) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IP} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv4_values = {'version': 4, 'header_length': 5, 'tos': 0, 'total_length': l, 'identification': 0, 'flags': 0, 'offset': 0, 'ttl': 255, 'proto': inet.IPPROTO_SCTP, 'csum': p_ipv4.csum, 'src': '0.0.0.0', 'dst': '0.0.0.0', 'option': None} _ipv4_str = ','.join(['%s=%s' % (k, repr(ipv4_values[k])) for k, v in inspect.getmembers(p_ipv4) if k in ipv4_values]) ipv4_str = '%s(%s)' % (ipv4.ipv4.__name__, _ipv4_str) data_values = {'unordered': 0, 'begin': 0, 'end': 0, 'length': 16 + len(self.payload), 'tsn': 0, 'sid': 0, 'seq': 0, 'payload_id': 0, 'payload_data': self.payload} _data_str = ','.join(['%s=%s' % (k, repr(data_values[k])) for k in sorted(data_values.keys())]) data_str = '[%s(%s)]' % (sctp.chunk_data.__name__, _data_str) sctp_values = {'src_port': 0, 'dst_port': 0, 'vtag': 0, 'csum': p_sctp.csum, 'chunks': data_str} _sctp_str = ','.join(['%s=%s' % (k, sctp_values[k]) for k, _ in inspect.getmembers(p_sctp) if k in sctp_values]) sctp_str = '%s(%s)' % (sctp.sctp.__name__, _sctp_str) pkt_str = '%s, %s, %s' % (eth_str, ipv4_str, sctp_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv4_str, str(p_ipv4)) eq_(ipv4_str, repr(p_ipv4)) eq_(sctp_str, str(p_sctp)) eq_(sctp_str, repr(p_sctp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv4_icmp(self): # buid packet e = ethernet.ethernet() ip = ipv4.ipv4(proto=inet.IPPROTO_ICMP) ic = icmp.icmp() p = e/ip/ic p.serialize() ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x08\x00' # ipv4 !BBHHHBBHII ip_buf = '\x45' \ + '\x00' \ + '\x00\x1c' \ + '\x00\x00' \ + '\x00\x00' \ + '\xff' \ + '\x01' \ + '\x00\x00' \ + ipaddr \ + ipaddr # icmp !BBH + echo !HH ic_buf = '\x08' \ + '\x00' \ + '\x00\x00' \ + '\x00\x00' \ + '\x00\x00' buf = e_buf + ip_buf + ic_buf # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv4 = protocols['ipv4'] p_icmp = protocols['icmp'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IP, p_eth.ethertype) # ipv4 ok_(p_ipv4) eq_(4, p_ipv4.version) eq_(5, p_ipv4.header_length) eq_(0, p_ipv4.tos) l = len(ip_buf) + len(ic_buf) eq_(l, p_ipv4.total_length) eq_(0, p_ipv4.identification) eq_(0, p_ipv4.flags) eq_(255, p_ipv4.ttl) eq_(inet.IPPROTO_ICMP, p_ipv4.proto) eq_('0.0.0.0', p_ipv4.src) eq_('0.0.0.0', p_ipv4.dst) t = bytearray(ip_buf) struct.pack_into('!H', t, 10, p_ipv4.csum) eq_(packet_utils.checksum(t), 0) # icmp ok_(p_icmp) eq_(8, p_icmp.type) eq_(0, p_icmp.code) eq_(0, p_icmp.data.id) eq_(0, p_icmp.data.seq) eq_(len(ic_buf), len(p_icmp)) t = bytearray(ic_buf) struct.pack_into('!H', t, 2, p_icmp.csum) eq_(packet_utils.checksum(t), 0) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IP} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, _ in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv4_values = {'version': 4, 'header_length': 5, 'tos': 0, 'total_length': l, 'identification': 0, 'flags': 0, 'offset': p_ipv4.offset, 'ttl': 255, 'proto': inet.IPPROTO_ICMP, 'csum': p_ipv4.csum, 'src': '0.0.0.0', 'dst': '0.0.0.0', 'option': None} _ipv4_str = ','.join(['%s=%s' % (k, repr(ipv4_values[k])) for k, _ in inspect.getmembers(p_ipv4) if k in ipv4_values]) ipv4_str = '%s(%s)' % (ipv4.ipv4.__name__, _ipv4_str) echo_values = {'id': 0, 'seq': 0, 'data': None} _echo_str = ','.join(['%s=%s' % (k, repr(echo_values[k])) for k in sorted(echo_values.keys())]) echo_str = '%s(%s)' % (icmp.echo.__name__, _echo_str) icmp_values = {'type': 8, 'code': 0, 'csum': p_icmp.csum, 'data': echo_str} _icmp_str = ','.join(['%s=%s' % (k, icmp_values[k]) for k, _ in inspect.getmembers(p_icmp) if k in icmp_values]) icmp_str = '%s(%s)' % (icmp.icmp.__name__, _icmp_str) pkt_str = '%s, %s, %s' % (eth_str, ipv4_str, icmp_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv4_str, str(p_ipv4)) eq_(ipv4_str, repr(p_ipv4)) eq_(icmp_str, str(p_icmp)) eq_(icmp_str, repr(p_icmp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv6_udp(self): # build packet e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6) ip = ipv6.ipv6(nxt=inet.IPPROTO_UDP) u = udp.udp() p = e/ip/u/self.payload p.serialize() ipaddr = addrconv.ipv6.text_to_bin('::') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x86\xdd' # ipv6 !IHBB16s16s' ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x11' \ + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr # udp !HHHH u_buf = '\x00\x00' \ + '\x00\x00' \ + '\x00\x28' \ + '\x00\x00' buf = e_buf + ip_buf + u_buf + self.payload # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv6 = protocols['ipv6'] p_udp = protocols['udp'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 ok_(p_ipv6) eq_(6, p_ipv6.version) eq_(0, p_ipv6.traffic_class) eq_(0, p_ipv6.flow_label) eq_(len(u_buf) + len(self.payload), p_ipv6.payload_length) eq_(inet.IPPROTO_UDP, p_ipv6.nxt) eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) # udp ok_(p_udp) eq_(0, p_udp.src_port) eq_(0, p_udp.dst_port) eq_(len(u_buf) + len(self.payload), p_udp.total_length) eq_(0x2bc2, p_udp.csum) t = bytearray(u_buf) struct.pack_into('!H', t, 6, p_udp.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(u_buf) + len(self.payload), 17) t = ph + t + self.payload eq_(packet_utils.checksum(t), 0) # payload ok_('payload' in protocols) eq_(self.payload, protocols['payload'].tostring()) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IPV6} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv6_values = {'version': 6, 'traffic_class': 0, 'flow_label': 0, 'payload_length': len(u_buf) + len(self.payload), 'nxt': inet.IPPROTO_UDP, 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} _ipv6_str = ','.join(['%s=%s' % (k, repr(ipv6_values[k])) for k, v in inspect.getmembers(p_ipv6) if k in ipv6_values]) ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str) udp_values = {'src_port': 0, 'dst_port': 0, 'total_length': len(u_buf) + len(self.payload), 'csum': 0x2bc2} _udp_str = ','.join(['%s=%s' % (k, repr(udp_values[k])) for k, v in inspect.getmembers(p_udp) if k in udp_values]) udp_str = '%s(%s)' % (udp.udp.__name__, _udp_str) pkt_str = '%s, %s, %s, %s' % (eth_str, ipv6_str, udp_str, repr(protocols['payload'])) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv6_str, str(p_ipv6)) eq_(ipv6_str, repr(p_ipv6)) eq_(udp_str, str(p_udp)) eq_(udp_str, repr(p_udp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv6_tcp(self): # build packet e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6) ip = ipv6.ipv6() t = tcp.tcp(option='\x01\x02') p = e/ip/t/self.payload p.serialize() ipaddr = addrconv.ipv6.text_to_bin('::') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x86\xdd' # ipv6 !IHBB16s16s' ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x06' \ + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr # tcp !HHIIBBHHH + option t_buf = '\x00\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x60' \ + '\x00' \ + '\x00\x00' \ + '\x00\x00' \ + '\x00\x00' \ + '\x01\x02\x00\x00' buf = e_buf + ip_buf + t_buf + self.payload # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv6 = protocols['ipv6'] p_tcp = protocols['tcp'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 ok_(p_ipv6) eq_(6, p_ipv6.version) eq_(0, p_ipv6.traffic_class) eq_(0, p_ipv6.flow_label) eq_(len(t_buf) + len(self.payload), p_ipv6.payload_length) eq_(inet.IPPROTO_TCP, p_ipv6.nxt) eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) # tcp ok_(p_tcp) eq_(0, p_tcp.src_port) eq_(0, p_tcp.dst_port) eq_(0, p_tcp.seq) eq_(0, p_tcp.ack) eq_(6, p_tcp.offset) eq_(0, p_tcp.bits) eq_(0, p_tcp.window_size) eq_(0, p_tcp.urgent) eq_(len(t_buf), len(p_tcp)) t = bytearray(t_buf) struct.pack_into('!H', t, 16, p_tcp.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(t_buf) + len(self.payload), 6) t = ph + t + self.payload eq_(packet_utils.checksum(t), 0) # payload ok_('payload' in protocols) eq_(self.payload, protocols['payload'].tostring()) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IPV6} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv6_values = {'version': 6, 'traffic_class': 0, 'flow_label': 0, 'payload_length': len(t_buf) + len(self.payload), 'nxt': inet.IPPROTO_TCP, 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} _ipv6_str = ','.join(['%s=%s' % (k, repr(ipv6_values[k])) for k, v in inspect.getmembers(p_ipv6) if k in ipv6_values]) ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str) tcp_values = {'src_port': 0, 'dst_port': 0, 'seq': 0, 'ack': 0, 'offset': 6, 'bits': 0, 'window_size': 0, 'csum': p_tcp.csum, 'urgent': 0, 'option': p_tcp.option} _tcp_str = ','.join(['%s=%s' % (k, repr(tcp_values[k])) for k, v in inspect.getmembers(p_tcp) if k in tcp_values]) tcp_str = '%s(%s)' % (tcp.tcp.__name__, _tcp_str) pkt_str = '%s, %s, %s, %s' % (eth_str, ipv6_str, tcp_str, repr(protocols['payload'])) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv6_str, str(p_ipv6)) eq_(ipv6_str, repr(p_ipv6)) eq_(tcp_str, str(p_tcp)) eq_(tcp_str, repr(p_tcp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv6_sctp(self): # build packet e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6) ip = ipv6.ipv6(nxt=inet.IPPROTO_SCTP) s = sctp.sctp(chunks=[sctp.chunk_data(payload_data=self.payload)]) p = e/ip/s p.serialize() ipaddr = addrconv.ipv6.text_to_bin('::') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x86\xdd' # ipv6 !IHBB16s16s' ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x84' \ + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr # sctp !HHII + chunk_data !BBHIHHI + payload s_buf = '\x00\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00' \ + '\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + '\x00\x00' \ + '\x00\x00' \ + '\x00\x00\x00\x00' \ + self.payload buf = e_buf + ip_buf + s_buf # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv6 = protocols['ipv6'] p_sctp = protocols['sctp'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 ok_(p_ipv6) eq_(6, p_ipv6.version) eq_(0, p_ipv6.traffic_class) eq_(0, p_ipv6.flow_label) eq_(len(s_buf), p_ipv6.payload_length) eq_(inet.IPPROTO_SCTP, p_ipv6.nxt) eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) # sctp ok_(p_sctp) eq_(0, p_sctp.src_port) eq_(0, p_sctp.dst_port) eq_(0, p_sctp.vtag) assert isinstance(p_sctp.chunks[0], sctp.chunk_data) eq_(0, p_sctp.chunks[0]._type) eq_(0, p_sctp.chunks[0].unordered) eq_(0, p_sctp.chunks[0].begin) eq_(0, p_sctp.chunks[0].end) eq_(16 + len(self.payload), p_sctp.chunks[0].length) eq_(0, p_sctp.chunks[0].tsn) eq_(0, p_sctp.chunks[0].sid) eq_(0, p_sctp.chunks[0].seq) eq_(0, p_sctp.chunks[0].payload_id) eq_(self.payload, p_sctp.chunks[0].payload_data) eq_(len(s_buf), len(p_sctp)) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IPV6} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv6_values = {'version': 6, 'traffic_class': 0, 'flow_label': 0, 'payload_length': len(s_buf), 'nxt': inet.IPPROTO_SCTP, 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} _ipv6_str = ','.join(['%s=%s' % (k, repr(ipv6_values[k])) for k, v in inspect.getmembers(p_ipv6) if k in ipv6_values]) ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str) data_values = {'unordered': 0, 'begin': 0, 'end': 0, 'length': 16 + len(self.payload), 'tsn': 0, 'sid': 0, 'seq': 0, 'payload_id': 0, 'payload_data': self.payload} _data_str = ','.join(['%s=%s' % (k, repr(data_values[k])) for k in sorted(data_values.keys())]) data_str = '[%s(%s)]' % (sctp.chunk_data.__name__, _data_str) sctp_values = {'src_port': 0, 'dst_port': 0, 'vtag': 0, 'csum': p_sctp.csum, 'chunks': data_str} _sctp_str = ','.join(['%s=%s' % (k, sctp_values[k]) for k, _ in inspect.getmembers(p_sctp) if k in sctp_values]) sctp_str = '%s(%s)' % (sctp.sctp.__name__, _sctp_str) pkt_str = '%s, %s, %s' % (eth_str, ipv6_str, sctp_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv6_str, str(p_ipv6)) eq_(ipv6_str, repr(p_ipv6)) eq_(sctp_str, str(p_sctp)) eq_(sctp_str, repr(p_sctp)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_ipv6_icmpv6(self): # build packet e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6) ip = ipv6.ipv6(nxt=inet.IPPROTO_ICMPV6) ic = icmpv6.icmpv6() p = e/ip/ic p.serialize() ipaddr = addrconv.ipv6.text_to_bin('::') # ethernet !6s6sH e_buf = '\xff\xff\xff\xff\xff\xff' \ + '\x00\x00\x00\x00\x00\x00' \ + '\x86\xdd' # ipv6 !IHBB16s16s' ip_buf = '\x60\x00\x00\x00' \ + '\x00\x00' \ + '\x3a' \ + '\xff' \ + '\x00\x00' \ + ipaddr \ + ipaddr # icmpv6 !BBH ic_buf = '\x00' \ + '\x00' \ + '\x00\x00' buf = e_buf + ip_buf + ic_buf # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_ipv6 = protocols['ipv6'] p_icmpv6 = protocols['icmpv6'] # ethernet ok_(p_eth) eq_('ff:ff:ff:ff:ff:ff', p_eth.dst) eq_('00:00:00:00:00:00', p_eth.src) eq_(ether.ETH_TYPE_IPV6, p_eth.ethertype) # ipv6 ok_(p_ipv6) eq_(6, p_ipv6.version) eq_(0, p_ipv6.traffic_class) eq_(0, p_ipv6.flow_label) eq_(len(ic_buf), p_ipv6.payload_length) eq_(inet.IPPROTO_ICMPV6, p_ipv6.nxt) eq_(255, p_ipv6.hop_limit) eq_('::', p_ipv6.src) eq_('::', p_ipv6.dst) # icmpv6 ok_(p_icmpv6) eq_(0, p_icmpv6.type_) eq_(0, p_icmpv6.code) eq_(len(ic_buf), len(p_icmpv6)) t = bytearray(ic_buf) struct.pack_into('!H', t, 2, p_icmpv6.csum) ph = struct.pack('!16s16sI3xB', ipaddr, ipaddr, len(ic_buf), 58) t = ph + t eq_(packet_utils.checksum(t), 0) # to string eth_values = {'dst': 'ff:ff:ff:ff:ff:ff', 'src': '00:00:00:00:00:00', 'ethertype': ether.ETH_TYPE_IPV6} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, _ in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ipv6_values = {'version': 6, 'traffic_class': 0, 'flow_label': 0, 'payload_length': len(ic_buf), 'nxt': inet.IPPROTO_ICMPV6, 'hop_limit': 255, 'src': '::', 'dst': '::', 'ext_hdrs': []} _ipv6_str = ','.join(['%s=%s' % (k, repr(ipv6_values[k])) for k, _ in inspect.getmembers(p_ipv6) if k in ipv6_values]) ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str) icmpv6_values = {'type_': 0, 'code': 0, 'csum': p_icmpv6.csum, 'data': None} _icmpv6_str = ','.join(['%s=%s' % (k, repr(icmpv6_values[k])) for k, _ in inspect.getmembers(p_icmpv6) if k in icmpv6_values]) icmpv6_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _icmpv6_str) pkt_str = '%s, %s, %s' % (eth_str, ipv6_str, icmpv6_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(ipv6_str, str(p_ipv6)) eq_(ipv6_str, repr(p_ipv6)) eq_(icmpv6_str, str(p_icmpv6)) eq_(icmpv6_str, repr(p_icmpv6)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_llc_bpdu(self): # buid packet e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IEEE802_3) llc_control = llc.ControlFormatU(0, 0, 0) l = llc.llc(llc.SAP_BPDU, llc.SAP_BPDU, llc_control) b = bpdu.ConfigurationBPDUs(flags=0, root_priority=32768, root_system_id_extension=0, root_mac_address=self.src_mac, root_path_cost=0, bridge_priority=32768, bridge_system_id_extension=0, bridge_mac_address=self.dst_mac, port_priority=128, port_number=4, message_age=1, max_age=20, hello_time=2, forward_delay=15) p = packet.Packet() p.add_protocol(e) p.add_protocol(l) p.add_protocol(b) p.serialize() # ethernet !6s6sH e_buf = self.dst_mac + self.src_mac + '\x05\xdc' # llc !BBB l_buf = ('\x42' '\x42' '\x03') # bpdu !HBBBQIQHHHHH b_buf = ('\x00\x00' '\x00' '\x00' '\x00' '\x80\x64\xaa\xaa\xaa\xaa\xaa\xaa' '\x00\x00\x00\x04' '\x80\x64\xbb\xbb\xbb\xbb\xbb\xbb' '\x80\x04' '\x01\x00' '\x14\x00' '\x02\x00' '\x0f\x00') buf = e_buf + l_buf + b_buf # parse pkt = packet.Packet(array.array('B', p.data)) protocols = self.get_protocols(pkt) p_eth = protocols['ethernet'] p_llc = protocols['llc'] p_bpdu = protocols['ConfigurationBPDUs'] # ethernet ok_(p_eth) eq_(self.dst_mac, p_eth.dst) eq_(self.src_mac, p_eth.src) eq_(ether.ETH_TYPE_IEEE802_3, p_eth.ethertype) # llc ok_(p_llc) eq_(llc.SAP_BPDU, p_llc.dsap_addr) eq_(llc.SAP_BPDU, p_llc.ssap_addr) eq_(0, p_llc.control.modifier_function1) eq_(0, p_llc.control.pf_bit) eq_(0, p_llc.control.modifier_function2) # bpdu ok_(p_bpdu) eq_(bpdu.PROTOCOL_IDENTIFIER, p_bpdu._protocol_id) eq_(bpdu.PROTOCOLVERSION_ID_BPDU, p_bpdu._version_id) eq_(bpdu.TYPE_CONFIG_BPDU, p_bpdu._bpdu_type) eq_(0, p_bpdu.flags) eq_(32768, p_bpdu.root_priority) eq_(0, p_bpdu.root_system_id_extension) eq_(self.src_mac, p_bpdu.root_mac_address) eq_(0, p_bpdu.root_path_cost) eq_(32768, p_bpdu.bridge_priority) eq_(0, p_bpdu.bridge_system_id_extension) eq_(self.dst_mac, p_bpdu.bridge_mac_address) eq_(128, p_bpdu.port_priority) eq_(4, p_bpdu.port_number) eq_(1, p_bpdu.message_age) eq_(20, p_bpdu.max_age) eq_(2, p_bpdu.hello_time) eq_(15, p_bpdu.forward_delay) # to string eth_values = {'dst': self.dst_mac, 'src': self.src_mac, 'ethertype': ether.ETH_TYPE_IEEE802_3} _eth_str = ','.join(['%s=%s' % (k, repr(eth_values[k])) for k, v in inspect.getmembers(p_eth) if k in eth_values]) eth_str = '%s(%s)' % (ethernet.ethernet.__name__, _eth_str) ctrl_values = {'modifier_function1': 0, 'pf_bit': 0, 'modifier_function2': 0} _ctrl_str = ','.join(['%s=%s' % (k, repr(ctrl_values[k])) for k, v in inspect.getmembers(p_llc.control) if k in ctrl_values]) ctrl_str = '%s(%s)' % (llc.ControlFormatU.__name__, _ctrl_str) llc_values = {'dsap_addr': repr(llc.SAP_BPDU), 'ssap_addr': repr(llc.SAP_BPDU), 'control': ctrl_str} _llc_str = ','.join(['%s=%s' % (k, llc_values[k]) for k, v in inspect.getmembers(p_llc) if k in llc_values]) llc_str = '%s(%s)' % (llc.llc.__name__, _llc_str) bpdu_values = {'flags': 0, 'root_priority': long(32768), 'root_system_id_extension': long(0), 'root_mac_address': self.src_mac, 'root_path_cost': 0, 'bridge_priority': long(32768), 'bridge_system_id_extension': long(0), 'bridge_mac_address': self.dst_mac, 'port_priority': 128, 'port_number': 4, 'message_age': float(1), 'max_age': float(20), 'hello_time': float(2), 'forward_delay': float(15)} _bpdu_str = ','.join(['%s=%s' % (k, repr(bpdu_values[k])) for k, v in inspect.getmembers(p_bpdu) if k in bpdu_values]) bpdu_str = '%s(%s)' % (bpdu.ConfigurationBPDUs.__name__, _bpdu_str) pkt_str = '%s, %s, %s' % (eth_str, llc_str, bpdu_str) eq_(eth_str, str(p_eth)) eq_(eth_str, repr(p_eth)) eq_(llc_str, str(p_llc)) eq_(llc_str, repr(p_llc)) eq_(bpdu_str, str(p_bpdu)) eq_(bpdu_str, repr(p_bpdu)) eq_(pkt_str, str(pkt)) eq_(pkt_str, repr(pkt)) def test_div_api(self): e = ethernet.ethernet(self.dst_mac, self.src_mac, ether.ETH_TYPE_IP) i = ipv4.ipv4() u = udp.udp(self.src_port, self.dst_port) pkt = e/i/u ok_(isinstance(pkt, packet.Packet)) ok_(isinstance(pkt.protocols[0], ethernet.ethernet)) ok_(isinstance(pkt.protocols[1], ipv4.ipv4)) ok_(isinstance(pkt.protocols[2], udp.udp))
apache-2.0
[ 3, 1898, 334, 35, 9, 6029, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 646, 2882, 199, 646, 2050, 199, 646, 2702, 199, 646, 1625, 199, 646, 6485, 199, 504, 11354, 14, 2537, 492, 627, 199, 504, 11354, 14, 5265, 14, 2759, 492, 8232, 12, 18795, 199, 504, 25494, 14, 15129, 492, 30201, 12, 17260, 199, 504, 25494, 14, 773, 14, 6253, 492, 627, 199, 504, 25494, 14, 773, 492, 5552, 5598, 421, 199, 4947, 275, 2050, 14, 5572, 360, 396, 63, 6253, 358, 421, 199, 533, 1379, 2726, 8, 2796, 14, 1746, 304, 272, 408, 1379, 1930, 367, 3644, 272, 408, 339, 5042, 63, 3088, 275, 283, 2158, 26, 2158, 26, 2158, 26, 2158, 26, 2158, 26, 2158, 7, 272, 2928, 63, 3088, 275, 283, 2501, 26, 2501, 26, 2501, 26, 2501, 26, 2501, 26, 2501, 7, 272, 5042, 63, 3088, 63, 1393, 275, 5552, 5598, 14, 3088, 14, 505, 63, 475, 63, 1393, 8, 5119, 63, 3088, 9, 272, 2928, 63, 3088, 63, 1393, 275, 5552, 5598, 14, 3088, 14, 505, 63, 475, 63, 1393, 8, 2164, 63, 3088, 9, 272, 5042, 63, 711, 275, 283, 5756, 14, 6568, 14, 3933, 14, 709, 7, 272, 2928, 63, 711, 275, 283, 5756, 14, 6568, 14, 7507, 14, 1165, 7, 272, 5042, 63, 711, 63, 1393, 275, 5552, 5598, 14, 4774, 20, 14, 505, 63, 475, 63, 1393, 8, 5119, 63, 711, 9, 272, 2928, 63, 719, 275, 959, 4183, 272, 5042, 63, 719, 275, 6891, 996, 272, 2928, 63, 711, 63, 1393, 275, 5552, 5598, 14, 4774, 20, 14, 505, 63, 475, 63, 1393, 8, 2164, 63, 711, 9, 272, 4886, 275, 1557, 88, 1690, 60, 88, 1690, 60, 88, 2417, 60, 88, 1400, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 7, 971, 267, 435, 1557, 10879, 60, 1812, 21, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 7, 971, 267, 435, 1557, 88, 709, 60, 88, 845, 60, 88, 713, 60, 88, 969, 60, 88, 1079, 60, 88, 1046, 60, 88, 975, 60, 88, 1196, 7, 971, 267, 435, 1557, 88, 1085, 60, 88, 1167, 60, 88, 17, 65, 60, 88, 17, 66, 60, 88, 17, 67, 60, 88, 17, 68, 60, 88, 17, 69, 60, 88, 17, 70, 7, 339, 347, 664, 63, 16541, 8, 277, 12, 19927, 304, 267, 19230, 275, 1052, 267, 367, 299, 315, 19927, 26, 288, 340, 2688, 8, 80, 12, 283, 3922, 63, 354, 735, 355, 19230, 59, 80, 14, 3922, 63, 354, 61, 275, 299, 288, 587, 26, 355, 19230, 459, 4749, 418, 275, 299, 267, 372, 19230, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 12868, 8, 277, 304, 267, 327, 1032, 344, 3644, 267, 325, 275, 21944, 14, 20354, 8, 277, 14, 5119, 63, 3088, 12, 291, 14, 2164, 63, 3088, 12, 2892, 30201, 14, 21265, 63, 2711, 63, 23610, 9, 267, 282, 275, 26262, 14, 12868, 8, 17, 12, 30201, 14, 21265, 63, 2711, 63, 1772, 12, 1227, 12, 841, 12, 499, 12, 490, 291, 14, 2164, 63, 3088, 12, 291, 14, 2164, 63, 711, 12, 291, 14, 5119, 63, 3088, 12, 490, 291, 14, 5119, 63, 711, 9, 267, 299, 275, 3644, 14, 2726, 342, 267, 299, 14, 525, 63, 3922, 8, 69, 9, 267, 299, 14, 525, 63, 3922, 8, 65, 9, 267, 299, 14, 3549, 342, 398, 327, 21944, 8546, 22, 83, 22, 83, 40, 267, 325, 63, 1436, 275, 291, 14, 5119, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 2164, 63, 3088, 63, 1393, 971, 288, 435, 1557, 88, 2036, 60, 88, 1690, 7, 398, 327, 26262, 8546, 10213, 5342, 40, 22, 83, 41, 22, 83, 41, 267, 282, 63, 1436, 275, 1557, 88, 383, 60, 88, 614, 7, 971, 288, 435, 1557, 88, 2036, 60, 88, 383, 7, 971, 288, 435, 1557, 88, 1690, 7, 971, 288, 435, 1557, 88, 966, 7, 971, 288, 435, 1557, 88, 383, 60, 88, 996, 7, 971, 288, 435, 291, 14, 2164, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 2164, 63, 711, 63, 1393, 971, 288, 435, 291, 14, 5119, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 5119, 63, 711, 63, 1393, 398, 4123, 275, 325, 63, 1436, 435, 282, 63, 1436, 267, 3850, 2531, 1436, 12, 299, 14, 576, 9, 398, 327, 2198, 267, 19927, 275, 3644, 14, 2726, 8, 1144, 14, 1144, 360, 34, 297, 299, 14, 576, 430, 267, 19230, 275, 291, 14, 362, 63, 16541, 8, 20573, 9, 267, 299, 63, 12391, 275, 19230, 459, 20354, 418, 267, 299, 63, 12868, 275, 19230, 459, 12868, 418, 398, 327, 21944, 267, 4112, 2531, 80, 63, 12391, 9, 267, 3850, 2531, 277, 14, 5119, 63, 3088, 12, 299, 63, 12391, 14, 5119, 9, 267, 3850, 2531, 277, 14, 2164, 63, 3088, 12, 299, 63, 12391, 14, 2164, 9, 267, 3850, 2531, 27732, 14, 21265, 63, 2711, 63, 23610, 12, 299, 63, 12391, 14, 27732, 466, 9, 398, 327, 26262, 267, 4112, 2531, 80, 63, 12868, 9, 267, 3850, 2531, 17, 12, 299, 63, 12868, 14, 8090, 466, 9, 267, 3850, 2531, 27732, 14, 21265, 63 ]
[ 1898, 334, 35, 9, 6029, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 646, 2882, 199, 646, 2050, 199, 646, 2702, 199, 646, 1625, 199, 646, 6485, 199, 504, 11354, 14, 2537, 492, 627, 199, 504, 11354, 14, 5265, 14, 2759, 492, 8232, 12, 18795, 199, 504, 25494, 14, 15129, 492, 30201, 12, 17260, 199, 504, 25494, 14, 773, 14, 6253, 492, 627, 199, 504, 25494, 14, 773, 492, 5552, 5598, 421, 199, 4947, 275, 2050, 14, 5572, 360, 396, 63, 6253, 358, 421, 199, 533, 1379, 2726, 8, 2796, 14, 1746, 304, 272, 408, 1379, 1930, 367, 3644, 272, 408, 339, 5042, 63, 3088, 275, 283, 2158, 26, 2158, 26, 2158, 26, 2158, 26, 2158, 26, 2158, 7, 272, 2928, 63, 3088, 275, 283, 2501, 26, 2501, 26, 2501, 26, 2501, 26, 2501, 26, 2501, 7, 272, 5042, 63, 3088, 63, 1393, 275, 5552, 5598, 14, 3088, 14, 505, 63, 475, 63, 1393, 8, 5119, 63, 3088, 9, 272, 2928, 63, 3088, 63, 1393, 275, 5552, 5598, 14, 3088, 14, 505, 63, 475, 63, 1393, 8, 2164, 63, 3088, 9, 272, 5042, 63, 711, 275, 283, 5756, 14, 6568, 14, 3933, 14, 709, 7, 272, 2928, 63, 711, 275, 283, 5756, 14, 6568, 14, 7507, 14, 1165, 7, 272, 5042, 63, 711, 63, 1393, 275, 5552, 5598, 14, 4774, 20, 14, 505, 63, 475, 63, 1393, 8, 5119, 63, 711, 9, 272, 2928, 63, 719, 275, 959, 4183, 272, 5042, 63, 719, 275, 6891, 996, 272, 2928, 63, 711, 63, 1393, 275, 5552, 5598, 14, 4774, 20, 14, 505, 63, 475, 63, 1393, 8, 2164, 63, 711, 9, 272, 4886, 275, 1557, 88, 1690, 60, 88, 1690, 60, 88, 2417, 60, 88, 1400, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 7, 971, 267, 435, 1557, 10879, 60, 1812, 21, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 7, 971, 267, 435, 1557, 88, 709, 60, 88, 845, 60, 88, 713, 60, 88, 969, 60, 88, 1079, 60, 88, 1046, 60, 88, 975, 60, 88, 1196, 7, 971, 267, 435, 1557, 88, 1085, 60, 88, 1167, 60, 88, 17, 65, 60, 88, 17, 66, 60, 88, 17, 67, 60, 88, 17, 68, 60, 88, 17, 69, 60, 88, 17, 70, 7, 339, 347, 664, 63, 16541, 8, 277, 12, 19927, 304, 267, 19230, 275, 1052, 267, 367, 299, 315, 19927, 26, 288, 340, 2688, 8, 80, 12, 283, 3922, 63, 354, 735, 355, 19230, 59, 80, 14, 3922, 63, 354, 61, 275, 299, 288, 587, 26, 355, 19230, 459, 4749, 418, 275, 299, 267, 372, 19230, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 12868, 8, 277, 304, 267, 327, 1032, 344, 3644, 267, 325, 275, 21944, 14, 20354, 8, 277, 14, 5119, 63, 3088, 12, 291, 14, 2164, 63, 3088, 12, 2892, 30201, 14, 21265, 63, 2711, 63, 23610, 9, 267, 282, 275, 26262, 14, 12868, 8, 17, 12, 30201, 14, 21265, 63, 2711, 63, 1772, 12, 1227, 12, 841, 12, 499, 12, 490, 291, 14, 2164, 63, 3088, 12, 291, 14, 2164, 63, 711, 12, 291, 14, 5119, 63, 3088, 12, 490, 291, 14, 5119, 63, 711, 9, 267, 299, 275, 3644, 14, 2726, 342, 267, 299, 14, 525, 63, 3922, 8, 69, 9, 267, 299, 14, 525, 63, 3922, 8, 65, 9, 267, 299, 14, 3549, 342, 398, 327, 21944, 8546, 22, 83, 22, 83, 40, 267, 325, 63, 1436, 275, 291, 14, 5119, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 2164, 63, 3088, 63, 1393, 971, 288, 435, 1557, 88, 2036, 60, 88, 1690, 7, 398, 327, 26262, 8546, 10213, 5342, 40, 22, 83, 41, 22, 83, 41, 267, 282, 63, 1436, 275, 1557, 88, 383, 60, 88, 614, 7, 971, 288, 435, 1557, 88, 2036, 60, 88, 383, 7, 971, 288, 435, 1557, 88, 1690, 7, 971, 288, 435, 1557, 88, 966, 7, 971, 288, 435, 1557, 88, 383, 60, 88, 996, 7, 971, 288, 435, 291, 14, 2164, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 2164, 63, 711, 63, 1393, 971, 288, 435, 291, 14, 5119, 63, 3088, 63, 1393, 971, 288, 435, 291, 14, 5119, 63, 711, 63, 1393, 398, 4123, 275, 325, 63, 1436, 435, 282, 63, 1436, 267, 3850, 2531, 1436, 12, 299, 14, 576, 9, 398, 327, 2198, 267, 19927, 275, 3644, 14, 2726, 8, 1144, 14, 1144, 360, 34, 297, 299, 14, 576, 430, 267, 19230, 275, 291, 14, 362, 63, 16541, 8, 20573, 9, 267, 299, 63, 12391, 275, 19230, 459, 20354, 418, 267, 299, 63, 12868, 275, 19230, 459, 12868, 418, 398, 327, 21944, 267, 4112, 2531, 80, 63, 12391, 9, 267, 3850, 2531, 277, 14, 5119, 63, 3088, 12, 299, 63, 12391, 14, 5119, 9, 267, 3850, 2531, 277, 14, 2164, 63, 3088, 12, 299, 63, 12391, 14, 2164, 9, 267, 3850, 2531, 27732, 14, 21265, 63, 2711, 63, 23610, 12, 299, 63, 12391, 14, 27732, 466, 9, 398, 327, 26262, 267, 4112, 2531, 80, 63, 12868, 9, 267, 3850, 2531, 17, 12, 299, 63, 12868, 14, 8090, 466, 9, 267, 3850, 2531, 27732, 14, 21265, 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,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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 ]
psyke83/android_kernel_huawei_msm7x25
scripts/tracing/draw_functrace.py
14676
3560
#!/usr/bin/python """ Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com> Licensed under the terms of the GNU GPL License version 2 This script parses a trace provided by the function tracer in kernel/trace/trace_functions.c The resulted trace is processed into a tree to produce a more human view of the call stack by drawing textual but hierarchical tree of calls. Only the functions's names and the the call time are provided. Usage: Be sure that you have CONFIG_FUNCTION_TRACER # mount -t debugfs nodev /sys/kernel/debug # echo function > /sys/kernel/debug/tracing/current_tracer $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func Wait some times but not too much, the script is a bit slow. Break the pipe (Ctrl + Z) $ scripts/draw_functrace.py < raw_trace_func > draw_functrace Then you have your drawn trace in draw_functrace """ import sys, re class CallTree: """ This class provides a tree representation of the functions call stack. If a function has no parent in the kernel (interrupt, syscall, kernel thread...) then it is attached to a virtual parent called ROOT. """ ROOT = None def __init__(self, func, time = None, parent = None): self._func = func self._time = time if parent is None: self._parent = CallTree.ROOT else: self._parent = parent self._children = [] def calls(self, func, calltime): """ If a function calls another one, call this method to insert it into the tree at the appropriate place. @return: A reference to the newly created child node. """ child = CallTree(func, calltime, self) self._children.append(child) return child def getParent(self, func): """ Retrieve the last parent of the current node that has the name given by func. If this function is not on a parent, then create it as new child of root @return: A reference to the parent. """ tree = self while tree != CallTree.ROOT and tree._func != func: tree = tree._parent if tree == CallTree.ROOT: child = CallTree.ROOT.calls(func, None) return child return tree def __repr__(self): return self.__toString("", True) def __toString(self, branch, lastChild): if self._time is not None: s = "%s----%s (%s)\n" % (branch, self._func, self._time) else: s = "%s----%s\n" % (branch, self._func) i = 0 if lastChild: branch = branch[:-1] + " " while i < len(self._children): if i != len(self._children) - 1: s += "%s" % self._children[i].__toString(branch +\ " |", False) else: s += "%s" % self._children[i].__toString(branch +\ " |", True) i += 1 return s class BrokenLineException(Exception): """If the last line is not complete because of the pipe breakage, we want to stop the processing and ignore this line. """ pass class CommentLineException(Exception): """ If the line is a comment (as in the beginning of the trace file), just ignore it. """ pass def parseLine(line): line = line.strip() if line.startswith("#"): raise CommentLineException m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line) if m is None: raise BrokenLineException return (m.group(1), m.group(2), m.group(3)) def main(): CallTree.ROOT = CallTree("Root (Nowhere)", None, None) tree = CallTree.ROOT for line in sys.stdin: try: calltime, callee, caller = parseLine(line) except BrokenLineException: break except CommentLineException: continue tree = tree.getParent(caller) tree = tree.calls(callee, calltime) print CallTree.ROOT if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 624, 199, 7384, 9079, 334, 67, 9, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 31661, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 199, 2765, 2884, 19953, 282, 3307, 2741, 701, 314, 805, 29140, 315, 199, 4989, 15, 3446, 15, 3446, 63, 5777, 14, 67, 199, 1918, 522, 30355, 3307, 365, 7686, 1901, 282, 3123, 370, 7389, 282, 1655, 11779, 199, 1345, 402, 314, 1240, 3464, 701, 17455, 25884, 1325, 24787, 3123, 402, 199, 5352, 14, 5972, 314, 3423, 1159, 1561, 436, 314, 314, 1240, 900, 787, 2741, 14, 199, 199, 7692, 26, 199, 198, 3655, 3238, 626, 1265, 1172, 15869, 63, 15476, 63, 1766, 1348, 540, 199, 198, 3, 10760, 446, 84, 3105, 2319, 1031, 86, 1182, 1274, 15, 4989, 15, 1757, 199, 198, 3, 11343, 805, 690, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 1818, 63, 16825, 199, 198, 4, 6230, 1182, 1274, 15, 4989, 15, 1757, 15, 21635, 15, 3446, 63, 4990, 690, 6146, 15, 1773, 63, 3446, 63, 1532, 199, 198, 7536, 2005, 5431, 1325, 440, 4634, 8298, 12, 314, 2884, 365, 282, 4546, 11999, 14, 199, 198, 13948, 314, 5200, 334, 9778, 435, 3107, 9, 199, 198, 4, 10554, 15, 5485, 63, 31939, 5986, 14, 647, 665, 3066, 63, 3446, 63, 1532, 690, 5954, 63, 31939, 5986, 199, 198, 28226, 1265, 1172, 2195, 19341, 3307, 315, 5954, 63, 31939, 5986, 199, 624, 421, 199, 646, 984, 12, 295, 199, 199, 533, 23491, 26, 199, 198, 624, 961, 1021, 6571, 282, 3123, 6025, 402, 314, 3423, 507, 198, 1250, 3464, 14, 982, 282, 805, 965, 949, 1676, 315, 314, 5114, 334, 20172, 12, 507, 198, 19444, 12, 5114, 2462, 11965, 2066, 652, 365, 10102, 370, 282, 5791, 1676, 507, 198, 3527, 16547, 14, 199, 198, 624, 199, 198, 5441, 275, 488, 421, 198, 318, 636, 826, 721, 277, 12, 2562, 12, 900, 275, 488, 12, 1676, 275, 488, 304, 507, 198, 277, 423, 1532, 275, 2562, 507, 198, 277, 423, 521, 275, 900, 507, 198, 692, 1676, 365, 488, 26, 686, 198, 277, 423, 1708, 275, 23491, 14, 5441, 507, 198, 2836, 26, 686, 198, 277, 423, 1708, 275, 1676, 507, 198, 277, 423, 3223, 275, 942, 421, 198, 318, 4882, 8, 277, 12, 2562, 12, 1240, 521, 304, 507, 198, 624, 982, 282, 805, 4882, 4573, 1373, 12, 1240, 642, 1083, 370, 5518, 652, 686, 198, 9924, 314, 3123, 737, 314, 5827, 4192, 14, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 13903, 2737, 1982, 1031, 14, 507, 198, 624, 507, 198, 1739, 275, 23491, 8, 1532, 12, 1240, 521, 12, 291, 9, 507, 198, 277, 423, 3223, 14, 740, 8, 1739, 9, 507, 198, 1107, 1982, 421, 198, 318, 664, 6652, 8, 277, 12, 2562, 304, 507, 198, 624, 13939, 314, 2061, 1676, 402, 314, 1453, 1031, 626, 686, 198, 1989, 314, 536, 1627, 701, 2562, 14, 982, 642, 805, 365, 440, 686, 198, 265, 282, 1676, 12, 2066, 1218, 652, 465, 892, 1982, 402, 1738, 686, 198, 32, 1107, 26, 437, 3659, 370, 314, 1676, 14, 507, 198, 624, 507, 198, 2350, 275, 291, 507, 198, 6710, 3123, 1137, 23491, 14, 5441, 436, 3123, 423, 1532, 1137, 2562, 26, 686, 198, 2350, 275, 3123, 423, 1708, 507, 198, 692, 3123, 508, 23491, 14, 5441, 26, 686, 198, 1739, 275, 23491, 14, 5441, 14, 5352, 8, 1532, 12, 488, 9, 686, 198, 1107, 1982, 507, 198, 1107, 3123, 421, 198, 318, 636, 2722, 721, 277, 304, 507, 198, 1107, 291, 855, 16695, 12398, 715, 9, 421, 198, 318, 636, 16695, 8, 277, 12, 5246, 12, 2061, 3493, 304, 507, 198, 692, 291, 423, 521, 365, 440, 488, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 4366, 83, 2862, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 12, 291, 423, 521, 9, 507, 198, 2836, 26, 686, 198, 83, 275, 2071, 83, 375, 5, 83, 60, 78, 2, 450, 334, 4694, 12, 291, 423, 1532, 9, 2742, 198, 73, 275, 378, 507, 198, 692, 2061, 3493, 26, 686, 198, 4694, 275, 5246, 4439, 17, 61, 435, 298, 298, 507, 198, 6710, 284, 665, 822, 8, 277, 423, 3223, 304, 686, 198, 692, 284, 1137, 822, 8, 277, 423, 3223, 9, 446, 413, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 756, 9, 686, 198, 2836, 26, 1585, 198, 83, 847, 2071, 83, 2, 450, 291, 423, 3223, 59, 73, 17979, 16695, 8, 4694, 17992, 11674, 198, 2, 259, 1204, 401, 715, 9, 686, 198, 73, 847, 413, 507, 198, 1107, 308, 199, 199, 533, 23804, 29969, 8, 1726, 304, 199, 198, 624, 3917, 314, 2061, 1004, 365, 440, 4890, 2952, 402, 314, 5200, 2059, 474, 12, 21979, 781, 2934, 370, 3631, 314, 6661, 436, 3686, 642, 1004, 14, 199, 198, 624, 199, 198, 1529, 199, 199, 533, 6819, 29969, 8, 1726, 304, 199, 198, 624, 982, 314, 1004, 365, 282, 3721, 334, 305, 315, 314, 9608, 402, 314, 3307, 570, 395, 6722, 2951, 3686, 652, 14, 199, 198, 624, 199, 198, 1529, 421, 199, 318, 2198, 3049, 8, 604, 304, 199, 198, 604, 275, 1004, 14, 1913, 342, 199, 198, 692, 1004, 14, 2460, 10064, 2349, 507, 198, 3730, 6819, 29969, 199, 198, 77, 275, 295, 14, 1431, 480, 4735, 2677, 23778, 1103, 61, 435, 779, 16, 13, 25, 32455, 304, 334, 1103, 87, 8771, 665, 15426, 1103, 87, 11, 4186, 1004, 9, 199, 198, 692, 333, 365, 488, 26, 507, 198, 3730, 23804, 29969, 199, 198, 1107, 334, 77, 14, 923, 8, 17, 395, 333, 14, 923, 8, 18, 395, 333, 14, 923, 8, 19, 430, 421, 199, 318, 2446, 837, 199, 198, 2176, 3987, 14, 5441, 275, 23491, 480, 6405, 334, 14351, 1681, 4186, 488, 12, 488, 9, 199, 198, 2350, 275, 23491, 14, 5441, 421, 198, 509, 1004, 315, 984, 14, 6626, 26, 507, 198, 893, 26, 686, 198, 1250, 521, 12, 3213, 18387, 12, 8025, 275, 2198, 3049, 8, 604, 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, 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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 ]
MusculoskeletalAtlasProject/mapclient
src/mapclient/view/dialogs/log/loginformation.py
2
4487
""" MAP Client, a program to generate detailed musculoskeletal models for OpenSim. Copyright (C) 2012 University of Auckland This file is part of MAP Client. (http://launchpad.net/mapclient) MAP Client 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. MAP Client 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 MAP Client. If not, see <http://www.gnu.org/licenses/>.. """ from dateutil.parser import parse from PySide.QtGui import QDialog, QTableWidgetItem, QLabel from mapclient.view.dialogs.log.ui.ui_loginformation import Ui_LogInformation from mapclient.settings.general import getLogLocation class LogInformation(QDialog): """ Log record dialog to present the user with the log information recorded by the program. """ current_log_file = getLogLocation() def __init__(self, parent=None): QDialog.__init__(self, parent) self._ui = Ui_LogInformation() self._ui.setupUi(self) self._ui.detailsButton.setEnabled(False) self._makeConnections() def fillTable(self, parent=None): logs = self.loadSession(getLogLocation()) self.updateTable(logs) def _makeConnections(self): self._ui.information_table.itemSelectionChanged.connect(self._selectionChanged) self._ui.information_table.cellDoubleClicked.connect(self.showLogDetails) self._ui.detailsButton.clicked.connect(self.showLogDetails) self._ui.loadButton.clicked.connect(self.loadLogSession) def _selectionChanged(self): if self._ui.information_table.selectedItems(): self._ui.detailsButton.setEnabled(True) def showLogDetails(self): from mapclient.view.dialogs.log.logdetails import LogDetails dlg = LogDetails(self) dlg.setModal(True) index = self._ui.information_table.indexFromItem(self._ui.information_table.selectedItems()[0]) row = index.row() log_details = [] for column in range(self._ui.information_table.columnCount()): if column == 4: edit = self._ui.information_table.cellWidget(row, column) text = edit.text() else: text = self._ui.information_table.item(row, column).text() log_details.append(text) dlg.fillTable(log_details) dlg.exec_() def loadLogSession(self): from mapclient.view.dialogs.log.loadlogsession import LoadLogSession dlg = LoadLogSession(self) dlg.setModal(True) if dlg.exec_(): log_file = dlg.getLogSession() logs = self.loadSession(log_file) if logs: self.updateTable(logs) self.current_log_file = log_file def loadSession(self, filename): logs = [] with open(filename, 'r') as f: log_data = [line.rstrip('\n') for line in f] for entry in log_data: if entry: try: parse(entry[:25]) logs.append(entry.split(' - ')) except Exception: logs[-1][-1] += '\n' + entry return logs def updateTable(self, logs): self._ui.information_table.clearContents() self._ui.information_table.setRowCount(len(logs)) self._ui.information_table.setColumnCount(5) self._ui.information_table.setColumnHidden(0, True) self._ui.information_table.setColumnHidden(2, True) for row, log in enumerate(logs): for column, entry in enumerate(log): if column == 4: label = QLabel(entry) self._ui.information_table.setCellWidget(row, column, label) else: self._ui.information_table.setItem(row, column, QTableWidgetItem(entry)) self._ui.information_table.resizeColumnToContents(0) self._ui.information_table.resizeColumnToContents(1) self._ui.information_table.resizeRowsToContents()
gpl-3.0
[ 624, 199, 5443, 6810, 12, 282, 2240, 370, 3550, 16212, 333, 527, 15140, 11560, 415, 2723, 279, 1709, 367, 3232, 7467, 14, 272, 1898, 334, 35, 9, 6029, 221, 15904, 402, 437, 10112, 9688, 199, 199, 2765, 570, 365, 1777, 402, 603, 1282, 6810, 14, 334, 1014, 921, 9850, 6226, 14, 846, 15, 1130, 1258, 9, 339, 603, 1282, 6810, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 603, 1282, 6810, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 603, 1282, 6810, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 703, 199, 624, 199, 504, 22208, 14, 2087, 492, 2198, 199, 199, 504, 1611, 15414, 14, 10604, 492, 1413, 5619, 12, 1413, 3186, 29035, 12, 1413, 4314, 199, 199, 504, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 1907, 14, 1907, 63, 2886, 1869, 492, 32471, 63, 2445, 4935, 199, 504, 2341, 1258, 14, 1751, 14, 10706, 492, 664, 2445, 6592, 421, 199, 533, 5297, 4935, 8, 30983, 304, 272, 408, 272, 5297, 2777, 9592, 370, 3451, 314, 922, 543, 314, 943, 2556, 18894, 701, 314, 2240, 14, 272, 408, 339, 1453, 63, 793, 63, 493, 275, 664, 2445, 6592, 342, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 5619, 855, 826, 721, 277, 12, 1676, 9, 267, 291, 423, 1907, 275, 32471, 63, 2445, 4935, 342, 267, 291, 423, 1907, 14, 2758, 18203, 8, 277, 9, 267, 291, 423, 1907, 14, 5087, 4259, 14, 14329, 8, 797, 9, 267, 291, 423, 1875, 22122, 342, 339, 347, 5554, 3186, 8, 277, 12, 1676, 29, 403, 304, 267, 9610, 275, 291, 14, 912, 4434, 8, 362, 2445, 6592, 1012, 267, 291, 14, 873, 3186, 8, 7270, 9, 339, 347, 485, 1875, 22122, 8, 277, 304, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1053, 7713, 6970, 14, 2242, 8, 277, 423, 5592, 6970, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3890, 7281, 31483, 14, 2242, 8, 277, 14, 2384, 2445, 11347, 9, 267, 291, 423, 1907, 14, 5087, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2384, 2445, 11347, 9, 267, 291, 423, 1907, 14, 912, 4259, 14, 11276, 14, 2242, 8, 277, 14, 912, 2445, 4434, 9, 339, 347, 485, 5592, 6970, 8, 277, 304, 267, 340, 291, 423, 1907, 14, 11697, 63, 1224, 14, 5511, 7412, 837, 288, 291, 423, 1907, 14, 5087, 4259, 14, 14329, 8, 549, 9, 339, 347, 2498, 2445, 11347, 8, 277, 304, 267, 687, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 793, 5087, 492, 5297, 11347, 267, 19406, 275, 5297, 11347, 8, 277, 9, 267, 19406, 14, 409, 23689, 8, 549, 9, 267, 1478, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1080, 2532, 2081, 8, 277, 423, 1907, 14, 11697, 63, 1224, 14, 5511, 7412, 3430, 16, 566, 267, 1962, 275, 1478, 14, 1143, 342, 267, 943, 63, 5087, 275, 942, 267, 367, 2763, 315, 1425, 8, 277, 423, 1907, 14, 11697, 63, 1224, 14, 2301, 2353, 5109, 288, 340, 2763, 508, 841, 26, 355, 5283, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3890, 3339, 8, 1143, 12, 2763, 9, 355, 1318, 275, 5283, 14, 505, 342, 288, 587, 26, 355, 1318, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1053, 8, 1143, 12, 2763, 680, 505, 342, 288, 943, 63, 5087, 14, 740, 8, 505, 9, 267, 19406, 14, 4498, 3186, 8, 793, 63, 5087, 9, 267, 19406, 14, 1628, 12798, 339, 347, 2248, 2445, 4434, 8, 277, 304, 267, 687, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 912, 793, 1730, 492, 7190, 2445, 4434, 267, 19406, 275, 7190, 2445, 4434, 8, 277, 9, 267, 19406, 14, 409, 23689, 8, 549, 9, 267, 340, 19406, 14, 1628, 20708, 288, 943, 63, 493, 275, 19406, 14, 362, 2445, 4434, 342, 288, 9610, 275, 291, 14, 912, 4434, 8, 793, 63, 493, 9, 288, 340, 9610, 26, 355, 291, 14, 873, 3186, 8, 7270, 9, 355, 291, 14, 1818, 63, 793, 63, 493, 275, 943, 63, 493, 339, 347, 2248, 4434, 8, 277, 12, 1788, 304, 267, 9610, 275, 942, 267, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 288, 943, 63, 576, 275, 359, 604, 14, 6735, 2258, 78, 358, 367, 1004, 315, 289, 61, 288, 367, 2397, 315, 943, 63, 576, 26, 355, 340, 2397, 26, 490, 862, 26, 717, 2198, 8, 2373, 1491, 821, 566, 717, 9610, 14, 740, 8, 2373, 14, 1294, 360, 446, 20005, 490, 871, 2186, 26, 717, 9610, 1988, 17, 15898, 17, 61, 847, 1557, 78, 7, 435, 2397, 398, 372, 9610, 339, 347, 1678, 3186, 8, 277, 12, 9610, 304, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3584, 11383, 342, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 5810, 2353, 8, 552, 8, 7270, 430, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 2353, 8, 21, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 14983, 8, 16, 12, 715, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 14983, 8, 18, 12, 715, 9, 398, 367, 1962, 12, 943, 315, 3874, 8, 7270, 304, 288, 367, 2763, 12, 2397, 315, 3874, 8, 793, 304, 355, 340, 2763, 508, 841, 26, 490, 1768, 275, 1413, 4314, 8, 2373, 9, 490, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 8108, 3339, 8, 1143, 12, 2763, 12, 1768, 9, 355, 587, 26, 490, 291, 423, 1907, 14, 11697, 63, 1224 ]
[ 199, 5443, 6810, 12, 282, 2240, 370, 3550, 16212, 333, 527, 15140, 11560, 415, 2723, 279, 1709, 367, 3232, 7467, 14, 272, 1898, 334, 35, 9, 6029, 221, 15904, 402, 437, 10112, 9688, 199, 199, 2765, 570, 365, 1777, 402, 603, 1282, 6810, 14, 334, 1014, 921, 9850, 6226, 14, 846, 15, 1130, 1258, 9, 339, 603, 1282, 6810, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 603, 1282, 6810, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 603, 1282, 6810, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 703, 199, 624, 199, 504, 22208, 14, 2087, 492, 2198, 199, 199, 504, 1611, 15414, 14, 10604, 492, 1413, 5619, 12, 1413, 3186, 29035, 12, 1413, 4314, 199, 199, 504, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 1907, 14, 1907, 63, 2886, 1869, 492, 32471, 63, 2445, 4935, 199, 504, 2341, 1258, 14, 1751, 14, 10706, 492, 664, 2445, 6592, 421, 199, 533, 5297, 4935, 8, 30983, 304, 272, 408, 272, 5297, 2777, 9592, 370, 3451, 314, 922, 543, 314, 943, 2556, 18894, 701, 314, 2240, 14, 272, 408, 339, 1453, 63, 793, 63, 493, 275, 664, 2445, 6592, 342, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 267, 1413, 5619, 855, 826, 721, 277, 12, 1676, 9, 267, 291, 423, 1907, 275, 32471, 63, 2445, 4935, 342, 267, 291, 423, 1907, 14, 2758, 18203, 8, 277, 9, 267, 291, 423, 1907, 14, 5087, 4259, 14, 14329, 8, 797, 9, 267, 291, 423, 1875, 22122, 342, 339, 347, 5554, 3186, 8, 277, 12, 1676, 29, 403, 304, 267, 9610, 275, 291, 14, 912, 4434, 8, 362, 2445, 6592, 1012, 267, 291, 14, 873, 3186, 8, 7270, 9, 339, 347, 485, 1875, 22122, 8, 277, 304, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1053, 7713, 6970, 14, 2242, 8, 277, 423, 5592, 6970, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3890, 7281, 31483, 14, 2242, 8, 277, 14, 2384, 2445, 11347, 9, 267, 291, 423, 1907, 14, 5087, 4259, 14, 11276, 14, 2242, 8, 277, 14, 2384, 2445, 11347, 9, 267, 291, 423, 1907, 14, 912, 4259, 14, 11276, 14, 2242, 8, 277, 14, 912, 2445, 4434, 9, 339, 347, 485, 5592, 6970, 8, 277, 304, 267, 340, 291, 423, 1907, 14, 11697, 63, 1224, 14, 5511, 7412, 837, 288, 291, 423, 1907, 14, 5087, 4259, 14, 14329, 8, 549, 9, 339, 347, 2498, 2445, 11347, 8, 277, 304, 267, 687, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 793, 5087, 492, 5297, 11347, 267, 19406, 275, 5297, 11347, 8, 277, 9, 267, 19406, 14, 409, 23689, 8, 549, 9, 267, 1478, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1080, 2532, 2081, 8, 277, 423, 1907, 14, 11697, 63, 1224, 14, 5511, 7412, 3430, 16, 566, 267, 1962, 275, 1478, 14, 1143, 342, 267, 943, 63, 5087, 275, 942, 267, 367, 2763, 315, 1425, 8, 277, 423, 1907, 14, 11697, 63, 1224, 14, 2301, 2353, 5109, 288, 340, 2763, 508, 841, 26, 355, 5283, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3890, 3339, 8, 1143, 12, 2763, 9, 355, 1318, 275, 5283, 14, 505, 342, 288, 587, 26, 355, 1318, 275, 291, 423, 1907, 14, 11697, 63, 1224, 14, 1053, 8, 1143, 12, 2763, 680, 505, 342, 288, 943, 63, 5087, 14, 740, 8, 505, 9, 267, 19406, 14, 4498, 3186, 8, 793, 63, 5087, 9, 267, 19406, 14, 1628, 12798, 339, 347, 2248, 2445, 4434, 8, 277, 304, 267, 687, 2341, 1258, 14, 1345, 14, 328, 18238, 14, 793, 14, 912, 793, 1730, 492, 7190, 2445, 4434, 267, 19406, 275, 7190, 2445, 4434, 8, 277, 9, 267, 19406, 14, 409, 23689, 8, 549, 9, 267, 340, 19406, 14, 1628, 20708, 288, 943, 63, 493, 275, 19406, 14, 362, 2445, 4434, 342, 288, 9610, 275, 291, 14, 912, 4434, 8, 793, 63, 493, 9, 288, 340, 9610, 26, 355, 291, 14, 873, 3186, 8, 7270, 9, 355, 291, 14, 1818, 63, 793, 63, 493, 275, 943, 63, 493, 339, 347, 2248, 4434, 8, 277, 12, 1788, 304, 267, 9610, 275, 942, 267, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 288, 943, 63, 576, 275, 359, 604, 14, 6735, 2258, 78, 358, 367, 1004, 315, 289, 61, 288, 367, 2397, 315, 943, 63, 576, 26, 355, 340, 2397, 26, 490, 862, 26, 717, 2198, 8, 2373, 1491, 821, 566, 717, 9610, 14, 740, 8, 2373, 14, 1294, 360, 446, 20005, 490, 871, 2186, 26, 717, 9610, 1988, 17, 15898, 17, 61, 847, 1557, 78, 7, 435, 2397, 398, 372, 9610, 339, 347, 1678, 3186, 8, 277, 12, 9610, 304, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 3584, 11383, 342, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 5810, 2353, 8, 552, 8, 7270, 430, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 2353, 8, 21, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 14983, 8, 16, 12, 715, 9, 267, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 4547, 14983, 8, 18, 12, 715, 9, 398, 367, 1962, 12, 943, 315, 3874, 8, 7270, 304, 288, 367, 2763, 12, 2397, 315, 3874, 8, 793, 304, 355, 340, 2763, 508, 841, 26, 490, 1768, 275, 1413, 4314, 8, 2373, 9, 490, 291, 423, 1907, 14, 11697, 63, 1224, 14, 409, 8108, 3339, 8, 1143, 12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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
byaka/flaskJSONRPCServer
bench/utils.py
1
3754
#!/usr/bin/env python # -*- coding: utf-8 -*- __all__=['arrMin', 'arrMax', 'arrMedian', 'arrTrimean', 'arrMode', 'arrAverage', 'oGet', 'arrUnique'] def arrUnique(arr, key=None): #unique elements of array if not(arr): return [] tArr1=arr if key: tArr1=[key(s) for s in tArr1] tArr1=set(list(tArr1)) return tArr1 def arrFind(arr, item, default=-1): return oGet(arr, item, default=default) def oGet(o, key, default=None): try: return o[key] except: return default def arrAverage(arr): if not len(arr): return 0 return sum(arr)/float(len(arr)) def arrMax(arr, key=None, returnIndex=False): if not len(arr): return 0 if not returnIndex else -1 elif len(arr)==1: return arr[0] if not returnIndex else 0 if key: arr=[key(s) for s in arr] if not returnIndex: try: return max(arr) except: return None else: try: return arrFind(arr, max(arr)) except: -1 def arrMin(arr, key=None, returnIndex=False): if not len(arr): return 0 if not returnIndex else -1 elif len(arr)==1: return arr[0] if not returnIndex else 0 if key: arr=[key(s) for s in arr] if not returnIndex: try: return min(arr) except: return None else: try: return arrFind(arr, min(arr)) except: -1 def arrMedian(arr, arrMap=None): if not len(arr): return 0 elif len(arr)==1: return arr[0] if not arrMap: arrMap=sorted(range(len(arr)), key=lambda i:arr[i], reverse=False) if len(arrMap)%2: median=arr[arrMap[len(arrMap)/2]] else: median=(arr[arrMap[(len(arrMap)-1)/2]]+arr[arrMap[(len(arrMap)-1)/2+1]])/2.0 return median def arrQuartiles(arr, arrMap=None, method=1): if not len(arr): return 0 elif len(arr)==1: return arr[0] if not arrMap: arrMap=sorted(range(len(arr)), key=lambda i:arr[i], reverse=False) median=arrMedian(arr, arrMap) def getHalve(isLow=True, includeM=False): tArr=[] for i in arrMap: if isLow and (arr[i]<=median if includeM else arr[i]<median): tArr.append(arr[i]) if not isLow and (arr[i]>=median if includeM else arr[i]>median): tArr.append(arr[i]) tArrMap=range(len(tArr)) return tArr, tArrMap if method in [1, 2]: #methods "1-Var Stats" and "Tukey's hinges" tHalveL, tHalveL_arrMap=getHalve(True, method==2) tHalveH, tHalveH_arrMap=getHalve(False, method==2) qL=arrMedian(tHalveL, tHalveL_arrMap) qH=arrMedian(tHalveH, tHalveH_arrMap) elif method==3: tHalveL1, tHalveL1_arrMap=getHalve(True, False) tHalveH1, tHalveH1_arrMap=getHalve(False, False) qL1=arrMedian(tHalveL1, tHalveL1_arrMap) qH1=arrMedian(tHalveH1, tHalveH1_arrMap) tHalveL2, tHalveL2_arrMap=getHalve(True, True) tHalveH2, tHalveH2_arrMap=getHalve(False, True) qL2=arrMedian(tHalveL2, tHalveL2_arrMap) qH2=arrMedian(tHalveH2, tHalveH2_arrMap) qL=(qL1+qL2)/2.0 qH=(qH1+qH2)/2.0 return qL, median, qH def arrTrimean(arr, arrMap=None): """ >>> trimean([1, 1, 3, 5, 7, 9, 10, 14, 18]) 6.75 >>> trimean([0, 1, 2, 3, 4, 5, 6, 7, 8]) 4.0 """ if not len(arr): return 0 elif len(arr)==1: return arr[0] if not arrMap: arrMap=sorted(range(len(arr)), key=lambda i:arr[i], reverse=False) q1, m, q3=arrQuartiles(arr, arrMap, method=2) trimean=(q1+2.0*m+q3)/4.0 return trimean def arrMode(arr, rank=0, returnIndex=False): arrMap={} for i, v in enumerate(arr): if v not in arrMap: arrMap[v]=[] arrMap[v].append(i) kMap=arrMap.keys() if rank>=len(kMap): return [] if returnIndex else None kMap=sorted(kMap, key=lambda s: len(arrMap[s]), reverse=True) k=kMap[rank] return arrMap[k] if returnIndex else k if __name__=='__main__': pass
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 452, 363, 2968, 5250, 4649, 297, 283, 5250, 4261, 297, 283, 5250, 1352, 6268, 297, 283, 5250, 6948, 3670, 297, 283, 5250, 1385, 297, 283, 5250, 17400, 297, 283, 79, 1002, 297, 283, 5250, 11427, 418, 199, 199, 318, 7953, 11427, 8, 5250, 12, 790, 29, 403, 304, 2043, 327, 3235, 4008, 402, 1625, 2043, 340, 440, 8, 5250, 304, 372, 942, 2043, 307, 22011, 17, 29, 5250, 2043, 340, 790, 26, 307, 22011, 17, 1524, 498, 8, 83, 9, 367, 308, 315, 307, 22011, 17, 61, 2043, 307, 22011, 17, 29, 409, 8, 513, 8, 84, 22011, 17, 430, 2043, 372, 307, 22011, 17, 199, 199, 318, 7953, 6591, 8, 5250, 12, 1242, 12, 849, 4022, 17, 304, 2043, 372, 312, 1002, 8, 5250, 12, 1242, 12, 849, 29, 885, 9, 199, 199, 318, 312, 1002, 8, 79, 12, 790, 12, 849, 29, 403, 304, 2043, 862, 26, 372, 312, 59, 498, 61, 2043, 871, 26, 372, 849, 199, 199, 318, 7953, 17400, 8, 5250, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 372, 3089, 8, 5250, 2447, 1609, 8, 552, 8, 5250, 430, 199, 199, 318, 7953, 4261, 8, 5250, 12, 790, 29, 403, 12, 372, 2681, 29, 797, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 340, 440, 372, 2681, 587, 446, 17, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 340, 440, 372, 2681, 587, 378, 2043, 340, 790, 26, 7953, 1524, 498, 8, 83, 9, 367, 308, 315, 7953, 61, 2043, 340, 440, 372, 2681, 26, 489, 862, 26, 372, 1390, 8, 5250, 9, 489, 871, 26, 372, 488, 2043, 587, 26, 489, 862, 26, 372, 7953, 6591, 8, 5250, 12, 1390, 8, 5250, 430, 489, 871, 26, 446, 17, 199, 199, 318, 7953, 4649, 8, 5250, 12, 790, 29, 403, 12, 372, 2681, 29, 797, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 340, 440, 372, 2681, 587, 446, 17, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 340, 440, 372, 2681, 587, 378, 2043, 340, 790, 26, 7953, 1524, 498, 8, 83, 9, 367, 308, 315, 7953, 61, 2043, 340, 440, 372, 2681, 26, 489, 862, 26, 372, 1748, 8, 5250, 9, 489, 871, 26, 372, 488, 2043, 587, 26, 489, 862, 26, 372, 7953, 6591, 8, 5250, 12, 1748, 8, 5250, 430, 489, 871, 26, 446, 17, 199, 199, 318, 7953, 1352, 6268, 8, 5250, 12, 7953, 2956, 29, 403, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 2043, 340, 440, 7953, 2956, 26, 489, 7953, 2956, 29, 5917, 8, 1842, 8, 552, 8, 5250, 1826, 790, 29, 2734, 284, 26, 5250, 59, 73, 467, 3837, 29, 797, 9, 2043, 340, 822, 8, 5250, 2956, 19656, 18, 26, 489, 17312, 29, 5250, 59, 5250, 2956, 59, 552, 8, 5250, 2956, 2447, 18, 2677, 2043, 587, 26, 489, 17312, 2687, 5250, 59, 5250, 2956, 7528, 552, 8, 5250, 2956, 7216, 17, 2447, 18, 2677, 11, 5250, 59, 5250, 2956, 7528, 552, 8, 5250, 2956, 7216, 17, 2447, 18, 11, 17, 3934, 15, 18, 14, 16, 2043, 372, 17312, 199, 199, 318, 7953, 2371, 285, 18819, 8, 5250, 12, 7953, 2956, 29, 403, 12, 1083, 29, 17, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 2043, 340, 440, 7953, 2956, 26, 489, 7953, 2956, 29, 5917, 8, 1842, 8, 552, 8, 5250, 1826, 790, 29, 2734, 284, 26, 5250, 59, 73, 467, 3837, 29, 797, 9, 2043, 17312, 29, 5250, 1352, 6268, 8, 5250, 12, 7953, 2956, 9, 2043, 347, 664, 40, 279, 432, 8, 374, 10281, 29, 549, 12, 2387, 45, 29, 797, 304, 489, 307, 22011, 9811, 489, 367, 284, 315, 7953, 2956, 26, 268, 340, 365, 10281, 436, 334, 5250, 59, 73, 61, 12932, 13106, 340, 2387, 45, 587, 7953, 59, 73, 61, 28, 13106, 304, 307, 22011, 14, 740, 8, 5250, 59, 73, 566, 268, 340, 440, 365, 10281, 436, 334, 5250, 59, 73, 61, 8119, 13106, 340, 2387, 45, 587, 7953, 59, 73, 28474, 13106, 304, 307, 22011, 14, 740, 8, 5250, 59, 73, 566, 489, 307, 22011, 2956, 29, 1842, 8, 552, 8, 84, 22011, 430, 489, 372, 307, 22011, 12, 307, 22011, 2956, 2043, 340, 1083, 315, 359, 17, 12, 499, 2189, 327, 2474, 298, 17, 13, 5894, 29062, 2, 436, 298, 30669, 498, 1159, 394, 262, 3389, 2, 489, 307, 40, 279, 432, 44, 12, 307, 40, 279, 432, 44, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 1083, 389, 18, 9, 489, 307, 40, 279, 432, 40, 12, 307, 40, 279, 432, 40, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 797, 12, 1083, 389, 18, 9, 489, 1894, 44, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 44, 12, 307, 40, 279, 432, 44, 63, 5250, 2956, 9, 489, 1894, 40, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 40, 12, 307, 40, 279, 432, 40, 63, 5250, 2956, 9, 2043, 916, 1083, 389, 19, 26, 489, 307, 40, 279, 432, 44, 17, 12, 307, 40, 279, 432, 44, 17, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 756, 9, 489, 307, 40, 279, 432, 40, 17, 12, 307, 40, 279, 432, 40, 17, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 797, 12, 756, 9, 489, 1894, 44, 17, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 44, 17, 12, 307, 40, 279, 432, 44, 17, 63, 5250, 2956, 9, 489, 1894, 40, 17, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 40, 17, 12, 307, 40, 279, 432, 40, 17, 63, 5250, 2956, 9, 489, 307, 40, 279, 432, 44, 18, 12, 307, 40, 279, 432, 44, 18, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 715, 9, 489, 307, 40, 279, 432, 40, 18 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 452, 363, 2968, 5250, 4649, 297, 283, 5250, 4261, 297, 283, 5250, 1352, 6268, 297, 283, 5250, 6948, 3670, 297, 283, 5250, 1385, 297, 283, 5250, 17400, 297, 283, 79, 1002, 297, 283, 5250, 11427, 418, 199, 199, 318, 7953, 11427, 8, 5250, 12, 790, 29, 403, 304, 2043, 327, 3235, 4008, 402, 1625, 2043, 340, 440, 8, 5250, 304, 372, 942, 2043, 307, 22011, 17, 29, 5250, 2043, 340, 790, 26, 307, 22011, 17, 1524, 498, 8, 83, 9, 367, 308, 315, 307, 22011, 17, 61, 2043, 307, 22011, 17, 29, 409, 8, 513, 8, 84, 22011, 17, 430, 2043, 372, 307, 22011, 17, 199, 199, 318, 7953, 6591, 8, 5250, 12, 1242, 12, 849, 4022, 17, 304, 2043, 372, 312, 1002, 8, 5250, 12, 1242, 12, 849, 29, 885, 9, 199, 199, 318, 312, 1002, 8, 79, 12, 790, 12, 849, 29, 403, 304, 2043, 862, 26, 372, 312, 59, 498, 61, 2043, 871, 26, 372, 849, 199, 199, 318, 7953, 17400, 8, 5250, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 372, 3089, 8, 5250, 2447, 1609, 8, 552, 8, 5250, 430, 199, 199, 318, 7953, 4261, 8, 5250, 12, 790, 29, 403, 12, 372, 2681, 29, 797, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 340, 440, 372, 2681, 587, 446, 17, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 340, 440, 372, 2681, 587, 378, 2043, 340, 790, 26, 7953, 1524, 498, 8, 83, 9, 367, 308, 315, 7953, 61, 2043, 340, 440, 372, 2681, 26, 489, 862, 26, 372, 1390, 8, 5250, 9, 489, 871, 26, 372, 488, 2043, 587, 26, 489, 862, 26, 372, 7953, 6591, 8, 5250, 12, 1390, 8, 5250, 430, 489, 871, 26, 446, 17, 199, 199, 318, 7953, 4649, 8, 5250, 12, 790, 29, 403, 12, 372, 2681, 29, 797, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 340, 440, 372, 2681, 587, 446, 17, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 340, 440, 372, 2681, 587, 378, 2043, 340, 790, 26, 7953, 1524, 498, 8, 83, 9, 367, 308, 315, 7953, 61, 2043, 340, 440, 372, 2681, 26, 489, 862, 26, 372, 1748, 8, 5250, 9, 489, 871, 26, 372, 488, 2043, 587, 26, 489, 862, 26, 372, 7953, 6591, 8, 5250, 12, 1748, 8, 5250, 430, 489, 871, 26, 446, 17, 199, 199, 318, 7953, 1352, 6268, 8, 5250, 12, 7953, 2956, 29, 403, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 2043, 340, 440, 7953, 2956, 26, 489, 7953, 2956, 29, 5917, 8, 1842, 8, 552, 8, 5250, 1826, 790, 29, 2734, 284, 26, 5250, 59, 73, 467, 3837, 29, 797, 9, 2043, 340, 822, 8, 5250, 2956, 19656, 18, 26, 489, 17312, 29, 5250, 59, 5250, 2956, 59, 552, 8, 5250, 2956, 2447, 18, 2677, 2043, 587, 26, 489, 17312, 2687, 5250, 59, 5250, 2956, 7528, 552, 8, 5250, 2956, 7216, 17, 2447, 18, 2677, 11, 5250, 59, 5250, 2956, 7528, 552, 8, 5250, 2956, 7216, 17, 2447, 18, 11, 17, 3934, 15, 18, 14, 16, 2043, 372, 17312, 199, 199, 318, 7953, 2371, 285, 18819, 8, 5250, 12, 7953, 2956, 29, 403, 12, 1083, 29, 17, 304, 2043, 340, 440, 822, 8, 5250, 304, 372, 378, 2043, 916, 822, 8, 5250, 12694, 17, 26, 372, 7953, 59, 16, 61, 2043, 340, 440, 7953, 2956, 26, 489, 7953, 2956, 29, 5917, 8, 1842, 8, 552, 8, 5250, 1826, 790, 29, 2734, 284, 26, 5250, 59, 73, 467, 3837, 29, 797, 9, 2043, 17312, 29, 5250, 1352, 6268, 8, 5250, 12, 7953, 2956, 9, 2043, 347, 664, 40, 279, 432, 8, 374, 10281, 29, 549, 12, 2387, 45, 29, 797, 304, 489, 307, 22011, 9811, 489, 367, 284, 315, 7953, 2956, 26, 268, 340, 365, 10281, 436, 334, 5250, 59, 73, 61, 12932, 13106, 340, 2387, 45, 587, 7953, 59, 73, 61, 28, 13106, 304, 307, 22011, 14, 740, 8, 5250, 59, 73, 566, 268, 340, 440, 365, 10281, 436, 334, 5250, 59, 73, 61, 8119, 13106, 340, 2387, 45, 587, 7953, 59, 73, 28474, 13106, 304, 307, 22011, 14, 740, 8, 5250, 59, 73, 566, 489, 307, 22011, 2956, 29, 1842, 8, 552, 8, 84, 22011, 430, 489, 372, 307, 22011, 12, 307, 22011, 2956, 2043, 340, 1083, 315, 359, 17, 12, 499, 2189, 327, 2474, 298, 17, 13, 5894, 29062, 2, 436, 298, 30669, 498, 1159, 394, 262, 3389, 2, 489, 307, 40, 279, 432, 44, 12, 307, 40, 279, 432, 44, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 1083, 389, 18, 9, 489, 307, 40, 279, 432, 40, 12, 307, 40, 279, 432, 40, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 797, 12, 1083, 389, 18, 9, 489, 1894, 44, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 44, 12, 307, 40, 279, 432, 44, 63, 5250, 2956, 9, 489, 1894, 40, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 40, 12, 307, 40, 279, 432, 40, 63, 5250, 2956, 9, 2043, 916, 1083, 389, 19, 26, 489, 307, 40, 279, 432, 44, 17, 12, 307, 40, 279, 432, 44, 17, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 756, 9, 489, 307, 40, 279, 432, 40, 17, 12, 307, 40, 279, 432, 40, 17, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 797, 12, 756, 9, 489, 1894, 44, 17, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 44, 17, 12, 307, 40, 279, 432, 44, 17, 63, 5250, 2956, 9, 489, 1894, 40, 17, 29, 5250, 1352, 6268, 8, 84, 40, 279, 432, 40, 17, 12, 307, 40, 279, 432, 40, 17, 63, 5250, 2956, 9, 489, 307, 40, 279, 432, 44, 18, 12, 307, 40, 279, 432, 44, 18, 63, 5250, 2956, 29, 362, 40, 279, 432, 8, 549, 12, 715, 9, 489, 307, 40, 279, 432, 40, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
akiss77/servo
tests/wpt/web-platform-tests/old-tests/webdriver/user_input/clear_test.py
142
2601
# -*- mode: python; fill-column: 100; comment-column: 100; -*- import os import sys import unittest sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../.."))) import base_test from selenium.common import exceptions class ElementClearTest(base_test.WebDriverBaseTest): def test_writable_text_input_element_should_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_writable_input_page.html")) e = self.driver.find_element_by_css_selector("#writableTextInput") e.clear() self.assertEquals("", e.get_attribute("value")) def test_disabled_text_input_element_should_not_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_disabled_input_page.html")) e = self.driver.find_element_by_css_selector("#disabledTextInput") self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear()) def test_read_only_text_input_element_should_not_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_readonly_input_page.html")) e = self.driver.find_element_by_css_selector("#readOnlyTextInput") self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear()) def test_writable_text_area_element_should_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_writable_textarea_page.html")) e = self.driver.find_element_by_css_selector("#writableTextArea") e.clear() self.assertEquals("", e.get_attribute("value")) def test_disabled_text_area_element_should_not_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_disabled_textarea_page.html")) e = self.driver.find_element_by_css_selector("#disabledTextArea") self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear()) def test_read_only_text_input_element_should_not_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_readonly_textarea_page.html")) e = self.driver.find_element_by_css_selector("#readOnlyTextArea") self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear()) def test_content_editable_area_should_clear(self): self.driver.get(self.webserver.where_is("user_input/res/element_clear_contenteditable_page.html")) e = self.driver.find_element_by_css_selector("#contentEditableElement") e.clear() self.assertEquals("", e.text) if __name__ == "__main__": unittest.main()
mpl-2.0
[ 3, 1882, 818, 26, 2366, 27, 5554, 13, 2301, 26, 2948, 27, 3721, 13, 2301, 26, 2948, 27, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 29024, 703, 13324, 199, 646, 1300, 63, 396, 199, 504, 19481, 14, 2330, 492, 4967, 421, 199, 533, 6566, 9721, 774, 8, 1095, 63, 396, 14, 27009, 23170, 304, 272, 347, 511, 63, 15053, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 15053, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 15053, 18362, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 362, 63, 3215, 480, 585, 2237, 339, 347, 511, 63, 7011, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 7011, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 7011, 18362, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 739, 63, 2118, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 6753, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 739, 5903, 18362, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 15053, 63, 505, 63, 6789, 63, 2108, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 15053, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 15053, 1872, 11043, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 362, 63, 3215, 480, 585, 2237, 339, 347, 511, 63, 7011, 63, 505, 63, 6789, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 7011, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 7011, 1872, 11043, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 739, 63, 2118, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 6753, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 739, 5903, 1872, 11043, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 1317, 63, 10820, 63, 6789, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 388, 724, 266, 328, 1224, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 1317, 20957, 1224, 2162, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 505, 9, 421, 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 ]
[ 1882, 818, 26, 2366, 27, 5554, 13, 2301, 26, 2948, 27, 3721, 13, 2301, 26, 2948, 27, 1882, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2882, 199, 199, 1274, 14, 515, 14, 3176, 8, 17, 12, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 3460, 493, 3108, 29024, 703, 13324, 199, 646, 1300, 63, 396, 199, 504, 19481, 14, 2330, 492, 4967, 421, 199, 533, 6566, 9721, 774, 8, 1095, 63, 396, 14, 27009, 23170, 304, 272, 347, 511, 63, 15053, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 15053, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 15053, 18362, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 362, 63, 3215, 480, 585, 2237, 339, 347, 511, 63, 7011, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 7011, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 7011, 18362, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 739, 63, 2118, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 6753, 63, 1210, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 739, 5903, 18362, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 15053, 63, 505, 63, 6789, 63, 2108, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 15053, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 15053, 1872, 11043, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 362, 63, 3215, 480, 585, 2237, 339, 347, 511, 63, 7011, 63, 505, 63, 6789, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 7011, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 7011, 1872, 11043, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 739, 63, 2118, 63, 505, 63, 1210, 63, 2108, 63, 5626, 63, 1397, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 6753, 63, 20895, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 739, 5903, 1872, 11043, 531, 267, 291, 14, 1855, 8, 3924, 14, 3364, 2162, 2223, 1726, 12, 2400, 26, 325, 14, 3584, 1012, 339, 347, 511, 63, 1317, 63, 10820, 63, 6789, 63, 5626, 63, 3584, 8, 277, 304, 267, 291, 14, 3090, 14, 362, 8, 277, 14, 29819, 14, 4509, 63, 374, 480, 751, 63, 1210, 15, 470, 15, 2108, 63, 3584, 63, 388, 724, 266, 328, 1224, 63, 1606, 14, 1360, 2237, 267, 325, 275, 291, 14, 3090, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 10064, 1317, 20957, 1224, 2162, 531, 267, 325, 14, 3584, 342, 267, 291, 14, 2947, 12398, 325, 14, 505, 9, 421, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
usc-isi/horizon-old
horizon/horizon/dashboards/syspanel/flavors/forms.py
1
2657
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2011 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2011 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging from django import shortcuts from django.contrib import messages from django.utils.translation import ugettext as _ from openstackx.api import exceptions as api_exceptions from horizon import api from horizon import forms LOG = logging.getLogger(__name__) class CreateFlavor(forms.SelfHandlingForm): flavorid = forms.IntegerField(label=_("Flavor ID")) name = forms.CharField(max_length="25", label=_("Name")) vcpus = forms.CharField(max_length="5", label=_("VCPUs")) memory_mb = forms.CharField(max_length="5", label=_("Memory MB")) disk_gb = forms.CharField(max_length="5", label=_("Disk GB")) def handle(self, request, data): api.flavor_create(request, data['name'], int(data['memory_mb']), int(data['vcpus']), int(data['disk_gb']), int(data['flavorid'])) msg = _('%s was successfully added to flavors.') % data['name'] LOG.info(msg) messages.success(request, msg) return shortcuts.redirect('horizon:syspanel:flavors:index') class DeleteFlavor(forms.SelfHandlingForm): flavorid = forms.CharField(required=True) def handle(self, request, data): try: flavor_id = data['flavorid'] flavor = api.flavor_get(request, flavor_id) LOG.info('Deleting flavor with id "%s"' % flavor_id) api.flavor_delete(request, flavor_id, False) messages.info(request, _('Successfully deleted flavor: %s') % flavor.name) except api_exceptions.ApiException, e: messages.error(request, _('Unable to delete flavor: %s') % e.message) return shortcuts.redirect(request.build_absolute_uri())
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 7760, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 1639, 492, 3974, 12946, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 13869, 88, 14, 1246, 492, 4967, 465, 2986, 63, 3924, 199, 199, 504, 21726, 492, 2986, 199, 504, 21726, 492, 4513, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 2790, 16739, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 8541, 344, 275, 4513, 14, 3901, 8, 1302, 9384, 16739, 2870, 2237, 272, 536, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 821, 401, 1768, 9384, 985, 2237, 272, 30173, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 54, 11011, 83, 2237, 272, 4402, 63, 887, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 8628, 19487, 2237, 272, 4543, 63, 4908, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 10690, 18553, 2237, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 2986, 14, 6081, 63, 981, 8, 1069, 12, 2079, 666, 459, 354, 995, 2079, 1109, 8, 576, 459, 4844, 63, 887, 3815, 2079, 1109, 8, 576, 459, 19685, 3815, 2079, 1109, 8, 576, 459, 4032, 63, 4908, 3815, 2079, 1109, 8, 576, 459, 6081, 344, 5156, 267, 1499, 275, 485, 3508, 83, 1990, 8792, 3483, 370, 23547, 2659, 450, 666, 459, 354, 418, 267, 5051, 14, 815, 8, 1328, 9, 267, 3788, 14, 3742, 8, 1069, 12, 1499, 9, 267, 372, 3974, 12946, 14, 4876, 360, 16561, 26, 1274, 7885, 26, 18664, 26, 1080, 358, 421, 199, 533, 8496, 16739, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 8541, 344, 275, 4513, 14, 2183, 8, 2427, 29, 549, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 8541, 63, 344, 275, 666, 459, 6081, 344, 418, 288, 8541, 275, 2986, 14, 6081, 63, 362, 8, 1069, 12, 8541, 63, 344, 9, 288, 5051, 14, 815, 360, 22001, 8541, 543, 1305, 2071, 83, 4507, 450, 8541, 63, 344, 9, 288, 2986, 14, 6081, 63, 1807, 8, 1069, 12, 8541, 63, 344, 12, 756, 9, 288, 3788, 14, 815, 8, 1069, 12, 4018, 25001, 5463, 8541, 26, 450, 83, 358, 450, 2079, 8541, 14, 354, 9, 267, 871, 2986, 63, 3924, 14, 7394, 1726, 12, 325, 26, 288, 3788, 14, 705, 8, 1069, 12, 4018, 6005, 370, 3145, 8541, 26, 450, 83, 358, 450, 3660, 325, 14, 1188, 9, 267, 372, 3974, 12946, 14, 4876, 8, 1069, 14, 1506, 63, 6116, 63, 2302, 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 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 7760, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 1639, 492, 3974, 12946, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 13869, 88, 14, 1246, 492, 4967, 465, 2986, 63, 3924, 199, 199, 504, 21726, 492, 2986, 199, 504, 21726, 492, 4513, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 2790, 16739, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 8541, 344, 275, 4513, 14, 3901, 8, 1302, 9384, 16739, 2870, 2237, 272, 536, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 821, 401, 1768, 9384, 985, 2237, 272, 30173, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 54, 11011, 83, 2237, 272, 4402, 63, 887, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 8628, 19487, 2237, 272, 4543, 63, 4908, 275, 4513, 14, 2183, 8, 988, 63, 1267, 628, 21, 401, 1768, 9384, 10690, 18553, 2237, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 2986, 14, 6081, 63, 981, 8, 1069, 12, 2079, 666, 459, 354, 995, 2079, 1109, 8, 576, 459, 4844, 63, 887, 3815, 2079, 1109, 8, 576, 459, 19685, 3815, 2079, 1109, 8, 576, 459, 4032, 63, 4908, 3815, 2079, 1109, 8, 576, 459, 6081, 344, 5156, 267, 1499, 275, 485, 3508, 83, 1990, 8792, 3483, 370, 23547, 2659, 450, 666, 459, 354, 418, 267, 5051, 14, 815, 8, 1328, 9, 267, 3788, 14, 3742, 8, 1069, 12, 1499, 9, 267, 372, 3974, 12946, 14, 4876, 360, 16561, 26, 1274, 7885, 26, 18664, 26, 1080, 358, 421, 199, 533, 8496, 16739, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 8541, 344, 275, 4513, 14, 2183, 8, 2427, 29, 549, 9, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 862, 26, 288, 8541, 63, 344, 275, 666, 459, 6081, 344, 418, 288, 8541, 275, 2986, 14, 6081, 63, 362, 8, 1069, 12, 8541, 63, 344, 9, 288, 5051, 14, 815, 360, 22001, 8541, 543, 1305, 2071, 83, 4507, 450, 8541, 63, 344, 9, 288, 2986, 14, 6081, 63, 1807, 8, 1069, 12, 8541, 63, 344, 12, 756, 9, 288, 3788, 14, 815, 8, 1069, 12, 4018, 25001, 5463, 8541, 26, 450, 83, 358, 450, 2079, 8541, 14, 354, 9, 267, 871, 2986, 63, 3924, 14, 7394, 1726, 12, 325, 26, 288, 3788, 14, 705, 8, 1069, 12, 4018, 6005, 370, 3145, 8541, 26, 450, 83, 358, 450, 3660, 325, 14, 1188, 9, 267, 372, 3974, 12946, 14, 4876, 8, 1069, 14, 1506, 63, 6116, 63, 2302, 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, 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, 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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 ]
bitdomo2/android_kernel_lge_gammaw
tools/perf/scripts/python/syscall-counts.py
11181
1522
# system call counts # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts.py [comm]\n"; for_comm = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): print "%-40s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 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 ]
[ 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 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, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 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, 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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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 ]
ckloss/LIGGGHTS-PUBLIC
python/examples/viz_gl.py
25
1846
#!/usr/bin/env python -i # preceeding line should have path for Python on your machine # viz_gl.py # Purpose: viz running LAMMPS simulation via GL tool in Pizza.py # Syntax: viz_gl.py in.lammps Nfreq Nsteps # in.lammps = LAMMPS input script # Nfreq = dump and viz shapshot every this many steps # Nsteps = run for this many steps import sys sys.path.append("./pizza") # parse command line argv = sys.argv if len(argv) != 4: print "Syntax: viz_gl.py in.lammps Nfreq Nsteps" sys.exit() infile = sys.argv[1] nfreq = int(sys.argv[2]) nsteps = int(sys.argv[3]) me = 0 # uncomment if running in parallel via Pypar #import pypar #me = pypar.rank() #nprocs = pypar.size() from lammps import lammps lmp = lammps() # run infile all at once # assumed to have no run command in it # dump a file in native LAMMPS dump format for Pizza.py dump tool lmp.file(infile) lmp.command("thermo %d" % nfreq) lmp.command("dump python all atom %d tmp.dump" % nfreq) # initial 0-step run to generate dump file and image lmp.command("run 0 pre yes post no") ntimestep = 0 # wrapper on GL window via Pizza.py gl tool # just proc 0 handles reading of dump file and viz if me == 0: import Tkinter tkroot = Tkinter.Tk() tkroot.withdraw() from dump import dump from gl import gl d = dump("tmp.dump",0) g = gl(d) d.next() d.unscale() g.zoom(1) g.shift(0,0) g.rotate(0,270) g.q(10) g.box(1) g.show(ntimestep) # run nfreq steps at a time w/out pre/post, read dump snapshot, display it while ntimestep < nsteps: lmp.command("run %d pre no post no" % nfreq) ntimestep += nfreq if me == 0: d.next() d.unscale() g.show(ntimestep) lmp.command("run 0 pre no post yes") # uncomment if running in parallel via Pypar #print "Proc %d out of %d procs has" % (me,nprocs), lmp #pypar.finalize()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 446, 73, 199, 3, 9222, 379, 316, 1004, 1077, 1172, 931, 367, 2018, 641, 2195, 6844, 199, 199, 3, 373, 565, 63, 3528, 14, 647, 199, 3, 23177, 4070, 26, 373, 565, 3879, 29935, 1658, 51, 17625, 4799, 3563, 4744, 315, 510, 30937, 14, 647, 199, 3, 18377, 26, 221, 373, 565, 63, 3528, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 199, 3, 3515, 315, 14, 17984, 13408, 275, 29935, 1658, 51, 1324, 2884, 199, 3, 3515, 653, 5646, 275, 5461, 436, 373, 565, 1033, 439, 2782, 4036, 642, 5002, 7124, 199, 3, 3515, 653, 5895, 275, 1255, 367, 642, 5002, 7124, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 28615, 80, 30937, 531, 199, 199, 3, 2198, 1414, 1004, 199, 199, 3020, 275, 984, 14, 3020, 199, 692, 822, 8, 3020, 9, 1137, 841, 26, 523, 870, 298, 16626, 26, 373, 565, 63, 3528, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 2, 523, 984, 14, 2224, 342, 199, 199, 13880, 275, 984, 14, 3020, 59, 17, 61, 199, 78, 5646, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 561, 6224, 275, 1109, 8, 1274, 14, 3020, 59, 19, 566, 199, 199, 278, 275, 378, 199, 3, 625, 3349, 340, 3879, 315, 9861, 4799, 1611, 462, 199, 3, 646, 1134, 462, 199, 3, 278, 275, 1134, 462, 14, 4648, 342, 199, 3, 78, 24463, 275, 1134, 462, 14, 890, 342, 199, 199, 504, 25917, 13408, 492, 25917, 13408, 199, 76, 311, 275, 25917, 13408, 342, 199, 199, 3, 1255, 14734, 1006, 737, 5403, 199, 3, 10826, 370, 1172, 949, 1255, 1414, 315, 652, 199, 3, 5461, 282, 570, 315, 5438, 29935, 1658, 51, 5461, 1475, 367, 510, 30937, 14, 647, 5461, 4744, 199, 199, 76, 311, 14, 493, 8, 13880, 9, 199, 76, 311, 14, 1531, 480, 728, 573, 450, 68, 2, 450, 302, 5646, 9, 199, 76, 311, 14, 1531, 480, 2724, 2366, 1006, 6222, 450, 68, 3529, 14, 2724, 2, 450, 302, 5646, 9, 199, 199, 3, 2536, 378, 13, 2926, 1255, 370, 3550, 5461, 570, 436, 1834, 199, 199, 76, 311, 14, 1531, 480, 1065, 378, 876, 9456, 2963, 949, 531, 199, 78, 521, 2926, 275, 378, 199, 199, 3, 4975, 641, 3563, 4353, 4799, 510, 30937, 14, 647, 6482, 4744, 199, 3, 2951, 6499, 378, 10022, 7664, 402, 5461, 570, 436, 373, 565, 199, 199, 692, 562, 508, 378, 26, 523, 492, 16826, 523, 10157, 1231, 275, 16826, 14, 15189, 342, 523, 10157, 1231, 14, 1045, 5485, 342, 819, 687, 5461, 492, 5461, 523, 687, 6482, 492, 6482, 819, 366, 275, 5461, 480, 2791, 14, 2724, 401, 16, 9, 523, 486, 275, 6482, 8, 68, 9, 523, 366, 14, 2184, 342, 523, 366, 14, 324, 3467, 342, 523, 486, 14, 10598, 8, 17, 9, 523, 486, 14, 4723, 8, 16, 12, 16, 9, 523, 486, 14, 12873, 8, 16, 12, 13299, 9, 523, 486, 14, 81, 8, 709, 9, 523, 486, 14, 1977, 8, 17, 9, 523, 486, 14, 2384, 8, 78, 521, 2926, 9, 199, 199, 3, 1255, 302, 5646, 7124, 737, 282, 900, 336, 15, 548, 876, 15, 1932, 12, 1586, 5461, 5740, 12, 2929, 652, 199, 199, 6710, 302, 521, 2926, 665, 700, 6224, 26, 523, 634, 311, 14, 1531, 480, 1065, 450, 68, 876, 949, 2963, 949, 2, 450, 302, 5646, 9, 523, 302, 521, 2926, 847, 302, 5646, 523, 340, 562, 508, 378, 26, 272, 366, 14, 2184, 342, 272, 366, 14, 324, 3467, 342, 272, 486, 14, 2384, 8, 78, 521, 2926, 9, 199, 199, 76, 311, 14, 1531, 480, 1065, 378, 876, 949, 2963, 9456, 531, 199, 199, 3, 625, 3349, 340, 3879, 315, 9861, 4799, 1611, 462, 199, 3, 1361, 298, 15019, 450, 68, 734, 402, 450, 68, 557, 1259, 965, 2, 450, 334, 278, 12, 78, 24463, 395, 634, 311, 199, 3, 647, 462, 14, 14450, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 446, 73, 199, 3, 9222, 379, 316, 1004, 1077, 1172, 931, 367, 2018, 641, 2195, 6844, 199, 199, 3, 373, 565, 63, 3528, 14, 647, 199, 3, 23177, 4070, 26, 373, 565, 3879, 29935, 1658, 51, 17625, 4799, 3563, 4744, 315, 510, 30937, 14, 647, 199, 3, 18377, 26, 221, 373, 565, 63, 3528, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 199, 3, 3515, 315, 14, 17984, 13408, 275, 29935, 1658, 51, 1324, 2884, 199, 3, 3515, 653, 5646, 275, 5461, 436, 373, 565, 1033, 439, 2782, 4036, 642, 5002, 7124, 199, 3, 3515, 653, 5895, 275, 1255, 367, 642, 5002, 7124, 199, 199, 646, 984, 199, 1274, 14, 515, 14, 740, 28615, 80, 30937, 531, 199, 199, 3, 2198, 1414, 1004, 199, 199, 3020, 275, 984, 14, 3020, 199, 692, 822, 8, 3020, 9, 1137, 841, 26, 523, 870, 298, 16626, 26, 373, 565, 63, 3528, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 2, 523, 984, 14, 2224, 342, 199, 199, 13880, 275, 984, 14, 3020, 59, 17, 61, 199, 78, 5646, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 561, 6224, 275, 1109, 8, 1274, 14, 3020, 59, 19, 566, 199, 199, 278, 275, 378, 199, 3, 625, 3349, 340, 3879, 315, 9861, 4799, 1611, 462, 199, 3, 646, 1134, 462, 199, 3, 278, 275, 1134, 462, 14, 4648, 342, 199, 3, 78, 24463, 275, 1134, 462, 14, 890, 342, 199, 199, 504, 25917, 13408, 492, 25917, 13408, 199, 76, 311, 275, 25917, 13408, 342, 199, 199, 3, 1255, 14734, 1006, 737, 5403, 199, 3, 10826, 370, 1172, 949, 1255, 1414, 315, 652, 199, 3, 5461, 282, 570, 315, 5438, 29935, 1658, 51, 5461, 1475, 367, 510, 30937, 14, 647, 5461, 4744, 199, 199, 76, 311, 14, 493, 8, 13880, 9, 199, 76, 311, 14, 1531, 480, 728, 573, 450, 68, 2, 450, 302, 5646, 9, 199, 76, 311, 14, 1531, 480, 2724, 2366, 1006, 6222, 450, 68, 3529, 14, 2724, 2, 450, 302, 5646, 9, 199, 199, 3, 2536, 378, 13, 2926, 1255, 370, 3550, 5461, 570, 436, 1834, 199, 199, 76, 311, 14, 1531, 480, 1065, 378, 876, 9456, 2963, 949, 531, 199, 78, 521, 2926, 275, 378, 199, 199, 3, 4975, 641, 3563, 4353, 4799, 510, 30937, 14, 647, 6482, 4744, 199, 3, 2951, 6499, 378, 10022, 7664, 402, 5461, 570, 436, 373, 565, 199, 199, 692, 562, 508, 378, 26, 523, 492, 16826, 523, 10157, 1231, 275, 16826, 14, 15189, 342, 523, 10157, 1231, 14, 1045, 5485, 342, 819, 687, 5461, 492, 5461, 523, 687, 6482, 492, 6482, 819, 366, 275, 5461, 480, 2791, 14, 2724, 401, 16, 9, 523, 486, 275, 6482, 8, 68, 9, 523, 366, 14, 2184, 342, 523, 366, 14, 324, 3467, 342, 523, 486, 14, 10598, 8, 17, 9, 523, 486, 14, 4723, 8, 16, 12, 16, 9, 523, 486, 14, 12873, 8, 16, 12, 13299, 9, 523, 486, 14, 81, 8, 709, 9, 523, 486, 14, 1977, 8, 17, 9, 523, 486, 14, 2384, 8, 78, 521, 2926, 9, 199, 199, 3, 1255, 302, 5646, 7124, 737, 282, 900, 336, 15, 548, 876, 15, 1932, 12, 1586, 5461, 5740, 12, 2929, 652, 199, 199, 6710, 302, 521, 2926, 665, 700, 6224, 26, 523, 634, 311, 14, 1531, 480, 1065, 450, 68, 876, 949, 2963, 949, 2, 450, 302, 5646, 9, 523, 302, 521, 2926, 847, 302, 5646, 523, 340, 562, 508, 378, 26, 272, 366, 14, 2184, 342, 272, 366, 14, 324, 3467, 342, 272, 486, 14, 2384, 8, 78, 521, 2926, 9, 199, 199, 76, 311, 14, 1531, 480, 1065, 378, 876, 949, 2963, 9456, 531, 199, 199, 3, 625, 3349, 340, 3879, 315, 9861, 4799, 1611, 462, 199, 3, 1361, 298, 15019, 450, 68, 734, 402, 450, 68, 557, 1259, 965, 2, 450, 334, 278, 12, 78, 24463, 395, 634, 311, 199, 3, 647, 462, 14, 14450, 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, 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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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 ]
ingted/crmsh
contrib/setup.py
3
1050
#!/usr/bin/python from setuptools import setup setup(name='pygments-crmsh-lexers', version='0.0.5', description='Pygments crmsh custom lexers.', keywords='pygments crmsh lexer', license='BSD', author='Kristoffer Gronlund', author_email='kgronlund@suse.com', url='https://github.com/ClusterLabs/crmsh', packages=['pygments_crmsh_lexers'], install_requires=['pygments>=2.0.2'], entry_points='''[pygments.lexers] ANSIColorsLexer=pygments_crmsh_lexers:ANSIColorsLexer CrmshLexer=pygments_crmsh_lexers:CrmshLexer''', classifiers=[ 'Environment :: Plugins', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Software Development :: Libraries :: Python Modules', ],)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 504, 9116, 492, 3272, 199, 199, 2758, 8, 354, 534, 12173, 13, 15213, 609, 13, 12245, 297, 489, 1015, 534, 16, 14, 16, 14, 21, 297, 489, 1369, 534, 2713, 4664, 2467, 77, 609, 3537, 7103, 1192, 3130, 489, 7681, 534, 12173, 2467, 77, 609, 10426, 297, 489, 4190, 534, 15400, 297, 2541, 4132, 534, 43, 18824, 12786, 598, 2641, 76, 725, 297, 489, 4132, 63, 2123, 534, 75, 2587, 265, 76, 725, 32, 83, 1180, 14, 957, 297, 2541, 1166, 534, 2859, 921, 5031, 14, 957, 15, 9581, 44, 2101, 15, 15213, 609, 297, 2541, 6117, 2968, 12173, 63, 15213, 609, 63, 12245, 995, 489, 3907, 63, 6537, 2968, 12173, 8119, 18, 14, 16, 14, 18, 995, 2541, 2397, 63, 3438, 19938, 59, 12173, 14, 12245, 61, 1993, 32271, 948, 393, 1384, 5838, 29, 12173, 63, 15213, 609, 63, 12245, 26, 5622, 948, 393, 1384, 5838, 1993, 445, 5682, 609, 5838, 29, 12173, 63, 15213, 609, 63, 12245, 26, 35, 5682, 609, 5838, 18108, 2541, 19137, 1524, 881, 283, 8263, 3800, 30317, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 881, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 489, 2156, 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, 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, 199, 504, 9116, 492, 3272, 199, 199, 2758, 8, 354, 534, 12173, 13, 15213, 609, 13, 12245, 297, 489, 1015, 534, 16, 14, 16, 14, 21, 297, 489, 1369, 534, 2713, 4664, 2467, 77, 609, 3537, 7103, 1192, 3130, 489, 7681, 534, 12173, 2467, 77, 609, 10426, 297, 489, 4190, 534, 15400, 297, 2541, 4132, 534, 43, 18824, 12786, 598, 2641, 76, 725, 297, 489, 4132, 63, 2123, 534, 75, 2587, 265, 76, 725, 32, 83, 1180, 14, 957, 297, 2541, 1166, 534, 2859, 921, 5031, 14, 957, 15, 9581, 44, 2101, 15, 15213, 609, 297, 2541, 6117, 2968, 12173, 63, 15213, 609, 63, 12245, 995, 489, 3907, 63, 6537, 2968, 12173, 8119, 18, 14, 16, 14, 18, 995, 2541, 2397, 63, 3438, 19938, 59, 12173, 14, 12245, 61, 1993, 32271, 948, 393, 1384, 5838, 29, 12173, 63, 15213, 609, 63, 12245, 26, 5622, 948, 393, 1384, 5838, 1993, 445, 5682, 609, 5838, 29, 12173, 63, 15213, 609, 63, 12245, 26, 35, 5682, 609, 5838, 18108, 2541, 19137, 1524, 881, 283, 8263, 3800, 30317, 297, 881, 283, 23910, 23975, 3800, 23493, 297, 881, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 881, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 881, 283, 11411, 8466, 3800, 2018, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 881, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 881, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 489, 2156, 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, 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, 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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 ]
MadCat34/Sick-Beard
lib/hachoir_parser/archive/ace.py
90
9964
""" ACE parser From wotsit.org and the SDK header (bitflags) Partial study of a new block type (5) I've called "new_recovery", as its syntax is very close to the former one (of type 2). Status: can only read totally file and header blocks. Author: Christophe Gisquet <christophe.gisquet@free.fr> Creation date: 19 january 2006 """ from lib.hachoir_parser import Parser from lib.hachoir_core.field import (StaticFieldSet, FieldSet, Bit, Bits, NullBits, RawBytes, Enum, UInt8, UInt16, UInt32, PascalString8, PascalString16, String, TimeDateMSDOS32) from lib.hachoir_core.text_handler import textHandler, filesizeHandler, hexadecimal from lib.hachoir_core.endian import LITTLE_ENDIAN from lib.hachoir_parser.common.msdos import MSDOSFileAttr32 MAGIC = "**ACE**" OS_MSDOS = 0 OS_WIN32 = 2 HOST_OS = { 0: "MS-DOS", 1: "OS/2", 2: "Win32", 3: "Unix", 4: "MAC-OS", 5: "Win NT", 6: "Primos", 7: "APPLE GS", 8: "ATARI", 9: "VAX VMS", 10: "AMIGA", 11: "NEXT", } COMPRESSION_TYPE = { 0: "Store", 1: "Lempel-Ziv 77", 2: "ACE v2.0", } COMPRESSION_MODE = { 0: "fastest", 1: "fast", 2: "normal", 3: "good", 4: "best", } # TODO: Computing the CRC16 would also prove useful #def markerValidate(self): # return not self["extend"].value and self["signature"].value == MAGIC and \ # self["host_os"].value<12 class MarkerFlags(StaticFieldSet): format = ( (Bit, "extend", "Whether the header is extended"), (Bit, "has_comment", "Whether the archive has a comment"), (NullBits, "unused", 7, "Reserved bits"), (Bit, "sfx", "SFX"), (Bit, "limited_dict", "Junior SFX with 256K dictionary"), (Bit, "multi_volume", "Part of a set of ACE archives"), (Bit, "has_av_string", "This header holds an AV-string"), (Bit, "recovery_record", "Recovery record preset"), (Bit, "locked", "Archive is locked"), (Bit, "solid", "Archive uses solid compression") ) def markerFlags(self): yield MarkerFlags(self, "flags", "Marker flags") def markerHeader(self): yield String(self, "signature", 7, "Signature") yield UInt8(self, "ver_extract", "Version needed to extract archive") yield UInt8(self, "ver_created", "Version used to create archive") yield Enum(UInt8(self, "host_os", "OS where the files were compressed"), HOST_OS) yield UInt8(self, "vol_num", "Volume number") yield TimeDateMSDOS32(self, "time", "Date and time (MS DOS format)") yield Bits(self, "reserved", 64, "Reserved size for future extensions") flags = self["flags"] if flags["has_av_string"].value: yield PascalString8(self, "av_string", "AV String") if flags["has_comment"].value: size = filesizeHandler(UInt16(self, "comment_size", "Comment size")) yield size if size.value > 0: yield RawBytes(self, "compressed_comment", size.value, \ "Compressed comment") class FileFlags(StaticFieldSet): format = ( (Bit, "extend", "Whether the header is extended"), (Bit, "has_comment", "Presence of file comment"), (Bits, "unused", 10, "Unused bit flags"), (Bit, "encrypted", "File encrypted with password"), (Bit, "previous", "File continued from previous volume"), (Bit, "next", "File continues on the next volume"), (Bit, "solid", "File compressed using previously archived files") ) def fileFlags(self): yield FileFlags(self, "flags", "File flags") def fileHeader(self): yield filesizeHandler(UInt32(self, "compressed_size", "Size of the compressed file")) yield filesizeHandler(UInt32(self, "uncompressed_size", "Uncompressed file size")) yield TimeDateMSDOS32(self, "ftime", "Date and time (MS DOS format)") if self["/header/host_os"].value in (OS_MSDOS, OS_WIN32): yield MSDOSFileAttr32(self, "file_attr", "File attributes") else: yield textHandler(UInt32(self, "file_attr", "File attributes"), hexadecimal) yield textHandler(UInt32(self, "file_crc32", "CRC32 checksum over the compressed file)"), hexadecimal) yield Enum(UInt8(self, "compression_type", "Type of compression"), COMPRESSION_TYPE) yield Enum(UInt8(self, "compression_mode", "Quality of compression"), COMPRESSION_MODE) yield textHandler(UInt16(self, "parameters", "Compression parameters"), hexadecimal) yield textHandler(UInt16(self, "reserved", "Reserved data"), hexadecimal) # Filename yield PascalString16(self, "filename", "Filename") # Comment if self["flags/has_comment"].value: yield filesizeHandler(UInt16(self, "comment_size", "Size of the compressed comment")) if self["comment_size"].value > 0: yield RawBytes(self, "comment_data", self["comment_size"].value, "Comment data") def fileBody(self): size = self["compressed_size"].value if size > 0: yield RawBytes(self, "compressed_data", size, "Compressed data") def fileDesc(self): return "File entry: %s (%s)" % (self["filename"].value, self["compressed_size"].display) def recoveryHeader(self): yield filesizeHandler(UInt32(self, "rec_blk_size", "Size of recovery data")) self.body_size = self["rec_blk_size"].size yield String(self, "signature", 7, "Signature, normally '**ACE**'") yield textHandler(UInt32(self, "relative_start", "Relative start (to this block) of the data this block is mode of"), hexadecimal) yield UInt32(self, "num_blocks", "Number of blocks the data is split into") yield UInt32(self, "size_blocks", "Size of these blocks") yield UInt16(self, "crc16_blocks", "CRC16 over recovery data") # size_blocks blocks of size size_blocks follow # The ultimate data is the xor data of all those blocks size = self["size_blocks"].value for index in xrange(self["num_blocks"].value): yield RawBytes(self, "data[]", size, "Recovery block %i" % index) yield RawBytes(self, "xor_data", size, "The XOR value of the above data blocks") def recoveryDesc(self): return "Recovery block, size=%u" % self["body_size"].display def newRecoveryHeader(self): """ This header is described nowhere """ if self["flags/extend"].value: yield filesizeHandler(UInt32(self, "body_size", "Size of the unknown body following")) self.body_size = self["body_size"].value yield textHandler(UInt32(self, "unknown[]", "Unknown field, probably 0"), hexadecimal) yield String(self, "signature", 7, "Signature, normally '**ACE**'") yield textHandler(UInt32(self, "relative_start", "Offset (=crc16's) of this block in the file"), hexadecimal) yield textHandler(UInt32(self, "unknown[]", "Unknown field, probably 0"), hexadecimal) class BaseFlags(StaticFieldSet): format = ( (Bit, "extend", "Whether the header is extended"), (NullBits, "unused", 15, "Unused bit flags") ) def parseFlags(self): yield BaseFlags(self, "flags", "Unknown flags") def parseHeader(self): if self["flags/extend"].value: yield filesizeHandler(UInt32(self, "body_size", "Size of the unknown body following")) self.body_size = self["body_size"].value def parseBody(self): if self.body_size > 0: yield RawBytes(self, "body_data", self.body_size, "Body data, unhandled") class Block(FieldSet): TAG_INFO = { 0: ("header", "Archiver header", markerFlags, markerHeader, None), 1: ("file[]", fileDesc, fileFlags, fileHeader, fileBody), 2: ("recovery[]", recoveryDesc, recoveryHeader, None, None), 5: ("new_recovery[]", None, None, newRecoveryHeader, None) } def __init__(self, parent, name, description=None): FieldSet.__init__(self, parent, name, description) self.body_size = 0 self.desc_func = None type = self["block_type"].value if type in self.TAG_INFO: self._name, desc, self.parseFlags, self.parseHeader, self.parseBody = self.TAG_INFO[type] if desc: if isinstance(desc, str): self._description = desc else: self.desc_func = desc else: self.warning("Processing as unknown block block of type %u" % type) if not self.parseFlags: self.parseFlags = parseFlags if not self.parseHeader: self.parseHeader = parseHeader if not self.parseBody: self.parseBody = parseBody def createFields(self): yield textHandler(UInt16(self, "crc16", "Archive CRC16 (from byte 4 on)"), hexadecimal) yield filesizeHandler(UInt16(self, "head_size", "Block size (from byte 4 on)")) yield UInt8(self, "block_type", "Block type") # Flags for flag in self.parseFlags(self): yield flag # Rest of the header for field in self.parseHeader(self): yield field size = self["head_size"].value - (self.current_size//8) + (2+2) if size > 0: yield RawBytes(self, "extra_data", size, "Extra header data, unhandled") # Body in itself for field in self.parseBody(self): yield field def createDescription(self): if self.desc_func: return self.desc_func(self) else: return "Block: %s" % self["type"].display class AceFile(Parser): endian = LITTLE_ENDIAN PARSER_TAGS = { "id": "ace", "category": "archive", "file_ext": ("ace",), "mime": (u"application/x-ace-compressed",), "min_size": 50*8, "description": "ACE archive" } def validate(self): if self.stream.readBytes(7*8, len(MAGIC)) != MAGIC: return "Invalid magic" return True def createFields(self): while not self.eof: yield Block(self, "block[]")
gpl-3.0
[ 624, 199, 4121, 1798, 199, 199, 2532, 336, 357, 2221, 14, 1308, 436, 314, 15610, 1406, 334, 2075, 2469, 9, 199, 199, 18192, 25932, 402, 282, 892, 1853, 730, 334, 21, 9, 473, 9064, 2797, 298, 1222, 63, 29920, 401, 465, 2399, 199, 7093, 365, 7437, 4002, 370, 314, 26610, 1373, 334, 1618, 730, 499, 680, 199, 199, 3694, 26, 883, 1454, 1586, 12657, 1183, 570, 436, 1406, 5664, 14, 199, 5949, 26, 2799, 322, 2379, 426, 598, 374, 17917, 665, 335, 322, 2379, 426, 14, 5668, 17917, 32, 4624, 14, 4391, 30, 199, 13921, 1434, 26, 5851, 1335, 290, 20527, 8315, 199, 624, 199, 199, 504, 1973, 14, 72, 21301, 63, 2087, 492, 10191, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 698, 492, 334, 9278, 23532, 12, 5024, 1084, 12, 272, 10199, 12, 26612, 12, 12119, 10787, 12, 13480, 5571, 12, 11305, 12, 272, 10666, 24, 12, 10666, 975, 12, 10666, 708, 12, 272, 510, 305, 915, 1558, 24, 12, 510, 305, 915, 1558, 975, 12, 2624, 12, 272, 4703, 2506, 3053, 32735, 708, 9, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 505, 63, 2232, 492, 1318, 2461, 12, 23858, 2461, 12, 20379, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 199, 504, 1973, 14, 72, 21301, 63, 2087, 14, 2330, 14, 706, 18339, 492, 14282, 32735, 1173, 7144, 708, 199, 199, 19973, 275, 298, 538, 4121, 538, 2, 199, 199, 3100, 63, 3053, 32735, 275, 378, 199, 3100, 63, 7941, 708, 275, 499, 199, 5449, 63, 3100, 275, 469, 272, 378, 26, 298, 3053, 13, 32735, 401, 272, 413, 26, 298, 3100, 15, 18, 401, 272, 499, 26, 298, 8886, 708, 401, 272, 650, 26, 298, 21607, 401, 272, 841, 26, 298, 9410, 13, 3100, 401, 272, 959, 26, 298, 8886, 23350, 401, 272, 1227, 26, 298, 4562, 16908, 401, 272, 1520, 26, 298, 31683, 598, 51, 401, 272, 1695, 26, 298, 619, 689, 41, 401, 272, 1749, 26, 298, 54, 9839, 812, 3053, 401, 272, 1616, 26, 298, 1156, 1277, 33, 401, 272, 4119, 26, 298, 21917, 401, 199, 93, 199, 199, 30193, 63, 2711, 275, 469, 272, 378, 26, 298, 5502, 401, 272, 413, 26, 298, 44, 2109, 352, 13, 58, 1003, 8375, 401, 272, 499, 26, 298, 4121, 373, 18, 14, 16, 401, 199, 93, 199, 199, 30193, 63, 6963, 275, 469, 272, 378, 26, 298, 70, 32645, 401, 272, 413, 26, 298, 7015, 401, 272, 499, 26, 298, 3302, 401, 272, 650, 26, 298, 8302, 401, 272, 841, 26, 298, 7010, 401, 199, 93, 199, 199, 3, 3254, 26, 27799, 314, 26658, 975, 3955, 2597, 557, 432, 2997, 199, 3, 318, 3608, 12584, 8, 277, 304, 199, 3, 259, 372, 440, 291, 905, 2880, 4140, 585, 436, 291, 905, 5233, 4140, 585, 508, 23336, 436, 971, 199, 3, 3698, 291, 905, 1102, 63, 736, 4140, 585, 28, 713, 199, 199, 533, 26903, 6381, 8, 9278, 23532, 304, 272, 1475, 275, 334, 267, 334, 4734, 12, 298, 2880, 401, 298, 26625, 314, 1406, 365, 9243, 1288, 267, 334, 4734, 12, 298, 1989, 63, 3349, 401, 298, 26625, 314, 6359, 965, 282, 3721, 1288, 267, 334, 8849, 10787, 12, 298, 8618, 401, 1520, 12, 298, 10285, 5821, 1288, 267, 334, 4734, 12, 298, 7646, 88, 401, 298, 13107, 56, 1288, 267, 334, 4734, 12, 298, 14136, 63, 807, 401, 298, 42, 5411, 269, 428, 22322, 543, 7633, 43, 2600, 1288, 267, 334, 4734, 12, 298, 3029, 63, 2405, 401, 298, 8416, 402, 282, 663, 402, 437, 2089, 25993, 1288, 267, 334, 4734, 12, 298, 1989, 63, 1214, 63, 875, 401, 298, 2765, 1406, 15164, 376, 437, 54, 13, 875, 1288, 267, 334, 4734, 12, 298, 29920, 63, 3059, 401, 298, 497, 6913, 2777, 876, 409, 1288, 267, 334, 4734, 12, 298, 9325, 401, 298, 13042, 365, 14233, 1288, 267, 334, 4734, 12, 298, 18533, 401, 298, 13042, 4440, 18609, 10291, 531, 272, 776, 199, 199, 318, 3608, 6381, 8, 277, 304, 272, 1995, 26903, 6381, 8, 277, 12, 298, 2469, 401, 298, 12825, 3285, 531, 199, 199, 318, 3608, 2567, 8, 277, 304, 272, 1995, 2624, 8, 277, 12, 298, 5233, 401, 1520, 12, 298, 10014, 531, 272, 1995, 10666, 24, 8, 277, 12, 298, 422, 63, 5005, 401, 298, 3353, 4346, 370, 5536, 6359, 531, 272, 1995, 10666, 24, 8, 277, 12, 298, 422, 63, 3966, 401, 298, 3353, 1202, 370, 1218, 6359, 531, 272, 1995, 11305, 8, 13304, 24, 8, 277, 12, 298, 1102, 63, 736, 401, 298, 3100, 2382, 314, 1584, 4898, 12335, 1288, 25741, 63, 3100, 9, 272, 1995, 10666, 24, 8, 277, 12, 298, 5650, 63, 1507, 401, 298, 6464, 1329, 531, 272, 1995, 4703, 2506, 3053, 32735, 708, 8, 277, 12, 298, 521, 401, 298, 2506, 436, 900, 334, 3053, 577, 3100, 1475, 6320, 272, 1995, 26612, 8, 277, 12, 298, 10421, 401, 5049, 12, 298, 10285, 1568, 367, 6466, 5478, 531, 272, 3285, 275, 291, 905, 2469, 937, 272, 340, 3285, 905, 1989, 63, 1214, 63, 875, 4140, 585, 26, 267, 1995, 510, 305, 915, 1558, 24, 8, 277, 12, 298, 1214, 63, 875, 401, 298, 6087, 2624, 531, 272, 340, 3285, 905, 1989, 63, 3349, 4140, 585, 26, 267, 1568, 275, 23858, 2461, 8, 13304, 975, 8, 277, 12, 298, 3349, 63, 890, 401, 298, 7488, 1568, 2237, 267, 1995, 1568, 267, 340, 1568, 14, 585, 690, 378, 26, 288, 1995, 13480, 5571, 8, 277, 12, 298, 10895, 63, 3349, 401, 1568, 14, 585, 12, 971, 2574, 298, 25428, 3721, 531, 199, 199, 533, 3814, 6381, 8, 9278, 23532, 304, 272, 1475, 275, 334, 267, 334, 4734, 12, 298, 2880, 401, 298, 26625, 314, 1406, 365, 9243, 1288, 267, 334, 4734, 12, 298, 1989, 63, 3349, 401, 298, 2398, 14073, 402, 570, 3721, 1288, 267, 334, 10787, 12, 298, 8618, 401, 1616, 12, 298, 20782, 4546, 3285, 1288, 267, 334, 4734, 12, 298, 15078, 401, 298, 1173, 14862, 543, 2505, 1288, 267, 334, 4734, 12, 298, 6352, 401, 298, 1173, 32541, 687, 4136, 3301, 1288, 267, 334, 4734, 12, 298, 2184, 401, 298, 1173, 32438, 641, 314, 2163, 3301, 1288, 267 ]
[ 199, 4121, 1798, 199, 199, 2532, 336, 357, 2221, 14, 1308, 436, 314, 15610, 1406, 334, 2075, 2469, 9, 199, 199, 18192, 25932, 402, 282, 892, 1853, 730, 334, 21, 9, 473, 9064, 2797, 298, 1222, 63, 29920, 401, 465, 2399, 199, 7093, 365, 7437, 4002, 370, 314, 26610, 1373, 334, 1618, 730, 499, 680, 199, 199, 3694, 26, 883, 1454, 1586, 12657, 1183, 570, 436, 1406, 5664, 14, 199, 5949, 26, 2799, 322, 2379, 426, 598, 374, 17917, 665, 335, 322, 2379, 426, 14, 5668, 17917, 32, 4624, 14, 4391, 30, 199, 13921, 1434, 26, 5851, 1335, 290, 20527, 8315, 199, 624, 199, 199, 504, 1973, 14, 72, 21301, 63, 2087, 492, 10191, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 698, 492, 334, 9278, 23532, 12, 5024, 1084, 12, 272, 10199, 12, 26612, 12, 12119, 10787, 12, 13480, 5571, 12, 11305, 12, 272, 10666, 24, 12, 10666, 975, 12, 10666, 708, 12, 272, 510, 305, 915, 1558, 24, 12, 510, 305, 915, 1558, 975, 12, 2624, 12, 272, 4703, 2506, 3053, 32735, 708, 9, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 505, 63, 2232, 492, 1318, 2461, 12, 23858, 2461, 12, 20379, 199, 504, 1973, 14, 72, 21301, 63, 1018, 14, 15009, 492, 491, 31783, 63, 21046, 199, 504, 1973, 14, 72, 21301, 63, 2087, 14, 2330, 14, 706, 18339, 492, 14282, 32735, 1173, 7144, 708, 199, 199, 19973, 275, 298, 538, 4121, 538, 2, 199, 199, 3100, 63, 3053, 32735, 275, 378, 199, 3100, 63, 7941, 708, 275, 499, 199, 5449, 63, 3100, 275, 469, 272, 378, 26, 298, 3053, 13, 32735, 401, 272, 413, 26, 298, 3100, 15, 18, 401, 272, 499, 26, 298, 8886, 708, 401, 272, 650, 26, 298, 21607, 401, 272, 841, 26, 298, 9410, 13, 3100, 401, 272, 959, 26, 298, 8886, 23350, 401, 272, 1227, 26, 298, 4562, 16908, 401, 272, 1520, 26, 298, 31683, 598, 51, 401, 272, 1695, 26, 298, 619, 689, 41, 401, 272, 1749, 26, 298, 54, 9839, 812, 3053, 401, 272, 1616, 26, 298, 1156, 1277, 33, 401, 272, 4119, 26, 298, 21917, 401, 199, 93, 199, 199, 30193, 63, 2711, 275, 469, 272, 378, 26, 298, 5502, 401, 272, 413, 26, 298, 44, 2109, 352, 13, 58, 1003, 8375, 401, 272, 499, 26, 298, 4121, 373, 18, 14, 16, 401, 199, 93, 199, 199, 30193, 63, 6963, 275, 469, 272, 378, 26, 298, 70, 32645, 401, 272, 413, 26, 298, 7015, 401, 272, 499, 26, 298, 3302, 401, 272, 650, 26, 298, 8302, 401, 272, 841, 26, 298, 7010, 401, 199, 93, 199, 199, 3, 3254, 26, 27799, 314, 26658, 975, 3955, 2597, 557, 432, 2997, 199, 3, 318, 3608, 12584, 8, 277, 304, 199, 3, 259, 372, 440, 291, 905, 2880, 4140, 585, 436, 291, 905, 5233, 4140, 585, 508, 23336, 436, 971, 199, 3, 3698, 291, 905, 1102, 63, 736, 4140, 585, 28, 713, 199, 199, 533, 26903, 6381, 8, 9278, 23532, 304, 272, 1475, 275, 334, 267, 334, 4734, 12, 298, 2880, 401, 298, 26625, 314, 1406, 365, 9243, 1288, 267, 334, 4734, 12, 298, 1989, 63, 3349, 401, 298, 26625, 314, 6359, 965, 282, 3721, 1288, 267, 334, 8849, 10787, 12, 298, 8618, 401, 1520, 12, 298, 10285, 5821, 1288, 267, 334, 4734, 12, 298, 7646, 88, 401, 298, 13107, 56, 1288, 267, 334, 4734, 12, 298, 14136, 63, 807, 401, 298, 42, 5411, 269, 428, 22322, 543, 7633, 43, 2600, 1288, 267, 334, 4734, 12, 298, 3029, 63, 2405, 401, 298, 8416, 402, 282, 663, 402, 437, 2089, 25993, 1288, 267, 334, 4734, 12, 298, 1989, 63, 1214, 63, 875, 401, 298, 2765, 1406, 15164, 376, 437, 54, 13, 875, 1288, 267, 334, 4734, 12, 298, 29920, 63, 3059, 401, 298, 497, 6913, 2777, 876, 409, 1288, 267, 334, 4734, 12, 298, 9325, 401, 298, 13042, 365, 14233, 1288, 267, 334, 4734, 12, 298, 18533, 401, 298, 13042, 4440, 18609, 10291, 531, 272, 776, 199, 199, 318, 3608, 6381, 8, 277, 304, 272, 1995, 26903, 6381, 8, 277, 12, 298, 2469, 401, 298, 12825, 3285, 531, 199, 199, 318, 3608, 2567, 8, 277, 304, 272, 1995, 2624, 8, 277, 12, 298, 5233, 401, 1520, 12, 298, 10014, 531, 272, 1995, 10666, 24, 8, 277, 12, 298, 422, 63, 5005, 401, 298, 3353, 4346, 370, 5536, 6359, 531, 272, 1995, 10666, 24, 8, 277, 12, 298, 422, 63, 3966, 401, 298, 3353, 1202, 370, 1218, 6359, 531, 272, 1995, 11305, 8, 13304, 24, 8, 277, 12, 298, 1102, 63, 736, 401, 298, 3100, 2382, 314, 1584, 4898, 12335, 1288, 25741, 63, 3100, 9, 272, 1995, 10666, 24, 8, 277, 12, 298, 5650, 63, 1507, 401, 298, 6464, 1329, 531, 272, 1995, 4703, 2506, 3053, 32735, 708, 8, 277, 12, 298, 521, 401, 298, 2506, 436, 900, 334, 3053, 577, 3100, 1475, 6320, 272, 1995, 26612, 8, 277, 12, 298, 10421, 401, 5049, 12, 298, 10285, 1568, 367, 6466, 5478, 531, 272, 3285, 275, 291, 905, 2469, 937, 272, 340, 3285, 905, 1989, 63, 1214, 63, 875, 4140, 585, 26, 267, 1995, 510, 305, 915, 1558, 24, 8, 277, 12, 298, 1214, 63, 875, 401, 298, 6087, 2624, 531, 272, 340, 3285, 905, 1989, 63, 3349, 4140, 585, 26, 267, 1568, 275, 23858, 2461, 8, 13304, 975, 8, 277, 12, 298, 3349, 63, 890, 401, 298, 7488, 1568, 2237, 267, 1995, 1568, 267, 340, 1568, 14, 585, 690, 378, 26, 288, 1995, 13480, 5571, 8, 277, 12, 298, 10895, 63, 3349, 401, 1568, 14, 585, 12, 971, 2574, 298, 25428, 3721, 531, 199, 199, 533, 3814, 6381, 8, 9278, 23532, 304, 272, 1475, 275, 334, 267, 334, 4734, 12, 298, 2880, 401, 298, 26625, 314, 1406, 365, 9243, 1288, 267, 334, 4734, 12, 298, 1989, 63, 3349, 401, 298, 2398, 14073, 402, 570, 3721, 1288, 267, 334, 10787, 12, 298, 8618, 401, 1616, 12, 298, 20782, 4546, 3285, 1288, 267, 334, 4734, 12, 298, 15078, 401, 298, 1173, 14862, 543, 2505, 1288, 267, 334, 4734, 12, 298, 6352, 401, 298, 1173, 32541, 687, 4136, 3301, 1288, 267, 334, 4734, 12, 298, 2184, 401, 298, 1173, 32438, 641, 314, 2163, 3301, 1288, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
utecuy/edx-platform
lms/djangoapps/ccx/tests/test_field_override_performance.py
44
9734
# coding=UTF-8 """ Performance tests for field overrides. """ import ddt import itertools import mock from nose.plugins.skip import SkipTest from courseware.views import progress # pylint: disable=import-error from courseware.field_overrides import OverrideFieldData from datetime import datetime from django.conf import settings from django.core.cache import get_cache from django.test.client import RequestFactory from django.test.utils import override_settings from edxmako.middleware import MakoMiddleware # pylint: disable=import-error from nose.plugins.attrib import attr from pytz import UTC from request_cache.middleware import RequestCache from student.models import CourseEnrollment from student.tests.factories import UserFactory # pylint: disable=import-error from xblock.core import XBlock from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, \ TEST_DATA_SPLIT_MODULESTORE, TEST_DATA_MONGO_MODULESTORE from xmodule.modulestore.tests.factories import check_mongo_calls_range, CourseFactory, check_sum_of_calls from xmodule.modulestore.tests.utils import ProceduralCourseTestMixin from ccx_keys.locator import CCXLocator from ccx.tests.factories import CcxFactory @attr('shard_1') @mock.patch.dict( 'django.conf.settings.FEATURES', { 'ENABLE_XBLOCK_VIEW_ENDPOINT': True, 'ENABLE_MAX_SCORE_CACHE': False, } ) @ddt.ddt class FieldOverridePerformanceTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase): """ Base class for instrumenting SQL queries and Mongo reads for field override providers. """ __test__ = False # TEST_DATA must be overridden by subclasses TEST_DATA = None def setUp(self): """ Create a test client, course, and user. """ super(FieldOverridePerformanceTestCase, self).setUp() self.request_factory = RequestFactory() self.student = UserFactory.create() self.request = self.request_factory.get("foo") self.request.user = self.student self.course = None self.ccx = None MakoMiddleware().process_request(self.request) def setup_course(self, size, enable_ccx, view_as_ccx): """ Build a gradable course where each node has `size` children. """ grading_policy = { "GRADER": [ { "drop_count": 2, "min_count": 12, "short_label": "HW", "type": "Homework", "weight": 0.15 }, { "drop_count": 2, "min_count": 12, "type": "Lab", "weight": 0.15 }, { "drop_count": 0, "min_count": 1, "short_label": "Midterm", "type": "Midterm Exam", "weight": 0.3 }, { "drop_count": 0, "min_count": 1, "short_label": "Final", "type": "Final Exam", "weight": 0.4 } ], "GRADE_CUTOFFS": { "Pass": 0.5 } } self.course = CourseFactory.create( graded=True, start=datetime.now(UTC), grading_policy=grading_policy, enable_ccx=enable_ccx, ) self.populate_course(size) course_key = self.course.id if enable_ccx: self.ccx = CcxFactory.create(course_id=self.course.id) if view_as_ccx: course_key = CCXLocator.from_course_locator(self.course.id, self.ccx.id) CourseEnrollment.enroll( self.student, course_key ) def grade_course(self, course, view_as_ccx): """ Renders the progress page for the given course. """ course_key = course.id if view_as_ccx: course_key = CCXLocator.from_course_locator(course_key, self.ccx.id) return progress( self.request, course_id=unicode(course_key), student_id=self.student.id ) def assertMongoCallCount(self, calls): """ Assert that mongodb is queried ``calls`` times in the surrounded context. """ return check_mongo_calls_range(max_finds=calls) def assertXBlockInstantiations(self, instantiations): """ Assert that exactly ``instantiations`` XBlocks are instantiated in the surrounded context. """ return check_sum_of_calls(XBlock, ['__init__'], instantiations, instantiations, include_arguments=False) def instrument_course_progress_render(self, course_width, enable_ccx, view_as_ccx, queries, reads, xblocks): """ Renders the progress page, instrumenting Mongo reads and SQL queries. """ self.setup_course(course_width, enable_ccx, view_as_ccx) # Switch to published-only mode to simulate the LMS with self.settings(MODULESTORE_BRANCH='published-only'): # Clear all caches before measuring for cache in settings.CACHES: get_cache(cache).clear() # Refill the metadata inheritance cache modulestore().get_course(self.course.id, depth=None) # We clear the request cache to simulate a new request in the LMS. RequestCache.clear_request_cache() # Reset the list of provider classes, so that our django settings changes # can actually take affect. OverrideFieldData.provider_classes = None with self.assertNumQueries(queries): with self.assertMongoCallCount(reads): with self.assertXBlockInstantiations(xblocks): self.grade_course(self.course, view_as_ccx) @ddt.data(*itertools.product(('no_overrides', 'ccx'), range(1, 4), (True, False), (True, False))) @ddt.unpack @override_settings( FIELD_OVERRIDE_PROVIDERS=(), ) def test_field_overrides(self, overrides, course_width, enable_ccx, view_as_ccx): """ Test without any field overrides. """ providers = { 'no_overrides': (), 'ccx': ('ccx.overrides.CustomCoursesForEdxOverrideProvider',) } if overrides == 'no_overrides' and view_as_ccx: raise SkipTest("Can't view a ccx course if field overrides are disabled.") if not enable_ccx and view_as_ccx: raise SkipTest("Can't view a ccx course if ccx is disabled on the course") if self.MODULESTORE == TEST_DATA_MONGO_MODULESTORE and view_as_ccx: raise SkipTest("Can't use a MongoModulestore test as a CCX course") with self.settings(FIELD_OVERRIDE_PROVIDERS=providers[overrides]): queries, reads, xblocks = self.TEST_DATA[(overrides, course_width, enable_ccx, view_as_ccx)] self.instrument_course_progress_render(course_width, enable_ccx, view_as_ccx, queries, reads, xblocks) class TestFieldOverrideMongoPerformance(FieldOverridePerformanceTestCase): """ Test cases for instrumenting field overrides against the Mongo modulestore. """ MODULESTORE = TEST_DATA_MONGO_MODULESTORE __test__ = True TEST_DATA = { # (providers, course_width, enable_ccx, view_as_ccx): # of sql queries, # of mongo queries, # of xblocks ('no_overrides', 1, True, False): (24, 6, 13), ('no_overrides', 2, True, False): (69, 6, 84), ('no_overrides', 3, True, False): (264, 6, 335), ('ccx', 1, True, False): (24, 6, 13), ('ccx', 2, True, False): (69, 6, 84), ('ccx', 3, True, False): (264, 6, 335), ('ccx', 1, True, True): (24, 6, 13), ('ccx', 2, True, True): (69, 6, 84), ('ccx', 3, True, True): (264, 6, 335), ('no_overrides', 1, False, False): (24, 6, 13), ('no_overrides', 2, False, False): (69, 6, 84), ('no_overrides', 3, False, False): (264, 6, 335), ('ccx', 1, False, False): (24, 6, 13), ('ccx', 2, False, False): (69, 6, 84), ('ccx', 3, False, False): (264, 6, 335), ('ccx', 1, False, True): (24, 6, 13), ('ccx', 2, False, True): (69, 6, 84), ('ccx', 3, False, True): (264, 6, 335), } class TestFieldOverrideSplitPerformance(FieldOverridePerformanceTestCase): """ Test cases for instrumenting field overrides against the Split modulestore. """ MODULESTORE = TEST_DATA_SPLIT_MODULESTORE __test__ = True TEST_DATA = { ('no_overrides', 1, True, False): (24, 4, 9), ('no_overrides', 2, True, False): (69, 19, 54), ('no_overrides', 3, True, False): (264, 84, 215), ('ccx', 1, True, False): (24, 4, 9), ('ccx', 2, True, False): (69, 19, 54), ('ccx', 3, True, False): (264, 84, 215), ('ccx', 1, True, True): (26, 4, 13), ('ccx', 2, True, True): (71, 19, 84), ('ccx', 3, True, True): (266, 84, 335), ('no_overrides', 1, False, False): (24, 4, 9), ('no_overrides', 2, False, False): (69, 19, 54), ('no_overrides', 3, False, False): (264, 84, 215), ('ccx', 1, False, False): (24, 4, 9), ('ccx', 2, False, False): (69, 19, 54), ('ccx', 3, False, False): (264, 84, 215), ('ccx', 1, False, True): (24, 4, 9), ('ccx', 2, False, True): (69, 19, 54), ('ccx', 3, False, True): (264, 84, 215), }
agpl-3.0
[ 3, 2803, 29, 6610, 13, 24, 199, 624, 199, 25635, 2295, 367, 901, 10580, 14, 199, 624, 199, 646, 366, 3583, 199, 646, 7975, 199, 646, 1683, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 199, 504, 20736, 14, 4196, 492, 6696, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 20736, 14, 698, 63, 12867, 492, 11041, 792, 1451, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 22435, 19491, 14, 5754, 492, 603, 23564, 6608, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 504, 15444, 492, 12174, 199, 504, 1056, 63, 1637, 14, 5754, 492, 4784, 4437, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 17996, 1746, 12, 971, 272, 7393, 63, 3998, 63, 30538, 63, 27011, 12, 7393, 63, 3998, 63, 45, 26477, 63, 27011, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 1104, 63, 9217, 63, 5352, 63, 1842, 12, 17862, 12, 1104, 63, 1838, 63, 1618, 63, 5352, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1208, 492, 2165, 6867, 4889, 6979, 22060, 199, 504, 7429, 88, 63, 1612, 14, 6354, 492, 17586, 56, 10725, 199, 504, 7429, 88, 14, 2219, 14, 15406, 492, 445, 11859, 2927, 421, 199, 32, 962, 360, 10810, 63, 17, 358, 199, 32, 1805, 14, 2068, 14, 807, 8, 272, 283, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 272, 469, 267, 283, 8898, 63, 56, 8475, 63, 12058, 63, 21054, 356, 715, 12, 267, 283, 8898, 63, 4283, 63, 5153, 5788, 63, 8677, 356, 756, 12, 272, 789, 199, 9, 199, 32, 11138, 14, 11138, 199, 533, 5024, 11954, 25635, 1746, 8, 919, 6867, 4889, 6979, 22060, 12, 4318, 17996, 1746, 304, 272, 408, 272, 3523, 1021, 367, 14498, 316, 5385, 9212, 436, 13503, 11597, 367, 901, 4278, 272, 18032, 14, 272, 408, 272, 636, 396, 363, 275, 756, 339, 327, 7393, 63, 3998, 1471, 506, 10087, 701, 9180, 272, 7393, 63, 3998, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 511, 1890, 12, 2518, 12, 436, 922, 14, 267, 408, 267, 1613, 8, 792, 11954, 25635, 1746, 12, 291, 680, 5996, 342, 398, 291, 14, 1069, 63, 3702, 275, 18638, 342, 267, 291, 14, 5500, 275, 16047, 14, 981, 342, 267, 291, 14, 1069, 275, 291, 14, 1069, 63, 3702, 14, 362, 480, 1421, 531, 267, 291, 14, 1069, 14, 751, 275, 291, 14, 5500, 267, 291, 14, 1972, 275, 488, 267, 291, 14, 19541, 275, 488, 398, 603, 23564, 6608, 1252, 1412, 63, 1069, 8, 277, 14, 1069, 9, 339, 347, 3272, 63, 1972, 8, 277, 12, 1568, 12, 4756, 63, 19541, 12, 2455, 63, 305, 63, 19541, 304, 267, 408, 267, 6516, 282, 7659, 461, 2518, 2382, 1924, 1031, 965, 658, 890, 64, 4978, 14, 267, 408, 267, 22815, 63, 3185, 275, 469, 288, 298, 3975, 21372, 582, 359, 355, 469, 490, 298, 4824, 63, 835, 582, 499, 12, 490, 298, 827, 63, 835, 582, 3144, 12, 490, 298, 3612, 63, 1302, 582, 298, 15487, 401, 490, 298, 466, 582, 298, 12054, 800, 401, 490, 298, 3463, 582, 378, 14, 1046, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 499, 12, 490, 298, 827, 63, 835, 582, 3144, 12, 490, 298, 466, 582, 298, 22511, 401, 490, 298, 3463, 582, 378, 14, 1046, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 378, 12, 490, 298, 827, 63, 835, 582, 413, 12, 490, 298, 3612, 63, 1302, 582, 298, 28735, 5125, 401, 490, 298, 466, 582, 298, 28735, 5125, 1316, 455, 401, 490, 298, 3463, 582, 378, 14, 19, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 378, 12, 490, 298, 827, 63, 835, 582, 413, 12, 490, 298, 3612, 63, 1302, 582, 298, 12776, 401, 490, 298, 466, 582, 298, 12776, 1316, 455, 401, 490, 298, 3463, 582, 378, 14, 20, 355, 789, 288, 2156, 288, 298, 28594, 63, 24678, 7517, 51, 582, 469, 355, 298, 4986, 582, 378, 14, 21, 288, 789, 267, 789, 398, 291, 14, 1972, 275, 17862, 14, 981, 8, 288, 1999, 770, 29, 549, 12, 288, 1343, 29, 2083, 14, 2131, 8, 11288, 395, 288, 22815, 63, 3185, 29, 16050, 63, 3185, 12, 288, 4756, 63, 19541, 29, 4296, 63, 19541, 12, 267, 776, 267, 291, 14, 13817, 63, 1972, 8, 890, 9, 398, 2518, 63, 498, 275, 291, 14, 1972, 14, 344, 267, 340, 4756, 63, 19541, 26, 288, 291, 14, 19541, 275, 445, 11859, 2927, 14, 981, 8, 1972, 63, 344, 29, 277, 14, 1972, 14, 344, 9, 288, 340, 2455, 63, 305, 63, 19541, 26, 355, 2518, 63, 498, 275, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 277, 14, 1972, 14, 344, 12, 291, 14, 19541, 14, 344, 9, 398, 18946, 14, 14695, 8, 288, 291, 14, 5500, 12, 288, 2518, 63, 498, 267, 776, 339, 347, 16183, 63, 1972, 8, 277, 12, 2518, 12, 2455, 63, 305, 63, 19541, 304, 267, 408, 267, 10055, 7735, 314, 6696, 2034, 367, 314, 1627, 2518, 14, 267, 408, 267, 2518, 63, 498, 275, 2518, 14, 344, 267, 340, 2455, 63, 305, 63, 19541, 26, 288, 2518, 63, 498, 275, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 1972, 63, 498, 12, 291, 14, 19541, 14, 344, 9, 398, 372, 6696, 8, 288, 291, 14, 1069, 12, 288, 2518, 63, 344, 29, 2975, 8, 1972, 63, 498, 395, 288, 6474, 63, 344, 29, 277, 14, 5500, 14, 344, 267, 776, 339, 347, 702, 20393, 2176, 2353, 8, 277, 12, 4882, 304, 267, 408, 267, 10716, 626, 32315, 13152, 365, 30081, 1124 ]
[ 2803, 29, 6610, 13, 24, 199, 624, 199, 25635, 2295, 367, 901, 10580, 14, 199, 624, 199, 646, 366, 3583, 199, 646, 7975, 199, 646, 1683, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 199, 504, 20736, 14, 4196, 492, 6696, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 20736, 14, 698, 63, 12867, 492, 11041, 792, 1451, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 22435, 19491, 14, 5754, 492, 603, 23564, 6608, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 504, 15444, 492, 12174, 199, 504, 1056, 63, 1637, 14, 5754, 492, 4784, 4437, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 221, 327, 4287, 26, 3507, 29, 646, 13, 705, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 17996, 1746, 12, 971, 272, 7393, 63, 3998, 63, 30538, 63, 27011, 12, 7393, 63, 3998, 63, 45, 26477, 63, 27011, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 1104, 63, 9217, 63, 5352, 63, 1842, 12, 17862, 12, 1104, 63, 1838, 63, 1618, 63, 5352, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1208, 492, 2165, 6867, 4889, 6979, 22060, 199, 504, 7429, 88, 63, 1612, 14, 6354, 492, 17586, 56, 10725, 199, 504, 7429, 88, 14, 2219, 14, 15406, 492, 445, 11859, 2927, 421, 199, 32, 962, 360, 10810, 63, 17, 358, 199, 32, 1805, 14, 2068, 14, 807, 8, 272, 283, 1176, 14, 2190, 14, 1751, 14, 13313, 297, 272, 469, 267, 283, 8898, 63, 56, 8475, 63, 12058, 63, 21054, 356, 715, 12, 267, 283, 8898, 63, 4283, 63, 5153, 5788, 63, 8677, 356, 756, 12, 272, 789, 199, 9, 199, 32, 11138, 14, 11138, 199, 533, 5024, 11954, 25635, 1746, 8, 919, 6867, 4889, 6979, 22060, 12, 4318, 17996, 1746, 304, 272, 408, 272, 3523, 1021, 367, 14498, 316, 5385, 9212, 436, 13503, 11597, 367, 901, 4278, 272, 18032, 14, 272, 408, 272, 636, 396, 363, 275, 756, 339, 327, 7393, 63, 3998, 1471, 506, 10087, 701, 9180, 272, 7393, 63, 3998, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 511, 1890, 12, 2518, 12, 436, 922, 14, 267, 408, 267, 1613, 8, 792, 11954, 25635, 1746, 12, 291, 680, 5996, 342, 398, 291, 14, 1069, 63, 3702, 275, 18638, 342, 267, 291, 14, 5500, 275, 16047, 14, 981, 342, 267, 291, 14, 1069, 275, 291, 14, 1069, 63, 3702, 14, 362, 480, 1421, 531, 267, 291, 14, 1069, 14, 751, 275, 291, 14, 5500, 267, 291, 14, 1972, 275, 488, 267, 291, 14, 19541, 275, 488, 398, 603, 23564, 6608, 1252, 1412, 63, 1069, 8, 277, 14, 1069, 9, 339, 347, 3272, 63, 1972, 8, 277, 12, 1568, 12, 4756, 63, 19541, 12, 2455, 63, 305, 63, 19541, 304, 267, 408, 267, 6516, 282, 7659, 461, 2518, 2382, 1924, 1031, 965, 658, 890, 64, 4978, 14, 267, 408, 267, 22815, 63, 3185, 275, 469, 288, 298, 3975, 21372, 582, 359, 355, 469, 490, 298, 4824, 63, 835, 582, 499, 12, 490, 298, 827, 63, 835, 582, 3144, 12, 490, 298, 3612, 63, 1302, 582, 298, 15487, 401, 490, 298, 466, 582, 298, 12054, 800, 401, 490, 298, 3463, 582, 378, 14, 1046, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 499, 12, 490, 298, 827, 63, 835, 582, 3144, 12, 490, 298, 466, 582, 298, 22511, 401, 490, 298, 3463, 582, 378, 14, 1046, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 378, 12, 490, 298, 827, 63, 835, 582, 413, 12, 490, 298, 3612, 63, 1302, 582, 298, 28735, 5125, 401, 490, 298, 466, 582, 298, 28735, 5125, 1316, 455, 401, 490, 298, 3463, 582, 378, 14, 19, 355, 1660, 355, 469, 490, 298, 4824, 63, 835, 582, 378, 12, 490, 298, 827, 63, 835, 582, 413, 12, 490, 298, 3612, 63, 1302, 582, 298, 12776, 401, 490, 298, 466, 582, 298, 12776, 1316, 455, 401, 490, 298, 3463, 582, 378, 14, 20, 355, 789, 288, 2156, 288, 298, 28594, 63, 24678, 7517, 51, 582, 469, 355, 298, 4986, 582, 378, 14, 21, 288, 789, 267, 789, 398, 291, 14, 1972, 275, 17862, 14, 981, 8, 288, 1999, 770, 29, 549, 12, 288, 1343, 29, 2083, 14, 2131, 8, 11288, 395, 288, 22815, 63, 3185, 29, 16050, 63, 3185, 12, 288, 4756, 63, 19541, 29, 4296, 63, 19541, 12, 267, 776, 267, 291, 14, 13817, 63, 1972, 8, 890, 9, 398, 2518, 63, 498, 275, 291, 14, 1972, 14, 344, 267, 340, 4756, 63, 19541, 26, 288, 291, 14, 19541, 275, 445, 11859, 2927, 14, 981, 8, 1972, 63, 344, 29, 277, 14, 1972, 14, 344, 9, 288, 340, 2455, 63, 305, 63, 19541, 26, 355, 2518, 63, 498, 275, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 277, 14, 1972, 14, 344, 12, 291, 14, 19541, 14, 344, 9, 398, 18946, 14, 14695, 8, 288, 291, 14, 5500, 12, 288, 2518, 63, 498, 267, 776, 339, 347, 16183, 63, 1972, 8, 277, 12, 2518, 12, 2455, 63, 305, 63, 19541, 304, 267, 408, 267, 10055, 7735, 314, 6696, 2034, 367, 314, 1627, 2518, 14, 267, 408, 267, 2518, 63, 498, 275, 2518, 14, 344, 267, 340, 2455, 63, 305, 63, 19541, 26, 288, 2518, 63, 498, 275, 17586, 56, 10725, 14, 504, 63, 1972, 63, 6354, 8, 1972, 63, 498, 12, 291, 14, 19541, 14, 344, 9, 398, 372, 6696, 8, 288, 291, 14, 1069, 12, 288, 2518, 63, 344, 29, 2975, 8, 1972, 63, 498, 395, 288, 6474, 63, 344, 29, 277, 14, 5500, 14, 344, 267, 776, 339, 347, 702, 20393, 2176, 2353, 8, 277, 12, 4882, 304, 267, 408, 267, 10716, 626, 32315, 13152, 365, 30081, 1124, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
juergh/dwarf
tests/clients/test_nova.py
2
4430
#!/usr/bin/env python # # Copyright (c) 2017 Hewlett Packard Enterprise, L.P. # Copyright (c) 2013 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. import libvirt import os import time from tests import data from tests import utils def verify_private_key(stdout): line = [l for l in stdout.split('\n') if l != ''] if ((line[0] == '-----BEGIN PRIVATE KEY-----' and line[-1] == '-----END PRIVATE KEY-----')): return stdout return '' def cwd(filename): return os.path.join(os.path.dirname(__file__), 'data', filename) server1 = data.server['11111111-2222-3333-4444-555555555555'] server1_image = data.image[server1['image_id']] class DwarfTestCase(utils.TestCase): def setUp(self): super(DwarfTestCase, self).setUp() self.start_dwarf() def tearDown(self): self.stop_dwarf() super(DwarfTestCase, self).tearDown() def test_nova_flavors(self): self.exec_verify(['nova', 'flavor-list'], filename=cwd('nova_flavor-list')) self.exec_verify(['nova', 'flavor-show', '100'], filename=cwd('nova_flavor-show')) self.exec_verify(['nova', 'flavor-delete', '100'], filename=cwd('nova_flavor-delete')) self.exec_verify(['nova', 'flavor-create', 'test.flavor', '999', '1024', '15', '2'], filename=cwd('nova_flavor-create')) def test_nova_keypairs(self): self.exec_verify(['nova', 'keypair-add', 'test key', '--pub-key', cwd('nova_keypair-add.pub')], stdout='') self.exec_verify(['nova', 'keypair-list'], filename=cwd('nova_keypair-list')) self.exec_verify(['nova', 'keypair-show', 'test key'], filename=cwd('nova_keypair-show')) self.exec_verify(['nova', 'keypair-delete', 'test key'], stdout='') self.exec_verify(['nova', 'keypair-add', 'test key'], callback=verify_private_key) def test_nova_servers(self): # Preload an image self.create_image(server1_image) self.exec_verify(['nova', 'boot', '--flavor', server1['flavor_id'], '--image', server1['image_id'], server1['name']], filename=cwd('nova_boot')) self.exec_verify(['nova', 'list'], filename=cwd('nova_list.building')) libvirt.DOMAIN_STATE = libvirt.VIR_DOMAIN_RUNNING libvirt.IP_ADDRESS = server1['ip'] time.sleep(3) # Should show the IP and status 'active' self.exec_verify(['nova', 'list'], filename=cwd('nova_list')) self.exec_verify(['nova', 'show', server1['id']], filename=cwd('nova_show')) self.exec_verify(['nova', 'console-log', server1['id']], stdout='Test server console log\n') self.exec_verify(['nova', 'stop', server1['id']], stdout='Request to stop server %s has been ' 'accepted.\n' % server1['id']) # Should show status 'stopped' self.exec_verify(['nova', 'show', server1['id']], filename=cwd('nova_show.stopped')) self.exec_verify(['nova', 'start', server1['id']], stdout='Request to start server %s has been ' 'accepted.\n' % server1['id']) # Should show status 'active' self.exec_verify(['nova', 'show', server1['id']], filename=cwd('nova_show')) self.exec_verify(['nova', 'reboot', server1['id']], stdout='Request to reboot server <Server: %s> has ' 'been accepted.\n' % server1['name'])
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 27849, 9954, 1005, 29949, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 13108, 199, 646, 747, 199, 646, 900, 199, 199, 504, 2295, 492, 666, 199, 504, 2295, 492, 3778, 421, 199, 318, 4911, 63, 4239, 63, 498, 8, 2703, 304, 272, 1004, 275, 359, 76, 367, 634, 315, 3839, 14, 1294, 2258, 78, 358, 340, 634, 1137, 28696, 272, 340, 3666, 604, 59, 16, 61, 508, 283, 9858, 15947, 28644, 1951, 9301, 9858, 7, 436, 268, 1004, 1988, 17, 61, 508, 283, 9858, 3902, 28644, 1951, 9301, 9858, 8109, 267, 372, 3839, 272, 372, 2125, 421, 199, 318, 8288, 8, 1501, 304, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 297, 1788, 9, 421, 199, 1000, 17, 275, 666, 14, 1000, 459, 14757, 13, 9993, 13, 6772, 13, 22872, 13, 19161, 19161, 19161, 418, 199, 1000, 17, 63, 1569, 275, 666, 14, 1569, 59, 1000, 17, 459, 1569, 63, 344, 6538, 421, 199, 533, 577, 3281, 70, 1746, 8, 1208, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 36, 3281, 70, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 928, 63, 68, 3281, 70, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2379, 63, 68, 3281, 70, 342, 267, 1613, 8, 36, 3281, 70, 1746, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 6765, 63, 18664, 8, 277, 304, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 2384, 297, 283, 1960, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 1807, 297, 283, 1960, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 1807, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 981, 297, 283, 396, 14, 6081, 297, 283, 5637, 297, 2079, 283, 7727, 297, 283, 1046, 297, 283, 18, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 981, 1333, 339, 347, 511, 63, 6765, 63, 30825, 8, 277, 304, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 525, 297, 283, 396, 790, 297, 2850, 5645, 13, 498, 297, 2079, 8288, 360, 6765, 63, 19263, 13, 525, 14, 5645, 2665, 586, 3839, 13275, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 19263, 13, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 2384, 297, 283, 396, 790, 995, 586, 1788, 29, 6525, 360, 6765, 63, 19263, 13, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 1807, 297, 283, 396, 790, 995, 586, 3839, 13275, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 525, 297, 283, 396, 790, 995, 586, 3233, 29, 4712, 63, 4239, 63, 498, 9, 339, 347, 511, 63, 6765, 63, 5871, 8, 277, 304, 267, 327, 5543, 912, 376, 1834, 267, 291, 14, 981, 63, 1569, 8, 1000, 17, 63, 1569, 9, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 4930, 297, 2850, 6081, 297, 1654, 17, 459, 6081, 63, 344, 995, 2079, 2850, 1569, 297, 1654, 17, 459, 1569, 63, 344, 995, 1654, 17, 459, 354, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 4930, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 513, 14, 17952, 1333, 398, 13108, 14, 7378, 63, 6689, 275, 13108, 14, 13679, 63, 7378, 63, 17305, 267, 13108, 14, 1772, 63, 12368, 275, 1654, 17, 459, 711, 418, 267, 900, 14, 4532, 8, 19, 9, 398, 327, 7719, 2498, 314, 3531, 436, 2004, 283, 2682, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384, 297, 1654, 17, 459, 344, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6614, 13, 793, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 774, 1654, 8559, 943, 60, 78, 358, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2379, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 2017, 370, 3631, 1654, 450, 83, 965, 2757, 283, 586, 283, 16121, 3134, 78, 7, 450, 1654, 17, 459, 344, 1105, 398, 327, 7719, 2498, 2004, 283, 14661, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384, 297, 1654, 17, 459, 344, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 2384, 14, 14661, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 928, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 2017, 370, 1343, 1654, 450, 83, 965, 2757, 283, 586, 283, 16121, 3134, 78, 7, 450, 1654, 17, 459, 344, 1105, 398, 327, 7719, 2498, 2004, 283, 2682, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 27849, 9954, 1005, 29949, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 13108, 199, 646, 747, 199, 646, 900, 199, 199, 504, 2295, 492, 666, 199, 504, 2295, 492, 3778, 421, 199, 318, 4911, 63, 4239, 63, 498, 8, 2703, 304, 272, 1004, 275, 359, 76, 367, 634, 315, 3839, 14, 1294, 2258, 78, 358, 340, 634, 1137, 28696, 272, 340, 3666, 604, 59, 16, 61, 508, 283, 9858, 15947, 28644, 1951, 9301, 9858, 7, 436, 268, 1004, 1988, 17, 61, 508, 283, 9858, 3902, 28644, 1951, 9301, 9858, 8109, 267, 372, 3839, 272, 372, 2125, 421, 199, 318, 8288, 8, 1501, 304, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 297, 1788, 9, 421, 199, 1000, 17, 275, 666, 14, 1000, 459, 14757, 13, 9993, 13, 6772, 13, 22872, 13, 19161, 19161, 19161, 418, 199, 1000, 17, 63, 1569, 275, 666, 14, 1569, 59, 1000, 17, 459, 1569, 63, 344, 6538, 421, 199, 533, 577, 3281, 70, 1746, 8, 1208, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 36, 3281, 70, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 928, 63, 68, 3281, 70, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2379, 63, 68, 3281, 70, 342, 267, 1613, 8, 36, 3281, 70, 1746, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 6765, 63, 18664, 8, 277, 304, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 2384, 297, 283, 1960, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 1807, 297, 283, 1960, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 1807, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6081, 13, 981, 297, 283, 396, 14, 6081, 297, 283, 5637, 297, 2079, 283, 7727, 297, 283, 1046, 297, 283, 18, 995, 586, 1788, 29, 6525, 360, 6765, 63, 6081, 13, 981, 1333, 339, 347, 511, 63, 6765, 63, 30825, 8, 277, 304, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 525, 297, 283, 396, 790, 297, 2850, 5645, 13, 498, 297, 2079, 8288, 360, 6765, 63, 19263, 13, 525, 14, 5645, 2665, 586, 3839, 13275, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 19263, 13, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 2384, 297, 283, 396, 790, 995, 586, 1788, 29, 6525, 360, 6765, 63, 19263, 13, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 1807, 297, 283, 396, 790, 995, 586, 3839, 13275, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 19263, 13, 525, 297, 283, 396, 790, 995, 586, 3233, 29, 4712, 63, 4239, 63, 498, 9, 339, 347, 511, 63, 6765, 63, 5871, 8, 277, 304, 267, 327, 5543, 912, 376, 1834, 267, 291, 14, 981, 63, 1569, 8, 1000, 17, 63, 1569, 9, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 4930, 297, 2850, 6081, 297, 1654, 17, 459, 6081, 63, 344, 995, 2079, 2850, 1569, 297, 1654, 17, 459, 1569, 63, 344, 995, 1654, 17, 459, 354, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 4930, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 513, 14, 17952, 1333, 398, 13108, 14, 7378, 63, 6689, 275, 13108, 14, 13679, 63, 7378, 63, 17305, 267, 13108, 14, 1772, 63, 12368, 275, 1654, 17, 459, 711, 418, 267, 900, 14, 4532, 8, 19, 9, 398, 327, 7719, 2498, 314, 3531, 436, 2004, 283, 2682, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 513, 995, 586, 1788, 29, 6525, 360, 6765, 63, 513, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384, 297, 1654, 17, 459, 344, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 2384, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 6614, 13, 793, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 774, 1654, 8559, 943, 60, 78, 358, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2379, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 2017, 370, 3631, 1654, 450, 83, 965, 2757, 283, 586, 283, 16121, 3134, 78, 7, 450, 1654, 17, 459, 344, 1105, 398, 327, 7719, 2498, 2004, 283, 14661, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384, 297, 1654, 17, 459, 344, 2157, 586, 1788, 29, 6525, 360, 6765, 63, 2384, 14, 14661, 1333, 398, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 928, 297, 1654, 17, 459, 344, 2157, 586, 3839, 534, 2017, 370, 1343, 1654, 450, 83, 965, 2757, 283, 586, 283, 16121, 3134, 78, 7, 450, 1654, 17, 459, 344, 1105, 398, 327, 7719, 2498, 2004, 283, 2682, 7, 267, 291, 14, 1628, 63, 4712, 2941, 6765, 297, 283, 2384, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
behzadnouri/numpy
numpy/random/__init__.py
84
5492
""" ======================== Random Number Generation ======================== ==================== ========================================================= Utility functions ============================================================================== random Uniformly distributed values of a given shape. bytes Uniformly distributed random bytes. random_integers Uniformly distributed integers in a given range. random_sample Uniformly distributed floats in a given range. random Alias for random_sample ranf Alias for random_sample sample Alias for random_sample choice Generate a weighted random sample from a given array-like permutation Randomly permute a sequence / generate a random sequence. shuffle Randomly permute a sequence in place. seed Seed the random number generator. ==================== ========================================================= ==================== ========================================================= Compatibility functions ============================================================================== rand Uniformly distributed values. randn Normally distributed values. ranf Uniformly distributed floating point numbers. randint Uniformly distributed integers in a given range. ==================== ========================================================= ==================== ========================================================= Univariate distributions ============================================================================== beta Beta distribution over ``[0, 1]``. binomial Binomial distribution. chisquare :math:`\\chi^2` distribution. exponential Exponential distribution. f F (Fisher-Snedecor) distribution. gamma Gamma distribution. geometric Geometric distribution. gumbel Gumbel distribution. hypergeometric Hypergeometric distribution. laplace Laplace distribution. logistic Logistic distribution. lognormal Log-normal distribution. logseries Logarithmic series distribution. negative_binomial Negative binomial distribution. noncentral_chisquare Non-central chi-square distribution. noncentral_f Non-central F distribution. normal Normal / Gaussian distribution. pareto Pareto distribution. poisson Poisson distribution. power Power distribution. rayleigh Rayleigh distribution. triangular Triangular distribution. uniform Uniform distribution. vonmises Von Mises circular distribution. wald Wald (inverse Gaussian) distribution. weibull Weibull distribution. zipf Zipf's distribution over ranked data. ==================== ========================================================= ==================== ========================================================= Multivariate distributions ============================================================================== dirichlet Multivariate generalization of Beta distribution. multinomial Multivariate generalization of the binomial distribution. multivariate_normal Multivariate generalization of the normal distribution. ==================== ========================================================= ==================== ========================================================= Standard distributions ============================================================================== standard_cauchy Standard Cauchy-Lorentz distribution. standard_exponential Standard exponential distribution. standard_gamma Standard Gamma distribution. standard_normal Standard normal distribution. standard_t Standard Student's t-distribution. ==================== ========================================================= ==================== ========================================================= Internal functions ============================================================================== get_state Get tuple representing internal state of generator. set_state Set state of generator. ==================== ========================================================= """ from __future__ import division, absolute_import, print_function import warnings # To get sub-modules from .info import __doc__, __all__ with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="numpy.ndarray size changed") from .mtrand import * # Some aliases: ranf = random = sample = random_sample __all__.extend(['ranf', 'random', 'sample']) def __RandomState_ctor(): """Return a RandomState instance. This function exists solely to assist (un)pickling. Note that the state of the RandomState returned here is irrelevant, as this function's entire purpose is to return a newly allocated RandomState whose state pickle can set. Consequently the RandomState returned by this function is a freshly allocated copy with a seed=0. See https://github.com/numpy/numpy/issues/4763 for a detailed discussion """ return RandomState(seed=0) from numpy.testing.nosetester import _numpy_tester test = _numpy_tester().test bench = _numpy_tester().bench
bsd-3-clause
[ 624, 199, 1280, 763, 199, 3883, 4860, 1464, 425, 199, 1280, 763, 199, 199, 1280, 532, 19691, 763, 199, 17505, 3423, 199, 5695, 17224, 199, 2355, 5185, 1910, 8241, 590, 1854, 1338, 402, 282, 1627, 2215, 14, 199, 2394, 4483, 1910, 8241, 590, 1854, 2196, 2783, 14, 199, 2355, 63, 23931, 420, 1910, 8241, 590, 1854, 9446, 315, 282, 1627, 1425, 14, 199, 2355, 63, 3271, 263, 1910, 8241, 590, 1854, 15657, 315, 282, 1627, 1425, 14, 199, 2355, 5185, 24777, 367, 2196, 63, 3271, 199, 1312, 70, 463, 24777, 367, 2196, 63, 3271, 199, 3271, 5185, 24777, 367, 2196, 63, 3271, 199, 5095, 5185, 7958, 282, 14609, 2196, 2690, 687, 282, 1627, 1625, 13, 2930, 199, 23832, 3515, 9571, 590, 10869, 938, 282, 3414, 1182, 3550, 282, 2196, 3414, 14, 199, 11777, 4519, 9571, 590, 10869, 938, 282, 3414, 315, 4192, 14, 199, 5176, 463, 3240, 379, 314, 2196, 1329, 4306, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 2404, 5880, 3423, 199, 5695, 17224, 199, 3759, 463, 1910, 8241, 590, 1854, 1338, 14, 199, 10843, 4483, 24573, 1854, 1338, 14, 199, 1312, 70, 463, 1910, 8241, 590, 1854, 8402, 2376, 5579, 14, 199, 8393, 4519, 1910, 8241, 590, 1854, 9446, 315, 282, 1627, 1425, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 1358, 23225, 10208, 199, 5695, 17224, 199, 5683, 463, 29521, 4084, 1806, 29345, 16, 12, 413, 30029, 199, 27578, 3777, 699, 16956, 4084, 14, 199, 30883, 5937, 3322, 520, 3442, 1705, 1103, 13175, 62, 18, 64, 4084, 14, 199, 27093, 3515, 1316, 11819, 4084, 14, 199, 70, 8540, 481, 334, 38, 2453, 281, 13, 51, 685, 6518, 9, 4084, 14, 199, 7325, 4483, 598, 4746, 4084, 14, 199, 31509, 3322, 5346, 15890, 4084, 14, 199, 71, 4295, 352, 5185, 598, 4295, 352, 4084, 14, 199, 9547, 31509, 755, 21344, 31509, 4084, 14, 199, 416, 2778, 4519, 491, 439, 1071, 4084, 14, 199, 23452, 3777, 5297, 6937, 4084, 14, 199, 320, 784, 1783, 3322, 5297, 13, 3302, 4084, 14, 199, 793, 5602, 3322, 5297, 18327, 15003, 6779, 4084, 14, 199, 7371, 63, 27578, 259, 32548, 2517, 6471, 4084, 14, 199, 2865, 16067, 63, 30883, 5937, 10172, 13, 16067, 23275, 13, 9646, 4084, 14, 199, 2865, 16067, 63, 70, 260, 10172, 13, 16067, 481, 4084, 14, 199, 3302, 5185, 11514, 1182, 17131, 4084, 14, 199, 4096, 475, 5185, 510, 1530, 475, 4084, 14, 199, 29606, 4519, 4376, 18571, 4084, 14, 199, 5652, 4483, 18879, 4084, 14, 199, 803, 274, 2056, 3777, 30703, 274, 2056, 4084, 14, 199, 29663, 3698, 12480, 11572, 4084, 14, 199, 8830, 4519, 1910, 8241, 4084, 14, 199, 86, 265, 77, 1388, 3777, 812, 265, 603, 1388, 15032, 4084, 14, 199, 20877, 68, 463, 644, 27075, 334, 11668, 17131, 9, 4084, 14, 199, 1129, 20587, 4519, 2136, 20587, 4084, 14, 199, 3065, 70, 463, 16688, 70, 1159, 4084, 1806, 6915, 379, 666, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 3947, 13805, 10208, 199, 5695, 17224, 199, 328, 19683, 3322, 6879, 13805, 8605, 2072, 402, 29521, 4084, 14, 199, 28265, 3515, 6879, 13805, 8605, 2072, 402, 314, 2517, 6471, 4084, 14, 199, 3029, 13805, 63, 3302, 221, 6879, 13805, 8605, 2072, 402, 314, 3293, 4084, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 9232, 10208, 199, 5695, 17224, 199, 6807, 63, 696, 30074, 420, 9739, 8790, 30074, 13, 2041, 640, 90, 4084, 14, 199, 6807, 63, 27093, 9739, 23160, 4084, 14, 199, 6807, 63, 7325, 755, 9739, 598, 4746, 4084, 14, 199, 6807, 63, 3302, 420, 9739, 3293, 4084, 14, 199, 6807, 63, 84, 3698, 9739, 17246, 1159, 307, 13, 4972, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 8405, 3423, 199, 5695, 17224, 199, 362, 63, 929, 3322, 2372, 2008, 6144, 5007, 1174, 402, 4306, 14, 199, 409, 63, 929, 3322, 2494, 1174, 402, 4306, 14, 199, 1280, 532, 19691, 763, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 199, 3, 4005, 664, 1007, 13, 3112, 199, 504, 1275, 815, 492, 636, 1301, 3108, 636, 452, 363, 421, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 23945, 480, 4247, 401, 1245, 628, 4714, 14, 8237, 1568, 2896, 531, 272, 687, 1275, 77, 454, 460, 492, 627, 199, 199, 3, 6601, 5481, 26, 199, 1312, 70, 275, 2196, 275, 2690, 275, 2196, 63, 3271, 199, 363, 452, 4343, 2880, 2941, 1312, 70, 297, 283, 2355, 297, 283, 3271, 1105, 199, 199, 318, 636, 15726, 63, 630, 837, 272, 408, 1767, 282, 22233, 1256, 14, 339, 961, 805, 3495, 30869, 590, 370, 465, 11734, 334, 324, 9, 24773, 14, 339, 3390, 626, 314, 1174, 402, 314, 22233, 2138, 2348, 365, 8190, 21906, 12, 465, 642, 805, 1159, 272, 8039, 12016, 365, 370, 372, 282, 13903, 17659, 22233, 7447, 1174, 5927, 883, 663, 14, 272, 1448, 11277, 590, 314, 22233, 2138, 701, 642, 805, 365, 282, 17480, 590, 17659, 1331, 272, 543, 282, 6347, 29, 16, 14, 339, 1666, 4178, 921, 5031, 14, 957, 15, 4714, 15, 4714, 15, 10115, 15, 22351, 19, 367, 282, 16212, 16582, 339, 408, 272, 372, 22233, 8, 5176, 29, 16, 9, 199, 199, 504, 2680, 14, 4776, 14, 21085, 8234, 492, 485, 4714, 63, 8234, 199, 396, 275, 485, 4714, 63, 8234, 1252, 396, 199, 16571, 275, 485, 4714, 63, 8234, 1252, 16571, 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 ]
[ 199, 1280, 763, 199, 3883, 4860, 1464, 425, 199, 1280, 763, 199, 199, 1280, 532, 19691, 763, 199, 17505, 3423, 199, 5695, 17224, 199, 2355, 5185, 1910, 8241, 590, 1854, 1338, 402, 282, 1627, 2215, 14, 199, 2394, 4483, 1910, 8241, 590, 1854, 2196, 2783, 14, 199, 2355, 63, 23931, 420, 1910, 8241, 590, 1854, 9446, 315, 282, 1627, 1425, 14, 199, 2355, 63, 3271, 263, 1910, 8241, 590, 1854, 15657, 315, 282, 1627, 1425, 14, 199, 2355, 5185, 24777, 367, 2196, 63, 3271, 199, 1312, 70, 463, 24777, 367, 2196, 63, 3271, 199, 3271, 5185, 24777, 367, 2196, 63, 3271, 199, 5095, 5185, 7958, 282, 14609, 2196, 2690, 687, 282, 1627, 1625, 13, 2930, 199, 23832, 3515, 9571, 590, 10869, 938, 282, 3414, 1182, 3550, 282, 2196, 3414, 14, 199, 11777, 4519, 9571, 590, 10869, 938, 282, 3414, 315, 4192, 14, 199, 5176, 463, 3240, 379, 314, 2196, 1329, 4306, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 2404, 5880, 3423, 199, 5695, 17224, 199, 3759, 463, 1910, 8241, 590, 1854, 1338, 14, 199, 10843, 4483, 24573, 1854, 1338, 14, 199, 1312, 70, 463, 1910, 8241, 590, 1854, 8402, 2376, 5579, 14, 199, 8393, 4519, 1910, 8241, 590, 1854, 9446, 315, 282, 1627, 1425, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 1358, 23225, 10208, 199, 5695, 17224, 199, 5683, 463, 29521, 4084, 1806, 29345, 16, 12, 413, 30029, 199, 27578, 3777, 699, 16956, 4084, 14, 199, 30883, 5937, 3322, 520, 3442, 1705, 1103, 13175, 62, 18, 64, 4084, 14, 199, 27093, 3515, 1316, 11819, 4084, 14, 199, 70, 8540, 481, 334, 38, 2453, 281, 13, 51, 685, 6518, 9, 4084, 14, 199, 7325, 4483, 598, 4746, 4084, 14, 199, 31509, 3322, 5346, 15890, 4084, 14, 199, 71, 4295, 352, 5185, 598, 4295, 352, 4084, 14, 199, 9547, 31509, 755, 21344, 31509, 4084, 14, 199, 416, 2778, 4519, 491, 439, 1071, 4084, 14, 199, 23452, 3777, 5297, 6937, 4084, 14, 199, 320, 784, 1783, 3322, 5297, 13, 3302, 4084, 14, 199, 793, 5602, 3322, 5297, 18327, 15003, 6779, 4084, 14, 199, 7371, 63, 27578, 259, 32548, 2517, 6471, 4084, 14, 199, 2865, 16067, 63, 30883, 5937, 10172, 13, 16067, 23275, 13, 9646, 4084, 14, 199, 2865, 16067, 63, 70, 260, 10172, 13, 16067, 481, 4084, 14, 199, 3302, 5185, 11514, 1182, 17131, 4084, 14, 199, 4096, 475, 5185, 510, 1530, 475, 4084, 14, 199, 29606, 4519, 4376, 18571, 4084, 14, 199, 5652, 4483, 18879, 4084, 14, 199, 803, 274, 2056, 3777, 30703, 274, 2056, 4084, 14, 199, 29663, 3698, 12480, 11572, 4084, 14, 199, 8830, 4519, 1910, 8241, 4084, 14, 199, 86, 265, 77, 1388, 3777, 812, 265, 603, 1388, 15032, 4084, 14, 199, 20877, 68, 463, 644, 27075, 334, 11668, 17131, 9, 4084, 14, 199, 1129, 20587, 4519, 2136, 20587, 4084, 14, 199, 3065, 70, 463, 16688, 70, 1159, 4084, 1806, 6915, 379, 666, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 3947, 13805, 10208, 199, 5695, 17224, 199, 328, 19683, 3322, 6879, 13805, 8605, 2072, 402, 29521, 4084, 14, 199, 28265, 3515, 6879, 13805, 8605, 2072, 402, 314, 2517, 6471, 4084, 14, 199, 3029, 13805, 63, 3302, 221, 6879, 13805, 8605, 2072, 402, 314, 3293, 4084, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 9232, 10208, 199, 5695, 17224, 199, 6807, 63, 696, 30074, 420, 9739, 8790, 30074, 13, 2041, 640, 90, 4084, 14, 199, 6807, 63, 27093, 9739, 23160, 4084, 14, 199, 6807, 63, 7325, 755, 9739, 598, 4746, 4084, 14, 199, 6807, 63, 3302, 420, 9739, 3293, 4084, 14, 199, 6807, 63, 84, 3698, 9739, 17246, 1159, 307, 13, 4972, 14, 199, 1280, 532, 19691, 763, 199, 199, 1280, 532, 19691, 763, 199, 8405, 3423, 199, 5695, 17224, 199, 362, 63, 929, 3322, 2372, 2008, 6144, 5007, 1174, 402, 4306, 14, 199, 409, 63, 929, 3322, 2494, 1174, 402, 4306, 14, 199, 1280, 532, 19691, 763, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 199, 3, 4005, 664, 1007, 13, 3112, 199, 504, 1275, 815, 492, 636, 1301, 3108, 636, 452, 363, 421, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 23945, 480, 4247, 401, 1245, 628, 4714, 14, 8237, 1568, 2896, 531, 272, 687, 1275, 77, 454, 460, 492, 627, 199, 199, 3, 6601, 5481, 26, 199, 1312, 70, 275, 2196, 275, 2690, 275, 2196, 63, 3271, 199, 363, 452, 4343, 2880, 2941, 1312, 70, 297, 283, 2355, 297, 283, 3271, 1105, 199, 199, 318, 636, 15726, 63, 630, 837, 272, 408, 1767, 282, 22233, 1256, 14, 339, 961, 805, 3495, 30869, 590, 370, 465, 11734, 334, 324, 9, 24773, 14, 339, 3390, 626, 314, 1174, 402, 314, 22233, 2138, 2348, 365, 8190, 21906, 12, 465, 642, 805, 1159, 272, 8039, 12016, 365, 370, 372, 282, 13903, 17659, 22233, 7447, 1174, 5927, 883, 663, 14, 272, 1448, 11277, 590, 314, 22233, 2138, 701, 642, 805, 365, 282, 17480, 590, 17659, 1331, 272, 543, 282, 6347, 29, 16, 14, 339, 1666, 4178, 921, 5031, 14, 957, 15, 4714, 15, 4714, 15, 10115, 15, 22351, 19, 367, 282, 16212, 16582, 339, 408, 272, 372, 22233, 8, 5176, 29, 16, 9, 199, 199, 504, 2680, 14, 4776, 14, 21085, 8234, 492, 485, 4714, 63, 8234, 199, 396, 275, 485, 4714, 63, 8234, 1252, 396, 199, 16571, 275, 485, 4714, 63, 8234, 1252, 16571, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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est/_pytest/nose.py
228
2527
""" run test suites written for nose. """ import sys import py import pytest from _pytest import unittest def get_skip_exceptions(): skip_classes = set() for module_name in ('unittest', 'unittest2', 'nose'): mod = sys.modules.get(module_name) if hasattr(mod, 'SkipTest'): skip_classes.add(mod.SkipTest) return tuple(skip_classes) def pytest_runtest_makereport(item, call): if call.excinfo and call.excinfo.errisinstance(get_skip_exceptions()): # let's substitute the excinfo with a pytest.skip one call2 = call.__class__(lambda: pytest.skip(str(call.excinfo.value)), call.when) call.excinfo = call2.excinfo @pytest.hookimpl(trylast=True) def pytest_runtest_setup(item): if is_potential_nosetest(item): if isinstance(item.parent, pytest.Generator): gen = item.parent if not hasattr(gen, '_nosegensetup'): call_optional(gen.obj, 'setup') if isinstance(gen.parent, pytest.Instance): call_optional(gen.parent.obj, 'setup') gen._nosegensetup = True if not call_optional(item.obj, 'setup'): # call module level setup if there is no object level one call_optional(item.parent.obj, 'setup') #XXX this implies we only call teardown when setup worked item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item) def teardown_nose(item): if is_potential_nosetest(item): if not call_optional(item.obj, 'teardown'): call_optional(item.parent.obj, 'teardown') #if hasattr(item.parent, '_nosegensetup'): # #call_optional(item._nosegensetup, 'teardown') # del item.parent._nosegensetup def pytest_make_collect_report(collector): if isinstance(collector, pytest.Generator): call_optional(collector.obj, 'setup') def is_potential_nosetest(item): # extra check needed since we do not do nose style setup/teardown # on direct unittest style classes return isinstance(item, pytest.Function) and \ not isinstance(item, unittest.TestCaseFunction) def call_optional(obj, name): method = getattr(obj, name, None) isfixture = hasattr(method, "_pytestfixturefunction") if method is not None and not isfixture and py.builtin.callable(method): # If there's any problems allow the exception to raise rather than # silently ignoring them method() return True
mpl-2.0
[ 624, 1255, 511, 24203, 5313, 367, 11354, 14, 408, 199, 199, 646, 984, 199, 199, 646, 1134, 199, 646, 4613, 199, 504, 485, 4462, 492, 2882, 421, 199, 318, 664, 63, 2759, 63, 3924, 837, 272, 3372, 63, 2888, 275, 663, 342, 272, 367, 859, 63, 354, 315, 661, 2796, 297, 283, 2796, 18, 297, 283, 21085, 735, 267, 3413, 275, 984, 14, 3112, 14, 362, 8, 578, 63, 354, 9, 267, 340, 2688, 8, 1494, 12, 283, 25755, 735, 288, 3372, 63, 2888, 14, 525, 8, 1494, 14, 25755, 9, 272, 372, 2008, 8, 2759, 63, 2888, 9, 421, 199, 318, 4613, 63, 1065, 396, 63, 1875, 3070, 8, 1053, 12, 1240, 304, 272, 340, 1240, 14, 27447, 436, 1240, 14, 27447, 14, 281, 5719, 842, 8, 362, 63, 2759, 63, 3924, 5109, 267, 327, 4691, 1159, 23080, 314, 21596, 543, 282, 4613, 14, 2759, 1373, 267, 1240, 18, 275, 1240, 855, 533, 721, 2734, 26, 490, 4613, 14, 2759, 8, 495, 8, 1250, 14, 27447, 14, 585, 1826, 1240, 14, 6526, 9, 267, 1240, 14, 27447, 275, 1240, 18, 14, 27447, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2019, 29, 549, 9, 199, 318, 4613, 63, 1065, 396, 63, 2758, 8, 1053, 304, 272, 340, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 267, 340, 1228, 8, 1053, 14, 1708, 12, 4613, 14, 7599, 304, 288, 3805, 275, 1242, 14, 1708, 288, 340, 440, 2688, 8, 2268, 12, 2513, 21085, 2268, 2758, 735, 355, 1240, 63, 4144, 8, 2268, 14, 1113, 12, 283, 2758, 358, 355, 340, 1228, 8, 2268, 14, 1708, 12, 4613, 14, 3244, 304, 490, 1240, 63, 4144, 8, 2268, 14, 1708, 14, 1113, 12, 283, 2758, 358, 355, 3805, 423, 21085, 2268, 2758, 275, 715, 267, 340, 440, 1240, 63, 4144, 8, 1053, 14, 1113, 12, 283, 2758, 735, 288, 327, 1240, 859, 2166, 3272, 340, 2337, 365, 949, 909, 2166, 1373, 288, 1240, 63, 4144, 8, 1053, 14, 1708, 14, 1113, 12, 283, 2758, 358, 267, 327, 13933, 642, 22660, 781, 1454, 1240, 17558, 1380, 3272, 26731, 267, 1242, 14, 1730, 423, 2758, 929, 14, 525, 30092, 1332, 2734, 26, 17558, 63, 21085, 8, 1053, 1826, 1242, 9, 199, 199, 318, 17558, 63, 21085, 8, 1053, 304, 272, 340, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 267, 340, 440, 1240, 63, 4144, 8, 1053, 14, 1113, 12, 283, 15236, 735, 288, 1240, 63, 4144, 8, 1053, 14, 1708, 14, 1113, 12, 283, 15236, 358, 267, 327, 692, 2688, 8, 1053, 14, 1708, 12, 2513, 21085, 2268, 2758, 735, 267, 327, 259, 327, 1250, 63, 4144, 8, 1053, 423, 21085, 2268, 2758, 12, 283, 15236, 358, 267, 327, 259, 2150, 1242, 14, 1708, 423, 21085, 2268, 2758, 421, 199, 318, 4613, 63, 1875, 63, 7112, 63, 3070, 8, 10946, 304, 272, 340, 1228, 8, 10946, 12, 4613, 14, 7599, 304, 267, 1240, 63, 4144, 8, 10946, 14, 1113, 12, 283, 2758, 358, 421, 199, 318, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 272, 327, 2402, 1104, 4346, 3967, 781, 886, 440, 886, 11354, 3449, 3272, 15, 15236, 272, 327, 641, 4125, 2882, 3449, 3992, 272, 372, 1228, 8, 1053, 12, 4613, 14, 3481, 9, 436, 971, 267, 440, 1228, 8, 1053, 12, 2882, 14, 1746, 3481, 9, 421, 199, 318, 1240, 63, 4144, 8, 1113, 12, 536, 304, 272, 1083, 275, 2519, 8, 1113, 12, 536, 12, 488, 9, 272, 365, 5997, 275, 2688, 8, 765, 12, 2668, 4462, 5997, 1593, 531, 272, 340, 1083, 365, 440, 488, 436, 440, 365, 5997, 436, 1134, 14, 5351, 14, 8296, 8, 765, 304, 267, 327, 982, 2337, 1159, 1263, 8826, 2040, 314, 1919, 370, 746, 7830, 2419, 267, 327, 18030, 17289, 3062, 267, 1083, 342, 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 ]
[ 1255, 511, 24203, 5313, 367, 11354, 14, 408, 199, 199, 646, 984, 199, 199, 646, 1134, 199, 646, 4613, 199, 504, 485, 4462, 492, 2882, 421, 199, 318, 664, 63, 2759, 63, 3924, 837, 272, 3372, 63, 2888, 275, 663, 342, 272, 367, 859, 63, 354, 315, 661, 2796, 297, 283, 2796, 18, 297, 283, 21085, 735, 267, 3413, 275, 984, 14, 3112, 14, 362, 8, 578, 63, 354, 9, 267, 340, 2688, 8, 1494, 12, 283, 25755, 735, 288, 3372, 63, 2888, 14, 525, 8, 1494, 14, 25755, 9, 272, 372, 2008, 8, 2759, 63, 2888, 9, 421, 199, 318, 4613, 63, 1065, 396, 63, 1875, 3070, 8, 1053, 12, 1240, 304, 272, 340, 1240, 14, 27447, 436, 1240, 14, 27447, 14, 281, 5719, 842, 8, 362, 63, 2759, 63, 3924, 5109, 267, 327, 4691, 1159, 23080, 314, 21596, 543, 282, 4613, 14, 2759, 1373, 267, 1240, 18, 275, 1240, 855, 533, 721, 2734, 26, 490, 4613, 14, 2759, 8, 495, 8, 1250, 14, 27447, 14, 585, 1826, 1240, 14, 6526, 9, 267, 1240, 14, 27447, 275, 1240, 18, 14, 27447, 421, 199, 32, 4462, 14, 3664, 5472, 8, 893, 2019, 29, 549, 9, 199, 318, 4613, 63, 1065, 396, 63, 2758, 8, 1053, 304, 272, 340, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 267, 340, 1228, 8, 1053, 14, 1708, 12, 4613, 14, 7599, 304, 288, 3805, 275, 1242, 14, 1708, 288, 340, 440, 2688, 8, 2268, 12, 2513, 21085, 2268, 2758, 735, 355, 1240, 63, 4144, 8, 2268, 14, 1113, 12, 283, 2758, 358, 355, 340, 1228, 8, 2268, 14, 1708, 12, 4613, 14, 3244, 304, 490, 1240, 63, 4144, 8, 2268, 14, 1708, 14, 1113, 12, 283, 2758, 358, 355, 3805, 423, 21085, 2268, 2758, 275, 715, 267, 340, 440, 1240, 63, 4144, 8, 1053, 14, 1113, 12, 283, 2758, 735, 288, 327, 1240, 859, 2166, 3272, 340, 2337, 365, 949, 909, 2166, 1373, 288, 1240, 63, 4144, 8, 1053, 14, 1708, 14, 1113, 12, 283, 2758, 358, 267, 327, 13933, 642, 22660, 781, 1454, 1240, 17558, 1380, 3272, 26731, 267, 1242, 14, 1730, 423, 2758, 929, 14, 525, 30092, 1332, 2734, 26, 17558, 63, 21085, 8, 1053, 1826, 1242, 9, 199, 199, 318, 17558, 63, 21085, 8, 1053, 304, 272, 340, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 267, 340, 440, 1240, 63, 4144, 8, 1053, 14, 1113, 12, 283, 15236, 735, 288, 1240, 63, 4144, 8, 1053, 14, 1708, 14, 1113, 12, 283, 15236, 358, 267, 327, 692, 2688, 8, 1053, 14, 1708, 12, 2513, 21085, 2268, 2758, 735, 267, 327, 259, 327, 1250, 63, 4144, 8, 1053, 423, 21085, 2268, 2758, 12, 283, 15236, 358, 267, 327, 259, 2150, 1242, 14, 1708, 423, 21085, 2268, 2758, 421, 199, 318, 4613, 63, 1875, 63, 7112, 63, 3070, 8, 10946, 304, 272, 340, 1228, 8, 10946, 12, 4613, 14, 7599, 304, 267, 1240, 63, 4144, 8, 10946, 14, 1113, 12, 283, 2758, 358, 421, 199, 318, 365, 63, 24668, 63, 21085, 396, 8, 1053, 304, 272, 327, 2402, 1104, 4346, 3967, 781, 886, 440, 886, 11354, 3449, 3272, 15, 15236, 272, 327, 641, 4125, 2882, 3449, 3992, 272, 372, 1228, 8, 1053, 12, 4613, 14, 3481, 9, 436, 971, 267, 440, 1228, 8, 1053, 12, 2882, 14, 1746, 3481, 9, 421, 199, 318, 1240, 63, 4144, 8, 1113, 12, 536, 304, 272, 1083, 275, 2519, 8, 1113, 12, 536, 12, 488, 9, 272, 365, 5997, 275, 2688, 8, 765, 12, 2668, 4462, 5997, 1593, 531, 272, 340, 1083, 365, 440, 488, 436, 440, 365, 5997, 436, 1134, 14, 5351, 14, 8296, 8, 765, 304, 267, 327, 982, 2337, 1159, 1263, 8826, 2040, 314, 1919, 370, 746, 7830, 2419, 267, 327, 18030, 17289, 3062, 267, 1083, 342, 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,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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 ]
bzzzz/cython
Cython/Tests/TestCodeWriter.py
132
2316
from Cython.TestUtils import CythonTest class TestCodeWriter(CythonTest): # CythonTest uses the CodeWriter heavily, so do some checking by # roundtripping Cython code through the test framework. # Note that this test is dependant upon the normal Cython parser # to generate the input trees to the CodeWriter. This save *a lot* # of time; better to spend that time writing other tests than perfecting # this one... # Whitespace is very significant in this process: # - always newline on new block (!) # - indent 4 spaces # - 1 space around every operator def t(self, codestr): self.assertCode(codestr, self.fragment(codestr).root) def test_print(self): self.t(u""" print x, y print x + y ** 2 print x, y, z, """) def test_if(self): self.t(u"if x:\n pass") def test_ifelifelse(self): self.t(u""" if x: pass elif y: pass elif z + 34 ** 34 - 2: pass else: pass """) def test_def(self): self.t(u""" def f(x, y, z): pass def f(x = 34, y = 54, z): pass """) def test_longness_and_signedness(self): self.t(u"def f(unsigned long long long long long int y):\n pass") def test_signed_short(self): self.t(u"def f(signed short int y):\n pass") def test_typed_args(self): self.t(u"def f(int x, unsigned long int y):\n pass") def test_cdef_var(self): self.t(u""" cdef int hello cdef int hello = 4, x = 3, y, z """) def test_for_loop(self): self.t(u""" for x, y, z in f(g(h(34) * 2) + 23): print x, y, z else: print 43 """) def test_inplace_assignment(self): self.t(u"x += 43") def test_attribute(self): self.t(u"a.x") if __name__ == "__main__": import unittest unittest.main()
apache-2.0
[ 504, 26741, 14, 774, 7535, 492, 26741, 774, 199, 199, 533, 1379, 3034, 6261, 8, 9156, 898, 774, 304, 272, 327, 26741, 774, 4440, 314, 5495, 6261, 946, 1214, 3444, 12, 880, 886, 2005, 7907, 701, 272, 327, 6168, 599, 3637, 26741, 1233, 4012, 314, 511, 10059, 14, 339, 327, 3390, 626, 642, 511, 365, 11687, 867, 12188, 314, 3293, 26741, 1798, 272, 327, 370, 3550, 314, 1324, 14416, 370, 314, 5495, 6261, 14, 961, 3354, 627, 65, 13918, 10, 272, 327, 402, 900, 27, 8034, 370, 26387, 626, 900, 3575, 1163, 2295, 2419, 23668, 316, 272, 327, 642, 1373, 1396, 339, 327, 24403, 365, 7437, 16474, 315, 642, 2112, 26, 272, 327, 221, 446, 3544, 8057, 641, 892, 1853, 19452, 9, 272, 327, 221, 446, 4363, 841, 7883, 272, 327, 221, 446, 413, 4601, 6818, 4036, 4182, 339, 347, 307, 8, 277, 12, 1233, 495, 304, 267, 291, 14, 479, 3034, 8, 600, 495, 12, 291, 14, 7677, 8, 600, 495, 680, 1231, 9, 339, 347, 511, 63, 1361, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 870, 671, 12, 612, 490, 870, 671, 435, 612, 1011, 499, 490, 870, 671, 12, 612, 12, 1315, 12, 2049, 7857, 339, 347, 511, 63, 692, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 692, 671, 3427, 78, 259, 986, 531, 339, 347, 511, 63, 692, 4164, 2836, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 340, 671, 26, 717, 986, 490, 916, 612, 26, 717, 986, 490, 916, 1315, 435, 8177, 1011, 8177, 446, 499, 26, 717, 986, 490, 587, 26, 717, 986, 355, 7857, 339, 347, 511, 63, 318, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 347, 289, 8, 88, 12, 612, 12, 1315, 304, 717, 986, 490, 347, 289, 8, 88, 275, 8177, 12, 612, 275, 13470, 12, 1315, 304, 717, 986, 2049, 7857, 339, 347, 511, 63, 2809, 4171, 63, 460, 63, 1737, 4171, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 2244, 1846, 1846, 1846, 1846, 1846, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 1737, 63, 3612, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 1737, 3974, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 22033, 63, 589, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 442, 671, 12, 7381, 1846, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 31875, 63, 1391, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 286, 318, 1109, 16509, 490, 286, 318, 1109, 16509, 275, 841, 12, 671, 275, 650, 12, 612, 12, 1315, 355, 7857, 339, 347, 511, 63, 509, 63, 3813, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 367, 671, 12, 612, 12, 1315, 315, 289, 8, 71, 8, 72, 8, 1082, 9, 627, 499, 9, 435, 6546, 304, 717, 870, 671, 12, 612, 12, 1315, 490, 587, 26, 717, 870, 11851, 355, 7857, 339, 347, 511, 63, 15008, 63, 10861, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 88, 847, 11851, 531, 339, 347, 511, 63, 3215, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 65, 14, 88, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2882, 272, 2882, 14, 973, 342, 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 ]
[ 26741, 14, 774, 7535, 492, 26741, 774, 199, 199, 533, 1379, 3034, 6261, 8, 9156, 898, 774, 304, 272, 327, 26741, 774, 4440, 314, 5495, 6261, 946, 1214, 3444, 12, 880, 886, 2005, 7907, 701, 272, 327, 6168, 599, 3637, 26741, 1233, 4012, 314, 511, 10059, 14, 339, 327, 3390, 626, 642, 511, 365, 11687, 867, 12188, 314, 3293, 26741, 1798, 272, 327, 370, 3550, 314, 1324, 14416, 370, 314, 5495, 6261, 14, 961, 3354, 627, 65, 13918, 10, 272, 327, 402, 900, 27, 8034, 370, 26387, 626, 900, 3575, 1163, 2295, 2419, 23668, 316, 272, 327, 642, 1373, 1396, 339, 327, 24403, 365, 7437, 16474, 315, 642, 2112, 26, 272, 327, 221, 446, 3544, 8057, 641, 892, 1853, 19452, 9, 272, 327, 221, 446, 4363, 841, 7883, 272, 327, 221, 446, 413, 4601, 6818, 4036, 4182, 339, 347, 307, 8, 277, 12, 1233, 495, 304, 267, 291, 14, 479, 3034, 8, 600, 495, 12, 291, 14, 7677, 8, 600, 495, 680, 1231, 9, 339, 347, 511, 63, 1361, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 870, 671, 12, 612, 490, 870, 671, 435, 612, 1011, 499, 490, 870, 671, 12, 612, 12, 1315, 12, 2049, 7857, 339, 347, 511, 63, 692, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 692, 671, 3427, 78, 259, 986, 531, 339, 347, 511, 63, 692, 4164, 2836, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 340, 671, 26, 717, 986, 490, 916, 612, 26, 717, 986, 490, 916, 1315, 435, 8177, 1011, 8177, 446, 499, 26, 717, 986, 490, 587, 26, 717, 986, 355, 7857, 339, 347, 511, 63, 318, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 347, 289, 8, 88, 12, 612, 12, 1315, 304, 717, 986, 490, 347, 289, 8, 88, 275, 8177, 12, 612, 275, 13470, 12, 1315, 304, 717, 986, 2049, 7857, 339, 347, 511, 63, 2809, 4171, 63, 460, 63, 1737, 4171, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 2244, 1846, 1846, 1846, 1846, 1846, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 1737, 63, 3612, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 1737, 3974, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 22033, 63, 589, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 318, 289, 8, 442, 671, 12, 7381, 1846, 1109, 612, 17211, 78, 259, 986, 531, 339, 347, 511, 63, 31875, 63, 1391, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 286, 318, 1109, 16509, 490, 286, 318, 1109, 16509, 275, 841, 12, 671, 275, 650, 12, 612, 12, 1315, 355, 7857, 339, 347, 511, 63, 509, 63, 3813, 8, 277, 304, 267, 291, 14, 84, 8, 85, 624, 490, 367, 671, 12, 612, 12, 1315, 315, 289, 8, 71, 8, 72, 8, 1082, 9, 627, 499, 9, 435, 6546, 304, 717, 870, 671, 12, 612, 12, 1315, 490, 587, 26, 717, 870, 11851, 355, 7857, 339, 347, 511, 63, 15008, 63, 10861, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 88, 847, 11851, 531, 339, 347, 511, 63, 3215, 8, 277, 304, 267, 291, 14, 84, 8, 85, 2, 65, 14, 88, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2882, 272, 2882, 14, 973, 342, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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. # ============================================================================== """Preprocess images and bounding boxes for detection. We perform two sets of operations in preprocessing stage: (a) operations that are applied to both training and testing data, (b) operations that are applied only to training data for the purpose of data augmentation. A preprocessing function receives a set of inputs, e.g. an image and bounding boxes, performs an operation on them, and returns them. Some examples are: randomly cropping the image, randomly mirroring the image, randomly changing the brightness, contrast, hue and randomly jittering the bounding boxes. The preprocess function receives a tensor_dict which is a dictionary that maps different field names to their tensors. For example, tensor_dict[fields.InputDataFields.image] holds the image tensor. The image is a rank 4 tensor: [1, height, width, channels] with dtype=tf.float32. The groundtruth_boxes is a rank 2 tensor: [N, 4] where in each row there is a box with [ymin xmin ymax xmax]. Boxes are in normalized coordinates meaning their coordinate values range in [0, 1] Important Note: In tensor_dict, images is a rank 4 tensor, but preprocessing functions receive a rank 3 tensor for processing the image. Thus, inside the preprocess function we squeeze the image to become a rank 3 tensor and then we pass it to the functions. At the end of the preprocess we expand the image back to rank 4. """ import sys import tensorflow as tf from tensorflow.python.ops import control_flow_ops from object_detection.core import box_list from object_detection.core import box_list_ops from object_detection.core import keypoint_ops from object_detection.core import standard_fields as fields def _apply_with_random_selector(x, func, num_cases): """Computes func(x, sel), with sel sampled from [0...num_cases-1]. Args: x: input Tensor. func: Python function to apply. num_cases: Python int32, number of cases to sample sel from. Returns: The result of func(x, sel), where func receives the value of the selector as a python integer, but sel is sampled dynamically. """ rand_sel = tf.random_uniform([], maxval=num_cases, dtype=tf.int32) # Pass the real x only to one of the func calls. return control_flow_ops.merge([func( control_flow_ops.switch(x, tf.equal(rand_sel, case))[1], case) for case in range(num_cases)])[0] def _apply_with_random_selector_tuples(x, func, num_cases): """Computes func(x, sel), with sel sampled from [0...num_cases-1]. Args: x: A tuple of input tensors. func: Python function to apply. num_cases: Python int32, number of cases to sample sel from. Returns: The result of func(x, sel), where func receives the value of the selector as a python integer, but sel is sampled dynamically. """ num_inputs = len(x) rand_sel = tf.random_uniform([], maxval=num_cases, dtype=tf.int32) # Pass the real x only to one of the func calls. tuples = [list() for t in x] for case in range(num_cases): new_x = [control_flow_ops.switch(t, tf.equal(rand_sel, case))[1] for t in x] output = func(tuple(new_x), case) for j in range(num_inputs): tuples[j].append(output[j]) for i in range(num_inputs): tuples[i] = control_flow_ops.merge(tuples[i])[0] return tuple(tuples) def _random_integer(minval, maxval, seed): """Returns a random 0-D tensor between minval and maxval. Args: minval: minimum value of the random tensor. maxval: maximum value of the random tensor. seed: random seed. Returns: A random 0-D tensor between minval and maxval. """ return tf.random_uniform( [], minval=minval, maxval=maxval, dtype=tf.int32, seed=seed) def normalize_image(image, original_minval, original_maxval, target_minval, target_maxval): """Normalizes pixel values in the image. Moves the pixel values from the current [original_minval, original_maxval] range to a the [target_minval, target_maxval] range. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels]. original_minval: current image minimum value. original_maxval: current image maximum value. target_minval: target image minimum value. target_maxval: target image maximum value. Returns: image: image which is the same shape as input image. """ with tf.name_scope('NormalizeImage', values=[image]): original_minval = float(original_minval) original_maxval = float(original_maxval) target_minval = float(target_minval) target_maxval = float(target_maxval) image = tf.to_float(image) image = tf.subtract(image, original_minval) image = tf.multiply(image, (target_maxval - target_minval) / (original_maxval - original_minval)) image = tf.add(image, target_minval) return image def flip_boxes(boxes): """Left-right flip the boxes. Args: boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. Returns: Flipped boxes. """ # Flip boxes. ymin, xmin, ymax, xmax = tf.split(value=boxes, num_or_size_splits=4, axis=1) flipped_xmin = tf.subtract(1.0, xmax) flipped_xmax = tf.subtract(1.0, xmin) flipped_boxes = tf.concat([ymin, flipped_xmin, ymax, flipped_xmax], 1) return flipped_boxes def retain_boxes_above_threshold( boxes, labels, label_scores, masks=None, keypoints=None, threshold=0.0): """Retains boxes whose label score is above a given threshold. If the label score for a box is missing (represented by NaN), the box is retained. The boxes that don't pass the threshold will not appear in the returned tensor. Args: boxes: float32 tensor of shape [num_instance, 4] representing boxes location in normalized coordinates. labels: rank 1 int32 tensor of shape [num_instance] containing the object classes. label_scores: float32 tensor of shape [num_instance] representing the score for each box. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. threshold: scalar python float. Returns: retained_boxes: [num_retained_instance, 4] retianed_labels: [num_retained_instance] retained_label_scores: [num_retained_instance] If masks, or keypoints are not None, the function also returns: retained_masks: [num_retained_instance, height, width] retained_keypoints: [num_retained_instance, num_keypoints, 2] """ with tf.name_scope('RetainBoxesAboveThreshold', values=[boxes, labels, label_scores]): indices = tf.where( tf.logical_or(label_scores > threshold, tf.is_nan(label_scores))) indices = tf.squeeze(indices, axis=1) retained_boxes = tf.gather(boxes, indices) retained_labels = tf.gather(labels, indices) retained_label_scores = tf.gather(label_scores, indices) result = [retained_boxes, retained_labels, retained_label_scores] if masks is not None: retained_masks = tf.gather(masks, indices) result.append(retained_masks) if keypoints is not None: retained_keypoints = tf.gather(keypoints, indices) result.append(retained_keypoints) return result def _flip_masks(masks): """Left-right flips masks. Args: masks: rank 3 float32 tensor with shape [num_instances, height, width] representing instance masks. Returns: flipped masks: rank 3 float32 tensor with shape [num_instances, height, width] representing instance masks. """ return masks[:, :, ::-1] def random_horizontal_flip( image, boxes=None, masks=None, keypoints=None, keypoint_flip_permutation=None, seed=None): """Randomly decides whether to mirror the image and detections or not. The probability of flipping the image is 50%. Args: image: rank 3 float32 tensor with shape [height, width, channels]. boxes: (optional) rank 2 float32 tensor with shape [N, 4] containing the bounding boxes. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. keypoint_flip_permutation: rank 1 int32 tensor containing keypoint flip permutation. seed: random seed Returns: image: image which is the same shape as input image. If boxes, masks, keypoints, and keypoint_flip_permutation is not None, the function also returns the following tensors. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] Raises: ValueError: if keypoints are provided but keypoint_flip_permutation is not. """ def _flip_image(image): # flip image image_flipped = tf.image.flip_left_right(image) return image_flipped if keypoints is not None and keypoint_flip_permutation is None: raise ValueError( 'keypoints are provided but keypoints_flip_permutation is not provided') with tf.name_scope('RandomHorizontalFlip', values=[image, boxes]): result = [] # random variable defining whether to do flip or not do_a_flip_random = tf.random_uniform([], seed=seed) # flip only if there are bounding boxes in image! do_a_flip_random = tf.logical_and( tf.greater(tf.size(boxes), 0), tf.greater(do_a_flip_random, 0.5)) # flip image image = tf.cond(do_a_flip_random, lambda: _flip_image(image), lambda: image) result.append(image) # flip boxes if boxes is not None: boxes = tf.cond( do_a_flip_random, lambda: flip_boxes(boxes), lambda: boxes) result.append(boxes) # flip masks if masks is not None: masks = tf.cond( do_a_flip_random, lambda: _flip_masks(masks), lambda: masks) result.append(masks) # flip keypoints if keypoints is not None and keypoint_flip_permutation is not None: permutation = keypoint_flip_permutation keypoints = tf.cond( do_a_flip_random, lambda: keypoint_ops.flip_horizontal(keypoints, 0.5, permutation), lambda: keypoints) result.append(keypoints) return tuple(result) def random_pixel_value_scale(image, minval=0.9, maxval=1.1, seed=None): """Scales each value in the pixels of the image. This function scales each pixel independent of the other ones. For each value in image tensor, draws a random number between minval and maxval and multiples the values with them. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. minval: lower ratio of scaling pixel values. maxval: upper ratio of scaling pixel values. seed: random seed. Returns: image: image which is the same shape as input image. """ with tf.name_scope('RandomPixelValueScale', values=[image]): color_coef = tf.random_uniform( tf.shape(image), minval=minval, maxval=maxval, dtype=tf.float32, seed=seed) image = tf.multiply(image, color_coef) image = tf.clip_by_value(image, 0.0, 1.0) return image def random_image_scale(image, masks=None, min_scale_ratio=0.5, max_scale_ratio=2.0, seed=None): """Scales the image size. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels]. masks: (optional) rank 3 float32 tensor containing masks with size [height, width, num_masks]. The value is set to None if there are no masks. min_scale_ratio: minimum scaling ratio. max_scale_ratio: maximum scaling ratio. seed: random seed. Returns: image: image which is the same rank as input image. masks: If masks is not none, resized masks which are the same rank as input masks will be returned. """ with tf.name_scope('RandomImageScale', values=[image]): result = [] image_shape = tf.shape(image) image_height = image_shape[0] image_width = image_shape[1] size_coef = tf.random_uniform([], minval=min_scale_ratio, maxval=max_scale_ratio, dtype=tf.float32, seed=seed) image_newysize = tf.to_int32( tf.multiply(tf.to_float(image_height), size_coef)) image_newxsize = tf.to_int32( tf.multiply(tf.to_float(image_width), size_coef)) image = tf.image.resize_images( image, [image_newysize, image_newxsize], align_corners=True) result.append(image) if masks: masks = tf.image.resize_nearest_neighbor( masks, [image_newysize, image_newxsize], align_corners=True) result.append(masks) return tuple(result) def random_rgb_to_gray(image, probability=0.1, seed=None): """Changes the image from RGB to Grayscale with the given probability. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. probability: the probability of returning a grayscale image. The probability should be a number between [0, 1]. seed: random seed. Returns: image: image which is the same shape as input image. """ def _image_to_gray(image): image_gray1 = tf.image.rgb_to_grayscale(image) image_gray3 = tf.image.grayscale_to_rgb(image_gray1) return image_gray3 with tf.name_scope('RandomRGBtoGray', values=[image]): # random variable defining whether to do flip or not do_gray_random = tf.random_uniform([], seed=seed) image = tf.cond( tf.greater(do_gray_random, probability), lambda: image, lambda: _image_to_gray(image)) return image def random_adjust_brightness(image, max_delta=0.2): """Randomly adjusts brightness. Makes sure the output image is still between 0 and 1. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. max_delta: how much to change the brightness. A value between [0, 1). Returns: image: image which is the same shape as input image. boxes: boxes which is the same shape as input boxes. """ with tf.name_scope('RandomAdjustBrightness', values=[image]): image = tf.image.random_brightness(image, max_delta) image = tf.clip_by_value(image, clip_value_min=0.0, clip_value_max=1.0) return image def random_adjust_contrast(image, min_delta=0.8, max_delta=1.25): """Randomly adjusts contrast. Makes sure the output image is still between 0 and 1. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. min_delta: see max_delta. max_delta: how much to change the contrast. Contrast will change with a value between min_delta and max_delta. This value will be multiplied to the current contrast of the image. Returns: image: image which is the same shape as input image. """ with tf.name_scope('RandomAdjustContrast', values=[image]): image = tf.image.random_contrast(image, min_delta, max_delta) image = tf.clip_by_value(image, clip_value_min=0.0, clip_value_max=1.0) return image def random_adjust_hue(image, max_delta=0.02): """Randomly adjusts hue. Makes sure the output image is still between 0 and 1. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. max_delta: change hue randomly with a value between 0 and max_delta. Returns: image: image which is the same shape as input image. """ with tf.name_scope('RandomAdjustHue', values=[image]): image = tf.image.random_hue(image, max_delta) image = tf.clip_by_value(image, clip_value_min=0.0, clip_value_max=1.0) return image def random_adjust_saturation(image, min_delta=0.8, max_delta=1.25): """Randomly adjusts saturation. Makes sure the output image is still between 0 and 1. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. min_delta: see max_delta. max_delta: how much to change the saturation. Saturation will change with a value between min_delta and max_delta. This value will be multiplied to the current saturation of the image. Returns: image: image which is the same shape as input image. """ with tf.name_scope('RandomAdjustSaturation', values=[image]): image = tf.image.random_saturation(image, min_delta, max_delta) image = tf.clip_by_value(image, clip_value_min=0.0, clip_value_max=1.0) return image def random_distort_color(image, color_ordering=0): """Randomly distorts color. Randomly distorts color using a combination of brightness, hue, contrast and saturation changes. Makes sure the output image is still between 0 and 1. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. color_ordering: Python int, a type of distortion (valid values: 0, 1). Returns: image: image which is the same shape as input image. Raises: ValueError: if color_ordering is not in {0, 1}. """ with tf.name_scope('RandomDistortColor', values=[image]): if color_ordering == 0: image = tf.image.random_brightness(image, max_delta=32. / 255.) image = tf.image.random_saturation(image, lower=0.5, upper=1.5) image = tf.image.random_hue(image, max_delta=0.2) image = tf.image.random_contrast(image, lower=0.5, upper=1.5) elif color_ordering == 1: image = tf.image.random_brightness(image, max_delta=32. / 255.) image = tf.image.random_contrast(image, lower=0.5, upper=1.5) image = tf.image.random_saturation(image, lower=0.5, upper=1.5) image = tf.image.random_hue(image, max_delta=0.2) else: raise ValueError('color_ordering must be in {0, 1}') # The random_* ops do not necessarily clamp. image = tf.clip_by_value(image, 0.0, 1.0) return image def random_jitter_boxes(boxes, ratio=0.05, seed=None): """Randomly jitter boxes in image. Args: boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. ratio: The ratio of the box width and height that the corners can jitter. For example if the width is 100 pixels and ratio is 0.05, the corners can jitter up to 5 pixels in the x direction. seed: random seed. Returns: boxes: boxes which is the same shape as input boxes. """ def random_jitter_box(box, ratio, seed): """Randomly jitter box. Args: box: bounding box [1, 1, 4]. ratio: max ratio between jittered box and original box, a number between [0, 0.5]. seed: random seed. Returns: jittered_box: jittered box. """ rand_numbers = tf.random_uniform( [1, 1, 4], minval=-ratio, maxval=ratio, dtype=tf.float32, seed=seed) box_width = tf.subtract(box[0, 0, 3], box[0, 0, 1]) box_height = tf.subtract(box[0, 0, 2], box[0, 0, 0]) hw_coefs = tf.stack([box_height, box_width, box_height, box_width]) hw_rand_coefs = tf.multiply(hw_coefs, rand_numbers) jittered_box = tf.add(box, hw_rand_coefs) jittered_box = tf.clip_by_value(jittered_box, 0.0, 1.0) return jittered_box with tf.name_scope('RandomJitterBoxes', values=[boxes]): # boxes are [N, 4]. Lets first make them [N, 1, 1, 4] boxes_shape = tf.shape(boxes) boxes = tf.expand_dims(boxes, 1) boxes = tf.expand_dims(boxes, 2) distorted_boxes = tf.map_fn( lambda x: random_jitter_box(x, ratio, seed), boxes, dtype=tf.float32) distorted_boxes = tf.reshape(distorted_boxes, boxes_shape) return distorted_boxes def _strict_random_crop_image(image, boxes, labels, masks=None, keypoints=None, min_object_covered=1.0, aspect_ratio_range=(0.75, 1.33), area_range=(0.1, 1.0), overlap_thresh=0.3): """Performs random crop. Note: boxes will be clipped to the crop. Keypoint coordinates that are outside the crop will be set to NaN, which is consistent with the original keypoint encoding for non-existing keypoints. This function always crops the image and is supposed to be used by `random_crop_image` function which sometimes returns image unchanged. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes with shape [num_instances, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio_range: allowed range for aspect ratio of cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. Returns: image: image which is the same rank as input image. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. labels: new labels. If masks, or keypoints is not None, the function also returns: masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] """ with tf.name_scope('RandomCropImage', values=[image, boxes]): image_shape = tf.shape(image) # boxes are [N, 4]. Lets first make them [N, 1, 4]. boxes_expanded = tf.expand_dims( tf.clip_by_value( boxes, clip_value_min=0.0, clip_value_max=1.0), 1) sample_distorted_bounding_box = tf.image.sample_distorted_bounding_box( image_shape, bounding_boxes=boxes_expanded, min_object_covered=min_object_covered, aspect_ratio_range=aspect_ratio_range, area_range=area_range, max_attempts=100, use_image_if_no_bounding_boxes=True) im_box_begin, im_box_size, im_box = sample_distorted_bounding_box new_image = tf.slice(image, im_box_begin, im_box_size) new_image.set_shape([None, None, image.get_shape()[2]]) # [1, 4] im_box_rank2 = tf.squeeze(im_box, squeeze_dims=[0]) # [4] im_box_rank1 = tf.squeeze(im_box) boxlist = box_list.BoxList(boxes) boxlist.add_field('labels', labels) im_boxlist = box_list.BoxList(im_box_rank2) # remove boxes that are outside cropped image boxlist, inside_window_ids = box_list_ops.prune_completely_outside_window( boxlist, im_box_rank1) # remove boxes that are outside image overlapping_boxlist, keep_ids = box_list_ops.prune_non_overlapping_boxes( boxlist, im_boxlist, overlap_thresh) # change the coordinate of the remaining boxes new_labels = overlapping_boxlist.get_field('labels') new_boxlist = box_list_ops.change_coordinate_frame(overlapping_boxlist, im_box_rank1) new_boxes = new_boxlist.get() new_boxes = tf.clip_by_value( new_boxes, clip_value_min=0.0, clip_value_max=1.0) result = [new_image, new_boxes, new_labels] if masks is not None: masks_of_boxes_inside_window = tf.gather(masks, inside_window_ids) masks_of_boxes_completely_inside_window = tf.gather( masks_of_boxes_inside_window, keep_ids) masks_box_begin = [0, im_box_begin[0], im_box_begin[1]] masks_box_size = [-1, im_box_size[0], im_box_size[1]] new_masks = tf.slice( masks_of_boxes_completely_inside_window, masks_box_begin, masks_box_size) result.append(new_masks) if keypoints is not None: keypoints_of_boxes_inside_window = tf.gather(keypoints, inside_window_ids) keypoints_of_boxes_completely_inside_window = tf.gather( keypoints_of_boxes_inside_window, keep_ids) new_keypoints = keypoint_ops.change_coordinate_frame( keypoints_of_boxes_completely_inside_window, im_box_rank1) new_keypoints = keypoint_ops.prune_outside_window(new_keypoints, [0.0, 0.0, 1.0, 1.0]) result.append(new_keypoints) return tuple(result) def random_crop_image(image, boxes, labels, masks=None, keypoints=None, min_object_covered=1.0, aspect_ratio_range=(0.75, 1.33), area_range=(0.1, 1.0), overlap_thresh=0.3, random_coef=0.0, seed=None): """Randomly crops the image. Given the input image and its bounding boxes, this op randomly crops a subimage. Given a user-provided set of input constraints, the crop window is resampled until it satisfies these constraints. If within 100 trials it is unable to find a valid crop, the original image is returned. See the Args section for a description of the input constraints. Both input boxes and returned Boxes are in normalized form (e.g., lie in the unit square [0, 1]). This function will return the original image with probability random_coef. Note: boxes will be clipped to the crop. Keypoint coordinates that are outside the crop will be set to NaN, which is consistent with the original keypoint encoding for non-existing keypoints. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes with shape [num_instances, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio_range: allowed range for aspect ratio of cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. random_coef: a random coefficient that defines the chance of getting the original image. If random_coef is 0, we will always get the cropped image, and if it is 1.0, we will always get the original image. seed: random seed. Returns: image: Image shape will be [new_height, new_width, channels]. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. labels: new labels. If masks, or keypoints are not None, the function also returns: masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] """ def strict_random_crop_image_fn(): return _strict_random_crop_image( image, boxes, labels, masks=masks, keypoints=keypoints, min_object_covered=min_object_covered, aspect_ratio_range=aspect_ratio_range, area_range=area_range, overlap_thresh=overlap_thresh) # avoids tf.cond to make faster RCNN training on borg. See b/140057645. if random_coef < sys.float_info.min: result = strict_random_crop_image_fn() else: do_a_crop_random = tf.random_uniform([], seed=seed) do_a_crop_random = tf.greater(do_a_crop_random, random_coef) outputs = [image, boxes, labels] if masks is not None: outputs.append(masks) if keypoints is not None: outputs.append(keypoints) result = tf.cond(do_a_crop_random, strict_random_crop_image_fn, lambda: tuple(outputs)) return result def random_pad_image(image, boxes, min_image_size=None, max_image_size=None, pad_color=None, seed=None): """Randomly pads the image. This function randomly pads the image with zeros. The final size of the padded image will be between min_image_size and max_image_size. if min_image_size is smaller than the input image size, min_image_size will be set to the input image size. The same for max_image_size. The input image will be located at a uniformly random location inside the padded image. The relative location of the boxes to the original image will remain the same. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. min_image_size: a tensor of size [min_height, min_width], type tf.int32. If passed as None, will be set to image size [height, width]. max_image_size: a tensor of size [max_height, max_width], type tf.int32. If passed as None, will be set to twice the image [height * 2, width * 2]. pad_color: padding color. A rank 1 tensor of [3] with dtype=tf.float32. if set as None, it will be set to average color of the input image. seed: random seed. Returns: image: Image shape will be [new_height, new_width, channels]. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. """ if pad_color is None: pad_color = tf.reduce_mean(image, reduction_indices=[0, 1]) image_shape = tf.shape(image) image_height = image_shape[0] image_width = image_shape[1] if max_image_size is None: max_image_size = tf.stack([image_height * 2, image_width * 2]) max_image_size = tf.maximum(max_image_size, tf.stack([image_height, image_width])) if min_image_size is None: min_image_size = tf.stack([image_height, image_width]) min_image_size = tf.maximum(min_image_size, tf.stack([image_height, image_width])) target_height = tf.cond( max_image_size[0] > min_image_size[0], lambda: _random_integer(min_image_size[0], max_image_size[0], seed), lambda: max_image_size[0]) target_width = tf.cond( max_image_size[1] > min_image_size[1], lambda: _random_integer(min_image_size[1], max_image_size[1], seed), lambda: max_image_size[1]) offset_height = tf.cond( target_height > image_height, lambda: _random_integer(0, target_height - image_height, seed), lambda: tf.constant(0, dtype=tf.int32)) offset_width = tf.cond( target_width > image_width, lambda: _random_integer(0, target_width - image_width, seed), lambda: tf.constant(0, dtype=tf.int32)) new_image = tf.image.pad_to_bounding_box( image, offset_height=offset_height, offset_width=offset_width, target_height=target_height, target_width=target_width) # Setting color of the padded pixels image_ones = tf.ones_like(image) image_ones_padded = tf.image.pad_to_bounding_box( image_ones, offset_height=offset_height, offset_width=offset_width, target_height=target_height, target_width=target_width) image_color_paded = (1.0 - image_ones_padded) * pad_color new_image += image_color_paded # setting boxes new_window = tf.to_float( tf.stack([ -offset_height, -offset_width, target_height - offset_height, target_width - offset_width ])) new_window /= tf.to_float( tf.stack([image_height, image_width, image_height, image_width])) boxlist = box_list.BoxList(boxes) new_boxlist = box_list_ops.change_coordinate_frame(boxlist, new_window) new_boxes = new_boxlist.get() return new_image, new_boxes def random_crop_pad_image(image, boxes, labels, min_object_covered=1.0, aspect_ratio_range=(0.75, 1.33), area_range=(0.1, 1.0), overlap_thresh=0.3, random_coef=0.0, min_padded_size_ratio=None, max_padded_size_ratio=None, pad_color=None, seed=None): """Randomly crops and pads the image. Given an input image and its bounding boxes, this op first randomly crops the image and then randomly pads the image with background values. Parameters min_padded_size_ratio and max_padded_size_ratio, determine the range of the final output image size. Specifically, the final image size will have a size in the range of min_padded_size_ratio * tf.shape(image) and max_padded_size_ratio * tf.shape(image). Note that these ratios are with respect to the size of the original image, so we can't capture the same effect easily by independently applying RandomCropImage followed by RandomPadImage. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio_range: allowed range for aspect ratio of cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. random_coef: a random coefficient that defines the chance of getting the original image. If random_coef is 0, we will always get the cropped image, and if it is 1.0, we will always get the original image. min_padded_size_ratio: min ratio of padded image height and width to the input image's height and width. If None, it will be set to [0.0, 0.0]. max_padded_size_ratio: max ratio of padded image height and width to the input image's height and width. If None, it will be set to [2.0, 2.0]. pad_color: padding color. A rank 1 tensor of [3] with dtype=tf.float32. if set as None, it will be set to average color of the randomly cropped image. seed: random seed. Returns: padded_image: padded image. padded_boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. cropped_labels: cropped labels. """ image_size = tf.shape(image) image_height = image_size[0] image_width = image_size[1] if min_padded_size_ratio is None: min_padded_size_ratio = tf.constant([0.0, 0.0], tf.float32) if max_padded_size_ratio is None: max_padded_size_ratio = tf.constant([2.0, 2.0], tf.float32) cropped_image, cropped_boxes, cropped_labels = random_crop_image( image=image, boxes=boxes, labels=labels, min_object_covered=min_object_covered, aspect_ratio_range=aspect_ratio_range, area_range=area_range, overlap_thresh=overlap_thresh, random_coef=random_coef, seed=seed) min_image_size = tf.to_int32( tf.to_float(tf.stack([image_height, image_width])) * min_padded_size_ratio) max_image_size = tf.to_int32( tf.to_float(tf.stack([image_height, image_width])) * max_padded_size_ratio) padded_image, padded_boxes = random_pad_image( cropped_image, cropped_boxes, min_image_size=min_image_size, max_image_size=max_image_size, pad_color=pad_color, seed=seed) return padded_image, padded_boxes, cropped_labels def random_crop_to_aspect_ratio(image, boxes, labels, masks=None, keypoints=None, aspect_ratio=1.0, overlap_thresh=0.3, seed=None): """Randomly crops an image to the specified aspect ratio. Randomly crops the a portion of the image such that the crop is of the specified aspect ratio, and the crop is as large as possible. If the specified aspect ratio is larger than the aspect ratio of the image, this op will randomly remove rows from the top and bottom of the image. If the specified aspect ratio is less than the aspect ratio of the image, this op will randomly remove cols from the left and right of the image. If the specified aspect ratio is the same as the aspect ratio of the image, this op will return the image. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. aspect_ratio: the aspect ratio of cropped image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. seed: random seed. Returns: image: image which is the same rank as input image. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. labels: new labels. If masks, or keypoints is not None, the function also returns: masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] Raises: ValueError: If image is not a 3D tensor. """ if len(image.get_shape()) != 3: raise ValueError('Image should be 3D tensor') with tf.name_scope('RandomCropToAspectRatio', values=[image]): image_shape = tf.shape(image) orig_height = image_shape[0] orig_width = image_shape[1] orig_aspect_ratio = tf.to_float(orig_width) / tf.to_float(orig_height) new_aspect_ratio = tf.constant(aspect_ratio, dtype=tf.float32) def target_height_fn(): return tf.to_int32( tf.round( tf.to_float(orig_height) * orig_aspect_ratio / new_aspect_ratio)) target_height = tf.cond( orig_aspect_ratio >= new_aspect_ratio, lambda: orig_height, target_height_fn) def target_width_fn(): return tf.to_int32( tf.round( tf.to_float(orig_width) * new_aspect_ratio / orig_aspect_ratio)) target_width = tf.cond( orig_aspect_ratio <= new_aspect_ratio, lambda: orig_width, target_width_fn) # either offset_height = 0 and offset_width is randomly chosen from # [0, offset_width - target_width), or else offset_width = 0 and # offset_height is randomly chosen from [0, offset_height - target_height) offset_height = _random_integer(0, orig_height - target_height + 1, seed) offset_width = _random_integer(0, orig_width - target_width + 1, seed) new_image = tf.image.crop_to_bounding_box( image, offset_height, offset_width, target_height, target_width) im_box = tf.stack([ tf.to_float(offset_height) / tf.to_float(orig_height), tf.to_float(offset_width) / tf.to_float(orig_width), tf.to_float(offset_height + target_height) / tf.to_float(orig_height), tf.to_float(offset_width + target_width) / tf.to_float(orig_width) ]) boxlist = box_list.BoxList(boxes) boxlist.add_field('labels', labels) im_boxlist = box_list.BoxList(tf.expand_dims(im_box, 0)) # remove boxes whose overlap with the image is less than overlap_thresh overlapping_boxlist, keep_ids = box_list_ops.prune_non_overlapping_boxes( boxlist, im_boxlist, overlap_thresh) # change the coordinate of the remaining boxes new_labels = overlapping_boxlist.get_field('labels') new_boxlist = box_list_ops.change_coordinate_frame(overlapping_boxlist, im_box) new_boxlist = box_list_ops.clip_to_window(new_boxlist, tf.constant( [0.0, 0.0, 1.0, 1.0], tf.float32)) new_boxes = new_boxlist.get() result = [new_image, new_boxes, new_labels] if masks is not None: masks_inside_window = tf.gather(masks, keep_ids) masks_box_begin = tf.stack([0, offset_height, offset_width]) masks_box_size = tf.stack([-1, target_height, target_width]) new_masks = tf.slice(masks_inside_window, masks_box_begin, masks_box_size) result.append(new_masks) if keypoints is not None: keypoints_inside_window = tf.gather(keypoints, keep_ids) new_keypoints = keypoint_ops.change_coordinate_frame( keypoints_inside_window, im_box) new_keypoints = keypoint_ops.prune_outside_window(new_keypoints, [0.0, 0.0, 1.0, 1.0]) result.append(new_keypoints) return tuple(result) def random_black_patches(image, max_black_patches=10, probability=0.5, size_to_image_ratio=0.1, random_seed=None): """Randomly adds some black patches to the image. This op adds up to max_black_patches square black patches of a fixed size to the image where size is specified via the size_to_image_ratio parameter. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels] with pixel values varying between [0, 1]. max_black_patches: number of times that the function tries to add a black box to the image. probability: at each try, what is the chance of adding a box. size_to_image_ratio: Determines the ratio of the size of the black patches to the size of the image. box_size = size_to_image_ratio * min(image_width, image_height) random_seed: random seed. Returns: image """ def add_black_patch_to_image(image): """Function for adding one patch to the image. Args: image: image Returns: image with a randomly added black box """ image_shape = tf.shape(image) image_height = image_shape[0] image_width = image_shape[1] box_size = tf.to_int32( tf.multiply( tf.minimum(tf.to_float(image_height), tf.to_float(image_width)), size_to_image_ratio)) normalized_y_min = tf.random_uniform( [], minval=0.0, maxval=(1.0 - size_to_image_ratio), seed=random_seed) normalized_x_min = tf.random_uniform( [], minval=0.0, maxval=(1.0 - size_to_image_ratio), seed=random_seed) y_min = tf.to_int32(normalized_y_min * tf.to_float(image_height)) x_min = tf.to_int32(normalized_x_min * tf.to_float(image_width)) black_box = tf.ones([box_size, box_size, 3], dtype=tf.float32) mask = 1.0 - tf.image.pad_to_bounding_box(black_box, y_min, x_min, image_height, image_width) image = tf.multiply(image, mask) return image with tf.name_scope('RandomBlackPatchInImage', values=[image]): for _ in range(max_black_patches): random_prob = tf.random_uniform([], minval=0.0, maxval=1.0, dtype=tf.float32, seed=random_seed) image = tf.cond( tf.greater(random_prob, probability), lambda: image, lambda: add_black_patch_to_image(image)) return image def image_to_float(image): """Used in Faster R-CNN. Casts image pixel values to float. Args: image: input image which might be in tf.uint8 or sth else format Returns: image: image in tf.float32 format. """ with tf.name_scope('ImageToFloat', values=[image]): image = tf.to_float(image) return image def random_resize_method(image, target_size): """Uses a random resize method to resize the image to target size. Args: image: a rank 3 tensor. target_size: a list of [target_height, target_width] Returns: resized image. """ resized_image = _apply_with_random_selector( image, lambda x, method: tf.image.resize_images(x, target_size, method), num_cases=4) return resized_image def _compute_new_static_size(image, min_dimension, max_dimension): """Compute new static shape for resize_to_range method.""" image_shape = image.get_shape().as_list() orig_height = image_shape[0] orig_width = image_shape[1] orig_min_dim = min(orig_height, orig_width) # Calculates the larger of the possible sizes large_scale_factor = min_dimension / float(orig_min_dim) # Scaling orig_(height|width) by large_scale_factor will make the smaller # dimension equal to min_dimension, save for floating point rounding errors. # For reasonably-sized images, taking the nearest integer will reliably # eliminate this error. large_height = int(round(orig_height * large_scale_factor)) large_width = int(round(orig_width * large_scale_factor)) large_size = [large_height, large_width] if max_dimension: # Calculates the smaller of the possible sizes, use that if the larger # is too big. orig_max_dim = max(orig_height, orig_width) small_scale_factor = max_dimension / float(orig_max_dim) # Scaling orig_(height|width) by small_scale_factor will make the larger # dimension equal to max_dimension, save for floating point rounding # errors. For reasonably-sized images, taking the nearest integer will # reliably eliminate this error. small_height = int(round(orig_height * small_scale_factor)) small_width = int(round(orig_width * small_scale_factor)) small_size = [small_height, small_width] new_size = large_size if max(large_size) > max_dimension: new_size = small_size else: new_size = large_size return tf.constant(new_size) def _compute_new_dynamic_size(image, min_dimension, max_dimension): """Compute new dynamic shape for resize_to_range method.""" image_shape = tf.shape(image) orig_height = tf.to_float(image_shape[0]) orig_width = tf.to_float(image_shape[1]) orig_min_dim = tf.minimum(orig_height, orig_width) # Calculates the larger of the possible sizes min_dimension = tf.constant(min_dimension, dtype=tf.float32) large_scale_factor = min_dimension / orig_min_dim # Scaling orig_(height|width) by large_scale_factor will make the smaller # dimension equal to min_dimension, save for floating point rounding errors. # For reasonably-sized images, taking the nearest integer will reliably # eliminate this error. large_height = tf.to_int32(tf.round(orig_height * large_scale_factor)) large_width = tf.to_int32(tf.round(orig_width * large_scale_factor)) large_size = tf.stack([large_height, large_width]) if max_dimension: # Calculates the smaller of the possible sizes, use that if the larger # is too big. orig_max_dim = tf.maximum(orig_height, orig_width) max_dimension = tf.constant(max_dimension, dtype=tf.float32) small_scale_factor = max_dimension / orig_max_dim # Scaling orig_(height|width) by small_scale_factor will make the larger # dimension equal to max_dimension, save for floating point rounding # errors. For reasonably-sized images, taking the nearest integer will # reliably eliminate this error. small_height = tf.to_int32(tf.round(orig_height * small_scale_factor)) small_width = tf.to_int32(tf.round(orig_width * small_scale_factor)) small_size = tf.stack([small_height, small_width]) new_size = tf.cond( tf.to_float(tf.reduce_max(large_size)) > max_dimension, lambda: small_size, lambda: large_size) else: new_size = large_size return new_size def resize_to_range(image, masks=None, min_dimension=None, max_dimension=None, align_corners=False): """Resizes an image so its dimensions are within the provided value. The output size can be described by two cases: 1. If the image can be rescaled so its minimum dimension is equal to the provided value without the other dimension exceeding max_dimension, then do so. 2. Otherwise, resize so the largest dimension is equal to max_dimension. Args: image: A 3D tensor of shape [height, width, channels] masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. min_dimension: (optional) (scalar) desired size of the smaller image dimension. max_dimension: (optional) (scalar) maximum allowed size of the larger image dimension. align_corners: bool. If true, exactly align all 4 corners of the input and output. Defaults to False. Returns: A 3D tensor of shape [new_height, new_width, channels], where the image has been resized (with bilinear interpolation) so that min(new_height, new_width) == min_dimension or max(new_height, new_width) == max_dimension. If masks is not None, also outputs masks: A 3D tensor of shape [num_instances, new_height, new_width] Raises: ValueError: if the image is not a 3D tensor. """ if len(image.get_shape()) != 3: raise ValueError('Image should be 3D tensor') with tf.name_scope('ResizeToRange', values=[image, min_dimension]): if image.get_shape().is_fully_defined(): new_size = _compute_new_static_size(image, min_dimension, max_dimension) else: new_size = _compute_new_dynamic_size(image, min_dimension, max_dimension) new_image = tf.image.resize_images(image, new_size, align_corners=align_corners) result = new_image if masks is not None: new_masks = tf.expand_dims(masks, 3) new_masks = tf.image.resize_nearest_neighbor(new_masks, new_size, align_corners=align_corners) new_masks = tf.squeeze(new_masks, 3) result = [new_image, new_masks] return result def scale_boxes_to_pixel_coordinates(image, boxes, keypoints=None): """Scales boxes from normalized to pixel coordinates. Args: image: A 3D float32 tensor of shape [height, width, channels]. boxes: A 2D float32 tensor of shape [num_boxes, 4] containing the bounding boxes in normalized coordinates. Each row is of the form [ymin, xmin, ymax, xmax]. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. Returns: image: unchanged input image. scaled_boxes: a 2D float32 tensor of shape [num_boxes, 4] containing the bounding boxes in pixel coordinates. scaled_keypoints: a 3D float32 tensor with shape [num_instances, num_keypoints, 2] containing the keypoints in pixel coordinates. """ boxlist = box_list.BoxList(boxes) image_height = tf.shape(image)[0] image_width = tf.shape(image)[1] scaled_boxes = box_list_ops.scale(boxlist, image_height, image_width).get() result = [image, scaled_boxes] if keypoints is not None: scaled_keypoints = keypoint_ops.scale(keypoints, image_height, image_width) result.append(scaled_keypoints) return tuple(result) # pylint: disable=g-doc-return-or-yield def resize_image(image, masks=None, new_height=600, new_width=1024, method=tf.image.ResizeMethod.BILINEAR, align_corners=False): """See `tf.image.resize_images` for detailed doc.""" with tf.name_scope( 'ResizeImage', values=[image, new_height, new_width, method, align_corners]): new_image = tf.image.resize_images(image, [new_height, new_width], method=method, align_corners=align_corners) result = new_image if masks is not None: num_instances = tf.shape(masks)[0] new_size = tf.constant([new_height, new_width], dtype=tf.int32) def resize_masks_branch(): new_masks = tf.expand_dims(masks, 3) new_masks = tf.image.resize_nearest_neighbor( new_masks, new_size, align_corners=align_corners) new_masks = tf.squeeze(new_masks, axis=3) return new_masks def reshape_masks_branch(): new_masks = tf.reshape(masks, [0, new_size[0], new_size[1]]) return new_masks masks = tf.cond(num_instances > 0, resize_masks_branch, reshape_masks_branch) result = [new_image, masks] return result def subtract_channel_mean(image, means=None): """Normalizes an image by subtracting a mean from each channel. Args: image: A 3D tensor of shape [height, width, channels] means: float list containing a mean for each channel Returns: normalized_images: a tensor of shape [height, width, channels] Raises: ValueError: if images is not a 4D tensor or if the number of means is not equal to the number of channels. """ with tf.name_scope('SubtractChannelMean', values=[image, means]): if len(image.get_shape()) != 3: raise ValueError('Input must be of size [height, width, channels]') if len(means) != image.get_shape()[-1]: raise ValueError('len(means) must match the number of channels') return image - [[means]] def one_hot_encoding(labels, num_classes=None): """One-hot encodes the multiclass labels. Example usage: labels = tf.constant([1, 4], dtype=tf.int32) one_hot = OneHotEncoding(labels, num_classes=5) one_hot.eval() # evaluates to [0, 1, 0, 0, 1] Args: labels: A tensor of shape [None] corresponding to the labels. num_classes: Number of classes in the dataset. Returns: onehot_labels: a tensor of shape [num_classes] corresponding to the one hot encoding of the labels. Raises: ValueError: if num_classes is not specified. """ with tf.name_scope('OneHotEncoding', values=[labels]): if num_classes is None: raise ValueError('num_classes must be specified') labels = tf.one_hot(labels, num_classes, 1, 0) return tf.reduce_max(labels, 0) def rgb_to_gray(image): """Converts a 3 channel RGB image to a 1 channel grayscale image. Args: image: Rank 3 float32 tensor containing 1 image -> [height, width, 3] with pixel values varying between [0, 1]. Returns: image: A single channel grayscale image -> [image, height, 1]. """ return tf.image.rgb_to_grayscale(image) def ssd_random_crop(image, boxes, labels, masks=None, keypoints=None, min_object_covered=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0), aspect_ratio_range=((0.5, 2.0),) * 7, area_range=((0.1, 1.0),) * 7, overlap_thresh=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0), random_coef=(0.15,) * 7, seed=None): """Random crop preprocessing with default parameters as in SSD paper. Liu et al., SSD: Single shot multibox detector. For further information on random crop preprocessing refer to RandomCrop function above. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio_range: allowed range for aspect ratio of cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. random_coef: a random coefficient that defines the chance of getting the original image. If random_coef is 0, we will always get the cropped image, and if it is 1.0, we will always get the original image. seed: random seed. Returns: image: image which is the same rank as input image. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. labels: new labels. If masks, or keypoints is not None, the function also returns: masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] """ def random_crop_selector(selected_result, index): """Applies random_crop_image to selected result. Args: selected_result: A tuple containing image, boxes, labels, keypoints (if not None), and masks (if not None). index: The index that was randomly selected. Returns: A tuple containing image, boxes, labels, keypoints (if not None), and masks (if not None). """ i = 3 image, boxes, labels = selected_result[:i] selected_masks = None selected_keypoints = None if masks is not None: selected_masks = selected_result[i] i += 1 if keypoints is not None: selected_keypoints = selected_result[i] return random_crop_image( image=image, boxes=boxes, labels=labels, masks=selected_masks, keypoints=selected_keypoints, min_object_covered=min_object_covered[index], aspect_ratio_range=aspect_ratio_range[index], area_range=area_range[index], overlap_thresh=overlap_thresh[index], random_coef=random_coef[index], seed=seed) result = _apply_with_random_selector_tuples( tuple( t for t in (image, boxes, labels, masks, keypoints) if t is not None), random_crop_selector, num_cases=len(min_object_covered)) return result def ssd_random_crop_pad(image, boxes, labels, min_object_covered=(0.1, 0.3, 0.5, 0.7, 0.9, 1.0), aspect_ratio_range=((0.5, 2.0),) * 6, area_range=((0.1, 1.0),) * 6, overlap_thresh=(0.1, 0.3, 0.5, 0.7, 0.9, 1.0), random_coef=(0.15,) * 6, min_padded_size_ratio=(None,) * 6, max_padded_size_ratio=(None,) * 6, pad_color=(None,) * 6, seed=None): """Random crop preprocessing with default parameters as in SSD paper. Liu et al., SSD: Single shot multibox detector. For further information on random crop preprocessing refer to RandomCrop function above. Args: image: rank 3 float32 tensor containing 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio_range: allowed range for aspect ratio of cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. random_coef: a random coefficient that defines the chance of getting the original image. If random_coef is 0, we will always get the cropped image, and if it is 1.0, we will always get the original image. min_padded_size_ratio: min ratio of padded image height and width to the input image's height and width. If None, it will be set to [0.0, 0.0]. max_padded_size_ratio: max ratio of padded image height and width to the input image's height and width. If None, it will be set to [2.0, 2.0]. pad_color: padding color. A rank 1 tensor of [3] with dtype=tf.float32. if set as None, it will be set to average color of the randomly cropped image. seed: random seed. Returns: image: Image shape will be [new_height, new_width, channels]. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. new_labels: new labels. """ def random_crop_pad_selector(image_boxes_labels, index): image, boxes, labels = image_boxes_labels return random_crop_pad_image( image, boxes, labels, min_object_covered=min_object_covered[index], aspect_ratio_range=aspect_ratio_range[index], area_range=area_range[index], overlap_thresh=overlap_thresh[index], random_coef=random_coef[index], min_padded_size_ratio=min_padded_size_ratio[index], max_padded_size_ratio=max_padded_size_ratio[index], pad_color=pad_color[index], seed=seed) new_image, new_boxes, new_labels = _apply_with_random_selector_tuples( (image, boxes, labels), random_crop_pad_selector, num_cases=len(min_object_covered)) return new_image, new_boxes, new_labels def ssd_random_crop_fixed_aspect_ratio( image, boxes, labels, masks=None, keypoints=None, min_object_covered=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0), aspect_ratio=1.0, area_range=((0.1, 1.0),) * 7, overlap_thresh=(0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0), random_coef=(0.15,) * 7, seed=None): """Random crop preprocessing with default parameters as in SSD paper. Liu et al., SSD: Single shot multibox detector. For further information on random crop preprocessing refer to RandomCrop function above. The only difference is that the aspect ratio of the crops are fixed. Args: image: rank 3 float32 tensor contains 1 image -> [height, width, channels] with pixel values varying between [0, 1]. boxes: rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. labels: rank 1 int32 tensor containing the object classes. masks: (optional) rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. The masks are of the same height, width as the input `image`. keypoints: (optional) rank 3 float32 tensor with shape [num_instances, num_keypoints, 2]. The keypoints are in y-x normalized coordinates. min_object_covered: the cropped image must cover at least this fraction of at least one of the input bounding boxes. aspect_ratio: aspect ratio of the cropped image. area_range: allowed range for area ratio between cropped image and the original image. overlap_thresh: minimum overlap thresh with new cropped image to keep the box. random_coef: a random coefficient that defines the chance of getting the original image. If random_coef is 0, we will always get the cropped image, and if it is 1.0, we will always get the original image. seed: random seed. Returns: image: image which is the same rank as input image. boxes: boxes which is the same rank as input boxes. Boxes are in normalized form. labels: new labels. If masks, or keypoints is not None, the function also returns: masks: rank 3 float32 tensor with shape [num_instances, height, width] containing instance masks. keypoints: rank 3 float32 tensor with shape [num_instances, num_keypoints, 2] """ aspect_ratio_range = ((aspect_ratio, aspect_ratio),) * len(area_range) crop_result = ssd_random_crop(image, boxes, labels, masks, keypoints, min_object_covered, aspect_ratio_range, area_range, overlap_thresh, random_coef, seed) i = 3 new_image, new_boxes, new_labels = crop_result[:i] new_masks = None new_keypoints = None if masks is not None: new_masks = crop_result[i] i += 1 if keypoints is not None: new_keypoints = crop_result[i] result = random_crop_to_aspect_ratio( new_image, new_boxes, new_labels, new_masks, new_keypoints, aspect_ratio=aspect_ratio, seed=seed) return result def get_default_func_arg_map(include_instance_masks=False, include_keypoints=False): """Returns the default mapping from a preprocessor function to its args. Args: include_instance_masks: If True, preprocessing functions will modify the instance masks, too. include_keypoints: If True, preprocessing functions will modify the keypoints, too. Returns: A map from preprocessing functions to the arguments they receive. """ groundtruth_instance_masks = None if include_instance_masks: groundtruth_instance_masks = ( fields.InputDataFields.groundtruth_instance_masks) groundtruth_keypoints = None if include_keypoints: groundtruth_keypoints = fields.InputDataFields.groundtruth_keypoints prep_func_arg_map = { normalize_image: (fields.InputDataFields.image,), random_horizontal_flip: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_instance_masks, groundtruth_keypoints,), random_pixel_value_scale: (fields.InputDataFields.image,), random_image_scale: (fields.InputDataFields.image, groundtruth_instance_masks,), random_rgb_to_gray: (fields.InputDataFields.image,), random_adjust_brightness: (fields.InputDataFields.image,), random_adjust_contrast: (fields.InputDataFields.image,), random_adjust_hue: (fields.InputDataFields.image,), random_adjust_saturation: (fields.InputDataFields.image,), random_distort_color: (fields.InputDataFields.image,), random_jitter_boxes: (fields.InputDataFields.groundtruth_boxes,), random_crop_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_instance_masks, groundtruth_keypoints,), random_pad_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes), random_crop_pad_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes), random_crop_to_aspect_ratio: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_instance_masks, groundtruth_keypoints,), random_black_patches: (fields.InputDataFields.image,), retain_boxes_above_threshold: ( fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, fields.InputDataFields.groundtruth_label_scores, groundtruth_instance_masks, groundtruth_keypoints,), image_to_float: (fields.InputDataFields.image,), random_resize_method: (fields.InputDataFields.image,), resize_to_range: (fields.InputDataFields.image, groundtruth_instance_masks,), scale_boxes_to_pixel_coordinates: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_keypoints,), flip_boxes: (fields.InputDataFields.groundtruth_boxes,), resize_image: (fields.InputDataFields.image, groundtruth_instance_masks,), subtract_channel_mean: (fields.InputDataFields.image,), one_hot_encoding: (fields.InputDataFields.groundtruth_image_classes,), rgb_to_gray: (fields.InputDataFields.image,), ssd_random_crop: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_instance_masks, groundtruth_keypoints,), ssd_random_crop_pad: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes), ssd_random_crop_fixed_aspect_ratio: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_instance_masks, groundtruth_keypoints,), } return prep_func_arg_map def preprocess(tensor_dict, preprocess_options, func_arg_map=None): """Preprocess images and bounding boxes. Various types of preprocessing (to be implemented) based on the preprocess_options dictionary e.g. "crop image" (affects image and possibly boxes), "white balance image" (affects only image), etc. If self._options is None, no preprocessing is done. Args: tensor_dict: dictionary that contains images, boxes, and can contain other things as well. images-> rank 4 float32 tensor contains 1 image -> [1, height, width, 3]. with pixel values varying between [0, 1] boxes-> rank 2 float32 tensor containing the bounding boxes -> [N, 4]. Boxes are in normalized form meaning their coordinates vary between [0, 1]. Each row is in the form of [ymin, xmin, ymax, xmax]. preprocess_options: It is a list of tuples, where each tuple contains a function and a dictionary that contains arguments and their values. func_arg_map: mapping from preprocessing functions to arguments that they expect to receive and return. Returns: tensor_dict: which contains the preprocessed images, bounding boxes, etc. Raises: ValueError: (a) If the functions passed to Preprocess are not in func_arg_map. (b) If the arguments that a function needs do not exist in tensor_dict. (c) If image in tensor_dict is not rank 4 """ if func_arg_map is None: func_arg_map = get_default_func_arg_map() # changes the images to image (rank 4 to rank 3) since the functions # receive rank 3 tensor for image if fields.InputDataFields.image in tensor_dict: images = tensor_dict[fields.InputDataFields.image] if len(images.get_shape()) != 4: raise ValueError('images in tensor_dict should be rank 4') image = tf.squeeze(images, squeeze_dims=[0]) tensor_dict[fields.InputDataFields.image] = image # Preprocess inputs based on preprocess_options for option in preprocess_options: func, params = option if func not in func_arg_map: raise ValueError('The function %s does not exist in func_arg_map' % (func.__name__)) arg_names = func_arg_map[func] for a in arg_names: if a is not None and a not in tensor_dict: raise ValueError('The function %s requires argument %s' % (func.__name__, a)) def get_arg(key): return tensor_dict[key] if key is not None else None args = [get_arg(a) for a in arg_names] results = func(*args, **params) if not isinstance(results, (list, tuple)): results = (results,) # Removes None args since the return values will not contain those. arg_names = [arg_name for arg_name in arg_names if arg_name is not None] for res, arg_name in zip(results, arg_names): tensor_dict[arg_name] = res # changes the image to images (rank 3 to rank 4) to be compatible to what # we received in the first place if fields.InputDataFields.image in tensor_dict: image = tensor_dict[fields.InputDataFields.image] images = tf.expand_dims(image, 0) tensor_dict[fields.InputDataFields.image] = images return tensor_dict
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 26539, 5935, 436, 16842, 17193, 367, 15212, 14, 199, 199, 6004, 5147, 2877, 5951, 402, 5331, 315, 26471, 9546, 26, 199, 8, 65, 9, 5331, 626, 787, 6781, 370, 3865, 6093, 436, 5343, 666, 12, 199, 8, 66, 9, 5331, 626, 787, 6781, 1454, 370, 6093, 666, 367, 314, 12016, 402, 272, 666, 18336, 3117, 14, 199, 199, 33, 26471, 805, 23192, 282, 663, 402, 4153, 12, 199, 69, 14, 71, 14, 376, 1834, 436, 16842, 17193, 12, 199, 529, 3351, 376, 3439, 641, 3062, 12, 436, 2529, 3062, 14, 199, 7700, 7251, 787, 26, 19311, 286, 20148, 314, 1834, 12, 19311, 15216, 316, 314, 1834, 12, 673, 19311, 13729, 314, 27702, 12, 30347, 12, 28679, 436, 673, 19311, 31292, 351, 316, 314, 16842, 17193, 14, 199, 199, 1918, 23351, 805, 23192, 282, 2345, 63, 807, 1314, 365, 282, 2600, 626, 9033, 199, 14020, 901, 1561, 370, 3932, 10519, 14, 2104, 2893, 12, 199, 3128, 63, 807, 59, 955, 14, 3205, 1451, 7304, 14, 1569, 61, 15164, 314, 1834, 2345, 14, 199, 1918, 1834, 365, 282, 6915, 841, 2345, 26, 359, 17, 12, 4569, 12, 3462, 12, 9245, 61, 543, 199, 2271, 29, 3249, 14, 1609, 708, 14, 710, 19252, 17167, 63, 12922, 365, 282, 6915, 499, 2345, 26, 359, 46, 12, 841, 61, 2382, 199, 262, 1924, 1962, 2337, 365, 282, 5689, 543, 359, 27429, 22036, 21023, 19906, 1055, 199, 3532, 397, 787, 315, 9657, 8983, 11150, 199, 1589, 723, 10021, 1338, 1425, 315, 359, 16, 12, 413, 61, 199, 199, 6295, 867, 3390, 26, 1010, 2345, 63, 807, 12, 5935, 365, 282, 6915, 841, 2345, 12, 1325, 26471, 199, 5777, 9128, 282, 6915, 650, 2345, 367, 6661, 314, 1834, 14, 20227, 12, 6272, 314, 199, 17677, 805, 781, 308, 14167, 314, 1834, 370, 8649, 282, 6915, 650, 2345, 436, 2066, 199, 1129, 986, 652, 370, 314, 3423, 14, 2854, 314, 1284, 402, 314, 23351, 781, 6544, 314, 1834, 199, 894, 370, 6915, 841, 14, 199, 624, 199, 199, 646, 984, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 199, 504, 909, 63, 11934, 14, 1018, 492, 5689, 63, 513, 199, 504, 909, 63, 11934, 14, 1018, 492, 5689, 63, 513, 63, 1483, 199, 504, 909, 63, 11934, 14, 1018, 492, 790, 1403, 63, 1483, 199, 504, 909, 63, 11934, 14, 1018, 492, 4465, 63, 955, 465, 1504, 421, 199, 318, 485, 4998, 63, 1045, 63, 2355, 63, 6662, 8, 88, 12, 2562, 12, 1967, 63, 9403, 304, 523, 408, 22594, 2562, 8, 88, 12, 13680, 395, 543, 13680, 24914, 687, 359, 16, 1396, 1507, 63, 9403, 13, 17, 1055, 819, 3033, 26, 272, 671, 26, 1324, 5878, 14, 272, 2562, 26, 2018, 805, 370, 4838, 14, 272, 1967, 63, 9403, 26, 2018, 1109, 708, 12, 1329, 402, 5560, 370, 2690, 13680, 687, 14, 819, 1803, 26, 272, 710, 754, 402, 2562, 8, 88, 12, 13680, 395, 2382, 2562, 23192, 314, 574, 402, 314, 272, 9759, 465, 282, 2366, 3000, 12, 1325, 13680, 365, 24914, 18774, 14, 523, 408, 523, 10261, 63, 5891, 275, 2833, 14, 2355, 63, 8830, 8798, 23291, 29, 1507, 63, 9403, 12, 2152, 29, 3249, 14, 442, 708, 9, 523, 327, 8325, 314, 3363, 671, 1454, 370, 1373, 402, 314, 2562, 4882, 14, 523, 372, 3304, 63, 1659, 63, 1483, 14, 5628, 779, 1532, 8, 489, 3304, 63, 1659, 63, 1483, 14, 5656, 8, 88, 12, 2833, 14, 1452, 8, 3759, 63, 5891, 12, 1930, 11515, 17, 467, 1930, 9, 639, 367, 1930, 315, 1425, 8, 1507, 63, 9403, 3948, 59, 16, 61, 421, 199, 318, 485, 4998, 63, 1045, 63, 2355, 63, 6662, 63, 11760, 8, 88, 12, 2562, 12, 1967, 63, 9403, 304, 523, 408, 22594, 2562, 8, 88, 12, 13680, 395, 543, 13680, 24914, 687, 359, 16, 1396, 1507, 63, 9403, 13, 17, 1055, 819, 3033, 26, 272, 671, 26, 437, 2008, 402, 1324, 10519, 14, 272, 2562, 26, 2018, 805, 370, 4838, 14, 272, 1967, 63, 9403, 26, 2018, 1109, 708, 12, 1329, 402, 5560, 370, 2690, 13680, 687, 14, 819, 1803, 26, 272, 710, 754, 402, 2562, 8, 88, 12, 13680, 395, 2382, 2562, 23192, 314, 574, 402, 314, 272, 9759, 465, 282, 2366, 3000, 12, 1325, 13680, 365, 24914, 18774, 14, 523, 408, 523, 1967, 63, 3711, 275, 822, 8, 88, 9, 523, 10261, 63, 5891, 275, 2833, 14, 2355, 63, 8830, 8798, 23291, 29, 1507, 63, 9403, 12, 2152, 29, 3249, 14, 442, 708, 9, 523, 327, 8325, 314, 3363, 671, 1454, 370, 1373, 402, 314, 2562, 4882, 14, 819, 6346, 275, 359, 513, 342, 367, 307, 315, 671, 61, 523, 367, 1930, 315, 1425, 8, 1507, 63, 9403, 304, 272, 892, 63, 88, 275, 359, 2785, 63, 1659, 63, 1483, 14, 5656, 8, 84, 12, 2833, 14, 1452, 8, 3759, 63, 5891, 12, 1930, 11515, 17, 61, 367, 307, 315, 671, 61, 272, 1072, 275, 2562, 8, 2960, 8, 1222, 63, 88, 395, 1930, 9, 272, 367, 1335, 315, 1425, 8, 1507, 63, 3711, 304, 489, 6346, 59, 74, 1055, 740, 8, 1199, 59, 74, 566, 819, 367, 284, 315, 1425, 8, 1507, 63, 3711, 304, 272, 6346, 59, 73, 61, 275, 3304, 63, 1659, 63, 1483, 14, 5628, 8, 11760 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 26539, 5935, 436, 16842, 17193, 367, 15212, 14, 199, 199, 6004, 5147, 2877, 5951, 402, 5331, 315, 26471, 9546, 26, 199, 8, 65, 9, 5331, 626, 787, 6781, 370, 3865, 6093, 436, 5343, 666, 12, 199, 8, 66, 9, 5331, 626, 787, 6781, 1454, 370, 6093, 666, 367, 314, 12016, 402, 272, 666, 18336, 3117, 14, 199, 199, 33, 26471, 805, 23192, 282, 663, 402, 4153, 12, 199, 69, 14, 71, 14, 376, 1834, 436, 16842, 17193, 12, 199, 529, 3351, 376, 3439, 641, 3062, 12, 436, 2529, 3062, 14, 199, 7700, 7251, 787, 26, 19311, 286, 20148, 314, 1834, 12, 19311, 15216, 316, 314, 1834, 12, 673, 19311, 13729, 314, 27702, 12, 30347, 12, 28679, 436, 673, 19311, 31292, 351, 316, 314, 16842, 17193, 14, 199, 199, 1918, 23351, 805, 23192, 282, 2345, 63, 807, 1314, 365, 282, 2600, 626, 9033, 199, 14020, 901, 1561, 370, 3932, 10519, 14, 2104, 2893, 12, 199, 3128, 63, 807, 59, 955, 14, 3205, 1451, 7304, 14, 1569, 61, 15164, 314, 1834, 2345, 14, 199, 1918, 1834, 365, 282, 6915, 841, 2345, 26, 359, 17, 12, 4569, 12, 3462, 12, 9245, 61, 543, 199, 2271, 29, 3249, 14, 1609, 708, 14, 710, 19252, 17167, 63, 12922, 365, 282, 6915, 499, 2345, 26, 359, 46, 12, 841, 61, 2382, 199, 262, 1924, 1962, 2337, 365, 282, 5689, 543, 359, 27429, 22036, 21023, 19906, 1055, 199, 3532, 397, 787, 315, 9657, 8983, 11150, 199, 1589, 723, 10021, 1338, 1425, 315, 359, 16, 12, 413, 61, 199, 199, 6295, 867, 3390, 26, 1010, 2345, 63, 807, 12, 5935, 365, 282, 6915, 841, 2345, 12, 1325, 26471, 199, 5777, 9128, 282, 6915, 650, 2345, 367, 6661, 314, 1834, 14, 20227, 12, 6272, 314, 199, 17677, 805, 781, 308, 14167, 314, 1834, 370, 8649, 282, 6915, 650, 2345, 436, 2066, 199, 1129, 986, 652, 370, 314, 3423, 14, 2854, 314, 1284, 402, 314, 23351, 781, 6544, 314, 1834, 199, 894, 370, 6915, 841, 14, 199, 624, 199, 199, 646, 984, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 199, 504, 909, 63, 11934, 14, 1018, 492, 5689, 63, 513, 199, 504, 909, 63, 11934, 14, 1018, 492, 5689, 63, 513, 63, 1483, 199, 504, 909, 63, 11934, 14, 1018, 492, 790, 1403, 63, 1483, 199, 504, 909, 63, 11934, 14, 1018, 492, 4465, 63, 955, 465, 1504, 421, 199, 318, 485, 4998, 63, 1045, 63, 2355, 63, 6662, 8, 88, 12, 2562, 12, 1967, 63, 9403, 304, 523, 408, 22594, 2562, 8, 88, 12, 13680, 395, 543, 13680, 24914, 687, 359, 16, 1396, 1507, 63, 9403, 13, 17, 1055, 819, 3033, 26, 272, 671, 26, 1324, 5878, 14, 272, 2562, 26, 2018, 805, 370, 4838, 14, 272, 1967, 63, 9403, 26, 2018, 1109, 708, 12, 1329, 402, 5560, 370, 2690, 13680, 687, 14, 819, 1803, 26, 272, 710, 754, 402, 2562, 8, 88, 12, 13680, 395, 2382, 2562, 23192, 314, 574, 402, 314, 272, 9759, 465, 282, 2366, 3000, 12, 1325, 13680, 365, 24914, 18774, 14, 523, 408, 523, 10261, 63, 5891, 275, 2833, 14, 2355, 63, 8830, 8798, 23291, 29, 1507, 63, 9403, 12, 2152, 29, 3249, 14, 442, 708, 9, 523, 327, 8325, 314, 3363, 671, 1454, 370, 1373, 402, 314, 2562, 4882, 14, 523, 372, 3304, 63, 1659, 63, 1483, 14, 5628, 779, 1532, 8, 489, 3304, 63, 1659, 63, 1483, 14, 5656, 8, 88, 12, 2833, 14, 1452, 8, 3759, 63, 5891, 12, 1930, 11515, 17, 467, 1930, 9, 639, 367, 1930, 315, 1425, 8, 1507, 63, 9403, 3948, 59, 16, 61, 421, 199, 318, 485, 4998, 63, 1045, 63, 2355, 63, 6662, 63, 11760, 8, 88, 12, 2562, 12, 1967, 63, 9403, 304, 523, 408, 22594, 2562, 8, 88, 12, 13680, 395, 543, 13680, 24914, 687, 359, 16, 1396, 1507, 63, 9403, 13, 17, 1055, 819, 3033, 26, 272, 671, 26, 437, 2008, 402, 1324, 10519, 14, 272, 2562, 26, 2018, 805, 370, 4838, 14, 272, 1967, 63, 9403, 26, 2018, 1109, 708, 12, 1329, 402, 5560, 370, 2690, 13680, 687, 14, 819, 1803, 26, 272, 710, 754, 402, 2562, 8, 88, 12, 13680, 395, 2382, 2562, 23192, 314, 574, 402, 314, 272, 9759, 465, 282, 2366, 3000, 12, 1325, 13680, 365, 24914, 18774, 14, 523, 408, 523, 1967, 63, 3711, 275, 822, 8, 88, 9, 523, 10261, 63, 5891, 275, 2833, 14, 2355, 63, 8830, 8798, 23291, 29, 1507, 63, 9403, 12, 2152, 29, 3249, 14, 442, 708, 9, 523, 327, 8325, 314, 3363, 671, 1454, 370, 1373, 402, 314, 2562, 4882, 14, 819, 6346, 275, 359, 513, 342, 367, 307, 315, 671, 61, 523, 367, 1930, 315, 1425, 8, 1507, 63, 9403, 304, 272, 892, 63, 88, 275, 359, 2785, 63, 1659, 63, 1483, 14, 5656, 8, 84, 12, 2833, 14, 1452, 8, 3759, 63, 5891, 12, 1930, 11515, 17, 61, 367, 307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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 ]
ric2b/Vivaldi-browser
chromium/components/policy/tools/template_writers/writers/plist_strings_writer_unittest.py
10
13019
#!/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. '''Unit tests for writers.plist_strings_writer''' import os import sys if __name__ == '__main__': sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..')) import unittest from writers import writer_unittest_common class PListStringsWriterUnittest(writer_unittest_common.WriterUnittestCommon): '''Unit tests for PListStringsWriter.''' def testEmpty(self): # Test PListStringsWriter in case of empty polices. policy_json = ''' { 'policy_definitions': [], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Chromium preferen"ces', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' }, 'plist_strings') expected_output = ('Chromium.pfm_title = "Chromium";\n' 'Chromium.pfm_description = "Chromium preferen\\"ces";') self.assertEquals(output.strip(), expected_output.strip()) def testEmptyVersion(self): # Test PListStringsWriter in case of empty polices. policy_json = ''' { 'policy_definitions': [], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Chromium preferen"ces', 'desc': 'blah' } } }''' output = self.GetOutput( policy_json, { '_chromium': '1', 'mac_bundle_id': 'com.example.Test', 'version': '39.0.0.0' }, 'plist_strings') expected_output = ('/* chromium version: 39.0.0.0 */\n' 'Chromium.pfm_title = "Chromium";\n' 'Chromium.pfm_description = "Chromium preferen\\"ces";') self.assertEquals(output.strip(), expected_output.strip()) def testMainPolicy(self): # Tests a policy group with a single policy of type 'main'. policy_json = ''' { 'policy_definitions': [ { 'name': 'MainGroup', 'type': 'group', 'caption': 'Caption of main.', 'desc': 'Description of main.', 'policies': ['MainPolicy'], }, { 'name': 'MainPolicy', 'type': 'main', 'supported_on': ['chrome.mac:8-'], 'caption': 'Caption of main policy.', 'desc': 'Description of main policy.', }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Preferences of Google Chrome', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_google_chrome': '1', 'mac_bundle_id': 'com.example.Test' }, 'plist_strings') expected_output = ( 'Google_Chrome.pfm_title = "Google Chrome";\n' 'Google_Chrome.pfm_description = "Preferences of Google Chrome";\n' 'MainPolicy.pfm_title = "Caption of main policy.";\n' 'MainPolicy.pfm_description = "Description of main policy.";') self.assertEquals(output.strip(), expected_output.strip()) def testStringPolicy(self): # Tests a policy group with a single policy of type 'string'. Also test # inheriting group description to policy description. policy_json = ''' { 'policy_definitions': [ { 'name': 'StringGroup', 'type': 'group', 'caption': 'Caption of group.', 'desc': """Description of group. With a newline.""", 'policies': ['StringPolicy'], }, { 'name': 'StringPolicy', 'type': 'string', 'caption': 'Caption of policy.', 'desc': """Description of policy. With a newline.""", 'supported_on': ['chrome.mac:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Preferences of Chromium', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' }, 'plist_strings') expected_output = ('Chromium.pfm_title = "Chromium";\n' 'Chromium.pfm_description = "Preferences of Chromium";\n' 'StringPolicy.pfm_title = "Caption of policy.";\n' 'StringPolicy.pfm_description = ' '"Description of policy.\\nWith a newline.";') self.assertEquals(output.strip(), expected_output.strip()) def testStringListPolicy(self): # Tests a policy group with a single policy of type 'list'. policy_json = ''' { 'policy_definitions': [ { 'name': 'ListGroup', 'type': 'group', 'caption': '', 'desc': '', 'policies': ['ListPolicy'], }, { 'name': 'ListPolicy', 'type': 'list', 'caption': 'Caption of policy.', 'desc': """Description of policy. With a newline.""", 'schema': { 'type': 'array', 'items': { 'type': 'string' }, }, 'supported_on': ['chrome.mac:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Preferences of Chromium', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' }, 'plist_strings') expected_output = ('Chromium.pfm_title = "Chromium";\n' 'Chromium.pfm_description = "Preferences of Chromium";\n' 'ListPolicy.pfm_title = "Caption of policy.";\n' 'ListPolicy.pfm_description = ' '"Description of policy.\\nWith a newline.";') self.assertEquals(output.strip(), expected_output.strip()) def testStringEnumListPolicy(self): # Tests a policy group with a single policy of type 'string-enum-list'. policy_json = ''' { 'policy_definitions': [ { 'name': 'EnumGroup', 'type': 'group', 'caption': '', 'desc': '', 'policies': ['EnumPolicy'], }, { 'name': 'EnumPolicy', 'type': 'string-enum-list', 'caption': 'Caption of policy.', 'desc': """Description of policy. With a newline.""", 'schema': { 'type': 'array', 'items': { 'type': 'string' }, }, 'items': [ { 'name': 'ProxyServerDisabled', 'value': 'one', 'caption': 'Option1' }, { 'name': 'ProxyServerAutoDetect', 'value': 'two', 'caption': 'Option2' }, ], 'supported_on': ['chrome.mac:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Preferences of Chromium', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' }, 'plist_strings') expected_output = ('Chromium.pfm_title = "Chromium";\n' 'Chromium.pfm_description = "Preferences of Chromium";\n' 'EnumPolicy.pfm_title = "Caption of policy.";\n' 'EnumPolicy.pfm_description = ' '"one - Option1\\ntwo - Option2\\n' 'Description of policy.\\nWith a newline.";') self.assertEquals(output.strip(), expected_output.strip()) def testIntEnumPolicy(self): # Tests a policy group with a single policy of type 'int-enum'. policy_json = ''' { 'policy_definitions': [ { 'name': 'EnumGroup', 'type': 'group', 'desc': '', 'caption': '', 'policies': ['EnumPolicy'], }, { 'name': 'EnumPolicy', 'type': 'int-enum', 'desc': 'Description of policy.', 'caption': 'Caption of policy.', 'items': [ { 'name': 'ProxyServerDisabled', 'value': 0, 'caption': 'Option1' }, { 'name': 'ProxyServerAutoDetect', 'value': 1, 'caption': 'Option2' }, ], 'supported_on': ['chrome.mac:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Google Chrome preferences', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2' }, 'plist_strings') expected_output = ( 'Google_Chrome.pfm_title = "Google Chrome";\n' 'Google_Chrome.pfm_description = "Google Chrome preferences";\n' 'EnumPolicy.pfm_title = "Caption of policy.";\n' 'EnumPolicy.pfm_description = ' '"0 - Option1\\n1 - Option2\\nDescription of policy.";\n') self.assertEquals(output.strip(), expected_output.strip()) def testStringEnumPolicy(self): # Tests a policy group with a single policy of type 'string-enum'. policy_json = ''' { 'policy_definitions': [ { 'name': 'EnumGroup', 'type': 'group', 'desc': '', 'caption': '', 'policies': ['EnumPolicy'], }, { 'name': 'EnumPolicy', 'type': 'string-enum', 'desc': 'Description of policy.', 'caption': 'Caption of policy.', 'items': [ { 'name': 'ProxyServerDisabled', 'value': 'one', 'caption': 'Option1' }, { 'name': 'ProxyServerAutoDetect', 'value': 'two', 'caption': 'Option2' }, ], 'supported_on': ['chrome.mac:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Google Chrome preferences', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2' }, 'plist_strings') expected_output = ( 'Google_Chrome.pfm_title = "Google Chrome";\n' 'Google_Chrome.pfm_description = "Google Chrome preferences";\n' 'EnumPolicy.pfm_title = "Caption of policy.";\n' 'EnumPolicy.pfm_description = ' '"one - Option1\\ntwo - Option2\\nDescription of policy.";\n') self.assertEquals(output.strip(), expected_output.strip()) def testNonSupportedPolicy(self): # Tests a policy that is not supported on Mac, so its strings shouldn't # be included in the plist string table. policy_json = ''' { 'policy_definitions': [ { 'name': 'NonMacGroup', 'type': 'group', 'caption': '', 'desc': '', 'policies': ['NonMacPolicy'], }, { 'name': 'NonMacPolicy', 'type': 'string', 'caption': '', 'desc': '', 'supported_on': ['chrome_os:8-'], }, ], 'policy_atomic_group_definitions': [], 'placeholders': [], 'messages': { 'mac_chrome_preferences': { 'text': 'Google Chrome preferences', 'desc': 'blah' } } }''' output = self.GetOutput(policy_json, { '_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2' }, 'plist_strings') expected_output = ( 'Google_Chrome.pfm_title = "Google Chrome";\n' 'Google_Chrome.pfm_description = "Google Chrome preferences";') self.assertEquals(output.strip(), expected_output.strip()) if __name__ == '__main__': unittest.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, 2344, 5072, 2295, 367, 2211, 878, 14, 10265, 63, 5465, 63, 5491, 2344, 199, 199, 646, 747, 199, 646, 984, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 29866, 703, 1333, 199, 199, 646, 2882, 199, 199, 504, 2211, 878, 492, 7060, 63, 2796, 63, 2330, 421, 199, 533, 510, 1296, 12672, 6261, 1358, 1770, 8, 5491, 63, 2796, 63, 2330, 14, 6261, 1358, 1770, 7844, 304, 523, 1449, 5072, 2295, 367, 510, 1296, 12672, 6261, 10595, 819, 347, 511, 4699, 8, 277, 304, 272, 327, 1379, 510, 1296, 12672, 6261, 315, 1930, 402, 2701, 1115, 7598, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 990, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 29381, 876, 1485, 2, 823, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 3185, 63, 1001, 12, 469, 267, 2513, 13211, 356, 283, 17, 297, 267, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 7, 272, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 661, 29381, 14, 9928, 77, 63, 1213, 275, 298, 29381, 2, 3779, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1802, 275, 298, 29381, 876, 1485, 15022, 823, 2, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 4699, 3353, 8, 277, 304, 272, 327, 1379, 510, 1296, 12672, 6261, 315, 1930, 402, 2701, 1115, 7598, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 990, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 29381, 876, 1485, 2, 823, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 267, 4592, 63, 1001, 12, 469, 288, 2513, 13211, 356, 283, 17, 297, 288, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 297, 288, 283, 1023, 356, 283, 1355, 14, 16, 14, 16, 14, 16, 7, 267, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 661, 6331, 682, 7419, 1015, 26, 10551, 14, 16, 14, 16, 14, 16, 9399, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1213, 275, 298, 29381, 2, 3779, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1802, 275, 298, 29381, 876, 1485, 15022, 823, 2, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 6756, 4845, 8, 277, 304, 272, 327, 6496, 282, 4592, 1572, 543, 282, 2849, 4592, 402, 730, 283, 973, 1370, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 359, 881, 469, 288, 283, 354, 356, 283, 6756, 2448, 297, 288, 283, 466, 356, 283, 923, 297, 288, 283, 13410, 356, 283, 28366, 402, 2446, 3130, 288, 283, 3257, 356, 283, 5831, 402, 2446, 3130, 288, 283, 11767, 356, 788, 6756, 4845, 995, 881, 1660, 881, 469, 288, 283, 354, 356, 283, 6756, 4845, 297, 288, 283, 466, 356, 283, 973, 297, 288, 283, 4946, 63, 265, 356, 788, 9887, 14, 3088, 26, 24, 13, 995, 288, 283, 13410, 356, 283, 28366, 402, 2446, 4592, 3130, 288, 283, 3257, 356, 283, 5831, 402, 2446, 4592, 3130, 881, 1660, 267, 2156, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 30772, 402, 4475, 16776, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 3185, 63, 1001, 12, 469, 267, 2513, 3098, 63, 9887, 356, 283, 17, 297, 267, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 7, 272, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 334, 267, 283, 13266, 63, 18083, 14, 9928, 77, 63, 1213, 275, 298, 13266, 16776, 2, 3779, 78, 7, 267, 283, 13266, 63, 18083, 14, 9928, 77, 63, 1802, 275, 298, 30772, 402, 4475, 16776, 2, 3779, 78, 7, 267, 283, 6756, 4845, 14, 9928, 77, 63, 1213, 275, 298, 28366, 402, 2446, 4592, 2122, 3779, 78, 7, 267, 283, 6756, 4845, 14, 9928, 77, 63, 1802, 275, 298, 5831, 402, 2446, 4592, 2122, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 1558, 4845, 8, 277, 304, 272, 327, 6496, 282, 4592, 1572, 543, 282, 2849, 4592, 402, 730, 283, 875, 1370, 6121, 511, 272, 327, 29927, 1572, 1369, 370, 4592, 1369, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 359, 881, 469, 288, 283, 354, 356, 283, 1558, 2448, 297, 288, 283, 466, 356, 283, 923, 297, 288, 283, 13410, 356, 283, 28366, 402, 1572, 3130, 288, 283, 3257, 356, 408, 5831, 402, 1572, 14, 199, 3007, 282, 8057, 17129, 288, 283, 11767, 356, 788, 1558, 4845, 995, 881, 1660, 881, 469, 288, 283, 354, 356, 283, 1558, 4845, 297, 288, 283, 466, 356, 283, 875, 297, 288, 283, 13410, 356, 283, 28366, 402, 4592, 3130, 288, 283, 3257, 356, 408, 5831, 402, 4592, 14, 199, 3007, 282, 8057, 17129, 288, 283, 4946, 63, 265, 356, 788, 9887 ]
[ 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, 2344, 5072, 2295, 367, 2211, 878, 14, 10265, 63, 5465, 63, 5491, 2344, 199, 199, 646, 747, 199, 646, 984, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 29866, 703, 1333, 199, 199, 646, 2882, 199, 199, 504, 2211, 878, 492, 7060, 63, 2796, 63, 2330, 421, 199, 533, 510, 1296, 12672, 6261, 1358, 1770, 8, 5491, 63, 2796, 63, 2330, 14, 6261, 1358, 1770, 7844, 304, 523, 1449, 5072, 2295, 367, 510, 1296, 12672, 6261, 10595, 819, 347, 511, 4699, 8, 277, 304, 272, 327, 1379, 510, 1296, 12672, 6261, 315, 1930, 402, 2701, 1115, 7598, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 990, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 29381, 876, 1485, 2, 823, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 3185, 63, 1001, 12, 469, 267, 2513, 13211, 356, 283, 17, 297, 267, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 7, 272, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 661, 29381, 14, 9928, 77, 63, 1213, 275, 298, 29381, 2, 3779, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1802, 275, 298, 29381, 876, 1485, 15022, 823, 2, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 4699, 3353, 8, 277, 304, 272, 327, 1379, 510, 1296, 12672, 6261, 315, 1930, 402, 2701, 1115, 7598, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 990, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 29381, 876, 1485, 2, 823, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 267, 4592, 63, 1001, 12, 469, 288, 2513, 13211, 356, 283, 17, 297, 288, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 297, 288, 283, 1023, 356, 283, 1355, 14, 16, 14, 16, 14, 16, 7, 267, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 661, 6331, 682, 7419, 1015, 26, 10551, 14, 16, 14, 16, 14, 16, 9399, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1213, 275, 298, 29381, 2, 3779, 78, 7, 2432, 283, 29381, 14, 9928, 77, 63, 1802, 275, 298, 29381, 876, 1485, 15022, 823, 2, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 6756, 4845, 8, 277, 304, 272, 327, 6496, 282, 4592, 1572, 543, 282, 2849, 4592, 402, 730, 283, 973, 1370, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 359, 881, 469, 288, 283, 354, 356, 283, 6756, 2448, 297, 288, 283, 466, 356, 283, 923, 297, 288, 283, 13410, 356, 283, 28366, 402, 2446, 3130, 288, 283, 3257, 356, 283, 5831, 402, 2446, 3130, 288, 283, 11767, 356, 788, 6756, 4845, 995, 881, 1660, 881, 469, 288, 283, 354, 356, 283, 6756, 4845, 297, 288, 283, 466, 356, 283, 973, 297, 288, 283, 4946, 63, 265, 356, 788, 9887, 14, 3088, 26, 24, 13, 995, 288, 283, 13410, 356, 283, 28366, 402, 2446, 4592, 3130, 288, 283, 3257, 356, 283, 5831, 402, 2446, 4592, 3130, 881, 1660, 267, 2156, 267, 283, 3185, 63, 10910, 63, 923, 63, 15388, 356, 990, 267, 283, 22100, 356, 990, 267, 283, 3431, 356, 469, 881, 283, 3088, 63, 9887, 63, 18063, 356, 469, 288, 283, 505, 356, 283, 30772, 402, 4475, 16776, 297, 288, 283, 3257, 356, 283, 12702, 7, 881, 789, 267, 789, 489, 789, 2344, 272, 1072, 275, 291, 14, 18614, 8, 3185, 63, 1001, 12, 469, 267, 2513, 3098, 63, 9887, 356, 283, 17, 297, 267, 283, 3088, 63, 6469, 63, 344, 356, 283, 957, 14, 2694, 14, 774, 7, 272, 1660, 283, 10265, 63, 5465, 358, 272, 1420, 63, 1199, 275, 334, 267, 283, 13266, 63, 18083, 14, 9928, 77, 63, 1213, 275, 298, 13266, 16776, 2, 3779, 78, 7, 267, 283, 13266, 63, 18083, 14, 9928, 77, 63, 1802, 275, 298, 30772, 402, 4475, 16776, 2, 3779, 78, 7, 267, 283, 6756, 4845, 14, 9928, 77, 63, 1213, 275, 298, 28366, 402, 2446, 4592, 2122, 3779, 78, 7, 267, 283, 6756, 4845, 14, 9928, 77, 63, 1802, 275, 298, 5831, 402, 2446, 4592, 2122, 10784, 272, 291, 14, 2947, 8, 1199, 14, 1913, 1062, 1420, 63, 1199, 14, 1913, 1012, 819, 347, 511, 1558, 4845, 8, 277, 304, 272, 327, 6496, 282, 4592, 1572, 543, 282, 2849, 4592, 402, 730, 283, 875, 1370, 6121, 511, 272, 327, 29927, 1572, 1369, 370, 4592, 1369, 14, 272, 4592, 63, 1001, 275, 1449, 489, 469, 267, 283, 3185, 63, 15388, 356, 359, 881, 469, 288, 283, 354, 356, 283, 1558, 2448, 297, 288, 283, 466, 356, 283, 923, 297, 288, 283, 13410, 356, 283, 28366, 402, 1572, 3130, 288, 283, 3257, 356, 408, 5831, 402, 1572, 14, 199, 3007, 282, 8057, 17129, 288, 283, 11767, 356, 788, 1558, 4845, 995, 881, 1660, 881, 469, 288, 283, 354, 356, 283, 1558, 4845, 297, 288, 283, 466, 356, 283, 875, 297, 288, 283, 13410, 356, 283, 28366, 402, 4592, 3130, 288, 283, 3257, 356, 408, 5831, 402, 4592, 14, 199, 3007, 282, 8057, 17129, 288, 283, 4946, 63, 265, 356, 788, 9887, 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 ]
spock1104/android_kernel_zte_msm8930
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py
12980
5411
# SchedGui.py - Python extension for perf script, basic GUI code for # traces drawing and overview. # # Copyright (C) 2010 by Frederic Weisbecker <fweisbec@gmail.com> # # This software is distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. try: import wx except ImportError: raise ImportError, "You need to install the wxpython lib for this script" class RootFrame(wx.Frame): Y_OFFSET = 100 RECT_HEIGHT = 100 RECT_SPACE = 50 EVENT_MARKING_WIDTH = 5 def __init__(self, sched_tracer, title, parent = None, id = -1): wx.Frame.__init__(self, parent, id, title) (self.screen_width, self.screen_height) = wx.GetDisplaySize() self.screen_width -= 10 self.screen_height -= 10 self.zoom = 0.5 self.scroll_scale = 20 self.sched_tracer = sched_tracer self.sched_tracer.set_root_win(self) (self.ts_start, self.ts_end) = sched_tracer.interval() self.update_width_virtual() self.nr_rects = sched_tracer.nr_rectangles() + 1 self.height_virtual = RootFrame.Y_OFFSET + (self.nr_rects * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)) # whole window panel self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height)) # scrollable container self.scroll = wx.ScrolledWindow(self.panel) self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale) self.scroll.EnableScrolling(True, True) self.scroll.SetFocus() # scrollable drawing area self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width - 15, self.screen_height / 2)) self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint) self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press) self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down) self.scroll.Bind(wx.EVT_PAINT, self.on_paint) self.scroll.Bind(wx.EVT_KEY_DOWN, self.on_key_press) self.scroll.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down) self.scroll.Fit() self.Fit() self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, self.height_virtual, wx.SIZE_USE_EXISTING) self.txt = None self.Show(True) def us_to_px(self, val): return val / (10 ** 3) * self.zoom def px_to_us(self, val): return (val / self.zoom) * (10 ** 3) def scroll_start(self): (x, y) = self.scroll.GetViewStart() return (x * self.scroll_scale, y * self.scroll_scale) def scroll_start_us(self): (x, y) = self.scroll_start() return self.px_to_us(x) def paint_rectangle_zone(self, nr, color, top_color, start, end): offset_px = self.us_to_px(start - self.ts_start) width_px = self.us_to_px(end - self.ts_start) offset_py = RootFrame.Y_OFFSET + (nr * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)) width_py = RootFrame.RECT_HEIGHT dc = self.dc if top_color is not None: (r, g, b) = top_color top_color = wx.Colour(r, g, b) brush = wx.Brush(top_color, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangle(offset_px, offset_py, width_px, RootFrame.EVENT_MARKING_WIDTH) width_py -= RootFrame.EVENT_MARKING_WIDTH offset_py += RootFrame.EVENT_MARKING_WIDTH (r ,g, b) = color color = wx.Colour(r, g, b) brush = wx.Brush(color, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangle(offset_px, offset_py, width_px, width_py) def update_rectangles(self, dc, start, end): start += self.ts_start end += self.ts_start self.sched_tracer.fill_zone(start, end) def on_paint(self, event): dc = wx.PaintDC(self.scroll_panel) self.dc = dc width = min(self.width_virtual, self.screen_width) (x, y) = self.scroll_start() start = self.px_to_us(x) end = self.px_to_us(x + width) self.update_rectangles(dc, start, end) def rect_from_ypixel(self, y): y -= RootFrame.Y_OFFSET rect = y / (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE) height = y % (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE) if rect < 0 or rect > self.nr_rects - 1 or height > RootFrame.RECT_HEIGHT: return -1 return rect def update_summary(self, txt): if self.txt: self.txt.Destroy() self.txt = wx.StaticText(self.panel, -1, txt, (0, (self.screen_height / 2) + 50)) def on_mouse_down(self, event): (x, y) = event.GetPositionTuple() rect = self.rect_from_ypixel(y) if rect == -1: return t = self.px_to_us(x) + self.ts_start self.sched_tracer.mouse_down(rect, t) def update_width_virtual(self): self.width_virtual = self.us_to_px(self.ts_end - self.ts_start) def __zoom(self, x): self.update_width_virtual() (xpos, ypos) = self.scroll.GetViewStart() xpos = self.us_to_px(x) / self.scroll_scale self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale, xpos, ypos) self.Refresh() def zoom_in(self): x = self.scroll_start_us() self.zoom *= 2 self.__zoom(x) def zoom_out(self): x = self.scroll_start_us() self.zoom /= 2 self.__zoom(x) def on_key_press(self, event): key = event.GetRawKeyCode() if key == ord("+"): self.zoom_in() return if key == ord("-"): self.zoom_out() return key = event.GetKeyCode() (x, y) = self.scroll.GetViewStart() if key == wx.WXK_RIGHT: self.scroll.Scroll(x + 1, y) elif key == wx.WXK_LEFT: self.scroll.Scroll(x - 1, y) elif key == wx.WXK_DOWN: self.scroll.Scroll(x, y + 1) elif key == wx.WXK_UP: self.scroll.Scroll(x, y - 1)
gpl-2.0
[ 3, 428, 1809, 4324, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 5678, 17160, 1233, 367, 199, 3, 198, 198, 28388, 17455, 436, 23503, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 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, 893, 26, 199, 198, 646, 4818, 199, 2590, 3545, 26, 199, 198, 3730, 3545, 12, 298, 5556, 1929, 370, 3907, 314, 4818, 1548, 1973, 367, 642, 2884, 2, 421, 199, 533, 19059, 8, 6323, 14, 3160, 304, 199, 198, 57, 63, 14839, 275, 2948, 199, 198, 4168, 63, 13509, 275, 2948, 199, 198, 4168, 63, 11658, 275, 5238, 199, 198, 8193, 63, 10520, 1206, 63, 11139, 275, 959, 421, 198, 318, 636, 826, 721, 277, 12, 10286, 63, 16825, 12, 2538, 12, 1676, 275, 488, 12, 1305, 275, 446, 17, 304, 507, 198, 6323, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 1305, 12, 2538, 9, 2742, 198, 8, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 9, 275, 4818, 14, 1002, 7687, 2320, 342, 507, 198, 277, 14, 5410, 63, 2063, 4862, 1616, 507, 198, 277, 14, 5410, 63, 3333, 4862, 1616, 507, 198, 277, 14, 10598, 275, 378, 14, 21, 507, 198, 277, 14, 6755, 63, 3467, 275, 3388, 507, 198, 277, 14, 10487, 63, 16825, 275, 10286, 63, 16825, 507, 198, 277, 14, 10487, 63, 16825, 14, 409, 63, 1231, 63, 2676, 8, 277, 9, 507, 198, 8, 277, 14, 1086, 63, 928, 12, 291, 14, 1086, 63, 500, 9, 275, 10286, 63, 16825, 14, 4284, 342, 507, 198, 277, 14, 873, 63, 2063, 63, 2065, 342, 507, 198, 277, 14, 7865, 63, 23411, 275, 10286, 63, 16825, 14, 7865, 63, 1201, 13162, 342, 435, 413, 507, 198, 277, 14, 3333, 63, 2065, 275, 19059, 14, 57, 63, 14839, 435, 334, 277, 14, 7865, 63, 23411, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 2742, 198, 3, 8852, 4353, 12748, 507, 198, 277, 14, 7885, 275, 4818, 14, 10185, 8, 277, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 430, 2742, 198, 3, 13704, 461, 3970, 507, 198, 277, 14, 6755, 275, 4818, 14, 29145, 4301, 8, 277, 14, 7885, 9, 507, 198, 277, 14, 6755, 14, 1084, 13127, 16264, 8, 277, 14, 6755, 63, 3467, 12, 291, 14, 6755, 63, 3467, 12, 291, 14, 2063, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 12, 291, 14, 3333, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 9, 507, 198, 277, 14, 6755, 14, 6476, 13127, 316, 8, 549, 12, 715, 9, 507, 198, 277, 14, 6755, 14, 1084, 17310, 342, 2742, 198, 3, 13704, 461, 17455, 9150, 507, 198, 277, 14, 6755, 63, 7885, 275, 4818, 14, 10185, 8, 277, 14, 6755, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 446, 4114, 12, 291, 14, 5410, 63, 3333, 1182, 499, 430, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 2742, 198, 277, 14, 6755, 14, 13776, 342, 507, 198, 277, 14, 13776, 342, 2742, 198, 277, 14, 6755, 63, 7885, 14, 1084, 23370, 2801, 17, 12, 446, 17, 12, 291, 14, 2063, 63, 2065, 12, 291, 14, 3333, 63, 2065, 12, 4818, 14, 4305, 63, 4701, 63, 13301, 1206, 9, 2742, 198, 277, 14, 2424, 275, 488, 2742, 198, 277, 14, 6824, 8, 549, 9, 421, 198, 318, 2739, 63, 475, 63, 5326, 8, 277, 12, 1139, 304, 507, 198, 1107, 1139, 1182, 334, 709, 1011, 650, 9, 627, 291, 14, 10598, 421, 198, 318, 21162, 63, 475, 63, 527, 8, 277, 12, 1139, 304, 507, 198, 1107, 334, 637, 1182, 291, 14, 10598, 9, 627, 334, 709, 1011, 650, 9, 421, 198, 318, 13704, 63, 928, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 14, 1002, 2768, 3162, 342, 507, 198, 1107, 334, 88, 627, 291, 14, 6755, 63, 3467, 12, 612, 627, 291, 14, 6755, 63, 3467, 9, 421, 198, 318, 13704, 63, 928, 63, 527, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 63, 928, 342, 507, 198, 1107, 291, 14, 5326, 63, 475, 63, 527, 8, 88, 9, 421, 198, 318, 32055, 63, 19954, 63, 2619, 8, 277, 12, 14762, 12, 3164, 12, 2746, 63, 2326, 12, 1343, 12, 1284, 304, 507, 198, 2743, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 928, 446, 291, 14, 1086, 63, 928, 9, 507, 198, 2063, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 500, 446, 291, 14, 1086, 63, 928, 9, 2742, 198, 2743, 63, 647, 275, 19059, 14, 57, 63, 14839, 435, 334, 7865, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 507, 198, 2063, 63, 647, 275, 19059, 14, 4168, 63, 13509, 2742, 198, 3833, 275, 291, 14, 3833, 2742, 198, 692, 2746, 63, 2326, 365, 440, 488, 26, 686, 198, 8, 82, 12, 486, 12, 330, 9, 275, 2746, 63, 2326, 686, 198, 2119, 63, 2326, 275, 4818, 14 ]
[ 428, 1809, 4324, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 5678, 17160, 1233, 367, 199, 3, 198, 198, 28388, 17455, 436, 23503, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 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, 893, 26, 199, 198, 646, 4818, 199, 2590, 3545, 26, 199, 198, 3730, 3545, 12, 298, 5556, 1929, 370, 3907, 314, 4818, 1548, 1973, 367, 642, 2884, 2, 421, 199, 533, 19059, 8, 6323, 14, 3160, 304, 199, 198, 57, 63, 14839, 275, 2948, 199, 198, 4168, 63, 13509, 275, 2948, 199, 198, 4168, 63, 11658, 275, 5238, 199, 198, 8193, 63, 10520, 1206, 63, 11139, 275, 959, 421, 198, 318, 636, 826, 721, 277, 12, 10286, 63, 16825, 12, 2538, 12, 1676, 275, 488, 12, 1305, 275, 446, 17, 304, 507, 198, 6323, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 1305, 12, 2538, 9, 2742, 198, 8, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 9, 275, 4818, 14, 1002, 7687, 2320, 342, 507, 198, 277, 14, 5410, 63, 2063, 4862, 1616, 507, 198, 277, 14, 5410, 63, 3333, 4862, 1616, 507, 198, 277, 14, 10598, 275, 378, 14, 21, 507, 198, 277, 14, 6755, 63, 3467, 275, 3388, 507, 198, 277, 14, 10487, 63, 16825, 275, 10286, 63, 16825, 507, 198, 277, 14, 10487, 63, 16825, 14, 409, 63, 1231, 63, 2676, 8, 277, 9, 507, 198, 8, 277, 14, 1086, 63, 928, 12, 291, 14, 1086, 63, 500, 9, 275, 10286, 63, 16825, 14, 4284, 342, 507, 198, 277, 14, 873, 63, 2063, 63, 2065, 342, 507, 198, 277, 14, 7865, 63, 23411, 275, 10286, 63, 16825, 14, 7865, 63, 1201, 13162, 342, 435, 413, 507, 198, 277, 14, 3333, 63, 2065, 275, 19059, 14, 57, 63, 14839, 435, 334, 277, 14, 7865, 63, 23411, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 2742, 198, 3, 8852, 4353, 12748, 507, 198, 277, 14, 7885, 275, 4818, 14, 10185, 8, 277, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 430, 2742, 198, 3, 13704, 461, 3970, 507, 198, 277, 14, 6755, 275, 4818, 14, 29145, 4301, 8, 277, 14, 7885, 9, 507, 198, 277, 14, 6755, 14, 1084, 13127, 16264, 8, 277, 14, 6755, 63, 3467, 12, 291, 14, 6755, 63, 3467, 12, 291, 14, 2063, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 12, 291, 14, 3333, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 9, 507, 198, 277, 14, 6755, 14, 6476, 13127, 316, 8, 549, 12, 715, 9, 507, 198, 277, 14, 6755, 14, 1084, 17310, 342, 2742, 198, 3, 13704, 461, 17455, 9150, 507, 198, 277, 14, 6755, 63, 7885, 275, 4818, 14, 10185, 8, 277, 14, 6755, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 446, 4114, 12, 291, 14, 5410, 63, 3333, 1182, 499, 430, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 2742, 198, 277, 14, 6755, 14, 13776, 342, 507, 198, 277, 14, 13776, 342, 2742, 198, 277, 14, 6755, 63, 7885, 14, 1084, 23370, 2801, 17, 12, 446, 17, 12, 291, 14, 2063, 63, 2065, 12, 291, 14, 3333, 63, 2065, 12, 4818, 14, 4305, 63, 4701, 63, 13301, 1206, 9, 2742, 198, 277, 14, 2424, 275, 488, 2742, 198, 277, 14, 6824, 8, 549, 9, 421, 198, 318, 2739, 63, 475, 63, 5326, 8, 277, 12, 1139, 304, 507, 198, 1107, 1139, 1182, 334, 709, 1011, 650, 9, 627, 291, 14, 10598, 421, 198, 318, 21162, 63, 475, 63, 527, 8, 277, 12, 1139, 304, 507, 198, 1107, 334, 637, 1182, 291, 14, 10598, 9, 627, 334, 709, 1011, 650, 9, 421, 198, 318, 13704, 63, 928, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 14, 1002, 2768, 3162, 342, 507, 198, 1107, 334, 88, 627, 291, 14, 6755, 63, 3467, 12, 612, 627, 291, 14, 6755, 63, 3467, 9, 421, 198, 318, 13704, 63, 928, 63, 527, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 63, 928, 342, 507, 198, 1107, 291, 14, 5326, 63, 475, 63, 527, 8, 88, 9, 421, 198, 318, 32055, 63, 19954, 63, 2619, 8, 277, 12, 14762, 12, 3164, 12, 2746, 63, 2326, 12, 1343, 12, 1284, 304, 507, 198, 2743, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 928, 446, 291, 14, 1086, 63, 928, 9, 507, 198, 2063, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 500, 446, 291, 14, 1086, 63, 928, 9, 2742, 198, 2743, 63, 647, 275, 19059, 14, 57, 63, 14839, 435, 334, 7865, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 507, 198, 2063, 63, 647, 275, 19059, 14, 4168, 63, 13509, 2742, 198, 3833, 275, 291, 14, 3833, 2742, 198, 692, 2746, 63, 2326, 365, 440, 488, 26, 686, 198, 8, 82, 12, 486, 12, 330, 9, 275, 2746, 63, 2326, 686, 198, 2119, 63, 2326, 275, 4818, 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,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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 ]
waxmanr/moose
gui/vtk/MeshRenderWidget.py
34
21092
import os, sys, getopt try: from PyQt4 import QtCore, QtGui QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot except ImportError: try: from PySide import QtCore, QtGui QtCore.QString = str except ImportError: raise ImportError("Cannot load either PyQt or PySide") import vtk from vtk.util.colors import peacock, tomato, red, white, black from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor from PeacockActor import PeacockActor from ClippedActor import ClippedActor import RendererFactory class MeshRenderWidget(QtGui.QWidget): def __init__(self, tree_widget): QtGui.QWidget.__init__(self) self.tree_widget = tree_widget self.tree_widget.mesh_item_changed.connect(self.meshItemChanged) self.mesh_file_name = '' self.mesh_renderer = None self.current_block_actors = {} self.current_sideset_actors = {} self.current_nodeset_actors = {} self.this_layout = QtGui.QVBoxLayout() self.setLayout(self.this_layout) self.vtkwidget = QVTKRenderWindowInteractor(self) self.renderer = vtk.vtkRenderer() self.renderer.SetBackground(0.2,0.2,0.2) self.renderer.SetBackground2(1,1,1) self.renderer.SetGradientBackground(1) self.renderer.ResetCamera() self.this_layout.addWidget(self.vtkwidget) self.this_layout.setStretchFactor(self.vtkwidget, 10) self.vtkwidget.setMinimumHeight(300) self.vtkwidget.GetRenderWindow().AddRenderer(self.renderer) self.interactor = self.vtkwidget.GetRenderWindow().GetInteractor() self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera()) self.show() self.interactor.Initialize() self.controls_layout = QtGui.QHBoxLayout() self.left_controls_layout = QtGui.QVBoxLayout() self.block_view_group_box = QtGui.QGroupBox('Show Blocks') self.block_view_group_box.setMaximumWidth(150) # self.block_view_group_box.setMaximumHeight(200) self.block_view_layout = QtGui.QVBoxLayout() self.block_view_list = QtGui.QListView() self.block_view_model = QtGui.QStandardItemModel() self.block_view_model.itemChanged.connect(self._blockViewItemChanged) self.block_view_list.setModel(self.block_view_model) self.block_view_layout.addWidget(self.block_view_list) self.block_view_group_box.setLayout(self.block_view_layout) self.left_controls_layout.addWidget(self.block_view_group_box) self.controls_layout.addLayout(self.left_controls_layout) self.right_controls_layout = QtGui.QVBoxLayout() self.controls_layout.addLayout(self.right_controls_layout) self.view_mesh_checkbox = QtGui.QCheckBox('View Mesh') self.view_mesh_checkbox.setToolTip('Toggle viewing of mesh elements') self.view_mesh_checkbox.setCheckState(QtCore.Qt.Checked) self.view_mesh_checkbox.stateChanged.connect(self.viewMeshCheckboxChanged) self.right_controls_layout.addWidget(self.view_mesh_checkbox) self.highlight_group_box = QtGui.QGroupBox('Highlight') self.highlight_group_box.setMaximumHeight(70) self.highlight_group_box.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) # self.highlight_group_box.setMaximumWidth(200) self.highlight_layout = QtGui.QHBoxLayout() self.highlight_group_box.setLayout(self.highlight_layout) self.right_controls_layout.addWidget(self.highlight_group_box) self.highlight_block_label = QtGui.QLabel('Block:') self.highlight_block_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.highlight_block_combo = QtGui.QComboBox() # self.highlight_block_combo.setMaximumWidth(50) self.highlight_block_combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) self.highlight_block_combo.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) self.highlight_block_combo.setToolTip('Highlight a block in the mesh') self.highlight_block_combo.currentIndexChanged[str].connect(self.showBlockSelected) self.highlight_layout.addWidget(self.highlight_block_label) self.highlight_layout.addWidget(self.highlight_block_combo) self.highlight_sideset_label = QtGui.QLabel('Sideset:') self.highlight_sideset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.highlight_sideset_combo = QtGui.QComboBox() # self.highlight_sideset_combo.setMaximumWidth(50) self.highlight_sideset_combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) self.highlight_sideset_combo.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) self.highlight_sideset_combo.setToolTip('Highlight a sideset in the mesh') self.highlight_sideset_combo.currentIndexChanged[str].connect(self.showSidesetSelected) self.highlight_layout.addWidget(self.highlight_sideset_label) self.highlight_layout.addWidget(self.highlight_sideset_combo) self.highlight_nodeset_label = QtGui.QLabel('Nodeset:') self.highlight_nodeset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.highlight_nodeset_combo = QtGui.QComboBox() # self.highlight_nodeset_combo.setMaximumWidth(50) self.highlight_nodeset_combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) self.highlight_nodeset_combo.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) self.highlight_nodeset_combo.setToolTip('Highlight a nodeset in the mesh') self.highlight_nodeset_combo.currentIndexChanged[str].connect(self.showNodesetSelected) self.highlight_layout.addWidget(self.highlight_nodeset_label) self.highlight_layout.addWidget(self.highlight_nodeset_combo) self.highlight_clear = QtGui.QPushButton('Clear') self.highlight_clear.setToolTip('Clear highlighting') self.highlight_clear.setDisabled(True) self.highlight_clear.clicked.connect(self.clearHighlight) self.highlight_layout.addWidget(self.highlight_clear) self.plane = vtk.vtkPlane() self.plane.SetOrigin(0, 0, 0) self.plane.SetNormal(1, 0, 0) self.clip_groupbox = QtGui.QGroupBox("Clip") self.clip_groupbox.setToolTip('Toggle clip mode to slice the mesh open along a plane') self.clip_groupbox.setCheckable(True) self.clip_groupbox.setChecked(False) self.clip_groupbox.setMaximumHeight(70) self.clip_groupbox.toggled[bool].connect(self._clippingToggled) clip_layout = QtGui.QHBoxLayout() self.clip_plane_combobox = QtGui.QComboBox() self.clip_plane_combobox.setToolTip('Direction of the normal for the clip plane') self.clip_plane_combobox.addItem('x') self.clip_plane_combobox.addItem('y') self.clip_plane_combobox.addItem('z') self.clip_plane_combobox.currentIndexChanged[str].connect(self._clipNormalChanged) clip_layout.addWidget(self.clip_plane_combobox) self.clip_plane_slider = QtGui.QSlider(QtCore.Qt.Horizontal) self.clip_plane_slider.setToolTip('Slide to change plane position') self.clip_plane_slider.setRange(0, 100) self.clip_plane_slider.setSliderPosition(50) self.clip_plane_slider.sliderMoved[int].connect(self._clipSliderMoved) clip_layout.addWidget(self.clip_plane_slider) # vbox->addStretch(1); self.clip_groupbox.setLayout(clip_layout) self.right_controls_layout.addWidget(self.clip_groupbox) self.this_layout.addLayout(self.controls_layout) self.this_layout.setStretchFactor(self.controls_layout, 1) self.bounds = {} self.bounds['x'] = [0.0, 0.0] self.bounds['y'] = [0.0, 0.0] self.bounds['z'] = [0.0, 0.0] # self.draw_edges_checkbox = QtGui.QCheckBox("View Mesh") # self.left_controls_layout.addWidget(self.draw_edges_checkbox) def clear(self): self.highlight_block_combo.clear() self.highlight_sideset_combo.clear() self.highlight_nodeset_combo.clear() for block_actor_name, block_actor in self.current_block_actors.items(): block_actor.hide() for sideset_actor_name, sideset_actor in self.current_sideset_actors.items(): sideset_actor.hide() for nodeset_actor_name, nodeset_actor in self.current_nodeset_actors.items(): nodeset_actor.hide() self.current_block_actors = {} self.current_sideset_actors = {} self.current_nodeset_actors = {} def meshItemChanged(self, item): # Disconnect some actions while we fill stuff in if self.mesh_renderer: self.highlight_block_combo.currentIndexChanged[str].disconnect(self.showBlockSelected) self.highlight_sideset_combo.currentIndexChanged[str].disconnect(self.showSidesetSelected) self.highlight_nodeset_combo.currentIndexChanged[str].disconnect(self.showNodesetSelected) self.clear() self.mesh_renderer = RendererFactory.getRenderer(self, item.table_data) if self.mesh_renderer: self.show() else: self.hide() return self.current_block_actors = self.mesh_renderer.block_actors self.current_sideset_actors = self.mesh_renderer.sideset_actors self.current_nodeset_actors = self.mesh_renderer.nodeset_actors self.block_view_model.clear() for block in self.mesh_renderer.blocks: block_display_name = str(block) if block in self.mesh_renderer.block_id_to_name: block_display_name += ' : ' + self.mesh_renderer.block_id_to_name[block] item = QtGui.QStandardItem(str(block_display_name)) item.exodus_block = block item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Checked) self.block_view_model.appendRow(item) for block_actor_name, block_actor in self.current_block_actors.items(): block_actor.show() block_actor.showEdges() block_names = [] for block_actor_id, block_actor in self.current_block_actors.items(): name = block_actor_id.strip(' ') if int(name) in self.mesh_renderer.block_id_to_name: name += ' : ' + self.mesh_renderer.block_id_to_name[int(name)] block_names.append(name) self.highlight_block_combo.addItem('') for block_actor_name in sorted(block_names, key=lambda name: int(name.split(' ')[0])): self.highlight_block_combo.addItem(str(block_actor_name)) sideset_names = [] for sideset_actor_id, sideset_actor in self.current_sideset_actors.items(): sideset_actor.setColor(red) name = sideset_actor_id.strip(' ') if int(name) in self.mesh_renderer.sideset_id_to_name: name += ' : ' + self.mesh_renderer.sideset_id_to_name[int(name)] sideset_names.append(name) self.highlight_sideset_combo.addItem('') for sideset_actor_name in sorted(sideset_names, key=lambda name: int(name.split(' ')[0])): self.highlight_sideset_combo.addItem(sideset_actor_name) nodeset_names = [] for nodeset_actor_id, nodeset_actor in self.current_nodeset_actors.items(): nodeset_actor.setColor(red) name = nodeset_actor_id.strip(' ') if int(name) in self.mesh_renderer.nodeset_id_to_name: name += ' : ' + self.mesh_renderer.nodeset_id_to_name[int(name)] nodeset_names.append(name) self.highlight_nodeset_combo.addItem('') for nodeset_actor_name in sorted(nodeset_names, key=lambda name: int(name.split(' ')[0])): self.highlight_nodeset_combo.addItem(nodeset_actor_name) self.highlight_block_combo.currentIndexChanged[str].connect(self.showBlockSelected) self.highlight_sideset_combo.currentIndexChanged[str].connect(self.showSidesetSelected) self.highlight_nodeset_combo.currentIndexChanged[str].connect(self.showNodesetSelected) self.setBounds() # Avoid z-buffer fighting vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset() self.renderer.ResetCamera() self.vtkwidget.repaint() def setBounds(self): for actor_name, actor in self.current_block_actors.items(): current_bounds = actor.getBounds() self.bounds['x'][0] = min(self.bounds['x'][0], current_bounds[0]) self.bounds['x'][1] = max(self.bounds['x'][1], current_bounds[1]) self.bounds['y'][0] = min(self.bounds['y'][0], current_bounds[2]) self.bounds['y'][1] = max(self.bounds['y'][1], current_bounds[3]) self.bounds['z'][0] = min(self.bounds['z'][0], current_bounds[4]) self.bounds['z'][1] = max(self.bounds['z'][1], current_bounds[5]) def swapActors(self, current, new): for old_name, old_actor in current.items(): new[old_name].sync(old_actor) old_actor.hide() def _blockViewItemChanged(self, item): if item.checkState() == QtCore.Qt.Checked: self.current_block_actors[str(item.exodus_block)].show() else: self.current_block_actors[str(item.exodus_block)].hide() self.vtkwidget.repaint() def _clippingToggled(self, value): if value: self.swapActors(self.current_block_actors, self.mesh_renderer.clipped_block_actors) self.current_block_actors = self.mesh_renderer.clipped_block_actors self.swapActors(self.current_sideset_actors, self.mesh_renderer.clipped_sideset_actors) self.current_sideset_actors = self.mesh_renderer.clipped_sideset_actors self.swapActors(self.current_nodeset_actors, self.mesh_renderer.clipped_nodeset_actors) self.current_nodeset_actors = self.mesh_renderer.clipped_nodeset_actors self._clipNormalChanged(self.clip_plane_combobox.currentText()) else: self.swapActors(self.current_block_actors, self.mesh_renderer.block_actors) self.current_block_actors = self.mesh_renderer.block_actors self.swapActors(self.current_sideset_actors, self.mesh_renderer.sideset_actors) self.current_sideset_actors = self.mesh_renderer.sideset_actors self.swapActors(self.current_nodeset_actors, self.mesh_renderer.nodeset_actors) self.current_nodeset_actors = self.mesh_renderer.nodeset_actors self.vtkwidget.repaint() def _clipNormalChanged(self, value): self.plane.SetOrigin(self.bounds['x'][0], self.bounds['y'][0], self.bounds['z'][0]) if value == 'x': self.plane.SetNormal(1, 0, 0) elif value == 'y': self.plane.SetNormal(0, 1, 0) else: self.plane.SetNormal(0, 0, 1) self.clip_plane_slider.setSliderPosition(50) self._clipSliderMoved(50) def _clipSliderMoved(self, value): direction = str(self.clip_plane_combobox.currentText()) step_size = (self.bounds[direction][1] - self.bounds[direction][0])/100.0 steps = value distance = float(steps)*step_size position = self.bounds[direction][0] + distance old = self.plane.GetOrigin() self.plane.SetOrigin(position if direction == 'x' else old[0], position if direction == 'y' else old[1], position if direction == 'z' else old[2]) for actor_name, actor in self.current_sideset_actors.items(): actor.movePlane() for actor_name, actor in self.current_nodeset_actors.items(): actor.movePlane() for actor_name, actor in self.current_block_actors.items(): actor.movePlane() self.vtkwidget.repaint() def viewMeshCheckboxChanged(self, value): if value == QtCore.Qt.Checked: for actor_name, actor in self.current_sideset_actors.items(): actor.showEdges() for actor_name, actor in self.current_nodeset_actors.items(): actor.showEdges() for actor_name, actor in self.current_block_actors.items(): actor.showEdges() else: for actor_name, actor in self.current_sideset_actors.items(): actor.hideEdges() for actor_name, actor in self.current_nodeset_actors.items(): actor.hideEdges() for actor_name, actor in self.current_block_actors.items(): actor.hideEdges() self.vtkwidget.repaint() def clearBlockComboBox(self): self.highlight_block_combo.currentIndexChanged[str].disconnect(self.showBlockSelected) self.highlight_block_combo.setCurrentIndex(0) self.highlight_block_combo.currentIndexChanged[str].connect(self.showBlockSelected) def clearSidesetComboBox(self): self.highlight_sideset_combo.currentIndexChanged[str].disconnect(self.showSidesetSelected) self.highlight_sideset_combo.setCurrentIndex(0) self.highlight_sideset_combo.currentIndexChanged[str].connect(self.showSidesetSelected) def clearNodesetComboBox(self): self.highlight_nodeset_combo.currentIndexChanged[str].disconnect(self.showNodesetSelected) self.highlight_nodeset_combo.setCurrentIndex(0) self.highlight_nodeset_combo.currentIndexChanged[str].connect(self.showNodesetSelected) def showBlockSelected(self, block_name): if block_name != '': self.clearSidesetComboBox() self.clearNodesetComboBox() self.highlightBlock(str(block_name).split(' ')[0]) else: self.clearActors() def showSidesetSelected(self, sideset_name): if sideset_name != '': self.clearBlockComboBox() self.clearNodesetComboBox() self.highlightBoundary(str(sideset_name).split(' ')[0]) else: self.clearActors() def showNodesetSelected(self, nodeset_name): if nodeset_name != '': self.clearBlockComboBox() self.clearSidesetComboBox() self.highlightNodeset(str(nodeset_name).split(' ')[0]) else: self.clearActors() def highlightBoundary(self, boundary): self.highlight_clear.setDisabled(False) # Turn off all sidesets for actor_name, actor in self.current_sideset_actors.items(): actor.hide() # Turn off all nodesets for actor_name, actor in self.current_nodeset_actors.items(): actor.hide() # Turn solids to only edges... but only if they are visible for actor_name, actor in self.current_block_actors.items(): actor.setColor(black) actor.goWireframe() boundaries = boundary.strip("'").split(' ') for the_boundary in boundaries: if the_boundary in self.current_sideset_actors: self.current_sideset_actors[the_boundary].show() elif the_boundary in self.current_nodeset_actors: self.current_nodeset_actors[the_boundary].show() elif the_boundary in self.mesh_renderer.name_to_sideset_id: self.current_sideset_actors[str(self.mesh_renderer.name_to_sideset_id[the_boundary])].show() elif the_boundary in self.mesh_renderer.name_to_nodeset_id: self.current_nodeset_actors[str(self.mesh_renderer.name_to_nodeset_id[the_boundary])].show() self.vtkwidget.repaint() def highlightNodeset(self, boundary): self.highlight_clear.setDisabled(False) # Turn off all sidesets for actor_name, actor in self.current_sideset_actors.items(): actor.hide() # Turn off all nodesets for actor_name, actor in self.current_nodeset_actors.items(): actor.hide() # Turn solids to only edges... but only if they are visible for actor_name, actor in self.current_block_actors.items(): actor.setColor(black) actor.goWireframe() boundaries = boundary.strip("'").split(' ') for the_boundary in boundaries: if the_boundary in self.current_nodeset_actors: self.current_nodeset_actors[the_boundary].show() elif the_boundary in self.mesh_renderer.name_to_nodeset_id: self.current_nodeset_actors[str(self.mesh_renderer.name_to_nodeset_id[the_boundary])].show() self.vtkwidget.repaint() def highlightBlock(self, block): self.highlight_clear.setDisabled(False) # Turn off all sidesets for actor_name, actor in self.current_sideset_actors.items(): actor.hide() # Turn off all nodesets for actor_name, actor in self.current_nodeset_actors.items(): actor.hide() # Turn solids to only edges... for actor_name, actor in self.current_block_actors.items(): actor.setColor(black) actor.goWireframe() blocks = block.strip("'").split(' ') for the_block in blocks: if the_block in self.current_block_actors: self.current_block_actors[the_block].setColor(red) self.current_block_actors[the_block].goSolid() elif the_block in self.mesh_renderer.name_to_block_id: self.current_block_actors[str(self.mesh_renderer.name_to_block_id[the_block])].setColor(red) self.current_block_actors[str(self.mesh_renderer.name_to_block_id[the_block])].goSolid() self.vtkwidget.repaint() def clearActors(self): # Turn off all sidesets for actor_name, actor in self.current_sideset_actors.items(): actor.hide() # Turn off all nodesets for actor_name, actor in self.current_nodeset_actors.items(): actor.hide() # Show solids and edges - but only if something is visible for actor_name, actor in self.current_block_actors.items(): actor.setColor(white) actor.goSolid() self.vtkwidget.repaint() def clearHighlight(self): self.highlight_block_combo.setCurrentIndex(0) self.highlight_sideset_combo.setCurrentIndex(0) self.highlight_nodeset_combo.setCurrentIndex(0) self.highlight_clear.setDisabled(True) self.clearActors()
lgpl-2.1
[ 646, 747, 12, 984, 12, 12733, 199, 199, 893, 26, 272, 687, 14084, 20, 492, 10565, 12, 5928, 272, 10565, 14, 11274, 275, 10565, 14, 24835, 11274, 272, 10565, 14, 15183, 275, 10565, 14, 24835, 15183, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 1611, 15414, 492, 10565, 12, 5928, 267, 10565, 14, 49, 1558, 275, 620, 272, 871, 3545, 26, 267, 746, 3545, 480, 6612, 2248, 1902, 14084, 503, 1611, 15414, 531, 199, 199, 646, 11144, 199, 504, 11144, 14, 1974, 14, 7120, 492, 299, 4489, 331, 346, 12, 370, 569, 79, 12, 8992, 12, 10424, 12, 12136, 199, 504, 11144, 14, 8440, 20, 14, 49, 8156, 43, 9216, 4301, 607, 2967, 630, 492, 1413, 8156, 43, 9216, 4301, 607, 2967, 630, 199, 199, 504, 510, 4489, 331, 346, 12258, 492, 510, 4489, 331, 346, 12258, 199, 504, 445, 3587, 1915, 12258, 492, 445, 3587, 1915, 12258, 199, 199, 646, 10055, 5813, 2927, 199, 199, 533, 603, 10613, 9216, 3339, 8, 10604, 14, 23894, 304, 523, 347, 636, 826, 721, 277, 12, 3123, 63, 3440, 304, 272, 5928, 14, 23894, 855, 826, 721, 277, 9, 272, 291, 14, 2350, 63, 3440, 275, 3123, 63, 3440, 272, 291, 14, 2350, 63, 3440, 14, 6480, 63, 1053, 63, 2489, 14, 2242, 8, 277, 14, 6480, 2081, 6970, 9, 339, 291, 14, 6480, 63, 493, 63, 354, 275, 2125, 339, 291, 14, 6480, 63, 12471, 275, 488, 339, 291, 14, 1818, 63, 1457, 63, 32546, 275, 1052, 272, 291, 14, 1818, 63, 2441, 409, 63, 32546, 275, 1052, 272, 291, 14, 1818, 63, 932, 409, 63, 32546, 275, 1052, 339, 291, 14, 3749, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 409, 4798, 8, 277, 14, 3749, 63, 4209, 9, 339, 291, 14, 5941, 829, 1691, 275, 1413, 8156, 43, 9216, 4301, 607, 2967, 630, 8, 277, 9, 339, 291, 14, 12471, 275, 11144, 14, 11919, 11355, 342, 272, 291, 14, 12471, 14, 1084, 14148, 8, 16, 14, 18, 12, 16, 14, 18, 12, 16, 14, 18, 9, 272, 291, 14, 12471, 14, 1084, 14148, 18, 8, 17, 12, 17, 12, 17, 9, 272, 291, 14, 12471, 14, 1084, 9942, 14148, 8, 17, 9, 272, 291, 14, 12471, 14, 9637, 18425, 342, 339, 291, 14, 3749, 63, 4209, 14, 9475, 8, 277, 14, 5941, 829, 1691, 9, 272, 291, 14, 3749, 63, 4209, 14, 409, 21537, 12666, 8, 277, 14, 5941, 829, 1691, 12, 1616, 9, 339, 291, 14, 5941, 829, 1691, 14, 32608, 8436, 8, 5863, 9, 339, 291, 14, 5941, 829, 1691, 14, 1002, 9216, 4301, 1252, 1123, 11355, 8, 277, 14, 12471, 9, 272, 291, 14, 262, 2967, 630, 275, 291, 14, 5941, 829, 1691, 14, 1002, 9216, 4301, 1252, 1002, 607, 2967, 630, 342, 339, 291, 14, 262, 2967, 630, 14, 1084, 607, 2967, 630, 6609, 8, 11919, 14, 11919, 607, 2967, 630, 6609, 7927, 8571, 18425, 1012, 339, 291, 14, 2384, 342, 272, 291, 14, 262, 2967, 630, 14, 9345, 342, 339, 291, 14, 13658, 63, 4209, 275, 5928, 14, 27088, 18536, 342, 339, 291, 14, 3039, 63, 13658, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 339, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 275, 5928, 14, 49, 2448, 3532, 360, 6824, 8651, 83, 358, 272, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 10915, 6216, 8, 8251, 9, 199, 3, 259, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 10915, 8436, 8, 1840, 9, 339, 291, 14, 1457, 63, 1345, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 1457, 63, 1345, 63, 513, 275, 5928, 14, 49, 23239, 342, 272, 291, 14, 1457, 63, 1345, 63, 1238, 275, 5928, 14, 49, 9232, 2081, 1685, 342, 272, 291, 14, 1457, 63, 1345, 63, 1238, 14, 1053, 6970, 14, 2242, 8, 277, 423, 1457, 2768, 2081, 6970, 9, 272, 291, 14, 1457, 63, 1345, 63, 513, 14, 409, 1685, 8, 277, 14, 1457, 63, 1345, 63, 1238, 9, 272, 291, 14, 1457, 63, 1345, 63, 4209, 14, 9475, 8, 277, 14, 1457, 63, 1345, 63, 513, 9, 339, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 4798, 8, 277, 14, 1457, 63, 1345, 63, 4209, 9, 272, 291, 14, 3039, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 1457, 63, 1345, 63, 923, 63, 1977, 9, 272, 291, 14, 13658, 63, 4209, 14, 30571, 8, 277, 14, 3039, 63, 13658, 63, 4209, 9, 2378, 291, 14, 1019, 63, 13658, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 13658, 63, 4209, 14, 30571, 8, 277, 14, 1019, 63, 13658, 63, 4209, 9, 339, 291, 14, 1345, 63, 6480, 63, 13456, 275, 5928, 14, 49, 20530, 360, 2768, 603, 10613, 358, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 29892, 360, 24743, 2455, 316, 402, 9364, 4008, 358, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 409, 1799, 2223, 8, 10901, 14, 4238, 14, 14627, 9, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 929, 6970, 14, 2242, 8, 277, 14, 1345, 12241, 26366, 6970, 9, 272, 291, 14, 1019, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 1345, 63, 6480, 63, 13456, 9, 339, 291, 14, 14337, 63, 923, 63, 1977, 275, 5928, 14, 49, 2448, 3532, 360, 11688, 4040, 358, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 10915, 8436, 8, 2760, 9, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 21735, 4845, 8, 10604, 14, 19934, 14, 12092, 12839, 316, 12, 5928, 14, 19934, 14, 9515, 9, 199, 3, 259, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 10915, 6216, 8, 1840, 9, 272, 291, 14, 14337, 63, 4209, 275, 5928, 14, 27088, 18536, 342, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 4798, 8, 277, 14, 14337, 63, 4209, 9, 272, 291, 14, 1019, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 14337, 63, 923, 63, 1977, 9, 339, 291, 14, 14337, 63, 1457, 63, 1302, 275, 5928, 14, 19890, 360, 3142, 10993, 272, 291, 14, 14337, 63, 1457, 63, 1302, 14, 409, 16613, 8, 10901 ]
[ 747, 12, 984, 12, 12733, 199, 199, 893, 26, 272, 687, 14084, 20, 492, 10565, 12, 5928, 272, 10565, 14, 11274, 275, 10565, 14, 24835, 11274, 272, 10565, 14, 15183, 275, 10565, 14, 24835, 15183, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 1611, 15414, 492, 10565, 12, 5928, 267, 10565, 14, 49, 1558, 275, 620, 272, 871, 3545, 26, 267, 746, 3545, 480, 6612, 2248, 1902, 14084, 503, 1611, 15414, 531, 199, 199, 646, 11144, 199, 504, 11144, 14, 1974, 14, 7120, 492, 299, 4489, 331, 346, 12, 370, 569, 79, 12, 8992, 12, 10424, 12, 12136, 199, 504, 11144, 14, 8440, 20, 14, 49, 8156, 43, 9216, 4301, 607, 2967, 630, 492, 1413, 8156, 43, 9216, 4301, 607, 2967, 630, 199, 199, 504, 510, 4489, 331, 346, 12258, 492, 510, 4489, 331, 346, 12258, 199, 504, 445, 3587, 1915, 12258, 492, 445, 3587, 1915, 12258, 199, 199, 646, 10055, 5813, 2927, 199, 199, 533, 603, 10613, 9216, 3339, 8, 10604, 14, 23894, 304, 523, 347, 636, 826, 721, 277, 12, 3123, 63, 3440, 304, 272, 5928, 14, 23894, 855, 826, 721, 277, 9, 272, 291, 14, 2350, 63, 3440, 275, 3123, 63, 3440, 272, 291, 14, 2350, 63, 3440, 14, 6480, 63, 1053, 63, 2489, 14, 2242, 8, 277, 14, 6480, 2081, 6970, 9, 339, 291, 14, 6480, 63, 493, 63, 354, 275, 2125, 339, 291, 14, 6480, 63, 12471, 275, 488, 339, 291, 14, 1818, 63, 1457, 63, 32546, 275, 1052, 272, 291, 14, 1818, 63, 2441, 409, 63, 32546, 275, 1052, 272, 291, 14, 1818, 63, 932, 409, 63, 32546, 275, 1052, 339, 291, 14, 3749, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 409, 4798, 8, 277, 14, 3749, 63, 4209, 9, 339, 291, 14, 5941, 829, 1691, 275, 1413, 8156, 43, 9216, 4301, 607, 2967, 630, 8, 277, 9, 339, 291, 14, 12471, 275, 11144, 14, 11919, 11355, 342, 272, 291, 14, 12471, 14, 1084, 14148, 8, 16, 14, 18, 12, 16, 14, 18, 12, 16, 14, 18, 9, 272, 291, 14, 12471, 14, 1084, 14148, 18, 8, 17, 12, 17, 12, 17, 9, 272, 291, 14, 12471, 14, 1084, 9942, 14148, 8, 17, 9, 272, 291, 14, 12471, 14, 9637, 18425, 342, 339, 291, 14, 3749, 63, 4209, 14, 9475, 8, 277, 14, 5941, 829, 1691, 9, 272, 291, 14, 3749, 63, 4209, 14, 409, 21537, 12666, 8, 277, 14, 5941, 829, 1691, 12, 1616, 9, 339, 291, 14, 5941, 829, 1691, 14, 32608, 8436, 8, 5863, 9, 339, 291, 14, 5941, 829, 1691, 14, 1002, 9216, 4301, 1252, 1123, 11355, 8, 277, 14, 12471, 9, 272, 291, 14, 262, 2967, 630, 275, 291, 14, 5941, 829, 1691, 14, 1002, 9216, 4301, 1252, 1002, 607, 2967, 630, 342, 339, 291, 14, 262, 2967, 630, 14, 1084, 607, 2967, 630, 6609, 8, 11919, 14, 11919, 607, 2967, 630, 6609, 7927, 8571, 18425, 1012, 339, 291, 14, 2384, 342, 272, 291, 14, 262, 2967, 630, 14, 9345, 342, 339, 291, 14, 13658, 63, 4209, 275, 5928, 14, 27088, 18536, 342, 339, 291, 14, 3039, 63, 13658, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 339, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 275, 5928, 14, 49, 2448, 3532, 360, 6824, 8651, 83, 358, 272, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 10915, 6216, 8, 8251, 9, 199, 3, 259, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 10915, 8436, 8, 1840, 9, 339, 291, 14, 1457, 63, 1345, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 1457, 63, 1345, 63, 513, 275, 5928, 14, 49, 23239, 342, 272, 291, 14, 1457, 63, 1345, 63, 1238, 275, 5928, 14, 49, 9232, 2081, 1685, 342, 272, 291, 14, 1457, 63, 1345, 63, 1238, 14, 1053, 6970, 14, 2242, 8, 277, 423, 1457, 2768, 2081, 6970, 9, 272, 291, 14, 1457, 63, 1345, 63, 513, 14, 409, 1685, 8, 277, 14, 1457, 63, 1345, 63, 1238, 9, 272, 291, 14, 1457, 63, 1345, 63, 4209, 14, 9475, 8, 277, 14, 1457, 63, 1345, 63, 513, 9, 339, 291, 14, 1457, 63, 1345, 63, 923, 63, 1977, 14, 409, 4798, 8, 277, 14, 1457, 63, 1345, 63, 4209, 9, 272, 291, 14, 3039, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 1457, 63, 1345, 63, 923, 63, 1977, 9, 272, 291, 14, 13658, 63, 4209, 14, 30571, 8, 277, 14, 3039, 63, 13658, 63, 4209, 9, 2378, 291, 14, 1019, 63, 13658, 63, 4209, 275, 5928, 14, 25527, 18536, 342, 272, 291, 14, 13658, 63, 4209, 14, 30571, 8, 277, 14, 1019, 63, 13658, 63, 4209, 9, 339, 291, 14, 1345, 63, 6480, 63, 13456, 275, 5928, 14, 49, 20530, 360, 2768, 603, 10613, 358, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 29892, 360, 24743, 2455, 316, 402, 9364, 4008, 358, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 409, 1799, 2223, 8, 10901, 14, 4238, 14, 14627, 9, 272, 291, 14, 1345, 63, 6480, 63, 13456, 14, 929, 6970, 14, 2242, 8, 277, 14, 1345, 12241, 26366, 6970, 9, 272, 291, 14, 1019, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 1345, 63, 6480, 63, 13456, 9, 339, 291, 14, 14337, 63, 923, 63, 1977, 275, 5928, 14, 49, 2448, 3532, 360, 11688, 4040, 358, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 10915, 8436, 8, 2760, 9, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 21735, 4845, 8, 10604, 14, 19934, 14, 12092, 12839, 316, 12, 5928, 14, 19934, 14, 9515, 9, 199, 3, 259, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 10915, 6216, 8, 1840, 9, 272, 291, 14, 14337, 63, 4209, 275, 5928, 14, 27088, 18536, 342, 272, 291, 14, 14337, 63, 923, 63, 1977, 14, 409, 4798, 8, 277, 14, 14337, 63, 4209, 9, 272, 291, 14, 1019, 63, 13658, 63, 4209, 14, 9475, 8, 277, 14, 14337, 63, 923, 63, 1977, 9, 339, 291, 14, 14337, 63, 1457, 63, 1302, 275, 5928, 14, 19890, 360, 3142, 10993, 272, 291, 14, 14337, 63, 1457, 63, 1302, 14, 409, 16613, 8, 10901, 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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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 ]
steven-albanese/sams
sams/tests/test_analyze.py
1
1207
""" Test SAMS analysis code. """ __author__ = 'John D. Chodera' ################################################################################ # IMPORTS ################################################################################ from simtk import openmm, unit from simtk.openmm import app import os, os.path import sys, math import numpy as np import logging from functools import partial import sams.analysis ################################################################################ # TEST SAMPLERS ################################################################################ def test_analysis(): """ Test analysis. """ from sams.tests.testsystems import AlanineDipeptideVacuumSimulatedTempering netcdf_filename = 'output.nc' test = AlanineDipeptideVacuumSimulatedTempering(netcdf_filename=netcdf_filename) testsystem_name = test.__class__.__name__ niterations = 20 # number of iterations to run test.mcmc_sampler.nsteps = 5 # Test SAMSSampler. test.sams_sampler.run(niterations) # Test analysis from sams.analysis import analyze analyze(netcdf_filename, test, 'analyze.pdf') if __name__=="__main__": test_analysis()
mit
[ 624, 199, 774, 428, 1156, 51, 11284, 1233, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 12923, 577, 14, 2799, 380, 345, 7, 199, 199, 13289, 199, 3, 5025, 2596, 51, 199, 13289, 199, 199, 504, 4389, 2663, 492, 1551, 596, 12, 4137, 199, 504, 4389, 2663, 14, 1490, 596, 492, 1145, 199, 646, 747, 12, 747, 14, 515, 199, 646, 984, 12, 3473, 199, 646, 2680, 465, 980, 199, 646, 2050, 199, 504, 9143, 492, 7417, 199, 199, 646, 308, 19470, 14, 10466, 199, 199, 13289, 199, 3, 7393, 428, 7855, 3960, 199, 13289, 199, 199, 318, 511, 63, 10466, 837, 272, 408, 272, 1379, 11284, 14, 339, 408, 272, 687, 308, 19470, 14, 2219, 14, 396, 19135, 492, 437, 1502, 1132, 1341, 12636, 280, 271, 54, 645, 19805, 7467, 8097, 6530, 15663, 272, 1851, 10790, 63, 1501, 275, 283, 1199, 14, 7966, 7, 272, 511, 275, 437, 1502, 1132, 1341, 12636, 280, 271, 54, 645, 19805, 7467, 8097, 6530, 15663, 8, 846, 10790, 63, 1501, 29, 846, 10790, 63, 1501, 9, 272, 511, 2253, 63, 354, 275, 511, 855, 533, 4914, 354, 363, 272, 302, 13570, 275, 3388, 327, 1329, 402, 10615, 370, 1255, 272, 511, 14, 77, 4400, 67, 63, 22934, 14, 561, 6224, 275, 959, 339, 327, 1379, 428, 1156, 2300, 865, 82, 14, 272, 511, 14, 83, 19470, 63, 22934, 14, 1065, 8, 78, 13570, 9, 339, 327, 1379, 11284, 272, 687, 308, 19470, 14, 10466, 492, 19897, 272, 19897, 8, 846, 10790, 63, 1501, 12, 511, 12, 283, 21184, 14, 5607, 358, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 272, 511, 63, 10466, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 774, 428, 1156, 51, 11284, 1233, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 12923, 577, 14, 2799, 380, 345, 7, 199, 199, 13289, 199, 3, 5025, 2596, 51, 199, 13289, 199, 199, 504, 4389, 2663, 492, 1551, 596, 12, 4137, 199, 504, 4389, 2663, 14, 1490, 596, 492, 1145, 199, 646, 747, 12, 747, 14, 515, 199, 646, 984, 12, 3473, 199, 646, 2680, 465, 980, 199, 646, 2050, 199, 504, 9143, 492, 7417, 199, 199, 646, 308, 19470, 14, 10466, 199, 199, 13289, 199, 3, 7393, 428, 7855, 3960, 199, 13289, 199, 199, 318, 511, 63, 10466, 837, 272, 408, 272, 1379, 11284, 14, 339, 408, 272, 687, 308, 19470, 14, 2219, 14, 396, 19135, 492, 437, 1502, 1132, 1341, 12636, 280, 271, 54, 645, 19805, 7467, 8097, 6530, 15663, 272, 1851, 10790, 63, 1501, 275, 283, 1199, 14, 7966, 7, 272, 511, 275, 437, 1502, 1132, 1341, 12636, 280, 271, 54, 645, 19805, 7467, 8097, 6530, 15663, 8, 846, 10790, 63, 1501, 29, 846, 10790, 63, 1501, 9, 272, 511, 2253, 63, 354, 275, 511, 855, 533, 4914, 354, 363, 272, 302, 13570, 275, 3388, 327, 1329, 402, 10615, 370, 1255, 272, 511, 14, 77, 4400, 67, 63, 22934, 14, 561, 6224, 275, 959, 339, 327, 1379, 428, 1156, 2300, 865, 82, 14, 272, 511, 14, 83, 19470, 63, 22934, 14, 1065, 8, 78, 13570, 9, 339, 327, 1379, 11284, 272, 687, 308, 19470, 14, 10466, 492, 19897, 272, 19897, 8, 846, 10790, 63, 1501, 12, 511, 12, 283, 21184, 14, 5607, 358, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 272, 511, 63, 10466, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
lmazuel/azure-sdk-for-python
azure-batch/azure/batch/models/job_schedule_patch_options.py
1
3130
# 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.serialization import Model class JobSchedulePatchOptions(Model): """Additional parameters for patch operation. :param timeout: The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. Default value: 30 . :type timeout: int :param client_request_id: The caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. :type client_request_id: str :param return_client_request_id: Whether the server should return the client-request-id in the response. Default value: False . :type return_client_request_id: bool :param ocp_date: The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly. :type ocp_date: datetime :param if_match: An ETag value associated with the version of the resource known to the client. The operation will be performed only if the resource's current ETag on the service exactly matches the value specified by the client. :type if_match: str :param if_none_match: An ETag value associated with the version of the resource known to the client. The operation will be performed only if the resource's current ETag on the service does not match the value specified by the client. :type if_none_match: str :param if_modified_since: A timestamp indicating the last modified time of the resource known to the client. The operation will be performed only if the resource on the service has been modified since the specified time. :type if_modified_since: datetime :param if_unmodified_since: A timestamp indicating the last modified time of the resource known to the client. The operation will be performed only if the resource on the service has not been modified since the specified time. :type if_unmodified_since: datetime """ def __init__(self, timeout=30, client_request_id=None, return_client_request_id=False, ocp_date=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None): super(JobSchedulePatchOptions, self).__init__() self.timeout = timeout self.client_request_id = client_request_id self.return_client_request_id = return_client_request_id self.ocp_date = ocp_date self.if_match = if_match self.if_none_match = if_none_match self.if_modified_since = if_modified_since self.if_unmodified_since = if_unmodified_since
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, 12161, 492, 5822, 421, 199, 533, 15057, 15535, 11173, 4558, 8, 1685, 304, 272, 408, 8824, 2633, 367, 3371, 3439, 14, 339, 520, 635, 2653, 26, 710, 5696, 900, 626, 314, 1654, 883, 26387, 6661, 314, 1362, 1056, 12, 315, 4696, 14, 710, 849, 365, 4233, 4696, 14, 3758, 574, 26, 4233, 1275, 272, 520, 466, 2653, 26, 1109, 272, 520, 635, 1890, 63, 1069, 63, 344, 26, 710, 8025, 13, 10176, 1056, 8503, 12, 315, 314, 1362, 1824, 402, 282, 21645, 543, 949, 5509, 425, 4066, 465, 1094, 590, 27158, 12, 325, 14, 71, 14, 1362, 1749, 35, 20, 36, 1400, 8699, 13, 18, 36, 1367, 13, 20, 7695, 19, 13, 24, 11024, 13, 1082, 12532, 5196, 25, 38, 18, 34, 16, 14, 272, 520, 466, 1890, 63, 1069, 63, 344, 26, 620, 272, 520, 635, 372, 63, 1258, 63, 1069, 63, 344, 26, 7480, 314, 1654, 1077, 372, 314, 1362, 1890, 13, 1069, 13, 344, 315, 314, 1177, 14, 3758, 574, 26, 756, 1275, 272, 520, 466, 372, 63, 1258, 63, 1069, 63, 344, 26, 2155, 272, 520, 635, 312, 1850, 63, 602, 26, 710, 900, 314, 1056, 1990, 21117, 14, 6810, 8363, 1362, 13609, 663, 642, 370, 314, 1453, 2656, 12516, 900, 27, 663, 652, 7662, 340, 1362, 1265, 787, 6358, 314, 14880, 3261, 5370, 14, 272, 520, 466, 312, 1850, 63, 602, 26, 2197, 272, 520, 635, 340, 63, 1431, 26, 1626, 662, 1931, 574, 4568, 543, 314, 1015, 402, 314, 2073, 1362, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 314, 1362, 2073, 1159, 1453, 662, 1931, 641, 314, 2435, 8840, 4450, 314, 574, 2013, 1362, 701, 314, 1890, 14, 272, 520, 466, 340, 63, 1431, 26, 620, 272, 520, 635, 340, 63, 3592, 63, 1431, 26, 1626, 662, 1931, 574, 4568, 543, 314, 1015, 402, 314, 1362, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 314, 1362, 2073, 1159, 1453, 662, 1931, 641, 314, 2435, 1630, 440, 1336, 314, 574, 2013, 1362, 701, 314, 1890, 14, 272, 520, 466, 340, 63, 3592, 63, 1431, 26, 620, 272, 520, 635, 340, 63, 5540, 63, 8585, 26, 437, 4913, 9297, 314, 2061, 6042, 900, 402, 1362, 314, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 1362, 314, 2073, 641, 314, 2435, 965, 2757, 6042, 3967, 314, 2013, 900, 14, 272, 520, 466, 340, 63, 5540, 63, 8585, 26, 2197, 272, 520, 635, 340, 63, 324, 5540, 63, 8585, 26, 437, 4913, 9297, 314, 2061, 6042, 900, 1362, 402, 314, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 1362, 340, 314, 2073, 641, 314, 2435, 965, 440, 2757, 6042, 3967, 314, 2013, 1362, 900, 14, 272, 520, 466, 340, 63, 324, 5540, 63, 8585, 26, 2197, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 1216, 12, 1890, 63, 1069, 63, 344, 29, 403, 12, 372, 63, 1258, 63, 1069, 63, 344, 29, 797, 12, 312, 1850, 63, 602, 29, 403, 12, 340, 63, 1431, 29, 403, 12, 340, 63, 3592, 63, 1431, 29, 403, 12, 340, 63, 5540, 63, 8585, 29, 403, 12, 340, 63, 324, 5540, 63, 8585, 29, 403, 304, 267, 1613, 8, 6694, 15535, 11173, 4558, 12, 291, 2843, 826, 4533, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1258, 63, 1069, 63, 344, 275, 1890, 63, 1069, 63, 344, 267, 291, 14, 1107, 63, 1258, 63, 1069, 63, 344, 275, 372, 63, 1258, 63, 1069, 63, 344, 267, 291, 14, 679, 80, 63, 602, 275, 312, 1850, 63, 602, 267, 291, 14, 692, 63, 1431, 275, 340, 63, 1431, 267, 291, 14, 692, 63, 3592, 63, 1431, 275, 340, 63, 3592, 63, 1431, 267, 291, 14, 692, 63, 5540, 63, 8585, 275, 340, 63, 5540, 63, 8585, 267, 291, 14, 692, 63, 324, 5540, 63, 8585, 275, 340, 63, 324, 5540, 63, 8585, 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 ]
[ 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, 12161, 492, 5822, 421, 199, 533, 15057, 15535, 11173, 4558, 8, 1685, 304, 272, 408, 8824, 2633, 367, 3371, 3439, 14, 339, 520, 635, 2653, 26, 710, 5696, 900, 626, 314, 1654, 883, 26387, 6661, 314, 1362, 1056, 12, 315, 4696, 14, 710, 849, 365, 4233, 4696, 14, 3758, 574, 26, 4233, 1275, 272, 520, 466, 2653, 26, 1109, 272, 520, 635, 1890, 63, 1069, 63, 344, 26, 710, 8025, 13, 10176, 1056, 8503, 12, 315, 314, 1362, 1824, 402, 282, 21645, 543, 949, 5509, 425, 4066, 465, 1094, 590, 27158, 12, 325, 14, 71, 14, 1362, 1749, 35, 20, 36, 1400, 8699, 13, 18, 36, 1367, 13, 20, 7695, 19, 13, 24, 11024, 13, 1082, 12532, 5196, 25, 38, 18, 34, 16, 14, 272, 520, 466, 1890, 63, 1069, 63, 344, 26, 620, 272, 520, 635, 372, 63, 1258, 63, 1069, 63, 344, 26, 7480, 314, 1654, 1077, 372, 314, 1362, 1890, 13, 1069, 13, 344, 315, 314, 1177, 14, 3758, 574, 26, 756, 1275, 272, 520, 466, 372, 63, 1258, 63, 1069, 63, 344, 26, 2155, 272, 520, 635, 312, 1850, 63, 602, 26, 710, 900, 314, 1056, 1990, 21117, 14, 6810, 8363, 1362, 13609, 663, 642, 370, 314, 1453, 2656, 12516, 900, 27, 663, 652, 7662, 340, 1362, 1265, 787, 6358, 314, 14880, 3261, 5370, 14, 272, 520, 466, 312, 1850, 63, 602, 26, 2197, 272, 520, 635, 340, 63, 1431, 26, 1626, 662, 1931, 574, 4568, 543, 314, 1015, 402, 314, 2073, 1362, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 314, 1362, 2073, 1159, 1453, 662, 1931, 641, 314, 2435, 8840, 4450, 314, 574, 2013, 1362, 701, 314, 1890, 14, 272, 520, 466, 340, 63, 1431, 26, 620, 272, 520, 635, 340, 63, 3592, 63, 1431, 26, 1626, 662, 1931, 574, 4568, 543, 314, 1015, 402, 314, 1362, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 314, 1362, 2073, 1159, 1453, 662, 1931, 641, 314, 2435, 1630, 440, 1336, 314, 574, 2013, 1362, 701, 314, 1890, 14, 272, 520, 466, 340, 63, 3592, 63, 1431, 26, 620, 272, 520, 635, 340, 63, 5540, 63, 8585, 26, 437, 4913, 9297, 314, 2061, 6042, 900, 402, 1362, 314, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 340, 1362, 314, 2073, 641, 314, 2435, 965, 2757, 6042, 3967, 314, 2013, 900, 14, 272, 520, 466, 340, 63, 5540, 63, 8585, 26, 2197, 272, 520, 635, 340, 63, 324, 5540, 63, 8585, 26, 437, 4913, 9297, 314, 2061, 6042, 900, 1362, 402, 314, 2073, 6040, 370, 314, 1890, 14, 710, 3439, 911, 506, 10585, 1454, 1362, 340, 314, 2073, 641, 314, 2435, 965, 440, 2757, 6042, 3967, 314, 2013, 1362, 900, 14, 272, 520, 466, 340, 63, 324, 5540, 63, 8585, 26, 2197, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 1216, 12, 1890, 63, 1069, 63, 344, 29, 403, 12, 372, 63, 1258, 63, 1069, 63, 344, 29, 797, 12, 312, 1850, 63, 602, 29, 403, 12, 340, 63, 1431, 29, 403, 12, 340, 63, 3592, 63, 1431, 29, 403, 12, 340, 63, 5540, 63, 8585, 29, 403, 12, 340, 63, 324, 5540, 63, 8585, 29, 403, 304, 267, 1613, 8, 6694, 15535, 11173, 4558, 12, 291, 2843, 826, 4533, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1258, 63, 1069, 63, 344, 275, 1890, 63, 1069, 63, 344, 267, 291, 14, 1107, 63, 1258, 63, 1069, 63, 344, 275, 372, 63, 1258, 63, 1069, 63, 344, 267, 291, 14, 679, 80, 63, 602, 275, 312, 1850, 63, 602, 267, 291, 14, 692, 63, 1431, 275, 340, 63, 1431, 267, 291, 14, 692, 63, 3592, 63, 1431, 275, 340, 63, 3592, 63, 1431, 267, 291, 14, 692, 63, 5540, 63, 8585, 275, 340, 63, 5540, 63, 8585, 267, 291, 14, 692, 63, 324, 5540, 63, 8585, 275, 340, 63, 324, 5540, 63, 8585, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
m1ck/bookadoptions
django/utils/log.py
152
3494
import logging import sys from django.core import mail # Make sure a NullHandler is available # This was added in Python 2.7/3.2 try: from logging import NullHandler except ImportError: class NullHandler(logging.Handler): def emit(self, record): pass # Make sure that dictConfig is available # This was added in Python 2.7/3.2 try: from logging.config import dictConfig except ImportError: from django.utils.dictconfig import dictConfig if sys.version_info < (2, 5): class LoggerCompat(object): def __init__(self, logger): self._logger = logger def __getattr__(self, name): val = getattr(self._logger, name) if callable(val): def _wrapper(*args, **kwargs): # Python 2.4 logging module doesn't support 'extra' parameter to # methods of Logger kwargs.pop('extra', None) return val(*args, **kwargs) return _wrapper else: return val def getLogger(name=None): return LoggerCompat(logging.getLogger(name=name)) else: getLogger = logging.getLogger # Ensure the creation of the Django logger # with a null handler. This ensures we don't get any # 'No handlers could be found for logger "django"' messages logger = getLogger('django') if not logger.handlers: logger.addHandler(NullHandler()) class AdminEmailHandler(logging.Handler): def __init__(self, include_html=False): logging.Handler.__init__(self) self.include_html = include_html """An exception log handler that e-mails log entries to site admins. If the request is passed as the first argument to the log record, request data will be provided in the """ def emit(self, record): import traceback from django.conf import settings from django.views.debug import ExceptionReporter try: if sys.version_info < (2,5): # A nasty workaround required because Python 2.4's logging # module doesn't support passing in extra context. # For this handler, the only extra data we need is the # request, and that's in the top stack frame. request = record.exc_info[2].tb_frame.f_locals['request'] else: request = record.request subject = '%s (%s IP): %s' % ( record.levelname, (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), record.msg ) request_repr = repr(request) except: subject = '%s: %s' % ( record.levelname, record.msg ) request = None request_repr = "Request repr() unavailable" if record.exc_info: exc_info = record.exc_info stack_trace = '\n'.join(traceback.format_exception(*record.exc_info)) else: exc_info = (None, record.msg, None) stack_trace = 'No stack trace available' message = "%s\n\n%s" % (stack_trace, request_repr) reporter = ExceptionReporter(request, is_email=True, *exc_info) html_message = self.include_html and reporter.get_traceback_html() or None mail.mail_admins(subject, message, fail_silently=True, html_message=html_message)
bsd-3-clause
[ 646, 2050, 199, 646, 984, 199, 504, 1639, 14, 1018, 492, 6016, 199, 199, 3, 4155, 3238, 282, 12119, 2461, 365, 2808, 199, 3, 961, 1990, 3483, 315, 2018, 499, 14, 23, 15, 19, 14, 18, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 3, 4155, 3238, 626, 1211, 2028, 365, 2808, 199, 3, 961, 1990, 3483, 315, 2018, 499, 14, 23, 15, 19, 14, 18, 199, 893, 26, 272, 687, 2050, 14, 888, 492, 1211, 2028, 199, 2590, 3545, 26, 272, 687, 1639, 14, 1208, 14, 807, 888, 492, 1211, 2028, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 959, 304, 272, 1021, 15996, 2404, 292, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 2512, 304, 288, 291, 423, 2921, 275, 2512, 398, 347, 636, 5675, 721, 277, 12, 536, 304, 288, 1139, 275, 2519, 8, 277, 423, 2921, 12, 536, 9, 288, 340, 4550, 8, 637, 304, 355, 347, 485, 5029, 2031, 589, 12, 1011, 958, 304, 490, 327, 2018, 499, 14, 20, 2050, 859, 3181, 1133, 2291, 283, 2911, 7, 2725, 370, 490, 327, 3102, 402, 15996, 490, 2074, 14, 1935, 360, 2911, 297, 488, 9, 490, 372, 1139, 2031, 589, 12, 1011, 958, 9, 355, 372, 485, 5029, 288, 587, 26, 355, 372, 1139, 339, 347, 28138, 8, 354, 29, 403, 304, 267, 372, 15996, 2404, 292, 8, 4806, 14, 5572, 8, 354, 29, 354, 430, 199, 2836, 26, 272, 28138, 275, 2050, 14, 5572, 199, 199, 3, 7523, 314, 7143, 402, 314, 5634, 2512, 199, 3, 543, 282, 2973, 3016, 14, 961, 15620, 781, 2793, 1133, 664, 1263, 199, 3, 283, 1944, 8297, 4293, 506, 1911, 367, 2512, 298, 1176, 4507, 3788, 199, 2921, 275, 28138, 360, 1176, 358, 199, 692, 440, 2512, 14, 5586, 26, 272, 2512, 14, 18826, 8, 8849, 2461, 1012, 199, 199, 533, 9516, 7035, 2461, 8, 4806, 14, 2461, 304, 272, 347, 636, 826, 721, 277, 12, 2387, 63, 1360, 29, 797, 304, 267, 2050, 14, 2461, 855, 826, 721, 277, 9, 18418, 291, 14, 2613, 63, 1360, 275, 2387, 63, 1360, 339, 408, 2493, 1919, 943, 3016, 626, 325, 13, 1198, 83, 943, 4811, 370, 4770, 4628, 83, 14, 339, 982, 314, 1056, 365, 3032, 465, 314, 1642, 1423, 370, 314, 943, 2777, 12, 272, 1056, 666, 911, 506, 2741, 315, 314, 272, 408, 272, 347, 8689, 8, 277, 12, 2777, 304, 267, 492, 5190, 267, 687, 1639, 14, 2190, 492, 2202, 267, 687, 1639, 14, 4196, 14, 1757, 492, 2186, 15891, 398, 862, 26, 288, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 21, 304, 355, 327, 437, 302, 27352, 18092, 1415, 2952, 2018, 499, 14, 20, 1159, 2050, 355, 327, 859, 3181, 1133, 2291, 9476, 315, 2402, 1067, 14, 355, 327, 2104, 642, 3016, 12, 314, 1454, 2402, 666, 781, 1929, 365, 314, 355, 327, 1056, 12, 436, 626, 1159, 315, 314, 2746, 3464, 2787, 14, 355, 1056, 275, 2777, 14, 2804, 63, 815, 59, 18, 1055, 5842, 63, 1943, 14, 70, 63, 9350, 459, 1069, 418, 288, 587, 26, 355, 1056, 275, 2777, 14, 1069, 953, 5420, 275, 1543, 83, 4366, 83, 3531, 304, 450, 83, 7, 450, 334, 355, 2777, 14, 20056, 12, 355, 334, 1069, 14, 10614, 14, 362, 360, 16058, 63, 7803, 358, 315, 2202, 14, 17681, 63, 12346, 436, 283, 4672, 7, 503, 283, 21043, 659, 355, 2777, 14, 1328, 288, 776, 288, 1056, 63, 2722, 275, 4700, 8, 1069, 9, 267, 871, 26, 288, 5420, 275, 1543, 83, 26, 450, 83, 7, 450, 334, 355, 2777, 14, 20056, 12, 355, 2777, 14, 1328, 288, 776, 953, 1056, 275, 488, 288, 1056, 63, 2722, 275, 298, 2017, 4700, 342, 18735, 2, 398, 340, 2777, 14, 2804, 63, 815, 26, 288, 3178, 63, 815, 275, 2777, 14, 2804, 63, 815, 288, 3464, 63, 3446, 275, 1557, 78, 1370, 904, 8, 6894, 14, 908, 63, 1971, 2031, 3059, 14, 2804, 63, 815, 430, 267, 587, 26, 288, 3178, 63, 815, 275, 334, 403, 12, 2777, 14, 1328, 12, 488, 9, 288, 3464, 63, 3446, 275, 283, 1944, 3464, 3307, 2808, 7, 398, 1245, 275, 2071, 83, 60, 78, 60, 78, 5, 83, 2, 450, 334, 2340, 63, 3446, 12, 1056, 63, 2722, 9, 267, 17663, 275, 2186, 15891, 8, 1069, 12, 365, 63, 2123, 29, 549, 12, 627, 2804, 63, 815, 9, 267, 3517, 63, 1188, 275, 291, 14, 2613, 63, 1360, 436, 17663, 14, 362, 63, 6894, 63, 1360, 342, 503, 488, 267, 6016, 14, 1198, 63, 23121, 8, 5875, 12, 1245, 12, 2449, 63, 25163, 29, 549, 12, 586, 3517, 63, 1188, 29, 1360, 63, 1188, 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 ]
[ 2050, 199, 646, 984, 199, 504, 1639, 14, 1018, 492, 6016, 199, 199, 3, 4155, 3238, 282, 12119, 2461, 365, 2808, 199, 3, 961, 1990, 3483, 315, 2018, 499, 14, 23, 15, 19, 14, 18, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 3, 4155, 3238, 626, 1211, 2028, 365, 2808, 199, 3, 961, 1990, 3483, 315, 2018, 499, 14, 23, 15, 19, 14, 18, 199, 893, 26, 272, 687, 2050, 14, 888, 492, 1211, 2028, 199, 2590, 3545, 26, 272, 687, 1639, 14, 1208, 14, 807, 888, 492, 1211, 2028, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 959, 304, 272, 1021, 15996, 2404, 292, 8, 785, 304, 267, 347, 636, 826, 721, 277, 12, 2512, 304, 288, 291, 423, 2921, 275, 2512, 398, 347, 636, 5675, 721, 277, 12, 536, 304, 288, 1139, 275, 2519, 8, 277, 423, 2921, 12, 536, 9, 288, 340, 4550, 8, 637, 304, 355, 347, 485, 5029, 2031, 589, 12, 1011, 958, 304, 490, 327, 2018, 499, 14, 20, 2050, 859, 3181, 1133, 2291, 283, 2911, 7, 2725, 370, 490, 327, 3102, 402, 15996, 490, 2074, 14, 1935, 360, 2911, 297, 488, 9, 490, 372, 1139, 2031, 589, 12, 1011, 958, 9, 355, 372, 485, 5029, 288, 587, 26, 355, 372, 1139, 339, 347, 28138, 8, 354, 29, 403, 304, 267, 372, 15996, 2404, 292, 8, 4806, 14, 5572, 8, 354, 29, 354, 430, 199, 2836, 26, 272, 28138, 275, 2050, 14, 5572, 199, 199, 3, 7523, 314, 7143, 402, 314, 5634, 2512, 199, 3, 543, 282, 2973, 3016, 14, 961, 15620, 781, 2793, 1133, 664, 1263, 199, 3, 283, 1944, 8297, 4293, 506, 1911, 367, 2512, 298, 1176, 4507, 3788, 199, 2921, 275, 28138, 360, 1176, 358, 199, 692, 440, 2512, 14, 5586, 26, 272, 2512, 14, 18826, 8, 8849, 2461, 1012, 199, 199, 533, 9516, 7035, 2461, 8, 4806, 14, 2461, 304, 272, 347, 636, 826, 721, 277, 12, 2387, 63, 1360, 29, 797, 304, 267, 2050, 14, 2461, 855, 826, 721, 277, 9, 18418, 291, 14, 2613, 63, 1360, 275, 2387, 63, 1360, 339, 408, 2493, 1919, 943, 3016, 626, 325, 13, 1198, 83, 943, 4811, 370, 4770, 4628, 83, 14, 339, 982, 314, 1056, 365, 3032, 465, 314, 1642, 1423, 370, 314, 943, 2777, 12, 272, 1056, 666, 911, 506, 2741, 315, 314, 272, 408, 272, 347, 8689, 8, 277, 12, 2777, 304, 267, 492, 5190, 267, 687, 1639, 14, 2190, 492, 2202, 267, 687, 1639, 14, 4196, 14, 1757, 492, 2186, 15891, 398, 862, 26, 288, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 21, 304, 355, 327, 437, 302, 27352, 18092, 1415, 2952, 2018, 499, 14, 20, 1159, 2050, 355, 327, 859, 3181, 1133, 2291, 9476, 315, 2402, 1067, 14, 355, 327, 2104, 642, 3016, 12, 314, 1454, 2402, 666, 781, 1929, 365, 314, 355, 327, 1056, 12, 436, 626, 1159, 315, 314, 2746, 3464, 2787, 14, 355, 1056, 275, 2777, 14, 2804, 63, 815, 59, 18, 1055, 5842, 63, 1943, 14, 70, 63, 9350, 459, 1069, 418, 288, 587, 26, 355, 1056, 275, 2777, 14, 1069, 953, 5420, 275, 1543, 83, 4366, 83, 3531, 304, 450, 83, 7, 450, 334, 355, 2777, 14, 20056, 12, 355, 334, 1069, 14, 10614, 14, 362, 360, 16058, 63, 7803, 358, 315, 2202, 14, 17681, 63, 12346, 436, 283, 4672, 7, 503, 283, 21043, 659, 355, 2777, 14, 1328, 288, 776, 288, 1056, 63, 2722, 275, 4700, 8, 1069, 9, 267, 871, 26, 288, 5420, 275, 1543, 83, 26, 450, 83, 7, 450, 334, 355, 2777, 14, 20056, 12, 355, 2777, 14, 1328, 288, 776, 953, 1056, 275, 488, 288, 1056, 63, 2722, 275, 298, 2017, 4700, 342, 18735, 2, 398, 340, 2777, 14, 2804, 63, 815, 26, 288, 3178, 63, 815, 275, 2777, 14, 2804, 63, 815, 288, 3464, 63, 3446, 275, 1557, 78, 1370, 904, 8, 6894, 14, 908, 63, 1971, 2031, 3059, 14, 2804, 63, 815, 430, 267, 587, 26, 288, 3178, 63, 815, 275, 334, 403, 12, 2777, 14, 1328, 12, 488, 9, 288, 3464, 63, 3446, 275, 283, 1944, 3464, 3307, 2808, 7, 398, 1245, 275, 2071, 83, 60, 78, 60, 78, 5, 83, 2, 450, 334, 2340, 63, 3446, 12, 1056, 63, 2722, 9, 267, 17663, 275, 2186, 15891, 8, 1069, 12, 365, 63, 2123, 29, 549, 12, 627, 2804, 63, 815, 9, 267, 3517, 63, 1188, 275, 291, 14, 2613, 63, 1360, 436, 17663, 14, 362, 63, 6894, 63, 1360, 342, 503, 488, 267, 6016, 14, 1198, 63, 23121, 8, 5875, 12, 1245, 12, 2449, 63, 25163, 29, 549, 12, 586, 3517, 63, 1188, 29, 1360, 63, 1188, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
lcf8858/Sample_Lua
frameworks/cocos2d-x/tools/cocos2d-console/plugins/plugin_luacompile/__init__.py
11
10258
#!/usr/bin/python # ---------------------------------------------------------------------------- # cocos "luacompile" plugin # # Copyright 2013 (C) Intel # # License: MIT # ---------------------------------------------------------------------------- ''' "luacompile" plugin for cocos command line tool ''' __docformat__ = 'restructuredtext' import sys import subprocess import os import json import inspect import cocos ############################################################ #http://www.coolcode.org/archives/?article-307.html ############################################################ import struct _DELTA = 0x9E3779B9 def _long2str(v, w): n = (len(v) - 1) << 2 if w: m = v[-1] if (m < n - 3) or (m > n): return '' n = m s = struct.pack('<%iL' % len(v), *v) return s[0:n] if w else s def _str2long(s, w): n = len(s) m = (4 - (n & 3) & 3) + n s = s.ljust(m, "\0") v = list(struct.unpack('<%iL' % (m >> 2), s)) if w: v.append(n) return v def encrypt(str, key): if str == '': return str v = _str2long(str, True) k = _str2long(key.ljust(16, "\0"), False) n = len(v) - 1 z = v[n] y = v[0] sum = 0 q = 6 + 52 // (n + 1) while q > 0: sum = (sum + _DELTA) & 0xffffffff e = sum >> 2 & 3 for p in xrange(n): y = v[p + 1] v[p] = (v[p] + ((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z))) & 0xffffffff z = v[p] y = v[0] v[n] = (v[n] + ((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[n & 3 ^ e] ^ z))) & 0xffffffff z = v[n] q -= 1 return _long2str(v, False) def decrypt(str, key): if str == '': return str v = _str2long(str, False) k = _str2long(key.ljust(16, "\0"), False) n = len(v) - 1 z = v[n] y = v[0] q = 6 + 52 // (n + 1) sum = (q * _DELTA) & 0xffffffff while (sum != 0): e = sum >> 2 & 3 for p in xrange(n, 0, -1): z = v[p - 1] v[p] = (v[p] - ((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z))) & 0xffffffff y = v[p] z = v[n] v[0] = (v[0] - ((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[0 & 3 ^ e] ^ z))) & 0xffffffff y = v[0] sum = (sum - _DELTA) & 0xffffffff return _long2str(v, True) #import cocos class CCPluginLuaCompile(cocos.CCPlugin): """ compiles (encodes) and minifies Lua files """ @staticmethod def plugin_name(): return "luacompile" @staticmethod def brief_description(): # returns a short description of this module return "minifies and/or compiles lua files" # This is not the constructor, just an initializator def init(self, options, workingdir): """ Arguments: - `options`: """ self._current_src_dir = None self._src_dir_arr = self.normalize_path_in_list(options.src_dir_arr) self._dst_dir = options.dst_dir if not os.path.isabs(self._dst_dir): self._dst_dir = os.path.abspath(self._dst_dir) self._verbose = options.verbose self._workingdir = workingdir self._lua_files = {} self._isEncrypt = options.encrypt self._encryptkey = options.encryptkey self._encryptsign = options.encryptsign self._luajit_exe_path = self.get_luajit_path() if self._luajit_exe_path is None: raise cocos.CCPluginError("Can't find right luajit for current system.") self._luajit_dir = os.path.dirname(self._luajit_exe_path) def normalize_path_in_list(self, list): for i in list: tmp = os.path.normpath(i) if not os.path.isabs(tmp): tmp = os.path.abspath(tmp) list[list.index(i)] = tmp return list def get_relative_path(self, luafile): try: pos = luafile.index(self._current_src_dir) if pos != 0: raise cocos.CCPluginError("cannot find src directory in file path.") return luafile[len(self._current_src_dir)+1:] except ValueError: raise cocos.CCPluginError("cannot find src directory in file path.") def get_output_file_path(self, luafile): """ Gets output file path by source lua file """ # create folder for generated file luac_filepath = "" # Unknow to remove 'c' relative_path = self.get_relative_path(luafile)+"c" luac_filepath = os.path.join(self._dst_dir, relative_path) dst_rootpath = os.path.split(luac_filepath)[0] try: # print "creating dir (%s)" % (dst_rootpath) os.makedirs(dst_rootpath) except OSError: if os.path.exists(dst_rootpath) == False: # There was an error on creation, so make sure we know about it raise cocos.CCPluginError("Error: cannot create folder in "+dst_rootpath) # print "return luac path: "+luac_filepath return luac_filepath def get_luajit_path(self): ret = None if cocos.os_is_win32(): ret = os.path.join(self._workingdir, "bin", "luajit.exe") elif cocos.os_is_mac(): ret = os.path.join(self._workingdir, "bin", "lua", "luajit-mac") elif cocos.os_is_linux(): ret = os.path.join(self._workingdir, "bin", "lua", "luajit-linux") return ret def compile_lua(self, lua_file, output_file): """ Compiles lua file """ cocos.Logging.debug("compiling lua (%s) to bytecode..." % lua_file) with cocos.pushd(self._luajit_dir): cmd_str = "\"%s\" -b \"%s\" \"%s\"" % (self._luajit_exe_path, lua_file, output_file) self._run_cmd(cmd_str) # TODO # def compress_js(self): def deep_iterate_dir(self, rootDir): for lists in os.listdir(rootDir): path = os.path.join(rootDir, lists) if os.path.isdir(path): self.deep_iterate_dir(path) elif os.path.isfile(path): if os.path.splitext(path)[1] == ".lua": self._lua_files[self._current_src_dir].append(path) # UNDO # def index_in_list(self, lua_file, l): # def lua_filename_pre_order_compare(self, a, b): # def lua_filename_post_order_compare(self, a, b): # def _lua_filename_compare(self, a, b, files, delta): # def reorder_lua_files(self): def handle_all_lua_files(self): """ Arguments: - `self`: """ cocos.Logging.info("compiling lua script files to bytecode") index = 0 for src_dir in self._src_dir_arr: for lua_file in self._lua_files[src_dir]: self._current_src_dir = src_dir dst_lua_file = self.get_output_file_path(lua_file) self.compile_lua(lua_file, dst_lua_file) if self._isEncrypt == True: bytesFile = open(dst_lua_file, "rb+") encryBytes = encrypt(bytesFile.read(), self._encryptkey) encryBytes = self._encryptsign + encryBytes bytesFile.seek(0) bytesFile.write(encryBytes) bytesFile.close() index = index + 1 def run(self, argv, dependencies): """ """ self.parse_args(argv) # create output directory try: os.makedirs(self._dst_dir) except OSError: if os.path.exists(self._dst_dir) == False: raise cocos.CCPluginError("Error: cannot create folder in " + self._dst_dir) # deep iterate the src directory for src_dir in self._src_dir_arr: self._current_src_dir = src_dir self._lua_files[self._current_src_dir] = [] self.deep_iterate_dir(src_dir) self.handle_all_lua_files() cocos.Logging.info("compilation finished") def parse_args(self, argv): """ """ from optparse import OptionParser parser = OptionParser("usage: %prog luacompile -s src_dir -d dst_dir -v") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="verbose output") parser.add_option("-s", "--src", action="append", type="string", dest="src_dir_arr", help="source directory of lua files needed to be compiled, supports mutiple source directory") parser.add_option("-d", "--dst", action="store", type="string", dest="dst_dir", help="destination directory of lua bytecode files to be stored") parser.add_option("-e", "--encrypt", action="store_true", dest="encrypt",default=False, help="Whether or not to encrypt") parser.add_option("-k", "--encryptkey", dest="encryptkey",default="2dxLua", help="encrypt key") parser.add_option("-b", "--encryptsign", dest="encryptsign",default="XXTEA", help="encrypt sign") (options, args) = parser.parse_args(argv) if options.src_dir_arr == None: raise cocos.CCPluginError("Please set source folder by \"-s\" or \"-src\", run ./luacompile.py -h for the usage ") elif options.dst_dir == None: raise cocos.CCPluginError("Please set destination folder by \"-d\" or \"-dst\", run ./luacompile.py -h for the usage ") else: for src_dir in options.src_dir_arr: if os.path.exists(src_dir) == False: raise cocos.CCPluginError("Error: dir (%s) doesn't exist..." % (src_dir)) # script directory workingdir = os.path.dirname(inspect.getfile(inspect.currentframe())) self.init(options, workingdir)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 27103, 199, 3, 512, 5197, 298, 76, 1458, 2014, 2, 3589, 199, 3, 199, 3, 1898, 6171, 334, 35, 9, 20619, 199, 3, 199, 3, 844, 26, 10697, 199, 3, 27103, 199, 199, 2344, 199, 2, 76, 1458, 2014, 2, 3589, 367, 512, 5197, 1414, 1004, 4744, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 747, 199, 646, 2022, 199, 646, 6485, 199, 199, 646, 512, 5197, 199, 199, 26207, 381, 221, 199, 3, 1014, 921, 1544, 14, 18499, 600, 14, 1308, 15, 28067, 10197, 6934, 13, 11516, 14, 1360, 199, 26207, 381, 9948, 199, 646, 2702, 9948, 199, 63, 4424, 6166, 275, 378, 88, 25, 37, 7332, 25, 34, 25, 257, 199, 199, 318, 485, 2809, 18, 495, 8, 86, 12, 336, 304, 23855, 302, 275, 334, 552, 8, 86, 9, 446, 413, 9, 5213, 499, 23855, 340, 336, 26, 27439, 333, 275, 373, 1988, 17, 61, 27439, 340, 334, 77, 665, 302, 446, 650, 9, 503, 334, 77, 690, 302, 304, 372, 2125, 27439, 302, 275, 333, 23855, 308, 275, 2702, 14, 1389, 18875, 73, 44, 7, 450, 822, 8, 86, 395, 627, 86, 9, 23855, 372, 308, 59, 16, 26, 78, 61, 340, 336, 587, 308, 257, 2043, 199, 318, 485, 495, 18, 2809, 8, 83, 12, 336, 304, 23855, 302, 275, 822, 8, 83, 9, 23855, 333, 275, 334, 20, 446, 334, 78, 1253, 650, 9, 1253, 650, 9, 435, 302, 23855, 308, 275, 308, 14, 19996, 8, 77, 12, 1867, 16, 531, 23855, 373, 275, 769, 8, 1820, 14, 5301, 18875, 73, 44, 7, 450, 334, 77, 4331, 499, 395, 308, 430, 23855, 340, 336, 26, 373, 14, 740, 8, 78, 9, 23855, 372, 373, 257, 2043, 199, 318, 14645, 8, 495, 12, 790, 304, 23855, 340, 620, 508, 8061, 372, 620, 23855, 373, 275, 485, 495, 18, 2809, 8, 495, 12, 715, 9, 23855, 1022, 275, 485, 495, 18, 2809, 8, 498, 14, 19996, 8, 975, 12, 1867, 16, 1288, 756, 9, 23855, 302, 275, 822, 8, 86, 9, 446, 413, 23855, 1315, 275, 373, 59, 78, 61, 23855, 612, 275, 373, 59, 16, 61, 23855, 3089, 275, 378, 23855, 1894, 275, 1227, 435, 14589, 5001, 334, 78, 435, 413, 9, 23855, 1830, 1894, 690, 378, 26, 27439, 3089, 275, 334, 1838, 435, 485, 4424, 6166, 9, 1253, 378, 21870, 27439, 325, 275, 3089, 4331, 499, 1253, 650, 27439, 367, 299, 315, 4945, 8, 78, 304, 257, 288, 612, 275, 373, 59, 80, 435, 413, 61, 257, 288, 373, 59, 80, 61, 275, 334, 86, 59, 80, 61, 435, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 80, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 257, 288, 1315, 275, 373, 59, 80, 61, 27439, 612, 275, 373, 59, 16, 61, 27439, 373, 59, 78, 61, 275, 334, 86, 59, 78, 61, 435, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 78, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 27439, 1315, 275, 373, 59, 78, 61, 27439, 1894, 4862, 413, 23855, 372, 485, 2809, 18, 495, 8, 86, 12, 756, 9, 257, 2043, 199, 318, 20090, 8, 495, 12, 790, 304, 23855, 340, 620, 508, 8061, 372, 620, 23855, 373, 275, 485, 495, 18, 2809, 8, 495, 12, 756, 9, 23855, 1022, 275, 485, 495, 18, 2809, 8, 498, 14, 19996, 8, 975, 12, 1867, 16, 1288, 756, 9, 23855, 302, 275, 822, 8, 86, 9, 446, 413, 23855, 1315, 275, 373, 59, 78, 61, 23855, 612, 275, 373, 59, 16, 61, 23855, 1894, 275, 1227, 435, 14589, 5001, 334, 78, 435, 413, 9, 23855, 3089, 275, 334, 81, 627, 485, 4424, 6166, 9, 1253, 378, 21870, 23855, 1830, 334, 1838, 1137, 378, 304, 27439, 325, 275, 3089, 4331, 499, 1253, 650, 27439, 367, 299, 315, 4945, 8, 78, 12, 378, 12, 446, 17, 304, 257, 288, 1315, 275, 373, 59, 80, 446, 413, 61, 257, 288, 373, 59, 80, 61, 275, 334, 86, 59, 80, 61, 446, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 80, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 257, 288, 612, 275, 373, 59, 80, 61, 27439, 1315, 275, 373, 59, 78, 61, 27439, 373, 59, 16, 61, 275, 334, 86, 59, 16, 61, 446, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 16, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 27439, 612, 275, 373, 59, 16, 61, 27439, 3089, 275, 334, 1838, 446, 485, 4424, 6166, 9, 1253, 378, 21870, 23855, 372, 485, 2809, 18, 495, 8, 86, 12, 715, 9, 257, 4388, 199, 3, 646, 512, 5197, 199, 533, 445, 2890, 76, 1632, 44, 1458, 12626, 8, 331, 5197, 14, 2571, 5061, 304, 272, 408, 272, 6555, 83, 334, 2143, 83, 9, 436, 1748, 11594, 491, 1458, 1584, 272, 408, 272, 768, 4639, 272, 347, 3589, 63, 354, 837, 267, 372, 298, 76, 1458, 2014, 2, 339, 768, 4639, 272, 347, 29226, 63, 1802, 837, 267, 327, 2529, 282, 3974, 1369, 402, 642, 859, 267, 372, 298, 827, 11594, 436, 15, 269, 6555, 83, 634, 1458, 1584, 2, 339, 327, 961, 365, 440, 314, 3787, 12, 2951, 376, 2536, 565, 707, 272, 347, 4205, 8, 277, 12, 1511, 12, 6449, 694, 304, 267, 408, 267, 7628, 26, 267, 446, 658, 1419, 8340, 267, 408, 267, 291, 423, 1818, 63, 2164, 63, 694, 275, 488, 267, 291, 423, 2164, 63, 694, 63, 5250, 275, 291, 14, 7721, 63, 515, 63, 262, 63, 513, 8, 1419, 14, 2164, 63, 694, 63, 5250, 9 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 27103, 199, 3, 512, 5197, 298, 76, 1458, 2014, 2, 3589, 199, 3, 199, 3, 1898, 6171, 334, 35, 9, 20619, 199, 3, 199, 3, 844, 26, 10697, 199, 3, 27103, 199, 199, 2344, 199, 2, 76, 1458, 2014, 2, 3589, 367, 512, 5197, 1414, 1004, 4744, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 747, 199, 646, 2022, 199, 646, 6485, 199, 199, 646, 512, 5197, 199, 199, 26207, 381, 221, 199, 3, 1014, 921, 1544, 14, 18499, 600, 14, 1308, 15, 28067, 10197, 6934, 13, 11516, 14, 1360, 199, 26207, 381, 9948, 199, 646, 2702, 9948, 199, 63, 4424, 6166, 275, 378, 88, 25, 37, 7332, 25, 34, 25, 257, 199, 199, 318, 485, 2809, 18, 495, 8, 86, 12, 336, 304, 23855, 302, 275, 334, 552, 8, 86, 9, 446, 413, 9, 5213, 499, 23855, 340, 336, 26, 27439, 333, 275, 373, 1988, 17, 61, 27439, 340, 334, 77, 665, 302, 446, 650, 9, 503, 334, 77, 690, 302, 304, 372, 2125, 27439, 302, 275, 333, 23855, 308, 275, 2702, 14, 1389, 18875, 73, 44, 7, 450, 822, 8, 86, 395, 627, 86, 9, 23855, 372, 308, 59, 16, 26, 78, 61, 340, 336, 587, 308, 257, 2043, 199, 318, 485, 495, 18, 2809, 8, 83, 12, 336, 304, 23855, 302, 275, 822, 8, 83, 9, 23855, 333, 275, 334, 20, 446, 334, 78, 1253, 650, 9, 1253, 650, 9, 435, 302, 23855, 308, 275, 308, 14, 19996, 8, 77, 12, 1867, 16, 531, 23855, 373, 275, 769, 8, 1820, 14, 5301, 18875, 73, 44, 7, 450, 334, 77, 4331, 499, 395, 308, 430, 23855, 340, 336, 26, 373, 14, 740, 8, 78, 9, 23855, 372, 373, 257, 2043, 199, 318, 14645, 8, 495, 12, 790, 304, 23855, 340, 620, 508, 8061, 372, 620, 23855, 373, 275, 485, 495, 18, 2809, 8, 495, 12, 715, 9, 23855, 1022, 275, 485, 495, 18, 2809, 8, 498, 14, 19996, 8, 975, 12, 1867, 16, 1288, 756, 9, 23855, 302, 275, 822, 8, 86, 9, 446, 413, 23855, 1315, 275, 373, 59, 78, 61, 23855, 612, 275, 373, 59, 16, 61, 23855, 3089, 275, 378, 23855, 1894, 275, 1227, 435, 14589, 5001, 334, 78, 435, 413, 9, 23855, 1830, 1894, 690, 378, 26, 27439, 3089, 275, 334, 1838, 435, 485, 4424, 6166, 9, 1253, 378, 21870, 27439, 325, 275, 3089, 4331, 499, 1253, 650, 27439, 367, 299, 315, 4945, 8, 78, 304, 257, 288, 612, 275, 373, 59, 80, 435, 413, 61, 257, 288, 373, 59, 80, 61, 275, 334, 86, 59, 80, 61, 435, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 80, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 257, 288, 1315, 275, 373, 59, 80, 61, 27439, 612, 275, 373, 59, 16, 61, 27439, 373, 59, 78, 61, 275, 334, 86, 59, 78, 61, 435, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 78, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 27439, 1315, 275, 373, 59, 78, 61, 27439, 1894, 4862, 413, 23855, 372, 485, 2809, 18, 495, 8, 86, 12, 756, 9, 257, 2043, 199, 318, 20090, 8, 495, 12, 790, 304, 23855, 340, 620, 508, 8061, 372, 620, 23855, 373, 275, 485, 495, 18, 2809, 8, 495, 12, 756, 9, 23855, 1022, 275, 485, 495, 18, 2809, 8, 498, 14, 19996, 8, 975, 12, 1867, 16, 1288, 756, 9, 23855, 302, 275, 822, 8, 86, 9, 446, 413, 23855, 1315, 275, 373, 59, 78, 61, 23855, 612, 275, 373, 59, 16, 61, 23855, 1894, 275, 1227, 435, 14589, 5001, 334, 78, 435, 413, 9, 23855, 3089, 275, 334, 81, 627, 485, 4424, 6166, 9, 1253, 378, 21870, 23855, 1830, 334, 1838, 1137, 378, 304, 27439, 325, 275, 3089, 4331, 499, 1253, 650, 27439, 367, 299, 315, 4945, 8, 78, 12, 378, 12, 446, 17, 304, 257, 288, 1315, 275, 373, 59, 80, 446, 413, 61, 257, 288, 373, 59, 80, 61, 275, 334, 86, 59, 80, 61, 446, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 80, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 257, 288, 612, 275, 373, 59, 80, 61, 27439, 1315, 275, 373, 59, 78, 61, 27439, 373, 59, 16, 61, 275, 334, 86, 59, 16, 61, 446, 3666, 90, 4331, 959, 7167, 612, 5213, 499, 9, 435, 334, 89, 4331, 650, 7167, 1315, 5213, 841, 9, 7167, 334, 1838, 7167, 612, 9, 435, 334, 75, 59, 16, 1253, 650, 7167, 325, 61, 7167, 1315, 1724, 1253, 378, 21870, 27439, 612, 275, 373, 59, 16, 61, 27439, 3089, 275, 334, 1838, 446, 485, 4424, 6166, 9, 1253, 378, 21870, 23855, 372, 485, 2809, 18, 495, 8, 86, 12, 715, 9, 257, 4388, 199, 3, 646, 512, 5197, 199, 533, 445, 2890, 76, 1632, 44, 1458, 12626, 8, 331, 5197, 14, 2571, 5061, 304, 272, 408, 272, 6555, 83, 334, 2143, 83, 9, 436, 1748, 11594, 491, 1458, 1584, 272, 408, 272, 768, 4639, 272, 347, 3589, 63, 354, 837, 267, 372, 298, 76, 1458, 2014, 2, 339, 768, 4639, 272, 347, 29226, 63, 1802, 837, 267, 327, 2529, 282, 3974, 1369, 402, 642, 859, 267, 372, 298, 827, 11594, 436, 15, 269, 6555, 83, 634, 1458, 1584, 2, 339, 327, 961, 365, 440, 314, 3787, 12, 2951, 376, 2536, 565, 707, 272, 347, 4205, 8, 277, 12, 1511, 12, 6449, 694, 304, 267, 408, 267, 7628, 26, 267, 446, 658, 1419, 8340, 267, 408, 267, 291, 423, 1818, 63, 2164, 63, 694, 275, 488, 267, 291, 423, 2164, 63, 694, 63, 5250, 275, 291, 14, 7721, 63, 515, 63, 262, 63, 513, 8, 1419, 14, 2164, 63, 694, 63, 5250, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
lukw00/shogun
tests/integration/generator/regression.py
22
3484
"""Generator for Regression""" import shogun.Regression as regression from shogun.Kernel import GaussianKernel import fileop import featop import dataop import category def _compute (params, feats, kernel, pout): """ Compute a regression and gather result data. @param params misc parameters for the regression method @param feats features of the kernel/regression @param kernel kernel @param pout previously gathered data from kernel ready to be written to file """ kernel.parallel.set_num_threads(params['num_threads']) kernel.init(feats['train'], feats['train']) params['labels'], labels=dataop.get_labels(feats['train'].get_num_vectors()) try: fun=eval('regression.'+params['name']) except AttributeError: return if params['type']=='svm': regression=fun(params['C'], params['epsilon'], kernel, labels) regression.set_tube_epsilon(params['tube_epsilon']) else: regression=fun(params['tau'], kernel, labels) regression.parallel.set_num_threads(params['num_threads']) regression.train() if params['type']=='svm': params['bias']=regression.get_bias() params['alpha_sum']=0 for item in regression.get_alphas().tolist(): params['alpha_sum']+=item params['sv_sum']=0 for item in regression.get_support_vectors(): params['sv_sum']+=item kernel.init(feats['train'], feats['test']) params['classified']=regression.apply().get_labels() output=pout.copy() output.update(fileop.get_output(category.REGRESSION, params)) fileop.write(category.REGRESSION, output) def _loop (regressions, feats, kernel, pout): """ Loop through regression computations, only slightly differing in parameters. @param regressions names of the regression methods to loop through @param feats features of the kernel/regression @param kernel kernel @param pout previously gathered data from kernel ready to be written to file """ for r in regressions: r['num_threads']=1 if r['type']=='svm': r['C']=.017 r['epsilon']=1e-5 r['accuracy']=r['epsilon']*10 r['tube_epsilon']=1e-2 _compute(r, feats, kernel, pout) r['C']=.23 _compute(r, feats, kernel, pout) r['C']=1.5 _compute(r, feats, kernel, pout) r['C']=30 _compute(r, feats, kernel, pout) r['epsilon']=1e-4 r['accuracy']=r['epsilon']*10 _compute(r, feats, kernel, pout) r['tube_epsilon']=1e-3 _compute(r, feats, kernel, pout) elif r['type']=='kernelmachine': r['tau']=1e-6 _compute(r, feats, kernel, pout) r['tau']=1e-5 _compute(r, feats, kernel, pout) else: continue # BUG in SVRLight: # glibc detected *** /usr/bin/python: free(): invalid next size (fast) if r['name']!='SVRLight': r['num_threads']=16 _compute(r, feats, kernel, pout) ########################################################################## # public ########################################################################## def run (): """Run generator for all regression methods.""" regressions=( {'name': 'SVRLight', 'type': 'svm', 'accuracy': 1e-6}, {'name': 'LibSVR', 'type': 'svm', 'accuracy': 1e-6}, {'name': 'KRR', 'type': 'kernelmachine', 'accuracy': 1e-8}, ) params={ 'name': 'Gaussian', 'args': {'key': ('width',), 'val': (1.5,)}, 'feature_class': 'simple', 'feature_type': 'Real', 'data': dataop.get_rand() } output=fileop.get_output(category.KERNEL, params) feats=featop.get_simple('Real', params['data']) kernel=GaussianKernel(10, *params['args']['val']) _loop(regressions, feats, kernel, output)
gpl-3.0
[ 624, 7599, 367, 13262, 624, 199, 199, 646, 930, 17924, 14, 13013, 465, 10864, 199, 504, 930, 17924, 14, 14127, 492, 17131, 14127, 199, 199, 646, 570, 411, 199, 646, 13953, 411, 199, 646, 666, 411, 199, 646, 4637, 421, 199, 318, 485, 3357, 334, 1162, 12, 1964, 1956, 12, 5114, 12, 299, 548, 304, 199, 198, 624, 199, 198, 8564, 282, 10864, 436, 13082, 754, 666, 14, 421, 198, 32, 635, 1862, 18576, 2633, 367, 314, 10864, 1083, 199, 198, 32, 635, 1964, 1956, 4534, 402, 314, 5114, 15, 12513, 199, 198, 32, 635, 5114, 5114, 199, 198, 32, 635, 299, 548, 10889, 16072, 31051, 666, 687, 5114, 10144, 370, 506, 5313, 370, 570, 199, 198, 624, 421, 198, 4989, 14, 11887, 14, 409, 63, 1507, 63, 6962, 8, 1162, 459, 1507, 63, 6962, 1105, 199, 198, 4989, 14, 826, 8, 29255, 459, 2834, 995, 1964, 1956, 459, 2834, 1105, 199, 198, 1162, 459, 3512, 995, 3628, 29, 576, 411, 14, 362, 63, 3512, 8, 29255, 459, 2834, 2278, 362, 63, 1507, 63, 12280, 1012, 421, 198, 893, 26, 507, 198, 7036, 29, 2579, 360, 12513, 3530, 11, 1162, 459, 354, 1105, 199, 198, 2590, 4281, 26, 507, 198, 1107, 421, 198, 692, 1862, 459, 466, 418, 6803, 16820, 356, 507, 198, 12513, 29, 7036, 8, 1162, 459, 35, 995, 1862, 459, 15761, 995, 5114, 12, 3628, 9, 507, 198, 12513, 14, 409, 63, 84, 3375, 63, 15761, 8, 1162, 459, 84, 3375, 63, 15761, 1105, 199, 198, 2836, 26, 507, 198, 12513, 29, 7036, 8, 1162, 459, 16656, 995, 5114, 12, 3628, 9, 199, 198, 12513, 14, 11887, 14, 409, 63, 1507, 63, 6962, 8, 1162, 459, 1507, 63, 6962, 1105, 421, 198, 12513, 14, 2834, 342, 421, 198, 692, 1862, 459, 466, 418, 6803, 16820, 356, 507, 198, 1162, 459, 8160, 13784, 12513, 14, 362, 63, 8160, 342, 507, 198, 1162, 459, 4468, 63, 1838, 13784, 16, 507, 198, 509, 1242, 315, 10864, 14, 362, 63, 17479, 1252, 13633, 837, 686, 198, 1162, 459, 4468, 63, 1838, 418, 10365, 1053, 507, 198, 1162, 459, 2772, 63, 1838, 13784, 16, 507, 198, 509, 1242, 315, 10864, 14, 362, 63, 4058, 63, 12280, 837, 686, 198, 1162, 459, 2772, 63, 1838, 418, 10365, 1053, 421, 198, 4989, 14, 826, 8, 29255, 459, 2834, 995, 1964, 1956, 459, 396, 1105, 199, 198, 1162, 459, 12334, 1290, 13784, 12513, 14, 4998, 1252, 362, 63, 3512, 342, 421, 198, 1199, 29, 80, 548, 14, 1574, 342, 199, 198, 1199, 14, 873, 8, 493, 411, 14, 362, 63, 1199, 8, 3710, 14, 907, 3975, 9577, 12, 1862, 430, 199, 198, 493, 411, 14, 952, 8, 3710, 14, 907, 3975, 9577, 12, 1072, 9, 421, 199, 318, 485, 3813, 334, 1135, 6274, 12, 1964, 1956, 12, 5114, 12, 299, 548, 304, 199, 198, 624, 199, 198, 7382, 4012, 10864, 28319, 1298, 12, 1454, 18023, 28488, 315, 2633, 14, 421, 198, 32, 635, 1295, 6274, 1561, 402, 314, 10864, 3102, 370, 4438, 4012, 199, 198, 32, 635, 1964, 1956, 4534, 402, 314, 5114, 15, 12513, 199, 198, 32, 635, 5114, 5114, 199, 198, 32, 635, 299, 548, 10889, 16072, 31051, 666, 687, 5114, 10144, 370, 506, 5313, 370, 570, 199, 198, 624, 421, 198, 509, 519, 315, 1295, 6274, 26, 507, 198, 82, 459, 1507, 63, 6962, 13784, 17, 507, 198, 692, 519, 459, 466, 418, 6803, 16820, 356, 686, 198, 82, 459, 35, 13784, 14, 9570, 686, 198, 82, 459, 15761, 13784, 17, 69, 13, 21, 686, 198, 82, 459, 13374, 13784, 82, 459, 15761, 20445, 709, 686, 198, 82, 459, 84, 3375, 63, 15761, 13784, 17, 69, 13, 18, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 14, 1789, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 17, 14, 21, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 1216, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 15761, 13784, 17, 69, 13, 20, 686, 198, 82, 459, 13374, 13784, 82, 459, 15761, 20445, 709, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 84, 3375, 63, 15761, 13784, 17, 69, 13, 19, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 507, 198, 4164, 519, 459, 466, 418, 6803, 4989, 6744, 356, 686, 198, 82, 459, 16656, 13784, 17, 69, 13, 22, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 16656, 13784, 17, 69, 13, 21, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 507, 198, 2836, 26, 686, 198, 6958, 2742, 198, 3, 699, 10134, 315, 14056, 2431, 1070, 26, 507, 198, 3, 486, 20217, 10501, 19688, 1182, 2647, 15, 1393, 15, 1548, 26, 2867, 837, 3866, 2163, 1568, 334, 7015, 9, 507, 198, 692, 519, 459, 354, 418, 27909, 4985, 2431, 1070, 356, 686, 198, 82, 459, 1507, 63, 6962, 13784, 975, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 199, 199, 26863, 199, 3, 4575, 199, 26863, 199, 199, 318, 1255, 23390, 199, 198, 624, 2540, 4306, 367, 1006, 10864, 3102, 1041, 421, 198, 1135, 6274, 2687, 507, 198, 1445, 354, 356, 283, 4985, 2431, 1070, 297, 283, 466, 356, 283, 16820, 297, 283, 13374, 356, 413, 69, 13, 22, 1386, 507, 198, 1445, 354, 356, 283, 4728, 4985, 50, 297, 283, 466, 356, 283, 16820, 297, 283, 13374, 356, 413, 69, 13, 22, 1386, 507, 198, 1445, 354, 356, 283, 43, 13381, 297, 283, 466, 356, 283, 4989, 6744, 297, 283, 13374, 356, 413, 69, 13, 24, 1386, 199, 198, 9, 421, 198, 1162, 3126, 507, 198, 7, 354, 356, 283, 26756, 297, 507, 198, 7, 589, 356, 791, 498, 356, 661, 2063, 5529, 283, 637, 356, 334, 17, 14, 21, 4258 ]
[ 7599, 367, 13262, 624, 199, 199, 646, 930, 17924, 14, 13013, 465, 10864, 199, 504, 930, 17924, 14, 14127, 492, 17131, 14127, 199, 199, 646, 570, 411, 199, 646, 13953, 411, 199, 646, 666, 411, 199, 646, 4637, 421, 199, 318, 485, 3357, 334, 1162, 12, 1964, 1956, 12, 5114, 12, 299, 548, 304, 199, 198, 624, 199, 198, 8564, 282, 10864, 436, 13082, 754, 666, 14, 421, 198, 32, 635, 1862, 18576, 2633, 367, 314, 10864, 1083, 199, 198, 32, 635, 1964, 1956, 4534, 402, 314, 5114, 15, 12513, 199, 198, 32, 635, 5114, 5114, 199, 198, 32, 635, 299, 548, 10889, 16072, 31051, 666, 687, 5114, 10144, 370, 506, 5313, 370, 570, 199, 198, 624, 421, 198, 4989, 14, 11887, 14, 409, 63, 1507, 63, 6962, 8, 1162, 459, 1507, 63, 6962, 1105, 199, 198, 4989, 14, 826, 8, 29255, 459, 2834, 995, 1964, 1956, 459, 2834, 1105, 199, 198, 1162, 459, 3512, 995, 3628, 29, 576, 411, 14, 362, 63, 3512, 8, 29255, 459, 2834, 2278, 362, 63, 1507, 63, 12280, 1012, 421, 198, 893, 26, 507, 198, 7036, 29, 2579, 360, 12513, 3530, 11, 1162, 459, 354, 1105, 199, 198, 2590, 4281, 26, 507, 198, 1107, 421, 198, 692, 1862, 459, 466, 418, 6803, 16820, 356, 507, 198, 12513, 29, 7036, 8, 1162, 459, 35, 995, 1862, 459, 15761, 995, 5114, 12, 3628, 9, 507, 198, 12513, 14, 409, 63, 84, 3375, 63, 15761, 8, 1162, 459, 84, 3375, 63, 15761, 1105, 199, 198, 2836, 26, 507, 198, 12513, 29, 7036, 8, 1162, 459, 16656, 995, 5114, 12, 3628, 9, 199, 198, 12513, 14, 11887, 14, 409, 63, 1507, 63, 6962, 8, 1162, 459, 1507, 63, 6962, 1105, 421, 198, 12513, 14, 2834, 342, 421, 198, 692, 1862, 459, 466, 418, 6803, 16820, 356, 507, 198, 1162, 459, 8160, 13784, 12513, 14, 362, 63, 8160, 342, 507, 198, 1162, 459, 4468, 63, 1838, 13784, 16, 507, 198, 509, 1242, 315, 10864, 14, 362, 63, 17479, 1252, 13633, 837, 686, 198, 1162, 459, 4468, 63, 1838, 418, 10365, 1053, 507, 198, 1162, 459, 2772, 63, 1838, 13784, 16, 507, 198, 509, 1242, 315, 10864, 14, 362, 63, 4058, 63, 12280, 837, 686, 198, 1162, 459, 2772, 63, 1838, 418, 10365, 1053, 421, 198, 4989, 14, 826, 8, 29255, 459, 2834, 995, 1964, 1956, 459, 396, 1105, 199, 198, 1162, 459, 12334, 1290, 13784, 12513, 14, 4998, 1252, 362, 63, 3512, 342, 421, 198, 1199, 29, 80, 548, 14, 1574, 342, 199, 198, 1199, 14, 873, 8, 493, 411, 14, 362, 63, 1199, 8, 3710, 14, 907, 3975, 9577, 12, 1862, 430, 199, 198, 493, 411, 14, 952, 8, 3710, 14, 907, 3975, 9577, 12, 1072, 9, 421, 199, 318, 485, 3813, 334, 1135, 6274, 12, 1964, 1956, 12, 5114, 12, 299, 548, 304, 199, 198, 624, 199, 198, 7382, 4012, 10864, 28319, 1298, 12, 1454, 18023, 28488, 315, 2633, 14, 421, 198, 32, 635, 1295, 6274, 1561, 402, 314, 10864, 3102, 370, 4438, 4012, 199, 198, 32, 635, 1964, 1956, 4534, 402, 314, 5114, 15, 12513, 199, 198, 32, 635, 5114, 5114, 199, 198, 32, 635, 299, 548, 10889, 16072, 31051, 666, 687, 5114, 10144, 370, 506, 5313, 370, 570, 199, 198, 624, 421, 198, 509, 519, 315, 1295, 6274, 26, 507, 198, 82, 459, 1507, 63, 6962, 13784, 17, 507, 198, 692, 519, 459, 466, 418, 6803, 16820, 356, 686, 198, 82, 459, 35, 13784, 14, 9570, 686, 198, 82, 459, 15761, 13784, 17, 69, 13, 21, 686, 198, 82, 459, 13374, 13784, 82, 459, 15761, 20445, 709, 686, 198, 82, 459, 84, 3375, 63, 15761, 13784, 17, 69, 13, 18, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 14, 1789, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 17, 14, 21, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 35, 13784, 1216, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 15761, 13784, 17, 69, 13, 20, 686, 198, 82, 459, 13374, 13784, 82, 459, 15761, 20445, 709, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 84, 3375, 63, 15761, 13784, 17, 69, 13, 19, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 507, 198, 4164, 519, 459, 466, 418, 6803, 4989, 6744, 356, 686, 198, 82, 459, 16656, 13784, 17, 69, 13, 22, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 686, 198, 82, 459, 16656, 13784, 17, 69, 13, 21, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 507, 198, 2836, 26, 686, 198, 6958, 2742, 198, 3, 699, 10134, 315, 14056, 2431, 1070, 26, 507, 198, 3, 486, 20217, 10501, 19688, 1182, 2647, 15, 1393, 15, 1548, 26, 2867, 837, 3866, 2163, 1568, 334, 7015, 9, 507, 198, 692, 519, 459, 354, 418, 27909, 4985, 2431, 1070, 356, 686, 198, 82, 459, 1507, 63, 6962, 13784, 975, 686, 198, 63, 3357, 8, 82, 12, 1964, 1956, 12, 5114, 12, 299, 548, 9, 199, 199, 26863, 199, 3, 4575, 199, 26863, 199, 199, 318, 1255, 23390, 199, 198, 624, 2540, 4306, 367, 1006, 10864, 3102, 1041, 421, 198, 1135, 6274, 2687, 507, 198, 1445, 354, 356, 283, 4985, 2431, 1070, 297, 283, 466, 356, 283, 16820, 297, 283, 13374, 356, 413, 69, 13, 22, 1386, 507, 198, 1445, 354, 356, 283, 4728, 4985, 50, 297, 283, 466, 356, 283, 16820, 297, 283, 13374, 356, 413, 69, 13, 22, 1386, 507, 198, 1445, 354, 356, 283, 43, 13381, 297, 283, 466, 356, 283, 4989, 6744, 297, 283, 13374, 356, 413, 69, 13, 24, 1386, 199, 198, 9, 421, 198, 1162, 3126, 507, 198, 7, 354, 356, 283, 26756, 297, 507, 198, 7, 589, 356, 791, 498, 356, 661, 2063, 5529, 283, 637, 356, 334, 17, 14, 21, 4258, 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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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 ]
antoviaque/edx-platform
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
7
17412
""" Tests for programs celery tasks. """ import ddt import httpretty import json import mock import unittest from celery.exceptions import MaxRetriesExceededError from django.conf import settings from django.test import override_settings, TestCase from edx_rest_api_client.client import EdxRestApiClient from oauth2_provider.tests.factories import ClientFactory from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfigMixin from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin from openedx.core.djangoapps.programs.tasks.v1 import tasks from student.tests.factories import UserFactory TASKS_MODULE = 'openedx.core.djangoapps.programs.tasks.v1.tasks' @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class GetApiClientTestCase(TestCase, ProgramsApiConfigMixin): """ Test the get_api_client function """ @mock.patch(TASKS_MODULE + '.get_id_token') def test_get_api_client(self, mock_get_id_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name='programs') api_config = self.create_programs_config( internal_service_url='http://foo', api_version_number=99, ) mock_get_id_token.return_value = 'test-token' api_client = tasks.get_api_client(api_config, student) self.assertEqual(mock_get_id_token.call_args[0], (student, 'programs')) self.assertEqual(api_client._store['base_url'], 'http://foo/api/v99/') # pylint: disable=protected-access self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class GetCompletedCoursesTestCase(TestCase): """ Test the get_completed_courses function """ def make_cert_result(self, **kwargs): """ Helper to create dummy results from the certificates API """ result = { 'username': 'dummy-username', 'course_key': 'dummy-course', 'type': 'dummy-type', 'status': 'dummy-status', 'download_url': 'http://www.example.com/cert.pdf', 'grade': '0.98', 'created': '2015-07-31T00:00:00Z', 'modified': '2015-07-31T00:00:00Z', } result.update(**kwargs) return result @mock.patch(TASKS_MODULE + '.get_certificates_for_user') def test_get_completed_courses(self, mock_get_certs_for_user): """ Ensure the function correctly calls to and handles results from the certificates API """ student = UserFactory(username='test-username') mock_get_certs_for_user.return_value = [ self.make_cert_result(status='downloadable', type='verified', course_key='downloadable-course'), self.make_cert_result(status='generating', type='prof-ed', course_key='generating-course'), self.make_cert_result(status='unknown', type='honor', course_key='unknown-course'), ] result = tasks.get_completed_courses(student) self.assertEqual(mock_get_certs_for_user.call_args[0], (student.username, )) self.assertEqual(result, [ {'course_id': 'downloadable-course', 'mode': 'verified'}, {'course_id': 'generating-course', 'mode': 'prof-ed'}, ]) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class GetCompletedProgramsTestCase(TestCase): """ Test the get_completed_programs function """ @httpretty.activate def test_get_completed_programs(self): """ Ensure the correct API call gets made """ test_client = EdxRestApiClient('http://test-server', jwt='test-token') httpretty.register_uri( httpretty.POST, 'http://test-server/programs/complete/', body='{"program_ids": [1, 2, 3]}', content_type='application/json', ) payload = [ {'course_id': 'test-course-1', 'mode': 'verified'}, {'course_id': 'test-course-2', 'mode': 'prof-ed'}, ] result = tasks.get_completed_programs(test_client, payload) self.assertEqual(json.loads(httpretty.last_request().body), {'completed_courses': payload}) self.assertEqual(result, [1, 2, 3]) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class GetAwardedCertificateProgramsTestCase(TestCase): """ Test the get_awarded_certificate_programs function """ def make_credential_result(self, **kwargs): """ Helper to make dummy results from the credentials API """ result = { 'id': 1, 'username': 'dummy-username', 'credential': { 'credential_id': None, 'program_id': None, }, 'status': 'dummy-status', 'uuid': 'dummy-uuid', 'certificate_url': 'http://credentials.edx.org/credentials/dummy-uuid/' } result.update(**kwargs) return result @mock.patch(TASKS_MODULE + '.get_user_credentials') def test_get_awarded_certificate_programs(self, mock_get_user_credentials): """ Ensure the API is called and results handled correctly. """ student = UserFactory(username='test-username') mock_get_user_credentials.return_value = [ self.make_credential_result(status='awarded', credential={'program_id': 1}), self.make_credential_result(status='awarded', credential={'course_id': 2}), self.make_credential_result(status='revoked', credential={'program_id': 3}), ] result = tasks.get_awarded_certificate_programs(student) self.assertEqual(mock_get_user_credentials.call_args[0], (student, )) self.assertEqual(result, [1]) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class AwardProgramCertificateTestCase(TestCase): """ Test the award_program_certificate function """ @httpretty.activate def test_award_program_certificate(self): """ Ensure the correct API call gets made """ test_username = 'test-username' test_client = EdxRestApiClient('http://test-server', jwt='test-token') httpretty.register_uri( httpretty.POST, 'http://test-server/user_credentials/', ) tasks.award_program_certificate(test_client, test_username, 123) expected_body = { 'username': test_username, 'credential': {'program_id': 123}, 'attributes': [] } self.assertEqual(json.loads(httpretty.last_request().body), expected_body) @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') @ddt.ddt @mock.patch(TASKS_MODULE + '.award_program_certificate') @mock.patch(TASKS_MODULE + '.get_awarded_certificate_programs') @mock.patch(TASKS_MODULE + '.get_completed_programs') @mock.patch(TASKS_MODULE + '.get_completed_courses') @override_settings(CREDENTIALS_SERVICE_USERNAME='test-service-username') class AwardProgramCertificatesTestCase(TestCase, ProgramsApiConfigMixin, CredentialsApiConfigMixin): """ Tests for the 'award_program_certificates' celery task. """ def setUp(self): super(AwardProgramCertificatesTestCase, self).setUp() self.create_programs_config() self.create_credentials_config() self.student = UserFactory.create(username='test-student') ClientFactory.create(name='programs') ClientFactory.create(name='credentials') UserFactory.create(username=settings.CREDENTIALS_SERVICE_USERNAME) # pylint: disable=no-member def test_completion_check( self, mock_get_completed_courses, mock_get_completed_programs, mock_get_awarded_certificate_programs, # pylint: disable=unused-argument mock_award_program_certificate, # pylint: disable=unused-argument ): """ Checks that the Programs API is used correctly to determine completed programs. """ completed_courses = [ {'course_id': 'course-1', 'type': 'verified'}, {'course_id': 'course-2', 'type': 'prof-ed'}, ] mock_get_completed_courses.return_value = completed_courses tasks.award_program_certificates.delay(self.student.username).get() self.assertEqual( mock_get_completed_programs.call_args[0][1], completed_courses ) @ddt.data( ([1], [2, 3]), ([], [1, 2, 3]), ([1, 2, 3], []), ) @ddt.unpack def test_awarding_certs( self, already_awarded_program_ids, expected_awarded_program_ids, mock_get_completed_courses, # pylint: disable=unused-argument mock_get_completed_programs, mock_get_awarded_certificate_programs, mock_award_program_certificate, ): """ Checks that the Credentials API is used to award certificates for the proper programs. """ mock_get_completed_programs.return_value = [1, 2, 3] mock_get_awarded_certificate_programs.return_value = already_awarded_program_ids tasks.award_program_certificates.delay(self.student.username).get() actual_program_ids = [call[0][2] for call in mock_award_program_certificate.call_args_list] self.assertEqual(actual_program_ids, expected_awarded_program_ids) @ddt.data( ('programs', 'enable_certification'), ('credentials', 'enable_learner_issuance'), ) @ddt.unpack def test_retry_if_config_disabled( self, disabled_config_type, disabled_config_attribute, *mock_helpers ): """ Checks that the task is aborted if any relevant api configs are disabled. """ getattr(self, 'create_{}_config'.format(disabled_config_type))(**{disabled_config_attribute: False}) with mock.patch(TASKS_MODULE + '.LOGGER.warning') as mock_warning: with self.assertRaises(MaxRetriesExceededError): tasks.award_program_certificates.delay(self.student.username).get() self.assertTrue(mock_warning.called) for mock_helper in mock_helpers: self.assertFalse(mock_helper.called) def test_abort_if_invalid_username(self, *mock_helpers): """ Checks that the task will be aborted and not retried if the username passed was not found, and that an exception is logged. """ with mock.patch(TASKS_MODULE + '.LOGGER.exception') as mock_exception: tasks.award_program_certificates.delay('nonexistent-username').get() self.assertTrue(mock_exception.called) for mock_helper in mock_helpers: self.assertFalse(mock_helper.called) def test_abort_if_no_completed_courses( self, mock_get_completed_courses, mock_get_completed_programs, mock_get_awarded_certificate_programs, mock_award_program_certificate, ): """ Checks that the task will be aborted without further action if the student does not have any completed courses, but that a warning is logged. """ mock_get_completed_courses.return_value = [] with mock.patch(TASKS_MODULE + '.LOGGER.warning') as mock_warning: tasks.award_program_certificates.delay(self.student.username).get() self.assertTrue(mock_warning.called) self.assertTrue(mock_get_completed_courses.called) self.assertFalse(mock_get_completed_programs.called) self.assertFalse(mock_get_awarded_certificate_programs.called) self.assertFalse(mock_award_program_certificate.called) def test_abort_if_no_completed_programs( self, mock_get_completed_courses, mock_get_completed_programs, mock_get_awarded_certificate_programs, mock_award_program_certificate, ): """ Checks that the task will be aborted without further action if there are no programs for which to award a certificate. """ mock_get_completed_programs.return_value = [] tasks.award_program_certificates.delay(self.student.username).get() self.assertTrue(mock_get_completed_courses.called) self.assertTrue(mock_get_completed_programs.called) self.assertFalse(mock_get_awarded_certificate_programs.called) self.assertFalse(mock_award_program_certificate.called) def _make_side_effect(self, side_effects): """ DRY helper. Returns a side effect function for use with mocks that will be called multiple times, permitting Exceptions to be raised (or not) in a specified order. See Also: http://www.voidspace.org.uk/python/mock/examples.html#multiple-calls-with-different-effects http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.side_effect """ def side_effect(*_a): # pylint: disable=missing-docstring if side_effects: exc = side_effects.pop(0) if exc: raise exc return mock.DEFAULT return side_effect def test_continue_awarding_certs_if_error( self, mock_get_completed_courses, # pylint: disable=unused-argument mock_get_completed_programs, mock_get_awarded_certificate_programs, mock_award_program_certificate, ): """ Checks that a single failure to award one of several certificates does not cause the entire task to fail. Also ensures that successfully awarded certs are logged as INFO and exceptions that arise are logged also. """ mock_get_completed_programs.return_value = [1, 2] mock_get_awarded_certificate_programs.side_effect = [[], [2]] mock_award_program_certificate.side_effect = self._make_side_effect([Exception('boom'), None]) with mock.patch(TASKS_MODULE + '.LOGGER.info') as mock_info, \ mock.patch(TASKS_MODULE + '.LOGGER.exception') as mock_exception: tasks.award_program_certificates.delay(self.student.username).get() self.assertEqual(mock_award_program_certificate.call_count, 3) mock_exception.assert_called_once_with(mock.ANY, 1, self.student.username) mock_info.assert_any_call(mock.ANY, 1, self.student.username) mock_info.assert_any_call(mock.ANY, 2, self.student.username) def test_retry_on_certificates_api_errors( self, mock_get_completed_courses, *_mock_helpers # pylint: disable=unused-argument ): """ Ensures that any otherwise-unhandled errors that arise while trying to get existing course certificates (e.g. network issues or other transient API errors) will cause the task to be failed and queued for retry. """ mock_get_completed_courses.side_effect = self._make_side_effect([Exception('boom'), None]) tasks.award_program_certificates.delay(self.student.username).get() self.assertEqual(mock_get_completed_courses.call_count, 2) def test_retry_on_programs_api_errors( self, mock_get_completed_courses, # pylint: disable=unused-argument mock_get_completed_programs, *_mock_helpers # pylint: disable=unused-argument ): """ Ensures that any otherwise-unhandled errors that arise while trying to get completed programs (e.g. network issues or other transient API errors) will cause the task to be failed and queued for retry. """ mock_get_completed_programs.side_effect = self._make_side_effect([Exception('boom'), None]) tasks.award_program_certificates.delay(self.student.username).get() self.assertEqual(mock_get_completed_programs.call_count, 2) def test_retry_on_credentials_api_errors( self, mock_get_completed_courses, # pylint: disable=unused-argument mock_get_completed_programs, mock_get_awarded_certificate_programs, mock_award_program_certificate, ): """ Ensures that any otherwise-unhandled errors that arise while trying to get existing program credentials (e.g. network issues or other transient API errors) will cause the task to be failed and queued for retry. """ mock_get_completed_programs.return_value = [1, 2] mock_get_awarded_certificate_programs.return_value = [1] mock_get_awarded_certificate_programs.side_effect = self._make_side_effect([Exception('boom'), None]) tasks.award_program_certificates.delay(self.student.username).get() self.assertEqual(mock_get_awarded_certificate_programs.call_count, 2) self.assertEqual(mock_award_program_certificate.call_count, 1)
agpl-3.0
[ 624, 199, 2925, 367, 18572, 22748, 6527, 14, 199, 624, 199, 199, 646, 366, 3583, 199, 646, 22768, 9118, 199, 646, 2022, 199, 646, 1683, 199, 646, 2882, 199, 199, 504, 22748, 14, 3924, 492, 8228, 32720, 24748, 547, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 12, 7640, 199, 504, 22435, 63, 3911, 63, 1246, 63, 1258, 14, 1258, 492, 662, 8373, 13726, 7394, 3041, 199, 199, 504, 9725, 18, 63, 3780, 14, 2219, 14, 15406, 492, 6810, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 6942, 14, 2219, 14, 30192, 492, 23934, 7394, 2028, 4256, 199, 504, 22709, 14, 1018, 14, 16432, 14, 28464, 14, 2219, 14, 30192, 492, 2165, 9292, 7394, 2028, 4256, 199, 504, 22709, 14, 1018, 14, 16432, 14, 28464, 14, 5054, 14, 86, 17, 492, 6527, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 421, 199, 17179, 51, 63, 10001, 275, 283, 1490, 8268, 14, 1018, 14, 16432, 14, 28464, 14, 5054, 14, 86, 17, 14, 5054, 7, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 7394, 3041, 1746, 8, 1746, 12, 2165, 9292, 7394, 2028, 4256, 304, 272, 408, 272, 1379, 314, 664, 63, 1246, 63, 1258, 805, 272, 408, 339, 768, 1805, 14, 2068, 8, 17179, 51, 63, 10001, 435, 1987, 362, 63, 344, 63, 1418, 358, 272, 347, 511, 63, 362, 63, 1246, 63, 1258, 8, 277, 12, 1683, 63, 362, 63, 344, 63, 1418, 304, 267, 408, 267, 7523, 314, 805, 365, 10663, 314, 2451, 3261, 4882, 4079, 641, 4153, 267, 408, 267, 6474, 275, 16047, 342, 267, 6810, 2927, 14, 981, 8, 354, 534, 28464, 358, 267, 2986, 63, 888, 275, 291, 14, 981, 63, 28464, 63, 888, 8, 288, 5007, 63, 1364, 63, 633, 534, 1014, 921, 1421, 297, 288, 2986, 63, 1023, 63, 1955, 29, 1020, 12, 267, 776, 267, 1683, 63, 362, 63, 344, 63, 1418, 14, 1107, 63, 585, 275, 283, 396, 13, 1418, 7, 398, 2986, 63, 1258, 275, 6527, 14, 362, 63, 1246, 63, 1258, 8, 1246, 63, 888, 12, 6474, 9, 267, 291, 14, 629, 8, 1805, 63, 362, 63, 344, 63, 1418, 14, 1250, 63, 589, 59, 16, 467, 334, 5500, 12, 283, 28464, 1333, 267, 291, 14, 629, 8, 1246, 63, 1258, 423, 1617, 459, 1095, 63, 633, 995, 283, 1014, 921, 1421, 15, 1246, 15, 86, 1020, 6217, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 291, 14, 629, 8, 1246, 63, 1258, 423, 1617, 459, 1730, 2278, 1178, 14, 1418, 12, 283, 396, 13, 1418, 358, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 19908, 35, 567, 874, 1746, 8, 1746, 304, 272, 408, 272, 1379, 314, 664, 63, 12634, 63, 11653, 805, 272, 408, 339, 347, 1852, 63, 4736, 63, 1099, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 11642, 370, 1218, 7283, 2058, 687, 314, 14512, 3261, 267, 408, 267, 754, 275, 469, 288, 283, 2473, 356, 283, 5869, 13, 2473, 297, 288, 283, 1972, 63, 498, 356, 283, 5869, 13, 1972, 297, 288, 283, 466, 356, 283, 5869, 13, 466, 297, 288, 283, 1205, 356, 283, 5869, 13, 1205, 297, 288, 283, 4249, 63, 633, 356, 283, 1014, 921, 1544, 14, 2694, 14, 957, 15, 4736, 14, 5607, 297, 288, 283, 4523, 356, 283, 16, 14, 2905, 297, 288, 283, 3966, 356, 283, 7806, 13, 1780, 13, 2192, 52, 383, 26, 383, 26, 383, 58, 297, 288, 283, 5540, 356, 283, 7806, 13, 1780, 13, 2192, 52, 383, 26, 383, 26, 383, 58, 297, 267, 789, 267, 754, 14, 873, 3682, 958, 9, 267, 372, 754, 339, 768, 1805, 14, 2068, 8, 17179, 51, 63, 10001, 435, 1987, 362, 63, 16159, 63, 509, 63, 751, 358, 272, 347, 511, 63, 362, 63, 12634, 63, 11653, 8, 277, 12, 1683, 63, 362, 63, 8356, 63, 509, 63, 751, 304, 267, 408, 267, 7523, 314, 805, 6657, 4882, 370, 436, 10022, 2058, 687, 314, 267, 14512, 3261, 267, 408, 267, 6474, 275, 16047, 8, 2473, 534, 396, 13, 2473, 358, 267, 1683, 63, 362, 63, 8356, 63, 509, 63, 751, 14, 1107, 63, 585, 275, 359, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 4249, 461, 297, 730, 534, 12949, 297, 2518, 63, 498, 534, 4249, 461, 13, 1972, 659, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 2038, 1958, 297, 730, 534, 14979, 13, 379, 297, 2518, 63, 498, 534, 2038, 1958, 13, 1972, 659, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 5187, 297, 730, 534, 19923, 297, 2518, 63, 498, 534, 5187, 13, 1972, 659, 267, 1622, 398, 754, 275, 6527, 14, 362, 63, 12634, 63, 11653, 8, 5500, 9, 267, 291, 14, 629, 8, 1805, 63, 362, 63, 8356, 63, 509, 63, 751, 14, 1250, 63, 589, 59, 16, 467, 334, 5500, 14, 2473, 12, 5082, 267, 291, 14, 629, 8, 1099, 12, 359, 288, 791, 1972, 63, 344, 356, 283, 4249, 461, 13, 1972, 297, 283, 632, 356, 283, 12949, 2267, 288, 791, 1972, 63, 344, 356, 283, 2038, 1958, 13, 1972, 297, 283, 632, 356, 283, 14979, 13, 379, 2267, 267, 4794, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 19908, 919, 9292, 1746, 8, 1746, 304, 272, 408, 272, 1379, 314, 664, 63, 12634, 63, 28464, 805, 272, 408, 339, 768, 16916, 9118, 14, 8222, 272, 347, 511, 63, 362, 63, 12634, 63, 28464, 8, 277, 304, 267, 408, 267, 7523, 314, 3211, 3261, 1240, 7545, 6326, 267, 408, 267, 511, 63, 1258, 275, 662, 8373, 13726, 7394, 3041, 360, 1014, 921, 396, 13, 1000, 297, 1335, 9115, 534, 396, 13, 1418, 358, 267, 22768, 9118, 14, 2683, 63, 2302, 8, 288, 22768 ]
[ 199, 2925, 367, 18572, 22748, 6527, 14, 199, 624, 199, 199, 646, 366, 3583, 199, 646, 22768, 9118, 199, 646, 2022, 199, 646, 1683, 199, 646, 2882, 199, 199, 504, 22748, 14, 3924, 492, 8228, 32720, 24748, 547, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 12, 7640, 199, 504, 22435, 63, 3911, 63, 1246, 63, 1258, 14, 1258, 492, 662, 8373, 13726, 7394, 3041, 199, 199, 504, 9725, 18, 63, 3780, 14, 2219, 14, 15406, 492, 6810, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 6942, 14, 2219, 14, 30192, 492, 23934, 7394, 2028, 4256, 199, 504, 22709, 14, 1018, 14, 16432, 14, 28464, 14, 2219, 14, 30192, 492, 2165, 9292, 7394, 2028, 4256, 199, 504, 22709, 14, 1018, 14, 16432, 14, 28464, 14, 5054, 14, 86, 17, 492, 6527, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 421, 199, 17179, 51, 63, 10001, 275, 283, 1490, 8268, 14, 1018, 14, 16432, 14, 28464, 14, 5054, 14, 86, 17, 14, 5054, 7, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 7394, 3041, 1746, 8, 1746, 12, 2165, 9292, 7394, 2028, 4256, 304, 272, 408, 272, 1379, 314, 664, 63, 1246, 63, 1258, 805, 272, 408, 339, 768, 1805, 14, 2068, 8, 17179, 51, 63, 10001, 435, 1987, 362, 63, 344, 63, 1418, 358, 272, 347, 511, 63, 362, 63, 1246, 63, 1258, 8, 277, 12, 1683, 63, 362, 63, 344, 63, 1418, 304, 267, 408, 267, 7523, 314, 805, 365, 10663, 314, 2451, 3261, 4882, 4079, 641, 4153, 267, 408, 267, 6474, 275, 16047, 342, 267, 6810, 2927, 14, 981, 8, 354, 534, 28464, 358, 267, 2986, 63, 888, 275, 291, 14, 981, 63, 28464, 63, 888, 8, 288, 5007, 63, 1364, 63, 633, 534, 1014, 921, 1421, 297, 288, 2986, 63, 1023, 63, 1955, 29, 1020, 12, 267, 776, 267, 1683, 63, 362, 63, 344, 63, 1418, 14, 1107, 63, 585, 275, 283, 396, 13, 1418, 7, 398, 2986, 63, 1258, 275, 6527, 14, 362, 63, 1246, 63, 1258, 8, 1246, 63, 888, 12, 6474, 9, 267, 291, 14, 629, 8, 1805, 63, 362, 63, 344, 63, 1418, 14, 1250, 63, 589, 59, 16, 467, 334, 5500, 12, 283, 28464, 1333, 267, 291, 14, 629, 8, 1246, 63, 1258, 423, 1617, 459, 1095, 63, 633, 995, 283, 1014, 921, 1421, 15, 1246, 15, 86, 1020, 6217, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 291, 14, 629, 8, 1246, 63, 1258, 423, 1617, 459, 1730, 2278, 1178, 14, 1418, 12, 283, 396, 13, 1418, 358, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 19908, 35, 567, 874, 1746, 8, 1746, 304, 272, 408, 272, 1379, 314, 664, 63, 12634, 63, 11653, 805, 272, 408, 339, 347, 1852, 63, 4736, 63, 1099, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 11642, 370, 1218, 7283, 2058, 687, 314, 14512, 3261, 267, 408, 267, 754, 275, 469, 288, 283, 2473, 356, 283, 5869, 13, 2473, 297, 288, 283, 1972, 63, 498, 356, 283, 5869, 13, 1972, 297, 288, 283, 466, 356, 283, 5869, 13, 466, 297, 288, 283, 1205, 356, 283, 5869, 13, 1205, 297, 288, 283, 4249, 63, 633, 356, 283, 1014, 921, 1544, 14, 2694, 14, 957, 15, 4736, 14, 5607, 297, 288, 283, 4523, 356, 283, 16, 14, 2905, 297, 288, 283, 3966, 356, 283, 7806, 13, 1780, 13, 2192, 52, 383, 26, 383, 26, 383, 58, 297, 288, 283, 5540, 356, 283, 7806, 13, 1780, 13, 2192, 52, 383, 26, 383, 26, 383, 58, 297, 267, 789, 267, 754, 14, 873, 3682, 958, 9, 267, 372, 754, 339, 768, 1805, 14, 2068, 8, 17179, 51, 63, 10001, 435, 1987, 362, 63, 16159, 63, 509, 63, 751, 358, 272, 347, 511, 63, 362, 63, 12634, 63, 11653, 8, 277, 12, 1683, 63, 362, 63, 8356, 63, 509, 63, 751, 304, 267, 408, 267, 7523, 314, 805, 6657, 4882, 370, 436, 10022, 2058, 687, 314, 267, 14512, 3261, 267, 408, 267, 6474, 275, 16047, 8, 2473, 534, 396, 13, 2473, 358, 267, 1683, 63, 362, 63, 8356, 63, 509, 63, 751, 14, 1107, 63, 585, 275, 359, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 4249, 461, 297, 730, 534, 12949, 297, 2518, 63, 498, 534, 4249, 461, 13, 1972, 659, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 2038, 1958, 297, 730, 534, 14979, 13, 379, 297, 2518, 63, 498, 534, 2038, 1958, 13, 1972, 659, 288, 291, 14, 1875, 63, 4736, 63, 1099, 8, 1205, 534, 5187, 297, 730, 534, 19923, 297, 2518, 63, 498, 534, 5187, 13, 1972, 659, 267, 1622, 398, 754, 275, 6527, 14, 362, 63, 12634, 63, 11653, 8, 5500, 9, 267, 291, 14, 629, 8, 1805, 63, 362, 63, 8356, 63, 509, 63, 751, 14, 1250, 63, 589, 59, 16, 467, 334, 5500, 14, 2473, 12, 5082, 267, 291, 14, 629, 8, 1099, 12, 359, 288, 791, 1972, 63, 344, 356, 283, 4249, 461, 13, 1972, 297, 283, 632, 356, 283, 12949, 2267, 288, 791, 1972, 63, 344, 356, 283, 2038, 1958, 13, 1972, 297, 283, 632, 356, 283, 14979, 13, 379, 2267, 267, 4794, 421, 199, 32, 2796, 14, 11278, 8, 1751, 14, 5441, 63, 18125, 508, 283, 15807, 14, 3603, 297, 283, 774, 1454, 1686, 315, 21577, 358, 199, 533, 2372, 19908, 919, 9292, 1746, 8, 1746, 304, 272, 408, 272, 1379, 314, 664, 63, 12634, 63, 28464, 805, 272, 408, 339, 768, 16916, 9118, 14, 8222, 272, 347, 511, 63, 362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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 ]
billbonney/ardupilot
mk/PX4/Tools/genmsg/test/test_genmsg_command_line.py
216
1937
# Software License Agreement (BSD License) # # Copyright (c) 2011, Willow Garage, Inc. # 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 Willow Garage, Inc. 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 AND FITNESS # FOR A PARTICULAR PURPOSE 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. def test_includepath_to_dict(): from genmsg.command_line import includepath_to_dict assert {} == includepath_to_dict([]) assert {'std_msgs': [ 'foo' ]} == includepath_to_dict(['std_msgs:foo']) assert {'std_msgs': [ 'foo' ], 'bar_msgs': [ 'baz:colon' ]} == includepath_to_dict(['std_msgs:foo', 'bar_msgs:baz:colon'])
gpl-3.0
[ 3, 2290, 844, 28629, 334, 15400, 844, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 12, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 259, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 259, 543, 314, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 259, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 199, 318, 511, 63, 2613, 515, 63, 475, 63, 807, 837, 272, 687, 3805, 1328, 14, 1531, 63, 604, 492, 2387, 515, 63, 475, 63, 807, 272, 702, 1052, 508, 2387, 515, 63, 475, 63, 807, 4157, 272, 702, 791, 1516, 63, 13429, 356, 359, 283, 1421, 7, 1622, 93, 508, 2387, 515, 63, 475, 63, 807, 2941, 1516, 63, 13429, 26, 1421, 1105, 272, 702, 791, 1516, 63, 13429, 356, 359, 283, 1421, 7, 2156, 283, 1700, 63, 13429, 356, 359, 283, 6185, 26, 12167, 7, 1622, 93, 508, 2387, 515, 63, 475, 63, 807, 2941, 1516, 63, 13429, 26, 1421, 297, 283, 1700, 63, 13429, 26, 6185, 26, 12167, 1105, 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 ]
[ 2290, 844, 28629, 334, 15400, 844, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 7760, 12, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 259, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 259, 543, 314, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 259, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 199, 318, 511, 63, 2613, 515, 63, 475, 63, 807, 837, 272, 687, 3805, 1328, 14, 1531, 63, 604, 492, 2387, 515, 63, 475, 63, 807, 272, 702, 1052, 508, 2387, 515, 63, 475, 63, 807, 4157, 272, 702, 791, 1516, 63, 13429, 356, 359, 283, 1421, 7, 1622, 93, 508, 2387, 515, 63, 475, 63, 807, 2941, 1516, 63, 13429, 26, 1421, 1105, 272, 702, 791, 1516, 63, 13429, 356, 359, 283, 1421, 7, 2156, 283, 1700, 63, 13429, 356, 359, 283, 6185, 26, 12167, 7, 1622, 93, 508, 2387, 515, 63, 475, 63, 807, 2941, 1516, 63, 13429, 26, 1421, 297, 283, 1700, 63, 13429, 26, 6185, 26, 12167, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
crisely09/horton
horton/scripts/test/test_wpart.py
1
5071
# -*- coding: utf-8 -*- # HORTON: Helpful Open-source Research TOol for N-fermion systems. # Copyright (C) 2011-2016 The HORTON Development Team # # This file is part of HORTON. # # HORTON 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. # # HORTON is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/> # # -- import os, h5py as h5 from horton import * # pylint: disable=wildcard-import,unused-wildcard-import from horton.test.common import check_script, tmpdir from horton.part.test.common import get_proatomdb_hf_sto3g from horton.scripts.test.common import copy_files, check_files from horton.scripts.wpart import wpart_schemes def test_wpart_schemes(): assert 'b' in wpart_schemes assert 'h' in wpart_schemes assert 'hi' in wpart_schemes assert wpart_schemes['hi'] is HirshfeldIWPart assert wpart_schemes['hi'].options == ['lmax', 'threshold', 'maxiter'] assert not wpart_schemes['hi'].linear assert wpart_schemes['h'].linear assert wpart_schemes['b'].linear for WPartClass in wpart_schemes.itervalues(): assert hasattr(WPartClass, 'options') def write_atomdb_sto3g(dn, do_deriv=True): padb = get_proatomdb_hf_sto3g() if not do_deriv: # remove the derivatives of the pro-atoms (ugly hack to test backward compatibility). for record in padb._records: record._deriv = None padb.to_file(os.path.join(dn, 'atoms.h5')) def check_script_water_sto3g(scheme, do_deriv=True): with tmpdir('horton.scripts.test.test_wpart.test_script_water_sto3g_%s' % scheme) as dn: fn_fchk = 'water_sto3g_hf_g03.fchk' copy_files(dn, [fn_fchk]) if scheme == 'b': check_script('horton-wpart.py %s water_sto3g_hf_g03_wpart.h5:wpart %s --debug' % (fn_fchk, scheme), dn) else: write_atomdb_sto3g(dn, do_deriv) check_script('horton-wpart.py %s water_sto3g_hf_g03_wpart.h5:wpart %s atoms.h5 --slow' % (fn_fchk, scheme), dn) fn_h5 = 'water_sto3g_hf_g03_wpart.h5' check_files(dn, [fn_h5]) with h5.File(os.path.join(dn, fn_h5)) as f: assert 'wpart' in f assert abs(f['wpart/charges'][:].sum()) < 1e-2 assert 'wpart/spin_charges' not in f assert 'atom_00000' in f['wpart'] for s in 'density_decomposition', 'hartree_decomposition': assert s in f['wpart']['atom_00000'] assert 'spline_00000' in f['wpart']['atom_00000'][s] assert 'rtransform' in f['wpart']['atom_00000'][s]['spline_00000'].attrs assert 'extrapolation' in f['wpart']['atom_00000'][s]['spline_00000'].attrs assert 'y' in f['wpart']['atom_00000'][s]['spline_00000'] assert 'd' in f['wpart']['atom_00000'][s]['spline_00000'] if scheme != 'b': assert 'spline_prodensity' in f['wpart']['atom_00000'] assert 'spline_prohartree' in f['wpart']['atom_00000'] def test_script_water_sto3g_b(): check_script_water_sto3g('b') def test_script_water_sto3g_h(): check_script_water_sto3g('h') def test_script_water_sto3g_h_noderiv(): check_script_water_sto3g('h', do_deriv=False) def test_script_water_sto3g_hi(): check_script_water_sto3g('hi') def test_script_water_sto3g_hi_noderiv(): check_script_water_sto3g('hi', do_deriv=False) def check_script_ch3_rohf_sto3g(scheme, do_deriv=True): with tmpdir('horton.scripts.test.test_wpart.test_script_ch3_rohf_sto3g_%s' % scheme) as dn: fn_fchk = 'ch3_rohf_sto3g_g03.fchk' copy_files(dn, [fn_fchk]) if scheme == 'b': check_script('horton-wpart.py %s foo.h5:wpart %s --debug' % (fn_fchk, scheme), dn) else: write_atomdb_sto3g(dn, do_deriv) check_script('horton-wpart.py %s foo.h5:wpart %s atoms.h5' % (fn_fchk, scheme), dn) fn_h5 = 'foo.h5' check_files(dn, [fn_h5]) with h5.File(os.path.join(dn, fn_h5)) as f: assert 'wpart' in f assert abs(f['wpart/charges'][:].sum()) < 1e-2 assert abs(f['wpart/spin_charges'][:].sum() - 1) < 1e-2 def test_script_ch3_rohf_sto3g_b(): check_script_ch3_rohf_sto3g('b') def test_script_ch3_rohf_sto3g_h(): check_script_ch3_rohf_sto3g('h') def test_script_ch3_rohf_sto3g_h_noderiv(): check_script_ch3_rohf_sto3g('h', do_deriv=False) def test_script_ch3_rohf_sto3g_hi(): check_script_ch3_rohf_sto3g('hi') def test_script_ch3_rohf_sto3g_hi_noderiv(): check_script_ch3_rohf_sto3g('hi', do_deriv=False)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 9261, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 421, 199, 646, 747, 12, 394, 21, 647, 465, 394, 21, 199, 199, 504, 394, 361, 265, 492, 627, 221, 327, 4287, 26, 3507, 29, 16692, 13, 646, 12, 8618, 13, 16692, 13, 646, 199, 504, 394, 361, 265, 14, 396, 14, 2330, 492, 1104, 63, 1579, 12, 12885, 199, 504, 394, 361, 265, 14, 2064, 14, 396, 14, 2330, 492, 664, 63, 496, 4188, 697, 63, 9188, 63, 14308, 19, 71, 199, 504, 394, 361, 265, 14, 6429, 14, 396, 14, 2330, 492, 1331, 63, 1725, 12, 1104, 63, 1725, 199, 504, 394, 361, 265, 14, 6429, 14, 87, 2064, 492, 336, 2064, 63, 26818, 421, 199, 318, 511, 63, 87, 2064, 63, 26818, 837, 272, 702, 283, 66, 7, 315, 336, 2064, 63, 26818, 272, 702, 283, 72, 7, 315, 336, 2064, 63, 26818, 272, 702, 283, 5812, 7, 315, 336, 2064, 63, 26818, 272, 702, 336, 2064, 63, 26818, 459, 5812, 418, 365, 869, 723, 609, 70, 457, 22275, 8416, 272, 702, 336, 2064, 63, 26818, 459, 5812, 2278, 1419, 508, 788, 76, 988, 297, 283, 7227, 297, 283, 988, 1661, 418, 272, 702, 440, 336, 2064, 63, 26818, 459, 5812, 2278, 6676, 272, 702, 336, 2064, 63, 26818, 459, 72, 2278, 6676, 272, 702, 336, 2064, 63, 26818, 459, 66, 2278, 6676, 339, 367, 644, 8416, 2543, 315, 336, 2064, 63, 26818, 14, 13012, 837, 267, 702, 2688, 8, 55, 8416, 2543, 12, 283, 1419, 358, 421, 199, 318, 2218, 63, 4188, 697, 63, 14308, 19, 71, 8, 4272, 12, 886, 63, 17922, 29, 549, 304, 272, 6567, 66, 275, 664, 63, 496, 4188, 697, 63, 9188, 63, 14308, 19, 71, 342, 272, 340, 440, 886, 63, 17922, 26, 267, 327, 2813, 314, 28059, 402, 314, 557, 13, 11521, 334, 1518, 590, 11176, 370, 511, 13388, 7163, 680, 267, 367, 2777, 315, 6567, 66, 423, 6502, 26, 288, 2777, 423, 17922, 275, 488, 272, 6567, 66, 14, 475, 63, 493, 8, 736, 14, 515, 14, 904, 8, 4272, 12, 283, 11521, 14, 72, 21, 1333, 421, 199, 318, 1104, 63, 1579, 63, 17217, 63, 14308, 19, 71, 8, 5512, 12, 886, 63, 17922, 29, 549, 304, 272, 543, 12885, 360, 7222, 265, 14, 6429, 14, 396, 14, 396, 63, 87, 2064, 14, 396, 63, 1579, 63, 17217, 63, 14308, 19, 71, 4970, 83, 7, 450, 5687, 9, 465, 14052, 26, 267, 4325, 63, 70, 14823, 275, 283, 17217, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 14, 70, 14823, 7, 267, 1331, 63, 1725, 8, 4272, 12, 359, 2324, 63, 70, 14823, 566, 267, 340, 5687, 508, 283, 66, 356, 288, 1104, 63, 1579, 360, 7222, 265, 13, 87, 2064, 14, 647, 450, 83, 22834, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 26, 87, 2064, 450, 83, 1553, 1757, 7, 450, 334, 2324, 63, 70, 14823, 12, 5687, 395, 14052, 9, 267, 587, 26, 288, 2218, 63, 4188, 697, 63, 14308, 19, 71, 8, 4272, 12, 886, 63, 17922, 9, 288, 1104, 63, 1579, 360, 7222, 265, 13, 87, 2064, 14, 647, 450, 83, 22834, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 26, 87, 2064, 450, 83, 14503, 14, 72, 21, 1553, 14362, 7, 450, 334, 2324, 63, 70, 14823, 12, 5687, 395, 14052, 9, 267, 4325, 63, 72, 21, 275, 283, 17217, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 7, 267, 1104, 63, 1725, 8, 4272, 12, 359, 2324, 63, 72, 21, 566, 267, 543, 394, 21, 14, 1173, 8, 736, 14, 515, 14, 904, 8, 4272, 12, 4325, 63, 72, 21, 430, 465, 289, 26, 288, 702, 283, 87, 2064, 7, 315, 289, 288, 702, 2853, 8, 70, 459, 87, 2064, 15, 1560, 3389, 418, 1491, 1055, 1838, 1012, 665, 413, 69, 13, 18, 288, 702, 283, 87, 2064, 15, 14809, 63, 1560, 3389, 7, 440, 315, 289, 288, 702, 283, 4188, 63, 5345, 7, 315, 289, 459, 87, 2064, 418, 288, 367, 308, 315, 283, 15669, 63, 31384, 297, 283, 72, 580, 850, 63, 31384, 356, 355, 702, 308, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 418, 355, 702, 283, 27066, 63, 5345, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 61, 355, 702, 283, 82, 4711, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 2278, 3288, 355, 702, 283, 832, 1330, 10410, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 2278, 3288, 355, 702, 283, 89, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 418, 355, 702, 283, 68, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 418 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 9261, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 421, 199, 646, 747, 12, 394, 21, 647, 465, 394, 21, 199, 199, 504, 394, 361, 265, 492, 627, 221, 327, 4287, 26, 3507, 29, 16692, 13, 646, 12, 8618, 13, 16692, 13, 646, 199, 504, 394, 361, 265, 14, 396, 14, 2330, 492, 1104, 63, 1579, 12, 12885, 199, 504, 394, 361, 265, 14, 2064, 14, 396, 14, 2330, 492, 664, 63, 496, 4188, 697, 63, 9188, 63, 14308, 19, 71, 199, 504, 394, 361, 265, 14, 6429, 14, 396, 14, 2330, 492, 1331, 63, 1725, 12, 1104, 63, 1725, 199, 504, 394, 361, 265, 14, 6429, 14, 87, 2064, 492, 336, 2064, 63, 26818, 421, 199, 318, 511, 63, 87, 2064, 63, 26818, 837, 272, 702, 283, 66, 7, 315, 336, 2064, 63, 26818, 272, 702, 283, 72, 7, 315, 336, 2064, 63, 26818, 272, 702, 283, 5812, 7, 315, 336, 2064, 63, 26818, 272, 702, 336, 2064, 63, 26818, 459, 5812, 418, 365, 869, 723, 609, 70, 457, 22275, 8416, 272, 702, 336, 2064, 63, 26818, 459, 5812, 2278, 1419, 508, 788, 76, 988, 297, 283, 7227, 297, 283, 988, 1661, 418, 272, 702, 440, 336, 2064, 63, 26818, 459, 5812, 2278, 6676, 272, 702, 336, 2064, 63, 26818, 459, 72, 2278, 6676, 272, 702, 336, 2064, 63, 26818, 459, 66, 2278, 6676, 339, 367, 644, 8416, 2543, 315, 336, 2064, 63, 26818, 14, 13012, 837, 267, 702, 2688, 8, 55, 8416, 2543, 12, 283, 1419, 358, 421, 199, 318, 2218, 63, 4188, 697, 63, 14308, 19, 71, 8, 4272, 12, 886, 63, 17922, 29, 549, 304, 272, 6567, 66, 275, 664, 63, 496, 4188, 697, 63, 9188, 63, 14308, 19, 71, 342, 272, 340, 440, 886, 63, 17922, 26, 267, 327, 2813, 314, 28059, 402, 314, 557, 13, 11521, 334, 1518, 590, 11176, 370, 511, 13388, 7163, 680, 267, 367, 2777, 315, 6567, 66, 423, 6502, 26, 288, 2777, 423, 17922, 275, 488, 272, 6567, 66, 14, 475, 63, 493, 8, 736, 14, 515, 14, 904, 8, 4272, 12, 283, 11521, 14, 72, 21, 1333, 421, 199, 318, 1104, 63, 1579, 63, 17217, 63, 14308, 19, 71, 8, 5512, 12, 886, 63, 17922, 29, 549, 304, 272, 543, 12885, 360, 7222, 265, 14, 6429, 14, 396, 14, 396, 63, 87, 2064, 14, 396, 63, 1579, 63, 17217, 63, 14308, 19, 71, 4970, 83, 7, 450, 5687, 9, 465, 14052, 26, 267, 4325, 63, 70, 14823, 275, 283, 17217, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 14, 70, 14823, 7, 267, 1331, 63, 1725, 8, 4272, 12, 359, 2324, 63, 70, 14823, 566, 267, 340, 5687, 508, 283, 66, 356, 288, 1104, 63, 1579, 360, 7222, 265, 13, 87, 2064, 14, 647, 450, 83, 22834, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 26, 87, 2064, 450, 83, 1553, 1757, 7, 450, 334, 2324, 63, 70, 14823, 12, 5687, 395, 14052, 9, 267, 587, 26, 288, 2218, 63, 4188, 697, 63, 14308, 19, 71, 8, 4272, 12, 886, 63, 17922, 9, 288, 1104, 63, 1579, 360, 7222, 265, 13, 87, 2064, 14, 647, 450, 83, 22834, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 26, 87, 2064, 450, 83, 14503, 14, 72, 21, 1553, 14362, 7, 450, 334, 2324, 63, 70, 14823, 12, 5687, 395, 14052, 9, 267, 4325, 63, 72, 21, 275, 283, 17217, 63, 14308, 19, 71, 63, 9188, 63, 71, 1644, 63, 87, 2064, 14, 72, 21, 7, 267, 1104, 63, 1725, 8, 4272, 12, 359, 2324, 63, 72, 21, 566, 267, 543, 394, 21, 14, 1173, 8, 736, 14, 515, 14, 904, 8, 4272, 12, 4325, 63, 72, 21, 430, 465, 289, 26, 288, 702, 283, 87, 2064, 7, 315, 289, 288, 702, 2853, 8, 70, 459, 87, 2064, 15, 1560, 3389, 418, 1491, 1055, 1838, 1012, 665, 413, 69, 13, 18, 288, 702, 283, 87, 2064, 15, 14809, 63, 1560, 3389, 7, 440, 315, 289, 288, 702, 283, 4188, 63, 5345, 7, 315, 289, 459, 87, 2064, 418, 288, 367, 308, 315, 283, 15669, 63, 31384, 297, 283, 72, 580, 850, 63, 31384, 356, 355, 702, 308, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 418, 355, 702, 283, 27066, 63, 5345, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 61, 355, 702, 283, 82, 4711, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 2278, 3288, 355, 702, 283, 832, 1330, 10410, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 2278, 3288, 355, 702, 283, 89, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 418, 355, 702, 283, 68, 7, 315, 289, 459, 87, 2064, 2545, 4188, 63, 5345, 3488, 83, 2733, 27066, 63, 5345, 418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
samskeller/zeroclickinfo-fathead
lib/fathead/UNCLEAN/parse_cplusplus.py
1
1380
from BeautifulSoup import BeautifulSoup import re import os import sys import MySQLdb conn = MySQLdb.connect(user='root') openclosetags = re.compile('''<.*?>|</.*?>''',re.DOTALL) files = [] for file in os.listdir('./docs/cplusplus/'): files.append('./docs/cplusplus/%s'%(file)) #http://www.cplusplus.com/reference/ for file in files: filecontents = open(file).read() soup = BeautifulSoup(filecontents) for node in soup.findAll("div",{"class":re.compile(r'\btype-post\b')}): name = openclosetags.sub('',str(node.findAll("div","post-title")[0])) desc = openclosetags.sub('',str(node.findAll("div","p-con")[0].findAll('p')[0])) s = node.findAll("div","wp_syntax")[0].findAll('pre') synopsis = '' if len(s) == 1: synopsis = openclosetags.sub('',str(s[0])) else: synopsis = openclosetags.sub('',str(s[1])) url = node.findAll('a')[0]['href'] if len(sys.argv) == 1 or sys.argv[1].lower() == 'tsv': print "%s\t%s\t%s\t%s\t%s"%(name,url,desc,synopsis,desc) if sys.argv[1].lower() == 'sql': print '''INSERT INTO functions (`id`, `name`, `namespace`, `url`, `description`, `synopsis`, `detail`, `type`, `lang`) VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');'''%(name,'',url,conn.escape_string(desc),conn.escape_string(synopsis),'','stuntsnippets','')
apache-2.0
[ 504, 17132, 492, 17132, 202, 199, 646, 295, 202, 199, 646, 747, 202, 199, 646, 984, 202, 199, 646, 25709, 8065, 199, 1631, 275, 25709, 14, 2242, 8, 751, 534, 1231, 358, 2999, 199, 1490, 1251, 409, 7391, 275, 295, 14, 2014, 10505, 28, 6697, 21521, 1108, 6697, 30, 18108, 264, 14, 16504, 9, 2999, 199, 1725, 275, 942, 2999, 199, 509, 570, 315, 747, 14, 7374, 17371, 4757, 15, 67, 6666, 6666, 26985, 10292, 1584, 14, 740, 17371, 4757, 15, 67, 6666, 6666, 3149, 83, 13328, 493, 430, 2999, 199, 3, 1014, 921, 1544, 14, 67, 6666, 6666, 14, 957, 15, 4443, 15, 202, 199, 509, 570, 315, 1584, 26, 10292, 570, 4407, 275, 1551, 8, 493, 680, 739, 342, 15497, 10292, 9108, 275, 17132, 8, 493, 4407, 9, 15497, 10292, 367, 1031, 315, 9108, 14, 32651, 480, 3015, 401, 6641, 533, 582, 264, 14, 2014, 8, 82, 1154, 66, 466, 13, 1932, 60, 66, 21004, 304, 1128, 536, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 932, 14, 32651, 480, 3015, 2266, 1932, 13, 1213, 9981, 16, 2459, 1128, 4328, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 932, 14, 32651, 480, 3015, 2266, 80, 13, 388, 9981, 16, 1055, 32651, 360, 80, 5832, 16, 2459, 1128, 308, 275, 1031, 14, 32651, 480, 3015, 2266, 14649, 63, 7093, 9981, 16, 1055, 32651, 360, 657, 358, 1128, 9560, 27573, 275, 2125, 1128, 340, 822, 8, 83, 9, 508, 413, 26, 1039, 9560, 27573, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 83, 59, 16, 2459, 1128, 587, 26, 1039, 9560, 27573, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 83, 59, 17, 2459, 1128, 1166, 275, 1031, 14, 32651, 360, 65, 5832, 16, 2733, 6399, 418, 18801, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 1055, 2325, 342, 508, 283, 29362, 356, 8608, 870, 2071, 83, 60, 84, 5, 83, 60, 84, 5, 83, 60, 84, 5, 83, 60, 84, 5, 83, 14007, 354, 12, 633, 12, 3257, 12, 9466, 27573, 12, 3257, 9, 1128, 340, 984, 14, 3020, 59, 17, 1055, 2325, 342, 508, 283, 3009, 356, 8608, 870, 1449, 10258, 12872, 3423, 13493, 344, 3559, 658, 354, 3559, 658, 3251, 3559, 658, 633, 3559, 658, 1802, 3559, 658, 9466, 27573, 3559, 658, 5506, 3559, 658, 466, 3559, 658, 4159, 10522, 13992, 334, 8084, 12, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 11339, 2344, 2840, 354, 2584, 297, 633, 12, 1631, 14, 3765, 63, 875, 8, 3257, 395, 1631, 14, 3765, 63, 875, 8, 9466, 27573, 26582, 1673, 270, 638, 32566, 20944, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17132, 492, 17132, 202, 199, 646, 295, 202, 199, 646, 747, 202, 199, 646, 984, 202, 199, 646, 25709, 8065, 199, 1631, 275, 25709, 14, 2242, 8, 751, 534, 1231, 358, 2999, 199, 1490, 1251, 409, 7391, 275, 295, 14, 2014, 10505, 28, 6697, 21521, 1108, 6697, 30, 18108, 264, 14, 16504, 9, 2999, 199, 1725, 275, 942, 2999, 199, 509, 570, 315, 747, 14, 7374, 17371, 4757, 15, 67, 6666, 6666, 26985, 10292, 1584, 14, 740, 17371, 4757, 15, 67, 6666, 6666, 3149, 83, 13328, 493, 430, 2999, 199, 3, 1014, 921, 1544, 14, 67, 6666, 6666, 14, 957, 15, 4443, 15, 202, 199, 509, 570, 315, 1584, 26, 10292, 570, 4407, 275, 1551, 8, 493, 680, 739, 342, 15497, 10292, 9108, 275, 17132, 8, 493, 4407, 9, 15497, 10292, 367, 1031, 315, 9108, 14, 32651, 480, 3015, 401, 6641, 533, 582, 264, 14, 2014, 8, 82, 1154, 66, 466, 13, 1932, 60, 66, 21004, 304, 1128, 536, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 932, 14, 32651, 480, 3015, 2266, 1932, 13, 1213, 9981, 16, 2459, 1128, 4328, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 932, 14, 32651, 480, 3015, 2266, 80, 13, 388, 9981, 16, 1055, 32651, 360, 80, 5832, 16, 2459, 1128, 308, 275, 1031, 14, 32651, 480, 3015, 2266, 14649, 63, 7093, 9981, 16, 1055, 32651, 360, 657, 358, 1128, 9560, 27573, 275, 2125, 1128, 340, 822, 8, 83, 9, 508, 413, 26, 1039, 9560, 27573, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 83, 59, 16, 2459, 1128, 587, 26, 1039, 9560, 27573, 275, 1551, 1251, 409, 7391, 14, 954, 8594, 495, 8, 83, 59, 17, 2459, 1128, 1166, 275, 1031, 14, 32651, 360, 65, 5832, 16, 2733, 6399, 418, 18801, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 1055, 2325, 342, 508, 283, 29362, 356, 8608, 870, 2071, 83, 60, 84, 5, 83, 60, 84, 5, 83, 60, 84, 5, 83, 60, 84, 5, 83, 14007, 354, 12, 633, 12, 3257, 12, 9466, 27573, 12, 3257, 9, 1128, 340, 984, 14, 3020, 59, 17, 1055, 2325, 342, 508, 283, 3009, 356, 8608, 870, 1449, 10258, 12872, 3423, 13493, 344, 3559, 658, 354, 3559, 658, 3251, 3559, 658, 633, 3559, 658, 1802, 3559, 658, 9466, 27573, 3559, 658, 5506, 3559, 658, 466, 3559, 658, 4159, 10522, 13992, 334, 8084, 12, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 297, 1543, 83, 11339, 2344, 2840, 354, 2584, 297, 633, 12, 1631, 14, 3765, 63, 875, 8, 3257, 395, 1631, 14, 3765, 63, 875, 8, 9466, 27573, 26582, 1673, 270, 638, 32566, 20944, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
ldts/zephyr
scripts/west_commands/runners/hifive1.py
2
1307
# Copyright (c) 2019, Timon Baetz # # SPDX-License-Identifier: Apache-2.0 '''HiFive1-specific (flash only) runner.''' from os import path from runners.core import ZephyrBinaryRunner, RunnerCaps class HiFive1BinaryRunner(ZephyrBinaryRunner): '''Runner front-end for the HiFive1 board, using openocd.''' def __init__(self, cfg): super(HiFive1BinaryRunner, self).__init__(cfg) self.openocd_config = path.join(cfg.board_dir, 'support', 'openocd.cfg') @classmethod def name(cls): return 'hifive1' @classmethod def capabilities(cls): return RunnerCaps(commands={'flash'}) @classmethod def do_add_parser(cls, parser): pass @classmethod def create(cls, cfg, args): if cfg.gdb is None: raise ValueError('--gdb not provided at command line') return HiFive1BinaryRunner(cfg) def do_run(self, command, **kwargs): openocd_cmd = ([self.cfg.openocd, '-f', self.openocd_config]) gdb_cmd = ([self.cfg.gdb, self.cfg.elf_file, '--batch', '-ex', 'set remotetimeout 240', '-ex', 'target extended-remote localhost:3333', '-ex', 'load', '-ex', 'quit']) self.run_server_and_client(openocd_cmd, gdb_cmd)
apache-2.0
[ 3, 1898, 334, 67, 9, 20312, 12, 26244, 265, 699, 65, 386, 90, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 199, 199, 2344, 16106, 38, 1912, 17, 13, 6100, 334, 11331, 1454, 9, 7876, 10595, 199, 199, 504, 747, 492, 931, 199, 199, 504, 1255, 8715, 14, 1018, 492, 3107, 69, 32248, 6636, 7446, 12, 3378, 1372, 35, 7461, 421, 199, 533, 869, 73, 38, 1912, 17, 6636, 7446, 8, 58, 69, 32248, 6636, 7446, 304, 272, 1449, 7446, 13738, 13, 500, 367, 314, 869, 73, 38, 1912, 17, 13811, 12, 1808, 1551, 679, 68, 10595, 339, 347, 636, 826, 721, 277, 12, 4810, 304, 267, 1613, 8, 16106, 38, 1912, 17, 6636, 7446, 12, 291, 2843, 826, 721, 4128, 9, 267, 291, 14, 1490, 679, 68, 63, 888, 275, 931, 14, 904, 8, 4128, 14, 3576, 63, 694, 12, 283, 4058, 297, 283, 1490, 679, 68, 14, 4128, 358, 339, 768, 3744, 272, 347, 536, 8, 1886, 304, 267, 372, 283, 72, 1903, 432, 17, 7, 339, 768, 3744, 272, 347, 14918, 8, 1886, 304, 267, 372, 3378, 1372, 35, 7461, 8, 4405, 3713, 11331, 3071, 339, 768, 3744, 272, 347, 886, 63, 525, 63, 2087, 8, 1886, 12, 1798, 304, 267, 986, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 4810, 12, 1249, 304, 267, 340, 4810, 14, 17119, 365, 488, 26, 288, 746, 1722, 4517, 17119, 440, 2741, 737, 1414, 1004, 358, 398, 372, 869, 73, 38, 1912, 17, 6636, 7446, 8, 4128, 9, 339, 347, 886, 63, 1065, 8, 277, 12, 1414, 12, 1011, 958, 304, 267, 1551, 679, 68, 63, 1760, 275, 7287, 277, 14, 4128, 14, 1490, 679, 68, 12, 2475, 70, 297, 291, 14, 1490, 679, 68, 63, 888, 566, 267, 12124, 63, 1760, 275, 7287, 277, 14, 4128, 14, 17119, 12, 291, 14, 4128, 14, 25371, 63, 493, 12, 2850, 2912, 297, 490, 2475, 476, 297, 283, 409, 3982, 2593, 21883, 297, 490, 2475, 476, 297, 283, 1375, 9243, 13, 3846, 11667, 26, 6772, 297, 490, 2475, 476, 297, 283, 912, 297, 490, 2475, 476, 297, 283, 10589, 1105, 267, 291, 14, 1065, 63, 1000, 63, 460, 63, 1258, 8, 1490, 679, 68, 63, 1760, 12, 12124, 63, 1760, 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 ]
[ 1898, 334, 67, 9, 20312, 12, 26244, 265, 699, 65, 386, 90, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 3668, 13, 18, 14, 16, 199, 199, 2344, 16106, 38, 1912, 17, 13, 6100, 334, 11331, 1454, 9, 7876, 10595, 199, 199, 504, 747, 492, 931, 199, 199, 504, 1255, 8715, 14, 1018, 492, 3107, 69, 32248, 6636, 7446, 12, 3378, 1372, 35, 7461, 421, 199, 533, 869, 73, 38, 1912, 17, 6636, 7446, 8, 58, 69, 32248, 6636, 7446, 304, 272, 1449, 7446, 13738, 13, 500, 367, 314, 869, 73, 38, 1912, 17, 13811, 12, 1808, 1551, 679, 68, 10595, 339, 347, 636, 826, 721, 277, 12, 4810, 304, 267, 1613, 8, 16106, 38, 1912, 17, 6636, 7446, 12, 291, 2843, 826, 721, 4128, 9, 267, 291, 14, 1490, 679, 68, 63, 888, 275, 931, 14, 904, 8, 4128, 14, 3576, 63, 694, 12, 283, 4058, 297, 283, 1490, 679, 68, 14, 4128, 358, 339, 768, 3744, 272, 347, 536, 8, 1886, 304, 267, 372, 283, 72, 1903, 432, 17, 7, 339, 768, 3744, 272, 347, 14918, 8, 1886, 304, 267, 372, 3378, 1372, 35, 7461, 8, 4405, 3713, 11331, 3071, 339, 768, 3744, 272, 347, 886, 63, 525, 63, 2087, 8, 1886, 12, 1798, 304, 267, 986, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 4810, 12, 1249, 304, 267, 340, 4810, 14, 17119, 365, 488, 26, 288, 746, 1722, 4517, 17119, 440, 2741, 737, 1414, 1004, 358, 398, 372, 869, 73, 38, 1912, 17, 6636, 7446, 8, 4128, 9, 339, 347, 886, 63, 1065, 8, 277, 12, 1414, 12, 1011, 958, 304, 267, 1551, 679, 68, 63, 1760, 275, 7287, 277, 14, 4128, 14, 1490, 679, 68, 12, 2475, 70, 297, 291, 14, 1490, 679, 68, 63, 888, 566, 267, 12124, 63, 1760, 275, 7287, 277, 14, 4128, 14, 17119, 12, 291, 14, 4128, 14, 25371, 63, 493, 12, 2850, 2912, 297, 490, 2475, 476, 297, 283, 409, 3982, 2593, 21883, 297, 490, 2475, 476, 297, 283, 1375, 9243, 13, 3846, 11667, 26, 6772, 297, 490, 2475, 476, 297, 283, 912, 297, 490, 2475, 476, 297, 283, 10589, 1105, 267, 291, 14, 1065, 63, 1000, 63, 460, 63, 1258, 8, 1490, 679, 68, 63, 1760, 12, 12124, 63, 1760, 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, 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,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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 ]
Anonymous-X6/django
tests/admin_registration/tests.py
266
4640
from __future__ import unicode_literals from django.contrib import admin from django.contrib.admin.decorators import register from django.contrib.admin.sites import site from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from .models import Location, Person, Place, Traveler class NameAdmin(admin.ModelAdmin): list_display = ['name'] save_on_top = True class CustomSite(admin.AdminSite): pass class TestRegistration(SimpleTestCase): def setUp(self): self.site = admin.AdminSite() def test_bare_registration(self): self.site.register(Person) self.assertTrue( isinstance(self.site._registry[Person], admin.options.ModelAdmin) ) def test_registration_with_model_admin(self): self.site.register(Person, NameAdmin) self.assertTrue( isinstance(self.site._registry[Person], NameAdmin) ) def test_prevent_double_registration(self): self.site.register(Person) self.assertRaises(admin.sites.AlreadyRegistered, self.site.register, Person) def test_registration_with_star_star_options(self): self.site.register(Person, search_fields=['name']) self.assertEqual(self.site._registry[Person].search_fields, ['name']) def test_star_star_overrides(self): self.site.register(Person, NameAdmin, search_fields=["name"], list_display=['__str__']) self.assertEqual(self.site._registry[Person].search_fields, ['name']) self.assertEqual(self.site._registry[Person].list_display, ['__str__']) self.assertTrue(self.site._registry[Person].save_on_top) def test_iterable_registration(self): self.site.register([Person, Place], search_fields=['name']) self.assertTrue( isinstance(self.site._registry[Person], admin.options.ModelAdmin) ) self.assertEqual(self.site._registry[Person].search_fields, ['name']) self.assertTrue( isinstance(self.site._registry[Place], admin.options.ModelAdmin) ) self.assertEqual(self.site._registry[Place].search_fields, ['name']) def test_abstract_model(self): """ Exception is raised when trying to register an abstract model. Refs #12004. """ self.assertRaises(ImproperlyConfigured, self.site.register, Location) def test_is_registered_model(self): "Checks for registered models should return true." self.site.register(Person) self.assertTrue(self.site.is_registered(Person)) def test_is_registered_not_registered_model(self): "Checks for unregistered models should return false." self.assertFalse(self.site.is_registered(Person)) class TestRegistrationDecorator(SimpleTestCase): """ Tests the register decorator in admin.decorators For clarity: @register(Person) class AuthorAdmin(ModelAdmin): pass is functionally equal to (the way it is written in these tests): AuthorAdmin = register(Person)(AuthorAdmin) """ def setUp(self): self.default_site = site self.custom_site = CustomSite() def test_basic_registration(self): register(Person)(NameAdmin) self.assertTrue( isinstance(self.default_site._registry[Person], admin.options.ModelAdmin) ) self.default_site.unregister(Person) def test_custom_site_registration(self): register(Person, site=self.custom_site)(NameAdmin) self.assertTrue( isinstance(self.custom_site._registry[Person], admin.options.ModelAdmin) ) def test_multiple_registration(self): register(Traveler, Place)(NameAdmin) self.assertTrue( isinstance(self.default_site._registry[Traveler], admin.options.ModelAdmin) ) self.default_site.unregister(Traveler) self.assertTrue( isinstance(self.default_site._registry[Place], admin.options.ModelAdmin) ) self.default_site.unregister(Place) def test_wrapped_class_not_a_model_admin(self): self.assertRaisesMessage(ValueError, 'Wrapped class must subclass ModelAdmin.', register(Person), CustomSite) def test_custom_site_not_an_admin_site(self): self.assertRaisesMessage(ValueError, 'site must subclass AdminSite', register(Person, site=Traveler), NameAdmin)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 11582, 492, 2274, 199, 504, 1639, 14, 2828, 14, 2113, 14, 8619, 492, 4770, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 24424, 199, 199, 504, 1275, 992, 492, 12625, 12, 8028, 12, 10902, 12, 12643, 432, 1435, 421, 199, 533, 2812, 4880, 8, 2113, 14, 12976, 304, 272, 769, 63, 2918, 275, 788, 354, 418, 272, 3354, 63, 265, 63, 2119, 275, 715, 421, 199, 533, 8388, 8972, 8, 2113, 14, 4880, 8972, 304, 272, 986, 421, 199, 533, 1379, 11757, 8, 17968, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 2124, 275, 4628, 14, 4880, 8972, 342, 339, 347, 511, 63, 14890, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 339, 347, 511, 63, 8054, 63, 1045, 63, 1238, 63, 2113, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2812, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 2812, 4880, 9, 267, 776, 339, 347, 511, 63, 657, 782, 63, 3157, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1855, 8, 2113, 14, 8619, 14, 16760, 20341, 12, 2079, 291, 14, 2124, 14, 2683, 12, 2079, 8028, 9, 339, 347, 511, 63, 8054, 63, 1045, 63, 7848, 63, 7848, 63, 1419, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2754, 63, 955, 2968, 354, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 339, 347, 511, 63, 7848, 63, 7848, 63, 12867, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2812, 4880, 12, 2574, 2754, 63, 955, 6270, 354, 2255, 769, 63, 2918, 2968, 363, 495, 363, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 513, 63, 2918, 12, 586, 14050, 495, 363, 1105, 267, 291, 14, 1815, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 2117, 63, 265, 63, 2119, 9, 339, 347, 511, 63, 8147, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 779, 7344, 12, 10902, 467, 2754, 63, 955, 2968, 354, 1105, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 11613, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 11613, 1055, 1733, 63, 955, 12, 788, 354, 1105, 339, 347, 511, 63, 6198, 63, 1238, 8, 277, 304, 267, 408, 267, 2186, 365, 4915, 1380, 9936, 370, 2274, 376, 9006, 1402, 14, 267, 22165, 327, 713, 7979, 14, 267, 408, 267, 291, 14, 1855, 8, 8499, 10951, 12, 291, 14, 2124, 14, 2683, 12, 12625, 9, 339, 347, 511, 63, 374, 63, 11616, 63, 1238, 8, 277, 304, 267, 298, 11834, 367, 7264, 1709, 1077, 372, 2549, 2122, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1815, 8, 277, 14, 2124, 14, 374, 63, 11616, 8, 7344, 430, 339, 347, 511, 63, 374, 63, 11616, 63, 1397, 63, 11616, 63, 1238, 8, 277, 304, 267, 298, 11834, 367, 625, 11616, 1709, 1077, 372, 3055, 2122, 267, 291, 14, 3334, 8, 277, 14, 2124, 14, 374, 63, 11616, 8, 7344, 430, 421, 199, 533, 1379, 11757, 14946, 8, 17968, 304, 272, 408, 272, 6496, 314, 2274, 7531, 315, 4628, 14, 11582, 339, 2104, 824, 7945, 26, 398, 768, 2683, 8, 7344, 9, 267, 1021, 6529, 4880, 8, 12976, 304, 288, 986, 339, 365, 805, 1183, 4472, 370, 334, 1589, 4340, 652, 365, 5313, 315, 3520, 2295, 304, 398, 6529, 4880, 275, 2274, 8, 7344, 5130, 5949, 4880, 9, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 885, 63, 2124, 275, 4770, 267, 291, 14, 4229, 63, 2124, 275, 8388, 8972, 342, 339, 347, 511, 63, 4316, 63, 8054, 8, 277, 304, 267, 2274, 8, 7344, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 7344, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 7344, 9, 339, 347, 511, 63, 4229, 63, 2124, 63, 8054, 8, 277, 304, 267, 2274, 8, 7344, 12, 4770, 29, 277, 14, 4229, 63, 2124, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 4229, 63, 2124, 423, 5189, 59, 7344, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 339, 347, 511, 63, 6048, 63, 8054, 8, 277, 304, 267, 2274, 8, 2437, 432, 1435, 12, 10902, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 2437, 432, 1435, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 2437, 432, 1435, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 11613, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 11613, 9, 339, 347, 511, 63, 9130, 63, 533, 63, 1397, 63, 65, 63, 1238, 63, 2113, 8, 277, 304, 267, 291, 14, 14638, 8, 3393, 12, 283, 15991, 1915, 1021, 1471, 5516, 30093, 3130, 288, 2274, 8, 7344, 395, 8388, 8972, 9, 339, 347, 511, 63, 4229, 63, 2124, 63, 1397 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 11582, 492, 2274, 199, 504, 1639, 14, 2828, 14, 2113, 14, 8619, 492, 4770, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 24424, 199, 199, 504, 1275, 992, 492, 12625, 12, 8028, 12, 10902, 12, 12643, 432, 1435, 421, 199, 533, 2812, 4880, 8, 2113, 14, 12976, 304, 272, 769, 63, 2918, 275, 788, 354, 418, 272, 3354, 63, 265, 63, 2119, 275, 715, 421, 199, 533, 8388, 8972, 8, 2113, 14, 4880, 8972, 304, 272, 986, 421, 199, 533, 1379, 11757, 8, 17968, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 2124, 275, 4628, 14, 4880, 8972, 342, 339, 347, 511, 63, 14890, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 339, 347, 511, 63, 8054, 63, 1045, 63, 1238, 63, 2113, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2812, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 2812, 4880, 9, 267, 776, 339, 347, 511, 63, 657, 782, 63, 3157, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1855, 8, 2113, 14, 8619, 14, 16760, 20341, 12, 2079, 291, 14, 2124, 14, 2683, 12, 2079, 8028, 9, 339, 347, 511, 63, 8054, 63, 1045, 63, 7848, 63, 7848, 63, 1419, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2754, 63, 955, 2968, 354, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 339, 347, 511, 63, 7848, 63, 7848, 63, 12867, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 8, 7344, 12, 2812, 4880, 12, 2574, 2754, 63, 955, 6270, 354, 2255, 769, 63, 2918, 2968, 363, 495, 363, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 513, 63, 2918, 12, 586, 14050, 495, 363, 1105, 267, 291, 14, 1815, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 2117, 63, 265, 63, 2119, 9, 339, 347, 511, 63, 8147, 63, 8054, 8, 277, 304, 267, 291, 14, 2124, 14, 2683, 779, 7344, 12, 10902, 467, 2754, 63, 955, 2968, 354, 1105, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 7344, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 7344, 1055, 1733, 63, 955, 12, 788, 354, 1105, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 2124, 423, 5189, 59, 11613, 467, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 629, 8, 277, 14, 2124, 423, 5189, 59, 11613, 1055, 1733, 63, 955, 12, 788, 354, 1105, 339, 347, 511, 63, 6198, 63, 1238, 8, 277, 304, 267, 408, 267, 2186, 365, 4915, 1380, 9936, 370, 2274, 376, 9006, 1402, 14, 267, 22165, 327, 713, 7979, 14, 267, 408, 267, 291, 14, 1855, 8, 8499, 10951, 12, 291, 14, 2124, 14, 2683, 12, 12625, 9, 339, 347, 511, 63, 374, 63, 11616, 63, 1238, 8, 277, 304, 267, 298, 11834, 367, 7264, 1709, 1077, 372, 2549, 2122, 267, 291, 14, 2124, 14, 2683, 8, 7344, 9, 267, 291, 14, 1815, 8, 277, 14, 2124, 14, 374, 63, 11616, 8, 7344, 430, 339, 347, 511, 63, 374, 63, 11616, 63, 1397, 63, 11616, 63, 1238, 8, 277, 304, 267, 298, 11834, 367, 625, 11616, 1709, 1077, 372, 3055, 2122, 267, 291, 14, 3334, 8, 277, 14, 2124, 14, 374, 63, 11616, 8, 7344, 430, 421, 199, 533, 1379, 11757, 14946, 8, 17968, 304, 272, 408, 272, 6496, 314, 2274, 7531, 315, 4628, 14, 11582, 339, 2104, 824, 7945, 26, 398, 768, 2683, 8, 7344, 9, 267, 1021, 6529, 4880, 8, 12976, 304, 288, 986, 339, 365, 805, 1183, 4472, 370, 334, 1589, 4340, 652, 365, 5313, 315, 3520, 2295, 304, 398, 6529, 4880, 275, 2274, 8, 7344, 5130, 5949, 4880, 9, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 885, 63, 2124, 275, 4770, 267, 291, 14, 4229, 63, 2124, 275, 8388, 8972, 342, 339, 347, 511, 63, 4316, 63, 8054, 8, 277, 304, 267, 2274, 8, 7344, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 7344, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 7344, 9, 339, 347, 511, 63, 4229, 63, 2124, 63, 8054, 8, 277, 304, 267, 2274, 8, 7344, 12, 4770, 29, 277, 14, 4229, 63, 2124, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 4229, 63, 2124, 423, 5189, 59, 7344, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 339, 347, 511, 63, 6048, 63, 8054, 8, 277, 304, 267, 2274, 8, 2437, 432, 1435, 12, 10902, 5130, 985, 4880, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 2437, 432, 1435, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 2437, 432, 1435, 9, 267, 291, 14, 1815, 8, 288, 1228, 8, 277, 14, 885, 63, 2124, 423, 5189, 59, 11613, 467, 2432, 4628, 14, 1419, 14, 12976, 9, 267, 776, 267, 291, 14, 885, 63, 2124, 14, 18408, 8, 11613, 9, 339, 347, 511, 63, 9130, 63, 533, 63, 1397, 63, 65, 63, 1238, 63, 2113, 8, 277, 304, 267, 291, 14, 14638, 8, 3393, 12, 283, 15991, 1915, 1021, 1471, 5516, 30093, 3130, 288, 2274, 8, 7344, 395, 8388, 8972, 9, 339, 347, 511, 63, 4229, 63, 2124, 63, 1397, 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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gustavo Niemeyer <niemeyer@conectiva.com> # # This file is part of Smart Package Manager. # # Smart Package Manager 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. # # Smart Package Manager 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 Smart Package Manager; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # from smart.util.strtools import sizeToStr, speedToStr from smart.media import MediaSet, DeviceMedia from smart.uncompress import Uncompressor from smart.mirror import MirrorSystem from smart.const import * from smart import * import tempfile import socket import urllib import string import thread import time import os import re MAXRETRIES = 30 SPEEDDELAY = 1 CANCELDELAY = 2 MAXACTIVEDOWNLOADS = 10 SOCKETTIMEOUT = 120 class FetcherCancelled(Error): pass class Fetcher(object): _registry = {} _localschemes = [] def __init__(self): self._uncompressor = Uncompressor() self._mediaset = MediaSet() self._uncompressing = 0 self._localdir = tempfile.gettempdir() self._mirrorsystem = MirrorSystem() self._mangle = False self._caching = OPTIONAL self._items = {} self._handlers = {} self._forcecopy = False self._forcemountedcopy = False self._localpathprefix = None self._cancel = False self._speedupdated = 0 self._activedownloads = 0 self._activedownloadslock = thread.allocate_lock() self._maxactivedownloads = 0 self.time = 0 def reset(self): self._items.clear() self._uncompressing = 0 def cancel(self): self._cancel = True def getItem(self, url): return self._items.get(url) def getItems(self): return self._items.values() def getSucceededSet(self): set = {} for item in self._items.values(): if item.getStatus() == SUCCEEDED: set[item.getOriginalURL()] = item.getTargetPath() return set def getFailedSet(self): set = {} for item in self._items.values(): if item.getStatus() == FAILED: set[item.getOriginalURL()] = item.getFailedReason() return set def getUncompressor(self): return self._uncompressor def getMediaSet(self): return self._mediaset def getMirrorSystem(self): return self._mirrorsystem def getCaching(self): return self._caching def setCaching(self, value): self._caching = value def setLocalDir(self, localdir, mangle=False): self._localdir = localdir self._mangle = mangle def getLocalDir(self): return self._localdir def setLocalPathPrefix(self, prefix): self._localpathprefix = prefix def getLocalPathPrefix(self): return self._localpathprefix def getLocalPath(self, item): assert isinstance(item, FetchItem) url = item.getOriginalURL() if self._mangle: filename = url.replace("/", "_") else: scheme, selector = urllib.splittype(url) host, path = urllib.splithost(selector) path, query = urllib.splitquery(path) path = urllib.unquote(path) filename = os.path.basename(path) if self._localpathprefix: filename = self._localpathprefix+filename return os.path.join(self._localdir, filename) def setForceCopy(self, value): self._forcecopy = value def getForceCopy(self): return self._forcecopy def setForceMountedCopy(self, value): self._forcemountedcopy = value def getForceMountedCopy(self): return self._forcemountedcopy def changeActiveDownloads(self, value): result = False self._activedownloadslock.acquire() if self._activedownloads+value <= self._maxactivedownloads: self._activedownloads += value result = True self._activedownloadslock.release() return result def getActiveDownloads(self): return self._activedownloads def enqueue(self, url, **info): if url in self._items: raise Error, _("%s is already in the queue") % url mirror = self._mirrorsystem.get(url) item = FetchItem(self, url, mirror) self._items[url] = item if info: item.setInfo(**info) handler = self.getHandlerInstance(item) handler.enqueue(item) return item def runLocal(self): for handler in self._handlers.values(): handler.runLocal() def run(self, what=None, progress=None): #socket.setdefaulttimeout(sysconf.get("socket-timeout", SOCKETTIMEOUT)) self._cancel = False self._activedownloads = 0 self._maxactivedownloads = sysconf.get("max-active-downloads", MAXACTIVEDOWNLOADS) self.time = time.time() handlers = self._handlers.values() total = len(self._items) self.runLocal() local = len([x for x in self._items.values() if x.getStatus() == SUCCEEDED]) if local == total or self._caching is ALWAYS: if progress: progress.add(total) return if progress: prog = progress prog.add(local) if what: prog.setTopic(_("Fetching %s...") % what) prog.show() else: prog = iface.getProgress(self, True) prog.start() prog.set(local, total) if what: topic = _("Fetching %s...") % what else: topic = _("Fetching information...") prog.setTopic(topic) prog.show() for handler in handlers: handler.start() active = handlers[:] uncomp = self._uncompressor uncompchecked = {} self._speedupdated = self.time cancelledtime = None while active or self._uncompressing: self.time = time.time() if self._cancel: if not cancelledtime: cancelledtime = self.time for handler in active[:]: if not handler.wasCancelled(): handler.cancel() if not handler.tick(): active.remove(handler) # We won't wait for handlers which are not being nice. if time.time() > cancelledtime+CANCELDELAY: for item in self._items.values(): if item.getStatus() != SUCCEEDED: item.setCancelled() # Remove handlers, since we don't know their state. self._handlers.clear() prog.show() break prog.show() continue for handler in active[:]: if not handler.tick(): active.remove(handler) if self._speedupdated+SPEEDDELAY < self.time: self._speedupdated = self.time updatespeed = True else: updatespeed = False for url in self._items: item = self._items[url] if item.getStatus() == FAILED: if (item.getRetries() < MAXRETRIES and item.setNextURL()): item.reset() handler = self.getHandlerInstance(item) handler.enqueue(item) if handler not in active: active.append(handler) continue elif (item.getStatus() != SUCCEEDED or not item.getInfo("uncomp")): if updatespeed: item.updateSpeed() continue localpath = item.getTargetPath() if localpath in uncompchecked: continue uncompchecked[localpath] = True uncomphandler = uncomp.getHandler(localpath) if not uncomphandler: continue uncomppath = uncomphandler.getTargetPath(localpath) if (not self.hasStrongValidate(item, uncomp=True) or not self.validate(item, uncomppath, uncomp=True)): self._uncompressing += 1 thread.start_new_thread(self._uncompress, (item, localpath, uncomphandler)) else: item.setSucceeded(uncomppath) prog.show() time.sleep(0.1) for handler in handlers: handler.stop() if not progress: prog.stop() if self._cancel: raise FetcherCancelled, _("Cancelled") def _uncompress(self, item, localpath, uncomphandler): try: uncomphandler.uncompress(localpath) except Error, e: item.setFailed(unicode(e)) else: uncomppath = uncomphandler.getTargetPath(localpath) valid, reason = self.validate(item, uncomppath, withreason=True, uncomp=True) if not valid: item.setFailed(reason) else: item.setSucceeded(uncomppath) self._uncompressing -= 1 def getLocalSchemes(self): return self._localschemes getLocalSchemes = classmethod(getLocalSchemes) def setHandler(self, scheme, klass, local=False): self._registry[scheme] = klass if local: self._localschemes.append(scheme) setHandler = classmethod(setHandler) def getHandler(self, scheme, klass): return self._registry.get(scheme) getHandler = classmethod(getHandler) def getHandlerInstance(self, item): scheme = item.getURL().scheme proxy = sysconf.get("%s-proxy" % scheme) if proxy: os.environ["%s_proxy" % scheme] = proxy handler = self._handlers.get(scheme) if not handler: klass = self._registry.get(scheme) if not klass: raise Error, _("Unsupported scheme: %s") % scheme handler = klass(self) self._handlers[scheme] = handler return handler def hasStrongValidate(self, item, uncomp=False): if uncomp: prefix = "uncomp_" else: prefix = "" return bool(item.getInfo(prefix+"md5") or item.getInfo(prefix+"sha")) def validate(self, item, localpath, withreason=False, uncomp=False): try: if not os.path.isfile(localpath): raise Error, _("File not found") if uncomp: uncompprefix = "uncomp_" else: uncompprefix = "" validate = item.getInfo(uncompprefix+"validate") if validate: valid, reason = validate(item.getOriginalURL(), localpath, withreason=True) if valid is not None: if withreason: return valid, reason else: return valid size = item.getInfo(uncompprefix+"size") if size: lsize = os.path.getsize(localpath) if lsize != size: raise Error, _("Unexpected size (expected %d, got %d)") % \ (size, lsize) filemd5 = item.getInfo(uncompprefix+"md5") if filemd5: import md5 digest = md5.md5() file = open(localpath) data = file.read(BLOCKSIZE) while data: digest.update(data) data = file.read(BLOCKSIZE) lfilemd5 = digest.hexdigest() if lfilemd5 != filemd5: raise Error, _("Invalid MD5 (expected %s, got %s)") % \ (filemd5, lfilemd5) else: filesha = item.getInfo(uncompprefix+"sha") if filesha: import sha digest = sha.sha() file = open(localpath) data = file.read(BLOCKSIZE) while data: digest.update(data) data = file.read(BLOCKSIZE) lfilesha = digest.hexdigest() if lfilesha != filesha: raise Error, _("Invalid SHA (expected %s, got %s)") % \ (filesha, lfilesha) except Error, reason: if withreason: return False, reason return False else: if withreason: return True, None return True class FetchItem(object): def __init__(self, fetcher, url, mirror): self._fetcher = fetcher self._url = url self._mirror = mirror self._urlobj = URL(mirror.getNext()) self._retries = 0 self._starttime = None self._current = 0 self._total = 0 self._speed = 0 self._speedtime = 0 self._speedcurrent = 0 self._info = {} self._status = WAITING self._failedreason = None self._targetpath = None self._progress = iface.getSubProgress(fetcher) def reset(self): self._status = WAITING self._failedreason = None self._targetpath = None self._starttime = None self._current = 0 self._total = 0 self._speed = 0 self._speedtime = 0 self._speedcurrent = 0 url = self._urlobj.original if self._progress.getSub(url): self._progress.setSubStopped(url) self._progress.show() self._progress.resetSub(url) def getRetries(self): return self._retries def setNextURL(self): self._retries += 1 url = self._mirror.getNext() if url: self._urlobj.set(url) return True else: self._urlobj.set(self._url) return False def getOriginalURL(self): return self._url def getURL(self): return self._urlobj def setURL(self, url): self._urlobj.set(url) def getStatus(self): return self._status def getFailedReason(self): return self._failedreason def getTargetPath(self): return self._targetpath def getInfo(self, kind, default=None): return self._info.get(kind, default) def setInfo(self, **info): # Known used info kinds: # # - validate: validate function, it must accept a 'withreason' # keyword, and must return either 'valid, reason' # or just 'valid', depending on 'withreason'. 'valid' # may be None, True, or False. If it's True or False, # no other information will be checked. # - md5, sha: file digest # - size: file size # - uncomp: whether to uncompress or not # - uncomp_{md5,sha,size}: uncompressed equivalents # for kind in ("md5", "sha", "uncomp_md5", "uncomp_sha"): value = info.get(kind) if value: info[kind] = value.lower() self._info.update(info) def start(self): if self._status is WAITING: self._status = RUNNING self._starttime = self._fetcher.time prog = self._progress url = self._urlobj.original prog.setSubTopic(url, url) prog.setSubTopic(url, re.sub("([a-z]+:/+[^:/]+:)[^/]+(@.*)", r"\1*\2", url)) prog.setSub(url, 0, self._info.get("size") or 1, 1) prog.show() def progress(self, current, total): if self._status is RUNNING: self._current = current self._total = total if total: subdata = {} subdata["current"] = sizeToStr(current) subdata["total"] = sizeToStr(total) subdata["speed"] = speedToStr(self._speed) self._progress.setSub(self._urlobj.original, current, total, 1, subdata) self._progress.show() def updateSpeed(self): if self._status is RUNNING: now = self._fetcher.time if not self._current or not self._speedtime: self._speedcurrent = self._current self._speedtime = now elif self._speedtime+1 < now: speed = self._speed currentdelta = self._current-self._speedcurrent timedelta = now-self._speedtime speed = currentdelta/timedelta self._speed = self._speed+(speed-self._speed)*0.25 self._speedtime = now self._speedcurrent = self._current self.progress(self._current, self._total) def setSucceeded(self, targetpath, fetchedsize=0): if self._status is not FAILED: self._status = SUCCEEDED self._targetpath = targetpath if self._starttime: if fetchedsize: now = self._fetcher.time timedelta = now-self._starttime if timedelta < 1: timedelta = 1 self._mirror.addInfo(time=timedelta, size=fetchedsize) self._speed = fetchedsize/timedelta self._progress.setSubDone(self._urlobj.original) self._progress.show() def setFailed(self, reason): self._status = FAILED self._failedreason = reason if self._starttime: self._mirror.addInfo(failed=1) self._progress.setSubStopped(self._urlobj.original) self._progress.show() def setCancelled(self): self.setFailed(_("Cancelled")) class URL(object): def __init__(self, url=None): if url: self.set(url) else: self.reset() def reset(self): self.original = "" self.scheme = "" self.user = "" self.passwd = "" self.host = "" self.port = None self.path = "" self.query = "" def set(self, url): if url.startswith("/"): self.scheme = "file" rest = url else: if ":/" not in url: raise Error, _("Invalid URL: %s") % url self.scheme, rest = urllib.splittype(url) if self.scheme in Fetcher.getLocalSchemes(): scheme = self.scheme self.reset() self.scheme = scheme self.original = url self.path = os.path.normpath(rest) if self.path.startswith("//"): self.path = self.path[1:] return self.original = url host, rest = urllib.splithost(rest) user, host = urllib.splituser(host) if user: self.user, self.passwd = urllib.splitpasswd(user) else: self.user = "" self.passwd = "" self.host, self.port = urllib.splitport(host) if self.host.startswith("[") and self.host.endswith("]"): self.host = self.host[1:-1] self.path, self.query = urllib.splitquery(rest) self.user = self.user and urllib.unquote(self.user) or "" self.passwd = self.passwd and urllib.unquote(self.passwd) or "" self.path = urllib.unquote(self.path) def __str__(self): if self.scheme in Fetcher.getLocalSchemes(): return "%s://%s" % (self.scheme, urllib.quote(self.path)) url = self.scheme+"://" if self.user: url += urllib.quote(self.user) if self.passwd: url += ":" url += urllib.quote(self.passwd) url += "@" url += self.host if self.port: url += ":%s" % self.port if self.path: url += urllib.quote(self.path) else: url += "/" if self.query: url += "?" url += self.query return url class FetcherHandler(object): def __init__(self, fetcher): self._fetcher = fetcher self._queue = [] self._cancel = False def getQueue(self): return self._queue def wasCancelled(self): return self._cancel def enqueue(self, item): self._queue.append(item) def dequeue(self, item): self._queue.remove(item) def start(self): # Fetcher is starting. self._queue.sort() self._cancel = False def stop(self): # Fetcher is stopping. pass def cancel(self): # Downloads are being cancelled. self._cancel = True queue = self._queue[:] del self._queue[:] for item in queue: item.setCancelled() def changeActiveDownloads(self, value): return self._fetcher.changeActiveDownloads(value) def tick(self): # Ticking does periodic maintenance of the tasks running # inside the handler. It should return true while there # is still something to be done, and should not lock for # very long. Threads should be started for that purpose. return False def getLocalPath(self, item): return self._fetcher.getLocalPath(item) def runLocal(self, caching=None): # That's part of the caching magic. fetcher = self._fetcher if not caching: caching = fetcher.getCaching() if caching is not NEVER: uncompressor = fetcher.getUncompressor() for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] localpath = self.getLocalPath(item) uncomphandler = uncompressor.getHandler(localpath) if uncomphandler and item.getInfo("uncomp"): uncomppath = uncomphandler.getTargetPath(localpath) valid, reason = fetcher.validate(item, uncomppath, withreason=True, uncomp=True) if not valid and fetcher.validate(item, localpath): uncomphandler.uncompress(localpath) valid, reason = fetcher.validate(item, uncomppath, withreason=True, uncomp=True) elif valid and not fetcher.hasStrongValidate(item, True): valid, reason = fetcher.validate(item, localpath, withreason=True) localpath = uncomppath else: valid, reason = fetcher.validate(item, localpath, withreason=True) if valid: del self._queue[i] item.setSucceeded(localpath) elif caching is ALWAYS: del self._queue[i] item.setFailed(reason) class FileHandler(FetcherHandler): RETRIES = 3 def __init__(self, *args): FetcherHandler.__init__(self, *args) self._active = False self._mediaset = self._fetcher.getMediaSet() self._forcecopy = {} def stop(self): FetcherHandler.stop(self) self._forcecopy.clear() def processMedias(self): self._forcecopy.clear() for item in self._queue: localpath = item.getURL().path localpath, media = self._mediaset.processFilePath(localpath) if media: if (not media.wasMounted() and self._fetcher.getForceMountedCopy()): self._forcecopy[item] = True if isinstance(media, DeviceMedia): # We don't want item.getURL().original changed, so that # progress still shows the original path. item.getURL().path = localpath def getLocalPath(self, item): if item in self._forcecopy or self._fetcher.getForceCopy(): return FetcherHandler.getLocalPath(self, item) else: return item.getURL().path def runLocal(self): self.processMedias() if self._fetcher.getForceCopy(): FetcherHandler.runLocal(self) else: # First, handle compressed files without uncompressed # versions available. fetcher = self._fetcher caching = fetcher.getCaching() uncompressor = fetcher.getUncompressor() for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] if item in self._forcecopy: if caching is not ALWAYS: del self._queue[i] continue elif not item.getInfo("uncomp"): continue localpath = self.getLocalPath(item) uncomphandler = uncompressor.getHandler(localpath) if uncomphandler: uncomppath = uncomphandler.getTargetPath(localpath) if not fetcher.validate(item, uncomppath, uncomp=True): valid, reason = fetcher.validate(item, localpath, withreason=True) if valid: linkpath = self._fetcher.getLocalPath(item) if os.path.isfile(linkpath): os.unlink(linkpath) os.symlink(localpath, linkpath) uncomppath = uncomphandler.getTargetPath(linkpath) uncomphandler.uncompress(linkpath) valid, reason = fetcher.validate(item, uncomppath, withreason=True, uncomp=True) os.unlink(linkpath) if valid: item.setSucceeded(uncomppath) else: item.setFailed(reason) del self._queue[i] # Then, everything else, but the items selected in self._forcecopy FetcherHandler.runLocal(self, caching=ALWAYS) if caching is not ALWAYS: self._queue.extend(self._forcecopy.keys()) def tick(self): if self._queue and not self._active: self._active = True thread.start_new_thread(self.copy, ()) return self._active def copy(self): while self._queue: item = self._queue.pop(0) item.start() retries = 0 filepath = item.getURL().path localpath = self.getLocalPath(item) assert filepath != localpath while retries < self.RETRIES: try: input = open(filepath) output = open(localpath, "w") while True: data = input.read(BLOCKSIZE) if not data: break output.write(data) except (IOError, OSError), e: error = unicode(e) retries += 1 else: item.setSucceeded(localpath) break else: item.setFailed(error) self._active = False Fetcher.setHandler("file", FileHandler, local=True) class LocalMediaHandler(FileHandler): def runLocal(self): if not self._fetcher.getForceCopy(): # When not copying, convert earlier to get local files # from the media. self.convertToFile() FileHandler.runLocal(self) def start(self): self.convertToFile() FileHandler.start(self) def convertToFile(self): mediaset = self._fetcher.getMediaSet() for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] itempath = item.getURL().path media = item.getInfo("media") if not media: media = mediaset.getDefault() if media: media.mount() else: mediaset.mountAll() media = mediaset.findFile(itempath) if not media or not media.isMounted(): item.setFailed(_("Media not found")) del self._queue[i] continue item.setURL(media.joinURL(itempath)) Fetcher.setHandler("localmedia", LocalMediaHandler, local=True) class FTPHandler(FetcherHandler): MAXACTIVE = 5 MAXINACTIVE = 5 MAXPERHOST = 2 TIMEOUT = 60 def __init__(self, *args): FetcherHandler.__init__(self, *args) self._active = {} # ftp -> host self._inactive = {} # ftp -> (user, host, port) self._lock = thread.allocate_lock() self._activelimit = {} # host -> num def tick(self): import ftplib self._lock.acquire() if self._queue: if len(self._active) < self.MAXACTIVE: for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] url = item.getURL() hostactive = [x for x in self._active if self._active[x] == url.host] maxactive = self._activelimit.get(url.host, self.MAXPERHOST) if (len(hostactive) < maxactive and self.changeActiveDownloads(+1)): del self._queue[i] userhost = (url.user, url.host, url.port) for ftp in self._inactive: if self._inactive[ftp] == userhost: del self._inactive[ftp] self._active[ftp] = url.host thread.start_new_thread(self.fetch, (ftp, item)) break else: if len(self._inactive) > self.MAXINACTIVE: del self._inactive[ftp] ftp = ftplib.FTP() ftp.lasttime = self._fetcher.time self._active[ftp] = url.host thread.start_new_thread(self.connect, (ftp, item, len(hostactive))) self._lock.release() return bool(self._queue or self._active) def connect(self, ftp, item, active): item.start() url = item.getURL() import ftplib try: ftp.connect(url.host, url.port) ftp.login(url.user, url.passwd) except (socket.error, ftplib.Error, EOFError), e: if isinstance(e, ftplib.error_perm) and active: item.reset() self._lock.acquire() self._queue.append(item) self._lock.release() self._activelimit[item.getURL().host] = active else: try: errmsg = unicode(e[1]) except IndexError: errmsg = unicode(e) item.setFailed(errmsg) self._lock.acquire() del self._active[ftp] self._lock.release() self.changeActiveDownloads(-1) else: self.fetch(ftp, item) def fetch(self, ftp, item): import ftplib fetcher = self._fetcher url = item.getURL() if self._cancel: item.setCancelled() self.changeActiveDownloads(-1) return item.start() try: try: ftp.cwd(os.path.dirname(url.path)) except ftplib.Error: if ftp.lasttime+self.TIMEOUT < fetcher.time: raise EOFError raise filename = os.path.basename(url.path) localpath = self.getLocalPath(item) mtime = None total = None # Check if the file exists at all. ftp.nlst(filename) try: resp = ftp.sendcmd("MDTM "+filename) if resp[:3] == "213": mtimes = resp[3:].strip() mtime = time.mktime(time.strptime(mtimes, "%Y%m%d%H%M%S")) except (ftplib.Error, ValueError): pass try: total = ftp.size(filename) except ftplib.Error: pass else: size = item.getInfo("size") if size and size != total: raise Error, _("Server reports unexpected size") if (not mtime or not os.path.isfile(localpath) or mtime != os.path.getmtime(localpath) or not fetcher.validate(item, localpath)): localpathpart = localpath+".part" if (os.path.isfile(localpathpart) and (not total or os.path.getsize(localpathpart) < total)): rest = os.path.getsize(localpathpart) openmode = "a" item.current = rest else: rest = None openmode = "w" item.current = 0 try: local = open(localpathpart, openmode) except (IOError, OSError), e: raise Error, "%s: %s" % (localpathpart, e) def write(data): if self._cancel: raise FetcherCancelled local.write(data) item.current += len(data) item.progress(item.current, total) try: ftp.retrbinary("RETR "+filename, write, BLOCKSIZE, rest) finally: local.close() if mtime: os.utime(localpathpart, (mtime, mtime)) os.rename(localpathpart, localpath) valid, reason = fetcher.validate(item, localpath, withreason=True) if not valid: if openmode == "a": # Try again, from the very start. item.reset() self._lock.acquire() self._queue.append(item) self._lock.release() else: raise Error, reason else: if total: fetchedsize = total-(rest or 0) elif not rest: fetchedsize = os.path.getsize(localpath) else: fetchedsize = None item.setSucceeded(localpath, fetchedsize) else: item.setSucceeded(localpath) except (socket.error, EOFError): # Put it back on the queue, and kill this ftp object. self._lock.acquire() self._queue.append(item) del self._active[ftp] self._lock.release() self.changeActiveDownloads(-1) return except (Error, IOError, OSError, ftplib.Error), e: item.setFailed(unicode(e)) except FetcherCancelled: item.setCancelled() self._lock.acquire() ftp.lasttime = fetcher.time self._inactive[ftp] = (url.user, url.host, url.port) del self._active[ftp] self._lock.release() self.changeActiveDownloads(-1) Fetcher.setHandler("ftp", FTPHandler) class URLLIBHandler(FetcherHandler): MAXACTIVE = 5 def __init__(self, *args): FetcherHandler.__init__(self, *args) self._active = 0 self._lock = thread.allocate_lock() def tick(self): self._lock.acquire() if self._queue: while (self._active < self.MAXACTIVE and self.changeActiveDownloads(+1)): self._active += 1 thread.start_new_thread(self.fetch, ()) self._lock.release() return bool(self._queue or self._active) def fetch(self): import urllib, rfc822 class Opener(urllib.FancyURLopener): user = None passwd = None def prompt_user_passwd(self, host, realm): return self.user, self.passwd def http_error_default(self, url, fp, errcode, errmsg, headers): if not fp: fp = open("/dev/null") info = urllib.addinfourl(fp, headers, "http:" + url) info.errcode = errcode info.errmsg = errmsg return info opener = Opener() fetcher = self._fetcher while not self._cancel: self._lock.acquire() if not self._queue: self._lock.release() break item = self._queue.pop() self._lock.release() url = item.getURL() opener.user = url.user opener.passwd = url.passwd item.start() try: localpath = self.getLocalPath(item) current = 0 total = None size = item.getInfo("size") del opener.addheaders[:] if (os.path.isfile(localpath) and fetcher.validate(item, localpath)): mtime = os.path.getmtime(localpath) opener.addheader("if-modified-since", rfc822.formatdate(mtime)) localpathpart = localpath+".part" if os.path.isfile(localpathpart): partsize = os.path.getsize(localpathpart) if not size or partsize < size: opener.addheader("range", "bytes=%d-" % partsize) else: partsize = 0 remote = opener.open(url.original) if hasattr(remote, "errcode") and remote.errcode == 416: # Range not satisfiable, try again without it. opener.addheaders = [x for x in opener.addheaders if x[0] != "range"] remote = opener.open(url.original) if hasattr(remote, "errcode") and remote.errcode != 206: # 206 = Partial Content raise remote info = remote.info() if "content-length" in info: total = int(info["content-length"]) elif size: total = size if "content-range" in info: openmode = "a" current = partsize if "content-length" in info: total += partsize else: partsize = 0 openmode = "w" if size and total and size != total: raise Error, _("Server reports unexpected size") try: local = open(localpathpart, openmode) except (IOError, OSError), e: raise IOError, "%s: %s" % (localpathpart, e) try: data = remote.read(BLOCKSIZE) while data: if self._cancel: raise FetcherCancelled local.write(data) current += len(data) item.progress(current, total) data = remote.read(BLOCKSIZE) finally: local.close() remote.close() os.rename(localpathpart, localpath) valid, reason = fetcher.validate(item, localpath, withreason=True) if not valid: if openmode == "a": # Try again, from the very start. item.reset() self._lock.acquire() self._queue.append(item) self._lock.release() else: raise Error, reason else: if total: fetchedsize = total-partsize elif not partsize: fetchedsize = os.path.getsize(localpath) else: fetchedsize = None item.setSucceeded(localpath, fetchedsize) if "last-modified" in info: mtimes = info["last-modified"] mtimet = rfc822.parsedate(mtimes) if mtimet: mtime = time.mktime(mtimet) os.utime(localpath, (mtime, mtime)) except urllib.addinfourl, remote: if remote.errcode == 304: # Not modified item.setSucceeded(localpath) else: item.setFailed(remote.errmsg) except (IOError, OSError, Error, socket.error), e: try: errmsg = unicode(e[1]) except IndexError: errmsg = unicode(e) item.setFailed(errmsg) except FetcherCancelled: item.setCancelled() self._lock.acquire() self._active -= 1 self._lock.release() self.changeActiveDownloads(-1) #Fetcher.setHandler("ftp", URLLIBHandler) Fetcher.setHandler("http", URLLIBHandler) Fetcher.setHandler("https", URLLIBHandler) Fetcher.setHandler("gopher", URLLIBHandler) # This is not in use, since urllib2 is not thread safe, and # the authentication scheme requires additional steps which # are still not implemented. Also, we need some way to handle # 206 returns without breaking out. """ class URLLIB2Handler(FetcherHandler): MAXACTIVE = 1 USECACHEDFTP = True _openerinstalled = False def __init__(self, *args): FetcherHandler.__init__(self, *args) if not URLLIB2Handler._openerinstalled: from smart.util import urllib2 URLLIB2Handler._openerinstalled = True handlerlist = [] if self.USECACHEDFTP: handlerlist.append(urllib2.CacheFTPHandler) handlerlist.append(urllib2.GopherHandler) opener = urllib2.build_opener(urllib2.CacheFTPHandler) urllib2.install_opener(opener) self._active = 0 self._lock = thread.allocate_lock() def tick(self): self._lock.acquire() if self._queue: while (self._active < self.MAXACTIVE and self.changeActiveDownloads(+1)): self._active += 1 thread.start_new_thread(self.fetch, ()) self._lock.release() return bool(self._queue or self._active) def fetch(self): import urllib2, rfc822 fetcher = self._fetcher while True: self._lock.acquire() if not self._queue: self._lock.release() break item = self._queue.pop() self._lock.release() item.start() url = item.getURL() try: localpath = self.getLocalPath(item) current = 0 total = None size = item.getInfo("size") request = urllib2.Request(url.original) if (os.path.isfile(localpath) and fetcher.validate(item, localpath)): mtime = os.path.getmtime(localpath) request.add_header("if-modified-since", rfc822.formatdate(mtime)) localpathpart = localpath+".part" if os.path.isfile(localpathpart): partsize = os.path.getsize(localpathpart) if not size or partsize < size: request.add_header("range", "bytes=%d-" % partsize) else: partsize = 0 try: remote = urllib2.urlopen(request) except urllib2.HTTPError, e: if e.code == 416: # Range not satisfiable del request.headers["Range"] remote = urllib2.urlopen(request) else: raise info = remote.info() if "content-length" in info: total = int(info["content-length"]) elif size: total = size if "content-range" in info: openmode = "a" current = partsize total += partsize else: openmode = "w" if size and total and size != total: raise Error, _("Server reports unexpected size") try: local = open(localpathpart, openmode) except (IOError, OSError), e: raise IOError, "%s: %s" % (localpathpart, e) try: data = remote.read(BLOCKSIZE) while data: local.write(data) current += len(data) item.progress(current, total) data = remote.read(BLOCKSIZE) finally: local.close() remote.close() os.rename(localpathpart, localpath) valid, reason = fetcher.validate(url, localpath, withreason=True) if not valid: if openmode == "a": # Try again, from the very start. item.reset() self._lock.acquire() self._queue.append(item) self._lock.release() else: raise Error, reason else: if total: fetchedsize = total-partsize elif not partsize: fetchedsize = os.path.getsize(localpath) else: fetchedsize = None item.setSucceeded(localpath, fetchedsize) if "last-modified" in info: mtimes = info["last-modified"] mtimet = rfc822.parsedate(mtimes) if mtimet: mtime = time.mktime(mtimet) os.utime(localpath, (mtime, mtime)) except urllib2.HTTPError, e: if e.code == 304: # Not modified item.setSucceeded(localpath) else: item.setFailed(unicode(e)) except (IOError, OSError, Error), e: item.setFailed(unicode(e)) self._lock.acquire() self._active -= 1 self._lock.release() self.changeActiveDownloads(-1) #Fetcher.setHandler("ftp", URLLIB2Handler) Fetcher.setHandler("http", URLLIB2Handler) Fetcher.setHandler("https", URLLIB2Handler) Fetcher.setHandler("gopher", URLLIB2Handler) """#""" class PyCurlHandler(FetcherHandler): MAXACTIVE = 5 MAXINACTIVE = 5 MAXPERHOST = 2 def __init__(self, *args): import pycurl FetcherHandler.__init__(self, *args) self._active = {} # handle -> (scheme, host) self._inactive = {} # handle -> (user, host, port) self._activelimit = {} # host -> num self._running = False self._multi = pycurl.CurlMulti() self._lock = thread.allocate_lock() def tick(self): import pycurl if not self._running and self._queue: self._running = True thread.start_new_thread(self.perform, ()) fetcher = self._fetcher multi = self._multi if self._cancel: self._lock.acquire() for handle in self._active: item = handle.item item.setCancelled() url = item.getURL() multi.remove_handle(handle) userhost = (url.user, url.host, url.port) self._active.clear() self._lock.release() num = 1 while num != 0: self._lock.acquire() num, succeeded, failed = multi.info_read() self._lock.release() self.changeActiveDownloads(-len(succeeded)-len(failed)) for handle in succeeded: item = handle.item local = handle.local localpath = handle.localpath url = item.getURL() local.close() self._lock.acquire() multi.remove_handle(handle) self._lock.release() if handle.getinfo(pycurl.SIZE_DOWNLOAD) == 0: # Not modified os.unlink(localpath+".part") else: if os.path.isfile(localpath): os.unlink(localpath) os.rename(localpath+".part", localpath) mtime = handle.getinfo(pycurl.INFO_FILETIME) if mtime != -1: os.utime(localpath, (mtime, mtime)) del self._active[handle] userhost = (url.user, url.host, url.port) self._inactive[handle] = userhost valid, reason = fetcher.validate(item, localpath, withreason=True) if valid: fetchedsize = handle.getinfo(pycurl.SIZE_DOWNLOAD) item.setSucceeded(localpath, fetchedsize) elif handle.partsize: self._queue.append(item) else: item.setFailed(reason) for handle, errno, errmsg in failed: item = handle.item local = handle.local localpath = handle.localpath url = item.getURL() local.close() self._lock.acquire() multi.remove_handle(handle) self._lock.release() del self._active[handle] userhost = (url.user, url.host, url.port) self._inactive[handle] = userhost if handle.partsize and "byte ranges" in errmsg: os.unlink(localpath+".part") item.reset() self._queue.append(item) elif handle.active and "password" in errmsg: item.reset() self._queue.append(item) self._activelimit[item.getURL().host] = handle.active del self._inactive[handle] else: item.setFailed(errmsg) if self._queue: if len(self._active) < self.MAXACTIVE: for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] url = item.getURL() schemehost = (url.scheme, url.host) hostactive = [x for x in self._active if self._active[x] == schemehost] maxactive = self._activelimit.get(url.host, self.MAXPERHOST) if (len(hostactive) < maxactive and self.changeActiveDownloads(+1)): del self._queue[i] userhost = (url.user, url.host, url.port) for handle in self._inactive: if self._inactive[handle] == userhost: del self._inactive[handle] self._active[handle] = schemehost break else: if len(self._inactive) > self.MAXINACTIVE: del self._inactive[handle] handle = pycurl.Curl() self._active[handle] = schemehost localpath = self.getLocalPath(item) localpathpart = localpath+".part" size = item.getInfo("size") if os.path.isfile(localpathpart): partsize = os.path.getsize(localpathpart) if size and partsize >= size: partsize = 0 else: partsize = 0 handle.partsize = partsize if partsize: openmode = "a" handle.setopt(pycurl.RESUME_FROM_LARGE, long(partsize)) else: openmode = "w" handle.setopt(pycurl.RESUME_FROM_LARGE, 0L) try: local = open(localpathpart, openmode) except (IOError, OSError), e: item.setFailed("%s: %s" % (localpathpart, e)) continue handle.item = item handle.local = local handle.localpath = localpath handle.active = len(hostactive) item.start() def progress(downtotal, downcurrent, uptotal, upcurrent, item=item, size=size, partsize=partsize): if not downtotal: if size and downcurrent: item.progress(partsize+downcurrent, size) else: item.progress(partsize+downcurrent, partsize+downtotal) handle.setopt(pycurl.URL, str(url)) handle.setopt(pycurl.OPT_FILETIME, 1) handle.setopt(pycurl.NOPROGRESS, 0) handle.setopt(pycurl.PROGRESSFUNCTION, progress) handle.setopt(pycurl.WRITEDATA, local) if fetcher.validate(item, localpath): handle.setopt(pycurl.TIMECONDITION, pycurl.TIMECONDITION_IFMODSINCE) mtime = os.path.getmtime(localpath) if url.scheme == "ftp": mtime += 1 # libcurl handles ftp mtime wrongly handle.setopt(pycurl.TIMEVALUE, mtime) self._lock.acquire() multi.add_handle(handle) self._lock.release() return bool(self._queue or self._active) def perform(self): import pycurl multi = self._multi mp = pycurl.E_CALL_MULTI_PERFORM while self._queue or self._active: self._lock.acquire() res = mp while res == mp: res, num = multi.perform() self._lock.release() time.sleep(0.2) self._running = False try: import pycurl except ImportError: pass else: schemes = pycurl.version_info()[-1] for scheme in schemes: if scheme != "file": Fetcher.setHandler(scheme, PyCurlHandler) class SCPHandler(FetcherHandler): MAXACTIVE = 5 MAXPERHOST = 2 def __init__(self, *args): FetcherHandler.__init__(self, *args) self._active = [] # item self._lock = thread.allocate_lock() def tick(self): import ftplib self._lock.acquire() if self._queue: if len(self._active) < self.MAXACTIVE: for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] url = item.getURL() hostactive = [x for x in self._active if x.getURL().host == url.host] if (len(hostactive) < self.MAXPERHOST and self.changeActiveDownloads(+1)): del self._queue[i] self._active.append(item) item.total = None item.localpath = None thread.start_new_thread(self.fetch, (item,)) prog = iface.getSubProgress(self._fetcher) for item in self._active: if item.total and item.localpath: try: size = os.path.getsize(item.localpath) except OSError: pass else: item.progress(size, item.total) self._lock.release() return bool(self._queue or self._active) def fetch(self, item): from smart.util.ssh import SSH fetcher = self._fetcher prog = iface.getSubProgress(self._fetcher) item.start() url = item.getURL() if not url.user: import pwd url.user = pwd.getpwuid(os.getuid()).pw_name if url.host[-1] == ":": url.host = url.host[:-1] locurl = URL() locurl.scheme = url.scheme locurl.user = url.user locurl.host = url.host locurl.port = url.port def getpassword(location=str(locurl)): return iface.askPassword(location) del locurl ssh = SSH(url.user, url.host, url.passwd, getpassword) try: localpath = self.getLocalPath(item) mtime = None total = None size = item.getInfo("size") status, output = ssh.ssh("stat -c '%%Y %%s' %s" % url.path) if status == 0: tokens = output.split() try: mtime = int(tokens[0]) total = int(tokens[1]) except ValueError: if size: total = size else: if size and size != total: raise Error, _("Server reports unexpected size") elif size: total = size item.total = total fetchedsize = 0 if (not mtime or not os.path.isfile(localpath) or mtime != os.path.getmtime(localpath) or not fetcher.validate(item, localpath)): item.localpath = localpath+".part" status, output = ssh.rscp(url.path, item.localpath) if status != 0: raise Error, output os.rename(item.localpath, localpath) fetchedsize = os.path.getsize(localpath) if mtime: os.utime(localpath, (mtime, mtime)) valid, reason = fetcher.validate(item, localpath, withreason=True) if not valid: raise Error, reason except (Error, IOError, OSError), e: item.setFailed(unicode(e)) else: item.setSucceeded(localpath, fetchedsize) self._lock.acquire() self._active.remove(item) self._lock.release() self.changeActiveDownloads(-1) Fetcher.setHandler("scp", SCPHandler) class RHNHandler(FetcherHandler): MAXACTIVE = 5 MAXPERHOST = 2 def __init__(self, *args): FetcherHandler.__init__(self, *args) self._active = [] # item # self._lock = thread.allocate_lock() def tick(self): # import ftplib # self._lock.acquire() if self._queue: if len(self._active) < self.MAXACTIVE: for i in range(len(self._queue)-1,-1,-1): item = self._queue[i] url = item.getURL() hostactive = [x for x in self._active if x.getURL().host == url.host] if (len(hostactive) < self.MAXPERHOST and self.changeActiveDownloads(+1)): del self._queue[i] self._active.append(item) item.total = None item.localpath = None # thread.start_new_thread(self.fetch, (item,)) self.fetch(item) prog = iface.getSubProgress(self._fetcher) for item in self._active: if item.total and item.localpath: try: size = os.path.getsize(item.localpath) except OSError: pass else: item.progress(size, item.total) # self._lock.release() return bool(self._queue or self._active) def fetch(self, item): from rhn.client import rhnPackages fetcher = self._fetcher prog = iface.getSubProgress(self._fetcher) item.start() try: url = item.getURL() channel = url.host parts = url.path.split("/")[1:-1] pkghash = "/".join(parts) localpath = self.getLocalPath(item) # FIXME (20050329): This might not be thread safe because # rhnPackages.downloadPackages uses some global state. We # should probably only initialize xmlrpc stuff once per # fetch session anyways. rhnPackages.downloadPackage(channel, pkghash, localpath) if not os.path.isfile(localpath): raise Error, _("File not found") fetchedsize = os.path.getsize(localpath) except (Error, IOError, OSError), e: item.setFailed(unicode(e)) except: # Since rhnPackages.downloadPackage() can return many # different exceptions, just set this item to failed so # that we don't hang. item.setFailed(unicode(sys.exc_info()[0])) else: item.setSucceeded(localpath, fetchedsize) # self._lock.acquire() self._active.remove(item) # self._lock.release() self.changeActiveDownloads(-1) Fetcher.setHandler("rhn", RHNHandler) # vim:ts=4:sw=4:et
gpl-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 8353, 445, 368, 67, 280, 3042, 12, 3277, 14, 199, 3, 199, 3, 27694, 701, 598, 833, 1214, 79, 653, 1873, 278, 23009, 665, 78, 1873, 278, 23009, 32, 67, 368, 67, 280, 3042, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 26017, 15665, 13537, 14, 199, 3, 199, 3, 26017, 15665, 13537, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 199, 3, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 26017, 15665, 13537, 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, 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, 26017, 15665, 13537, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 504, 11179, 14, 1974, 14, 495, 2537, 492, 1568, 1378, 2848, 12, 8112, 1378, 2848, 199, 504, 11179, 14, 4603, 492, 12300, 1084, 12, 12272, 11398, 199, 504, 11179, 14, 324, 6447, 492, 1910, 27879, 199, 504, 11179, 14, 12324, 492, 603, 7932, 3989, 199, 504, 11179, 14, 1297, 492, 627, 199, 504, 11179, 492, 627, 199, 646, 5549, 199, 646, 2838, 199, 646, 4011, 199, 646, 1059, 199, 646, 2462, 199, 646, 900, 199, 646, 747, 199, 646, 295, 199, 199, 4283, 32528, 275, 4233, 199, 29110, 18616, 275, 413, 199, 20707, 18616, 275, 499, 199, 4283, 20425, 1149, 47, 3705, 7405, 51, 275, 1616, 199, 17462, 8899, 275, 13960, 199, 199, 533, 16347, 281, 22127, 8, 547, 304, 986, 199, 199, 533, 16347, 281, 8, 785, 304, 339, 485, 5189, 275, 1052, 272, 485, 1832, 26818, 275, 942, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 324, 27879, 275, 1910, 27879, 342, 267, 291, 423, 4603, 409, 275, 12300, 1084, 342, 267, 291, 423, 324, 6447, 316, 275, 378, 267, 291, 423, 1832, 694, 275, 5549, 14, 31572, 342, 267, 291, 423, 12324, 2253, 275, 603, 7932, 3989, 342, 267, 291, 423, 29602, 275, 756, 267, 291, 423, 22738, 275, 30953, 267, 291, 423, 1744, 275, 1052, 267, 291, 423, 5586, 275, 1052, 267, 291, 423, 3990, 1574, 275, 756, 267, 291, 423, 3990, 27919, 1574, 275, 756, 267, 291, 423, 1832, 515, 1861, 275, 488, 267, 291, 423, 6406, 275, 756, 267, 291, 423, 7625, 5334, 275, 378, 267, 291, 423, 5416, 1354, 944, 3640, 275, 378, 267, 291, 423, 5416, 1354, 944, 3640, 831, 275, 2462, 14, 12991, 63, 831, 342, 267, 291, 423, 988, 5416, 1354, 944, 3640, 275, 378, 267, 291, 14, 521, 275, 378, 339, 347, 5305, 8, 277, 304, 267, 291, 423, 1744, 14, 3584, 342, 267, 291, 423, 324, 6447, 316, 275, 378, 339, 347, 9311, 8, 277, 304, 267, 291, 423, 6406, 275, 715, 339, 347, 664, 2081, 8, 277, 12, 1166, 304, 267, 372, 291, 423, 1744, 14, 362, 8, 633, 9, 339, 347, 664, 7412, 8, 277, 304, 267, 372, 291, 423, 1744, 14, 1459, 342, 339, 347, 664, 32453, 1084, 8, 277, 304, 267, 663, 275, 1052, 267, 367, 1242, 315, 291, 423, 1744, 14, 1459, 837, 288, 340, 1242, 14, 362, 3694, 342, 508, 5698, 8601, 25953, 26, 355, 663, 59, 1053, 14, 362, 17286, 2632, 5106, 275, 1242, 14, 362, 4277, 2042, 342, 267, 372, 663, 339, 347, 664, 4276, 1084, 8, 277, 304, 267, 663, 275, 1052, 267, 367, 1242, 315, 291, 423, 1744, 14, 1459, 837, 288, 340, 1242, 14, 362, 3694, 342, 508, 26892, 26, 355, 663, 59, 1053, 14, 362, 17286, 2632, 5106, 275, 1242, 14, 362, 4276, 16148, 342, 267, 372, 663, 339, 347, 664, 1358, 27879, 8, 277, 304, 267, 372, 291, 423, 324, 27879, 339, 347, 664, 11398, 1084, 8, 277, 304, 267, 372, 291, 423, 4603, 409, 339, 347, 664, 28034, 3989, 8, 277, 304, 267, 372, 291, 423, 12324, 2253, 339, 347, 664, 35, 23302, 8, 277, 304, 267, 372, 291, 423, 22738, 339, 347, 663, 35, 23302, 8, 277, 12, 574, 304, 267, 291, 423, 22738, 275, 574, 339, 347, 663, 5339, 3567, 8, 277, 12, 2257, 694, 12, 333, 4593, 29, 797, 304, 267, 291, 423, 1832, 694, 275, 2257, 694, 267, 291, 423, 29602, 275, 333, 4593, 339, 347, 664, 5339, 3567, 8, 277, 304, 267, 372, 291, 423, 1832, 694, 339, 347, 663, 26453, 4793, 8, 277, 12, 2403, 304, 267, 291, 423, 1832, 515, 1861, 275, 2403, 339, 347, 664, 26453, 4793, 8, 277, 304, 267, 372, 291, 423, 1832, 515, 1861, 339, 347, 664, 26453, 8, 277, 12, 1242, 304, 267, 702, 1228, 8, 1053, 12, 16347, 2081, 9, 267, 1166, 275, 1242, 14, 362, 17286, 2632, 342, 267, 340, 291, 423, 29602, 26, 288, 1788, 275, 1166, 14, 1814, 27374, 2668, 531, 267, 587, 26, 288, 5687, 12, 9759, 275, 4011, 14, 1294, 466, 8, 633, 9, 288, 1591, 12, 931, 275, 4011, 14, 681, 317, 15157, 8, 6662, 9, 288, 931, 12, 1827, 275, 4011, 14, 1294, 1131, 8, 515, 9, 288, 931, 275, 4011, 14, 12240, 8, 515, 9, 288, 1788, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 267, 340, 291, 423, 1832, 515, 1861, 26, 288, 1788, 275, 291, 423, 1832, 515, 1861, 11, 1501, 267, 372, 747, 14, 515, 14, 904, 8, 277, 423, 1832, 694, 12, 1788, 9, 339, 347, 663, 13606, 5116, 8, 277, 12, 574, 304, 267, 291, 423, 3990, 1574, 275, 574, 339, 347, 664, 13606, 5116, 8, 277, 304, 267, 372, 291, 423, 3990, 1574, 339, 347, 663, 13606, 3716, 16325, 5116, 8, 277, 12, 574, 304, 267, 291, 423, 3990, 27919 ]
[ 199, 3, 1898, 334, 67, 9, 8353, 445, 368, 67, 280, 3042, 12, 3277, 14, 199, 3, 199, 3, 27694, 701, 598, 833, 1214, 79, 653, 1873, 278, 23009, 665, 78, 1873, 278, 23009, 32, 67, 368, 67, 280, 3042, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 26017, 15665, 13537, 14, 199, 3, 199, 3, 26017, 15665, 13537, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 199, 3, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 26017, 15665, 13537, 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, 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, 26017, 15665, 13537, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 199, 3, 199, 504, 11179, 14, 1974, 14, 495, 2537, 492, 1568, 1378, 2848, 12, 8112, 1378, 2848, 199, 504, 11179, 14, 4603, 492, 12300, 1084, 12, 12272, 11398, 199, 504, 11179, 14, 324, 6447, 492, 1910, 27879, 199, 504, 11179, 14, 12324, 492, 603, 7932, 3989, 199, 504, 11179, 14, 1297, 492, 627, 199, 504, 11179, 492, 627, 199, 646, 5549, 199, 646, 2838, 199, 646, 4011, 199, 646, 1059, 199, 646, 2462, 199, 646, 900, 199, 646, 747, 199, 646, 295, 199, 199, 4283, 32528, 275, 4233, 199, 29110, 18616, 275, 413, 199, 20707, 18616, 275, 499, 199, 4283, 20425, 1149, 47, 3705, 7405, 51, 275, 1616, 199, 17462, 8899, 275, 13960, 199, 199, 533, 16347, 281, 22127, 8, 547, 304, 986, 199, 199, 533, 16347, 281, 8, 785, 304, 339, 485, 5189, 275, 1052, 272, 485, 1832, 26818, 275, 942, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 324, 27879, 275, 1910, 27879, 342, 267, 291, 423, 4603, 409, 275, 12300, 1084, 342, 267, 291, 423, 324, 6447, 316, 275, 378, 267, 291, 423, 1832, 694, 275, 5549, 14, 31572, 342, 267, 291, 423, 12324, 2253, 275, 603, 7932, 3989, 342, 267, 291, 423, 29602, 275, 756, 267, 291, 423, 22738, 275, 30953, 267, 291, 423, 1744, 275, 1052, 267, 291, 423, 5586, 275, 1052, 267, 291, 423, 3990, 1574, 275, 756, 267, 291, 423, 3990, 27919, 1574, 275, 756, 267, 291, 423, 1832, 515, 1861, 275, 488, 267, 291, 423, 6406, 275, 756, 267, 291, 423, 7625, 5334, 275, 378, 267, 291, 423, 5416, 1354, 944, 3640, 275, 378, 267, 291, 423, 5416, 1354, 944, 3640, 831, 275, 2462, 14, 12991, 63, 831, 342, 267, 291, 423, 988, 5416, 1354, 944, 3640, 275, 378, 267, 291, 14, 521, 275, 378, 339, 347, 5305, 8, 277, 304, 267, 291, 423, 1744, 14, 3584, 342, 267, 291, 423, 324, 6447, 316, 275, 378, 339, 347, 9311, 8, 277, 304, 267, 291, 423, 6406, 275, 715, 339, 347, 664, 2081, 8, 277, 12, 1166, 304, 267, 372, 291, 423, 1744, 14, 362, 8, 633, 9, 339, 347, 664, 7412, 8, 277, 304, 267, 372, 291, 423, 1744, 14, 1459, 342, 339, 347, 664, 32453, 1084, 8, 277, 304, 267, 663, 275, 1052, 267, 367, 1242, 315, 291, 423, 1744, 14, 1459, 837, 288, 340, 1242, 14, 362, 3694, 342, 508, 5698, 8601, 25953, 26, 355, 663, 59, 1053, 14, 362, 17286, 2632, 5106, 275, 1242, 14, 362, 4277, 2042, 342, 267, 372, 663, 339, 347, 664, 4276, 1084, 8, 277, 304, 267, 663, 275, 1052, 267, 367, 1242, 315, 291, 423, 1744, 14, 1459, 837, 288, 340, 1242, 14, 362, 3694, 342, 508, 26892, 26, 355, 663, 59, 1053, 14, 362, 17286, 2632, 5106, 275, 1242, 14, 362, 4276, 16148, 342, 267, 372, 663, 339, 347, 664, 1358, 27879, 8, 277, 304, 267, 372, 291, 423, 324, 27879, 339, 347, 664, 11398, 1084, 8, 277, 304, 267, 372, 291, 423, 4603, 409, 339, 347, 664, 28034, 3989, 8, 277, 304, 267, 372, 291, 423, 12324, 2253, 339, 347, 664, 35, 23302, 8, 277, 304, 267, 372, 291, 423, 22738, 339, 347, 663, 35, 23302, 8, 277, 12, 574, 304, 267, 291, 423, 22738, 275, 574, 339, 347, 663, 5339, 3567, 8, 277, 12, 2257, 694, 12, 333, 4593, 29, 797, 304, 267, 291, 423, 1832, 694, 275, 2257, 694, 267, 291, 423, 29602, 275, 333, 4593, 339, 347, 664, 5339, 3567, 8, 277, 304, 267, 372, 291, 423, 1832, 694, 339, 347, 663, 26453, 4793, 8, 277, 12, 2403, 304, 267, 291, 423, 1832, 515, 1861, 275, 2403, 339, 347, 664, 26453, 4793, 8, 277, 304, 267, 372, 291, 423, 1832, 515, 1861, 339, 347, 664, 26453, 8, 277, 12, 1242, 304, 267, 702, 1228, 8, 1053, 12, 16347, 2081, 9, 267, 1166, 275, 1242, 14, 362, 17286, 2632, 342, 267, 340, 291, 423, 29602, 26, 288, 1788, 275, 1166, 14, 1814, 27374, 2668, 531, 267, 587, 26, 288, 5687, 12, 9759, 275, 4011, 14, 1294, 466, 8, 633, 9, 288, 1591, 12, 931, 275, 4011, 14, 681, 317, 15157, 8, 6662, 9, 288, 931, 12, 1827, 275, 4011, 14, 1294, 1131, 8, 515, 9, 288, 931, 275, 4011, 14, 12240, 8, 515, 9, 288, 1788, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 267, 340, 291, 423, 1832, 515, 1861, 26, 288, 1788, 275, 291, 423, 1832, 515, 1861, 11, 1501, 267, 372, 747, 14, 515, 14, 904, 8, 277, 423, 1832, 694, 12, 1788, 9, 339, 347, 663, 13606, 5116, 8, 277, 12, 574, 304, 267, 291, 423, 3990, 1574, 275, 574, 339, 347, 664, 13606, 5116, 8, 277, 304, 267, 372, 291, 423, 3990, 1574, 339, 347, 663, 13606, 3716, 16325, 5116, 8, 277, 12, 574, 304, 267, 291, 423, 3990, 27919, 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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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 ]
masklinn/babel
babel/util.py
86
8167
# -*- coding: utf-8 -*- """ babel.util ~~~~~~~~~~ Various utility classes and functions. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. """ import codecs from datetime import timedelta, tzinfo import os import re import textwrap from babel._compat import izip, imap missing = object() def distinct(iterable): """Yield all items in an iterable collection that are distinct. Unlike when using sets for a similar effect, the original ordering of the items in the collection is preserved by this function. >>> print list(distinct([1, 2, 1, 3, 4, 4])) [1, 2, 3, 4] >>> print list(distinct('foobar')) ['f', 'o', 'b', 'a', 'r'] :param iterable: the iterable collection providing the data """ seen = set() for item in iter(iterable): if item not in seen: yield item seen.add(item) # Regexp to match python magic encoding line PYTHON_MAGIC_COMMENT_re = re.compile( br'[ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)', re.VERBOSE) def parse_encoding(fp): """Deduce the encoding of a source file from magic comment. It does this in the same way as the `Python interpreter`__ .. __: http://docs.python.org/ref/encodings.html The ``fp`` argument should be a seekable file object. (From Jeff Dairiki) """ pos = fp.tell() fp.seek(0) try: line1 = fp.readline() has_bom = line1.startswith(codecs.BOM_UTF8) if has_bom: line1 = line1[len(codecs.BOM_UTF8):] m = PYTHON_MAGIC_COMMENT_re.match(line1) if not m: try: import parser parser.suite(line1.decode('latin-1')) except (ImportError, SyntaxError): # Either it's a real syntax error, in which case the source is # not valid python source, or line2 is a continuation of line1, # in which case we don't want to scan line2 for a magic # comment. pass else: line2 = fp.readline() m = PYTHON_MAGIC_COMMENT_re.match(line2) if has_bom: if m: raise SyntaxError( "python refuses to compile code with both a UTF8 " "byte-order-mark and a magic encoding comment") return 'utf_8' elif m: return m.group(1).decode('latin-1') else: return None finally: fp.seek(pos) def pathmatch(pattern, filename): """Extended pathname pattern matching. This function is similar to what is provided by the ``fnmatch`` module in the Python standard library, but: * can match complete (relative or absolute) path names, and not just file names, and * also supports a convenience pattern ("**") to match files at any directory level. Examples: >>> pathmatch('**.py', 'bar.py') True >>> pathmatch('**.py', 'foo/bar/baz.py') True >>> pathmatch('**.py', 'templates/index.html') False >>> pathmatch('**/templates/*.html', 'templates/index.html') True >>> pathmatch('**/templates/*.html', 'templates/foo/bar.html') False :param pattern: the glob pattern :param filename: the path name of the file to match against """ symbols = { '?': '[^/]', '?/': '[^/]/', '*': '[^/]+', '*/': '[^/]+/', '**/': '(?:.+/)*?', '**': '(?:.+/)*?[^/]+', } buf = [] for idx, part in enumerate(re.split('([?*]+/?)', pattern)): if idx % 2: buf.append(symbols[part]) elif part: buf.append(re.escape(part)) match = re.match(''.join(buf) + '$', filename.replace(os.sep, '/')) return match is not None class TextWrapper(textwrap.TextWrapper): wordsep_re = re.compile( r'(\s+|' # any whitespace r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))' # em-dash ) def wraptext(text, width=70, initial_indent='', subsequent_indent=''): """Simple wrapper around the ``textwrap.wrap`` function in the standard library. This version does not wrap lines on hyphens in words. :param text: the text to wrap :param width: the maximum line width :param initial_indent: string that will be prepended to the first line of wrapped output :param subsequent_indent: string that will be prepended to all lines save the first of wrapped output """ wrapper = TextWrapper(width=width, initial_indent=initial_indent, subsequent_indent=subsequent_indent, break_long_words=False) return wrapper.wrap(text) class odict(dict): """Ordered dict implementation. :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 """ def __init__(self, data=None): dict.__init__(self, data or {}) self._keys = list(dict.keys(self)) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __setitem__(self, key, item): dict.__setitem__(self, key, item) if key not in self._keys: self._keys.append(key) def __iter__(self): return iter(self._keys) iterkeys = __iter__ def clear(self): dict.clear(self) self._keys = [] def copy(self): d = odict() d.update(self) return d def items(self): return zip(self._keys, self.values()) def iteritems(self): return izip(self._keys, self.itervalues()) def keys(self): return self._keys[:] def pop(self, key, default=missing): if default is missing: return dict.pop(self, key) elif key not in self: return default self._keys.remove(key) return dict.pop(self, key, default) def popitem(self, key): self._keys.remove(key) return dict.popitem(key) def setdefault(self, key, failobj = None): dict.setdefault(self, key, failobj) if key not in self._keys: self._keys.append(key) def update(self, dict): for (key, val) in dict.items(): self[key] = val def values(self): return map(self.get, self._keys) def itervalues(self): return imap(self.get, self._keys) try: relpath = os.path.relpath except AttributeError: def relpath(path, start='.'): """Compute the relative path to one path from another. >>> relpath('foo/bar.txt', '').replace(os.sep, '/') 'foo/bar.txt' >>> relpath('foo/bar.txt', 'foo').replace(os.sep, '/') 'bar.txt' >>> relpath('foo/bar.txt', 'baz').replace(os.sep, '/') '../foo/bar.txt' """ start_list = os.path.abspath(start).split(os.sep) path_list = os.path.abspath(path).split(os.sep) # Work out how much of the filepath is shared by start and path. i = len(os.path.commonprefix([start_list, path_list])) rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:] return os.path.join(*rel_list) class FixedOffsetTimezone(tzinfo): """Fixed offset in minutes east from UTC.""" def __init__(self, offset, name=None): self._offset = timedelta(minutes=offset) if name is None: name = 'Etc/GMT+%d' % offset self.zone = name def __str__(self): return self.zone def __repr__(self): return '<FixedOffset "%s" %s>' % (self.zone, self._offset) def utcoffset(self, dt): return self._offset def tzname(self, dt): return self.zone def dst(self, dt): return ZERO import pytz as _pytz from babel import localtime # Export the localtime functionality here because that's # where it was in the past. UTC = _pytz.utc LOCALTZ = localtime.LOCALTZ get_localzone = localtime.get_localzone STDOFFSET = localtime.STDOFFSET DSTOFFSET = localtime.DSTOFFSET DSTDIFF = localtime.DSTDIFF ZERO = localtime.ZERO
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 1974, 272, 221, 4919, 1714, 339, 21107, 1785, 11420, 3992, 436, 3423, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 6010, 199, 504, 2197, 492, 6871, 12, 10313, 199, 646, 747, 199, 646, 295, 199, 646, 13390, 199, 504, 29178, 423, 5819, 492, 28697, 12, 23646, 199, 199, 4752, 275, 909, 342, 421, 199, 318, 15392, 8, 8147, 304, 272, 408, 22889, 1006, 2974, 315, 376, 6076, 3245, 626, 787, 15392, 14, 339, 25059, 1380, 1808, 5951, 367, 282, 8545, 7763, 12, 314, 3379, 7794, 402, 314, 272, 2974, 315, 314, 3245, 365, 17731, 701, 642, 805, 14, 339, 1306, 870, 769, 8, 12926, 779, 17, 12, 499, 12, 413, 12, 650, 12, 841, 12, 841, 2459, 272, 359, 17, 12, 499, 12, 650, 12, 841, 61, 272, 1306, 870, 769, 8, 12926, 360, 9664, 1333, 272, 788, 70, 297, 283, 79, 297, 283, 66, 297, 283, 65, 297, 283, 82, 418, 339, 520, 635, 6076, 26, 314, 6076, 3245, 13070, 314, 666, 272, 408, 272, 6775, 275, 663, 342, 272, 367, 1242, 315, 2740, 8, 8147, 304, 267, 340, 1242, 440, 315, 6775, 26, 288, 1995, 1242, 288, 6775, 14, 525, 8, 1053, 9, 199, 199, 3, 12939, 80, 370, 1336, 2366, 10628, 2644, 1004, 199, 11720, 63, 19973, 63, 10973, 63, 264, 275, 295, 14, 2014, 8, 272, 11665, 3894, 971, 84, 60, 70, 3672, 971, 3, 23076, 2803, 59, 29, 26, 1527, 971, 84, 3672, 779, 2696, 87, 14, 28798, 295, 14, 16075, 9, 199, 318, 2198, 63, 2991, 8, 3997, 304, 272, 408, 36, 379, 3683, 314, 2644, 402, 282, 1350, 570, 687, 10628, 3721, 14, 339, 2779, 1630, 642, 315, 314, 2011, 4340, 465, 314, 658, 4718, 12693, 64, 363, 339, 2508, 636, 26, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 1121, 15, 21138, 14, 1360, 339, 710, 1124, 3997, 1040, 1423, 1077, 506, 282, 12005, 461, 570, 909, 14, 339, 334, 2532, 1603, 3609, 577, 5789, 322, 8810, 9, 272, 408, 272, 2086, 275, 4090, 14, 9974, 342, 272, 4090, 14, 5507, 8, 16, 9, 272, 862, 26, 267, 1004, 17, 275, 4090, 14, 6407, 342, 267, 965, 63, 16302, 275, 1004, 17, 14, 2460, 8, 8933, 14, 19550, 63, 6610, 24, 9, 267, 340, 965, 63, 16302, 26, 288, 1004, 17, 275, 1004, 17, 59, 552, 8, 8933, 14, 19550, 63, 6610, 24, 15405, 398, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 17, 9, 267, 340, 440, 333, 26, 288, 862, 26, 355, 492, 1798, 355, 1798, 14, 5768, 8, 604, 17, 14, 2708, 360, 10378, 13, 17, 1333, 288, 871, 334, 17825, 12, 12053, 304, 355, 327, 13083, 652, 1159, 282, 3363, 6302, 1125, 12, 315, 1314, 1930, 314, 1350, 365, 355, 327, 440, 1686, 2366, 1350, 12, 503, 1004, 18, 365, 282, 16015, 402, 1004, 17, 12, 355, 327, 315, 1314, 1930, 781, 2793, 1133, 2934, 370, 8000, 1004, 18, 367, 282, 10628, 355, 327, 3721, 14, 355, 986, 288, 587, 26, 355, 1004, 18, 275, 4090, 14, 6407, 342, 355, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 18, 9, 398, 340, 965, 63, 16302, 26, 288, 340, 333, 26, 355, 746, 12053, 8, 490, 298, 1548, 2984, 5589, 370, 6555, 1233, 543, 3865, 282, 9094, 24, 298, 490, 298, 4414, 13, 1648, 13, 1657, 436, 282, 10628, 2644, 3721, 531, 288, 372, 283, 1624, 63, 24, 7, 267, 916, 333, 26, 288, 372, 333, 14, 923, 8, 17, 680, 2708, 360, 10378, 13, 17, 358, 267, 587, 26, 288, 372, 488, 272, 3753, 26, 267, 4090, 14, 5507, 8, 1712, 9, 199, 199, 318, 931, 1431, 8, 3401, 12, 1788, 304, 272, 408, 14107, 11776, 3851, 4877, 14, 339, 961, 805, 365, 8545, 370, 4052, 365, 2741, 701, 314, 1124, 15359, 1040, 859, 315, 272, 314, 2018, 4465, 3555, 12, 1325, 26, 10813, 627, 883, 1336, 4890, 334, 6188, 503, 3679, 9, 931, 1561, 12, 436, 440, 2951, 570, 2126, 1561, 12, 436, 1362, 627, 2597, 5171, 282, 16777, 3851, 1689, 538, 531, 370, 1336, 1584, 737, 1263, 2126, 2082, 2166, 14, 339, 6058, 26, 339, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1700, 14, 647, 358, 272, 715, 272, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1421, 15, 1700, 15, 6185, 14, 647, 358, 272, 715, 272, 1306, 931, 1431, 31260, 14, 647, 297, 283, 5876, 15, 1080, 14, 1360, 358, 272, 756, 339, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1080, 14, 1360, 358, 272, 715, 272, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1421, 15, 1700, 14, 1360, 358, 272, 756, 339, 520, 635, 3851, 26, 314, 5739, 3851, 272, 520, 635, 1788, 26, 314, 931, 536, 402, 314, 570, 370, 1336, 6169, 272, 408, 272, 6698, 275, 469, 267, 8720, 356, 257, 283, 4735, 15, 4300, 267, 8720, 25772, 221, 283, 4735, 15, 61, 3678, 267, 22969, 257, 283, 4735, 15, 11529, 267, 6438, 25772, 221, 283, 26285, 3678, 267, 23940, 25772, 283, 5169, 6977, 15, 3342, 7044, 267, 23940, 356, 221, 283, 5169, 6977, 15, 3342, 31, 4735, 15, 11529, 272, 789, 272, 4123, 275, 942, 272, 367, 4280, 12, 1777, 315, 3874, 8, 264, 14, 1294, 360, 779, 31, 10, 2807, 10197, 3196, 3851, 2298, 267, 340, 4280, 450, 499, 26, 288, 4123, 14, 740, 8, 7450, 59, 2064, 566, 267, 916, 1777, 26, 288, 4123, 14, 740, 8, 264, 14, 3765, 8, 2064, 430, 272, 1336, 275, 295, 14, 1431, 17840, 904, 8, 1436, 9, 435, 283, 4268, 1788, 14, 1814, 8, 736, 14, 4127, 12, 1994, 1333, 272, 372, 1336, 365, 440, 488, 421, 199, 533, 4516, 4590, 8, 505, 3823, 14, 1872, 4590, 304, 272, 4349, 4127, 63, 264, 275, 295, 14, 2014, 8, 267, 519, 13445, 83, 11, 5227, 22456, 327, 1263, 8139, 267, 519, 10120, 28, 32296, 87, 60, 12525, 3212 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 1974, 272, 221, 4919, 1714, 339, 21107, 1785, 11420, 3992, 436, 3423, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 6010, 199, 504, 2197, 492, 6871, 12, 10313, 199, 646, 747, 199, 646, 295, 199, 646, 13390, 199, 504, 29178, 423, 5819, 492, 28697, 12, 23646, 199, 199, 4752, 275, 909, 342, 421, 199, 318, 15392, 8, 8147, 304, 272, 408, 22889, 1006, 2974, 315, 376, 6076, 3245, 626, 787, 15392, 14, 339, 25059, 1380, 1808, 5951, 367, 282, 8545, 7763, 12, 314, 3379, 7794, 402, 314, 272, 2974, 315, 314, 3245, 365, 17731, 701, 642, 805, 14, 339, 1306, 870, 769, 8, 12926, 779, 17, 12, 499, 12, 413, 12, 650, 12, 841, 12, 841, 2459, 272, 359, 17, 12, 499, 12, 650, 12, 841, 61, 272, 1306, 870, 769, 8, 12926, 360, 9664, 1333, 272, 788, 70, 297, 283, 79, 297, 283, 66, 297, 283, 65, 297, 283, 82, 418, 339, 520, 635, 6076, 26, 314, 6076, 3245, 13070, 314, 666, 272, 408, 272, 6775, 275, 663, 342, 272, 367, 1242, 315, 2740, 8, 8147, 304, 267, 340, 1242, 440, 315, 6775, 26, 288, 1995, 1242, 288, 6775, 14, 525, 8, 1053, 9, 199, 199, 3, 12939, 80, 370, 1336, 2366, 10628, 2644, 1004, 199, 11720, 63, 19973, 63, 10973, 63, 264, 275, 295, 14, 2014, 8, 272, 11665, 3894, 971, 84, 60, 70, 3672, 971, 3, 23076, 2803, 59, 29, 26, 1527, 971, 84, 3672, 779, 2696, 87, 14, 28798, 295, 14, 16075, 9, 199, 318, 2198, 63, 2991, 8, 3997, 304, 272, 408, 36, 379, 3683, 314, 2644, 402, 282, 1350, 570, 687, 10628, 3721, 14, 339, 2779, 1630, 642, 315, 314, 2011, 4340, 465, 314, 658, 4718, 12693, 64, 363, 339, 2508, 636, 26, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 1121, 15, 21138, 14, 1360, 339, 710, 1124, 3997, 1040, 1423, 1077, 506, 282, 12005, 461, 570, 909, 14, 339, 334, 2532, 1603, 3609, 577, 5789, 322, 8810, 9, 272, 408, 272, 2086, 275, 4090, 14, 9974, 342, 272, 4090, 14, 5507, 8, 16, 9, 272, 862, 26, 267, 1004, 17, 275, 4090, 14, 6407, 342, 267, 965, 63, 16302, 275, 1004, 17, 14, 2460, 8, 8933, 14, 19550, 63, 6610, 24, 9, 267, 340, 965, 63, 16302, 26, 288, 1004, 17, 275, 1004, 17, 59, 552, 8, 8933, 14, 19550, 63, 6610, 24, 15405, 398, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 17, 9, 267, 340, 440, 333, 26, 288, 862, 26, 355, 492, 1798, 355, 1798, 14, 5768, 8, 604, 17, 14, 2708, 360, 10378, 13, 17, 1333, 288, 871, 334, 17825, 12, 12053, 304, 355, 327, 13083, 652, 1159, 282, 3363, 6302, 1125, 12, 315, 1314, 1930, 314, 1350, 365, 355, 327, 440, 1686, 2366, 1350, 12, 503, 1004, 18, 365, 282, 16015, 402, 1004, 17, 12, 355, 327, 315, 1314, 1930, 781, 2793, 1133, 2934, 370, 8000, 1004, 18, 367, 282, 10628, 355, 327, 3721, 14, 355, 986, 288, 587, 26, 355, 1004, 18, 275, 4090, 14, 6407, 342, 355, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 18, 9, 398, 340, 965, 63, 16302, 26, 288, 340, 333, 26, 355, 746, 12053, 8, 490, 298, 1548, 2984, 5589, 370, 6555, 1233, 543, 3865, 282, 9094, 24, 298, 490, 298, 4414, 13, 1648, 13, 1657, 436, 282, 10628, 2644, 3721, 531, 288, 372, 283, 1624, 63, 24, 7, 267, 916, 333, 26, 288, 372, 333, 14, 923, 8, 17, 680, 2708, 360, 10378, 13, 17, 358, 267, 587, 26, 288, 372, 488, 272, 3753, 26, 267, 4090, 14, 5507, 8, 1712, 9, 199, 199, 318, 931, 1431, 8, 3401, 12, 1788, 304, 272, 408, 14107, 11776, 3851, 4877, 14, 339, 961, 805, 365, 8545, 370, 4052, 365, 2741, 701, 314, 1124, 15359, 1040, 859, 315, 272, 314, 2018, 4465, 3555, 12, 1325, 26, 10813, 627, 883, 1336, 4890, 334, 6188, 503, 3679, 9, 931, 1561, 12, 436, 440, 2951, 570, 2126, 1561, 12, 436, 1362, 627, 2597, 5171, 282, 16777, 3851, 1689, 538, 531, 370, 1336, 1584, 737, 1263, 2126, 2082, 2166, 14, 339, 6058, 26, 339, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1700, 14, 647, 358, 272, 715, 272, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1421, 15, 1700, 15, 6185, 14, 647, 358, 272, 715, 272, 1306, 931, 1431, 31260, 14, 647, 297, 283, 5876, 15, 1080, 14, 1360, 358, 272, 756, 339, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1080, 14, 1360, 358, 272, 715, 272, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1421, 15, 1700, 14, 1360, 358, 272, 756, 339, 520, 635, 3851, 26, 314, 5739, 3851, 272, 520, 635, 1788, 26, 314, 931, 536, 402, 314, 570, 370, 1336, 6169, 272, 408, 272, 6698, 275, 469, 267, 8720, 356, 257, 283, 4735, 15, 4300, 267, 8720, 25772, 221, 283, 4735, 15, 61, 3678, 267, 22969, 257, 283, 4735, 15, 11529, 267, 6438, 25772, 221, 283, 26285, 3678, 267, 23940, 25772, 283, 5169, 6977, 15, 3342, 7044, 267, 23940, 356, 221, 283, 5169, 6977, 15, 3342, 31, 4735, 15, 11529, 272, 789, 272, 4123, 275, 942, 272, 367, 4280, 12, 1777, 315, 3874, 8, 264, 14, 1294, 360, 779, 31, 10, 2807, 10197, 3196, 3851, 2298, 267, 340, 4280, 450, 499, 26, 288, 4123, 14, 740, 8, 7450, 59, 2064, 566, 267, 916, 1777, 26, 288, 4123, 14, 740, 8, 264, 14, 3765, 8, 2064, 430, 272, 1336, 275, 295, 14, 1431, 17840, 904, 8, 1436, 9, 435, 283, 4268, 1788, 14, 1814, 8, 736, 14, 4127, 12, 1994, 1333, 272, 372, 1336, 365, 440, 488, 421, 199, 533, 4516,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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 ]
jregovic/python-driver
tests/unit/io/utils.py
6
3730
# Copyright 2013-2015 DataStax, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import time class TimerCallback(): invoked = False created_time = 0 invoked_time = 0 expected_wait = 0 def __init__(self, expected_wait): self.invoked = False self.created_time = time.time() self.expected_wait = expected_wait def invoke(self): self.invoked_time = time.time() self.invoked = True def was_invoked(self): return self.invoked def get_wait_time(self): elapsed_time = self.invoked_time - self.created_time return elapsed_time def wait_match_excepted(self): if self.expected_wait-.01 <= self.get_wait_time() <= self.expected_wait+.01: return True return False def get_timeout(gross_time, start, end, precision, split_range): """ A way to generate varying timeouts based on ranges :param gross_time: Some integer between start and end :param start: the start value of the range :param end: the end value of the range :param precision: the precision to use to generate the timeout. :param split_range: generate values from both ends :return: a timeout value to use """ if(split_range): top_num = float(end)/precision bottom_num = float(start)/precision if gross_time % 2 == 0: timeout = top_num - float(gross_time)/precision else: timeout = bottom_num + float(gross_time)/precision else: timeout = float(gross_time)/precision return timeout def submit_and_wait_for_completion(unit_test, connection, start, end, increment, precision, split_range=False): """ This will submit a number of timers to the provided connection. It will then ensure that the corresponding callback is invoked in the appropriate amount of time. :param unit_test: Invoking unit tests :param connection: Connection to create the timer on. :param start: Lower bound of range. :param end: Upper bound of the time range :param increment: +1, or -1 :param precision: 100 for centisecond, 1000 for milliseconds :param split_range: True to split the range between incrementing and decrementing. """ # Various lists for tracking callback as completed or pending pending_callbacks = [] completed_callbacks = [] # submit timers with various timeouts for gross_time in range(start, end, increment): timeout = get_timeout(gross_time, start, end, precision, split_range) callback = TimerCallback(timeout) connection.create_timer(timeout, callback.invoke) pending_callbacks.append(callback) # wait for all the callbacks associated with the timers to be invoked while len(pending_callbacks) is not 0: for callback in pending_callbacks: if callback.was_invoked(): pending_callbacks.remove(callback) completed_callbacks.append(callback) time.sleep(.1) # ensure they are all called back in a timely fashion for callback in completed_callbacks: unit_test.assertAlmostEqual(callback.expected_wait, callback.get_wait_time(), delta=.1)
apache-2.0
[ 3, 1898, 6171, 13, 7806, 3918, 3391, 88, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 900, 421, 199, 533, 22287, 2806, 837, 339, 10302, 275, 756, 272, 2737, 63, 521, 275, 378, 272, 10302, 63, 521, 275, 378, 272, 1420, 63, 2573, 275, 378, 339, 347, 636, 826, 721, 277, 12, 1420, 63, 2573, 304, 267, 291, 14, 5350, 7620, 275, 756, 267, 291, 14, 3966, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 2062, 63, 2573, 275, 1420, 63, 2573, 339, 347, 12677, 8, 277, 304, 267, 291, 14, 5350, 7620, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 5350, 7620, 275, 715, 339, 347, 1990, 63, 5350, 7620, 8, 277, 304, 267, 372, 291, 14, 5350, 7620, 339, 347, 664, 63, 2573, 63, 521, 8, 277, 304, 267, 14439, 63, 521, 275, 291, 14, 5350, 7620, 63, 521, 446, 291, 14, 3966, 63, 521, 267, 372, 14439, 63, 521, 339, 347, 3618, 63, 1431, 63, 476, 7203, 8, 277, 304, 267, 340, 291, 14, 2062, 63, 2573, 30858, 614, 2695, 291, 14, 362, 63, 2573, 63, 521, 342, 2695, 291, 14, 2062, 63, 2573, 26240, 614, 26, 288, 372, 715, 267, 372, 756, 421, 199, 318, 664, 63, 2593, 8, 71, 3685, 63, 521, 12, 1343, 12, 1284, 12, 7151, 12, 3715, 63, 1842, 304, 272, 408, 272, 437, 4340, 370, 3550, 17083, 316, 25870, 4079, 641, 12271, 272, 520, 635, 486, 3685, 63, 521, 26, 6601, 3000, 3382, 1343, 436, 1284, 272, 520, 635, 1343, 26, 314, 1343, 574, 402, 314, 1425, 272, 520, 635, 1284, 26, 314, 1284, 574, 402, 314, 1425, 272, 520, 635, 7151, 26, 314, 7151, 370, 675, 370, 3550, 314, 2653, 14, 272, 520, 635, 3715, 63, 1842, 26, 3550, 1338, 687, 3865, 11187, 272, 520, 1107, 26, 282, 2653, 574, 370, 675, 272, 408, 272, 340, 8, 1294, 63, 1842, 304, 288, 2746, 63, 1507, 275, 2069, 8, 500, 2447, 6833, 288, 9048, 63, 1507, 275, 2069, 8, 928, 2447, 6833, 288, 340, 486, 3685, 63, 521, 450, 499, 508, 378, 26, 355, 2653, 275, 2746, 63, 1507, 446, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 288, 587, 26, 355, 2653, 275, 9048, 63, 1507, 435, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 339, 587, 26, 267, 2653, 275, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 339, 372, 2653, 421, 199, 318, 11482, 63, 460, 63, 2573, 63, 509, 63, 13207, 8, 3248, 63, 396, 12, 1950, 12, 1343, 12, 1284, 12, 11609, 12, 7151, 12, 3715, 63, 1842, 29, 797, 304, 272, 408, 2043, 961, 911, 11482, 282, 1329, 402, 900, 2393, 370, 314, 2741, 1950, 14, 2779, 911, 2066, 4868, 626, 314, 5226, 2043, 3233, 365, 10302, 315, 314, 5827, 5982, 402, 900, 14, 2043, 520, 635, 4137, 63, 396, 26, 221, 30110, 17967, 4137, 2295, 2043, 520, 635, 1950, 26, 8113, 370, 1218, 314, 9715, 641, 14, 2043, 520, 635, 1343, 26, 29893, 3914, 402, 1425, 14, 2043, 520, 635, 1284, 26, 4949, 529, 3914, 402, 314, 900, 1425, 2043, 520, 635, 11609, 26, 435, 17, 12, 503, 446, 17, 2043, 520, 635, 7151, 26, 2948, 367, 9679, 280, 4375, 12, 5198, 367, 21131, 2043, 520, 635, 3715, 63, 1842, 26, 715, 370, 3715, 314, 1425, 3382, 11609, 316, 436, 477, 4062, 316, 14, 2043, 408, 339, 327, 21107, 1785, 5548, 367, 15161, 3233, 465, 9709, 503, 9413, 272, 9413, 63, 11948, 275, 942, 272, 9709, 63, 11948, 275, 942, 339, 327, 11482, 900, 2393, 543, 7750, 25870, 272, 367, 486, 3685, 63, 521, 315, 1425, 8, 928, 12, 1284, 12, 11609, 304, 267, 2653, 275, 664, 63, 2593, 8, 71, 3685, 63, 521, 12, 1343, 12, 1284, 12, 7151, 12, 3715, 63, 1842, 9, 267, 3233, 275, 22287, 2806, 8, 2593, 9, 267, 1950, 14, 981, 63, 7414, 8, 2593, 12, 3233, 14, 15195, 9, 267, 9413, 63, 11948, 14, 740, 8, 3058, 9, 339, 327, 3618, 367, 1006, 314, 13484, 4568, 543, 314, 900, 2393, 370, 506, 10302, 272, 1830, 822, 8, 6455, 63, 11948, 9, 365, 440, 378, 26, 267, 367, 3233, 315, 9413, 63, 11948, 26, 288, 340, 3233, 14, 10274, 63, 5350, 7620, 837, 355, 9413, 63, 11948, 14, 2168, 8, 3058, 9, 355, 9709, 63, 11948, 14, 740, 8, 3058, 9, 267, 900, 14, 4532, 13417, 17, 9, 339, 327, 4868, 2985, 787, 1006, 2797, 1771, 315, 282, 900, 590, 32285, 272, 367, 3233, 315, 9709, 63, 11948, 26, 267, 4137, 63, 396, 14, 7904, 8, 3058, 14, 2062, 63, 2573, 12, 3233, 14, 362, 63, 2573, 63, 521, 1062, 5762, 15856, 17, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6171, 13, 7806, 3918, 3391, 88, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 900, 421, 199, 533, 22287, 2806, 837, 339, 10302, 275, 756, 272, 2737, 63, 521, 275, 378, 272, 10302, 63, 521, 275, 378, 272, 1420, 63, 2573, 275, 378, 339, 347, 636, 826, 721, 277, 12, 1420, 63, 2573, 304, 267, 291, 14, 5350, 7620, 275, 756, 267, 291, 14, 3966, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 2062, 63, 2573, 275, 1420, 63, 2573, 339, 347, 12677, 8, 277, 304, 267, 291, 14, 5350, 7620, 63, 521, 275, 900, 14, 521, 342, 267, 291, 14, 5350, 7620, 275, 715, 339, 347, 1990, 63, 5350, 7620, 8, 277, 304, 267, 372, 291, 14, 5350, 7620, 339, 347, 664, 63, 2573, 63, 521, 8, 277, 304, 267, 14439, 63, 521, 275, 291, 14, 5350, 7620, 63, 521, 446, 291, 14, 3966, 63, 521, 267, 372, 14439, 63, 521, 339, 347, 3618, 63, 1431, 63, 476, 7203, 8, 277, 304, 267, 340, 291, 14, 2062, 63, 2573, 30858, 614, 2695, 291, 14, 362, 63, 2573, 63, 521, 342, 2695, 291, 14, 2062, 63, 2573, 26240, 614, 26, 288, 372, 715, 267, 372, 756, 421, 199, 318, 664, 63, 2593, 8, 71, 3685, 63, 521, 12, 1343, 12, 1284, 12, 7151, 12, 3715, 63, 1842, 304, 272, 408, 272, 437, 4340, 370, 3550, 17083, 316, 25870, 4079, 641, 12271, 272, 520, 635, 486, 3685, 63, 521, 26, 6601, 3000, 3382, 1343, 436, 1284, 272, 520, 635, 1343, 26, 314, 1343, 574, 402, 314, 1425, 272, 520, 635, 1284, 26, 314, 1284, 574, 402, 314, 1425, 272, 520, 635, 7151, 26, 314, 7151, 370, 675, 370, 3550, 314, 2653, 14, 272, 520, 635, 3715, 63, 1842, 26, 3550, 1338, 687, 3865, 11187, 272, 520, 1107, 26, 282, 2653, 574, 370, 675, 272, 408, 272, 340, 8, 1294, 63, 1842, 304, 288, 2746, 63, 1507, 275, 2069, 8, 500, 2447, 6833, 288, 9048, 63, 1507, 275, 2069, 8, 928, 2447, 6833, 288, 340, 486, 3685, 63, 521, 450, 499, 508, 378, 26, 355, 2653, 275, 2746, 63, 1507, 446, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 288, 587, 26, 355, 2653, 275, 9048, 63, 1507, 435, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 339, 587, 26, 267, 2653, 275, 2069, 8, 71, 3685, 63, 521, 2447, 6833, 339, 372, 2653, 421, 199, 318, 11482, 63, 460, 63, 2573, 63, 509, 63, 13207, 8, 3248, 63, 396, 12, 1950, 12, 1343, 12, 1284, 12, 11609, 12, 7151, 12, 3715, 63, 1842, 29, 797, 304, 272, 408, 2043, 961, 911, 11482, 282, 1329, 402, 900, 2393, 370, 314, 2741, 1950, 14, 2779, 911, 2066, 4868, 626, 314, 5226, 2043, 3233, 365, 10302, 315, 314, 5827, 5982, 402, 900, 14, 2043, 520, 635, 4137, 63, 396, 26, 221, 30110, 17967, 4137, 2295, 2043, 520, 635, 1950, 26, 8113, 370, 1218, 314, 9715, 641, 14, 2043, 520, 635, 1343, 26, 29893, 3914, 402, 1425, 14, 2043, 520, 635, 1284, 26, 4949, 529, 3914, 402, 314, 900, 1425, 2043, 520, 635, 11609, 26, 435, 17, 12, 503, 446, 17, 2043, 520, 635, 7151, 26, 2948, 367, 9679, 280, 4375, 12, 5198, 367, 21131, 2043, 520, 635, 3715, 63, 1842, 26, 715, 370, 3715, 314, 1425, 3382, 11609, 316, 436, 477, 4062, 316, 14, 2043, 408, 339, 327, 21107, 1785, 5548, 367, 15161, 3233, 465, 9709, 503, 9413, 272, 9413, 63, 11948, 275, 942, 272, 9709, 63, 11948, 275, 942, 339, 327, 11482, 900, 2393, 543, 7750, 25870, 272, 367, 486, 3685, 63, 521, 315, 1425, 8, 928, 12, 1284, 12, 11609, 304, 267, 2653, 275, 664, 63, 2593, 8, 71, 3685, 63, 521, 12, 1343, 12, 1284, 12, 7151, 12, 3715, 63, 1842, 9, 267, 3233, 275, 22287, 2806, 8, 2593, 9, 267, 1950, 14, 981, 63, 7414, 8, 2593, 12, 3233, 14, 15195, 9, 267, 9413, 63, 11948, 14, 740, 8, 3058, 9, 339, 327, 3618, 367, 1006, 314, 13484, 4568, 543, 314, 900, 2393, 370, 506, 10302, 272, 1830, 822, 8, 6455, 63, 11948, 9, 365, 440, 378, 26, 267, 367, 3233, 315, 9413, 63, 11948, 26, 288, 340, 3233, 14, 10274, 63, 5350, 7620, 837, 355, 9413, 63, 11948, 14, 2168, 8, 3058, 9, 355, 9709, 63, 11948, 14, 740, 8, 3058, 9, 267, 900, 14, 4532, 13417, 17, 9, 339, 327, 4868, 2985, 787, 1006, 2797, 1771, 315, 282, 900, 590, 32285, 272, 367, 3233, 315, 9709, 63, 11948, 26, 267, 4137, 63, 396, 14, 7904, 8, 3058, 14, 2062, 63, 2573, 12, 3233, 14, 362, 63, 2573, 63, 521, 1062, 5762, 15856, 17, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Skullmonkey/IPS-Syntax
html_completions.py
13
10848
import sublime, sublime_plugin import re def match(rex, str): m = rex.match(str) if m: return m.group(0) else: return None # This responds to on_query_completions, but conceptually it's expanding # expressions, rather than completing words. # # It expands these simple expressions: # tag.class # tag#id class HtmlCompletions(sublime_plugin.EventListener): def on_query_completions(self, view, prefix, locations): # Only trigger within HTML if not view.match_selector(locations[0], "text.html - source - meta.tag, punctuation.definition.tag.begin"): return [] # Get the contents of each line, from the beginning of the line to # each point lines = [view.substr(sublime.Region(view.line(l).a, l)) for l in locations] # Reverse the contents of each line, to simulate having the regex # match backwards lines = [l[::-1] for l in lines] # Check the first location looks like an expression rex = re.compile("([\w-]+)([.#])(\w+)") expr = match(rex, lines[0]) if not expr: return [] # Ensure that all other lines have identical expressions for i in xrange(1, len(lines)): ex = match(rex, lines[i]) if ex != expr: return [] # Return the completions arg, op, tag = rex.match(expr).groups() arg = arg[::-1] tag = tag[::-1] expr = expr[::-1] if op == '.': snippet = "<{0} class=\"{1}\">$1</{0}>$0".format(tag, arg) else: snippet = "<{0} id=\"{1}\">$1</{0}>$0".format(tag, arg) return [(expr, snippet)] # Provide completions that match just after typing an opening angle bracket class TagCompletions(sublime_plugin.EventListener): def on_query_completions(self, view, prefix, locations): # Only trigger within HTML if not view.match_selector(locations[0], "text.html - source"): return [] pt = locations[0] - len(prefix) - 1 ch = view.substr(sublime.Region(pt, pt + 1)) if ch != '<': return [] return ([ ("a\tTag", "a href=\"$1\">$2</a>"), ("abbr\tTag", "abbr>$1</abbr>"), ("acronym\tTag", "acronym>$1</acronym>"), ("address\tTag", "address>$1</address>"), ("applet\tTag", "applet>$1</applet>"), ("area\tTag", "area>$1</area>"), ("b\tTag", "b>$1</b>"), ("base\tTag", "base>$1</base>"), ("big\tTag", "big>$1</big>"), ("blockquote\tTag", "blockquote>$1</blockquote>"), ("body\tTag", "body>$1</body>"), ("button\tTag", "button>$1</button>"), ("center\tTag", "center>$1</center>"), ("caption\tTag", "caption>$1</caption>"), ("cdata\tTag", "cdata>$1</cdata>"), ("cite\tTag", "cite>$1</cite>"), ("col\tTag", "col>$1</col>"), ("colgroup\tTag", "colgroup>$1</colgroup>"), ("code\tTag", "code>$1</code>"), ("div\tTag", "div>$1</div>"), ("dd\tTag", "dd>$1</dd>"), ("del\tTag", "del>$1</del>"), ("dfn\tTag", "dfn>$1</dfn>"), ("dl\tTag", "dl>$1</dl>"), ("dt\tTag", "dt>$1</dt>"), ("em\tTag", "em>$1</em>"), ("fieldset\tTag", "fieldset>$1</fieldset>"), ("font\tTag", "font>$1</font>"), ("form\tTag", "form>$1</form>"), ("frame\tTag", "frame>$1</frame>"), ("frameset\tTag", "frameset>$1</frameset>"), ("head\tTag", "head>$1</head>"), ("h1\tTag", "h1>$1</h1>"), ("h2\tTag", "h2>$1</h2>"), ("h3\tTag", "h3>$1</h3>"), ("h4\tTag", "h4>$1</h4>"), ("h5\tTag", "h5>$1</h5>"), ("h6\tTag", "h6>$1</h6>"), ("i\tTag", "i>$1</i>"), ("iframe\tTag", "iframe src=\"$1\"></iframe>"), ("ins\tTag", "ins>$1</ins>"), ("kbd\tTag", "kbd>$1</kbd>"), ("li\tTag", "li>$1</li>"), ("label\tTag", "label>$1</label>"), ("legend\tTag", "legend>$1</legend>"), ("link\tTag", "link rel=\"stylesheet\" type=\"text/css\" href=\"$1\">"), ("map\tTag", "map>$1</map>"), ("noframes\tTag", "noframes>$1</noframes>"), ("object\tTag", "object>$1</object>"), ("ol\tTag", "ol>$1</ol>"), ("optgroup\tTag", "optgroup>$1</optgroup>"), ("option\tTag", "option>$0</option>"), ("p\tTag", "p>$1</p>"), ("pre\tTag", "pre>$1</pre>"), ("span\tTag", "span>$1</span>"), ("samp\tTag", "samp>$1</samp>"), ("script\tTag", "script type=\"${1:text/javascript}\">$0</script>"), ("style\tTag", "style type=\"${1:text/css}\">$0</style>"), ("select\tTag", "select>$1</select>"), ("small\tTag", "small>$1</small>"), ("strong\tTag", "strong>$1</strong>"), ("sub\tTag", "sub>$1</sub>"), ("sup\tTag", "sup>$1</sup>"), ("table\tTag", "table>$1</table>"), ("tbody\tTag", "tbody>$1</tbody>"), ("td\tTag", "td>$1</td>"), ("textarea\tTag", "textarea>$1</textarea>"), ("tfoot\tTag", "tfoot>$1</tfoot>"), ("th\tTag", "th>$1</th>"), ("thead\tTag", "thead>$1</thead>"), ("title\tTag", "title>$1</title>"), ("tr\tTag", "tr>$1</tr>"), ("tt\tTag", "tt>$1</tt>"), ("u\tTag", "u>$1</u>"), ("ul\tTag", "ul>$1</ul>"), ("var\tTag", "var>$1</var>"), ("br\tTag", "br>"), ("embed\tTag", "embed>"), ("hr\tTag", "hr>"), ("img\tTag", "img src=\"$1\">"), ("input\tTag", "input>"), ("meta\tTag", "meta>"), ("param\tTag", "param name=\"$1\" value=\"$2\">"), ("article\tTag", "article>$1</article>"), ("aside\tTag", "aside>$1</aside>"), ("audio\tTag", "audio>$1</audio>"), ("canvas\tTag", "canvas>$1</canvas>"), ("footer\tTag", "footer>$1</footer>"), ("header\tTag", "header>$1</header>"), ("nav\tTag", "nav>$1</nav>"), ("section\tTag", "section>$1</section>"), ("video\tTag", "video>$1</video>"), ("A\tTag", "A HREF=\"$1\">$2</A>"), ("ABBR\tTag", "ABBR>$1</ABBR>"), ("ACRONYM\tTag", "ACRONYM>$1</ACRONYM>"), ("ADDRESS\tTag", "ADDRESS>$1</ADDRESS>"), ("APPLET\tTag", "APPLET>$1</APPLET>"), ("AREA\tTag", "AREA>$1</AREA>"), ("B\tTag", "B>$1</B>"), ("BASE\tTag", "BASE>$1</BASE>"), ("BIG\tTag", "BIG>$1</BIG>"), ("BLOCKQUOTE\tTag", "BLOCKQUOTE>$1</BLOCKQUOTE>"), ("BODY\tTag", "BODY>$1</BODY>"), ("BUTTON\tTag", "BUTTON>$1</BUTTON>"), ("CENTER\tTag", "CENTER>$1</CENTER>"), ("CAPTION\tTag", "CAPTION>$1</CAPTION>"), ("CDATA\tTag", "CDATA>$1</CDATA>"), ("CITE\tTag", "CITE>$1</CITE>"), ("COL\tTag", "COL>$1</COL>"), ("COLGROUP\tTag", "COLGROUP>$1</COLGROUP>"), ("CODE\tTag", "CODE>$1</CODE>"), ("DIV\tTag", "DIV>$1</DIV>"), ("DD\tTag", "DD>$1</DD>"), ("DEL\tTag", "DEL>$1</DEL>"), ("DFN\tTag", "DFN>$1</DFN>"), ("DL\tTag", "DL>$1</DL>"), ("DT\tTag", "DT>$1</DT>"), ("EM\tTag", "EM>$1</EM>"), ("FIELDSET\tTag", "FIELDSET>$1</FIELDSET>"), ("FONT\tTag", "FONT>$1</FONT>"), ("FORM\tTag", "FORM>$1</FORM>"), ("FRAME\tTag", "FRAME>$1</FRAME>"), ("FRAMESET\tTag", "FRAMESET>$1</FRAMESET>"), ("HEAD\tTag", "HEAD>$1</HEAD>"), ("H1\tTag", "H1>$1</H1>"), ("H2\tTag", "H2>$1</H2>"), ("H3\tTag", "H3>$1</H3>"), ("H4\tTag", "H4>$1</H4>"), ("H5\tTag", "H5>$1</H5>"), ("H6\tTag", "H6>$1</H6>"), ("I\tTag", "I>$1</I>"), ("IFRAME\tTag", "IFRAME src=\"$1\"></IFRAME>"), ("INS\tTag", "INS>$1</INS>"), ("KBD\tTag", "KBD>$1</KBD>"), ("LI\tTag", "LI>$1</LI>"), ("LABEL\tTag", "LABEL>$1</LABEL>"), ("LEGEND\tTag", "LEGEND>$1</LEGEND>"), ("LINK\tTag", "LINK>$1</LINK>"), ("MAP\tTag", "MAP>$1</MAP>"), ("NOFRAMES\tTag", "NOFRAMES>$1</NOFRAMES>"), ("OBJECT\tTag", "OBJECT>$1</OBJECT>"), ("OL\tTag", "OL>$1</OL>"), ("OPTGROUP\tTag", "OPTGROUP>$1</OPTGROUP>"), ("OPTION\tTag", "OPTION>$1</OPTION>"), ("P\tTag", "P>$1</P>"), ("PRE\tTag", "PRE>$1</PRE>"), ("SPAN\tTag", "SPAN>$1</SPAN>"), ("SAMP\tTag", "SAMP>$1</SAMP>"), ("SCRIPT\tTag", "SCRIPT TYPE=\"${1:text/javascript}\">$0</SCRIPT>"), ("STYLE\tTag", "STYLE TYPE=\"${1:text/css}\">$0</STYLE>"), ("SELECT\tTag", "SELECT>$1</SELECT>"), ("SMALL\tTag", "SMALL>$1</SMALL>"), ("STRONG\tTag", "STRONG>$1</STRONG>"), ("SUB\tTag", "SUB>$1</SUB>"), ("SUP\tTag", "SUP>$1</SUP>"), ("TABLE\tTag", "TABLE>$1</TABLE>"), ("TBODY\tTag", "TBODY>$1</TBODY>"), ("TD\tTag", "TD>$1</TD>"), ("TEXTAREA\tTag", "TEXTAREA>$1</TEXTAREA>"), ("TFOOT\tTag", "TFOOT>$1</TFOOT>"), ("TH\tTag", "TH>$1</TH>"), ("THEAD\tTag", "THEAD>$1</THEAD>"), ("TITLE\tTag", "TITLE>$1</TITLE>"), ("TR\tTag", "TR>$1</TR>"), ("TT\tTag", "TT>$1</TT>"), ("U\tTag", "U>$1</U>"), ("UL\tTag", "UL>$1</UL>"), ("VAR\tTag", "VAR>$1</VAR>"), ("BR\tTag", "BR>"), ("EMBED\tTag", "EMBED>"), ("HR\tTag", "HR>"), ("IMG\tTag", "IMG SRC=\"$1\">"), ("INPUT\tTag", "INPUT>"), ("META\tTag", "META>"), ("PARAM\tTag", "PARAM NAME=\"$1\" VALUE=\"$2\">)"), ("ARTICLE\tTag", "ARTICLE>$1</ARTICLE>"), ("ASIDE\tTag", "ASIDE>$1</ASIDE>"), ("AUDIO\tTag", "AUDIO>$1</AUDIO>"), ("CANVAS\tTag", "CANVAS>$1</CANVAS>"), ("FOOTER\tTag", "FOOTER>$1</FOOTER>"), ("HEADER\tTag", "HEADER>$1</HEADER>"), ("NAV\tTag", "NAV>$1</NAV>"), ("SECTION\tTag", "SECTION>$1</SECTION>"), ("VIDEO\tTag", "VIDEO>$1</VIDEO>") ], sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
mit
[ 646, 1007, 18687, 12, 1007, 18687, 63, 2718, 199, 646, 295, 199, 199, 318, 1336, 8, 15063, 12, 620, 304, 272, 333, 275, 295, 88, 14, 1431, 8, 495, 9, 272, 340, 333, 26, 267, 372, 333, 14, 923, 8, 16, 9, 272, 587, 26, 267, 372, 488, 199, 199, 3, 961, 9163, 795, 370, 641, 63, 1131, 63, 28832, 12, 1325, 19834, 3163, 652, 1159, 6544, 316, 199, 3, 8455, 12, 7830, 2419, 2831, 1337, 5932, 14, 199, 3, 199, 3, 2779, 1437, 5915, 3520, 3486, 8455, 26, 199, 3, 1947, 14, 533, 199, 3, 1947, 3, 344, 199, 533, 20880, 6600, 852, 8, 954, 18687, 63, 2718, 14, 2390, 10464, 304, 272, 347, 641, 63, 1131, 63, 28832, 8, 277, 12, 2455, 12, 2403, 12, 9918, 304, 267, 327, 5972, 6804, 4453, 4163, 267, 340, 440, 2455, 14, 1431, 63, 6662, 8, 8022, 59, 16, 467, 355, 298, 505, 14, 1360, 446, 1350, 446, 3404, 14, 1450, 12, 22929, 14, 7463, 14, 1450, 14, 5037, 2349, 288, 372, 942, 398, 327, 2372, 314, 4072, 402, 1924, 1004, 12, 687, 314, 9608, 402, 314, 1004, 370, 267, 327, 1924, 2376, 267, 2385, 275, 359, 1345, 14, 22668, 8, 954, 18687, 14, 10708, 8, 1345, 14, 604, 8, 76, 680, 65, 12, 634, 430, 288, 367, 634, 315, 9918, 61, 398, 327, 22734, 314, 4072, 402, 1924, 1004, 12, 370, 20577, 9445, 314, 5163, 267, 327, 1336, 8552, 267, 2385, 275, 359, 76, 14172, 17, 61, 367, 634, 315, 2385, 61, 398, 327, 2670, 314, 1642, 2909, 10734, 2839, 376, 3965, 267, 295, 88, 275, 295, 14, 2014, 480, 16510, 87, 13, 11896, 779, 14, 3, 566, 2961, 87, 11, 6320, 267, 5348, 275, 1336, 8, 15063, 12, 2385, 59, 16, 566, 267, 340, 440, 5348, 26, 288, 372, 942, 398, 327, 7523, 626, 1006, 1163, 2385, 1172, 13130, 8455, 267, 367, 284, 315, 4945, 8, 17, 12, 822, 8, 1278, 2298, 288, 444, 275, 1336, 8, 15063, 12, 2385, 59, 73, 566, 288, 340, 444, 1137, 5348, 26, 355, 372, 942, 398, 327, 1432, 314, 31516, 267, 1680, 12, 1687, 12, 1947, 275, 295, 88, 14, 1431, 8, 3684, 680, 2634, 342, 398, 1680, 275, 1680, 14172, 17, 61, 267, 1947, 275, 1947, 14172, 17, 61, 267, 5348, 275, 5348, 14172, 17, 61, 398, 340, 1687, 508, 26351, 288, 17440, 275, 3886, 91, 16, 93, 1021, 8178, 91, 17, 4988, 1743, 4, 17, 1108, 91, 16, 93, 30, 4, 16, 1674, 908, 8, 1450, 12, 1680, 9, 267, 587, 26, 288, 17440, 275, 3886, 91, 16, 93, 1305, 8178, 91, 17, 4988, 1743, 4, 17, 1108, 91, 16, 93, 30, 4, 16, 1674, 908, 8, 1450, 12, 1680, 9, 398, 372, 3842, 3684, 12, 17440, 1874, 421, 199, 3, 22896, 31516, 626, 1336, 2951, 2410, 14090, 376, 13618, 9324, 14540, 199, 533, 8053, 6600, 852, 8, 954, 18687, 63, 2718, 14, 2390, 10464, 304, 272, 347, 641, 63, 1131, 63, 28832, 8, 277, 12, 2455, 12, 2403, 12, 9918, 304, 267, 327, 5972, 6804, 4453, 4163, 267, 340, 440, 2455, 14, 1431, 63, 6662, 8, 8022, 59, 16, 467, 355, 298, 505, 14, 1360, 446, 1350, 2349, 288, 372, 942, 398, 10063, 275, 9918, 59, 16, 61, 446, 822, 8, 1861, 9, 446, 413, 267, 682, 275, 2455, 14, 22668, 8, 954, 18687, 14, 10708, 8, 541, 12, 10063, 435, 413, 430, 267, 340, 682, 1137, 2650, 356, 288, 372, 942, 398, 372, 7287, 288, 1689, 65, 60, 84, 1931, 401, 298, 65, 4369, 8178, 4, 17, 60, 1743, 4, 18, 1108, 65, 30, 1288, 288, 1689, 20787, 60, 84, 1931, 401, 298, 20787, 30, 4, 17, 1108, 20787, 30, 1288, 288, 1689, 645, 2641, 12828, 60, 84, 1931, 401, 298, 645, 2641, 12828, 30, 4, 17, 1108, 645, 2641, 12828, 30, 1288, 288, 1689, 1562, 60, 84, 1931, 401, 298, 1562, 30, 4, 17, 1108, 1562, 30, 1288, 288, 1689, 571, 2723, 60, 84, 1931, 401, 298, 571, 2723, 30, 4, 17, 1108, 571, 2723, 30, 1288, 288, 1689, 6789, 60, 84, 1931, 401, 298, 6789, 30, 4, 17, 1108, 6789, 30, 1288, 288, 1689, 66, 60, 84, 1931, 401, 298, 66, 30, 4, 17, 1108, 66, 30, 1288, 288, 1689, 1095, 60, 84, 1931, 401, 298, 1095, 30, 4, 17, 1108, 1095, 30, 1288, 288, 1689, 5076, 60, 84, 1931, 401, 298, 5076, 30, 4, 17, 1108, 5076, 30, 1288, 288, 1689, 28623, 60, 84, 1931, 401, 298, 28623, 30, 4, 17, 1108, 28623, 30, 1288, 288, 1689, 2030, 60, 84, 1931, 401, 298, 2030, 30, 4, 17, 1108, 2030, 30, 1288, 288, 1689, 3887, 60, 84, 1931, 401, 298, 3887, 30, 4, 17, 1108, 3887, 30, 1288, 288, 1689, 4218, 60, 84, 1931, 401, 298, 4218, 30, 4, 17, 1108, 4218, 30, 1288, 288, 1689, 13410, 60, 84, 1931, 401, 298, 13410, 30, 4, 17, 1108, 13410, 30, 1288, 288, 1689, 15892, 60, 84, 1931, 401, 298, 15892, 30, 4, 17, 1108, 15892, 30, 1288, 288, 1689, 25171, 60, 84, 1931, 401, 298, 25171, 30, 4, 17, 1108, 25171, 30, 1288, 288, 1689, 761, 60, 84, 1931, 401, 298, 761, 30, 4, 17, 1108, 761, 30, 1288, 288, 1689, 761, 923, 60, 84, 1931, 401, 298, 761, 923, 30, 4, 17, 1108, 761, 923, 30, 1288, 288, 1689, 600, 60, 84, 1931, 401, 298, 600, 30, 4, 17, 1108, 600, 30, 1288, 288, 1689, 3015, 60, 84, 1931, 401, 298, 3015, 30, 4, 17, 1108, 3015, 30, 1288, 288, 1689, 617, 60, 84, 1931, 401, 298, 617, 30, 4, 17, 1108, 617, 30, 1288, 288, 1689, 2264, 60, 84, 1931, 401, 298, 2264, 30, 4, 17, 1108, 2264, 30, 1288, 288, 1689, 1587, 78, 60, 84, 1931, 401, 298, 1587, 78, 30, 4, 17, 1108, 1587, 78, 30, 1288, 288, 1689, 5030, 60, 84, 1931, 401, 298, 5030, 30, 4, 17, 1108, 5030, 30, 1288, 288, 1689, 3583, 60, 84, 1931, 401, 298, 3583, 30, 4, 17, 1108, 3583, 30, 1288, 288, 1689, 5633, 60, 84, 1931, 401, 298, 5633, 30, 4, 17, 1108, 5633, 30, 1288, 288, 1689, 698, 409, 60, 84, 1931, 401, 298, 698, 409, 30, 4 ]
[ 1007, 18687, 12, 1007, 18687, 63, 2718, 199, 646, 295, 199, 199, 318, 1336, 8, 15063, 12, 620, 304, 272, 333, 275, 295, 88, 14, 1431, 8, 495, 9, 272, 340, 333, 26, 267, 372, 333, 14, 923, 8, 16, 9, 272, 587, 26, 267, 372, 488, 199, 199, 3, 961, 9163, 795, 370, 641, 63, 1131, 63, 28832, 12, 1325, 19834, 3163, 652, 1159, 6544, 316, 199, 3, 8455, 12, 7830, 2419, 2831, 1337, 5932, 14, 199, 3, 199, 3, 2779, 1437, 5915, 3520, 3486, 8455, 26, 199, 3, 1947, 14, 533, 199, 3, 1947, 3, 344, 199, 533, 20880, 6600, 852, 8, 954, 18687, 63, 2718, 14, 2390, 10464, 304, 272, 347, 641, 63, 1131, 63, 28832, 8, 277, 12, 2455, 12, 2403, 12, 9918, 304, 267, 327, 5972, 6804, 4453, 4163, 267, 340, 440, 2455, 14, 1431, 63, 6662, 8, 8022, 59, 16, 467, 355, 298, 505, 14, 1360, 446, 1350, 446, 3404, 14, 1450, 12, 22929, 14, 7463, 14, 1450, 14, 5037, 2349, 288, 372, 942, 398, 327, 2372, 314, 4072, 402, 1924, 1004, 12, 687, 314, 9608, 402, 314, 1004, 370, 267, 327, 1924, 2376, 267, 2385, 275, 359, 1345, 14, 22668, 8, 954, 18687, 14, 10708, 8, 1345, 14, 604, 8, 76, 680, 65, 12, 634, 430, 288, 367, 634, 315, 9918, 61, 398, 327, 22734, 314, 4072, 402, 1924, 1004, 12, 370, 20577, 9445, 314, 5163, 267, 327, 1336, 8552, 267, 2385, 275, 359, 76, 14172, 17, 61, 367, 634, 315, 2385, 61, 398, 327, 2670, 314, 1642, 2909, 10734, 2839, 376, 3965, 267, 295, 88, 275, 295, 14, 2014, 480, 16510, 87, 13, 11896, 779, 14, 3, 566, 2961, 87, 11, 6320, 267, 5348, 275, 1336, 8, 15063, 12, 2385, 59, 16, 566, 267, 340, 440, 5348, 26, 288, 372, 942, 398, 327, 7523, 626, 1006, 1163, 2385, 1172, 13130, 8455, 267, 367, 284, 315, 4945, 8, 17, 12, 822, 8, 1278, 2298, 288, 444, 275, 1336, 8, 15063, 12, 2385, 59, 73, 566, 288, 340, 444, 1137, 5348, 26, 355, 372, 942, 398, 327, 1432, 314, 31516, 267, 1680, 12, 1687, 12, 1947, 275, 295, 88, 14, 1431, 8, 3684, 680, 2634, 342, 398, 1680, 275, 1680, 14172, 17, 61, 267, 1947, 275, 1947, 14172, 17, 61, 267, 5348, 275, 5348, 14172, 17, 61, 398, 340, 1687, 508, 26351, 288, 17440, 275, 3886, 91, 16, 93, 1021, 8178, 91, 17, 4988, 1743, 4, 17, 1108, 91, 16, 93, 30, 4, 16, 1674, 908, 8, 1450, 12, 1680, 9, 267, 587, 26, 288, 17440, 275, 3886, 91, 16, 93, 1305, 8178, 91, 17, 4988, 1743, 4, 17, 1108, 91, 16, 93, 30, 4, 16, 1674, 908, 8, 1450, 12, 1680, 9, 398, 372, 3842, 3684, 12, 17440, 1874, 421, 199, 3, 22896, 31516, 626, 1336, 2951, 2410, 14090, 376, 13618, 9324, 14540, 199, 533, 8053, 6600, 852, 8, 954, 18687, 63, 2718, 14, 2390, 10464, 304, 272, 347, 641, 63, 1131, 63, 28832, 8, 277, 12, 2455, 12, 2403, 12, 9918, 304, 267, 327, 5972, 6804, 4453, 4163, 267, 340, 440, 2455, 14, 1431, 63, 6662, 8, 8022, 59, 16, 467, 355, 298, 505, 14, 1360, 446, 1350, 2349, 288, 372, 942, 398, 10063, 275, 9918, 59, 16, 61, 446, 822, 8, 1861, 9, 446, 413, 267, 682, 275, 2455, 14, 22668, 8, 954, 18687, 14, 10708, 8, 541, 12, 10063, 435, 413, 430, 267, 340, 682, 1137, 2650, 356, 288, 372, 942, 398, 372, 7287, 288, 1689, 65, 60, 84, 1931, 401, 298, 65, 4369, 8178, 4, 17, 60, 1743, 4, 18, 1108, 65, 30, 1288, 288, 1689, 20787, 60, 84, 1931, 401, 298, 20787, 30, 4, 17, 1108, 20787, 30, 1288, 288, 1689, 645, 2641, 12828, 60, 84, 1931, 401, 298, 645, 2641, 12828, 30, 4, 17, 1108, 645, 2641, 12828, 30, 1288, 288, 1689, 1562, 60, 84, 1931, 401, 298, 1562, 30, 4, 17, 1108, 1562, 30, 1288, 288, 1689, 571, 2723, 60, 84, 1931, 401, 298, 571, 2723, 30, 4, 17, 1108, 571, 2723, 30, 1288, 288, 1689, 6789, 60, 84, 1931, 401, 298, 6789, 30, 4, 17, 1108, 6789, 30, 1288, 288, 1689, 66, 60, 84, 1931, 401, 298, 66, 30, 4, 17, 1108, 66, 30, 1288, 288, 1689, 1095, 60, 84, 1931, 401, 298, 1095, 30, 4, 17, 1108, 1095, 30, 1288, 288, 1689, 5076, 60, 84, 1931, 401, 298, 5076, 30, 4, 17, 1108, 5076, 30, 1288, 288, 1689, 28623, 60, 84, 1931, 401, 298, 28623, 30, 4, 17, 1108, 28623, 30, 1288, 288, 1689, 2030, 60, 84, 1931, 401, 298, 2030, 30, 4, 17, 1108, 2030, 30, 1288, 288, 1689, 3887, 60, 84, 1931, 401, 298, 3887, 30, 4, 17, 1108, 3887, 30, 1288, 288, 1689, 4218, 60, 84, 1931, 401, 298, 4218, 30, 4, 17, 1108, 4218, 30, 1288, 288, 1689, 13410, 60, 84, 1931, 401, 298, 13410, 30, 4, 17, 1108, 13410, 30, 1288, 288, 1689, 15892, 60, 84, 1931, 401, 298, 15892, 30, 4, 17, 1108, 15892, 30, 1288, 288, 1689, 25171, 60, 84, 1931, 401, 298, 25171, 30, 4, 17, 1108, 25171, 30, 1288, 288, 1689, 761, 60, 84, 1931, 401, 298, 761, 30, 4, 17, 1108, 761, 30, 1288, 288, 1689, 761, 923, 60, 84, 1931, 401, 298, 761, 923, 30, 4, 17, 1108, 761, 923, 30, 1288, 288, 1689, 600, 60, 84, 1931, 401, 298, 600, 30, 4, 17, 1108, 600, 30, 1288, 288, 1689, 3015, 60, 84, 1931, 401, 298, 3015, 30, 4, 17, 1108, 3015, 30, 1288, 288, 1689, 617, 60, 84, 1931, 401, 298, 617, 30, 4, 17, 1108, 617, 30, 1288, 288, 1689, 2264, 60, 84, 1931, 401, 298, 2264, 30, 4, 17, 1108, 2264, 30, 1288, 288, 1689, 1587, 78, 60, 84, 1931, 401, 298, 1587, 78, 30, 4, 17, 1108, 1587, 78, 30, 1288, 288, 1689, 5030, 60, 84, 1931, 401, 298, 5030, 30, 4, 17, 1108, 5030, 30, 1288, 288, 1689, 3583, 60, 84, 1931, 401, 298, 3583, 30, 4, 17, 1108, 3583, 30, 1288, 288, 1689, 5633, 60, 84, 1931, 401, 298, 5633, 30, 4, 17, 1108, 5633, 30, 1288, 288, 1689, 698, 409, 60, 84, 1931, 401, 298, 698, 409, 30, 4, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
minorua/QGIS
python/plugins/processing/algs/grass7/ext/i_smap.py
45
1530
# -*- coding: utf-8 -*- """ *************************************************************************** i_smap.py --------- Date : March 2016 Copyright : (C) 2016 by Médéric Ribreux Email : medspx at medspx dot fr *************************************************************************** * * * 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. * * * *************************************************************************** """ __author__ = 'Médéric Ribreux' __date__ = 'March 2016' __copyright__ = '(C) 2016, Médéric Ribreux' from .i import regroupRasters, importSigFile def processCommand(alg, parameters, context, feedback): # Regroup rasters group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup') # import signature signatureFile = alg.parameterAsString(parameters, 'signaturefile', context) shortSigFile = importSigFile(alg, group, subgroup, signatureFile, 'sigset') parameters['signaturefile'] = shortSigFile # Handle other parameters alg.processCommand(parameters, context, feedback)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 284, 63, 83, 1130, 14, 647, 272, 3001, 13, 272, 6148, 463, 520, 603, 1047, 7800, 272, 1898, 3322, 520, 334, 35, 9, 7800, 701, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 272, 11426, 4483, 520, 562, 68, 681, 88, 737, 562, 68, 681, 88, 6308, 9513, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 45, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 363, 602, 363, 275, 283, 45, 1047, 7800, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 7800, 12, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 199, 504, 1275, 73, 492, 295, 923, 50, 305, 878, 12, 492, 11575, 1173, 421, 199, 318, 2112, 3110, 8, 6731, 12, 2633, 12, 1067, 12, 17145, 304, 272, 327, 799, 923, 519, 305, 878, 272, 1572, 12, 1007, 923, 275, 295, 923, 50, 305, 878, 8, 6731, 12, 2633, 12, 1067, 12, 283, 1210, 297, 283, 923, 297, 283, 954, 923, 358, 339, 327, 492, 4955, 272, 4955, 1173, 275, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 5233, 493, 297, 1067, 9, 272, 3974, 11575, 1173, 275, 492, 11575, 1173, 8, 6731, 12, 1572, 12, 1007, 923, 12, 4955, 1173, 12, 283, 4093, 409, 358, 272, 2633, 459, 5233, 493, 418, 275, 3974, 11575, 1173, 339, 327, 8690, 1163, 2633, 272, 15760, 14, 1412, 3110, 8, 3214, 12, 1067, 12, 17145, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 284, 63, 83, 1130, 14, 647, 272, 3001, 13, 272, 6148, 463, 520, 603, 1047, 7800, 272, 1898, 3322, 520, 334, 35, 9, 7800, 701, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 272, 11426, 4483, 520, 562, 68, 681, 88, 737, 562, 68, 681, 88, 6308, 9513, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 45, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 363, 602, 363, 275, 283, 45, 1047, 7800, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 7800, 12, 603, 5741, 68, 5741, 1567, 820, 1892, 264, 2521, 7, 199, 199, 504, 1275, 73, 492, 295, 923, 50, 305, 878, 12, 492, 11575, 1173, 421, 199, 318, 2112, 3110, 8, 6731, 12, 2633, 12, 1067, 12, 17145, 304, 272, 327, 799, 923, 519, 305, 878, 272, 1572, 12, 1007, 923, 275, 295, 923, 50, 305, 878, 8, 6731, 12, 2633, 12, 1067, 12, 283, 1210, 297, 283, 923, 297, 283, 954, 923, 358, 339, 327, 492, 4955, 272, 4955, 1173, 275, 15760, 14, 5329, 2822, 1558, 8, 3214, 12, 283, 5233, 493, 297, 1067, 9, 272, 3974, 11575, 1173, 275, 492, 11575, 1173, 8, 6731, 12, 1572, 12, 1007, 923, 12, 4955, 1173, 12, 283, 4093, 409, 358, 272, 2633, 459, 5233, 493, 418, 275, 3974, 11575, 1173, 339, 327, 8690, 1163, 2633, 272, 15760, 14, 1412, 3110, 8, 3214, 12, 1067, 12, 17145, 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, 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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an atomic could a symbol, varaiable (and others) pyDatalog.create_atoms('people, alice, bob') # insert a fact + people(alice) # 'people' is a symbol print people # OUT: <pyDatalog.pyParser.Symbol object at 0x93e744c> # declare a variable pyDatalog.create_atoms('X') # query the instances of people print(people(X)) # OUT: [('alice',)] # it's a unary tuple for i in people(X): print i # OUT: ('alice',) # add more instance of people + people(bob) for i in people(X): print i # OUT: ('alice',) # OUT: ('bob',) # you can see from below, an atom may be a symbol or a var # symbol starts with lowercase # var starts with uppercase type(bob) # OUT: <class 'pyDatalog.pyParser.Symbol'> type(people) # OUT: <class 'pyDatalog.pyParser.Symbol'> type(X) # OUT: <class 'pyDatalog.pyDatalog.Variable'> # 'people(x)' is a query! print type(people(X)) # OUT: <class 'pyDatalog.pyParser.Query'> # now test metamodeling: 'people' is both a peridate name and a symbol # This is very RDF-ish and Pythonic # Python is naturally a superset of RDF # Why? Python is Lisp-ish, and the inventor of RDF is the inventor of Lisp pyDatalog.create_atoms('label') # use 'people' as a symbol # remember: previous it's used as a predicate + label(people, 'a person') pyDatalog.create_atoms('Y') print label(X,Y) # OUT: [('people', 'a person')] print label(X,Y)[0] # OUT: ('people', 'a person') # this is a binay tuple # now, we query a predicate name, then construct a query from its result # it's dynamic metamodeling pyDatalog.create_atoms('Z') g=label(X,Y)[0][0] print g # OUT: 'people' # use eval to contruct a query from string print eval(g) # OUT: people print eval(g)(Z) # OUT: [('alice',), ('bob',)]
lgpl-2.1
[ 504, 1134, 36, 12519, 492, 1134, 36, 12519, 199, 3, 5738, 26, 1134, 36, 12519, 1015, 378, 14, 713, 14, 16, 199, 199, 3, 1218, 2005, 14503, 14, 376, 15374, 4293, 282, 5272, 12, 2729, 5789, 461, 334, 460, 11789, 9, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 13562, 12, 741, 1885, 12, 26961, 358, 199, 199, 3, 5518, 282, 10572, 199, 11, 13135, 8, 19179, 9, 199, 199, 3, 283, 13562, 7, 365, 282, 5272, 199, 1361, 13135, 199, 3, 5738, 26, 665, 647, 36, 12519, 14, 647, 2842, 14, 8169, 909, 737, 378, 88, 3129, 69, 15839, 67, 30, 199, 199, 3, 20771, 282, 1750, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 56, 358, 199, 199, 3, 1827, 314, 4454, 402, 13135, 199, 1361, 8, 13562, 8, 56, 430, 199, 3, 5738, 26, 4274, 19179, 297, 1874, 199, 3, 652, 1159, 282, 21603, 2008, 199, 199, 509, 284, 315, 13135, 8, 56, 304, 870, 284, 199, 3, 5738, 26, 661, 19179, 9538, 199, 199, 3, 1050, 1655, 1256, 402, 13135, 199, 11, 13135, 8, 7913, 9, 199, 509, 284, 315, 13135, 8, 56, 304, 870, 284, 199, 3, 5738, 26, 661, 19179, 9538, 199, 3, 5738, 26, 661, 7913, 9538, 199, 199, 3, 1265, 883, 1937, 687, 5084, 12, 376, 6222, 1443, 506, 282, 5272, 503, 282, 2729, 199, 3, 5272, 9174, 543, 12141, 199, 3, 2729, 9174, 543, 22681, 199, 199, 466, 8, 7913, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 8169, 8423, 199, 466, 8, 13562, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 8169, 8423, 199, 466, 8, 56, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 36, 12519, 14, 2773, 8423, 199, 199, 3, 283, 13562, 8, 88, 3171, 365, 282, 1827, 1, 199, 1361, 730, 8, 13562, 8, 56, 430, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 3227, 8423, 199, 199, 3, 3063, 511, 7647, 455, 380, 2983, 26, 283, 13562, 7, 365, 3865, 282, 1126, 344, 323, 536, 436, 282, 5272, 199, 3, 961, 365, 7437, 820, 3888, 13, 2453, 436, 2018, 530, 199, 3, 2018, 365, 13872, 300, 1183, 282, 1613, 409, 402, 820, 3888, 221, 199, 3, 6827, 31, 2018, 365, 491, 27474, 13, 2453, 12, 436, 314, 315, 782, 269, 402, 820, 3888, 365, 314, 315, 782, 269, 402, 491, 27474, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 1302, 358, 199, 3, 675, 283, 13562, 7, 465, 282, 5272, 199, 3, 21027, 26, 4136, 652, 1159, 1202, 465, 282, 11944, 199, 11, 1768, 8, 13562, 12, 283, 65, 4954, 358, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 57, 358, 199, 1361, 1768, 8, 56, 12, 57, 9, 199, 3, 5738, 26, 4274, 13562, 297, 283, 65, 4954, 5440, 199, 1361, 1768, 8, 56, 12, 57, 2788, 16, 61, 199, 3, 5738, 26, 661, 13562, 297, 283, 65, 4954, 358, 199, 3, 642, 365, 282, 2517, 1187, 2008, 199, 199, 3, 3063, 12, 781, 1827, 282, 11944, 536, 12, 2066, 6982, 282, 1827, 687, 2399, 754, 199, 3, 652, 1159, 8336, 7647, 455, 380, 2983, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 58, 358, 199, 199, 71, 29, 1302, 8, 56, 12, 57, 2788, 16, 1527, 16, 61, 199, 1361, 486, 199, 3, 5738, 26, 283, 13562, 7, 199, 199, 3, 675, 3468, 370, 406, 454, 918, 282, 1827, 687, 1059, 199, 1361, 3468, 8, 71, 9, 199, 3, 5738, 26, 13135, 199, 1361, 3468, 8, 71, 5130, 58, 9, 199, 3, 5738, 26, 4274, 19179, 5529, 661, 7913, 297, 1874, 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 ]
[ 1134, 36, 12519, 492, 1134, 36, 12519, 199, 3, 5738, 26, 1134, 36, 12519, 1015, 378, 14, 713, 14, 16, 199, 199, 3, 1218, 2005, 14503, 14, 376, 15374, 4293, 282, 5272, 12, 2729, 5789, 461, 334, 460, 11789, 9, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 13562, 12, 741, 1885, 12, 26961, 358, 199, 199, 3, 5518, 282, 10572, 199, 11, 13135, 8, 19179, 9, 199, 199, 3, 283, 13562, 7, 365, 282, 5272, 199, 1361, 13135, 199, 3, 5738, 26, 665, 647, 36, 12519, 14, 647, 2842, 14, 8169, 909, 737, 378, 88, 3129, 69, 15839, 67, 30, 199, 199, 3, 20771, 282, 1750, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 56, 358, 199, 199, 3, 1827, 314, 4454, 402, 13135, 199, 1361, 8, 13562, 8, 56, 430, 199, 3, 5738, 26, 4274, 19179, 297, 1874, 199, 3, 652, 1159, 282, 21603, 2008, 199, 199, 509, 284, 315, 13135, 8, 56, 304, 870, 284, 199, 3, 5738, 26, 661, 19179, 9538, 199, 199, 3, 1050, 1655, 1256, 402, 13135, 199, 11, 13135, 8, 7913, 9, 199, 509, 284, 315, 13135, 8, 56, 304, 870, 284, 199, 3, 5738, 26, 661, 19179, 9538, 199, 3, 5738, 26, 661, 7913, 9538, 199, 199, 3, 1265, 883, 1937, 687, 5084, 12, 376, 6222, 1443, 506, 282, 5272, 503, 282, 2729, 199, 3, 5272, 9174, 543, 12141, 199, 3, 2729, 9174, 543, 22681, 199, 199, 466, 8, 7913, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 8169, 8423, 199, 466, 8, 13562, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 8169, 8423, 199, 466, 8, 56, 9, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 36, 12519, 14, 2773, 8423, 199, 199, 3, 283, 13562, 8, 88, 3171, 365, 282, 1827, 1, 199, 1361, 730, 8, 13562, 8, 56, 430, 199, 3, 5738, 26, 665, 533, 283, 647, 36, 12519, 14, 647, 2842, 14, 3227, 8423, 199, 199, 3, 3063, 511, 7647, 455, 380, 2983, 26, 283, 13562, 7, 365, 3865, 282, 1126, 344, 323, 536, 436, 282, 5272, 199, 3, 961, 365, 7437, 820, 3888, 13, 2453, 436, 2018, 530, 199, 3, 2018, 365, 13872, 300, 1183, 282, 1613, 409, 402, 820, 3888, 221, 199, 3, 6827, 31, 2018, 365, 491, 27474, 13, 2453, 12, 436, 314, 315, 782, 269, 402, 820, 3888, 365, 314, 315, 782, 269, 402, 491, 27474, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 1302, 358, 199, 3, 675, 283, 13562, 7, 465, 282, 5272, 199, 3, 21027, 26, 4136, 652, 1159, 1202, 465, 282, 11944, 199, 11, 1768, 8, 13562, 12, 283, 65, 4954, 358, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 57, 358, 199, 1361, 1768, 8, 56, 12, 57, 9, 199, 3, 5738, 26, 4274, 13562, 297, 283, 65, 4954, 5440, 199, 1361, 1768, 8, 56, 12, 57, 2788, 16, 61, 199, 3, 5738, 26, 661, 13562, 297, 283, 65, 4954, 358, 199, 3, 642, 365, 282, 2517, 1187, 2008, 199, 199, 3, 3063, 12, 781, 1827, 282, 11944, 536, 12, 2066, 6982, 282, 1827, 687, 2399, 754, 199, 3, 652, 1159, 8336, 7647, 455, 380, 2983, 199, 199, 647, 36, 12519, 14, 981, 63, 11521, 360, 58, 358, 199, 199, 71, 29, 1302, 8, 56, 12, 57, 2788, 16, 1527, 16, 61, 199, 1361, 486, 199, 3, 5738, 26, 283, 13562, 7, 199, 199, 3, 675, 3468, 370, 406, 454, 918, 282, 1827, 687, 1059, 199, 1361, 3468, 8, 71, 9, 199, 3, 5738, 26, 13135, 199, 1361, 3468, 8, 71, 5130, 58, 9, 199, 3, 5738, 26, 4274, 19179, 5529, 661, 7913, 297, 1874, 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, 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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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, 0, 0, 0, 0 ]
ocefpaf/cf_units
cf_units/util.py
2
3978
# (C) British Crown Copyright 2010 - 2019, Met Office # # This file is part of cf-units. # # cf-units 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. # # cf-units 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 cf-units. If not, see <http://www.gnu.org/licenses/>. """ Miscellaneous utility functions. """ from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa from six import with_metaclass import abc try: from collections.abc import Hashable except ImportError: # PY2 from collections import Hashable def approx_equal(a, b, max_absolute_error=1e-10, max_relative_error=1e-10): """ Returns whether two numbers are almost equal, allowing for the finite precision of floating point numbers. """ # Deal with numbers close to zero if abs(a - b) < max_absolute_error: return True # Ensure we get consistent results if "a" and "b" are supplied in the # opposite order. max_ab = max([a, b], key=abs) relative_error = abs(a - b) / max_ab return relative_error < max_relative_error class _MetaOrderedHashable(abc.ABCMeta): """ A metaclass that ensures that non-abstract subclasses of _OrderedHashable without an explicit __init__ method are given a default __init__ method with the appropriate method signature. Also, an _init method is provided to allow subclasses with their own __init__ constructors to initialise their values via an explicit method signature. NB. This metaclass is used to construct the _OrderedHashable class as well as all its subclasses. """ def __new__(cls, name, bases, namespace): # We only want to modify concrete classes that have defined the # "_names" property. if '_names' in namespace and \ not isinstance(namespace['_names'], abc.abstractproperty): args = ', '.join(namespace['_names']) # Ensure the class has a constructor with explicit arguments. if '__init__' not in namespace: # Create a default __init__ method for the class method_source = ('def __init__(self, %s):\n ' 'self._init_from_tuple((%s,))' % (args, args)) exec(method_source, namespace) # Ensure the class has a "helper constructor" with explicit # arguments. if '_init' not in namespace: # Create a default _init method for the class method_source = ('def _init(self, %s):\n ' 'self._init_from_tuple((%s,))' % (args, args)) exec(method_source, namespace) return super(_MetaOrderedHashable, cls).__new__( cls, name, bases, namespace) class _OrderedHashable(with_metaclass(_MetaOrderedHashable, Hashable)): """ Convenience class for creating "immutable", hashable, and ordered classes. Instance identity is defined by the specific list of attribute names declared in the abstract attribute "_names". Subclasses must declare the attribute "_names" as an iterable containing the names of all the attributes relevant to equality/hash-value/ordering. Initial values should be set by using :: self._init(self, value1, value2, ..) .. note:: It's the responsibility of the subclass to ensure that the values of its attributes are themselves hashable. """ pass
lgpl-3.0
[ 3, 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 7129, 446, 20312, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3980, 13, 5260, 14, 199, 3, 199, 3, 3980, 13, 5260, 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, 3980, 13, 5260, 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, 3980, 13, 5260, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 30248, 11420, 3423, 14, 199, 199, 624, 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, 504, 3816, 492, 543, 63, 6577, 199, 646, 13022, 199, 893, 26, 272, 687, 5055, 14, 3175, 492, 16101, 461, 199, 2590, 3545, 26, 272, 327, 7843, 18, 272, 687, 5055, 492, 16101, 461, 421, 199, 318, 14106, 63, 1452, 8, 65, 12, 330, 12, 1390, 63, 6116, 63, 705, 29, 17, 69, 13, 709, 12, 1390, 63, 6188, 63, 705, 29, 17, 69, 13, 709, 304, 272, 408, 272, 1803, 3775, 2877, 5579, 787, 18871, 4472, 12, 17266, 367, 314, 272, 21837, 7151, 402, 8402, 2376, 5579, 14, 339, 408, 272, 327, 1487, 279, 543, 5579, 4002, 370, 4697, 272, 340, 2853, 8, 65, 446, 330, 9, 665, 1390, 63, 6116, 63, 705, 26, 267, 372, 715, 272, 327, 7523, 781, 664, 12137, 2058, 340, 298, 65, 2, 436, 298, 66, 2, 787, 6841, 315, 314, 272, 327, 26912, 1865, 14, 272, 1390, 63, 371, 275, 1390, 779, 65, 12, 330, 467, 790, 29, 2101, 9, 272, 3847, 63, 705, 275, 2853, 8, 65, 446, 330, 9, 1182, 1390, 63, 371, 272, 372, 3847, 63, 705, 665, 1390, 63, 6188, 63, 705, 421, 199, 533, 485, 3396, 22567, 3476, 461, 8, 3175, 14, 22254, 304, 272, 408, 272, 437, 17074, 626, 15620, 626, 2222, 13, 6198, 9180, 402, 485, 22567, 3476, 461, 272, 1928, 376, 5027, 636, 826, 363, 1083, 787, 1627, 282, 849, 636, 826, 363, 1083, 272, 543, 314, 5827, 1083, 4955, 14, 339, 6121, 12, 376, 485, 826, 1083, 365, 2741, 370, 2040, 9180, 543, 3932, 5705, 272, 636, 826, 363, 31604, 370, 2536, 572, 3932, 1338, 4799, 376, 5027, 1083, 272, 4955, 14, 339, 25377, 14, 961, 17074, 365, 1202, 370, 6982, 314, 485, 22567, 3476, 461, 1021, 465, 5521, 272, 465, 1006, 2399, 9180, 14, 339, 408, 339, 347, 636, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3231, 304, 267, 327, 2136, 1454, 2934, 370, 2811, 13801, 3992, 626, 1172, 3247, 314, 267, 327, 2668, 1247, 2, 3324, 14, 267, 340, 2513, 1247, 7, 315, 3231, 436, 971, 355, 440, 1228, 8, 3251, 8680, 1247, 995, 13022, 14, 6198, 1829, 304, 288, 1249, 275, 1656, 1987, 904, 8, 3251, 8680, 1247, 1105, 953, 327, 7523, 314, 1021, 965, 282, 3787, 543, 5027, 2368, 14, 288, 340, 2560, 826, 12217, 440, 315, 3231, 26, 355, 327, 2790, 282, 849, 636, 826, 363, 1083, 367, 314, 1021, 355, 1083, 63, 1365, 275, 661, 318, 636, 826, 721, 277, 12, 450, 83, 17211, 78, 283, 639, 283, 277, 423, 826, 63, 504, 63, 2960, 1332, 5, 83, 4641, 7, 450, 334, 589, 12, 1249, 430, 355, 2146, 8, 765, 63, 1365, 12, 3231, 9, 953, 327, 7523, 314, 1021, 965, 282, 298, 3676, 3787, 2, 543, 5027, 288, 327, 2368, 14, 288, 340, 2513, 826, 7, 440, 315, 3231, 26, 355, 327, 2790, 282, 849, 485, 826, 1083, 367, 314, 1021, 355, 1083, 63, 1365, 275, 661, 318, 485, 826, 8, 277, 12, 450, 83, 17211, 78, 283, 639, 283, 277, 423, 826, 63, 504, 63, 2960, 1332, 5, 83, 4641, 7, 450, 334, 589, 12, 1249, 430, 355, 2146, 8, 765, 63, 1365, 12, 3231, 9, 398, 372, 1613, 1547, 3396, 22567, 3476, 461, 12, 843, 2843, 1222, 721, 288, 843, 12, 536, 12, 9768, 12, 3231, 9, 421, 199, 533, 485, 22567, 3476, 461, 8, 1045, 63, 6577, 1547, 3396, 22567, 3476, 461, 12, 16101, 461, 2298, 272, 408, 272, 1448, 23329, 1021, 367, 6425, 298, 17836, 401, 21197, 12, 436, 7741, 3992, 14, 339, 10066, 8503, 365, 3247, 701, 314, 2488, 769, 402, 2225, 1561, 272, 14290, 315, 314, 9006, 2225, 2668, 1247, 1674, 20196, 1471, 20771, 314, 272, 2225, 2668, 1247, 2, 465, 376, 6076, 3035, 314, 1561, 402, 1006, 314, 272, 3004, 12082, 370, 16612, 15, 2227, 13, 585, 15, 7128, 14, 339, 6026, 1338, 1077, 506, 663, 701, 1808, 3800, 267, 291, 423, 826, 8, 277, 12, 574, 17, 12, 574, 18, 12, 2508, 9, 339, 2508, 5317, 447, 398, 2779, 1159, 314, 9163, 4783, 402, 314, 5516, 370, 4868, 626, 314, 1338, 402, 267, 2399, 3004, 787, 17279, 21197, 14, 339, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 7129, 446, 20312, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3980, 13, 5260, 14, 199, 3, 199, 3, 3980, 13, 5260, 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, 3980, 13, 5260, 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, 3980, 13, 5260, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 30248, 11420, 3423, 14, 199, 199, 624, 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, 504, 3816, 492, 543, 63, 6577, 199, 646, 13022, 199, 893, 26, 272, 687, 5055, 14, 3175, 492, 16101, 461, 199, 2590, 3545, 26, 272, 327, 7843, 18, 272, 687, 5055, 492, 16101, 461, 421, 199, 318, 14106, 63, 1452, 8, 65, 12, 330, 12, 1390, 63, 6116, 63, 705, 29, 17, 69, 13, 709, 12, 1390, 63, 6188, 63, 705, 29, 17, 69, 13, 709, 304, 272, 408, 272, 1803, 3775, 2877, 5579, 787, 18871, 4472, 12, 17266, 367, 314, 272, 21837, 7151, 402, 8402, 2376, 5579, 14, 339, 408, 272, 327, 1487, 279, 543, 5579, 4002, 370, 4697, 272, 340, 2853, 8, 65, 446, 330, 9, 665, 1390, 63, 6116, 63, 705, 26, 267, 372, 715, 272, 327, 7523, 781, 664, 12137, 2058, 340, 298, 65, 2, 436, 298, 66, 2, 787, 6841, 315, 314, 272, 327, 26912, 1865, 14, 272, 1390, 63, 371, 275, 1390, 779, 65, 12, 330, 467, 790, 29, 2101, 9, 272, 3847, 63, 705, 275, 2853, 8, 65, 446, 330, 9, 1182, 1390, 63, 371, 272, 372, 3847, 63, 705, 665, 1390, 63, 6188, 63, 705, 421, 199, 533, 485, 3396, 22567, 3476, 461, 8, 3175, 14, 22254, 304, 272, 408, 272, 437, 17074, 626, 15620, 626, 2222, 13, 6198, 9180, 402, 485, 22567, 3476, 461, 272, 1928, 376, 5027, 636, 826, 363, 1083, 787, 1627, 282, 849, 636, 826, 363, 1083, 272, 543, 314, 5827, 1083, 4955, 14, 339, 6121, 12, 376, 485, 826, 1083, 365, 2741, 370, 2040, 9180, 543, 3932, 5705, 272, 636, 826, 363, 31604, 370, 2536, 572, 3932, 1338, 4799, 376, 5027, 1083, 272, 4955, 14, 339, 25377, 14, 961, 17074, 365, 1202, 370, 6982, 314, 485, 22567, 3476, 461, 1021, 465, 5521, 272, 465, 1006, 2399, 9180, 14, 339, 408, 339, 347, 636, 1222, 721, 1886, 12, 536, 12, 9768, 12, 3231, 304, 267, 327, 2136, 1454, 2934, 370, 2811, 13801, 3992, 626, 1172, 3247, 314, 267, 327, 2668, 1247, 2, 3324, 14, 267, 340, 2513, 1247, 7, 315, 3231, 436, 971, 355, 440, 1228, 8, 3251, 8680, 1247, 995, 13022, 14, 6198, 1829, 304, 288, 1249, 275, 1656, 1987, 904, 8, 3251, 8680, 1247, 1105, 953, 327, 7523, 314, 1021, 965, 282, 3787, 543, 5027, 2368, 14, 288, 340, 2560, 826, 12217, 440, 315, 3231, 26, 355, 327, 2790, 282, 849, 636, 826, 363, 1083, 367, 314, 1021, 355, 1083, 63, 1365, 275, 661, 318, 636, 826, 721, 277, 12, 450, 83, 17211, 78, 283, 639, 283, 277, 423, 826, 63, 504, 63, 2960, 1332, 5, 83, 4641, 7, 450, 334, 589, 12, 1249, 430, 355, 2146, 8, 765, 63, 1365, 12, 3231, 9, 953, 327, 7523, 314, 1021, 965, 282, 298, 3676, 3787, 2, 543, 5027, 288, 327, 2368, 14, 288, 340, 2513, 826, 7, 440, 315, 3231, 26, 355, 327, 2790, 282, 849, 485, 826, 1083, 367, 314, 1021, 355, 1083, 63, 1365, 275, 661, 318, 485, 826, 8, 277, 12, 450, 83, 17211, 78, 283, 639, 283, 277, 423, 826, 63, 504, 63, 2960, 1332, 5, 83, 4641, 7, 450, 334, 589, 12, 1249, 430, 355, 2146, 8, 765, 63, 1365, 12, 3231, 9, 398, 372, 1613, 1547, 3396, 22567, 3476, 461, 12, 843, 2843, 1222, 721, 288, 843, 12, 536, 12, 9768, 12, 3231, 9, 421, 199, 533, 485, 22567, 3476, 461, 8, 1045, 63, 6577, 1547, 3396, 22567, 3476, 461, 12, 16101, 461, 2298, 272, 408, 272, 1448, 23329, 1021, 367, 6425, 298, 17836, 401, 21197, 12, 436, 7741, 3992, 14, 339, 10066, 8503, 365, 3247, 701, 314, 2488, 769, 402, 2225, 1561, 272, 14290, 315, 314, 9006, 2225, 2668, 1247, 1674, 20196, 1471, 20771, 314, 272, 2225, 2668, 1247, 2, 465, 376, 6076, 3035, 314, 1561, 402, 1006, 314, 272, 3004, 12082, 370, 16612, 15, 2227, 13, 585, 15, 7128, 14, 339, 6026, 1338, 1077, 506, 663, 701, 1808, 3800, 267, 291, 423, 826, 8, 277, 12, 574, 17, 12, 574, 18, 12, 2508, 9, 339, 2508, 5317, 447, 398, 2779, 1159, 314, 9163, 4783, 402, 314, 5516, 370, 4868, 626, 314, 1338, 402, 267, 2399, 3004, 787, 17279, 21197, 14, 339, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0 ]
jefftc/changlab
web2py/applications/admin/controllers/wizard.py
2
23288
# -*- coding: utf-8 -*- import os import uuid import re import pickle import urllib import glob from gluon.admin import app_create, plugin_install from gluon.fileutils import abspath, read_file, write_file def reset(session): session.app = { 'name': '', 'params': [('title', 'My New App'), ('subtitle', 'powered by web2py'), ('author', 'you'), ('author_email', 'you@example.com'), ('keywords', ''), ('description', ''), ('layout_theme', 'Default'), ('database_uri', 'sqlite://storage.sqlite'), ('security_key', str(uuid.uuid4())), ('email_server', 'localhost'), ('email_sender', 'you@example.com'), ('email_login', ''), ('login_method', 'local'), ('login_config', ''), ('plugins', [])], 'tables': ['auth_user'], 'table_auth_user': ['username', 'first_name', 'last_name', 'email', 'password'], 'pages': ['index', 'error'], 'page_index': '# Welcome to my new app', 'page_error': '# Error: the document does not exist', } if not session.app: reset(session) def listify(x): if not isinstance(x, (list, tuple)): return x and [x] or [] return x def clean(name): return re.sub('\W+', '_', name.strip().lower()) def index(): response.view = 'wizard/step.html' reset(session) apps = os.listdir(os.path.join(request.folder, '..')) form = SQLFORM.factory(Field('name', requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()])) if form.accepts(request.vars): app = form.vars.name session.app['name'] = app if MULTI_USER_MODE and db(db.app.name == app)(db.app.owner != auth.user.id).count(): session.flash = 'App belongs already to other user' elif app in apps: meta = os.path.normpath( os.path.join(os.path.normpath(request.folder), '..', app, 'wizard.metadata')) if os.path.exists(meta): try: metafile = open(meta, 'rb') try: session.app = pickle.load(metafile) finally: metafile.close() session.flash = T("The app exists, was created by wizard, continue to overwrite!") except: session.flash = T("The app exists, was NOT created by wizard, continue to overwrite!") redirect(URL('step1')) return dict(step='Start', form=form) def step1(): from gluon.contrib.simplejson import loads import urllib if not session.themes: url = LAYOUTS_APP + '/default/layouts.json' try: data = urllib.urlopen(url).read() session.themes = ['Default'] + loads(data)['layouts'] except: session.themes = ['Default'] themes = session.themes if not session.plugins: url = PLUGINS_APP + '/default/plugins.json' try: data = urllib.urlopen(url).read() session.plugins = loads(data)['plugins'] except: session.plugins = [] plugins = [x.split('.')[2] for x in session.plugins] response.view = 'wizard/step.html' params = dict(session.app['params']) form = SQLFORM.factory( Field('title', default=params.get('title', None), requires=IS_NOT_EMPTY()), Field('subtitle', default=params.get('subtitle', None)), Field('author', default=params.get('author', None)), Field( 'author_email', default=params.get('author_email', None)), Field('keywords', default=params.get('keywords', None)), Field('description', 'text', default=params.get('description', None)), Field('layout_theme', requires=IS_IN_SET(themes), default=params.get('layout_theme', themes[0])), Field( 'database_uri', default=params.get('database_uri', None)), Field( 'security_key', default=params.get('security_key', None)), Field( 'email_server', default=params.get('email_server', None)), Field( 'email_sender', default=params.get('email_sender', None)), Field('email_login', default=params.get('email_login', None)), Field('login_method', requires=IS_IN_SET(('local', 'janrain')), default=params.get('login_method', 'local')), Field( 'login_config', default=params.get('login_config', None)), Field('plugins', 'list:string', requires=IS_IN_SET(plugins, multiple=True))) if form.accepts(request.vars): session.app['params'] = [(key, form.vars.get(key, None)) for key, value in session.app['params']] redirect(URL('step2')) return dict(step='1: Setting Parameters', form=form) def step2(): response.view = 'wizard/step.html' form = SQLFORM.factory(Field('table_names', 'list:string', default=session.app['tables'])) if form.accepts(request.vars): table_names = [clean(t) for t in listify(form.vars.table_names) if t.strip()] if [t for t in table_names if t.startswith('auth_') and not t == 'auth_user']: form.error.table_names = \ T('invalid table names (auth_* tables already defined)') else: session.app['tables'] = table_names for table in session.app['tables']: if not 'table_' + table in session.app: session.app['table_' + table] = ['name'] if not table == 'auth_user': name = table + '_manage' if not name in session.app['pages']: session.app['pages'].append(name) session.app['page_' + name] = \ '## Manage %s\n\n{{=form}}' % (table) if session.app['tables']: redirect(URL('step3', args=0)) else: redirect(URL('step4')) return dict(step='2: Tables', form=form) def step3(): response.view = 'wizard/step.html' n = int(request.args(0) or 0) m = len(session.app['tables']) if n >= m: redirect(URL('step2')) table = session.app['tables'][n] form = SQLFORM.factory(Field('field_names', 'list:string', default=session.app.get('table_' + table, []))) if form.accepts(request.vars) and form.vars.field_names: fields = listify(form.vars.field_names) if table == 'auth_user': for field in ['first_name', 'last_name', 'username', 'email', 'password']: if not field in fields: fields.append(field) session.app['table_' + table] = [t.strip().lower() for t in listify(form.vars.field_names) if t.strip()] try: tables = sort_tables(session.app['tables']) except RuntimeError: response.flash = T('invalid circular reference') else: if n < m - 1: redirect(URL('step3', args=n + 1)) else: redirect(URL('step4')) return dict(step='3: Fields for table "%s" (%s of %s)' % (table, n + 1, m), table=table, form=form) def step4(): response.view = 'wizard/step.html' form = SQLFORM.factory(Field('pages', 'list:string', default=session.app['pages'])) if form.accepts(request.vars): session.app['pages'] = [clean(t) for t in listify(form.vars.pages) if t.strip()] if session.app['pages']: redirect(URL('step5', args=0)) else: redirect(URL('step6')) return dict(step='4: Pages', form=form) def step5(): response.view = 'wizard/step.html' n = int(request.args(0) or 0) m = len(session.app['pages']) if n >= m: redirect(URL('step4')) page = session.app['pages'][n] markmin_url = 'http://web2py.com/examples/static/markmin.html' form = SQLFORM.factory(Field('content', 'text', default=session.app.get('page_' + page, []), comment=A('use markmin', _href=markmin_url, _target='_blank')), formstyle='table2cols') if form.accepts(request.vars): session.app['page_' + page] = form.vars.content if n < m - 1: redirect(URL('step5', args=n + 1)) else: redirect(URL('step6')) return dict(step='5: View for page "%s" (%s of %s)' % (page, n + 1, m), form=form) def step6(): response.view = 'wizard/step.html' params = dict(session.app['params']) app = session.app['name'] form = SQLFORM.factory( Field('generate_model', 'boolean', default=True), Field('generate_controller', 'boolean', default=True), Field('generate_views', 'boolean', default=True), Field('generate_menu', 'boolean', default=True), Field('apply_layout', 'boolean', default=True), Field('erase_database', 'boolean', default=True), Field('populate_database', 'boolean', default=True)) if form.accepts(request.vars): if DEMO_MODE: session.flash = T('Application cannot be generated in demo mode') redirect(URL('index')) create(form.vars) session.flash = 'Application %s created' % app redirect(URL('generated')) return dict(step='6: Generate app "%s"' % app, form=form) def generated(): return dict(app=session.app['name']) def sort_tables(tables): import re regex = re.compile('(%s)' % '|'.join(tables)) is_auth_user = 'auth_user' in tables d = {} for table in tables: d[table] = [] for field in session.app['table_%s' % table]: d[table] += regex.findall(field) tables = [] if is_auth_user: tables.append('auth_user') def append(table, trail=[]): if table in trail: raise RuntimeError for t in d[table]: # if not t==table: (problem, no dropdown for self references) append(t, trail=trail + [table]) if not table in tables: tables.append(table) for table in d: append(table) return tables def make_table(table, fields): rawtable = table if table != 'auth_user': table = 't_' + table s = '' s += '\n' + '#' * 40 + '\n' s += "db.define_table('%s',\n" % table first_field = 'id' for field in fields: items = [x.lower() for x in field.split()] has = {} keys = [] for key in ['notnull', 'unique', 'integer', 'double', 'boolean', 'float', 'boolean', 'date', 'time', 'datetime', 'text', 'wiki', 'html', 'file', 'upload', 'image', 'true', 'hidden', 'readonly', 'writeonly', 'multiple', 'notempty', 'required']: if key in items[1:]: keys.append(key) has[key] = True tables = session.app['tables'] refs = [t for t in tables if t in items] items = items[:1] + [x for x in items[1:] if not x in keys and not x in tables] barename = name = '_'.join(items) if table[:2] == 't_': name = 'f_' + name if first_field == 'id': first_field = name ### determine field type ftype = 'string' deftypes = {'integer': 'integer', 'double': 'double', 'boolean': 'boolean', 'float': 'double', 'bool': 'boolean', 'date': 'date', 'time': 'time', 'datetime': 'datetime', 'text': 'text', 'file': 'upload', 'image': 'upload', 'upload': 'upload', 'wiki': 'text', 'html': 'text'} for key, t in deftypes.items(): if key in has: ftype = t if refs: key = refs[0] if not key == 'auth_user': key = 't_' + key if 'multiple' in has: ftype = 'list:reference %s' % key else: ftype = 'reference %s' % key if ftype == 'string' and 'multiple' in has: ftype = 'list:string' elif ftype == 'integer' and 'multiple' in has: ftype = 'list:integer' elif name == 'password': ftype = 'password' s += " Field('%s', type='%s'" % (name, ftype) ### determine field attributes if 'notnull' in has or 'notempty' in has or 'required' in has: s += ', notnull=True' if 'unique' in has: s += ', unique=True' if ftype == 'boolean' and 'true' in has: s += ",\n default=True" ### determine field representation elif 'wiki' in has: s += ",\n represent=lambda x, row: MARKMIN(x)" s += ",\n comment='WIKI (markmin)'" elif 'html' in has: s += ",\n represent=lambda x, row: XML(x,sanitize=True)" s += ",\n comment='HTML (sanitized)'" ### determine field access if name == 'password' or 'writeonly' in has: s += ",\n readable=False" elif 'hidden' in has: s += ",\n writable=False, readable=False" elif 'readonly' in has: s += ",\n writable=False" ### make up a label s += ",\n label=T('%s')),\n" % \ ' '.join(x.capitalize() for x in barename.split('_')) if table == 'auth_user': s += " Field('created_on','datetime',default=request.now,\n" s += " label=T('Created On'),writable=False,readable=False),\n" s += " Field('modified_on','datetime',default=request.now,\n" s += " label=T('Modified On'),writable=False,readable=False,\n" s += " update=request.now),\n" s += " Field('registration_key',default='',\n" s += " writable=False,readable=False),\n" s += " Field('reset_password_key',default='',\n" s += " writable=False,readable=False),\n" s += " Field('registration_id',default='',\n" s += " writable=False,readable=False),\n" elif 'auth_user' in session.app['tables']: s += " auth.signature,\n" s += " format='%(" + first_field + ")s',\n" s += " migrate=settings.migrate)\n\n" if table == 'auth_user': s += """ db.auth_user.first_name.requires = IS_NOT_EMPTY( error_message=auth.messages.is_empty) db.auth_user.last_name.requires = IS_NOT_EMPTY( error_message=auth.messages.is_empty) db.auth_user.password.requires = CRYPT( key=auth.settings.hmac_key, min_length=4) db.auth_user.username.requires = IS_NOT_IN_DB(db, db.auth_user.username) db.auth_user.email.requires = ( IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db, db.auth_user.email)) """ else: s += "db.define_table('%s_archive',db.%s,Field('current_record','reference %s',readable=False,writable=False))\n" % (table, table, table) return s def fix_db(filename): params = dict(session.app['params']) content = read_file(filename, 'rb') if 'auth_user' in session.app['tables']: auth_user = make_table('auth_user', session.app['table_auth_user']) content = content.replace('sqlite://storage.sqlite', params['database_uri']) content = content.replace('auth.define_tables()', auth_user + 'auth.define_tables(migrate = settings.migrate)') content += """ mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login """ if params['login_method'] == 'janrain': content += """ from gluon.contrib.login_methods.rpx_account import RPXAccount auth.settings.actions_disabled=['register','change_password', 'request_reset_password'] auth.settings.login_form = RPXAccount(request, api_key = settings.login_config.split(':')[-1], domain = settings.login_config.split(':')[0], url = "http://%s/%s/default/user/login" % (request.env.http_host,request.application)) """ write_file(filename, content, 'wb') def make_menu(pages): s = '' s += 'response.title = settings.title\n' s += 'response.subtitle = settings.subtitle\n' s += "response.meta.author = '%(author)s <%(author_email)s>' % settings\n" s += 'response.meta.keywords = settings.keywords\n' s += 'response.meta.description = settings.description\n' s += 'response.menu = [\n' for page in pages: if not page.startswith('error'): if page.endswith('_manage'): page_name = page[:-7] else: page_name = page page_name = ' '.join(x.capitalize() for x in page_name.split('_')) s += "(T('%s'),URL('default','%s')==URL(),URL('default','%s'),[]),\n" \ % (page_name, page, page) s += ']' return s def make_page(page, contents): if 'auth_user' in session.app['tables'] and not page in ('index', 'error'): s = "@auth.requires_login()\ndef %s():\n" % page else: s = "def %s():\n" % page items = page.rsplit('_', 1) if items[0] in session.app['tables'] and len(items) == 2 and items[1] == 'manage': s += " form = SQLFORM.smartgrid(db.t_%s,onupdate=auth.archive)\n" % items[0] s += " return locals()\n\n" else: s += " return dict()\n\n" return s def make_view(page, contents): s = "{{extend 'layout.html'}}\n\n" s += str(MARKMIN(contents)) return s def populate(tables): s = 'from gluon.contrib.populate import populate\n' s += 'if db(db.auth_user).isempty():\n' for table in sort_tables(tables): t = table == 'auth_user' and 'auth_user' or 't_' + table s += " populate(db.%s,10)\n" % t return s def create(options): if DEMO_MODE: session.flash = T('disabled in demo mode') redirect(URL('step6')) params = dict(session.app['params']) app = session.app['name'] if app_create(app, request, force=True, key=params['security_key']): if MULTI_USER_MODE: db.app.insert(name=app, owner=auth.user.id) else: session.flash = 'Failure to create application' redirect(URL('step6')) ### save metadata in newapp/wizard.metadata try: meta = os.path.join(request.folder, '..', app, 'wizard.metadata') file = open(meta, 'wb') pickle.dump(session.app, file) file.close() except IOError: session.flash = 'Failure to write wizard metadata' redirect(URL('step6')) ### apply theme if options.apply_layout and params['layout_theme'] != 'Default': try: fn = 'web2py.plugin.layout_%s.w2p' % params['layout_theme'] theme = urllib.urlopen( LAYOUTS_APP + '/static/plugin_layouts/plugins/' + fn) plugin_install(app, theme, request, fn) except: session.flash = T("unable to download layout") ### apply plugins for plugin in params['plugins']: try: plugin_name = 'web2py.plugin.' + plugin + '.w2p' stream = urllib.urlopen(PLUGINS_APP + '/static/' + plugin_name) plugin_install(app, stream, request, plugin_name) except Exception, e: session.flash = T("unable to download plugin: %s" % plugin) ### write configuration file into newapp/models/0.py model = os.path.join(request.folder, '..', app, 'models', '0.py') file = open(model, 'wb') try: file.write("from gluon.storage import Storage\n") file.write("settings = Storage()\n\n") file.write("settings.migrate = True\n") for key, value in session.app['params']: file.write("settings.%s = %s\n" % (key, repr(value))) finally: file.close() ### write configuration file into newapp/models/menu.py if options.generate_menu: model = os.path.join(request.folder, '..', app, 'models', 'menu.py') file = open(model, 'wb') try: file.write(make_menu(session.app['pages'])) finally: file.close() ### customize the auth_user table model = os.path.join(request.folder, '..', app, 'models', 'db.py') fix_db(model) ### create newapp/models/db_wizard.py if options.generate_model: model = os.path.join( request.folder, '..', app, 'models', 'db_wizard.py') file = open(model, 'wb') try: file.write('### we prepend t_ to tablenames and f_ to fieldnames for disambiguity\n\n') tables = sort_tables(session.app['tables']) for table in tables: if table == 'auth_user': continue file.write(make_table(table, session.app['table_' + table])) finally: file.close() model = os.path.join(request.folder, '..', app, 'models', 'db_wizard_populate.py') if os.path.exists(model): os.unlink(model) if options.populate_database and session.app['tables']: file = open(model, 'wb') try: file.write(populate(session.app['tables'])) finally: file.close() ### create newapp/controllers/default.py if options.generate_controller: controller = os.path.join( request.folder, '..', app, 'controllers', 'default.py') file = open(controller, 'wb') try: file.write("""# -*- coding: utf-8 -*- ### required - do no delete def user(): return dict(form=auth()) def download(): return response.download(request,db) def call(): return service() ### end requires """) for page in session.app['pages']: file.write( make_page(page, session.app.get('page_' + page, ''))) finally: file.close() ### create newapp/views/default/*.html if options.generate_views: for page in session.app['pages']: view = os.path.join( request.folder, '..', app, 'views', 'default', page + '.html') file = open(view, 'wb') try: file.write( make_view(page, session.app.get('page_' + page, ''))) finally: file.close() if options.erase_database: path = os.path.join(request.folder, '..', app, 'databases', '*') for file in glob.glob(path): os.unlink(file)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 646, 5377, 199, 646, 295, 199, 646, 5927, 199, 646, 4011, 199, 646, 5739, 199, 504, 26752, 14, 2113, 492, 1145, 63, 981, 12, 3589, 63, 3174, 199, 504, 26752, 14, 493, 1208, 492, 19529, 12, 1586, 63, 493, 12, 2218, 63, 493, 421, 199, 318, 5305, 8, 1730, 304, 272, 2351, 14, 571, 275, 469, 267, 283, 354, 356, 3260, 267, 283, 1162, 356, 4274, 1213, 297, 283, 5713, 7053, 4693, 659, 673, 661, 14348, 297, 283, 555, 21221, 701, 3330, 18, 647, 659, 673, 661, 2502, 297, 283, 13297, 659, 673, 661, 2502, 63, 2123, 297, 283, 13297, 32, 2694, 14, 957, 659, 673, 661, 7511, 297, 9929, 673, 661, 1802, 297, 9929, 673, 661, 4209, 63, 7915, 297, 283, 2698, 659, 673, 661, 4659, 63, 2302, 297, 283, 10659, 921, 3494, 14, 10659, 659, 673, 661, 4416, 63, 498, 297, 620, 8, 2580, 14, 2580, 20, 22606, 673, 661, 2123, 63, 1000, 297, 283, 5967, 659, 673, 661, 2123, 63, 8114, 297, 283, 13297, 32, 2694, 14, 957, 659, 673, 661, 2123, 63, 2886, 297, 9929, 673, 661, 2886, 63, 765, 297, 283, 1832, 659, 673, 661, 2886, 63, 888, 297, 9929, 673, 661, 5265, 297, 3073, 467, 267, 283, 5987, 356, 788, 1178, 63, 751, 995, 267, 283, 1224, 63, 1178, 63, 751, 356, 788, 2473, 297, 283, 2246, 63, 354, 297, 1169, 283, 2019, 63, 354, 297, 283, 2123, 297, 283, 2060, 995, 267, 283, 5856, 356, 788, 1080, 297, 283, 705, 995, 267, 283, 1606, 63, 1080, 356, 3943, 644, 14628, 370, 3002, 892, 1145, 297, 267, 283, 1606, 63, 705, 356, 3943, 4520, 26, 314, 2213, 1630, 440, 2187, 297, 272, 789, 199, 199, 692, 440, 2351, 14, 571, 26, 272, 5305, 8, 1730, 9, 421, 199, 318, 769, 2021, 8, 88, 304, 272, 340, 440, 1228, 8, 88, 12, 334, 513, 12, 2008, 2298, 267, 372, 671, 436, 359, 88, 61, 503, 942, 272, 372, 671, 421, 199, 318, 3633, 8, 354, 304, 272, 372, 295, 14, 954, 2258, 55, 7386, 25469, 536, 14, 1913, 1252, 2325, 1012, 421, 199, 318, 1478, 837, 272, 1177, 14, 1345, 275, 283, 9819, 15, 2926, 14, 1360, 7, 272, 5305, 8, 1730, 9, 272, 8686, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 1069, 14, 3741, 12, 11541, 1333, 272, 1824, 275, 5385, 3516, 14, 3702, 8, 792, 360, 354, 297, 5074, 1524, 1311, 63, 4609, 63, 13993, 1062, 8962, 2281, 63, 748, 9791, 879, 2639, 18082, 342, 2459, 272, 340, 1824, 14, 27692, 8, 1069, 14, 2936, 304, 267, 1145, 275, 1824, 14, 2936, 14, 354, 267, 2351, 14, 571, 459, 354, 418, 275, 1145, 267, 340, 24895, 41, 63, 3791, 63, 6963, 436, 1592, 8, 697, 14, 571, 14, 354, 508, 1145, 5130, 697, 14, 571, 14, 4597, 1137, 1790, 14, 751, 14, 344, 680, 835, 837, 288, 2351, 14, 11331, 275, 283, 2640, 15006, 2575, 370, 1163, 922, 7, 267, 916, 1145, 315, 8686, 26, 288, 3404, 275, 747, 14, 515, 14, 9267, 8, 355, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 9267, 8, 1069, 14, 3741, 395, 2490, 19155, 1145, 12, 283, 9819, 14, 2343, 1333, 288, 340, 747, 14, 515, 14, 2444, 8, 2024, 304, 355, 862, 26, 490, 3404, 493, 275, 1551, 8, 2024, 12, 283, 4848, 358, 490, 862, 26, 717, 2351, 14, 571, 275, 5927, 14, 912, 8, 2024, 493, 9, 490, 3753, 26, 717, 3404, 493, 14, 1600, 342, 490, 2351, 14, 11331, 275, 377, 480, 1918, 1145, 3495, 12, 1990, 2737, 701, 12262, 12, 1980, 370, 8970, 9124, 355, 871, 26, 490, 2351, 14, 11331, 275, 377, 480, 1918, 1145, 3495, 12, 1990, 2845, 2737, 701, 12262, 12, 1980, 370, 8970, 9124, 267, 4660, 8, 2632, 360, 2926, 17, 1333, 272, 372, 1211, 8, 2926, 534, 3162, 297, 1824, 29, 964, 9, 421, 199, 318, 3650, 17, 837, 272, 687, 26752, 14, 2828, 14, 4129, 1001, 492, 14404, 272, 492, 4011, 272, 340, 440, 2351, 14, 23900, 26, 267, 1166, 275, 491, 3448, 1877, 51, 63, 7121, 435, 1994, 885, 15, 4209, 83, 14, 1001, 7, 267, 862, 26, 288, 666, 275, 4011, 14, 10890, 8, 633, 680, 739, 342, 288, 2351, 14, 23900, 275, 788, 2698, 418, 435, 14404, 8, 576, 11820, 4209, 83, 418, 267, 871, 26, 288, 2351, 14, 23900, 275, 788, 2698, 418, 272, 17915, 275, 2351, 14, 23900, 272, 340, 440, 2351, 14, 5265, 26, 267, 1166, 275, 10092, 10134, 10789, 63, 7121, 435, 1994, 885, 15, 5265, 14, 1001, 7, 267, 862, 26, 288, 666, 275, 4011, 14, 10890, 8, 633, 680, 739, 342, 288, 2351, 14, 5265, 275, 14404, 8, 576, 11820, 5265, 418, 267, 871, 26, 288, 2351, 14, 5265, 275, 942, 272, 8963, 275, 359, 88, 14, 1294, 19237, 18, 61, 367, 671, 315, 2351, 14, 5265, 61, 272, 1177, 14, 1345, 275, 283, 9819, 15, 2926, 14, 1360, 7, 272, 1862, 275, 1211, 8, 1730, 14, 571, 459, 1162, 1105, 272, 1824, 275, 5385, 3516, 14, 3702, 8, 267, 5024, 360, 1213, 297, 849, 29, 1162, 14, 362, 360, 1213, 297, 488, 395, 1598, 5074, 29, 1311, 63, 4609, 63, 13993, 4000, 267, 5024, 360, 14348, 297, 849, 29, 1162, 14, 362, 360, 14348, 297, 488, 1826, 267, 5024, 360, 2502, 297, 849, 29, 1162, 14, 362, 360, 2502, 297, 488, 1826, 267, 5024, 8, 288, 283, 2502, 63, 2123, 297, 849, 29, 1162, 14, 362, 360, 2502, 63, 2123, 297, 488, 1826, 267, 5024, 360, 7511, 297, 849, 29, 1162, 14, 362, 360, 7511, 297, 488, 1826, 267, 5024, 360, 1802, 297, 283, 505, 297, 1598, 849, 29, 1162, 14, 362, 360, 1802, 297, 488, 1826, 267, 5024, 360, 4209, 63, 7915, 297, 5074, 29, 1311, 63, 568, 63, 3597, 8, 23900, 395, 1598, 849, 29, 1162, 14, 362, 360, 4209, 63, 7915, 297, 17915, 59, 16, 12884, 267, 5024, 8, 288, 283, 4659, 63, 2302, 297, 849, 29, 1162, 14, 362, 360, 4659, 63, 2302, 297, 488, 1826, 267, 5024, 8, 288, 283, 4416, 63, 498, 297, 849 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 646, 5377, 199, 646, 295, 199, 646, 5927, 199, 646, 4011, 199, 646, 5739, 199, 504, 26752, 14, 2113, 492, 1145, 63, 981, 12, 3589, 63, 3174, 199, 504, 26752, 14, 493, 1208, 492, 19529, 12, 1586, 63, 493, 12, 2218, 63, 493, 421, 199, 318, 5305, 8, 1730, 304, 272, 2351, 14, 571, 275, 469, 267, 283, 354, 356, 3260, 267, 283, 1162, 356, 4274, 1213, 297, 283, 5713, 7053, 4693, 659, 673, 661, 14348, 297, 283, 555, 21221, 701, 3330, 18, 647, 659, 673, 661, 2502, 297, 283, 13297, 659, 673, 661, 2502, 63, 2123, 297, 283, 13297, 32, 2694, 14, 957, 659, 673, 661, 7511, 297, 9929, 673, 661, 1802, 297, 9929, 673, 661, 4209, 63, 7915, 297, 283, 2698, 659, 673, 661, 4659, 63, 2302, 297, 283, 10659, 921, 3494, 14, 10659, 659, 673, 661, 4416, 63, 498, 297, 620, 8, 2580, 14, 2580, 20, 22606, 673, 661, 2123, 63, 1000, 297, 283, 5967, 659, 673, 661, 2123, 63, 8114, 297, 283, 13297, 32, 2694, 14, 957, 659, 673, 661, 2123, 63, 2886, 297, 9929, 673, 661, 2886, 63, 765, 297, 283, 1832, 659, 673, 661, 2886, 63, 888, 297, 9929, 673, 661, 5265, 297, 3073, 467, 267, 283, 5987, 356, 788, 1178, 63, 751, 995, 267, 283, 1224, 63, 1178, 63, 751, 356, 788, 2473, 297, 283, 2246, 63, 354, 297, 1169, 283, 2019, 63, 354, 297, 283, 2123, 297, 283, 2060, 995, 267, 283, 5856, 356, 788, 1080, 297, 283, 705, 995, 267, 283, 1606, 63, 1080, 356, 3943, 644, 14628, 370, 3002, 892, 1145, 297, 267, 283, 1606, 63, 705, 356, 3943, 4520, 26, 314, 2213, 1630, 440, 2187, 297, 272, 789, 199, 199, 692, 440, 2351, 14, 571, 26, 272, 5305, 8, 1730, 9, 421, 199, 318, 769, 2021, 8, 88, 304, 272, 340, 440, 1228, 8, 88, 12, 334, 513, 12, 2008, 2298, 267, 372, 671, 436, 359, 88, 61, 503, 942, 272, 372, 671, 421, 199, 318, 3633, 8, 354, 304, 272, 372, 295, 14, 954, 2258, 55, 7386, 25469, 536, 14, 1913, 1252, 2325, 1012, 421, 199, 318, 1478, 837, 272, 1177, 14, 1345, 275, 283, 9819, 15, 2926, 14, 1360, 7, 272, 5305, 8, 1730, 9, 272, 8686, 275, 747, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 1069, 14, 3741, 12, 11541, 1333, 272, 1824, 275, 5385, 3516, 14, 3702, 8, 792, 360, 354, 297, 5074, 1524, 1311, 63, 4609, 63, 13993, 1062, 8962, 2281, 63, 748, 9791, 879, 2639, 18082, 342, 2459, 272, 340, 1824, 14, 27692, 8, 1069, 14, 2936, 304, 267, 1145, 275, 1824, 14, 2936, 14, 354, 267, 2351, 14, 571, 459, 354, 418, 275, 1145, 267, 340, 24895, 41, 63, 3791, 63, 6963, 436, 1592, 8, 697, 14, 571, 14, 354, 508, 1145, 5130, 697, 14, 571, 14, 4597, 1137, 1790, 14, 751, 14, 344, 680, 835, 837, 288, 2351, 14, 11331, 275, 283, 2640, 15006, 2575, 370, 1163, 922, 7, 267, 916, 1145, 315, 8686, 26, 288, 3404, 275, 747, 14, 515, 14, 9267, 8, 355, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 9267, 8, 1069, 14, 3741, 395, 2490, 19155, 1145, 12, 283, 9819, 14, 2343, 1333, 288, 340, 747, 14, 515, 14, 2444, 8, 2024, 304, 355, 862, 26, 490, 3404, 493, 275, 1551, 8, 2024, 12, 283, 4848, 358, 490, 862, 26, 717, 2351, 14, 571, 275, 5927, 14, 912, 8, 2024, 493, 9, 490, 3753, 26, 717, 3404, 493, 14, 1600, 342, 490, 2351, 14, 11331, 275, 377, 480, 1918, 1145, 3495, 12, 1990, 2737, 701, 12262, 12, 1980, 370, 8970, 9124, 355, 871, 26, 490, 2351, 14, 11331, 275, 377, 480, 1918, 1145, 3495, 12, 1990, 2845, 2737, 701, 12262, 12, 1980, 370, 8970, 9124, 267, 4660, 8, 2632, 360, 2926, 17, 1333, 272, 372, 1211, 8, 2926, 534, 3162, 297, 1824, 29, 964, 9, 421, 199, 318, 3650, 17, 837, 272, 687, 26752, 14, 2828, 14, 4129, 1001, 492, 14404, 272, 492, 4011, 272, 340, 440, 2351, 14, 23900, 26, 267, 1166, 275, 491, 3448, 1877, 51, 63, 7121, 435, 1994, 885, 15, 4209, 83, 14, 1001, 7, 267, 862, 26, 288, 666, 275, 4011, 14, 10890, 8, 633, 680, 739, 342, 288, 2351, 14, 23900, 275, 788, 2698, 418, 435, 14404, 8, 576, 11820, 4209, 83, 418, 267, 871, 26, 288, 2351, 14, 23900, 275, 788, 2698, 418, 272, 17915, 275, 2351, 14, 23900, 272, 340, 440, 2351, 14, 5265, 26, 267, 1166, 275, 10092, 10134, 10789, 63, 7121, 435, 1994, 885, 15, 5265, 14, 1001, 7, 267, 862, 26, 288, 666, 275, 4011, 14, 10890, 8, 633, 680, 739, 342, 288, 2351, 14, 5265, 275, 14404, 8, 576, 11820, 5265, 418, 267, 871, 26, 288, 2351, 14, 5265, 275, 942, 272, 8963, 275, 359, 88, 14, 1294, 19237, 18, 61, 367, 671, 315, 2351, 14, 5265, 61, 272, 1177, 14, 1345, 275, 283, 9819, 15, 2926, 14, 1360, 7, 272, 1862, 275, 1211, 8, 1730, 14, 571, 459, 1162, 1105, 272, 1824, 275, 5385, 3516, 14, 3702, 8, 267, 5024, 360, 1213, 297, 849, 29, 1162, 14, 362, 360, 1213, 297, 488, 395, 1598, 5074, 29, 1311, 63, 4609, 63, 13993, 4000, 267, 5024, 360, 14348, 297, 849, 29, 1162, 14, 362, 360, 14348, 297, 488, 1826, 267, 5024, 360, 2502, 297, 849, 29, 1162, 14, 362, 360, 2502, 297, 488, 1826, 267, 5024, 8, 288, 283, 2502, 63, 2123, 297, 849, 29, 1162, 14, 362, 360, 2502, 63, 2123, 297, 488, 1826, 267, 5024, 360, 7511, 297, 849, 29, 1162, 14, 362, 360, 7511, 297, 488, 1826, 267, 5024, 360, 1802, 297, 283, 505, 297, 1598, 849, 29, 1162, 14, 362, 360, 1802, 297, 488, 1826, 267, 5024, 360, 4209, 63, 7915, 297, 5074, 29, 1311, 63, 568, 63, 3597, 8, 23900, 395, 1598, 849, 29, 1162, 14, 362, 360, 4209, 63, 7915, 297, 17915, 59, 16, 12884, 267, 5024, 8, 288, 283, 4659, 63, 2302, 297, 849, 29, 1162, 14, 362, 360, 4659, 63, 2302, 297, 488, 1826, 267, 5024, 8, 288, 283, 4416, 63, 498, 297, 849, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aYukiSekiguchi/ACCESS-Chromium
chrome/tools/build/generate_policy_source.py
3
15372
#!/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. '''python %prog [options] platform chromium_os_flag template platform specifies which platform source is being generated for and can be one of (win, mac, linux) chromium_os_flag should be 1 if this is a Chromium OS build template is the path to a .json policy template file.''' from __future__ import with_statement from optparse import OptionParser import sys CHROME_MANDATORY_SUBKEY = 'SOFTWARE\\\\Policies\\\\Google\\\\Chrome' CHROME_RECOMMENDED_SUBKEY = CHROME_MANDATORY_SUBKEY + '\\\\Recommended' CHROMIUM_MANDATORY_SUBKEY = 'SOFTWARE\\\\Policies\\\\Chromium' CHROMIUM_RECOMMENDED_SUBKEY = CHROMIUM_MANDATORY_SUBKEY + '\\\\Recommended' TYPE_MAP = { 'dict': 'TYPE_DICTIONARY', 'int': 'TYPE_INTEGER', 'int-enum': 'TYPE_INTEGER', 'list': 'TYPE_LIST', 'main': 'TYPE_BOOLEAN', 'string': 'TYPE_STRING', 'string-enum': 'TYPE_STRING', } def main(): parser = OptionParser(usage=__doc__) parser.add_option('--pch', '--policy-constants-header', dest='header_path', help='generate header file of policy constants', metavar='FILE') parser.add_option('--pcc', '--policy-constants-source', dest='source_path', help='generate source file of policy constants', metavar='FILE') parser.add_option('--ppb', '--policy-protobuf', dest='proto_path', help='generate cloud policy protobuf file', metavar='FILE') parser.add_option('--ppd', '--protobuf-decoder', dest='decoder_path', help='generate C++ code decoding the policy protobuf', metavar='FILE') (opts, args) = parser.parse_args() if len(args) != 3: print 'exactly platform, chromium_os flag and input file must be specified.' parser.print_help() return 2 template_file_contents = _LoadJSONFile(args[2]) if opts.header_path is not None: _WritePolicyConstantHeader(template_file_contents, args, opts) if opts.source_path is not None: _WritePolicyConstantSource(template_file_contents, args, opts) if opts.proto_path is not None: _WriteProtobuf(template_file_contents, args, opts.proto_path) if opts.decoder_path is not None: _WriteProtobufParser(template_file_contents, args, opts.decoder_path) return 0 #------------------ shared helpers ---------------------------------# def _OutputGeneratedWarningForC(f, template_file_path): f.write('//\n' '// DO NOT MODIFY THIS FILE DIRECTLY!\n' '// IT IS GENERATED BY generate_policy_source.py\n' '// FROM ' + template_file_path + '\n' '//\n\n') # Returns a tuple with details about the given policy: # (name, type, list_of_platforms, is_deprecated, is_device_policy) def _GetPolicyDetails(policy): name = policy['name'] if not TYPE_MAP.has_key(policy['type']): print 'Unknown policy type for %s: %s' % (name, policy['type']) sys.exit(3) vtype = TYPE_MAP[policy['type']] # platforms is a list of 'chrome', 'chrome_os' and/or 'chrome_frame'. platforms = [ x.split(':')[0] for x in policy['supported_on'] ] is_deprecated = policy.get('deprecated', False) return (name, vtype, platforms, is_deprecated) def _GetPolicyList(template_file_contents): policies = [] for policy in template_file_contents['policy_definitions']: if policy['type'] == 'group': for sub_policy in policy['policies']: policies.append(_GetPolicyDetails(sub_policy)) else: policies.append(_GetPolicyDetails(policy)) # Tuples are sorted in lexicographical order, which will sort by policy name # in this case. policies.sort() return policies def _GetPolicyNameList(template_file_contents): return [name for (name, _, _, _) in _GetPolicyList(template_file_contents)] def _GetChromePolicyList(template_file_contents): return [(name, platforms, vtype) for (name, vtype, platforms, _) in _GetPolicyList(template_file_contents)] def _GetDeprecatedPolicyList(template_file_contents): return [name for (name, _, _, is_deprecated) in _GetPolicyList(template_file_contents) if is_deprecated] def _LoadJSONFile(json_file): with open(json_file, 'r') as f: text = f.read() return eval(text) #------------------ policy constants header ------------------------# def _WritePolicyConstantHeader(template_file_contents, args, opts): os = args[0] with open(opts.header_path, 'w') as f: _OutputGeneratedWarningForC(f, args[2]) f.write('#ifndef CHROME_COMMON_POLICY_CONSTANTS_H_\n' '#define CHROME_COMMON_POLICY_CONSTANTS_H_\n' '#pragma once\n' '\n' '#include <string>\n' '\n' '#include "base/values.h"\n' '\n' 'namespace policy {\n\n') if os == 'win': f.write('// The windows registry path where mandatory policy ' 'configuration resides.\n' 'extern const wchar_t kRegistryMandatorySubKey[];\n' '// The windows registry path where recommended policy ' 'configuration resides.\n' 'extern const wchar_t kRegistryRecommendedSubKey[];\n\n') f.write('// Lists policy types mapped to their names and expected types.\n' '// Used to initialize ConfigurationPolicyProviders.\n' 'struct PolicyDefinitionList {\n' ' struct Entry {\n' ' const char* name;\n' ' base::Value::Type value_type;\n' ' };\n' '\n' ' const Entry* begin;\n' ' const Entry* end;\n' '};\n' '\n' '// Returns true if the given policy is deprecated.\n' 'bool IsDeprecatedPolicy(const std::string& policy);\n' '\n' '// Returns the default policy definition list for Chrome.\n' 'const PolicyDefinitionList* GetChromePolicyDefinitionList();\n\n') f.write('// Key names for the policy settings.\n' 'namespace key {\n\n') for policy_name in _GetPolicyNameList(template_file_contents): f.write('extern const char k' + policy_name + '[];\n') f.write('\n} // namespace key\n\n' '} // namespace policy\n\n' '#endif // CHROME_COMMON_POLICY_CONSTANTS_H_\n') #------------------ policy constants source ------------------------# def _WritePolicyConstantSource(template_file_contents, args, opts): os = args[0] is_chromium_os = args[1] == '1' platform = None platform_wildcard = None if is_chromium_os: platform = 'chrome_os' else: platform = 'chrome.' + os.lower() platform_wildcard = 'chrome.*' with open(opts.source_path, 'w') as f: _OutputGeneratedWarningForC(f, args[2]) f.write('#include "base/basictypes.h"\n' '#include "base/logging.h"\n' '#include "policy/policy_constants.h"\n' '\n' 'namespace policy {\n\n') f.write('namespace {\n\n') f.write('const PolicyDefinitionList::Entry kEntries[] = {\n') policy_list = _GetChromePolicyList(template_file_contents) for (name, platforms, vtype) in policy_list: if (platform in platforms) or (platform_wildcard in platforms): f.write(' { key::k%s, Value::%s },\n' % (name, vtype)) f.write('};\n\n') f.write('const PolicyDefinitionList kChromePolicyList = {\n' ' kEntries,\n' ' kEntries + arraysize(kEntries),\n' '};\n\n') f.write('// List of deprecated policies.\n' 'const char* kDeprecatedPolicyList[] = {\n') for name in _GetDeprecatedPolicyList(template_file_contents): f.write(' key::k%s,\n' % name) f.write('};\n\n') f.write('} // namespace\n\n') if os == 'win': f.write('#if defined(GOOGLE_CHROME_BUILD)\n' 'const wchar_t kRegistryMandatorySubKey[] = ' 'L"' + CHROME_MANDATORY_SUBKEY + '";\n' 'const wchar_t kRegistryRecommendedSubKey[] = ' 'L"' + CHROME_RECOMMENDED_SUBKEY + '";\n' '#else\n' 'const wchar_t kRegistryMandatorySubKey[] = ' 'L"' + CHROMIUM_MANDATORY_SUBKEY + '";\n' 'const wchar_t kRegistryRecommendedSubKey[] = ' 'L"' + CHROMIUM_RECOMMENDED_SUBKEY + '";\n' '#endif\n\n') f.write('bool IsDeprecatedPolicy(const std::string& policy) {\n' ' for (size_t i = 0; i < arraysize(kDeprecatedPolicyList);' ' ++i) {\n' ' if (policy == kDeprecatedPolicyList[i])\n' ' return true;\n' ' }\n' ' return false;\n' '}\n' '\n' 'const PolicyDefinitionList* GetChromePolicyDefinitionList() {\n' ' return &kChromePolicyList;\n' '}\n\n') f.write('namespace key {\n\n') for policy_name in _GetPolicyNameList(template_file_contents): f.write('const char k%s[] = "%s";\n' % (policy_name, policy_name)) f.write('\n} // namespace key\n\n' '} // namespace policy\n') #------------------ policy protobuf --------------------------------# PROTO_HEAD = ''' syntax = "proto2"; option optimize_for = LITE_RUNTIME; package enterprise_management; message StringList { repeated string entries = 1; } message PolicyOptions { enum PolicyMode { // The given settings are applied regardless of user choice. MANDATORY = 0; // The user may choose to override the given settings. RECOMMENDED = 1; // No policy value is present and the policy should be ignored. UNSET = 2; } optional PolicyMode mode = 1 [default = MANDATORY]; } ''' # TODO(joaodasilva): introduce a message to represent dictionary values. # Mapping 'dict' to 'string' for now. http://crbug.com/108997 PROTOBUF_TYPE = { 'dict': 'string', 'int': 'int64', 'int-enum': 'int64', 'list': 'StringList', 'main': 'bool', 'string': 'string', 'string-enum': 'string', } # Field IDs [1..RESERVED_IDS] will not be used in the wrapping protobuf. RESERVED_IDS = 2 def _WritePolicyProto(file, policy, fields): if policy.get('device_only', False): return file.write('message %sProto {\n' % policy['name']) file.write(' optional PolicyOptions policy_options = 1;\n') file.write(' optional %s %s = 2;\n' % (PROTOBUF_TYPE[policy['type']], policy['name'])) file.write('}\n\n') fields += [' optional %sProto %s = %s;\n' % (policy['name'], policy['name'], policy['id'] + RESERVED_IDS)] def _WriteProtobuf(template_file_contents, args, outfilepath): with open(outfilepath, 'w') as f: _OutputGeneratedWarningForC(f, args[2]) f.write(PROTO_HEAD) fields = [] f.write('// PBs for individual settings.\n\n') for policy in template_file_contents['policy_definitions']: if policy['type'] == 'group': for sub_policy in policy['policies']: _WritePolicyProto(f, sub_policy, fields) else: _WritePolicyProto(f, policy, fields) f.write('// --------------------------------------------------\n' '// Big wrapper PB containing the above groups.\n\n' 'message CloudPolicySettings {\n') f.write(''.join(fields)) f.write('}\n\n') #------------------ protobuf decoder -------------------------------# CPP_HEAD = ''' #include <limits> #include <string> #include "base/logging.h" #include "base/values.h" #include "chrome/browser/policy/policy_map.h" #include "chrome/browser/policy/proto/cloud_policy.pb.h" #include "policy/policy_constants.h" using google::protobuf::RepeatedPtrField; namespace policy { namespace em = enterprise_management; Value* DecodeIntegerValue(google::protobuf::int64 value) { if (value < std::numeric_limits<int>::min() || value > std::numeric_limits<int>::max()) { LOG(WARNING) << "Integer value " << value << " out of numeric limits, ignoring."; return NULL; } return Value::CreateIntegerValue(static_cast<int>(value)); } ListValue* DecodeStringList(const em::StringList& string_list) { ListValue* list_value = new ListValue; RepeatedPtrField<std::string>::const_iterator entry; for (entry = string_list.entries().begin(); entry != string_list.entries().end(); ++entry) { list_value->Append(Value::CreateStringValue(*entry)); } return list_value; } void DecodePolicy(const em::CloudPolicySettings& policy, PolicyMap* map) { ''' CPP_FOOT = '''} } // namespace policy ''' def _CreateValue(type, arg): if type == 'main': return "Value::CreateBooleanValue(%s)" % arg elif type in ('int', 'int-enum'): return "DecodeIntegerValue(%s)" % arg elif type in ('string', 'string-enum'): return "Value::CreateStringValue(%s)" % arg elif type == 'list': return "DecodeStringList(%s)" % arg elif type == 'dict': # TODO(joaodasilva): decode 'dict' types. http://crbug.com/108997 return "new DictionaryValue()" else: raise NotImplementedError() def _WritePolicyCode(file, policy): if policy.get('device_only', False): return membername = policy['name'].lower() proto_type = '%sProto' % policy['name'] proto_name = '%s_proto' % membername file.write(' if (policy.has_%s()) {\n' % membername) file.write(' const em::%s& %s = policy.%s();\n' % (proto_type, proto_name, membername)) file.write(' if (%s.has_%s()) {\n' % (proto_name, membername)) file.write(' PolicyLevel level = POLICY_LEVEL_MANDATORY;\n' ' bool do_set = true;\n' ' if (%s.has_policy_options()) {\n' ' do_set = false;\n' ' switch(%s.policy_options().mode()) {\n' % (proto_name, proto_name)) file.write(' case em::PolicyOptions::MANDATORY:\n' ' do_set = true;\n' ' level = POLICY_LEVEL_MANDATORY;\n' ' break;\n' ' case em::PolicyOptions::RECOMMENDED:\n' ' do_set = true;\n' ' level = POLICY_LEVEL_RECOMMENDED;\n' ' break;\n' ' case em::PolicyOptions::UNSET:\n' ' break;\n' ' }\n' ' }\n' ' if (do_set) {\n') file.write(' Value* value = %s;\n' % (_CreateValue(policy['type'], '%s.%s()' % (proto_name, membername)))) file.write(' map->Set(key::k%s, level, POLICY_SCOPE_USER, value);\n' % policy['name']) file.write(' }\n' ' }\n' ' }\n') def _WriteProtobufParser(template_file_contents, args, outfilepath): with open(outfilepath, 'w') as f: _OutputGeneratedWarningForC(f, args[2]) f.write(CPP_HEAD) for policy in template_file_contents['policy_definitions']: if policy['type'] == 'group': for sub_policy in policy['policies']: _WritePolicyCode(f, sub_policy) else: _WritePolicyCode(f, policy) f.write(CPP_FOOT) 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, 199, 2344, 1548, 450, 6595, 359, 1419, 61, 4298, 682, 7419, 63, 736, 63, 4173, 1978, 199, 199, 3246, 9314, 1314, 4298, 1350, 365, 3769, 4046, 367, 523, 436, 883, 506, 1373, 402, 334, 2676, 12, 4497, 12, 18369, 9, 199, 13211, 63, 736, 63, 4173, 1077, 506, 413, 340, 642, 365, 282, 12051, 4403, 1900, 199, 1160, 365, 314, 931, 370, 282, 1275, 1001, 4592, 1978, 570, 10595, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 8691, 492, 13491, 199, 646, 984, 421, 199, 1244, 31364, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 275, 283, 26734, 8712, 27079, 8712, 13266, 8712, 18083, 7, 199, 1244, 31364, 63, 907, 5378, 25518, 63, 6348, 3078, 275, 6624, 31364, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 435, 31375, 497, 11902, 7, 199, 30334, 24967, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 275, 283, 26734, 8712, 27079, 8712, 29381, 7, 199, 30334, 24967, 63, 907, 5378, 25518, 63, 6348, 3078, 275, 6624, 3810, 24967, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 435, 31375, 497, 11902, 7, 199, 199, 2711, 63, 5443, 275, 469, 523, 283, 807, 356, 283, 2711, 63, 12511, 1075, 4392, 297, 523, 283, 442, 356, 283, 2711, 63, 9596, 297, 523, 283, 442, 13, 4869, 356, 283, 2711, 63, 9596, 297, 523, 283, 513, 356, 283, 2711, 63, 4924, 297, 523, 283, 973, 356, 283, 2711, 63, 25312, 297, 523, 283, 875, 356, 283, 2711, 63, 5353, 297, 523, 283, 875, 13, 4869, 356, 283, 2711, 63, 5353, 297, 199, 93, 421, 199, 318, 2446, 837, 523, 1798, 275, 13491, 8, 3807, 18971, 1301, 3368, 523, 1798, 14, 525, 63, 1422, 4517, 23938, 297, 2850, 3185, 13, 5559, 13, 1291, 297, 2053, 534, 1291, 63, 515, 297, 490, 1720, 534, 4208, 1406, 570, 402, 4592, 5262, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 80, 2055, 297, 2850, 3185, 13, 5559, 13, 1365, 297, 2053, 534, 1365, 63, 515, 297, 490, 1720, 534, 4208, 1350, 570, 402, 4592, 5262, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 802, 66, 297, 2850, 3185, 13, 7204, 297, 2053, 534, 2625, 63, 515, 297, 490, 1720, 534, 4208, 8002, 4592, 25886, 570, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 802, 68, 297, 2850, 7204, 13, 8813, 297, 2053, 534, 8813, 63, 515, 297, 490, 1720, 534, 4208, 445, 4176, 1233, 15952, 314, 4592, 25886, 297, 490, 8214, 534, 3817, 358, 819, 334, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 819, 340, 822, 8, 589, 9, 1137, 650, 26, 272, 870, 283, 7327, 590, 4298, 12, 682, 7419, 63, 736, 3305, 436, 1324, 570, 1471, 506, 2013, 3530, 272, 1798, 14, 1361, 63, 3437, 342, 272, 372, 499, 523, 1978, 63, 493, 63, 4407, 275, 485, 6200, 6243, 1173, 8, 589, 59, 18, 566, 523, 340, 3999, 14, 1291, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 4845, 9737, 2567, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 9, 523, 340, 3999, 14, 1365, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 4845, 9737, 2980, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 9, 523, 340, 3999, 14, 2625, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 8548, 1436, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 14, 2625, 63, 515, 9, 523, 340, 3999, 14, 8813, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 8548, 1436, 2842, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 14, 8813, 63, 515, 9, 523, 372, 378, 421, 199, 32152, 306, 5709, 10897, 11016, 8492, 199, 318, 485, 2959, 12706, 3849, 1858, 35, 8, 70, 12, 1978, 63, 493, 63, 515, 304, 272, 289, 14, 952, 15079, 60, 78, 7, 288, 18290, 3506, 2845, 10362, 1914, 18114, 5749, 13024, 8703, 6084, 12525, 78, 7, 288, 18290, 473, 52, 2281, 29087, 6989, 6515, 3550, 63, 3185, 63, 1365, 14, 647, 60, 78, 7, 288, 18290, 4442, 283, 435, 1978, 63, 493, 63, 515, 435, 1557, 78, 7, 288, 18290, 60, 78, 60, 78, 358, 421, 199, 3, 1803, 282, 2008, 543, 2436, 3595, 314, 1627, 4592, 26, 199, 3, 334, 354, 12, 730, 12, 769, 63, 1618, 63, 19601, 12, 365, 63, 6667, 12, 365, 63, 1782, 63, 3185, 9, 199, 318, 485, 1002, 4845, 11347, 8, 3185, 304, 523, 536, 275, 4592, 459, 354, 418, 523, 340, 440, 11511, 63, 5443, 14, 1989, 63, 498, 8, 3185, 459, 466, 9090, 272, 870, 283, 5912, 4592, 730, 367, 450, 83, 26, 450, 83, 7, 450, 334, 354, 12, 4592, 459, 466, 1105, 272, 984, 14, 2224, 8, 19, 9, 523, 29878, 275, 11511, 63, 5443, 59, 3185, 459, 466, 6538, 523, 327, 10677, 365, 282, 769, 402, 283, 9887, 297, 283, 9887, 63, 736, 7, 436, 15, 269, 283, 9887, 63, 1943, 1370, 523, 10677, 275, 359, 671, 14, 1294, 24050, 16, 61, 367, 671, 315, 4592, 459, 4946, 63, 265, 418, 1622, 523, 365, 63, 6667, 275, 4592, 14, 362, 360, 6667, 297, 756, 9, 523, 372, 334, 354, 12, 29878, 12, 10677, 12, 365, 63, 6667, 9, 421, 199, 318, 485, 1002, 4845, 1296, 8, 1160, 63, 493, 63, 4407, 304, 523, 14118, 275, 942, 523, 367, 4592, 315, 1978, 63, 493, 63, 4407, 459, 3185, 63, 15388, 2565, 272, 340, 4592, 459, 466, 418, 508, 283, 923, 356, 489, 367, 1007, 63, 3185, 315, 4592, 459, 11767, 2565, 267, 14118, 14, 740, 1547, 1002, 4845, 11347, 8, 954, 63, 3185, 430, 272, 587, 26, 489, 14118, 14, 740, 1547, 1002, 4845, 11347, 8, 3185, 430, 523, 327, 11634, 83, 787, 3355, 315, 1026, 30077, 2180, 2652, 1865, 12, 1314, 911, 4069, 701, 4592, 536, 523, 327, 315, 642, 1930, 14 ]
[ 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, 199, 2344, 1548, 450, 6595, 359, 1419, 61, 4298, 682, 7419, 63, 736, 63, 4173, 1978, 199, 199, 3246, 9314, 1314, 4298, 1350, 365, 3769, 4046, 367, 523, 436, 883, 506, 1373, 402, 334, 2676, 12, 4497, 12, 18369, 9, 199, 13211, 63, 736, 63, 4173, 1077, 506, 413, 340, 642, 365, 282, 12051, 4403, 1900, 199, 1160, 365, 314, 931, 370, 282, 1275, 1001, 4592, 1978, 570, 10595, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 8691, 492, 13491, 199, 646, 984, 421, 199, 1244, 31364, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 275, 283, 26734, 8712, 27079, 8712, 13266, 8712, 18083, 7, 199, 1244, 31364, 63, 907, 5378, 25518, 63, 6348, 3078, 275, 6624, 31364, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 435, 31375, 497, 11902, 7, 199, 30334, 24967, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 275, 283, 26734, 8712, 27079, 8712, 29381, 7, 199, 30334, 24967, 63, 907, 5378, 25518, 63, 6348, 3078, 275, 6624, 3810, 24967, 63, 45, 3649, 619, 5347, 63, 6348, 3078, 435, 31375, 497, 11902, 7, 199, 199, 2711, 63, 5443, 275, 469, 523, 283, 807, 356, 283, 2711, 63, 12511, 1075, 4392, 297, 523, 283, 442, 356, 283, 2711, 63, 9596, 297, 523, 283, 442, 13, 4869, 356, 283, 2711, 63, 9596, 297, 523, 283, 513, 356, 283, 2711, 63, 4924, 297, 523, 283, 973, 356, 283, 2711, 63, 25312, 297, 523, 283, 875, 356, 283, 2711, 63, 5353, 297, 523, 283, 875, 13, 4869, 356, 283, 2711, 63, 5353, 297, 199, 93, 421, 199, 318, 2446, 837, 523, 1798, 275, 13491, 8, 3807, 18971, 1301, 3368, 523, 1798, 14, 525, 63, 1422, 4517, 23938, 297, 2850, 3185, 13, 5559, 13, 1291, 297, 2053, 534, 1291, 63, 515, 297, 490, 1720, 534, 4208, 1406, 570, 402, 4592, 5262, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 80, 2055, 297, 2850, 3185, 13, 5559, 13, 1365, 297, 2053, 534, 1365, 63, 515, 297, 490, 1720, 534, 4208, 1350, 570, 402, 4592, 5262, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 802, 66, 297, 2850, 3185, 13, 7204, 297, 2053, 534, 2625, 63, 515, 297, 490, 1720, 534, 4208, 8002, 4592, 25886, 570, 297, 490, 8214, 534, 3817, 358, 523, 1798, 14, 525, 63, 1422, 4517, 802, 68, 297, 2850, 7204, 13, 8813, 297, 2053, 534, 8813, 63, 515, 297, 490, 1720, 534, 4208, 445, 4176, 1233, 15952, 314, 4592, 25886, 297, 490, 8214, 534, 3817, 358, 819, 334, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 819, 340, 822, 8, 589, 9, 1137, 650, 26, 272, 870, 283, 7327, 590, 4298, 12, 682, 7419, 63, 736, 3305, 436, 1324, 570, 1471, 506, 2013, 3530, 272, 1798, 14, 1361, 63, 3437, 342, 272, 372, 499, 523, 1978, 63, 493, 63, 4407, 275, 485, 6200, 6243, 1173, 8, 589, 59, 18, 566, 523, 340, 3999, 14, 1291, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 4845, 9737, 2567, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 9, 523, 340, 3999, 14, 1365, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 4845, 9737, 2980, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 9, 523, 340, 3999, 14, 2625, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 8548, 1436, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 14, 2625, 63, 515, 9, 523, 340, 3999, 14, 8813, 63, 515, 365, 440, 488, 26, 272, 485, 3534, 8548, 1436, 2842, 8, 1160, 63, 493, 63, 4407, 12, 1249, 12, 3999, 14, 8813, 63, 515, 9, 523, 372, 378, 421, 199, 32152, 306, 5709, 10897, 11016, 8492, 199, 318, 485, 2959, 12706, 3849, 1858, 35, 8, 70, 12, 1978, 63, 493, 63, 515, 304, 272, 289, 14, 952, 15079, 60, 78, 7, 288, 18290, 3506, 2845, 10362, 1914, 18114, 5749, 13024, 8703, 6084, 12525, 78, 7, 288, 18290, 473, 52, 2281, 29087, 6989, 6515, 3550, 63, 3185, 63, 1365, 14, 647, 60, 78, 7, 288, 18290, 4442, 283, 435, 1978, 63, 493, 63, 515, 435, 1557, 78, 7, 288, 18290, 60, 78, 60, 78, 358, 421, 199, 3, 1803, 282, 2008, 543, 2436, 3595, 314, 1627, 4592, 26, 199, 3, 334, 354, 12, 730, 12, 769, 63, 1618, 63, 19601, 12, 365, 63, 6667, 12, 365, 63, 1782, 63, 3185, 9, 199, 318, 485, 1002, 4845, 11347, 8, 3185, 304, 523, 536, 275, 4592, 459, 354, 418, 523, 340, 440, 11511, 63, 5443, 14, 1989, 63, 498, 8, 3185, 459, 466, 9090, 272, 870, 283, 5912, 4592, 730, 367, 450, 83, 26, 450, 83, 7, 450, 334, 354, 12, 4592, 459, 466, 1105, 272, 984, 14, 2224, 8, 19, 9, 523, 29878, 275, 11511, 63, 5443, 59, 3185, 459, 466, 6538, 523, 327, 10677, 365, 282, 769, 402, 283, 9887, 297, 283, 9887, 63, 736, 7, 436, 15, 269, 283, 9887, 63, 1943, 1370, 523, 10677, 275, 359, 671, 14, 1294, 24050, 16, 61, 367, 671, 315, 4592, 459, 4946, 63, 265, 418, 1622, 523, 365, 63, 6667, 275, 4592, 14, 362, 360, 6667, 297, 756, 9, 523, 372, 334, 354, 12, 29878, 12, 10677, 12, 365, 63, 6667, 9, 421, 199, 318, 485, 1002, 4845, 1296, 8, 1160, 63, 493, 63, 4407, 304, 523, 14118, 275, 942, 523, 367, 4592, 315, 1978, 63, 493, 63, 4407, 459, 3185, 63, 15388, 2565, 272, 340, 4592, 459, 466, 418, 508, 283, 923, 356, 489, 367, 1007, 63, 3185, 315, 4592, 459, 11767, 2565, 267, 14118, 14, 740, 1547, 1002, 4845, 11347, 8, 954, 63, 3185, 430, 272, 587, 26, 489, 14118, 14, 740, 1547, 1002, 4845, 11347, 8, 3185, 430, 523, 327, 11634, 83, 787, 3355, 315, 1026, 30077, 2180, 2652, 1865, 12, 1314, 911, 4069, 701, 4592, 536, 523, 327, 315, 642, 1930, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
rmasters/inbox
migrations/versions/013_add_spool_msg.py
11
1490
"""Add SpoolMessage table Revision ID: f7dbd9bf4a6 Revises: 13102e0e6fbd Create Date: 2014-04-16 03:51:49.484697 """ # revision identifiers, used by Alembic. revision = 'f7dbd9bf4a6' down_revision = '193802835c33' from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('message', sa.Column('inbox_uid', sa.String(length=64), nullable=True)) op.add_column('message', sa.Column('type', sa.String(length=16), nullable=True)) op.create_table( 'spoolmessage', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_date', sa.DateTime(), nullable=True), sa.Column( 'is_sent', sa.Boolean, server_default=sa.sql.expression.false(), nullable=False), sa.Column('resolved_message_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['id'], ['message.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint( ['resolved_message_id'], ['message.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_column('message', 'type') op.drop_column('message', 'inbox_uid') op.drop_table('spoolmessage') ### end Alembic commands ###
agpl-3.0
[ 624, 1123, 428, 2293, 2209, 1817, 199, 199, 12714, 2870, 26, 289, 23, 697, 68, 25, 4361, 20, 65, 22, 199, 497, 433, 874, 26, 4944, 7759, 69, 16, 69, 22, 17108, 199, 2499, 6148, 26, 6927, 13, 966, 13, 975, 30569, 26, 2869, 26, 1887, 14, 29618, 19301, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 70, 23, 697, 68, 25, 4361, 20, 65, 22, 7, 199, 2110, 63, 5792, 275, 283, 1167, 1703, 15501, 1276, 67, 1153, 7, 199, 199, 504, 30960, 20596, 492, 1687, 199, 646, 8335, 465, 2937, 421, 199, 318, 10754, 837, 272, 6754, 3718, 2599, 4046, 701, 6832, 20596, 446, 8749, 11311, 1, 6754, 272, 1687, 14, 525, 63, 2301, 360, 1188, 297, 2937, 14, 4547, 360, 27515, 63, 1535, 297, 2937, 14, 1558, 8, 1267, 29, 772, 395, 4318, 7854, 29, 549, 430, 272, 1687, 14, 525, 63, 2301, 360, 1188, 297, 2937, 14, 4547, 360, 466, 297, 2937, 14, 1558, 8, 1267, 29, 975, 395, 4318, 7854, 29, 549, 430, 339, 1687, 14, 981, 63, 1224, 8, 267, 283, 83, 2293, 1188, 297, 267, 2937, 14, 4547, 360, 344, 297, 2937, 14, 2674, 1062, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 3966, 63, 602, 297, 2937, 14, 3926, 1062, 7854, 29, 549, 395, 267, 2937, 14, 4547, 8, 288, 283, 374, 63, 1150, 297, 2937, 14, 4082, 12, 288, 1654, 63, 885, 29, 2231, 14, 3009, 14, 5599, 14, 3910, 1062, 288, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 13697, 63, 1188, 63, 344, 297, 2937, 14, 2674, 1062, 7854, 29, 549, 395, 267, 2937, 14, 3190, 8463, 2941, 344, 995, 788, 1188, 14, 344, 995, 16549, 534, 10855, 659, 267, 2937, 14, 3190, 8463, 8, 288, 788, 13697, 63, 1188, 63, 344, 995, 288, 788, 1188, 14, 344, 995, 288, 16549, 534, 10855, 659, 267, 2937, 14, 29457, 8463, 360, 344, 358, 272, 776, 272, 6754, 1284, 6832, 20596, 3718, 6754, 421, 199, 318, 32498, 837, 272, 6754, 3718, 2599, 4046, 701, 6832, 20596, 446, 8749, 11311, 1, 6754, 272, 1687, 14, 4824, 63, 2301, 360, 1188, 297, 283, 466, 358, 272, 1687, 14, 4824, 63, 2301, 360, 1188, 297, 283, 27515, 63, 1535, 358, 339, 1687, 14, 4824, 63, 1224, 360, 83, 2293, 1188, 358, 272, 6754, 1284, 6832, 20596, 3718, 6754, 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 ]
[ 1123, 428, 2293, 2209, 1817, 199, 199, 12714, 2870, 26, 289, 23, 697, 68, 25, 4361, 20, 65, 22, 199, 497, 433, 874, 26, 4944, 7759, 69, 16, 69, 22, 17108, 199, 2499, 6148, 26, 6927, 13, 966, 13, 975, 30569, 26, 2869, 26, 1887, 14, 29618, 19301, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 70, 23, 697, 68, 25, 4361, 20, 65, 22, 7, 199, 2110, 63, 5792, 275, 283, 1167, 1703, 15501, 1276, 67, 1153, 7, 199, 199, 504, 30960, 20596, 492, 1687, 199, 646, 8335, 465, 2937, 421, 199, 318, 10754, 837, 272, 6754, 3718, 2599, 4046, 701, 6832, 20596, 446, 8749, 11311, 1, 6754, 272, 1687, 14, 525, 63, 2301, 360, 1188, 297, 2937, 14, 4547, 360, 27515, 63, 1535, 297, 2937, 14, 1558, 8, 1267, 29, 772, 395, 4318, 7854, 29, 549, 430, 272, 1687, 14, 525, 63, 2301, 360, 1188, 297, 2937, 14, 4547, 360, 466, 297, 2937, 14, 1558, 8, 1267, 29, 975, 395, 4318, 7854, 29, 549, 430, 339, 1687, 14, 981, 63, 1224, 8, 267, 283, 83, 2293, 1188, 297, 267, 2937, 14, 4547, 360, 344, 297, 2937, 14, 2674, 1062, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 3966, 63, 602, 297, 2937, 14, 3926, 1062, 7854, 29, 549, 395, 267, 2937, 14, 4547, 8, 288, 283, 374, 63, 1150, 297, 2937, 14, 4082, 12, 288, 1654, 63, 885, 29, 2231, 14, 3009, 14, 5599, 14, 3910, 1062, 288, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 13697, 63, 1188, 63, 344, 297, 2937, 14, 2674, 1062, 7854, 29, 549, 395, 267, 2937, 14, 3190, 8463, 2941, 344, 995, 788, 1188, 14, 344, 995, 16549, 534, 10855, 659, 267, 2937, 14, 3190, 8463, 8, 288, 788, 13697, 63, 1188, 63, 344, 995, 288, 788, 1188, 14, 344, 995, 288, 16549, 534, 10855, 659, 267, 2937, 14, 29457, 8463, 360, 344, 358, 272, 776, 272, 6754, 1284, 6832, 20596, 3718, 6754, 421, 199, 318, 32498, 837, 272, 6754, 3718, 2599, 4046, 701, 6832, 20596, 446, 8749, 11311, 1, 6754, 272, 1687, 14, 4824, 63, 2301, 360, 1188, 297, 283, 466, 358, 272, 1687, 14, 4824, 63, 2301, 360, 1188, 297, 283, 27515, 63, 1535, 358, 339, 1687, 14, 4824, 63, 1224, 360, 83, 2293, 1188, 358, 272, 6754, 1284, 6832, 20596, 3718, 6754, 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, 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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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 ]
kennedyshead/home-assistant
homeassistant/components/arest/switch.py
21
6607
"""Support for an exposed aREST RESTful API of a device.""" import logging import requests import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME, CONF_RESOURCE, HTTP_OK import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) CONF_FUNCTIONS = "functions" CONF_PINS = "pins" CONF_INVERT = "invert" DEFAULT_NAME = "aREST switch" PIN_FUNCTION_SCHEMA = vol.Schema( { vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_INVERT, default=False): cv.boolean, } ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_RESOURCE): cv.url, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_PINS, default={}): vol.Schema( {cv.string: PIN_FUNCTION_SCHEMA} ), vol.Optional(CONF_FUNCTIONS, default={}): vol.Schema( {cv.string: PIN_FUNCTION_SCHEMA} ), } ) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the aREST switches.""" resource = config[CONF_RESOURCE] try: response = requests.get(resource, timeout=10) except requests.exceptions.MissingSchema: _LOGGER.error( "Missing resource or schema in configuration. Add http:// to your URL" ) return False except requests.exceptions.ConnectionError: _LOGGER.error("No route to device at %s", resource) return False dev = [] pins = config[CONF_PINS] for pinnum, pin in pins.items(): dev.append( ArestSwitchPin( resource, config.get(CONF_NAME, response.json()[CONF_NAME]), pin.get(CONF_NAME), pinnum, pin[CONF_INVERT], ) ) functions = config[CONF_FUNCTIONS] for funcname, func in functions.items(): dev.append( ArestSwitchFunction( resource, config.get(CONF_NAME, response.json()[CONF_NAME]), func.get(CONF_NAME), funcname, ) ) add_entities(dev) class ArestSwitchBase(SwitchEntity): """Representation of an aREST switch.""" def __init__(self, resource, location, name): """Initialize the switch.""" self._resource = resource self._name = f"{location.title()} {name.title()}" self._state = None self._available = True @property def name(self): """Return the name of the switch.""" return self._name @property def is_on(self): """Return true if device is on.""" return self._state @property def available(self): """Could the device be accessed during the last update call.""" return self._available class ArestSwitchFunction(ArestSwitchBase): """Representation of an aREST switch.""" def __init__(self, resource, location, name, func): """Initialize the switch.""" super().__init__(resource, location, name) self._func = func request = requests.get(f"{self._resource}/{self._func}", timeout=10) if request.status_code != HTTP_OK: _LOGGER.error("Can't find function") return try: request.json()["return_value"] except KeyError: _LOGGER.error("No return_value received") except ValueError: _LOGGER.error("Response invalid") def turn_on(self, **kwargs): """Turn the device on.""" request = requests.get( f"{self._resource}/{self._func}", timeout=10, params={"params": "1"} ) if request.status_code == HTTP_OK: self._state = True else: _LOGGER.error("Can't turn on function %s at %s", self._func, self._resource) def turn_off(self, **kwargs): """Turn the device off.""" request = requests.get( f"{self._resource}/{self._func}", timeout=10, params={"params": "0"} ) if request.status_code == HTTP_OK: self._state = False else: _LOGGER.error( "Can't turn off function %s at %s", self._func, self._resource ) def update(self): """Get the latest data from aREST API and update the state.""" try: request = requests.get(f"{self._resource}/{self._func}", timeout=10) self._state = request.json()["return_value"] != 0 self._available = True except requests.exceptions.ConnectionError: _LOGGER.warning("No route to device %s", self._resource) self._available = False class ArestSwitchPin(ArestSwitchBase): """Representation of an aREST switch. Based on digital I/O.""" def __init__(self, resource, location, name, pin, invert): """Initialize the switch.""" super().__init__(resource, location, name) self._pin = pin self.invert = invert request = requests.get(f"{self._resource}/mode/{self._pin}/o", timeout=10) if request.status_code != HTTP_OK: _LOGGER.error("Can't set mode") self._available = False def turn_on(self, **kwargs): """Turn the device on.""" turn_on_payload = int(not self.invert) request = requests.get( f"{self._resource}/digital/{self._pin}/{turn_on_payload}", timeout=10 ) if request.status_code == HTTP_OK: self._state = True else: _LOGGER.error("Can't turn on pin %s at %s", self._pin, self._resource) def turn_off(self, **kwargs): """Turn the device off.""" turn_off_payload = int(self.invert) request = requests.get( f"{self._resource}/digital/{self._pin}/{turn_off_payload}", timeout=10 ) if request.status_code == HTTP_OK: self._state = False else: _LOGGER.error("Can't turn off pin %s at %s", self._pin, self._resource) def update(self): """Get the latest data from aREST API and update the state.""" try: request = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10) status_value = int(self.invert) self._state = request.json()["return_value"] != status_value self._available = True except requests.exceptions.ConnectionError: _LOGGER.warning("No route to device %s", self._resource) self._available = False
apache-2.0
[ 624, 11532, 367, 376, 19282, 282, 15740, 14880, 1893, 3261, 402, 282, 2243, 1041, 199, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 21966, 63, 10926, 12, 17711, 7302, 199, 504, 8846, 14, 1297, 492, 6392, 63, 2339, 12, 6392, 63, 14110, 12, 3101, 63, 3593, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 29865, 275, 298, 5777, 2, 199, 3103, 63, 48, 10789, 275, 298, 21746, 2, 199, 3103, 63, 568, 8851, 275, 298, 18957, 2, 199, 199, 3472, 63, 2339, 275, 298, 65, 15740, 6258, 2, 199, 199, 30929, 63, 15476, 63, 10926, 275, 5236, 14, 6700, 8, 272, 469, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 568, 8851, 12, 849, 29, 797, 304, 6277, 14, 4871, 12, 272, 789, 199, 9, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 14110, 304, 6277, 14, 633, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 48, 10789, 12, 849, 16420, 5236, 14, 6700, 8, 288, 469, 5107, 14, 875, 26, 510, 568, 63, 15476, 63, 10926, 93, 267, 2318, 267, 5236, 14, 7012, 8, 3103, 63, 29865, 12, 849, 16420, 5236, 14, 6700, 8, 288, 469, 5107, 14, 875, 26, 510, 568, 63, 15476, 63, 10926, 93, 267, 2318, 272, 789, 199, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 282, 15740, 24563, 1041, 272, 2073, 275, 1101, 59, 3103, 63, 14110, 61, 339, 862, 26, 267, 1177, 275, 4145, 14, 362, 8, 1927, 12, 2653, 29, 709, 9, 272, 871, 4145, 14, 3924, 14, 7718, 6700, 26, 267, 485, 10186, 14, 705, 8, 288, 298, 7718, 2073, 503, 4177, 315, 2897, 14, 2654, 1455, 921, 370, 2195, 2851, 2, 267, 776, 267, 372, 756, 272, 871, 4145, 14, 3924, 14, 20349, 26, 267, 485, 10186, 14, 705, 480, 1944, 7475, 370, 2243, 737, 450, 83, 401, 2073, 9, 267, 372, 756, 339, 4866, 275, 942, 272, 30541, 275, 1101, 59, 3103, 63, 48, 10789, 61, 272, 367, 10713, 1507, 12, 10713, 315, 30541, 14, 1744, 837, 267, 4866, 14, 740, 8, 288, 437, 3911, 10167, 19909, 8, 355, 2073, 12, 355, 1101, 14, 362, 8, 3103, 63, 2339, 12, 1177, 14, 1001, 3430, 3103, 63, 2339, 2522, 355, 10713, 14, 362, 8, 3103, 63, 2339, 395, 355, 10713, 1507, 12, 355, 10713, 59, 3103, 63, 568, 8851, 467, 288, 776, 267, 776, 339, 3423, 275, 1101, 59, 3103, 63, 29865, 61, 272, 367, 24092, 12, 2562, 315, 3423, 14, 1744, 837, 267, 4866, 14, 740, 8, 288, 437, 3911, 10167, 3481, 8, 355, 2073, 12, 355, 1101, 14, 362, 8, 3103, 63, 2339, 12, 1177, 14, 1001, 3430, 3103, 63, 2339, 2522, 355, 2562, 14, 362, 8, 3103, 63, 2339, 395, 355, 24092, 12, 288, 776, 267, 776, 339, 1050, 63, 8327, 8, 2374, 9, 421, 199, 533, 437, 3911, 10167, 1563, 8, 10167, 7302, 304, 272, 408, 20609, 402, 376, 282, 15740, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 2073, 12, 2909, 12, 536, 304, 267, 408, 9345, 314, 6258, 1041, 267, 291, 423, 1927, 275, 2073, 267, 291, 423, 354, 275, 289, 14381, 1985, 14, 1213, 12737, 469, 354, 14, 1213, 342, 7063, 267, 291, 423, 929, 275, 488, 267, 291, 423, 4561, 275, 715, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 6258, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 2808, 8, 277, 304, 267, 408, 6531, 314, 2243, 506, 13810, 5309, 314, 2061, 1678, 1240, 1041, 267, 372, 291, 423, 4561, 421, 199, 533, 437, 3911, 10167, 3481, 8, 33, 3911, 10167, 1563, 304, 272, 408, 20609, 402, 376, 282, 15740, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 2073, 12, 2909, 12, 536, 12, 2562, 304, 267, 408, 9345, 314, 6258, 1041, 267, 1613, 11027, 826, 721, 1927, 12, 2909, 12, 536, 9, 267, 291, 423, 1532, 275, 2562, 398, 1056, 275, 4145, 14, 362, 8, 70, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 9, 398, 340, 1056, 14, 1205, 63, 600, 1137, 3101, 63, 3593, 26, 288, 485, 10186, 14, 705, 480, 6049, 1133, 2342, 805, 531, 288, 372, 398, 862, 26, 288, 1056, 14, 1001, 22957, 1107, 63, 585, 937, 267, 871, 4067, 26, 288, 485, 10186, 14, 705, 480, 1944, 372, 63, 585, 3086, 531, 267, 871, 1722, 26, 288, 485, 10186, 14, 705, 480, 2364, 3866, 531, 339, 347, 7485, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 641, 1041, 267, 1056, 275, 4145, 14, 362, 8, 288, 289, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 12, 1862, 8871, 1162, 582, 298, 17, 3570, 267, 776, 398, 340, 1056, 14, 1205, 63, 600, 508, 3101, 63, 3593, 26, 288, 291, 423, 929, 275, 715, 267, 587, 26, 288, 485, 10186, 14, 705, 480, 6049, 1133, 7485, 641, 805, 450, 83, 737, 450, 83, 401, 291, 423, 1532, 12, 291, 423, 1927, 9, 339, 347, 7485, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 2331, 1041, 267, 1056, 275, 4145, 14, 362, 8, 288, 289, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 12, 1862, 8871, 1162, 582, 298, 16, 3570, 267, 776, 398, 340, 1056, 14, 1205, 63, 600, 508, 3101, 63, 3593, 26, 288, 291, 423, 929, 275, 756, 267, 587, 26, 288, 485, 10186, 14, 705, 8, 355, 298, 6049, 1133, 7485, 2331 ]
[ 11532, 367, 376, 19282, 282, 15740, 14880, 1893, 3261, 402, 282, 2243, 1041, 199, 199, 646, 2050, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 21966, 63, 10926, 12, 17711, 7302, 199, 504, 8846, 14, 1297, 492, 6392, 63, 2339, 12, 6392, 63, 14110, 12, 3101, 63, 3593, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 29865, 275, 298, 5777, 2, 199, 3103, 63, 48, 10789, 275, 298, 21746, 2, 199, 3103, 63, 568, 8851, 275, 298, 18957, 2, 199, 199, 3472, 63, 2339, 275, 298, 65, 15740, 6258, 2, 199, 199, 30929, 63, 15476, 63, 10926, 275, 5236, 14, 6700, 8, 272, 469, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 568, 8851, 12, 849, 29, 797, 304, 6277, 14, 4871, 12, 272, 789, 199, 9, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 14110, 304, 6277, 14, 633, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 48, 10789, 12, 849, 16420, 5236, 14, 6700, 8, 288, 469, 5107, 14, 875, 26, 510, 568, 63, 15476, 63, 10926, 93, 267, 2318, 267, 5236, 14, 7012, 8, 3103, 63, 29865, 12, 849, 16420, 5236, 14, 6700, 8, 288, 469, 5107, 14, 875, 26, 510, 568, 63, 15476, 63, 10926, 93, 267, 2318, 272, 789, 199, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 282, 15740, 24563, 1041, 272, 2073, 275, 1101, 59, 3103, 63, 14110, 61, 339, 862, 26, 267, 1177, 275, 4145, 14, 362, 8, 1927, 12, 2653, 29, 709, 9, 272, 871, 4145, 14, 3924, 14, 7718, 6700, 26, 267, 485, 10186, 14, 705, 8, 288, 298, 7718, 2073, 503, 4177, 315, 2897, 14, 2654, 1455, 921, 370, 2195, 2851, 2, 267, 776, 267, 372, 756, 272, 871, 4145, 14, 3924, 14, 20349, 26, 267, 485, 10186, 14, 705, 480, 1944, 7475, 370, 2243, 737, 450, 83, 401, 2073, 9, 267, 372, 756, 339, 4866, 275, 942, 272, 30541, 275, 1101, 59, 3103, 63, 48, 10789, 61, 272, 367, 10713, 1507, 12, 10713, 315, 30541, 14, 1744, 837, 267, 4866, 14, 740, 8, 288, 437, 3911, 10167, 19909, 8, 355, 2073, 12, 355, 1101, 14, 362, 8, 3103, 63, 2339, 12, 1177, 14, 1001, 3430, 3103, 63, 2339, 2522, 355, 10713, 14, 362, 8, 3103, 63, 2339, 395, 355, 10713, 1507, 12, 355, 10713, 59, 3103, 63, 568, 8851, 467, 288, 776, 267, 776, 339, 3423, 275, 1101, 59, 3103, 63, 29865, 61, 272, 367, 24092, 12, 2562, 315, 3423, 14, 1744, 837, 267, 4866, 14, 740, 8, 288, 437, 3911, 10167, 3481, 8, 355, 2073, 12, 355, 1101, 14, 362, 8, 3103, 63, 2339, 12, 1177, 14, 1001, 3430, 3103, 63, 2339, 2522, 355, 2562, 14, 362, 8, 3103, 63, 2339, 395, 355, 24092, 12, 288, 776, 267, 776, 339, 1050, 63, 8327, 8, 2374, 9, 421, 199, 533, 437, 3911, 10167, 1563, 8, 10167, 7302, 304, 272, 408, 20609, 402, 376, 282, 15740, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 2073, 12, 2909, 12, 536, 304, 267, 408, 9345, 314, 6258, 1041, 267, 291, 423, 1927, 275, 2073, 267, 291, 423, 354, 275, 289, 14381, 1985, 14, 1213, 12737, 469, 354, 14, 1213, 342, 7063, 267, 291, 423, 929, 275, 488, 267, 291, 423, 4561, 275, 715, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 6258, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 2808, 8, 277, 304, 267, 408, 6531, 314, 2243, 506, 13810, 5309, 314, 2061, 1678, 1240, 1041, 267, 372, 291, 423, 4561, 421, 199, 533, 437, 3911, 10167, 3481, 8, 33, 3911, 10167, 1563, 304, 272, 408, 20609, 402, 376, 282, 15740, 6258, 1041, 339, 347, 636, 826, 721, 277, 12, 2073, 12, 2909, 12, 536, 12, 2562, 304, 267, 408, 9345, 314, 6258, 1041, 267, 1613, 11027, 826, 721, 1927, 12, 2909, 12, 536, 9, 267, 291, 423, 1532, 275, 2562, 398, 1056, 275, 4145, 14, 362, 8, 70, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 9, 398, 340, 1056, 14, 1205, 63, 600, 1137, 3101, 63, 3593, 26, 288, 485, 10186, 14, 705, 480, 6049, 1133, 2342, 805, 531, 288, 372, 398, 862, 26, 288, 1056, 14, 1001, 22957, 1107, 63, 585, 937, 267, 871, 4067, 26, 288, 485, 10186, 14, 705, 480, 1944, 372, 63, 585, 3086, 531, 267, 871, 1722, 26, 288, 485, 10186, 14, 705, 480, 2364, 3866, 531, 339, 347, 7485, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 641, 1041, 267, 1056, 275, 4145, 14, 362, 8, 288, 289, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 12, 1862, 8871, 1162, 582, 298, 17, 3570, 267, 776, 398, 340, 1056, 14, 1205, 63, 600, 508, 3101, 63, 3593, 26, 288, 291, 423, 929, 275, 715, 267, 587, 26, 288, 485, 10186, 14, 705, 480, 6049, 1133, 7485, 641, 805, 450, 83, 737, 450, 83, 401, 291, 423, 1532, 12, 291, 423, 1927, 9, 339, 347, 7485, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 2243, 2331, 1041, 267, 1056, 275, 4145, 14, 362, 8, 288, 289, 14381, 277, 423, 1927, 16152, 277, 423, 1532, 10750, 2653, 29, 709, 12, 1862, 8871, 1162, 582, 298, 16, 3570, 267, 776, 398, 340, 1056, 14, 1205, 63, 600, 508, 3101, 63, 3593, 26, 288, 291, 423, 929, 275, 756, 267, 587, 26, 288, 485, 10186, 14, 705, 8, 355, 298, 6049, 1133, 7485, 2331, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
webostin/django-btc
tests/m2m_through_regress/tests.py
68
9143
from __future__ import unicode_literals from django.core import management from django.contrib.auth.models import User from django.test import TestCase from django.utils.six import StringIO from .models import (Person, Group, Membership, UserMembership, Car, Driver, CarDriver) class M2MThroughTestCase(TestCase): def test_everything(self): bob = Person.objects.create(name="Bob") jim = Person.objects.create(name="Jim") rock = Group.objects.create(name="Rock") roll = Group.objects.create(name="Roll") frank = User.objects.create_user("frank", "frank@example.com", "password") jane = User.objects.create_user("jane", "jane@example.com", "password") Membership.objects.create(person=bob, group=rock) Membership.objects.create(person=bob, group=roll) Membership.objects.create(person=jim, group=rock) self.assertQuerysetEqual( bob.group_set.all(), [ "<Group: Rock>", "<Group: Roll>", ], ordered=False ) self.assertQuerysetEqual( roll.members.all(), [ "<Person: Bob>", ] ) self.assertRaises(AttributeError, setattr, bob, "group_set", []) self.assertRaises(AttributeError, setattr, roll, "members", []) self.assertRaises(AttributeError, rock.members.create, name="Anne") self.assertRaises(AttributeError, bob.group_set.create, name="Funk") UserMembership.objects.create(user=frank, group=rock) UserMembership.objects.create(user=frank, group=roll) UserMembership.objects.create(user=jane, group=rock) self.assertQuerysetEqual( frank.group_set.all(), [ "<Group: Rock>", "<Group: Roll>", ], ordered=False ) self.assertQuerysetEqual( roll.user_members.all(), [ "<User: frank>", ] ) def test_serialization(self): "m2m-through models aren't serialized as m2m fields. Refs #8134" p = Person.objects.create(name="Bob") g = Group.objects.create(name="Roll") m = Membership.objects.create(person=p, group=g) pks = {"p_pk": p.pk, "g_pk": g.pk, "m_pk": m.pk} out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertJSONEqual(out.getvalue().strip(), """[{"pk": %(m_pk)s, "model": "m2m_through_regress.membership", "fields": {"person": %(p_pk)s, "price": 100, "group": %(g_pk)s}}, {"pk": %(p_pk)s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk": %(g_pk)s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]""" % pks) out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="xml", indent=2, stdout=out) self.assertXMLEqual(out.getvalue().strip(), """ <?xml version="1.0" encoding="utf-8"?> <django-objects version="1.0"> <object pk="%(m_pk)s" model="m2m_through_regress.membership"> <field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">%(p_pk)s</field> <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">%(g_pk)s</field> <field type="IntegerField" name="price">100</field> </object> <object pk="%(p_pk)s" model="m2m_through_regress.person"> <field type="CharField" name="name">Bob</field> </object> <object pk="%(g_pk)s" model="m2m_through_regress.group"> <field type="CharField" name="name">Roll</field> </object> </django-objects> """.strip() % pks) def test_join_trimming(self): "Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254" bob = Person.objects.create(name="Bob") jim = Person.objects.create(name="Jim") rock = Group.objects.create(name="Rock") roll = Group.objects.create(name="Roll") Membership.objects.create(person=bob, group=rock) Membership.objects.create(person=jim, group=rock, price=50) Membership.objects.create(person=bob, group=roll, price=50) self.assertQuerysetEqual( rock.members.filter(membership__price=50), [ "<Person: Jim>", ] ) self.assertQuerysetEqual( bob.group_set.filter(membership__price=50), [ "<Group: Roll>", ] ) class ToFieldThroughTests(TestCase): def setUp(self): self.car = Car.objects.create(make="Toyota") self.driver = Driver.objects.create(name="Ryan Briscoe") CarDriver.objects.create(car=self.car, driver=self.driver) # We are testing if wrong objects get deleted due to using wrong # field value in m2m queries. So, it is essential that the pk # numberings do not match. # Create one intentionally unused driver to mix up the autonumbering self.unused_driver = Driver.objects.create(name="Barney Gumble") # And two intentionally unused cars. self.unused_car1 = Car.objects.create(make="Trabant") self.unused_car2 = Car.objects.create(make="Wartburg") def test_to_field(self): self.assertQuerysetEqual( self.car.drivers.all(), ["<Driver: Ryan Briscoe>"] ) def test_to_field_reverse(self): self.assertQuerysetEqual( self.driver.car_set.all(), ["<Car: Toyota>"] ) def test_to_field_clear_reverse(self): self.driver.car_set.clear() self.assertQuerysetEqual( self.driver.car_set.all(), []) def test_to_field_clear(self): self.car.drivers.clear() self.assertQuerysetEqual( self.car.drivers.all(), []) # Low level tests for _add_items and _remove_items. We test these methods # because .add/.remove aren't available for m2m fields with through, but # through is the only way to set to_field currently. We do want to make # sure these methods are ready if the ability to use .add or .remove with # to_field relations is added some day. def test_add(self): self.assertQuerysetEqual( self.car.drivers.all(), ["<Driver: Ryan Briscoe>"] ) # Yikes - barney is going to drive... self.car.drivers._add_items('car', 'driver', self.unused_driver) self.assertQuerysetEqual( self.car.drivers.all(), ["<Driver: Barney Gumble>", "<Driver: Ryan Briscoe>"] ) def test_add_null(self): nullcar = Car.objects.create(make=None) with self.assertRaises(ValueError): nullcar.drivers._add_items('car', 'driver', self.unused_driver) def test_add_related_null(self): nulldriver = Driver.objects.create(name=None) with self.assertRaises(ValueError): self.car.drivers._add_items('car', 'driver', nulldriver) def test_add_reverse(self): car2 = Car.objects.create(make="Honda") self.assertQuerysetEqual( self.driver.car_set.all(), ["<Car: Toyota>"] ) self.driver.car_set._add_items('driver', 'car', car2) self.assertQuerysetEqual( self.driver.car_set.all(), ["<Car: Toyota>", "<Car: Honda>"], ordered=False ) def test_add_null_reverse(self): nullcar = Car.objects.create(make=None) with self.assertRaises(ValueError): self.driver.car_set._add_items('driver', 'car', nullcar) def test_add_null_reverse_related(self): nulldriver = Driver.objects.create(name=None) with self.assertRaises(ValueError): nulldriver.car_set._add_items('driver', 'car', self.car) def test_remove(self): self.assertQuerysetEqual( self.car.drivers.all(), ["<Driver: Ryan Briscoe>"] ) self.car.drivers._remove_items('car', 'driver', self.driver) self.assertQuerysetEqual( self.car.drivers.all(), []) def test_remove_reverse(self): self.assertQuerysetEqual( self.driver.car_set.all(), ["<Car: Toyota>"] ) self.driver.car_set._remove_items('driver', 'car', self.car) self.assertQuerysetEqual( self.driver.car_set.all(), []) class ThroughLoadDataTestCase(TestCase): fixtures = ["m2m_through"] def test_sequence_creation(self): "Check that sequences on an m2m_through are created for the through model, not a phantom auto-generated m2m table. Refs #11107" out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertJSONEqual(out.getvalue().strip(), """[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}]""")
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 199, 504, 1275, 992, 492, 334, 7344, 12, 5611, 12, 24326, 12, 2876, 19480, 12, 14243, 12, 19447, 12, 272, 14243, 6158, 9, 421, 199, 533, 603, 18, 45, 26732, 1746, 8, 1746, 304, 339, 347, 511, 63, 14287, 2127, 8, 277, 304, 267, 26961, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 22593, 531, 267, 1335, 1017, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 42, 1017, 531, 398, 882, 346, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 50, 766, 531, 267, 11848, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 24363, 531, 398, 289, 4648, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 70, 4648, 401, 298, 70, 4648, 32, 2694, 14, 957, 401, 298, 2060, 531, 267, 1335, 5865, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 74, 5865, 401, 298, 74, 5865, 32, 2694, 14, 957, 401, 298, 2060, 531, 398, 24326, 14, 1462, 14, 981, 8, 5484, 29, 7913, 12, 1572, 29, 24892, 9, 267, 24326, 14, 1462, 14, 981, 8, 5484, 29, 7913, 12, 1572, 29, 2827, 9, 267, 24326, 14, 1462, 14, 981, 8, 5484, 29, 74, 1017, 12, 1572, 29, 24892, 9, 398, 291, 14, 7108, 8, 288, 26961, 14, 923, 63, 409, 14, 452, 1062, 359, 355, 3886, 2448, 26, 820, 766, 7166, 355, 3886, 2448, 26, 820, 14385, 7166, 288, 2156, 288, 7741, 29, 797, 267, 776, 398, 291, 14, 7108, 8, 288, 11848, 14, 6334, 14, 452, 1062, 359, 355, 3886, 7344, 26, 699, 2873, 7166, 288, 1622, 267, 776, 398, 291, 14, 1855, 8, 10227, 12, 5371, 12, 26961, 12, 298, 923, 63, 409, 401, 3073, 267, 291, 14, 1855, 8, 10227, 12, 5371, 12, 11848, 12, 298, 6334, 401, 3073, 398, 291, 14, 1855, 8, 10227, 12, 882, 346, 14, 6334, 14, 981, 12, 536, 628, 2493, 685, 531, 267, 291, 14, 1855, 8, 10227, 12, 26961, 14, 923, 63, 409, 14, 981, 12, 536, 628, 38, 1778, 531, 398, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 70, 4648, 12, 1572, 29, 24892, 9, 267, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 70, 4648, 12, 1572, 29, 2827, 9, 267, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 74, 5865, 12, 1572, 29, 24892, 9, 398, 291, 14, 7108, 8, 288, 289, 4648, 14, 923, 63, 409, 14, 452, 1062, 359, 355, 3886, 2448, 26, 820, 766, 7166, 355, 3886, 2448, 26, 820, 14385, 7166, 288, 2156, 288, 7741, 29, 797, 267, 776, 398, 291, 14, 7108, 8, 288, 11848, 14, 751, 63, 6334, 14, 452, 1062, 359, 355, 3886, 1899, 26, 289, 4648, 7166, 288, 1622, 267, 776, 339, 347, 511, 63, 12161, 8, 277, 304, 267, 298, 77, 18, 77, 13, 8304, 1709, 10621, 1133, 6380, 465, 333, 18, 77, 1504, 14, 22165, 327, 24, 7582, 2, 398, 299, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 22593, 531, 267, 486, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 24363, 531, 267, 333, 275, 24326, 14, 1462, 14, 981, 8, 5484, 29, 80, 12, 1572, 29, 71, 9, 398, 3803, 83, 275, 2420, 80, 63, 2051, 582, 299, 14, 2051, 12, 298, 71, 63, 2051, 582, 486, 14, 2051, 12, 298, 77, 63, 2051, 582, 333, 14, 2051, 93, 398, 734, 275, 5228, 342, 267, 10041, 14, 1250, 63, 1531, 480, 2724, 576, 401, 298, 77, 18, 77, 63, 8304, 63, 25883, 401, 1475, 628, 1001, 401, 3839, 29, 548, 9, 267, 291, 14, 479, 6243, 591, 8, 548, 14, 7150, 1252, 1913, 1062, 408, 59, 6641, 2051, 582, 2818, 77, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 13105, 401, 298, 955, 582, 2420, 5484, 582, 2818, 80, 63, 2051, 9, 83, 12, 298, 4777, 582, 2948, 12, 298, 923, 582, 2818, 71, 63, 2051, 9, 83, 13459, 2420, 2051, 582, 2818, 80, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 401, 298, 955, 582, 2420, 354, 582, 298, 22593, 3570, 1386, 2420, 2051, 582, 2818, 71, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 401, 298, 955, 582, 2420, 354, 582, 298, 24363, 3570, 11049, 624, 450, 3803, 83, 9, 398, 734, 275, 5228, 342, 267, 10041, 14, 1250, 63, 1531, 480, 2724, 576, 401, 298, 77, 18, 77, 63, 8304, 63, 25883, 401, 1475, 628, 1652, 401, 288, 4363, 29, 18, 12, 3839, 29, 548, 9, 267, 291, 14, 479, 4317, 591, 8, 548, 14, 7150, 1252, 1913, 1062, 408, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 1624, 13, 24, 24327, 199, 28, 1176, 13, 1462, 1015, 628, 17, 14, 16, 1743, 523, 665, 785, 3803, 17662, 77, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 13105, 1743, 272, 665, 698, 370, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 2, 536, 628, 5484, 2, 4668, 628, 4089, 10939, 5640, 1743, 2840, 80, 63, 2051, 9, 83, 1108, 698, 30, 272, 665, 698, 370, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 2, 536, 628, 923, 2, 4668, 628, 4089, 10939, 5640, 1743, 2840, 71, 63, 2051, 9, 83, 1108, 698, 30, 272, 665, 698, 730, 628, 3901, 2, 536, 628, 4777, 1743, 1960, 1108, 698, 30, 523, 3068, 785, 30, 523, 665, 785, 3803, 17662, 80, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 1743, 272, 665, 698, 730, 628, 2183, 2, 536, 628, 354, 1743, 22593, 1108, 698, 30, 523, 3068, 785, 30, 523, 665, 785, 3803, 17662, 71, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 1743, 272, 665, 698, 730, 628, 2183, 2 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 199, 504, 1275, 992, 492, 334, 7344, 12, 5611, 12, 24326, 12, 2876, 19480, 12, 14243, 12, 19447, 12, 272, 14243, 6158, 9, 421, 199, 533, 603, 18, 45, 26732, 1746, 8, 1746, 304, 339, 347, 511, 63, 14287, 2127, 8, 277, 304, 267, 26961, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 22593, 531, 267, 1335, 1017, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 42, 1017, 531, 398, 882, 346, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 50, 766, 531, 267, 11848, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 24363, 531, 398, 289, 4648, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 70, 4648, 401, 298, 70, 4648, 32, 2694, 14, 957, 401, 298, 2060, 531, 267, 1335, 5865, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 74, 5865, 401, 298, 74, 5865, 32, 2694, 14, 957, 401, 298, 2060, 531, 398, 24326, 14, 1462, 14, 981, 8, 5484, 29, 7913, 12, 1572, 29, 24892, 9, 267, 24326, 14, 1462, 14, 981, 8, 5484, 29, 7913, 12, 1572, 29, 2827, 9, 267, 24326, 14, 1462, 14, 981, 8, 5484, 29, 74, 1017, 12, 1572, 29, 24892, 9, 398, 291, 14, 7108, 8, 288, 26961, 14, 923, 63, 409, 14, 452, 1062, 359, 355, 3886, 2448, 26, 820, 766, 7166, 355, 3886, 2448, 26, 820, 14385, 7166, 288, 2156, 288, 7741, 29, 797, 267, 776, 398, 291, 14, 7108, 8, 288, 11848, 14, 6334, 14, 452, 1062, 359, 355, 3886, 7344, 26, 699, 2873, 7166, 288, 1622, 267, 776, 398, 291, 14, 1855, 8, 10227, 12, 5371, 12, 26961, 12, 298, 923, 63, 409, 401, 3073, 267, 291, 14, 1855, 8, 10227, 12, 5371, 12, 11848, 12, 298, 6334, 401, 3073, 398, 291, 14, 1855, 8, 10227, 12, 882, 346, 14, 6334, 14, 981, 12, 536, 628, 2493, 685, 531, 267, 291, 14, 1855, 8, 10227, 12, 26961, 14, 923, 63, 409, 14, 981, 12, 536, 628, 38, 1778, 531, 398, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 70, 4648, 12, 1572, 29, 24892, 9, 267, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 70, 4648, 12, 1572, 29, 2827, 9, 267, 2876, 19480, 14, 1462, 14, 981, 8, 751, 29, 74, 5865, 12, 1572, 29, 24892, 9, 398, 291, 14, 7108, 8, 288, 289, 4648, 14, 923, 63, 409, 14, 452, 1062, 359, 355, 3886, 2448, 26, 820, 766, 7166, 355, 3886, 2448, 26, 820, 14385, 7166, 288, 2156, 288, 7741, 29, 797, 267, 776, 398, 291, 14, 7108, 8, 288, 11848, 14, 751, 63, 6334, 14, 452, 1062, 359, 355, 3886, 1899, 26, 289, 4648, 7166, 288, 1622, 267, 776, 339, 347, 511, 63, 12161, 8, 277, 304, 267, 298, 77, 18, 77, 13, 8304, 1709, 10621, 1133, 6380, 465, 333, 18, 77, 1504, 14, 22165, 327, 24, 7582, 2, 398, 299, 275, 8028, 14, 1462, 14, 981, 8, 354, 628, 22593, 531, 267, 486, 275, 5611, 14, 1462, 14, 981, 8, 354, 628, 24363, 531, 267, 333, 275, 24326, 14, 1462, 14, 981, 8, 5484, 29, 80, 12, 1572, 29, 71, 9, 398, 3803, 83, 275, 2420, 80, 63, 2051, 582, 299, 14, 2051, 12, 298, 71, 63, 2051, 582, 486, 14, 2051, 12, 298, 77, 63, 2051, 582, 333, 14, 2051, 93, 398, 734, 275, 5228, 342, 267, 10041, 14, 1250, 63, 1531, 480, 2724, 576, 401, 298, 77, 18, 77, 63, 8304, 63, 25883, 401, 1475, 628, 1001, 401, 3839, 29, 548, 9, 267, 291, 14, 479, 6243, 591, 8, 548, 14, 7150, 1252, 1913, 1062, 408, 59, 6641, 2051, 582, 2818, 77, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 13105, 401, 298, 955, 582, 2420, 5484, 582, 2818, 80, 63, 2051, 9, 83, 12, 298, 4777, 582, 2948, 12, 298, 923, 582, 2818, 71, 63, 2051, 9, 83, 13459, 2420, 2051, 582, 2818, 80, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 401, 298, 955, 582, 2420, 354, 582, 298, 22593, 3570, 1386, 2420, 2051, 582, 2818, 71, 63, 2051, 9, 83, 12, 298, 1238, 582, 298, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 401, 298, 955, 582, 2420, 354, 582, 298, 24363, 3570, 11049, 624, 450, 3803, 83, 9, 398, 734, 275, 5228, 342, 267, 10041, 14, 1250, 63, 1531, 480, 2724, 576, 401, 298, 77, 18, 77, 63, 8304, 63, 25883, 401, 1475, 628, 1652, 401, 288, 4363, 29, 18, 12, 3839, 29, 548, 9, 267, 291, 14, 479, 4317, 591, 8, 548, 14, 7150, 1252, 1913, 1062, 408, 199, 28, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 1624, 13, 24, 24327, 199, 28, 1176, 13, 1462, 1015, 628, 17, 14, 16, 1743, 523, 665, 785, 3803, 17662, 77, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 13105, 1743, 272, 665, 698, 370, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 2, 536, 628, 5484, 2, 4668, 628, 4089, 10939, 5640, 1743, 2840, 80, 63, 2051, 9, 83, 1108, 698, 30, 272, 665, 698, 370, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 2, 536, 628, 923, 2, 4668, 628, 4089, 10939, 5640, 1743, 2840, 71, 63, 2051, 9, 83, 1108, 698, 30, 272, 665, 698, 730, 628, 3901, 2, 536, 628, 4777, 1743, 1960, 1108, 698, 30, 523, 3068, 785, 30, 523, 665, 785, 3803, 17662, 80, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 5484, 1743, 272, 665, 698, 730, 628, 2183, 2, 536, 628, 354, 1743, 22593, 1108, 698, 30, 523, 3068, 785, 30, 523, 665, 785, 3803, 17662, 71, 63, 2051, 9, 83, 2, 1402, 628, 77, 18, 77, 63, 8304, 63, 25883, 14, 923, 1743, 272, 665, 698, 730, 628, 2183, 2, 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,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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 ]
bobrock/eden
static/scripts/tools/jsmin.py
513
7471
#!/usr/bin/python # This code is original from jsmin by Douglas Crockford, it was translated to # Python by Baruch Even. The original code had the following copyright and # license. # # /* jsmin.c # 2007-01-08 # # Copyright (c) 2002 Douglas Crockford (www.crockford.com) # # 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 shall be used for Good, not Evil. # # 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. # */ from StringIO import StringIO def jsmin(js): ins = StringIO(js) outs = StringIO() JavascriptMinify().minify(ins, outs) str = outs.getvalue() if len(str) > 0 and str[0] == '\n': str = str[1:] return str def isAlphanum(c): """return true if the character is a letter, digit, underscore, dollar sign, or non-ASCII character. """ return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or (c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126)); class UnterminatedComment(Exception): pass class UnterminatedStringLiteral(Exception): pass class UnterminatedRegularExpression(Exception): pass class JavascriptMinify(object): def _outA(self): self.outstream.write(self.theA) def _outB(self): self.outstream.write(self.theB) def _get(self): """return the next character from stdin. Watch out for lookahead. If the character is a control character, translate it to a space or linefeed. """ c = self.theLookahead self.theLookahead = None if c == None: c = self.instream.read(1) if c >= ' ' or c == '\n': return c if c == '': # EOF return '\000' if c == '\r': return '\n' return ' ' def _peek(self): self.theLookahead = self._get() return self.theLookahead def _next(self): """get the next character, excluding comments. peek() is used to see if a '/' is followed by a '/' or '*'. """ c = self._get() if c == '/': p = self._peek() if p == '/': c = self._get() while c > '\n': c = self._get() return c if p == '*': c = self._get() while 1: c = self._get() if c == '*': if self._peek() == '/': self._get() return ' ' if c == '\000': raise UnterminatedComment() return c def _action(self, action): """do something! What you do is determined by the argument: 1 Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B. (Delete A). 3 Get the next B. (Delete B). action treats a string as a single character. Wow! action recognizes a regular expression if it is preceded by ( or , or =. """ if action <= 1: self._outA() if action <= 2: self.theA = self.theB if self.theA == "'" or self.theA == '"': while 1: self._outA() self.theA = self._get() if self.theA == self.theB: break if self.theA <= '\n': raise UnterminatedStringLiteral() if self.theA == '\\': self._outA() self.theA = self._get() if action <= 3: self.theB = self._next() if self.theB == '/' and (self.theA == '(' or self.theA == ',' or self.theA == '=' or self.theA == ':' or self.theA == '[' or self.theA == '?' or self.theA == '!' or self.theA == '&' or self.theA == '|'): self._outA() self._outB() while 1: self.theA = self._get() if self.theA == '/': break elif self.theA == '\\': self._outA() self.theA = self._get() elif self.theA <= '\n': raise UnterminatedRegularExpression() self._outA() self.theB = self._next() def _jsmin(self): """Copy the input to the output, deleting the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed. """ self.theA = '\n' self._action(3) while self.theA != '\000': if self.theA == ' ': if isAlphanum(self.theB): self._action(1) else: self._action(2) elif self.theA == '\n': if self.theB in ['{', '[', '(', '+', '-']: self._action(1) elif self.theB == ' ': self._action(3) else: if isAlphanum(self.theB): self._action(1) else: self._action(2) else: if self.theB == ' ': if isAlphanum(self.theA): self._action(1) else: self._action(3) elif self.theB == '\n': if self.theA in ['}', ']', ')', '+', '-', '"', '\'']: self._action(1) else: if isAlphanum(self.theA): self._action(1) else: self._action(3) else: self._action(1) def minify(self, instream, outstream): self.instream = instream self.outstream = outstream self.theA = None self.thaB = None self.theLookahead = None self._jsmin() self.instream.close() if __name__ == '__main__': import sys jsm = JavascriptMinify() jsm.minify(sys.stdin, sys.stdout)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 961, 1233, 365, 3379, 687, 8586, 827, 701, 577, 810, 3528, 305, 445, 24892, 18090, 12, 652, 1990, 14598, 370, 199, 3, 2018, 701, 12377, 2133, 22207, 14, 710, 3379, 1233, 10530, 314, 2569, 4248, 436, 199, 3, 4190, 14, 199, 3, 199, 3, 13505, 8586, 827, 14, 67, 199, 3, 259, 10219, 13, 614, 13, 2036, 199, 3, 199, 3, 1898, 334, 67, 9, 14790, 577, 810, 3528, 305, 445, 24892, 18090, 221, 334, 1544, 14, 67, 24892, 18090, 14, 957, 9, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 3, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 3, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 199, 3, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 199, 3, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 710, 2290, 10989, 506, 1202, 367, 22311, 12, 440, 662, 29792, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 11589, 199, 199, 504, 5228, 492, 5228, 199, 199, 318, 8586, 827, 8, 3596, 304, 272, 5261, 275, 5228, 8, 3596, 9, 272, 31557, 275, 5228, 342, 272, 31861, 4649, 2021, 1252, 827, 2021, 8, 3617, 12, 31557, 9, 272, 620, 275, 31557, 14, 7150, 342, 272, 340, 822, 8, 495, 9, 690, 378, 436, 620, 59, 16, 61, 508, 1557, 78, 356, 267, 620, 275, 620, 59, 17, 2938, 272, 372, 620, 199, 199, 318, 365, 2439, 16014, 453, 8, 67, 304, 272, 408, 1107, 2549, 340, 314, 4528, 365, 282, 8082, 12, 10964, 12, 18888, 12, 1779, 366, 25317, 2070, 12, 503, 2222, 13, 12292, 4528, 14, 272, 408, 272, 372, 3666, 67, 2356, 283, 65, 7, 436, 286, 2695, 283, 90, 358, 503, 334, 67, 2356, 283, 16, 7, 436, 286, 2695, 283, 25, 358, 503, 288, 334, 67, 2356, 283, 33, 7, 436, 286, 2695, 283, 58, 358, 503, 286, 508, 14135, 503, 286, 508, 25271, 503, 286, 508, 22548, 503, 334, 67, 365, 440, 488, 436, 6206, 8, 67, 9, 690, 21572, 16674, 199, 199, 533, 1910, 18375, 7488, 8, 1726, 304, 272, 986, 199, 199, 533, 1910, 18375, 1558, 7621, 8, 1726, 304, 272, 986, 199, 199, 533, 1910, 18375, 16038, 9093, 8, 1726, 304, 272, 986, 199, 199, 533, 31861, 4649, 2021, 8, 785, 304, 339, 347, 485, 548, 33, 8, 277, 304, 267, 291, 14, 548, 1745, 14, 952, 8, 277, 14, 1589, 33, 9, 272, 347, 485, 548, 34, 8, 277, 304, 267, 291, 14, 548, 1745, 14, 952, 8, 277, 14, 1589, 34, 9, 339, 347, 485, 362, 8, 277, 304, 267, 408, 1107, 314, 2163, 4528, 687, 9009, 14, 29075, 734, 367, 16076, 14, 982, 1779, 314, 4528, 365, 282, 3304, 4528, 12, 9028, 652, 370, 282, 4601, 503, 1779, 1004, 3871, 14, 267, 408, 267, 286, 275, 291, 14, 1589, 20926, 10938, 267, 291, 14, 1589, 20926, 10938, 275, 488, 267, 340, 286, 508, 488, 26, 288, 286, 275, 291, 14, 262, 1745, 14, 739, 8, 17, 9, 267, 340, 286, 2356, 283, 283, 503, 286, 508, 1557, 78, 356, 288, 372, 286, 267, 340, 286, 508, 8061, 327, 9027, 288, 372, 1557, 1493, 7, 267, 340, 286, 508, 1557, 82, 356, 288, 372, 1557, 78, 7, 267, 372, 283, 283, 339, 347, 485, 13164, 8, 277, 304, 267, 291, 14, 1589, 20926, 10938, 275, 291, 423, 362, 342, 267, 372, 291, 14, 1589, 20926, 10938, 339, 347, 485, 2184, 8, 277, 304, 267, 408, 362, 314, 2163, 4528, 12, 28529, 6786, 14, 15094, 342, 365, 1202, 370, 1937, 1779, 340, 282, 7324, 365, 9437, 701, 282, 7324, 503, 6438, 1370, 267, 408, 267, 286, 275, 291, 423, 362, 342, 267, 340, 286, 508, 20549, 288, 299, 275, 291, 423, 13164, 342, 288, 340, 299, 508, 20549, 355, 286, 275, 291, 423, 362, 342, 355, 1830, 286, 690, 1557, 78, 356, 490, 286, 275, 291, 423, 362, 342, 355, 372, 286, 288, 340, 299, 508, 22969, 355, 286, 275, 291, 423, 362, 342, 355, 1830, 413, 26, 490, 286, 275, 291, 423, 362, 342, 490, 340, 286, 508, 22969, 717, 340, 291, 423, 13164, 342, 508, 20549, 1169, 291, 423, 362, 342, 1169, 372, 283, 283, 490, 340, 286, 508, 1557, 1493, 356, 717, 746, 1910, 18375, 7488, 342, 398, 372, 286, 339, 347, 485, 1287, 8, 277, 12, 1595, 304, 267, 408, 1117, 6020, 1, 14791, 1265, 886, 365, 12037, 701, 314, 1423, 26, 1779, 413, 257, 7242, 437, 14, 11247, 699, 370, 437, 14, 2372, 314, 2163, 699, 14, 1779, 499, 257, 11247, 699, 370, 437, 14, 2372, 314, 2163, 699, 14, 334, 5392, 437, 680, 1779, 650, 257, 2372, 314, 2163, 699, 14, 334, 5392, 699, 680, 1779, 1595, 20991, 1956, 282, 1059, 465, 282, 2849, 4528, 14, 644, 583, 1, 1779, 1595, 17319, 6491, 282, 5578, 3965, 340, 652, 365, 9222, 770, 701, 334, 503, 2360, 503, 275, 14, 267, 408, 267, 340, 1595, 2695, 413, 26, 288, 291, 423, 548, 33, 342, 398, 340, 1595, 2695, 499, 26, 288, 291, 14, 1589, 33, 275, 291, 14, 1589, 34 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 961, 1233, 365, 3379, 687, 8586, 827, 701, 577, 810, 3528, 305, 445, 24892, 18090, 12, 652, 1990, 14598, 370, 199, 3, 2018, 701, 12377, 2133, 22207, 14, 710, 3379, 1233, 10530, 314, 2569, 4248, 436, 199, 3, 4190, 14, 199, 3, 199, 3, 13505, 8586, 827, 14, 67, 199, 3, 259, 10219, 13, 614, 13, 2036, 199, 3, 199, 3, 1898, 334, 67, 9, 14790, 577, 810, 3528, 305, 445, 24892, 18090, 221, 334, 1544, 14, 67, 24892, 18090, 14, 957, 9, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 3, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 3, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 199, 3, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 199, 3, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 710, 2290, 10989, 506, 1202, 367, 22311, 12, 440, 662, 29792, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 11589, 199, 199, 504, 5228, 492, 5228, 199, 199, 318, 8586, 827, 8, 3596, 304, 272, 5261, 275, 5228, 8, 3596, 9, 272, 31557, 275, 5228, 342, 272, 31861, 4649, 2021, 1252, 827, 2021, 8, 3617, 12, 31557, 9, 272, 620, 275, 31557, 14, 7150, 342, 272, 340, 822, 8, 495, 9, 690, 378, 436, 620, 59, 16, 61, 508, 1557, 78, 356, 267, 620, 275, 620, 59, 17, 2938, 272, 372, 620, 199, 199, 318, 365, 2439, 16014, 453, 8, 67, 304, 272, 408, 1107, 2549, 340, 314, 4528, 365, 282, 8082, 12, 10964, 12, 18888, 12, 1779, 366, 25317, 2070, 12, 503, 2222, 13, 12292, 4528, 14, 272, 408, 272, 372, 3666, 67, 2356, 283, 65, 7, 436, 286, 2695, 283, 90, 358, 503, 334, 67, 2356, 283, 16, 7, 436, 286, 2695, 283, 25, 358, 503, 288, 334, 67, 2356, 283, 33, 7, 436, 286, 2695, 283, 58, 358, 503, 286, 508, 14135, 503, 286, 508, 25271, 503, 286, 508, 22548, 503, 334, 67, 365, 440, 488, 436, 6206, 8, 67, 9, 690, 21572, 16674, 199, 199, 533, 1910, 18375, 7488, 8, 1726, 304, 272, 986, 199, 199, 533, 1910, 18375, 1558, 7621, 8, 1726, 304, 272, 986, 199, 199, 533, 1910, 18375, 16038, 9093, 8, 1726, 304, 272, 986, 199, 199, 533, 31861, 4649, 2021, 8, 785, 304, 339, 347, 485, 548, 33, 8, 277, 304, 267, 291, 14, 548, 1745, 14, 952, 8, 277, 14, 1589, 33, 9, 272, 347, 485, 548, 34, 8, 277, 304, 267, 291, 14, 548, 1745, 14, 952, 8, 277, 14, 1589, 34, 9, 339, 347, 485, 362, 8, 277, 304, 267, 408, 1107, 314, 2163, 4528, 687, 9009, 14, 29075, 734, 367, 16076, 14, 982, 1779, 314, 4528, 365, 282, 3304, 4528, 12, 9028, 652, 370, 282, 4601, 503, 1779, 1004, 3871, 14, 267, 408, 267, 286, 275, 291, 14, 1589, 20926, 10938, 267, 291, 14, 1589, 20926, 10938, 275, 488, 267, 340, 286, 508, 488, 26, 288, 286, 275, 291, 14, 262, 1745, 14, 739, 8, 17, 9, 267, 340, 286, 2356, 283, 283, 503, 286, 508, 1557, 78, 356, 288, 372, 286, 267, 340, 286, 508, 8061, 327, 9027, 288, 372, 1557, 1493, 7, 267, 340, 286, 508, 1557, 82, 356, 288, 372, 1557, 78, 7, 267, 372, 283, 283, 339, 347, 485, 13164, 8, 277, 304, 267, 291, 14, 1589, 20926, 10938, 275, 291, 423, 362, 342, 267, 372, 291, 14, 1589, 20926, 10938, 339, 347, 485, 2184, 8, 277, 304, 267, 408, 362, 314, 2163, 4528, 12, 28529, 6786, 14, 15094, 342, 365, 1202, 370, 1937, 1779, 340, 282, 7324, 365, 9437, 701, 282, 7324, 503, 6438, 1370, 267, 408, 267, 286, 275, 291, 423, 362, 342, 267, 340, 286, 508, 20549, 288, 299, 275, 291, 423, 13164, 342, 288, 340, 299, 508, 20549, 355, 286, 275, 291, 423, 362, 342, 355, 1830, 286, 690, 1557, 78, 356, 490, 286, 275, 291, 423, 362, 342, 355, 372, 286, 288, 340, 299, 508, 22969, 355, 286, 275, 291, 423, 362, 342, 355, 1830, 413, 26, 490, 286, 275, 291, 423, 362, 342, 490, 340, 286, 508, 22969, 717, 340, 291, 423, 13164, 342, 508, 20549, 1169, 291, 423, 362, 342, 1169, 372, 283, 283, 490, 340, 286, 508, 1557, 1493, 356, 717, 746, 1910, 18375, 7488, 342, 398, 372, 286, 339, 347, 485, 1287, 8, 277, 12, 1595, 304, 267, 408, 1117, 6020, 1, 14791, 1265, 886, 365, 12037, 701, 314, 1423, 26, 1779, 413, 257, 7242, 437, 14, 11247, 699, 370, 437, 14, 2372, 314, 2163, 699, 14, 1779, 499, 257, 11247, 699, 370, 437, 14, 2372, 314, 2163, 699, 14, 334, 5392, 437, 680, 1779, 650, 257, 2372, 314, 2163, 699, 14, 334, 5392, 699, 680, 1779, 1595, 20991, 1956, 282, 1059, 465, 282, 2849, 4528, 14,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
apollo13/ansible
lib/ansible/module_utils/facts/system/python.py
232
1999
# This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. from __future__ import (absolute_import, division, print_function) __metaclass__ = type import sys from ansible.module_utils.facts.collector import BaseFactCollector try: # Check if we have SSLContext support from ssl import create_default_context, SSLContext del create_default_context del SSLContext HAS_SSLCONTEXT = True except ImportError: HAS_SSLCONTEXT = False class PythonFactCollector(BaseFactCollector): name = 'python' _fact_ids = set() def collect(self, module=None, collected_facts=None): python_facts = {} python_facts['python'] = { 'version': { 'major': sys.version_info[0], 'minor': sys.version_info[1], 'micro': sys.version_info[2], 'releaselevel': sys.version_info[3], 'serial': sys.version_info[4] }, 'version_info': list(sys.version_info), 'executable': sys.executable, 'has_sslcontext': HAS_SSLCONTEXT } try: python_facts['python']['type'] = sys.subversion[0] except AttributeError: try: python_facts['python']['type'] = sys.implementation.name except AttributeError: python_facts['python']['type'] = None return python_facts
gpl-3.0
[ 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 10946, 492, 3523, 24704, 12852, 199, 199, 893, 26, 272, 327, 2670, 340, 781, 1172, 7799, 2998, 2291, 272, 687, 6149, 492, 1218, 63, 885, 63, 1100, 12, 7799, 2998, 272, 2150, 1218, 63, 885, 63, 1100, 272, 2150, 7799, 2998, 272, 7509, 63, 5413, 9059, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 5413, 9059, 275, 756, 421, 199, 533, 2018, 24704, 12852, 8, 1563, 24704, 12852, 304, 272, 536, 275, 283, 1548, 7, 272, 485, 7783, 63, 1580, 275, 663, 342, 339, 347, 8775, 8, 277, 12, 859, 29, 403, 12, 13736, 63, 5047, 29, 403, 304, 267, 2366, 63, 5047, 275, 1052, 267, 2366, 63, 5047, 459, 1548, 418, 275, 469, 288, 283, 1023, 356, 469, 355, 283, 8452, 356, 984, 14, 1023, 63, 815, 59, 16, 467, 355, 283, 11067, 356, 984, 14, 1023, 63, 815, 59, 17, 467, 355, 283, 6453, 356, 984, 14, 1023, 63, 815, 59, 18, 467, 355, 283, 3221, 1896, 356, 984, 14, 1023, 63, 815, 59, 19, 467, 355, 283, 2171, 356, 984, 14, 1023, 63, 815, 59, 20, 61, 288, 1660, 288, 283, 1023, 63, 815, 356, 769, 8, 1274, 14, 1023, 63, 815, 395, 288, 283, 5904, 356, 984, 14, 5904, 12, 288, 283, 1989, 63, 4266, 1100, 356, 7509, 63, 5413, 9059, 267, 789, 398, 862, 26, 288, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 984, 14, 954, 1023, 59, 16, 61, 267, 871, 4281, 26, 288, 862, 26, 355, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 984, 14, 12236, 14, 354, 288, 871, 4281, 26, 355, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 488, 398, 372, 2366, 63, 5047, 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 ]
[ 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 5047, 14, 10946, 492, 3523, 24704, 12852, 199, 199, 893, 26, 272, 327, 2670, 340, 781, 1172, 7799, 2998, 2291, 272, 687, 6149, 492, 1218, 63, 885, 63, 1100, 12, 7799, 2998, 272, 2150, 1218, 63, 885, 63, 1100, 272, 2150, 7799, 2998, 272, 7509, 63, 5413, 9059, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 5413, 9059, 275, 756, 421, 199, 533, 2018, 24704, 12852, 8, 1563, 24704, 12852, 304, 272, 536, 275, 283, 1548, 7, 272, 485, 7783, 63, 1580, 275, 663, 342, 339, 347, 8775, 8, 277, 12, 859, 29, 403, 12, 13736, 63, 5047, 29, 403, 304, 267, 2366, 63, 5047, 275, 1052, 267, 2366, 63, 5047, 459, 1548, 418, 275, 469, 288, 283, 1023, 356, 469, 355, 283, 8452, 356, 984, 14, 1023, 63, 815, 59, 16, 467, 355, 283, 11067, 356, 984, 14, 1023, 63, 815, 59, 17, 467, 355, 283, 6453, 356, 984, 14, 1023, 63, 815, 59, 18, 467, 355, 283, 3221, 1896, 356, 984, 14, 1023, 63, 815, 59, 19, 467, 355, 283, 2171, 356, 984, 14, 1023, 63, 815, 59, 20, 61, 288, 1660, 288, 283, 1023, 63, 815, 356, 769, 8, 1274, 14, 1023, 63, 815, 395, 288, 283, 5904, 356, 984, 14, 5904, 12, 288, 283, 1989, 63, 4266, 1100, 356, 7509, 63, 5413, 9059, 267, 789, 398, 862, 26, 288, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 984, 14, 954, 1023, 59, 16, 61, 267, 871, 4281, 26, 288, 862, 26, 355, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 984, 14, 12236, 14, 354, 288, 871, 4281, 26, 355, 2366, 63, 5047, 459, 1548, 2545, 466, 418, 275, 488, 398, 372, 2366, 63, 5047, 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, 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,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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 ]
rolandmansilla/microblog
flask/lib/python2.7/site-packages/pip/exceptions.py
32
7741
"""Exceptions used throughout package""" from __future__ import absolute_import from itertools import chain, groupby, repeat from pip._vendor.six import iteritems class PipError(Exception): """Base pip exception""" class InstallationError(PipError): """General exception during installation""" class UninstallationError(PipError): """General exception during uninstallation""" class DistributionNotFound(InstallationError): """Raised when a distribution cannot be found to satisfy a requirement""" class RequirementsFileParseError(InstallationError): """Raised when a general error occurs parsing a requirements file line.""" class BestVersionAlreadyInstalled(PipError): """Raised when the most up-to-date version of a package is already installed.""" class BadCommand(PipError): """Raised when virtualenv or a command is not found""" class CommandError(PipError): """Raised when there is an error in command-line arguments""" class PreviousBuildDirError(PipError): """Raised when there's a previous conflicting build directory""" class InvalidWheelFilename(InstallationError): """Invalid wheel filename.""" class UnsupportedWheel(InstallationError): """Unsupported wheel.""" class HashErrors(InstallationError): """Multiple HashError instances rolled into one for reporting""" def __init__(self): self.errors = [] def append(self, error): self.errors.append(error) def __str__(self): lines = [] self.errors.sort(key=lambda e: e.order) for cls, errors_of_cls in groupby(self.errors, lambda e: e.__class__): lines.append(cls.head) lines.extend(e.body() for e in errors_of_cls) if lines: return '\n'.join(lines) def __nonzero__(self): return bool(self.errors) def __bool__(self): return self.__nonzero__() class HashError(InstallationError): """ A failure to verify a package against known-good hashes :cvar order: An int sorting hash exception classes by difficulty of recovery (lower being harder), so the user doesn't bother fretting about unpinned packages when he has deeper issues, like VCS dependencies, to deal with. Also keeps error reports in a deterministic order. :cvar head: A section heading for display above potentially many exceptions of this kind :ivar req: The InstallRequirement that triggered this error. This is pasted on after the exception is instantiated, because it's not typically available earlier. """ req = None head = '' def body(self): """Return a summary of me for display under the heading. This default implementation simply prints a description of the triggering requirement. :param req: The InstallRequirement that provoked this error, with populate_link() having already been called """ return ' %s' % self._requirement_name() def __str__(self): return '%s\n%s' % (self.head, self.body()) def _requirement_name(self): """Return a description of the requirement that triggered me. This default implementation returns long description of the req, with line numbers """ return str(self.req) if self.req else 'unknown package' class VcsHashUnsupported(HashError): """A hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.""" order = 0 head = ("Can't verify hashes for these requirements because we don't " "have a way to hash version control repositories:") class DirectoryUrlHashUnsupported(HashError): """A hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.""" order = 1 head = ("Can't verify hashes for these file:// requirements because they " "point to directories:") class HashMissing(HashError): """A hash was needed for a requirement but is absent.""" order = 2 head = ('Hashes are required in --require-hashes mode, but they are ' 'missing from some requirements. Here is a list of those ' 'requirements along with the hashes their downloaded archives ' 'actually had. Add lines like these to your requirements files to ' 'prevent tampering. (If you did not enable --require-hashes ' 'manually, note that it turns on automatically when any package ' 'has a hash.)') def __init__(self, gotten_hash): """ :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded """ self.gotten_hash = gotten_hash def body(self): from pip.utils.hashes import FAVORITE_HASH # Dodge circular import. package_name = (self.req.req if self.req and # In case someone feeds something # downright stupid to # InstallRequirement's constructor: getattr(self.req, 'req', None) else 'unknown package') return ' %s --hash=%s:%s' % (package_name, FAVORITE_HASH, self.gotten_hash) class HashUnpinned(HashError): """A requirement had a hash specified but was not pinned to a specific version.""" order = 3 head = ('In --require-hashes mode, all requirements must have their ' 'versions pinned with ==. These do not:') class HashMismatch(HashError): """ Distribution file hash values don't match. :ivar package_name: The name of the package that triggered the hash mismatch. Feel free to write to this after the exception is raise to improve its error message. """ order = 4 head = ('THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS ' 'FILE. If you have updated the package versions, please update ' 'the hashes. Otherwise, examine the package contents carefully; ' 'someone may have tampered with them.') def __init__(self, allowed, gots): """ :param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the files under suspicion """ self.allowed = allowed self.gots = gots def body(self): return ' %s:\n%s' % (self._requirement_name(), self._hash_comparison()) def _hash_comparison(self): """ Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef """ def hash_then_or(hash_name): # For now, all the decent hashes have 6-char names, so we can get # away with hard-coding space literals. return chain([hash_name], repeat(' or')) lines = [] for hash_name, expecteds in iteritems(self.allowed): prefix = hash_then_or(hash_name) lines.extend((' Expected %s %s' % (next(prefix), e)) for e in expecteds) lines.append(' Got %s\n' % self.gots[hash_name].hexdigest()) prefix = ' or' return '\n'.join(lines)
bsd-3-clause
[ 624, 16836, 1202, 23088, 2559, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 7975, 492, 6036, 12, 20371, 12, 11982, 199, 199, 504, 7305, 423, 9884, 14, 4174, 492, 10849, 421, 199, 533, 510, 711, 547, 8, 1726, 304, 272, 408, 1563, 7305, 1919, 624, 421, 199, 533, 26866, 547, 8, 32457, 547, 304, 272, 408, 14109, 1919, 5309, 12096, 624, 421, 199, 533, 1910, 23048, 547, 8, 32457, 547, 304, 272, 408, 14109, 1919, 5309, 625, 23048, 624, 421, 199, 533, 11839, 4667, 8, 31456, 547, 304, 272, 408, 16894, 1380, 282, 4084, 3913, 506, 1911, 370, 23082, 282, 10685, 624, 421, 199, 533, 18513, 1470, 1173, 9123, 8, 31456, 547, 304, 272, 408, 16894, 1380, 282, 8605, 1125, 11058, 6057, 282, 9760, 570, 1004, 1041, 421, 199, 533, 699, 597, 3353, 16760, 21268, 8, 32457, 547, 304, 272, 408, 16894, 1380, 314, 4750, 1536, 13, 475, 13, 602, 1015, 402, 282, 2559, 365, 2575, 272, 4903, 1041, 421, 199, 533, 8857, 3110, 8, 32457, 547, 304, 272, 408, 16894, 1380, 19128, 503, 282, 1414, 365, 440, 1911, 624, 421, 199, 533, 14393, 8, 32457, 547, 304, 272, 408, 16894, 1380, 2337, 365, 376, 1125, 315, 1414, 13, 604, 2368, 624, 421, 199, 533, 26902, 3425, 3567, 547, 8, 32457, 547, 304, 272, 408, 16894, 1380, 2337, 1159, 282, 4136, 28204, 1900, 2082, 624, 421, 199, 533, 6378, 25663, 8117, 8, 31456, 547, 304, 272, 408, 3364, 9989, 1788, 1041, 421, 199, 533, 19022, 25663, 8, 31456, 547, 304, 272, 408, 12647, 9989, 1041, 421, 199, 533, 16101, 9298, 8, 31456, 547, 304, 272, 408, 8433, 16101, 547, 4454, 20182, 1146, 1901, 1373, 367, 17290, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2550, 275, 942, 339, 347, 5666, 8, 277, 12, 1125, 304, 267, 291, 14, 2550, 14, 740, 8, 705, 9, 339, 347, 636, 495, 721, 277, 304, 267, 2385, 275, 942, 267, 291, 14, 2550, 14, 3191, 8, 498, 29, 2734, 325, 26, 325, 14, 1648, 9, 267, 367, 843, 12, 2552, 63, 1618, 63, 1886, 315, 20371, 8, 277, 14, 2550, 12, 2400, 325, 26, 325, 855, 533, 18580, 288, 2385, 14, 740, 8, 1886, 14, 2993, 9, 288, 2385, 14, 2880, 8, 69, 14, 2030, 342, 367, 325, 315, 2552, 63, 1618, 63, 1886, 9, 267, 340, 2385, 26, 288, 372, 1557, 78, 1370, 904, 8, 1278, 9, 339, 347, 636, 10262, 721, 277, 304, 267, 372, 2155, 8, 277, 14, 2550, 9, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 291, 855, 10262, 4533, 421, 199, 533, 16101, 547, 8, 31456, 547, 304, 272, 408, 272, 437, 5988, 370, 4911, 282, 2559, 6169, 6040, 13, 8302, 14647, 339, 520, 26781, 1865, 26, 1626, 1109, 13351, 2631, 1919, 3992, 701, 23976, 17323, 402, 267, 24201, 334, 2325, 3769, 12159, 424, 395, 880, 314, 922, 3181, 1133, 26962, 289, 3292, 1337, 267, 3595, 625, 7751, 7439, 6117, 1380, 946, 965, 477, 15033, 10876, 12, 2839, 23563, 267, 5124, 12, 370, 7962, 543, 14, 6121, 18578, 1125, 13924, 315, 282, 267, 25286, 1865, 14, 272, 520, 26781, 4854, 26, 437, 3420, 16631, 367, 2929, 3432, 18994, 5002, 267, 4967, 402, 642, 4928, 272, 520, 7725, 2648, 26, 710, 13276, 17947, 626, 15572, 642, 1125, 14, 961, 365, 267, 19099, 471, 641, 2410, 314, 1919, 365, 17544, 12, 2952, 652, 1159, 440, 267, 13609, 2808, 14119, 14, 339, 408, 272, 2648, 275, 488, 272, 4854, 275, 2125, 339, 347, 2396, 8, 277, 304, 267, 408, 1767, 282, 6212, 402, 562, 367, 2929, 1334, 314, 16631, 14, 398, 961, 849, 4514, 9329, 14767, 282, 1369, 402, 314, 267, 6804, 316, 10685, 14, 398, 520, 635, 2648, 26, 710, 13276, 17947, 626, 24074, 7620, 642, 1125, 12, 543, 288, 13904, 63, 1073, 342, 9445, 2575, 2757, 2797, 398, 408, 267, 372, 283, 259, 450, 83, 7, 450, 291, 423, 12434, 63, 354, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 60, 78, 5, 83, 7, 450, 334, 277, 14, 2993, 12, 291, 14, 2030, 1012, 339, 347, 485, 12434, 63, 354, 8, 277, 304, 267, 408, 1767, 282, 1369, 402, 314, 10685, 626, 15572, 562, 14, 398, 961, 849, 4514, 2529, 1846, 1369, 402, 314, 2648, 12, 543, 267, 1004, 5579, 398, 408, 267, 372, 620, 8, 277, 14, 2103, 9, 340, 291, 14, 2103, 587, 283, 5187, 2559, 7, 421, 199, 533, 812, 1259, 3476, 12647, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 2741, 367, 282, 1015, 13, 2785, 13, 2253, 13, 6788, 10685, 12, 1325, 272, 781, 2793, 1133, 1172, 282, 1083, 367, 25223, 5204, 1041, 339, 1865, 275, 378, 272, 4854, 275, 1689, 6049, 1133, 4911, 14647, 367, 3520, 9760, 2952, 781, 2793, 1133, 298, 288, 298, 7804, 282, 4340, 370, 2631, 1015, 3304, 23737, 9107, 421, 199, 533, 15191, 6417, 3476, 12647, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 2741, 367, 282, 1015, 13, 2785, 13, 2253, 13, 6788, 10685, 12, 1325, 272, 781, 2793, 1133, 1172, 282, 1083, 367, 25223, 5204, 1041, 339, 1865, 275, 413, 272, 4854, 275, 1689, 6049, 1133, 4911, 14647, 367, 3520, 570, 921, 9760, 2952, 2985, 298, 288, 298, 1403, 370, 6602, 9107, 421, 199, 533, 16101, 7718, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 4346, 367, 282, 10685, 1325, 365, 9552, 1041, 339, 1865, 275, 499, 272, 4854, 275, 661, 31660, 787, 1415, 315, 1553, 4365, 13, 12428, 818, 12, 1325, 2985, 787, 283, 288, 283, 4752, 687, 2005, 9760, 14, 11842, 365, 282, 769, 402, 5204, 283, 288, 283, 7538, 3180, 543, 314, 14647, 3932, 13557, 25993, 283, 288, 283, 2442, 3163, 10530, 14, 2654, 2385, 2839, 3520, 370, 2195, 9760, 1584, 370, 283, 288, 283, 657, 782, 3052, 311, 15663, 14, 334, 3917, 1265, 8103, 440, 4756, 1553, 4365, 13, 12428, 283, 288, 283, 1237, 3163, 12, 5317, 626, 652, 25449, 641, 5847, 1380, 1263, 2559, 283, 288, 283, 1989, 282, 2631, 4959, 358, 339, 347, 636, 826, 721, 277, 12, 4788, 724, 63, 2227, 304, 267, 408, 267, 520, 635, 4788, 724, 63, 2227, 26, 710, 2631, 402, 314, 334 ]
[ 16836, 1202, 23088, 2559, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 7975, 492, 6036, 12, 20371, 12, 11982, 199, 199, 504, 7305, 423, 9884, 14, 4174, 492, 10849, 421, 199, 533, 510, 711, 547, 8, 1726, 304, 272, 408, 1563, 7305, 1919, 624, 421, 199, 533, 26866, 547, 8, 32457, 547, 304, 272, 408, 14109, 1919, 5309, 12096, 624, 421, 199, 533, 1910, 23048, 547, 8, 32457, 547, 304, 272, 408, 14109, 1919, 5309, 625, 23048, 624, 421, 199, 533, 11839, 4667, 8, 31456, 547, 304, 272, 408, 16894, 1380, 282, 4084, 3913, 506, 1911, 370, 23082, 282, 10685, 624, 421, 199, 533, 18513, 1470, 1173, 9123, 8, 31456, 547, 304, 272, 408, 16894, 1380, 282, 8605, 1125, 11058, 6057, 282, 9760, 570, 1004, 1041, 421, 199, 533, 699, 597, 3353, 16760, 21268, 8, 32457, 547, 304, 272, 408, 16894, 1380, 314, 4750, 1536, 13, 475, 13, 602, 1015, 402, 282, 2559, 365, 2575, 272, 4903, 1041, 421, 199, 533, 8857, 3110, 8, 32457, 547, 304, 272, 408, 16894, 1380, 19128, 503, 282, 1414, 365, 440, 1911, 624, 421, 199, 533, 14393, 8, 32457, 547, 304, 272, 408, 16894, 1380, 2337, 365, 376, 1125, 315, 1414, 13, 604, 2368, 624, 421, 199, 533, 26902, 3425, 3567, 547, 8, 32457, 547, 304, 272, 408, 16894, 1380, 2337, 1159, 282, 4136, 28204, 1900, 2082, 624, 421, 199, 533, 6378, 25663, 8117, 8, 31456, 547, 304, 272, 408, 3364, 9989, 1788, 1041, 421, 199, 533, 19022, 25663, 8, 31456, 547, 304, 272, 408, 12647, 9989, 1041, 421, 199, 533, 16101, 9298, 8, 31456, 547, 304, 272, 408, 8433, 16101, 547, 4454, 20182, 1146, 1901, 1373, 367, 17290, 624, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2550, 275, 942, 339, 347, 5666, 8, 277, 12, 1125, 304, 267, 291, 14, 2550, 14, 740, 8, 705, 9, 339, 347, 636, 495, 721, 277, 304, 267, 2385, 275, 942, 267, 291, 14, 2550, 14, 3191, 8, 498, 29, 2734, 325, 26, 325, 14, 1648, 9, 267, 367, 843, 12, 2552, 63, 1618, 63, 1886, 315, 20371, 8, 277, 14, 2550, 12, 2400, 325, 26, 325, 855, 533, 18580, 288, 2385, 14, 740, 8, 1886, 14, 2993, 9, 288, 2385, 14, 2880, 8, 69, 14, 2030, 342, 367, 325, 315, 2552, 63, 1618, 63, 1886, 9, 267, 340, 2385, 26, 288, 372, 1557, 78, 1370, 904, 8, 1278, 9, 339, 347, 636, 10262, 721, 277, 304, 267, 372, 2155, 8, 277, 14, 2550, 9, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 291, 855, 10262, 4533, 421, 199, 533, 16101, 547, 8, 31456, 547, 304, 272, 408, 272, 437, 5988, 370, 4911, 282, 2559, 6169, 6040, 13, 8302, 14647, 339, 520, 26781, 1865, 26, 1626, 1109, 13351, 2631, 1919, 3992, 701, 23976, 17323, 402, 267, 24201, 334, 2325, 3769, 12159, 424, 395, 880, 314, 922, 3181, 1133, 26962, 289, 3292, 1337, 267, 3595, 625, 7751, 7439, 6117, 1380, 946, 965, 477, 15033, 10876, 12, 2839, 23563, 267, 5124, 12, 370, 7962, 543, 14, 6121, 18578, 1125, 13924, 315, 282, 267, 25286, 1865, 14, 272, 520, 26781, 4854, 26, 437, 3420, 16631, 367, 2929, 3432, 18994, 5002, 267, 4967, 402, 642, 4928, 272, 520, 7725, 2648, 26, 710, 13276, 17947, 626, 15572, 642, 1125, 14, 961, 365, 267, 19099, 471, 641, 2410, 314, 1919, 365, 17544, 12, 2952, 652, 1159, 440, 267, 13609, 2808, 14119, 14, 339, 408, 272, 2648, 275, 488, 272, 4854, 275, 2125, 339, 347, 2396, 8, 277, 304, 267, 408, 1767, 282, 6212, 402, 562, 367, 2929, 1334, 314, 16631, 14, 398, 961, 849, 4514, 9329, 14767, 282, 1369, 402, 314, 267, 6804, 316, 10685, 14, 398, 520, 635, 2648, 26, 710, 13276, 17947, 626, 24074, 7620, 642, 1125, 12, 543, 288, 13904, 63, 1073, 342, 9445, 2575, 2757, 2797, 398, 408, 267, 372, 283, 259, 450, 83, 7, 450, 291, 423, 12434, 63, 354, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 60, 78, 5, 83, 7, 450, 334, 277, 14, 2993, 12, 291, 14, 2030, 1012, 339, 347, 485, 12434, 63, 354, 8, 277, 304, 267, 408, 1767, 282, 1369, 402, 314, 10685, 626, 15572, 562, 14, 398, 961, 849, 4514, 2529, 1846, 1369, 402, 314, 2648, 12, 543, 267, 1004, 5579, 398, 408, 267, 372, 620, 8, 277, 14, 2103, 9, 340, 291, 14, 2103, 587, 283, 5187, 2559, 7, 421, 199, 533, 812, 1259, 3476, 12647, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 2741, 367, 282, 1015, 13, 2785, 13, 2253, 13, 6788, 10685, 12, 1325, 272, 781, 2793, 1133, 1172, 282, 1083, 367, 25223, 5204, 1041, 339, 1865, 275, 378, 272, 4854, 275, 1689, 6049, 1133, 4911, 14647, 367, 3520, 9760, 2952, 781, 2793, 1133, 298, 288, 298, 7804, 282, 4340, 370, 2631, 1015, 3304, 23737, 9107, 421, 199, 533, 15191, 6417, 3476, 12647, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 2741, 367, 282, 1015, 13, 2785, 13, 2253, 13, 6788, 10685, 12, 1325, 272, 781, 2793, 1133, 1172, 282, 1083, 367, 25223, 5204, 1041, 339, 1865, 275, 413, 272, 4854, 275, 1689, 6049, 1133, 4911, 14647, 367, 3520, 570, 921, 9760, 2952, 2985, 298, 288, 298, 1403, 370, 6602, 9107, 421, 199, 533, 16101, 7718, 8, 3476, 547, 304, 272, 408, 33, 2631, 1990, 4346, 367, 282, 10685, 1325, 365, 9552, 1041, 339, 1865, 275, 499, 272, 4854, 275, 661, 31660, 787, 1415, 315, 1553, 4365, 13, 12428, 818, 12, 1325, 2985, 787, 283, 288, 283, 4752, 687, 2005, 9760, 14, 11842, 365, 282, 769, 402, 5204, 283, 288, 283, 7538, 3180, 543, 314, 14647, 3932, 13557, 25993, 283, 288, 283, 2442, 3163, 10530, 14, 2654, 2385, 2839, 3520, 370, 2195, 9760, 1584, 370, 283, 288, 283, 657, 782, 3052, 311, 15663, 14, 334, 3917, 1265, 8103, 440, 4756, 1553, 4365, 13, 12428, 283, 288, 283, 1237, 3163, 12, 5317, 626, 652, 25449, 641, 5847, 1380, 1263, 2559, 283, 288, 283, 1989, 282, 2631, 4959, 358, 339, 347, 636, 826, 721, 277, 12, 4788, 724, 63, 2227, 304, 267, 408, 267, 520, 635, 4788, 724, 63, 2227, 26, 710, 2631, 402, 314, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
5j9/wikitextparser
wikitextparser/_config.py
1
6983
"""Utilities to override default configurations.""" from collections import defaultdict as _defaultdict from typing import Iterable as _Iterable def _plant_trie(strings: _Iterable[str]) -> dict: """Create a Trie out of a list of words and return an atomic regex pattern. The corresponding Regex should match much faster than a simple Regex union. """ # plant the trie trie = {} for string in strings: d = trie for char in string: d[char] = char in d and d[char] or {} d = d[char] d[''] = None # EOS return trie def _pattern(trie: dict) -> str: """Convert a trie to a regex pattern.""" if '' in trie: if len(trie) == 1: return '' optional = True del trie[''] else: optional = False subpattern_to_chars = _defaultdict(list) for char, sub_trie in trie.items(): subpattern = _pattern(sub_trie) subpattern_to_chars[subpattern].append(char) alts = [] for subpattern, chars in subpattern_to_chars.items(): if len(chars) == 1: alts.append(chars[0] + subpattern) else: chars.sort(reverse=True) alts.append('[' + ''.join(chars) + ']' + subpattern) if len(alts) == 1: result = alts[0] if optional: if len(result) == 1: result += '?+' else: # more than one character in alts[0] result = '(?:' + result + ')?+' else: alts.sort(reverse=True) result = '(?>' + '|'.join(alts) + ')' if optional: result += '?+' return result def regex_pattern(words: _Iterable[str]) -> bytes: """Convert words to a regex pattern that matches any of them.""" return _pattern(_plant_trie(words)).encode() # Contents of the some of the extension tags can be parsed as wikitext. # For example, templates are valid inside the poem tag: # <poem>{{text|Hi!}}</poem> # But not within math or source or ... # for more information about the <categorytree> tag see: # https://www.mediawiki.org/wiki/Extension:CategoryTree# # The_.7B.7B.23categorytree.7D.7D_parser_function _parsable_tag_extensions = { 'categorytree', 'gallery', 'imagemap', 'includeonly', 'indicator', 'inputbox', 'noinclude', 'onlyinclude', 'poem', 'ref', 'references', 'section', } # For a complete list of extension tags on your wiki, see the # "Parser extension tags" section at the end of [[Special:Version]]. # <templatedata> and <includeonly> were manually added to the following lists. # A simple trick to find out if a tag should be listed here or not is as # follows: # Create the {{text}} template in your wiki (You can copy the source code from # English Wikipedia). Then save the following in a test page: # {{text|0<tagname>1}}2</tagname>3}}4 # If the ending braces in the rendered result appear between 3 and 4, then # `tagname` is not an extension tag (e.g. <small>). Otherwise, i.e. if those # braces appear between 1 and 2 or completely don't show up, `tagname` is # a tag extension (e.g.: <pre>). _unparsable_tag_extensions = { 'ce', 'charinsert', 'chem', 'graph', 'hiero', 'languages', # Extension:Translate 'mapframe', 'maplink', 'math', 'nowiki', 'pagelist', 'pagequality', 'pages', 'pre', 'score', 'source', 'syntaxhighlight', 'templatedata', 'templatestyles', 'timeline', } _tag_extensions = _parsable_tag_extensions | _unparsable_tag_extensions # Copied from DefaultSettings.php # https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php # See also: https://www.mediawiki.org/wiki/Help:Links#External_links _bare_external_link_schemes = { 'bitcoin:', 'ftp://', 'ftps://', 'geo:', 'git://', 'gopher://', 'http://', 'https://', 'irc://', 'ircs://', 'magnet:', 'mailto:', 'mms://', 'news:', 'nntp://', 'redis://', 'sftp://', 'sip:', 'sips:', 'sms:', 'ssh://', 'svn://', 'tel:', 'telnet://', 'urn:', 'worldwind://', 'xmpp:', # '//' } # generated using dev/html_tag_names.py _valid_html_tag_names = { 's', 'ins', 'code', 'b', 'ol', 'i', 'h5', 'th', 'dt', 'td', 'wbr', 'div', 'big', 'p', 'small', 'h4', 'tt', 'span', 'font', 'ruby', 'h3', 'dfn', 'rb', 'li', 'h1', 'cite', 'dl', 'rtc', 'em', 'q', 'h2', 'samp', 'strike', 'time', 'blockquote', 'bdi', 'del', 'br', 'rp', 'hr', 'abbr', 'sub', 'u', 'kbd', 'table', 'rt', 'dd', 'var', 'ul', 'tr', 'center', 'data', 'strong', 'mark', 'h6', 'bdo', 'caption', 'sup'} _HTML_TAG_NAME = regex_pattern(_valid_html_tag_names) + br'\b' _parser_functions = { 'ARTICLEPAGENAME', 'ARTICLEPAGENAMEE', 'ARTICLESPACE', 'ARTICLESPACEE', 'BASEPAGENAME', 'BASEPAGENAMEE', 'CASCADINGSOURCES', 'CONTENTLANG', 'CONTENTLANGUAGE', 'CURRENTDAY', 'CURRENTDAY2', 'CURRENTDAYNAME', 'CURRENTDOW', 'CURRENTHOUR', 'CURRENTMONTH', 'CURRENTMONTH1', 'CURRENTMONTHABBREV', 'CURRENTMONTHNAME', 'CURRENTMONTHNAMEGEN', 'CURRENTTIME', 'CURRENTTIMESTAMP', 'CURRENTVERSION', 'CURRENTWEEK', 'CURRENTYEAR', 'DEFAULTCATEGORYSORT', 'DEFAULTSORT', 'DEFAULTSORTKEY', 'DIRECTIONMARK', 'DIRMARK', 'DISPLAYTITLE', 'FULLPAGENAME', 'FULLPAGENAMEE', 'LOCALDAY', 'LOCALDAY2', 'LOCALDAYNAME', 'LOCALDOW', 'LOCALHOUR', 'LOCALMONTH', 'LOCALMONTH1', 'LOCALMONTHABBREV', 'LOCALMONTHNAME', 'LOCALMONTHNAMEGEN', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCALWEEK', 'LOCALYEAR', 'NAMESPACE', 'NAMESPACEE', 'NAMESPACENUMBER', 'NUMBERINGROUP', 'NUMBEROFACTIVEUSERS', 'NUMBEROFADMINS', 'NUMBEROFARTICLES', 'NUMBEROFEDITS', 'NUMBEROFFILES', 'NUMBEROFPAGES', 'NUMBEROFUSERS', 'NUMBEROFVIEWS', 'NUMINGROUP', 'PAGEID', 'PAGELANGUAGE', 'PAGENAME', 'PAGENAMEE', 'PAGESINCAT', 'PAGESINCATEGORY', 'PAGESINNAMESPACE', 'PAGESINNS', 'PAGESIZE', 'PROTECTIONEXPIRY', 'PROTECTIONLEVEL', 'REVISIONDAY', 'REVISIONDAY2', 'REVISIONID', 'REVISIONMONTH', 'REVISIONMONTH1', 'REVISIONTIMESTAMP', 'REVISIONUSER', 'REVISIONYEAR', 'ROOTPAGENAME', 'ROOTPAGENAMEE', 'SCRIPTPATH', 'SERVER', 'SERVERNAME', 'SITENAME', 'STYLEPATH', 'SUBJECTPAGENAME', 'SUBJECTPAGENAMEE', 'SUBJECTSPACE', 'SUBJECTSPACEE', 'SUBPAGENAME', 'SUBPAGENAMEE', 'TALKPAGENAME', 'TALKPAGENAMEE', 'TALKSPACE', 'TALKSPACEE', 'anchorencode', 'canonicalurl', 'filepath', 'formatnum', 'fullurl', 'gender', 'grammar', 'int', 'lc', 'lcfirst', 'localurl', 'msg', 'msgnw', 'ns', 'nse', 'padleft', 'padright', 'plural', 'raw', 'safesubst', 'subst', 'uc', 'ucfirst', 'urlencode', }
gpl-3.0
[ 624, 22905, 370, 4278, 849, 13422, 1041, 421, 199, 504, 5055, 492, 10018, 465, 485, 21501, 199, 504, 14090, 492, 19937, 465, 485, 20852, 421, 199, 318, 485, 31655, 63, 599, 69, 8, 5465, 26, 485, 20852, 59, 495, 566, 1035, 1211, 26, 272, 408, 2499, 282, 377, 11317, 734, 402, 282, 769, 402, 5932, 436, 372, 376, 15374, 5163, 3851, 14, 339, 710, 5226, 12939, 1077, 1336, 8298, 12930, 2419, 282, 3486, 12939, 13629, 14, 272, 408, 272, 327, 1620, 867, 314, 3229, 69, 272, 3229, 69, 275, 1052, 272, 367, 1059, 315, 3326, 26, 267, 366, 275, 3229, 69, 267, 367, 1495, 315, 1059, 26, 288, 366, 59, 1560, 61, 275, 1495, 315, 366, 436, 366, 59, 1560, 61, 503, 1052, 288, 366, 275, 366, 59, 1560, 61, 267, 366, 459, 418, 275, 488, 221, 327, 662, 3100, 272, 372, 3229, 69, 421, 199, 318, 485, 3401, 8, 599, 69, 26, 1211, 9, 1035, 620, 26, 272, 408, 7306, 282, 3229, 69, 370, 282, 5163, 3851, 1041, 272, 340, 2125, 315, 3229, 69, 26, 267, 340, 822, 8, 599, 69, 9, 508, 413, 26, 288, 372, 2125, 267, 2716, 275, 715, 267, 2150, 3229, 69, 459, 418, 272, 587, 26, 267, 2716, 275, 756, 339, 30179, 63, 475, 63, 6574, 275, 485, 21501, 8, 513, 9, 339, 367, 1495, 12, 1007, 63, 599, 69, 315, 3229, 69, 14, 1744, 837, 267, 30179, 275, 485, 3401, 8, 954, 63, 599, 69, 9, 267, 30179, 63, 475, 63, 6574, 59, 954, 3401, 1055, 740, 8, 1560, 9, 339, 741, 1086, 275, 942, 272, 367, 30179, 12, 8365, 315, 30179, 63, 475, 63, 6574, 14, 1744, 837, 267, 340, 822, 8, 6574, 9, 508, 413, 26, 288, 741, 1086, 14, 740, 8, 6574, 59, 16, 61, 435, 30179, 9, 267, 587, 26, 288, 8365, 14, 3191, 8, 4471, 29, 549, 9, 288, 741, 1086, 14, 740, 360, 459, 435, 6522, 904, 8, 6574, 9, 435, 24840, 435, 30179, 9, 339, 340, 822, 8, 279, 1086, 9, 508, 413, 26, 267, 754, 275, 741, 1086, 59, 16, 61, 267, 340, 2716, 26, 288, 340, 822, 8, 1099, 9, 508, 413, 26, 355, 754, 847, 8720, 4786, 288, 587, 26, 221, 327, 1655, 2419, 1373, 4528, 315, 741, 1086, 59, 16, 61, 355, 754, 275, 17644, 4881, 435, 754, 435, 5320, 31, 4786, 272, 587, 26, 267, 741, 1086, 14, 3191, 8, 4471, 29, 549, 9, 267, 754, 275, 17644, 3524, 435, 21590, 904, 8, 279, 1086, 9, 435, 16107, 267, 340, 2716, 26, 288, 754, 847, 8720, 4786, 272, 372, 754, 421, 199, 318, 5163, 63, 3401, 8, 3148, 26, 485, 20852, 59, 495, 566, 1035, 2783, 26, 272, 408, 7306, 5932, 370, 282, 5163, 3851, 626, 4450, 1263, 402, 3062, 1041, 272, 372, 485, 3401, 1547, 31655, 63, 599, 69, 8, 3148, 4992, 2143, 342, 421, 199, 3, 6646, 83, 402, 314, 2005, 402, 314, 3329, 3762, 883, 506, 4565, 465, 17195, 505, 14, 199, 3, 2104, 2893, 12, 7009, 787, 1686, 6272, 314, 1115, 5633, 1947, 26, 199, 3, 259, 665, 555, 5633, 19386, 505, 92, 16106, 1, 4863, 1108, 555, 5633, 30, 199, 3, 11017, 440, 4453, 3473, 503, 1350, 503, 2263, 199, 3, 367, 1655, 2556, 3595, 314, 665, 3710, 2350, 30, 1947, 1937, 26, 199, 3, 4178, 921, 1544, 14, 4603, 6797, 14, 1308, 15, 6797, 15, 6382, 26, 7841, 3987, 3, 199, 3, 259, 710, 3754, 23, 34, 14, 23, 34, 14, 1789, 3710, 2350, 14, 23, 36, 14, 23, 36, 63, 2087, 63, 1593, 199, 63, 21152, 461, 63, 1450, 63, 5359, 275, 469, 272, 283, 3710, 2350, 297, 272, 283, 25372, 297, 272, 283, 1569, 1130, 297, 272, 283, 2613, 2118, 297, 272, 283, 15785, 297, 272, 283, 1210, 1977, 297, 272, 283, 889, 2613, 297, 272, 283, 2118, 2613, 297, 272, 283, 555, 5633, 297, 272, 283, 1121, 297, 272, 283, 12635, 297, 272, 283, 2792, 297, 199, 93, 199, 3, 2104, 282, 4890, 769, 402, 3329, 3762, 641, 2195, 17195, 12, 1937, 314, 199, 3, 298, 2842, 3329, 3762, 2, 3420, 737, 314, 1284, 402, 3474, 12246, 26, 3353, 20230, 199, 3, 665, 1160, 576, 30, 436, 665, 2613, 2118, 30, 4898, 10250, 3483, 370, 314, 221, 2569, 5548, 14, 199, 3, 437, 3486, 20907, 370, 2342, 734, 340, 282, 1947, 1077, 506, 10532, 2348, 503, 440, 365, 465, 199, 3, 11924, 26, 199, 3, 2790, 314, 8448, 505, 4863, 1978, 315, 2195, 17195, 334, 5556, 883, 1331, 314, 1350, 1233, 687, 199, 3, 20144, 644, 29386, 680, 9442, 3354, 314, 2569, 315, 282, 511, 2034, 26, 199, 3, 8448, 505, 92, 16, 28, 24173, 30, 17, 4863, 18, 1108, 24173, 30, 19, 4863, 20, 199, 3, 982, 314, 13401, 27158, 315, 314, 8018, 754, 7468, 3382, 650, 436, 841, 12, 2066, 199, 3, 658, 24173, 64, 365, 440, 376, 3329, 1947, 334, 69, 14, 71, 14, 665, 7241, 10121, 6630, 12, 284, 14, 69, 14, 340, 5204, 199, 3, 27158, 7468, 3382, 413, 436, 499, 503, 14793, 2793, 1133, 2498, 1536, 12, 658, 24173, 64, 365, 199, 3, 282, 1947, 3329, 334, 69, 14, 71, 16781, 665, 657, 10121, 199, 63, 324, 21152, 461, 63, 1450, 63, 5359, 275, 469, 272, 283, 301, 297, 272, 283, 1560, 3176, 297, 272, 283, 24448, 297, 272, 283, 2180, 297, 272, 283, 5812, 3478, 297, 272, 283, 13209, 297, 221, 327, 13282, 26, 18355, 272, 283, 1130, 1943, 297, 272, 283, 1130, 1073, 297, 272, 283, 3442, 297, 272, 283, 2131, 11545, 297, 272, 283, 1606, 513, 297, 272, 283, 1606, 9161, 297, 272, 283, 5856, 297, 272, 283, 657, 297, 272, 283, 3397, 297, 272, 283, 1365, 297, 272, 283, 7093, 14337, 297, 272, 283, 1160, 576, 297, 272, 283, 1160, 12955, 297, 272, 283, 19369, 297, 199, 93, 199, 63, 1450, 63, 5359, 275, 485, 21152, 461, 63, 1450, 63, 5359, 1204, 485, 324, 21152, 461, 63, 1450, 63, 5359, 199, 199, 3, 29622, 5299, 687, 3758, 5268, 14, 8624, 199, 3, 4178, 921, 838, 2129, 707, 14, 5319, 1036, 2391, 14, 1308, 15, 1365, 15, 4603, 6797, 15, 4570, 15, 4133, 15, 9441, 15, 2698 ]
[ 22905, 370, 4278, 849, 13422, 1041, 421, 199, 504, 5055, 492, 10018, 465, 485, 21501, 199, 504, 14090, 492, 19937, 465, 485, 20852, 421, 199, 318, 485, 31655, 63, 599, 69, 8, 5465, 26, 485, 20852, 59, 495, 566, 1035, 1211, 26, 272, 408, 2499, 282, 377, 11317, 734, 402, 282, 769, 402, 5932, 436, 372, 376, 15374, 5163, 3851, 14, 339, 710, 5226, 12939, 1077, 1336, 8298, 12930, 2419, 282, 3486, 12939, 13629, 14, 272, 408, 272, 327, 1620, 867, 314, 3229, 69, 272, 3229, 69, 275, 1052, 272, 367, 1059, 315, 3326, 26, 267, 366, 275, 3229, 69, 267, 367, 1495, 315, 1059, 26, 288, 366, 59, 1560, 61, 275, 1495, 315, 366, 436, 366, 59, 1560, 61, 503, 1052, 288, 366, 275, 366, 59, 1560, 61, 267, 366, 459, 418, 275, 488, 221, 327, 662, 3100, 272, 372, 3229, 69, 421, 199, 318, 485, 3401, 8, 599, 69, 26, 1211, 9, 1035, 620, 26, 272, 408, 7306, 282, 3229, 69, 370, 282, 5163, 3851, 1041, 272, 340, 2125, 315, 3229, 69, 26, 267, 340, 822, 8, 599, 69, 9, 508, 413, 26, 288, 372, 2125, 267, 2716, 275, 715, 267, 2150, 3229, 69, 459, 418, 272, 587, 26, 267, 2716, 275, 756, 339, 30179, 63, 475, 63, 6574, 275, 485, 21501, 8, 513, 9, 339, 367, 1495, 12, 1007, 63, 599, 69, 315, 3229, 69, 14, 1744, 837, 267, 30179, 275, 485, 3401, 8, 954, 63, 599, 69, 9, 267, 30179, 63, 475, 63, 6574, 59, 954, 3401, 1055, 740, 8, 1560, 9, 339, 741, 1086, 275, 942, 272, 367, 30179, 12, 8365, 315, 30179, 63, 475, 63, 6574, 14, 1744, 837, 267, 340, 822, 8, 6574, 9, 508, 413, 26, 288, 741, 1086, 14, 740, 8, 6574, 59, 16, 61, 435, 30179, 9, 267, 587, 26, 288, 8365, 14, 3191, 8, 4471, 29, 549, 9, 288, 741, 1086, 14, 740, 360, 459, 435, 6522, 904, 8, 6574, 9, 435, 24840, 435, 30179, 9, 339, 340, 822, 8, 279, 1086, 9, 508, 413, 26, 267, 754, 275, 741, 1086, 59, 16, 61, 267, 340, 2716, 26, 288, 340, 822, 8, 1099, 9, 508, 413, 26, 355, 754, 847, 8720, 4786, 288, 587, 26, 221, 327, 1655, 2419, 1373, 4528, 315, 741, 1086, 59, 16, 61, 355, 754, 275, 17644, 4881, 435, 754, 435, 5320, 31, 4786, 272, 587, 26, 267, 741, 1086, 14, 3191, 8, 4471, 29, 549, 9, 267, 754, 275, 17644, 3524, 435, 21590, 904, 8, 279, 1086, 9, 435, 16107, 267, 340, 2716, 26, 288, 754, 847, 8720, 4786, 272, 372, 754, 421, 199, 318, 5163, 63, 3401, 8, 3148, 26, 485, 20852, 59, 495, 566, 1035, 2783, 26, 272, 408, 7306, 5932, 370, 282, 5163, 3851, 626, 4450, 1263, 402, 3062, 1041, 272, 372, 485, 3401, 1547, 31655, 63, 599, 69, 8, 3148, 4992, 2143, 342, 421, 199, 3, 6646, 83, 402, 314, 2005, 402, 314, 3329, 3762, 883, 506, 4565, 465, 17195, 505, 14, 199, 3, 2104, 2893, 12, 7009, 787, 1686, 6272, 314, 1115, 5633, 1947, 26, 199, 3, 259, 665, 555, 5633, 19386, 505, 92, 16106, 1, 4863, 1108, 555, 5633, 30, 199, 3, 11017, 440, 4453, 3473, 503, 1350, 503, 2263, 199, 3, 367, 1655, 2556, 3595, 314, 665, 3710, 2350, 30, 1947, 1937, 26, 199, 3, 4178, 921, 1544, 14, 4603, 6797, 14, 1308, 15, 6797, 15, 6382, 26, 7841, 3987, 3, 199, 3, 259, 710, 3754, 23, 34, 14, 23, 34, 14, 1789, 3710, 2350, 14, 23, 36, 14, 23, 36, 63, 2087, 63, 1593, 199, 63, 21152, 461, 63, 1450, 63, 5359, 275, 469, 272, 283, 3710, 2350, 297, 272, 283, 25372, 297, 272, 283, 1569, 1130, 297, 272, 283, 2613, 2118, 297, 272, 283, 15785, 297, 272, 283, 1210, 1977, 297, 272, 283, 889, 2613, 297, 272, 283, 2118, 2613, 297, 272, 283, 555, 5633, 297, 272, 283, 1121, 297, 272, 283, 12635, 297, 272, 283, 2792, 297, 199, 93, 199, 3, 2104, 282, 4890, 769, 402, 3329, 3762, 641, 2195, 17195, 12, 1937, 314, 199, 3, 298, 2842, 3329, 3762, 2, 3420, 737, 314, 1284, 402, 3474, 12246, 26, 3353, 20230, 199, 3, 665, 1160, 576, 30, 436, 665, 2613, 2118, 30, 4898, 10250, 3483, 370, 314, 221, 2569, 5548, 14, 199, 3, 437, 3486, 20907, 370, 2342, 734, 340, 282, 1947, 1077, 506, 10532, 2348, 503, 440, 365, 465, 199, 3, 11924, 26, 199, 3, 2790, 314, 8448, 505, 4863, 1978, 315, 2195, 17195, 334, 5556, 883, 1331, 314, 1350, 1233, 687, 199, 3, 20144, 644, 29386, 680, 9442, 3354, 314, 2569, 315, 282, 511, 2034, 26, 199, 3, 8448, 505, 92, 16, 28, 24173, 30, 17, 4863, 18, 1108, 24173, 30, 19, 4863, 20, 199, 3, 982, 314, 13401, 27158, 315, 314, 8018, 754, 7468, 3382, 650, 436, 841, 12, 2066, 199, 3, 658, 24173, 64, 365, 440, 376, 3329, 1947, 334, 69, 14, 71, 14, 665, 7241, 10121, 6630, 12, 284, 14, 69, 14, 340, 5204, 199, 3, 27158, 7468, 3382, 413, 436, 499, 503, 14793, 2793, 1133, 2498, 1536, 12, 658, 24173, 64, 365, 199, 3, 282, 1947, 3329, 334, 69, 14, 71, 16781, 665, 657, 10121, 199, 63, 324, 21152, 461, 63, 1450, 63, 5359, 275, 469, 272, 283, 301, 297, 272, 283, 1560, 3176, 297, 272, 283, 24448, 297, 272, 283, 2180, 297, 272, 283, 5812, 3478, 297, 272, 283, 13209, 297, 221, 327, 13282, 26, 18355, 272, 283, 1130, 1943, 297, 272, 283, 1130, 1073, 297, 272, 283, 3442, 297, 272, 283, 2131, 11545, 297, 272, 283, 1606, 513, 297, 272, 283, 1606, 9161, 297, 272, 283, 5856, 297, 272, 283, 657, 297, 272, 283, 3397, 297, 272, 283, 1365, 297, 272, 283, 7093, 14337, 297, 272, 283, 1160, 576, 297, 272, 283, 1160, 12955, 297, 272, 283, 19369, 297, 199, 93, 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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 ]
huanchenz/STX-h-store
third_party/python/boto/ec2/securitygroup.py
11
11648
# Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2011, Eucalyptus Systems, Inc. # # 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, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing 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 MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR 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. """ Represents an EC2 Security Group """ from boto.ec2.ec2object import TaggedEC2Object from boto.exception import BotoClientError class SecurityGroup(TaggedEC2Object): def __init__(self, connection=None, owner_id=None, name=None, description=None, id=None): TaggedEC2Object.__init__(self, connection) self.id = id self.owner_id = owner_id self.name = name self.description = description self.rules = [] def __repr__(self): return 'SecurityGroup:%s' % self.name def startElement(self, name, attrs, connection): retval = TaggedEC2Object.startElement(self, name, attrs, connection) if retval is not None: return retval if name == 'item': self.rules.append(IPPermissions(self)) return self.rules[-1] else: return None def endElement(self, name, value, connection): if name == 'ownerId': self.owner_id = value elif name == 'groupId': self.id = value elif name == 'groupName': self.name = value elif name == 'groupDescription': self.description = value elif name == 'ipRanges': pass elif name == 'return': if value == 'false': self.status = False elif value == 'true': self.status = True else: raise Exception( 'Unexpected value of status %s for group %s'%( value, self.name ) ) else: setattr(self, name, value) def delete(self): return self.connection.delete_security_group(self.name) def add_rule(self, ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip): """ Add a rule to the SecurityGroup object. Note that this method only changes the local version of the object. No information is sent to EC2. """ rule = IPPermissions(self) rule.ip_protocol = ip_protocol rule.from_port = from_port rule.to_port = to_port self.rules.append(rule) rule.add_grant(src_group_name, src_group_owner_id, cidr_ip) def remove_rule(self, ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip): """ Remove a rule to the SecurityGroup object. Note that this method only changes the local version of the object. No information is sent to EC2. """ target_rule = None for rule in self.rules: if rule.ip_protocol == ip_protocol: if rule.from_port == from_port: if rule.to_port == to_port: target_rule = rule target_grant = None for grant in rule.grants: if grant.name == src_group_name: if grant.owner_id == src_group_owner_id: if grant.cidr_ip == cidr_ip: target_grant = grant if target_grant: rule.grants.remove(target_grant) if len(rule.grants) == 0: self.rules.remove(target_rule) def authorize(self, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None, src_group=None): """ Add a new rule to this security group. You need to pass in either src_group_name OR ip_protocol, from_port, to_port, and cidr_ip. In other words, either you are authorizing another group or you are authorizing some ip-based rule. :type ip_protocol: string :param ip_protocol: Either tcp | udp | icmp :type from_port: int :param from_port: The beginning port number you are enabling :type to_port: int :param to_port: The ending port number you are enabling :type cidr_ip: string :param cidr_ip: The CIDR block you are providing access to. See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing :type src_group: :class:`boto.ec2.securitygroup.SecurityGroup` or :class:`boto.ec2.securitygroup.GroupOrCIDR` :param src_group: The Security Group you are granting access to. :rtype: bool :return: True if successful. """ if src_group: cidr_ip = None src_group_name = src_group.name src_group_owner_id = src_group.owner_id else: src_group_name = None src_group_owner_id = None status = self.connection.authorize_security_group(self.name, src_group_name, src_group_owner_id, ip_protocol, from_port, to_port, cidr_ip) if status: self.add_rule(ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip) return status def revoke(self, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None, src_group=None): if src_group: cidr_ip=None src_group_name = src_group.name src_group_owner_id = src_group.owner_id else: src_group_name = None src_group_owner_id = None status = self.connection.revoke_security_group(self.name, src_group_name, src_group_owner_id, ip_protocol, from_port, to_port, cidr_ip) if status: self.remove_rule(ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip) return status def copy_to_region(self, region, name=None): """ Create a copy of this security group in another region. Note that the new security group will be a separate entity and will not stay in sync automatically after the copy operation. :type region: :class:`boto.ec2.regioninfo.RegionInfo` :param region: The region to which this security group will be copied. :type name: string :param name: The name of the copy. If not supplied, the copy will have the same name as this security group. :rtype: :class:`boto.ec2.securitygroup.SecurityGroup` :return: The new security group. """ if region.name == self.region: raise BotoClientError('Unable to copy to the same Region') conn_params = self.connection.get_params() rconn = region.connect(**conn_params) sg = rconn.create_security_group(name or self.name, self.description) source_groups = [] for rule in self.rules: grant = rule.grants[0] for grant in rule.grants: if grant.name: if grant.name not in source_groups: source_groups.append(grant.name) sg.authorize(None, None, None, None, grant) else: sg.authorize(rule.ip_protocol, rule.from_port, rule.to_port, grant.cidr_ip) return sg def instances(self): """ Find all of the current instances that are running within this security group. :rtype: list of :class:`boto.ec2.instance.Instance` :return: A list of Instance objects """ # It would be more efficient to do this with filters now # but not all services that implement EC2 API support filters. instances = [] rs = self.connection.get_all_instances() for reservation in rs: uses_group = [g.name for g in reservation.groups if g.name == self.name] if uses_group: instances.extend(reservation.instances) return instances class IPPermissions(object): def __init__(self, parent=None): self.parent = parent self.ip_protocol = None self.from_port = None self.to_port = None self.grants = [] def __repr__(self): return 'IPPermissions:%s(%s-%s)' % (self.ip_protocol, self.from_port, self.to_port) def startElement(self, name, attrs, connection): if name == 'item': self.grants.append(GroupOrCIDR(self)) return self.grants[-1] return None def endElement(self, name, value, connection): if name == 'ipProtocol': self.ip_protocol = value elif name == 'fromPort': self.from_port = value elif name == 'toPort': self.to_port = value else: setattr(self, name, value) def add_grant(self, name=None, owner_id=None, cidr_ip=None): grant = GroupOrCIDR(self) grant.owner_id = owner_id grant.name = name grant.cidr_ip = cidr_ip self.grants.append(grant) return grant class GroupOrCIDR(object): def __init__(self, parent=None): self.owner_id = None self.name = None self.cidr_ip = None def __repr__(self): if self.cidr_ip: return '%s' % self.cidr_ip else: return '%s-%s' % (self.name, self.owner_id) def startElement(self, name, attrs, connection): return None def endElement(self, name, value, connection): if name == 'userId': self.owner_id = value elif name == 'groupName': self.name = value if name == 'cidrIp': self.cidr_ip = value else: setattr(self, name, value)
gpl-3.0
[ 3, 1898, 334, 67, 9, 8315, 13, 8128, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7760, 12, 662, 85, 915, 89, 541, 527, 15285, 12, 3277, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 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, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 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, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 18089, 376, 15352, 18, 13863, 5611, 199, 624, 199, 504, 6055, 14, 825, 18, 14, 825, 18, 785, 492, 32121, 4220, 18, 1692, 199, 504, 6055, 14, 1971, 492, 24411, 19992, 199, 199, 533, 13863, 2448, 8, 26403, 4220, 18, 1692, 304, 2286, 347, 636, 826, 721, 277, 12, 1950, 29, 403, 12, 5771, 63, 344, 29, 403, 12, 326, 536, 29, 403, 12, 1369, 29, 403, 12, 1305, 29, 403, 304, 267, 32121, 4220, 18, 1692, 855, 826, 721, 277, 12, 1950, 9, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 4597, 63, 344, 275, 5771, 63, 344, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4423, 275, 942, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 19280, 2689, 83, 7, 450, 291, 14, 354, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 12, 1950, 304, 267, 9151, 275, 32121, 4220, 18, 1692, 14, 30398, 8, 277, 12, 536, 12, 3290, 12, 1950, 9, 267, 340, 9151, 365, 440, 488, 26, 288, 372, 9151, 267, 340, 536, 508, 283, 1053, 356, 288, 291, 14, 4423, 14, 740, 8, 1772, 17004, 8, 277, 430, 288, 372, 291, 14, 4423, 1988, 17, 61, 267, 587, 26, 288, 372, 488, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 4597, 1304, 356, 288, 291, 14, 4597, 63, 344, 275, 574, 267, 916, 536, 508, 283, 923, 1304, 356, 288, 291, 14, 344, 275, 574, 267, 916, 536, 508, 283, 923, 985, 356, 288, 291, 14, 354, 275, 574, 267, 916, 536, 508, 283, 923, 5831, 356, 288, 291, 14, 1802, 275, 574, 267, 916, 536, 508, 283, 711, 23019, 356, 288, 986, 267, 916, 536, 508, 283, 1107, 356, 288, 340, 574, 508, 283, 3910, 356, 355, 291, 14, 1205, 275, 756, 288, 916, 574, 508, 283, 2052, 356, 355, 291, 14, 1205, 275, 715, 288, 587, 26, 355, 746, 2186, 8, 490, 283, 8708, 574, 402, 2004, 450, 83, 367, 1572, 450, 83, 13328, 717, 574, 12, 12723, 291, 14, 354, 490, 776, 355, 776, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 3145, 8, 277, 304, 267, 372, 291, 14, 2105, 14, 1807, 63, 4416, 63, 923, 8, 277, 14, 354, 9, 339, 347, 1050, 63, 2200, 8, 277, 12, 3384, 63, 3922, 12, 687, 63, 719, 12, 370, 63, 719, 12, 326, 2928, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 304, 267, 408, 267, 2654, 282, 2332, 370, 314, 13863, 2448, 909, 14, 221, 3390, 626, 642, 1083, 267, 1454, 4493, 314, 2257, 1015, 402, 314, 909, 14, 221, 3091, 2556, 267, 365, 4847, 370, 15352, 18, 14, 267, 408, 267, 2332, 275, 3531, 17004, 8, 277, 9, 267, 2332, 14, 711, 63, 3922, 275, 3384, 63, 3922, 267, 2332, 14, 504, 63, 719, 275, 687, 63, 719, 267, 2332, 14, 475, 63, 719, 275, 370, 63, 719, 267, 291, 14, 4423, 14, 740, 8, 2200, 9, 267, 2332, 14, 525, 63, 17362, 8, 2164, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 9, 339, 347, 2813, 63, 2200, 8, 277, 12, 3384, 63, 3922, 12, 687, 63, 719, 12, 370, 63, 719, 12, 490, 2928, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 304, 267, 408, 267, 5852, 282, 2332, 370, 314, 13863, 2448, 909, 14, 221, 3390, 626, 642, 1083, 267, 1454, 4493, 314, 2257, 1015, 402, 314, 909, 14, 221, 3091, 2556, 267, 365, 4847, 370, 15352, 18, 14, 267, 408, 267, 1347, 63, 2200, 275, 488, 267, 367, 2332, 315, 291, 14, 4423, 26, 288, 340, 2332, 14, 711, 63, 3922, 508, 3384, 63, 3922, 26, 355, 340, 2332, 14, 504, 63, 719, 508, 687, 63, 719, 26, 490, 340, 2332, 14, 475, 63, 719, 508, 370, 63, 719, 26, 717, 1347, 63, 2200, 275, 2332, 717, 1347, 63, 17362, 275, 488, 717, 367, 16085, 315, 2332, 14, 2587, 2285, 26, 1169, 340, 16085, 14, 354, 508, 2928, 63, 923, 63, 354, 26, 1816, 340, 16085, 14, 4597, 63, 344, 508, 2928, 63, 923, 63, 4597, 63, 344, 26, 2511, 340, 16085, 14, 10509, 63, 711, 508, 16770, 63, 711, 26, 3147, 1347, 63, 17362, 275, 16085, 717, 340, 1347, 63, 17362, 26, 1169, 2332, 14, 2587, 2285, 14, 2168, 8, 1375, 63 ]
[ 1898, 334, 67, 9, 8315, 13, 8128, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7760, 12, 662, 85, 915, 89, 541, 527, 15285, 12, 3277, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 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, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 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, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 221, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 624, 199, 18089, 376, 15352, 18, 13863, 5611, 199, 624, 199, 504, 6055, 14, 825, 18, 14, 825, 18, 785, 492, 32121, 4220, 18, 1692, 199, 504, 6055, 14, 1971, 492, 24411, 19992, 199, 199, 533, 13863, 2448, 8, 26403, 4220, 18, 1692, 304, 2286, 347, 636, 826, 721, 277, 12, 1950, 29, 403, 12, 5771, 63, 344, 29, 403, 12, 326, 536, 29, 403, 12, 1369, 29, 403, 12, 1305, 29, 403, 304, 267, 32121, 4220, 18, 1692, 855, 826, 721, 277, 12, 1950, 9, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 4597, 63, 344, 275, 5771, 63, 344, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 4423, 275, 942, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 19280, 2689, 83, 7, 450, 291, 14, 354, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 12, 1950, 304, 267, 9151, 275, 32121, 4220, 18, 1692, 14, 30398, 8, 277, 12, 536, 12, 3290, 12, 1950, 9, 267, 340, 9151, 365, 440, 488, 26, 288, 372, 9151, 267, 340, 536, 508, 283, 1053, 356, 288, 291, 14, 4423, 14, 740, 8, 1772, 17004, 8, 277, 430, 288, 372, 291, 14, 4423, 1988, 17, 61, 267, 587, 26, 288, 372, 488, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 4597, 1304, 356, 288, 291, 14, 4597, 63, 344, 275, 574, 267, 916, 536, 508, 283, 923, 1304, 356, 288, 291, 14, 344, 275, 574, 267, 916, 536, 508, 283, 923, 985, 356, 288, 291, 14, 354, 275, 574, 267, 916, 536, 508, 283, 923, 5831, 356, 288, 291, 14, 1802, 275, 574, 267, 916, 536, 508, 283, 711, 23019, 356, 288, 986, 267, 916, 536, 508, 283, 1107, 356, 288, 340, 574, 508, 283, 3910, 356, 355, 291, 14, 1205, 275, 756, 288, 916, 574, 508, 283, 2052, 356, 355, 291, 14, 1205, 275, 715, 288, 587, 26, 355, 746, 2186, 8, 490, 283, 8708, 574, 402, 2004, 450, 83, 367, 1572, 450, 83, 13328, 717, 574, 12, 12723, 291, 14, 354, 490, 776, 355, 776, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 3145, 8, 277, 304, 267, 372, 291, 14, 2105, 14, 1807, 63, 4416, 63, 923, 8, 277, 14, 354, 9, 339, 347, 1050, 63, 2200, 8, 277, 12, 3384, 63, 3922, 12, 687, 63, 719, 12, 370, 63, 719, 12, 326, 2928, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 304, 267, 408, 267, 2654, 282, 2332, 370, 314, 13863, 2448, 909, 14, 221, 3390, 626, 642, 1083, 267, 1454, 4493, 314, 2257, 1015, 402, 314, 909, 14, 221, 3091, 2556, 267, 365, 4847, 370, 15352, 18, 14, 267, 408, 267, 2332, 275, 3531, 17004, 8, 277, 9, 267, 2332, 14, 711, 63, 3922, 275, 3384, 63, 3922, 267, 2332, 14, 504, 63, 719, 275, 687, 63, 719, 267, 2332, 14, 475, 63, 719, 275, 370, 63, 719, 267, 291, 14, 4423, 14, 740, 8, 2200, 9, 267, 2332, 14, 525, 63, 17362, 8, 2164, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 9, 339, 347, 2813, 63, 2200, 8, 277, 12, 3384, 63, 3922, 12, 687, 63, 719, 12, 370, 63, 719, 12, 490, 2928, 63, 923, 63, 354, 12, 2928, 63, 923, 63, 4597, 63, 344, 12, 16770, 63, 711, 304, 267, 408, 267, 5852, 282, 2332, 370, 314, 13863, 2448, 909, 14, 221, 3390, 626, 642, 1083, 267, 1454, 4493, 314, 2257, 1015, 402, 314, 909, 14, 221, 3091, 2556, 267, 365, 4847, 370, 15352, 18, 14, 267, 408, 267, 1347, 63, 2200, 275, 488, 267, 367, 2332, 315, 291, 14, 4423, 26, 288, 340, 2332, 14, 711, 63, 3922, 508, 3384, 63, 3922, 26, 355, 340, 2332, 14, 504, 63, 719, 508, 687, 63, 719, 26, 490, 340, 2332, 14, 475, 63, 719, 508, 370, 63, 719, 26, 717, 1347, 63, 2200, 275, 2332, 717, 1347, 63, 17362, 275, 488, 717, 367, 16085, 315, 2332, 14, 2587, 2285, 26, 1169, 340, 16085, 14, 354, 508, 2928, 63, 923, 63, 354, 26, 1816, 340, 16085, 14, 4597, 63, 344, 508, 2928, 63, 923, 63, 4597, 63, 344, 26, 2511, 340, 16085,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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 ]
ryanoberto/homevolution
node.py
1
6518
#!/usr/bin/python """ The MIT License (MIT) Copyright (c) 2014 Leon Jacobs 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. """ import yaml import RPi.GPIO as GPIO import time import logging import sys, traceback import socket import json from flask import Flask, jsonify, abort, make_response, render_template, request from flask_cors import CORS from flask.ext.httpauth import HTTPBasicAuth #from app import app #Open Config file f=open('node-config.yml') config = yaml.safe_load(f) #config=yaml.load(f) f.close() #set my variables with info from the config file SECRET = config["SECRET"] PORT = config["SERVER"]["PORT"] HOST = config["SERVER"]["HOST"] BUFFER_SIZE = config["SERVER"]["BUFFER_SIZE"] APPNAME = config["PROGNAME"] NODENAME = config["NODENAME"] NODEIP = config["NODEIP"] LOGFILE = config["LOGFILE"] LOGFORMAT = config["LOGFORMAT"] LOG_LEVEL = config["LOG_LEVEL"] API_DEBUG = config["DEBUG"] #Logging logger = logging.getLogger(APPNAME) hdlr = logging.FileHandler(LOGFILE) #formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') formatter = logging.Formatter(LOGFORMAT) hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(LOG_LEVEL) logging.basicConfig() #Setup my GPIO Stuff GPIO.setmode(GPIO.BCM) #GPIO.setwarnings(False) # Given a specific channel, we return associated output gpio # def channel2output(channel): for d in config['DEVICES']: if config['DEVICES'][d]['GPIO_IN'] == channel: return config['DEVICES'][d]['GPIO_OUT'] # Given a specific output, check its state and toggle it def toggleOutput(gpioOut): GPIO.setup(gpioOut, GPIO.OUT) if (GPIO.input(gpioOut) == 1): logger.info("Turning " + str(gpioOut) + " on") GPIO.output(gpioOut, GPIO.LOW) else: logger.info("Turning " + str(gpioOut) + " off") GPIO.output(gpioOut, GPIO.HIGH) # Given a specific channel, do something def doSomething(channel): # Find the output for the input output = channel2output(channel) logger.info("Button Pressed") logger.info("Got output: " + str(output) + " for channel: " + str(channel)) toggleOutput(output) for d in config["DEVICES"]: pin_out = config["DEVICES"][d]["GPIO_OUT"] pin_in = config["DEVICES"][d]["GPIO_IN"] """ Set outputs to off when we start """ GPIO.setup(pin_out, GPIO.OUT, initial=GPIO.HIGH) logger.info("Setting up " + str(pin_out) + " as output and setting to off...") #check if in put is set if pin_in > 0: # set inputs to in GPIO.setup(pin_in, GPIO.IN) #pull up or pull down examples # GPIO.setup(pin_in, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) # GPIO.setup(pin_in, GPIO.IN, pull_up_down = GPIO.PUD_UP) logger.info("Setting up " + str(pin_in) + " as input...") #check if input is set # add events to inputs was 400 #GPIO.add_event_detect(pin_in, GPIO.BOTH, callback=doSomething); #GPIO.add_event_detect(pin_in, GPIO.FAILING, callback=doSomething, bouncetime=300) GPIO.add_event_detect(pin_in, GPIO.RISING, callback=doSomething, bouncetime=300); #GPIO.wait_for_edge(pin_in, GPIO.RISING) app = Flask(__name__, static_url_path='') cors = CORS(app) @app.route('/') @app.route('/index') def index(): devices = str(config['DEVICES'].keys()) dev = {} for o in config['DEVICES']: pin = config["DEVICES"][o]["GPIO_OUT"] if(GPIO.input(pin) == 0): dev[o] = "On" else: dev[o] = "Off" # Pass the template data into the template node.html and return it to the user templateData = { 'devs' : dev, 'nodename' : NODENAME, 'nodeip' : NODEIP, 'port' : PORT } return render_template('node.html', **templateData) """ API stuff """ #List available devices @app.route('/api/list', methods = ['GET']) #@auth.login_required def get_list(): #devices = str(config['DEVICES'].keys()) devices = config['DEVICES'].keys() return jsonify( { 'devices': devices } ) #get status of a device @app.route('/api/<device>/<action>', methods = ['GET']) def apiaction(device, action): if action == "status": devices = config['DEVICES'].keys() if device == "all": dev = {NODEIP:{}} for o in config['DEVICES']: pin = config["DEVICES"][o]["GPIO_OUT"] if(GPIO.input(pin) == 0): #d = o+ " : On" #dev.append(d) dev[NODEIP][o] = "On" else: #d = o+ " : Off" #dev.append(d) dev[NODEIP][o] = "Off" #return jsonify( { dev } ) return json.dumps(dev) else: pin = config["DEVICES"][device]["GPIO_OUT"] if(GPIO.input(pin) == 0): logger.info("device " + device + " status on") return jsonify({ 'device' : device, 'status': 'on' }) else: logger.info("device " + device + " status off") return jsonify({ 'device' : device, 'status': 'off' }) #Get the output pin pin = config["DEVICES"][device]["GPIO_OUT"] #Turn on device if action == "on": if(GPIO.input(pin) == 0): logger.info(device + " is already on") return jsonify({ 'device' : device, 'status': 'already on' }) else: GPIO.output(pin, GPIO.LOW) #return 'Turned '+ device +' On \n' logger.info("Turned " + device + " on") return jsonify({ 'device' : device, 'status': 'on' }) #Turn off device if action == "off": if(GPIO.input(pin) == 1): logger.info(device + " is already off") return jsonify({ 'device' : device, 'status': 'already off' }) else: GPIO.output(pin, GPIO.HIGH) logger.info("Turned " + device + " off") return jsonify({ 'device' : device, 'status': 'off' }) app.run(host=HOST, port=PORT, debug=API_DEBUG) GPIO.cleanup()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6927, 7005, 265, 1603, 13286, 1533, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 624, 199, 199, 646, 8864, 199, 646, 820, 10542, 14, 21071, 465, 20899, 199, 646, 900, 199, 646, 2050, 199, 646, 984, 12, 5190, 199, 646, 2838, 199, 646, 2022, 199, 504, 7209, 492, 16704, 12, 23819, 12, 12004, 12, 1852, 63, 1310, 12, 3795, 63, 1160, 12, 1056, 199, 504, 7209, 63, 30967, 492, 445, 4149, 199, 504, 7209, 14, 832, 14, 16916, 387, 762, 492, 3101, 6845, 2817, 199, 3, 504, 1145, 492, 1145, 199, 199, 3, 4299, 4094, 570, 199, 70, 29, 1490, 360, 932, 13, 888, 14, 11714, 358, 199, 888, 275, 8864, 14, 3489, 63, 912, 8, 70, 9, 199, 3, 888, 29, 5963, 14, 912, 8, 70, 9, 199, 70, 14, 1600, 342, 199, 199, 3, 409, 3002, 2860, 543, 2256, 687, 314, 1101, 570, 199, 12961, 275, 1101, 905, 12961, 937, 199, 3657, 275, 1101, 905, 6613, 6611, 3657, 937, 199, 5449, 275, 1101, 905, 6613, 6611, 5449, 937, 199, 10960, 63, 4305, 275, 1101, 905, 6613, 6611, 10960, 63, 4305, 937, 199, 7121, 2339, 275, 1101, 905, 2514, 39, 2339, 937, 199, 2826, 36, 11536, 275, 1101, 905, 2826, 36, 11536, 937, 199, 8063, 1772, 275, 1101, 905, 8063, 1772, 937, 199, 4947, 3817, 275, 1101, 905, 4947, 3817, 937, 199, 4947, 4807, 275, 1101, 905, 4947, 4807, 937, 199, 4947, 63, 11817, 275, 1101, 905, 4947, 63, 11817, 937, 199, 3735, 63, 5287, 275, 1101, 905, 5287, 937, 199, 199, 3, 14054, 199, 2921, 275, 2050, 14, 5572, 8, 7121, 2339, 9, 199, 28738, 82, 275, 2050, 14, 21982, 8, 4947, 3817, 9, 199, 199, 3, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 199, 8911, 275, 2050, 14, 7772, 8, 4947, 4807, 9, 199, 28738, 82, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 28738, 82, 9, 199, 2921, 14, 13548, 8, 4947, 63, 11817, 9, 199, 4806, 14, 19602, 342, 199, 199, 3, 8555, 3002, 20899, 1933, 3043, 199, 21071, 14, 409, 632, 8, 21071, 14, 6265, 45, 9, 199, 3, 21071, 14, 409, 5451, 8, 797, 9, 421, 199, 3, 9138, 282, 2488, 3623, 12, 781, 372, 4568, 1072, 30279, 199, 3, 221, 199, 318, 3623, 18, 1199, 8, 2775, 304, 199, 198, 509, 366, 315, 1101, 459, 1093, 8670, 2565, 507, 198, 692, 1101, 459, 1093, 8670, 3488, 68, 2733, 21071, 63, 568, 418, 508, 3623, 26, 686, 198, 1107, 1101, 459, 1093, 8670, 3488, 68, 2733, 21071, 63, 1877, 418, 199, 199, 3, 9138, 282, 2488, 1072, 12, 1104, 2399, 1174, 436, 19420, 652, 199, 318, 19420, 2959, 8, 21918, 2204, 304, 199, 198, 21071, 14, 2758, 8, 21918, 2204, 12, 20899, 14, 1877, 9, 199, 198, 692, 334, 21071, 14, 1210, 8, 21918, 2204, 9, 508, 413, 304, 507, 198, 2921, 14, 815, 480, 16838, 316, 298, 435, 620, 8, 21918, 2204, 9, 435, 298, 641, 531, 507, 198, 21071, 14, 1199, 8, 21918, 2204, 12, 20899, 14, 5896, 9, 199, 198, 2836, 26, 507, 198, 2921, 14, 815, 480, 16838, 316, 298, 435, 620, 8, 21918, 2204, 9, 435, 298, 2331, 531, 507, 198, 21071, 14, 1199, 8, 21918, 2204, 12, 20899, 14, 17624, 9, 421, 199, 3, 9138, 282, 2488, 3623, 12, 886, 6020, 199, 318, 886, 20641, 8, 2775, 304, 199, 198, 3, 6668, 314, 1072, 367, 314, 1324, 199, 198, 1199, 275, 3623, 18, 1199, 8, 2775, 9, 199, 198, 2921, 14, 815, 480, 4259, 510, 5111, 531, 199, 198, 2921, 14, 815, 480, 13662, 1072, 26, 298, 435, 620, 8, 1199, 9, 435, 298, 367, 3623, 26, 298, 435, 620, 8, 2775, 430, 9948, 198, 13396, 2959, 8, 1199, 9, 421, 199, 509, 366, 315, 1101, 905, 1093, 8670, 6229, 199, 198, 7751, 63, 548, 275, 1101, 905, 1093, 8670, 9210, 68, 7541, 21071, 63, 1877, 937, 199, 198, 7751, 63, 262, 275, 1101, 905, 1093, 8670, 9210, 68, 7541, 21071, 63, 568, 937, 199, 198, 624, 523, 198, 1084, 4704, 370, 2331, 1380, 781, 1343, 199, 198, 624, 199, 198, 21071, 14, 2758, 8, 7751, 63, 548, 12, 20899, 14, 1877, 12, 2536, 29, 21071, 14, 17624, 9, 199, 198, 2921, 14, 815, 480, 7776, 1536, 298, 435, 620, 8, 7751, 63, 548, 9, 435, 298, 465, 1072, 436, 4260, 370, 2331, 12594, 199, 198, 3, 1074, 340, 315, 5324, 365, 663, 199, 198, 692, 10713, 63, 262, 690, 378, 26, 507, 198, 3, 663, 4153, 370, 315, 507, 198, 21071, 14, 2758, 8, 7751, 63, 262, 12, 20899, 14, 568, 9, 507, 198, 3, 9302, 1536, 503, 10299, 3224, 7251, 507, 198, 3, 20899, 14, 2758, 8, 7751, 63, 262, 12, 20899, 14, 568, 12, 10299 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6927, 7005, 265, 1603, 13286, 1533, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 624, 199, 199, 646, 8864, 199, 646, 820, 10542, 14, 21071, 465, 20899, 199, 646, 900, 199, 646, 2050, 199, 646, 984, 12, 5190, 199, 646, 2838, 199, 646, 2022, 199, 504, 7209, 492, 16704, 12, 23819, 12, 12004, 12, 1852, 63, 1310, 12, 3795, 63, 1160, 12, 1056, 199, 504, 7209, 63, 30967, 492, 445, 4149, 199, 504, 7209, 14, 832, 14, 16916, 387, 762, 492, 3101, 6845, 2817, 199, 3, 504, 1145, 492, 1145, 199, 199, 3, 4299, 4094, 570, 199, 70, 29, 1490, 360, 932, 13, 888, 14, 11714, 358, 199, 888, 275, 8864, 14, 3489, 63, 912, 8, 70, 9, 199, 3, 888, 29, 5963, 14, 912, 8, 70, 9, 199, 70, 14, 1600, 342, 199, 199, 3, 409, 3002, 2860, 543, 2256, 687, 314, 1101, 570, 199, 12961, 275, 1101, 905, 12961, 937, 199, 3657, 275, 1101, 905, 6613, 6611, 3657, 937, 199, 5449, 275, 1101, 905, 6613, 6611, 5449, 937, 199, 10960, 63, 4305, 275, 1101, 905, 6613, 6611, 10960, 63, 4305, 937, 199, 7121, 2339, 275, 1101, 905, 2514, 39, 2339, 937, 199, 2826, 36, 11536, 275, 1101, 905, 2826, 36, 11536, 937, 199, 8063, 1772, 275, 1101, 905, 8063, 1772, 937, 199, 4947, 3817, 275, 1101, 905, 4947, 3817, 937, 199, 4947, 4807, 275, 1101, 905, 4947, 4807, 937, 199, 4947, 63, 11817, 275, 1101, 905, 4947, 63, 11817, 937, 199, 3735, 63, 5287, 275, 1101, 905, 5287, 937, 199, 199, 3, 14054, 199, 2921, 275, 2050, 14, 5572, 8, 7121, 2339, 9, 199, 28738, 82, 275, 2050, 14, 21982, 8, 4947, 3817, 9, 199, 199, 3, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 199, 8911, 275, 2050, 14, 7772, 8, 4947, 4807, 9, 199, 28738, 82, 14, 26076, 8, 8911, 9, 199, 2921, 14, 18826, 8, 28738, 82, 9, 199, 2921, 14, 13548, 8, 4947, 63, 11817, 9, 199, 4806, 14, 19602, 342, 199, 199, 3, 8555, 3002, 20899, 1933, 3043, 199, 21071, 14, 409, 632, 8, 21071, 14, 6265, 45, 9, 199, 3, 21071, 14, 409, 5451, 8, 797, 9, 421, 199, 3, 9138, 282, 2488, 3623, 12, 781, 372, 4568, 1072, 30279, 199, 3, 221, 199, 318, 3623, 18, 1199, 8, 2775, 304, 199, 198, 509, 366, 315, 1101, 459, 1093, 8670, 2565, 507, 198, 692, 1101, 459, 1093, 8670, 3488, 68, 2733, 21071, 63, 568, 418, 508, 3623, 26, 686, 198, 1107, 1101, 459, 1093, 8670, 3488, 68, 2733, 21071, 63, 1877, 418, 199, 199, 3, 9138, 282, 2488, 1072, 12, 1104, 2399, 1174, 436, 19420, 652, 199, 318, 19420, 2959, 8, 21918, 2204, 304, 199, 198, 21071, 14, 2758, 8, 21918, 2204, 12, 20899, 14, 1877, 9, 199, 198, 692, 334, 21071, 14, 1210, 8, 21918, 2204, 9, 508, 413, 304, 507, 198, 2921, 14, 815, 480, 16838, 316, 298, 435, 620, 8, 21918, 2204, 9, 435, 298, 641, 531, 507, 198, 21071, 14, 1199, 8, 21918, 2204, 12, 20899, 14, 5896, 9, 199, 198, 2836, 26, 507, 198, 2921, 14, 815, 480, 16838, 316, 298, 435, 620, 8, 21918, 2204, 9, 435, 298, 2331, 531, 507, 198, 21071, 14, 1199, 8, 21918, 2204, 12, 20899, 14, 17624, 9, 421, 199, 3, 9138, 282, 2488, 3623, 12, 886, 6020, 199, 318, 886, 20641, 8, 2775, 304, 199, 198, 3, 6668, 314, 1072, 367, 314, 1324, 199, 198, 1199, 275, 3623, 18, 1199, 8, 2775, 9, 199, 198, 2921, 14, 815, 480, 4259, 510, 5111, 531, 199, 198, 2921, 14, 815, 480, 13662, 1072, 26, 298, 435, 620, 8, 1199, 9, 435, 298, 367, 3623, 26, 298, 435, 620, 8, 2775, 430, 9948, 198, 13396, 2959, 8, 1199, 9, 421, 199, 509, 366, 315, 1101, 905, 1093, 8670, 6229, 199, 198, 7751, 63, 548, 275, 1101, 905, 1093, 8670, 9210, 68, 7541, 21071, 63, 1877, 937, 199, 198, 7751, 63, 262, 275, 1101, 905, 1093, 8670, 9210, 68, 7541, 21071, 63, 568, 937, 199, 198, 624, 523, 198, 1084, 4704, 370, 2331, 1380, 781, 1343, 199, 198, 624, 199, 198, 21071, 14, 2758, 8, 7751, 63, 548, 12, 20899, 14, 1877, 12, 2536, 29, 21071, 14, 17624, 9, 199, 198, 2921, 14, 815, 480, 7776, 1536, 298, 435, 620, 8, 7751, 63, 548, 9, 435, 298, 465, 1072, 436, 4260, 370, 2331, 12594, 199, 198, 3, 1074, 340, 315, 5324, 365, 663, 199, 198, 692, 10713, 63, 262, 690, 378, 26, 507, 198, 3, 663, 4153, 370, 315, 507, 198, 21071, 14, 2758, 8, 7751, 63, 262, 12, 20899, 14, 568, 9, 507, 198, 3, 9302, 1536, 503, 10299, 3224, 7251, 507, 198, 3, 20899, 14, 2758, 8, 7751, 63, 262, 12, 20899, 14, 568, 12, 10299, 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, 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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 ]
jtyuan/racetrack
src/arch/x86/isa/insts/simd128/integer/compare/compare_and_write_mask.py
91
5729
# Copyright (c) 2007 The Hewlett-Packard Development Company # All rights reserved. # # The license below extends only to copyright in the software and shall # not be construed as granting a license to any other intellectual # property including but not limited to intellectual property relating # to a hardware implementation of the functionality of the software # licensed hereunder. You may use the software subject to the license # terms below provided that you ensure that this notice is replicated # unmodified and in its entirety in all distributions of the software, # modified or unmodified, in source code or in binary form. # # 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 the copyright holders 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 AND FITNESS FOR # A PARTICULAR PURPOSE 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. # # Authors: Gabe Black microcode = ''' def macroop PCMPEQB_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=1, ext=0 mcmpi2r xmmh, xmmh, xmmhm, size=1, ext=0 }; def macroop PCMPEQB_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=1, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=1, ext=0 }; def macroop PCMPEQB_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=1, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=1, ext=0 }; def macroop PCMPEQW_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=2, ext=0 mcmpi2r xmmh, xmmh, xmmhm, size=2, ext=0 }; def macroop PCMPEQW_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=2, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=2, ext=0 }; def macroop PCMPEQW_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=2, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=2, ext=0 }; def macroop PCMPEQD_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=4, ext=0 mcmpi2r xmmh, xmmh, xmmhm, size=4, ext=0 }; def macroop PCMPEQD_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=4, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=4, ext=0 }; def macroop PCMPEQD_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=4, ext=0 mcmpi2r xmmh, xmmh, ufp2, size=4, ext=0 }; def macroop PCMPGTB_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=1, ext=2 mcmpi2r xmmh, xmmh, xmmhm, size=1, ext=2 }; def macroop PCMPGTB_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=1, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=1, ext=2 }; def macroop PCMPGTB_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=1, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=1, ext=2 }; def macroop PCMPGTW_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=2, ext=2 mcmpi2r xmmh, xmmh, xmmhm, size=2, ext=2 }; def macroop PCMPGTW_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=2, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=2, ext=2 }; def macroop PCMPGTW_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=2, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=2, ext=2 }; def macroop PCMPGTD_XMM_XMM { mcmpi2r xmml, xmml, xmmlm, size=4, ext=2 mcmpi2r xmmh, xmmh, xmmhm, size=4, ext=2 }; def macroop PCMPGTD_XMM_M { ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=4, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=4, ext=2 }; def macroop PCMPGTD_XMM_P { rdip t7 ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 mcmpi2r xmml, xmml, ufp1, size=4, ext=2 mcmpi2r xmmh, xmmh, ufp2, size=4, ext=2 }; '''
bsd-3-clause
[ 3, 1898, 334, 67, 9, 10219, 710, 27849, 13, 29471, 15290, 15878, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 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, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 598, 7570, 30593, 199, 199, 6453, 600, 275, 1449, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 45, 469, 272, 15930, 80, 26337, 17, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 48, 469, 272, 519, 21846, 307, 23, 272, 15930, 80, 26337, 17, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 45, 469, 272, 15930, 80, 26337, 17, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 48, 469, 272, 519, 21846, 307, 23, 272, 15930, 80, 26337, 17, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 36, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 20, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 20, 12, 1599 ]
[ 1898, 334, 67, 9, 10219, 710, 27849, 13, 29471, 15290, 15878, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 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, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 598, 7570, 30593, 199, 199, 6453, 600, 275, 1449, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 45, 469, 272, 15930, 80, 26337, 17, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 31893, 63, 19439, 63, 48, 469, 272, 519, 21846, 307, 23, 272, 15930, 80, 26337, 17, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 17, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 17, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 45, 469, 272, 15930, 80, 26337, 17, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 20417, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 55, 63, 19439, 63, 48, 469, 272, 519, 21846, 307, 23, 272, 15930, 80, 26337, 17, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 401, 18252, 29, 24, 272, 15930, 80, 26337, 18, 12, 8812, 12, 8012, 30788, 12, 298, 6178, 2749, 22194, 435, 1695, 401, 18252, 29, 24, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 26337, 17, 12, 1568, 29, 18, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 26337, 18, 12, 1568, 29, 18, 12, 1599, 29, 16, 199, 12084, 199, 199, 318, 21308, 510, 9249, 1510, 49, 36, 63, 19439, 63, 19439, 469, 272, 333, 5730, 73, 18, 82, 18286, 76, 12, 18286, 76, 12, 18286, 14344, 12, 1568, 29, 20, 12, 1599, 29, 16, 272, 333, 5730, 73, 18, 82, 18286, 72, 12, 18286, 72, 12, 18286, 14038, 12, 1568, 29, 20, 12, 1599, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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import settings from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.test.utils import override_settings from django.utils import six from .middleware import RedirectFallbackMiddleware from .models import Redirect @override_settings( APPEND_SLASH=False, MIDDLEWARE_CLASSES=list(settings.MIDDLEWARE_CLASSES) + ['django.contrib.redirects.middleware.RedirectFallbackMiddleware'], SITE_ID=1, ) class RedirectTests(TestCase): def setUp(self): self.site = Site.objects.get(pk=settings.SITE_ID) def test_model(self): r1 = Redirect.objects.create( site=self.site, old_path='/initial', new_path='/new_target') self.assertEqual(six.text_type(r1), "/initial ---> /new_target") def test_redirect(self): Redirect.objects.create( site=self.site, old_path='/initial', new_path='/new_target') response = self.client.get('/initial') self.assertRedirects(response, '/new_target', status_code=301, target_status_code=404) @override_settings(APPEND_SLASH=True) def test_redirect_with_append_slash(self): Redirect.objects.create( site=self.site, old_path='/initial/', new_path='/new_target/') response = self.client.get('/initial') self.assertRedirects(response, '/new_target/', status_code=301, target_status_code=404) @override_settings(APPEND_SLASH=True) def test_redirect_with_append_slash_and_query_string(self): Redirect.objects.create( site=self.site, old_path='/initial/?foo', new_path='/new_target/') response = self.client.get('/initial?foo') self.assertRedirects(response, '/new_target/', status_code=301, target_status_code=404) def test_response_gone(self): """When the redirect target is '', return a 410""" Redirect.objects.create( site=self.site, old_path='/initial', new_path='') response = self.client.get('/initial') self.assertEqual(response.status_code, 410) @override_settings( INSTALLED_APPS=[app for app in settings.INSTALLED_APPS if app != 'django.contrib.sites']) def test_sites_not_installed(self): with self.assertRaises(ImproperlyConfigured): RedirectFallbackMiddleware()
mit
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 5754, 492, 18532, 21860, 6608, 199, 504, 1275, 992, 492, 18532, 421, 199, 32, 4415, 63, 1751, 8, 272, 19525, 3902, 63, 27192, 29, 797, 12, 272, 30718, 63, 13748, 29, 513, 8, 1751, 14, 19987, 63, 13748, 9, 435, 267, 788, 1176, 14, 2828, 14, 13607, 14, 5754, 14, 7071, 21860, 6608, 995, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 18532, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2124, 275, 11666, 14, 1462, 14, 362, 8, 2051, 29, 1751, 14, 7917, 63, 998, 9, 339, 347, 511, 63, 1238, 8, 277, 304, 267, 519, 17, 275, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 8805, 1222, 63, 1375, 358, 267, 291, 14, 629, 8, 4174, 14, 505, 63, 466, 8, 82, 17, 395, 3286, 2747, 1553, 5118, 1182, 1222, 63, 1375, 531, 339, 347, 511, 63, 4876, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 8805, 1222, 63, 1375, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 297, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 768, 4415, 63, 1751, 8, 25248, 63, 27192, 29, 549, 9, 272, 347, 511, 63, 4876, 63, 1045, 63, 740, 63, 7001, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 3678, 892, 63, 515, 8805, 1222, 63, 1375, 6217, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 3678, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 768, 4415, 63, 1751, 8, 25248, 63, 27192, 29, 549, 9, 272, 347, 511, 63, 4876, 63, 1045, 63, 740, 63, 7001, 63, 460, 63, 1131, 63, 875, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 10197, 1421, 297, 892, 63, 515, 8805, 1222, 63, 1375, 6217, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 31, 1421, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 3678, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 347, 511, 63, 1310, 63, 32227, 8, 277, 304, 267, 408, 11423, 314, 4660, 1347, 365, 3260, 372, 282, 32321, 624, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 13275, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 32321, 9, 339, 768, 4415, 63, 1751, 8, 267, 31061, 63, 14219, 1524, 571, 367, 1145, 315, 2202, 14, 15942, 63, 14219, 717, 340, 1145, 1137, 283, 1176, 14, 2828, 14, 8619, 1105, 272, 347, 511, 63, 8619, 63, 1397, 63, 7657, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 8499, 10951, 304, 288, 18532, 21860, 6608, 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 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 5754, 492, 18532, 21860, 6608, 199, 504, 1275, 992, 492, 18532, 421, 199, 32, 4415, 63, 1751, 8, 272, 19525, 3902, 63, 27192, 29, 797, 12, 272, 30718, 63, 13748, 29, 513, 8, 1751, 14, 19987, 63, 13748, 9, 435, 267, 788, 1176, 14, 2828, 14, 13607, 14, 5754, 14, 7071, 21860, 6608, 995, 272, 428, 4427, 63, 998, 29, 17, 12, 199, 9, 199, 533, 18532, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2124, 275, 11666, 14, 1462, 14, 362, 8, 2051, 29, 1751, 14, 7917, 63, 998, 9, 339, 347, 511, 63, 1238, 8, 277, 304, 267, 519, 17, 275, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 8805, 1222, 63, 1375, 358, 267, 291, 14, 629, 8, 4174, 14, 505, 63, 466, 8, 82, 17, 395, 3286, 2747, 1553, 5118, 1182, 1222, 63, 1375, 531, 339, 347, 511, 63, 4876, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 8805, 1222, 63, 1375, 358, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 297, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 768, 4415, 63, 1751, 8, 25248, 63, 27192, 29, 549, 9, 272, 347, 511, 63, 4876, 63, 1045, 63, 740, 63, 7001, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 3678, 892, 63, 515, 8805, 1222, 63, 1375, 6217, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 3678, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 768, 4415, 63, 1751, 8, 25248, 63, 27192, 29, 549, 9, 272, 347, 511, 63, 4876, 63, 1045, 63, 740, 63, 7001, 63, 460, 63, 1131, 63, 875, 8, 277, 304, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 10197, 1421, 297, 892, 63, 515, 8805, 1222, 63, 1375, 6217, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 31, 1421, 358, 267, 291, 14, 17466, 8, 1310, 12, 288, 1994, 1222, 63, 1375, 3678, 2004, 63, 600, 29, 8507, 12, 1347, 63, 1205, 63, 600, 29, 5188, 9, 339, 347, 511, 63, 1310, 63, 32227, 8, 277, 304, 267, 408, 11423, 314, 4660, 1347, 365, 3260, 372, 282, 32321, 624, 267, 18532, 14, 1462, 14, 981, 8, 288, 4770, 29, 277, 14, 2124, 12, 2269, 63, 515, 8805, 2747, 297, 892, 63, 515, 13275, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2747, 358, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 32321, 9, 339, 768, 4415, 63, 1751, 8, 267, 31061, 63, 14219, 1524, 571, 367, 1145, 315, 2202, 14, 15942, 63, 14219, 717, 340, 1145, 1137, 283, 1176, 14, 2828, 14, 8619, 1105, 272, 347, 511, 63, 8619, 63, 1397, 63, 7657, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 8499, 10951, 304, 288, 18532, 21860, 6608, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
FeatherCoin/Feathercoin
test/functional/feature_versionbits_warning.py
17
5111
#!/usr/bin/env python3 # Copyright (c) 2016-2019 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test version bits warning system. Generate chains with block versions that appear to be signalling unknown soft-forks, and test that warning alerts are generated. """ import os import re from test_framework.blocktools import create_block, create_coinbase from test_framework.messages import msg_block from test_framework.mininode import P2PInterface, mininode_lock from test_framework.test_framework import BitcoinTestFramework from test_framework.util import wait_until VB_PERIOD = 144 # versionbits period length for regtest VB_THRESHOLD = 108 # versionbits activation threshold for regtest VB_TOP_BITS = 0x20000000 VB_UNKNOWN_BIT = 27 # Choose a bit unassigned to any deployment VB_UNKNOWN_VERSION = VB_TOP_BITS | (1 << VB_UNKNOWN_BIT) WARN_UNKNOWN_RULES_ACTIVE = "unknown new rules activated (versionbit {})".format(VB_UNKNOWN_BIT) VB_PATTERN = re.compile("Warning: unknown new rules activated.*versionbit") class VersionBitsWarningTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 def setup_network(self): self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt") # Open and close to create zero-length file with open(self.alert_filename, 'w', encoding='utf8'): pass self.extra_args = [["-alertnotify=echo %s >> \"" + self.alert_filename + "\""]] self.setup_nodes() def send_blocks_with_version(self, peer, numblocks, version): """Send numblocks blocks to peer with version set""" tip = self.nodes[0].getbestblockhash() height = self.nodes[0].getblockcount() block_time = self.nodes[0].getblockheader(tip)["time"] + 1 tip = int(tip, 16) for _ in range(numblocks): block = create_block(tip, create_coinbase(height + 1), block_time) block.nVersion = version block.solve() peer.send_message(msg_block(block)) block_time += 1 height += 1 tip = block.sha256 peer.sync_with_ping() def versionbits_in_alert_file(self): """Test that the versionbits warning has been written to the alert file.""" alert_text = open(self.alert_filename, 'r', encoding='utf8').read() return VB_PATTERN.search(alert_text) is not None def run_test(self): node = self.nodes[0] node.add_p2p_connection(P2PInterface()) node_deterministic_address = node.get_deterministic_priv_key().address # Mine one period worth of blocks node.generatetoaddress(VB_PERIOD, node_deterministic_address) self.log.info("Check that there is no warning if previous VB_BLOCKS have <VB_THRESHOLD blocks with unknown versionbits version.") # Build one period of blocks with < VB_THRESHOLD blocks signaling some unknown bit self.send_blocks_with_version(node.p2p, VB_THRESHOLD - 1, VB_UNKNOWN_VERSION) node.generatetoaddress(VB_PERIOD - VB_THRESHOLD + 1, node_deterministic_address) # Check that we're not getting any versionbit-related errors in get*info() assert not VB_PATTERN.match(node.getmininginfo()["warnings"]) assert not VB_PATTERN.match(node.getnetworkinfo()["warnings"]) # Build one period of blocks with VB_THRESHOLD blocks signaling some unknown bit self.send_blocks_with_version(node.p2p, VB_THRESHOLD, VB_UNKNOWN_VERSION) node.generatetoaddress(VB_PERIOD - VB_THRESHOLD, node_deterministic_address) self.log.info("Check that there is a warning if previous VB_BLOCKS have >=VB_THRESHOLD blocks with unknown versionbits version.") # Mine a period worth of expected blocks so the generic block-version warning # is cleared. This will move the versionbit state to ACTIVE. node.generatetoaddress(VB_PERIOD, node_deterministic_address) # Stop-start the node. This is required because bitcoind will only warn once about unknown versions or unknown rules activating. self.restart_node(0) # Generating one block guarantees that we'll get out of IBD node.generatetoaddress(1, node_deterministic_address) wait_until(lambda: not node.getblockchaininfo()['initialblockdownload'], timeout=10, lock=mininode_lock) # Generating one more block will be enough to generate an error. node.generatetoaddress(1, node_deterministic_address) # Check that get*info() shows the versionbits unknown rules warning assert WARN_UNKNOWN_RULES_ACTIVE in node.getmininginfo()["warnings"] assert WARN_UNKNOWN_RULES_ACTIVE in node.getnetworkinfo()["warnings"] # Check that the alert file shows the versionbits unknown rules warning wait_until(lambda: self.versionbits_in_alert_file(), timeout=60) if __name__ == '__main__': VersionBitsWarningTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 13, 14982, 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, 624, 774, 1015, 5821, 5721, 2656, 14, 199, 199, 6864, 30640, 543, 1853, 5459, 626, 7468, 370, 506, 2070, 26039, 5809, 199, 4617, 13, 509, 6080, 12, 436, 511, 626, 5721, 31529, 787, 4046, 14, 199, 624, 199, 646, 747, 199, 646, 295, 199, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 1218, 63, 1457, 12, 1218, 63, 30488, 199, 504, 511, 63, 4857, 14, 3431, 492, 1499, 63, 1457, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 510, 18, 48, 4267, 12, 1748, 15993, 63, 831, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 3618, 63, 8111, 199, 199, 27966, 63, 27081, 275, 21771, 3698, 327, 1015, 5609, 6247, 2582, 367, 1295, 396, 199, 27966, 63, 19307, 275, 24579, 263, 327, 1015, 5609, 10361, 8765, 367, 1295, 396, 199, 27966, 63, 11422, 63, 14662, 275, 378, 88, 18, 9084, 199, 27966, 63, 11588, 63, 11970, 275, 8087, 755, 327, 29826, 282, 4546, 625, 12941, 370, 1263, 14295, 199, 27966, 63, 11588, 63, 4612, 275, 812, 34, 63, 11422, 63, 14662, 1204, 334, 17, 5213, 812, 34, 63, 11588, 63, 11970, 9, 199, 199, 17449, 63, 11588, 63, 31490, 63, 10401, 275, 298, 5187, 892, 4713, 22225, 334, 1023, 2075, 5009, 1674, 908, 8, 27966, 63, 11588, 63, 11970, 9, 199, 27966, 63, 10764, 275, 295, 14, 2014, 480, 3849, 26, 5809, 892, 4713, 22225, 2795, 1023, 2075, 531, 199, 199, 533, 3394, 10787, 3849, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 1507, 63, 2415, 275, 413, 339, 347, 3272, 63, 1200, 8, 277, 304, 267, 291, 14, 9241, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1419, 14, 8616, 12, 298, 9241, 14, 2424, 531, 267, 327, 3232, 436, 4002, 370, 1218, 4697, 13, 1267, 570, 267, 543, 1551, 8, 277, 14, 9241, 63, 1501, 12, 283, 87, 297, 2644, 534, 1624, 24, 735, 288, 986, 267, 291, 14, 2911, 63, 589, 275, 24212, 13, 9241, 6814, 29, 7878, 450, 83, 4331, 19669, 435, 291, 14, 9241, 63, 1501, 435, 1867, 341, 2677, 267, 291, 14, 2758, 63, 2415, 342, 339, 347, 3222, 63, 4166, 63, 1045, 63, 1023, 8, 277, 12, 9104, 12, 1967, 4166, 12, 1015, 304, 267, 408, 6795, 1967, 4166, 5664, 370, 9104, 543, 1015, 663, 624, 267, 19201, 275, 291, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 342, 267, 4569, 275, 291, 14, 2415, 59, 16, 1055, 30710, 342, 267, 1853, 63, 521, 275, 291, 14, 2415, 59, 16, 1055, 17785, 1291, 8, 8996, 26332, 521, 937, 435, 413, 267, 19201, 275, 1109, 8, 8996, 12, 3193, 9, 398, 367, 485, 315, 1425, 8, 1507, 4166, 304, 288, 1853, 275, 1218, 63, 1457, 8, 8996, 12, 1218, 63, 30488, 8, 3333, 435, 413, 395, 1853, 63, 521, 9, 288, 1853, 14, 78, 3353, 275, 1015, 288, 1853, 14, 11356, 342, 288, 9104, 14, 2254, 63, 1188, 8, 1328, 63, 1457, 8, 1457, 430, 288, 1853, 63, 521, 847, 413, 288, 4569, 847, 413, 288, 19201, 275, 1853, 14, 4835, 3912, 267, 9104, 14, 5186, 63, 1045, 63, 4073, 342, 339, 347, 1015, 5609, 63, 262, 63, 9241, 63, 493, 8, 277, 304, 267, 408, 774, 626, 314, 1015, 5609, 5721, 965, 2757, 5313, 370, 314, 10459, 570, 1041, 267, 10459, 63, 505, 275, 1551, 8, 277, 14, 9241, 63, 1501, 12, 283, 82, 297, 2644, 534, 1624, 24, 1959, 739, 342, 267, 372, 812, 34, 63, 10764, 14, 1733, 8, 9241, 63, 505, 9, 365, 440, 488, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1031, 275, 291, 14, 2415, 59, 16, 61, 267, 1031, 14, 525, 63, 80, 18, 80, 63, 2105, 8, 48, 18, 48, 4267, 1012, 398, 1031, 63, 30709, 63, 1562, 275, 1031, 14, 362, 63, 30709, 63, 10605, 63, 498, 1252, 1562, 267, 327, 603, 1132, 1373, 6247, 25235, 402, 5664, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 12, 1031, 63, 30709, 63, 1562, 9, 398, 291, 14, 793, 14, 815, 480, 1799, 626, 2337, 365, 949, 5721, 340, 4136, 812, 34, 63, 8475, 51, 1172, 665, 27966, 63, 19307, 5664, 543, 5809, 1015, 5609, 1015, 2685, 267, 327, 6516, 1373, 6247, 402, 5664, 543, 665, 812, 34, 63, 19307, 5664, 4673, 316, 2005, 5809, 4546, 267, 291, 14, 2254, 63, 4166, 63, 1045, 63, 1023, 8, 932, 14, 80, 18, 80, 12, 812, 34, 63, 19307, 446, 413, 12, 812, 34, 63, 11588, 63, 4612, 9, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 446, 812, 34, 63, 19307, 435, 413, 12, 1031, 63, 30709, 63, 1562, 9, 398, 327, 2670, 626, 781, 3984, 440, 10232, 1263, 1015, 2075, 13, 2407, 2552, 315, 664, 10, 815, 342, 267, 702, 440, 812, 34, 63, 10764, 14, 1431, 8, 932, 14, 362, 827, 316, 815, 22957, 5451, 3135, 267, 702, 440, 812, 34, 63, 10764, 14, 1431, 8, 932, 14, 362, 1200, 815, 22957, 5451, 3135, 398, 327, 6516, 1373, 6247, 402, 5664, 543, 812, 34, 63, 19307, 5664, 4673, 316, 2005, 5809, 4546, 267, 291, 14, 2254, 63, 4166, 63, 1045, 63, 1023, 8, 932, 14, 80, 18, 80, 12, 812, 34, 63, 19307, 12, 812, 34, 63, 11588, 63, 4612, 9, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 446, 812, 34, 63, 19307, 12, 1031, 63, 30709, 63, 1562, 9, 398, 291, 14, 793, 14, 815, 480, 1799, 626, 2337, 365, 282, 5721, 340, 4136, 812, 34, 63, 8475, 51, 1172, 2356, 27966, 63, 19307, 5664, 543, 5809, 1015, 5609, 1015, 2685, 267, 327, 603, 1132, 282, 6247, 25235, 402, 1420, 5664, 880, 314, 7809, 1853, 13, 1023 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 7800, 13, 14982, 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, 624, 774, 1015, 5821, 5721, 2656, 14, 199, 199, 6864, 30640, 543, 1853, 5459, 626, 7468, 370, 506, 2070, 26039, 5809, 199, 4617, 13, 509, 6080, 12, 436, 511, 626, 5721, 31529, 787, 4046, 14, 199, 624, 199, 646, 747, 199, 646, 295, 199, 199, 504, 511, 63, 4857, 14, 1457, 2537, 492, 1218, 63, 1457, 12, 1218, 63, 30488, 199, 504, 511, 63, 4857, 14, 3431, 492, 1499, 63, 1457, 199, 504, 511, 63, 4857, 14, 827, 15993, 492, 510, 18, 48, 4267, 12, 1748, 15993, 63, 831, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 3618, 63, 8111, 199, 199, 27966, 63, 27081, 275, 21771, 3698, 327, 1015, 5609, 6247, 2582, 367, 1295, 396, 199, 27966, 63, 19307, 275, 24579, 263, 327, 1015, 5609, 10361, 8765, 367, 1295, 396, 199, 27966, 63, 11422, 63, 14662, 275, 378, 88, 18, 9084, 199, 27966, 63, 11588, 63, 11970, 275, 8087, 755, 327, 29826, 282, 4546, 625, 12941, 370, 1263, 14295, 199, 27966, 63, 11588, 63, 4612, 275, 812, 34, 63, 11422, 63, 14662, 1204, 334, 17, 5213, 812, 34, 63, 11588, 63, 11970, 9, 199, 199, 17449, 63, 11588, 63, 31490, 63, 10401, 275, 298, 5187, 892, 4713, 22225, 334, 1023, 2075, 5009, 1674, 908, 8, 27966, 63, 11588, 63, 11970, 9, 199, 27966, 63, 10764, 275, 295, 14, 2014, 480, 3849, 26, 5809, 892, 4713, 22225, 2795, 1023, 2075, 531, 199, 199, 533, 3394, 10787, 3849, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 2758, 63, 3118, 63, 4429, 275, 715, 267, 291, 14, 1507, 63, 2415, 275, 413, 339, 347, 3272, 63, 1200, 8, 277, 304, 267, 291, 14, 9241, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1419, 14, 8616, 12, 298, 9241, 14, 2424, 531, 267, 327, 3232, 436, 4002, 370, 1218, 4697, 13, 1267, 570, 267, 543, 1551, 8, 277, 14, 9241, 63, 1501, 12, 283, 87, 297, 2644, 534, 1624, 24, 735, 288, 986, 267, 291, 14, 2911, 63, 589, 275, 24212, 13, 9241, 6814, 29, 7878, 450, 83, 4331, 19669, 435, 291, 14, 9241, 63, 1501, 435, 1867, 341, 2677, 267, 291, 14, 2758, 63, 2415, 342, 339, 347, 3222, 63, 4166, 63, 1045, 63, 1023, 8, 277, 12, 9104, 12, 1967, 4166, 12, 1015, 304, 267, 408, 6795, 1967, 4166, 5664, 370, 9104, 543, 1015, 663, 624, 267, 19201, 275, 291, 14, 2415, 59, 16, 1055, 362, 7010, 25848, 342, 267, 4569, 275, 291, 14, 2415, 59, 16, 1055, 30710, 342, 267, 1853, 63, 521, 275, 291, 14, 2415, 59, 16, 1055, 17785, 1291, 8, 8996, 26332, 521, 937, 435, 413, 267, 19201, 275, 1109, 8, 8996, 12, 3193, 9, 398, 367, 485, 315, 1425, 8, 1507, 4166, 304, 288, 1853, 275, 1218, 63, 1457, 8, 8996, 12, 1218, 63, 30488, 8, 3333, 435, 413, 395, 1853, 63, 521, 9, 288, 1853, 14, 78, 3353, 275, 1015, 288, 1853, 14, 11356, 342, 288, 9104, 14, 2254, 63, 1188, 8, 1328, 63, 1457, 8, 1457, 430, 288, 1853, 63, 521, 847, 413, 288, 4569, 847, 413, 288, 19201, 275, 1853, 14, 4835, 3912, 267, 9104, 14, 5186, 63, 1045, 63, 4073, 342, 339, 347, 1015, 5609, 63, 262, 63, 9241, 63, 493, 8, 277, 304, 267, 408, 774, 626, 314, 1015, 5609, 5721, 965, 2757, 5313, 370, 314, 10459, 570, 1041, 267, 10459, 63, 505, 275, 1551, 8, 277, 14, 9241, 63, 1501, 12, 283, 82, 297, 2644, 534, 1624, 24, 1959, 739, 342, 267, 372, 812, 34, 63, 10764, 14, 1733, 8, 9241, 63, 505, 9, 365, 440, 488, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1031, 275, 291, 14, 2415, 59, 16, 61, 267, 1031, 14, 525, 63, 80, 18, 80, 63, 2105, 8, 48, 18, 48, 4267, 1012, 398, 1031, 63, 30709, 63, 1562, 275, 1031, 14, 362, 63, 30709, 63, 10605, 63, 498, 1252, 1562, 267, 327, 603, 1132, 1373, 6247, 25235, 402, 5664, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 12, 1031, 63, 30709, 63, 1562, 9, 398, 291, 14, 793, 14, 815, 480, 1799, 626, 2337, 365, 949, 5721, 340, 4136, 812, 34, 63, 8475, 51, 1172, 665, 27966, 63, 19307, 5664, 543, 5809, 1015, 5609, 1015, 2685, 267, 327, 6516, 1373, 6247, 402, 5664, 543, 665, 812, 34, 63, 19307, 5664, 4673, 316, 2005, 5809, 4546, 267, 291, 14, 2254, 63, 4166, 63, 1045, 63, 1023, 8, 932, 14, 80, 18, 80, 12, 812, 34, 63, 19307, 446, 413, 12, 812, 34, 63, 11588, 63, 4612, 9, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 446, 812, 34, 63, 19307, 435, 413, 12, 1031, 63, 30709, 63, 1562, 9, 398, 327, 2670, 626, 781, 3984, 440, 10232, 1263, 1015, 2075, 13, 2407, 2552, 315, 664, 10, 815, 342, 267, 702, 440, 812, 34, 63, 10764, 14, 1431, 8, 932, 14, 362, 827, 316, 815, 22957, 5451, 3135, 267, 702, 440, 812, 34, 63, 10764, 14, 1431, 8, 932, 14, 362, 1200, 815, 22957, 5451, 3135, 398, 327, 6516, 1373, 6247, 402, 5664, 543, 812, 34, 63, 19307, 5664, 4673, 316, 2005, 5809, 4546, 267, 291, 14, 2254, 63, 4166, 63, 1045, 63, 1023, 8, 932, 14, 80, 18, 80, 12, 812, 34, 63, 19307, 12, 812, 34, 63, 11588, 63, 4612, 9, 267, 1031, 14, 4208, 475, 1562, 8, 27966, 63, 27081, 446, 812, 34, 63, 19307, 12, 1031, 63, 30709, 63, 1562, 9, 398, 291, 14, 793, 14, 815, 480, 1799, 626, 2337, 365, 282, 5721, 340, 4136, 812, 34, 63, 8475, 51, 1172, 2356, 27966, 63, 19307, 5664, 543, 5809, 1015, 5609, 1015, 2685, 267, 327, 603, 1132, 282, 6247, 25235, 402, 1420, 5664, 880, 314, 7809, 1853, 13, 1023, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
barreeeiroo/appinventor-sources
appinventor/misc/componentcreator/helpers.py
81
5237
import re from shutil import copy class DuplicateError(Exception): pass class NewComponent(): def __init__(self, compName=None, compImgName=None): self.compName = compName self.compImgName = compImgName self.imgFile = None def addImageReference(self): # read original file with open('../../appengine/src/com/google/appinventor/client/Images.java', 'r') as f: text = f.read() #open template and insert variables with open('Image.java.template') as f: newtxt = f.read() % ( self.compName, self.compImgName, self.compImgName) # if already exists a declaration with same name if re.search(re.escape(newtxt), text): raise DuplicateError # insert new component in file and write text = re.sub(re.escape('procedures();'), 'procedures();\n%s' % newtxt, text) with open('../../appengine/src/com/google/appinventor/client/Images.java', 'w') as f: f.write(text) def copyImageToFolder(self): # if user enabled resizing if self.resizeImage: from PIL import Image # crop and resize image im = Image.open(self.imgFile) diff = max(im.size) - min(im.size) if im.size[0] > im.size[1]: box = (diff / 2, 0, im.size[0] - diff / 2, im.size[1]) else: box = (0, diff / 2, im.size[0], im.size[1] - diff / 2) im = im.crop(box) im.thumbnail((16, 16), Image.ANTIALIAS) im.save('../../appengine/src/com/google/appinventor/images/%s.png' % self.compImgName, "PNG") else: copy(self.imgFile, '../../appengine/src/com/google/appinventor/images/%s.png' % self.compImgName) def createMockComponent(self): if self.visibleComponent: # if visible component, create new mockcomponent with open('Mock.java.template') as f: mockFileContent = f.read( ) % (self.compName, self.compName, self.compName, self.compName, self.compName, self.compName, self.compImgName, self.compName) with open( '../../appengine/src/com/google/appinventor/client/editor/simple/components/Mock%s.java' % self.compName, 'w') as f: f.write(mockFileContent) # update simple component descriptor with new component with open('../../appengine/src/com/google/appinventor/client/editor/simple/palette/SimpleComponentDescriptor.java', 'r') as f: text = f.read() if self.visibleComponent: basetxt = 'import com.google.appinventor.client.editor.simple.components.' newtxt = basetxt + 'Mock' + self.compName + ';' text = re.sub(re.escape(basetxt + 'MockWebViewer;'), basetxt + 'MockWebViewer;\n' + newtxt, text) basetxt = 'return new MockWebViewer(editor);' newtxt = ' } else if (name.equals(Mock%s.TYPE)) {\n return new Mock%s(editor);' % (self.compName, self.compName) text = re.sub(re.escape(basetxt), basetxt + '\n'+newtxt, text) basetxt = 'bundledImages.put("images/web.png", images.web());' text = re.sub(re.escape(basetxt), basetxt + '\n bundledImages.put("images/%s.png", images.%s());' % (self.compImgName, self.compImgName), text) with open('../../appengine/src/com/google/appinventor/client/editor/simple/palette/SimpleComponentDescriptor.java', 'w') as f: f.write(text) def createComponent(self): version = self.compName.upper() + '_COMPONENT_VERSION' # get template for visible or nonvisible component and write to file if self.visibleComponent: with open('VisibleComponent.java.template') as f: content = f.read() % ( version, self.category, self.compImgName, self.compName, self.compName, self.compName) with open('../../components/src/com/google/appinventor/components/runtime/%s.java' % self.compName, 'w') as f2: f2.write(content) else: with open('NonVisibleComponent.java.template') as f: content = f.read() % ( version, self.category, self.compImgName, self.compName, self.compName) with open('../../components/src/com/google/appinventor/components/runtime/%s.java' % self.compName, 'w') as f2: f2.write(content) with open('../../components/src/com/google/appinventor/components/common/YaVersion.java', 'r') as f: text = f.read() oldtxt = 'public static final int SLIDER_COMPONENT_VERSION = 1;' newtxt = '\n\n\n // For %s 1:\n // - Initial Version.\n' % version newtxt += ' public static final int %s = 1;' % version text = re.sub(re.escape(oldtxt), oldtxt + newtxt, text) with open('../../components/src/com/google/appinventor/components/common/YaVersion.java', 'w') as f: f.write(text)
apache-2.0
[ 646, 295, 199, 504, 5145, 492, 1331, 199, 199, 533, 23942, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 7053, 7004, 837, 339, 347, 636, 826, 721, 277, 12, 1013, 985, 29, 403, 12, 1013, 27261, 985, 29, 403, 304, 267, 291, 14, 863, 985, 275, 1013, 985, 267, 291, 14, 863, 27261, 985, 275, 1013, 27261, 985, 267, 291, 14, 4060, 1173, 275, 488, 339, 347, 1050, 3491, 5083, 8, 277, 304, 267, 327, 1586, 3379, 570, 267, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 18882, 14, 6138, 297, 283, 82, 358, 465, 289, 26, 288, 1318, 275, 289, 14, 739, 342, 398, 327, 1490, 1978, 436, 5518, 2860, 267, 543, 1551, 360, 3491, 14, 6138, 14, 1160, 358, 465, 289, 26, 288, 892, 2424, 275, 289, 14, 739, 342, 450, 334, 355, 291, 14, 863, 985, 12, 291, 14, 863, 27261, 985, 12, 291, 14, 863, 27261, 985, 9, 398, 327, 340, 2575, 3495, 282, 12560, 543, 2011, 536, 267, 340, 295, 14, 1733, 8, 264, 14, 3765, 8, 1222, 2424, 395, 1318, 304, 288, 746, 23942, 547, 398, 327, 5518, 892, 3931, 315, 570, 436, 2218, 267, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 360, 496, 6867, 1482, 7303, 659, 283, 496, 6867, 1482, 342, 3779, 78, 5, 83, 7, 450, 892, 2424, 12, 1318, 9, 398, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 18882, 14, 6138, 297, 283, 87, 358, 465, 289, 26, 288, 289, 14, 952, 8, 505, 9, 339, 347, 1331, 3491, 1378, 7850, 8, 277, 304, 267, 327, 340, 922, 5223, 295, 30639, 267, 340, 291, 14, 8709, 3491, 26, 288, 687, 14937, 492, 6047, 953, 327, 18366, 436, 15210, 1834, 288, 3416, 275, 6047, 14, 1490, 8, 277, 14, 4060, 1173, 9, 288, 3915, 275, 1390, 8, 1017, 14, 890, 9, 446, 1748, 8, 1017, 14, 890, 9, 288, 340, 3416, 14, 890, 59, 16, 61, 690, 3416, 14, 890, 59, 17, 2189, 355, 5689, 275, 334, 3028, 1182, 499, 12, 378, 12, 3416, 14, 890, 59, 16, 61, 446, 3915, 1182, 499, 12, 3416, 14, 890, 59, 17, 566, 288, 587, 26, 355, 5689, 275, 334, 16, 12, 3915, 1182, 499, 12, 3416, 14, 890, 59, 16, 467, 3416, 14, 890, 59, 17, 61, 446, 3915, 1182, 499, 9, 953, 3416, 275, 3416, 14, 15816, 8, 1977, 9, 288, 3416, 14, 8311, 1332, 975, 12, 3193, 395, 6047, 14, 1441, 4938, 11352, 9, 953, 3416, 14, 2117, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 4782, 3149, 83, 14, 4524, 7, 450, 355, 291, 14, 863, 27261, 985, 12, 298, 24454, 531, 398, 587, 26, 288, 1331, 8, 277, 14, 4060, 1173, 12, 283, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 4782, 3149, 83, 14, 4524, 7, 450, 291, 14, 863, 27261, 985, 9, 2378, 347, 1218, 3346, 7004, 8, 277, 304, 267, 340, 291, 14, 6604, 7004, 26, 288, 327, 340, 8917, 3931, 12, 1218, 892, 1683, 3173, 288, 543, 1551, 360, 3346, 14, 6138, 14, 1160, 358, 465, 289, 26, 355, 1683, 1173, 2714, 275, 289, 14, 739, 8, 355, 776, 450, 334, 277, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 2151, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 27261, 985, 12, 291, 14, 863, 985, 9, 355, 543, 1551, 8, 490, 283, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 4608, 15, 3346, 5, 83, 14, 6138, 7, 450, 490, 291, 14, 863, 985, 12, 283, 87, 358, 465, 289, 26, 490, 289, 14, 952, 8, 1805, 1173, 2714, 9, 398, 327, 1678, 3486, 3931, 5872, 543, 892, 3931, 267, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 16506, 15, 3184, 7004, 4311, 14, 6138, 297, 283, 82, 358, 465, 289, 26, 288, 1318, 275, 289, 14, 739, 342, 953, 340, 291, 14, 6604, 7004, 26, 355, 19325, 409, 400, 275, 283, 646, 2414, 14, 3098, 14, 571, 262, 782, 269, 14, 1258, 14, 7515, 14, 4129, 14, 4608, 3530, 355, 892, 2424, 275, 221, 19325, 409, 400, 435, 283, 3346, 7, 435, 291, 14, 863, 985, 435, 20054, 355, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 435, 283, 3346, 5926, 22347, 27, 659, 1816, 19325, 409, 400, 435, 283, 3346, 5926, 22347, 3779, 78, 7, 435, 892, 2424, 12, 1318, 9, 2234, 19325, 409, 400, 275, 283, 1107, 892, 4420, 5926, 22347, 8, 7515, 27756, 355, 892, 2424, 275, 221, 283, 259, 789, 587, 340, 334, 354, 14, 11332, 8, 3346, 5, 83, 14, 2711, 430, 9459, 78, 420, 372, 892, 4420, 5, 83, 8, 7515, 27756, 450, 334, 277, 14, 863, 985, 12, 291, 14, 863, 985, 9, 355, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 395, 19325, 409, 400, 435, 1557, 78, 6828, 1222, 2424, 12, 1318, 9, 22919, 19325, 409, 400, 275, 283, 66, 725, 1146, 18882, 14, 524, 480, 4782, 15, 2520, 14, 4524, 401, 5935, 14, 2520, 1012, 8942, 288, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 395, 19325, 409, 400, 435, 1557, 78, 259, 330, 725, 1146, 18882, 14, 524, 480, 4782, 3149, 83, 14, 4524, 401, 5935, 4111, 83, 1012, 8942, 2079, 450, 334, 277, 14, 863, 27261, 985, 12, 291, 14, 863, 27261, 985, 395, 1318, 9, 398, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 16506, 15, 3184, 7004, 4311, 14, 6138, 297, 283, 87, 358, 465, 289, 26, 288, 289, 14, 952, 8, 505, 9, 339, 347, 1218, 7004, 8, 277, 304, 267, 1015, 275, 291, 14, 863, 985, 14, 4142, 342 ]
[ 295, 199, 504, 5145, 492, 1331, 199, 199, 533, 23942, 547, 8, 1726, 304, 272, 986, 199, 199, 533, 7053, 7004, 837, 339, 347, 636, 826, 721, 277, 12, 1013, 985, 29, 403, 12, 1013, 27261, 985, 29, 403, 304, 267, 291, 14, 863, 985, 275, 1013, 985, 267, 291, 14, 863, 27261, 985, 275, 1013, 27261, 985, 267, 291, 14, 4060, 1173, 275, 488, 339, 347, 1050, 3491, 5083, 8, 277, 304, 267, 327, 1586, 3379, 570, 267, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 18882, 14, 6138, 297, 283, 82, 358, 465, 289, 26, 288, 1318, 275, 289, 14, 739, 342, 398, 327, 1490, 1978, 436, 5518, 2860, 267, 543, 1551, 360, 3491, 14, 6138, 14, 1160, 358, 465, 289, 26, 288, 892, 2424, 275, 289, 14, 739, 342, 450, 334, 355, 291, 14, 863, 985, 12, 291, 14, 863, 27261, 985, 12, 291, 14, 863, 27261, 985, 9, 398, 327, 340, 2575, 3495, 282, 12560, 543, 2011, 536, 267, 340, 295, 14, 1733, 8, 264, 14, 3765, 8, 1222, 2424, 395, 1318, 304, 288, 746, 23942, 547, 398, 327, 5518, 892, 3931, 315, 570, 436, 2218, 267, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 360, 496, 6867, 1482, 7303, 659, 283, 496, 6867, 1482, 342, 3779, 78, 5, 83, 7, 450, 892, 2424, 12, 1318, 9, 398, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 18882, 14, 6138, 297, 283, 87, 358, 465, 289, 26, 288, 289, 14, 952, 8, 505, 9, 339, 347, 1331, 3491, 1378, 7850, 8, 277, 304, 267, 327, 340, 922, 5223, 295, 30639, 267, 340, 291, 14, 8709, 3491, 26, 288, 687, 14937, 492, 6047, 953, 327, 18366, 436, 15210, 1834, 288, 3416, 275, 6047, 14, 1490, 8, 277, 14, 4060, 1173, 9, 288, 3915, 275, 1390, 8, 1017, 14, 890, 9, 446, 1748, 8, 1017, 14, 890, 9, 288, 340, 3416, 14, 890, 59, 16, 61, 690, 3416, 14, 890, 59, 17, 2189, 355, 5689, 275, 334, 3028, 1182, 499, 12, 378, 12, 3416, 14, 890, 59, 16, 61, 446, 3915, 1182, 499, 12, 3416, 14, 890, 59, 17, 566, 288, 587, 26, 355, 5689, 275, 334, 16, 12, 3915, 1182, 499, 12, 3416, 14, 890, 59, 16, 467, 3416, 14, 890, 59, 17, 61, 446, 3915, 1182, 499, 9, 953, 3416, 275, 3416, 14, 15816, 8, 1977, 9, 288, 3416, 14, 8311, 1332, 975, 12, 3193, 395, 6047, 14, 1441, 4938, 11352, 9, 953, 3416, 14, 2117, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 4782, 3149, 83, 14, 4524, 7, 450, 355, 291, 14, 863, 27261, 985, 12, 298, 24454, 531, 398, 587, 26, 288, 1331, 8, 277, 14, 4060, 1173, 12, 283, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 4782, 3149, 83, 14, 4524, 7, 450, 291, 14, 863, 27261, 985, 9, 2378, 347, 1218, 3346, 7004, 8, 277, 304, 267, 340, 291, 14, 6604, 7004, 26, 288, 327, 340, 8917, 3931, 12, 1218, 892, 1683, 3173, 288, 543, 1551, 360, 3346, 14, 6138, 14, 1160, 358, 465, 289, 26, 355, 1683, 1173, 2714, 275, 289, 14, 739, 8, 355, 776, 450, 334, 277, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 2151, 291, 14, 863, 985, 12, 291, 14, 863, 985, 12, 291, 14, 863, 27261, 985, 12, 291, 14, 863, 985, 9, 355, 543, 1551, 8, 490, 283, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 4608, 15, 3346, 5, 83, 14, 6138, 7, 450, 490, 291, 14, 863, 985, 12, 283, 87, 358, 465, 289, 26, 490, 289, 14, 952, 8, 1805, 1173, 2714, 9, 398, 327, 1678, 3486, 3931, 5872, 543, 892, 3931, 267, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 16506, 15, 3184, 7004, 4311, 14, 6138, 297, 283, 82, 358, 465, 289, 26, 288, 1318, 275, 289, 14, 739, 342, 953, 340, 291, 14, 6604, 7004, 26, 355, 19325, 409, 400, 275, 283, 646, 2414, 14, 3098, 14, 571, 262, 782, 269, 14, 1258, 14, 7515, 14, 4129, 14, 4608, 3530, 355, 892, 2424, 275, 221, 19325, 409, 400, 435, 283, 3346, 7, 435, 291, 14, 863, 985, 435, 20054, 355, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 435, 283, 3346, 5926, 22347, 27, 659, 1816, 19325, 409, 400, 435, 283, 3346, 5926, 22347, 3779, 78, 7, 435, 892, 2424, 12, 1318, 9, 2234, 19325, 409, 400, 275, 283, 1107, 892, 4420, 5926, 22347, 8, 7515, 27756, 355, 892, 2424, 275, 221, 283, 259, 789, 587, 340, 334, 354, 14, 11332, 8, 3346, 5, 83, 14, 2711, 430, 9459, 78, 420, 372, 892, 4420, 5, 83, 8, 7515, 27756, 450, 334, 277, 14, 863, 985, 12, 291, 14, 863, 985, 9, 355, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 395, 19325, 409, 400, 435, 1557, 78, 6828, 1222, 2424, 12, 1318, 9, 22919, 19325, 409, 400, 275, 283, 66, 725, 1146, 18882, 14, 524, 480, 4782, 15, 2520, 14, 4524, 401, 5935, 14, 2520, 1012, 8942, 288, 1318, 275, 295, 14, 954, 8, 264, 14, 3765, 8, 2470, 409, 400, 395, 19325, 409, 400, 435, 1557, 78, 259, 330, 725, 1146, 18882, 14, 524, 480, 4782, 3149, 83, 14, 4524, 401, 5935, 4111, 83, 1012, 8942, 2079, 450, 334, 277, 14, 863, 27261, 985, 12, 291, 14, 863, 27261, 985, 395, 1318, 9, 398, 543, 1551, 360, 9707, 15358, 15, 2164, 15, 957, 15, 3098, 15, 571, 262, 782, 269, 15, 1258, 15, 7515, 15, 4129, 15, 16506, 15, 3184, 7004, 4311, 14, 6138, 297, 283, 87, 358, 465, 289, 26, 288, 289, 14, 952, 8, 505, 9, 339, 347, 1218, 7004, 8, 277, 304, 267, 1015, 275, 291, 14, 863, 985, 14, 4142, 342, 0 ]
[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]
jalexvig/tensorflow
tensorflow/python/training/session_manager_test.py
22
32764
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for SessionManager.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os from tensorflow.python.client import session as session_lib from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import variables from tensorflow.python.platform import gfile from tensorflow.python.platform import test from tensorflow.python.training import saver as saver_lib from tensorflow.python.training import server_lib from tensorflow.python.training import session_manager class SessionManagerTest(test.TestCase): def testPrepareSessionSucceeds(self): with ops.Graph().as_default(): v = variables.Variable([1.0, 2.0, 3.0], name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer()) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) def testPrepareSessionSucceedsWithInitFeedDict(self): with ops.Graph().as_default(): p = array_ops.placeholder(dtypes.float32, shape=(3,)) v = variables.Variable(p, name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer(), init_feed_dict={p: [1.0, 2.0, 3.0]}) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) def testPrepareSessionSucceedsWithInitFn(self): with ops.Graph().as_default(): v = variables.Variable([125], name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) sess = sm.prepare_session( "", init_fn=lambda sess: sess.run(v.initializer)) self.assertAllClose([125], sess.run(v)) def testPrepareSessionFails(self): checkpoint_dir = os.path.join(self.get_temp_dir(), "prepare_session") checkpoint_dir2 = os.path.join(self.get_temp_dir(), "prepare_session2") try: gfile.DeleteRecursively(checkpoint_dir) gfile.DeleteRecursively(checkpoint_dir2) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable([1.0, 2.0, 3.0], name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer(), saver=saver, checkpoint_dir=checkpoint_dir) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) checkpoint_filename = os.path.join(checkpoint_dir, "prepare_session_checkpoint") saver.save(sess, checkpoint_filename) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): # Renames the checkpoint directory. os.rename(checkpoint_dir, checkpoint_dir2) gfile.MakeDirs(checkpoint_dir) v = variables.Variable([6.0, 7.0, 8.0], name="v") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) # This should fail as there's no checkpoint within 2 seconds. with self.assertRaisesRegexp( RuntimeError, "no init_op or init_fn or local_init_op was given"): sess = sm.prepare_session( "", init_op=None, saver=saver, checkpoint_dir=checkpoint_dir, wait_for_checkpoint=True, max_wait_secs=2) # Rename the checkpoint directory back. gfile.DeleteRecursively(checkpoint_dir) os.rename(checkpoint_dir2, checkpoint_dir) # This should succeed as there's checkpoint. sess = sm.prepare_session( "", init_op=None, saver=saver, checkpoint_dir=checkpoint_dir, wait_for_checkpoint=True, max_wait_secs=2) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) def _test_recovered_variable(self, checkpoint_dir=None, checkpoint_filename_with_path=None): # Create a new Graph and SessionManager and recover from a checkpoint. with ops.Graph().as_default(): v = variables.Variable(2, name="v") with session_lib.Session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm2.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir, checkpoint_filename_with_path=checkpoint_filename_with_path) self.assertTrue(initialized) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) def testRecoverSession(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), "recover_session") try: gfile.DeleteRecursively(checkpoint_dir) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertFalse(initialized) sess.run(v.initializer) self.assertEquals(1, sess.run(v)) saver.save(sess, os.path.join(checkpoint_dir, "recover_session_checkpoint")) self._test_recovered_variable(checkpoint_dir=checkpoint_dir) self._test_recovered_variable( checkpoint_filename_with_path=saver_lib.latest_checkpoint( checkpoint_dir)) # Cannot set both checkpoint_dir and checkpoint_filename_with_path. with self.assertRaises(ValueError): self._test_recovered_variable( checkpoint_dir=checkpoint_dir, checkpoint_filename_with_path=saver_lib.latest_checkpoint( checkpoint_dir)) def testWaitForSessionReturnsNoneAfterTimeout(self): with ops.Graph().as_default(): variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), recovery_wait_secs=1) # Set max_wait_secs to allow us to try a few times. with self.assertRaises(errors.DeadlineExceededError): sm.wait_for_session(master="", max_wait_secs=3) def testInitWithNoneLocalInitOpError(self): # Creating a SessionManager with a None local_init_op but # non-None ready_for_local_init_op raises ValueError with self.assertRaisesRegexp(ValueError, "If you pass a ready_for_local_init_op " "you must also pass a local_init_op "): session_manager.SessionManager( ready_for_local_init_op=variables.report_uninitialized_variables( variables.global_variables()), local_init_op=None) def testRecoverSessionWithReadyForLocalInitOp(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), "recover_session_ready_for_local_init") try: gfile.DeleteRecursively(checkpoint_dir) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertFalse(initialized) sess.run(v.initializer) self.assertEquals(1, sess.run(v)) saver.save(sess, os.path.join(checkpoint_dir, "recover_session_checkpoint")) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): v = variables.Variable(2, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables( variables.global_variables()), local_init_op=w.initializer) saver = saver_lib.Saver({"v": v}) sess, initialized = sm2.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertTrue(initialized) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) self.assertEquals(1, sess.run(w)) def testRecoverSessionWithReadyForLocalInitOpFailsToReadyLocal(self): # We use ready_for_local_init_op=tf.report_uninitialized_variables(), # which causes recover_session to not run local_init_op, and to return # initialized=False # Create a checkpoint. checkpoint_dir = os.path.join( self.get_temp_dir(), "recover_session_ready_for_local_init_fails_to_ready_local") try: gfile.DeleteRecursively(checkpoint_dir) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertFalse(initialized) sess.run(v.initializer) self.assertEquals(1, sess.run(v)) saver.save(sess, os.path.join(checkpoint_dir, "recover_session_checkpoint")) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): v = variables.Variable(2, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables(), local_init_op=w.initializer) saver = saver_lib.Saver({"v": v}) sess, initialized = sm2.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertFalse(initialized) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( False, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) def testRecoverSessionNoChkptStillRunsLocalInitOp(self): # This test checks for backwards compatibility. # In particular, we continue to ensure that recover_session will execute # local_init_op exactly once, regardless of whether the session was # successfully recovered. with ops.Graph().as_default(): w = variables.Variable( 1, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=None, local_init_op=w.initializer) # Try to recover session from None sess, initialized = sm2.recover_session( "", saver=None, checkpoint_dir=None) # Succeeds because recover_session still run local_init_op self.assertFalse(initialized) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(w)) def testRecoverSessionFailsStillRunsLocalInitOp(self): # Create a checkpoint. checkpoint_dir = os.path.join( self.get_temp_dir(), "recover_session_ready_for_local_init_fails_stil_run") try: gfile.DeleteRecursively(checkpoint_dir) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): v = variables.Variable(2, name="v") w = variables.Variable( 1, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=None, local_init_op=w.initializer) saver = saver_lib.Saver({"v": v}) sess, initialized = sm2.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir, wait_for_checkpoint=False) self.assertFalse(initialized) self.assertEqual( False, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(w)) def testWaitForSessionLocalInit(self): server = server_lib.Server.create_local_server() with ops.Graph().as_default() as graph: v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") sm = session_manager.SessionManager( graph=graph, ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables( variables.global_variables()), local_init_op=w.initializer) # Initialize v but not w s = session_lib.Session(server.target, graph=graph) s.run(v.initializer) sess = sm.wait_for_session(server.target, max_wait_secs=3) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) self.assertEquals(1, sess.run(w)) def testWaitForSessionWithReadyForLocalInitOpFailsToReadyLocal(self): with ops.Graph().as_default() as graph: v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") sm = session_manager.SessionManager( graph=graph, ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables(), local_init_op=w.initializer) with self.assertRaises(errors_impl.DeadlineExceededError): # Time-out because w fails to be initialized, # because of overly restrictive ready_for_local_init_op sm.wait_for_session("", max_wait_secs=3) def testWaitForSessionInsufficientReadyForLocalInitCheck(self): with ops.Graph().as_default() as graph: v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") sm = session_manager.SessionManager( graph=graph, ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=None, local_init_op=w.initializer) with self.assertRaisesRegexp(errors_impl.DeadlineExceededError, "Session was not ready after waiting.*"): sm.wait_for_session("", max_wait_secs=3) def testPrepareSessionWithReadyForLocalInitOp(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") x = variables.Variable( 3 * v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="x") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) self.assertEqual(False, variables.is_variable_initialized(x).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables( variables.global_variables()), local_init_op=[w.initializer, x.initializer]) sess = sm2.prepare_session("", init_op=v.initializer) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("x:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) self.assertEquals(1, sess.run(w)) self.assertEquals(3, sess.run(x)) def testPrepareSessionWithPartialInitOp(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") x = variables.Variable( 3 * v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="x") # TODO(b/70206927): Use ResourceVariables once they are handled properly. v_res = variables.Variable(1, name="v_res") w_res = variables.Variable( v_res, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w_res") x_res = variables.Variable( 3 * v_res, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="x_res") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) self.assertEqual(False, variables.is_variable_initialized(x).eval()) self.assertEqual(False, variables.is_variable_initialized(v_res).eval()) self.assertEqual(False, variables.is_variable_initialized(w_res).eval()) self.assertEqual(False, variables.is_variable_initialized(x_res).eval()) sm2 = session_manager.SessionManager(local_init_op=[ w.initializer, x.initializer, w_res.initializer, x_res.initializer ]) sess = sm2.prepare_session("", init_op=None) self.assertEqual( False, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("x:0")).eval(session=sess)) self.assertEquals(1, sess.run(w)) self.assertEquals(3, sess.run(x)) self.assertEqual( False, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v_res:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("w_res:0")).eval(session=sess)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("x_res:0")).eval(session=sess)) self.assertEquals(1, sess.run(w_res)) self.assertEquals(3, sess.run(x_res)) def testPrepareSessionWithCyclicInitializer(self): # Regression test. Previously Variable._build_initializer_expr would enter # into an infinite recursion when the variable's initial_value involved # cyclic dependencies. with ops.Graph().as_default(): i = control_flow_ops.while_loop(lambda i: i < 1, lambda i: i + 1, [0]) v = variables.Variable(array_ops.identity(i), name="v") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) sm = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) sess = sm.prepare_session("", init_op=v.initializer) self.assertEqual(1, sess.run(v)) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) def testPrepareSessionDidNotInitLocalVariable(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) with self.assertRaisesRegexp( RuntimeError, "Init operations did not make model ready.*"): sm2.prepare_session("", init_op=v.initializer) def testPrepareSessionDidNotInitLocalVariableList(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables()) with self.assertRaisesRegexp(RuntimeError, "Init operations did not make model ready"): sm2.prepare_session("", init_op=[v.initializer]) def testPrepareSessionWithReadyNotReadyForLocal(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=variables.report_uninitialized_variables( variables.global_variables()), local_init_op=w.initializer) with self.assertRaisesRegexp( RuntimeError, "Init operations did not make model ready for local_init"): sm2.prepare_session("", init_op=None) def testPrepareSessionWithInsufficientReadyForLocalInitCheck(self): with ops.Graph().as_default(): v = variables.Variable(1, name="v") w = variables.Variable( v, trainable=False, collections=[ops.GraphKeys.LOCAL_VARIABLES], name="w") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) self.assertEqual(False, variables.is_variable_initialized(w).eval()) sm2 = session_manager.SessionManager( ready_op=variables.report_uninitialized_variables(), ready_for_local_init_op=None, local_init_op=w.initializer) with self.assertRaisesRegexp(RuntimeError, "Init operations did not make model ready.*"): sm2.prepare_session("", init_op=None) class ObsoleteSessionManagerTest(test.TestCase): def testPrepareSessionSucceeds(self): with ops.Graph().as_default(): v = variables.Variable([1.0, 2.0, 3.0], name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer()) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) def testPrepareSessionSucceedsWithInitFeedDict(self): with ops.Graph().as_default(): p = array_ops.placeholder(dtypes.float32, shape=(3,)) v = variables.Variable(p, name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer(), init_feed_dict={p: [1.0, 2.0, 3.0]}) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) def testPrepareSessionSucceedsWithInitFn(self): with ops.Graph().as_default(): v = variables.Variable([125], name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) sess = sm.prepare_session( "", init_fn=lambda sess: sess.run(v.initializer)) self.assertAllClose([125], sess.run(v)) def testPrepareSessionFails(self): checkpoint_dir = os.path.join(self.get_temp_dir(), "prepare_session") checkpoint_dir2 = os.path.join(self.get_temp_dir(), "prepare_session2") try: gfile.DeleteRecursively(checkpoint_dir) gfile.DeleteRecursively(checkpoint_dir2) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable([1.0, 2.0, 3.0], name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) saver = saver_lib.Saver({"v": v}) sess = sm.prepare_session( "", init_op=variables.global_variables_initializer(), saver=saver, checkpoint_dir=checkpoint_dir) self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) checkpoint_filename = os.path.join(checkpoint_dir, "prepare_session_checkpoint") saver.save(sess, checkpoint_filename) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): # Renames the checkpoint directory. os.rename(checkpoint_dir, checkpoint_dir2) gfile.MakeDirs(checkpoint_dir) v = variables.Variable([6.0, 7.0, 8.0], name="v") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) saver = saver_lib.Saver({"v": v}) # This should fail as there's no checkpoint within 2 seconds. with self.assertRaisesRegexp( RuntimeError, "no init_op or init_fn or local_init_op was given"): sess = sm.prepare_session( "", init_op=None, saver=saver, checkpoint_dir=checkpoint_dir, wait_for_checkpoint=True, max_wait_secs=2) # Rename the checkpoint directory back. gfile.DeleteRecursively(checkpoint_dir) os.rename(checkpoint_dir2, checkpoint_dir) # This should succeed as there's checkpoint. sess = sm.prepare_session( "", init_op=None, saver=saver, checkpoint_dir=checkpoint_dir, wait_for_checkpoint=True, max_wait_secs=2) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) def testRecoverSession(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), "recover_session") try: gfile.DeleteRecursively(checkpoint_dir) except errors.OpError: pass # Ignore gfile.MakeDirs(checkpoint_dir) with ops.Graph().as_default(): v = variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertFalse(initialized) sess.run(v.initializer) self.assertEquals(1, sess.run(v)) saver.save(sess, os.path.join(checkpoint_dir, "recover_session_checkpoint")) # Create a new Graph and SessionManager and recover. with ops.Graph().as_default(): v = variables.Variable(2, name="v") with self.test_session(): self.assertEqual(False, variables.is_variable_initialized(v).eval()) sm2 = session_manager.SessionManager( ready_op=variables.assert_variables_initialized()) saver = saver_lib.Saver({"v": v}) sess, initialized = sm2.recover_session( "", saver=saver, checkpoint_dir=checkpoint_dir) self.assertTrue(initialized) self.assertEqual( True, variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) def testWaitForSessionReturnsNoneAfterTimeout(self): with ops.Graph().as_default(): variables.Variable(1, name="v") sm = session_manager.SessionManager( ready_op=variables.assert_variables_initialized(), recovery_wait_secs=1) # Set max_wait_secs to allow us to try a few times. with self.assertRaises(errors.DeadlineExceededError): sm.wait_for_session(master="", max_wait_secs=3) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 8596, 2988, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 465, 2351, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 17559, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 1654, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 2351, 63, 2609, 421, 199, 533, 8596, 2988, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 22281, 4434, 22937, 5923, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1012, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 22937, 5923, 3007, 9346, 7658, 2141, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 299, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 2687, 19, 4641, 489, 373, 275, 2860, 14, 2773, 8, 80, 12, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 881, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1062, 881, 4205, 63, 3871, 63, 807, 3126, 80, 26, 359, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 13412, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 22937, 5923, 3007, 9346, 9656, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 6889, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 4205, 63, 2324, 29, 2734, 4043, 26, 4043, 14, 1065, 8, 86, 14, 6498, 430, 489, 291, 14, 7260, 779, 6889, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 4874, 83, 8, 277, 304, 272, 9997, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 6726, 63, 1730, 531, 272, 9997, 63, 694, 18, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 6726, 63, 1730, 18, 531, 272, 862, 26, 489, 26532, 14, 5392, 14244, 9840, 8, 10109, 63, 694, 9, 489, 26532, 14, 5392, 14244, 9840, 8, 10109, 63, 694, 18, 9, 272, 871, 2552, 14, 21783, 26, 489, 986, 221, 327, 14092, 272, 26532, 14, 5483, 17051, 8, 10109, 63, 694, 9, 339, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 17559, 275, 17559, 63, 773, 14, 20829, 6333, 86, 582, 373, 1552, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 881, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1062, 881, 17559, 29, 21166, 12, 881, 9997, 63, 694, 29, 10109, 63, 694, 9, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 489, 9997, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 10109, 63, 694, 12, 1460, 298, 6726, 63, 1730, 63, 10109, 531, 489, 17559, 14, 2117, 8, 5480, 12, 9997, 63, 1501, 9, 272, 327, 2790, 282, 892, 11513, 436, 8596, 2988, 436, 22803, 14, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 327, 10055, 14015, 314, 9997, 2082, 14, 489, 747, 14, 8165, 8, 10109, 63, 694, 12, 9997, 63, 694, 18, 9, 489, 26532, 14, 5483, 17051, 8, 10109, 63, 694, 9, 489, 373, 275, 2860, 14, 2773, 779 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 8596, 2988, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 465, 2351, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 7588, 492, 17559, 465, 17559, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 1654, 63, 773, 199, 504, 3228, 14, 1548, 14, 7588, 492, 2351, 63, 2609, 421, 199, 533, 8596, 2988, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 22281, 4434, 22937, 5923, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1012, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 22937, 5923, 3007, 9346, 7658, 2141, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 299, 275, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 708, 12, 2215, 2687, 19, 4641, 489, 373, 275, 2860, 14, 2773, 8, 80, 12, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 881, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1062, 881, 4205, 63, 3871, 63, 807, 3126, 80, 26, 359, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 13412, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 22937, 5923, 3007, 9346, 9656, 8, 277, 304, 272, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 6889, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 4205, 63, 2324, 29, 2734, 4043, 26, 4043, 14, 1065, 8, 86, 14, 6498, 430, 489, 291, 14, 7260, 779, 6889, 467, 4043, 14, 1065, 8, 86, 430, 819, 347, 511, 22281, 4434, 4874, 83, 8, 277, 304, 272, 9997, 63, 694, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 6726, 63, 1730, 531, 272, 9997, 63, 694, 18, 275, 747, 14, 515, 14, 904, 8, 277, 14, 362, 63, 808, 63, 694, 1062, 298, 6726, 63, 1730, 18, 531, 272, 862, 26, 489, 26532, 14, 5392, 14244, 9840, 8, 10109, 63, 694, 9, 489, 26532, 14, 5392, 14244, 9840, 8, 10109, 63, 694, 18, 9, 272, 871, 2552, 14, 21783, 26, 489, 986, 221, 327, 14092, 272, 26532, 14, 5483, 17051, 8, 10109, 63, 694, 9, 339, 543, 4156, 14, 4578, 1252, 305, 63, 885, 837, 489, 373, 275, 2860, 14, 2773, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 536, 628, 86, 531, 489, 4383, 275, 2351, 63, 2609, 14, 4434, 2988, 8, 881, 10144, 63, 411, 29, 3669, 14, 3070, 63, 324, 12486, 63, 3669, 1012, 489, 17559, 275, 17559, 63, 773, 14, 20829, 6333, 86, 582, 373, 1552, 489, 4043, 275, 4383, 14, 6726, 63, 1730, 8, 881, 4873, 881, 4205, 63, 411, 29, 3669, 14, 2966, 63, 3669, 63, 6498, 1062, 881, 17559, 29, 21166, 12, 881, 9997, 63, 694, 29, 10109, 63, 694, 9, 489, 291, 14, 7260, 779, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 467, 4043, 14, 1065, 8, 86, 430, 489, 9997, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 10109, 63, 694, 12, 1460, 298, 6726, 63, 1730, 63, 10109, 531, 489, 17559, 14, 2117, 8, 5480, 12, 9997, 63, 1501, 9, 272, 327, 2790, 282, 892, 11513, 436, 8596, 2988, 436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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 ]
codeskyblue/xmind-sdk-python
xmind/core/saver.py
5
1401
#!/usr/bin/env python #-*- coding: utf-8 -*- """ xmind.core.saver ~~~~~~~~~~~~~~~~~ :copyright: :license: """ __author__ = "aiqi@xmind.net <Woody Ai>" import codecs from . import const from .. import utils class WorkbookSaver(object): def __init__(self, workbook): """ Save `WorkbookDocument` as XMind file. :param workbook: `WorkbookDocument` object """ self._workbook = workbook def _get_content(self): content_path = utils.join_path(utils.temp_dir(), const.CONTENT_XML) with codecs.open(content_path, "w", encoding="utf-8") as f: self._workbook.output(f) return content_path def save(self, path=None): """ Save the workbook to the given path. If the path is not given, then will save to the path set in workbook. """ path = path or self._workbook.get_path() if not path: raise Exception("Please specify a filename for the XMind file") path = utils.get_abs_path(path) file_name, ext = utils.split_ext(path) if ext != const.XMIND_EXT: raise Exception("XMind filenames require a '%s' extension" % const.XMIND_EXT) content = self._get_content() f=utils.compress(path) f.write(content, const.CONTENT_XML) def main(): pass if __name__ == "__main__": main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 13, 1837, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 17725, 688, 14, 1018, 14, 21166, 272, 18294, 94, 339, 520, 7307, 26, 272, 520, 1682, 26, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 5789, 23104, 32, 10198, 688, 14, 846, 665, 26724, 1351, 437, 73, 4335, 199, 199, 646, 6010, 199, 199, 504, 1275, 492, 950, 199, 504, 2508, 492, 3778, 421, 199, 533, 9361, 2706, 20829, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1736, 2706, 304, 267, 408, 11063, 658, 6517, 2706, 5564, 64, 465, 1323, 45, 688, 570, 14, 398, 520, 635, 1736, 2706, 26, 658, 6517, 2706, 5564, 64, 909, 398, 408, 267, 291, 423, 30765, 275, 1736, 2706, 339, 347, 485, 362, 63, 1317, 8, 277, 304, 267, 1564, 63, 515, 275, 3778, 14, 904, 63, 515, 8, 1208, 14, 808, 63, 694, 1062, 950, 14, 9663, 63, 4317, 9, 398, 543, 6010, 14, 1490, 8, 1317, 63, 515, 12, 298, 87, 401, 2644, 628, 1624, 13, 24, 531, 465, 289, 26, 288, 291, 423, 30765, 14, 1199, 8, 70, 9, 398, 372, 1564, 63, 515, 339, 347, 3354, 8, 277, 12, 931, 29, 403, 304, 267, 408, 267, 11063, 314, 1736, 2706, 370, 314, 1627, 931, 14, 982, 314, 931, 365, 440, 1627, 12, 2066, 267, 911, 3354, 370, 314, 931, 663, 315, 1736, 2706, 14, 267, 408, 267, 931, 275, 931, 503, 291, 423, 30765, 14, 362, 63, 515, 342, 398, 340, 440, 931, 26, 288, 746, 2186, 480, 8254, 4165, 282, 1788, 367, 314, 1323, 45, 688, 570, 531, 398, 931, 275, 3778, 14, 362, 63, 2101, 63, 515, 8, 515, 9, 398, 570, 63, 354, 12, 1599, 275, 3778, 14, 1294, 63, 832, 8, 515, 9, 398, 340, 1599, 1137, 950, 14, 13901, 3192, 63, 2472, 26, 288, 746, 2186, 480, 13901, 688, 6203, 4409, 282, 1543, 83, 7, 3329, 2, 450, 950, 14, 13901, 3192, 63, 2472, 9, 398, 1564, 275, 291, 423, 362, 63, 1317, 342, 398, 289, 29, 1208, 14, 6447, 8, 515, 9, 267, 289, 14, 952, 8, 1317, 12, 950, 14, 9663, 63, 4317, 9, 421, 199, 318, 2446, 837, 272, 986, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 13, 1837, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 17725, 688, 14, 1018, 14, 21166, 272, 18294, 94, 339, 520, 7307, 26, 272, 520, 1682, 26, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 5789, 23104, 32, 10198, 688, 14, 846, 665, 26724, 1351, 437, 73, 4335, 199, 199, 646, 6010, 199, 199, 504, 1275, 492, 950, 199, 504, 2508, 492, 3778, 421, 199, 533, 9361, 2706, 20829, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1736, 2706, 304, 267, 408, 11063, 658, 6517, 2706, 5564, 64, 465, 1323, 45, 688, 570, 14, 398, 520, 635, 1736, 2706, 26, 658, 6517, 2706, 5564, 64, 909, 398, 408, 267, 291, 423, 30765, 275, 1736, 2706, 339, 347, 485, 362, 63, 1317, 8, 277, 304, 267, 1564, 63, 515, 275, 3778, 14, 904, 63, 515, 8, 1208, 14, 808, 63, 694, 1062, 950, 14, 9663, 63, 4317, 9, 398, 543, 6010, 14, 1490, 8, 1317, 63, 515, 12, 298, 87, 401, 2644, 628, 1624, 13, 24, 531, 465, 289, 26, 288, 291, 423, 30765, 14, 1199, 8, 70, 9, 398, 372, 1564, 63, 515, 339, 347, 3354, 8, 277, 12, 931, 29, 403, 304, 267, 408, 267, 11063, 314, 1736, 2706, 370, 314, 1627, 931, 14, 982, 314, 931, 365, 440, 1627, 12, 2066, 267, 911, 3354, 370, 314, 931, 663, 315, 1736, 2706, 14, 267, 408, 267, 931, 275, 931, 503, 291, 423, 30765, 14, 362, 63, 515, 342, 398, 340, 440, 931, 26, 288, 746, 2186, 480, 8254, 4165, 282, 1788, 367, 314, 1323, 45, 688, 570, 531, 398, 931, 275, 3778, 14, 362, 63, 2101, 63, 515, 8, 515, 9, 398, 570, 63, 354, 12, 1599, 275, 3778, 14, 1294, 63, 832, 8, 515, 9, 398, 340, 1599, 1137, 950, 14, 13901, 3192, 63, 2472, 26, 288, 746, 2186, 480, 13901, 688, 6203, 4409, 282, 1543, 83, 7, 3329, 2, 450, 950, 14, 13901, 3192, 63, 2472, 9, 398, 1564, 275, 291, 423, 362, 63, 1317, 342, 398, 289, 29, 1208, 14, 6447, 8, 515, 9, 267, 289, 14, 952, 8, 1317, 12, 950, 14, 9663, 63, 4317, 9, 421, 199, 318, 2446, 837, 272, 986, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2446, 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, 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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 ]
stack-of-tasks/rbdlpy
tutorial/lib/python2.7/site-packages/OpenGL/GL/NV/texture_expand_normal.py
9
1288
'''OpenGL extension NV.texture_expand_normal This module customises the behaviour of the OpenGL.raw.GL.NV.texture_expand_normal to provide a more Python-friendly API Overview (from the spec) This extension provides a remapping mode where unsigned texture components (in the range [0,1]) can be treated as though they contained signed data (in the range [-1,+1]). This allows applications to easily encode signed data into unsigned texture formats. The functionality of this extension is nearly identical to the EXPAND_NORMAL_NV remapping mode provided in the NV_register_combiners extension, although it applies even if register combiners are used. The official definition of this extension is available here: http://www.opengl.org/registry/specs/NV/texture_expand_normal.txt ''' from OpenGL import platform, constant, arrays from OpenGL import extensions, wrapper import ctypes from OpenGL.raw.GL import _types, _glgets from OpenGL.raw.GL.NV.texture_expand_normal import * from OpenGL.raw.GL.NV.texture_expand_normal import _EXTENSION_NAME def glInitTextureExpandNormalNV(): '''Return boolean indicating whether this extension is available''' from OpenGL import extensions return extensions.hasGLExtension( _EXTENSION_NAME ) ### END AUTOGENERATED SECTION
lgpl-3.0
[ 2344, 4299, 2226, 3329, 653, 54, 14, 12611, 63, 4441, 63, 3302, 199, 199, 2765, 859, 3537, 1388, 314, 13942, 402, 314, 221, 199, 4299, 2226, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 370, 5647, 282, 1655, 221, 199, 4718, 13, 17317, 3261, 199, 199, 28077, 334, 504, 314, 3158, 9, 8299, 198, 2765, 3329, 6571, 282, 295, 4745, 818, 2382, 7381, 14855, 199, 198, 4608, 334, 262, 314, 1425, 359, 16, 12, 17, 566, 883, 506, 10184, 465, 10617, 2985, 199, 198, 30288, 10514, 666, 334, 262, 314, 1425, 5243, 17, 12, 11, 17, 6575, 221, 961, 6127, 199, 198, 15853, 370, 16174, 3752, 10514, 666, 1901, 7381, 14855, 199, 198, 6321, 14, 8299, 198, 1918, 9330, 402, 642, 3329, 365, 17429, 590, 13130, 370, 314, 199, 198, 20612, 63, 10765, 63, 7312, 295, 4745, 818, 2741, 315, 314, 653, 54, 63, 2683, 63, 6560, 262, 1192, 199, 198, 3435, 12, 22160, 652, 12966, 2755, 340, 2274, 5300, 262, 1192, 787, 1202, 14, 199, 199, 1918, 25410, 5492, 402, 642, 3329, 365, 2808, 2348, 26, 199, 1014, 921, 1544, 14, 32477, 14, 1308, 15, 5189, 15, 7273, 15, 7312, 15, 12611, 63, 4441, 63, 3302, 14, 2424, 199, 2344, 199, 504, 24374, 492, 4298, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 12, 4975, 199, 646, 5577, 199, 504, 24374, 14, 1773, 14, 2226, 492, 485, 1313, 12, 485, 3528, 24894, 199, 504, 24374, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 492, 627, 199, 504, 24374, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 492, 485, 15498, 63, 2339, 199, 199, 318, 6482, 9346, 17165, 12839, 6241, 7312, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 687, 24374, 492, 5478, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 485, 15498, 63, 2339, 776, 421, 199, 5680, 7729, 25420, 12795, 6989, 29074, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4299, 2226, 3329, 653, 54, 14, 12611, 63, 4441, 63, 3302, 199, 199, 2765, 859, 3537, 1388, 314, 13942, 402, 314, 221, 199, 4299, 2226, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 370, 5647, 282, 1655, 221, 199, 4718, 13, 17317, 3261, 199, 199, 28077, 334, 504, 314, 3158, 9, 8299, 198, 2765, 3329, 6571, 282, 295, 4745, 818, 2382, 7381, 14855, 199, 198, 4608, 334, 262, 314, 1425, 359, 16, 12, 17, 566, 883, 506, 10184, 465, 10617, 2985, 199, 198, 30288, 10514, 666, 334, 262, 314, 1425, 5243, 17, 12, 11, 17, 6575, 221, 961, 6127, 199, 198, 15853, 370, 16174, 3752, 10514, 666, 1901, 7381, 14855, 199, 198, 6321, 14, 8299, 198, 1918, 9330, 402, 642, 3329, 365, 17429, 590, 13130, 370, 314, 199, 198, 20612, 63, 10765, 63, 7312, 295, 4745, 818, 2741, 315, 314, 653, 54, 63, 2683, 63, 6560, 262, 1192, 199, 198, 3435, 12, 22160, 652, 12966, 2755, 340, 2274, 5300, 262, 1192, 787, 1202, 14, 199, 199, 1918, 25410, 5492, 402, 642, 3329, 365, 2808, 2348, 26, 199, 1014, 921, 1544, 14, 32477, 14, 1308, 15, 5189, 15, 7273, 15, 7312, 15, 12611, 63, 4441, 63, 3302, 14, 2424, 199, 2344, 199, 504, 24374, 492, 4298, 12, 4413, 12, 6572, 199, 504, 24374, 492, 5478, 12, 4975, 199, 646, 5577, 199, 504, 24374, 14, 1773, 14, 2226, 492, 485, 1313, 12, 485, 3528, 24894, 199, 504, 24374, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 492, 627, 199, 504, 24374, 14, 1773, 14, 2226, 14, 7312, 14, 12611, 63, 4441, 63, 3302, 492, 485, 15498, 63, 2339, 199, 199, 318, 6482, 9346, 17165, 12839, 6241, 7312, 837, 272, 1449, 1767, 5046, 9297, 3775, 642, 3329, 365, 2808, 2344, 272, 687, 24374, 492, 5478, 272, 372, 5478, 14, 1989, 12827, 88, 724, 438, 8, 485, 15498, 63, 2339, 776, 421, 199, 5680, 7729, 25420, 12795, 6989, 29074, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
faarwa/EngSocP5
zxing/cpp/scons/scons-local-2.0.0.final.0/SCons/Tool/Perforce.py
34
3814
"""SCons.Tool.Perforce.py Tool-specific initialization for Perforce Source Code Management system. There normally shouldn't be any need to import this module directly. It will usually be imported through the generic SCons.Tool.Tool() selection method. """ # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation # # 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__ = "src/engine/SCons/Tool/Perforce.py 5023 2010/06/14 22:05:46 scons" import os import SCons.Action import SCons.Builder import SCons.Node.FS import SCons.Util # This function should maybe be moved to SCons.Util? from SCons.Tool.PharLapCommon import addPathIfNotExists # Variables that we want to import from the base OS environment. _import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD', 'P4CHARSET', 'P4LANGUAGE', 'SystemRoot' ] PerforceAction = SCons.Action.Action('$P4COM', '$P4COMSTR') def generate(env): """Add a Builder factory function and construction variables for Perforce to an Environment.""" def PerforceFactory(env=env): """ """ import SCons.Warnings as W W.warn(W.DeprecatedSourceCodeWarning, """The Perforce() factory is deprecated and there is no replacement.""") return SCons.Builder.Builder(action = PerforceAction, env = env) #setattr(env, 'Perforce', PerforceFactory) env.Perforce = PerforceFactory env['P4'] = 'p4' env['P4FLAGS'] = SCons.Util.CLVar('') env['P4COM'] = '$P4 $P4FLAGS sync $TARGET' try: environ = env['ENV'] except KeyError: environ = {} env['ENV'] = environ # Perforce seems to use the PWD environment variable rather than # calling getcwd() for itself, which is odd. If no PWD variable # is present, p4 WILL call getcwd, but this seems to cause problems # with good ol' Windows's tilde-mangling for long file names. environ['PWD'] = env.Dir('#').get_abspath() for var in _import_env: v = os.environ.get(var) if v: environ[var] = v if SCons.Util.can_read_reg: # If we can read the registry, add the path to Perforce to our environment. try: k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE, 'Software\\Perforce\\environment') val, tok = SCons.Util.RegQueryValueEx(k, 'P4INSTROOT') addPathIfNotExists(environ, 'PATH', val) except SCons.Util.RegError: # Can't detect where Perforce is, hope the user has it set in the # PATH. pass def exists(env): return env.Detect('p4') # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
gpl-3.0
[ 624, 18521, 14, 5157, 14, 2623, 3990, 14, 647, 199, 199, 5157, 13, 6100, 11097, 367, 3492, 3990, 5800, 5495, 8259, 2656, 14, 199, 199, 10924, 12252, 9296, 1133, 506, 1263, 1929, 370, 492, 642, 859, 5370, 14, 199, 7940, 911, 9987, 506, 8439, 4012, 314, 7809, 8218, 14, 5157, 14, 5157, 342, 199, 5592, 1083, 14, 199, 199, 624, 199, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 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, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 2623, 3990, 14, 647, 959, 16771, 7129, 15, 1690, 15, 1079, 6928, 26, 1717, 26, 2466, 31551, 2, 199, 199, 646, 747, 199, 199, 646, 8218, 14, 3310, 199, 646, 8218, 14, 6437, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 9562, 199, 199, 3, 961, 805, 1077, 11703, 506, 12155, 370, 8218, 14, 9562, 31, 199, 504, 8218, 14, 5157, 14, 5663, 285, 44, 439, 7844, 492, 1050, 2042, 3917, 25095, 421, 199, 3, 17198, 626, 781, 2934, 370, 492, 687, 314, 1300, 4403, 3734, 14, 199, 63, 646, 63, 1813, 275, 359, 283, 48, 20, 3657, 297, 283, 48, 20, 9901, 297, 283, 48, 20, 3791, 297, 283, 3791, 297, 283, 11958, 297, 283, 48, 20, 6909, 16698, 297, 355, 283, 48, 20, 23969, 297, 283, 48, 20, 13947, 297, 283, 3989, 6405, 7, 1622, 199, 199, 2623, 3990, 3310, 275, 8218, 14, 3310, 14, 3310, 14676, 48, 20, 11265, 297, 4505, 48, 20, 11265, 3027, 358, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 1123, 282, 19286, 6434, 805, 436, 14538, 2860, 367, 272, 3492, 3990, 370, 376, 9711, 1041, 339, 347, 3492, 3990, 2927, 8, 1813, 29, 1813, 304, 267, 408, 408, 267, 492, 8218, 14, 15921, 465, 644, 267, 644, 14, 4050, 8, 55, 14, 19727, 2980, 3034, 3849, 12, 408, 1918, 3492, 3990, 342, 6434, 365, 5906, 436, 2337, 365, 949, 8343, 24887, 267, 372, 8218, 14, 6437, 14, 6437, 8, 1287, 275, 3492, 3990, 3310, 12, 2589, 275, 2589, 9, 339, 327, 10202, 8, 1813, 12, 283, 2623, 3990, 297, 3492, 3990, 2927, 9, 272, 2589, 14, 2623, 3990, 275, 3492, 3990, 2927, 339, 2589, 459, 48, 20, 418, 420, 275, 283, 80, 20, 7, 272, 2589, 459, 48, 20, 4831, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 48, 20, 11265, 418, 257, 275, 4505, 48, 20, 2672, 48, 20, 4831, 7604, 2672, 9268, 7, 272, 862, 26, 267, 6160, 275, 2589, 459, 9984, 418, 272, 871, 4067, 26, 267, 6160, 275, 1052, 267, 2589, 459, 9984, 418, 275, 6160, 339, 327, 3492, 3990, 12237, 370, 675, 314, 510, 16698, 3734, 1750, 7830, 2419, 272, 327, 6358, 664, 6525, 342, 367, 6337, 12, 1314, 365, 16699, 14, 221, 982, 949, 510, 16698, 1750, 272, 327, 365, 3451, 12, 299, 20, 644, 14961, 1240, 664, 6525, 12, 1325, 642, 12237, 370, 7675, 8826, 272, 327, 543, 6954, 9113, 7, 5417, 1159, 221, 16488, 13, 77, 26896, 367, 1846, 570, 1561, 14, 272, 6160, 459, 10780, 36, 418, 275, 2589, 14, 3567, 7863, 1959, 362, 63, 4832, 342, 339, 367, 2729, 315, 485, 646, 63, 1813, 26, 267, 373, 275, 747, 14, 2314, 14, 362, 8, 1391, 9, 267, 340, 373, 26, 288, 6160, 59, 1391, 61, 275, 373, 339, 340, 8218, 14, 9562, 14, 2425, 63, 739, 63, 1135, 26, 267, 327, 982, 781, 883, 1586, 314, 7086, 12, 1050, 314, 931, 370, 3492, 3990, 370, 4154, 3734, 14, 267, 862, 26, 288, 1022, 29, 18521, 14, 9562, 14, 2872, 28144, 920, 8, 18521, 14, 9562, 14, 72, 498, 63, 1494, 14, 23802, 63, 7486, 63, 20890, 12, 4228, 283, 10337, 1103, 2623, 3990, 1103, 5418, 358, 288, 1139, 12, 8431, 275, 8218, 14, 9562, 14, 2872, 3227, 1110, 920, 8, 75, 12, 283, 48, 20, 7834, 5441, 358, 288, 1050, 2042, 3917, 25095, 8, 2314, 12, 283, 3243, 297, 1139, 9, 267, 871, 8218, 14, 9562, 14, 2872, 547, 26, 288, 327, 6855, 1133, 9696, 2382, 3492, 3990, 365, 12, 3661, 314, 922, 965, 652, 663, 315, 314, 288, 327, 15097, 14, 288, 986, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2589, 14, 20064, 360, 80, 20, 358, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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 ]
[ 18521, 14, 5157, 14, 2623, 3990, 14, 647, 199, 199, 5157, 13, 6100, 11097, 367, 3492, 3990, 5800, 5495, 8259, 2656, 14, 199, 199, 10924, 12252, 9296, 1133, 506, 1263, 1929, 370, 492, 642, 859, 5370, 14, 199, 7940, 911, 9987, 506, 8439, 4012, 314, 7809, 8218, 14, 5157, 14, 5157, 342, 199, 5592, 1083, 14, 199, 199, 624, 199, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 710, 8218, 2752, 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, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 2623, 3990, 14, 647, 959, 16771, 7129, 15, 1690, 15, 1079, 6928, 26, 1717, 26, 2466, 31551, 2, 199, 199, 646, 747, 199, 199, 646, 8218, 14, 3310, 199, 646, 8218, 14, 6437, 199, 646, 8218, 14, 1716, 14, 7079, 199, 646, 8218, 14, 9562, 199, 199, 3, 961, 805, 1077, 11703, 506, 12155, 370, 8218, 14, 9562, 31, 199, 504, 8218, 14, 5157, 14, 5663, 285, 44, 439, 7844, 492, 1050, 2042, 3917, 25095, 421, 199, 3, 17198, 626, 781, 2934, 370, 492, 687, 314, 1300, 4403, 3734, 14, 199, 63, 646, 63, 1813, 275, 359, 283, 48, 20, 3657, 297, 283, 48, 20, 9901, 297, 283, 48, 20, 3791, 297, 283, 3791, 297, 283, 11958, 297, 283, 48, 20, 6909, 16698, 297, 355, 283, 48, 20, 23969, 297, 283, 48, 20, 13947, 297, 283, 3989, 6405, 7, 1622, 199, 199, 2623, 3990, 3310, 275, 8218, 14, 3310, 14, 3310, 14676, 48, 20, 11265, 297, 4505, 48, 20, 11265, 3027, 358, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 1123, 282, 19286, 6434, 805, 436, 14538, 2860, 367, 272, 3492, 3990, 370, 376, 9711, 1041, 339, 347, 3492, 3990, 2927, 8, 1813, 29, 1813, 304, 267, 408, 408, 267, 492, 8218, 14, 15921, 465, 644, 267, 644, 14, 4050, 8, 55, 14, 19727, 2980, 3034, 3849, 12, 408, 1918, 3492, 3990, 342, 6434, 365, 5906, 436, 2337, 365, 949, 8343, 24887, 267, 372, 8218, 14, 6437, 14, 6437, 8, 1287, 275, 3492, 3990, 3310, 12, 2589, 275, 2589, 9, 339, 327, 10202, 8, 1813, 12, 283, 2623, 3990, 297, 3492, 3990, 2927, 9, 272, 2589, 14, 2623, 3990, 275, 3492, 3990, 2927, 339, 2589, 459, 48, 20, 418, 420, 275, 283, 80, 20, 7, 272, 2589, 459, 48, 20, 4831, 418, 275, 8218, 14, 9562, 14, 1981, 5894, 8355, 272, 2589, 459, 48, 20, 11265, 418, 257, 275, 4505, 48, 20, 2672, 48, 20, 4831, 7604, 2672, 9268, 7, 272, 862, 26, 267, 6160, 275, 2589, 459, 9984, 418, 272, 871, 4067, 26, 267, 6160, 275, 1052, 267, 2589, 459, 9984, 418, 275, 6160, 339, 327, 3492, 3990, 12237, 370, 675, 314, 510, 16698, 3734, 1750, 7830, 2419, 272, 327, 6358, 664, 6525, 342, 367, 6337, 12, 1314, 365, 16699, 14, 221, 982, 949, 510, 16698, 1750, 272, 327, 365, 3451, 12, 299, 20, 644, 14961, 1240, 664, 6525, 12, 1325, 642, 12237, 370, 7675, 8826, 272, 327, 543, 6954, 9113, 7, 5417, 1159, 221, 16488, 13, 77, 26896, 367, 1846, 570, 1561, 14, 272, 6160, 459, 10780, 36, 418, 275, 2589, 14, 3567, 7863, 1959, 362, 63, 4832, 342, 339, 367, 2729, 315, 485, 646, 63, 1813, 26, 267, 373, 275, 747, 14, 2314, 14, 362, 8, 1391, 9, 267, 340, 373, 26, 288, 6160, 59, 1391, 61, 275, 373, 339, 340, 8218, 14, 9562, 14, 2425, 63, 739, 63, 1135, 26, 267, 327, 982, 781, 883, 1586, 314, 7086, 12, 1050, 314, 931, 370, 3492, 3990, 370, 4154, 3734, 14, 267, 862, 26, 288, 1022, 29, 18521, 14, 9562, 14, 2872, 28144, 920, 8, 18521, 14, 9562, 14, 72, 498, 63, 1494, 14, 23802, 63, 7486, 63, 20890, 12, 4228, 283, 10337, 1103, 2623, 3990, 1103, 5418, 358, 288, 1139, 12, 8431, 275, 8218, 14, 9562, 14, 2872, 3227, 1110, 920, 8, 75, 12, 283, 48, 20, 7834, 5441, 358, 288, 1050, 2042, 3917, 25095, 8, 2314, 12, 283, 3243, 297, 1139, 9, 267, 871, 8218, 14, 9562, 14, 2872, 547, 26, 288, 327, 6855, 1133, 9696, 2382, 3492, 3990, 365, 12, 3661, 314, 922, 965, 652, 663, 315, 314, 288, 327, 15097, 14, 288, 986, 199, 199, 318, 3495, 8, 1813, 304, 272, 372, 2589, 14, 20064, 360, 80, 20, 358, 199, 199, 3, 10111, 17198, 26, 199, 3, 5174, 13, 2063, 26, 20, 199, 3, 4363, 13, 8741, 13, 632, 26, 20613, 199, 3, 9599, 26, 199, 3, 6695, 26, 663, 26414, 20849, 29, 20, 20105, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Surbias/surbias.github.io
node_modules/grunt-docker/node_modules/docker/node_modules/pygmentize-bundled/vendor/pygments/build-2.7/pygments/lexers/asm.py
292
13314
# -*- coding: utf-8 -*- """ pygments.lexers.asm ~~~~~~~~~~~~~~~~~~~ Lexers for assembly languages. :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer from pygments.lexers.compiled import DLexer, CppLexer, CLexer from pygments.token import Text, Name, Number, String, Comment, Punctuation, \ Other, Keyword, Operator __all__ = ['GasLexer', 'ObjdumpLexer','DObjdumpLexer', 'CppObjdumpLexer', 'CObjdumpLexer', 'LlvmLexer', 'NasmLexer', 'Ca65Lexer'] class GasLexer(RegexLexer): """ For Gas (AT&T) assembly code. """ name = 'GAS' aliases = ['gas', 'asm'] filenames = ['*.s', '*.S'] mimetypes = ['text/x-gas'] #: optional Comment or Whitespace string = r'"(\\"|[^"])*"' char = r'[a-zA-Z$._0-9@-]' identifier = r'(?:[a-zA-Z$_]' + char + '*|\.' + char + '+)' number = r'(?:0[xX][a-zA-Z0-9]+|\d+)' tokens = { 'root': [ include('whitespace'), (identifier + ':', Name.Label), (r'\.' + identifier, Name.Attribute, 'directive-args'), (r'lock|rep(n?z)?|data\d+', Name.Attribute), (identifier, Name.Function, 'instruction-args'), (r'[\r\n]+', Text) ], 'directive-args': [ (identifier, Name.Constant), (string, String), ('@' + identifier, Name.Attribute), (number, Number.Integer), (r'[\r\n]+', Text, '#pop'), (r'#.*?$', Comment, '#pop'), include('punctuation'), include('whitespace') ], 'instruction-args': [ # For objdump-disassembled code, shouldn't occur in # actual assembler input ('([a-z0-9]+)( )(<)('+identifier+')(>)', bygroups(Number.Hex, Text, Punctuation, Name.Constant, Punctuation)), ('([a-z0-9]+)( )(<)('+identifier+')([-+])('+number+')(>)', bygroups(Number.Hex, Text, Punctuation, Name.Constant, Punctuation, Number.Integer, Punctuation)), # Address constants (identifier, Name.Constant), (number, Number.Integer), # Registers ('%' + identifier, Name.Variable), # Numeric constants ('$'+number, Number.Integer), (r"$'(.|\\')'", String.Char), (r'[\r\n]+', Text, '#pop'), (r'#.*?$', Comment, '#pop'), include('punctuation'), include('whitespace') ], 'whitespace': [ (r'\n', Text), (r'\s+', Text), (r'#.*?\n', Comment) ], 'punctuation': [ (r'[-*,.():]+', Punctuation) ] } def analyse_text(text): if re.match(r'^\.(text|data|section)', text, re.M): return True elif re.match(r'^\.\w+', text, re.M): return 0.1 class ObjdumpLexer(RegexLexer): """ For the output of 'objdump -dr' """ name = 'objdump' aliases = ['objdump'] filenames = ['*.objdump'] mimetypes = ['text/x-objdump'] hex = r'[0-9A-Za-z]' tokens = { 'root': [ # File name & format: ('(.*?)(:)( +file format )(.*?)$', bygroups(Name.Label, Punctuation, Text, String)), # Section header ('(Disassembly of section )(.*?)(:)$', bygroups(Text, Name.Label, Punctuation)), # Function labels # (With offset) ('('+hex+'+)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$', bygroups(Number.Hex, Text, Punctuation, Name.Function, Punctuation, Number.Hex, Punctuation)), # (Without offset) ('('+hex+'+)( )(<)(.*?)(>:)$', bygroups(Number.Hex, Text, Punctuation, Name.Function, Punctuation)), # Code line with disassembled instructions ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)( *\t)([a-zA-Z].*?)$', bygroups(Text, Name.Label, Text, Number.Hex, Text, using(GasLexer))), # Code line with ascii ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)( *)(.*?)$', bygroups(Text, Name.Label, Text, Number.Hex, Text, String)), # Continued code line, only raw opcodes without disassembled # instruction ('( *)('+hex+r'+:)(\t)((?:'+hex+hex+' )+)$', bygroups(Text, Name.Label, Text, Number.Hex)), # Skipped a few bytes (r'\t\.\.\.$', Text), # Relocation line # (With offset) (r'(\t\t\t)('+hex+r'+:)( )([^\t]+)(\t)(.*?)([-+])(0x' + hex + '+)$', bygroups(Text, Name.Label, Text, Name.Property, Text, Name.Constant, Punctuation, Number.Hex)), # (Without offset) (r'(\t\t\t)('+hex+r'+:)( )([^\t]+)(\t)(.*?)$', bygroups(Text, Name.Label, Text, Name.Property, Text, Name.Constant)), (r'[^\n]+\n', Other) ] } class DObjdumpLexer(DelegatingLexer): """ For the output of 'objdump -Sr on compiled D files' """ name = 'd-objdump' aliases = ['d-objdump'] filenames = ['*.d-objdump'] mimetypes = ['text/x-d-objdump'] def __init__(self, **options): super(DObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options) class CppObjdumpLexer(DelegatingLexer): """ For the output of 'objdump -Sr on compiled C++ files' """ name = 'cpp-objdump' aliases = ['cpp-objdump', 'c++-objdumb', 'cxx-objdump'] filenames = ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'] mimetypes = ['text/x-cpp-objdump'] def __init__(self, **options): super(CppObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options) class CObjdumpLexer(DelegatingLexer): """ For the output of 'objdump -Sr on compiled C files' """ name = 'c-objdump' aliases = ['c-objdump'] filenames = ['*.c-objdump'] mimetypes = ['text/x-c-objdump'] def __init__(self, **options): super(CObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options) class LlvmLexer(RegexLexer): """ For LLVM assembly code. """ name = 'LLVM' aliases = ['llvm'] filenames = ['*.ll'] mimetypes = ['text/x-llvm'] #: optional Comment or Whitespace string = r'"[^"]*?"' identifier = r'([-a-zA-Z$._][-a-zA-Z$._0-9]*|' + string + ')' tokens = { 'root': [ include('whitespace'), # Before keywords, because keywords are valid label names :(... (identifier + '\s*:', Name.Label), include('keyword'), (r'%' + identifier, Name.Variable),#Name.Identifier.Local), (r'@' + identifier, Name.Variable.Global),#Name.Identifier.Global), (r'%\d+', Name.Variable.Anonymous),#Name.Identifier.Anonymous), (r'@\d+', Name.Variable.Global),#Name.Identifier.Anonymous), (r'!' + identifier, Name.Variable), (r'!\d+', Name.Variable.Anonymous), (r'c?' + string, String), (r'0[xX][a-fA-F0-9]+', Number), (r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number), (r'[=<>{}\[\]()*.,!]|x\b', Punctuation) ], 'whitespace': [ (r'(\n|\s)+', Text), (r';.*?\n', Comment) ], 'keyword': [ # Regular keywords (r'(begin|end' r'|true|false' r'|declare|define' r'|global|constant' r'|private|linker_private|internal|available_externally|linkonce' r'|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport' r'|common|default|hidden|protected|extern_weak|external' r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple' r'|datalayout|volatile|nuw|nsw|nnan|ninf|nsz|arcp|fast|exact|inbounds' r'|align|addrspace|section|alias|module|asm|sideeffect|gc|dbg' r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc' r'|arm_aapcscc|arm_aapcs_vfpcc|ptx_device|ptx_kernel' r'|cc|c' r'|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture' r'|byval|nest|readnone|readonly' r'|inlinehint|noinline|alwaysinline|optsize|ssp|sspreq|noredzone' r'|noimplicitfloat|naked' r'|type|opaque' r'|eq|ne|slt|sgt|sle' r'|sge|ult|ugt|ule|uge' r'|oeq|one|olt|ogt|ole' r'|oge|ord|uno|ueq|une' r'|x' # instructions r'|add|fadd|sub|fsub|mul|fmul|udiv|sdiv|fdiv|urem|srem|frem|shl' r'|lshr|ashr|and|or|xor|icmp|fcmp' r'|phi|call|trunc|zext|sext|fptrunc|fpext|uitofp|sitofp|fptoui' r'fptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch' r'|invoke|unwind|unreachable' r'|malloc|alloca|free|load|store|getelementptr' r'|extractelement|insertelement|shufflevector|getresult' r'|extractvalue|insertvalue' r')\b', Keyword), # Types (r'void|float|double|x86_fp80|fp128|ppc_fp128|label|metadata', Keyword.Type), # Integer types (r'i[1-9]\d*', Keyword) ] } class NasmLexer(RegexLexer): """ For Nasm (Intel) assembly code. """ name = 'NASM' aliases = ['nasm'] filenames = ['*.asm', '*.ASM'] mimetypes = ['text/x-nasm'] identifier = r'[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*' hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9]+[0-9a-fA-F]*h)' octn = r'[0-7]+q' binn = r'[01]+b' decn = r'[0-9]+' floatn = decn + r'\.e?' + decn string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`" declkw = r'(?:res|d)[bwdqt]|times' register = (r'r[0-9][0-5]?[bwd]|' r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|' r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]') wordop = r'seg|wrt|strict' type = r'byte|[dq]?word' directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|' r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|' r'EXPORT|LIBRARY|MODULE') flags = re.IGNORECASE | re.MULTILINE tokens = { 'root': [ include('whitespace'), (r'^\s*%', Comment.Preproc, 'preproc'), (identifier + ':', Name.Label), (r'(%s)(\s+)(equ)' % identifier, bygroups(Name.Constant, Keyword.Declaration, Keyword.Declaration), 'instruction-args'), (directives, Keyword, 'instruction-args'), (declkw, Keyword.Declaration, 'instruction-args'), (identifier, Name.Function, 'instruction-args'), (r'[\r\n]+', Text) ], 'instruction-args': [ (string, String), (hexn, Number.Hex), (octn, Number.Oct), (binn, Number), (floatn, Number.Float), (decn, Number.Integer), include('punctuation'), (register, Name.Builtin), (identifier, Name.Variable), (r'[\r\n]+', Text, '#pop'), include('whitespace') ], 'preproc': [ (r'[^;\n]+', Comment.Preproc), (r';.*?\n', Comment.Single, '#pop'), (r'\n', Comment.Preproc, '#pop'), ], 'whitespace': [ (r'\n', Text), (r'[ \t]+', Text), (r';.*', Comment.Single) ], 'punctuation': [ (r'[,():\[\]]+', Punctuation), (r'[&|^<>+*/%~-]+', Operator), (r'[$]+', Keyword.Constant), (wordop, Operator.Word), (type, Keyword.Type) ], } class Ca65Lexer(RegexLexer): """ For ca65 assembler sources. *New in Pygments 1.6.* """ name = 'ca65' aliases = ['ca65'] filenames = ['*.s'] flags = re.IGNORECASE tokens = { 'root': [ (r';.*', Comment.Single), (r'\s+', Text), (r'[a-z_.@$][\w.@$]*:', Name.Label), (r'((ld|st)[axy]|(in|de)[cxy]|asl|lsr|ro[lr]|adc|sbc|cmp|cp[xy]' r'|cl[cvdi]|se[cdi]|jmp|jsr|bne|beq|bpl|bmi|bvc|bvs|bcc|bcs' r'|p[lh][ap]|rt[is]|brk|nop|ta[xy]|t[xy]a|txs|tsx|and|ora|eor' r'|bit)\b', Keyword), (r'\.[a-z0-9_]+', Keyword.Pseudo), (r'[-+~*/^&|!<>=]', Operator), (r'"[^"\n]*.', String), (r"'[^'\n]*.", String.Char), (r'\$[0-9a-f]+|[0-9a-f]+h\b', Number.Hex), (r'\d+|%[01]+', Number.Integer), (r'[#,.:()=]', Punctuation), (r'[a-z_.@$][\w.@$]*', Name), ] } def analyse_text(self, text): # comments in GAS start with "#" if re.match(r'^\s*;', text, re.MULTILINE): return 0.9
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 11374, 272, 18294, 23597, 339, 491, 476, 1192, 367, 24869, 10815, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 2387, 12, 10259, 12, 1808, 12, 1487, 4170, 1958, 5838, 199, 504, 13277, 14, 12245, 14, 8427, 492, 577, 5838, 12, 445, 802, 5838, 12, 445, 5838, 199, 504, 13277, 14, 1418, 492, 4516, 12, 2812, 12, 4860, 12, 2624, 12, 6819, 12, 10357, 12, 971, 1362, 5439, 12, 6431, 12, 11013, 199, 199, 363, 452, 363, 275, 788, 39, 305, 5838, 297, 283, 5665, 2724, 5838, 1673, 1649, 468, 2724, 5838, 297, 283, 19705, 5665, 2724, 5838, 297, 1779, 283, 1439, 468, 2724, 5838, 297, 283, 23096, 2611, 5838, 297, 283, 46, 11374, 5838, 297, 283, 3630, 2182, 5838, 418, 421, 199, 533, 598, 305, 5838, 8, 19856, 304, 272, 408, 272, 2104, 598, 305, 334, 619, 6, 52, 9, 24869, 1233, 14, 272, 408, 272, 536, 275, 283, 39, 1179, 7, 272, 5481, 275, 788, 24364, 297, 283, 11374, 418, 272, 6203, 275, 17855, 83, 297, 11937, 51, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 24364, 418, 339, 6079, 2716, 6819, 503, 24403, 272, 1059, 275, 519, 4065, 8, 15022, 23629, 3135, 10, 4507, 272, 1495, 275, 519, 3894, 65, 13, 6353, 13, 58, 4, 423, 16, 13, 25, 32, 13, 6616, 272, 5148, 275, 519, 20459, 59, 65, 13, 6353, 13, 58, 4, 63, 6616, 435, 1495, 435, 6438, 6113, 3530, 435, 1495, 435, 6681, 3171, 272, 1329, 275, 519, 20459, 16, 59, 24110, 1527, 65, 13, 6353, 13, 58, 16, 13, 25, 2807, 6113, 68, 29600, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 2387, 360, 8506, 659, 288, 334, 5364, 435, 25475, 2812, 14, 4314, 395, 288, 334, 82, 1154, 3530, 435, 5148, 12, 2812, 14, 1646, 12, 283, 15047, 13, 589, 659, 288, 334, 82, 7, 831, 92, 1155, 8, 78, 31, 90, 5547, 92, 576, 60, 68, 7386, 2812, 14, 1646, 395, 288, 334, 5364, 12, 2812, 14, 3481, 12, 283, 22880, 13, 589, 659, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 9, 267, 2156, 267, 283, 15047, 13, 589, 356, 359, 288, 334, 5364, 12, 2812, 14, 9737, 395, 288, 334, 875, 12, 2624, 395, 288, 661, 32, 7, 435, 5148, 12, 2812, 14, 1646, 395, 288, 334, 1955, 12, 4860, 14, 2674, 395, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 12, 3943, 1935, 659, 953, 334, 82, 11525, 6697, 4268, 6819, 12, 3943, 1935, 659, 953, 2387, 360, 25181, 659, 288, 2387, 360, 8506, 358, 267, 2156, 267, 283, 22880, 13, 589, 356, 359, 288, 327, 2104, 1559, 2724, 13, 2297, 21263, 68, 1233, 12, 9296, 1133, 4781, 315, 288, 327, 3503, 22931, 82, 1324, 288, 661, 779, 65, 13, 90, 16, 13, 25, 2807, 5130, 776, 27530, 9, 19975, 5364, 11, 7533, 30, 3196, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 9737, 12, 586, 10357, 1826, 288, 661, 779, 65, 13, 90, 16, 13, 25, 2807, 5130, 776, 27530, 9, 19975, 5364, 13854, 779, 6793, 566, 19975, 1955, 11, 7533, 30, 3196, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 9737, 12, 586, 10357, 12, 4860, 14, 2674, 12, 10357, 1826, 953, 327, 9906, 5262, 288, 334, 5364, 12, 2812, 14, 9737, 395, 288, 334, 1955, 12, 4860, 14, 2674, 395, 288, 327, 5044, 14186, 288, 16651, 7, 435, 5148, 12, 2812, 14, 2773, 395, 288, 327, 19378, 5262, 288, 661, 4, 6828, 1955, 12, 4860, 14, 2674, 395, 288, 334, 82, 2, 4, 6774, 14, 17780, 358, 4662, 2624, 14, 1610, 395, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 12, 3943, 1935, 659, 288, 334, 82, 11525, 6697, 4268, 6819, 12, 3943, 1935, 659, 288, 2387, 360, 25181, 659, 288, 2387, 360, 8506, 358, 267, 2156, 267, 283, 8506, 356, 359, 288, 334, 82, 1154, 78, 297, 4516, 395, 288, 334, 82, 1154, 83, 7386, 4516, 395, 288, 334, 82, 11525, 21040, 78, 297, 6819, 9, 267, 2156, 267, 283, 25181, 356, 359, 288, 334, 82, 7, 1988, 10381, 14, 837, 11529, 10357, 9, 267, 1622, 272, 789, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 340, 295, 14, 1431, 8, 82, 4289, 4537, 8, 505, 92, 576, 92, 2792, 3196, 1318, 12, 295, 14, 45, 304, 288, 372, 715, 267, 916, 295, 14, 1431, 8, 82, 15542, 3134, 87, 7386, 1318, 12, 295, 14, 45, 304, 288, 372, 378, 14, 17, 421, 199, 533, 24921, 2724, 5838, 8, 19856, 304, 272, 408, 272, 2104, 314, 1072, 402, 283, 1113, 2724, 446, 5012, 7, 272, 408, 272, 536, 275, 283, 1113, 2724, 7, 272, 5481, 275, 788, 1113, 2724, 418, 272, 6203, 275, 17855, 1113, 2724, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 1113, 2724, 418, 339, 6318, 275, 519, 3894, 16, 13, 25, 33, 13, 13163, 13, 90, 6616, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 327, 3814, 536, 1253, 1475, 26, 288, 661, 17140, 5130, 26, 5130, 435, 493, 1475, 776, 17140, 29150, 355, 10259, 8, 985, 14, 4314, 12, 10357, 12, 4516, 12, 2624, 1826, 288, 327, 15247, 1406, 288, 23845, 2825, 17828, 402, 3420, 776, 17140, 5130, 26, 29150, 355, 10259, 8, 1872, 12, 2812, 14, 4314, 12, 10357, 1826, 288, 327, 6801, 3628, 288, 327, 334, 3007, 3268, 9, 288, 661, 19975, 4097, 4786, 29653, 776, 27530, 5130, 6697, 31440, 6793, 566, 8, 16, 59, 24110, 1527, 33, 13, 13163, 13, 90, 16, 13, 25, 2807, 5130, 20020, 29150, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 3481, 12, 586, 10357, 12, 4860, 14, 10373, 12, 10357, 1826, 288, 327, 334, 12450, 3268, 9, 288, 661, 19975, 4097, 4786, 29653, 776, 27530, 5130, 6697, 5130, 20020, 29150, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 11374, 272, 18294, 23597, 339, 491, 476, 1192, 367, 24869, 10815, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 2387, 12, 10259, 12, 1808, 12, 1487, 4170, 1958, 5838, 199, 504, 13277, 14, 12245, 14, 8427, 492, 577, 5838, 12, 445, 802, 5838, 12, 445, 5838, 199, 504, 13277, 14, 1418, 492, 4516, 12, 2812, 12, 4860, 12, 2624, 12, 6819, 12, 10357, 12, 971, 1362, 5439, 12, 6431, 12, 11013, 199, 199, 363, 452, 363, 275, 788, 39, 305, 5838, 297, 283, 5665, 2724, 5838, 1673, 1649, 468, 2724, 5838, 297, 283, 19705, 5665, 2724, 5838, 297, 1779, 283, 1439, 468, 2724, 5838, 297, 283, 23096, 2611, 5838, 297, 283, 46, 11374, 5838, 297, 283, 3630, 2182, 5838, 418, 421, 199, 533, 598, 305, 5838, 8, 19856, 304, 272, 408, 272, 2104, 598, 305, 334, 619, 6, 52, 9, 24869, 1233, 14, 272, 408, 272, 536, 275, 283, 39, 1179, 7, 272, 5481, 275, 788, 24364, 297, 283, 11374, 418, 272, 6203, 275, 17855, 83, 297, 11937, 51, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 24364, 418, 339, 6079, 2716, 6819, 503, 24403, 272, 1059, 275, 519, 4065, 8, 15022, 23629, 3135, 10, 4507, 272, 1495, 275, 519, 3894, 65, 13, 6353, 13, 58, 4, 423, 16, 13, 25, 32, 13, 6616, 272, 5148, 275, 519, 20459, 59, 65, 13, 6353, 13, 58, 4, 63, 6616, 435, 1495, 435, 6438, 6113, 3530, 435, 1495, 435, 6681, 3171, 272, 1329, 275, 519, 20459, 16, 59, 24110, 1527, 65, 13, 6353, 13, 58, 16, 13, 25, 2807, 6113, 68, 29600, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 2387, 360, 8506, 659, 288, 334, 5364, 435, 25475, 2812, 14, 4314, 395, 288, 334, 82, 1154, 3530, 435, 5148, 12, 2812, 14, 1646, 12, 283, 15047, 13, 589, 659, 288, 334, 82, 7, 831, 92, 1155, 8, 78, 31, 90, 5547, 92, 576, 60, 68, 7386, 2812, 14, 1646, 395, 288, 334, 5364, 12, 2812, 14, 3481, 12, 283, 22880, 13, 589, 659, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 9, 267, 2156, 267, 283, 15047, 13, 589, 356, 359, 288, 334, 5364, 12, 2812, 14, 9737, 395, 288, 334, 875, 12, 2624, 395, 288, 661, 32, 7, 435, 5148, 12, 2812, 14, 1646, 395, 288, 334, 1955, 12, 4860, 14, 2674, 395, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 12, 3943, 1935, 659, 953, 334, 82, 11525, 6697, 4268, 6819, 12, 3943, 1935, 659, 953, 2387, 360, 25181, 659, 288, 2387, 360, 8506, 358, 267, 2156, 267, 283, 22880, 13, 589, 356, 359, 288, 327, 2104, 1559, 2724, 13, 2297, 21263, 68, 1233, 12, 9296, 1133, 4781, 315, 288, 327, 3503, 22931, 82, 1324, 288, 661, 779, 65, 13, 90, 16, 13, 25, 2807, 5130, 776, 27530, 9, 19975, 5364, 11, 7533, 30, 3196, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 9737, 12, 586, 10357, 1826, 288, 661, 779, 65, 13, 90, 16, 13, 25, 2807, 5130, 776, 27530, 9, 19975, 5364, 13854, 779, 6793, 566, 19975, 1955, 11, 7533, 30, 3196, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 9737, 12, 586, 10357, 12, 4860, 14, 2674, 12, 10357, 1826, 953, 327, 9906, 5262, 288, 334, 5364, 12, 2812, 14, 9737, 395, 288, 334, 1955, 12, 4860, 14, 2674, 395, 288, 327, 5044, 14186, 288, 16651, 7, 435, 5148, 12, 2812, 14, 2773, 395, 288, 327, 19378, 5262, 288, 661, 4, 6828, 1955, 12, 4860, 14, 2674, 395, 288, 334, 82, 2, 4, 6774, 14, 17780, 358, 4662, 2624, 14, 1610, 395, 288, 334, 82, 22123, 82, 60, 78, 11529, 4516, 12, 3943, 1935, 659, 288, 334, 82, 11525, 6697, 4268, 6819, 12, 3943, 1935, 659, 288, 2387, 360, 25181, 659, 288, 2387, 360, 8506, 358, 267, 2156, 267, 283, 8506, 356, 359, 288, 334, 82, 1154, 78, 297, 4516, 395, 288, 334, 82, 1154, 83, 7386, 4516, 395, 288, 334, 82, 11525, 21040, 78, 297, 6819, 9, 267, 2156, 267, 283, 25181, 356, 359, 288, 334, 82, 7, 1988, 10381, 14, 837, 11529, 10357, 9, 267, 1622, 272, 789, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 340, 295, 14, 1431, 8, 82, 4289, 4537, 8, 505, 92, 576, 92, 2792, 3196, 1318, 12, 295, 14, 45, 304, 288, 372, 715, 267, 916, 295, 14, 1431, 8, 82, 15542, 3134, 87, 7386, 1318, 12, 295, 14, 45, 304, 288, 372, 378, 14, 17, 421, 199, 533, 24921, 2724, 5838, 8, 19856, 304, 272, 408, 272, 2104, 314, 1072, 402, 283, 1113, 2724, 446, 5012, 7, 272, 408, 272, 536, 275, 283, 1113, 2724, 7, 272, 5481, 275, 788, 1113, 2724, 418, 272, 6203, 275, 17855, 1113, 2724, 418, 272, 13290, 275, 788, 505, 15, 88, 13, 1113, 2724, 418, 339, 6318, 275, 519, 3894, 16, 13, 25, 33, 13, 13163, 13, 90, 6616, 339, 4645, 275, 469, 267, 283, 1231, 356, 359, 288, 327, 3814, 536, 1253, 1475, 26, 288, 661, 17140, 5130, 26, 5130, 435, 493, 1475, 776, 17140, 29150, 355, 10259, 8, 985, 14, 4314, 12, 10357, 12, 4516, 12, 2624, 1826, 288, 327, 15247, 1406, 288, 23845, 2825, 17828, 402, 3420, 776, 17140, 5130, 26, 29150, 355, 10259, 8, 1872, 12, 2812, 14, 4314, 12, 10357, 1826, 288, 327, 6801, 3628, 288, 327, 334, 3007, 3268, 9, 288, 661, 19975, 4097, 4786, 29653, 776, 27530, 5130, 6697, 31440, 6793, 566, 8, 16, 59, 24110, 1527, 33, 13, 13163, 13, 90, 16, 13, 25, 2807, 5130, 20020, 29150, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 10357, 12, 2812, 14, 3481, 12, 586, 10357, 12, 4860, 14, 10373, 12, 10357, 1826, 288, 327, 334, 12450, 3268, 9, 288, 661, 19975, 4097, 4786, 29653, 776, 27530, 5130, 6697, 5130, 20020, 29150, 355, 10259, 8, 3259, 14, 10373, 12, 4516, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
StephenHamilton/gini
backend/src/gloader/xml/dom/TreeWalker.py
10
6995
######################################################################## # # File Name: TreeWalker.py # # """ Tree Walker from DOM Level 2. Allows multi-directional iteration over nodes. WWW: http://4suite.com/4DOM e-mail: support@4suite.com Copyright (c) 2000 Fourthought Inc, USA. All Rights Reserved. See http://4suite.com/COPYRIGHT for license and copyright information """ from NodeFilter import NodeFilter from xml.dom import NoModificationAllowedErr from xml.dom import NotSupportedErr class TreeWalker: def __init__(self, root, whatToShow, filter, expandEntityReferences): self.__dict__['__root'] = root self.__dict__['__whatToShow'] = whatToShow self.__dict__['__filter'] = filter self.__dict__['__expandEntityReferences'] = expandEntityReferences self.__dict__['__currentNode'] = root ### Attribute Access Methods -- xxx.attr ### def __getattr__(self, name): attrFunc = self._readComputedAttrs.get(name) if attrFunc: return attrFunc(self) def __setattr__(self, name, value): #Make sure attribute is not read-only if name in self.__class__._readOnlyAttrs: raise NoModificationAllowedErr() #If it's computed execute that function attrFunc = self.__class__._writeComputedAttrs.get(name) if attrFunc: attrFunc(self, value) #Otherwise, just set the attribute else: self.__dict__[name] = value ### Attribute Methods -- xxx._get_attr() ### def _get_root(self): return self.__dict__['__root'] def _get_filter(self): return self.__dict__['__filter'] def _get_whatToShow(self): return self.__dict__['__whatToShow'] def _get_expandEntityReferences(self): return self.__dict__['__expandEntityReferences'] def _get_currentNode(self): return self.__dict__['__currentNode'] def _set_currentNode(self, value): if value == None: raise NotSupportedErr() self.__dict__['__currentNode'] = value ### Methods ### def parentNode(self): next_node = None if self.__dict__['__currentNode'] != self.__dict__['__root']: next_node = self.__dict__['__currentNode']._get_parentNode() while next_node and next_node != self.__dict__['__root'] \ and not (self.__checkWhatToShow(next_node) \ and self.__checkFilter(next_node) == NodeFilter.FILTER_ACCEPT): next_node = next_node._get_parentNode() if next_node: self.__dict__['__currentNode'] = next_node return next_node def firstChild(self): next_node = None if self.__checkFilter(self.__dict__['__currentNode']) != NodeFilter.FILTER_REJECT: next_node = self.__dict__['__currentNode']._get_firstChild() while next_node and not (self.__checkWhatToShow(next_node) \ and self.__checkFilter(next_node) == NodeFilter.FILTER_ACCEPT): next_node = next_node._get_nextSibling() if next_node: self.__dict__['__currentNode'] = next_node return next_node def lastChild(self): next_node = None if self.__checkFilter(self.__dict__['__currentNode']) != NodeFilter.FILTER_REJECT: next_node = self.__dict__['__currentNode']._get_lastChild() while next_node and not (self.__checkWhatToShow(next_node) \ and self.__checkFilter(next_node) == NodeFilter.FILTER_ACCEPT): next_node = next_node._get_previousSibling() if next_node: self.__dict__['__currentNode'] = next_node return next_node def previousSibling(self): prev_node = None if self.__dict__['__currentNode'] != self.__root: prev_node = self.__dict__['__currentNode']._get_previousSibling() while prev_node and not (self.__checkWhatToShow(prev_node) \ and self.__checkFilter(prev_node) == NodeFilter.FILTER_ACCEPT): prev_node = prev_node._get_previousSibling() if prev_node: self.__dict__['__currentNode'] = prev_node return prev_node def nextSibling(self): next_node = None if self.__dict__['__currentNode'] != self.__root: next_node = self.__dict__['__currentNode']._get_nextSibling() while next_node and not (self.__checkWhatToShow(next_node) and self.__checkFilter(next_node) == NodeFilter.FILTER_ACCEPT): next_node = next_node._get_nextSibling() if next_node: self.__dict__['__currentNode'] = next_node return next_node def nextNode(self): next_node = self.__advance() while next_node and not (self.__checkWhatToShow(next_node) and self.__checkFilter(next_node) == NodeFilter.FILTER_ACCEPT): next_node = self.__advance() return next_node def previousNode(self): prev_node = self.__regress() while prev_node and not (self.__checkWhatToShow(prev_node) and self.__checkFilter(prev_node) == NodeFilter.FILTER_ACCEPT): prev_node = self.__regress() return prev_node def __advance(self): if self.firstChild(): return self.__dict__['__currentNode'] if self.nextSibling(): return self.__dict__['__currentNode'] while self.parentNode(): tmpnode = self.nextSibling() if tmpnode: return tmpnode return None def __regress(self): if self.previousSibling(): while self.lastChild(): pass return self.__dict__['__currentNode'] if self.parentNode(): return self.__dict__['__currentNode'] return None def __checkWhatToShow(self, node): show_bit = 1 << (node._get_nodeType() - 1) return self.__dict__['__whatToShow'] & show_bit def __checkFilter(self, node): if self.__dict__['__filter']: return self.__dict__['__filter'].acceptNode(node) else: return NodeFilter.FILTER_ACCEPT def __iter__(self): return self def next(self): node = self.nextNode() if node is None: raise StopIteration return node ### Attribute Access Mappings ### _readComputedAttrs = {'root':_get_root, 'whatToShow':_get_whatToShow, 'filter':_get_filter, 'expandEntityReferences':_get_expandEntityReferences, 'currentNode':_get_currentNode } _writeComputedAttrs = {'currentNode': _set_currentNode } # Create the read-only list of attributes _readOnlyAttrs = filter(lambda k,m=_writeComputedAttrs: not m.has_key(k), _readComputedAttrs.keys())
mit
[ 3949, 199, 3, 199, 3, 3814, 2812, 26, 3322, 12178, 26020, 14, 647, 199, 3, 199, 3, 199, 624, 199, 3987, 644, 14976, 687, 14316, 20400, 499, 14, 221, 22819, 3510, 13, 21360, 8494, 1806, 3380, 14, 199, 27084, 26, 1455, 921, 20, 5768, 14, 957, 15, 20, 10462, 260, 325, 13, 1198, 26, 2291, 32, 20, 5768, 14, 957, 199, 199, 7384, 334, 67, 9, 12293, 23843, 273, 20816, 3277, 12, 8217, 14, 257, 2900, 5924, 5702, 14, 199, 9295, 221, 1455, 921, 20, 5768, 14, 957, 15, 32324, 5716, 221, 367, 4190, 436, 4248, 2556, 199, 624, 199, 199, 504, 5013, 4131, 492, 5013, 4131, 199, 199, 504, 2748, 14, 4556, 492, 3091, 29188, 16070, 5432, 199, 504, 2748, 14, 4556, 492, 2832, 10682, 5432, 199, 199, 533, 12178, 26020, 26, 272, 347, 636, 826, 721, 277, 12, 1738, 12, 4052, 1378, 6824, 12, 2457, 12, 6544, 7302, 15242, 304, 267, 291, 855, 807, 363, 13742, 1231, 418, 275, 1738, 267, 291, 855, 807, 363, 13742, 10058, 1378, 6824, 418, 275, 4052, 1378, 6824, 267, 291, 855, 807, 363, 13742, 1541, 418, 275, 2457, 267, 291, 855, 807, 363, 13742, 4441, 7302, 15242, 418, 275, 6544, 7302, 15242, 267, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 1738, 339, 6754, 3882, 11003, 17653, 1553, 26571, 14, 962, 6754, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 1921, 7465, 275, 291, 423, 739, 2404, 4241, 21368, 14, 362, 8, 354, 9, 267, 340, 1921, 7465, 26, 288, 372, 1921, 7465, 8, 277, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 327, 5483, 3238, 2225, 365, 440, 1586, 13, 2118, 267, 340, 536, 315, 291, 855, 533, 363, 423, 739, 5903, 21368, 26, 288, 746, 3091, 29188, 16070, 5432, 342, 267, 327, 3917, 652, 1159, 9235, 5341, 626, 805, 267, 1921, 7465, 275, 291, 855, 533, 363, 423, 952, 2404, 4241, 21368, 14, 362, 8, 354, 9, 267, 340, 1921, 7465, 26, 288, 1921, 7465, 8, 277, 12, 574, 9, 267, 327, 8632, 2605, 12, 2951, 663, 314, 2225, 267, 587, 26, 288, 291, 855, 807, 12298, 354, 61, 275, 574, 339, 6754, 3882, 17653, 1553, 26571, 423, 362, 63, 962, 342, 6754, 339, 347, 485, 362, 63, 1231, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1231, 418, 339, 347, 485, 362, 63, 1541, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1541, 418, 339, 347, 485, 362, 63, 10058, 1378, 6824, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 10058, 1378, 6824, 418, 339, 347, 485, 362, 63, 4441, 7302, 15242, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 4441, 7302, 15242, 418, 339, 347, 485, 362, 63, 1818, 1716, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1818, 1716, 418, 339, 347, 485, 409, 63, 1818, 1716, 8, 277, 12, 574, 304, 267, 340, 574, 508, 488, 26, 288, 746, 2832, 10682, 5432, 342, 267, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 574, 339, 6754, 17653, 6754, 339, 347, 1676, 1716, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 807, 363, 13742, 1818, 1716, 418, 1137, 291, 855, 807, 363, 13742, 1231, 2565, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 24899, 342, 288, 1830, 2163, 63, 932, 436, 2163, 63, 932, 1137, 291, 855, 807, 363, 13742, 1231, 418, 971, 355, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 24899, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 1642, 3493, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 1074, 4131, 8, 277, 855, 807, 363, 13742, 1818, 1716, 1105, 1137, 5013, 4131, 14, 9905, 63, 907, 5550, 26, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 22262, 342, 288, 1830, 2163, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 30336, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 2061, 3493, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 1074, 4131, 8, 277, 855, 807, 363, 13742, 1818, 1716, 1105, 1137, 5013, 4131, 14, 9905, 63, 907, 5550, 26, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 2019, 3493, 342, 288, 1830, 2163, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 6352, 16016, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 4136, 16016, 8, 277, 304, 267, 5071, 63, 932, 275, 488, 267, 340, 291, 855, 807, 363, 13742, 1818, 1716, 418, 1137, 291, 855, 1231, 26, 288, 5071, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 6352, 16016, 342, 288, 1830, 5071, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 5701, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 5701, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 5071, 63, 932, 275, 5071, 63, 932, 423, 362, 63, 6352, 16016, 342, 267, 340, 5071, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418 ]
[ 199, 3, 199, 3, 3814, 2812, 26, 3322, 12178, 26020, 14, 647, 199, 3, 199, 3, 199, 624, 199, 3987, 644, 14976, 687, 14316, 20400, 499, 14, 221, 22819, 3510, 13, 21360, 8494, 1806, 3380, 14, 199, 27084, 26, 1455, 921, 20, 5768, 14, 957, 15, 20, 10462, 260, 325, 13, 1198, 26, 2291, 32, 20, 5768, 14, 957, 199, 199, 7384, 334, 67, 9, 12293, 23843, 273, 20816, 3277, 12, 8217, 14, 257, 2900, 5924, 5702, 14, 199, 9295, 221, 1455, 921, 20, 5768, 14, 957, 15, 32324, 5716, 221, 367, 4190, 436, 4248, 2556, 199, 624, 199, 199, 504, 5013, 4131, 492, 5013, 4131, 199, 199, 504, 2748, 14, 4556, 492, 3091, 29188, 16070, 5432, 199, 504, 2748, 14, 4556, 492, 2832, 10682, 5432, 199, 199, 533, 12178, 26020, 26, 272, 347, 636, 826, 721, 277, 12, 1738, 12, 4052, 1378, 6824, 12, 2457, 12, 6544, 7302, 15242, 304, 267, 291, 855, 807, 363, 13742, 1231, 418, 275, 1738, 267, 291, 855, 807, 363, 13742, 10058, 1378, 6824, 418, 275, 4052, 1378, 6824, 267, 291, 855, 807, 363, 13742, 1541, 418, 275, 2457, 267, 291, 855, 807, 363, 13742, 4441, 7302, 15242, 418, 275, 6544, 7302, 15242, 267, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 1738, 339, 6754, 3882, 11003, 17653, 1553, 26571, 14, 962, 6754, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 1921, 7465, 275, 291, 423, 739, 2404, 4241, 21368, 14, 362, 8, 354, 9, 267, 340, 1921, 7465, 26, 288, 372, 1921, 7465, 8, 277, 9, 339, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 267, 327, 5483, 3238, 2225, 365, 440, 1586, 13, 2118, 267, 340, 536, 315, 291, 855, 533, 363, 423, 739, 5903, 21368, 26, 288, 746, 3091, 29188, 16070, 5432, 342, 267, 327, 3917, 652, 1159, 9235, 5341, 626, 805, 267, 1921, 7465, 275, 291, 855, 533, 363, 423, 952, 2404, 4241, 21368, 14, 362, 8, 354, 9, 267, 340, 1921, 7465, 26, 288, 1921, 7465, 8, 277, 12, 574, 9, 267, 327, 8632, 2605, 12, 2951, 663, 314, 2225, 267, 587, 26, 288, 291, 855, 807, 12298, 354, 61, 275, 574, 339, 6754, 3882, 17653, 1553, 26571, 423, 362, 63, 962, 342, 6754, 339, 347, 485, 362, 63, 1231, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1231, 418, 339, 347, 485, 362, 63, 1541, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1541, 418, 339, 347, 485, 362, 63, 10058, 1378, 6824, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 10058, 1378, 6824, 418, 339, 347, 485, 362, 63, 4441, 7302, 15242, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 4441, 7302, 15242, 418, 339, 347, 485, 362, 63, 1818, 1716, 8, 277, 304, 267, 372, 291, 855, 807, 363, 13742, 1818, 1716, 418, 339, 347, 485, 409, 63, 1818, 1716, 8, 277, 12, 574, 304, 267, 340, 574, 508, 488, 26, 288, 746, 2832, 10682, 5432, 342, 267, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 574, 339, 6754, 17653, 6754, 339, 347, 1676, 1716, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 807, 363, 13742, 1818, 1716, 418, 1137, 291, 855, 807, 363, 13742, 1231, 2565, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 24899, 342, 288, 1830, 2163, 63, 932, 436, 2163, 63, 932, 1137, 291, 855, 807, 363, 13742, 1231, 418, 971, 355, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 24899, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 1642, 3493, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 1074, 4131, 8, 277, 855, 807, 363, 13742, 1818, 1716, 1105, 1137, 5013, 4131, 14, 9905, 63, 907, 5550, 26, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 22262, 342, 288, 1830, 2163, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 30336, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 2061, 3493, 8, 277, 304, 267, 2163, 63, 932, 275, 488, 267, 340, 291, 855, 1074, 4131, 8, 277, 855, 807, 363, 13742, 1818, 1716, 1105, 1137, 5013, 4131, 14, 9905, 63, 907, 5550, 26, 288, 2163, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 2019, 3493, 342, 288, 1830, 2163, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 2184, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 2184, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 2163, 63, 932, 275, 2163, 63, 932, 423, 362, 63, 6352, 16016, 342, 267, 340, 2163, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 275, 2163, 63, 932, 267, 372, 2163, 63, 932, 339, 347, 4136, 16016, 8, 277, 304, 267, 5071, 63, 932, 275, 488, 267, 340, 291, 855, 807, 363, 13742, 1818, 1716, 418, 1137, 291, 855, 1231, 26, 288, 5071, 63, 932, 275, 291, 855, 807, 363, 13742, 1818, 1716, 26099, 362, 63, 6352, 16016, 342, 288, 1830, 5071, 63, 932, 436, 440, 334, 277, 855, 1074, 21015, 1378, 6824, 8, 5701, 63, 932, 9, 971, 355, 436, 291, 855, 1074, 4131, 8, 5701, 63, 932, 9, 508, 5013, 4131, 14, 9905, 63, 13089, 304, 355, 5071, 63, 932, 275, 5071, 63, 932, 423, 362, 63, 6352, 16016, 342, 267, 340, 5071, 63, 932, 26, 288, 291, 855, 807, 363, 13742, 1818, 1716, 418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
vimalkumarvelayudhan/riboplot
riboplot/ribocore.py
2
12920
"""Common functions. """ import pysam import logging import subprocess from contextlib import contextmanager # create logger for the entire program log = logging.getLogger('riboplot') log.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(module)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') ch.setFormatter(formatter) log.addHandler(ch) class ArgumentError(Exception): """Raised when invalid arguments are sent in the command line.""" pass class BamFileError(Exception): """Errors related to BAM file""" pass class RiboPlotError(Exception): """General errors relating to riboplot.""" pass class RiboCountError(Exception): """General errors relating to ribocount.""" pass class RNACountsError(Exception): """For errors related to RNA Coverage generation using bedtools. """ pass def lengths_offsets(value): """Split the given comma separated value to multiple integer values. """ values = [] for item in value.split(','): item = int(item) values.append(item) return values @contextmanager def open_pysam_file(fname, ftype): """Open a BAM or FASTA file with pysam (for use with "with" statement)""" try: if ftype == 'bam': fpysam = pysam.AlignmentFile(fname, 'rb') elif ftype == 'fasta': fpysam = pysam.FastaFile(fname) yield fpysam except: raise else: fpysam.close() def is_bam_valid(bam_file): """Check if bam file is valid. Raises a ValueError if pysam cannot read the file. #TODO: pysam does not differentiate between BAM and SAM """ try: f = pysam.AlignmentFile(bam_file) except ValueError: raise except: raise else: f.close() return True def bam_has_index(bam_file): """Check if bam file has an index. Returns True/False.""" has_index = None with pysam.AlignmentFile(bam_file, 'rb') as bam_fileobj: try: bam_fileobj.fetch(bam_fileobj.references[0]) except ValueError as err: if err.message == 'fetch called on bamfile without index': bam_fileobj.close() has_index = False else: has_index = True return has_index def create_bam_index(bam_file): """Create an index for the given BAM file.""" pysam.index(bam_file) def is_fasta_valid(fasta_file): """Check if fasta file is valid. Raises a ValueError if pysam cannot read the file. #TODO: pysam does not differentiate between BAM and SAM """ try: f = pysam.FastaFile(fasta_file) except IOError: raise else: f.close() return True def get_first_transcript_name(fasta_file): """Return the first FASTA sequence from the given FASTA file. Keyword arguments: fasta_file -- FASTA format file of the transcriptome """ with open_pysam_file(fname=fasta_file, ftype='fasta') as f: transcript_name = f.references[0] return transcript_name def get_fasta_record(fasta_file, transcript_name): """Return a single transcript from a valid fasta file as a record. record[transcript_name] = sequence Keyword arguments: fasta_file -- FASTA format file of the transcriptome transcript_name -- Name of the transcript as in the FASTA header """ with open_pysam_file(fname=fasta_file, ftype='fasta') as f: sequence = f.fetch(transcript_name) return {transcript_name: sequence} def get_fasta_records(fasta, transcripts): """Return list of transcript records from the given fasta file. Each record will be of the form {'sequence_id': {'sequence': 'AAA', 'length': 3}} trascripts should be provided as a list of sequence id's. """ records = {} f = pysam.FastaFile(fasta) for transcript in transcripts: try: sequence, length = f.fetch(transcript), f.get_reference_length(transcript) except KeyError: msg = 'Transcript "{}" does not exist in transcriptome FASTA file'.format(transcript) log.error(msg) raise ArgumentError(msg) records[transcript] = {'sequence': sequence, 'length': length} f.close() return records def get_three_frame_orfs(sequence, starts=None, stops=None): """Find ORF's in frames 1, 2 and 3 for the given sequence. Positions returned are 1-based (not 0) Return format [{'start': start_position, 'stop': stop_position, 'sequence': sequence}, ] Keyword arguments: sequence -- sequence for the transcript starts -- List of codons to be considered as start (Default: ['ATG']) stops -- List of codons to be considered as stop (Default: ['TAG', 'TGA', 'TAA']) """ if not starts: starts = ['ATG'] if not stops: stops = ['TAG', 'TGA', 'TAA'] # Find ORFs in 3 frames orfs = [] for frame in range(3): start_codon = None orf = '' for position in range(frame, len(sequence), 3): codon = sequence[position:position + 3] if codon in starts: # We have found a start already, so add codon to orf and # continue. This is an internal MET if start_codon is not None: orf += codon continue # New orf start start_codon = position orf = codon else: # if sequence starts with ATG, start_codon will be 0 if start_codon is None: # We haven't found a start codon yet continue orf += codon if codon in stops: # orfs[start_codon + 1] = orf orfs.append({'start': start_codon + 1, 'stop': position + 3, 'sequence': orf}) # Reset start_codon = None orf = '' return orfs def get_longest_orf(orfs): """Find longest ORF from the given list of ORFs.""" sorted_orf = sorted(orfs, key=lambda x: len(x['sequence']), reverse=True)[0] return sorted_orf def filter_ribo_counts(counts, orf_start=None, orf_stop=None): """Filter read counts and return only upstream of orf_start or downstream of orf_stop. Keyword arguments: counts -- Ribo-Seq read counts obtained from get_ribo_counts. orf_start -- Start position of the longest ORF. orf_stop -- Stop position of the longest ORF. """ filtered_counts = dict.copy(counts) for position in counts: if orf_start and orf_stop: # if only upstream and downstream reads are required, check if # current position is upstream or downstream of the ORF start/stop # if not, remove from counts if (position > orf_start and position < orf_stop): filtered_counts.pop(position) elif orf_start: # check if current position is upstream of ORF start. if not, remove if position >= orf_start: filtered_counts.pop(position) elif orf_stop: # check if current position is downstream of ORF stop. If not, # remove if position <= orf_stop: filtered_counts.pop(position) # calculate total reads for this transcript total_reads = sum(sum(item.values()) for item in filtered_counts.values()) return filtered_counts, total_reads def get_ribo_counts(ribo_fileobj, transcript_name, read_lengths, read_offsets): """For each mapped read of the given transcript in the BAM file (pysam AlignmentFile object), return the position (+1) and the corresponding frame (1, 2 or 3) to which it aligns. Keyword arguments: ribo_fileobj -- file object - BAM file opened using pysam AlignmentFile transcript_name -- Name of transcript to get counts for read_length (optional) -- If provided, get counts only for reads of this length. """ read_counts = {} total_reads = 0 for record in ribo_fileobj.fetch(transcript_name): query_length = record.query_length position_ref = record.pos + 1 for index, read_length in enumerate(read_lengths): position = position_ref # reset position if read_length == 0 or read_length == query_length: # if an offset is specified, increment position by that offset. position += read_offsets[index] else: # ignore other reads/lengths continue total_reads += 1 try: read_counts[position] except KeyError: read_counts[position] = {1: 0, 2: 0, 3: 0} # calculate the frame of the read from position rem = position % 3 if rem == 0: read_counts[position][3] += 1 else: read_counts[position][rem] += 1 log.debug('Total read counts: {}'.format(total_reads)) log.debug('RiboSeq read counts for transcript: {0}\n{1}'.format(transcript_name, read_counts)) return read_counts, total_reads def check_required_arguments(ribo_file, transcriptome_fasta, transcript_name=None): """Check required arguments of both riboplot and ribocount.""" # Is this a valid BAM file? i.e., can pysam read it? try: is_bam_valid(ribo_file) except ValueError: log.error('The given RiboSeq BAM file is not valid') raise # Does the BAM file have an index? If not, create it. if not bam_has_index(ribo_file): log.info('Creating an index for the BAM file...') create_bam_index(ribo_file) if not bam_has_index(ribo_file): msg = ('Could not create an index for this BAM file. Is this a valid BAM file ' 'and/or is the BAM file sorted by chromosomal coordinates?') log.error(msg) raise BamFileError(msg) # Is FASTA file valid? fasta_valid = False try: fasta_valid = is_fasta_valid(transcriptome_fasta) except IOError: log.error('Transcriptome FASTA file is not valid') raise if fasta_valid: if transcript_name: try: get_fasta_records(transcriptome_fasta, [transcript_name]) except IOError: log.error('Could not get FASTA sequence of "{}" from transcriptome FASTA file'.format(transcript_name)) raise else: # ribocount doesn't have a transcript option so we get the first # sequence name from the fasta file transcript_name = get_first_transcript_name(transcriptome_fasta) # check if transcript also exists in BAM with pysam.AlignmentFile(ribo_file, 'rb') as bam_file: if transcript_name not in bam_file.references: msg = 'Transcript "{}" does not exist in BAM file'.format(transcript_name) log.error(msg) raise ArgumentError(msg) def check_rna_file(rna_file): """Check if bedtools is available and if the given RNA-Seq bam file is valid. """ try: subprocess.check_output(['bedtools', '--version']) except OSError: log.error('Could not find bedtools in PATH. bedtools is required ' 'for generating RNA coverage plot.') raise # Is this a valid BAM file? i.e., can pysam read it? try: is_bam_valid(rna_file) except ValueError: log.error('The given RNASeq BAM file is not valid') raise def check_read_lengths(ribo_file, read_lengths): """Check if read lengths are valid (positive). """ # check if there are any valid read lengths to check i.e., not equal to 0 valid_lengths = list(set(read_lengths)) # if read length is 0, all read lengths are requested so we skip further # checks. if len(valid_lengths) == 1 and valid_lengths[0] == 0: return for read_length in valid_lengths: if read_length < 0: msg = 'Read length must be a positive value' log.error(msg) raise ArgumentError(msg) def check_read_offsets(read_offsets): """Check if read offsets are valid (positive).""" for read_offset in read_offsets: if read_offset < 0: msg = 'Read offset must be 0 or greater' log.error(msg) raise ArgumentError(msg) def check_read_lengths_offsets(read_lengths, read_offsets): """Check if read length has corresponding read offset for all read lengths. """ if not len(read_lengths) == len(read_offsets): raise ArgumentError('Each read length should have a corresponding offset value') else: return True
bsd-3-clause
[ 624, 7844, 3423, 14, 408, 199, 646, 10382, 455, 199, 646, 2050, 199, 646, 3873, 199, 504, 15502, 492, 27608, 421, 199, 3, 1218, 2512, 367, 314, 8039, 2240, 199, 793, 275, 2050, 14, 5572, 360, 30759, 411, 1653, 358, 199, 793, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 3, 1218, 8559, 3016, 543, 282, 10948, 943, 2166, 199, 335, 275, 2050, 14, 22482, 342, 199, 335, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 446, 2818, 578, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 297, 1434, 5045, 9569, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 358, 199, 335, 14, 26076, 8, 8911, 9, 199, 793, 14, 18826, 8, 335, 9, 421, 199, 533, 5886, 547, 8, 1726, 304, 272, 408, 16894, 1380, 3866, 2368, 787, 4847, 315, 314, 1414, 1004, 1041, 272, 986, 421, 199, 533, 699, 455, 25212, 8, 1726, 304, 272, 408, 9298, 4048, 370, 699, 1156, 570, 624, 272, 986, 421, 199, 533, 820, 73, 656, 10711, 547, 8, 1726, 304, 272, 408, 14109, 2552, 4668, 1958, 370, 8012, 66, 411, 1653, 1041, 272, 986, 421, 199, 533, 820, 73, 656, 2353, 547, 8, 1726, 304, 272, 408, 14109, 2552, 4668, 1958, 370, 8012, 656, 835, 1041, 272, 986, 421, 199, 533, 820, 7170, 23209, 547, 8, 1726, 304, 272, 408, 1858, 2552, 4048, 370, 820, 7170, 1849, 3652, 10152, 1808, 30739, 2537, 14, 408, 272, 986, 421, 199, 318, 17464, 63, 14253, 8, 585, 304, 272, 408, 8862, 314, 1627, 10029, 11673, 574, 370, 3663, 3000, 1338, 14, 408, 272, 1338, 275, 942, 272, 367, 1242, 315, 574, 14, 1294, 25908, 267, 1242, 275, 1109, 8, 1053, 9, 267, 1338, 14, 740, 8, 1053, 9, 272, 372, 1338, 421, 199, 32, 14237, 199, 318, 1551, 63, 15983, 455, 63, 493, 8, 5252, 12, 8570, 304, 272, 408, 4299, 282, 699, 1156, 503, 481, 11307, 33, 570, 543, 10382, 455, 334, 509, 675, 543, 298, 1045, 2, 5164, 9471, 272, 862, 26, 267, 340, 8570, 508, 283, 21112, 356, 288, 4090, 588, 455, 275, 10382, 455, 14, 16613, 1173, 8, 5252, 12, 283, 4848, 358, 267, 916, 8570, 508, 283, 20309, 356, 288, 4090, 588, 455, 275, 10382, 455, 14, 1906, 1207, 1173, 8, 5252, 9, 267, 1995, 4090, 588, 455, 272, 871, 26, 267, 746, 272, 587, 26, 267, 4090, 588, 455, 14, 1600, 342, 421, 199, 318, 365, 63, 21112, 63, 1078, 8, 21112, 63, 493, 304, 272, 408, 1799, 340, 330, 455, 570, 365, 1686, 14, 6218, 282, 1722, 340, 10382, 455, 3913, 1586, 314, 570, 14, 339, 327, 11768, 26, 10382, 455, 221, 1630, 440, 26796, 323, 3382, 699, 1156, 436, 428, 1156, 272, 408, 272, 862, 26, 267, 289, 275, 10382, 455, 14, 16613, 1173, 8, 21112, 63, 493, 9, 272, 871, 1722, 26, 267, 746, 272, 871, 26, 267, 746, 272, 587, 26, 267, 289, 14, 1600, 342, 339, 372, 715, 421, 199, 318, 330, 455, 63, 1989, 63, 1080, 8, 21112, 63, 493, 304, 272, 408, 1799, 340, 330, 455, 570, 965, 376, 1478, 14, 1803, 715, 15, 797, 1041, 272, 965, 63, 1080, 275, 488, 272, 543, 10382, 455, 14, 16613, 1173, 8, 21112, 63, 493, 12, 283, 4848, 358, 465, 330, 455, 63, 9234, 26, 267, 862, 26, 288, 330, 455, 63, 9234, 14, 3535, 8, 21112, 63, 9234, 14, 12635, 59, 16, 566, 267, 871, 1722, 465, 2329, 26, 288, 340, 2329, 14, 1188, 508, 283, 3535, 2797, 641, 330, 455, 493, 1928, 1478, 356, 355, 330, 455, 63, 9234, 14, 1600, 342, 355, 965, 63, 1080, 275, 756, 267, 587, 26, 288, 965, 63, 1080, 275, 715, 272, 372, 965, 63, 1080, 421, 199, 318, 1218, 63, 21112, 63, 1080, 8, 21112, 63, 493, 304, 272, 408, 2499, 376, 1478, 367, 314, 1627, 699, 1156, 570, 1041, 272, 10382, 455, 14, 1080, 8, 21112, 63, 493, 9, 421, 199, 318, 365, 63, 20309, 63, 1078, 8, 20309, 63, 493, 304, 272, 408, 1799, 340, 30544, 570, 365, 1686, 14, 6218, 282, 1722, 340, 10382, 455, 3913, 1586, 314, 570, 14, 339, 327, 11768, 26, 10382, 455, 221, 1630, 440, 26796, 323, 3382, 699, 1156, 436, 428, 1156, 272, 408, 272, 862, 26, 267, 289, 275, 10382, 455, 14, 1906, 1207, 1173, 8, 20309, 63, 493, 9, 272, 871, 5925, 26, 267, 746, 272, 587, 26, 267, 289, 14, 1600, 342, 272, 372, 715, 421, 199, 318, 664, 63, 2246, 63, 21656, 63, 354, 8, 20309, 63, 493, 304, 272, 408, 1767, 314, 1642, 481, 11307, 33, 3414, 687, 314, 1627, 481, 11307, 33, 570, 14, 339, 6431, 2368, 26, 272, 30544, 63, 493, 1553, 481, 11307, 33, 1475, 570, 402, 314, 7115, 729, 5816, 278, 339, 408, 272, 543, 1551, 63, 15983, 455, 63, 493, 8, 5252, 29, 20309, 63, 493, 12, 8570, 534, 20309, 358, 465, 289, 26, 267, 27229, 63, 354, 275, 289, 14, 12635, 59, 16, 61, 272, 372, 27229, 63, 354, 421, 199, 318, 664, 63, 20309, 63, 3059, 8, 20309, 63, 493, 12, 27229, 63, 354, 304, 272, 408, 1767, 282, 2849, 27229, 687, 282, 1686, 30544, 570, 465, 282, 2777, 14, 339, 2777, 59, 21656, 63, 354, 61, 275, 3414, 339, 6431, 2368, 26, 272, 30544, 63, 493, 1553, 481, 11307, 33, 1475, 570, 402, 314, 7115, 729, 5816, 278, 272, 27229, 63, 354, 1553, 2812, 402, 314, 27229, 465, 315, 314, 481, 11307, 33, 1406, 339, 408, 272, 543, 1551, 63, 15983, 455, 63, 493, 8, 5252, 29, 20309, 63, 493, 12, 8570, 534, 20309, 358, 465, 289, 26, 267, 3414, 275, 289, 14, 3535, 8, 21656, 63, 354, 9, 272, 372, 469, 21656, 63, 354, 26, 3414, 93, 421, 199, 318, 664, 63, 20309, 63, 6502, 8, 20309, 12, 7115, 6429, 304, 272, 408, 1767, 769, 402, 27229, 5767, 687, 314, 1627, 30544, 570, 14, 272, 7048, 2777, 911, 506, 402, 314, 1824, 791, 4041, 63, 344, 356, 791, 4041, 356, 283, 10985, 297, 283, 1267, 356, 650, 4863, 339, 5651, 7229, 83, 1077, 506, 2741, 465, 282, 769, 402, 3414, 1305 ]
[ 7844, 3423, 14, 408, 199, 646, 10382, 455, 199, 646, 2050, 199, 646, 3873, 199, 504, 15502, 492, 27608, 421, 199, 3, 1218, 2512, 367, 314, 8039, 2240, 199, 793, 275, 2050, 14, 5572, 360, 30759, 411, 1653, 358, 199, 793, 14, 13548, 8, 4806, 14, 5287, 9, 199, 199, 3, 1218, 8559, 3016, 543, 282, 10948, 943, 2166, 199, 335, 275, 2050, 14, 22482, 342, 199, 335, 14, 13548, 8, 4806, 14, 4531, 9, 199, 199, 8911, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 446, 2818, 578, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 297, 1434, 5045, 9569, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 358, 199, 335, 14, 26076, 8, 8911, 9, 199, 793, 14, 18826, 8, 335, 9, 421, 199, 533, 5886, 547, 8, 1726, 304, 272, 408, 16894, 1380, 3866, 2368, 787, 4847, 315, 314, 1414, 1004, 1041, 272, 986, 421, 199, 533, 699, 455, 25212, 8, 1726, 304, 272, 408, 9298, 4048, 370, 699, 1156, 570, 624, 272, 986, 421, 199, 533, 820, 73, 656, 10711, 547, 8, 1726, 304, 272, 408, 14109, 2552, 4668, 1958, 370, 8012, 66, 411, 1653, 1041, 272, 986, 421, 199, 533, 820, 73, 656, 2353, 547, 8, 1726, 304, 272, 408, 14109, 2552, 4668, 1958, 370, 8012, 656, 835, 1041, 272, 986, 421, 199, 533, 820, 7170, 23209, 547, 8, 1726, 304, 272, 408, 1858, 2552, 4048, 370, 820, 7170, 1849, 3652, 10152, 1808, 30739, 2537, 14, 408, 272, 986, 421, 199, 318, 17464, 63, 14253, 8, 585, 304, 272, 408, 8862, 314, 1627, 10029, 11673, 574, 370, 3663, 3000, 1338, 14, 408, 272, 1338, 275, 942, 272, 367, 1242, 315, 574, 14, 1294, 25908, 267, 1242, 275, 1109, 8, 1053, 9, 267, 1338, 14, 740, 8, 1053, 9, 272, 372, 1338, 421, 199, 32, 14237, 199, 318, 1551, 63, 15983, 455, 63, 493, 8, 5252, 12, 8570, 304, 272, 408, 4299, 282, 699, 1156, 503, 481, 11307, 33, 570, 543, 10382, 455, 334, 509, 675, 543, 298, 1045, 2, 5164, 9471, 272, 862, 26, 267, 340, 8570, 508, 283, 21112, 356, 288, 4090, 588, 455, 275, 10382, 455, 14, 16613, 1173, 8, 5252, 12, 283, 4848, 358, 267, 916, 8570, 508, 283, 20309, 356, 288, 4090, 588, 455, 275, 10382, 455, 14, 1906, 1207, 1173, 8, 5252, 9, 267, 1995, 4090, 588, 455, 272, 871, 26, 267, 746, 272, 587, 26, 267, 4090, 588, 455, 14, 1600, 342, 421, 199, 318, 365, 63, 21112, 63, 1078, 8, 21112, 63, 493, 304, 272, 408, 1799, 340, 330, 455, 570, 365, 1686, 14, 6218, 282, 1722, 340, 10382, 455, 3913, 1586, 314, 570, 14, 339, 327, 11768, 26, 10382, 455, 221, 1630, 440, 26796, 323, 3382, 699, 1156, 436, 428, 1156, 272, 408, 272, 862, 26, 267, 289, 275, 10382, 455, 14, 16613, 1173, 8, 21112, 63, 493, 9, 272, 871, 1722, 26, 267, 746, 272, 871, 26, 267, 746, 272, 587, 26, 267, 289, 14, 1600, 342, 339, 372, 715, 421, 199, 318, 330, 455, 63, 1989, 63, 1080, 8, 21112, 63, 493, 304, 272, 408, 1799, 340, 330, 455, 570, 965, 376, 1478, 14, 1803, 715, 15, 797, 1041, 272, 965, 63, 1080, 275, 488, 272, 543, 10382, 455, 14, 16613, 1173, 8, 21112, 63, 493, 12, 283, 4848, 358, 465, 330, 455, 63, 9234, 26, 267, 862, 26, 288, 330, 455, 63, 9234, 14, 3535, 8, 21112, 63, 9234, 14, 12635, 59, 16, 566, 267, 871, 1722, 465, 2329, 26, 288, 340, 2329, 14, 1188, 508, 283, 3535, 2797, 641, 330, 455, 493, 1928, 1478, 356, 355, 330, 455, 63, 9234, 14, 1600, 342, 355, 965, 63, 1080, 275, 756, 267, 587, 26, 288, 965, 63, 1080, 275, 715, 272, 372, 965, 63, 1080, 421, 199, 318, 1218, 63, 21112, 63, 1080, 8, 21112, 63, 493, 304, 272, 408, 2499, 376, 1478, 367, 314, 1627, 699, 1156, 570, 1041, 272, 10382, 455, 14, 1080, 8, 21112, 63, 493, 9, 421, 199, 318, 365, 63, 20309, 63, 1078, 8, 20309, 63, 493, 304, 272, 408, 1799, 340, 30544, 570, 365, 1686, 14, 6218, 282, 1722, 340, 10382, 455, 3913, 1586, 314, 570, 14, 339, 327, 11768, 26, 10382, 455, 221, 1630, 440, 26796, 323, 3382, 699, 1156, 436, 428, 1156, 272, 408, 272, 862, 26, 267, 289, 275, 10382, 455, 14, 1906, 1207, 1173, 8, 20309, 63, 493, 9, 272, 871, 5925, 26, 267, 746, 272, 587, 26, 267, 289, 14, 1600, 342, 272, 372, 715, 421, 199, 318, 664, 63, 2246, 63, 21656, 63, 354, 8, 20309, 63, 493, 304, 272, 408, 1767, 314, 1642, 481, 11307, 33, 3414, 687, 314, 1627, 481, 11307, 33, 570, 14, 339, 6431, 2368, 26, 272, 30544, 63, 493, 1553, 481, 11307, 33, 1475, 570, 402, 314, 7115, 729, 5816, 278, 339, 408, 272, 543, 1551, 63, 15983, 455, 63, 493, 8, 5252, 29, 20309, 63, 493, 12, 8570, 534, 20309, 358, 465, 289, 26, 267, 27229, 63, 354, 275, 289, 14, 12635, 59, 16, 61, 272, 372, 27229, 63, 354, 421, 199, 318, 664, 63, 20309, 63, 3059, 8, 20309, 63, 493, 12, 27229, 63, 354, 304, 272, 408, 1767, 282, 2849, 27229, 687, 282, 1686, 30544, 570, 465, 282, 2777, 14, 339, 2777, 59, 21656, 63, 354, 61, 275, 3414, 339, 6431, 2368, 26, 272, 30544, 63, 493, 1553, 481, 11307, 33, 1475, 570, 402, 314, 7115, 729, 5816, 278, 272, 27229, 63, 354, 1553, 2812, 402, 314, 27229, 465, 315, 314, 481, 11307, 33, 1406, 339, 408, 272, 543, 1551, 63, 15983, 455, 63, 493, 8, 5252, 29, 20309, 63, 493, 12, 8570, 534, 20309, 358, 465, 289, 26, 267, 3414, 275, 289, 14, 3535, 8, 21656, 63, 354, 9, 272, 372, 469, 21656, 63, 354, 26, 3414, 93, 421, 199, 318, 664, 63, 20309, 63, 6502, 8, 20309, 12, 7115, 6429, 304, 272, 408, 1767, 769, 402, 27229, 5767, 687, 314, 1627, 30544, 570, 14, 272, 7048, 2777, 911, 506, 402, 314, 1824, 791, 4041, 63, 344, 356, 791, 4041, 356, 283, 10985, 297, 283, 1267, 356, 650, 4863, 339, 5651, 7229, 83, 1077, 506, 2741, 465, 282, 769, 402, 3414, 1305, 0 ]
[ 1, 1, 1, 1, 1,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ansible/modules/network/aci/msc_tenant.py
7
5147
#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: msc_tenant short_description: Manage tenants description: - Manage tenants on Cisco ACI Multi-Site. author: - Dag Wieers (@dagwieers) version_added: '2.8' options: tenant_id: description: - The ID of the tenant. type: str required: yes tenant: description: - The name of the tenant. type: str required: yes aliases: [ name, tenant_name ] display_name: description: - The name of the tenant to be displayed in the web UI. type: str required: yes description: description: - The description for this tenant. type: str state: description: - Use C(present) or C(absent) for adding or removing. - Use C(query) for listing an object or multiple objects. type: str choices: [ absent, present, query ] default: present extends_documentation_fragment: msc ''' EXAMPLES = r''' - name: Add a new tenant msc_tenant: host: msc_host username: admin password: SomeSecretPassword tenant: north_europe tenant_id: 101 display_name: North European Datacenter description: This tenant manages the NEDC environment. state: present delegate_to: localhost - name: Remove a tenant msc_tenant: host: msc_host username: admin password: SomeSecretPassword tenant: north_europe state: absent delegate_to: localhost - name: Query a tenant msc_tenant: host: msc_host username: admin password: SomeSecretPassword tenant: north_europe state: query delegate_to: localhost register: query_result - name: Query all tenants msc_tenant: host: msc_host username: admin password: SomeSecretPassword state: query delegate_to: localhost register: query_result ''' RETURN = r''' ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset def main(): argument_spec = msc_argument_spec() argument_spec.update( description=dict(type='str'), display_name=dict(type='str'), tenant=dict(type='str', required=False, aliases=['name', 'tenant_name']), tenant_id=dict(type='str', required=False), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['tenant']], ['state', 'present', ['tenant']], ], ) description = module.params['description'] display_name = module.params['display_name'] tenant = module.params['tenant'] tenant_id = module.params['tenant_id'] state = module.params['state'] msc = MSCModule(module) path = 'tenants' # Query for existing object(s) if tenant_id is None and tenant is None: msc.existing = msc.query_objs(path) elif tenant_id is None: msc.existing = msc.get_obj(path, name=tenant) if msc.existing: tenant_id = msc.existing['id'] elif tenant is None: msc.existing = msc.get_obj(path, id=tenant_id) else: msc.existing = msc.get_obj(path, id=tenant_id) existing_by_name = msc.get_obj(path, name=tenant) if existing_by_name and tenant_id != existing_by_name['id']: msc.fail_json(msg="Provided tenant '{0}' with id '{1}' does not match existing id '{2}'.".format(tenant, tenant_id, existing_by_name['id'])) # If we found an existing object, continue with it if tenant_id: path = 'tenants/{id}'.format(id=tenant_id) if state == 'query': pass elif state == 'absent': msc.previous = msc.existing if msc.existing: if module.check_mode: msc.existing = {} else: msc.existing = msc.request(path, method='DELETE') elif state == 'present': msc.previous = msc.existing msc.sanitize(dict( description=description, id=tenant_id, name=tenant, displayName=display_name, siteAssociations=[], userAssociations=[dict(userId="0000ffff0000000000000020")], ), collate=True) if msc.existing: if not issubset(msc.sent, msc.existing): if module.check_mode: msc.existing = msc.proposed else: msc.existing = msc.request(path, method='PUT', data=msc.sent) else: if module.check_mode: msc.existing = msc.proposed else: msc.existing = msc.request(path, method='POST', data=msc.sent) msc.exit_json() 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, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 333, 551, 63, 4647, 199, 3612, 63, 1802, 26, 14944, 16685, 2285, 199, 1802, 26, 199, 13, 14944, 16685, 2285, 641, 28356, 437, 3553, 6879, 13, 8972, 14, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 24, 7, 199, 1419, 26, 523, 8261, 63, 344, 26, 272, 1369, 26, 272, 446, 710, 2870, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 12, 8261, 63, 354, 1622, 523, 2929, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 370, 506, 9080, 315, 314, 3330, 14041, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 523, 1369, 26, 272, 1369, 26, 272, 446, 710, 1369, 367, 642, 8261, 14, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 333, 551, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 892, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 8261, 63, 344, 26, 14313, 272, 2929, 63, 354, 26, 653, 11297, 31615, 290, 3918, 4218, 272, 1369, 26, 961, 8261, 31965, 314, 653, 1149, 35, 3734, 14, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 5852, 282, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8133, 282, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 199, 13, 536, 26, 8133, 1006, 16685, 2285, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 22832, 14, 77, 551, 492, 603, 5153, 2377, 12, 333, 551, 63, 2094, 63, 1650, 12, 365, 9401, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 333, 551, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1369, 29, 807, 8, 466, 534, 495, 659, 267, 2929, 63, 354, 29, 807, 8, 466, 534, 495, 659, 267, 8261, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 12, 5481, 2968, 354, 297, 283, 4647, 63, 354, 3815, 267, 8261, 63, 344, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 395, 267, 1174, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1881, 297, 3415, 2968, 5575, 297, 283, 1881, 297, 283, 1131, 3815, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 2094, 63, 1650, 12, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 267, 1415, 63, 692, 1524, 288, 788, 929, 297, 283, 5575, 297, 788, 4647, 2157, 288, 788, 929, 297, 283, 1881, 297, 788, 4647, 2157, 267, 2156, 272, 776, 339, 1369, 275, 859, 14, 1162, 459, 1802, 418, 272, 2929, 63, 354, 275, 859, 14, 1162, 459, 2918, 63, 354, 418, 272, 8261, 275, 859, 14, 1162, 459, 4647, 418, 272, 8261, 63, 344, 275, 859, 14, 1162, 459, 4647, 63, 344, 418, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 333, 551, 275, 603, 5153, 2377, 8, 578, 9, 339, 931, 275, 283, 25021, 7, 339, 327, 8133, 367, 3411, 909, 8, 83, 9, 272, 340, 8261, 63, 344, 365, 488, 436, 8261, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 1131, 63, 8718, 8, 515, 9, 272, 916, 8261, 63, 344, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 536, 29, 4647, 9, 267, 340, 333, 551, 14, 5952, 26, 288, 8261, 63, 344, 275, 333, 551, 14, 5952, 459, 344, 418, 272, 916, 8261, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 1305, 29, 4647, 63, 344, 9, 272, 587, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 1305, 29, 4647, 63, 344, 9, 267, 3411, 63, 991, 63, 354, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 536, 29, 4647, 9, 267, 340, 3411, 63, 991, 63, 354, 436, 8261, 63, 344, 1137, 3411, 63, 991, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 333, 551, 63, 4647, 199, 3612, 63, 1802, 26, 14944, 16685, 2285, 199, 1802, 26, 199, 13, 14944, 16685, 2285, 641, 28356, 437, 3553, 6879, 13, 8972, 14, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 24, 7, 199, 1419, 26, 523, 8261, 63, 344, 26, 272, 1369, 26, 272, 446, 710, 2870, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 272, 5481, 26, 359, 536, 12, 8261, 63, 354, 1622, 523, 2929, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 370, 506, 9080, 315, 314, 3330, 14041, 14, 272, 730, 26, 620, 272, 1415, 26, 9456, 523, 1369, 26, 272, 1369, 26, 272, 446, 710, 1369, 367, 642, 8261, 14, 272, 730, 26, 620, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 730, 26, 620, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 333, 551, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 892, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 8261, 63, 344, 26, 14313, 272, 2929, 63, 354, 26, 653, 11297, 31615, 290, 3918, 4218, 272, 1369, 26, 961, 8261, 31965, 314, 653, 1149, 35, 3734, 14, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 5852, 282, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8133, 282, 8261, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 6590, 273, 63, 69, 12646, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 199, 13, 536, 26, 8133, 1006, 16685, 2285, 523, 333, 551, 63, 4647, 26, 272, 1591, 26, 333, 551, 63, 1102, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 1174, 26, 1827, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 1827, 63, 1099, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 22832, 14, 77, 551, 492, 603, 5153, 2377, 12, 333, 551, 63, 2094, 63, 1650, 12, 365, 9401, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 333, 551, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 267, 1369, 29, 807, 8, 466, 534, 495, 659, 267, 2929, 63, 354, 29, 807, 8, 466, 534, 495, 659, 267, 8261, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 12, 5481, 2968, 354, 297, 283, 4647, 63, 354, 3815, 267, 8261, 63, 344, 29, 807, 8, 466, 534, 495, 297, 1415, 29, 797, 395, 267, 1174, 29, 807, 8, 466, 534, 495, 297, 849, 534, 1881, 297, 3415, 2968, 5575, 297, 283, 1881, 297, 283, 1131, 3815, 272, 776, 339, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 2094, 63, 1650, 12, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 267, 1415, 63, 692, 1524, 288, 788, 929, 297, 283, 5575, 297, 788, 4647, 2157, 288, 788, 929, 297, 283, 1881, 297, 788, 4647, 2157, 267, 2156, 272, 776, 339, 1369, 275, 859, 14, 1162, 459, 1802, 418, 272, 2929, 63, 354, 275, 859, 14, 1162, 459, 2918, 63, 354, 418, 272, 8261, 275, 859, 14, 1162, 459, 4647, 418, 272, 8261, 63, 344, 275, 859, 14, 1162, 459, 4647, 63, 344, 418, 272, 1174, 275, 859, 14, 1162, 459, 929, 418, 339, 333, 551, 275, 603, 5153, 2377, 8, 578, 9, 339, 931, 275, 283, 25021, 7, 339, 327, 8133, 367, 3411, 909, 8, 83, 9, 272, 340, 8261, 63, 344, 365, 488, 436, 8261, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 1131, 63, 8718, 8, 515, 9, 272, 916, 8261, 63, 344, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 536, 29, 4647, 9, 267, 340, 333, 551, 14, 5952, 26, 288, 8261, 63, 344, 275, 333, 551, 14, 5952, 459, 344, 418, 272, 916, 8261, 365, 488, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 1305, 29, 4647, 63, 344, 9, 272, 587, 26, 267, 333, 551, 14, 5952, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 1305, 29, 4647, 63, 344, 9, 267, 3411, 63, 991, 63, 354, 275, 333, 551, 14, 362, 63, 1113, 8, 515, 12, 536, 29, 4647, 9, 267, 340, 3411, 63, 991, 63, 354, 436, 8261, 63, 344, 1137, 3411, 63, 991, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
andrebellafronte/stoq
stoqlib/gui/search/sellablesearch.py
2
16253
# -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 ## ## Copyright (C) 2005-2007 Async Open Source <http://www.async.com.br> ## All rights reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as published by ## the Free Software Foundation; 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 Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <stoq-devel@async.com.br> ## ## """ Implementation of sellable search """ from decimal import Decimal import gtk from kiwi.currency import currency from storm.expr import Ne from stoqlib.api import api from stoqlib.database.orm import ORMObject from stoqlib.domain.product import ProductSupplierInfo, Product from stoqlib.domain.sellable import Sellable from stoqlib.domain.views import SellableFullStockView from stoqlib.gui.dialogs.sellableimage import SellableImageViewer from stoqlib.gui.editors.producteditor import ProductEditor from stoqlib.gui.search.searchcolumns import (AccessorColumn, SearchColumn, QuantityColumn) from stoqlib.gui.search.searcheditor import SearchEditor from stoqlib.gui.wizards.productwizard import ProductCreateWizard from stoqlib.lib.defaults import sort_sellable_code from stoqlib.lib.formatters import format_quantity from stoqlib.lib.parameters import sysparam from stoqlib.lib.translation import stoqlib_gettext _ = stoqlib_gettext class SellableSearch(SearchEditor): title = _('Item search') size = (800, 500) model_list_lookup_attr = 'product_id' footer_ok_label = _('_Select item') search_spec = SellableFullStockView editor_class = None exclude_delivery_service = True text_field_columns = [SellableFullStockView.description, SellableFullStockView.category_description, SellableFullStockView.barcode, SellableFullStockView.code] def __init__(self, store, hide_footer=False, hide_toolbar=True, selection_mode=None, search_str=None, search_spec=None, search_query=None, double_click_confirm=True, info_message=None, show_closed_items=False): """ :param store: a store :param hide_footer: do I have to hide the dialog footer? :param hide_toolbar: do I have to hide the dialog toolbar? :param selection_mode: the kiwi list selection mode :param search_str: If this search should already filter for some string :param double_click_confirm: If double click a item in the list should automatically confirm :param show_closed_items: if this parameter is True, shows sellable with status closed """ if selection_mode is None: selection_mode = gtk.SELECTION_BROWSE self._image_viewer = None self._first_search = True self._first_search_string = search_str self._search_query = search_query self._show_closed_items = show_closed_items self._delivery_sellable = sysparam.get_object( store, 'DELIVERY_SERVICE').sellable SearchEditor.__init__(self, store, search_spec=search_spec, editor_class=self.editor_class, hide_footer=hide_footer, hide_toolbar=hide_toolbar, selection_mode=selection_mode, double_click_confirm=double_click_confirm) if info_message: self.set_message(info_message) if search_str: self.set_searchbar_search_string(search_str) self.search.refresh() # # SearchEditor # def key_shift_Return(self): self.confirm() def key_control_Return(self): self.confirm() def key_shift_KP_Enter(self): self.confirm() def key_control_KP_Enter(self): self.confirm() def close(self): # Make sure image viewer gets closed when this search closes self._close_image_viewer() super(SellableSearch, self).close() def confirm(self, retval=None): # FIXME: This is a hack, we need to do proper validation in the parent if retval is None and not self.ok_button.get_sensitive(): return super(SellableSearch, self).confirm(retval=retval) def setup_widgets(self): self.image_viewer_toggler = gtk.CheckMenuItem(_("Show image viewer")) self.popup = gtk.Menu() self.popup.add(self.image_viewer_toggler) self.popup.show_all() if hasattr(self.search_spec, 'product'): self.branch_stock_button = self.add_button(label=_('Stock details')) self.branch_stock_button.show() self.branch_stock_button.set_sensitive(False) else: self.branch_stock_button = None def create_filters(self): self.search.set_query(self.executer_query) def get_columns(self): columns = [SearchColumn('code', title=_(u'Code'), data_type=str), SearchColumn('barcode', title=_('Barcode'), data_type=str, sort_func=sort_sellable_code, width=80), SearchColumn('category_description', title=_('Category'), data_type=str, width=120), SearchColumn('description', title=_('Description'), data_type=str, expand=True, sorted=True), SearchColumn('manufacturer', title=_('Manufacturer'), data_type=str, visible=False), SearchColumn('model', title=_('Model'), data_type=str, visible=False)] if hasattr(self.search_spec, 'price'): columns.append(SearchColumn('price', title=_(u'Price'), data_type=currency, visible=True)) if hasattr(self.search_spec, 'minimum_quantity'): columns.append(SearchColumn('minimum_quantity', title=_(u'Minimum Qty'), data_type=Decimal, visible=False)) if hasattr(self.search_spec, 'stock'): columns.append(QuantityColumn('stock', title=_(u'In Stock'))) return columns def update_widgets(self): sellable_view = self.results.get_selected() self.set_edit_button_sensitive(bool(sellable_view)) self.ok_button.set_sensitive(bool(sellable_view)) if self.branch_stock_button is not None: self.branch_stock_button.set_sensitive( bool(self._get_selected_storable())) def executer_query(self, store): # If the viewable has a find_by_branch method, then lets use it instead # of the generic find, to show only the stock for the current branch. if hasattr(self.search_spec, 'find_by_branch'): branch = api.get_current_branch(store) results = self.search_spec.find_by_branch(store, branch) else: results = store.find(self.search_spec) if self._search_query: results = results.find(self._search_query) if not self._show_closed_items: results = results.find( self.search_spec.status == Sellable.STATUS_AVAILABLE) if self.exclude_delivery_service: results = results.find( self.search_spec.id != self._delivery_sellable.id) return results # # Private # def _get_selected_storable(self): product = getattr(self.results.get_selected(), 'product', None) if product and self.fast_iter: product = self.store.get(Product, product.id) return product and product.storable def _open_image_viewer(self): assert self._image_viewer is None self._image_viewer = SellableImageViewer(size=(325, 325)) self._update_image_viewer() self._image_viewer.toplevel.connect( 'delete-event', self._on_image_viewer__delete_event) self._image_viewer.show_all() def _close_image_viewer(self): if self._image_viewer is None: return self._image_viewer.destroy() self._image_viewer = None def _update_image_viewer(self): if self._image_viewer is None: return row = self.results.get_selected() self._image_viewer.set_sellable(row and row.sellable) # # Callbacks # def _on_image_viewer__delete_event(self, window, event): self._image_viewer = None self.image_viewer_toggler.set_active(False) def on_image_viewer_toggler__toggled(self, item): if item.get_active(): self._open_image_viewer() else: self._close_image_viewer() def on_results__right_click(self, klist, row, event): self.popup.popup(None, None, None, event.button, event.time) def on_results__selection_changed(self, klist, row): self._update_image_viewer() def on_branch_stock_button__clicked(self, widget): from stoqlib.gui.search.productsearch import ProductBranchSearch storable = self._get_selected_storable() if not storable: return self.run_dialog(ProductBranchSearch, self, self.store, storable) class SaleSellableSearch(SellableSearch): footer_ok_label = _('_Add sale items') has_new_button = False def __init__(self, store, hide_footer=False, hide_toolbar=True, search_str=None, search_query=None, info_message=None, sale_items=None, quantity=None): """ :param sale_items: optionally, a list of sellables which will be used to deduct stock values :param quantity: the quantity of stock to add to the order, is necessary to supply if you supply an order. """ self._quantity = quantity self._first_search = True self._first_search_string = search_str self._current_sale_stock = {} if sale_items: if self._quantity is None: raise TypeError("You need to specify a quantity " "when supplying an order") for item in sale_items: if item.sellable.product_storable: quantity = self._current_sale_stock.get(item.sellable.id, 0) quantity += item.quantity self._current_sale_stock[item.sellable.id] = quantity SellableSearch.__init__(self, store, hide_footer=hide_footer, hide_toolbar=hide_toolbar, search_str=search_str, search_query=search_query, info_message=info_message) # # SellableSearch # def search_completed(self, results, states): if not self._first_search: if self._first_search_string != self.get_searchbar_search_string(): self.set_message(None) if len(results) >= 1: results.select(results[0]) self.search.focus_search_entry() self._first_search = False def executer_query(self, store): results = super(SaleSellableSearch, self).executer_query(store) # if we select a quantity which is not an integer, filter out # sellables without a unit set if self._quantity is not None and (self._quantity % 1) != 0: results = results.find(Ne(Sellable.unit_id, None)) return results def update_widgets(self): super(SaleSellableSearch, self).update_widgets() sellable_view = self.results.get_selected() if not sellable_view: return sellable = sellable_view.sellable if (sellable.product_storable and self._quantity > self._get_available_stock(sellable_view)): self.ok_button.set_sensitive(False) else: self.ok_button.set_sensitive(True) def get_columns(self): return [SearchColumn('code', title=_('Code'), data_type=str, sort_func=sort_sellable_code, sorted=True), SearchColumn('barcode', title=_('Barcode'), data_type=str, visible=False), SearchColumn('description', title=_('Description'), data_type=str, expand=True), SearchColumn('manufacturer', title=_('Manufacturer'), data_type=str, visible=False), SearchColumn('model', title=_('Model'), data_type=str, visible=False), SearchColumn('price', title=_('Price'), data_type=currency, justify=gtk.JUSTIFY_RIGHT, width=120), SearchColumn('category_description', title=_('Category'), data_type=str, visible=False), AccessorColumn('stock', title=_(u'Stock'), accessor=self._get_available_stock, format_func=format_quantity, width=90, data_type=Decimal)] # # Private # def _get_available_stock(self, sellable_view): return sellable_view.stock - self._current_sale_stock.get( sellable_view.id, 0) class PurchaseSellableSearch(SellableSearch): editor_class = ProductEditor def __init__(self, store, hide_footer=False, hide_toolbar=False, search_str=None, search_spec=None, search_query=None, info_message=None, supplier=None): self._supplier = supplier SellableSearch.__init__(self, store, hide_footer=hide_footer, hide_toolbar=hide_toolbar, search_str=search_str, search_spec=search_spec, search_query=search_query, info_message=info_message) def get_editor_model(self, model): return model.product def run_editor(self, obj=None): store = api.new_store() if not obj: self.editor_class = ProductCreateWizard product = self.editor_class.run_wizard(self) product = product and store.fetch(product) else: self.editor_class = ProductEditor product = self.run_dialog(self.editor_class, self, store, store.fetch(obj), visual_mode=self._read_only) # This means we are creating a new product. After that, add the # current supplier as the supplier for this product if (obj is None and product and not product.is_supplied_by(self._supplier)): ProductSupplierInfo(store=store, supplier=store.fetch(self._supplier), product=product, base_cost=product.sellable.cost, is_main_supplier=True) if store.confirm(product): # If the return value is an ORMObject, fetch it from # the right connection if isinstance(product, ORMObject): product = self.store.get(type(product), product.id) # If we created a new object, confirm the dialog automatically if obj is None: self.confirm(product) store.close() return store.close() return product
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 309, 199, 309, 1898, 334, 35, 9, 11811, 13, 9488, 15223, 3232, 5800, 665, 1014, 921, 1544, 14, 4146, 14, 957, 14, 3289, 30, 199, 309, 2900, 4481, 4644, 199, 309, 199, 309, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 309, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 309, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 309, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 309, 2752, 12, 3277, 2020, 503, 5684, 26, 1455, 921, 1544, 14, 3689, 14, 1308, 8083, 199, 309, 199, 309, 6529, 8, 83, 304, 9785, 81, 11682, 665, 14308, 81, 13, 27870, 32, 4146, 14, 957, 14, 3289, 30, 199, 309, 199, 309, 199, 624, 24425, 402, 12743, 461, 2754, 408, 199, 199, 504, 6107, 492, 6345, 199, 199, 646, 8116, 199, 504, 1022, 73, 14249, 14, 4968, 492, 9952, 199, 504, 410, 1025, 14, 3684, 492, 5612, 199, 199, 504, 26123, 81, 773, 14, 1246, 492, 2986, 199, 504, 26123, 81, 773, 14, 4659, 14, 1025, 492, 23383, 1692, 199, 504, 26123, 81, 773, 14, 2261, 14, 2558, 492, 12705, 30080, 2354, 12, 12705, 199, 504, 26123, 81, 773, 14, 2261, 14, 23235, 461, 492, 428, 1697, 461, 199, 504, 26123, 81, 773, 14, 2261, 14, 4196, 492, 428, 1697, 461, 9042, 17103, 2768, 199, 504, 26123, 81, 773, 14, 5885, 14, 328, 18238, 14, 23235, 461, 1569, 492, 428, 1697, 461, 3491, 22347, 199, 504, 26123, 81, 773, 14, 5885, 14, 3773, 1384, 14, 496, 5905, 266, 27050, 492, 12705, 10423, 199, 504, 26123, 81, 773, 14, 5885, 14, 1733, 14, 1733, 3406, 492, 334, 5742, 4547, 12, 8730, 4547, 12, 6343, 31951, 4547, 9, 199, 504, 26123, 81, 773, 14, 5885, 14, 1733, 14, 261, 285, 595, 27050, 492, 8730, 10423, 199, 504, 26123, 81, 773, 14, 5885, 14, 87, 565, 5596, 14, 2558, 9819, 492, 12705, 2499, 20120, 199, 504, 26123, 81, 773, 14, 773, 14, 4322, 492, 4069, 63, 23235, 461, 63, 600, 199, 504, 26123, 81, 773, 14, 773, 14, 24270, 492, 1475, 63, 10577, 199, 504, 26123, 81, 773, 14, 773, 14, 3214, 492, 984, 635, 199, 504, 26123, 81, 773, 14, 773, 14, 6893, 492, 26123, 81, 773, 63, 5152, 199, 199, 63, 275, 26123, 81, 773, 63, 5152, 421, 199, 533, 428, 1697, 461, 5278, 8, 5278, 10423, 304, 272, 2538, 275, 4018, 2081, 2754, 358, 272, 1568, 275, 334, 6718, 12, 6891, 9, 272, 1402, 63, 513, 63, 3892, 63, 962, 275, 283, 2558, 63, 344, 7, 272, 14178, 63, 745, 63, 1302, 275, 4018, 63, 5446, 1242, 358, 272, 2754, 63, 1650, 275, 428, 1697, 461, 9042, 17103, 2768, 272, 8823, 63, 533, 275, 488, 272, 5760, 63, 14564, 63, 1364, 275, 715, 272, 1318, 63, 698, 63, 3406, 275, 359, 51, 1697, 461, 9042, 17103, 2768, 14, 1802, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 3710, 63, 1802, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 22091, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 600, 61, 339, 347, 636, 826, 721, 277, 12, 3877, 12, 13714, 63, 12781, 29, 797, 12, 13714, 63, 13951, 29, 549, 12, 326, 7267, 63, 632, 29, 403, 12, 2754, 63, 495, 29, 403, 12, 2754, 63, 1650, 29, 403, 12, 326, 2754, 63, 1131, 29, 403, 12, 4270, 63, 4891, 63, 9548, 29, 549, 12, 2256, 63, 1188, 29, 403, 12, 326, 2498, 63, 5938, 63, 1744, 29, 797, 304, 267, 408, 267, 520, 635, 3877, 26, 282, 3877, 267, 520, 635, 13714, 63, 12781, 26, 886, 473, 1172, 370, 13714, 314, 9592, 14178, 31, 267, 520, 635, 13714, 63, 13951, 26, 886, 473, 1172, 370, 13714, 314, 9592, 22483, 31, 267, 520, 635, 7267, 63, 632, 26, 314, 1022, 73, 14249, 769, 7267, 818, 267, 520, 635, 2754, 63, 495, 26, 982, 642, 2754, 1077, 2575, 2457, 367, 2005, 1059, 267, 520, 635, 4270, 63, 4891, 63, 9548, 26, 982, 4270, 8968, 282, 1242, 315, 314, 769, 1077, 288, 5847, 12679, 267, 520, 635, 2498, 63, 5938, 63, 1744, 26, 340, 642, 2725, 365, 715, 12, 13703, 12743, 461, 543, 288, 2004, 6876, 267, 408, 267, 340, 7267, 63, 632, 365, 488, 26, 288, 7267, 63, 632, 275, 8116, 14, 4859, 1075, 63, 31956, 899, 398, 291, 423, 1569, 63, 16645, 275, 488, 267, 291, 423, 2246, 63, 1733, 275, 715, 267, 291, 423, 2246, 63, 1733, 63, 875, 275, 2754, 63, 495, 267, 291, 423, 1733, 63, 1131, 275, 2754, 63, 1131, 267, 291, 423, 2384, 63, 5938, 63, 1744, 275, 2498, 63, 5938, 63, 1744, 267, 291, 423, 14564, 63, 23235, 461, 275, 984, 635, 14, 362, 63, 785, 8, 288, 3877, 12, 283, 1093, 2673, 2111, 57, 63, 10486, 1959, 23235, 461, 398, 8730, 10423, 855, 826, 721, 277, 12, 3877, 12, 2754, 63, 1650, 29, 1733, 63, 1650, 12, 2892, 8823, 63, 533, 29, 277, 14, 7515, 63, 533, 12, 2892, 13714, 63, 12781, 29, 8191, 63, 12781, 12, 2892, 13714, 63, 13951, 29, 8191, 63, 13951, 12, 2892, 7267, 63, 632, 29, 5592, 63, 632, 12, 2892, 4270, 63, 4891, 63, 9548, 29, 3157, 63, 4891, 63, 9548, 9, 398, 340, 2256, 63, 1188, 26, 288, 291, 14, 409, 63, 1188, 8, 815, 63, 1188, 9, 398, 340, 2754, 63, 495, 26, 288, 291, 14, 409, 63, 1733, 1700, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 309, 199, 309, 1898, 334, 35, 9, 11811, 13, 9488, 15223, 3232, 5800, 665, 1014, 921, 1544, 14, 4146, 14, 957, 14, 3289, 30, 199, 309, 2900, 4481, 4644, 199, 309, 199, 309, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 199, 309, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 309, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 309, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 309, 2752, 12, 3277, 2020, 503, 5684, 26, 1455, 921, 1544, 14, 3689, 14, 1308, 8083, 199, 309, 199, 309, 6529, 8, 83, 304, 9785, 81, 11682, 665, 14308, 81, 13, 27870, 32, 4146, 14, 957, 14, 3289, 30, 199, 309, 199, 309, 199, 624, 24425, 402, 12743, 461, 2754, 408, 199, 199, 504, 6107, 492, 6345, 199, 199, 646, 8116, 199, 504, 1022, 73, 14249, 14, 4968, 492, 9952, 199, 504, 410, 1025, 14, 3684, 492, 5612, 199, 199, 504, 26123, 81, 773, 14, 1246, 492, 2986, 199, 504, 26123, 81, 773, 14, 4659, 14, 1025, 492, 23383, 1692, 199, 504, 26123, 81, 773, 14, 2261, 14, 2558, 492, 12705, 30080, 2354, 12, 12705, 199, 504, 26123, 81, 773, 14, 2261, 14, 23235, 461, 492, 428, 1697, 461, 199, 504, 26123, 81, 773, 14, 2261, 14, 4196, 492, 428, 1697, 461, 9042, 17103, 2768, 199, 504, 26123, 81, 773, 14, 5885, 14, 328, 18238, 14, 23235, 461, 1569, 492, 428, 1697, 461, 3491, 22347, 199, 504, 26123, 81, 773, 14, 5885, 14, 3773, 1384, 14, 496, 5905, 266, 27050, 492, 12705, 10423, 199, 504, 26123, 81, 773, 14, 5885, 14, 1733, 14, 1733, 3406, 492, 334, 5742, 4547, 12, 8730, 4547, 12, 6343, 31951, 4547, 9, 199, 504, 26123, 81, 773, 14, 5885, 14, 1733, 14, 261, 285, 595, 27050, 492, 8730, 10423, 199, 504, 26123, 81, 773, 14, 5885, 14, 87, 565, 5596, 14, 2558, 9819, 492, 12705, 2499, 20120, 199, 504, 26123, 81, 773, 14, 773, 14, 4322, 492, 4069, 63, 23235, 461, 63, 600, 199, 504, 26123, 81, 773, 14, 773, 14, 24270, 492, 1475, 63, 10577, 199, 504, 26123, 81, 773, 14, 773, 14, 3214, 492, 984, 635, 199, 504, 26123, 81, 773, 14, 773, 14, 6893, 492, 26123, 81, 773, 63, 5152, 199, 199, 63, 275, 26123, 81, 773, 63, 5152, 421, 199, 533, 428, 1697, 461, 5278, 8, 5278, 10423, 304, 272, 2538, 275, 4018, 2081, 2754, 358, 272, 1568, 275, 334, 6718, 12, 6891, 9, 272, 1402, 63, 513, 63, 3892, 63, 962, 275, 283, 2558, 63, 344, 7, 272, 14178, 63, 745, 63, 1302, 275, 4018, 63, 5446, 1242, 358, 272, 2754, 63, 1650, 275, 428, 1697, 461, 9042, 17103, 2768, 272, 8823, 63, 533, 275, 488, 272, 5760, 63, 14564, 63, 1364, 275, 715, 272, 1318, 63, 698, 63, 3406, 275, 359, 51, 1697, 461, 9042, 17103, 2768, 14, 1802, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 3710, 63, 1802, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 22091, 12, 2079, 428, 1697, 461, 9042, 17103, 2768, 14, 600, 61, 339, 347, 636, 826, 721, 277, 12, 3877, 12, 13714, 63, 12781, 29, 797, 12, 13714, 63, 13951, 29, 549, 12, 326, 7267, 63, 632, 29, 403, 12, 2754, 63, 495, 29, 403, 12, 2754, 63, 1650, 29, 403, 12, 326, 2754, 63, 1131, 29, 403, 12, 4270, 63, 4891, 63, 9548, 29, 549, 12, 2256, 63, 1188, 29, 403, 12, 326, 2498, 63, 5938, 63, 1744, 29, 797, 304, 267, 408, 267, 520, 635, 3877, 26, 282, 3877, 267, 520, 635, 13714, 63, 12781, 26, 886, 473, 1172, 370, 13714, 314, 9592, 14178, 31, 267, 520, 635, 13714, 63, 13951, 26, 886, 473, 1172, 370, 13714, 314, 9592, 22483, 31, 267, 520, 635, 7267, 63, 632, 26, 314, 1022, 73, 14249, 769, 7267, 818, 267, 520, 635, 2754, 63, 495, 26, 982, 642, 2754, 1077, 2575, 2457, 367, 2005, 1059, 267, 520, 635, 4270, 63, 4891, 63, 9548, 26, 982, 4270, 8968, 282, 1242, 315, 314, 769, 1077, 288, 5847, 12679, 267, 520, 635, 2498, 63, 5938, 63, 1744, 26, 340, 642, 2725, 365, 715, 12, 13703, 12743, 461, 543, 288, 2004, 6876, 267, 408, 267, 340, 7267, 63, 632, 365, 488, 26, 288, 7267, 63, 632, 275, 8116, 14, 4859, 1075, 63, 31956, 899, 398, 291, 423, 1569, 63, 16645, 275, 488, 267, 291, 423, 2246, 63, 1733, 275, 715, 267, 291, 423, 2246, 63, 1733, 63, 875, 275, 2754, 63, 495, 267, 291, 423, 1733, 63, 1131, 275, 2754, 63, 1131, 267, 291, 423, 2384, 63, 5938, 63, 1744, 275, 2498, 63, 5938, 63, 1744, 267, 291, 423, 14564, 63, 23235, 461, 275, 984, 635, 14, 362, 63, 785, 8, 288, 3877, 12, 283, 1093, 2673, 2111, 57, 63, 10486, 1959, 23235, 461, 398, 8730, 10423, 855, 826, 721, 277, 12, 3877, 12, 2754, 63, 1650, 29, 1733, 63, 1650, 12, 2892, 8823, 63, 533, 29, 277, 14, 7515, 63, 533, 12, 2892, 13714, 63, 12781, 29, 8191, 63, 12781, 12, 2892, 13714, 63, 13951, 29, 8191, 63, 13951, 12, 2892, 7267, 63, 632, 29, 5592, 63, 632, 12, 2892, 4270, 63, 4891, 63, 9548, 29, 3157, 63, 4891, 63, 9548, 9, 398, 340, 2256, 63, 1188, 26, 288, 291, 14, 409, 63, 1188, 8, 815, 63, 1188, 9, 398, 340, 2754, 63, 495, 26, 288, 291, 14, 409, 63, 1733, 1700, 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, 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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 ]
sstone/bitcoin
test/functional/wallet_avoidreuse.py
12
16616
#!/usr/bin/env python3 # Copyright (c) 2018-2020 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the avoid_reuse and setwalletflag features.""" from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_approx, assert_equal, assert_raises_rpc_error, ) def reset_balance(node, discardaddr): '''Throw away all owned coins by the node so it gets a balance of 0.''' balance = node.getbalance(avoid_reuse=False) if balance > 0.5: node.sendtoaddress(address=discardaddr, amount=balance, subtractfeefromamount=True, avoid_reuse=False) def count_unspent(node): '''Count the unspent outputs for the given node and return various statistics''' r = { "total": { "count": 0, "sum": 0, }, "reused": { "count": 0, "sum": 0, }, } supports_reused = True for utxo in node.listunspent(minconf=0): r["total"]["count"] += 1 r["total"]["sum"] += utxo["amount"] if supports_reused and "reused" in utxo: if utxo["reused"]: r["reused"]["count"] += 1 r["reused"]["sum"] += utxo["amount"] else: supports_reused = False r["reused"]["supported"] = supports_reused return r def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None, margin=0.001): '''Make assertions about a node's unspent output statistics''' stats = count_unspent(node) if total_count is not None: assert_equal(stats["total"]["count"], total_count) if total_sum is not None: assert_approx(stats["total"]["sum"], total_sum, margin) if reused_supported is not None: assert_equal(stats["reused"]["supported"], reused_supported) if reused_count is not None: assert_equal(stats["reused"]["count"], reused_count) if reused_sum is not None: assert_approx(stats["reused"]["sum"], reused_sum, margin) def assert_balances(node, mine, margin=0.001): '''Make assertions about a node's getbalances output''' got = node.getbalances()["mine"] for k,v in mine.items(): assert_approx(got[k], v, margin) class AvoidReuseTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 # This test isn't testing txn relay/timing, so set whitelist on the # peers for instant txn relay. This speeds up the test run time 2-3x. self.extra_args = [["-whitelist=noban@127.0.0.1"]] * self.num_nodes def skip_test_if_missing_module(self): self.skip_if_no_wallet() def run_test(self): '''Set up initial chain and run tests defined below''' self.test_persistence() self.test_immutable() self.nodes[0].generate(110) self.sync_all() self.test_change_remains_change(self.nodes[1]) reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_sending_from_reused_address_without_avoid_reuse() reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_sending_from_reused_address_fails("legacy") reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_sending_from_reused_address_fails("p2sh-segwit") reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_sending_from_reused_address_fails("bech32") reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_getbalances_used() reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_full_destination_group_is_preferred() reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) self.test_all_destination_groups_are_used() def test_persistence(self): '''Test that wallet files persist the avoid_reuse flag.''' self.log.info("Test wallet files persist avoid_reuse flag") # Configure node 1 to use avoid_reuse self.nodes[1].setwalletflag('avoid_reuse') # Flags should be node1.avoid_reuse=false, node2.avoid_reuse=true assert_equal(self.nodes[0].getwalletinfo()["avoid_reuse"], False) assert_equal(self.nodes[1].getwalletinfo()["avoid_reuse"], True) self.restart_node(1) self.connect_nodes(0, 1) # Flags should still be node1.avoid_reuse=false, node2.avoid_reuse=true assert_equal(self.nodes[0].getwalletinfo()["avoid_reuse"], False) assert_equal(self.nodes[1].getwalletinfo()["avoid_reuse"], True) # Attempting to set flag to its current state should throw assert_raises_rpc_error(-8, "Wallet flag is already set to false", self.nodes[0].setwalletflag, 'avoid_reuse', False) assert_raises_rpc_error(-8, "Wallet flag is already set to true", self.nodes[1].setwalletflag, 'avoid_reuse', True) def test_immutable(self): '''Test immutable wallet flags''' self.log.info("Test immutable wallet flags") # Attempt to set the disable_private_keys flag; this should not work assert_raises_rpc_error(-8, "Wallet flag is immutable", self.nodes[1].setwalletflag, 'disable_private_keys') tempwallet = ".wallet_avoidreuse.py_test_immutable_wallet.dat" # Create a wallet with disable_private_keys set; this should work self.nodes[1].createwallet(wallet_name=tempwallet, disable_private_keys=True) w = self.nodes[1].get_wallet_rpc(tempwallet) # Attempt to unset the disable_private_keys flag; this should not work assert_raises_rpc_error(-8, "Wallet flag is immutable", w.setwalletflag, 'disable_private_keys', False) # Unload temp wallet self.nodes[1].unloadwallet(tempwallet) def test_change_remains_change(self, node): self.log.info("Test that change doesn't turn into non-change when spent") reset_balance(node, node.getnewaddress()) addr = node.getnewaddress() txid = node.sendtoaddress(addr, 1) out = node.listunspent(minconf=0, query_options={'minimumAmount': 2}) assert_equal(len(out), 1) assert_equal(out[0]['txid'], txid) changeaddr = out[0]['address'] # Make sure it's starting out as change as expected assert node.getaddressinfo(changeaddr)['ischange'] for logical_tx in node.listtransactions(): assert logical_tx.get('address') != changeaddr # Spend it reset_balance(node, node.getnewaddress()) # It should still be change assert node.getaddressinfo(changeaddr)['ischange'] for logical_tx in node.listtransactions(): assert logical_tx.get('address') != changeaddr def test_sending_from_reused_address_without_avoid_reuse(self): ''' Test the same as test_sending_from_reused_address_fails, except send the 10 BTC with the avoid_reuse flag set to false. This means the 10 BTC send should succeed, where it fails in test_sending_from_reused_address_fails. ''' self.log.info("Test sending from reused address with avoid_reuse=false") fundaddr = self.nodes[1].getnewaddress() retaddr = self.nodes[0].getnewaddress() self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) self.sync_all() # listunspent should show 1 single, unused 10 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=10, reused_supported=True, reused_count=0) # getbalances should show no used, 10 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 10}) # node 0 should not show a used entry, as it does not enable avoid_reuse assert("used" not in self.nodes[0].getbalances()["mine"]) self.nodes[1].sendtoaddress(retaddr, 5) self.nodes[0].generate(1) self.sync_all() # listunspent should show 1 single, unused 5 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=5, reused_supported=True, reused_count=0) # getbalances should show no used, 5 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) self.sync_all() # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=15, reused_count=1, reused_sum=10) # getbalances should show 10 used, 5 btc trusted assert_balances(self.nodes[1], mine={"used": 10, "trusted": 5}) self.nodes[1].sendtoaddress(address=retaddr, amount=10, avoid_reuse=False) # listunspent should show 1 total outputs (5 btc), unused assert_unspent(self.nodes[1], total_count=1, total_sum=5, reused_count=0) # getbalances should show no used, 5 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) # node 1 should now have about 5 btc left (for both cases) assert_approx(self.nodes[1].getbalance(), 5, 0.001) assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 5, 0.001) def test_sending_from_reused_address_fails(self, second_addr_type): ''' Test the simple case where [1] generates a new address A, then [0] sends 10 BTC to A. [1] spends 5 BTC from A. (leaving roughly 5 BTC useable) [0] sends 10 BTC to A again. [1] tries to spend 10 BTC (fails; dirty). [1] tries to spend 4 BTC (succeeds; change address sufficient) ''' self.log.info("Test sending from reused {} address fails".format(second_addr_type)) fundaddr = self.nodes[1].getnewaddress(label="", address_type="legacy") retaddr = self.nodes[0].getnewaddress() self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) self.sync_all() # listunspent should show 1 single, unused 10 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=10, reused_supported=True, reused_count=0) # getbalances should show no used, 10 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 10}) self.nodes[1].sendtoaddress(retaddr, 5) self.nodes[0].generate(1) self.sync_all() # listunspent should show 1 single, unused 5 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=5, reused_supported=True, reused_count=0) # getbalances should show no used, 5 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) if not self.options.descriptors: # For the second send, we transmute it to a related single-key address # to make sure it's also detected as re-use fund_spk = self.nodes[0].getaddressinfo(fundaddr)["scriptPubKey"] fund_decoded = self.nodes[0].decodescript(fund_spk) if second_addr_type == "p2sh-segwit": new_fundaddr = fund_decoded["segwit"]["p2sh-segwit"] elif second_addr_type == "bech32": new_fundaddr = fund_decoded["segwit"]["address"] else: new_fundaddr = fundaddr assert_equal(second_addr_type, "legacy") self.nodes[0].sendtoaddress(new_fundaddr, 10) self.nodes[0].generate(1) self.sync_all() # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=15, reused_count=1, reused_sum=10) # getbalances should show 10 used, 5 btc trusted assert_balances(self.nodes[1], mine={"used": 10, "trusted": 5}) # node 1 should now have a balance of 5 (no dirty) or 15 (including dirty) assert_approx(self.nodes[1].getbalance(), 5, 0.001) assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 15, 0.001) assert_raises_rpc_error(-6, "Insufficient funds", self.nodes[1].sendtoaddress, retaddr, 10) self.nodes[1].sendtoaddress(retaddr, 4) # listunspent should show 2 total outputs (1, 10 btc), one unused (1), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=11, reused_count=1, reused_sum=10) # getbalances should show 10 used, 1 btc trusted assert_balances(self.nodes[1], mine={"used": 10, "trusted": 1}) # node 1 should now have about 1 btc left (no dirty) and 11 (including dirty) assert_approx(self.nodes[1].getbalance(), 1, 0.001) assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 11, 0.001) def test_getbalances_used(self): ''' getbalances and listunspent should pick up on reused addresses immediately, even for address reusing outputs created before the first transaction was spending from that address ''' self.log.info("Test getbalances used category") # node under test should be completely empty assert_equal(self.nodes[1].getbalance(avoid_reuse=False), 0) new_addr = self.nodes[1].getnewaddress() ret_addr = self.nodes[0].getnewaddress() # send multiple transactions, reusing one address for _ in range(101): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) self.sync_all() # send transaction that should not use all the available outputs # per the current coin selection algorithm self.nodes[1].sendtoaddress(ret_addr, 5) # getbalances and listunspent should show the remaining outputs # in the reused address as used/reused assert_unspent(self.nodes[1], total_count=2, total_sum=96, reused_count=1, reused_sum=1, margin=0.01) assert_balances(self.nodes[1], mine={"used": 1, "trusted": 95}, margin=0.01) def test_full_destination_group_is_preferred(self): ''' Test the case where [1] only has 101 outputs of 1 BTC in the same reused address and tries to send a small payment of 0.5 BTC. The wallet should use 100 outputs from the reused address as inputs and not a single 1 BTC input, in order to join several outputs from the reused address. ''' self.log.info("Test that full destination groups are preferred in coin selection") # Node under test should be empty assert_equal(self.nodes[1].getbalance(avoid_reuse=False), 0) new_addr = self.nodes[1].getnewaddress() ret_addr = self.nodes[0].getnewaddress() # Send 101 outputs of 1 BTC to the same, reused address in the wallet for _ in range(101): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) self.sync_all() # Sending a transaction that is smaller than each one of the # available outputs txid = self.nodes[1].sendtoaddress(address=ret_addr, amount=0.5) inputs = self.nodes[1].getrawtransaction(txid, 1)["vin"] # The transaction should use 100 inputs exactly assert_equal(len(inputs), 100) def test_all_destination_groups_are_used(self): ''' Test the case where [1] only has 202 outputs of 1 BTC in the same reused address and tries to send a payment of 200.5 BTC. The wallet should use all 202 outputs from the reused address as inputs. ''' self.log.info("Test that all destination groups are used") # Node under test should be empty assert_equal(self.nodes[1].getbalance(avoid_reuse=False), 0) new_addr = self.nodes[1].getnewaddress() ret_addr = self.nodes[0].getnewaddress() # Send 202 outputs of 1 BTC to the same, reused address in the wallet for _ in range(202): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) self.sync_all() # Sending a transaction that needs to use the full groups # of 100 inputs but also the incomplete group of 2 inputs. txid = self.nodes[1].sendtoaddress(address=ret_addr, amount=200.5) inputs = self.nodes[1].getrawtransaction(txid, 1)["vin"] # The transaction should use 202 inputs exactly assert_equal(len(inputs), 202) if __name__ == '__main__': AvoidReuseTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 14894, 13, 13934, 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, 624, 774, 314, 5126, 63, 15712, 436, 663, 13892, 4173, 4534, 1041, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 334, 272, 702, 63, 16815, 12, 272, 702, 63, 1452, 12, 272, 702, 63, 3536, 63, 4354, 63, 705, 12, 199, 9, 199, 199, 318, 5305, 63, 7358, 8, 932, 12, 16895, 2697, 304, 272, 1449, 2719, 1143, 13437, 1006, 23191, 512, 3617, 701, 314, 1031, 880, 652, 7545, 282, 14094, 402, 378, 10595, 272, 14094, 275, 1031, 14, 29213, 8, 27403, 63, 15712, 29, 797, 9, 272, 340, 14094, 690, 378, 14, 21, 26, 267, 1031, 14, 23267, 1562, 8, 1562, 29, 14394, 2697, 12, 5982, 29, 7358, 12, 24129, 771, 2829, 293, 391, 3956, 29, 549, 12, 5126, 63, 15712, 29, 797, 9, 199, 199, 318, 2338, 63, 324, 19435, 8, 932, 304, 272, 1449, 2353, 314, 625, 19435, 4704, 367, 314, 1627, 1031, 436, 372, 7750, 11076, 2344, 272, 519, 275, 469, 267, 298, 2923, 582, 469, 288, 298, 835, 582, 378, 12, 288, 298, 1838, 582, 378, 12, 267, 1660, 267, 298, 264, 2972, 582, 469, 288, 298, 835, 582, 378, 12, 288, 298, 1838, 582, 378, 12, 267, 1660, 272, 789, 272, 5171, 63, 264, 2972, 275, 715, 272, 367, 11430, 15987, 315, 1031, 14, 513, 324, 19435, 8, 827, 2190, 29, 16, 304, 267, 519, 905, 2923, 6611, 835, 937, 847, 413, 267, 519, 905, 2923, 6611, 1838, 937, 847, 11430, 15987, 905, 4606, 937, 267, 340, 5171, 63, 264, 2972, 436, 298, 264, 2972, 2, 315, 11430, 15987, 26, 288, 340, 11430, 15987, 905, 264, 2972, 6229, 355, 519, 905, 264, 2972, 6611, 835, 937, 847, 413, 355, 519, 905, 264, 2972, 6611, 1838, 937, 847, 11430, 15987, 905, 4606, 937, 267, 587, 26, 288, 5171, 63, 264, 2972, 275, 756, 272, 519, 905, 264, 2972, 6611, 4946, 937, 275, 5171, 63, 264, 2972, 272, 372, 519, 199, 199, 318, 702, 63, 324, 19435, 8, 932, 12, 3141, 63, 835, 29, 403, 12, 3141, 63, 1838, 29, 403, 12, 24826, 63, 4946, 29, 403, 12, 24826, 63, 835, 29, 403, 12, 24826, 63, 1838, 29, 403, 12, 11042, 29, 16, 14, 4587, 304, 272, 1449, 5483, 22835, 3595, 282, 1031, 1159, 625, 19435, 1072, 11076, 2344, 272, 5020, 275, 2338, 63, 324, 19435, 8, 932, 9, 272, 340, 3141, 63, 835, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 2923, 6611, 835, 2255, 3141, 63, 835, 9, 272, 340, 3141, 63, 1838, 365, 440, 488, 26, 267, 702, 63, 16815, 8, 3200, 905, 2923, 6611, 1838, 2255, 3141, 63, 1838, 12, 11042, 9, 272, 340, 24826, 63, 4946, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 264, 2972, 6611, 4946, 2255, 24826, 63, 4946, 9, 272, 340, 24826, 63, 835, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 264, 2972, 6611, 835, 2255, 24826, 63, 835, 9, 272, 340, 24826, 63, 1838, 365, 440, 488, 26, 267, 702, 63, 16815, 8, 3200, 905, 264, 2972, 6611, 1838, 2255, 24826, 63, 1838, 12, 11042, 9, 199, 199, 318, 702, 63, 7358, 83, 8, 932, 12, 30820, 12, 11042, 29, 16, 14, 4587, 304, 272, 1449, 5483, 22835, 3595, 282, 1031, 1159, 664, 7358, 83, 1072, 2344, 272, 4788, 275, 1031, 14, 29213, 83, 22957, 19153, 937, 272, 367, 1022, 12, 86, 315, 30820, 14, 1744, 837, 267, 702, 63, 16815, 8, 7808, 59, 75, 467, 373, 12, 11042, 9, 199, 199, 533, 19503, 497, 1180, 774, 8, 4734, 9061, 26203, 304, 339, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 1507, 63, 2415, 275, 499, 267, 327, 961, 511, 5712, 1133, 5343, 23883, 25931, 15, 14639, 12, 880, 663, 22671, 641, 314, 267, 327, 28166, 367, 2727, 867, 23883, 25931, 14, 961, 8112, 83, 1536, 314, 511, 1255, 900, 499, 13, 19, 88, 14, 267, 291, 14, 2911, 63, 589, 275, 24212, 13, 14189, 29, 889, 13206, 32, 4195, 14, 16, 14, 16, 14, 17, 15261, 627, 291, 14, 1507, 63, 2415, 339, 347, 3372, 63, 396, 63, 692, 63, 4752, 63, 578, 8, 277, 304, 267, 291, 14, 2759, 63, 692, 63, 889, 63, 13892, 342, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1449, 1084, 1536, 2536, 6036, 436, 1255, 2295, 3247, 5084, 2344, 398, 291, 14, 396, 63, 24854, 342, 267, 291, 14, 396, 63, 17836, 342, 398, 291, 14, 2415, 59, 16, 1055, 4208, 8, 6019, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 291, 14, 396, 63, 1461, 63, 8902, 83, 63, 1461, 8, 277, 14, 2415, 59, 17, 566, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 7395, 63, 27403, 63, 15712, 342, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 10000, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 80, 18, 609, 13, 8359, 2503, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 1235, 335, 708, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 29213, 83, 63, 2972, 342, 267, 5305, 63, 7358 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 14894, 13, 13934, 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, 624, 774, 314, 5126, 63, 15712, 436, 663, 13892, 4173, 4534, 1041, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 334, 272, 702, 63, 16815, 12, 272, 702, 63, 1452, 12, 272, 702, 63, 3536, 63, 4354, 63, 705, 12, 199, 9, 199, 199, 318, 5305, 63, 7358, 8, 932, 12, 16895, 2697, 304, 272, 1449, 2719, 1143, 13437, 1006, 23191, 512, 3617, 701, 314, 1031, 880, 652, 7545, 282, 14094, 402, 378, 10595, 272, 14094, 275, 1031, 14, 29213, 8, 27403, 63, 15712, 29, 797, 9, 272, 340, 14094, 690, 378, 14, 21, 26, 267, 1031, 14, 23267, 1562, 8, 1562, 29, 14394, 2697, 12, 5982, 29, 7358, 12, 24129, 771, 2829, 293, 391, 3956, 29, 549, 12, 5126, 63, 15712, 29, 797, 9, 199, 199, 318, 2338, 63, 324, 19435, 8, 932, 304, 272, 1449, 2353, 314, 625, 19435, 4704, 367, 314, 1627, 1031, 436, 372, 7750, 11076, 2344, 272, 519, 275, 469, 267, 298, 2923, 582, 469, 288, 298, 835, 582, 378, 12, 288, 298, 1838, 582, 378, 12, 267, 1660, 267, 298, 264, 2972, 582, 469, 288, 298, 835, 582, 378, 12, 288, 298, 1838, 582, 378, 12, 267, 1660, 272, 789, 272, 5171, 63, 264, 2972, 275, 715, 272, 367, 11430, 15987, 315, 1031, 14, 513, 324, 19435, 8, 827, 2190, 29, 16, 304, 267, 519, 905, 2923, 6611, 835, 937, 847, 413, 267, 519, 905, 2923, 6611, 1838, 937, 847, 11430, 15987, 905, 4606, 937, 267, 340, 5171, 63, 264, 2972, 436, 298, 264, 2972, 2, 315, 11430, 15987, 26, 288, 340, 11430, 15987, 905, 264, 2972, 6229, 355, 519, 905, 264, 2972, 6611, 835, 937, 847, 413, 355, 519, 905, 264, 2972, 6611, 1838, 937, 847, 11430, 15987, 905, 4606, 937, 267, 587, 26, 288, 5171, 63, 264, 2972, 275, 756, 272, 519, 905, 264, 2972, 6611, 4946, 937, 275, 5171, 63, 264, 2972, 272, 372, 519, 199, 199, 318, 702, 63, 324, 19435, 8, 932, 12, 3141, 63, 835, 29, 403, 12, 3141, 63, 1838, 29, 403, 12, 24826, 63, 4946, 29, 403, 12, 24826, 63, 835, 29, 403, 12, 24826, 63, 1838, 29, 403, 12, 11042, 29, 16, 14, 4587, 304, 272, 1449, 5483, 22835, 3595, 282, 1031, 1159, 625, 19435, 1072, 11076, 2344, 272, 5020, 275, 2338, 63, 324, 19435, 8, 932, 9, 272, 340, 3141, 63, 835, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 2923, 6611, 835, 2255, 3141, 63, 835, 9, 272, 340, 3141, 63, 1838, 365, 440, 488, 26, 267, 702, 63, 16815, 8, 3200, 905, 2923, 6611, 1838, 2255, 3141, 63, 1838, 12, 11042, 9, 272, 340, 24826, 63, 4946, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 264, 2972, 6611, 4946, 2255, 24826, 63, 4946, 9, 272, 340, 24826, 63, 835, 365, 440, 488, 26, 267, 702, 63, 1452, 8, 3200, 905, 264, 2972, 6611, 835, 2255, 24826, 63, 835, 9, 272, 340, 24826, 63, 1838, 365, 440, 488, 26, 267, 702, 63, 16815, 8, 3200, 905, 264, 2972, 6611, 1838, 2255, 24826, 63, 1838, 12, 11042, 9, 199, 199, 318, 702, 63, 7358, 83, 8, 932, 12, 30820, 12, 11042, 29, 16, 14, 4587, 304, 272, 1449, 5483, 22835, 3595, 282, 1031, 1159, 664, 7358, 83, 1072, 2344, 272, 4788, 275, 1031, 14, 29213, 83, 22957, 19153, 937, 272, 367, 1022, 12, 86, 315, 30820, 14, 1744, 837, 267, 702, 63, 16815, 8, 7808, 59, 75, 467, 373, 12, 11042, 9, 199, 199, 533, 19503, 497, 1180, 774, 8, 4734, 9061, 26203, 304, 339, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 1507, 63, 2415, 275, 499, 267, 327, 961, 511, 5712, 1133, 5343, 23883, 25931, 15, 14639, 12, 880, 663, 22671, 641, 314, 267, 327, 28166, 367, 2727, 867, 23883, 25931, 14, 961, 8112, 83, 1536, 314, 511, 1255, 900, 499, 13, 19, 88, 14, 267, 291, 14, 2911, 63, 589, 275, 24212, 13, 14189, 29, 889, 13206, 32, 4195, 14, 16, 14, 16, 14, 17, 15261, 627, 291, 14, 1507, 63, 2415, 339, 347, 3372, 63, 396, 63, 692, 63, 4752, 63, 578, 8, 277, 304, 267, 291, 14, 2759, 63, 692, 63, 889, 63, 13892, 342, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1449, 1084, 1536, 2536, 6036, 436, 1255, 2295, 3247, 5084, 2344, 398, 291, 14, 396, 63, 24854, 342, 267, 291, 14, 396, 63, 17836, 342, 398, 291, 14, 2415, 59, 16, 1055, 4208, 8, 6019, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 291, 14, 396, 63, 1461, 63, 8902, 83, 63, 1461, 8, 277, 14, 2415, 59, 17, 566, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 7395, 63, 27403, 63, 15712, 342, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 10000, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 80, 18, 609, 13, 8359, 2503, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 24450, 63, 504, 63, 264, 2972, 63, 1562, 63, 15762, 480, 1235, 335, 708, 531, 267, 5305, 63, 7358, 8, 277, 14, 2415, 59, 17, 467, 291, 14, 2415, 59, 16, 1055, 21102, 1012, 267, 291, 14, 396, 63, 29213, 83, 63, 2972, 342, 267, 5305, 63, 7358, 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 ]
skoppisetty/secret-bugfixes
lib/sqlalchemy/orm/query.py
3
130048
# orm/query.py # Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """The Query class and support. Defines the :class:`.Query` class, the central construct used by the ORM to construct database queries. The :class:`.Query` class should not be confused with the :class:`.Select` class, which defines database SELECT operations at the SQL (non-ORM) level. ``Query`` differs from ``Select`` in that it returns ORM-mapped objects and interacts with an ORM session, whereas the ``Select`` construct interacts directly with the database to return iterable result sets. """ from itertools import chain from operator import itemgetter from sqlalchemy import sql, util, log, schema from sqlalchemy import exc as sa_exc from sqlalchemy.orm import exc as orm_exc from sqlalchemy.sql import util as sql_util from sqlalchemy.sql import expression, visitors, operators from sqlalchemy.orm import ( attributes, interfaces, mapper, object_mapper, evaluator, ) from sqlalchemy.orm.util import ( AliasedClass, ORMAdapter, _entity_descriptor, _entity_info, _is_aliased_class, _is_mapped_class, _orm_columns, _orm_selectable, join as orm_join,with_parent, _attr_as_key, aliased ) __all__ = ['Query', 'QueryContext', 'aliased'] def _generative(*assertions): """Mark a method as generative.""" @util.decorator def generate(fn, *args, **kw): self = args[0]._clone() for assertion in assertions: assertion(self, fn.func_name) fn(self, *args[1:], **kw) return self return generate class Query(object): """ORM-level SQL construction object. :class:`.Query` is the source of all SELECT statements generated by the ORM, both those formulated by end-user query operations as well as by high level internal operations such as related collection loading. It features a generative interface whereby successive calls return a new :class:`.Query` object, a copy of the former with additional criteria and options associated with it. :class:`.Query` objects are normally initially generated using the :meth:`~.Session.query` method of :class:`.Session`. For a full walkthrough of :class:`.Query` usage, see the :ref:`ormtutorial_toplevel`. """ _enable_eagerloads = True _enable_assertions = True _with_labels = False _criterion = None _yield_per = None _lockmode = None _order_by = False _group_by = False _having = None _distinct = False _prefixes = None _offset = None _limit = None _statement = None _correlate = frozenset() _populate_existing = False _invoke_all_eagers = True _version_check = False _autoflush = True _current_path = () _only_load_props = None _refresh_state = None _from_obj = () _join_entities = () _select_from_entity = None _filter_aliases = None _from_obj_alias = None _joinpath = _joinpoint = util.immutabledict() _execution_options = util.immutabledict() _params = util.immutabledict() _attributes = util.immutabledict() _with_options = () _with_hints = () _enable_single_crit = True def __init__(self, entities, session=None): self.session = session self._polymorphic_adapters = {} self._set_entities(entities) def _set_entities(self, entities, entity_wrapper=None): if entity_wrapper is None: entity_wrapper = _QueryEntity self._entities = [] for ent in util.to_list(entities): entity_wrapper(self, ent) self._setup_aliasizers(self._entities) def _setup_aliasizers(self, entities): if hasattr(self, '_mapper_adapter_map'): # usually safe to share a single map, but copying to prevent # subtle leaks if end-user is reusing base query with arbitrary # number of aliased() objects self._mapper_adapter_map = d = self._mapper_adapter_map.copy() else: self._mapper_adapter_map = d = {} for ent in entities: for entity in ent.entities: if entity not in d: mapper, selectable, is_aliased_class = \ _entity_info(entity) if not is_aliased_class and mapper.with_polymorphic: with_polymorphic = mapper._with_polymorphic_mappers if mapper.mapped_table not in \ self._polymorphic_adapters: self._mapper_loads_polymorphically_with(mapper, sql_util.ColumnAdapter( selectable, mapper._equivalent_columns)) adapter = None elif is_aliased_class: adapter = sql_util.ColumnAdapter( selectable, mapper._equivalent_columns) with_polymorphic = None else: with_polymorphic = adapter = None d[entity] = (mapper, adapter, selectable, is_aliased_class, with_polymorphic) ent.setup_entity(entity, *d[entity]) def _mapper_loads_polymorphically_with(self, mapper, adapter): for m2 in mapper._with_polymorphic_mappers: self._polymorphic_adapters[m2] = adapter for m in m2.iterate_to_root(): self._polymorphic_adapters[m.mapped_table] = \ self._polymorphic_adapters[m.local_table] = \ adapter def _set_select_from(self, *obj): fa = [] for from_obj in obj: if isinstance(from_obj, expression._SelectBase): from_obj = from_obj.alias() fa.append(from_obj) self._from_obj = tuple(fa) if len(self._from_obj) == 1 and \ isinstance(self._from_obj[0], expression.Alias): equivs = self.__all_equivs() self._from_obj_alias = sql_util.ColumnAdapter( self._from_obj[0], equivs) def _reset_polymorphic_adapter(self, mapper): for m2 in mapper._with_polymorphic_mappers: self._polymorphic_adapters.pop(m2, None) for m in m2.iterate_to_root(): self._polymorphic_adapters.pop(m.mapped_table, None) self._polymorphic_adapters.pop(m.local_table, None) def __adapt_polymorphic_element(self, element): if isinstance(element, expression.FromClause): search = element elif hasattr(element, 'table'): search = element.table else: search = None if search is not None: alias = self._polymorphic_adapters.get(search, None) if alias: return alias.adapt_clause(element) def _adapt_col_list(self, cols): return [ self._adapt_clause( expression._literal_as_text(o), True, True) for o in cols ] @_generative() def _adapt_all_clauses(self): self._orm_only_adapt = False def _adapt_clause(self, clause, as_filter, orm_only): """Adapt incoming clauses to transformations which have been applied within this query.""" adapters = [] # do we adapt all expression elements or only those # tagged as 'ORM' constructs ? orm_only = getattr(self, '_orm_only_adapt', orm_only) if as_filter and self._filter_aliases: for fa in self._filter_aliases._visitor_iterator: adapters.append( ( orm_only, fa.replace ) ) if self._from_obj_alias: # for the "from obj" alias, apply extra rule to the # 'ORM only' check, if this query were generated from a # subquery of itself, i.e. _from_selectable(), apply adaption # to all SQL constructs. adapters.append( ( getattr(self, '_orm_only_from_obj_alias', orm_only), self._from_obj_alias.replace ) ) if self._polymorphic_adapters: adapters.append( ( orm_only, self.__adapt_polymorphic_element ) ) if not adapters: return clause def replace(elem): for _orm_only, adapter in adapters: # if 'orm only', look for ORM annotations # in the element before adapting. if not _orm_only or \ '_orm_adapt' in elem._annotations or \ "parententity" in elem._annotations: e = adapter(elem) if e is not None: return e return visitors.replacement_traverse( clause, {}, replace ) def _entity_zero(self): return self._entities[0] def _mapper_zero(self): return self._select_from_entity or \ self._entity_zero().entity_zero @property def _mapper_entities(self): # TODO: this is wrong, its hardcoded to "primary entity" when # for the case of __all_equivs() it should not be # the name of this accessor is wrong too for ent in self._entities: if hasattr(ent, 'primary_entity'): yield ent def _joinpoint_zero(self): return self._joinpoint.get( '_joinpoint_entity', self._mapper_zero() ) def _mapper_zero_or_none(self): if not getattr(self._entities[0], 'primary_entity', False): return None return self._entities[0].mapper def _only_mapper_zero(self, rationale=None): if len(self._entities) > 1: raise sa_exc.InvalidRequestError( rationale or "This operation requires a Query against a single mapper." ) return self._mapper_zero() def _only_full_mapper_zero(self, methname): if len(self._entities) != 1: raise sa_exc.InvalidRequestError( "%s() can only be used against " "a single mapped class." % methname) entity = self._entity_zero() if not hasattr(entity, 'primary_entity'): raise sa_exc.InvalidRequestError( "%s() can only be used against " "a single mapped class." % methname) return entity.entity_zero def _only_entity_zero(self, rationale=None): if len(self._entities) > 1: raise sa_exc.InvalidRequestError( rationale or "This operation requires a Query against a single mapper." ) return self._entity_zero() def __all_equivs(self): equivs = {} for ent in self._mapper_entities: equivs.update(ent.mapper._equivalent_columns) return equivs def _get_condition(self): self._order_by = self._distinct = False return self._no_criterion_condition("get") def _no_criterion_condition(self, meth): if not self._enable_assertions: return if self._criterion is not None or \ self._statement is not None or self._from_obj or \ self._limit is not None or self._offset is not None or \ self._group_by or self._order_by or self._distinct: raise sa_exc.InvalidRequestError( "Query.%s() being called on a " "Query with existing criterion. " % meth) self._from_obj = () self._statement = self._criterion = None self._order_by = self._group_by = self._distinct = False def _no_clauseelement_condition(self, meth): if not self._enable_assertions: return if self._order_by: raise sa_exc.InvalidRequestError( "Query.%s() being called on a " "Query with existing criterion. " % meth) self._no_criterion_condition(meth) def _no_statement_condition(self, meth): if not self._enable_assertions: return if self._statement is not None: raise sa_exc.InvalidRequestError( ("Query.%s() being called on a Query with an existing full " "statement - can't apply criterion.") % meth) def _no_limit_offset(self, meth): if not self._enable_assertions: return if self._limit is not None or self._offset is not None: raise sa_exc.InvalidRequestError( "Query.%s() being called on a Query which already has LIMIT " "or OFFSET applied. To modify the row-limited results of a " " Query, call from_self() first. " "Otherwise, call %s() before limit() or offset() are applied." % (meth, meth) ) def _no_select_modifiers(self, meth): if not self._enable_assertions: return for attr, methname, notset in ( ('_limit', 'limit()', None), ('_offset', 'offset()', None), ('_order_by', 'order_by()', False), ('_group_by', 'group_by()', False), ('_distinct', 'distinct()', False), ): if getattr(self, attr) is not notset: raise sa_exc.InvalidRequestError( "Can't call Query.%s() when %s has been called" % (meth, methname) ) def _get_options(self, populate_existing=None, version_check=None, only_load_props=None, refresh_state=None): if populate_existing: self._populate_existing = populate_existing if version_check: self._version_check = version_check if refresh_state: self._refresh_state = refresh_state if only_load_props: self._only_load_props = set(only_load_props) return self def _clone(self): cls = self.__class__ q = cls.__new__(cls) q.__dict__ = self.__dict__.copy() return q @property def statement(self): """The full SELECT statement represented by this Query. The statement by default will not have disambiguating labels applied to the construct unless with_labels(True) is called first. """ stmt = self._compile_context(labels=self._with_labels).\ statement if self._params: stmt = stmt.params(self._params) # TODO: there's no tests covering effects of # the annotation not being there return stmt._annotate({'no_replacement_traverse': True}) def subquery(self, name=None): """return the full SELECT statement represented by this :class:`.Query`, embedded within an :class:`.Alias`. Eager JOIN generation within the query is disabled. The statement will not have disambiguating labels applied to the list of selected columns unless the :meth:`.Query.with_labels` method is used to generate a new :class:`.Query` with the option enabled. :param name: string name to be assigned as the alias; this is passed through to :meth:`.FromClause.alias`. If ``None``, a name will be deterministically generated at compile time. """ return self.enable_eagerloads(False).statement.alias(name=name) def cte(self, name=None, recursive=False): """Return the full SELECT statement represented by this :class:`.Query` represented as a common table expression (CTE). The :meth:`.Query.cte` method is new in 0.7.6. Parameters and usage are the same as those of the :meth:`._SelectBase.cte` method; see that method for further details. Here is the `Postgresql WITH RECURSIVE example <http://www.postgresql.org/docs/8.4/static/queries-with.html>`_. Note that, in this example, the ``included_parts`` cte and the ``incl_alias`` alias of it are Core selectables, which means the columns are accessed via the ``.c.`` attribute. The ``parts_alias`` object is an :func:`.orm.aliased` instance of the ``Part`` entity, so column-mapped attributes are available directly:: from sqlalchemy.orm import aliased class Part(Base): __tablename__ = 'part' part = Column(String, primary_key=True) sub_part = Column(String, primary_key=True) quantity = Column(Integer) included_parts = session.query( Part.sub_part, Part.part, Part.quantity).\\ filter(Part.part=="our part").\\ cte(name="included_parts", recursive=True) incl_alias = aliased(included_parts, name="pr") parts_alias = aliased(Part, name="p") included_parts = included_parts.union_all( session.query( parts_alias.part, parts_alias.sub_part, parts_alias.quantity).\\ filter(parts_alias.part==incl_alias.c.sub_part) ) q = session.query( included_parts.c.sub_part, func.sum(included_parts.c.quantity).label('total_quantity') ).\\ group_by(included_parts.c.sub_part) See also: :meth:`._SelectBase.cte` """ return self.enable_eagerloads(False).statement.cte(name=name, recursive=recursive) def label(self, name): """Return the full SELECT statement represented by this :class:`.Query`, converted to a scalar subquery with a label of the given name. Analogous to :meth:`sqlalchemy.sql._SelectBaseMixin.label`. New in 0.6.5. """ return self.enable_eagerloads(False).statement.label(name) def as_scalar(self): """Return the full SELECT statement represented by this :class:`.Query`, converted to a scalar subquery. Analogous to :meth:`sqlalchemy.sql._SelectBaseMixin.as_scalar`. New in 0.6.5. """ return self.enable_eagerloads(False).statement.as_scalar() def __clause_element__(self): return self.enable_eagerloads(False).with_labels().statement @_generative() def enable_eagerloads(self, value): """Control whether or not eager joins and subqueries are rendered. When set to False, the returned Query will not render eager joins regardless of :func:`~sqlalchemy.orm.joinedload`, :func:`~sqlalchemy.orm.subqueryload` options or mapper-level ``lazy='joined'``/``lazy='subquery'`` configurations. This is used primarily when nesting the Query's statement into a subquery or other selectable. """ self._enable_eagerloads = value @_generative() def with_labels(self): """Apply column labels to the return value of Query.statement. Indicates that this Query's `statement` accessor should return a SELECT statement that applies labels to all columns in the form <tablename>_<columnname>; this is commonly used to disambiguate columns from multiple tables which have the same name. When the `Query` actually issues SQL to load rows, it always uses column labeling. """ self._with_labels = True @_generative() def enable_assertions(self, value): """Control whether assertions are generated. When set to False, the returned Query will not assert its state before certain operations, including that LIMIT/OFFSET has not been applied when filter() is called, no criterion exists when get() is called, and no "from_statement()" exists when filter()/order_by()/group_by() etc. is called. This more permissive mode is used by custom Query subclasses to specify criterion or other modifiers outside of the usual usage patterns. Care should be taken to ensure that the usage pattern is even possible. A statement applied by from_statement() will override any criterion set by filter() or order_by(), for example. """ self._enable_assertions = value @property def whereclause(self): """A readonly attribute which returns the current WHERE criterion for this Query. This returned value is a SQL expression construct, or ``None`` if no criterion has been established. """ return self._criterion @_generative() def _with_current_path(self, path): """indicate that this query applies to objects loaded within a certain path. Used by deferred loaders (see strategies.py) which transfer query options from an originating query to a newly generated query intended for the deferred load. """ self._current_path = path @_generative(_no_clauseelement_condition) def with_polymorphic(self, cls_or_mappers, selectable=None, discriminator=None): """Load columns for descendant mappers of this Query's mapper. Using this method will ensure that each descendant mapper's tables are included in the FROM clause, and will allow filter() criterion to be used against those tables. The resulting instances will also have those columns already loaded so that no "post fetch" of those columns will be required. :param cls_or_mappers: a single class or mapper, or list of class/mappers, which inherit from this Query's mapper. Alternatively, it may also be the string ``'*'``, in which case all descending mappers will be added to the FROM clause. :param selectable: a table or select() statement that will be used in place of the generated FROM clause. This argument is required if any of the desired mappers use concrete table inheritance, since SQLAlchemy currently cannot generate UNIONs among tables automatically. If used, the ``selectable`` argument must represent the full set of tables and columns mapped by every desired mapper. Otherwise, the unaccounted mapped columns will result in their table being appended directly to the FROM clause which will usually lead to incorrect results. :param discriminator: a column to be used as the "discriminator" column for the given selectable. If not given, the polymorphic_on attribute of the mapper will be used, if any. This is useful for mappers that don't have polymorphic loading behavior by default, such as concrete table mappers. """ if not getattr(self._entities[0], 'primary_entity', False): raise sa_exc.InvalidRequestError( "No primary mapper set up for this Query.") entity = self._entities[0]._clone() self._entities = [entity] + self._entities[1:] entity.set_with_polymorphic(self, cls_or_mappers, selectable=selectable, discriminator=discriminator) @_generative() def yield_per(self, count): """Yield only ``count`` rows at a time. WARNING: use this method with caution; if the same instance is present in more than one batch of rows, end-user changes to attributes will be overwritten. In particular, it's usually impossible to use this setting with eagerly loaded collections (i.e. any lazy='joined' or 'subquery') since those collections will be cleared for a new load when encountered in a subsequent result batch. In the case of 'subquery' loading, the full result for all rows is fetched which generally defeats the purpose of :meth:`~sqlalchemy.orm.query.Query.yield_per`. Also note that many DBAPIs do not "stream" results, pre-buffering all rows before making them available, including mysql-python and psycopg2. :meth:`~sqlalchemy.orm.query.Query.yield_per` will also set the ``stream_results`` execution option to ``True``, which currently is only understood by psycopg2 and causes server side cursors to be used. """ self._yield_per = count self._execution_options = self._execution_options.copy() self._execution_options['stream_results'] = True def get(self, ident): """Return an instance based on the given primary key identifier, or ``None`` if not found. E.g.:: my_user = session.query(User).get(5) some_object = session.query(VersionedFoo).get((5, 10)) :meth:`~.Query.get` is special in that it provides direct access to the identity map of the owning :class:`.Session`. If the given primary key identifier is present in the local identity map, the object is returned directly from this collection and no SQL is emitted, unless the object has been marked fully expired. If not present, a SELECT is performed in order to locate the object. :meth:`~.Query.get` also will perform a check if the object is present in the identity map and marked as expired - a SELECT is emitted to refresh the object as well as to ensure that the row is still present. If not, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. :meth:`~.Query.get` is only used to return a single mapped instance, not multiple instances or individual column constructs, and strictly on a single primary key value. The originating :class:`.Query` must be constructed in this way, i.e. against a single mapped entity, with no additional filtering criterion. Loading options via :meth:`~.Query.options` may be applied however, and will be used if the object is not yet locally present. A lazy-loading, many-to-one attribute configured by :func:`.relationship`, using a simple foreign-key-to-primary-key criterion, will also use an operation equivalent to :meth:`~.Query.get` in order to retrieve the target value from the local identity map before querying the database. See :ref:`loading_toplevel` for further details on relationship loading. :param ident: A scalar or tuple value representing the primary key. For a composite primary key, the order of identifiers corresponds in most cases to that of the mapped :class:`.Table` object's primary key columns. For a :func:`.mapper` that was given the ``primary key`` argument during construction, the order of identifiers corresponds to the elements present in this collection. :return: The object instance, or ``None``. """ # convert composite types to individual args if hasattr(ident, '__composite_values__'): ident = ident.__composite_values__() ident = util.to_list(ident) mapper = self._only_full_mapper_zero("get") if len(ident) != len(mapper.primary_key): raise sa_exc.InvalidRequestError( "Incorrect number of values in identifier to formulate " "primary key for query.get(); primary key columns are %s" % ','.join("'%s'" % c for c in mapper.primary_key)) key = mapper.identity_key_from_primary_key(ident) if not self._populate_existing and \ not mapper.always_refresh and \ self._lockmode is None: instance = self._get_from_identity(self.session, key, False) if instance is not None: # reject calls for id in identity map but class # mismatch. if not issubclass(instance.__class__, mapper.class_): return None return instance return self._load_on_ident(key) @_generative() def correlate(self, *args): """Return a :class:`.Query` construct which will correlate the given FROM clauses to that of an enclosing :class:`.Query` or :func:`~.expression.select`. The method here accepts mapped classes, :func:`.aliased` constructs, and :func:`.mapper` constructs as arguments, which are resolved into expression constructs, in addition to appropriate expression constructs. The correlation arguments are ultimately passed to :meth:`.Select.correlate` after coercion to expression constructs. The correlation arguments take effect in such cases as when :meth:`.Query.from_self` is used, or when a subquery as returned by :meth:`.Query.subquery` is embedded in another :func:`~.expression.select` construct. """ self._correlate = self._correlate.union( _orm_selectable(s) for s in args) @_generative() def autoflush(self, setting): """Return a Query with a specific 'autoflush' setting. Note that a Session with autoflush=False will not autoflush, even if this flag is set to True at the Query level. Therefore this flag is usually used only to disable autoflush for a specific Query. """ self._autoflush = setting @_generative() def populate_existing(self): """Return a :class:`.Query` that will expire and refresh all instances as they are loaded, or reused from the current :class:`.Session`. :meth:`.populate_existing` does not improve behavior when the ORM is used normally - the :class:`.Session` object's usual behavior of maintaining a transaction and expiring all attributes after rollback or commit handles object state automatically. This method is not intended for general use. """ self._populate_existing = True @_generative() def _with_invoke_all_eagers(self, value): """Set the 'invoke all eagers' flag which causes joined- and subquery loaders to traverse into already-loaded related objects and collections. Default is that of :attr:`.Query._invoke_all_eagers`. """ self._invoke_all_eagers = value def with_parent(self, instance, property=None): """Add filtering criterion that relates the given instance to a child object or collection, using its attribute state as well as an established :func:`.relationship()` configuration. The method uses the :func:`.with_parent` function to generate the clause, the result of which is passed to :meth:`.Query.filter`. Parameters are the same as :func:`.with_parent`, with the exception that the given property can be None, in which case a search is performed against this :class:`.Query` object's target mapper. """ if property is None: from sqlalchemy.orm import properties mapper = object_mapper(instance) for prop in mapper.iterate_properties: if isinstance(prop, properties.PropertyLoader) and \ prop.mapper is self._mapper_zero(): property = prop break else: raise sa_exc.InvalidRequestError( "Could not locate a property which relates instances " "of class '%s' to instances of class '%s'" % ( self._mapper_zero().class_.__name__, instance.__class__.__name__) ) return self.filter(with_parent(instance, property)) @_generative() def add_entity(self, entity, alias=None): """add a mapped entity to the list of result columns to be returned.""" if alias is not None: entity = aliased(entity, alias) self._entities = list(self._entities) m = _MapperEntity(self, entity) self._setup_aliasizers([m]) @_generative() def with_session(self, session): """Return a :class:`Query` that will use the given :class:`.Session`. """ self.session = session def from_self(self, *entities): """return a Query that selects from this Query's SELECT statement. \*entities - optional list of entities which will replace those being selected. """ fromclause = self.with_labels().enable_eagerloads(False).\ _enable_single_crit(False).\ statement.correlate(None) q = self._from_selectable(fromclause) if entities: q._set_entities(entities) return q @_generative() def _enable_single_crit(self, val): self._enable_single_crit = val @_generative() def _from_selectable(self, fromclause): for attr in ( '_statement', '_criterion', '_order_by', '_group_by', '_limit', '_offset', '_joinpath', '_joinpoint', '_distinct', '_having', '_prefixes', ): self.__dict__.pop(attr, None) self._set_select_from(fromclause) # this enables clause adaptation for non-ORM # expressions. self._orm_only_from_obj_alias = False old_entities = self._entities self._entities = [] for e in old_entities: e.adapt_to_selectable(self, self._from_obj[0]) def values(self, *columns): """Return an iterator yielding result tuples corresponding to the given list of columns""" if not columns: return iter(()) q = self._clone() q._set_entities(columns, entity_wrapper=_ColumnEntity) if not q._yield_per: q._yield_per = 10 return iter(q) _values = values def value(self, column): """Return a scalar result corresponding to the given column expression.""" try: # Py3K #return self.values(column).__next__()[0] # Py2K return self.values(column).next()[0] # end Py2K except StopIteration: return None @_generative() def with_entities(self, *entities): """Return a new :class:`.Query` replacing the SELECT list with the given entities. e.g.:: # Users, filtered on some arbitrary criterion # and then ordered by related email address q = session.query(User).\\ join(User.address).\\ filter(User.name.like('%ed%')).\\ order_by(Address.email) # given *only* User.id==5, Address.email, and 'q', what # would the *next* User in the result be ? subq = q.with_entities(Address.email).\\ order_by(None).\\ filter(User.id==5).\\ subquery() q = q.join((subq, subq.c.email < Address.email)).\\ limit(1) New in 0.6.5. """ self._set_entities(entities) @_generative() def add_columns(self, *column): """Add one or more column expressions to the list of result columns to be returned.""" self._entities = list(self._entities) l = len(self._entities) for c in column: _ColumnEntity(self, c) # _ColumnEntity may add many entities if the # given arg is a FROM clause self._setup_aliasizers(self._entities[l:]) @util.pending_deprecation("0.7", ":meth:`.add_column` is superseded by :meth:`.add_columns`", False) def add_column(self, column): """Add a column expression to the list of result columns to be returned. Pending deprecation: :meth:`.add_column` will be superseded by :meth:`.add_columns`. """ return self.add_columns(column) def options(self, *args): """Return a new Query object, applying the given list of mapper options. Most supplied options regard changing how column- and relationship-mapped attributes are loaded. See the sections :ref:`deferred` and :ref:`loading_toplevel` for reference documentation. """ return self._options(False, *args) def _conditional_options(self, *args): return self._options(True, *args) @_generative() def _options(self, conditional, *args): # most MapperOptions write to the '_attributes' dictionary, # so copy that as well self._attributes = self._attributes.copy() opts = tuple(util.flatten_iterator(args)) self._with_options = self._with_options + opts if conditional: for opt in opts: opt.process_query_conditionally(self) else: for opt in opts: opt.process_query(self) def with_transformation(self, fn): """Return a new :class:`.Query` object transformed by the given function. E.g.:: def filter_something(criterion): def transform(q): return q.filter(criterion) return transform q = q.with_transformation(filter_something(x==5)) This allows ad-hoc recipes to be created for :class:`.Query` objects. See the example at :ref:`hybrid_transformers`. :meth:`~.Query.with_transformation` is new in SQLAlchemy 0.7.4. """ return fn(self) @_generative() def with_hint(self, selectable, text, dialect_name='*'): """Add an indexing hint for the given entity or selectable to this :class:`.Query`. Functionality is passed straight through to :meth:`~sqlalchemy.sql.expression.Select.with_hint`, with the addition that ``selectable`` can be a :class:`.Table`, :class:`.Alias`, or ORM entity / mapped class /etc. """ mapper, selectable, is_aliased_class = _entity_info(selectable) self._with_hints += ((selectable, text, dialect_name),) @_generative() def execution_options(self, **kwargs): """ Set non-SQL options which take effect during execution. The options are the same as those accepted by :meth:`.Connection.execution_options`. Note that the ``stream_results`` execution option is enabled automatically if the :meth:`~sqlalchemy.orm.query.Query.yield_per()` method is used. """ self._execution_options = self._execution_options.union(kwargs) @_generative() def with_lockmode(self, mode): """Return a new Query object with the specified locking mode. :param mode: a string representing the desired locking mode. A corresponding value is passed to the ``for_update`` parameter of :meth:`~sqlalchemy.sql.expression.select` when the query is executed. Valid values are: ``'update'`` - passes ``for_update=True``, which translates to ``FOR UPDATE`` (standard SQL, supported by most dialects) ``'update_nowait'`` - passes ``for_update='nowait'``, which translates to ``FOR UPDATE NOWAIT`` (supported by Oracle, PostgreSQL 8.1 upwards) ``'read'`` - passes ``for_update='read'``, which translates to ``LOCK IN SHARE MODE`` (for MySQL), and ``FOR SHARE`` (for PostgreSQL) ``'read_nowait'`` - passes ``for_update='read_nowait'``, which translates to ``FOR SHARE NOWAIT`` (supported by PostgreSQL). New in 0.7.7: ``FOR SHARE`` and ``FOR SHARE NOWAIT`` (PostgreSQL) """ self._lockmode = mode @_generative() def params(self, *args, **kwargs): """add values for bind parameters which may have been specified in filter(). parameters may be specified using \**kwargs, or optionally a single dictionary as the first positional argument. The reason for both is that \**kwargs is convenient, however some parameter dictionaries contain unicode keys in which case \**kwargs cannot be used. """ if len(args) == 1: kwargs.update(args[0]) elif len(args) > 0: raise sa_exc.ArgumentError( "params() takes zero or one positional argument, " "which is a dictionary.") self._params = self._params.copy() self._params.update(kwargs) @_generative(_no_statement_condition, _no_limit_offset) def filter(self, *criterion): """apply the given filtering criterion to a copy of this :class:`.Query`, using SQL expressions. e.g.:: session.query(MyClass).filter(MyClass.name == 'some name') Multiple criteria are joined together by AND (new in 0.7.5):: session.query(MyClass).\\ filter(MyClass.name == 'some name', MyClass.id > 5) The criterion is any SQL expression object applicable to the WHERE clause of a select. String expressions are coerced into SQL expression constructs via the :func:`.text` construct. See also: :meth:`.Query.filter_by` - filter on keyword expressions. """ for criterion in list(criterion): if isinstance(criterion, basestring): criterion = sql.text(criterion) if criterion is not None and \ not isinstance(criterion, sql.ClauseElement): raise sa_exc.ArgumentError( "filter() argument must be of type " "sqlalchemy.sql.ClauseElement or string") criterion = self._adapt_clause(criterion, True, True) if self._criterion is not None: self._criterion = self._criterion & criterion else: self._criterion = criterion def filter_by(self, **kwargs): """apply the given filtering criterion to a copy of this :class:`.Query`, using keyword expressions. e.g.:: session.query(MyClass).filter_by(name = 'some name') Multiple criteria are joined together by AND:: session.query(MyClass).\\ filter_by(name = 'some name', id = 5) The keyword expressions are extracted from the primary entity of the query, or the last entity that was the target of a call to :meth:`.Query.join`. See also: :meth:`.Query.filter` - filter on SQL expressions. """ clauses = [_entity_descriptor(self._joinpoint_zero(), key) == value for key, value in kwargs.iteritems()] return self.filter(sql.and_(*clauses)) @_generative(_no_statement_condition, _no_limit_offset) def order_by(self, *criterion): """apply one or more ORDER BY criterion to the query and return the newly resulting ``Query`` All existing ORDER BY settings can be suppressed by passing ``None`` - this will suppress any ORDER BY configured on mappers as well. Alternatively, an existing ORDER BY setting on the Query object can be entirely cancelled by passing ``False`` as the value - use this before calling methods where an ORDER BY is invalid. """ if len(criterion) == 1: if criterion[0] is False: if '_order_by' in self.__dict__: del self._order_by return if criterion[0] is None: self._order_by = None return criterion = self._adapt_col_list(criterion) if self._order_by is False or self._order_by is None: self._order_by = criterion else: self._order_by = self._order_by + criterion @_generative(_no_statement_condition, _no_limit_offset) def group_by(self, *criterion): """apply one or more GROUP BY criterion to the query and return the newly resulting :class:`.Query`""" criterion = list(chain(*[_orm_columns(c) for c in criterion])) criterion = self._adapt_col_list(criterion) if self._group_by is False: self._group_by = criterion else: self._group_by = self._group_by + criterion @_generative(_no_statement_condition, _no_limit_offset) def having(self, criterion): """apply a HAVING criterion to the query and return the newly resulting :class:`.Query`. :meth:`having` is used in conjunction with :meth:`group_by`. HAVING criterion makes it possible to use filters on aggregate functions like COUNT, SUM, AVG, MAX, and MIN, eg.:: q = session.query(User.id).\\ join(User.addresses).\\ group_by(User.id).\\ having(func.count(Address.id) > 2) """ if isinstance(criterion, basestring): criterion = sql.text(criterion) if criterion is not None and \ not isinstance(criterion, sql.ClauseElement): raise sa_exc.ArgumentError( "having() argument must be of type " "sqlalchemy.sql.ClauseElement or string") criterion = self._adapt_clause(criterion, True, True) if self._having is not None: self._having = self._having & criterion else: self._having = criterion def union(self, *q): """Produce a UNION of this Query against one or more queries. e.g.:: q1 = sess.query(SomeClass).filter(SomeClass.foo=='bar') q2 = sess.query(SomeClass).filter(SomeClass.bar=='foo') q3 = q1.union(q2) The method accepts multiple Query objects so as to control the level of nesting. A series of ``union()`` calls such as:: x.union(y).union(z).all() will nest on each ``union()``, and produces:: SELECT * FROM (SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y) UNION SELECT * FROM Z) Whereas:: x.union(y, z).all() produces:: SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y UNION SELECT * FROM Z) Note that many database backends do not allow ORDER BY to be rendered on a query called within UNION, EXCEPT, etc. To disable all ORDER BY clauses including those configured on mappers, issue ``query.order_by(None)`` - the resulting :class:`.Query` object will not render ORDER BY within its SELECT statement. """ return self._from_selectable( expression.union(*([self]+ list(q)))) def union_all(self, *q): """Produce a UNION ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. """ return self._from_selectable( expression.union_all(*([self]+ list(q))) ) def intersect(self, *q): """Produce an INTERSECT of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. """ return self._from_selectable( expression.intersect(*([self]+ list(q))) ) def intersect_all(self, *q): """Produce an INTERSECT ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. """ return self._from_selectable( expression.intersect_all(*([self]+ list(q))) ) def except_(self, *q): """Produce an EXCEPT of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. """ return self._from_selectable( expression.except_(*([self]+ list(q))) ) def except_all(self, *q): """Produce an EXCEPT ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. """ return self._from_selectable( expression.except_all(*([self]+ list(q))) ) def join(self, *props, **kwargs): """Create a SQL JOIN against this :class:`.Query` object's criterion and apply generatively, returning the newly resulting :class:`.Query`. **Simple Relationship Joins** Consider a mapping between two classes ``User`` and ``Address``, with a relationship ``User.addresses`` representing a collection of ``Address`` objects associated with each ``User``. The most common usage of :meth:`~.Query.join` is to create a JOIN along this relationship, using the ``User.addresses`` attribute as an indicator for how this should occur:: q = session.query(User).join(User.addresses) Where above, the call to :meth:`~.Query.join` along ``User.addresses`` will result in SQL equivalent to:: SELECT user.* FROM user JOIN address ON user.id = address.user_id In the above example we refer to ``User.addresses`` as passed to :meth:`~.Query.join` as the *on clause*, that is, it indicates how the "ON" portion of the JOIN should be constructed. For a single-entity query such as the one above (i.e. we start by selecting only from ``User`` and nothing else), the relationship can also be specified by its string name:: q = session.query(User).join("addresses") :meth:`~.Query.join` can also accommodate multiple "on clause" arguments to produce a chain of joins, such as below where a join across four related entities is constructed:: q = session.query(User).join("orders", "items", "keywords") The above would be shorthand for three separate calls to :meth:`~.Query.join`, each using an explicit attribute to indicate the source entity:: q = session.query(User).\\ join(User.orders).\\ join(Order.items).\\ join(Item.keywords) **Joins to a Target Entity or Selectable** A second form of :meth:`~.Query.join` allows any mapped entity or core selectable construct as a target. In this usage, :meth:`~.Query.join` will attempt to create a JOIN along the natural foreign key relationship between two entities:: q = session.query(User).join(Address) The above calling form of :meth:`.join` will raise an error if either there are no foreign keys between the two entities, or if there are multiple foreign key linkages between them. In the above calling form, :meth:`~.Query.join` is called upon to create the "on clause" automatically for us. The target can be any mapped entity or selectable, such as a :class:`.Table`:: q = session.query(User).join(addresses_table) **Joins to a Target with an ON Clause** The third calling form allows both the target entity as well as the ON clause to be passed explicitly. Suppose for example we wanted to join to ``Address`` twice, using an alias the second time. We use :func:`~sqlalchemy.orm.aliased` to create a distinct alias of ``Address``, and join to it using the ``target, onclause`` form, so that the alias can be specified explicitly as the target along with the relationship to instruct how the ON clause should proceed:: a_alias = aliased(Address) q = session.query(User).\\ join(User.addresses).\\ join(a_alias, User.addresses).\\ filter(Address.email_address=='ed@foo.com').\\ filter(a_alias.email_address=='ed@bar.com') Where above, the generated SQL would be similar to:: SELECT user.* FROM user JOIN address ON user.id = address.user_id JOIN address AS address_1 ON user.id=address_1.user_id WHERE address.email_address = :email_address_1 AND address_1.email_address = :email_address_2 The two-argument calling form of :meth:`~.Query.join` also allows us to construct arbitrary joins with SQL-oriented "on clause" expressions, not relying upon configured relationships at all. Any SQL expression can be passed as the ON clause when using the two-argument form, which should refer to the target entity in some way as well as an applicable source entity:: q = session.query(User).join(Address, User.id==Address.user_id) .. note:: In SQLAlchemy 0.6 and earlier, the two argument form of :meth:`~.Query.join` requires the usage of a tuple:: query(User).join((Address, User.id==Address.user_id)) This calling form is accepted in 0.7 and further, though is not necessary unless multiple join conditions are passed to a single :meth:`~.Query.join` call, which itself is also not generally necessary as it is now equivalent to multiple calls (this wasn't always the case). **Advanced Join Targeting and Adaption** There is a lot of flexibility in what the "target" can be when using :meth:`~.Query.join`. As noted previously, it also accepts :class:`.Table` constructs and other selectables such as :func:`.alias` and :func:`.select` constructs, with either the one or two-argument forms:: addresses_q = select([Address.user_id]).\\ filter(Address.email_address.endswith("@bar.com")).\\ alias() q = session.query(User).\\ join(addresses_q, addresses_q.c.user_id==User.id) :meth:`~.Query.join` also features the ability to *adapt* a :meth:`~sqlalchemy.orm.relationship` -driven ON clause to the target selectable. Below we construct a JOIN from ``User`` to a subquery against ``Address``, allowing the relationship denoted by ``User.addresses`` to *adapt* itself to the altered target:: address_subq = session.query(Address).\\ filter(Address.email_address == 'ed@foo.com').\\ subquery() q = session.query(User).join(address_subq, User.addresses) Producing SQL similar to:: SELECT user.* FROM user JOIN ( SELECT address.id AS id, address.user_id AS user_id, address.email_address AS email_address FROM address WHERE address.email_address = :email_address_1 ) AS anon_1 ON user.id = anon_1.user_id The above form allows one to fall back onto an explicit ON clause at any time:: q = session.query(User).\\ join(address_subq, User.id==address_subq.c.user_id) **Controlling what to Join From** While :meth:`~.Query.join` exclusively deals with the "right" side of the JOIN, we can also control the "left" side, in those cases where it's needed, using :meth:`~.Query.select_from`. Below we construct a query against ``Address`` but can still make usage of ``User.addresses`` as our ON clause by instructing the :class:`.Query` to select first from the ``User`` entity:: q = session.query(Address).select_from(User).\\ join(User.addresses).\\ filter(User.name == 'ed') Which will produce SQL similar to:: SELECT address.* FROM user JOIN address ON user.id=address.user_id WHERE user.name = :name_1 **Constructing Aliases Anonymously** :meth:`~.Query.join` can construct anonymous aliases using the ``aliased=True`` flag. This feature is useful when a query is being joined algorithmically, such as when querying self-referentially to an arbitrary depth:: q = session.query(Node).\\ join("children", "children", aliased=True) When ``aliased=True`` is used, the actual "alias" construct is not explicitly available. To work with it, methods such as :meth:`.Query.filter` will adapt the incoming entity to the last join point:: q = session.query(Node).\\ join("children", "children", aliased=True).\\ filter(Node.name == 'grandchild 1') When using automatic aliasing, the ``from_joinpoint=True`` argument can allow a multi-node join to be broken into multiple calls to :meth:`~.Query.join`, so that each path along the way can be further filtered:: q = session.query(Node).\\ join("children", aliased=True).\\ filter(Node.name='child 1').\\ join("children", aliased=True, from_joinpoint=True).\\ filter(Node.name == 'grandchild 1') The filtering aliases above can then be reset back to the original ``Node`` entity using :meth:`~.Query.reset_joinpoint`:: q = session.query(Node).\\ join("children", "children", aliased=True).\\ filter(Node.name == 'grandchild 1').\\ reset_joinpoint().\\ filter(Node.name == 'parent 1) For an example of ``aliased=True``, see the distribution example :ref:`examples_xmlpersistence` which illustrates an XPath-like query system using algorithmic joins. :param *props: A collection of one or more join conditions, each consisting of a relationship-bound attribute or string relationship name representing an "on clause", or a single target entity, or a tuple in the form of ``(target, onclause)``. A special two-argument calling form of the form ``target, onclause`` is also accepted. :param aliased=False: If True, indicate that the JOIN target should be anonymously aliased. Subsequent calls to :class:`~.Query.filter` and similar will adapt the incoming criterion to the target alias, until :meth:`~.Query.reset_joinpoint` is called. :param from_joinpoint=False: When using ``aliased=True``, a setting of True here will cause the join to be from the most recent joined target, rather than starting back from the original FROM clauses of the query. See also: :ref:`ormtutorial_joins` in the ORM tutorial. :ref:`inheritance_toplevel` for details on how :meth:`~.Query.join` is used for inheritance relationships. :func:`.orm.join` - a standalone ORM-level join function, used internally by :meth:`.Query.join`, which in previous SQLAlchemy versions was the primary ORM-level joining interface. """ aliased, from_joinpoint = kwargs.pop('aliased', False),\ kwargs.pop('from_joinpoint', False) if kwargs: raise TypeError("unknown arguments: %s" % ','.join(kwargs.iterkeys())) return self._join(props, outerjoin=False, create_aliases=aliased, from_joinpoint=from_joinpoint) def outerjoin(self, *props, **kwargs): """Create a left outer join against this ``Query`` object's criterion and apply generatively, returning the newly resulting ``Query``. Usage is the same as the ``join()`` method. """ aliased, from_joinpoint = kwargs.pop('aliased', False), \ kwargs.pop('from_joinpoint', False) if kwargs: raise TypeError("unknown arguments: %s" % ','.join(kwargs.iterkeys())) return self._join(props, outerjoin=True, create_aliases=aliased, from_joinpoint=from_joinpoint) def _update_joinpoint(self, jp): self._joinpoint = jp # copy backwards to the root of the _joinpath # dict, so that no existing dict in the path is mutated while 'prev' in jp: f, prev = jp['prev'] prev = prev.copy() prev[f] = jp jp['prev'] = (f, prev) jp = prev self._joinpath = jp @_generative(_no_statement_condition, _no_limit_offset) def _join(self, keys, outerjoin, create_aliases, from_joinpoint): """consumes arguments from join() or outerjoin(), places them into a consistent format with which to form the actual JOIN constructs. """ if not from_joinpoint: self._reset_joinpoint() if len(keys) == 2 and \ isinstance(keys[0], (expression.FromClause, type, AliasedClass)) and \ isinstance(keys[1], (basestring, expression.ClauseElement, interfaces.PropComparator)): # detect 2-arg form of join and # convert to a tuple. keys = (keys,) for arg1 in util.to_list(keys): if isinstance(arg1, tuple): # "tuple" form of join, multiple # tuples are accepted as well. The simpler # "2-arg" form is preferred. May deprecate # the "tuple" usage. arg1, arg2 = arg1 else: arg2 = None # determine onclause/right_entity. there # is a little bit of legacy behavior still at work here # which means they might be in either order. may possibly # lock this down to (right_entity, onclause) in 0.6. if isinstance(arg1, (interfaces.PropComparator, basestring)): right_entity, onclause = arg2, arg1 else: right_entity, onclause = arg1, arg2 left_entity = prop = None if isinstance(onclause, basestring): left_entity = self._joinpoint_zero() descriptor = _entity_descriptor(left_entity, onclause) onclause = descriptor # check for q.join(Class.propname, from_joinpoint=True) # and Class is that of the current joinpoint elif from_joinpoint and \ isinstance(onclause, interfaces.PropComparator): left_entity = onclause.parententity left_mapper, left_selectable, left_is_aliased = \ _entity_info(self._joinpoint_zero()) if left_mapper is left_entity: left_entity = self._joinpoint_zero() descriptor = _entity_descriptor(left_entity, onclause.key) onclause = descriptor if isinstance(onclause, interfaces.PropComparator): if right_entity is None: right_entity = onclause.property.mapper of_type = getattr(onclause, '_of_type', None) if of_type: right_entity = of_type else: right_entity = onclause.property.mapper left_entity = onclause.parententity prop = onclause.property if not isinstance(onclause, attributes.QueryableAttribute): onclause = prop if not create_aliases: # check for this path already present. # don't render in that case. edge = (left_entity, right_entity, prop.key) if edge in self._joinpoint: # The child's prev reference might be stale -- # it could point to a parent older than the # current joinpoint. If this is the case, # then we need to update it and then fix the # tree's spine with _update_joinpoint. Copy # and then mutate the child, which might be # shared by a different query object. jp = self._joinpoint[edge].copy() jp['prev'] = (edge, self._joinpoint) self._update_joinpoint(jp) continue elif onclause is not None and right_entity is None: # TODO: no coverage here raise NotImplementedError("query.join(a==b) not supported.") self._join_left_to_right( left_entity, right_entity, onclause, outerjoin, create_aliases, prop) def _join_left_to_right(self, left, right, onclause, outerjoin, create_aliases, prop): """append a JOIN to the query's from clause.""" self._polymorphic_adapters = self._polymorphic_adapters.copy() if left is None: if self._from_obj: left = self._from_obj[0] elif self._entities: left = self._entities[0].entity_zero_or_selectable if left is right and \ not create_aliases: raise sa_exc.InvalidRequestError( "Can't construct a join from %s to %s, they " "are the same entity" % (left, right)) right, right_is_aliased, onclause = self._prepare_right_side( right, onclause, outerjoin, create_aliases, prop) # if joining on a MapperProperty path, # track the path to prevent redundant joins if not create_aliases and prop: self._update_joinpoint({ '_joinpoint_entity':right, 'prev':((left, right, prop.key), self._joinpoint) }) else: self._joinpoint = { '_joinpoint_entity':right } self._join_to_left(left, right, right_is_aliased, onclause, outerjoin) def _prepare_right_side(self, right, onclause, outerjoin, create_aliases, prop): right_mapper, right_selectable, right_is_aliased = _entity_info(right) if right_mapper: self._join_entities += (right, ) if right_mapper and prop and \ not right_mapper.common_parent(prop.mapper): raise sa_exc.InvalidRequestError( "Join target %s does not correspond to " "the right side of join condition %s" % (right, onclause) ) if not right_mapper and prop: right_mapper = prop.mapper need_adapter = False if right_mapper and right is right_selectable: if not right_selectable.is_derived_from( right_mapper.mapped_table): raise sa_exc.InvalidRequestError( "Selectable '%s' is not derived from '%s'" % (right_selectable.description, right_mapper.mapped_table.description)) if not isinstance(right_selectable, expression.Alias): right_selectable = right_selectable.alias() right = aliased(right_mapper, right_selectable) need_adapter = True aliased_entity = right_mapper and \ not right_is_aliased and \ ( right_mapper.with_polymorphic or isinstance( right_mapper.mapped_table, expression.Join) ) if not need_adapter and (create_aliases or aliased_entity): right = aliased(right) need_adapter = True # if an alias() of the right side was generated here, # apply an adapter to all subsequent filter() calls # until reset_joinpoint() is called. if need_adapter: self._filter_aliases = ORMAdapter(right, equivalents=right_mapper and right_mapper._equivalent_columns or {}, chain_to=self._filter_aliases) # if the onclause is a ClauseElement, adapt it with any # adapters that are in place right now if isinstance(onclause, expression.ClauseElement): onclause = self._adapt_clause(onclause, True, True) # if an alias() on the right side was generated, # which is intended to wrap a the right side in a subquery, # ensure that columns retrieved from this target in the result # set are also adapted. if aliased_entity and not create_aliases: self._mapper_loads_polymorphically_with( right_mapper, ORMAdapter( right, equivalents=right_mapper._equivalent_columns ) ) return right, right_is_aliased, onclause def _join_to_left(self, left, right, right_is_aliased, onclause, outerjoin): left_mapper, left_selectable, left_is_aliased = _entity_info(left) # this is an overly broad assumption here, but there's a # very wide variety of situations where we rely upon orm.join's # adaption to glue clauses together, with joined-table inheritance's # wide array of variables taking up most of the space. # Setting the flag here is still a guess, so it is a bug # that we don't have definitive criterion to determine when # adaption should be enabled (or perhaps that we're even doing the # whole thing the way we are here). join_to_left = not right_is_aliased and not left_is_aliased if self._from_obj and left_selectable is not None: replace_clause_index, clause = sql_util.find_join_source( self._from_obj, left_selectable) if clause is not None: # the entire query's FROM clause is an alias of itself (i.e. # from_self(), similar). if the left clause is that one, # ensure it adapts to the left side. if self._from_obj_alias and clause is self._from_obj[0]: join_to_left = True # An exception case where adaption to the left edge is not # desirable. See above note on join_to_left. if join_to_left and isinstance(clause, expression.Join) and \ sql_util.clause_is_present(left_selectable, clause): join_to_left = False try: clause = orm_join(clause, right, onclause, isouter=outerjoin, join_to_left=join_to_left) except sa_exc.ArgumentError, ae: raise sa_exc.InvalidRequestError( "Could not find a FROM clause to join from. " "Tried joining to %s, but got: %s" % (right, ae)) self._from_obj = \ self._from_obj[:replace_clause_index] + \ (clause, ) + \ self._from_obj[replace_clause_index + 1:] return if left_mapper: for ent in self._entities: if ent.corresponds_to(left): clause = ent.selectable break else: clause = left elif left_selectable is not None: clause = left_selectable else: clause = None if clause is None: raise sa_exc.InvalidRequestError( "Could not find a FROM clause to join from") try: clause = orm_join(clause, right, onclause, isouter=outerjoin, join_to_left=join_to_left) except sa_exc.ArgumentError, ae: raise sa_exc.InvalidRequestError( "Could not find a FROM clause to join from. " "Tried joining to %s, but got: %s" % (right, ae)) self._from_obj = self._from_obj + (clause,) def _reset_joinpoint(self): self._joinpoint = self._joinpath self._filter_aliases = None @_generative(_no_statement_condition) def reset_joinpoint(self): """Return a new :class:`.Query`, where the "join point" has been reset back to the base FROM entities of the query. This method is usually used in conjunction with the ``aliased=True`` feature of the :meth:`~.Query.join` method. See the example in :meth:`~.Query.join` for how this is used. """ self._reset_joinpoint() @_generative(_no_clauseelement_condition) def select_from(self, *from_obj): """Set the FROM clause of this :class:`.Query` explicitly. Sending a mapped class or entity here effectively replaces the "left edge" of any calls to :meth:`~.Query.join`, when no joinpoint is otherwise established - usually, the default "join point" is the leftmost entity in the :class:`~.Query` object's list of entities to be selected. Mapped entities or plain :class:`~.Table` or other selectables can be sent here which will form the default FROM clause. See the example in :meth:`~.Query.join` for a typical usage of :meth:`~.Query.select_from`. """ obj = [] for fo in from_obj: if _is_mapped_class(fo): mapper, selectable, is_aliased_class = _entity_info(fo) self._select_from_entity = fo obj.append(selectable) elif not isinstance(fo, expression.FromClause): raise sa_exc.ArgumentError( "select_from() accepts FromClause objects only.") else: obj.append(fo) self._set_select_from(*obj) def __getitem__(self, item): if isinstance(item, slice): start, stop, step = util.decode_slice(item) if isinstance(stop, int) and \ isinstance(start, int) and \ stop - start <= 0: return [] # perhaps we should execute a count() here so that we # can still use LIMIT/OFFSET ? elif (isinstance(start, int) and start < 0) \ or (isinstance(stop, int) and stop < 0): return list(self)[item] res = self.slice(start, stop) if step is not None: return list(res)[None:None:item.step] else: return list(res) else: if item == -1: return list(self)[-1] else: return list(self[item:item+1])[0] @_generative(_no_statement_condition) def slice(self, start, stop): """apply LIMIT/OFFSET to the ``Query`` based on a " "range and return the newly resulting ``Query``.""" if start is not None and stop is not None: self._offset = (self._offset or 0) + start self._limit = stop - start elif start is None and stop is not None: self._limit = stop elif start is not None and stop is None: self._offset = (self._offset or 0) + start if self._offset == 0: self._offset = None @_generative(_no_statement_condition) def limit(self, limit): """Apply a ``LIMIT`` to the query and return the newly resulting ``Query``. """ self._limit = limit @_generative(_no_statement_condition) def offset(self, offset): """Apply an ``OFFSET`` to the query and return the newly resulting ``Query``. """ self._offset = offset @_generative(_no_statement_condition) def distinct(self, *criterion): """Apply a ``DISTINCT`` to the query and return the newly resulting ``Query``. :param \*expr: optional column expressions. When present, the Postgresql dialect will render a ``DISTINCT ON (<expressions>>)`` construct. """ if not criterion: self._distinct = True else: criterion = self._adapt_col_list(criterion) if isinstance(self._distinct, list): self._distinct += criterion else: self._distinct = criterion @_generative() def prefix_with(self, *prefixes): """Apply the prefixes to the query and return the newly resulting ``Query``. :param \*prefixes: optional prefixes, typically strings, not using any commas. In particular is useful for MySQL keywords. e.g.:: query = sess.query(User.name).\\ prefix_with('HIGH_PRIORITY').\\ prefix_with('SQL_SMALL_RESULT', 'ALL') Would render:: SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL users.name AS users_name FROM users New in 0.7.7. """ if self._prefixes: self._prefixes += prefixes else: self._prefixes = prefixes def all(self): """Return the results represented by this ``Query`` as a list. This results in an execution of the underlying query. """ return list(self) @_generative(_no_clauseelement_condition) def from_statement(self, statement): """Execute the given SELECT statement and return results. This method bypasses all internal statement compilation, and the statement is executed without modification. The statement argument is either a string, a ``select()`` construct, or a ``text()`` construct, and should return the set of columns appropriate to the entity class represented by this ``Query``. """ if isinstance(statement, basestring): statement = sql.text(statement) if not isinstance(statement, (expression._TextClause, expression._SelectBase)): raise sa_exc.ArgumentError( "from_statement accepts text(), select(), " "and union() objects only.") self._statement = statement def first(self): """Return the first result of this ``Query`` or None if the result doesn't contain any row. first() applies a limit of one within the generated SQL, so that only one primary entity row is generated on the server side (note this may consist of multiple result rows if join-loaded collections are present). Calling ``first()`` results in an execution of the underlying query. """ if self._statement is not None: ret = list(self)[0:1] else: ret = list(self[0:1]) if len(ret) > 0: return ret[0] else: return None def one(self): """Return exactly one result or raise an exception. Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects no rows. Raises ``sqlalchemy.orm.exc.MultipleResultsFound`` if multiple object identities are returned, or if multiple rows are returned for a query that does not return object identities. Note that an entity query, that is, one which selects one or more mapped classes as opposed to individual column attributes, may ultimately represent many rows but only one row of unique entity or entities - this is a successful result for one(). Calling ``one()`` results in an execution of the underlying query. As of 0.6, ``one()`` fully fetches all results instead of applying any kind of limit, so that the "unique"-ing of entities does not conceal multiple object identities. """ ret = list(self) l = len(ret) if l == 1: return ret[0] elif l == 0: raise orm_exc.NoResultFound("No row was found for one()") else: raise orm_exc.MultipleResultsFound( "Multiple rows were found for one()") def scalar(self): """Return the first element of the first result or None if no rows present. If multiple rows are returned, raises MultipleResultsFound. >>> session.query(Item).scalar() <Item> >>> session.query(Item.id).scalar() 1 >>> session.query(Item.id).filter(Item.id < 0).scalar() None >>> session.query(Item.id, Item.name).scalar() 1 >>> session.query(func.count(Parent.id)).scalar() 20 This results in an execution of the underlying query. """ try: ret = self.one() if not isinstance(ret, tuple): return ret return ret[0] except orm_exc.NoResultFound: return None def __iter__(self): context = self._compile_context() context.statement.use_labels = True if self._autoflush and not self._populate_existing: self.session._autoflush() return self._execute_and_instances(context) def _connection_from_session(self, **kw): conn = self.session.connection( **kw) if self._execution_options: conn = conn.execution_options(**self._execution_options) return conn def _execute_and_instances(self, querycontext): conn = self._connection_from_session( mapper = self._mapper_zero_or_none(), clause = querycontext.statement, close_with_result=True) result = conn.execute(querycontext.statement, self._params) return self.instances(result, querycontext) @property def column_descriptions(self): """Return metadata about the columns which would be returned by this :class:`.Query`. Format is a list of dictionaries:: user_alias = aliased(User, name='user2') q = sess.query(User, User.id, user_alias) # this expression: q.column_descriptions # would return: [ { 'name':'User', 'type':User, 'aliased':False, 'expr':User, }, { 'name':'id', 'type':Integer(), 'aliased':False, 'expr':User.id, }, { 'name':'user2', 'type':User, 'aliased':True, 'expr':user_alias } ] """ return [ { 'name':ent._label_name, 'type':ent.type, 'aliased':getattr(ent, 'is_aliased_class', False), 'expr':ent.expr } for ent in self._entities ] def instances(self, cursor, __context=None): """Given a ResultProxy cursor as returned by connection.execute(), return an ORM result as an iterator. e.g.:: result = engine.execute("select * from users") for u in session.query(User).instances(result): print u """ session = self.session context = __context if context is None: context = QueryContext(self) context.runid = _new_runid() filter_fns = [ent.filter_fn for ent in self._entities] filtered = id in filter_fns single_entity = filtered and len(self._entities) == 1 if filtered: if single_entity: filter_fn = id else: def filter_fn(row): return tuple(fn(x) for x, fn in zip(row, filter_fns)) custom_rows = single_entity and \ self._entities[0].mapper.dispatch.append_result (process, labels) = \ zip(*[ query_entity.row_processor(self, context, custom_rows) for query_entity in self._entities ]) while True: context.progress = {} context.partials = {} if self._yield_per: fetch = cursor.fetchmany(self._yield_per) if not fetch: break else: fetch = cursor.fetchall() if custom_rows: rows = [] for row in fetch: process[0](row, rows) elif single_entity: rows = [process[0](row, None) for row in fetch] else: rows = [util.NamedTuple([proc(row, None) for proc in process], labels) for row in fetch] if filtered: rows = util.unique_list(rows, filter_fn) if context.refresh_state and self._only_load_props \ and context.refresh_state in context.progress: context.refresh_state.commit( context.refresh_state.dict, self._only_load_props) context.progress.pop(context.refresh_state) session._finalize_loaded(context.progress) for ii, (dict_, attrs) in context.partials.iteritems(): ii.commit(dict_, attrs) for row in rows: yield row if not self._yield_per: break def merge_result(self, iterator, load=True): """Merge a result into this :class:`.Query` object's Session. Given an iterator returned by a :class:`.Query` of the same structure as this one, return an identical iterator of results, with all mapped instances merged into the session using :meth:`.Session.merge`. This is an optimized method which will merge all mapped instances, preserving the structure of the result rows and unmapped columns with less method overhead than that of calling :meth:`.Session.merge` explicitly for each value. The structure of the results is determined based on the column list of this :class:`.Query` - if these do not correspond, unchecked errors will occur. The 'load' argument is the same as that of :meth:`.Session.merge`. For an example of how :meth:`~.Query.merge_result` is used, see the source code for the example :ref:`examples_caching`, where :meth:`~.Query.merge_result` is used to efficiently restore state from a cache back into a target :class:`.Session`. """ session = self.session if load: # flush current contents if we expect to load data session._autoflush() autoflush = session.autoflush try: session.autoflush = False single_entity = len(self._entities) == 1 if single_entity: if isinstance(self._entities[0], _MapperEntity): result = [session._merge( attributes.instance_state(instance), attributes.instance_dict(instance), load=load, _recursive={}) for instance in iterator] else: result = list(iterator) else: mapped_entities = [i for i, e in enumerate(self._entities) if isinstance(e, _MapperEntity)] result = [] for row in iterator: newrow = list(row) for i in mapped_entities: newrow[i] = session._merge( attributes.instance_state(newrow[i]), attributes.instance_dict(newrow[i]), load=load, _recursive={}) result.append(util.NamedTuple(newrow, row._labels)) return iter(result) finally: session.autoflush = autoflush @classmethod def _get_from_identity(cls, session, key, passive): """Look up the given key in the given session's identity map, check the object for expired state if found. """ instance = session.identity_map.get(key) if instance is not None: state = attributes.instance_state(instance) # expired - ensure it still exists if state.expired: if passive is attributes.PASSIVE_NO_FETCH: # TODO: no coverage here return attributes.PASSIVE_NO_RESULT elif passive is attributes.PASSIVE_NO_FETCH_RELATED: # this mode is used within a flush and the instance's # expired state will be checked soon enough, if necessary return instance try: state(passive) except orm_exc.ObjectDeletedError: session._remove_newly_deleted(state) return None return instance else: return None def _load_on_ident(self, key, refresh_state=None, lockmode=None, only_load_props=None): """Load the given identity key from the database.""" lockmode = lockmode or self._lockmode if key is not None: ident = key[1] else: ident = None if refresh_state is None: q = self._clone() q._get_condition() else: q = self._clone() if ident is not None: mapper = self._mapper_zero() (_get_clause, _get_params) = mapper._get_clause # None present in ident - turn those comparisons # into "IS NULL" if None in ident: nones = set([ _get_params[col].key for col, value in zip(mapper.primary_key, ident) if value is None ]) _get_clause = sql_util.adapt_criterion_to_null( _get_clause, nones) _get_clause = q._adapt_clause(_get_clause, True, False) q._criterion = _get_clause params = dict([ (_get_params[primary_key].key, id_val) for id_val, primary_key in zip(ident, mapper.primary_key) ]) q._params = params if lockmode is not None: q._lockmode = lockmode q._get_options( populate_existing=bool(refresh_state), version_check=(lockmode is not None), only_load_props=only_load_props, refresh_state=refresh_state) q._order_by = None try: return q.one() except orm_exc.NoResultFound: return None @property def _select_args(self): return { 'limit':self._limit, 'offset':self._offset, 'distinct':self._distinct, 'prefixes':self._prefixes, 'group_by':self._group_by or None, 'having':self._having } @property def _should_nest_selectable(self): kwargs = self._select_args return (kwargs.get('limit') is not None or kwargs.get('offset') is not None or kwargs.get('distinct', False)) def count(self): """Return a count of rows this Query would return. This generates the SQL for this Query as follows:: SELECT count(1) AS count_1 FROM ( SELECT <rest of query follows...> ) AS anon_1 Note the above scheme is newly refined in 0.7 (as of 0.7b3). For fine grained control over specific columns to count, to skip the usage of a subquery or otherwise control of the FROM clause, or to use other aggregate functions, use :attr:`~sqlalchemy.sql.expression.func` expressions in conjunction with :meth:`~.Session.query`, i.e.:: from sqlalchemy import func # count User records, without # using a subquery. session.query(func.count(User.id)) # return count of user "id" grouped # by "name" session.query(func.count(User.id)).\\ group_by(User.name) from sqlalchemy import distinct # count distinct "name" values session.query(func.count(distinct(User.name))) """ col = sql.func.count(sql.literal_column('*')) return self.from_self(col).scalar() def delete(self, synchronize_session='evaluate'): """Perform a bulk delete query. Deletes rows matched by this query from the database. :param synchronize_session: chooses the strategy for the removal of matched objects from the session. Valid values are: ``False`` - don't synchronize the session. This option is the most efficient and is reliable once the session is expired, which typically occurs after a commit(), or explicitly using expire_all(). Before the expiration, objects may still remain in the session which were in fact deleted which can lead to confusing results if they are accessed via get() or already loaded collections. ``'fetch'`` - performs a select query before the delete to find objects that are matched by the delete query and need to be removed from the session. Matched objects are removed from the session. ``'evaluate'`` - Evaluate the query's criteria in Python straight on the objects in the session. If evaluation of the criteria isn't implemented, an error is raised. In that case you probably want to use the 'fetch' strategy as a fallback. The expression evaluator currently doesn't account for differing string collations between the database and Python. Returns the number of rows deleted, excluding any cascades. The method does *not* offer in-Python cascading of relationships - it is assumed that ON DELETE CASCADE is configured for any foreign key references which require it. The Session needs to be expired (occurs automatically after commit(), or call expire_all()) in order for the state of dependent objects subject to delete or delete-orphan cascade to be correctly represented. Note that the :meth:`.MapperEvents.before_delete` and :meth:`.MapperEvents.after_delete` events are **not** invoked from this method. It instead invokes :meth:`.SessionEvents.after_bulk_delete`. """ #TODO: lots of duplication and ifs - probably needs to be # refactored to strategies #TODO: cascades need handling. if synchronize_session not in [False, 'evaluate', 'fetch']: raise sa_exc.ArgumentError( "Valid strategies for session " "synchronization are False, 'evaluate' and " "'fetch'") self._no_select_modifiers("delete") self = self.enable_eagerloads(False) context = self._compile_context() if len(context.statement.froms) != 1 or \ not isinstance(context.statement.froms[0], schema.Table): raise sa_exc.ArgumentError("Only deletion via a single table " "query is currently supported") primary_table = context.statement.froms[0] session = self.session if self._autoflush: session._autoflush() if synchronize_session == 'evaluate': try: evaluator_compiler = evaluator.EvaluatorCompiler() if self.whereclause is not None: eval_condition = evaluator_compiler.process( self.whereclause) else: def eval_condition(obj): return True except evaluator.UnevaluatableError: raise sa_exc.InvalidRequestError( "Could not evaluate current criteria in Python. " "Specify 'fetch' or False for the synchronize_session " "parameter.") target_cls = self._mapper_zero().class_ #TODO: detect when the where clause is a trivial primary key match objs_to_expunge = [ obj for (cls, pk),obj in session.identity_map.iteritems() if issubclass(cls, target_cls) and eval_condition(obj)] elif synchronize_session == 'fetch': #TODO: use RETURNING when available select_stmt = context.statement.with_only_columns( primary_table.primary_key) matched_rows = session.execute( select_stmt, params=self._params).fetchall() delete_stmt = sql.delete(primary_table, context.whereclause) result = session.execute(delete_stmt, params=self._params) if synchronize_session == 'evaluate': for obj in objs_to_expunge: session._remove_newly_deleted(attributes.instance_state(obj)) elif synchronize_session == 'fetch': target_mapper = self._mapper_zero() for primary_key in matched_rows: identity_key = target_mapper.identity_key_from_primary_key( list(primary_key)) if identity_key in session.identity_map: session._remove_newly_deleted( attributes.instance_state( session.identity_map[identity_key] ) ) session.dispatch.after_bulk_delete(session, self, context, result) return result.rowcount def update(self, values, synchronize_session='evaluate'): """Perform a bulk update query. Updates rows matched by this query in the database. :param values: a dictionary with attributes names as keys and literal values or sql expressions as values. :param synchronize_session: chooses the strategy to update the attributes on objects in the session. Valid values are: ``False`` - don't synchronize the session. This option is the most efficient and is reliable once the session is expired, which typically occurs after a commit(), or explicitly using expire_all(). Before the expiration, updated objects may still remain in the session with stale values on their attributes, which can lead to confusing results. ``'fetch'`` - performs a select query before the update to find objects that are matched by the update query. The updated attributes are expired on matched objects. ``'evaluate'`` - Evaluate the Query's criteria in Python straight on the objects in the session. If evaluation of the criteria isn't implemented, an exception is raised. The expression evaluator currently doesn't account for differing string collations between the database and Python. Returns the number of rows matched by the update. The method does *not* offer in-Python cascading of relationships - it is assumed that ON UPDATE CASCADE is configured for any foreign key references which require it. The Session needs to be expired (occurs automatically after commit(), or call expire_all()) in order for the state of dependent objects subject foreign key cascade to be correctly represented. Note that the :meth:`.MapperEvents.before_update` and :meth:`.MapperEvents.after_update` events are **not** invoked from this method. It instead invokes :meth:`.SessionEvents.after_bulk_update`. """ #TODO: value keys need to be mapped to corresponding sql cols and # instr.attr.s to string keys #TODO: updates of manytoone relationships need to be converted to # fk assignments #TODO: cascades need handling. if synchronize_session == 'expire': util.warn_deprecated("The 'expire' value as applied to " "the synchronize_session argument of " "query.update() is now called 'fetch'") synchronize_session = 'fetch' if synchronize_session not in [False, 'evaluate', 'fetch']: raise sa_exc.ArgumentError( "Valid strategies for session synchronization " "are False, 'evaluate' and 'fetch'") self._no_select_modifiers("update") self = self.enable_eagerloads(False) context = self._compile_context() if len(context.statement.froms) != 1 or \ not isinstance(context.statement.froms[0], schema.Table): raise sa_exc.ArgumentError( "Only update via a single table query is " "currently supported") primary_table = context.statement.froms[0] session = self.session if self._autoflush: session._autoflush() if synchronize_session == 'evaluate': try: evaluator_compiler = evaluator.EvaluatorCompiler() if self.whereclause is not None: eval_condition = evaluator_compiler.process( self.whereclause) else: def eval_condition(obj): return True value_evaluators = {} for key,value in values.iteritems(): key = _attr_as_key(key) value_evaluators[key] = evaluator_compiler.process( expression._literal_as_binds(value)) except evaluator.UnevaluatableError: raise sa_exc.InvalidRequestError( "Could not evaluate current criteria in Python. " "Specify 'fetch' or False for the " "synchronize_session parameter.") target_cls = self._mapper_zero().class_ matched_objects = [] for (cls, pk),obj in session.identity_map.iteritems(): evaluated_keys = value_evaluators.keys() if issubclass(cls, target_cls) and eval_condition(obj): matched_objects.append(obj) elif synchronize_session == 'fetch': select_stmt = context.statement.with_only_columns( primary_table.primary_key) matched_rows = session.execute( select_stmt, params=self._params).fetchall() update_stmt = sql.update(primary_table, context.whereclause, values) result = session.execute(update_stmt, params=self._params) if synchronize_session == 'evaluate': target_cls = self._mapper_zero().class_ for obj in matched_objects: state, dict_ = attributes.instance_state(obj),\ attributes.instance_dict(obj) # only evaluate unmodified attributes to_evaluate = state.unmodified.intersection( evaluated_keys) for key in to_evaluate: dict_[key] = value_evaluators[key](obj) state.commit(dict_, list(to_evaluate)) # expire attributes with pending changes # (there was no autoflush, so they are overwritten) state.expire_attributes(dict_, set(evaluated_keys). difference(to_evaluate)) elif synchronize_session == 'fetch': target_mapper = self._mapper_zero() for primary_key in matched_rows: identity_key = target_mapper.identity_key_from_primary_key( list(primary_key)) if identity_key in session.identity_map: session.expire( session.identity_map[identity_key], [_attr_as_key(k) for k in values] ) session.dispatch.after_bulk_update(session, self, context, result) return result.rowcount def _compile_context(self, labels=True): context = QueryContext(self) if context.statement is not None: return context if self._lockmode: try: for_update = {'read': 'read', 'read_nowait': 'read_nowait', 'update': True, 'update_nowait': 'nowait', None: False}[self._lockmode] except KeyError: raise sa_exc.ArgumentError( "Unknown lockmode %r" % self._lockmode) else: for_update = False for entity in self._entities: entity.setup_context(self, context) for rec in context.create_eager_joins: strategy = rec[0] strategy(*rec[1:]) eager_joins = context.eager_joins.values() if context.from_clause: # "load from explicit FROMs" mode, # i.e. when select_from() or join() is used froms = list(context.from_clause) else: # "load from discrete FROMs" mode, # i.e. when each _MappedEntity has its own FROM froms = context.froms if self._enable_single_crit: self._adjust_for_single_inheritance(context) if not context.primary_columns: if self._only_load_props: raise sa_exc.InvalidRequestError( "No column-based properties specified for " "refresh operation. Use session.expire() " "to reload collections and related items.") else: raise sa_exc.InvalidRequestError( "Query contains no columns with which to " "SELECT from.") if context.multi_row_eager_loaders and self._should_nest_selectable: # for eager joins present and LIMIT/OFFSET/DISTINCT, # wrap the query inside a select, # then append eager joins onto that if context.order_by: order_by_col_expr = list( chain(*[ sql_util.unwrap_order_by(o) for o in context.order_by ]) ) else: context.order_by = None order_by_col_expr = [] inner = sql.select( context.primary_columns + order_by_col_expr, context.whereclause, from_obj=froms, use_labels=labels, correlate=False, # TODO: this order_by is only needed if # LIMIT/OFFSET is present in self._select_args, # else the application on the outside is enough order_by=context.order_by, **self._select_args ) for hint in self._with_hints: inner = inner.with_hint(*hint) if self._correlate: inner = inner.correlate(*self._correlate) inner = inner.alias() equivs = self.__all_equivs() context.adapter = sql_util.ColumnAdapter(inner, equivs) statement = sql.select( [inner] + context.secondary_columns, for_update=for_update, use_labels=labels) from_clause = inner for eager_join in eager_joins: # EagerLoader places a 'stop_on' attribute on the join, # giving us a marker as to where the "splice point" of # the join should be from_clause = sql_util.splice_joins( from_clause, eager_join, eager_join.stop_on) statement.append_from(from_clause) if context.order_by: statement.append_order_by( *context.adapter.copy_and_process( context.order_by ) ) statement.append_order_by(*context.eager_order_by) else: if not context.order_by: context.order_by = None if self._distinct and context.order_by: order_by_col_expr = list( chain(*[ sql_util.unwrap_order_by(o) for o in context.order_by ]) ) context.primary_columns += order_by_col_expr froms += tuple(context.eager_joins.values()) statement = sql.select( context.primary_columns + context.secondary_columns, context.whereclause, from_obj=froms, use_labels=labels, for_update=for_update, correlate=False, order_by=context.order_by, **self._select_args ) for hint in self._with_hints: statement = statement.with_hint(*hint) if self._correlate: statement = statement.correlate(*self._correlate) if context.eager_order_by: statement.append_order_by(*context.eager_order_by) context.statement = statement return context def _adjust_for_single_inheritance(self, context): """Apply single-table-inheritance filtering. For all distinct single-table-inheritance mappers represented in the columns clause of this query, add criterion to the WHERE clause of the given QueryContext such that only the appropriate subtypes are selected from the total results. """ for entity, (mapper, adapter, s, i, w) in \ self._mapper_adapter_map.iteritems(): if entity in self._join_entities: continue single_crit = mapper._single_table_criterion if single_crit is not None: if adapter: single_crit = adapter.traverse(single_crit) single_crit = self._adapt_clause(single_crit, False, False) context.whereclause = sql.and_( context.whereclause, single_crit) def __str__(self): return str(self._compile_context().statement) class _QueryEntity(object): """represent an entity column returned within a Query result.""" def __new__(cls, *args, **kwargs): if cls is _QueryEntity: entity = args[1] if not isinstance(entity, basestring) and \ _is_mapped_class(entity): cls = _MapperEntity else: cls = _ColumnEntity return object.__new__(cls) def _clone(self): q = self.__class__.__new__(self.__class__) q.__dict__ = self.__dict__.copy() return q class _MapperEntity(_QueryEntity): """mapper/class/AliasedClass entity""" def __init__(self, query, entity): self.primary_entity = not query._entities query._entities.append(self) self.entities = [entity] self.entity_zero = self.expr = entity def setup_entity(self, entity, mapper, adapter, from_obj, is_aliased_class, with_polymorphic): self.mapper = mapper self.adapter = adapter self.selectable = from_obj self._with_polymorphic = with_polymorphic self._polymorphic_discriminator = None self.is_aliased_class = is_aliased_class if is_aliased_class: self.path_entity = self.entity_zero = entity self._path = (entity,) self._label_name = self.entity_zero._sa_label_name self._reduced_path = (self.path_entity, ) else: self.path_entity = mapper self._path = (mapper,) self._reduced_path = (mapper.base_mapper, ) self.entity_zero = mapper self._label_name = self.mapper.class_.__name__ def set_with_polymorphic(self, query, cls_or_mappers, selectable, discriminator): if cls_or_mappers is None: query._reset_polymorphic_adapter(self.mapper) return mappers, from_obj = self.mapper._with_polymorphic_args( cls_or_mappers, selectable) self._with_polymorphic = mappers self._polymorphic_discriminator = discriminator # TODO: do the wrapped thing here too so that # with_polymorphic() can be applied to aliases if not self.is_aliased_class: self.selectable = from_obj query._mapper_loads_polymorphically_with(self.mapper, sql_util.ColumnAdapter(from_obj, self.mapper._equivalent_columns)) filter_fn = id @property def type(self): return self.mapper.class_ @property def entity_zero_or_selectable(self): return self.entity_zero def corresponds_to(self, entity): if _is_aliased_class(entity) or self.is_aliased_class: return entity is self.path_entity else: return entity.common_parent(self.path_entity) def adapt_to_selectable(self, query, sel): query._entities.append(self) def _get_entity_clauses(self, query, context): adapter = None if not self.is_aliased_class and query._polymorphic_adapters: adapter = query._polymorphic_adapters.get(self.mapper, None) if not adapter and self.adapter: adapter = self.adapter if adapter: if query._from_obj_alias: ret = adapter.wrap(query._from_obj_alias) else: ret = adapter else: ret = query._from_obj_alias return ret def row_processor(self, query, context, custom_rows): adapter = self._get_entity_clauses(query, context) if context.adapter and adapter: adapter = adapter.wrap(context.adapter) elif not adapter: adapter = context.adapter # polymorphic mappers which have concrete tables in # their hierarchy usually # require row aliasing unconditionally. if not adapter and self.mapper._requires_row_aliasing: adapter = sql_util.ColumnAdapter( self.selectable, self.mapper._equivalent_columns) if self.primary_entity: _instance = self.mapper._instance_processor( context, self._path, self._reduced_path, adapter, only_load_props=query._only_load_props, refresh_state=context.refresh_state, polymorphic_discriminator= self._polymorphic_discriminator ) else: _instance = self.mapper._instance_processor( context, self._path, self._reduced_path, adapter, polymorphic_discriminator= self._polymorphic_discriminator) return _instance, self._label_name def setup_context(self, query, context): adapter = self._get_entity_clauses(query, context) context.froms += (self.selectable,) if context.order_by is False and self.mapper.order_by: context.order_by = self.mapper.order_by # apply adaptation to the mapper's order_by if needed. if adapter: context.order_by = adapter.adapt_list( util.to_list( context.order_by ) ) if self._with_polymorphic: poly_properties = self.mapper._iterate_polymorphic_properties( self._with_polymorphic) else: poly_properties = self.mapper._polymorphic_properties for value in poly_properties: if query._only_load_props and \ value.key not in query._only_load_props: continue value.setup( context, self, self._path, self._reduced_path, adapter, only_load_props=query._only_load_props, column_collection=context.primary_columns ) if self._polymorphic_discriminator is not None: if adapter: pd = adapter.columns[self._polymorphic_discriminator] else: pd = self._polymorphic_discriminator context.primary_columns.append(pd) def __str__(self): return str(self.mapper) class _ColumnEntity(_QueryEntity): """Column/expression based entity.""" def __init__(self, query, column, namespace=None): self.expr = column self.namespace = namespace if isinstance(column, basestring): column = sql.literal_column(column) self._label_name = column.name elif isinstance(column, ( attributes.QueryableAttribute, interfaces.PropComparator )): self._label_name = column.key column = column.__clause_element__() else: self._label_name = getattr(column, 'key', None) if not isinstance(column, expression.ColumnElement) and \ hasattr(column, '_select_iterable'): for c in column._select_iterable: if c is column: break _ColumnEntity(query, c, namespace=column) if c is not column: return if not isinstance(column, sql.ColumnElement): raise sa_exc.InvalidRequestError( "SQL expression, column, or mapped entity " "expected - got '%r'" % (column, ) ) # If the Column is unnamed, give it a # label() so that mutable column expressions # can be located in the result even # if the expression's identity has been changed # due to adaption. if not column._label: column = column.label(None) query._entities.append(self) self.column = column self.froms = set() # look for ORM entities represented within the # given expression. Try to count only entities # for columns whose FROM object is in the actual list # of FROMs for the overall expression - this helps # subqueries which were built from ORM constructs from # leaking out their entities into the main select construct self.actual_froms = actual_froms = set(column._from_objects) self.entities = util.OrderedSet( elem._annotations['parententity'] for elem in visitors.iterate(column, {}) if 'parententity' in elem._annotations and actual_froms.intersection(elem._from_objects) ) if self.entities: self.entity_zero = list(self.entities)[0] elif self.namespace is not None: self.entity_zero = self.namespace else: self.entity_zero = None @property def entity_zero_or_selectable(self): if self.entity_zero is not None: return self.entity_zero elif self.actual_froms: return list(self.actual_froms)[0] else: return None @property def type(self): return self.column.type def filter_fn(self, item): return item def adapt_to_selectable(self, query, sel): c = _ColumnEntity(query, sel.corresponding_column(self.column)) c._label_name = self._label_name c.entity_zero = self.entity_zero c.entities = self.entities def setup_entity(self, entity, mapper, adapter, from_obj, is_aliased_class, with_polymorphic): if 'selectable' not in self.__dict__: self.selectable = from_obj self.froms.add(from_obj) def corresponds_to(self, entity): if self.entity_zero is None: return False elif _is_aliased_class(entity): return entity is self.entity_zero else: return not _is_aliased_class(self.entity_zero) and \ entity.common_parent(self.entity_zero) def _resolve_expr_against_query_aliases(self, query, expr, context): return query._adapt_clause(expr, False, True) def row_processor(self, query, context, custom_rows): column = self._resolve_expr_against_query_aliases( query, self.column, context) if context.adapter: column = context.adapter.columns[column] def proc(row, result): return row[column] return proc, self._label_name def setup_context(self, query, context): column = self._resolve_expr_against_query_aliases( query, self.column, context) context.froms += tuple(self.froms) context.primary_columns.append(column) def __str__(self): return str(self.column) log.class_logger(Query) class QueryContext(object): multi_row_eager_loaders = False adapter = None froms = () def __init__(self, query): if query._statement is not None: if isinstance(query._statement, expression._SelectBase) and \ not query._statement.use_labels: self.statement = query._statement.apply_labels() else: self.statement = query._statement else: self.statement = None self.from_clause = query._from_obj self.whereclause = query._criterion self.order_by = query._order_by self.query = query self.session = query.session self.populate_existing = query._populate_existing self.invoke_all_eagers = query._invoke_all_eagers self.version_check = query._version_check self.refresh_state = query._refresh_state self.primary_columns = [] self.secondary_columns = [] self.eager_order_by = [] self.eager_joins = {} self.create_eager_joins = [] self.propagate_options = set(o for o in query._with_options if o.propagate_to_loaders) self.attributes = query._attributes.copy() class AliasOption(interfaces.MapperOption): def __init__(self, alias): self.alias = alias def process_query(self, query): if isinstance(self.alias, basestring): alias = query._mapper_zero().mapped_table.alias(self.alias) else: alias = self.alias query._from_obj_alias = sql_util.ColumnAdapter(alias) _new_runid = util.counter()
gpl-3.0
[ 3, 9813, 15, 1131, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 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, 624, 1918, 8133, 1021, 436, 2291, 14, 199, 199, 23891, 314, 520, 533, 5026, 3227, 64, 1021, 12, 314, 18796, 221, 199, 8514, 1202, 701, 314, 23383, 370, 6982, 3050, 9212, 14, 199, 199, 1918, 520, 533, 5026, 3227, 64, 1021, 1077, 440, 506, 3743, 2972, 543, 314, 199, 26, 533, 5026, 5446, 64, 1021, 12, 1314, 7890, 3050, 221, 199, 4859, 5331, 737, 314, 5385, 334, 2865, 13, 8832, 9, 2166, 14, 221, 1124, 3227, 1040, 22754, 687, 221, 199, 1040, 5446, 1040, 315, 626, 652, 2529, 23383, 13, 11663, 2251, 436, 17232, 83, 543, 376, 221, 199, 8832, 2351, 12, 29781, 314, 1124, 5446, 1040, 6982, 17232, 83, 5370, 543, 314, 221, 199, 4659, 370, 372, 6076, 754, 5951, 14, 199, 199, 624, 199, 199, 504, 7975, 492, 6036, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 8335, 492, 3875, 12, 4884, 12, 943, 12, 4177, 199, 504, 8335, 492, 3178, 465, 2937, 63, 2804, 199, 504, 8335, 14, 1025, 492, 3178, 465, 9813, 63, 2804, 199, 504, 8335, 14, 3009, 492, 4884, 465, 3875, 63, 1974, 199, 504, 8335, 14, 3009, 492, 3965, 12, 5684, 1384, 12, 10211, 199, 504, 8335, 14, 1025, 492, 334, 272, 3004, 12, 8386, 12, 7796, 12, 909, 63, 7153, 12, 29207, 12, 272, 776, 199, 504, 8335, 14, 1025, 14, 1974, 492, 334, 272, 15170, 11185, 2543, 12, 1549, 2054, 68, 4185, 12, 485, 4502, 63, 4120, 12, 485, 4502, 63, 815, 12, 272, 485, 374, 63, 26930, 63, 533, 12, 485, 374, 63, 11663, 63, 533, 12, 485, 1025, 63, 3406, 12, 485, 1025, 63, 18837, 12, 272, 4263, 465, 9813, 63, 904, 12, 1045, 63, 1708, 12, 485, 962, 63, 305, 63, 498, 12, 26642, 272, 776, 421, 199, 363, 452, 363, 275, 788, 3227, 297, 283, 3227, 2998, 297, 283, 26930, 418, 421, 199, 318, 485, 2038, 1905, 2031, 305, 13049, 304, 272, 408, 6470, 282, 1083, 465, 1519, 1905, 1041, 339, 768, 1974, 14, 11547, 272, 347, 3550, 8, 2324, 12, 627, 589, 12, 1011, 829, 304, 267, 291, 275, 1249, 59, 16, 18289, 6311, 342, 267, 367, 14412, 315, 22835, 26, 288, 14412, 8, 277, 12, 4325, 14, 1532, 63, 354, 9, 267, 4325, 8, 277, 12, 627, 589, 59, 17, 8429, 1011, 829, 9, 267, 372, 291, 272, 372, 3550, 199, 199, 533, 8133, 8, 785, 304, 272, 408, 8832, 13, 1896, 5385, 14538, 909, 14, 339, 520, 533, 5026, 3227, 64, 365, 314, 1350, 402, 1006, 10468, 9834, 4046, 701, 314, 272, 23383, 12, 3865, 5204, 1824, 8097, 701, 1284, 13, 751, 1827, 5331, 465, 5521, 465, 701, 5591, 4721, 2166, 5007, 5331, 4066, 465, 4048, 3245, 8697, 14, 221, 2779, 5591, 4534, 282, 1519, 1905, 3217, 2382, 991, 27028, 3398, 4882, 372, 282, 892, 272, 520, 533, 5026, 3227, 64, 909, 12, 282, 1331, 402, 314, 26610, 543, 4722, 5591, 15647, 436, 1511, 4568, 543, 652, 14, 339, 520, 533, 5026, 3227, 64, 2251, 787, 12252, 22801, 4046, 1808, 314, 5591, 520, 5247, 18739, 4434, 14, 1131, 64, 1083, 402, 520, 533, 5026, 4434, 2313, 221, 2104, 282, 2615, 12778, 8304, 5591, 402, 520, 533, 5026, 3227, 64, 4503, 12, 1937, 314, 520, 1121, 1705, 1025, 23561, 63, 13517, 2313, 339, 408, 339, 485, 4296, 63, 10283, 3640, 275, 715, 272, 485, 4296, 63, 305, 13049, 275, 715, 272, 485, 1045, 63, 3512, 275, 756, 272, 485, 21418, 275, 488, 272, 485, 11481, 63, 529, 275, 488, 272, 485, 831, 632, 275, 488, 272, 485, 1648, 63, 991, 275, 756, 272, 485, 923, 63, 991, 275, 756, 272, 485, 31569, 275, 488, 272, 485, 12926, 275, 756, 272, 485, 14124, 275, 488, 272, 485, 2743, 275, 488, 272, 485, 3097, 275, 488, 272, 485, 6242, 275, 488, 272, 485, 30743, 275, 9522, 342, 272, 485, 13817, 63, 5952, 275, 756, 272, 485, 15195, 63, 452, 63, 69, 10246, 275, 715, 272, 485, 1023, 63, 1074, 275, 756, 272, 485, 2495, 4939, 275, 715, 272, 485, 1818, 63, 515, 275, 6248, 272, 485, 2118, 63, 912, 63, 6750, 275, 488, 272, 485, 6635, 63, 929, 275, 488, 272, 485, 504, 63, 1113, 275, 6248, 272, 485, 904, 63, 8327, 275, 6248, 272, 485, 2416, 63, 504, 63, 4502, 275, 488, 272, 485, 1541, 63, 8602, 275, 488, 272, 485, 504, 63, 1113, 63, 3620, 275, 488, 272, 485, 904, 515, 275, 485, 904, 1403, 275, 4884, 14, 17836, 807, 342, 272, 485, 9416, 63, 1419, 275, 4884, 14, 17836, 807, 342, 272, 485, 1162, 275, 4884, 14, 17836, 807, 342, 272, 485, 2987, 275, 4884, 14, 17836, 807, 342, 272, 485, 1045, 63, 1419, 275, 6248, 272, 485, 1045, 63, 12354, 275, 6248, 272, 485, 4296, 63, 4780, 63, 29506, 275, 715, 339, 347, 636, 826, 721, 277, 12, 9045, 12, 2351, 29, 403, 304, 267, 291, 14, 1730, 275, 2351, 267, 291, 423, 16653, 63, 21680, 275, 1052, 267, 291, 423, 409, 63, 8327, 8, 8327, 9, 339, 347, 485, 409, 63, 8327, 8, 277, 12, 9045, 12, 4642, 63, 5029, 29, 403, 304, 267, 340, 4642, 63, 5029, 365, 488, 26, 288, 4642, 63, 5029, 275, 485, 3227, 7302, 267, 291, 423, 8327, 275, 942, 267, 367, 15992, 315, 4884, 14, 475, 63, 513, 8, 8327, 304, 288, 4642, 63, 5029, 8, 277, 12, 15992, 9, 398, 291, 423, 2758, 63, 3620, 6315, 8, 277, 423, 8327, 9, 339, 347, 485, 2758, 63, 3620, 6315, 8, 277, 12, 9045, 304, 267, 340, 2688, 8, 277, 12, 2513, 7153, 63, 10394, 63, 1130, 735, 288, 327, 9987, 5048, 370, 8663, 282, 2849, 2341, 12, 1325, 16743, 370, 7981, 288, 327, 1007, 1118, 1026, 14631, 340, 1284, 13, 751, 365, 295, 4941, 1300, 1827, 543, 9697, 288, 327, 1329, 402, 26642, 342, 2251, 288, 291 ]
[ 9813, 15, 1131, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 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, 624, 1918, 8133, 1021, 436, 2291, 14, 199, 199, 23891, 314, 520, 533, 5026, 3227, 64, 1021, 12, 314, 18796, 221, 199, 8514, 1202, 701, 314, 23383, 370, 6982, 3050, 9212, 14, 199, 199, 1918, 520, 533, 5026, 3227, 64, 1021, 1077, 440, 506, 3743, 2972, 543, 314, 199, 26, 533, 5026, 5446, 64, 1021, 12, 1314, 7890, 3050, 221, 199, 4859, 5331, 737, 314, 5385, 334, 2865, 13, 8832, 9, 2166, 14, 221, 1124, 3227, 1040, 22754, 687, 221, 199, 1040, 5446, 1040, 315, 626, 652, 2529, 23383, 13, 11663, 2251, 436, 17232, 83, 543, 376, 221, 199, 8832, 2351, 12, 29781, 314, 1124, 5446, 1040, 6982, 17232, 83, 5370, 543, 314, 221, 199, 4659, 370, 372, 6076, 754, 5951, 14, 199, 199, 624, 199, 199, 504, 7975, 492, 6036, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 8335, 492, 3875, 12, 4884, 12, 943, 12, 4177, 199, 504, 8335, 492, 3178, 465, 2937, 63, 2804, 199, 504, 8335, 14, 1025, 492, 3178, 465, 9813, 63, 2804, 199, 504, 8335, 14, 3009, 492, 4884, 465, 3875, 63, 1974, 199, 504, 8335, 14, 3009, 492, 3965, 12, 5684, 1384, 12, 10211, 199, 504, 8335, 14, 1025, 492, 334, 272, 3004, 12, 8386, 12, 7796, 12, 909, 63, 7153, 12, 29207, 12, 272, 776, 199, 504, 8335, 14, 1025, 14, 1974, 492, 334, 272, 15170, 11185, 2543, 12, 1549, 2054, 68, 4185, 12, 485, 4502, 63, 4120, 12, 485, 4502, 63, 815, 12, 272, 485, 374, 63, 26930, 63, 533, 12, 485, 374, 63, 11663, 63, 533, 12, 485, 1025, 63, 3406, 12, 485, 1025, 63, 18837, 12, 272, 4263, 465, 9813, 63, 904, 12, 1045, 63, 1708, 12, 485, 962, 63, 305, 63, 498, 12, 26642, 272, 776, 421, 199, 363, 452, 363, 275, 788, 3227, 297, 283, 3227, 2998, 297, 283, 26930, 418, 421, 199, 318, 485, 2038, 1905, 2031, 305, 13049, 304, 272, 408, 6470, 282, 1083, 465, 1519, 1905, 1041, 339, 768, 1974, 14, 11547, 272, 347, 3550, 8, 2324, 12, 627, 589, 12, 1011, 829, 304, 267, 291, 275, 1249, 59, 16, 18289, 6311, 342, 267, 367, 14412, 315, 22835, 26, 288, 14412, 8, 277, 12, 4325, 14, 1532, 63, 354, 9, 267, 4325, 8, 277, 12, 627, 589, 59, 17, 8429, 1011, 829, 9, 267, 372, 291, 272, 372, 3550, 199, 199, 533, 8133, 8, 785, 304, 272, 408, 8832, 13, 1896, 5385, 14538, 909, 14, 339, 520, 533, 5026, 3227, 64, 365, 314, 1350, 402, 1006, 10468, 9834, 4046, 701, 314, 272, 23383, 12, 3865, 5204, 1824, 8097, 701, 1284, 13, 751, 1827, 5331, 465, 5521, 465, 701, 5591, 4721, 2166, 5007, 5331, 4066, 465, 4048, 3245, 8697, 14, 221, 2779, 5591, 4534, 282, 1519, 1905, 3217, 2382, 991, 27028, 3398, 4882, 372, 282, 892, 272, 520, 533, 5026, 3227, 64, 909, 12, 282, 1331, 402, 314, 26610, 543, 4722, 5591, 15647, 436, 1511, 4568, 543, 652, 14, 339, 520, 533, 5026, 3227, 64, 2251, 787, 12252, 22801, 4046, 1808, 314, 5591, 520, 5247, 18739, 4434, 14, 1131, 64, 1083, 402, 520, 533, 5026, 4434, 2313, 221, 2104, 282, 2615, 12778, 8304, 5591, 402, 520, 533, 5026, 3227, 64, 4503, 12, 1937, 314, 520, 1121, 1705, 1025, 23561, 63, 13517, 2313, 339, 408, 339, 485, 4296, 63, 10283, 3640, 275, 715, 272, 485, 4296, 63, 305, 13049, 275, 715, 272, 485, 1045, 63, 3512, 275, 756, 272, 485, 21418, 275, 488, 272, 485, 11481, 63, 529, 275, 488, 272, 485, 831, 632, 275, 488, 272, 485, 1648, 63, 991, 275, 756, 272, 485, 923, 63, 991, 275, 756, 272, 485, 31569, 275, 488, 272, 485, 12926, 275, 756, 272, 485, 14124, 275, 488, 272, 485, 2743, 275, 488, 272, 485, 3097, 275, 488, 272, 485, 6242, 275, 488, 272, 485, 30743, 275, 9522, 342, 272, 485, 13817, 63, 5952, 275, 756, 272, 485, 15195, 63, 452, 63, 69, 10246, 275, 715, 272, 485, 1023, 63, 1074, 275, 756, 272, 485, 2495, 4939, 275, 715, 272, 485, 1818, 63, 515, 275, 6248, 272, 485, 2118, 63, 912, 63, 6750, 275, 488, 272, 485, 6635, 63, 929, 275, 488, 272, 485, 504, 63, 1113, 275, 6248, 272, 485, 904, 63, 8327, 275, 6248, 272, 485, 2416, 63, 504, 63, 4502, 275, 488, 272, 485, 1541, 63, 8602, 275, 488, 272, 485, 504, 63, 1113, 63, 3620, 275, 488, 272, 485, 904, 515, 275, 485, 904, 1403, 275, 4884, 14, 17836, 807, 342, 272, 485, 9416, 63, 1419, 275, 4884, 14, 17836, 807, 342, 272, 485, 1162, 275, 4884, 14, 17836, 807, 342, 272, 485, 2987, 275, 4884, 14, 17836, 807, 342, 272, 485, 1045, 63, 1419, 275, 6248, 272, 485, 1045, 63, 12354, 275, 6248, 272, 485, 4296, 63, 4780, 63, 29506, 275, 715, 339, 347, 636, 826, 721, 277, 12, 9045, 12, 2351, 29, 403, 304, 267, 291, 14, 1730, 275, 2351, 267, 291, 423, 16653, 63, 21680, 275, 1052, 267, 291, 423, 409, 63, 8327, 8, 8327, 9, 339, 347, 485, 409, 63, 8327, 8, 277, 12, 9045, 12, 4642, 63, 5029, 29, 403, 304, 267, 340, 4642, 63, 5029, 365, 488, 26, 288, 4642, 63, 5029, 275, 485, 3227, 7302, 267, 291, 423, 8327, 275, 942, 267, 367, 15992, 315, 4884, 14, 475, 63, 513, 8, 8327, 304, 288, 4642, 63, 5029, 8, 277, 12, 15992, 9, 398, 291, 423, 2758, 63, 3620, 6315, 8, 277, 423, 8327, 9, 339, 347, 485, 2758, 63, 3620, 6315, 8, 277, 12, 9045, 304, 267, 340, 2688, 8, 277, 12, 2513, 7153, 63, 10394, 63, 1130, 735, 288, 327, 9987, 5048, 370, 8663, 282, 2849, 2341, 12, 1325, 16743, 370, 7981, 288, 327, 1007, 1118, 1026, 14631, 340, 1284, 13, 751, 365, 295, 4941, 1300, 1827, 543, 9697, 288, 327, 1329, 402, 26642, 342, 2251, 288, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sopier/django
django/conf/locale/fi/formats.py
504
1390
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # from __future__ import unicode_literals # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j. E Y' TIME_FORMAT = 'G.i' DATETIME_FORMAT = r'j. E Y \k\e\l\l\o G.i' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'j.n.Y' SHORT_DATETIME_FORMAT = 'j.n.Y G.i' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = [ '%d.%m.%Y', # '20.3.2014' '%d.%m.%y', # '20.3.14' ] DATETIME_INPUT_FORMATS = [ '%d.%m.%Y %H.%M.%S', # '20.3.2014 14.30.59' '%d.%m.%Y %H.%M.%S.%f', # '20.3.2014 14.30.59.000200' '%d.%m.%Y %H.%M', # '20.3.2014 14.30' '%d.%m.%Y', # '20.3.2014' '%d.%m.%y %H.%M.%S', # '20.3.14 14.30.59' '%d.%m.%y %H.%M.%S.%f', # '20.3.14 14.30.59.000200' '%d.%m.%y %H.%M', # '20.3.14 14.30' '%d.%m.%y', # '20.3.14' ] TIME_INPUT_FORMATS = [ '%H.%M.%S', # '14.30.59' '%H.%M.%S.%f', # '14.30.59.000200' '%H.%M', # '14.30' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '\xa0' # Non-breaking space NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 662, 1488, 7, 199, 4961, 63, 4807, 275, 283, 39, 14, 73, 7, 199, 12488, 63, 4807, 275, 519, 7, 74, 14, 662, 1488, 971, 75, 60, 69, 60, 76, 60, 76, 60, 79, 598, 14, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 78, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 78, 14, 57, 598, 14, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 1165, 14, 19, 14, 7280, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 1165, 14, 19, 14, 1079, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 297, 263, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 1165, 14, 19, 14, 7280, 7, 339, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 1165, 14, 19, 14, 1079, 7, 199, 61, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1079, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 263, 327, 283, 1079, 14, 1216, 7, 199, 61, 199, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 10172, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 662, 1488, 7, 199, 4961, 63, 4807, 275, 283, 39, 14, 73, 7, 199, 12488, 63, 4807, 275, 519, 7, 74, 14, 662, 1488, 971, 75, 60, 69, 60, 76, 60, 76, 60, 79, 598, 14, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 78, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 78, 14, 57, 598, 14, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 1165, 14, 19, 14, 7280, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 1165, 14, 19, 14, 1079, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 4111, 45, 297, 263, 327, 283, 1165, 14, 19, 14, 7280, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 1165, 14, 19, 14, 7280, 7, 339, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 1165, 14, 19, 14, 1079, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 1165, 14, 19, 14, 1079, 7, 199, 61, 199, 4961, 63, 7321, 63, 14019, 275, 359, 272, 1543, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 4111, 51, 4111, 70, 297, 221, 327, 283, 1079, 14, 1216, 14, 1427, 14, 25080, 7, 272, 1543, 40, 4111, 45, 297, 263, 327, 283, 1079, 14, 1216, 7, 199, 61, 199, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 10172, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 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, 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 ]
allisson/mutirao-python-oauth
oauth_example/accounts/tests/test_views.py
1
10982
# -*- coding: utf-8 -*- from django.test import TestCase from django.core.urlresolvers import reverse from django.contrib.auth.models import User from datetime import datetime, timedelta from mock import patch from accounts.models import Account class TestIndexView(TestCase): def setUp(self): self.url = reverse('accounts_account_list') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.account1 = Account.objects.create( user=self.user, provider='twitter', provider_id='1', provider_username='fulano1', oauth_token='708983112-iaDKF97Shz8cxZu9x86ZAj0MuYZcgNkRXNniXyzI', oauth_token_secret='u2spIuwwzaRtFvUHwaGFdoA7X4e1uiXXq81oWjJ9aos', ) self.account2 = Account.objects.create( user=self.user, provider='facebook', provider_id='2', provider_username='fulano2', oauth_token='CAACo0zwBRUMBAH2Vs6GoKeeqqd4t0qxgOdqbSUF2iQLMps6pf9IKqtcV8ZAOQ9vlZA6SpqnXlxA2fdpZAbKj5s1XlTAihTWQKSCMKODCddJpZAc0EBGbIvWGxX4LqH9G1MsSIIE3xkM71UQcb10CfV9pevYUPI4ZD', expires_in=datetime.now() + timedelta(days=60) ) self.account3 = Account.objects.create( user=self.user, provider='youtube', provider_id='3', provider_username='fulano3', oauth_token='ya29.AHES6ZShg0YNnCV1U2tdXGORa8RrRtXnvaBJ4_K2cD9iuns', refresh_token='1/00Gq_VIN9zRsdRFzhX8v-OrWgz8PfCA19ZSoRa1-Ih4', expires_in=datetime.now() + timedelta(hours=1) ) self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render(self): response = self.client.get(self.url) self.assertEquals(response.status_code, 200) self.assertTrue(self.account1 in response.context['account_list']) self.assertTrue(self.account2 in response.context['account_list']) self.assertTrue(self.account3 in response.context['account_list']) def twitter_get_request_token(*args, **kwargs): return u'request_token', u'secret_token' class TestTwitterNewView(TestCase): def setUp(self): self.url = reverse('accounts_twitter_new') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) @patch('rauth.OAuth1Service.get_request_token', twitter_get_request_token) def test_render(self): response = self.client.get(self.url) self.assertEquals( response['Location'], 'https://api.twitter.com/oauth/authorize?oauth_token=request_token' ) def twitter_get_access_token(*args, **kwargs): return u'oauth_token', u'oauth_token_secret' def twitter_get(*args, **kwargs): class TwitterGet(object): def json(self): data = {} data['id'] = 38895958 data['screen_name'] = 'theSeanCook' return data return TwitterGet() def twitter_get_session(*args, **kwargs): return 'oauth_token_secret' class TestTwitterCallbackView(TestCase): def setUp(self): self.url = reverse('accounts_twitter_callback') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render_without_tokens(self): response = self.client.get(self.url, follow=True) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Ocorreu um erro ao adicionar a conta do twitter.') response = self.client.get( self.url, {'oauth_token': 'oauth_token', 'oauth_verifier': 'oauth_verifier'}, follow=True ) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Ocorreu um erro ao adicionar a conta do twitter.') @patch('rauth.OAuth1Service.get_access_token', twitter_get_access_token) @patch('rauth.OAuth1Session.get', twitter_get) @patch('django.contrib.sessions.backends.signed_cookies.SessionStore.get', twitter_get_session) def test_render(self): session = self.client.session session['oauth_token_secret'] = 'oauth_token_secret' session.save() response = self.client.get( self.url, {'oauth_token': 'oauth_token', 'oauth_verifier': 'oauth_verifier'}, follow=True ) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Conta do twitter adicionada com sucesso.') self.assertTrue( Account.objects.filter( provider='twitter', provider_id='38895958', provider_username='theSeanCook' ) ) class TestFacebookNewView(TestCase): def setUp(self): self.url = reverse('accounts_facebook_new') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render(self): response = self.client.get(self.url) self.assertEquals( response['Location'], 'https://www.facebook.com/dialog/oauth?redirect_uri=http%3A%2F%2Fmutiraopython.org%2Faccounts%2Fnew%2Ffacebook%2Fcallback%2F&client_id=185625198282051' ) def facebook_get_raw_access_token(*args, **kwargs): class FacebookGetRaw(object): @property def content(self): data = 'access_token=access_token&expires=5158944' return data return FacebookGetRaw() def facebook_get(*args, **kwargs): class FacebookGet(object): def json(self): data = {} data['id'] = 38895958 data['username'] = 'theSeanCook' return data return FacebookGet() class TestFacebookCallbackView(TestCase): def setUp(self): self.url = reverse('accounts_facebook_callback') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render_without_code(self): response = self.client.get(self.url, follow=True) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Ocorreu um erro ao adicionar a conta do facebook.') @patch('rauth.OAuth2Service.get_raw_access_token', facebook_get_raw_access_token) @patch('rauth.OAuth2Session.get', facebook_get) def test_render(self): response = self.client.get(self.url, {'code': 'code'}, follow=True) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Conta do facebook adicionada com sucesso.') self.assertTrue( Account.objects.filter( provider='facebook', provider_id='38895958', provider_username='theSeanCook' ) ) class TestYoutubeNewView(TestCase): def setUp(self): self.url = reverse('accounts_youtube_new') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render(self): response = self.client.get(self.url) self.assertEquals( response['Location'], 'https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Fmutiraopython.org%2Faccounts%2Fnew%2Fyoutube%2Fcallback%2F&response_type=code&client_id=863393693267.apps.googleusercontent.com&approval_prompt=force&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline' ) def youtube_get_raw_access_token(*args, **kwargs): class YoutubeGetRaw(object): def json(self): data = { 'access_token': 'access_token', 'expires_in': 5158944, 'refresh_token': 'refresh_token' } return data return YoutubeGetRaw() def youtube_get(*args, **kwargs): class YoutubeGet(object): def json(self): data = {} data['id'] = 38895958 data['email'] = 'user@email.com' return data return YoutubeGet() class TestYoutubeCallbackView(TestCase): def setUp(self): self.url = reverse('accounts_youtube_callback') self.user = User.objects.create_user('user1', 'user1@email.com', '123456') self.client.login(username='user1', password='123456') def test_without_login(self): self.client.logout() response = self.client.get(self.url, follow=True) self.assertRedirects(response, '/login/?next=' + self.url) def test_render_without_code(self): response = self.client.get(self.url, follow=True) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Ocorreu um erro ao adicionar a conta do youtube.') @patch('rauth.OAuth2Service.get_raw_access_token', youtube_get_raw_access_token) @patch('rauth.OAuth2Session.get', youtube_get) def test_render(self): response = self.client.get(self.url, {'code': 'code'}, follow=True) self.assertRedirects(response, reverse('accounts_account_list')) self.assertContains(response, u'Conta do youtube adicionada com sucesso.') self.assertTrue( Account.objects.filter( provider='youtube', provider_id='38895958', provider_username='user@email.com' ) )
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 1683, 492, 3371, 199, 199, 504, 12639, 14, 992, 492, 9973, 421, 199, 533, 1379, 2681, 2768, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 633, 275, 3837, 360, 8370, 63, 2048, 63, 513, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 751, 17, 297, 283, 751, 17, 32, 2123, 14, 957, 297, 283, 19060, 358, 267, 291, 14, 2048, 17, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 13746, 297, 288, 5022, 63, 344, 534, 17, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 17, 297, 288, 9725, 63, 1418, 534, 2760, 13176, 2192, 713, 13, 4674, 10892, 38, 2576, 2662, 90, 24, 11859, 58, 85, 25, 88, 1184, 21959, 74, 16, 16215, 26184, 12595, 46, 75, 15361, 46, 8445, 56, 19873, 41, 297, 288, 9725, 63, 1418, 63, 4731, 534, 85, 18, 681, 41, 85, 978, 8076, 50, 84, 38, 86, 53, 40, 758, 17395, 1117, 33, 23, 56, 20, 69, 17, 1907, 2483, 81, 2835, 79, 55, 74, 42, 25, 31763, 297, 267, 776, 267, 291, 14, 2048, 18, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 16652, 297, 288, 5022, 63, 344, 534, 18, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 18, 297, 288, 9725, 63, 1418, 534, 35, 2276, 967, 16, 90, 87, 7184, 2639, 4134, 40, 18, 20343, 22, 7250, 43, 1024, 16672, 68, 20, 84, 16, 81, 88, 71, 47, 27073, 66, 6195, 38, 18, 73, 2940, 45, 1190, 22, 9928, 25, 41, 43, 81, 3641, 54, 24, 21959, 47, 49, 25, 7300, 21959, 22, 5058, 15156, 56, 76, 7471, 18, 2592, 80, 58, 5583, 43, 74, 21, 83, 17, 56, 76, 6166, 24278, 16491, 49, 43, 5153, 18379, 47, 5196, 617, 42, 80, 58, 1945, 16, 14138, 30271, 41, 86, 55, 39, 24110, 20, 44, 81, 40, 25, 39, 17, 13586, 2684, 4332, 19, 28351, 45, 3172, 53, 49, 2894, 709, 24304, 54, 25, 321, 32345, 2160, 41, 20, 58, 36, 297, 288, 12261, 63, 262, 29, 2083, 14, 2131, 342, 435, 6871, 8, 4899, 29, 2259, 9, 267, 776, 267, 291, 14, 2048, 19, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 9788, 297, 288, 5022, 63, 344, 534, 19, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 19, 297, 288, 9725, 63, 1418, 534, 11552, 1398, 14, 20755, 654, 22, 58, 2662, 71, 16, 30644, 78, 12847, 17, 53, 18, 2076, 56, 39, 726, 65, 24, 50, 82, 50, 84, 56, 78, 3042, 16262, 20, 63, 43, 18, 67, 36, 25, 73, 324, 83, 297, 288, 9236, 63, 1418, 534, 17, 15, 383, 39, 81, 63, 54, 568, 25, 90, 50, 3893, 11778, 3951, 56, 24, 86, 13, 2844, 55, 6838, 24, 48, 70, 3263, 1167, 58, 5158, 1537, 17, 13, 41, 72, 20, 297, 288, 12261, 63, 262, 29, 2083, 14, 2131, 342, 435, 6871, 8, 8419, 29, 17, 9, 267, 776, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 751, 17, 297, 2505, 534, 19060, 358, 339, 347, 511, 63, 7395, 63, 2886, 8, 277, 304, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 12, 2035, 29, 549, 9, 267, 291, 14, 17466, 8, 1310, 12, 1994, 2886, 10197, 2184, 534, 435, 291, 14, 633, 9, 339, 347, 511, 63, 3352, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 9, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 1815, 8, 277, 14, 2048, 17, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 267, 291, 14, 1815, 8, 277, 14, 2048, 18, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 267, 291, 14, 1815, 8, 277, 14, 2048, 19, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 421, 199, 318, 15811, 63, 362, 63, 1069, 63, 1418, 2031, 589, 12, 1011, 958, 304, 272, 372, 399, 3984, 613, 63, 1418, 297, 399, 1159, 825, 3292, 63, 1418, 7, 421, 199, 533, 1379, 24540, 4665, 2768, 8, 1746, 304, 2286, 347, 3613, 8, 277, 304, 267, 291, 14, 633, 275, 3837, 360, 8370, 63, 13746, 63, 1222, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 751, 17, 297, 283, 751, 17, 32, 2123, 14, 957, 297, 283, 19060, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 751, 17, 297, 2505, 534, 19060, 358, 339, 347, 511, 63, 7395, 63, 2886, 8, 277, 304, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 12, 2035, 29, 549, 9, 267, 291, 14, 17466, 8, 1310, 12, 1994, 2886, 10197, 2184, 534, 435, 291, 14, 633, 9, 339, 768, 2068, 360, 345, 762, 14, 12906, 17, 3167, 14, 362, 63, 1069, 63, 1418, 297, 15811, 63, 362, 63, 1069, 63, 1418, 9, 272, 347, 511, 63, 3352, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 9, 267, 291, 14, 2947, 8, 288, 1177, 459, 6592, 995, 288, 283, 2859, 921, 1246, 14, 13746, 14, 957, 15, 6126, 15, 14204, 31, 6126, 63, 1418, 29, 1069, 63, 1418, 7, 267, 776, 421, 199, 318, 15811, 63, 362, 63, 2732, 63, 1418, 2031, 589, 12, 1011, 958, 304, 272, 372, 399, 7, 6126, 63, 1418, 297, 399, 7, 6126, 63, 1418, 63, 4731, 7, 199, 199, 318, 15811, 63, 362, 2031, 589, 12, 1011, 958, 304, 339, 1021, 19259, 1002, 8, 785, 304, 398, 347, 2022, 8, 277, 304, 288, 666, 275, 1052, 288, 666, 459, 344, 418, 275, 650, 13976, 1427, 2010, 288, 666, 459, 5410, 63, 354, 418, 275 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 1683, 492, 3371, 199, 199, 504, 12639, 14, 992, 492, 9973, 421, 199, 533, 1379, 2681, 2768, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 633, 275, 3837, 360, 8370, 63, 2048, 63, 513, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 751, 17, 297, 283, 751, 17, 32, 2123, 14, 957, 297, 283, 19060, 358, 267, 291, 14, 2048, 17, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 13746, 297, 288, 5022, 63, 344, 534, 17, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 17, 297, 288, 9725, 63, 1418, 534, 2760, 13176, 2192, 713, 13, 4674, 10892, 38, 2576, 2662, 90, 24, 11859, 58, 85, 25, 88, 1184, 21959, 74, 16, 16215, 26184, 12595, 46, 75, 15361, 46, 8445, 56, 19873, 41, 297, 288, 9725, 63, 1418, 63, 4731, 534, 85, 18, 681, 41, 85, 978, 8076, 50, 84, 38, 86, 53, 40, 758, 17395, 1117, 33, 23, 56, 20, 69, 17, 1907, 2483, 81, 2835, 79, 55, 74, 42, 25, 31763, 297, 267, 776, 267, 291, 14, 2048, 18, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 16652, 297, 288, 5022, 63, 344, 534, 18, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 18, 297, 288, 9725, 63, 1418, 534, 35, 2276, 967, 16, 90, 87, 7184, 2639, 4134, 40, 18, 20343, 22, 7250, 43, 1024, 16672, 68, 20, 84, 16, 81, 88, 71, 47, 27073, 66, 6195, 38, 18, 73, 2940, 45, 1190, 22, 9928, 25, 41, 43, 81, 3641, 54, 24, 21959, 47, 49, 25, 7300, 21959, 22, 5058, 15156, 56, 76, 7471, 18, 2592, 80, 58, 5583, 43, 74, 21, 83, 17, 56, 76, 6166, 24278, 16491, 49, 43, 5153, 18379, 47, 5196, 617, 42, 80, 58, 1945, 16, 14138, 30271, 41, 86, 55, 39, 24110, 20, 44, 81, 40, 25, 39, 17, 13586, 2684, 4332, 19, 28351, 45, 3172, 53, 49, 2894, 709, 24304, 54, 25, 321, 32345, 2160, 41, 20, 58, 36, 297, 288, 12261, 63, 262, 29, 2083, 14, 2131, 342, 435, 6871, 8, 4899, 29, 2259, 9, 267, 776, 267, 291, 14, 2048, 19, 275, 9973, 14, 1462, 14, 981, 8, 288, 922, 29, 277, 14, 751, 12, 288, 5022, 534, 9788, 297, 288, 5022, 63, 344, 534, 19, 297, 288, 5022, 63, 2473, 534, 1893, 8143, 19, 297, 288, 9725, 63, 1418, 534, 11552, 1398, 14, 20755, 654, 22, 58, 2662, 71, 16, 30644, 78, 12847, 17, 53, 18, 2076, 56, 39, 726, 65, 24, 50, 82, 50, 84, 56, 78, 3042, 16262, 20, 63, 43, 18, 67, 36, 25, 73, 324, 83, 297, 288, 9236, 63, 1418, 534, 17, 15, 383, 39, 81, 63, 54, 568, 25, 90, 50, 3893, 11778, 3951, 56, 24, 86, 13, 2844, 55, 6838, 24, 48, 70, 3263, 1167, 58, 5158, 1537, 17, 13, 41, 72, 20, 297, 288, 12261, 63, 262, 29, 2083, 14, 2131, 342, 435, 6871, 8, 8419, 29, 17, 9, 267, 776, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 751, 17, 297, 2505, 534, 19060, 358, 339, 347, 511, 63, 7395, 63, 2886, 8, 277, 304, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 12, 2035, 29, 549, 9, 267, 291, 14, 17466, 8, 1310, 12, 1994, 2886, 10197, 2184, 534, 435, 291, 14, 633, 9, 339, 347, 511, 63, 3352, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 9, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 1815, 8, 277, 14, 2048, 17, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 267, 291, 14, 1815, 8, 277, 14, 2048, 18, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 267, 291, 14, 1815, 8, 277, 14, 2048, 19, 315, 1177, 14, 1100, 459, 2048, 63, 513, 1105, 421, 199, 318, 15811, 63, 362, 63, 1069, 63, 1418, 2031, 589, 12, 1011, 958, 304, 272, 372, 399, 3984, 613, 63, 1418, 297, 399, 1159, 825, 3292, 63, 1418, 7, 421, 199, 533, 1379, 24540, 4665, 2768, 8, 1746, 304, 2286, 347, 3613, 8, 277, 304, 267, 291, 14, 633, 275, 3837, 360, 8370, 63, 13746, 63, 1222, 358, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 751, 17, 297, 283, 751, 17, 32, 2123, 14, 957, 297, 283, 19060, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 534, 751, 17, 297, 2505, 534, 19060, 358, 339, 347, 511, 63, 7395, 63, 2886, 8, 277, 304, 267, 291, 14, 1258, 14, 11646, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 12, 2035, 29, 549, 9, 267, 291, 14, 17466, 8, 1310, 12, 1994, 2886, 10197, 2184, 534, 435, 291, 14, 633, 9, 339, 768, 2068, 360, 345, 762, 14, 12906, 17, 3167, 14, 362, 63, 1069, 63, 1418, 297, 15811, 63, 362, 63, 1069, 63, 1418, 9, 272, 347, 511, 63, 3352, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 633, 9, 267, 291, 14, 2947, 8, 288, 1177, 459, 6592, 995, 288, 283, 2859, 921, 1246, 14, 13746, 14, 957, 15, 6126, 15, 14204, 31, 6126, 63, 1418, 29, 1069, 63, 1418, 7, 267, 776, 421, 199, 318, 15811, 63, 362, 63, 2732, 63, 1418, 2031, 589, 12, 1011, 958, 304, 272, 372, 399, 7, 6126, 63, 1418, 297, 399, 7, 6126, 63, 1418, 63, 4731, 7, 199, 199, 318, 15811, 63, 362, 2031, 589, 12, 1011, 958, 304, 339, 1021, 19259, 1002, 8, 785, 304, 398, 347, 2022, 8, 277, 304, 288, 666, 275, 1052, 288, 666, 459, 344, 418, 275, 650, 13976, 1427, 2010, 288, 666, 459, 5410, 63, 354, 418, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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