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
alec-heif/MIT-Thesis
spark-bin/python/pyspark/profiler.py
77
5678
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import cProfile import pstats import os import atexit from pyspark.accumulators import AccumulatorParam class ProfilerCollector(object): """ This class keeps track of different profilers on a per stage basis. Also this is used to create new profilers for the different stages. """ def __init__(self, profiler_cls, dump_path=None): self.profiler_cls = profiler_cls self.profile_dump_path = dump_path self.profilers = [] def new_profiler(self, ctx): """ Create a new profiler using class `profiler_cls` """ return self.profiler_cls(ctx) def add_profiler(self, id, profiler): """ Add a profiler for RDD `id` """ if not self.profilers: if self.profile_dump_path: atexit.register(self.dump_profiles, self.profile_dump_path) else: atexit.register(self.show_profiles) self.profilers.append([id, profiler, False]) def dump_profiles(self, path): """ Dump the profile stats into directory `path` """ for id, profiler, _ in self.profilers: profiler.dump(id, path) self.profilers = [] def show_profiles(self): """ Print the profile stats to stdout """ for i, (id, profiler, showed) in enumerate(self.profilers): if not showed and profiler: profiler.show(id) # mark it as showed self.profilers[i][2] = True class Profiler(object): """ .. note:: DeveloperApi PySpark supports custom profilers, this is to allow for different profilers to be used as well as outputting to different formats than what is provided in the BasicProfiler. A custom profiler has to define or inherit the following methods: profile - will produce a system profile of some sort. stats - return the collected stats. dump - dumps the profiles to a path add - adds a profile to the existing accumulated profile The profiler class is chosen when creating a SparkContext >>> from pyspark import SparkConf, SparkContext >>> from pyspark import BasicProfiler >>> class MyCustomProfiler(BasicProfiler): ... def show(self, id): ... print("My custom profiles for RDD:%s" % id) ... >>> conf = SparkConf().set("spark.python.profile", "true") >>> sc = SparkContext('local', 'test', conf=conf, profiler_cls=MyCustomProfiler) >>> sc.parallelize(range(1000)).map(lambda x: 2 * x).take(10) [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] >>> sc.parallelize(range(1000)).count() 1000 >>> sc.show_profiles() My custom profiles for RDD:1 My custom profiles for RDD:3 >>> sc.stop() """ def __init__(self, ctx): pass def profile(self, func): """ Do profiling on the function `func`""" raise NotImplemented def stats(self): """ Return the collected profiling stats (pstats.Stats)""" raise NotImplemented def show(self, id): """ Print the profile stats to stdout, id is the RDD id """ stats = self.stats() if stats: print("=" * 60) print("Profile of RDD<id=%d>" % id) print("=" * 60) stats.sort_stats("time", "cumulative").print_stats() def dump(self, id, path): """ Dump the profile into path, id is the RDD id """ if not os.path.exists(path): os.makedirs(path) stats = self.stats() if stats: p = os.path.join(path, "rdd_%d.pstats" % id) stats.dump_stats(p) class PStatsParam(AccumulatorParam): """PStatsParam is used to merge pstats.Stats""" @staticmethod def zero(value): return None @staticmethod def addInPlace(value1, value2): if value1 is None: return value2 value1.add(value2) return value1 class BasicProfiler(Profiler): """ BasicProfiler is the default profiler, which is implemented based on cProfile and Accumulator """ def __init__(self, ctx): Profiler.__init__(self, ctx) # Creates a new accumulator for combining the profiles of different # partitions of a stage self._accumulator = ctx.accumulator(None, PStatsParam) def profile(self, func): """ Runs and profiles the method to_profile passed in. A profile object is returned. """ pr = cProfile.Profile() pr.runcall(func) st = pstats.Stats(pr) st.stream = None # make it picklable st.strip_dirs() # Adds a new profile to the existing accumulated value self._accumulator.add(st) def stats(self): return self._accumulator.value if __name__ == "__main__": import doctest (failure_count, test_count) = doctest.testmod() if failure_count: exit(-1)
mit
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 286, 5736, 199, 646, 299, 3200, 199, 646, 747, 199, 646, 19840, 199, 199, 504, 15847, 14, 13223, 26609, 492, 32254, 6109, 4098, 421, 199, 533, 14386, 82, 12852, 8, 785, 304, 272, 408, 272, 961, 1021, 18578, 4426, 402, 3365, 4690, 2393, 641, 282, 1126, 272, 9546, 5597, 14, 6121, 642, 365, 1202, 370, 1218, 892, 4690, 2393, 367, 272, 314, 3365, 24490, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 23173, 63, 1886, 12, 5461, 63, 515, 29, 403, 304, 267, 291, 14, 20132, 63, 1886, 275, 23173, 63, 1886, 267, 291, 14, 2913, 63, 2724, 63, 515, 275, 5461, 63, 515, 267, 291, 14, 2913, 2393, 275, 942, 339, 347, 892, 63, 20132, 8, 277, 12, 4027, 304, 267, 408, 2790, 282, 892, 23173, 1808, 1021, 658, 20132, 63, 1886, 64, 408, 267, 372, 291, 14, 20132, 63, 1886, 8, 3799, 9, 339, 347, 1050, 63, 20132, 8, 277, 12, 1305, 12, 23173, 304, 267, 408, 2654, 282, 23173, 367, 21310, 658, 344, 64, 408, 267, 340, 440, 291, 14, 2913, 2393, 26, 288, 340, 291, 14, 2913, 63, 2724, 63, 515, 26, 355, 19840, 14, 2683, 8, 277, 14, 2724, 63, 11225, 12, 291, 14, 2913, 63, 2724, 63, 515, 9, 288, 587, 26, 355, 19840, 14, 2683, 8, 277, 14, 2384, 63, 11225, 9, 398, 291, 14, 2913, 2393, 14, 740, 779, 344, 12, 23173, 12, 756, 566, 339, 347, 5461, 63, 11225, 8, 277, 12, 931, 304, 267, 408, 19460, 314, 4690, 5020, 1901, 2082, 658, 515, 64, 408, 267, 367, 1305, 12, 23173, 12, 485, 315, 291, 14, 2913, 2393, 26, 288, 23173, 14, 2724, 8, 344, 12, 931, 9, 267, 291, 14, 2913, 2393, 275, 942, 339, 347, 2498, 63, 11225, 8, 277, 304, 267, 408, 9101, 314, 4690, 5020, 370, 3839, 408, 267, 367, 284, 12, 334, 344, 12, 23173, 12, 2498, 379, 9, 315, 3874, 8, 277, 14, 2913, 2393, 304, 288, 340, 440, 2498, 379, 436, 23173, 26, 355, 23173, 14, 2384, 8, 344, 9, 355, 327, 2216, 652, 465, 2498, 379, 355, 291, 14, 2913, 2393, 59, 73, 1527, 18, 61, 275, 715, 421, 199, 533, 14386, 82, 8, 785, 304, 272, 408, 272, 2508, 5317, 447, 9607, 7394, 339, 1611, 27110, 5171, 3537, 4690, 2393, 12, 642, 365, 370, 2040, 367, 3365, 4690, 2393, 370, 272, 506, 1202, 465, 5521, 465, 1072, 1337, 370, 3365, 6752, 2419, 4052, 365, 2741, 315, 314, 272, 10082, 5736, 82, 14, 339, 437, 3537, 23173, 965, 370, 5627, 503, 8287, 314, 2569, 3102, 26, 267, 4690, 446, 911, 7389, 282, 2656, 4690, 402, 2005, 4069, 14, 267, 5020, 446, 372, 314, 13736, 5020, 14, 267, 5461, 446, 16864, 314, 17390, 370, 282, 931, 267, 1050, 446, 9584, 282, 4690, 370, 314, 3411, 29845, 4690, 339, 710, 23173, 1021, 365, 12414, 1380, 6425, 282, 21769, 339, 1306, 687, 15847, 492, 13932, 8930, 12, 21769, 272, 1306, 687, 15847, 492, 10082, 5736, 82, 272, 1306, 1021, 4932, 7223, 5736, 82, 8, 6845, 5736, 82, 304, 272, 2263, 258, 347, 2498, 8, 277, 12, 1305, 304, 272, 2263, 260, 870, 480, 5713, 3537, 17390, 367, 21310, 2689, 83, 2, 450, 1305, 9, 272, 2263, 272, 1306, 3743, 275, 13932, 8930, 1252, 409, 480, 9852, 14, 1548, 14, 2913, 401, 298, 2052, 531, 272, 1306, 4061, 275, 21769, 360, 1832, 297, 283, 396, 297, 3743, 29, 2190, 12, 23173, 63, 1886, 29, 5713, 7223, 5736, 82, 9, 272, 1306, 4061, 14, 27675, 8, 1842, 8, 5279, 4992, 1130, 8, 2734, 671, 26, 499, 627, 671, 680, 11066, 8, 709, 9, 272, 359, 16, 12, 499, 12, 841, 12, 1227, 12, 1695, 12, 1616, 12, 3144, 12, 4329, 12, 3193, 12, 6155, 61, 272, 1306, 4061, 14, 27675, 8, 1842, 8, 5279, 4992, 835, 342, 272, 5198, 272, 1306, 4061, 14, 2384, 63, 11225, 342, 272, 4932, 3537, 17390, 367, 21310, 26, 17, 272, 4932, 3537, 17390, 367, 21310, 26, 19, 272, 1306, 4061, 14, 2379, 342, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 986, 339, 347, 4690, 8, 277, 12, 2562, 304, 267, 408, 4226, 30238, 641, 314, 805, 658, 1532, 64, 624, 267, 746, 3784, 339, 347, 5020, 8, 277, 304, 267, 408, 1432, 314, 13736, 30238, 5020, 334, 80, 3200, 14, 8257, 9471, 267, 746, 3784, 339, 347, 2498, 8, 277, 12, 1305, 304, 267, 408, 9101, 314, 4690, 5020, 370, 3839, 12, 1305, 365, 314, 21310, 1305, 408, 267, 5020, 275, 291, 14, 3200, 342, 267, 340, 5020, 26, 288, 870, 480, 628, 627, 5212, 9, 288, 870, 480, 5736, 402, 21310, 28, 344, 2458, 68, 4335, 450, 1305, 9, 288, 870, 480, 628, 627, 5212, 9, 288, 5020, 14, 3191, 63, 3200, 480, 521, 401, 298, 11898, 16813, 3471, 1361, 63, 3200, 342, 339, 347, 5461, 8, 277, 12, 1305, 12, 931, 304, 267, 408, 19460, 314, 4690, 1901, 931, 12, 1305, 365, 314, 21310, 1305, 408, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 747, 14, 8347, 8, 515, 9, 267, 5020 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 286, 5736, 199, 646, 299, 3200, 199, 646, 747, 199, 646, 19840, 199, 199, 504, 15847, 14, 13223, 26609, 492, 32254, 6109, 4098, 421, 199, 533, 14386, 82, 12852, 8, 785, 304, 272, 408, 272, 961, 1021, 18578, 4426, 402, 3365, 4690, 2393, 641, 282, 1126, 272, 9546, 5597, 14, 6121, 642, 365, 1202, 370, 1218, 892, 4690, 2393, 367, 272, 314, 3365, 24490, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 23173, 63, 1886, 12, 5461, 63, 515, 29, 403, 304, 267, 291, 14, 20132, 63, 1886, 275, 23173, 63, 1886, 267, 291, 14, 2913, 63, 2724, 63, 515, 275, 5461, 63, 515, 267, 291, 14, 2913, 2393, 275, 942, 339, 347, 892, 63, 20132, 8, 277, 12, 4027, 304, 267, 408, 2790, 282, 892, 23173, 1808, 1021, 658, 20132, 63, 1886, 64, 408, 267, 372, 291, 14, 20132, 63, 1886, 8, 3799, 9, 339, 347, 1050, 63, 20132, 8, 277, 12, 1305, 12, 23173, 304, 267, 408, 2654, 282, 23173, 367, 21310, 658, 344, 64, 408, 267, 340, 440, 291, 14, 2913, 2393, 26, 288, 340, 291, 14, 2913, 63, 2724, 63, 515, 26, 355, 19840, 14, 2683, 8, 277, 14, 2724, 63, 11225, 12, 291, 14, 2913, 63, 2724, 63, 515, 9, 288, 587, 26, 355, 19840, 14, 2683, 8, 277, 14, 2384, 63, 11225, 9, 398, 291, 14, 2913, 2393, 14, 740, 779, 344, 12, 23173, 12, 756, 566, 339, 347, 5461, 63, 11225, 8, 277, 12, 931, 304, 267, 408, 19460, 314, 4690, 5020, 1901, 2082, 658, 515, 64, 408, 267, 367, 1305, 12, 23173, 12, 485, 315, 291, 14, 2913, 2393, 26, 288, 23173, 14, 2724, 8, 344, 12, 931, 9, 267, 291, 14, 2913, 2393, 275, 942, 339, 347, 2498, 63, 11225, 8, 277, 304, 267, 408, 9101, 314, 4690, 5020, 370, 3839, 408, 267, 367, 284, 12, 334, 344, 12, 23173, 12, 2498, 379, 9, 315, 3874, 8, 277, 14, 2913, 2393, 304, 288, 340, 440, 2498, 379, 436, 23173, 26, 355, 23173, 14, 2384, 8, 344, 9, 355, 327, 2216, 652, 465, 2498, 379, 355, 291, 14, 2913, 2393, 59, 73, 1527, 18, 61, 275, 715, 421, 199, 533, 14386, 82, 8, 785, 304, 272, 408, 272, 2508, 5317, 447, 9607, 7394, 339, 1611, 27110, 5171, 3537, 4690, 2393, 12, 642, 365, 370, 2040, 367, 3365, 4690, 2393, 370, 272, 506, 1202, 465, 5521, 465, 1072, 1337, 370, 3365, 6752, 2419, 4052, 365, 2741, 315, 314, 272, 10082, 5736, 82, 14, 339, 437, 3537, 23173, 965, 370, 5627, 503, 8287, 314, 2569, 3102, 26, 267, 4690, 446, 911, 7389, 282, 2656, 4690, 402, 2005, 4069, 14, 267, 5020, 446, 372, 314, 13736, 5020, 14, 267, 5461, 446, 16864, 314, 17390, 370, 282, 931, 267, 1050, 446, 9584, 282, 4690, 370, 314, 3411, 29845, 4690, 339, 710, 23173, 1021, 365, 12414, 1380, 6425, 282, 21769, 339, 1306, 687, 15847, 492, 13932, 8930, 12, 21769, 272, 1306, 687, 15847, 492, 10082, 5736, 82, 272, 1306, 1021, 4932, 7223, 5736, 82, 8, 6845, 5736, 82, 304, 272, 2263, 258, 347, 2498, 8, 277, 12, 1305, 304, 272, 2263, 260, 870, 480, 5713, 3537, 17390, 367, 21310, 2689, 83, 2, 450, 1305, 9, 272, 2263, 272, 1306, 3743, 275, 13932, 8930, 1252, 409, 480, 9852, 14, 1548, 14, 2913, 401, 298, 2052, 531, 272, 1306, 4061, 275, 21769, 360, 1832, 297, 283, 396, 297, 3743, 29, 2190, 12, 23173, 63, 1886, 29, 5713, 7223, 5736, 82, 9, 272, 1306, 4061, 14, 27675, 8, 1842, 8, 5279, 4992, 1130, 8, 2734, 671, 26, 499, 627, 671, 680, 11066, 8, 709, 9, 272, 359, 16, 12, 499, 12, 841, 12, 1227, 12, 1695, 12, 1616, 12, 3144, 12, 4329, 12, 3193, 12, 6155, 61, 272, 1306, 4061, 14, 27675, 8, 1842, 8, 5279, 4992, 835, 342, 272, 5198, 272, 1306, 4061, 14, 2384, 63, 11225, 342, 272, 4932, 3537, 17390, 367, 21310, 26, 17, 272, 4932, 3537, 17390, 367, 21310, 26, 19, 272, 1306, 4061, 14, 2379, 342, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 986, 339, 347, 4690, 8, 277, 12, 2562, 304, 267, 408, 4226, 30238, 641, 314, 805, 658, 1532, 64, 624, 267, 746, 3784, 339, 347, 5020, 8, 277, 304, 267, 408, 1432, 314, 13736, 30238, 5020, 334, 80, 3200, 14, 8257, 9471, 267, 746, 3784, 339, 347, 2498, 8, 277, 12, 1305, 304, 267, 408, 9101, 314, 4690, 5020, 370, 3839, 12, 1305, 365, 314, 21310, 1305, 408, 267, 5020, 275, 291, 14, 3200, 342, 267, 340, 5020, 26, 288, 870, 480, 628, 627, 5212, 9, 288, 870, 480, 5736, 402, 21310, 28, 344, 2458, 68, 4335, 450, 1305, 9, 288, 870, 480, 628, 627, 5212, 9, 288, 5020, 14, 3191, 63, 3200, 480, 521, 401, 298, 11898, 16813, 3471, 1361, 63, 3200, 342, 339, 347, 5461, 8, 277, 12, 1305, 12, 931, 304, 267, 408, 19460, 314, 4690, 1901, 931, 12, 1305, 365, 314, 21310, 1305, 408, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 747, 14, 8347, 8, 515, 9, 267, 5020, 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, 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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 ]
StuartLittlefair/astropy
astropy/timeseries/periodograms/lombscargle/implementations/fastchi2_impl.py
3
4890
import numpy as np from .utils import trig_sum def lombscargle_fastchi2(t, y, dy, f0, df, Nf, normalization='standard', fit_mean=True, center_data=True, nterms=1, use_fft=True, trig_sum_kwds=None): """Lomb-Scargle Periodogram This implements a fast chi-squared periodogram using the algorithm outlined in [4]_. The result is identical to the standard Lomb-Scargle periodogram. The advantage of this algorithm is the ability to compute multiterm periodograms relatively quickly. Parameters ---------- t, y, dy : array_like (NOT astropy.Quantities) times, values, and errors of the data points. These should be broadcastable to the same shape. f0, df, Nf : (float, float, int) parameters describing the frequency grid, f = f0 + df * arange(Nf). normalization : str, optional Normalization to use for the periodogram. Options are 'standard', 'model', 'log', or 'psd'. fit_mean : bool, optional if True, include a constant offset as part of the model at each frequency. This can lead to more accurate results, especially in the case of incomplete phase coverage. center_data : bool, optional if True, pre-center the data by subtracting the weighted mean of the input data. This is especially important if ``fit_mean = False`` nterms : int, optional Number of Fourier terms in the fit Returns ------- power : array_like Lomb-Scargle power associated with each frequency. Units of the result depend on the normalization. References ---------- .. [1] M. Zechmeister and M. Kurster, A&A 496, 577-584 (2009) .. [2] W. Press et al, Numerical Recipes in C (2002) .. [3] Scargle, J.D. ApJ 263:835-853 (1982) .. [4] Palmer, J. ApJ 695:496-502 (2009) """ if nterms == 0 and not fit_mean: raise ValueError("Cannot have nterms = 0 without fitting bias") if dy is None: dy = 1 # Validate and setup input data t, y, dy = np.broadcast_arrays(t, y, dy) if t.ndim != 1: raise ValueError("t, y, dy should be one dimensional") # Validate and setup frequency grid if f0 < 0: raise ValueError("Frequencies must be positive") if df <= 0: raise ValueError("Frequency steps must be positive") if Nf <= 0: raise ValueError("Number of frequencies must be positive") w = dy ** -2.0 ws = np.sum(w) # if fit_mean is true, centering the data now simplifies the math below. if center_data or fit_mean: y = y - np.dot(w, y) / ws yw = y / dy chi2_ref = np.dot(yw, yw) kwargs = dict.copy(trig_sum_kwds or {}) kwargs.update(f0=f0, df=df, use_fft=use_fft, N=Nf) # Here we build-up the matrices XTX and XTy using pre-computed # sums. The relevant identities are # 2 sin(mx) sin(nx) = cos(m-n)x - cos(m+n)x # 2 cos(mx) cos(nx) = cos(m-n)x + cos(m+n)x # 2 sin(mx) cos(nx) = sin(m-n)x + sin(m+n)x yws = np.sum(y * w) SCw = [(np.zeros(Nf), ws * np.ones(Nf))] SCw.extend([trig_sum(t, w, freq_factor=i, **kwargs) for i in range(1, 2 * nterms + 1)]) Sw, Cw = zip(*SCw) SCyw = [(np.zeros(Nf), yws * np.ones(Nf))] SCyw.extend([trig_sum(t, w * y, freq_factor=i, **kwargs) for i in range(1, nterms + 1)]) Syw, Cyw = zip(*SCyw) # Now create an indexing scheme so we can quickly # build-up matrices at each frequency order = [('C', 0)] if fit_mean else [] order.extend(sum([[('S', i), ('C', i)] for i in range(1, nterms + 1)], [])) funcs = dict(S=lambda m, i: Syw[m][i], C=lambda m, i: Cyw[m][i], SS=lambda m, n, i: 0.5 * (Cw[abs(m - n)][i] - Cw[m + n][i]), CC=lambda m, n, i: 0.5 * (Cw[abs(m - n)][i] + Cw[m + n][i]), SC=lambda m, n, i: 0.5 * (np.sign(m - n) * Sw[abs(m - n)][i] + Sw[m + n][i]), CS=lambda m, n, i: 0.5 * (np.sign(n - m) * Sw[abs(n - m)][i] + Sw[n + m][i])) def compute_power(i): XTX = np.array([[funcs[A[0] + B[0]](A[1], B[1], i) for A in order] for B in order]) XTy = np.array([funcs[A[0]](A[1], i) for A in order]) return np.dot(XTy.T, np.linalg.solve(XTX, XTy)) p = np.array([compute_power(i) for i in range(Nf)]) if normalization == 'psd': p *= 0.5 elif normalization == 'standard': p /= chi2_ref elif normalization == 'log': p = -np.log(1 - p / chi2_ref) elif normalization == 'model': p /= chi2_ref - p else: raise ValueError(f"normalization='{normalization}' not recognized") return p
bsd-3-clause
[ 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 1208, 492, 3229, 71, 63, 1838, 421, 199, 318, 560, 887, 551, 1273, 274, 63, 7015, 13175, 18, 8, 84, 12, 612, 12, 13119, 12, 289, 16, 12, 4051, 12, 653, 70, 12, 16973, 534, 6807, 297, 586, 5542, 63, 3670, 29, 549, 12, 8126, 63, 576, 29, 549, 12, 302, 9187, 29, 17, 12, 586, 675, 63, 9996, 29, 549, 12, 3229, 71, 63, 1838, 63, 10340, 29, 403, 304, 272, 408, 44, 24370, 13, 7181, 1273, 274, 16532, 79, 1679, 339, 961, 9031, 282, 7377, 23275, 13, 12973, 6247, 79, 1679, 1808, 314, 5563, 272, 734, 23058, 315, 359, 20, 61, 3754, 710, 754, 365, 13130, 370, 314, 4465, 491, 24370, 13, 7181, 1273, 274, 272, 6247, 79, 1679, 14, 710, 30268, 402, 642, 5563, 365, 314, 272, 21255, 370, 4526, 3510, 5125, 6247, 79, 9292, 13773, 9462, 23661, 14, 339, 3897, 272, 4143, 272, 307, 12, 612, 12, 13119, 520, 1625, 63, 2930, 221, 334, 4609, 28753, 14, 2371, 4466, 1417, 9, 267, 5431, 12, 1338, 12, 436, 2552, 402, 314, 666, 4501, 14, 5723, 1077, 506, 267, 11180, 461, 370, 314, 2011, 2215, 14, 272, 289, 16, 12, 4051, 12, 653, 70, 520, 334, 1609, 12, 2069, 12, 1109, 9, 267, 2633, 13660, 314, 9857, 6068, 12, 289, 275, 289, 16, 435, 4051, 627, 20461, 8, 46, 70, 680, 272, 16973, 520, 620, 12, 2716, 267, 11514, 2072, 370, 675, 367, 314, 6247, 79, 1679, 14, 267, 8394, 787, 283, 6807, 297, 283, 1238, 297, 283, 793, 297, 503, 283, 31600, 1370, 272, 5542, 63, 3670, 520, 2155, 12, 2716, 267, 340, 715, 12, 2387, 282, 4413, 3268, 465, 1777, 402, 314, 1402, 737, 1924, 267, 9857, 14, 961, 883, 12690, 370, 1655, 23189, 2058, 12, 24002, 315, 314, 267, 1930, 402, 17110, 7669, 11745, 14, 272, 8126, 63, 576, 520, 2155, 12, 2716, 267, 340, 715, 12, 876, 13, 4218, 314, 666, 701, 24129, 316, 314, 14609, 4615, 267, 402, 314, 1324, 666, 14, 961, 365, 24002, 11012, 340, 1124, 3269, 63, 3670, 275, 756, 1040, 272, 302, 9187, 520, 1109, 12, 2716, 267, 4860, 402, 23843, 4446, 2895, 315, 314, 5542, 339, 1803, 272, 5514, 272, 7074, 520, 1625, 63, 2930, 267, 491, 24370, 13, 7181, 1273, 274, 7074, 4568, 543, 1924, 9857, 14, 267, 1910, 1405, 402, 314, 754, 11687, 641, 314, 16973, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 3107, 12736, 278, 1429, 436, 603, 14, 1804, 300, 11652, 12, 437, 6, 33, 841, 2534, 12, 959, 1138, 13, 12248, 334, 8664, 9, 272, 2508, 359, 18, 61, 644, 14, 23583, 10844, 741, 12, 653, 27685, 799, 8233, 83, 315, 445, 334, 15135, 9, 272, 2508, 359, 19, 61, 13916, 1273, 274, 12, 1603, 14, 36, 14, 13450, 42, 499, 2766, 26, 32065, 13, 23901, 334, 1167, 2564, 9, 272, 2508, 359, 20, 61, 510, 279, 2626, 12, 1603, 14, 13450, 42, 1227, 2720, 26, 18105, 13, 24653, 334, 8664, 9, 272, 408, 272, 340, 302, 9187, 508, 378, 436, 440, 5542, 63, 3670, 26, 267, 746, 1722, 480, 6612, 1172, 302, 9187, 275, 378, 1928, 21774, 10671, 531, 339, 340, 13119, 365, 488, 26, 267, 13119, 275, 413, 339, 327, 12134, 436, 3272, 1324, 666, 272, 307, 12, 612, 12, 13119, 275, 980, 14, 10786, 63, 10095, 8, 84, 12, 612, 12, 13119, 9, 272, 340, 307, 14, 8322, 1137, 413, 26, 267, 746, 1722, 480, 84, 12, 612, 12, 13119, 1077, 506, 1373, 28341, 531, 339, 327, 12134, 436, 3272, 9857, 6068, 272, 340, 289, 16, 665, 378, 26, 267, 746, 1722, 480, 38, 17085, 1471, 506, 7317, 531, 272, 340, 4051, 2695, 378, 26, 267, 746, 1722, 480, 18285, 7124, 1471, 506, 7317, 531, 272, 340, 653, 70, 2695, 378, 26, 267, 746, 1722, 480, 3259, 402, 22411, 1471, 506, 7317, 531, 339, 336, 275, 13119, 1011, 446, 18, 14, 16, 272, 10900, 275, 980, 14, 1838, 8, 87, 9, 339, 327, 340, 5542, 63, 3670, 365, 2549, 12, 8126, 316, 314, 666, 3063, 17553, 5604, 314, 3473, 5084, 14, 272, 340, 8126, 63, 576, 503, 5542, 63, 3670, 26, 267, 612, 275, 612, 446, 980, 14, 3287, 8, 87, 12, 612, 9, 1182, 10900, 339, 612, 87, 275, 612, 1182, 13119, 272, 23275, 18, 63, 1121, 275, 980, 14, 3287, 8, 89, 87, 12, 612, 87, 9, 339, 2074, 275, 1211, 14, 1574, 8, 599, 71, 63, 1838, 63, 10340, 503, 5009, 272, 2074, 14, 873, 8, 70, 16, 29, 70, 16, 12, 4051, 29, 1587, 12, 675, 63, 9996, 29, 1180, 63, 9996, 12, 653, 29, 46, 70, 9, 339, 327, 11842, 781, 1900, 13, 384, 314, 12627, 1323, 10051, 436, 1323, 32603, 1808, 876, 13, 14378, 272, 327, 27690, 14, 710, 12082, 6120, 5080, 787, 272, 327, 499, 9829, 8, 9457, 9, 9829, 8, 7343, 9, 275, 9794, 8, 77, 13, 78, 9, 88, 446, 9794, 8, 77, 11, 78, 9, 88, 272, 327, 499, 9794, 8, 9457, 9, 9794, 8, 7343, 9, 275, 9794, 8, 77, 13, 78, 9, 88, 435, 9794, 8, 77, 11, 78, 9, 88, 272, 327, 499, 9829, 8, 9457, 9, 9794, 8, 7343, 9, 275, 9829, 8, 77, 13, 78, 9, 88, 435, 9829, 8, 77, 11, 78, 9, 88, 339, 612, 3569, 275, 980, 14, 1838, 8, 89, 627, 336, 9, 339, 12075, 87, 275, 3842, 1590, 14, 4250, 8, 46, 70, 395, 10900, 627, 980, 14, 4548, 8, 46, 70, 10524, 272, 12075, 87, 14, 2880, 779, 599, 71, 63, 1838, 8, 84, 12, 336, 12, 9220, 63, 4778, 29, 73, 12, 1011, 958, 9, 355, 367, 284, 315, 1425, 8, 17, 12, 499, 627, 302, 9187, 435, 413, 3948, 272, 16666, 12, 445, 87, 275, 3482, 2031, 5153, 87, 9, 339, 428, 9156, 87, 275, 3842, 1590, 14, 4250, 8, 46, 70, 395, 612, 3569, 627, 980, 14, 4548, 8, 46, 70, 10524, 272, 428, 9156, 87, 14, 2880, 779, 599, 71, 63, 1838, 8, 84, 12, 336, 627, 612, 12, 9220, 63, 4778, 29, 73, 12, 1011, 958, 9, 326, 367, 284, 315, 1425, 8, 17 ]
[ 646, 2680, 465, 980, 199, 199, 504, 1275, 1208, 492, 3229, 71, 63, 1838, 421, 199, 318, 560, 887, 551, 1273, 274, 63, 7015, 13175, 18, 8, 84, 12, 612, 12, 13119, 12, 289, 16, 12, 4051, 12, 653, 70, 12, 16973, 534, 6807, 297, 586, 5542, 63, 3670, 29, 549, 12, 8126, 63, 576, 29, 549, 12, 302, 9187, 29, 17, 12, 586, 675, 63, 9996, 29, 549, 12, 3229, 71, 63, 1838, 63, 10340, 29, 403, 304, 272, 408, 44, 24370, 13, 7181, 1273, 274, 16532, 79, 1679, 339, 961, 9031, 282, 7377, 23275, 13, 12973, 6247, 79, 1679, 1808, 314, 5563, 272, 734, 23058, 315, 359, 20, 61, 3754, 710, 754, 365, 13130, 370, 314, 4465, 491, 24370, 13, 7181, 1273, 274, 272, 6247, 79, 1679, 14, 710, 30268, 402, 642, 5563, 365, 314, 272, 21255, 370, 4526, 3510, 5125, 6247, 79, 9292, 13773, 9462, 23661, 14, 339, 3897, 272, 4143, 272, 307, 12, 612, 12, 13119, 520, 1625, 63, 2930, 221, 334, 4609, 28753, 14, 2371, 4466, 1417, 9, 267, 5431, 12, 1338, 12, 436, 2552, 402, 314, 666, 4501, 14, 5723, 1077, 506, 267, 11180, 461, 370, 314, 2011, 2215, 14, 272, 289, 16, 12, 4051, 12, 653, 70, 520, 334, 1609, 12, 2069, 12, 1109, 9, 267, 2633, 13660, 314, 9857, 6068, 12, 289, 275, 289, 16, 435, 4051, 627, 20461, 8, 46, 70, 680, 272, 16973, 520, 620, 12, 2716, 267, 11514, 2072, 370, 675, 367, 314, 6247, 79, 1679, 14, 267, 8394, 787, 283, 6807, 297, 283, 1238, 297, 283, 793, 297, 503, 283, 31600, 1370, 272, 5542, 63, 3670, 520, 2155, 12, 2716, 267, 340, 715, 12, 2387, 282, 4413, 3268, 465, 1777, 402, 314, 1402, 737, 1924, 267, 9857, 14, 961, 883, 12690, 370, 1655, 23189, 2058, 12, 24002, 315, 314, 267, 1930, 402, 17110, 7669, 11745, 14, 272, 8126, 63, 576, 520, 2155, 12, 2716, 267, 340, 715, 12, 876, 13, 4218, 314, 666, 701, 24129, 316, 314, 14609, 4615, 267, 402, 314, 1324, 666, 14, 961, 365, 24002, 11012, 340, 1124, 3269, 63, 3670, 275, 756, 1040, 272, 302, 9187, 520, 1109, 12, 2716, 267, 4860, 402, 23843, 4446, 2895, 315, 314, 5542, 339, 1803, 272, 5514, 272, 7074, 520, 1625, 63, 2930, 267, 491, 24370, 13, 7181, 1273, 274, 7074, 4568, 543, 1924, 9857, 14, 267, 1910, 1405, 402, 314, 754, 11687, 641, 314, 16973, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 3107, 12736, 278, 1429, 436, 603, 14, 1804, 300, 11652, 12, 437, 6, 33, 841, 2534, 12, 959, 1138, 13, 12248, 334, 8664, 9, 272, 2508, 359, 18, 61, 644, 14, 23583, 10844, 741, 12, 653, 27685, 799, 8233, 83, 315, 445, 334, 15135, 9, 272, 2508, 359, 19, 61, 13916, 1273, 274, 12, 1603, 14, 36, 14, 13450, 42, 499, 2766, 26, 32065, 13, 23901, 334, 1167, 2564, 9, 272, 2508, 359, 20, 61, 510, 279, 2626, 12, 1603, 14, 13450, 42, 1227, 2720, 26, 18105, 13, 24653, 334, 8664, 9, 272, 408, 272, 340, 302, 9187, 508, 378, 436, 440, 5542, 63, 3670, 26, 267, 746, 1722, 480, 6612, 1172, 302, 9187, 275, 378, 1928, 21774, 10671, 531, 339, 340, 13119, 365, 488, 26, 267, 13119, 275, 413, 339, 327, 12134, 436, 3272, 1324, 666, 272, 307, 12, 612, 12, 13119, 275, 980, 14, 10786, 63, 10095, 8, 84, 12, 612, 12, 13119, 9, 272, 340, 307, 14, 8322, 1137, 413, 26, 267, 746, 1722, 480, 84, 12, 612, 12, 13119, 1077, 506, 1373, 28341, 531, 339, 327, 12134, 436, 3272, 9857, 6068, 272, 340, 289, 16, 665, 378, 26, 267, 746, 1722, 480, 38, 17085, 1471, 506, 7317, 531, 272, 340, 4051, 2695, 378, 26, 267, 746, 1722, 480, 18285, 7124, 1471, 506, 7317, 531, 272, 340, 653, 70, 2695, 378, 26, 267, 746, 1722, 480, 3259, 402, 22411, 1471, 506, 7317, 531, 339, 336, 275, 13119, 1011, 446, 18, 14, 16, 272, 10900, 275, 980, 14, 1838, 8, 87, 9, 339, 327, 340, 5542, 63, 3670, 365, 2549, 12, 8126, 316, 314, 666, 3063, 17553, 5604, 314, 3473, 5084, 14, 272, 340, 8126, 63, 576, 503, 5542, 63, 3670, 26, 267, 612, 275, 612, 446, 980, 14, 3287, 8, 87, 12, 612, 9, 1182, 10900, 339, 612, 87, 275, 612, 1182, 13119, 272, 23275, 18, 63, 1121, 275, 980, 14, 3287, 8, 89, 87, 12, 612, 87, 9, 339, 2074, 275, 1211, 14, 1574, 8, 599, 71, 63, 1838, 63, 10340, 503, 5009, 272, 2074, 14, 873, 8, 70, 16, 29, 70, 16, 12, 4051, 29, 1587, 12, 675, 63, 9996, 29, 1180, 63, 9996, 12, 653, 29, 46, 70, 9, 339, 327, 11842, 781, 1900, 13, 384, 314, 12627, 1323, 10051, 436, 1323, 32603, 1808, 876, 13, 14378, 272, 327, 27690, 14, 710, 12082, 6120, 5080, 787, 272, 327, 499, 9829, 8, 9457, 9, 9829, 8, 7343, 9, 275, 9794, 8, 77, 13, 78, 9, 88, 446, 9794, 8, 77, 11, 78, 9, 88, 272, 327, 499, 9794, 8, 9457, 9, 9794, 8, 7343, 9, 275, 9794, 8, 77, 13, 78, 9, 88, 435, 9794, 8, 77, 11, 78, 9, 88, 272, 327, 499, 9829, 8, 9457, 9, 9794, 8, 7343, 9, 275, 9829, 8, 77, 13, 78, 9, 88, 435, 9829, 8, 77, 11, 78, 9, 88, 339, 612, 3569, 275, 980, 14, 1838, 8, 89, 627, 336, 9, 339, 12075, 87, 275, 3842, 1590, 14, 4250, 8, 46, 70, 395, 10900, 627, 980, 14, 4548, 8, 46, 70, 10524, 272, 12075, 87, 14, 2880, 779, 599, 71, 63, 1838, 8, 84, 12, 336, 12, 9220, 63, 4778, 29, 73, 12, 1011, 958, 9, 355, 367, 284, 315, 1425, 8, 17, 12, 499, 627, 302, 9187, 435, 413, 3948, 272, 16666, 12, 445, 87, 275, 3482, 2031, 5153, 87, 9, 339, 428, 9156, 87, 275, 3842, 1590, 14, 4250, 8, 46, 70, 395, 612, 3569, 627, 980, 14, 4548, 8, 46, 70, 10524, 272, 428, 9156, 87, 14, 2880, 779, 599, 71, 63, 1838, 8, 84, 12, 336, 627, 612, 12, 9220, 63, 4778, 29, 73, 12, 1011, 958, 9, 326, 367, 284, 315, 1425, 8, 17, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
smac0628/android_kernel_huawei_angler
tools/perf/scripts/python/event_analyzing_sample.py
4719
7393
# event_analyzing_sample.py: general event handler in python # # Current perf report is already very powerful with the annotation integrated, # and this script is not trying to be as powerful as perf report, but # providing end user/developer a flexible way to analyze the events other # than trace points. # # The 2 database related functions in this script just show how to gather # the basic information, and users can modify and write their own functions # according to their specific requirement. # # The first function "show_general_events" just does a basic grouping for all # generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is # for a x86 HW PMU event: PEBS with load latency data. # import os import sys import math import struct import sqlite3 sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from EventClass import * # # If the perf.data has a big number of samples, then the insert operation # will be very time consuming (about 10+ minutes for 10000 samples) if the # .db database is on disk. Move the .db file to RAM based FS to speedup # the handling, which will cut the time down to several seconds. # con = sqlite3.connect("/dev/shm/perf.db") con.isolation_level = None def trace_begin(): print "In trace_begin:\n" # # Will create several tables at the start, pebs_ll is for PEBS data with # load latency info, while gen_events is for general event. # con.execute(""" create table if not exists gen_events ( name text, symbol text, comm text, dso text );""") con.execute(""" create table if not exists pebs_ll ( name text, symbol text, comm text, dso text, flags integer, ip integer, status integer, dse integer, dla integer, lat integer );""") # # Create and insert event object to a database so that user could # do more analysis with simple database commands. # def process_event(param_dict): event_attr = param_dict["attr"] sample = param_dict["sample"] raw_buf = param_dict["raw_buf"] comm = param_dict["comm"] name = param_dict["ev_name"] # Symbol and dso info are not always resolved if (param_dict.has_key("dso")): dso = param_dict["dso"] else: dso = "Unknown_dso" if (param_dict.has_key("symbol")): symbol = param_dict["symbol"] else: symbol = "Unknown_symbol" # Create the event object and insert it to the right table in database event = create_event(name, comm, dso, symbol, raw_buf) insert_db(event) def insert_db(event): if event.ev_type == EVTYPE_GENERIC: con.execute("insert into gen_events values(?, ?, ?, ?)", (event.name, event.symbol, event.comm, event.dso)) elif event.ev_type == EVTYPE_PEBS_LL: event.ip &= 0x7fffffffffffffff event.dla &= 0x7fffffffffffffff con.execute("insert into pebs_ll values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (event.name, event.symbol, event.comm, event.dso, event.flags, event.ip, event.status, event.dse, event.dla, event.lat)) def trace_end(): print "In trace_end:\n" # We show the basic info for the 2 type of event classes show_general_events() show_pebs_ll() con.close() # # As the event number may be very big, so we can't use linear way # to show the histogram in real number, but use a log2 algorithm. # def num2sym(num): # Each number will have at least one '#' snum = '#' * (int)(math.log(num, 2) + 1) return snum def show_general_events(): # Check the total record number in the table count = con.execute("select count(*) from gen_events") for t in count: print "There is %d records in gen_events table" % t[0] if t[0] == 0: return print "Statistics about the general events grouped by thread/symbol/dso: \n" # Group by thread commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) for row in commq: print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by symbol print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") for row in symbolq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by dso print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74) dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") for row in dsoq: print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) # # This function just shows the basic info, and we could do more with the # data in the tables, like checking the function parameters when some # big latency events happen. # def show_pebs_ll(): count = con.execute("select count(*) from pebs_ll") for t in count: print "There is %d records in pebs_ll table" % t[0] if t[0] == 0: return print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n" # Group by thread commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)") print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) for row in commq: print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by symbol print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)") for row in symbolq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by dse dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)") print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58) for row in dseq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) # Group by latency latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat") print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58) for row in latq: print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) def trace_unhandled(event_name, context, event_fields_dict): print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
gpl-2.0
[ 3, 1566, 63, 4797, 20135, 63, 3271, 14, 647, 26, 8605, 1566, 3016, 315, 2366, 199, 3, 199, 3, 9338, 8582, 3622, 365, 2575, 7437, 7074, 1893, 543, 314, 11262, 17806, 972, 12, 199, 3, 436, 642, 2884, 365, 440, 9936, 370, 506, 465, 7074, 1893, 465, 8582, 3622, 12, 1325, 199, 3, 13070, 1284, 922, 15, 11071, 282, 26841, 4340, 370, 19897, 314, 4474, 1163, 199, 3, 2419, 3307, 4501, 14, 199, 3, 199, 3, 710, 499, 3050, 4048, 3423, 315, 642, 2884, 2951, 2498, 4212, 370, 13082, 199, 3, 314, 5678, 2556, 12, 436, 4390, 883, 2811, 436, 2218, 3932, 5705, 3423, 199, 3, 7182, 370, 3932, 2488, 10685, 14, 199, 3, 199, 3, 710, 1642, 805, 298, 2384, 63, 10706, 63, 4368, 2, 2951, 1630, 282, 5678, 17786, 367, 1006, 199, 3, 7809, 4474, 543, 314, 1720, 402, 11723, 12, 436, 314, 499, 977, 1373, 298, 2384, 63, 321, 1533, 63, 914, 2, 365, 199, 3, 367, 282, 671, 1184, 869, 55, 27320, 53, 1566, 26, 19599, 11087, 543, 2248, 23967, 666, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3473, 199, 646, 2702, 199, 646, 11723, 19, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 267, 1994, 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, 6763, 2543, 492, 627, 199, 199, 3, 199, 3, 982, 314, 8582, 14, 576, 965, 282, 7282, 1329, 402, 5845, 12, 2066, 314, 5518, 3439, 199, 3, 911, 506, 7437, 900, 406, 26745, 334, 10254, 1616, 11, 9395, 367, 11630, 5845, 9, 340, 314, 199, 3, 1275, 697, 3050, 365, 641, 4543, 14, 14171, 314, 1275, 697, 570, 370, 30207, 4079, 27500, 370, 8112, 384, 199, 3, 314, 7252, 12, 1314, 911, 10415, 314, 900, 3224, 370, 9978, 4696, 14, 199, 3, 199, 388, 275, 11723, 19, 14, 2242, 4769, 2374, 15, 609, 77, 15, 9452, 14, 697, 531, 199, 388, 14, 20808, 63, 1896, 275, 488, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 607, 3307, 63, 5037, 3427, 78, 2, 398, 327, 267, 327, 12823, 1218, 9978, 6716, 737, 314, 1343, 12, 4837, 1533, 63, 914, 365, 367, 19599, 11087, 666, 543, 267, 327, 2248, 23967, 2256, 12, 1830, 3805, 63, 4368, 365, 367, 8605, 1566, 14, 267, 327, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 3805, 63, 4368, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 355, 20682, 6141, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 4837, 1533, 63, 914, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 12, 717, 3285, 3000, 12, 717, 3384, 3000, 12, 717, 2004, 3000, 12, 717, 366, 261, 3000, 12, 717, 366, 416, 3000, 12, 717, 8396, 3000, 355, 20682, 6141, 199, 199, 3, 199, 3, 2790, 436, 5518, 1566, 909, 370, 282, 3050, 880, 626, 922, 4293, 199, 3, 886, 1655, 11284, 543, 3486, 3050, 3718, 14, 199, 3, 199, 318, 2112, 63, 1430, 8, 635, 63, 807, 304, 267, 1566, 63, 962, 275, 1215, 63, 807, 905, 962, 937, 267, 2690, 258, 275, 1215, 63, 807, 905, 3271, 937, 267, 3066, 63, 1436, 259, 275, 1215, 63, 807, 905, 1773, 63, 1436, 937, 267, 1923, 755, 275, 1215, 63, 807, 905, 1404, 937, 267, 536, 755, 275, 1215, 63, 807, 905, 6857, 63, 354, 937, 398, 327, 10080, 436, 25547, 2256, 787, 440, 3544, 12152, 267, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 32211, 14150, 355, 25547, 275, 1215, 63, 807, 905, 32211, 937, 267, 587, 26, 355, 25547, 275, 298, 5912, 63, 32211, 2, 398, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 5155, 14150, 355, 5272, 275, 1215, 63, 807, 905, 5155, 937, 267, 587, 26, 355, 5272, 275, 298, 5912, 63, 5155, 2, 398, 327, 2790, 314, 1566, 909, 436, 5518, 652, 370, 314, 2451, 1817, 315, 3050, 267, 1566, 275, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 5518, 63, 697, 8, 1430, 9, 199, 199, 318, 5518, 63, 697, 8, 1430, 304, 267, 340, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 29395, 26, 355, 406, 14, 2526, 480, 3176, 1901, 3805, 63, 4368, 1338, 2229, 12, 21259, 21259, 5805, 4186, 1816, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 430, 267, 916, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 1510, 11087, 63, 4464, 26, 355, 1566, 14, 711, 18415, 378, 88, 23, 15798, 12596, 70, 355, 1566, 14, 68, 416, 18415, 378, 88, 23, 15798, 12596, 70, 355, 406, 14, 2526, 480, 3176, 1901, 4837, 1533, 63, 914, 1338, 7558, 12, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 5805, 4186, 717, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 12, 1566, 14, 2469, 12, 1816, 1566, 14, 711, 12, 1566, 14, 1205, 12, 1566, 14, 68, 261, 12, 1566, 14, 68, 416, 12, 1566, 14, 4452, 430, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 607, 3307, 63, 500, 3427, 78, 2, 267, 327, 2136, 2498, 314, 5678, 2256, 367, 314, 499, 730, 402, 1566, 3992, 267, 2498, 63, 10706, 63, 4368, 342, 267, 2498, 63, 321, 1533, 63, 914, 342, 267, 406, 14, 1600, 342, 199, 199, 3, 199, 3, 3709, 314, 1566, 1329, 1443, 506, 7437, 7282, 12, 880, 781, 883, 1133, 675, 7798, 4340, 199, 3, 370, 2498, 314, 15379, 315, 3363, 1329, 12, 1325, 675, 282, 943, 18, 5563, 14, 199, 3, 199, 199, 318, 1967, 18, 3840, 8, 1507, 304, 267, 327, 7048, 1329, 911, 1172, 737, 5210, 1373, 19619, 267, 308, 1507, 275, 19619, 627, 334, 442, 5130, 3442, 14, 793, 8, 1507, 12, 499, 9, 435, 413, 9, 267, 372, 308, 1507, 199, 199, 318, 2498, 63, 10706, 63, 4368, 837 ]
[ 1566, 63, 4797, 20135, 63, 3271, 14, 647, 26, 8605, 1566, 3016, 315, 2366, 199, 3, 199, 3, 9338, 8582, 3622, 365, 2575, 7437, 7074, 1893, 543, 314, 11262, 17806, 972, 12, 199, 3, 436, 642, 2884, 365, 440, 9936, 370, 506, 465, 7074, 1893, 465, 8582, 3622, 12, 1325, 199, 3, 13070, 1284, 922, 15, 11071, 282, 26841, 4340, 370, 19897, 314, 4474, 1163, 199, 3, 2419, 3307, 4501, 14, 199, 3, 199, 3, 710, 499, 3050, 4048, 3423, 315, 642, 2884, 2951, 2498, 4212, 370, 13082, 199, 3, 314, 5678, 2556, 12, 436, 4390, 883, 2811, 436, 2218, 3932, 5705, 3423, 199, 3, 7182, 370, 3932, 2488, 10685, 14, 199, 3, 199, 3, 710, 1642, 805, 298, 2384, 63, 10706, 63, 4368, 2, 2951, 1630, 282, 5678, 17786, 367, 1006, 199, 3, 7809, 4474, 543, 314, 1720, 402, 11723, 12, 436, 314, 499, 977, 1373, 298, 2384, 63, 321, 1533, 63, 914, 2, 365, 199, 3, 367, 282, 671, 1184, 869, 55, 27320, 53, 1566, 26, 19599, 11087, 543, 2248, 23967, 666, 14, 199, 3, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3473, 199, 646, 2702, 199, 646, 11723, 19, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 267, 1994, 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, 6763, 2543, 492, 627, 199, 199, 3, 199, 3, 982, 314, 8582, 14, 576, 965, 282, 7282, 1329, 402, 5845, 12, 2066, 314, 5518, 3439, 199, 3, 911, 506, 7437, 900, 406, 26745, 334, 10254, 1616, 11, 9395, 367, 11630, 5845, 9, 340, 314, 199, 3, 1275, 697, 3050, 365, 641, 4543, 14, 14171, 314, 1275, 697, 570, 370, 30207, 4079, 27500, 370, 8112, 384, 199, 3, 314, 7252, 12, 1314, 911, 10415, 314, 900, 3224, 370, 9978, 4696, 14, 199, 3, 199, 388, 275, 11723, 19, 14, 2242, 4769, 2374, 15, 609, 77, 15, 9452, 14, 697, 531, 199, 388, 14, 20808, 63, 1896, 275, 488, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 607, 3307, 63, 5037, 3427, 78, 2, 398, 327, 267, 327, 12823, 1218, 9978, 6716, 737, 314, 1343, 12, 4837, 1533, 63, 914, 365, 367, 19599, 11087, 666, 543, 267, 327, 2248, 23967, 2256, 12, 1830, 3805, 63, 4368, 365, 367, 8605, 1566, 14, 267, 327, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 3805, 63, 4368, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 355, 20682, 6141, 267, 406, 14, 2526, 4852, 355, 1218, 1817, 340, 440, 3495, 4837, 1533, 63, 914, 334, 717, 536, 1318, 12, 717, 5272, 1318, 12, 717, 1923, 1318, 12, 717, 25547, 1318, 12, 717, 3285, 3000, 12, 717, 3384, 3000, 12, 717, 2004, 3000, 12, 717, 366, 261, 3000, 12, 717, 366, 416, 3000, 12, 717, 8396, 3000, 355, 20682, 6141, 199, 199, 3, 199, 3, 2790, 436, 5518, 1566, 909, 370, 282, 3050, 880, 626, 922, 4293, 199, 3, 886, 1655, 11284, 543, 3486, 3050, 3718, 14, 199, 3, 199, 318, 2112, 63, 1430, 8, 635, 63, 807, 304, 267, 1566, 63, 962, 275, 1215, 63, 807, 905, 962, 937, 267, 2690, 258, 275, 1215, 63, 807, 905, 3271, 937, 267, 3066, 63, 1436, 259, 275, 1215, 63, 807, 905, 1773, 63, 1436, 937, 267, 1923, 755, 275, 1215, 63, 807, 905, 1404, 937, 267, 536, 755, 275, 1215, 63, 807, 905, 6857, 63, 354, 937, 398, 327, 10080, 436, 25547, 2256, 787, 440, 3544, 12152, 267, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 32211, 14150, 355, 25547, 275, 1215, 63, 807, 905, 32211, 937, 267, 587, 26, 355, 25547, 275, 298, 5912, 63, 32211, 2, 398, 340, 334, 635, 63, 807, 14, 1989, 63, 498, 480, 5155, 14150, 355, 5272, 275, 1215, 63, 807, 905, 5155, 937, 267, 587, 26, 355, 5272, 275, 298, 5912, 63, 5155, 2, 398, 327, 2790, 314, 1566, 909, 436, 5518, 652, 370, 314, 2451, 1817, 315, 3050, 267, 1566, 275, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 5518, 63, 697, 8, 1430, 9, 199, 199, 318, 5518, 63, 697, 8, 1430, 304, 267, 340, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 29395, 26, 355, 406, 14, 2526, 480, 3176, 1901, 3805, 63, 4368, 1338, 2229, 12, 21259, 21259, 5805, 4186, 1816, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 430, 267, 916, 1566, 14, 6857, 63, 466, 508, 30069, 2711, 63, 1510, 11087, 63, 4464, 26, 355, 1566, 14, 711, 18415, 378, 88, 23, 15798, 12596, 70, 355, 1566, 14, 68, 416, 18415, 378, 88, 23, 15798, 12596, 70, 355, 406, 14, 2526, 480, 3176, 1901, 4837, 1533, 63, 914, 1338, 7558, 12, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 21259, 5805, 4186, 717, 334, 1430, 14, 354, 12, 1566, 14, 5155, 12, 1566, 14, 1404, 12, 1566, 14, 32211, 12, 1566, 14, 2469, 12, 1816, 1566, 14, 711, 12, 1566, 14, 1205, 12, 1566, 14, 68, 261, 12, 1566, 14, 68, 416, 12, 1566, 14, 4452, 430, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 298, 607, 3307, 63, 500, 3427, 78, 2, 267, 327, 2136, 2498, 314, 5678, 2256, 367, 314, 499, 730, 402, 1566, 3992, 267, 2498, 63, 10706, 63, 4368, 342, 267, 2498, 63, 321, 1533, 63, 914, 342, 267, 406, 14, 1600, 342, 199, 199, 3, 199, 3, 3709, 314, 1566, 1329, 1443, 506, 7437, 7282, 12, 880, 781, 883, 1133, 675, 7798, 4340, 199, 3, 370, 2498, 314, 15379, 315, 3363, 1329, 12, 1325, 675, 282, 943, 18, 5563, 14, 199, 3, 199, 199, 318, 1967, 18, 3840, 8, 1507, 304, 267, 327, 7048, 1329, 911, 1172, 737, 5210, 1373, 19619, 267, 308, 1507, 275, 19619, 627, 334, 442, 5130, 3442, 14, 793, 8, 1507, 12, 499, 9, 435, 413, 9, 267, 372, 308, 1507, 199, 199, 318, 2498, 63, 10706, 63, 4368, 837, 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,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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 ]
infobloxopen/infoblox-netmri
infoblox_netmri/api/broker/v2_5_0/rev_switch_fwd_neighbor_broker.py
17
40936
from ..broker import Broker class RevSwitchFwdNeighborBroker(Broker): controller = "rev_switch_fwd_neighbors" def show(self, **kwargs): """Shows the details for the specified rev switch fwd neighbor. **Inputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` True | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param methods: A list of rev switch fwd neighbor methods. The listed methods will be called on each rev switch fwd neighbor returned and included in the output. Available methods are: neighbor. :type methods: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param include: A list of associated object types to include in the output. The listed associations will be returned as outputs named according to the association name (see outputs below). Available includes are: neighbor. :type include: Array of String **Outputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :return rev_switch_fwd_neighbor: The rev switch fwd neighbor identified by the specified NeighborID. :rtype rev_switch_fwd_neighbor: RevSwitchFwdNeighbor """ return self.api_request(self._get_method_fullname("show"), kwargs) def index(self, **kwargs): """Lists the available rev switch fwd neighbors. Any of the inputs listed may be be used to narrow the list; other inputs will be ignored. Of the various ways to query lists, using this method is most efficient. **Inputs** | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Integer | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Array of Integer | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param SwitchFwdNeighborID: The internal NetMRI identifier for the switch forwarding neighbor relationship that was 'reversed' in order to generate this neighbor relationship. :type SwitchFwdNeighborID: Integer | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param SwitchFwdNeighborID: The internal NetMRI identifier for the switch forwarding neighbor relationship that was 'reversed' in order to generate this neighbor relationship. :type SwitchFwdNeighborID: Array of Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param DeviceGroupID: The internal NetMRI identifier of the device groups to which to limit the results. :type DeviceGroupID: Array of Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param timestamp: The data returned will represent the rev switch fwd neighbors as of this date and time. If omitted, the result will indicate the most recently collected data. :type timestamp: DateTime | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param methods: A list of rev switch fwd neighbor methods. The listed methods will be called on each rev switch fwd neighbor returned and included in the output. Available methods are: neighbor. :type methods: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param include: A list of associated object types to include in the output. The listed associations will be returned as outputs named according to the association name (see outputs below). Available includes are: neighbor. :type include: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 0 :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information. :type start: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 1000 :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000. :type limit: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` NeighborID :param sort: The data field(s) to use for sorting the output. Default is NeighborID. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. :type sort: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` asc :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'. :type dir: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param select: The list of attributes to return for each RevSwitchFwdNeighbor. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. If empty or omitted, all attributes will be returned. :type select: Array | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records. :type goto_field: String | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records. :type goto_value: String **Outputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :return rev_switch_fwd_neighbors: An array of the RevSwitchFwdNeighbor objects that match the specified input criteria. :rtype rev_switch_fwd_neighbors: Array of RevSwitchFwdNeighbor """ return self.api_list_request(self._get_method_fullname("index"), kwargs) def search(self, **kwargs): """Lists the available rev switch fwd neighbors matching the input criteria. This method provides a more flexible search interface than the index method, but searching using this method is more demanding on the system and will not perform to the same level as the index method. The input fields listed below will be used as in the index method, to filter the result, along with the optional query string and XML filter described below. **Inputs** | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Integer | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Array of Integer | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborChangedCols: The fields that changed between this revision of the record and the previous revision. :type RevSwitchFwdNeighborChangedCols: String | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborChangedCols: The fields that changed between this revision of the record and the previous revision. :type RevSwitchFwdNeighborChangedCols: Array of String | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborEndTime: The ending effective time of this revision of this record, or empty if still in effect. :type RevSwitchFwdNeighborEndTime: DateTime | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborEndTime: The ending effective time of this revision of this record, or empty if still in effect. :type RevSwitchFwdNeighborEndTime: Array of DateTime | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborMapSource: Internal tracking information for NetMRI algorithms. :type RevSwitchFwdNeighborMapSource: String | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborMapSource: Internal tracking information for NetMRI algorithms. :type RevSwitchFwdNeighborMapSource: Array of String | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborStartTime: The starting effective time of this revision of the record. :type RevSwitchFwdNeighborStartTime: DateTime | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborStartTime: The starting effective time of this revision of the record. :type RevSwitchFwdNeighborStartTime: Array of DateTime | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborTimestamp: The date and time this record was collected or calculated. :type RevSwitchFwdNeighborTimestamp: DateTime | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param RevSwitchFwdNeighborTimestamp: The date and time this record was collected or calculated. :type RevSwitchFwdNeighborTimestamp: Array of DateTime | ``api version min:`` 2.3 | ``api version max:`` 2.4 | ``required:`` False | ``default:`` None :param SwitchFwdNeighborID: The internal NetMRI identifier for the switch forwarding neighbor relationship that was 'reversed' in order to generate this neighbor relationship. :type SwitchFwdNeighborID: Integer | ``api version min:`` 2.5 | ``api version max:`` None | ``required:`` False | ``default:`` None :param SwitchFwdNeighborID: The internal NetMRI identifier for the switch forwarding neighbor relationship that was 'reversed' in order to generate this neighbor relationship. :type SwitchFwdNeighborID: Array of Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param DeviceGroupID: The internal NetMRI identifier of the device groups to which to limit the results. :type DeviceGroupID: Array of Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param timestamp: The data returned will represent the rev switch fwd neighbors as of this date and time. If omitted, the result will indicate the most recently collected data. :type timestamp: DateTime | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param methods: A list of rev switch fwd neighbor methods. The listed methods will be called on each rev switch fwd neighbor returned and included in the output. Available methods are: neighbor. :type methods: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param include: A list of associated object types to include in the output. The listed associations will be returned as outputs named according to the association name (see outputs below). Available includes are: neighbor. :type include: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 0 :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information. :type start: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 1000 :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000. :type limit: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` NeighborID :param sort: The data field(s) to use for sorting the output. Default is NeighborID. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. :type sort: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` asc :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'. :type dir: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param select: The list of attributes to return for each RevSwitchFwdNeighbor. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. If empty or omitted, all attributes will be returned. :type select: Array | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records. :type goto_field: String | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records. :type goto_value: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param query: This value will be matched against rev switch fwd neighbors, looking to see if one or more of the listed attributes contain the passed value. You may also surround the value with '/' and '/' to perform a regular expression search rather than a containment operation. Any record that matches will be returned. The attributes searched are: NeighborID, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborMapSource, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborTimestamp, SwitchFwdNeighborID. :type query: String | ``api version min:`` 2.3 | ``api version max:`` None | ``required:`` False | ``default:`` None :param xml_filter: A SetFilter XML structure to further refine the search. The SetFilter will be applied AFTER any search query or field values, but before any limit options. The limit and pagination will be enforced after the filter. Remind that this kind of filter may be costly and inefficient if not associated with a database filtering. :type xml_filter: String **Outputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :return rev_switch_fwd_neighbors: An array of the RevSwitchFwdNeighbor objects that match the specified input criteria. :rtype rev_switch_fwd_neighbors: Array of RevSwitchFwdNeighbor """ return self.api_list_request(self._get_method_fullname("search"), kwargs) def find(self, **kwargs): """Lists the available rev switch fwd neighbors matching the input specification. This provides the most flexible search specification of all the query mechanisms, enabling searching using comparison operations other than equality. However, it is more complex to use and will not perform as efficiently as the index or search methods. In the input descriptions below, 'field names' refers to the following fields: NeighborID, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborMapSource, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborTimestamp, SwitchFwdNeighborID. **Inputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_NeighborID: The operator to apply to the field NeighborID. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_NeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_NeighborID: If op_NeighborID is specified, the field named in this input will be compared to the value in NeighborID using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_NeighborID must be specified if op_NeighborID is specified. :type val_f_NeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_NeighborID: If op_NeighborID is specified, this value will be compared to the value in NeighborID using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_NeighborID must be specified if op_NeighborID is specified. :type val_c_NeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_RevSwitchFwdNeighborChangedCols: The operator to apply to the field RevSwitchFwdNeighborChangedCols. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. RevSwitchFwdNeighborChangedCols: The fields that changed between this revision of the record and the previous revision. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_RevSwitchFwdNeighborChangedCols: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_RevSwitchFwdNeighborChangedCols: If op_RevSwitchFwdNeighborChangedCols is specified, the field named in this input will be compared to the value in RevSwitchFwdNeighborChangedCols using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_RevSwitchFwdNeighborChangedCols must be specified if op_RevSwitchFwdNeighborChangedCols is specified. :type val_f_RevSwitchFwdNeighborChangedCols: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_RevSwitchFwdNeighborChangedCols: If op_RevSwitchFwdNeighborChangedCols is specified, this value will be compared to the value in RevSwitchFwdNeighborChangedCols using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_RevSwitchFwdNeighborChangedCols must be specified if op_RevSwitchFwdNeighborChangedCols is specified. :type val_c_RevSwitchFwdNeighborChangedCols: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_RevSwitchFwdNeighborEndTime: The operator to apply to the field RevSwitchFwdNeighborEndTime. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. RevSwitchFwdNeighborEndTime: The ending effective time of this revision of this record, or empty if still in effect. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_RevSwitchFwdNeighborEndTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_RevSwitchFwdNeighborEndTime: If op_RevSwitchFwdNeighborEndTime is specified, the field named in this input will be compared to the value in RevSwitchFwdNeighborEndTime using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_RevSwitchFwdNeighborEndTime must be specified if op_RevSwitchFwdNeighborEndTime is specified. :type val_f_RevSwitchFwdNeighborEndTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_RevSwitchFwdNeighborEndTime: If op_RevSwitchFwdNeighborEndTime is specified, this value will be compared to the value in RevSwitchFwdNeighborEndTime using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_RevSwitchFwdNeighborEndTime must be specified if op_RevSwitchFwdNeighborEndTime is specified. :type val_c_RevSwitchFwdNeighborEndTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_RevSwitchFwdNeighborMapSource: The operator to apply to the field RevSwitchFwdNeighborMapSource. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. RevSwitchFwdNeighborMapSource: Internal tracking information for NetMRI algorithms. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_RevSwitchFwdNeighborMapSource: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_RevSwitchFwdNeighborMapSource: If op_RevSwitchFwdNeighborMapSource is specified, the field named in this input will be compared to the value in RevSwitchFwdNeighborMapSource using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_RevSwitchFwdNeighborMapSource must be specified if op_RevSwitchFwdNeighborMapSource is specified. :type val_f_RevSwitchFwdNeighborMapSource: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_RevSwitchFwdNeighborMapSource: If op_RevSwitchFwdNeighborMapSource is specified, this value will be compared to the value in RevSwitchFwdNeighborMapSource using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_RevSwitchFwdNeighborMapSource must be specified if op_RevSwitchFwdNeighborMapSource is specified. :type val_c_RevSwitchFwdNeighborMapSource: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_RevSwitchFwdNeighborStartTime: The operator to apply to the field RevSwitchFwdNeighborStartTime. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. RevSwitchFwdNeighborStartTime: The starting effective time of this revision of the record. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_RevSwitchFwdNeighborStartTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_RevSwitchFwdNeighborStartTime: If op_RevSwitchFwdNeighborStartTime is specified, the field named in this input will be compared to the value in RevSwitchFwdNeighborStartTime using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_RevSwitchFwdNeighborStartTime must be specified if op_RevSwitchFwdNeighborStartTime is specified. :type val_f_RevSwitchFwdNeighborStartTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_RevSwitchFwdNeighborStartTime: If op_RevSwitchFwdNeighborStartTime is specified, this value will be compared to the value in RevSwitchFwdNeighborStartTime using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_RevSwitchFwdNeighborStartTime must be specified if op_RevSwitchFwdNeighborStartTime is specified. :type val_c_RevSwitchFwdNeighborStartTime: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_RevSwitchFwdNeighborTimestamp: The operator to apply to the field RevSwitchFwdNeighborTimestamp. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. RevSwitchFwdNeighborTimestamp: The date and time this record was collected or calculated. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_RevSwitchFwdNeighborTimestamp: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_RevSwitchFwdNeighborTimestamp: If op_RevSwitchFwdNeighborTimestamp is specified, the field named in this input will be compared to the value in RevSwitchFwdNeighborTimestamp using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_RevSwitchFwdNeighborTimestamp must be specified if op_RevSwitchFwdNeighborTimestamp is specified. :type val_f_RevSwitchFwdNeighborTimestamp: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_RevSwitchFwdNeighborTimestamp: If op_RevSwitchFwdNeighborTimestamp is specified, this value will be compared to the value in RevSwitchFwdNeighborTimestamp using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_RevSwitchFwdNeighborTimestamp must be specified if op_RevSwitchFwdNeighborTimestamp is specified. :type val_c_RevSwitchFwdNeighborTimestamp: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param op_SwitchFwdNeighborID: The operator to apply to the field SwitchFwdNeighborID. Valid values are: =, <>, rlike, not rlike, >, >=, <, <=, like, not like, is null, is not null, between. SwitchFwdNeighborID: The internal NetMRI identifier for the switch forwarding neighbor relationship that was 'reversed' in order to generate this neighbor relationship. For the between operator the value will be treated as an Array if comma delimited string is passed, and it must contain an even number of values. :type op_SwitchFwdNeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_f_SwitchFwdNeighborID: If op_SwitchFwdNeighborID is specified, the field named in this input will be compared to the value in SwitchFwdNeighborID using the specified operator. That is, the value in this input will be treated as another field name, rather than a constant value. Either this field or val_c_SwitchFwdNeighborID must be specified if op_SwitchFwdNeighborID is specified. :type val_f_SwitchFwdNeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param val_c_SwitchFwdNeighborID: If op_SwitchFwdNeighborID is specified, this value will be compared to the value in SwitchFwdNeighborID using the specified operator. The value in this input will be treated as an explicit constant value. Either this field or val_f_SwitchFwdNeighborID must be specified if op_SwitchFwdNeighborID is specified. :type val_c_SwitchFwdNeighborID: String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param DeviceGroupID: The internal NetMRI identifier of the device groups to which to limit the results. :type DeviceGroupID: Array of Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param timestamp: The data returned will represent the rev switch fwd neighbors as of this date and time. If omitted, the result will indicate the most recently collected data. :type timestamp: DateTime | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param methods: A list of rev switch fwd neighbor methods. The listed methods will be called on each rev switch fwd neighbor returned and included in the output. Available methods are: neighbor. :type methods: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param include: A list of associated object types to include in the output. The listed associations will be returned as outputs named according to the association name (see outputs below). Available includes are: neighbor. :type include: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 0 :param start: The record number to return in the selected page of data. It will always appear, although it may not be the first record. See the :limit for more information. :type start: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` 1000 :param limit: The size of the page of data, that is, the maximum number of records returned. The limit size will be used to break the data up into pages and the first page with the start record will be returned. So if you have 100 records and use a :limit of 10 and a :start of 10, you will get records 10-19. The maximum limit is 10000. :type limit: Integer | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` NeighborID :param sort: The data field(s) to use for sorting the output. Default is NeighborID. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. :type sort: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` asc :param dir: The direction(s) in which to sort the data. Default is 'asc'. Valid values are 'asc' and 'desc'. :type dir: Array of String | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :param select: The list of attributes to return for each RevSwitchFwdNeighbor. Valid values are NeighborID, RevSwitchFwdNeighborStartTime, RevSwitchFwdNeighborEndTime, RevSwitchFwdNeighborChangedCols, RevSwitchFwdNeighborTimestamp, RevSwitchFwdNeighborMapSource, SwitchFwdNeighborID. If empty or omitted, all attributes will be returned. :type select: Array | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_field: The field name for NIOS GOTO that is used for locating a row position of records. :type goto_field: String | ``api version min:`` 2.8 | ``api version max:`` None | ``required:`` False | ``default:`` None :param goto_value: The value of goto_field for NIOS GOTO that is used for locating a row position of records. :type goto_value: String | ``api version min:`` 2.3 | ``api version max:`` None | ``required:`` False | ``default:`` None :param xml_filter: A SetFilter XML structure to further refine the search. The SetFilter will be applied AFTER any search query or field values, but before any limit options. The limit and pagination will be enforced after the filter. Remind that this kind of filter may be costly and inefficient if not associated with a database filtering. :type xml_filter: String **Outputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :return rev_switch_fwd_neighbors: An array of the RevSwitchFwdNeighbor objects that match the specified input criteria. :rtype rev_switch_fwd_neighbors: Array of RevSwitchFwdNeighbor """ return self.api_list_request(self._get_method_fullname("find"), kwargs) def neighbor(self, **kwargs): """The neighbor relationship, which contains the source and destination device information. **Inputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` True | ``default:`` None :param NeighborID: The internal NetMRI identifier for the neighbor relationship. This can be used to look up the Neighbor relationship which contains the source and destination device information. :type NeighborID: Integer **Outputs** | ``api version min:`` None | ``api version max:`` None | ``required:`` False | ``default:`` None :return : The neighbor relationship, which contains the source and destination device information. :rtype : Neighbor """ return self.api_request(self._get_method_fullname("neighbor"), kwargs)
apache-2.0
[ 504, 2508, 16620, 492, 27651, 421, 199, 533, 799, 86, 10167, 38, 2989, 13779, 14017, 8, 14017, 304, 272, 7614, 275, 298, 4964, 63, 5656, 63, 27912, 63, 11113, 2, 339, 347, 2498, 8, 277, 12, 1011, 958, 304, 267, 408, 6824, 83, 314, 2436, 367, 314, 2013, 6822, 6258, 31336, 15503, 14, 953, 1011, 15124, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 715, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 3102, 26, 437, 769, 402, 6822, 6258, 31336, 15503, 3102, 14, 710, 10532, 3102, 911, 506, 2797, 641, 1924, 6822, 6258, 31336, 15503, 2138, 436, 5120, 315, 314, 1072, 14, 23840, 3102, 787, 26, 15503, 14, 1467, 520, 466, 3102, 26, 8725, 402, 2624, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 2387, 26, 437, 769, 402, 4568, 909, 2943, 370, 2387, 315, 314, 1072, 14, 710, 10532, 4035, 1298, 911, 506, 2138, 465, 4704, 4310, 7182, 370, 314, 20640, 536, 334, 3239, 4704, 5084, 680, 23840, 6952, 787, 26, 15503, 14, 1467, 520, 466, 2387, 26, 8725, 402, 2624, 953, 1011, 18669, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 1107, 6822, 63, 5656, 63, 27912, 63, 13881, 26, 710, 6822, 6258, 31336, 15503, 15836, 701, 314, 2013, 5612, 7201, 998, 14, 1467, 520, 4500, 6822, 63, 5656, 63, 27912, 63, 13881, 26, 799, 86, 10167, 38, 2989, 13779, 953, 408, 398, 372, 291, 14, 1246, 63, 1069, 8, 277, 423, 362, 63, 765, 63, 9930, 480, 2384, 1288, 2074, 9, 339, 347, 1478, 8, 277, 12, 1011, 958, 304, 267, 408, 15116, 314, 2808, 6822, 6258, 31336, 15845, 14, 6184, 402, 314, 4153, 10532, 1443, 506, 506, 1202, 370, 31530, 314, 769, 27, 1163, 4153, 911, 506, 5525, 14, 24545, 314, 7750, 15217, 370, 1827, 5548, 12, 1808, 642, 1083, 365, 4750, 13402, 14, 953, 1011, 15124, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 19, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 499, 14, 20, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 21, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 19, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 499, 14, 20, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 17711, 38, 2989, 13779, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 6258, 24119, 15503, 8931, 626, 1990, 283, 13501, 7, 315, 1865, 370, 3550, 642, 15503, 8931, 14, 1467, 520, 466, 17711, 38, 2989, 13779, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 21, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 17711, 38, 2989, 13779, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 6258, 24119, 15503, 8931, 626, 1990, 283, 13501, 7, 315, 1865, 370, 3550, 642, 15503, 8931, 14, 1467, 520, 466, 17711, 38, 2989, 13779, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 12272, 2448, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 402, 314, 2243, 4652, 370, 1314, 370, 2304, 314, 2058, 14, 1467, 520, 466, 12272, 2448, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 4913, 26, 710, 666, 2138, 911, 2954, 314, 6822, 6258, 31336, 15845, 465, 402, 642, 1434, 436, 900, 14, 982, 11684, 12, 314, 754, 911, 6623, 314, 4750, 23568, 13736, 666, 14, 1467, 520, 466, 4913, 26, 13686, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 3102, 26, 437, 769, 402, 6822, 6258, 31336, 15503, 3102, 14, 710, 10532, 3102, 911, 506, 2797, 641, 1924, 6822, 6258, 31336, 15503, 2138, 436, 5120, 315, 314, 1072, 14, 23840, 3102, 787, 26, 15503, 14, 1467, 520, 466, 3102, 26, 8725, 402, 2624, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221 ]
[ 2508, 16620, 492, 27651, 421, 199, 533, 799, 86, 10167, 38, 2989, 13779, 14017, 8, 14017, 304, 272, 7614, 275, 298, 4964, 63, 5656, 63, 27912, 63, 11113, 2, 339, 347, 2498, 8, 277, 12, 1011, 958, 304, 267, 408, 6824, 83, 314, 2436, 367, 314, 2013, 6822, 6258, 31336, 15503, 14, 953, 1011, 15124, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 715, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 3102, 26, 437, 769, 402, 6822, 6258, 31336, 15503, 3102, 14, 710, 10532, 3102, 911, 506, 2797, 641, 1924, 6822, 6258, 31336, 15503, 2138, 436, 5120, 315, 314, 1072, 14, 23840, 3102, 787, 26, 15503, 14, 1467, 520, 466, 3102, 26, 8725, 402, 2624, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 2387, 26, 437, 769, 402, 4568, 909, 2943, 370, 2387, 315, 314, 1072, 14, 710, 10532, 4035, 1298, 911, 506, 2138, 465, 4704, 4310, 7182, 370, 314, 20640, 536, 334, 3239, 4704, 5084, 680, 23840, 6952, 787, 26, 15503, 14, 1467, 520, 466, 2387, 26, 8725, 402, 2624, 953, 1011, 18669, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 1107, 6822, 63, 5656, 63, 27912, 63, 13881, 26, 710, 6822, 6258, 31336, 15503, 15836, 701, 314, 2013, 5612, 7201, 998, 14, 1467, 520, 4500, 6822, 63, 5656, 63, 27912, 63, 13881, 26, 799, 86, 10167, 38, 2989, 13779, 953, 408, 398, 372, 291, 14, 1246, 63, 1069, 8, 277, 423, 362, 63, 765, 63, 9930, 480, 2384, 1288, 2074, 9, 339, 347, 1478, 8, 277, 12, 1011, 958, 304, 267, 408, 15116, 314, 2808, 6822, 6258, 31336, 15845, 14, 6184, 402, 314, 4153, 10532, 1443, 506, 506, 1202, 370, 31530, 314, 769, 27, 1163, 4153, 911, 506, 5525, 14, 24545, 314, 7750, 15217, 370, 1827, 5548, 12, 1808, 642, 1083, 365, 4750, 13402, 14, 953, 1011, 15124, 538, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 19, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 499, 14, 20, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 21, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 5612, 7201, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 15503, 8931, 14, 961, 883, 506, 1202, 370, 3648, 1536, 314, 5612, 7201, 8931, 1314, 3509, 314, 1350, 436, 5724, 2243, 2556, 14, 1467, 520, 466, 5612, 7201, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 19, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 499, 14, 20, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 17711, 38, 2989, 13779, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 6258, 24119, 15503, 8931, 626, 1990, 283, 13501, 7, 315, 1865, 370, 3550, 642, 15503, 8931, 14, 1467, 520, 466, 17711, 38, 2989, 13779, 998, 26, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 499, 14, 21, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 17711, 38, 2989, 13779, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 367, 314, 6258, 24119, 15503, 8931, 626, 1990, 283, 13501, 7, 315, 1865, 370, 3550, 642, 15503, 8931, 14, 1467, 520, 466, 17711, 38, 2989, 13779, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 12272, 2448, 998, 26, 710, 5007, 5365, 45, 6129, 5148, 402, 314, 2243, 4652, 370, 1314, 370, 2304, 314, 2058, 14, 1467, 520, 466, 12272, 2448, 998, 26, 8725, 402, 7225, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 4913, 26, 710, 666, 2138, 911, 2954, 314, 6822, 6258, 31336, 15845, 465, 402, 642, 1434, 436, 900, 14, 982, 11684, 12, 314, 754, 911, 6623, 314, 4750, 23568, 13736, 666, 14, 1467, 520, 466, 4913, 26, 13686, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 1124, 885, 5409, 488, 10798, 520, 635, 3102, 26, 437, 769, 402, 6822, 6258, 31336, 15503, 3102, 14, 710, 10532, 3102, 911, 506, 2797, 641, 1924, 6822, 6258, 31336, 15503, 2138, 436, 5120, 315, 314, 1072, 14, 23840, 3102, 787, 26, 15503, 14, 1467, 520, 466, 3102, 26, 8725, 402, 2624, 953, 1204, 221, 1124, 1246, 1015, 1748, 5409, 488, 288, 1204, 221, 1124, 1246, 1015, 1390, 5409, 488, 288, 1204, 221, 1124, 2427, 5409, 756, 288, 1204, 221, 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 ]
schettino72/nikola
nikola/plugins/compile/rest/soundcloud.py
9
2015
# -*- coding: utf-8 -*- """SoundCloud directive for reStructuredText.""" from docutils import nodes from docutils.parsers.rst import Directive, directives from nikola.plugin_categories import RestExtension class Plugin(RestExtension): """Plugin for soundclound directive.""" name = "rest_soundcloud" def set_site(self, site): """Set Nikola site.""" self.site = site directives.register_directive('soundcloud', SoundCloud) directives.register_directive('soundcloud_playlist', SoundCloudPlaylist) return super(Plugin, self).set_site(site) CODE = ("""<iframe width="{width}" height="{height}" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/{preslug}/""" """{sid}"> </iframe>""") class SoundCloud(Directive): """reST extension for inserting SoundCloud embedded music. Usage: .. soundcloud:: <sound id> :height: 400 :width: 600 """ has_content = True required_arguments = 1 option_spec = { 'width': directives.positive_int, 'height': directives.positive_int, } preslug = "tracks" def run(self): """Run the soundcloud directive.""" self.check_content() options = { 'sid': self.arguments[0], 'width': 600, 'height': 160, 'preslug': self.preslug, } options.update(self.options) return [nodes.raw('', CODE.format(**options), format='html')] def check_content(self): """Emit a deprecation warning if there is content.""" if self.content: # pragma: no cover raise self.warning("This directive does not accept content. The " "'key=value' format for options is deprecated, " "use ':key: value' instead") class SoundCloudPlaylist(SoundCloud): """reST directive for SoundCloud playlists.""" preslug = "playlists"
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 18670, 9089, 13613, 367, 295, 27486, 1872, 1041, 199, 199, 504, 18382, 492, 3380, 199, 504, 18382, 14, 11531, 14, 8332, 492, 3757, 8374, 12, 13502, 421, 199, 504, 302, 3258, 22205, 14, 2718, 63, 8906, 492, 30417, 6382, 421, 199, 533, 11349, 8, 13726, 6382, 304, 339, 408, 5061, 367, 20453, 1251, 725, 13613, 1041, 339, 536, 275, 298, 3911, 63, 14990, 4091, 2, 339, 347, 663, 63, 2124, 8, 277, 12, 4770, 304, 267, 408, 1084, 653, 3258, 22205, 4770, 1041, 267, 291, 14, 2124, 275, 4770, 267, 13502, 14, 2683, 63, 15047, 360, 14990, 4091, 297, 428, 1034, 9089, 9, 267, 13502, 14, 2683, 63, 15047, 360, 14990, 4091, 63, 10411, 297, 428, 1034, 9089, 27259, 9, 267, 372, 1613, 8, 5061, 12, 291, 680, 409, 63, 2124, 8, 2124, 9, 421, 199, 6012, 275, 334, 624, 28, 20052, 3462, 18448, 2063, 7063, 4569, 18448, 3333, 7063, 199, 6755, 316, 628, 889, 2, 2787, 8665, 628, 889, 2, 199, 2164, 628, 2859, 921, 87, 14, 14990, 4091, 14, 957, 15, 6147, 10197, 633, 29, 1014, 921, 1246, 14, 14990, 4091, 14, 957, 5321, 24919, 32047, 5995, 624, 267, 408, 91, 4148, 93, 1743, 199, 1108, 20052, 15366, 421, 199, 533, 428, 1034, 9089, 8, 29489, 304, 339, 408, 264, 840, 3329, 367, 28498, 428, 1034, 9089, 12169, 30891, 14, 339, 11028, 26, 267, 2508, 20453, 4091, 447, 665, 14990, 1305, 30, 1779, 520, 3333, 26, 8290, 1779, 520, 2063, 26, 11624, 339, 408, 339, 965, 63, 1317, 275, 715, 272, 1415, 63, 4958, 275, 413, 272, 945, 63, 1650, 275, 469, 267, 283, 2063, 356, 13502, 14, 8965, 63, 442, 12, 267, 283, 3333, 356, 13502, 14, 8965, 63, 442, 12, 272, 789, 272, 25210, 32047, 275, 298, 16274, 2, 339, 347, 1255, 8, 277, 304, 267, 408, 2540, 314, 20453, 4091, 13613, 1041, 267, 291, 14, 1074, 63, 1317, 342, 267, 1511, 275, 469, 288, 283, 4148, 356, 291, 14, 4958, 59, 16, 467, 288, 283, 2063, 356, 11624, 12, 288, 283, 3333, 356, 21235, 12, 288, 283, 24919, 32047, 356, 291, 14, 24919, 32047, 12, 267, 789, 267, 1511, 14, 873, 8, 277, 14, 1419, 9, 267, 372, 359, 2415, 14, 1773, 8594, 22547, 14, 908, 3682, 1419, 395, 1475, 534, 1360, 5440, 339, 347, 1104, 63, 1317, 8, 277, 304, 267, 408, 37, 1147, 282, 17831, 5721, 340, 2337, 365, 1564, 1041, 267, 340, 291, 14, 1317, 26, 221, 327, 11942, 26, 949, 8486, 288, 746, 291, 14, 3764, 480, 2765, 13613, 1630, 440, 4729, 1564, 14, 710, 298, 3044, 3546, 498, 29, 585, 7, 1475, 367, 1511, 365, 5906, 12, 298, 3044, 298, 1180, 7596, 498, 26, 574, 7, 3140, 531, 421, 199, 533, 428, 1034, 9089, 27259, 8, 18670, 9089, 304, 339, 408, 264, 840, 13613, 367, 428, 1034, 9089, 5232, 6717, 1041, 339, 25210, 32047, 275, 298, 2802, 6717, 2, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 18670, 9089, 13613, 367, 295, 27486, 1872, 1041, 199, 199, 504, 18382, 492, 3380, 199, 504, 18382, 14, 11531, 14, 8332, 492, 3757, 8374, 12, 13502, 421, 199, 504, 302, 3258, 22205, 14, 2718, 63, 8906, 492, 30417, 6382, 421, 199, 533, 11349, 8, 13726, 6382, 304, 339, 408, 5061, 367, 20453, 1251, 725, 13613, 1041, 339, 536, 275, 298, 3911, 63, 14990, 4091, 2, 339, 347, 663, 63, 2124, 8, 277, 12, 4770, 304, 267, 408, 1084, 653, 3258, 22205, 4770, 1041, 267, 291, 14, 2124, 275, 4770, 267, 13502, 14, 2683, 63, 15047, 360, 14990, 4091, 297, 428, 1034, 9089, 9, 267, 13502, 14, 2683, 63, 15047, 360, 14990, 4091, 63, 10411, 297, 428, 1034, 9089, 27259, 9, 267, 372, 1613, 8, 5061, 12, 291, 680, 409, 63, 2124, 8, 2124, 9, 421, 199, 6012, 275, 334, 624, 28, 20052, 3462, 18448, 2063, 7063, 4569, 18448, 3333, 7063, 199, 6755, 316, 628, 889, 2, 2787, 8665, 628, 889, 2, 199, 2164, 628, 2859, 921, 87, 14, 14990, 4091, 14, 957, 15, 6147, 10197, 633, 29, 1014, 921, 1246, 14, 14990, 4091, 14, 957, 5321, 24919, 32047, 5995, 624, 267, 408, 91, 4148, 93, 1743, 199, 1108, 20052, 15366, 421, 199, 533, 428, 1034, 9089, 8, 29489, 304, 339, 408, 264, 840, 3329, 367, 28498, 428, 1034, 9089, 12169, 30891, 14, 339, 11028, 26, 267, 2508, 20453, 4091, 447, 665, 14990, 1305, 30, 1779, 520, 3333, 26, 8290, 1779, 520, 2063, 26, 11624, 339, 408, 339, 965, 63, 1317, 275, 715, 272, 1415, 63, 4958, 275, 413, 272, 945, 63, 1650, 275, 469, 267, 283, 2063, 356, 13502, 14, 8965, 63, 442, 12, 267, 283, 3333, 356, 13502, 14, 8965, 63, 442, 12, 272, 789, 272, 25210, 32047, 275, 298, 16274, 2, 339, 347, 1255, 8, 277, 304, 267, 408, 2540, 314, 20453, 4091, 13613, 1041, 267, 291, 14, 1074, 63, 1317, 342, 267, 1511, 275, 469, 288, 283, 4148, 356, 291, 14, 4958, 59, 16, 467, 288, 283, 2063, 356, 11624, 12, 288, 283, 3333, 356, 21235, 12, 288, 283, 24919, 32047, 356, 291, 14, 24919, 32047, 12, 267, 789, 267, 1511, 14, 873, 8, 277, 14, 1419, 9, 267, 372, 359, 2415, 14, 1773, 8594, 22547, 14, 908, 3682, 1419, 395, 1475, 534, 1360, 5440, 339, 347, 1104, 63, 1317, 8, 277, 304, 267, 408, 37, 1147, 282, 17831, 5721, 340, 2337, 365, 1564, 1041, 267, 340, 291, 14, 1317, 26, 221, 327, 11942, 26, 949, 8486, 288, 746, 291, 14, 3764, 480, 2765, 13613, 1630, 440, 4729, 1564, 14, 710, 298, 3044, 3546, 498, 29, 585, 7, 1475, 367, 1511, 365, 5906, 12, 298, 3044, 298, 1180, 7596, 498, 26, 574, 7, 3140, 531, 421, 199, 533, 428, 1034, 9089, 27259, 8, 18670, 9089, 304, 339, 408, 264, 840, 13613, 367, 428, 1034, 9089, 5232, 6717, 1041, 339, 25210, 32047, 275, 298, 2802, 6717, 2, 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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pytest
testing/test_genscript.py
194
1689
import pytest import sys @pytest.fixture(scope="module") def standalone(request): return Standalone(request) class Standalone: def __init__(self, request): self.testdir = request.getfuncargvalue("testdir") script = "mypytest" result = self.testdir.runpytest("--genscript=%s" % script) assert result.ret == 0 self.script = self.testdir.tmpdir.join(script) assert self.script.check() def run(self, anypython, testdir, *args): return testdir._run(anypython, self.script, *args) def test_gen(testdir, anypython, standalone): if sys.version_info >= (2,7): result = testdir._run(anypython, "-c", "import sys;print (sys.version_info >=(2,7))") assert result.ret == 0 if result.stdout.str() == "False": pytest.skip("genscript called from python2.7 cannot work " "earlier python versions") result = standalone.run(anypython, testdir, '--version') if result.ret == 2: result.stderr.fnmatch_lines(["*ERROR: setuptools not installed*"]) elif result.ret == 0: result.stderr.fnmatch_lines([ "*imported from*mypytest*" ]) p = testdir.makepyfile("def test_func(): assert 0") result = standalone.run(anypython, testdir, p) assert result.ret != 0 else: pytest.fail("Unexpected return code") def test_freeze_includes(): """ Smoke test for freeze_includes(), to ensure that it works across all supported python versions. """ includes = pytest.freeze_includes() assert len(includes) > 1 assert '_pytest.genscript' in includes
mit
[ 646, 4613, 199, 646, 984, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 578, 531, 199, 318, 18042, 8, 1069, 304, 272, 372, 1933, 460, 10636, 8, 1069, 9, 199, 199, 533, 1933, 460, 10636, 26, 272, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 16634, 275, 1056, 14, 362, 1532, 1273, 585, 480, 16634, 531, 267, 2884, 275, 298, 1662, 4462, 2, 267, 754, 275, 291, 14, 16634, 14, 19889, 6739, 2268, 1579, 2458, 83, 2, 450, 2884, 9, 267, 702, 754, 14, 3292, 508, 378, 267, 291, 14, 1579, 275, 291, 14, 16634, 14, 8616, 14, 904, 8, 1579, 9, 267, 702, 291, 14, 1579, 14, 1074, 342, 339, 347, 1255, 8, 277, 12, 1263, 1548, 12, 7368, 12, 627, 589, 304, 267, 372, 7368, 423, 1065, 8, 1629, 1548, 12, 291, 14, 1579, 12, 627, 589, 9, 199, 199, 318, 511, 63, 2268, 8, 16634, 12, 1263, 1548, 12, 18042, 304, 272, 340, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 23, 304, 267, 754, 275, 7368, 423, 1065, 8, 1629, 1548, 12, 3905, 67, 401, 1816, 298, 646, 984, 27, 1361, 334, 1274, 14, 1023, 63, 815, 2356, 8, 18, 12, 23, 430, 531, 267, 702, 754, 14, 3292, 508, 378, 267, 340, 754, 14, 2703, 14, 495, 342, 508, 298, 797, 582, 288, 4613, 14, 2759, 480, 2268, 1579, 2797, 687, 2366, 18, 14, 23, 3913, 1736, 298, 717, 298, 2210, 5697, 2366, 5459, 531, 272, 754, 275, 18042, 14, 1065, 8, 1629, 1548, 12, 7368, 12, 2850, 1023, 358, 272, 340, 754, 14, 3292, 508, 499, 26, 267, 754, 14, 3083, 14, 15359, 63, 1278, 5234, 10, 3170, 26, 9116, 440, 4903, 10, 3135, 272, 916, 754, 14, 3292, 508, 378, 26, 267, 754, 14, 3083, 14, 15359, 63, 1278, 779, 288, 8969, 17932, 687, 10, 1662, 4462, 12469, 267, 4794, 267, 299, 275, 7368, 14, 17358, 480, 318, 511, 63, 1532, 837, 702, 378, 531, 267, 754, 275, 18042, 14, 1065, 8, 1629, 1548, 12, 7368, 12, 299, 9, 267, 702, 754, 14, 3292, 1137, 378, 272, 587, 26, 267, 4613, 14, 1633, 480, 8708, 372, 1233, 531, 421, 199, 318, 511, 63, 18459, 63, 9441, 837, 272, 408, 272, 428, 17767, 511, 367, 22778, 63, 9441, 1062, 370, 4868, 626, 652, 5419, 9371, 1006, 272, 3748, 2366, 5459, 14, 272, 408, 272, 6952, 275, 4613, 14, 18459, 63, 9441, 342, 272, 702, 822, 8, 9441, 9, 690, 413, 272, 702, 2513, 4462, 14, 2268, 1579, 7, 315, 6952, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4613, 199, 646, 984, 421, 199, 32, 4462, 14, 5997, 8, 2645, 628, 578, 531, 199, 318, 18042, 8, 1069, 304, 272, 372, 1933, 460, 10636, 8, 1069, 9, 199, 199, 533, 1933, 460, 10636, 26, 272, 347, 636, 826, 721, 277, 12, 1056, 304, 267, 291, 14, 16634, 275, 1056, 14, 362, 1532, 1273, 585, 480, 16634, 531, 267, 2884, 275, 298, 1662, 4462, 2, 267, 754, 275, 291, 14, 16634, 14, 19889, 6739, 2268, 1579, 2458, 83, 2, 450, 2884, 9, 267, 702, 754, 14, 3292, 508, 378, 267, 291, 14, 1579, 275, 291, 14, 16634, 14, 8616, 14, 904, 8, 1579, 9, 267, 702, 291, 14, 1579, 14, 1074, 342, 339, 347, 1255, 8, 277, 12, 1263, 1548, 12, 7368, 12, 627, 589, 304, 267, 372, 7368, 423, 1065, 8, 1629, 1548, 12, 291, 14, 1579, 12, 627, 589, 9, 199, 199, 318, 511, 63, 2268, 8, 16634, 12, 1263, 1548, 12, 18042, 304, 272, 340, 984, 14, 1023, 63, 815, 2356, 334, 18, 12, 23, 304, 267, 754, 275, 7368, 423, 1065, 8, 1629, 1548, 12, 3905, 67, 401, 1816, 298, 646, 984, 27, 1361, 334, 1274, 14, 1023, 63, 815, 2356, 8, 18, 12, 23, 430, 531, 267, 702, 754, 14, 3292, 508, 378, 267, 340, 754, 14, 2703, 14, 495, 342, 508, 298, 797, 582, 288, 4613, 14, 2759, 480, 2268, 1579, 2797, 687, 2366, 18, 14, 23, 3913, 1736, 298, 717, 298, 2210, 5697, 2366, 5459, 531, 272, 754, 275, 18042, 14, 1065, 8, 1629, 1548, 12, 7368, 12, 2850, 1023, 358, 272, 340, 754, 14, 3292, 508, 499, 26, 267, 754, 14, 3083, 14, 15359, 63, 1278, 5234, 10, 3170, 26, 9116, 440, 4903, 10, 3135, 272, 916, 754, 14, 3292, 508, 378, 26, 267, 754, 14, 3083, 14, 15359, 63, 1278, 779, 288, 8969, 17932, 687, 10, 1662, 4462, 12469, 267, 4794, 267, 299, 275, 7368, 14, 17358, 480, 318, 511, 63, 1532, 837, 702, 378, 531, 267, 754, 275, 18042, 14, 1065, 8, 1629, 1548, 12, 7368, 12, 299, 9, 267, 702, 754, 14, 3292, 1137, 378, 272, 587, 26, 267, 4613, 14, 1633, 480, 8708, 372, 1233, 531, 421, 199, 318, 511, 63, 18459, 63, 9441, 837, 272, 408, 272, 428, 17767, 511, 367, 22778, 63, 9441, 1062, 370, 4868, 626, 652, 5419, 9371, 1006, 272, 3748, 2366, 5459, 14, 272, 408, 272, 6952, 275, 4613, 14, 18459, 63, 9441, 342, 272, 702, 822, 8, 9441, 9, 690, 413, 272, 702, 2513, 4462, 14, 2268, 1579, 7, 315, 6952, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0 ]
keithroe/vtkoptix
ThirdParty/Twisted/twisted/web/test/_util.py
33
2475
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ General helpers for L{twisted.web} unit tests. """ from twisted.internet.defer import succeed from twisted.web import server from twisted.trial.unittest import TestCase from twisted.python.failure import Failure from twisted.web._flatten import flattenString from twisted.web.error import FlattenerError def _render(resource, request): result = resource.render(request) if isinstance(result, str): request.write(result) request.finish() return succeed(None) elif result is server.NOT_DONE_YET: if request.finished: return succeed(None) else: return request.notifyFinish() else: raise ValueError("Unexpected return value: %r" % (result,)) class FlattenTestCase(TestCase): """ A test case that assists with testing L{twisted.web._flatten}. """ def assertFlattensTo(self, root, target): """ Assert that a root element, when flattened, is equal to a string. """ d = flattenString(None, root) d.addCallback(lambda s: self.assertEqual(s, target)) return d def assertFlattensImmediately(self, root, target): """ Assert that a root element, when flattened, is equal to a string, and performs no asynchronus Deferred anything. This version is more convenient in tests which wish to make multiple assertions about flattening, since it can be called multiple times without having to add multiple callbacks. @return: the result of rendering L{root}, which should be equivalent to L{target}. @rtype: L{bytes} """ results = [] it = self.assertFlattensTo(root, target) it.addBoth(results.append) # Do our best to clean it up if something goes wrong. self.addCleanup(it.cancel) if not results: self.fail("Rendering did not complete immediately.") result = results[0] if isinstance(result, Failure): result.raiseException() return results[0] def assertFlatteningRaises(self, root, exn): """ Assert flattening a root element raises a particular exception. """ d = self.assertFailure(self.assertFlattensTo(root, ''), FlattenerError) d.addCallback(lambda exc: self.assertIsInstance(exc._exception, exn)) return d
bsd-3-clause
[ 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 14109, 10897, 367, 491, 91, 12145, 14, 2520, 93, 4137, 2295, 14, 199, 624, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 2520, 492, 1654, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 2520, 423, 8487, 492, 9378, 1558, 199, 504, 7390, 14, 2520, 14, 705, 492, 19005, 724, 281, 547, 421, 199, 318, 485, 3352, 8, 1927, 12, 1056, 304, 272, 754, 275, 2073, 14, 3352, 8, 1069, 9, 272, 340, 1228, 8, 1099, 12, 620, 304, 267, 1056, 14, 952, 8, 1099, 9, 267, 1056, 14, 8192, 342, 267, 372, 17961, 8, 403, 9, 272, 916, 754, 365, 1654, 14, 4609, 63, 22162, 63, 57, 775, 26, 267, 340, 1056, 14, 8669, 26, 288, 372, 17961, 8, 403, 9, 267, 587, 26, 288, 372, 1056, 14, 6814, 22084, 342, 272, 587, 26, 267, 746, 1722, 480, 8708, 372, 574, 26, 450, 82, 2, 450, 334, 1099, 4641, 4388, 199, 533, 19005, 724, 1746, 8, 1746, 304, 272, 408, 272, 437, 511, 1930, 626, 465, 338, 10329, 543, 5343, 491, 91, 12145, 14, 2520, 423, 8487, 5565, 272, 408, 272, 347, 702, 17271, 32461, 1378, 8, 277, 12, 1738, 12, 1347, 304, 267, 408, 267, 10716, 626, 282, 1738, 1819, 12, 1380, 18767, 12, 365, 4472, 370, 282, 1059, 14, 267, 408, 267, 366, 275, 9378, 1558, 8, 403, 12, 1738, 9, 267, 366, 14, 10053, 8, 2734, 308, 26, 291, 14, 629, 8, 83, 12, 1347, 430, 267, 372, 366, 2378, 347, 702, 17271, 32461, 24481, 590, 8, 277, 12, 1738, 12, 1347, 304, 267, 408, 267, 10716, 626, 282, 1738, 1819, 12, 1380, 18767, 12, 365, 4472, 370, 282, 1059, 12, 436, 267, 18628, 949, 465, 6030, 527, 17448, 7003, 14, 398, 961, 1015, 365, 1655, 22700, 315, 2295, 1314, 13809, 370, 1852, 3663, 267, 22835, 3595, 9378, 316, 12, 3967, 652, 883, 506, 2797, 3663, 5431, 267, 1928, 9445, 370, 1050, 3663, 13484, 14, 398, 768, 1107, 26, 314, 754, 402, 14066, 491, 91, 1231, 1386, 1314, 1077, 506, 7353, 370, 288, 491, 91, 1375, 5565, 267, 768, 4500, 26, 491, 91, 2394, 93, 267, 408, 267, 2058, 275, 942, 267, 652, 275, 291, 14, 479, 17271, 32461, 1378, 8, 1231, 12, 1347, 9, 267, 652, 14, 525, 18088, 8, 2604, 14, 740, 9, 267, 327, 4226, 4154, 5526, 370, 3633, 652, 1536, 340, 6020, 13538, 6835, 14, 267, 291, 14, 12808, 8, 390, 14, 6406, 9, 267, 340, 440, 2058, 26, 288, 291, 14, 1633, 480, 9216, 316, 8103, 440, 4890, 9939, 2685, 267, 754, 275, 2058, 59, 16, 61, 267, 340, 1228, 8, 1099, 12, 20367, 304, 288, 754, 14, 3730, 1726, 342, 267, 372, 2058, 59, 16, 61, 2378, 347, 702, 29302, 316, 1811, 8, 277, 12, 1738, 12, 444, 78, 304, 267, 408, 267, 10716, 9378, 316, 282, 1738, 1819, 6534, 282, 6770, 1919, 14, 267, 408, 267, 366, 275, 291, 14, 479, 6782, 8, 277, 14, 479, 17271, 32461, 1378, 8, 1231, 12, 9929, 19005, 724, 281, 547, 9, 267, 366, 14, 10053, 8, 2734, 3178, 26, 291, 14, 6926, 8, 2804, 423, 1971, 12, 444, 78, 430, 267, 372, 366, 28154, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 14109, 10897, 367, 491, 91, 12145, 14, 2520, 93, 4137, 2295, 14, 199, 624, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17961, 199, 504, 7390, 14, 2520, 492, 1654, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 504, 7390, 14, 2520, 423, 8487, 492, 9378, 1558, 199, 504, 7390, 14, 2520, 14, 705, 492, 19005, 724, 281, 547, 421, 199, 318, 485, 3352, 8, 1927, 12, 1056, 304, 272, 754, 275, 2073, 14, 3352, 8, 1069, 9, 272, 340, 1228, 8, 1099, 12, 620, 304, 267, 1056, 14, 952, 8, 1099, 9, 267, 1056, 14, 8192, 342, 267, 372, 17961, 8, 403, 9, 272, 916, 754, 365, 1654, 14, 4609, 63, 22162, 63, 57, 775, 26, 267, 340, 1056, 14, 8669, 26, 288, 372, 17961, 8, 403, 9, 267, 587, 26, 288, 372, 1056, 14, 6814, 22084, 342, 272, 587, 26, 267, 746, 1722, 480, 8708, 372, 574, 26, 450, 82, 2, 450, 334, 1099, 4641, 4388, 199, 533, 19005, 724, 1746, 8, 1746, 304, 272, 408, 272, 437, 511, 1930, 626, 465, 338, 10329, 543, 5343, 491, 91, 12145, 14, 2520, 423, 8487, 5565, 272, 408, 272, 347, 702, 17271, 32461, 1378, 8, 277, 12, 1738, 12, 1347, 304, 267, 408, 267, 10716, 626, 282, 1738, 1819, 12, 1380, 18767, 12, 365, 4472, 370, 282, 1059, 14, 267, 408, 267, 366, 275, 9378, 1558, 8, 403, 12, 1738, 9, 267, 366, 14, 10053, 8, 2734, 308, 26, 291, 14, 629, 8, 83, 12, 1347, 430, 267, 372, 366, 2378, 347, 702, 17271, 32461, 24481, 590, 8, 277, 12, 1738, 12, 1347, 304, 267, 408, 267, 10716, 626, 282, 1738, 1819, 12, 1380, 18767, 12, 365, 4472, 370, 282, 1059, 12, 436, 267, 18628, 949, 465, 6030, 527, 17448, 7003, 14, 398, 961, 1015, 365, 1655, 22700, 315, 2295, 1314, 13809, 370, 1852, 3663, 267, 22835, 3595, 9378, 316, 12, 3967, 652, 883, 506, 2797, 3663, 5431, 267, 1928, 9445, 370, 1050, 3663, 13484, 14, 398, 768, 1107, 26, 314, 754, 402, 14066, 491, 91, 1231, 1386, 1314, 1077, 506, 7353, 370, 288, 491, 91, 1375, 5565, 267, 768, 4500, 26, 491, 91, 2394, 93, 267, 408, 267, 2058, 275, 942, 267, 652, 275, 291, 14, 479, 17271, 32461, 1378, 8, 1231, 12, 1347, 9, 267, 652, 14, 525, 18088, 8, 2604, 14, 740, 9, 267, 327, 4226, 4154, 5526, 370, 3633, 652, 1536, 340, 6020, 13538, 6835, 14, 267, 291, 14, 12808, 8, 390, 14, 6406, 9, 267, 340, 440, 2058, 26, 288, 291, 14, 1633, 480, 9216, 316, 8103, 440, 4890, 9939, 2685, 267, 754, 275, 2058, 59, 16, 61, 267, 340, 1228, 8, 1099, 12, 20367, 304, 288, 754, 14, 3730, 1726, 342, 267, 372, 2058, 59, 16, 61, 2378, 347, 702, 29302, 316, 1811, 8, 277, 12, 1738, 12, 444, 78, 304, 267, 408, 267, 10716, 9378, 316, 282, 1738, 1819, 6534, 282, 6770, 1919, 14, 267, 408, 267, 366, 275, 291, 14, 479, 6782, 8, 277, 14, 479, 17271, 32461, 1378, 8, 1231, 12, 9929, 19005, 724, 281, 547, 9, 267, 366, 14, 10053, 8, 2734, 3178, 26, 291, 14, 6926, 8, 2804, 423, 1971, 12, 444, 78, 430, 267, 372, 366, 28154, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
pataquets/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py
126
5449
# Copyright (c) 2011 Google 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 Google 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. import BaseHTTPServer import cgi import codecs import datetime import fnmatch import json import mimetypes import os.path import shutil import threading import time import urlparse import wsgiref.handlers import BaseHTTPServer class ReflectionHandler(BaseHTTPServer.BaseHTTPRequestHandler): STATIC_FILE_EXTENSIONS = ['.js', '.css', '.html'] # Subclasses should override. STATIC_FILE_DIRECTORY = None # Setting this flag to True causes the server to send # Access-Control-Allow-Origin: * # with every response. allow_cross_origin_requests = False def do_GET(self): self._handle_request() def do_POST(self): self._handle_request() def do_HEAD(self): self._handle_request() def read_entity_body(self): length = int(self.headers.getheader('content-length')) return self.rfile.read(length) def _read_entity_body_as_json(self): return json.loads(self.read_entity_body()) def _handle_request(self): if "?" in self.path: path, query_string = self.path.split("?", 1) self.query = cgi.parse_qs(query_string) else: path = self.path self.query = {} function_or_file_name = path[1:] or "index.html" _, extension = os.path.splitext(function_or_file_name) if extension in self.STATIC_FILE_EXTENSIONS: self._serve_static_file(function_or_file_name) return function_name = function_or_file_name.replace(".", "_") if not hasattr(self, function_name): self.send_error(404, "Unknown function %s" % function_name) return if function_name[0] == "_": self.send_error(401, "Not allowed to invoke private or protected methods") return function = getattr(self, function_name) function() def _serve_static_file(self, static_path): self._serve_file(os.path.join(self.STATIC_FILE_DIRECTORY, static_path)) def quitquitquit(self): self._serve_text("Server quit.\n") # Shutdown has to happen on another thread from the server's thread, # otherwise there's a deadlock threading.Thread(target=lambda: self.server.shutdown()).start() def _send_access_control_header(self): if self.allow_cross_origin_requests: self.send_header('Access-Control-Allow-Origin', '*') def _serve_text(self, text): self.send_response(200) self._send_access_control_header() self.send_header("Content-type", "text/plain") self.end_headers() self.wfile.write(text) def _serve_json(self, json_object): self.send_response(200) self._send_access_control_header() self.send_header('Content-type', 'application/json') self.end_headers() json.dump(json_object, self.wfile) def _serve_file(self, file_path, cacheable_seconds=0, headers_only=False): if not os.path.exists(file_path): self.send_error(404, "File not found") return with codecs.open(file_path, "rb") as static_file: self.send_response(200) self._send_access_control_header() self.send_header("Content-Length", os.path.getsize(file_path)) mime_type, encoding = mimetypes.guess_type(file_path) if mime_type: self.send_header("Content-type", mime_type) if cacheable_seconds: expires_time = (datetime.datetime.now() + datetime.timedelta(0, cacheable_seconds)) expires_formatted = wsgiref.handlers.format_date_time( time.mktime(expires_time.timetuple())) self.send_header("Expires", expires_formatted) self.end_headers() if not headers_only: shutil.copyfileobj(static_file, self.wfile)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 199, 646, 3523, 14938, 199, 199, 646, 16004, 199, 646, 6010, 199, 646, 2197, 199, 646, 15951, 199, 646, 2022, 199, 646, 13290, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 5796, 199, 646, 900, 199, 646, 7097, 199, 646, 12464, 1121, 14, 5586, 199, 646, 3523, 14938, 421, 199, 533, 15397, 1486, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 272, 27815, 63, 3817, 63, 18451, 275, 18953, 3596, 297, 1987, 3919, 297, 1987, 1360, 418, 272, 327, 20196, 1077, 4278, 14, 272, 27815, 63, 3817, 63, 16436, 275, 488, 339, 327, 13510, 642, 3305, 370, 715, 14486, 314, 1654, 370, 3222, 272, 327, 257, 11003, 13, 3717, 13, 7852, 13, 12834, 26, 627, 272, 327, 543, 4036, 1177, 14, 272, 2040, 63, 7925, 63, 6493, 63, 6615, 275, 756, 339, 347, 886, 63, 2970, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 886, 63, 4030, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 886, 63, 5211, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 1586, 63, 4502, 63, 2030, 8, 277, 304, 267, 2582, 275, 1109, 8, 277, 14, 2139, 14, 19958, 360, 1317, 13, 1267, 1333, 267, 372, 291, 14, 23830, 14, 739, 8, 1267, 9, 339, 347, 485, 739, 63, 4502, 63, 2030, 63, 305, 63, 1001, 8, 277, 304, 267, 372, 2022, 14, 3640, 8, 277, 14, 739, 63, 4502, 63, 2030, 1012, 339, 347, 485, 2479, 63, 1069, 8, 277, 304, 267, 340, 29325, 315, 291, 14, 515, 26, 288, 931, 12, 1827, 63, 875, 275, 291, 14, 515, 14, 1294, 480, 15583, 413, 9, 288, 291, 14, 1131, 275, 16004, 14, 1122, 63, 6177, 8, 1131, 63, 875, 9, 267, 587, 26, 288, 931, 275, 291, 14, 515, 288, 291, 14, 1131, 275, 1052, 267, 805, 63, 269, 63, 493, 63, 354, 275, 931, 59, 17, 2938, 503, 298, 1080, 14, 1360, 2, 398, 5501, 3329, 275, 747, 14, 515, 14, 7973, 8, 1593, 63, 269, 63, 493, 63, 354, 9, 267, 340, 3329, 315, 291, 14, 10449, 63, 3817, 63, 18451, 26, 288, 291, 423, 4909, 63, 1986, 63, 493, 8, 1593, 63, 269, 63, 493, 63, 354, 9, 288, 372, 398, 805, 63, 354, 275, 805, 63, 269, 63, 493, 63, 354, 14, 1814, 30381, 2668, 531, 267, 340, 440, 2688, 8, 277, 12, 805, 63, 354, 304, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 298, 5912, 805, 450, 83, 2, 450, 805, 63, 354, 9, 288, 372, 267, 340, 805, 63, 354, 59, 16, 61, 508, 2668, 582, 288, 291, 14, 2254, 63, 705, 8, 8854, 12, 298, 1763, 4370, 370, 12677, 5726, 503, 17819, 3102, 531, 288, 372, 267, 805, 275, 2519, 8, 277, 12, 805, 63, 354, 9, 267, 805, 342, 339, 347, 485, 4909, 63, 1986, 63, 493, 8, 277, 12, 2955, 63, 515, 304, 267, 291, 423, 4909, 63, 493, 8, 736, 14, 515, 14, 904, 8, 277, 14, 10449, 63, 3817, 63, 16436, 12, 2955, 63, 515, 430, 339, 347, 17242, 10589, 10589, 8, 277, 304, 267, 291, 423, 4909, 63, 505, 480, 3120, 17242, 3134, 78, 531, 267, 327, 5244, 6159, 965, 370, 5992, 641, 4573, 2462, 687, 314, 1654, 1159, 2462, 12, 267, 327, 4257, 2337, 1159, 282, 12314, 831, 267, 5796, 14, 4436, 8, 1375, 29, 2734, 26, 291, 14, 1000, 14, 8831, 8801, 928, 342, 339, 347, 485, 2254, 63, 2732, 63, 2785, 63, 1291, 8, 277, 304, 267, 340, 291, 14, 3306, 63, 7925, 63, 6493, 63, 6615, 26, 288, 291, 14, 2254, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 339, 347, 485, 4909, 63, 505, 8, 277, 12, 1318, 304, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 423, 2254, 63, 2732, 63, 2785, 63, 1291, 342, 267, 291, 14, 2254, 63, 1291, 480, 2714, 13, 466, 401, 298, 505, 15, 6104, 531, 267, 291, 14, 500, 63, 2139, 342, 267, 291, 14, 18076, 14, 952, 8, 505, 9, 339, 347, 485, 4909, 63, 1001, 8, 277, 12, 2022, 63, 785, 304, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 423, 2254, 63, 2732 ]
[ 1898, 334, 67, 9, 7760, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 199, 646, 3523, 14938, 199, 199, 646, 16004, 199, 646, 6010, 199, 646, 2197, 199, 646, 15951, 199, 646, 2022, 199, 646, 13290, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 5796, 199, 646, 900, 199, 646, 7097, 199, 646, 12464, 1121, 14, 5586, 199, 646, 3523, 14938, 421, 199, 533, 15397, 1486, 2461, 8, 1563, 14938, 14, 1563, 23518, 304, 272, 27815, 63, 3817, 63, 18451, 275, 18953, 3596, 297, 1987, 3919, 297, 1987, 1360, 418, 272, 327, 20196, 1077, 4278, 14, 272, 27815, 63, 3817, 63, 16436, 275, 488, 339, 327, 13510, 642, 3305, 370, 715, 14486, 314, 1654, 370, 3222, 272, 327, 257, 11003, 13, 3717, 13, 7852, 13, 12834, 26, 627, 272, 327, 543, 4036, 1177, 14, 272, 2040, 63, 7925, 63, 6493, 63, 6615, 275, 756, 339, 347, 886, 63, 2970, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 886, 63, 4030, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 886, 63, 5211, 8, 277, 304, 267, 291, 423, 2479, 63, 1069, 342, 339, 347, 1586, 63, 4502, 63, 2030, 8, 277, 304, 267, 2582, 275, 1109, 8, 277, 14, 2139, 14, 19958, 360, 1317, 13, 1267, 1333, 267, 372, 291, 14, 23830, 14, 739, 8, 1267, 9, 339, 347, 485, 739, 63, 4502, 63, 2030, 63, 305, 63, 1001, 8, 277, 304, 267, 372, 2022, 14, 3640, 8, 277, 14, 739, 63, 4502, 63, 2030, 1012, 339, 347, 485, 2479, 63, 1069, 8, 277, 304, 267, 340, 29325, 315, 291, 14, 515, 26, 288, 931, 12, 1827, 63, 875, 275, 291, 14, 515, 14, 1294, 480, 15583, 413, 9, 288, 291, 14, 1131, 275, 16004, 14, 1122, 63, 6177, 8, 1131, 63, 875, 9, 267, 587, 26, 288, 931, 275, 291, 14, 515, 288, 291, 14, 1131, 275, 1052, 267, 805, 63, 269, 63, 493, 63, 354, 275, 931, 59, 17, 2938, 503, 298, 1080, 14, 1360, 2, 398, 5501, 3329, 275, 747, 14, 515, 14, 7973, 8, 1593, 63, 269, 63, 493, 63, 354, 9, 267, 340, 3329, 315, 291, 14, 10449, 63, 3817, 63, 18451, 26, 288, 291, 423, 4909, 63, 1986, 63, 493, 8, 1593, 63, 269, 63, 493, 63, 354, 9, 288, 372, 398, 805, 63, 354, 275, 805, 63, 269, 63, 493, 63, 354, 14, 1814, 30381, 2668, 531, 267, 340, 440, 2688, 8, 277, 12, 805, 63, 354, 304, 288, 291, 14, 2254, 63, 705, 8, 5188, 12, 298, 5912, 805, 450, 83, 2, 450, 805, 63, 354, 9, 288, 372, 267, 340, 805, 63, 354, 59, 16, 61, 508, 2668, 582, 288, 291, 14, 2254, 63, 705, 8, 8854, 12, 298, 1763, 4370, 370, 12677, 5726, 503, 17819, 3102, 531, 288, 372, 267, 805, 275, 2519, 8, 277, 12, 805, 63, 354, 9, 267, 805, 342, 339, 347, 485, 4909, 63, 1986, 63, 493, 8, 277, 12, 2955, 63, 515, 304, 267, 291, 423, 4909, 63, 493, 8, 736, 14, 515, 14, 904, 8, 277, 14, 10449, 63, 3817, 63, 16436, 12, 2955, 63, 515, 430, 339, 347, 17242, 10589, 10589, 8, 277, 304, 267, 291, 423, 4909, 63, 505, 480, 3120, 17242, 3134, 78, 531, 267, 327, 5244, 6159, 965, 370, 5992, 641, 4573, 2462, 687, 314, 1654, 1159, 2462, 12, 267, 327, 4257, 2337, 1159, 282, 12314, 831, 267, 5796, 14, 4436, 8, 1375, 29, 2734, 26, 291, 14, 1000, 14, 8831, 8801, 928, 342, 339, 347, 485, 2254, 63, 2732, 63, 2785, 63, 1291, 8, 277, 304, 267, 340, 291, 14, 3306, 63, 7925, 63, 6493, 63, 6615, 26, 288, 291, 14, 2254, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 339, 347, 485, 4909, 63, 505, 8, 277, 12, 1318, 304, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 423, 2254, 63, 2732, 63, 2785, 63, 1291, 342, 267, 291, 14, 2254, 63, 1291, 480, 2714, 13, 466, 401, 298, 505, 15, 6104, 531, 267, 291, 14, 500, 63, 2139, 342, 267, 291, 14, 18076, 14, 952, 8, 505, 9, 339, 347, 485, 4909, 63, 1001, 8, 277, 12, 2022, 63, 785, 304, 267, 291, 14, 2254, 63, 1310, 8, 1840, 9, 267, 291, 423, 2254, 63, 2732, 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,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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 ]
johnwallace123/dx-toolkit
src/python/dxpy/utils/genomic_utils.py
3
1240
# Copyright (C) 2013-2016 DNAnexus, Inc. # # This file is part of dx-toolkit (DNAnexus platform client libraries). # # 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 from ..compat import USING_PYTHON2, str if USING_PYTHON2: import string maketrans = string.maketrans else: maketrans = bytes.maketrans COMPLEMENT = maketrans(b"ATGCatgc", b"TACGTACG") SEQ_PATTERN = re.compile(b'[ACGTacgtNn]*$') def reverse_complement(seq): if isinstance(seq, str): bytes_seq = seq.encode('utf-8') else: bytes_seq = seq if not SEQ_PATTERN.match(bytes_seq): raise ValueError('Sequence %r must consist only of A, C, G, T, N' % (seq,)) return bytes_seq.translate(COMPLEMENT)[::-1]
apache-2.0
[ 3, 1898, 334, 35, 9, 6171, 13, 9261, 24842, 2493, 476, 527, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 11868, 13, 31994, 334, 10872, 2493, 476, 527, 4298, 1890, 8363, 680, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 199, 3, 257, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 282, 1331, 199, 3, 257, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 504, 2508, 5819, 492, 32210, 63, 11720, 18, 12, 620, 199, 199, 692, 32210, 63, 11720, 18, 26, 272, 492, 1059, 272, 5475, 31552, 275, 1059, 14, 22191, 31552, 199, 2836, 26, 272, 5475, 31552, 275, 2783, 14, 22191, 31552, 199, 199, 6790, 10320, 275, 5475, 31552, 8, 66, 2, 619, 7484, 292, 9493, 401, 330, 2, 52, 27351, 12986, 531, 199, 199, 28674, 63, 10764, 275, 295, 14, 2014, 8, 66, 3894, 27351, 645, 3308, 46, 78, 3672, 9988, 199, 199, 318, 3837, 63, 2731, 434, 8, 3610, 304, 272, 340, 1228, 8, 3610, 12, 620, 304, 267, 2783, 63, 3610, 275, 5412, 14, 2143, 360, 1624, 13, 24, 358, 272, 587, 26, 267, 2783, 63, 3610, 275, 5412, 272, 340, 440, 5795, 49, 63, 10764, 14, 1431, 8, 2394, 63, 3610, 304, 267, 746, 1722, 360, 5826, 450, 82, 1471, 17568, 1454, 402, 437, 12, 445, 12, 598, 12, 377, 12, 653, 7, 450, 334, 3610, 4641, 272, 372, 2783, 63, 3610, 14, 5275, 8, 6790, 10320, 2788, 21123, 17, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 6171, 13, 9261, 24842, 2493, 476, 527, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 11868, 13, 31994, 334, 10872, 2493, 476, 527, 4298, 1890, 8363, 680, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 199, 3, 257, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 282, 1331, 199, 3, 257, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 504, 2508, 5819, 492, 32210, 63, 11720, 18, 12, 620, 199, 199, 692, 32210, 63, 11720, 18, 26, 272, 492, 1059, 272, 5475, 31552, 275, 1059, 14, 22191, 31552, 199, 2836, 26, 272, 5475, 31552, 275, 2783, 14, 22191, 31552, 199, 199, 6790, 10320, 275, 5475, 31552, 8, 66, 2, 619, 7484, 292, 9493, 401, 330, 2, 52, 27351, 12986, 531, 199, 199, 28674, 63, 10764, 275, 295, 14, 2014, 8, 66, 3894, 27351, 645, 3308, 46, 78, 3672, 9988, 199, 199, 318, 3837, 63, 2731, 434, 8, 3610, 304, 272, 340, 1228, 8, 3610, 12, 620, 304, 267, 2783, 63, 3610, 275, 5412, 14, 2143, 360, 1624, 13, 24, 358, 272, 587, 26, 267, 2783, 63, 3610, 275, 5412, 272, 340, 440, 5795, 49, 63, 10764, 14, 1431, 8, 2394, 63, 3610, 304, 267, 746, 1722, 360, 5826, 450, 82, 1471, 17568, 1454, 402, 437, 12, 445, 12, 598, 12, 377, 12, 653, 7, 450, 334, 3610, 4641, 272, 372, 2783, 63, 3610, 14, 5275, 8, 6790, 10320, 2788, 21123, 17, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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------- - `nanmin` -- minimum non-NaN value - `nanmax` -- maximum non-NaN value - `nanargmin` -- index of minimum non-NaN value - `nanargmax` -- index of maximum non-NaN value - `nansum` -- sum of non-NaN values - `nanprod` -- product of non-NaN values - `nancumsum` -- cumulative sum of non-NaN values - `nancumprod` -- cumulative product of non-NaN values - `nanmean` -- mean of non-NaN values - `nanvar` -- variance of non-NaN values - `nanstd` -- standard deviation of non-NaN values - `nanmedian` -- median of non-NaN values - `nanpercentile` -- qth percentile of non-NaN values """ from __future__ import division, absolute_import, print_function import warnings import numpy as np from numpy.lib.function_base import _ureduce as _ureduce __all__ = [ 'nansum', 'nanmax', 'nanmin', 'nanargmax', 'nanargmin', 'nanmean', 'nanmedian', 'nanpercentile', 'nanvar', 'nanstd', 'nanprod', 'nancumsum', 'nancumprod' ] def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations where NaNs were present. If `a` is not of inexact type, do nothing and return `a` together with a mask of None. Note that scalars will end up as array scalars, which is important for using the result as the value of the out argument in some operations. Parameters ---------- a : array-like Input array. val : float NaN values are set to val before doing the operation. Returns ------- y : ndarray If `a` is of inexact type, return a copy of `a` with the NaNs replaced by the fill value, otherwise return `a`. mask: {bool, None} If `a` is of inexact type, return a boolean mask marking locations of NaNs, otherwise return None. """ is_new = not isinstance(a, np.ndarray) if is_new: a = np.array(a) if not issubclass(a.dtype.type, np.inexact): return a, None if not is_new: # need copy a = np.array(a, subok=True) mask = np.isnan(a) np.copyto(a, val, where=mask) return a, mask def _copyto(a, val, mask): """ Replace values in `a` with NaN where `mask` is True. This differs from copyto in that it will deal with the case where `a` is a numpy scalar. Parameters ---------- a : ndarray or numpy scalar Array or numpy scalar some of whose values are to be replaced by val. val : numpy scalar Value used a replacement. mask : ndarray, scalar Boolean array. Where True the corresponding element of `a` is replaced by `val`. Broadcasts. Returns ------- res : ndarray, scalar Array with elements replaced or scalar `val`. """ if isinstance(a, np.ndarray): np.copyto(a, val, where=mask, casting='unsafe') else: a = a.dtype.type(val) return a def _divide_by_count(a, b, out=None): """ Compute a/b ignoring invalid results. If `a` is an array the division is done in place. If `a` is a scalar, then its type is preserved in the output. If out is None, then then a is used instead so that the division is in place. Note that this is only called with `a` an inexact type. Parameters ---------- a : {ndarray, numpy scalar} Numerator. Expected to be of inexact type but not checked. b : {ndarray, numpy scalar} Denominator. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. Returns ------- ret : {ndarray, numpy scalar} The return value is a/b. If `a` was an ndarray the division is done in place. If `a` is a numpy scalar, the division preserves its type. """ with np.errstate(invalid='ignore', divide='ignore'): if isinstance(a, np.ndarray): if out is None: return np.divide(a, b, out=a, casting='unsafe') else: return np.divide(a, b, out=out, casting='unsafe') else: if out is None: return a.dtype.type(a / b) else: # This is questionable, but currently a numpy scalar can # be output to a zero dimensional array. return np.divide(a, b, out=out, casting='unsafe') def nanmin(a, axis=None, out=None, keepdims=np._NoValue): """ Return minimum of an array or minimum along an axis, ignoring any NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is raised and Nan is returned for that slice. Parameters ---------- a : array_like Array containing numbers whose minimum is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the minimum is computed. The default is to compute the minimum of the flattened array. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See `doc.ufuncs` for details. .. versionadded:: 1.8.0 keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If the value is anything but the default, then `keepdims` will be passed through to the `min` method of sub-classes of `ndarray`. If the sub-classes methods does not implement `keepdims` any exceptions will be raised. .. versionadded:: 1.8.0 Returns ------- nanmin : ndarray An array with the same shape as `a`, with the specified axis removed. If `a` is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as `a` is returned. See Also -------- nanmax : The maximum value of an array along a given axis, ignoring any NaNs. amin : The minimum value of an array along a given axis, propagating any NaNs. fmin : Element-wise minimum of two arrays, ignoring any NaNs. minimum : Element-wise minimum of two arrays, propagating any NaNs. isnan : Shows which elements are Not a Number (NaN). isfinite: Shows which elements are neither NaN nor infinity. amax, fmax, maximum Notes ----- NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number. If the input has a integer type the function is equivalent to np.min. Examples -------- >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nanmin(a) 1.0 >>> np.nanmin(a, axis=0) array([ 1., 2.]) >>> np.nanmin(a, axis=1) array([ 1., 3.]) When positive infinity and negative infinity are present: >>> np.nanmin([1, 2, np.nan, np.inf]) 1.0 >>> np.nanmin([1, 2, np.nan, np.NINF]) -inf """ kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims if not isinstance(a, np.ndarray) or type(a) is np.ndarray: # Fast, but not safe for subclasses of ndarray res = np.fmin.reduce(a, axis=axis, out=out, **kwargs) if np.isnan(res).any(): warnings.warn("All-NaN axis encountered", RuntimeWarning, stacklevel=2) else: # Slow, but safe for subclasses of ndarray a, mask = _replace_nan(a, +np.inf) res = np.amin(a, axis=axis, out=out, **kwargs) if mask is None: return res # Check for all-NaN axis mask = np.all(mask, axis=axis, **kwargs) if np.any(mask): res = _copyto(res, np.nan, mask) warnings.warn("All-NaN axis encountered", RuntimeWarning, stacklevel=2) return res def nanmax(a, axis=None, out=None, keepdims=np._NoValue): """ Return the maximum of an array or maximum along an axis, ignoring any NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is raised and NaN is returned for that slice. Parameters ---------- a : array_like Array containing numbers whose maximum is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the maximum is computed. The default is to compute the maximum of the flattened array. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See `doc.ufuncs` for details. .. versionadded:: 1.8.0 keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If the value is anything but the default, then `keepdims` will be passed through to the `max` method of sub-classes of `ndarray`. If the sub-classes methods does not implement `keepdims` any exceptions will be raised. .. versionadded:: 1.8.0 Returns ------- nanmax : ndarray An array with the same shape as `a`, with the specified axis removed. If `a` is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as `a` is returned. See Also -------- nanmin : The minimum value of an array along a given axis, ignoring any NaNs. amax : The maximum value of an array along a given axis, propagating any NaNs. fmax : Element-wise maximum of two arrays, ignoring any NaNs. maximum : Element-wise maximum of two arrays, propagating any NaNs. isnan : Shows which elements are Not a Number (NaN). isfinite: Shows which elements are neither NaN nor infinity. amin, fmin, minimum Notes ----- NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number. If the input has a integer type the function is equivalent to np.max. Examples -------- >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nanmax(a) 3.0 >>> np.nanmax(a, axis=0) array([ 3., 2.]) >>> np.nanmax(a, axis=1) array([ 2., 3.]) When positive infinity and negative infinity are present: >>> np.nanmax([1, 2, np.nan, np.NINF]) 2.0 >>> np.nanmax([1, 2, np.nan, np.inf]) inf """ kwargs = {} if keepdims is not np._NoValue: kwargs['keepdims'] = keepdims if not isinstance(a, np.ndarray) or type(a) is np.ndarray: # Fast, but not safe for subclasses of ndarray res = np.fmax.reduce(a, axis=axis, out=out, **kwargs) if np.isnan(res).any(): warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=2) else: # Slow, but safe for subclasses of ndarray a, mask = _replace_nan(a, -np.inf) res = np.amax(a, axis=axis, out=out, **kwargs) if mask is None: return res # Check for all-NaN axis mask = np.all(mask, axis=axis, **kwargs) if np.any(mask): res = _copyto(res, np.nan, mask) warnings.warn("All-NaN axis encountered", RuntimeWarning, stacklevel=2) return res def nanargmin(a, axis=None): """ Return the indices of the minimum values in the specified axis ignoring NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results cannot be trusted if a slice contains only NaNs and Infs. Parameters ---------- a : array_like Input data. axis : int, optional Axis along which to operate. By default flattened input is used. Returns ------- index_array : ndarray An array of indices or a single index value. See Also -------- argmin, nanargmax Examples -------- >>> a = np.array([[np.nan, 4], [2, 3]]) >>> np.argmin(a) 0 >>> np.nanargmin(a) 2 >>> np.nanargmin(a, axis=0) array([1, 1]) >>> np.nanargmin(a, axis=1) array([1, 0]) """ a, mask = _replace_nan(a, np.inf) res = np.argmin(a, axis=axis) if mask is not None: mask = np.all(mask, axis=axis) if np.any(mask): raise ValueError("All-NaN slice encountered") return res def nanargmax(a, axis=None): """ Return the indices of the maximum values in the specified axis ignoring NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results cannot be trusted if a slice contains only NaNs and -Infs. Parameters ---------- a : array_like Input data. axis : int, optional Axis along which to operate. By default flattened input is used. Returns ------- index_array : ndarray An array of indices or a single index value. See Also -------- argmax, nanargmin Examples -------- >>> a = np.array([[np.nan, 4], [2, 3]]) >>> np.argmax(a) 0 >>> np.nanargmax(a) 1 >>> np.nanargmax(a, axis=0) array([1, 0]) >>> np.nanargmax(a, axis=1) array([1, 1]) """ a, mask = _replace_nan(a, -np.inf) res = np.argmax(a, axis=axis) if mask is not None: mask = np.all(mask, axis=axis) if np.any(mask): raise ValueError("All-NaN slice encountered") return res def nansum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue): """ Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. In NumPy versions <= 1.8.0 Nan is returned for slices that are all-NaN or empty. In later versions zero is returned. Parameters ---------- a : array_like Array containing numbers whose sum is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the sum is computed. The default is to compute the sum of the flattened array. dtype : data-type, optional The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of `a` is used. An exception is when `a` has an integer type with less precision than the platform (u)intp. In that case, the default will be either (u)int32 or (u)int64 depending on whether the platform is 32 or 64 bits. For inexact inputs, dtype must be inexact. .. versionadded:: 1.8.0 out : ndarray, optional Alternate output array in which to place the result. The default is ``None``. If provided, it must have the same shape as the expected output, but the type will be cast if necessary. See `doc.ufuncs` for details. The casting of NaN to integer can yield unexpected results. .. versionadded:: 1.8.0 keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If the value is anything but the default, then `keepdims` will be passed through to the `mean` or `sum` methods of sub-classes of `ndarray`. If the sub-classes methods does not implement `keepdims` any exceptions will be raised. .. versionadded:: 1.8.0 Returns ------- nansum : ndarray. A new array holding the result is returned unless `out` is specified, in which it is returned. The result has the same size as `a`, and the same shape as `a` if `axis` is not None or `a` is a 1-d array. See Also -------- numpy.sum : Sum across array propagating NaNs. isnan : Show which elements are NaN. isfinite: Show which elements are not NaN or +/-inf. Notes ----- If both positive and negative infinity are present, the sum will be Not A Number (NaN). Examples -------- >>> np.nansum(1) 1 >>> np.nansum([1]) 1 >>> np.nansum([1, np.nan]) 1.0 >>> a = np.array([[1, 1], [1, np.nan]]) >>> np.nansum(a) 3.0 >>> np.nansum(a, axis=0) array([ 2., 1.]) >>> np.nansum([1, np.nan, np.inf]) inf >>> np.nansum([1, np.nan, np.NINF]) -inf >>> np.nansum([1, np.nan, np.inf, -np.inf]) # both +/- infinity present nan """ a, mask = _replace_nan(a, 0) return np.sum(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims) def nanprod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue): """ Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones. One is returned for slices that are all-NaN or empty. .. versionadded:: 1.10.0 Parameters ---------- a : array_like Array containing numbers whose sum is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the product is computed. The default is to compute the product of the flattened array. dtype : data-type, optional The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of `a` is used. An exception is when `a` has an integer type with less precision than the platform (u)intp. In that case, the default will be either (u)int32 or (u)int64 depending on whether the platform is 32 or 64 bits. For inexact inputs, dtype must be inexact. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``. If provided, it must have the same shape as the expected output, but the type will be cast if necessary. See `doc.ufuncs` for details. The casting of NaN to integer can yield unexpected results. keepdims : bool, optional If True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `arr`. Returns ------- nanprod : ndarray A new array holding the result is returned unless `out` is specified, in which case it is returned. See Also -------- numpy.prod : Product across array propagating NaNs. isnan : Show which elements are NaN. Examples -------- >>> np.nanprod(1) 1 >>> np.nanprod([1]) 1 >>> np.nanprod([1, np.nan]) 1.0 >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nanprod(a) 6.0 >>> np.nanprod(a, axis=0) array([ 3., 2.]) """ a, mask = _replace_nan(a, 1) return np.prod(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims) def nancumsum(a, axis=None, dtype=None, out=None): """ Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros. Zeros are returned for slices that are all-NaN or empty. .. versionadded:: 1.12.0 Parameters ---------- a : array_like Input array. axis : int, optional Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array. dtype : dtype, optional Type of the returned array and of the accumulator in which the elements are summed. If `dtype` is not specified, it defaults to the dtype of `a`, unless `a` has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See `doc.ufuncs` (Section "Output arguments") for more details. Returns ------- nancumsum : ndarray. A new array holding the result is returned unless `out` is specified, in which it is returned. The result has the same size as `a`, and the same shape as `a` if `axis` is not None or `a` is a 1-d array. See Also -------- numpy.cumsum : Cumulative sum across array propagating NaNs. isnan : Show which elements are NaN. Examples -------- >>> np.nancumsum(1) array([1]) >>> np.nancumsum([1]) array([1]) >>> np.nancumsum([1, np.nan]) array([ 1., 1.]) >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nancumsum(a) array([ 1., 3., 6., 6.]) >>> np.nancumsum(a, axis=0) array([[ 1., 2.], [ 4., 2.]]) >>> np.nancumsum(a, axis=1) array([[ 1., 3.], [ 3., 3.]]) """ a, mask = _replace_nan(a, 0) return np.cumsum(a, axis=axis, dtype=dtype, out=out) def nancumprod(a, axis=None, dtype=None, out=None): """ Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one. The cumulative product does not change when NaNs are encountered and leading NaNs are replaced by ones. Ones are returned for slices that are all-NaN or empty. .. versionadded:: 1.12.0 Parameters ---------- a : array_like Input array. axis : int, optional Axis along which the cumulative product is computed. By default the input is flattened. dtype : dtype, optional Type of the returned array, as well as of the accumulator in which the elements are multiplied. If *dtype* is not specified, it defaults to the dtype of `a`, unless `a` has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used instead. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type of the resulting values will be cast if necessary. Returns ------- nancumprod : ndarray A new array holding the result is returned unless `out` is specified, in which case it is returned. See Also -------- numpy.cumprod : Cumulative product across array propagating NaNs. isnan : Show which elements are NaN. Examples -------- >>> np.nancumprod(1) array([1]) >>> np.nancumprod([1]) array([1]) >>> np.nancumprod([1, np.nan]) array([ 1., 1.]) >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nancumprod(a) array([ 1., 2., 6., 6.]) >>> np.nancumprod(a, axis=0) array([[ 1., 2.], [ 3., 2.]]) >>> np.nancumprod(a, axis=1) array([[ 1., 2.], [ 3., 3.]]) """ a, mask = _replace_nan(a, 1) return np.cumprod(a, axis=axis, dtype=dtype, out=out) def nanmean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue): """ Compute the arithmetic mean along the specified axis, ignoring NaNs. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. `float64` intermediate and return values are used for integer inputs. For all-NaN slices, NaN is returned and a `RuntimeWarning` is raised. .. versionadded:: 1.8.0 Parameters ---------- a : array_like Array containing numbers whose mean is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the means are computed. The default is to compute the mean of the flattened array. dtype : data-type, optional Type to use in computing the mean. For integer inputs, the default is `float64`; for inexact inputs, it is the same as the input dtype. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See `doc.ufuncs` for details. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If the value is anything but the default, then `keepdims` will be passed through to the `mean` or `sum` methods of sub-classes of `ndarray`. If the sub-classes methods does not implement `keepdims` any exceptions will be raised. Returns ------- m : ndarray, see dtype parameter above If `out=None`, returns a new array containing the mean values, otherwise a reference to the output array is returned. Nan is returned for slices that contain only NaNs. See Also -------- average : Weighted average mean : Arithmetic mean taken while not ignoring NaNs var, nanvar Notes ----- The arithmetic mean is the sum of the non-NaN elements along the axis divided by the number of non-NaN elements. Note that for floating-point input, the mean is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for `float32`. Specifying a higher-precision accumulator using the `dtype` keyword can alleviate this issue. Examples -------- >>> a = np.array([[1, np.nan], [3, 4]]) >>> np.nanmean(a) 2.6666666666666665 >>> np.nanmean(a, axis=0) array([ 2., 4.]) >>> np.nanmean(a, axis=1) array([ 1., 3.5]) """ arr, mask = _replace_nan(a, 0) if mask is None: return np.mean(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims) if dtype is not None: dtype = np.dtype(dtype) if dtype is not None and not issubclass(dtype.type, np.inexact): raise TypeError("If a is inexact, then dtype must be inexact") if out is not None and not issubclass(out.dtype.type, np.inexact): raise TypeError("If a is inexact, then out must be inexact") cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=keepdims) tot = np.sum(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims) avg = _divide_by_count(tot, cnt, out=out) isbad = (cnt == 0) if isbad.any(): warnings.warn("Mean of empty slice", RuntimeWarning, stacklevel=2) # NaN is the only possible bad value, so no further # action is needed to handle bad results. return avg def _nanmedian1d(arr1d, overwrite_input=False): """ Private function for rank 1 arrays. Compute the median ignoring NaNs. See nanmedian for parameter usage """ c = np.isnan(arr1d) s = np.where(c)[0] if s.size == arr1d.size: warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=3) return np.nan elif s.size == 0: return np.median(arr1d, overwrite_input=overwrite_input) else: if overwrite_input: x = arr1d else: x = arr1d.copy() # select non-nans at end of array enonan = arr1d[-s.size:][~c[-s.size:]] # fill nans in beginning of array with non-nans of end x[s[:enonan.size]] = enonan # slice nans away return np.median(x[:-s.size], overwrite_input=True) def _nanmedian(a, axis=None, out=None, overwrite_input=False): """ Private function that doesn't support extended axis or keepdims. These methods are extended to this function using _ureduce See nanmedian for parameter usage """ if axis is None or a.ndim == 1: part = a.ravel() if out is None: return _nanmedian1d(part, overwrite_input) else: out[...] = _nanmedian1d(part, overwrite_input) return out else: # for small medians use sort + indexing which is still faster than # apply_along_axis # benchmarked with shuffled (50, 50, x) containing a few NaN if a.shape[axis] < 600: return _nanmedian_small(a, axis, out, overwrite_input) result = np.apply_along_axis(_nanmedian1d, axis, a, overwrite_input) if out is not None: out[...] = result return result def _nanmedian_small(a, axis=None, out=None, overwrite_input=False): """ sort + indexing median, faster for small medians along multiple dimensions due to the high overhead of apply_along_axis see nanmedian for parameter usage """ a = np.ma.masked_array(a, np.isnan(a)) m = np.ma.median(a, axis=axis, overwrite_input=overwrite_input) for i in range(np.count_nonzero(m.mask.ravel())): warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=3) if out is not None: out[...] = m.filled(np.nan) return out return m.filled(np.nan) def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValue): """ Compute the median along the specified axis, while ignoring NaNs. Returns the median of the array elements. .. versionadded:: 1.9.0 Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : {int, sequence of int, None}, optional Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the array. A sequence of axes is supported since version 1.9.0. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary. overwrite_input : bool, optional If True, then allow use of memory of input array `a` for calculations. The input array will be modified by the call to `median`. This will save memory when you do not need to preserve the contents of the input array. Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. If `overwrite_input` is ``True`` and `a` is not already an `ndarray`, an error will be raised. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If this is anything but the default value it will be passed through (in the special case of an empty array) to the `mean` function of the underlying array. If the array is a sub-class and `mean` does not have the kwarg `keepdims` this will raise a RuntimeError. Returns ------- median : ndarray A new array holding the result. If the input contains integers or floats smaller than ``float64``, then the output data-type is ``np.float64``. Otherwise, the data-type of the output is the same as that of the input. If `out` is specified, that array is returned instead. See Also -------- mean, median, percentile Notes ----- Given a vector ``V`` of length ``N``, the median of ``V`` is the middle value of a sorted copy of ``V``, ``V_sorted`` - i.e., ``V_sorted[(N-1)/2]``, when ``N`` is odd and the average of the two middle values of ``V_sorted`` when ``N`` is even. Examples -------- >>> a = np.array([[10.0, 7, 4], [3, 2, 1]]) >>> a[0, 1] = np.nan >>> a array([[ 10., nan, 4.], [ 3., 2., 1.]]) >>> np.median(a) nan >>> np.nanmedian(a) 3.0 >>> np.nanmedian(a, axis=0) array([ 6.5, 2., 2.5]) >>> np.median(a, axis=1) array([ 7., 2.]) >>> b = a.copy() >>> np.nanmedian(b, axis=1, overwrite_input=True) array([ 7., 2.]) >>> assert not np.all(a==b) >>> b = a.copy() >>> np.nanmedian(b, axis=None, overwrite_input=True) 3.0 >>> assert not np.all(a==b) """ a = np.asanyarray(a) # apply_along_axis in _nanmedian doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = _ureduce(a, func=_nanmedian, axis=axis, out=out, overwrite_input=overwrite_input) if keepdims and keepdims is not np._NoValue: return r.reshape(k) else: return r def nanpercentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=np._NoValue): """ Compute the qth percentile of the data along the specified axis, while ignoring nan values. Returns the qth percentile(s) of the array elements. .. versionadded:: 1.9.0 Parameters ---------- a : array_like Input array or object that can be converted to an array. q : float in range of [0,100] (or sequence of floats) Percentile to compute, which must be between 0 and 100 inclusive. axis : {int, sequence of int, None}, optional Axis or axes along which the percentiles are computed. The default is to compute the percentile(s) along a flattened version of the array. A sequence of axes is supported since version 1.9.0. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary. overwrite_input : bool, optional If True, then allow use of memory of input array `a` for calculations. The input array will be modified by the call to `percentile`. This will save memory when you do not need to preserve the contents of the input array. In this case you should not make any assumptions about the contents of the input `a` after this function completes -- treat it as undefined. Default is False. If `a` is not already an array, this parameter will have no effect as `a` will be converted to an array internally regardless of the value of this parameter. interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'} This optional parameter specifies the interpolation method to use when the desired quantile lies between two data points ``i < j``: * linear: ``i + (j - i) * fraction``, where ``fraction`` is the fractional part of the index surrounded by ``i`` and ``j``. * lower: ``i``. * higher: ``j``. * nearest: ``i`` or ``j``, whichever is nearest. * midpoint: ``(i + j) / 2``. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original array `a`. If this is anything but the default value it will be passed through (in the special case of an empty array) to the `mean` function of the underlying array. If the array is a sub-class and `mean` does not have the kwarg `keepdims` this will raise a RuntimeError. Returns ------- percentile : scalar or ndarray If `q` is a single percentile and `axis=None`, then the result is a scalar. If multiple percentiles are given, first axis of the result corresponds to the percentiles. The other axes are the axes that remain after the reduction of `a`. If the input contains integers or floats smaller than ``float64``, the output data-type is ``float64``. Otherwise, the output data-type is the same as that of the input. If `out` is specified, that array is returned instead. See Also -------- nanmean, nanmedian, percentile, median, mean Notes ----- Given a vector ``V`` of length ``N``, the ``q``-th percentile of ``V`` is the value ``q/100`` of the way from the mimumum to the maximum in in a sorted copy of ``V``. The values and distances of the two nearest neighbors as well as the `interpolation` parameter will determine the percentile if the normalized ranking does not match the location of ``q`` exactly. This function is the same as the median if ``q=50``, the same as the minimum if ``q=0`` and the same as the maximum if ``q=100``. Examples -------- >>> a = np.array([[10., 7., 4.], [3., 2., 1.]]) >>> a[0][1] = np.nan >>> a array([[ 10., nan, 4.], [ 3., 2., 1.]]) >>> np.percentile(a, 50) nan >>> np.nanpercentile(a, 50) 3.5 >>> np.nanpercentile(a, 50, axis=0) array([ 6.5, 2., 2.5]) >>> np.nanpercentile(a, 50, axis=1, keepdims=True) array([[ 7.], [ 2.]]) >>> m = np.nanpercentile(a, 50, axis=0) >>> out = np.zeros_like(m) >>> np.nanpercentile(a, 50, axis=0, out=out) array([ 6.5, 2., 2.5]) >>> m array([ 6.5, 2. , 2.5]) >>> b = a.copy() >>> np.nanpercentile(b, 50, axis=1, overwrite_input=True) array([ 7., 2.]) >>> assert not np.all(a==b) """ a = np.asanyarray(a) q = np.asanyarray(q) # apply_along_axis in _nanpercentile doesn't handle empty arrays well, # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) r, k = _ureduce(a, func=_nanpercentile, q=q, axis=axis, out=out, overwrite_input=overwrite_input, interpolation=interpolation) if keepdims and keepdims is not np._NoValue: if q.ndim == 0: return r.reshape(k) else: return r.reshape([len(q)] + k) else: return r def _nanpercentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear'): """ Private function that doesn't support extended axis or keepdims. These methods are extended to this function using _ureduce See nanpercentile for parameter usage """ if axis is None or a.ndim == 1: part = a.ravel() result = _nanpercentile1d(part, q, overwrite_input, interpolation) else: result = np.apply_along_axis(_nanpercentile1d, axis, a, q, overwrite_input, interpolation) # apply_along_axis fills in collapsed axis with results. # Move that axis to the beginning to match percentile's # convention. if q.ndim != 0: result = np.rollaxis(result, axis) if out is not None: out[...] = result return result def _nanpercentile1d(arr1d, q, overwrite_input=False, interpolation='linear'): """ Private function for rank 1 arrays. Compute percentile ignoring NaNs. See nanpercentile for parameter usage """ c = np.isnan(arr1d) s = np.where(c)[0] if s.size == arr1d.size: warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=3) if q.ndim == 0: return np.nan else: return np.nan * np.ones((len(q),)) elif s.size == 0: return np.percentile(arr1d, q, overwrite_input=overwrite_input, interpolation=interpolation) else: if overwrite_input: x = arr1d else: x = arr1d.copy() # select non-nans at end of array enonan = arr1d[-s.size:][~c[-s.size:]] # fill nans in beginning of array with non-nans of end x[s[:enonan.size]] = enonan # slice nans away return np.percentile(x[:-s.size], q, overwrite_input=True, interpolation=interpolation) def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue): """ Compute the variance along the specified axis, while ignoring NaNs. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis. For all-NaN slices or slices with zero degrees of freedom, NaN is returned and a `RuntimeWarning` is raised. .. versionadded:: 1.8.0 Parameters ---------- a : array_like Array containing numbers whose variance is desired. If `a` is not an array, a conversion is attempted. axis : int, optional Axis along which the variance is computed. The default is to compute the variance of the flattened array. dtype : data-type, optional Type to use in computing the variance. For arrays of integer type the default is `float32`; for arrays of float types it is the same as the array type. out : ndarray, optional Alternate output array in which to place the result. It must have the same shape as the expected output, but the type is cast if necessary. ddof : int, optional "Delta Degrees of Freedom": the divisor used in the calculation is ``N - ddof``, where ``N`` represents the number of non-NaN elements. By default `ddof` is zero. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. Returns ------- variance : ndarray, see dtype parameter above If `out` is None, return a new array containing the variance, otherwise return a reference to the output array. If ddof is >= the number of non-NaN elements in a slice or the slice contains only NaNs, then the result for that slice is NaN. See Also -------- std : Standard deviation mean : Average var : Variance while not ignoring NaNs nanstd, nanmean numpy.doc.ufuncs : Section "Output arguments" Notes ----- The variance is the average of the squared deviations from the mean, i.e., ``var = mean(abs(x - x.mean())**2)``. The mean is normally calculated as ``x.sum() / N``, where ``N = len(x)``. If, however, `ddof` is specified, the divisor ``N - ddof`` is used instead. In standard statistical practice, ``ddof=1`` provides an unbiased estimator of the variance of a hypothetical infinite population. ``ddof=0`` provides a maximum likelihood estimate of the variance for normally distributed variables. Note that for complex numbers, the absolute value is taken before squaring, so that the result is always real and nonnegative. For floating-point input, the variance is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for `float32` (see example below). Specifying a higher-accuracy accumulator using the ``dtype`` keyword can alleviate this issue. For this function to work on sub-classes of ndarray, they must define `sum` with the kwarg `keepdims` Examples -------- >>> a = np.array([[1, np.nan], [3, 4]]) >>> np.var(a) 1.5555555555555554 >>> np.nanvar(a, axis=0) array([ 1., 0.]) >>> np.nanvar(a, axis=1) array([ 0., 0.25]) """ arr, mask = _replace_nan(a, 0) if mask is None: return np.var(arr, axis=axis, dtype=dtype, out=out, ddof=ddof, keepdims=keepdims) if dtype is not None: dtype = np.dtype(dtype) if dtype is not None and not issubclass(dtype.type, np.inexact): raise TypeError("If a is inexact, then dtype must be inexact") if out is not None and not issubclass(out.dtype.type, np.inexact): raise TypeError("If a is inexact, then out must be inexact") # Compute mean if type(arr) is np.matrix: _keepdims = np._NoValue else: _keepdims = True # we need to special case matrix for reverse compatibility # in order for this to work, these sums need to be called with # keepdims=True, however matrix now raises an error in this case, but # the reason that it drops the keepdims kwarg is to force keepdims=True # so this used to work by serendipity. cnt = np.sum(~mask, axis=axis, dtype=np.intp, keepdims=_keepdims) avg = np.sum(arr, axis=axis, dtype=dtype, keepdims=_keepdims) avg = _divide_by_count(avg, cnt) # Compute squared deviation from mean. np.subtract(arr, avg, out=arr, casting='unsafe') arr = _copyto(arr, 0, mask) if issubclass(arr.dtype.type, np.complexfloating): sqr = np.multiply(arr, arr.conj(), out=arr).real else: sqr = np.multiply(arr, arr, out=arr) # Compute variance. var = np.sum(sqr, axis=axis, dtype=dtype, out=out, keepdims=keepdims) if var.ndim < cnt.ndim: # Subclasses of ndarray may ignore keepdims, so check here. cnt = cnt.squeeze(axis) dof = cnt - ddof var = _divide_by_count(var, dof) isbad = (dof <= 0) if np.any(isbad): warnings.warn("Degrees of freedom <= 0 for slice.", RuntimeWarning, stacklevel=2) # NaN, inf, or negative numbers are all possible bad # values, so explicitly replace them with NaN. var = _copyto(var, np.nan, isbad) return var def nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue): """ Compute the standard deviation along the specified axis, while ignoring NaNs. Returns the standard deviation, a measure of the spread of a distribution, of the non-NaN array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis. For all-NaN slices or slices with zero degrees of freedom, NaN is returned and a `RuntimeWarning` is raised. .. versionadded:: 1.8.0 Parameters ---------- a : array_like Calculate the standard deviation of the non-NaN values. axis : int, optional Axis along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array. dtype : dtype, optional Type to use in computing the standard deviation. For arrays of integer type the default is float64, for arrays of float types it is the same as the array type. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape as the expected output but the type (of the calculated values) will be cast if necessary. ddof : int, optional Means Delta Degrees of Freedom. The divisor used in calculations is ``N - ddof``, where ``N`` represents the number of non-NaN elements. By default `ddof` is zero. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original `a`. If this value is anything but the default it is passed through as-is to the relevant functions of the sub-classes. If these functions do not have a `keepdims` kwarg, a RuntimeError will be raised. Returns ------- standard_deviation : ndarray, see dtype parameter above. If `out` is None, return a new array containing the standard deviation, otherwise return a reference to the output array. If ddof is >= the number of non-NaN elements in a slice or the slice contains only NaNs, then the result for that slice is NaN. See Also -------- var, mean, std nanvar, nanmean numpy.doc.ufuncs : Section "Output arguments" Notes ----- The standard deviation is the square root of the average of the squared deviations from the mean: ``std = sqrt(mean(abs(x - x.mean())**2))``. The average squared deviation is normally calculated as ``x.sum() / N``, where ``N = len(x)``. If, however, `ddof` is specified, the divisor ``N - ddof`` is used instead. In standard statistical practice, ``ddof=1`` provides an unbiased estimator of the variance of the infinite population. ``ddof=0`` provides a maximum likelihood estimate of the variance for normally distributed variables. The standard deviation computed in this function is the square root of the estimated variance, so even with ``ddof=1``, it will not be an unbiased estimate of the standard deviation per se. Note that, for complex numbers, `std` takes the absolute value before squaring, so that the result is always real and nonnegative. For floating-point input, the *std* is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-accuracy accumulator using the `dtype` keyword can alleviate this issue. Examples -------- >>> a = np.array([[1, np.nan], [3, 4]]) >>> np.nanstd(a) 1.247219128924647 >>> np.nanstd(a, axis=0) array([ 1., 0.]) >>> np.nanstd(a, axis=1) array([ 0., 0.5]) """ var = nanvar(a, axis=axis, dtype=dtype, out=out, ddof=ddof, keepdims=keepdims) if isinstance(var, np.ndarray): std = np.sqrt(var, out=var) else: std = var.dtype.type(np.sqrt(var)) return std
apache-2.0
[ 624, 199, 13967, 626, 3686, 16046, 14, 199, 199, 13967, 199, 9960, 199, 199, 13, 658, 4304, 827, 64, 1553, 7481, 2222, 13, 14300, 574, 199, 13, 658, 4304, 988, 64, 1553, 5696, 2222, 13, 14300, 574, 199, 13, 658, 4304, 26488, 64, 1553, 1478, 402, 7481, 2222, 13, 14300, 574, 199, 13, 658, 4304, 16383, 64, 1553, 1478, 402, 5696, 2222, 13, 14300, 574, 199, 13, 658, 27605, 453, 64, 1553, 3089, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 8788, 64, 1553, 3336, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 23916, 64, 1553, 25814, 3089, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 67, 1220, 19402, 64, 1553, 25814, 3336, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 3670, 64, 1553, 4615, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 1391, 64, 1553, 11773, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 1516, 64, 1553, 4465, 18458, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 13106, 64, 1553, 17312, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 21188, 64, 1553, 1894, 273, 31537, 402, 2222, 13, 14300, 1338, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 773, 14, 1593, 63, 1095, 492, 485, 3297, 3683, 465, 485, 3297, 3683, 421, 199, 363, 452, 363, 275, 359, 272, 283, 27605, 453, 297, 283, 4304, 988, 297, 283, 4304, 827, 297, 283, 4304, 16383, 297, 283, 4304, 26488, 297, 283, 4304, 3670, 297, 272, 283, 4304, 13106, 297, 283, 4304, 21188, 297, 283, 4304, 1391, 297, 283, 4304, 1516, 297, 283, 4304, 8788, 297, 272, 283, 4304, 23916, 297, 283, 4304, 67, 1220, 19402, 7, 272, 1622, 421, 199, 318, 485, 1814, 63, 4304, 8, 65, 12, 1139, 304, 272, 408, 272, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 1852, 282, 1331, 402, 658, 65, 3559, 3350, 31930, 543, 272, 314, 658, 637, 64, 574, 12, 436, 372, 314, 1331, 10451, 543, 282, 5046, 3656, 272, 31318, 314, 9918, 2382, 31930, 4898, 3451, 14, 982, 658, 65, 64, 365, 440, 402, 272, 315, 7327, 730, 12, 886, 6548, 436, 372, 658, 65, 64, 10451, 543, 282, 3656, 402, 488, 14, 339, 3390, 626, 19945, 911, 1284, 1536, 465, 1625, 19945, 12, 1314, 365, 11012, 272, 367, 1808, 314, 754, 465, 314, 574, 402, 314, 734, 1423, 315, 2005, 272, 5331, 14, 339, 3897, 272, 4143, 272, 282, 520, 1625, 13, 2930, 267, 6924, 1625, 14, 272, 1139, 520, 2069, 267, 16046, 1338, 787, 663, 370, 1139, 2544, 9689, 314, 3439, 14, 339, 1803, 272, 5514, 272, 612, 520, 6800, 267, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 372, 282, 1331, 402, 658, 65, 64, 543, 314, 31930, 267, 8717, 701, 314, 5554, 574, 12, 4257, 372, 658, 65, 2313, 272, 3656, 26, 469, 2245, 12, 488, 93, 267, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 372, 282, 5046, 3656, 31318, 9918, 402, 267, 31930, 12, 4257, 372, 488, 14, 339, 408, 272, 365, 63, 1222, 275, 440, 1228, 8, 65, 12, 980, 14, 8237, 9, 272, 340, 365, 63, 1222, 26, 267, 282, 275, 980, 14, 1144, 8, 65, 9, 272, 340, 440, 11602, 8, 65, 14, 2271, 14, 466, 12, 980, 14, 262, 7327, 304, 267, 372, 282, 12, 488, 272, 340, 440, 365, 63, 1222, 26, 267, 327, 1929, 1331, 267, 282, 275, 980, 14, 1144, 8, 65, 12, 1007, 745, 29, 549, 9, 339, 3656, 275, 980, 14, 12936, 8, 65, 9, 272, 980, 14, 1574, 475, 8, 65, 12, 1139, 12, 2382, 29, 2629, 9, 272, 372, 282, 12, 3656, 421, 199, 318, 485, 1574, 475, 8, 65, 12, 1139, 12, 3656, 304, 272, 408, 272, 14402, 1338, 315, 658, 65, 64, 543, 16046, 2382, 658, 2629, 64, 365, 715, 14, 221, 961, 22754, 687, 272, 1331, 475, 315, 626, 652, 911, 7962, 543, 314, 1930, 2382, 658, 65, 64, 365, 282, 2680, 6917, 14, 339, 3897, 272, 4143, 272, 282, 520, 6800, 503, 2680, 6917, 267, 8725, 503, 2680, 6917, 2005, 402, 7447, 1338, 787, 370, 506, 8717, 267, 701, 1139, 14, 272, 1139, 520, 2680, 6917, 267, 1594, 1202, 282, 8343, 14, 272, 3656, 520, 6800, 12, 6917, 267, 9411, 1625, 14, 17685, 715, 314, 5226, 1819, 402, 658, 65, 64, 365, 267, 8717, 701, 658, 637, 2313, 699, 5659, 83, 14, 339, 1803, 272, 5514, 272, 522, 520, 6800, 12, 6917, 267, 8725, 543, 4008, 8717, 503, 6917, 658, 637, 2313, 339, 408, 272, 340, 1228, 8, 65, 12, 980, 14, 8237, 304, 267, 980, 14, 1574, 475, 8, 65, 12, 1139, 12, 2382, 29, 2629, 12, 22883, 534, 14242, 358, 272, 587, 26, 267, 282, 275, 282, 14, 2271, 14, 466, 8, 637, 9, 272, 372, 282, 421, 199, 318, 485, 16081, 63, 991, 63, 835, 8, 65, 12, 330, 12, 734, 29, 403, 304, 272, 408, 272, 8354, 282, 15, 66, 17289, 3866, 2058, 14, 982, 658, 65, 64, 365, 376, 1625, 314, 4629, 272, 365, 4224, 315, 4192, 14, 982, 658, 65, 64, 365, 282, 6917, 12, 2066, 2399, 730, 365, 17731, 315, 314, 272, 1072, 14, 982, 734, 365, 488, 12, 2066, 2066, 282, 365, 1202, 3140, 880, 626, 314, 272, 4629, 365, 315, 4192, 14, 3390, 626, 642, 365, 1454, 2797, 543, 658, 65, 64, 376, 315, 7327, 272, 730, 14, 339, 3897, 272, 4143, 272, 282, 520, 469, 8237, 12, 2680, 6917, 93, 267, 653, 940, 9043, 14, 13796, 370, 506, 402, 315, 7327, 730, 1325, 440, 7923, 14, 272, 330, 520, 469, 8237, 12, 2680, 6917, 93, 267, 25187, 12675, 14, 272, 734, 520, 6800, 12, 2716, 267, 17669, 323, 1072, 1625, 315, 1314, 370, 4192, 314, 754, 14, 221, 710, 849, 267, 365, 1124, 403, 1040, 27, 340, 2741, 12, 652, 1471, 1172, 314, 2011, 2215, 465, 314, 267, 1420, 1072, 12, 1325, 314, 730, 911, 506, 9106, 340, 5784, 14, 339, 1803, 272, 5514, 272, 2203, 520, 469, 8237, 12, 2680, 6917, 93, 267, 710, 372, 574 ]
[ 199, 13967, 626, 3686, 16046, 14, 199, 199, 13967, 199, 9960, 199, 199, 13, 658, 4304, 827, 64, 1553, 7481, 2222, 13, 14300, 574, 199, 13, 658, 4304, 988, 64, 1553, 5696, 2222, 13, 14300, 574, 199, 13, 658, 4304, 26488, 64, 1553, 1478, 402, 7481, 2222, 13, 14300, 574, 199, 13, 658, 4304, 16383, 64, 1553, 1478, 402, 5696, 2222, 13, 14300, 574, 199, 13, 658, 27605, 453, 64, 1553, 3089, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 8788, 64, 1553, 3336, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 23916, 64, 1553, 25814, 3089, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 67, 1220, 19402, 64, 1553, 25814, 3336, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 3670, 64, 1553, 4615, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 1391, 64, 1553, 11773, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 1516, 64, 1553, 4465, 18458, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 13106, 64, 1553, 17312, 402, 2222, 13, 14300, 1338, 199, 13, 658, 4304, 21188, 64, 1553, 1894, 273, 31537, 402, 2222, 13, 14300, 1338, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 773, 14, 1593, 63, 1095, 492, 485, 3297, 3683, 465, 485, 3297, 3683, 421, 199, 363, 452, 363, 275, 359, 272, 283, 27605, 453, 297, 283, 4304, 988, 297, 283, 4304, 827, 297, 283, 4304, 16383, 297, 283, 4304, 26488, 297, 283, 4304, 3670, 297, 272, 283, 4304, 13106, 297, 283, 4304, 21188, 297, 283, 4304, 1391, 297, 283, 4304, 1516, 297, 283, 4304, 8788, 297, 272, 283, 4304, 23916, 297, 283, 4304, 67, 1220, 19402, 7, 272, 1622, 421, 199, 318, 485, 1814, 63, 4304, 8, 65, 12, 1139, 304, 272, 408, 272, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 1852, 282, 1331, 402, 658, 65, 3559, 3350, 31930, 543, 272, 314, 658, 637, 64, 574, 12, 436, 372, 314, 1331, 10451, 543, 282, 5046, 3656, 272, 31318, 314, 9918, 2382, 31930, 4898, 3451, 14, 982, 658, 65, 64, 365, 440, 402, 272, 315, 7327, 730, 12, 886, 6548, 436, 372, 658, 65, 64, 10451, 543, 282, 3656, 402, 488, 14, 339, 3390, 626, 19945, 911, 1284, 1536, 465, 1625, 19945, 12, 1314, 365, 11012, 272, 367, 1808, 314, 754, 465, 314, 574, 402, 314, 734, 1423, 315, 2005, 272, 5331, 14, 339, 3897, 272, 4143, 272, 282, 520, 1625, 13, 2930, 267, 6924, 1625, 14, 272, 1139, 520, 2069, 267, 16046, 1338, 787, 663, 370, 1139, 2544, 9689, 314, 3439, 14, 339, 1803, 272, 5514, 272, 612, 520, 6800, 267, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 372, 282, 1331, 402, 658, 65, 64, 543, 314, 31930, 267, 8717, 701, 314, 5554, 574, 12, 4257, 372, 658, 65, 2313, 272, 3656, 26, 469, 2245, 12, 488, 93, 267, 982, 658, 65, 64, 365, 402, 315, 7327, 730, 12, 372, 282, 5046, 3656, 31318, 9918, 402, 267, 31930, 12, 4257, 372, 488, 14, 339, 408, 272, 365, 63, 1222, 275, 440, 1228, 8, 65, 12, 980, 14, 8237, 9, 272, 340, 365, 63, 1222, 26, 267, 282, 275, 980, 14, 1144, 8, 65, 9, 272, 340, 440, 11602, 8, 65, 14, 2271, 14, 466, 12, 980, 14, 262, 7327, 304, 267, 372, 282, 12, 488, 272, 340, 440, 365, 63, 1222, 26, 267, 327, 1929, 1331, 267, 282, 275, 980, 14, 1144, 8, 65, 12, 1007, 745, 29, 549, 9, 339, 3656, 275, 980, 14, 12936, 8, 65, 9, 272, 980, 14, 1574, 475, 8, 65, 12, 1139, 12, 2382, 29, 2629, 9, 272, 372, 282, 12, 3656, 421, 199, 318, 485, 1574, 475, 8, 65, 12, 1139, 12, 3656, 304, 272, 408, 272, 14402, 1338, 315, 658, 65, 64, 543, 16046, 2382, 658, 2629, 64, 365, 715, 14, 221, 961, 22754, 687, 272, 1331, 475, 315, 626, 652, 911, 7962, 543, 314, 1930, 2382, 658, 65, 64, 365, 282, 2680, 6917, 14, 339, 3897, 272, 4143, 272, 282, 520, 6800, 503, 2680, 6917, 267, 8725, 503, 2680, 6917, 2005, 402, 7447, 1338, 787, 370, 506, 8717, 267, 701, 1139, 14, 272, 1139, 520, 2680, 6917, 267, 1594, 1202, 282, 8343, 14, 272, 3656, 520, 6800, 12, 6917, 267, 9411, 1625, 14, 17685, 715, 314, 5226, 1819, 402, 658, 65, 64, 365, 267, 8717, 701, 658, 637, 2313, 699, 5659, 83, 14, 339, 1803, 272, 5514, 272, 522, 520, 6800, 12, 6917, 267, 8725, 543, 4008, 8717, 503, 6917, 658, 637, 2313, 339, 408, 272, 340, 1228, 8, 65, 12, 980, 14, 8237, 304, 267, 980, 14, 1574, 475, 8, 65, 12, 1139, 12, 2382, 29, 2629, 12, 22883, 534, 14242, 358, 272, 587, 26, 267, 282, 275, 282, 14, 2271, 14, 466, 8, 637, 9, 272, 372, 282, 421, 199, 318, 485, 16081, 63, 991, 63, 835, 8, 65, 12, 330, 12, 734, 29, 403, 304, 272, 408, 272, 8354, 282, 15, 66, 17289, 3866, 2058, 14, 982, 658, 65, 64, 365, 376, 1625, 314, 4629, 272, 365, 4224, 315, 4192, 14, 982, 658, 65, 64, 365, 282, 6917, 12, 2066, 2399, 730, 365, 17731, 315, 314, 272, 1072, 14, 982, 734, 365, 488, 12, 2066, 2066, 282, 365, 1202, 3140, 880, 626, 314, 272, 4629, 365, 315, 4192, 14, 3390, 626, 642, 365, 1454, 2797, 543, 658, 65, 64, 376, 315, 7327, 272, 730, 14, 339, 3897, 272, 4143, 272, 282, 520, 469, 8237, 12, 2680, 6917, 93, 267, 653, 940, 9043, 14, 13796, 370, 506, 402, 315, 7327, 730, 1325, 440, 7923, 14, 272, 330, 520, 469, 8237, 12, 2680, 6917, 93, 267, 25187, 12675, 14, 272, 734, 520, 6800, 12, 2716, 267, 17669, 323, 1072, 1625, 315, 1314, 370, 4192, 314, 754, 14, 221, 710, 849, 267, 365, 1124, 403, 1040, 27, 340, 2741, 12, 652, 1471, 1172, 314, 2011, 2215, 465, 314, 267, 1420, 1072, 12, 1325, 314, 730, 911, 506, 9106, 340, 5784, 14, 339, 1803, 272, 5514, 272, 2203, 520, 469, 8237, 12, 2680, 6917, 93, 267, 710, 372, 574, 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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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 ]
radicalbit/ambari
ambari-server/src/main/python/ambari_server/dbConfiguration.py
1
22431
#!/usr/bin/env python ''' Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' import glob import os import shutil from ambari_commons import OSConst, OSCheck from ambari_commons.exceptions import FatalException from ambari_commons.logging_utils import get_silent, print_error_msg, print_info_msg, print_warning_msg, set_silent from ambari_commons.os_family_impl import OsFamilyImpl from ambari_commons.str_utils import cbool from ambari_server.serverClassPath import JDBC_DRIVER_PATH_PROPERTY from ambari_server.serverConfiguration import decrypt_password_for_alias, get_ambari_properties, get_is_secure, \ get_resources_location, get_value_from_properties, is_alias_string, \ JDBC_PASSWORD_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, PRESS_ENTER_MSG, DEFAULT_DBMS_PROPERTY, JDBC_DATABASE_PROPERTY, \ PERSISTENCE_TYPE_PROPERTY, update_properties, configDefaults from ambari_server.userInput import get_YN_input, get_validated_string_input #Database settings DB_STATUS_RUNNING_DEFAULT = "running" SETUP_DB_CONNECT_TIMEOUT = 5 SETUP_DB_CONNECT_ATTEMPTS = 3 USERNAME_PATTERN = "^[a-zA-Z_][a-zA-Z0-9_\-]*$" PASSWORD_PATTERN = "^[a-zA-Z0-9_-]*$" CUSTOM_JDBC_DB_NAMES = ["postgres", "mysql", "mssql", "oracle", "hsqldb", "sqlanywhere", "bdb"] DATABASE_NAMES = ["postgres", "oracle", "mysql", "mssql", "sqlanywhere", "bdb"] DATABASE_FULL_NAMES = {"oracle": "Oracle", "mysql": "MySQL", "mssql": "Microsoft SQL Server", "postgres": "PostgreSQL", "sqlanywhere": "SQL Anywhere", "bdb" : "Berkeley DB"} LINUX_DBMS_KEYS_LIST = [ 'embedded', 'oracle', 'mysql', 'postgres', 'mssql', 'sqlanywhere', 'bdb'] AMBARI_DATABASE_NAME = "ambari" AMBARI_DATABASE_TITLE = "ambari" TAR_GZ_ARCHIVE_TYPE = ".tar.gz" default_connectors_map = { "mssql":"sqljdbc4.jar", "mysql":"mysql-connector-java.jar", "postgres":"postgresql-jdbc.jar", "oracle":"ojdbc.jar", "sqlanywhere":"sajdbc4.jar", "hsqldb":"hsqldb.jar", "bdb": 'je-5.0.73.jar'} STORAGE_TYPE_LOCAL = 'local' STORAGE_TYPE_REMOTE = 'remote' DEFAULT_USERNAME = "ambari" DEFAULT_PASSWORD = "bigdata" # # Database configuration helper classes # class DBMSDesc: def __init__(self, i_dbms_key, i_storage_key, i_dbms_name, i_storage_name, i_fn_create_config): self.dbms_key = i_dbms_key self.storage_key = i_storage_key self.dbms_name = i_dbms_name self.storage_name = i_storage_name self.fn_create_config = i_fn_create_config def create_config(self, options, properties, dbId): return self.fn_create_config(options, properties, self.storage_key, dbId) class DbPropKeys: def __init__(self, i_dbms_key, i_driver_key, i_server_key, i_port_key, i_db_name_key, i_db_url_key): self.dbms_key = i_dbms_key self.driver_key = i_driver_key self.server_key = i_server_key self.port_key = i_port_key self.db_name_key = i_db_name_key self.db_url_key = i_db_url_key class DbAuthenticationKeys: def __init__(self, i_user_name_key, i_password_key, i_password_alias, i_password_filename): self.user_name_key = i_user_name_key self.password_key = i_password_key self.password_alias = i_password_alias self.password_filename = i_password_filename # # Database configuration base class # class DBMSConfig(object): def __init__(self, options, properties, storage_type): """ #Just load the defaults. The derived classes will be able to modify them later """ self.persistence_type = storage_type self.dbms = "" self.driver_class_name = "" self.driver_file_name = "" self.driver_symlink_name = "" self.database_host = "" self.database_port = "" self.database_name = "" self.database_username = "" self.db_title = AMBARI_DATABASE_TITLE self.must_set_database_options = DBMSConfig._init_member_with_default(options, "must_set_database_options", False) self.JDBC_DRIVER_INSTALL_MSG = 'Before starting Ambari Server, you must install the JDBC driver.' self.isSecure = get_is_secure(properties) pass # # Public methods # # # Main method. Configures the database according to the options and the existing properties. # def configure_database(self, properties, options): result = self._prompt_db_properties() if result: #DB setup should be done last after doing any setup. if self._is_local_database(): self._setup_local_server(properties, options) # this issue appears only for Suse. Postgres need /var/run/postgresql dir but do not create it if OSCheck.is_suse_family(): self._create_postgres_lock_directory() else: self._setup_remote_server(properties, options) return result def setup_database(self): print 'Configuring {0} database...'.format(self.db_title) #DB setup should be done last after doing any setup. if self._is_local_database(): self._setup_local_database() else: self._setup_remote_database() pass def reset_database(self): if self._is_local_database(): self._reset_local_database() else: self._reset_remote_database() pass def ensure_jdbc_driver_installed(self, properties): server_jdbc_path = properties.get_property(JDBC_DRIVER_PATH_PROPERTY) if server_jdbc_path and os.path.isfile(server_jdbc_path): return True default_driver_path = self._get_default_driver_path(properties) if default_driver_path and os.path.isfile(default_driver_path): ambari_should_use_existing_default_jdbc = get_YN_input("Should ambari use existing default jdbc {0} [y/n] (y)? ".format(default_driver_path), True) if ambari_should_use_existing_default_jdbc: properties.process_pair(JDBC_DRIVER_PATH_PROPERTY, default_driver_path) update_properties(properties) return True path_to_custom_jdbc_driver = get_validated_string_input("Enter full path to custom jdbc driver: ", None, None, None, False, False) if path_to_custom_jdbc_driver and os.path.isfile(path_to_custom_jdbc_driver): try: custom_jdbc_name = os.path.basename(path_to_custom_jdbc_driver) if not path_to_custom_jdbc_driver == os.path.join(configDefaults.JAVA_SHARE_PATH, custom_jdbc_name): if os.path.isfile(os.path.join(configDefaults.JAVA_SHARE_PATH, custom_jdbc_name)): replace_jdbc_in_share_dir = get_YN_input("You already have file {0} in /usr/share/java/. Should it be replaced? [y/n] (y)? ".format(custom_jdbc_name), True) if replace_jdbc_in_share_dir: try: os.remove(os.path.join(configDefaults.JAVA_SHARE_PATH, custom_jdbc_name)) except Exception, ee: err = 'ERROR: Could not remove jdbc file. %s' % os.path.join(configDefaults.JAVA_SHARE_PATH, custom_jdbc_name) raise FatalException(1, err) shutil.copy(path_to_custom_jdbc_driver, configDefaults.JAVA_SHARE_PATH) print "Copying {0} to {1}".format(path_to_custom_jdbc_driver, configDefaults.JAVA_SHARE_PATH) except Exception, e: err = "Can not copy file {0} to {1} due to: {2} . Please check file " \ "permissions and free disk space.".format(path_to_custom_jdbc_driver, configDefaults.JAVA_SHARE_PATH, str(e)) raise FatalException(1, err) properties.process_pair(JDBC_DRIVER_PATH_PROPERTY, path_to_custom_jdbc_driver) update_properties(properties) return True else: print_error_msg("Custom jdbc connector path is unavailable. Please put correct path to jdbc connector.") return False def change_db_files_owner(self): if self._is_local_database(): retcode = self._change_db_files_owner() if not retcode == 0: raise FatalException(20, 'Unable to change owner of database objects') # # Private implementation # @staticmethod def _read_password_from_properties(properties, options): database_password = DEFAULT_PASSWORD password_file = get_value_from_properties(properties, JDBC_PASSWORD_PROPERTY, "") if password_file: if is_alias_string(password_file): database_password = decrypt_password_for_alias(properties, JDBC_RCA_PASSWORD_ALIAS, options) else: if os.path.isabs(password_file) and os.path.exists(password_file): with open(password_file, 'r') as file: database_password = file.read() return database_password @staticmethod def _init_member_with_default(options, attr_name, default_val): options_val = getattr(options, attr_name, None) val = options_val if options_val is not None and options_val is not "" else default_val return val @staticmethod def _init_member_with_properties(options, attr_name, properties, property_key): options_val = getattr(options, attr_name, None) if options_val is None or options_val is "": options_val = get_value_from_properties(properties, property_key, None) return options_val @staticmethod def _init_member_with_prop_default(options, attr_name, properties, property_key, default_val): val = DBMSConfig._init_member_with_properties(options, attr_name, properties, property_key) if val is None or val is "": val = default_val return val # # Checks if options determine local DB configuration # def _is_local_database(self): return self.persistence_type == STORAGE_TYPE_LOCAL def _prompt_db_properties(self): #if WINDOWS # prompt for SQL Server host and instance name #else # go the classic Linux way #linux_prompt_db_properties(args) return False def _create_postgres_lock_directory(self): pass def _setup_local_server(self, properties, options): pass def _setup_local_database(self): pass def _reset_local_database(self): pass def _setup_remote_server(self, properties, options): pass def _setup_remote_database(self): pass def _reset_remote_database(self): pass def _prompt_jdbc_driver_install(self, properties): result = self._is_jdbc_driver_installed(properties) if result == -1: if get_silent(): print_error_msg(self.JDBC_DRIVER_INSTALL_MSG) else: print_warning_msg(self.JDBC_DRIVER_INSTALL_MSG) raw_input(PRESS_ENTER_MSG) result = self._is_jdbc_driver_installed(properties) return (result, self.JDBC_DRIVER_INSTALL_MSG) def _is_jdbc_driver_installed(self, properties): return 1 def _install_jdbc_driver(self, properties, files_list): return False def ensure_dbms_is_running(self, options, properties, scmStatus=None): pass def _change_db_files_owner(self, args): return 0 # # Database configuration factory base class # class DBMSConfigFactory(object): def select_dbms(self, options): ''' # Base declaration of the DBMS selection method. :return: DBMS index in the descriptor table ''' pass def create(self, options, properties, dbId = "Ambari"): """ # Base declaration of the factory method. The outcome of the derived implementations # is expected to be a subclass of DBMSConfig. # properties = property bag that will ultimately define the type of database. Since # right now in Windows we only support SQL Server, this argument is not yet used. # dbId = additional information, that helps distinguish between various database connections, if applicable """ pass def get_supported_dbms(self): return [] def get_supported_jdbc_drivers(self): return [] def force_dbms_setup(self): return False def get_default_dbms_name(self): return "" # # Database configuration factory for Windows # @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) class DBMSConfigFactoryWindows(DBMSConfigFactory): def __init__(self): from ambari_server.dbConfiguration_windows import DATABASE_DBMS_MSSQL self.DBMS_KEYS_LIST = [ DATABASE_DBMS_MSSQL ] def select_dbms(self, options): # For now, we only support SQL Server in Windows, in remote mode. return 0 def create(self, options, properties, dbId = "Ambari"): """ # Windows implementation of the factory method. The outcome of the derived implementations # is expected to be a subclass of DBMSConfig. # properties = property bag that will ultimately define the type of database. Since # right now in Windows we only support SQL Server, this argument is not yet used. # dbId = additional information, that helps distinguish between various database connections, if applicable """ from ambari_server.dbConfiguration_windows import createMSSQLConfig return createMSSQLConfig(options, properties, STORAGE_TYPE_REMOTE, dbId) def get_supported_dbms(self): return self.DBMS_KEYS_LIST def get_supported_jdbc_drivers(self): return self.DBMS_KEYS_LIST # # Database configuration factory for Linux # @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT) class DBMSConfigFactoryLinux(DBMSConfigFactory): def __init__(self): from ambari_server.dbConfiguration_linux import createPGConfig, createOracleConfig, createMySQLConfig, \ createMSSQLConfig, createSQLAConfig, createBDBConfig self.DBMS_KEYS_LIST = LINUX_DBMS_KEYS_LIST self.DRIVER_KEYS_LIST = [ 'oracle', 'mysql', 'postgres', 'mssql', 'hsqldb', 'sqlanywhere', 'bdb' ] self.DBMS_LIST = [ DBMSDesc(self.DBMS_KEYS_LIST[3], STORAGE_TYPE_LOCAL, 'PostgreSQL', 'Embedded', createPGConfig), DBMSDesc(self.DBMS_KEYS_LIST[1], STORAGE_TYPE_REMOTE, 'Oracle', '', createOracleConfig), DBMSDesc(self.DBMS_KEYS_LIST[2], STORAGE_TYPE_REMOTE, 'MySQL / MariaDB', '', createMySQLConfig), DBMSDesc(self.DBMS_KEYS_LIST[3], STORAGE_TYPE_REMOTE, 'PostgreSQL', '', createPGConfig), DBMSDesc(self.DBMS_KEYS_LIST[4], STORAGE_TYPE_REMOTE, 'Microsoft SQL Server', 'Tech Preview', createMSSQLConfig), DBMSDesc(self.DBMS_KEYS_LIST[5], STORAGE_TYPE_REMOTE, 'SQL Anywhere', '', createSQLAConfig), DBMSDesc(self.DBMS_KEYS_LIST[6], STORAGE_TYPE_REMOTE, 'BDB', '', createBDBConfig) ] self.DBMS_DICT = \ { '-': 0, '-' + STORAGE_TYPE_LOCAL: 0, self.DBMS_KEYS_LIST[0] + '-': 0, self.DBMS_KEYS_LIST[2] + '-': 2, self.DBMS_KEYS_LIST[2] + '-' + STORAGE_TYPE_REMOTE: 2, self.DBMS_KEYS_LIST[4] + '-': 4, self.DBMS_KEYS_LIST[4] + '-' + STORAGE_TYPE_REMOTE: 4, self.DBMS_KEYS_LIST[1] + '-': 1, self.DBMS_KEYS_LIST[1] + '-' + STORAGE_TYPE_REMOTE: 1, self.DBMS_KEYS_LIST[3] + '-': 3, self.DBMS_KEYS_LIST[3] + '-' + STORAGE_TYPE_LOCAL: 0, self.DBMS_KEYS_LIST[3] + '-' + STORAGE_TYPE_REMOTE: 3, self.DBMS_KEYS_LIST[5] + '-': 5, self.DBMS_KEYS_LIST[5] + '-' + STORAGE_TYPE_REMOTE: 5, self.DBMS_KEYS_LIST[6] + '-': 6, self.DBMS_KEYS_LIST[6] + '-' + STORAGE_TYPE_LOCAL: 6, } self.DBMS_PROMPT_PATTERN = "[{0}] - {1}{2}\n" self.DBMS_CHOICE_PROMPT_PATTERN = "==============================================================================\n" \ "Enter choice ({0}): " self.JDK_VALID_CHOICES_PATTERN = "^[{0}]$" def force_dbms_setup(self): dbms_name = self.get_default_dbms_name() if dbms_name.strip(): return True else: return False def select_dbms(self, options): try: dbms_index = options.database_index except AttributeError: db_name = get_value_from_properties(get_ambari_properties(), JDBC_DATABASE_PROPERTY, "").strip().lower() persistence_type = get_value_from_properties(get_ambari_properties(), PERSISTENCE_TYPE_PROPERTY, "").strip().lower() if persistence_type == STORAGE_TYPE_LOCAL: dbms_index = self.DBMS_KEYS_LIST.index("embedded") elif db_name: dbms_index = self.DBMS_KEYS_LIST.index(db_name) else: dbms_index = self._get_default_dbms_index(options) if options.must_set_database_options: n_dbms = 1 dbms_choice_prompt = "==============================================================================\n" \ "Choose one of the following options:\n" dbms_choices = '' for desc in self.DBMS_LIST: if len(desc.storage_name) > 0: dbms_storage = " ({0})".format(desc.storage_name) else: dbms_storage = "" dbms_choice_prompt += self.DBMS_PROMPT_PATTERN.format(n_dbms, desc.dbms_name, dbms_storage) dbms_choices += str(n_dbms) n_dbms += 1 database_num = str(dbms_index + 1) dbms_choice_prompt += self.DBMS_CHOICE_PROMPT_PATTERN.format(database_num) dbms_valid_choices = self.JDK_VALID_CHOICES_PATTERN.format(dbms_choices) database_num = get_validated_string_input( dbms_choice_prompt, database_num, dbms_valid_choices, "Invalid number.", False ) dbms_index = int(database_num) - 1 if dbms_index >= n_dbms: print_info_msg('Unknown db option, default to {0} {1}.'.format( self.DBMS_LIST[0].storage_name, self.DBMS_LIST[0].dbms_name)) dbms_index = 0 return dbms_index def create(self, options, properties, dbId = "Ambari"): """ # Linux implementation of the factory method. The outcome of the derived implementations # is expected to be a subclass of DBMSConfig. # properties = property bag that will ultimately define the type of database. Supported types are # MySQL, MSSQL, Oracle and PostgreSQL. # dbId = additional information, that helps distinguish between various database connections, if applicable """ try: index = options.database_index except AttributeError: index = options.database_index = self._get_default_dbms_index(options) desc = self.DBMS_LIST[index] options.persistence_type = desc.storage_key dbmsConfig = desc.create_config(options, properties, dbId) return dbmsConfig def get_supported_dbms(self): return self.DBMS_KEYS_LIST def get_supported_jdbc_drivers(self): return self.DRIVER_KEYS_LIST def get_default_dbms_name(self): properties = get_ambari_properties() default_dbms_name = get_value_from_properties(properties, DEFAULT_DBMS_PROPERTY, "").strip().lower() if default_dbms_name not in self.DBMS_KEYS_LIST: return "" else: return default_dbms_name def _get_default_dbms_index(self, options): default_dbms_name = self.get_default_dbms_name() try: dbms_name = options.dbms if not dbms_name: dbms_name = default_dbms_name except AttributeError: dbms_name = default_dbms_name try: persistence_type = options.persistence_type if not persistence_type: persistence_type = "" except AttributeError: persistence_type = "" try: def_index = self.DBMS_DICT[dbms_name + "-" + persistence_type] except KeyError: # Unsupported database type (e.g. local Oracle, MySQL or MSSQL) raise FatalException(15, "Invalid database selection: {0} {1}".format( getattr(options, "persistence_type", ""), getattr(options, "dbms", ""))) return def_index def check_jdbc_drivers(args): # create jdbc symlinks if jdbc drivers are available in resources properties = get_ambari_properties() if properties == -1: err = "Error getting ambari properties" print_error_msg(err) raise FatalException(-1, err) resources_dir = get_resources_location(properties) try: db_idx_orig = args.database_index except AttributeError: db_idx_orig = None factory = DBMSConfigFactory() # AMBARI-5696 Validate the symlinks for each supported driver, in case various back-end HDP services happen to # use different DBMSes # This is skipped on Windows db_idx = 1 try: while db_idx < len(factory.get_supported_dbms()): args.database_index = db_idx dbms = factory.create(args, properties) if dbms.driver_symlink_name: jdbc_file_path = os.path.join(resources_dir, dbms.driver_file_name) if os.path.isfile(jdbc_file_path): jdbc_symlink = os.path.join(resources_dir, dbms.driver_symlink_name) if os.path.lexists(jdbc_symlink): os.remove(jdbc_symlink) os.symlink(jdbc_file_path, jdbc_symlink) db_idx += 1 finally: args.database_index = db_idx_orig #Check the JDBC driver status #If not found abort #Get SQL Server service status from SCM #If 'stopped' then start it #Wait until the status is 'started' or a configured timeout elapses #If the timeout has been reached, bail out with exception def ensure_dbms_is_running(options, properties, scmStatus=None): factory = DBMSConfigFactory() dbms = factory.create(options, properties) result = dbms._is_jdbc_driver_installed(properties) if result == -1: raise FatalException(-1, "JDBC driver is not installed. Run ambari-server setup and try again.") dbms.ensure_dbms_is_running(options, properties, scmStatus) def ensure_jdbc_driver_is_installed(options, properties): factory = DBMSConfigFactory() dbms = factory.create(options, properties) result = dbms._is_jdbc_driver_installed(properties) if result == -1: raise FatalException(-1, dbms.JDBC_DRIVER_INSTALL_MSG) dbms._extract_client_tarball(properties) def get_native_libs_path(options, properties): factory = DBMSConfigFactory() dbms = factory.create(options, properties) return dbms._get_native_libs(properties) def get_jdbc_driver_path(options, properties): factory = DBMSConfigFactory() dbms = factory.create(options, properties) return dbms._get_default_driver_path(properties)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 646, 5739, 199, 646, 747, 199, 646, 5145, 199, 199, 504, 16353, 759, 63, 2330, 83, 492, 4403, 6361, 12, 4403, 1799, 199, 504, 16353, 759, 63, 2330, 83, 14, 3924, 492, 481, 7539, 1726, 199, 504, 16353, 759, 63, 2330, 83, 14, 4806, 63, 1208, 492, 664, 63, 14434, 12, 870, 63, 705, 63, 1328, 12, 870, 63, 815, 63, 1328, 12, 870, 63, 3764, 63, 1328, 12, 663, 63, 14434, 199, 504, 16353, 759, 63, 2330, 83, 14, 736, 63, 6606, 63, 5472, 492, 593, 83, 16345, 4748, 199, 504, 16353, 759, 63, 2330, 83, 14, 495, 63, 1208, 492, 286, 2245, 199, 504, 16353, 759, 63, 1000, 14, 1000, 2543, 2042, 492, 1603, 23317, 63, 23401, 63, 3243, 63, 25091, 199, 504, 16353, 759, 63, 1000, 14, 1000, 5688, 492, 20090, 63, 2060, 63, 509, 63, 3620, 12, 664, 63, 11020, 759, 63, 3282, 12, 664, 63, 374, 63, 7817, 12, 971, 523, 664, 63, 4435, 63, 1985, 12, 664, 63, 585, 63, 504, 63, 3282, 12, 365, 63, 3620, 63, 875, 12, 971, 523, 1603, 23317, 63, 9032, 63, 25091, 12, 1603, 23317, 63, 50, 3263, 63, 9032, 63, 12644, 12, 12218, 1608, 63, 12533, 63, 9740, 12, 6186, 63, 2846, 3053, 63, 25091, 12, 1603, 23317, 63, 17873, 63, 25091, 12, 971, 523, 13873, 29367, 6013, 63, 2711, 63, 25091, 12, 1678, 63, 3282, 12, 1101, 16986, 199, 504, 16353, 759, 63, 1000, 14, 751, 3205, 492, 664, 63, 30644, 63, 1210, 12, 664, 63, 24372, 63, 875, 63, 1210, 421, 199, 3, 7243, 2202, 199, 2846, 63, 6305, 63, 17305, 63, 3472, 275, 298, 5720, 2, 199, 199, 20836, 63, 2846, 63, 14657, 63, 8899, 275, 959, 199, 20836, 63, 2846, 63, 14657, 63, 619, 12510, 9730, 275, 650, 199, 199, 11958, 63, 10764, 275, 18129, 59, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 63, 16185, 3672, 17351, 199, 9032, 63, 10764, 275, 18129, 59, 65, 13, 6353, 13, 58, 16, 13, 25, 32069, 3672, 17351, 199, 20519, 63, 42, 23317, 63, 2846, 63, 14546, 275, 2097, 10675, 401, 298, 8644, 401, 298, 30230, 401, 298, 16404, 401, 298, 72, 3009, 697, 401, 298, 3526, 1502, 89, 4509, 401, 298, 27178, 937, 199, 17873, 63, 14546, 275, 2097, 10675, 401, 298, 16404, 401, 298, 8644, 401, 298, 30230, 401, 298, 3526, 1502, 89, 4509, 401, 298, 27178, 937, 199, 17873, 63, 14742, 63, 14546, 275, 2420, 16404, 582, 298, 21202, 401, 298, 8644, 582, 298, 20784, 401, 298, 30230, 582, 298, 12940, 5385, 7146, 401, 298, 10675, 582, 523, 298, 31433, 401, 298, 3526, 1502, 89, 4509, 582, 298, 4657, 6184, 4509, 401, 298, 27178, 2, 520, 298, 24947, 415, 15515, 6249, 3570, 199, 26030, 63, 2846, 3053, 63, 17434, 63, 4924, 275, 359, 283, 18757, 297, 283, 16404, 297, 283, 8644, 297, 283, 10675, 297, 283, 30230, 297, 283, 3526, 1502, 89, 4509, 297, 283, 27178, 418, 199, 1156, 13895, 41, 63, 17873, 63, 2339, 275, 298, 11020, 759, 2, 199, 1156, 13895, 41, 63, 17873, 63, 19091, 275, 298, 11020, 759, 2, 199, 199, 52, 689, 63, 29847, 63, 28800, 63, 2711, 275, 3680, 5369, 14, 6838, 2, 199, 199, 885, 63, 2242, 1384, 63, 1130, 275, 469, 298, 30230, 5122, 3009, 29791, 20, 14, 7338, 401, 2574, 298, 8644, 5122, 8644, 13, 11815, 13, 6138, 14, 7338, 401, 2574, 298, 10675, 5122, 15437, 13, 29791, 14, 7338, 401, 2574, 298, 16404, 5122, 79, 29791, 14, 7338, 401, 2574, 298, 3526, 1502, 89, 4509, 5122, 2231, 29791, 20, 14, 7338, 401, 2574, 298, 72, 3009, 697, 5122, 72, 3009, 697, 14, 7338, 401, 2574, 298, 27178, 582, 283, 6532, 13, 21, 14, 16, 14, 2898, 14, 7338, 936, 199, 199, 17467, 63, 2711, 63, 7486, 275, 283, 1832, 7, 199, 17467, 63, 2711, 63, 16058, 275, 283, 3846, 7, 199, 199, 3472, 63, 11958, 275, 298, 11020, 759, 2, 199, 3472, 63, 9032, 275, 298, 5076, 576, 2, 199, 199, 3, 199, 3, 8692, 2897, 5922, 3992, 199, 3, 199, 533, 6249, 3053, 9921, 26, 523, 347, 636, 826, 721, 277, 12, 284, 63, 697, 706, 63, 498, 12, 284, 63, 3494, 63, 498, 12, 284, 63, 697, 706, 63, 354, 12, 284, 63, 3494, 63, 354, 12, 284, 63, 2324, 63, 981, 63, 888, 304, 272, 291, 14, 697, 706, 63, 498, 275, 284, 63, 697, 706, 63, 498, 272, 291, 14, 3494, 63, 498, 275, 284, 63, 3494, 63, 498, 272, 291, 14, 697, 706, 63, 354, 275, 284, 63, 697, 706, 63, 354, 272, 291, 14, 3494, 63, 354, 275, 284, 63, 3494, 63, 354, 272, 291, 14, 2324, 63, 981, 63, 888, 275, 284, 63, 2324, 63, 981, 63, 888, 819, 347, 1218, 63, 888, 8, 277, 12, 1511, 12, 4382, 12, 1592, 1304, 304, 272, 372, 291, 14, 2324, 63, 981, 63, 888, 8, 1419, 12, 4382, 12, 291, 14, 3494, 63, 498, 12, 1592, 1304, 9, 199, 199, 533, 28822, 9955, 6340, 26, 523, 347, 636, 826, 721, 277, 12, 284, 63, 697, 706, 63, 498 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 31661, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 269, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 16832, 543, 642, 1736, 367, 4722, 2556, 199, 1135, 1005, 316, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 475, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 2, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 1045, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 2344, 199, 646, 5739, 199, 646, 747, 199, 646, 5145, 199, 199, 504, 16353, 759, 63, 2330, 83, 492, 4403, 6361, 12, 4403, 1799, 199, 504, 16353, 759, 63, 2330, 83, 14, 3924, 492, 481, 7539, 1726, 199, 504, 16353, 759, 63, 2330, 83, 14, 4806, 63, 1208, 492, 664, 63, 14434, 12, 870, 63, 705, 63, 1328, 12, 870, 63, 815, 63, 1328, 12, 870, 63, 3764, 63, 1328, 12, 663, 63, 14434, 199, 504, 16353, 759, 63, 2330, 83, 14, 736, 63, 6606, 63, 5472, 492, 593, 83, 16345, 4748, 199, 504, 16353, 759, 63, 2330, 83, 14, 495, 63, 1208, 492, 286, 2245, 199, 504, 16353, 759, 63, 1000, 14, 1000, 2543, 2042, 492, 1603, 23317, 63, 23401, 63, 3243, 63, 25091, 199, 504, 16353, 759, 63, 1000, 14, 1000, 5688, 492, 20090, 63, 2060, 63, 509, 63, 3620, 12, 664, 63, 11020, 759, 63, 3282, 12, 664, 63, 374, 63, 7817, 12, 971, 523, 664, 63, 4435, 63, 1985, 12, 664, 63, 585, 63, 504, 63, 3282, 12, 365, 63, 3620, 63, 875, 12, 971, 523, 1603, 23317, 63, 9032, 63, 25091, 12, 1603, 23317, 63, 50, 3263, 63, 9032, 63, 12644, 12, 12218, 1608, 63, 12533, 63, 9740, 12, 6186, 63, 2846, 3053, 63, 25091, 12, 1603, 23317, 63, 17873, 63, 25091, 12, 971, 523, 13873, 29367, 6013, 63, 2711, 63, 25091, 12, 1678, 63, 3282, 12, 1101, 16986, 199, 504, 16353, 759, 63, 1000, 14, 751, 3205, 492, 664, 63, 30644, 63, 1210, 12, 664, 63, 24372, 63, 875, 63, 1210, 421, 199, 3, 7243, 2202, 199, 2846, 63, 6305, 63, 17305, 63, 3472, 275, 298, 5720, 2, 199, 199, 20836, 63, 2846, 63, 14657, 63, 8899, 275, 959, 199, 20836, 63, 2846, 63, 14657, 63, 619, 12510, 9730, 275, 650, 199, 199, 11958, 63, 10764, 275, 18129, 59, 65, 13, 6353, 13, 58, 17900, 65, 13, 6353, 13, 58, 16, 13, 25, 63, 16185, 3672, 17351, 199, 9032, 63, 10764, 275, 18129, 59, 65, 13, 6353, 13, 58, 16, 13, 25, 32069, 3672, 17351, 199, 20519, 63, 42, 23317, 63, 2846, 63, 14546, 275, 2097, 10675, 401, 298, 8644, 401, 298, 30230, 401, 298, 16404, 401, 298, 72, 3009, 697, 401, 298, 3526, 1502, 89, 4509, 401, 298, 27178, 937, 199, 17873, 63, 14546, 275, 2097, 10675, 401, 298, 16404, 401, 298, 8644, 401, 298, 30230, 401, 298, 3526, 1502, 89, 4509, 401, 298, 27178, 937, 199, 17873, 63, 14742, 63, 14546, 275, 2420, 16404, 582, 298, 21202, 401, 298, 8644, 582, 298, 20784, 401, 298, 30230, 582, 298, 12940, 5385, 7146, 401, 298, 10675, 582, 523, 298, 31433, 401, 298, 3526, 1502, 89, 4509, 582, 298, 4657, 6184, 4509, 401, 298, 27178, 2, 520, 298, 24947, 415, 15515, 6249, 3570, 199, 26030, 63, 2846, 3053, 63, 17434, 63, 4924, 275, 359, 283, 18757, 297, 283, 16404, 297, 283, 8644, 297, 283, 10675, 297, 283, 30230, 297, 283, 3526, 1502, 89, 4509, 297, 283, 27178, 418, 199, 1156, 13895, 41, 63, 17873, 63, 2339, 275, 298, 11020, 759, 2, 199, 1156, 13895, 41, 63, 17873, 63, 19091, 275, 298, 11020, 759, 2, 199, 199, 52, 689, 63, 29847, 63, 28800, 63, 2711, 275, 3680, 5369, 14, 6838, 2, 199, 199, 885, 63, 2242, 1384, 63, 1130, 275, 469, 298, 30230, 5122, 3009, 29791, 20, 14, 7338, 401, 2574, 298, 8644, 5122, 8644, 13, 11815, 13, 6138, 14, 7338, 401, 2574, 298, 10675, 5122, 15437, 13, 29791, 14, 7338, 401, 2574, 298, 16404, 5122, 79, 29791, 14, 7338, 401, 2574, 298, 3526, 1502, 89, 4509, 5122, 2231, 29791, 20, 14, 7338, 401, 2574, 298, 72, 3009, 697, 5122, 72, 3009, 697, 14, 7338, 401, 2574, 298, 27178, 582, 283, 6532, 13, 21, 14, 16, 14, 2898, 14, 7338, 936, 199, 199, 17467, 63, 2711, 63, 7486, 275, 283, 1832, 7, 199, 17467, 63, 2711, 63, 16058, 275, 283, 3846, 7, 199, 199, 3472, 63, 11958, 275, 298, 11020, 759, 2, 199, 3472, 63, 9032, 275, 298, 5076, 576, 2, 199, 199, 3, 199, 3, 8692, 2897, 5922, 3992, 199, 3, 199, 533, 6249, 3053, 9921, 26, 523, 347, 636, 826, 721, 277, 12, 284, 63, 697, 706, 63, 498, 12, 284, 63, 3494, 63, 498, 12, 284, 63, 697, 706, 63, 354, 12, 284, 63, 3494, 63, 354, 12, 284, 63, 2324, 63, 981, 63, 888, 304, 272, 291, 14, 697, 706, 63, 498, 275, 284, 63, 697, 706, 63, 498, 272, 291, 14, 3494, 63, 498, 275, 284, 63, 3494, 63, 498, 272, 291, 14, 697, 706, 63, 354, 275, 284, 63, 697, 706, 63, 354, 272, 291, 14, 3494, 63, 354, 275, 284, 63, 3494, 63, 354, 272, 291, 14, 2324, 63, 981, 63, 888, 275, 284, 63, 2324, 63, 981, 63, 888, 819, 347, 1218, 63, 888, 8, 277, 12, 1511, 12, 4382, 12, 1592, 1304, 304, 272, 372, 291, 14, 2324, 63, 981, 63, 888, 8, 1419, 12, 4382, 12, 291, 14, 3494, 63, 498, 12, 1592, 1304, 9, 199, 199, 533, 28822, 9955, 6340, 26, 523, 347, 636, 826, 721, 277, 12, 284, 63, 697, 706, 63, 498, 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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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 ]
TeamTwisted/external_chromium_org
third_party/closure_compiler/processor.py
32
3381
# Copyright 2014 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. """Process Chrome resources (HTML/CSS/JS) to handle <include> and <if> tags.""" from collections import defaultdict import re import os class LineNumber(object): """A simple wrapper to hold line information (e.g. file.js:32). Args: source_file: A file path. line_number: The line in |file|. """ def __init__(self, source_file, line_number): self.file = source_file self.line_number = int(line_number) class FileCache(object): """An in-memory cache to speed up reading the same files over and over. Usage: FileCache.read(path_to_file) """ _cache = defaultdict(str) @classmethod def read(self, source_file): """Read a file and return it as a string. Args: source_file: a file to read and return the contents of. Returns: |file| as a string. """ abs_file = os.path.abspath(source_file) self._cache[abs_file] = self._cache[abs_file] or open(abs_file, "r").read() return self._cache[abs_file] class Processor(object): """Processes resource files, inlining the contents of <include> tags, removing <if> tags, and retaining original line info. For example 1: /* blah.js */ 2: <if expr="is_win"> 3: <include src="win.js"> 4: </if> would be turned into: 1: /* blah.js */ 2: 3: /* win.js */ 4: alert('Ew; Windows.'); 5: Args: source_file: A file to process. Attributes: contents: Expanded contents after inlining <include>s and stripping <if>s. included_files: A list of files that were inlined via <include>. """ _IF_TAGS_REG = "</?if[^>]*?>" _INCLUDE_REG = "<include[^>]+src=['\"]([^>]*)['\"]>" def __init__(self, source_file): self._included_files = set() self._index = 0 self._lines = self._get_file(source_file) while self._index < len(self._lines): current_line = self._lines[self._index] match = re.search(self._INCLUDE_REG, current_line[2]) if match: file_dir = os.path.dirname(current_line[0]) self._include_file(os.path.join(file_dir, match.group(1))) else: self._index += 1 for i, line in enumerate(self._lines): self._lines[i] = line[:2] + (re.sub(self._IF_TAGS_REG, "", line[2]),) self.contents = "\n".join(l[2] for l in self._lines) # Returns a list of tuples in the format: (file, line number, line contents). def _get_file(self, source_file): lines = FileCache.read(source_file).splitlines() return [(source_file, lnum + 1, line) for lnum, line in enumerate(lines)] def _include_file(self, source_file): self._included_files.add(source_file) f = self._get_file(source_file) self._lines = self._lines[:self._index] + f + self._lines[self._index + 1:] def get_file_from_line(self, line_number): """Get the original file and line number for an expanded file's line number. Args: line_number: A processed file's line number. """ line_number = int(line_number) - 1 return LineNumber(self._lines[line_number][0], self._lines[line_number][1]) @property def included_files(self): """A list of files that were inlined via <include>.""" return self._included_files
bsd-3-clause
[ 3, 1898, 6927, 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, 624, 3498, 16776, 5944, 334, 4943, 15, 14391, 15, 11378, 9, 370, 2429, 665, 2613, 30, 436, 665, 692, 30, 3762, 1041, 199, 199, 504, 5055, 492, 10018, 199, 646, 295, 199, 646, 747, 421, 199, 533, 7030, 3259, 8, 785, 304, 523, 408, 33, 3486, 4975, 370, 10266, 1004, 2556, 334, 69, 14, 71, 14, 570, 14, 3596, 26, 708, 680, 12244, 3033, 26, 272, 1350, 63, 493, 26, 437, 570, 931, 14, 272, 1004, 63, 1955, 26, 710, 1004, 315, 1204, 493, 18257, 523, 408, 523, 347, 636, 826, 721, 277, 12, 1350, 63, 493, 12, 1004, 63, 1955, 304, 272, 291, 14, 493, 275, 1350, 63, 493, 272, 291, 14, 604, 63, 1955, 275, 1109, 8, 604, 63, 1955, 9, 421, 199, 533, 3814, 4437, 8, 785, 304, 523, 408, 2493, 315, 13, 4844, 2581, 370, 8112, 1536, 7664, 314, 2011, 1584, 1806, 436, 1806, 14, 12244, 11028, 26, 489, 3814, 4437, 14, 739, 8, 515, 63, 475, 63, 493, 9, 523, 408, 819, 485, 1637, 275, 10018, 8, 495, 9, 819, 768, 3744, 523, 347, 1586, 8, 277, 12, 1350, 63, 493, 304, 272, 408, 3284, 282, 570, 436, 372, 652, 465, 282, 1059, 14, 339, 3033, 26, 267, 1350, 63, 493, 26, 282, 570, 370, 1586, 436, 372, 314, 4072, 402, 14, 339, 1803, 26, 267, 1204, 493, 92, 465, 282, 1059, 14, 272, 408, 272, 2853, 63, 493, 275, 747, 14, 515, 14, 4832, 8, 1365, 63, 493, 9, 272, 291, 423, 1637, 59, 2101, 63, 493, 61, 275, 291, 423, 1637, 59, 2101, 63, 493, 61, 503, 1551, 8, 2101, 63, 493, 12, 298, 82, 3471, 739, 342, 272, 372, 291, 423, 1637, 59, 2101, 63, 493, 61, 421, 199, 533, 31500, 8, 785, 304, 523, 408, 25857, 2073, 1584, 12, 315, 30176, 314, 4072, 402, 665, 2613, 30, 3762, 12, 12881, 523, 665, 692, 30, 3762, 12, 436, 8074, 316, 3379, 1004, 2256, 14, 819, 2104, 2893, 2541, 413, 26, 13505, 14359, 14, 3596, 11589, 489, 499, 26, 665, 692, 5348, 628, 374, 63, 2676, 1743, 489, 650, 26, 665, 2613, 2928, 628, 2676, 14, 3596, 1743, 489, 841, 26, 3068, 692, 30, 819, 3955, 506, 19136, 1901, 26, 2541, 413, 26, 13505, 14359, 14, 3596, 11589, 489, 499, 26, 489, 650, 26, 13505, 4747, 14, 3596, 11589, 489, 841, 26, 10459, 360, 37, 87, 27, 5417, 2659, 27, 489, 959, 26, 819, 3033, 26, 489, 1350, 63, 493, 26, 437, 570, 370, 2112, 14, 819, 9382, 26, 489, 4072, 26, 7910, 7028, 4072, 2410, 315, 30176, 665, 2613, 30, 83, 436, 4024, 3637, 665, 692, 30, 83, 14, 489, 5120, 63, 1725, 26, 437, 769, 402, 1584, 626, 4898, 315, 23058, 4799, 665, 2613, 10827, 523, 408, 819, 485, 4656, 63, 17626, 63, 5616, 275, 15683, 31, 692, 28959, 31, 4335, 523, 485, 18171, 63, 5616, 275, 3886, 2613, 25524, 2164, 2968, 60, 937, 7059, 30, 3672, 11820, 60, 937, 4335, 819, 347, 636, 826, 721, 277, 12, 1350, 63, 493, 304, 272, 291, 423, 12409, 63, 1725, 275, 663, 342, 272, 291, 423, 1080, 275, 378, 272, 291, 423, 1278, 275, 291, 423, 362, 63, 493, 8, 1365, 63, 493, 9, 339, 1830, 291, 423, 1080, 665, 822, 8, 277, 423, 1278, 304, 489, 1453, 63, 604, 275, 291, 423, 1278, 59, 277, 423, 1080, 61, 489, 1336, 275, 295, 14, 1733, 8, 277, 423, 18171, 63, 5616, 12, 1453, 63, 604, 59, 18, 566, 489, 340, 1336, 26, 267, 570, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 1818, 63, 604, 59, 16, 566, 267, 291, 423, 2613, 63, 493, 8, 736, 14, 515, 14, 904, 8, 493, 63, 694, 12, 1336, 14, 923, 8, 17, 1724, 489, 587, 26, 267, 291, 423, 1080, 847, 413, 339, 367, 284, 12, 1004, 315, 3874, 8, 277, 423, 1278, 304, 489, 291, 423, 1278, 59, 73, 61, 275, 1004, 1491, 18, 61, 435, 334, 264, 14, 954, 8, 277, 423, 4656, 63, 17626, 63, 5616, 12, 4873, 1004, 59, 18, 2522, 9, 339, 291, 14, 4407, 275, 1867, 78, 1674, 904, 8, 76, 59, 18, 61, 367, 634, 315, 291, 423, 1278, 9, 819, 327, 1803, 282, 769, 402, 6346, 315, 314, 1475, 26, 334, 493, 12, 1004, 1329, 12, 1004, 4072, 680, 523, 347, 485, 362, 63, 493, 8, 277, 12, 1350, 63, 493, 304, 272, 2385, 275, 3814, 4437, 14, 739, 8, 1365, 63, 493, 680, 7644, 342, 272, 372, 3842, 1365, 63, 493, 12, 634, 1507, 435, 413, 12, 1004, 9, 367, 634, 1507, 12, 1004, 315, 3874, 8, 1278, 1874, 819, 347, 485, 2613, 63, 493, 8, 277, 12, 1350, 63, 493, 304, 272, 291, 423, 12409, 63, 1725, 14, 525, 8, 1365, 63, 493, 9, 272, 289, 275, 291, 423, 362, 63, 493, 8, 1365, 63, 493, 9, 272, 291, 423, 1278, 275, 291, 423, 1278, 1491, 277, 423, 1080, 61, 435, 289, 435, 291, 423, 1278, 59, 277, 423, 1080, 435, 413, 2938, 819, 347, 664, 63, 493, 63, 504, 63, 604, 8, 277, 12, 1004, 63, 1955, 304, 272, 408, 1002, 314, 3379, 570, 436, 1004, 1329, 367, 376, 11507, 570, 1159, 1004, 1329, 14, 339, 3033, 26, 267, 1004, 63, 1955, 26, 437, 7686, 570, 1159, 1004, 1329, 14, 272, 408, 272, 1004, 63, 1955, 275, 1109, 8, 604, 63, 1955, 9, 446, 413, 272, 372, 7030, 3259, 8, 277, 423, 1278, 59, 604, 63, 1955, 1527, 16, 467, 291, 423, 1278, 59, 604, 63, 1955, 1527, 17, 566, 819, 768, 1829, 523, 347, 5120, 63, 1725, 8, 277, 304, 272, 408, 33, 769, 402, 1584, 626, 4898, 315, 23058, 4799, 665, 2613, 30, 1041, 272, 372, 291, 423, 12409, 63, 1725, 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 ]
[ 1898, 6927, 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, 624, 3498, 16776, 5944, 334, 4943, 15, 14391, 15, 11378, 9, 370, 2429, 665, 2613, 30, 436, 665, 692, 30, 3762, 1041, 199, 199, 504, 5055, 492, 10018, 199, 646, 295, 199, 646, 747, 421, 199, 533, 7030, 3259, 8, 785, 304, 523, 408, 33, 3486, 4975, 370, 10266, 1004, 2556, 334, 69, 14, 71, 14, 570, 14, 3596, 26, 708, 680, 12244, 3033, 26, 272, 1350, 63, 493, 26, 437, 570, 931, 14, 272, 1004, 63, 1955, 26, 710, 1004, 315, 1204, 493, 18257, 523, 408, 523, 347, 636, 826, 721, 277, 12, 1350, 63, 493, 12, 1004, 63, 1955, 304, 272, 291, 14, 493, 275, 1350, 63, 493, 272, 291, 14, 604, 63, 1955, 275, 1109, 8, 604, 63, 1955, 9, 421, 199, 533, 3814, 4437, 8, 785, 304, 523, 408, 2493, 315, 13, 4844, 2581, 370, 8112, 1536, 7664, 314, 2011, 1584, 1806, 436, 1806, 14, 12244, 11028, 26, 489, 3814, 4437, 14, 739, 8, 515, 63, 475, 63, 493, 9, 523, 408, 819, 485, 1637, 275, 10018, 8, 495, 9, 819, 768, 3744, 523, 347, 1586, 8, 277, 12, 1350, 63, 493, 304, 272, 408, 3284, 282, 570, 436, 372, 652, 465, 282, 1059, 14, 339, 3033, 26, 267, 1350, 63, 493, 26, 282, 570, 370, 1586, 436, 372, 314, 4072, 402, 14, 339, 1803, 26, 267, 1204, 493, 92, 465, 282, 1059, 14, 272, 408, 272, 2853, 63, 493, 275, 747, 14, 515, 14, 4832, 8, 1365, 63, 493, 9, 272, 291, 423, 1637, 59, 2101, 63, 493, 61, 275, 291, 423, 1637, 59, 2101, 63, 493, 61, 503, 1551, 8, 2101, 63, 493, 12, 298, 82, 3471, 739, 342, 272, 372, 291, 423, 1637, 59, 2101, 63, 493, 61, 421, 199, 533, 31500, 8, 785, 304, 523, 408, 25857, 2073, 1584, 12, 315, 30176, 314, 4072, 402, 665, 2613, 30, 3762, 12, 12881, 523, 665, 692, 30, 3762, 12, 436, 8074, 316, 3379, 1004, 2256, 14, 819, 2104, 2893, 2541, 413, 26, 13505, 14359, 14, 3596, 11589, 489, 499, 26, 665, 692, 5348, 628, 374, 63, 2676, 1743, 489, 650, 26, 665, 2613, 2928, 628, 2676, 14, 3596, 1743, 489, 841, 26, 3068, 692, 30, 819, 3955, 506, 19136, 1901, 26, 2541, 413, 26, 13505, 14359, 14, 3596, 11589, 489, 499, 26, 489, 650, 26, 13505, 4747, 14, 3596, 11589, 489, 841, 26, 10459, 360, 37, 87, 27, 5417, 2659, 27, 489, 959, 26, 819, 3033, 26, 489, 1350, 63, 493, 26, 437, 570, 370, 2112, 14, 819, 9382, 26, 489, 4072, 26, 7910, 7028, 4072, 2410, 315, 30176, 665, 2613, 30, 83, 436, 4024, 3637, 665, 692, 30, 83, 14, 489, 5120, 63, 1725, 26, 437, 769, 402, 1584, 626, 4898, 315, 23058, 4799, 665, 2613, 10827, 523, 408, 819, 485, 4656, 63, 17626, 63, 5616, 275, 15683, 31, 692, 28959, 31, 4335, 523, 485, 18171, 63, 5616, 275, 3886, 2613, 25524, 2164, 2968, 60, 937, 7059, 30, 3672, 11820, 60, 937, 4335, 819, 347, 636, 826, 721, 277, 12, 1350, 63, 493, 304, 272, 291, 423, 12409, 63, 1725, 275, 663, 342, 272, 291, 423, 1080, 275, 378, 272, 291, 423, 1278, 275, 291, 423, 362, 63, 493, 8, 1365, 63, 493, 9, 339, 1830, 291, 423, 1080, 665, 822, 8, 277, 423, 1278, 304, 489, 1453, 63, 604, 275, 291, 423, 1278, 59, 277, 423, 1080, 61, 489, 1336, 275, 295, 14, 1733, 8, 277, 423, 18171, 63, 5616, 12, 1453, 63, 604, 59, 18, 566, 489, 340, 1336, 26, 267, 570, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 1818, 63, 604, 59, 16, 566, 267, 291, 423, 2613, 63, 493, 8, 736, 14, 515, 14, 904, 8, 493, 63, 694, 12, 1336, 14, 923, 8, 17, 1724, 489, 587, 26, 267, 291, 423, 1080, 847, 413, 339, 367, 284, 12, 1004, 315, 3874, 8, 277, 423, 1278, 304, 489, 291, 423, 1278, 59, 73, 61, 275, 1004, 1491, 18, 61, 435, 334, 264, 14, 954, 8, 277, 423, 4656, 63, 17626, 63, 5616, 12, 4873, 1004, 59, 18, 2522, 9, 339, 291, 14, 4407, 275, 1867, 78, 1674, 904, 8, 76, 59, 18, 61, 367, 634, 315, 291, 423, 1278, 9, 819, 327, 1803, 282, 769, 402, 6346, 315, 314, 1475, 26, 334, 493, 12, 1004, 1329, 12, 1004, 4072, 680, 523, 347, 485, 362, 63, 493, 8, 277, 12, 1350, 63, 493, 304, 272, 2385, 275, 3814, 4437, 14, 739, 8, 1365, 63, 493, 680, 7644, 342, 272, 372, 3842, 1365, 63, 493, 12, 634, 1507, 435, 413, 12, 1004, 9, 367, 634, 1507, 12, 1004, 315, 3874, 8, 1278, 1874, 819, 347, 485, 2613, 63, 493, 8, 277, 12, 1350, 63, 493, 304, 272, 291, 423, 12409, 63, 1725, 14, 525, 8, 1365, 63, 493, 9, 272, 289, 275, 291, 423, 362, 63, 493, 8, 1365, 63, 493, 9, 272, 291, 423, 1278, 275, 291, 423, 1278, 1491, 277, 423, 1080, 61, 435, 289, 435, 291, 423, 1278, 59, 277, 423, 1080, 435, 413, 2938, 819, 347, 664, 63, 493, 63, 504, 63, 604, 8, 277, 12, 1004, 63, 1955, 304, 272, 408, 1002, 314, 3379, 570, 436, 1004, 1329, 367, 376, 11507, 570, 1159, 1004, 1329, 14, 339, 3033, 26, 267, 1004, 63, 1955, 26, 437, 7686, 570, 1159, 1004, 1329, 14, 272, 408, 272, 1004, 63, 1955, 275, 1109, 8, 604, 63, 1955, 9, 446, 413, 272, 372, 7030, 3259, 8, 277, 423, 1278, 59, 604, 63, 1955, 1527, 16, 467, 291, 423, 1278, 59, 604, 63, 1955, 1527, 17, 566, 819, 768, 1829, 523, 347, 5120, 63, 1725, 8, 277, 304, 272, 408, 33, 769, 402, 1584, 626, 4898, 315, 23058, 4799, 665, 2613, 30, 1041, 272, 372, 291, 423, 12409, 63, 1725, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bpsinc-native/src_third_party_pywebsocket_src
test/testdata/handlers/abort_by_user_wsh.py
496
1798
# Copyright 2011, Google 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 Google 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. from mod_pywebsocket import handshake def web_socket_do_extra_handshake(request): raise handshake.AbortedByUserException("abort for test") def web_socket_transfer_data(request): raise handshake.AbortedByUserException("abort for test") # vi:sts=4 sw=4 et
bsd-3-clause
[ 3, 1898, 7760, 12, 4475, 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, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 421, 199, 504, 3413, 63, 21387, 492, 14305, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 746, 14305, 14, 5583, 1376, 2175, 1899, 1726, 480, 13845, 367, 511, 531, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 746, 14305, 14, 5583, 1376, 2175, 1899, 1726, 480, 13845, 367, 511, 531, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 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 ]
[ 1898, 7760, 12, 4475, 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, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 421, 199, 504, 3413, 63, 21387, 492, 14305, 421, 199, 318, 3330, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 8, 1069, 304, 272, 746, 14305, 14, 5583, 1376, 2175, 1899, 1726, 480, 13845, 367, 511, 531, 421, 199, 318, 3330, 63, 3450, 63, 9609, 63, 576, 8, 1069, 304, 272, 746, 14305, 14, 5583, 1376, 2175, 1899, 1726, 480, 13845, 367, 511, 531, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 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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
gmassei/wfrog
wfrender/datasource/accumulator.py
5
12486
## Copyright 2009 Laurent Bovet <laurent.bovet@windmaster.ch> ## Jordi Puigsegur <jordi.puigsegur@gmail.com> ## ## This file is part of wfrog ## ## wfrog is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. import logging from wfcommon.formula.base import AverageFormula from wfcommon.formula.base import MinFormula from wfcommon.formula.base import MaxFormula from wfcommon.formula.base import SumFormula from wfcommon.formula.wind import PredominantWindFormula from wfcommon.formula.wind import WindSectorAverageFormula from wfcommon.formula.wind import WindSectorMaxFormula from wfcommon.formula.wind import WindSectorFrequencyFormula from wfcommon.formula.temp import WindChillMinFormula from wfcommon.formula.temp import HeatIndexMaxFormula import copy import datetime import threading class AccumulatorDatasource(object): ''' Calculates data from a storage in an iterative way by traversing only recently added data. [ Properties ] storage [storage]: The underlying storage to get samples. slice [year|month|week|day|hour|minute] (optional): The unit of grouping for the calculated series. Defaults to 'hour'' span [numeric] (optional): Number of slices in the resulting series. Defaults to 24. period [numeric] (optional): Number of seconds between two refreshes of the calculated data. DEfaults to 120. format [string or list of strings] (optional): Date/time format string for labels. See Python strftime function. It can be a single string (only 1 label) or a list of formats. First label is 'lbl' and the rest are 'lbl2', lbl3', etc. formulas [dict] (optional): Specify what and how to calculate. Defines the structure of the resulting data. Dictionary keyed by the measure names ('temp', 'hum', ...). Values are dictionaries keyed by the serie names ('avg', 'min', ...) and containing 'formula' objects. caching [true|false] (optional): Enable/disable caching for normal requests. Defaults to true. ''' storage = None slice = 'hour' span = 23 format = None formats = { 'year': ['%y', '%Y'], 'month': ['%m', '%Y/%m'], 'week': ['%d/%m', '%Y/%m/%d'], 'day': ['%d/%m', '%Y/%m/%d'], 'hour': ['%H', '%Y/%m/%d %H'], 'minute': ['%H:%M', '%Y/%m/%d %H:%M'] } period = 120 default_formulas = { 'temp': { 'avg' : AverageFormula('temp'), 'min' : MinFormula('temp'), 'max' : MaxFormula('temp') }, 'dew' : { 'avg': AverageFormula('dew_point') }, 'hum' : { 'avg' : AverageFormula('hum'), 'min' : MinFormula('hum'), 'max' : MaxFormula('hum') }, 'press' : { 'avg' : AverageFormula('pressure'), 'min' : MinFormula('pressure'), 'max' : MaxFormula('pressure') }, 'wind' : { 'avg' : AverageFormula('wind'), 'max' : MaxFormula('wind_gust'), 'deg,dir' : PredominantWindFormula('wind') }, 'sectors' : { 'avg' : WindSectorAverageFormula('wind'), 'max' : WindSectorMaxFormula('wind_gust'), 'freq' : WindSectorFrequencyFormula('wind') }, 'rain' : { 'rate' : MaxFormula('rain_rate'), 'fall' : SumFormula('rain') }, 'uv' : { 'index' : MaxFormula('uv_index') } } formulas = default_formulas caching = True logger = logging.getLogger("datasource.accumulator") last_timestamp = datetime.datetime.fromtimestamp(0) cached_slices = None cached_series = None lock = threading.Lock() class Slice(object): def __init__(self, formulas, from_time, to_time, keys): self.formulas = copy.deepcopy(formulas) self.from_time = from_time self.to_time = to_time # replace string keys with index for performance for serie in self.formulas.values(): for formula in serie.values(): if type(formula.index)==str: formula.index = keys.index(formula.index) # Index can be a list of indexes (e.g. heatIndex or WindChill) elif type(formula.index)==list: formula.index = map(lambda x: keys.index(x), formula.index) def add_sample(self, sample): for serie in self.formulas.values(): for formula in serie.values(): formula.append(sample) def get_slice_duration(self): if self.slice == 'minute': return datetime.timedelta(0, 60) elif self.slice == 'hour': return datetime.timedelta(0, 3600) elif self.slice == 'day': return datetime.timedelta(1) elif self.slice == 'week': return datetime.timedelta(7) elif self.slice == 'month': return datetime.timedelta(30) elif self.slice == 'year': return datetime.timedelta(365) def get_slice_start(self, time): if self.slice == 'minute': return datetime.datetime(time.year, time.month, time.day, time.hour, time.minute) elif self.slice == 'hour': return datetime.datetime(time.year, time.month, time.day, time.hour) elif self.slice == 'day': return datetime.datetime(time.year, time.month, time.day) elif self.slice == 'week': (year, week, dayweek) = time.isocalendar() return iso_to_gregorian(year, week, 1) elif self.slice == 'month': return datetime.datetime(time.year, time.month, 1) elif self.slice == 'year': return datetime.datetime(time.year, 1, 1) def get_next_slice_start(self, time): if self.slice == 'minute': return time+datetime.timedelta(0,60) elif self.slice == 'hour': return time+datetime.timedelta(0,3600) elif self.slice == 'day': return time+datetime.timedelta(1,0) elif self.slice == 'week': (year, week, dayweek) = time.isocalendar() return iso_to_gregorian(year, week, 1)+datetime.timedelta(7) elif self.slice == 'month': if time.month == 12: return datetime.datetime(time.year + 1, 1, 1) else: return datetime.datetime(time.year, time.month + 1, 1) elif self.slice == 'year': return datetime.datetime(time.year + 1, 1, 1) def get_labels(self, slices): if self.format is not None: if type(self.format) == str: format_list = [self.format] else: format_list = self.format else: format_list = self.formats[self.slice] return [[slice.from_time.strftime(format) for slice in slices] for format in format_list] def update_slices(self, slices, from_time, to_time, context, last_timestamp=None): if len(slices) > 0: slice_from_time = slices[-1].to_time else: slice_from_time = from_time # Create the necessary slices t = self.get_slice_start(slice_from_time) keys = self.storage.keys(context=context) while t < to_time: end = self.get_next_slice_start(t) self.logger.debug("Creating slice %s - %s", t, end) slice = self.Slice(self.formulas, t, end, keys) slices.append(slice) t = end # Fill them with samples if last_timestamp: update_from_time = max(last_timestamp + datetime.timedelta(seconds=1), from_time) # Add 1 sec to last_timestamp so that the same sample is not retrieved twice else: update_from_time = from_time self.logger.debug("Update from %s ", update_from_time) s = 0 to_delete = 0 localtime_index = keys.index('localtime') for sample in self.storage.samples(update_from_time, to_time, context=context): # find the first slice receiving the samples sample_localtime = sample[localtime_index] while slices[s].to_time < sample_localtime: if slices[s].to_time < from_time: # count of obsolete slices to delete to_delete=s s = s + 1 slices[s].add_sample(sample) last_timestamp = sample_localtime return last_timestamp, to_delete def get_series(self, slices): result = {} for k,v in self.formulas.iteritems(): result[k]={} result[k]['series']={} for key in v.keys(): subkeys = key.split(',') for subkey in subkeys: result[k]['series'][subkey]=[] i = 1 for labels in self.get_labels(slices): literal = 'lbl%d' % i if i > 1 else 'lbl' i += 1 result[k]['series'][literal]=labels for slice in slices: for k,v in slice.formulas.iteritems(): for key,formula in v.iteritems(): value = formula.value() subkeys = key.split(',') if len(subkeys) == 1: value = [ value ] for i in range(len(subkeys)): result[k]['series'][subkeys[i]].append(value[i]) return result def execute(self,data={}, context={}): if data.has_key('time_end'): to_time = parse(data['time_end']) use_cache = False else: to_time = datetime.datetime.now() use_cache = self.caching duration = self.get_slice_duration() times = (self.span - 1) delta= duration * times from_time = self.get_slice_start(to_time - delta) if use_cache: self.logger.debug("Last timestamp: %s", self.last_timestamp) self.lock.acquire() try: if self.last_timestamp < to_time - datetime.timedelta(0,self.period) or self.cached_series is None: if self.cached_slices is None: self.cached_slices = [] last_timestamp, to_delete = self.update_slices(self.cached_slices, from_time, to_time, context, self.last_timestamp) self.cached_slices = self.cached_slices[to_delete:] self.logger.debug('Deleted %s slices', to_delete) self.logger.debug("Last timestamp: %s", self.last_timestamp) self.last_timestamp = last_timestamp self.cached_series = self.get_series(self.cached_slices) finally: self.lock.release() return self.cached_series else: # use_cache == False slices = [] self.update_slices(slices, from_time, to_time, context) return self.get_series(slices) def parse(isodate): if len(isodate) == 10: return datetime.datetime.strptime(isodate, "%Y-%m-%d") else: return datetime.datetime.strptime(isodate, "%Y-%m-%d"+isodate[10]+"%H:%M:%S") def iso_year_start(iso_year): "The gregorian calendar date of the first day of the given ISO year" fourth_jan = datetime.datetime(iso_year, 1, 4) delta = datetime.timedelta(fourth_jan.isoweekday()-1) return fourth_jan - delta def iso_to_gregorian(iso_year, iso_week, iso_day): "Gregorian calendar date for the given ISO year, week and day" year_start = iso_year_start(iso_year) return year_start + datetime.timedelta(iso_day-1, 0, 0, 0, 0, 0, iso_week-1)
gpl-3.0
[ 309, 1898, 8937, 7964, 608, 343, 5088, 28350, 665, 416, 608, 343, 14, 656, 28350, 32, 11530, 4133, 14, 335, 30, 199, 309, 4483, 1603, 269, 328, 510, 85, 528, 8359, 300, 665, 5857, 328, 14, 3165, 528, 8359, 300, 32, 6799, 14, 957, 30, 199, 309, 199, 309, 221, 961, 570, 365, 1777, 402, 17328, 19029, 199, 309, 199, 309, 221, 17328, 19029, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 309, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2050, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 437, 3652, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 10195, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 8228, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 12094, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 510, 581, 676, 262, 867, 55, 688, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 17400, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 4261, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 18285, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 808, 492, 644, 688, 1049, 778, 4649, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 808, 492, 5311, 292, 2681, 4261, 28533, 199, 199, 646, 1331, 199, 646, 2197, 199, 646, 5796, 199, 199, 533, 32254, 6109, 28369, 305, 616, 8, 785, 304, 272, 1449, 272, 28562, 666, 687, 282, 4887, 315, 376, 4826, 857, 4340, 701, 1468, 422, 1044, 272, 1454, 23568, 3483, 666, 14, 339, 359, 19329, 1622, 339, 4887, 359, 3494, 2189, 267, 710, 8793, 4887, 370, 664, 5845, 14, 339, 6014, 359, 3403, 92, 4482, 92, 6419, 92, 2977, 92, 5180, 92, 10698, 61, 334, 4144, 304, 267, 710, 4137, 402, 17786, 367, 314, 12950, 6779, 14, 267, 7827, 370, 283, 5180, 891, 339, 13598, 359, 6677, 61, 334, 4144, 304, 267, 4860, 402, 17184, 315, 314, 9183, 6779, 14, 267, 7827, 370, 5504, 14, 339, 6247, 359, 6677, 61, 334, 4144, 304, 267, 4860, 402, 4696, 3382, 2877, 9236, 397, 402, 314, 12950, 666, 14, 267, 3265, 1879, 83, 370, 13960, 14, 339, 1475, 359, 875, 503, 769, 402, 3326, 61, 334, 4144, 304, 267, 6148, 15, 521, 1475, 1059, 367, 3628, 14, 1666, 2018, 14053, 805, 14, 267, 2779, 883, 506, 282, 2849, 1059, 334, 2118, 413, 1768, 9, 503, 282, 769, 402, 6752, 14, 4960, 7758, 1768, 365, 283, 18842, 7, 436, 314, 4618, 787, 283, 18842, 18, 297, 32375, 19, 297, 5423, 14, 339, 1824, 32646, 359, 807, 61, 334, 4144, 304, 267, 13327, 4052, 436, 4212, 370, 8671, 14, 25022, 314, 5523, 402, 314, 267, 9183, 666, 14, 267, 11932, 19272, 701, 314, 9775, 1561, 661, 808, 297, 283, 72, 453, 297, 2263, 680, 13468, 267, 787, 11196, 19272, 701, 314, 542, 11317, 1561, 661, 8595, 297, 283, 827, 297, 19172, 436, 267, 3035, 283, 16798, 7, 2251, 14, 339, 13627, 359, 2052, 92, 3910, 61, 334, 4144, 304, 267, 12030, 15, 5993, 13627, 367, 3293, 4145, 14, 7827, 370, 2549, 14, 272, 1449, 339, 4887, 275, 488, 272, 6014, 275, 283, 5180, 7, 272, 13598, 275, 6546, 339, 1475, 275, 488, 339, 6752, 275, 469, 283, 3403, 356, 15926, 89, 297, 1543, 57, 995, 355, 283, 4482, 356, 15926, 77, 297, 1543, 57, 3149, 77, 995, 355, 283, 6419, 356, 15926, 68, 3149, 77, 297, 1543, 57, 3149, 77, 3149, 68, 995, 8892, 283, 2977, 356, 15926, 68, 3149, 77, 297, 1543, 57, 3149, 77, 3149, 68, 995, 355, 283, 5180, 356, 15926, 40, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 995, 355, 283, 10698, 356, 15926, 40, 2689, 45, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 418, 789, 339, 6247, 275, 13960, 339, 849, 63, 964, 32646, 275, 469, 267, 283, 808, 356, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 808, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 808, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 808, 358, 1660, 267, 283, 271, 87, 7, 520, 469, 283, 8595, 356, 437, 3652, 28533, 360, 271, 87, 63, 1403, 358, 1660, 267, 283, 72, 453, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 72, 453, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 72, 453, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 72, 453, 358, 1660, 267, 283, 2915, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 21999, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 21999, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 21999, 358, 1660, 267, 283, 11530, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 11530, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 11530, 63, 71, 833, 659, 673, 283, 6458, 12, 694, 7, 520, 510, 581, 676, 262, 867, 55, 688, 28533, 360, 11530, 358, 221, 1660, 267, 283, 261, 13451, 7, 520, 469, 283, 8595, 7, 520, 644, 688, 51, 2406, 17400, 28533, 360, 11530, 659, 1993, 283, 988, 7, 520, 644, 688, 51, 2406, 4261, 28533, 360, 11530, 63, 71, 833, 659, 1993, 283, 5646, 7, 520, 644, 688, 51, 2406, 18285, 28533, 360, 11530, 358, 1660, 267, 283, 6322, 7, 520, 469, 283 ]
[ 1898, 8937, 7964, 608, 343, 5088, 28350, 665, 416, 608, 343, 14, 656, 28350, 32, 11530, 4133, 14, 335, 30, 199, 309, 4483, 1603, 269, 328, 510, 85, 528, 8359, 300, 665, 5857, 328, 14, 3165, 528, 8359, 300, 32, 6799, 14, 957, 30, 199, 309, 199, 309, 221, 961, 570, 365, 1777, 402, 17328, 19029, 199, 309, 199, 309, 221, 17328, 19029, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 221, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 309, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2050, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 437, 3652, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 10195, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 8228, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 1095, 492, 12094, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 510, 581, 676, 262, 867, 55, 688, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 17400, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 4261, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 11530, 492, 644, 688, 51, 2406, 18285, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 808, 492, 644, 688, 1049, 778, 4649, 28533, 199, 504, 17328, 2330, 14, 16798, 14, 808, 492, 5311, 292, 2681, 4261, 28533, 199, 199, 646, 1331, 199, 646, 2197, 199, 646, 5796, 199, 199, 533, 32254, 6109, 28369, 305, 616, 8, 785, 304, 272, 1449, 272, 28562, 666, 687, 282, 4887, 315, 376, 4826, 857, 4340, 701, 1468, 422, 1044, 272, 1454, 23568, 3483, 666, 14, 339, 359, 19329, 1622, 339, 4887, 359, 3494, 2189, 267, 710, 8793, 4887, 370, 664, 5845, 14, 339, 6014, 359, 3403, 92, 4482, 92, 6419, 92, 2977, 92, 5180, 92, 10698, 61, 334, 4144, 304, 267, 710, 4137, 402, 17786, 367, 314, 12950, 6779, 14, 267, 7827, 370, 283, 5180, 891, 339, 13598, 359, 6677, 61, 334, 4144, 304, 267, 4860, 402, 17184, 315, 314, 9183, 6779, 14, 267, 7827, 370, 5504, 14, 339, 6247, 359, 6677, 61, 334, 4144, 304, 267, 4860, 402, 4696, 3382, 2877, 9236, 397, 402, 314, 12950, 666, 14, 267, 3265, 1879, 83, 370, 13960, 14, 339, 1475, 359, 875, 503, 769, 402, 3326, 61, 334, 4144, 304, 267, 6148, 15, 521, 1475, 1059, 367, 3628, 14, 1666, 2018, 14053, 805, 14, 267, 2779, 883, 506, 282, 2849, 1059, 334, 2118, 413, 1768, 9, 503, 282, 769, 402, 6752, 14, 4960, 7758, 1768, 365, 283, 18842, 7, 436, 314, 4618, 787, 283, 18842, 18, 297, 32375, 19, 297, 5423, 14, 339, 1824, 32646, 359, 807, 61, 334, 4144, 304, 267, 13327, 4052, 436, 4212, 370, 8671, 14, 25022, 314, 5523, 402, 314, 267, 9183, 666, 14, 267, 11932, 19272, 701, 314, 9775, 1561, 661, 808, 297, 283, 72, 453, 297, 2263, 680, 13468, 267, 787, 11196, 19272, 701, 314, 542, 11317, 1561, 661, 8595, 297, 283, 827, 297, 19172, 436, 267, 3035, 283, 16798, 7, 2251, 14, 339, 13627, 359, 2052, 92, 3910, 61, 334, 4144, 304, 267, 12030, 15, 5993, 13627, 367, 3293, 4145, 14, 7827, 370, 2549, 14, 272, 1449, 339, 4887, 275, 488, 272, 6014, 275, 283, 5180, 7, 272, 13598, 275, 6546, 339, 1475, 275, 488, 339, 6752, 275, 469, 283, 3403, 356, 15926, 89, 297, 1543, 57, 995, 355, 283, 4482, 356, 15926, 77, 297, 1543, 57, 3149, 77, 995, 355, 283, 6419, 356, 15926, 68, 3149, 77, 297, 1543, 57, 3149, 77, 3149, 68, 995, 8892, 283, 2977, 356, 15926, 68, 3149, 77, 297, 1543, 57, 3149, 77, 3149, 68, 995, 355, 283, 5180, 356, 15926, 40, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 995, 355, 283, 10698, 356, 15926, 40, 2689, 45, 297, 1543, 57, 3149, 77, 3149, 68, 450, 40, 2689, 45, 418, 789, 339, 6247, 275, 13960, 339, 849, 63, 964, 32646, 275, 469, 267, 283, 808, 356, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 808, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 808, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 808, 358, 1660, 267, 283, 271, 87, 7, 520, 469, 283, 8595, 356, 437, 3652, 28533, 360, 271, 87, 63, 1403, 358, 1660, 267, 283, 72, 453, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 72, 453, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 72, 453, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 72, 453, 358, 1660, 267, 283, 2915, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 21999, 659, 673, 283, 827, 7, 520, 10195, 28533, 360, 21999, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 21999, 358, 1660, 267, 283, 11530, 7, 520, 469, 283, 8595, 7, 520, 437, 3652, 28533, 360, 11530, 659, 673, 283, 988, 7, 520, 8228, 28533, 360, 11530, 63, 71, 833, 659, 673, 283, 6458, 12, 694, 7, 520, 510, 581, 676, 262, 867, 55, 688, 28533, 360, 11530, 358, 221, 1660, 267, 283, 261, 13451, 7, 520, 469, 283, 8595, 7, 520, 644, 688, 51, 2406, 17400, 28533, 360, 11530, 659, 1993, 283, 988, 7, 520, 644, 688, 51, 2406, 4261, 28533, 360, 11530, 63, 71, 833, 659, 1993, 283, 5646, 7, 520, 644, 688, 51, 2406, 18285, 28533, 360, 11530, 358, 1660, 267, 283, 6322, 7, 520, 469, 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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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 ]
SGenheden/lammps
python/examples/viz_atomeye.py
3
1953
#!/usr/bin/env python -i # preceeding line should have path for Python on your machine # viz_atomeye.py # Purpose: viz running LAMMPS simulation via AtomEye # Syntax: viz_atomeye.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 from __future__ import print_function import sys,os # set this to point to AtomEye version 3 executable # first line if want AtomEye output to screen, 2nd line to file #ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530" ATOMEYE3 = "/home/sjplimp/tools/atomeye3/A3.i686-20060530 > atomeye.out" # parse command line argv = sys.argv if len(argv) != 4: print("Syntax: viz_atomeye.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 extended CFG format for AtomEye lmp.file(infile) lmp.command("thermo %d" % nfreq) lmp.command("dump python all cfg %d tmp.cfg.* id type xs ys zs" % 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: a = os.popen(ATOMEYE3,'w') a.write("load_config tmp.cfg.0\n") a.flush() # 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: a.write("load_config tmp.cfg.%d\n" % ntimestep) a.flush() 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, 292, 1377, 8048, 14, 647, 199, 3, 23177, 4070, 26, 373, 565, 3879, 29935, 1658, 51, 17625, 4799, 18840, 37, 8048, 199, 3, 18377, 26, 221, 373, 565, 63, 292, 1377, 8048, 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, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 12, 736, 199, 199, 3, 663, 642, 370, 2376, 370, 18840, 37, 8048, 1015, 650, 7286, 199, 3, 1642, 1004, 340, 2934, 18840, 37, 8048, 1072, 370, 6426, 12, 499, 977, 1004, 370, 570, 199, 3, 619, 47, 3635, 57, 37, 19, 275, 3286, 4219, 15, 83, 11538, 317, 311, 15, 2537, 15, 292, 1377, 8048, 19, 15, 33, 19, 14, 73, 10253, 13, 7968, 1717, 1216, 2, 199, 619, 47, 3635, 57, 37, 19, 275, 3286, 4219, 15, 83, 11538, 317, 311, 15, 2537, 15, 292, 1377, 8048, 19, 15, 33, 19, 14, 73, 10253, 13, 7968, 1717, 1216, 690, 282, 475, 278, 8048, 14, 548, 2, 199, 199, 3, 2198, 1414, 1004, 199, 199, 3020, 275, 984, 14, 3020, 199, 692, 822, 8, 3020, 9, 1137, 841, 26, 523, 870, 480, 16626, 26, 373, 565, 63, 292, 1377, 8048, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 531, 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, 9243, 10974, 1475, 367, 18840, 37, 8048, 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, 4810, 450, 68, 3529, 14, 4128, 2795, 1305, 730, 12965, 19205, 1315, 83, 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, 282, 275, 747, 14, 12207, 8, 619, 47, 3635, 57, 37, 19, 2584, 87, 358, 523, 282, 14, 952, 480, 912, 63, 888, 3529, 14, 4128, 14, 16, 60, 78, 531, 523, 282, 14, 4939, 342, 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, 282, 14, 952, 480, 912, 63, 888, 3529, 14, 4128, 4111, 68, 60, 78, 2, 450, 302, 521, 2926, 9, 272, 282, 14, 4939, 342, 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, 480, 15019, 450, 68, 734, 402, 450, 68, 557, 1259, 965, 2, 450, 334, 278, 12, 78, 24463, 395, 634, 311, 9, 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 ]
[ 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, 292, 1377, 8048, 14, 647, 199, 3, 23177, 4070, 26, 373, 565, 3879, 29935, 1658, 51, 17625, 4799, 18840, 37, 8048, 199, 3, 18377, 26, 221, 373, 565, 63, 292, 1377, 8048, 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, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 12, 736, 199, 199, 3, 663, 642, 370, 2376, 370, 18840, 37, 8048, 1015, 650, 7286, 199, 3, 1642, 1004, 340, 2934, 18840, 37, 8048, 1072, 370, 6426, 12, 499, 977, 1004, 370, 570, 199, 3, 619, 47, 3635, 57, 37, 19, 275, 3286, 4219, 15, 83, 11538, 317, 311, 15, 2537, 15, 292, 1377, 8048, 19, 15, 33, 19, 14, 73, 10253, 13, 7968, 1717, 1216, 2, 199, 619, 47, 3635, 57, 37, 19, 275, 3286, 4219, 15, 83, 11538, 317, 311, 15, 2537, 15, 292, 1377, 8048, 19, 15, 33, 19, 14, 73, 10253, 13, 7968, 1717, 1216, 690, 282, 475, 278, 8048, 14, 548, 2, 199, 199, 3, 2198, 1414, 1004, 199, 199, 3020, 275, 984, 14, 3020, 199, 692, 822, 8, 3020, 9, 1137, 841, 26, 523, 870, 480, 16626, 26, 373, 565, 63, 292, 1377, 8048, 14, 647, 315, 14, 17984, 13408, 653, 5646, 653, 5895, 531, 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, 9243, 10974, 1475, 367, 18840, 37, 8048, 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, 4810, 450, 68, 3529, 14, 4128, 2795, 1305, 730, 12965, 19205, 1315, 83, 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, 282, 275, 747, 14, 12207, 8, 619, 47, 3635, 57, 37, 19, 2584, 87, 358, 523, 282, 14, 952, 480, 912, 63, 888, 3529, 14, 4128, 14, 16, 60, 78, 531, 523, 282, 14, 4939, 342, 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, 282, 14, 952, 480, 912, 63, 888, 3529, 14, 4128, 4111, 68, 60, 78, 2, 450, 302, 521, 2926, 9, 272, 282, 14, 4939, 342, 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, 480, 15019, 450, 68, 734, 402, 450, 68, 557, 1259, 965, 2, 450, 334, 278, 12, 78, 24463, 395, 634, 311, 9, 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, 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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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 ]
chirilo/mozillians
vendor-local/lib/python/celery/db/models.py
14
2231
# -*- coding: utf-8 -*- from __future__ import absolute_import from datetime import datetime import sqlalchemy as sa from .. import states from .session import ResultModelBase # See docstring of a805d4bd for an explanation for this workaround ;) if sa.__version__.startswith('0.5'): from .dfd042c7 import PickleType else: from .a805d4bd import PickleType # noqa class Task(ResultModelBase): """Task result/status.""" __tablename__ = "celery_taskmeta" __table_args__ = {"sqlite_autoincrement": True} id = sa.Column(sa.Integer, sa.Sequence("task_id_sequence"), primary_key=True, autoincrement=True) task_id = sa.Column(sa.String(255), unique=True) status = sa.Column(sa.String(50), default=states.PENDING) result = sa.Column(PickleType, nullable=True) date_done = sa.Column(sa.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=True) traceback = sa.Column(sa.Text, nullable=True) def __init__(self, task_id): self.task_id = task_id def to_dict(self): return {"task_id": self.task_id, "status": self.status, "result": self.result, "traceback": self.traceback, "date_done": self.date_done} def __repr__(self): return "<Task %s state: %s>" % (self.task_id, self.status) class TaskSet(ResultModelBase): """TaskSet result""" __tablename__ = "celery_tasksetmeta" __table_args__ = {"sqlite_autoincrement": True} id = sa.Column(sa.Integer, sa.Sequence("taskset_id_sequence"), autoincrement=True, primary_key=True) taskset_id = sa.Column(sa.String(255), unique=True) result = sa.Column(sa.PickleType, nullable=True) date_done = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=True) def __init__(self, taskset_id, result): self.taskset_id = taskset_id self.result = result def to_dict(self): return {"taskset_id": self.taskset_id, "result": self.result, "date_done": self.date_done} def __repr__(self): return u"<TaskSet: %s>" % (self.taskset_id, )
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 2197, 492, 2197, 199, 199, 646, 8335, 465, 2937, 199, 199, 504, 2508, 492, 6363, 199, 199, 504, 1275, 1730, 492, 10695, 1685, 1563, 199, 199, 3, 1666, 9214, 402, 282, 13027, 68, 20, 3691, 367, 376, 17531, 367, 642, 18092, 8700, 9, 199, 692, 2937, 855, 1023, 4343, 2460, 360, 16, 14, 21, 735, 272, 687, 1275, 1587, 68, 13011, 67, 23, 492, 31732, 804, 199, 2836, 26, 272, 687, 1275, 65, 13027, 68, 20, 3691, 492, 31732, 804, 221, 327, 8151, 421, 199, 533, 8495, 8, 2889, 1685, 1563, 304, 272, 408, 4476, 754, 15, 1205, 1041, 272, 636, 10983, 363, 275, 298, 23593, 63, 1765, 2024, 2, 272, 636, 1224, 63, 589, 363, 275, 2420, 10659, 63, 27755, 582, 715, 93, 339, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 2937, 14, 5826, 480, 1765, 63, 344, 63, 4041, 1288, 673, 5062, 63, 498, 29, 549, 12, 673, 32497, 29, 549, 9, 272, 2120, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 2299, 395, 3747, 29, 549, 9, 272, 2004, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 1400, 395, 849, 29, 4981, 14, 21243, 9, 272, 754, 275, 2937, 14, 4547, 8, 12755, 804, 12, 7854, 29, 549, 9, 272, 1434, 63, 4456, 275, 2937, 14, 4547, 8, 2231, 14, 3926, 12, 849, 29, 2083, 14, 10779, 12, 2432, 641, 873, 29, 2083, 14, 10779, 12, 7854, 29, 549, 9, 272, 5190, 275, 2937, 14, 4547, 8, 2231, 14, 1872, 12, 7854, 29, 549, 9, 339, 347, 636, 826, 721, 277, 12, 2120, 63, 344, 304, 267, 291, 14, 1765, 63, 344, 275, 2120, 63, 344, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 2420, 1765, 63, 344, 582, 291, 14, 1765, 63, 344, 12, 355, 298, 1205, 582, 291, 14, 1205, 12, 355, 298, 1099, 582, 291, 14, 1099, 12, 355, 298, 6894, 582, 291, 14, 6894, 12, 355, 298, 602, 63, 4456, 582, 291, 14, 602, 63, 4456, 93, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 4476, 450, 83, 1174, 26, 450, 83, 4335, 450, 334, 277, 14, 1765, 63, 344, 12, 291, 14, 1205, 9, 421, 199, 533, 8495, 1084, 8, 2889, 1685, 1563, 304, 272, 408, 4476, 1084, 754, 624, 272, 636, 10983, 363, 275, 298, 23593, 63, 1765, 409, 2024, 2, 272, 636, 1224, 63, 589, 363, 275, 2420, 10659, 63, 27755, 582, 715, 93, 339, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 2937, 14, 5826, 480, 1765, 409, 63, 344, 63, 4041, 1288, 355, 32497, 29, 549, 12, 5062, 63, 498, 29, 549, 9, 272, 2120, 409, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 2299, 395, 3747, 29, 549, 9, 272, 754, 275, 2937, 14, 4547, 8, 2231, 14, 12755, 804, 12, 7854, 29, 549, 9, 272, 1434, 63, 4456, 275, 2937, 14, 4547, 8, 2231, 14, 3926, 12, 849, 29, 2083, 14, 10779, 12, 2432, 7854, 29, 549, 9, 339, 347, 636, 826, 721, 277, 12, 2120, 409, 63, 344, 12, 754, 304, 267, 291, 14, 1765, 409, 63, 344, 275, 2120, 409, 63, 344, 267, 291, 14, 1099, 275, 754, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 2420, 1765, 409, 63, 344, 582, 291, 14, 1765, 409, 63, 344, 12, 355, 298, 1099, 582, 291, 14, 1099, 12, 355, 298, 602, 63, 4456, 582, 291, 14, 602, 63, 4456, 93, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 399, 17030, 4476, 1084, 26, 450, 83, 4335, 450, 334, 277, 14, 1765, 409, 63, 344, 12, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 2197, 492, 2197, 199, 199, 646, 8335, 465, 2937, 199, 199, 504, 2508, 492, 6363, 199, 199, 504, 1275, 1730, 492, 10695, 1685, 1563, 199, 199, 3, 1666, 9214, 402, 282, 13027, 68, 20, 3691, 367, 376, 17531, 367, 642, 18092, 8700, 9, 199, 692, 2937, 855, 1023, 4343, 2460, 360, 16, 14, 21, 735, 272, 687, 1275, 1587, 68, 13011, 67, 23, 492, 31732, 804, 199, 2836, 26, 272, 687, 1275, 65, 13027, 68, 20, 3691, 492, 31732, 804, 221, 327, 8151, 421, 199, 533, 8495, 8, 2889, 1685, 1563, 304, 272, 408, 4476, 754, 15, 1205, 1041, 272, 636, 10983, 363, 275, 298, 23593, 63, 1765, 2024, 2, 272, 636, 1224, 63, 589, 363, 275, 2420, 10659, 63, 27755, 582, 715, 93, 339, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 2937, 14, 5826, 480, 1765, 63, 344, 63, 4041, 1288, 673, 5062, 63, 498, 29, 549, 12, 673, 32497, 29, 549, 9, 272, 2120, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 2299, 395, 3747, 29, 549, 9, 272, 2004, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 1400, 395, 849, 29, 4981, 14, 21243, 9, 272, 754, 275, 2937, 14, 4547, 8, 12755, 804, 12, 7854, 29, 549, 9, 272, 1434, 63, 4456, 275, 2937, 14, 4547, 8, 2231, 14, 3926, 12, 849, 29, 2083, 14, 10779, 12, 2432, 641, 873, 29, 2083, 14, 10779, 12, 7854, 29, 549, 9, 272, 5190, 275, 2937, 14, 4547, 8, 2231, 14, 1872, 12, 7854, 29, 549, 9, 339, 347, 636, 826, 721, 277, 12, 2120, 63, 344, 304, 267, 291, 14, 1765, 63, 344, 275, 2120, 63, 344, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 2420, 1765, 63, 344, 582, 291, 14, 1765, 63, 344, 12, 355, 298, 1205, 582, 291, 14, 1205, 12, 355, 298, 1099, 582, 291, 14, 1099, 12, 355, 298, 6894, 582, 291, 14, 6894, 12, 355, 298, 602, 63, 4456, 582, 291, 14, 602, 63, 4456, 93, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 4476, 450, 83, 1174, 26, 450, 83, 4335, 450, 334, 277, 14, 1765, 63, 344, 12, 291, 14, 1205, 9, 421, 199, 533, 8495, 1084, 8, 2889, 1685, 1563, 304, 272, 408, 4476, 1084, 754, 624, 272, 636, 10983, 363, 275, 298, 23593, 63, 1765, 409, 2024, 2, 272, 636, 1224, 63, 589, 363, 275, 2420, 10659, 63, 27755, 582, 715, 93, 339, 1305, 275, 2937, 14, 4547, 8, 2231, 14, 2674, 12, 2937, 14, 5826, 480, 1765, 409, 63, 344, 63, 4041, 1288, 355, 32497, 29, 549, 12, 5062, 63, 498, 29, 549, 9, 272, 2120, 409, 63, 344, 275, 2937, 14, 4547, 8, 2231, 14, 1558, 8, 2299, 395, 3747, 29, 549, 9, 272, 754, 275, 2937, 14, 4547, 8, 2231, 14, 12755, 804, 12, 7854, 29, 549, 9, 272, 1434, 63, 4456, 275, 2937, 14, 4547, 8, 2231, 14, 3926, 12, 849, 29, 2083, 14, 10779, 12, 2432, 7854, 29, 549, 9, 339, 347, 636, 826, 721, 277, 12, 2120, 409, 63, 344, 12, 754, 304, 267, 291, 14, 1765, 409, 63, 344, 275, 2120, 409, 63, 344, 267, 291, 14, 1099, 275, 754, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 2420, 1765, 409, 63, 344, 582, 291, 14, 1765, 409, 63, 344, 12, 355, 298, 1099, 582, 291, 14, 1099, 12, 355, 298, 602, 63, 4456, 582, 291, 14, 602, 63, 4456, 93, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 399, 17030, 4476, 1084, 26, 450, 83, 4335, 450, 334, 277, 14, 1765, 409, 63, 344, 12, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
DannyVim/shadowsocks
shadowsocks/local.py
1015
2248
#!/usr/bin/env python # -*- coding: utf-8 -*- # # 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 sys import os import logging import signal sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../')) from shadowsocks import shell, daemon, eventloop, tcprelay, udprelay, asyncdns def main(): shell.check_python() # fix py2exe if hasattr(sys, "frozen") and sys.frozen in \ ("windows_exe", "console_exe"): p = os.path.dirname(os.path.abspath(sys.executable)) os.chdir(p) config = shell.get_config(True) daemon.daemon_exec(config) try: logging.info("starting local at %s:%d" % (config['local_address'], config['local_port'])) dns_resolver = asyncdns.DNSResolver() tcp_server = tcprelay.TCPRelay(config, dns_resolver, True) udp_server = udprelay.UDPRelay(config, dns_resolver, True) loop = eventloop.EventLoop() dns_resolver.add_to_loop(loop) tcp_server.add_to_loop(loop) udp_server.add_to_loop(loop) def handler(signum, _): logging.warn('received SIGQUIT, doing graceful shutting down..') tcp_server.close(next_tick=True) udp_server.close(next_tick=True) signal.signal(getattr(signal, 'SIGQUIT', signal.SIGTERM), handler) def int_handler(signum, _): sys.exit(1) signal.signal(signal.SIGINT, int_handler) daemon.set_user(config.get('user', None)) loop.run() except Exception as e: shell.print_exception(e) sys.exit(1) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 984, 199, 646, 747, 199, 646, 2050, 199, 646, 4673, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 1333, 199, 504, 15084, 21234, 492, 5218, 12, 11128, 12, 1566, 3813, 12, 14415, 657, 817, 12, 26759, 657, 817, 12, 5316, 5797, 421, 199, 318, 2446, 837, 272, 5218, 14, 1074, 63, 1548, 342, 339, 327, 5325, 1134, 18, 5803, 272, 340, 2688, 8, 1274, 12, 298, 11202, 531, 436, 984, 14, 11202, 315, 971, 288, 1689, 8258, 63, 5803, 401, 298, 6614, 63, 5803, 2349, 267, 299, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 5904, 430, 267, 747, 14, 8563, 8, 80, 9, 339, 1101, 275, 5218, 14, 362, 63, 888, 8, 549, 9, 339, 11128, 14, 10824, 63, 1628, 8, 888, 9, 339, 862, 26, 267, 2050, 14, 815, 480, 15769, 2257, 737, 450, 83, 2689, 68, 2, 450, 2151, 334, 888, 459, 1832, 63, 1562, 995, 1101, 459, 1832, 63, 719, 5156, 398, 6715, 63, 7717, 275, 5316, 5797, 14, 12323, 12407, 342, 267, 14719, 63, 1000, 275, 14415, 657, 817, 14, 9735, 5640, 1187, 8, 888, 12, 6715, 63, 7717, 12, 715, 9, 267, 18419, 63, 1000, 275, 26759, 657, 817, 14, 3383, 3311, 352, 1187, 8, 888, 12, 6715, 63, 7717, 12, 715, 9, 267, 4438, 275, 1566, 3813, 14, 2390, 7382, 342, 267, 6715, 63, 7717, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 267, 14719, 63, 1000, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 267, 18419, 63, 1000, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 398, 347, 3016, 8, 1037, 453, 12, 27574, 288, 2050, 14, 4050, 360, 9226, 15522, 2328, 649, 12, 9689, 19756, 1893, 24761, 1337, 3224, 703, 358, 288, 14719, 63, 1000, 14, 1600, 8, 2184, 63, 8284, 29, 549, 9, 288, 18419, 63, 1000, 14, 1600, 8, 2184, 63, 8284, 29, 549, 9, 267, 4673, 14, 4653, 8, 5675, 8, 4653, 12, 283, 7864, 2328, 649, 297, 4673, 14, 29190, 395, 3016, 9, 398, 347, 1109, 63, 2232, 8, 1037, 453, 12, 27574, 288, 984, 14, 2224, 8, 17, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 1109, 63, 2232, 9, 398, 11128, 14, 409, 63, 751, 8, 888, 14, 362, 360, 751, 297, 488, 430, 267, 4438, 14, 1065, 342, 272, 871, 2186, 465, 325, 26, 267, 5218, 14, 1361, 63, 1971, 8, 69, 9, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 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, 984, 199, 646, 747, 199, 646, 2050, 199, 646, 4673, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 1333, 199, 504, 15084, 21234, 492, 5218, 12, 11128, 12, 1566, 3813, 12, 14415, 657, 817, 12, 26759, 657, 817, 12, 5316, 5797, 421, 199, 318, 2446, 837, 272, 5218, 14, 1074, 63, 1548, 342, 339, 327, 5325, 1134, 18, 5803, 272, 340, 2688, 8, 1274, 12, 298, 11202, 531, 436, 984, 14, 11202, 315, 971, 288, 1689, 8258, 63, 5803, 401, 298, 6614, 63, 5803, 2349, 267, 299, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 5904, 430, 267, 747, 14, 8563, 8, 80, 9, 339, 1101, 275, 5218, 14, 362, 63, 888, 8, 549, 9, 339, 11128, 14, 10824, 63, 1628, 8, 888, 9, 339, 862, 26, 267, 2050, 14, 815, 480, 15769, 2257, 737, 450, 83, 2689, 68, 2, 450, 2151, 334, 888, 459, 1832, 63, 1562, 995, 1101, 459, 1832, 63, 719, 5156, 398, 6715, 63, 7717, 275, 5316, 5797, 14, 12323, 12407, 342, 267, 14719, 63, 1000, 275, 14415, 657, 817, 14, 9735, 5640, 1187, 8, 888, 12, 6715, 63, 7717, 12, 715, 9, 267, 18419, 63, 1000, 275, 26759, 657, 817, 14, 3383, 3311, 352, 1187, 8, 888, 12, 6715, 63, 7717, 12, 715, 9, 267, 4438, 275, 1566, 3813, 14, 2390, 7382, 342, 267, 6715, 63, 7717, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 267, 14719, 63, 1000, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 267, 18419, 63, 1000, 14, 525, 63, 475, 63, 3813, 8, 3813, 9, 398, 347, 3016, 8, 1037, 453, 12, 27574, 288, 2050, 14, 4050, 360, 9226, 15522, 2328, 649, 12, 9689, 19756, 1893, 24761, 1337, 3224, 703, 358, 288, 14719, 63, 1000, 14, 1600, 8, 2184, 63, 8284, 29, 549, 9, 288, 18419, 63, 1000, 14, 1600, 8, 2184, 63, 8284, 29, 549, 9, 267, 4673, 14, 4653, 8, 5675, 8, 4653, 12, 283, 7864, 2328, 649, 297, 4673, 14, 29190, 395, 3016, 9, 398, 347, 1109, 63, 2232, 8, 1037, 453, 12, 27574, 288, 984, 14, 2224, 8, 17, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 1109, 63, 2232, 9, 398, 11128, 14, 409, 63, 751, 8, 888, 14, 362, 360, 751, 297, 488, 430, 267, 4438, 14, 1065, 342, 272, 871, 2186, 465, 325, 26, 267, 5218, 14, 1361, 63, 1971, 8, 69, 9, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
BehavioralInsightsTeam/edx-platform
lms/djangoapps/certificates/management/commands/cert_whitelist.py
12
3674
""" Management command which sets or gets the certificate whitelist for a given user/course """ from __future__ import print_function from django.contrib.auth.models import User from django.core.management.base import BaseCommand, CommandError from opaque_keys.edx.keys import CourseKey from lms.djangoapps.certificates.models import CertificateWhitelist def get_user_from_identifier(identifier): """ This function takes the string identifier and fetch relevant user object from database """ identifier = identifier.strip() if '@' in identifier: user = User.objects.get(email=identifier) else: user = User.objects.get(username=identifier) return user class Command(BaseCommand): """ Management command to set or get the certificate whitelist for a given user(s)/course """ help = """ Sets or gets the certificate whitelist for a given user(s)/course Add a user or list of users to the whitelist for a course $ ... cert_whitelist --add joe -c "MITx/6.002x/2012_Fall" OR $ ... cert_whitelist --add joe,jenny,tom,jerry -c "MITx/6.002x/2012_Fall" Remove a user or list of users from the whitelist for a course $ ... cert_whitelist --del joe -c "MITx/6.002x/2012_Fall" OR $ ... cert_whitelist --del joe,jenny,tom,jerry -c "MITx/6.002x/2012_Fall" Print out who is whitelisted for a course $ ... cert_whitelist -c "MITx/6.002x/2012_Fall" """ def add_arguments(self, parser): parser.add_argument( '-a', '--add', metavar='USER', dest='add', default=False, help='user or list of users to add to the certificate whitelist' ) parser.add_argument( '-d', '--del', metavar='USER', dest='del', default=False, help='user or list of users to remove from the certificate whitelist' ) parser.add_argument( '-c', '--course-id', metavar='COURSE_ID', dest='course_id', default=False, help="course id to query" ) def handle(self, *args, **options): course_id = options['course_id'] if not course_id: raise CommandError("You must specify a course-id") def update_user_whitelist(username, add=True): """ Update the status of whitelist user(s) """ user = get_user_from_identifier(username) cert_whitelist, _created = CertificateWhitelist.objects.get_or_create( user=user, course_id=course ) cert_whitelist.whitelist = add cert_whitelist.save() # try to parse the serialized course key into a CourseKey course = CourseKey.from_string(course_id) if options['add'] and options['del']: raise CommandError("Either remove or add a user, not both") if options['add'] or options['del']: user_str = options['add'] or options['del'] add_to_whitelist = True if options['add'] else False users_list = user_str.split(",") for username in users_list: if username.strip(): update_user_whitelist(username, add=add_to_whitelist) whitelist = CertificateWhitelist.objects.filter(course_id=course) wl_users = '\n'.join( "{u.user.username} {u.user.email} {u.whitelist}".format(u=u) for u in whitelist ) print("User whitelist for course {0}:\n{1}".format(course_id, wl_users))
agpl-3.0
[ 624, 199, 14552, 1414, 1314, 5951, 503, 7545, 314, 5897, 22671, 367, 282, 1627, 199, 751, 15, 1972, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 199, 504, 21577, 14, 16432, 14, 16159, 14, 992, 492, 12904, 19803, 513, 421, 199, 318, 664, 63, 751, 63, 504, 63, 5364, 8, 5364, 304, 272, 408, 1362, 961, 805, 6181, 314, 1059, 5148, 436, 5267, 12082, 922, 909, 687, 3050, 272, 408, 272, 5148, 275, 5148, 14, 1913, 342, 272, 340, 22143, 315, 5148, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2123, 29, 5364, 9, 272, 587, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 5364, 9, 272, 372, 922, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 272, 8259, 1414, 370, 663, 503, 664, 314, 5897, 22671, 272, 367, 282, 1627, 922, 8, 83, 2447, 1972, 272, 408, 339, 1720, 275, 408, 272, 10729, 503, 7545, 314, 5897, 22671, 367, 282, 1627, 272, 922, 8, 83, 2447, 1972, 398, 2654, 282, 922, 503, 769, 402, 4390, 370, 314, 22671, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 1553, 525, 5225, 69, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 267, 1549, 267, 2672, 2263, 6250, 63, 14189, 1553, 525, 5225, 69, 12, 74, 287, 9745, 12, 3151, 12, 74, 281, 651, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 398, 5852, 282, 922, 503, 769, 402, 4390, 687, 314, 22671, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 1553, 2264, 5225, 69, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 267, 1549, 267, 2672, 2263, 6250, 63, 14189, 1553, 2264, 5225, 69, 12, 74, 287, 9745, 12, 3151, 12, 74, 281, 651, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 398, 9101, 734, 3963, 365, 10424, 15023, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 339, 408, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 65, 297, 2850, 525, 297, 288, 8214, 534, 3791, 297, 288, 2053, 534, 525, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 751, 503, 769, 402, 4390, 370, 1050, 370, 314, 5897, 22671, 7, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 68, 297, 2850, 2264, 297, 288, 8214, 534, 3791, 297, 288, 2053, 534, 2264, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 751, 503, 769, 402, 4390, 370, 2813, 687, 314, 5897, 22671, 7, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 67, 297, 2850, 1972, 13, 344, 297, 288, 8214, 534, 15552, 63, 998, 297, 288, 2053, 534, 1972, 63, 344, 297, 288, 849, 29, 797, 12, 288, 1720, 628, 1972, 1305, 370, 1827, 2, 267, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 2518, 63, 344, 275, 1511, 459, 1972, 63, 344, 418, 267, 340, 440, 2518, 63, 344, 26, 288, 746, 14393, 480, 5556, 1471, 4165, 282, 2518, 13, 344, 531, 398, 347, 1678, 63, 751, 63, 14189, 8, 2473, 12, 1050, 29, 549, 304, 288, 408, 288, 6162, 314, 2004, 402, 22671, 922, 8, 83, 9, 288, 408, 288, 922, 275, 664, 63, 751, 63, 504, 63, 5364, 8, 2473, 9, 288, 6250, 63, 14189, 12, 485, 3966, 275, 12904, 19803, 513, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 355, 922, 29, 751, 12, 2518, 63, 344, 29, 1972, 288, 776, 288, 6250, 63, 14189, 14, 14189, 275, 1050, 288, 6250, 63, 14189, 14, 2117, 342, 398, 327, 862, 370, 2198, 314, 6380, 2518, 790, 1901, 282, 22574, 267, 2518, 275, 22574, 14, 504, 63, 875, 8, 1972, 63, 344, 9, 398, 340, 1511, 459, 525, 418, 436, 1511, 459, 2264, 2565, 288, 746, 14393, 480, 37, 1711, 2813, 503, 1050, 282, 922, 12, 440, 3865, 531, 398, 340, 1511, 459, 525, 418, 503, 1511, 459, 2264, 2565, 288, 922, 63, 495, 275, 1511, 459, 525, 418, 503, 1511, 459, 2264, 418, 288, 1050, 63, 475, 63, 14189, 275, 715, 340, 1511, 459, 525, 418, 587, 756, 288, 4390, 63, 513, 275, 922, 63, 495, 14, 1294, 20324, 288, 367, 3434, 315, 4390, 63, 513, 26, 355, 340, 3434, 14, 1913, 837, 490, 1678, 63, 751, 63, 14189, 8, 2473, 12, 1050, 29, 525, 63, 475, 63, 14189, 9, 398, 22671, 275, 12904, 19803, 513, 14, 1462, 14, 1541, 8, 1972, 63, 344, 29, 1972, 9, 267, 336, 76, 63, 3707, 275, 1557, 78, 1370, 904, 8, 288, 5310, 85, 14, 751, 14, 2473, 93, 469, 85, 14, 751, 14, 2123, 93, 469, 85, 14, 14189, 5469, 908, 8, 85, 29, 85, 9, 288, 367, 399, 315, 22671, 267, 776, 267, 870, 480, 1899, 22671, 367, 2518, 469, 16, 93, 3427, 78, 91, 17, 5469, 908, 8, 1972, 63, 344, 12, 336, 76, 63, 3707, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 14552, 1414, 1314, 5951, 503, 7545, 314, 5897, 22671, 367, 282, 1627, 199, 751, 15, 1972, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 199, 504, 21577, 14, 16432, 14, 16159, 14, 992, 492, 12904, 19803, 513, 421, 199, 318, 664, 63, 751, 63, 504, 63, 5364, 8, 5364, 304, 272, 408, 1362, 961, 805, 6181, 314, 1059, 5148, 436, 5267, 12082, 922, 909, 687, 3050, 272, 408, 272, 5148, 275, 5148, 14, 1913, 342, 272, 340, 22143, 315, 5148, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2123, 29, 5364, 9, 272, 587, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2473, 29, 5364, 9, 272, 372, 922, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 272, 8259, 1414, 370, 663, 503, 664, 314, 5897, 22671, 272, 367, 282, 1627, 922, 8, 83, 2447, 1972, 272, 408, 339, 1720, 275, 408, 272, 10729, 503, 7545, 314, 5897, 22671, 367, 282, 1627, 272, 922, 8, 83, 2447, 1972, 398, 2654, 282, 922, 503, 769, 402, 4390, 370, 314, 22671, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 1553, 525, 5225, 69, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 267, 1549, 267, 2672, 2263, 6250, 63, 14189, 1553, 525, 5225, 69, 12, 74, 287, 9745, 12, 3151, 12, 74, 281, 651, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 398, 5852, 282, 922, 503, 769, 402, 4390, 687, 314, 22671, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 1553, 2264, 5225, 69, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 267, 1549, 267, 2672, 2263, 6250, 63, 14189, 1553, 2264, 5225, 69, 12, 74, 287, 9745, 12, 3151, 12, 74, 281, 651, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 398, 9101, 734, 3963, 365, 10424, 15023, 367, 282, 2518, 398, 2672, 2263, 6250, 63, 14189, 446, 67, 298, 13965, 88, 15, 22, 14, 7432, 88, 15, 7409, 63, 31354, 2, 339, 408, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 65, 297, 2850, 525, 297, 288, 8214, 534, 3791, 297, 288, 2053, 534, 525, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 751, 503, 769, 402, 4390, 370, 1050, 370, 314, 5897, 22671, 7, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 68, 297, 2850, 2264, 297, 288, 8214, 534, 3791, 297, 288, 2053, 534, 2264, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 751, 503, 769, 402, 4390, 370, 2813, 687, 314, 5897, 22671, 7, 267, 776, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 67, 297, 2850, 1972, 13, 344, 297, 288, 8214, 534, 15552, 63, 998, 297, 288, 2053, 534, 1972, 63, 344, 297, 288, 849, 29, 797, 12, 288, 1720, 628, 1972, 1305, 370, 1827, 2, 267, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 2518, 63, 344, 275, 1511, 459, 1972, 63, 344, 418, 267, 340, 440, 2518, 63, 344, 26, 288, 746, 14393, 480, 5556, 1471, 4165, 282, 2518, 13, 344, 531, 398, 347, 1678, 63, 751, 63, 14189, 8, 2473, 12, 1050, 29, 549, 304, 288, 408, 288, 6162, 314, 2004, 402, 22671, 922, 8, 83, 9, 288, 408, 288, 922, 275, 664, 63, 751, 63, 504, 63, 5364, 8, 2473, 9, 288, 6250, 63, 14189, 12, 485, 3966, 275, 12904, 19803, 513, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 355, 922, 29, 751, 12, 2518, 63, 344, 29, 1972, 288, 776, 288, 6250, 63, 14189, 14, 14189, 275, 1050, 288, 6250, 63, 14189, 14, 2117, 342, 398, 327, 862, 370, 2198, 314, 6380, 2518, 790, 1901, 282, 22574, 267, 2518, 275, 22574, 14, 504, 63, 875, 8, 1972, 63, 344, 9, 398, 340, 1511, 459, 525, 418, 436, 1511, 459, 2264, 2565, 288, 746, 14393, 480, 37, 1711, 2813, 503, 1050, 282, 922, 12, 440, 3865, 531, 398, 340, 1511, 459, 525, 418, 503, 1511, 459, 2264, 2565, 288, 922, 63, 495, 275, 1511, 459, 525, 418, 503, 1511, 459, 2264, 418, 288, 1050, 63, 475, 63, 14189, 275, 715, 340, 1511, 459, 525, 418, 587, 756, 288, 4390, 63, 513, 275, 922, 63, 495, 14, 1294, 20324, 288, 367, 3434, 315, 4390, 63, 513, 26, 355, 340, 3434, 14, 1913, 837, 490, 1678, 63, 751, 63, 14189, 8, 2473, 12, 1050, 29, 525, 63, 475, 63, 14189, 9, 398, 22671, 275, 12904, 19803, 513, 14, 1462, 14, 1541, 8, 1972, 63, 344, 29, 1972, 9, 267, 336, 76, 63, 3707, 275, 1557, 78, 1370, 904, 8, 288, 5310, 85, 14, 751, 14, 2473, 93, 469, 85, 14, 751, 14, 2123, 93, 469, 85, 14, 14189, 5469, 908, 8, 85, 29, 85, 9, 288, 367, 399, 315, 22671, 267, 776, 267, 870, 480, 1899, 22671, 367, 2518, 469, 16, 93, 3427, 78, 91, 17, 5469, 908, 8, 1972, 63, 344, 12, 336, 76, 63, 3707, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
antgonza/qiime
scripts/validate_mapping_file.py
15
8042
#!/usr/bin/env python from __future__ import division __author__ = "William Walters" __copyright__ = "Copyright 2011, The QIIME Project" __credits__ = ["William Walters"] __license__ = "GPL" __version__ = "1.9.1-dev" __maintainer__ = "William Walters" __email__ = "William.A.Walters@colorado.edu" from string import letters, digits from qiime.util import parse_command_line_parameters, get_options_lookup,\ make_option, create_dir from qiime.check_id_map import check_mapping_file options_lookup = get_options_lookup() script_info = {} script_info['brief_description'] = """Checks user's metadata mapping file for \ required data, valid format""" script_info['script_description'] = """Specifically, we check that: - The BarcodeSequence, LinkerPrimerSequences, and ReversePrimer fields have valid IUPAC DNA characters, and BarcodeSequence characters are non-degenerate (error) - The SampleID, BarcodeSequence, LinkerPrimerSequence, and Description headers are present. (error) - There are not duplicate header fields (error) - There are not duplicate barcodes (error) - Barcodes are of the same length. Suppressed when variable_len_barcode flag is passed (warning) - The headers do not contain invalid characters (alphanumeric and underscore only) (warning) - The data fields do not contain invalid characters (alphanumeric, underscore, space, and +-%./:,; characters) (warning) - SampleID fields are MIENS compliant (only alphanumeric and . characters). (warning) - There are no duplicates when the primer and variable length barcodes are appended (error) - There are no duplicates when barcodes and added demultiplex fields (-j option) are combined (error) - Data fields are not found beyond the Description column (warning) Details about the metadata mapping file format can be found here: http://www.qiime.org/documentation/file_formats.html#metadata-mapping-files Errors and warnings are saved to a log file. Errors can be caused by problems with the headers, invalid characters in barcodes or primers, or by duplications in SampleIDs or barcodes. Warnings can arise from invalid characters and variable length barcodes that are not specified with the --variable_len_barcode. Warnings will contain a reference to the cell (row,column) that the warning arose from. In addition to the log file, a "corrected_mapping" file will be created. Any invalid characters will be replaced with '.' characters in the SampleID fields (to enforce MIENS compliance) and text in other data fields will be replaced with the character specified by the -c parameter, which is an underscore "_" by default. A html file will be created as well, which will show locations of warnings and errors, highlighted in yellow and red respectively. If no errors or warnings were present the file will display a message saying such. Header errors can mask other errors, so these should be corrected first. If pooled primers are used, separate with a comma. For instance, a pooled set of three 27f primers (used to increase taxonomic coverage) could be specified in the LinkerPrimerSequence fields as such: AGGGTTCGATTCTGGCTCAG,AGAGTTTGATCCTGGCTTAG,AGAATTTGATCTTGGTTCAG """ script_info['script_usage'] = [] script_info['script_usage'].append(("""Example:""", """Check the Fasting_Map.txt \ mapping file for problems, supplying the required mapping file, and output \ the results in the validate_mapping_file_output directory""", """%prog -m \ Fasting_Map.txt -o validate_mapping_file_output""")) script_info['output_description'] = """A log file, html file, and \ corrected_mapping.txt file will be written to the current output directory.""" script_info['required_options'] = [ make_option('-m', '--mapping_fp', type='existing_filepath', help='Metadata mapping filepath') ] script_info['optional_options'] = [ make_option('-o', '--output_dir', type='new_dirpath', help='Required output directory for log file, corrected mapping ' + 'file, and html file. [default: %default]', default="./"), make_option('-v', '--verbose', help='Enable printing information to standard out ' + '[default: %default]', default=True, action='store_false'), make_option('-c', '--char_replace', type='string', help='Changes the default character used to replace invalid ' + 'characters found in the mapping file. Must be a valid character (' + 'alphanumeric, period, or underscore).' + '[default: %default]', default="_"), make_option('-b', '--not_barcoded', action='store_true', default=False, help='Use -b if barcodes are not present. BarcodeSequence header ' + 'still required. [default: %default]'), make_option('-B', '--variable_len_barcodes', action='store_true', default=False, help='Use -B if variable length barcodes are present to suppress ' + 'warnings about barcodes of unequal length. [default: %default]'), make_option('-p', '--disable_primer_check', action='store_true', default=False, help='Use -p to disable checks for primers. LinkerPrimerSequence ' + 'header still required. [default: %default]'), make_option('-j', '--added_demultiplex_field', type='string', help='Use -j to add a field to use in the mapping file as ' + 'additional demultiplexing (can be used with or without barcodes). ' + 'All combinations ' + 'of barcodes/primers and the these fields must be unique. The ' + 'fields must contain values that can be parsed from the fasta labels ' + 'such as "plate=R_2008_12_09". In this case, "plate" would be the ' + 'column header and "R_2008_12_09" would be the field data (minus ' + 'quotes) in the mapping file. To use the run prefix from the fasta ' + 'label, such as ">FLP3FBN01ELBSX", where "FLP3FBN01" is generated ' + 'from the run ID, use "-j run_prefix" and set the run prefix to ' + 'be used as the data under the column header "run_prefix". ' + ' [default: %default]'), make_option('-s', '--suppress_html', action='store_true', default=False, help='Use -s to disable html file generation, can be useful for ' + 'extremely large mapping files. [default: %default]'), ] script_info['version'] = __version__ def main(): option_parser, opts, args =\ parse_command_line_parameters(suppress_verbose=True, **script_info) mapping_fp = opts.mapping_fp has_barcodes = not opts.not_barcoded variable_len_barcodes = opts.variable_len_barcodes output_dir = opts.output_dir + "/" char_replace = opts.char_replace verbose = opts.verbose disable_primer_check = opts.disable_primer_check added_demultiplex_field = opts.added_demultiplex_field suppress_html = opts.suppress_html # Create output directory, check path/access to mapping file create_dir(output_dir) # Test for valid replacement characters valid_replacement_chars = digits + letters + "_" + "." if char_replace not in valid_replacement_chars: option_parser.error('-c option requires alphanumeric, period, or ' + 'underscore character.') if len(char_replace) != 1: option_parser.error('-c parameter must be a single character.') check_mapping_file(mapping_fp, output_dir, has_barcodes, char_replace, verbose, variable_len_barcodes, disable_primer_check, added_demultiplex_field, suppress_html) if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 363, 2502, 363, 275, 298, 55, 8148, 455, 644, 31185, 2, 199, 363, 7307, 363, 275, 298, 7384, 7760, 12, 710, 1413, 41, 3465, 7290, 2, 199, 363, 22461, 363, 275, 2097, 55, 8148, 455, 644, 31185, 937, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 25, 14, 17, 13, 2374, 2, 199, 363, 26665, 363, 275, 298, 55, 8148, 455, 644, 31185, 2, 199, 363, 2123, 363, 275, 298, 55, 8148, 455, 14, 33, 14, 55, 31185, 32, 2326, 5129, 14, 8654, 2, 199, 199, 504, 1059, 492, 14435, 12, 7576, 199, 199, 504, 31402, 1036, 14, 1974, 492, 2198, 63, 1531, 63, 604, 63, 3214, 12, 664, 63, 1419, 63, 3892, 4202, 272, 1852, 63, 1422, 12, 1218, 63, 694, 199, 504, 31402, 1036, 14, 1074, 63, 344, 63, 1130, 492, 1104, 63, 4745, 63, 493, 199, 199, 1419, 63, 3892, 275, 664, 63, 1419, 63, 3892, 342, 199, 1579, 63, 815, 275, 1052, 199, 1579, 63, 815, 459, 19127, 63, 1802, 418, 275, 408, 11834, 922, 1159, 3341, 4412, 570, 367, 971, 199, 2427, 666, 12, 1686, 1475, 624, 199, 1579, 63, 815, 459, 1579, 63, 1802, 418, 275, 408, 16786, 1183, 12, 781, 1104, 626, 26, 339, 446, 710, 12377, 600, 5826, 12, 10967, 281, 4562, 2626, 1513, 6227, 12, 436, 22734, 4562, 2626, 1504, 2126, 1172, 1686, 473, 2160, 1348, 577, 7170, 4110, 12, 436, 12377, 600, 5826, 4110, 2126, 787, 2222, 13, 271, 4208, 334, 705, 9, 272, 446, 710, 15227, 998, 12, 12377, 600, 5826, 12, 10967, 281, 4562, 2626, 5826, 12, 436, 11994, 2126, 2323, 787, 3451, 14, 334, 705, 9, 272, 446, 6006, 787, 440, 9250, 1406, 1504, 334, 705, 9, 272, 446, 6006, 787, 440, 9250, 4681, 6021, 334, 705, 9, 272, 446, 12377, 6021, 787, 402, 314, 2011, 2582, 14, 221, 29083, 5111, 1380, 2126, 1750, 63, 552, 63, 22091, 3305, 365, 3032, 334, 3764, 9, 272, 446, 710, 2323, 886, 440, 1395, 3866, 4110, 334, 31119, 436, 2126, 18888, 1454, 9, 334, 3764, 9, 272, 446, 710, 666, 1504, 886, 440, 1395, 3866, 4110, 334, 31119, 12, 2126, 18888, 12, 4601, 12, 436, 435, 3295, 13186, 11941, 27, 4110, 9, 334, 3764, 9, 272, 446, 15227, 998, 1504, 787, 603, 41, 8456, 1013, 22676, 334, 2118, 27964, 2126, 436, 1275, 4110, 680, 334, 3764, 9, 272, 446, 6006, 787, 949, 15755, 1380, 314, 1979, 2626, 436, 1750, 2582, 2126, 4681, 6021, 787, 11544, 334, 705, 9, 272, 446, 6006, 787, 949, 15755, 1380, 4681, 6021, 436, 3483, 477, 6048, 88, 2126, 1504, 5868, 74, 945, 9, 787, 12149, 334, 705, 9, 272, 446, 3918, 1504, 787, 440, 1911, 20561, 314, 11994, 2763, 334, 3764, 9, 339, 15621, 3595, 314, 3341, 4412, 570, 1475, 883, 506, 1911, 2348, 26, 272, 1455, 921, 1544, 14, 23104, 1036, 14, 1308, 15, 9970, 15, 493, 63, 6321, 14, 1360, 3, 2343, 13, 4745, 13, 1725, 339, 20456, 436, 3598, 787, 6290, 370, 282, 943, 570, 14, 221, 20456, 883, 506, 18104, 701, 272, 8826, 543, 314, 2323, 12, 3866, 4110, 315, 4681, 6021, 503, 1979, 16465, 12, 503, 272, 701, 366, 4230, 1298, 315, 15227, 12818, 503, 4681, 6021, 14, 339, 644, 2627, 883, 14554, 261, 687, 3866, 4110, 436, 1750, 2582, 4681, 6021, 626, 272, 787, 440, 2013, 543, 314, 1553, 1975, 63, 552, 63, 22091, 14, 272, 644, 2627, 911, 1395, 282, 3659, 370, 314, 4917, 334, 1143, 12, 2301, 9, 626, 314, 272, 5721, 282, 293, 261, 687, 14, 339, 1010, 10234, 370, 314, 943, 570, 12, 282, 298, 28125, 63, 4745, 2, 570, 911, 506, 2737, 14, 272, 6184, 3866, 4110, 911, 506, 8717, 543, 7815, 4110, 315, 272, 314, 15227, 998, 1504, 334, 475, 15814, 603, 41, 8456, 4151, 9, 436, 1318, 315, 1163, 666, 272, 1504, 911, 506, 8717, 543, 314, 4528, 2013, 701, 314, 446, 67, 2725, 12, 272, 1314, 365, 376, 18888, 14220, 701, 849, 14, 339, 437, 3517, 570, 911, 506, 2737, 465, 5521, 12, 1314, 911, 2498, 9918, 402, 272, 3598, 436, 2552, 12, 4721, 27883, 315, 31194, 436, 8992, 17342, 14, 221, 982, 949, 272, 2552, 503, 3598, 4898, 3451, 314, 570, 911, 2929, 282, 1245, 14722, 316, 272, 4066, 14, 221, 10240, 2552, 883, 3656, 1163, 2552, 12, 880, 3520, 1077, 506, 30156, 272, 1642, 14, 339, 982, 1115, 26509, 1979, 16465, 787, 1202, 12, 7396, 543, 282, 10029, 14, 221, 2104, 1256, 12, 282, 1115, 26509, 272, 663, 402, 7795, 8087, 70, 1979, 16465, 334, 2972, 370, 19781, 9067, 15222, 530, 11745, 9, 4293, 506, 272, 2013, 315, 314, 10967, 281, 4562, 2626, 5826, 1504, 465, 4066, 26, 272, 437, 29242, 1481, 4064, 11712, 14335, 1028, 12170, 12, 1254, 1254, 1481, 6332, 24355, 14335, 1028, 6967, 12, 1254, 33, 17789, 39, 619, 1028, 17569, 1481, 12170, 199, 624, 199, 1579, 63, 815, 459, 1579, 63, 3807, 418, 275, 942, 199, 1579, 63, 815, 459, 1579, 63, 3807, 2278, 740, 1332, 624, 9846, 26, 7208, 408, 1799, 314, 22613, 316, 63, 2956, 14, 2424, 971, 272, 4412, 570, 367, 8826, 12, 4973, 6670, 314, 1415, 4412, 570, 12, 436, 1072, 971, 272, 314, 2058, 315, 314, 4107, 63, 4745, 63, 493, 63, 1199, 2082, 7208, 408, 5, 6595, 446, 77, 971, 272, 22613, 316, 63, 2956, 14, 2424, 446, 79, 4107, 63, 4745, 63, 493, 63, 1199, 624, 430, 199, 1579, 63, 815, 459, 1199, 63, 1802, 418, 275, 408, 33, 943, 570, 12, 3517, 570, 12, 436, 971, 199, 28125, 63, 4745, 14, 2424, 570, 911, 506, 5313, 370, 314, 1453, 1072, 2082, 1041, 199, 1579, 63, 815, 459, 2427, 63, 1419, 418, 275, 359, 272, 1852, 63, 1422, 3654, 77, 297, 2850, 4745, 63, 3997, 297, 730, 534, 5952, 63, 7218, 297, 355, 1720, 534, 5142, 4412, 9911, 358, 199, 199, 61, 199, 1579, 63, 815, 459, 4144, 63, 1419, 418, 275, 359, 272, 1852, 63, 1422, 3654, 79, 297, 2850, 1199, 63, 694, 297, 730, 534, 1222, 63, 17254, 297, 355, 1720, 534, 8030, 1072, 2082, 367 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 363, 2502, 363, 275, 298, 55, 8148, 455, 644, 31185, 2, 199, 363, 7307, 363, 275, 298, 7384, 7760, 12, 710, 1413, 41, 3465, 7290, 2, 199, 363, 22461, 363, 275, 2097, 55, 8148, 455, 644, 31185, 937, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 25, 14, 17, 13, 2374, 2, 199, 363, 26665, 363, 275, 298, 55, 8148, 455, 644, 31185, 2, 199, 363, 2123, 363, 275, 298, 55, 8148, 455, 14, 33, 14, 55, 31185, 32, 2326, 5129, 14, 8654, 2, 199, 199, 504, 1059, 492, 14435, 12, 7576, 199, 199, 504, 31402, 1036, 14, 1974, 492, 2198, 63, 1531, 63, 604, 63, 3214, 12, 664, 63, 1419, 63, 3892, 4202, 272, 1852, 63, 1422, 12, 1218, 63, 694, 199, 504, 31402, 1036, 14, 1074, 63, 344, 63, 1130, 492, 1104, 63, 4745, 63, 493, 199, 199, 1419, 63, 3892, 275, 664, 63, 1419, 63, 3892, 342, 199, 1579, 63, 815, 275, 1052, 199, 1579, 63, 815, 459, 19127, 63, 1802, 418, 275, 408, 11834, 922, 1159, 3341, 4412, 570, 367, 971, 199, 2427, 666, 12, 1686, 1475, 624, 199, 1579, 63, 815, 459, 1579, 63, 1802, 418, 275, 408, 16786, 1183, 12, 781, 1104, 626, 26, 339, 446, 710, 12377, 600, 5826, 12, 10967, 281, 4562, 2626, 1513, 6227, 12, 436, 22734, 4562, 2626, 1504, 2126, 1172, 1686, 473, 2160, 1348, 577, 7170, 4110, 12, 436, 12377, 600, 5826, 4110, 2126, 787, 2222, 13, 271, 4208, 334, 705, 9, 272, 446, 710, 15227, 998, 12, 12377, 600, 5826, 12, 10967, 281, 4562, 2626, 5826, 12, 436, 11994, 2126, 2323, 787, 3451, 14, 334, 705, 9, 272, 446, 6006, 787, 440, 9250, 1406, 1504, 334, 705, 9, 272, 446, 6006, 787, 440, 9250, 4681, 6021, 334, 705, 9, 272, 446, 12377, 6021, 787, 402, 314, 2011, 2582, 14, 221, 29083, 5111, 1380, 2126, 1750, 63, 552, 63, 22091, 3305, 365, 3032, 334, 3764, 9, 272, 446, 710, 2323, 886, 440, 1395, 3866, 4110, 334, 31119, 436, 2126, 18888, 1454, 9, 334, 3764, 9, 272, 446, 710, 666, 1504, 886, 440, 1395, 3866, 4110, 334, 31119, 12, 2126, 18888, 12, 4601, 12, 436, 435, 3295, 13186, 11941, 27, 4110, 9, 334, 3764, 9, 272, 446, 15227, 998, 1504, 787, 603, 41, 8456, 1013, 22676, 334, 2118, 27964, 2126, 436, 1275, 4110, 680, 334, 3764, 9, 272, 446, 6006, 787, 949, 15755, 1380, 314, 1979, 2626, 436, 1750, 2582, 2126, 4681, 6021, 787, 11544, 334, 705, 9, 272, 446, 6006, 787, 949, 15755, 1380, 4681, 6021, 436, 3483, 477, 6048, 88, 2126, 1504, 5868, 74, 945, 9, 787, 12149, 334, 705, 9, 272, 446, 3918, 1504, 787, 440, 1911, 20561, 314, 11994, 2763, 334, 3764, 9, 339, 15621, 3595, 314, 3341, 4412, 570, 1475, 883, 506, 1911, 2348, 26, 272, 1455, 921, 1544, 14, 23104, 1036, 14, 1308, 15, 9970, 15, 493, 63, 6321, 14, 1360, 3, 2343, 13, 4745, 13, 1725, 339, 20456, 436, 3598, 787, 6290, 370, 282, 943, 570, 14, 221, 20456, 883, 506, 18104, 701, 272, 8826, 543, 314, 2323, 12, 3866, 4110, 315, 4681, 6021, 503, 1979, 16465, 12, 503, 272, 701, 366, 4230, 1298, 315, 15227, 12818, 503, 4681, 6021, 14, 339, 644, 2627, 883, 14554, 261, 687, 3866, 4110, 436, 1750, 2582, 4681, 6021, 626, 272, 787, 440, 2013, 543, 314, 1553, 1975, 63, 552, 63, 22091, 14, 272, 644, 2627, 911, 1395, 282, 3659, 370, 314, 4917, 334, 1143, 12, 2301, 9, 626, 314, 272, 5721, 282, 293, 261, 687, 14, 339, 1010, 10234, 370, 314, 943, 570, 12, 282, 298, 28125, 63, 4745, 2, 570, 911, 506, 2737, 14, 272, 6184, 3866, 4110, 911, 506, 8717, 543, 7815, 4110, 315, 272, 314, 15227, 998, 1504, 334, 475, 15814, 603, 41, 8456, 4151, 9, 436, 1318, 315, 1163, 666, 272, 1504, 911, 506, 8717, 543, 314, 4528, 2013, 701, 314, 446, 67, 2725, 12, 272, 1314, 365, 376, 18888, 14220, 701, 849, 14, 339, 437, 3517, 570, 911, 506, 2737, 465, 5521, 12, 1314, 911, 2498, 9918, 402, 272, 3598, 436, 2552, 12, 4721, 27883, 315, 31194, 436, 8992, 17342, 14, 221, 982, 949, 272, 2552, 503, 3598, 4898, 3451, 314, 570, 911, 2929, 282, 1245, 14722, 316, 272, 4066, 14, 221, 10240, 2552, 883, 3656, 1163, 2552, 12, 880, 3520, 1077, 506, 30156, 272, 1642, 14, 339, 982, 1115, 26509, 1979, 16465, 787, 1202, 12, 7396, 543, 282, 10029, 14, 221, 2104, 1256, 12, 282, 1115, 26509, 272, 663, 402, 7795, 8087, 70, 1979, 16465, 334, 2972, 370, 19781, 9067, 15222, 530, 11745, 9, 4293, 506, 272, 2013, 315, 314, 10967, 281, 4562, 2626, 5826, 1504, 465, 4066, 26, 272, 437, 29242, 1481, 4064, 11712, 14335, 1028, 12170, 12, 1254, 1254, 1481, 6332, 24355, 14335, 1028, 6967, 12, 1254, 33, 17789, 39, 619, 1028, 17569, 1481, 12170, 199, 624, 199, 1579, 63, 815, 459, 1579, 63, 3807, 418, 275, 942, 199, 1579, 63, 815, 459, 1579, 63, 3807, 2278, 740, 1332, 624, 9846, 26, 7208, 408, 1799, 314, 22613, 316, 63, 2956, 14, 2424, 971, 272, 4412, 570, 367, 8826, 12, 4973, 6670, 314, 1415, 4412, 570, 12, 436, 1072, 971, 272, 314, 2058, 315, 314, 4107, 63, 4745, 63, 493, 63, 1199, 2082, 7208, 408, 5, 6595, 446, 77, 971, 272, 22613, 316, 63, 2956, 14, 2424, 446, 79, 4107, 63, 4745, 63, 493, 63, 1199, 624, 430, 199, 1579, 63, 815, 459, 1199, 63, 1802, 418, 275, 408, 33, 943, 570, 12, 3517, 570, 12, 436, 971, 199, 28125, 63, 4745, 14, 2424, 570, 911, 506, 5313, 370, 314, 1453, 1072, 2082, 1041, 199, 1579, 63, 815, 459, 2427, 63, 1419, 418, 275, 359, 272, 1852, 63, 1422, 3654, 77, 297, 2850, 4745, 63, 3997, 297, 730, 534, 5952, 63, 7218, 297, 355, 1720, 534, 5142, 4412, 9911, 358, 199, 199, 61, 199, 1579, 63, 815, 459, 4144, 63, 1419, 418, 275, 359, 272, 1852, 63, 1422, 3654, 79, 297, 2850, 1199, 63, 694,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
yelongyu/chihu
venv/lib/python2.7/site-packages/sqlalchemy/orm/base.py
35
14668
# orm/base.py # Copyright (C) 2005-2016 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 """Constants and rudimental functions used throughout the ORM. """ from .. import util, inspection, exc as sa_exc from ..sql import expression from . import exc import operator PASSIVE_NO_RESULT = util.symbol( 'PASSIVE_NO_RESULT', """Symbol returned by a loader callable or other attribute/history retrieval operation when a value could not be determined, based on loader callable flags. """ ) ATTR_WAS_SET = util.symbol( 'ATTR_WAS_SET', """Symbol returned by a loader callable to indicate the retrieved value, or values, were assigned to their attributes on the target object. """ ) ATTR_EMPTY = util.symbol( 'ATTR_EMPTY', """Symbol used internally to indicate an attribute had no callable.""" ) NO_VALUE = util.symbol( 'NO_VALUE', """Symbol which may be placed as the 'previous' value of an attribute, indicating no value was loaded for an attribute when it was modified, and flags indicated we were not to load it. """ ) NEVER_SET = util.symbol( 'NEVER_SET', """Symbol which may be placed as the 'previous' value of an attribute indicating that the attribute had not been assigned to previously. """ ) NO_CHANGE = util.symbol( "NO_CHANGE", """No callables or SQL should be emitted on attribute access and no state should change """, canonical=0 ) CALLABLES_OK = util.symbol( "CALLABLES_OK", """Loader callables can be fired off if a value is not present. """, canonical=1 ) SQL_OK = util.symbol( "SQL_OK", """Loader callables can emit SQL at least on scalar value attributes.""", canonical=2 ) RELATED_OBJECT_OK = util.symbol( "RELATED_OBJECT_OK", """Callables can use SQL to load related objects as well as scalar value attributes. """, canonical=4 ) INIT_OK = util.symbol( "INIT_OK", """Attributes should be initialized with a blank value (None or an empty collection) upon get, if no other value can be obtained. """, canonical=8 ) NON_PERSISTENT_OK = util.symbol( "NON_PERSISTENT_OK", """Callables can be emitted if the parent is not persistent.""", canonical=16 ) LOAD_AGAINST_COMMITTED = util.symbol( "LOAD_AGAINST_COMMITTED", """Callables should use committed values as primary/foreign keys during a load. """, canonical=32 ) NO_AUTOFLUSH = util.symbol( "NO_AUTOFLUSH", """Loader callables should disable autoflush.""", canonical=64 ) # pre-packaged sets of flags used as inputs PASSIVE_OFF = util.symbol( "PASSIVE_OFF", "Callables can be emitted in all cases.", canonical=(RELATED_OBJECT_OK | NON_PERSISTENT_OK | INIT_OK | CALLABLES_OK | SQL_OK) ) PASSIVE_RETURN_NEVER_SET = util.symbol( "PASSIVE_RETURN_NEVER_SET", """PASSIVE_OFF ^ INIT_OK""", canonical=PASSIVE_OFF ^ INIT_OK ) PASSIVE_NO_INITIALIZE = util.symbol( "PASSIVE_NO_INITIALIZE", "PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OK", canonical=PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OK ) PASSIVE_NO_FETCH = util.symbol( "PASSIVE_NO_FETCH", "PASSIVE_OFF ^ SQL_OK", canonical=PASSIVE_OFF ^ SQL_OK ) PASSIVE_NO_FETCH_RELATED = util.symbol( "PASSIVE_NO_FETCH_RELATED", "PASSIVE_OFF ^ RELATED_OBJECT_OK", canonical=PASSIVE_OFF ^ RELATED_OBJECT_OK ) PASSIVE_ONLY_PERSISTENT = util.symbol( "PASSIVE_ONLY_PERSISTENT", "PASSIVE_OFF ^ NON_PERSISTENT_OK", canonical=PASSIVE_OFF ^ NON_PERSISTENT_OK ) DEFAULT_MANAGER_ATTR = '_sa_class_manager' DEFAULT_STATE_ATTR = '_sa_instance_state' _INSTRUMENTOR = ('mapper', 'instrumentor') EXT_CONTINUE = util.symbol('EXT_CONTINUE') EXT_STOP = util.symbol('EXT_STOP') ONETOMANY = util.symbol( 'ONETOMANY', """Indicates the one-to-many direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. """) MANYTOONE = util.symbol( 'MANYTOONE', """Indicates the many-to-one direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. """) MANYTOMANY = util.symbol( 'MANYTOMANY', """Indicates the many-to-many direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. """) NOT_EXTENSION = util.symbol( 'NOT_EXTENSION', """Symbol indicating an :class:`InspectionAttr` that's not part of sqlalchemy.ext. Is assigned to the :attr:`.InspectionAttr.extension_type` attibute. """) _never_set = frozenset([NEVER_SET]) _none_set = frozenset([None, NEVER_SET, PASSIVE_NO_RESULT]) _SET_DEFERRED_EXPIRED = util.symbol("SET_DEFERRED_EXPIRED") _DEFER_FOR_STATE = util.symbol("DEFER_FOR_STATE") def _generative(*assertions): """Mark a method as generative, e.g. method-chained.""" @util.decorator def generate(fn, *args, **kw): self = args[0]._clone() for assertion in assertions: assertion(self, fn.__name__) fn(self, *args[1:], **kw) return self return generate # these can be replaced by sqlalchemy.ext.instrumentation # if augmented class instrumentation is enabled. def manager_of_class(cls): return cls.__dict__.get(DEFAULT_MANAGER_ATTR, None) instance_state = operator.attrgetter(DEFAULT_STATE_ATTR) instance_dict = operator.attrgetter('__dict__') def instance_str(instance): """Return a string describing an instance.""" return state_str(instance_state(instance)) def state_str(state): """Return a string describing an instance via its InstanceState.""" if state is None: return "None" else: return '<%s at 0x%x>' % (state.class_.__name__, id(state.obj())) def state_class_str(state): """Return a string describing an instance's class via its InstanceState. """ if state is None: return "None" else: return '<%s>' % (state.class_.__name__, ) def attribute_str(instance, attribute): return instance_str(instance) + "." + attribute def state_attribute_str(state, attribute): return state_str(state) + "." + attribute def object_mapper(instance): """Given an object, return the primary Mapper associated with the object instance. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. This function is available via the inspection system as:: inspect(instance).mapper Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is not part of a mapping. """ return object_state(instance).mapper def object_state(instance): """Given an object, return the :class:`.InstanceState` associated with the object. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. Equivalent functionality is available via the :func:`.inspect` function as:: inspect(instance) Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is not part of a mapping. """ state = _inspect_mapped_object(instance) if state is None: raise exc.UnmappedInstanceError(instance) else: return state @inspection._inspects(object) def _inspect_mapped_object(instance): try: return instance_state(instance) # TODO: whats the py-2/3 syntax to catch two # different kinds of exceptions at once ? except exc.UnmappedClassError: return None except exc.NO_STATE: return None def _class_to_mapper(class_or_mapper): insp = inspection.inspect(class_or_mapper, False) if insp is not None: return insp.mapper else: raise exc.UnmappedClassError(class_or_mapper) def _mapper_or_none(entity): """Return the :class:`.Mapper` for the given class or None if the class is not mapped. """ insp = inspection.inspect(entity, False) if insp is not None: return insp.mapper else: return None def _is_mapped_class(entity): """Return True if the given object is a mapped class, :class:`.Mapper`, or :class:`.AliasedClass`. """ insp = inspection.inspect(entity, False) return insp is not None and \ not insp.is_clause_element and \ ( insp.is_mapper or insp.is_aliased_class ) def _attr_as_key(attr): if hasattr(attr, 'key'): return attr.key else: return expression._column_as_key(attr) def _orm_columns(entity): insp = inspection.inspect(entity, False) if hasattr(insp, 'selectable') and hasattr(insp.selectable, 'c'): return [c for c in insp.selectable.c] else: return [entity] def _is_aliased_class(entity): insp = inspection.inspect(entity, False) return insp is not None and \ getattr(insp, "is_aliased_class", False) def _entity_descriptor(entity, key): """Return a class attribute given an entity and string name. May return :class:`.InstrumentedAttribute` or user-defined attribute. """ insp = inspection.inspect(entity) if insp.is_selectable: description = entity entity = insp.c elif insp.is_aliased_class: entity = insp.entity description = entity elif hasattr(insp, "mapper"): description = entity = insp.mapper.class_ else: description = entity try: return getattr(entity, key) except AttributeError: raise sa_exc.InvalidRequestError( "Entity '%s' has no property '%s'" % (description, key) ) _state_mapper = util.dottedgetter('manager.mapper') @inspection._inspects(type) def _inspect_mapped_class(class_, configure=False): try: class_manager = manager_of_class(class_) if not class_manager.is_mapped: return None mapper = class_manager.mapper except exc.NO_STATE: return None else: if configure and mapper._new_mappers: mapper._configure_all() return mapper def class_mapper(class_, configure=True): """Given a class, return the primary :class:`.Mapper` associated with the key. Raises :exc:`.UnmappedClassError` if no mapping is configured on the given class, or :exc:`.ArgumentError` if a non-class object is passed. Equivalent functionality is available via the :func:`.inspect` function as:: inspect(some_mapped_class) Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the class is not mapped. """ mapper = _inspect_mapped_class(class_, configure=configure) if mapper is None: if not isinstance(class_, type): raise sa_exc.ArgumentError( "Class object expected, got '%r'." % (class_, )) raise exc.UnmappedClassError(class_) else: return mapper class InspectionAttr(object): """A base class applied to all ORM objects that can be returned by the :func:`.inspect` function. The attributes defined here allow the usage of simple boolean checks to test basic facts about the object returned. While the boolean checks here are basically the same as using the Python isinstance() function, the flags here can be used without the need to import all of these classes, and also such that the SQLAlchemy class system can change while leaving the flags here intact for forwards-compatibility. """ __slots__ = () is_selectable = False """Return True if this object is an instance of :class:`.Selectable`.""" is_aliased_class = False """True if this object is an instance of :class:`.AliasedClass`.""" is_instance = False """True if this object is an instance of :class:`.InstanceState`.""" is_mapper = False """True if this object is an instance of :class:`.Mapper`.""" is_property = False """True if this object is an instance of :class:`.MapperProperty`.""" is_attribute = False """True if this object is a Python :term:`descriptor`. This can refer to one of many types. Usually a :class:`.QueryableAttribute` which handles attributes events on behalf of a :class:`.MapperProperty`. But can also be an extension type such as :class:`.AssociationProxy` or :class:`.hybrid_property`. The :attr:`.InspectionAttr.extension_type` will refer to a constant identifying the specific subtype. .. seealso:: :attr:`.Mapper.all_orm_descriptors` """ is_clause_element = False """True if this object is an instance of :class:`.ClauseElement`.""" extension_type = NOT_EXTENSION """The extension type, if any. Defaults to :data:`.interfaces.NOT_EXTENSION` .. versionadded:: 0.8.0 .. seealso:: :data:`.HYBRID_METHOD` :data:`.HYBRID_PROPERTY` :data:`.ASSOCIATION_PROXY` """ class InspectionAttrInfo(InspectionAttr): """Adds the ``.info`` attribute to :class:`.InspectionAttr`. The rationale for :class:`.InspectionAttr` vs. :class:`.InspectionAttrInfo` is that the former is compatible as a mixin for classes that specify ``__slots__``; this is essentially an implementation artifact. """ @util.memoized_property def info(self): """Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. The dictionary is generated when first accessed. Alternatively, it can be specified as a constructor argument to the :func:`.column_property`, :func:`.relationship`, or :func:`.composite` functions. .. versionadded:: 0.8 Added support for .info to all :class:`.MapperProperty` subclasses. .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also available on extension types via the :attr:`.InspectionAttrInfo.info` attribute, so that it can apply to a wider variety of ORM and extension constructs. .. seealso:: :attr:`.QueryableAttribute.info` :attr:`.SchemaItem.info` """ return {} class _MappedAttribute(object): """Mixin for attributes which should be replaced by mapper-assigned attributes. """ __slots__ = ()
gpl-3.0
[ 3, 9813, 15, 1095, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 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, 22185, 436, 519, 14525, 434, 279, 3423, 1202, 23088, 314, 23383, 14, 199, 199, 624, 199, 199, 504, 2508, 492, 4884, 12, 5261, 10303, 12, 3178, 465, 2937, 63, 2804, 199, 504, 2508, 3009, 492, 3965, 199, 504, 1275, 492, 3178, 199, 646, 4182, 199, 199, 29634, 63, 2826, 63, 9517, 275, 4884, 14, 5155, 8, 272, 283, 29634, 63, 2826, 63, 9517, 297, 272, 408, 8169, 2138, 701, 282, 5077, 4550, 503, 1163, 2225, 15, 5570, 272, 27157, 3439, 1380, 282, 574, 4293, 440, 506, 12037, 12, 4079, 272, 641, 5077, 4550, 3285, 14, 272, 408, 199, 9, 199, 199, 5280, 63, 55, 1179, 63, 3597, 275, 4884, 14, 5155, 8, 272, 283, 5280, 63, 55, 1179, 63, 3597, 297, 272, 408, 8169, 2138, 701, 282, 5077, 4550, 370, 6623, 314, 272, 12396, 574, 12, 503, 1338, 12, 4898, 7943, 370, 3932, 3004, 272, 641, 314, 1347, 909, 14, 272, 408, 199, 9, 199, 199, 5280, 63, 13993, 275, 4884, 14, 5155, 8, 272, 283, 5280, 63, 13993, 297, 272, 408, 8169, 1202, 14448, 370, 6623, 376, 2225, 10530, 949, 4550, 1041, 199, 9, 199, 199, 2826, 63, 7041, 275, 4884, 14, 5155, 8, 272, 283, 2826, 63, 7041, 297, 272, 408, 8169, 1314, 1443, 506, 15090, 465, 314, 283, 6352, 7, 574, 402, 376, 2225, 12, 272, 9297, 949, 574, 1990, 6511, 367, 376, 2225, 1380, 652, 1990, 6042, 12, 272, 436, 3285, 22141, 781, 4898, 440, 370, 2248, 652, 14, 272, 408, 199, 9, 199, 199, 6388, 2111, 63, 3597, 275, 4884, 14, 5155, 8, 272, 283, 6388, 2111, 63, 3597, 297, 272, 408, 8169, 1314, 1443, 506, 15090, 465, 314, 283, 6352, 7, 574, 402, 376, 2225, 272, 9297, 626, 314, 2225, 10530, 440, 2757, 7943, 370, 10889, 14, 272, 408, 199, 9, 199, 199, 2826, 63, 16062, 275, 4884, 14, 5155, 8, 272, 298, 2826, 63, 16062, 401, 272, 408, 1944, 28041, 503, 5385, 1077, 506, 19515, 641, 2225, 2879, 272, 436, 949, 1174, 1077, 1570, 272, 10327, 11358, 29, 16, 199, 9, 199, 199, 11978, 17041, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 11978, 17041, 63, 3593, 401, 272, 408, 5455, 28041, 883, 506, 31974, 2331, 340, 282, 574, 272, 365, 440, 3451, 14, 272, 10327, 11358, 29, 17, 199, 9, 199, 199, 4657, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 4657, 63, 3593, 401, 272, 408, 5455, 28041, 883, 8689, 5385, 737, 5210, 641, 6917, 574, 3004, 17129, 272, 11358, 29, 18, 199, 9, 199, 199, 13604, 6989, 63, 9868, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 13604, 6989, 63, 9868, 63, 3593, 401, 272, 408, 2176, 5921, 883, 675, 5385, 370, 2248, 4048, 2251, 465, 5521, 272, 465, 6917, 574, 3004, 14, 272, 10327, 11358, 29, 20, 199, 9, 199, 199, 8727, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 8727, 63, 3593, 401, 272, 408, 5379, 1077, 506, 10038, 543, 282, 4596, 272, 574, 334, 403, 503, 376, 2701, 3245, 9, 12188, 664, 12, 340, 949, 1163, 272, 574, 883, 506, 15884, 14, 272, 10327, 11358, 29, 24, 199, 9, 199, 199, 13887, 63, 4227, 29367, 1309, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 13887, 63, 4227, 29367, 1309, 63, 3593, 401, 272, 408, 2176, 5921, 883, 506, 19515, 340, 314, 1676, 365, 440, 16149, 17129, 272, 11358, 29, 975, 199, 9, 199, 199, 7405, 63, 1254, 33, 7834, 63, 5378, 20779, 1149, 275, 4884, 14, 5155, 8, 272, 298, 7405, 63, 1254, 33, 7834, 63, 5378, 20779, 1149, 401, 272, 408, 2176, 5921, 1077, 675, 27659, 1338, 465, 5062, 15, 6846, 2883, 5309, 282, 272, 2248, 14, 272, 10327, 11358, 29, 708, 199, 9, 199, 199, 2826, 63, 13883, 32762, 275, 4884, 14, 5155, 8, 272, 298, 2826, 63, 13883, 32762, 401, 272, 408, 5455, 28041, 1077, 3507, 2599, 4939, 17129, 272, 11358, 29, 772, 199, 9, 199, 199, 3, 876, 13, 2491, 68, 5951, 402, 3285, 1202, 465, 4153, 199, 29634, 63, 7517, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 7517, 401, 272, 298, 2176, 5921, 883, 506, 19515, 315, 1006, 5560, 4765, 272, 11358, 2687, 13604, 6989, 63, 9868, 63, 3593, 1204, 11214, 63, 4227, 29367, 1309, 63, 3593, 1204, 2049, 20199, 63, 3593, 1204, 24251, 17041, 63, 3593, 1204, 5385, 63, 3593, 9, 199, 9, 199, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 401, 272, 408, 29634, 63, 7517, 7167, 20199, 63, 3593, 7208, 272, 11358, 29, 29634, 63, 7517, 7167, 20199, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 13768, 11025, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 13768, 11025, 401, 272, 298, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 7167, 24251, 17041, 63, 3593, 401, 272, 11358, 29, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 7167, 24251, 17041, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 32097, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 32097, 401, 272, 298, 29634, 63, 7517, 7167, 5385, 63, 3593, 401, 272, 11358, 29, 29634, 63, 7517, 7167, 5385, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 32097, 63, 13604, 6989, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 32097, 63, 13604, 6989, 401, 272, 298, 29634, 63, 7517, 7167, 820, 2901, 6989, 63, 9868, 63, 3593, 401, 272, 11358, 29, 29634, 63, 7517, 7167, 820, 2901, 6989, 63, 9868, 63, 3593, 199, 9, 199, 29634, 63, 10452, 63, 4227, 29367, 1309, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 10452, 63, 4227, 29367, 1309, 401, 272, 298, 29634, 63, 7517, 7167, 11214, 63, 4227, 29367, 1309, 63, 3593, 401, 272, 11358, 29, 29634, 63 ]
[ 9813, 15, 1095, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 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, 22185, 436, 519, 14525, 434, 279, 3423, 1202, 23088, 314, 23383, 14, 199, 199, 624, 199, 199, 504, 2508, 492, 4884, 12, 5261, 10303, 12, 3178, 465, 2937, 63, 2804, 199, 504, 2508, 3009, 492, 3965, 199, 504, 1275, 492, 3178, 199, 646, 4182, 199, 199, 29634, 63, 2826, 63, 9517, 275, 4884, 14, 5155, 8, 272, 283, 29634, 63, 2826, 63, 9517, 297, 272, 408, 8169, 2138, 701, 282, 5077, 4550, 503, 1163, 2225, 15, 5570, 272, 27157, 3439, 1380, 282, 574, 4293, 440, 506, 12037, 12, 4079, 272, 641, 5077, 4550, 3285, 14, 272, 408, 199, 9, 199, 199, 5280, 63, 55, 1179, 63, 3597, 275, 4884, 14, 5155, 8, 272, 283, 5280, 63, 55, 1179, 63, 3597, 297, 272, 408, 8169, 2138, 701, 282, 5077, 4550, 370, 6623, 314, 272, 12396, 574, 12, 503, 1338, 12, 4898, 7943, 370, 3932, 3004, 272, 641, 314, 1347, 909, 14, 272, 408, 199, 9, 199, 199, 5280, 63, 13993, 275, 4884, 14, 5155, 8, 272, 283, 5280, 63, 13993, 297, 272, 408, 8169, 1202, 14448, 370, 6623, 376, 2225, 10530, 949, 4550, 1041, 199, 9, 199, 199, 2826, 63, 7041, 275, 4884, 14, 5155, 8, 272, 283, 2826, 63, 7041, 297, 272, 408, 8169, 1314, 1443, 506, 15090, 465, 314, 283, 6352, 7, 574, 402, 376, 2225, 12, 272, 9297, 949, 574, 1990, 6511, 367, 376, 2225, 1380, 652, 1990, 6042, 12, 272, 436, 3285, 22141, 781, 4898, 440, 370, 2248, 652, 14, 272, 408, 199, 9, 199, 199, 6388, 2111, 63, 3597, 275, 4884, 14, 5155, 8, 272, 283, 6388, 2111, 63, 3597, 297, 272, 408, 8169, 1314, 1443, 506, 15090, 465, 314, 283, 6352, 7, 574, 402, 376, 2225, 272, 9297, 626, 314, 2225, 10530, 440, 2757, 7943, 370, 10889, 14, 272, 408, 199, 9, 199, 199, 2826, 63, 16062, 275, 4884, 14, 5155, 8, 272, 298, 2826, 63, 16062, 401, 272, 408, 1944, 28041, 503, 5385, 1077, 506, 19515, 641, 2225, 2879, 272, 436, 949, 1174, 1077, 1570, 272, 10327, 11358, 29, 16, 199, 9, 199, 199, 11978, 17041, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 11978, 17041, 63, 3593, 401, 272, 408, 5455, 28041, 883, 506, 31974, 2331, 340, 282, 574, 272, 365, 440, 3451, 14, 272, 10327, 11358, 29, 17, 199, 9, 199, 199, 4657, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 4657, 63, 3593, 401, 272, 408, 5455, 28041, 883, 8689, 5385, 737, 5210, 641, 6917, 574, 3004, 17129, 272, 11358, 29, 18, 199, 9, 199, 199, 13604, 6989, 63, 9868, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 13604, 6989, 63, 9868, 63, 3593, 401, 272, 408, 2176, 5921, 883, 675, 5385, 370, 2248, 4048, 2251, 465, 5521, 272, 465, 6917, 574, 3004, 14, 272, 10327, 11358, 29, 20, 199, 9, 199, 199, 8727, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 8727, 63, 3593, 401, 272, 408, 5379, 1077, 506, 10038, 543, 282, 4596, 272, 574, 334, 403, 503, 376, 2701, 3245, 9, 12188, 664, 12, 340, 949, 1163, 272, 574, 883, 506, 15884, 14, 272, 10327, 11358, 29, 24, 199, 9, 199, 199, 13887, 63, 4227, 29367, 1309, 63, 3593, 275, 4884, 14, 5155, 8, 272, 298, 13887, 63, 4227, 29367, 1309, 63, 3593, 401, 272, 408, 2176, 5921, 883, 506, 19515, 340, 314, 1676, 365, 440, 16149, 17129, 272, 11358, 29, 975, 199, 9, 199, 199, 7405, 63, 1254, 33, 7834, 63, 5378, 20779, 1149, 275, 4884, 14, 5155, 8, 272, 298, 7405, 63, 1254, 33, 7834, 63, 5378, 20779, 1149, 401, 272, 408, 2176, 5921, 1077, 675, 27659, 1338, 465, 5062, 15, 6846, 2883, 5309, 282, 272, 2248, 14, 272, 10327, 11358, 29, 708, 199, 9, 199, 199, 2826, 63, 13883, 32762, 275, 4884, 14, 5155, 8, 272, 298, 2826, 63, 13883, 32762, 401, 272, 408, 5455, 28041, 1077, 3507, 2599, 4939, 17129, 272, 11358, 29, 772, 199, 9, 199, 199, 3, 876, 13, 2491, 68, 5951, 402, 3285, 1202, 465, 4153, 199, 29634, 63, 7517, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 7517, 401, 272, 298, 2176, 5921, 883, 506, 19515, 315, 1006, 5560, 4765, 272, 11358, 2687, 13604, 6989, 63, 9868, 63, 3593, 1204, 11214, 63, 4227, 29367, 1309, 63, 3593, 1204, 2049, 20199, 63, 3593, 1204, 24251, 17041, 63, 3593, 1204, 5385, 63, 3593, 9, 199, 9, 199, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 401, 272, 408, 29634, 63, 7517, 7167, 20199, 63, 3593, 7208, 272, 11358, 29, 29634, 63, 7517, 7167, 20199, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 13768, 11025, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 13768, 11025, 401, 272, 298, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 7167, 24251, 17041, 63, 3593, 401, 272, 11358, 29, 29634, 63, 9677, 63, 6388, 2111, 63, 3597, 7167, 24251, 17041, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 32097, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 32097, 401, 272, 298, 29634, 63, 7517, 7167, 5385, 63, 3593, 401, 272, 11358, 29, 29634, 63, 7517, 7167, 5385, 63, 3593, 199, 9, 199, 29634, 63, 2826, 63, 32097, 63, 13604, 6989, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 2826, 63, 32097, 63, 13604, 6989, 401, 272, 298, 29634, 63, 7517, 7167, 820, 2901, 6989, 63, 9868, 63, 3593, 401, 272, 11358, 29, 29634, 63, 7517, 7167, 820, 2901, 6989, 63, 9868, 63, 3593, 199, 9, 199, 29634, 63, 10452, 63, 4227, 29367, 1309, 275, 4884, 14, 5155, 8, 272, 298, 29634, 63, 10452, 63, 4227, 29367, 1309, 401, 272, 298, 29634, 63, 7517, 7167, 11214, 63, 4227, 29367, 1309, 63, 3593, 401, 272, 11358, 29, 29634, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
azureplus/chromium_depot_tools
third_party/boto/roboto/awsqueryrequest.py
70
18654
# Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2010, 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. import sys import os import boto import optparse import copy import boto.exception import boto.roboto.awsqueryservice import bdb import traceback try: import epdb as debugger except ImportError: import pdb as debugger def boto_except_hook(debugger_flag, debug_flag): def excepthook(typ, value, tb): if typ is bdb.BdbQuit: sys.exit(1) sys.excepthook = sys.__excepthook__ if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty(): if debugger.__name__ == 'epdb': debugger.post_mortem(tb, typ, value) else: debugger.post_mortem(tb) elif debug_flag: print traceback.print_tb(tb) sys.exit(1) else: print value sys.exit(1) return excepthook class Line(object): def __init__(self, fmt, data, label): self.fmt = fmt self.data = data self.label = label self.line = '%s\t' % label self.printed = False def append(self, datum): self.line += '%s\t' % datum def print_it(self): if not self.printed: print self.line self.printed = True class RequiredParamError(boto.exception.BotoClientError): def __init__(self, required): self.required = required s = 'Required parameters are missing: %s' % self.required boto.exception.BotoClientError.__init__(self, s) class EncoderError(boto.exception.BotoClientError): def __init__(self, error_msg): s = 'Error encoding value (%s)' % error_msg boto.exception.BotoClientError.__init__(self, s) class FilterError(boto.exception.BotoClientError): def __init__(self, filters): self.filters = filters s = 'Unknown filters: %s' % self.filters boto.exception.BotoClientError.__init__(self, s) class Encoder: @classmethod def encode(cls, p, rp, v, label=None): if p.name.startswith('_'): return try: mthd = getattr(cls, 'encode_'+p.ptype) mthd(p, rp, v, label) except AttributeError: raise EncoderError('Unknown type: %s' % p.ptype) @classmethod def encode_string(cls, p, rp, v, l): if l: label = l else: label = p.name rp[label] = v encode_file = encode_string encode_enum = encode_string @classmethod def encode_integer(cls, p, rp, v, l): if l: label = l else: label = p.name rp[label] = '%d' % v @classmethod def encode_boolean(cls, p, rp, v, l): if l: label = l else: label = p.name if v: v = 'true' else: v = 'false' rp[label] = v @classmethod def encode_datetime(cls, p, rp, v, l): if l: label = l else: label = p.name rp[label] = v @classmethod def encode_array(cls, p, rp, v, l): v = boto.utils.mklist(v) if l: label = l else: label = p.name label = label + '.%d' for i, value in enumerate(v): rp[label%(i+1)] = value class AWSQueryRequest(object): ServiceClass = None Description = '' Params = [] Args = [] Filters = [] Response = {} CLITypeMap = {'string' : 'string', 'integer' : 'int', 'int' : 'int', 'enum' : 'choice', 'datetime' : 'string', 'dateTime' : 'string', 'file' : 'string', 'boolean' : None} @classmethod def name(cls): return cls.__name__ def __init__(self, **args): self.args = args self.parser = None self.cli_options = None self.cli_args = None self.cli_output_format = None self.connection = None self.list_markers = [] self.item_markers = [] self.request_params = {} self.connection_args = None def __repr__(self): return self.name() def get_connection(self, **args): if self.connection is None: self.connection = self.ServiceClass(**args) return self.connection @property def status(self): retval = None if self.http_response is not None: retval = self.http_response.status return retval @property def reason(self): retval = None if self.http_response is not None: retval = self.http_response.reason return retval @property def request_id(self): retval = None if self.aws_response is not None: retval = getattr(self.aws_response, 'requestId') return retval def process_filters(self): filters = self.args.get('filters', []) filter_names = [f['name'] for f in self.Filters] unknown_filters = [f for f in filters if f not in filter_names] if unknown_filters: raise FilterError('Unknown filters: %s' % unknown_filters) for i, filter in enumerate(self.Filters): name = filter['name'] if name in filters: self.request_params['Filter.%d.Name' % (i+1)] = name for j, value in enumerate(boto.utils.mklist(filters[name])): Encoder.encode(filter, self.request_params, value, 'Filter.%d.Value.%d' % (i+1, j+1)) def process_args(self, **args): """ Responsible for walking through Params defined for the request and: * Matching them with keyword parameters passed to the request constructor or via the command line. * Checking to see if all required parameters have been specified and raising an exception, if not. * Encoding each value into the set of request parameters that will be sent in the request to the AWS service. """ self.args.update(args) self.connection_args = copy.copy(self.args) if 'debug' in self.args and self.args['debug'] >= 2: boto.set_stream_logger(self.name()) required = [p.name for p in self.Params+self.Args if not p.optional] for param in self.Params+self.Args: if param.long_name: python_name = param.long_name.replace('-', '_') else: python_name = boto.utils.pythonize_name(param.name, '_') value = None if python_name in self.args: value = self.args[python_name] if value is None: value = param.default if value is not None: if param.name in required: required.remove(param.name) if param.request_param: if param.encoder: param.encoder(param, self.request_params, value) else: Encoder.encode(param, self.request_params, value) if python_name in self.args: del self.connection_args[python_name] if required: l = [] for p in self.Params+self.Args: if p.name in required: if p.short_name and p.long_name: l.append('(%s, %s)' % (p.optparse_short_name, p.optparse_long_name)) elif p.short_name: l.append('(%s)' % p.optparse_short_name) else: l.append('(%s)' % p.optparse_long_name) raise RequiredParamError(','.join(l)) boto.log.debug('request_params: %s' % self.request_params) self.process_markers(self.Response) def process_markers(self, fmt, prev_name=None): if fmt and fmt['type'] == 'object': for prop in fmt['properties']: self.process_markers(prop, fmt['name']) elif fmt and fmt['type'] == 'array': self.list_markers.append(prev_name) self.item_markers.append(fmt['name']) def send(self, verb='GET', **args): self.process_args(**args) self.process_filters() conn = self.get_connection(**self.connection_args) self.http_response = conn.make_request(self.name(), self.request_params, verb=verb) self.body = self.http_response.read() boto.log.debug(self.body) if self.http_response.status == 200: self.aws_response = boto.jsonresponse.Element(list_marker=self.list_markers, item_marker=self.item_markers) h = boto.jsonresponse.XmlHandler(self.aws_response, self) h.parse(self.body) return self.aws_response else: boto.log.error('%s %s' % (self.http_response.status, self.http_response.reason)) boto.log.error('%s' % self.body) raise conn.ResponseError(self.http_response.status, self.http_response.reason, self.body) def add_standard_options(self): group = optparse.OptionGroup(self.parser, 'Standard Options') # add standard options that all commands get group.add_option('-D', '--debug', action='store_true', help='Turn on all debugging output') group.add_option('--debugger', action='store_true', default=False, help='Enable interactive debugger on error') group.add_option('-U', '--url', action='store', help='Override service URL with value provided') group.add_option('--region', action='store', help='Name of the region to connect to') group.add_option('-I', '--access-key-id', action='store', help='Override access key value') group.add_option('-S', '--secret-key', action='store', help='Override secret key value') group.add_option('--version', action='store_true', help='Display version string') if self.Filters: self.group.add_option('--help-filters', action='store_true', help='Display list of available filters') self.group.add_option('--filter', action='append', metavar=' name=value', help='A filter for limiting the results') self.parser.add_option_group(group) def process_standard_options(self, options, args, d): if hasattr(options, 'help_filters') and options.help_filters: print 'Available filters:' for filter in self.Filters: print '%s\t%s' % (filter.name, filter.doc) sys.exit(0) if options.debug: self.args['debug'] = 2 if options.url: self.args['url'] = options.url if options.region: self.args['region'] = options.region if options.access_key_id: self.args['aws_access_key_id'] = options.access_key_id if options.secret_key: self.args['aws_secret_access_key'] = options.secret_key if options.version: # TODO - Where should the version # come from? print 'version x.xx' exit(0) sys.excepthook = boto_except_hook(options.debugger, options.debug) def get_usage(self): s = 'usage: %prog [options] ' l = [ a.long_name for a in self.Args ] s += ' '.join(l) for a in self.Args: if a.doc: s += '\n\n\t%s - %s' % (a.long_name, a.doc) return s def build_cli_parser(self): self.parser = optparse.OptionParser(description=self.Description, usage=self.get_usage()) self.add_standard_options() for param in self.Params: ptype = action = choices = None if param.ptype in self.CLITypeMap: ptype = self.CLITypeMap[param.ptype] action = 'store' if param.ptype == 'boolean': action = 'store_true' elif param.ptype == 'array': if len(param.items) == 1: ptype = param.items[0]['type'] action = 'append' elif param.cardinality != 1: action = 'append' if ptype or action == 'store_true': if param.short_name: self.parser.add_option(param.optparse_short_name, param.optparse_long_name, action=action, type=ptype, choices=param.choices, help=param.doc) elif param.long_name: self.parser.add_option(param.optparse_long_name, action=action, type=ptype, choices=param.choices, help=param.doc) def do_cli(self): if not self.parser: self.build_cli_parser() self.cli_options, self.cli_args = self.parser.parse_args() d = {} self.process_standard_options(self.cli_options, self.cli_args, d) for param in self.Params: if param.long_name: p_name = param.long_name.replace('-', '_') else: p_name = boto.utils.pythonize_name(param.name) value = getattr(self.cli_options, p_name) if param.ptype == 'file' and value: if value == '-': value = sys.stdin.read() else: path = os.path.expanduser(value) path = os.path.expandvars(path) if os.path.isfile(path): fp = open(path) value = fp.read() fp.close() else: self.parser.error('Unable to read file: %s' % path) d[p_name] = value for arg in self.Args: if arg.long_name: p_name = arg.long_name.replace('-', '_') else: p_name = boto.utils.pythonize_name(arg.name) value = None if arg.cardinality == 1: if len(self.cli_args) >= 1: value = self.cli_args[0] else: value = self.cli_args d[p_name] = value self.args.update(d) if hasattr(self.cli_options, 'filter') and self.cli_options.filter: d = {} for filter in self.cli_options.filter: name, value = filter.split('=') d[name] = value if 'filters' in self.args: self.args['filters'].update(d) else: self.args['filters'] = d try: response = self.main() self.cli_formatter(response) except RequiredParamError, e: print e sys.exit(1) except self.ServiceClass.ResponseError, err: print 'Error(%s): %s' % (err.error_code, err.error_message) sys.exit(1) except boto.roboto.awsqueryservice.NoCredentialsError, err: print 'Unable to find credentials.' sys.exit(1) except Exception, e: print e sys.exit(1) def _generic_cli_formatter(self, fmt, data, label=''): if fmt['type'] == 'object': for prop in fmt['properties']: if 'name' in fmt: if fmt['name'] in data: data = data[fmt['name']] if fmt['name'] in self.list_markers: label = fmt['name'] if label[-1] == 's': label = label[0:-1] label = label.upper() self._generic_cli_formatter(prop, data, label) elif fmt['type'] == 'array': for item in data: line = Line(fmt, item, label) if isinstance(item, dict): for field_name in item: line.append(item[field_name]) elif isinstance(item, basestring): line.append(item) line.print_it() def cli_formatter(self, data): """ This method is responsible for formatting the output for the command line interface. The default behavior is to call the generic CLI formatter which attempts to print something reasonable. If you want specific formatting, you should override this method and do your own thing. :type data: dict :param data: The data returned by AWS. """ if data: self._generic_cli_formatter(self.Response, data)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 7129, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7129, 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, 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, 646, 984, 199, 646, 747, 199, 646, 6055, 199, 646, 8691, 199, 646, 1331, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 9751, 79, 14, 7231, 1131, 1364, 199, 199, 646, 330, 697, 199, 646, 5190, 199, 893, 26, 272, 492, 5442, 697, 465, 14958, 199, 2590, 3545, 26, 272, 492, 10543, 465, 14958, 199, 199, 318, 6055, 63, 2590, 63, 3664, 8, 17612, 63, 4173, 12, 3105, 63, 4173, 304, 272, 347, 11553, 13316, 6992, 8, 9749, 12, 574, 12, 7070, 304, 267, 340, 6211, 365, 330, 697, 14, 34, 697, 24145, 26, 288, 984, 14, 2224, 8, 17, 9, 267, 984, 14, 476, 301, 13316, 6992, 275, 984, 855, 476, 301, 13316, 6992, 363, 398, 340, 14958, 63, 4173, 436, 984, 14, 2703, 14, 21122, 342, 436, 984, 14, 6626, 14, 21122, 837, 288, 340, 14958, 855, 354, 363, 508, 283, 1545, 697, 356, 355, 14958, 14, 1932, 63, 12416, 563, 8, 5842, 12, 6211, 12, 574, 9, 288, 587, 26, 355, 14958, 14, 1932, 63, 12416, 563, 8, 5842, 9, 267, 916, 3105, 63, 4173, 26, 288, 870, 5190, 14, 1361, 63, 5842, 8, 5842, 9, 288, 984, 14, 2224, 8, 17, 9, 267, 587, 26, 288, 870, 574, 288, 984, 14, 2224, 8, 17, 9, 339, 372, 11553, 13316, 6992, 199, 199, 533, 7030, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 7104, 12, 666, 12, 1768, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 576, 275, 666, 267, 291, 14, 1302, 275, 1768, 267, 291, 14, 604, 275, 1543, 83, 60, 84, 7, 450, 1768, 267, 291, 14, 27131, 275, 756, 339, 347, 5666, 8, 277, 12, 18908, 304, 267, 291, 14, 604, 847, 1543, 83, 60, 84, 7, 450, 18908, 339, 347, 870, 63, 390, 8, 277, 304, 267, 340, 440, 291, 14, 27131, 26, 288, 870, 291, 14, 604, 288, 291, 14, 27131, 275, 715, 199, 199, 533, 11105, 4098, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 1415, 304, 267, 291, 14, 2427, 275, 1415, 267, 308, 275, 283, 8030, 2633, 787, 4124, 26, 450, 83, 7, 450, 291, 14, 2427, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 199, 199, 533, 3447, 2693, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 1125, 63, 1328, 304, 267, 308, 275, 283, 547, 2644, 574, 4366, 83, 3171, 450, 1125, 63, 1328, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 268, 199, 533, 9388, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 4766, 304, 267, 291, 14, 4273, 275, 4766, 267, 308, 275, 283, 5912, 4766, 26, 450, 83, 7, 450, 291, 14, 4273, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 268, 199, 533, 3447, 2693, 26, 339, 768, 3744, 272, 347, 3752, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 1768, 29, 403, 304, 267, 340, 299, 14, 354, 14, 2460, 30018, 288, 372, 267, 862, 26, 288, 333, 273, 68, 275, 2519, 8, 1886, 12, 283, 2143, 20013, 80, 14, 29707, 9, 288, 333, 273, 68, 8, 80, 12, 15099, 12, 373, 12, 1768, 9, 267, 871, 4281, 26, 288, 746, 3447, 2693, 547, 360, 5912, 730, 26, 450, 83, 7, 450, 299, 14, 29707, 9, 5493, 768, 3744, 272, 347, 3752, 63, 875, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 15099, 59, 1302, 61, 275, 373, 339, 3752, 63, 493, 275, 3752, 63, 875, 272, 3752, 63, 4869, 275, 3752, 63, 875, 339, 768, 3744, 272, 347, 3752, 63, 4115, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 15099, 59, 1302, 61, 275, 1543, 68, 7, 450, 373, 5493, 768, 3744, 272, 347, 3752, 63, 4871, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 340, 373, 26, 288, 373, 275, 283, 2052, 7, 267, 587, 26, 288, 373, 275, 283, 3910, 7, 267, 15099, 59, 1302, 61, 275, 373, 5493, 768, 3744, 272, 347, 3752, 63, 2083, 8, 1886, 12, 299 ]
[ 1898, 334, 67, 9, 7129, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 7129, 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, 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, 646, 984, 199, 646, 747, 199, 646, 6055, 199, 646, 8691, 199, 646, 1331, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 9751, 79, 14, 7231, 1131, 1364, 199, 199, 646, 330, 697, 199, 646, 5190, 199, 893, 26, 272, 492, 5442, 697, 465, 14958, 199, 2590, 3545, 26, 272, 492, 10543, 465, 14958, 199, 199, 318, 6055, 63, 2590, 63, 3664, 8, 17612, 63, 4173, 12, 3105, 63, 4173, 304, 272, 347, 11553, 13316, 6992, 8, 9749, 12, 574, 12, 7070, 304, 267, 340, 6211, 365, 330, 697, 14, 34, 697, 24145, 26, 288, 984, 14, 2224, 8, 17, 9, 267, 984, 14, 476, 301, 13316, 6992, 275, 984, 855, 476, 301, 13316, 6992, 363, 398, 340, 14958, 63, 4173, 436, 984, 14, 2703, 14, 21122, 342, 436, 984, 14, 6626, 14, 21122, 837, 288, 340, 14958, 855, 354, 363, 508, 283, 1545, 697, 356, 355, 14958, 14, 1932, 63, 12416, 563, 8, 5842, 12, 6211, 12, 574, 9, 288, 587, 26, 355, 14958, 14, 1932, 63, 12416, 563, 8, 5842, 9, 267, 916, 3105, 63, 4173, 26, 288, 870, 5190, 14, 1361, 63, 5842, 8, 5842, 9, 288, 984, 14, 2224, 8, 17, 9, 267, 587, 26, 288, 870, 574, 288, 984, 14, 2224, 8, 17, 9, 339, 372, 11553, 13316, 6992, 199, 199, 533, 7030, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 7104, 12, 666, 12, 1768, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 576, 275, 666, 267, 291, 14, 1302, 275, 1768, 267, 291, 14, 604, 275, 1543, 83, 60, 84, 7, 450, 1768, 267, 291, 14, 27131, 275, 756, 339, 347, 5666, 8, 277, 12, 18908, 304, 267, 291, 14, 604, 847, 1543, 83, 60, 84, 7, 450, 18908, 339, 347, 870, 63, 390, 8, 277, 304, 267, 340, 440, 291, 14, 27131, 26, 288, 870, 291, 14, 604, 288, 291, 14, 27131, 275, 715, 199, 199, 533, 11105, 4098, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 1415, 304, 267, 291, 14, 2427, 275, 1415, 267, 308, 275, 283, 8030, 2633, 787, 4124, 26, 450, 83, 7, 450, 291, 14, 2427, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 199, 199, 533, 3447, 2693, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 1125, 63, 1328, 304, 267, 308, 275, 283, 547, 2644, 574, 4366, 83, 3171, 450, 1125, 63, 1328, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 268, 199, 533, 9388, 547, 8, 10914, 14, 1971, 14, 20380, 19992, 304, 339, 347, 636, 826, 721, 277, 12, 4766, 304, 267, 291, 14, 4273, 275, 4766, 267, 308, 275, 283, 5912, 4766, 26, 450, 83, 7, 450, 291, 14, 4273, 267, 6055, 14, 1971, 14, 20380, 19992, 855, 826, 721, 277, 12, 308, 9, 268, 199, 533, 3447, 2693, 26, 339, 768, 3744, 272, 347, 3752, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 1768, 29, 403, 304, 267, 340, 299, 14, 354, 14, 2460, 30018, 288, 372, 267, 862, 26, 288, 333, 273, 68, 275, 2519, 8, 1886, 12, 283, 2143, 20013, 80, 14, 29707, 9, 288, 333, 273, 68, 8, 80, 12, 15099, 12, 373, 12, 1768, 9, 267, 871, 4281, 26, 288, 746, 3447, 2693, 547, 360, 5912, 730, 26, 450, 83, 7, 450, 299, 14, 29707, 9, 5493, 768, 3744, 272, 347, 3752, 63, 875, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 15099, 59, 1302, 61, 275, 373, 339, 3752, 63, 493, 275, 3752, 63, 875, 272, 3752, 63, 4869, 275, 3752, 63, 875, 339, 768, 3744, 272, 347, 3752, 63, 4115, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 15099, 59, 1302, 61, 275, 1543, 68, 7, 450, 373, 5493, 768, 3744, 272, 347, 3752, 63, 4871, 8, 1886, 12, 299, 12, 15099, 12, 373, 12, 634, 304, 267, 340, 634, 26, 288, 1768, 275, 634, 267, 587, 26, 288, 1768, 275, 299, 14, 354, 267, 340, 373, 26, 288, 373, 275, 283, 2052, 7, 267, 587, 26, 288, 373, 275, 283, 3910, 7, 267, 15099, 59, 1302, 61, 275, 373, 5493, 768, 3744, 272, 347, 3752, 63,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, 1, 1, 1, 1, 1, 1, 1, 1 ]
openmicroscopy/openmicroscopy
examples/Training/python/Task_Scripts/Raw_Data2.py
3
3011
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2011 University of Dundee & Open Microscopy Environment. # All Rights Reserved. # Use is subject to license terms supplied in LICENSE.txt # """ FOR TRAINING PURPOSES ONLY! """ # This is a 'bare-bones' template to allow easy conversion from a simple # client-side Python script to a script run by the server, on the OMERO # scripting service. # To use the script, simply paste the body of the script (not the connection # code) into the point indicated below. # A more complete template, for 'real-world' scripts, is also included in this # folder # This script takes an Image ID as a parameter from the scripting service. from __future__ import print_function import omero.util.script_utils as scriptUtil from omero.gateway import BlitzGateway from numpy import hstack, int32 from Parse_OMERO_Properties import USERNAME, PASSWORD, HOST, PORT from Parse_OMERO_Properties import imageId # Script definition conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT) conn.connect() # First Task: Get the Average pixel value for a specified region: image = conn.getObject("Image", imageId) print(image.getName()) size_z = image.getSizeZ() size_c = image.getSizeC() size_t = image.getSizeT() t, c = 0, 0 # first plane of the image z = size_z/2 # at the mid Z-section x, y, w, h = 5, 5, 100, 100 # Our pre-defined x, y, w, h tile = (x, y, w, h) pixels = image.getPrimaryPixels() tile_data = pixels.getTile(z, c, t, tile) # get a numpy array. print("Tile at zct tile: ", z, c, t, tile) print(tile_data) print("shape: ", tile_data.shape) print("min:", tile_data.min(), " max:", tile_data.max(), "pixel type:", tile_data.dtype.name) average = float(tile_data.sum()) / (w * h) print("Average :", average) # Advanced: For each time point, get a column of data (E.g. for kymograph) size_y = image.getSizeY() size_x = image.getSizeX() x = size_x/2 y = 0 width = 10 # we were asked for '1' but this looks nicer height = size_x tile = (x, y, width, height) col_data = [] # let's collect the column data for each time point for t in range(size_t): print("Getting data for T, tile:", t, tile) col = pixels.getTile(z, c, t, tile) col_data.append(col) # ** BONUS ** # stack the numpy columns horizontally. hstack is a numpy function kymograph_data = hstack(col_data) print("kymograph_data", kymograph_data.shape) name = "kymograph.png" min_max = (kymograph_data.min(), kymograph_data.max()) scriptUtil.numpy_save_as_image(kymograph_data, min_max, int32, name) # attach the png to the image file_ann = conn.createFileAnnfromLocalFile( name, mimetype="image/png") print("Attaching %s to image" % name) image.linkAnnotation(file_ann) message = "Tile average value: %s" % average # Close connection: # ================================================================= # When you are done, close the session to free up server resources. conn.close()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 15904, 402, 577, 324, 11192, 1253, 3232, 27022, 83, 1574, 9711, 14, 199, 3, 8540, 2900, 5924, 5702, 14, 199, 3, 3645, 365, 5420, 370, 4190, 2895, 6841, 315, 5113, 14, 2424, 199, 3, 199, 199, 624, 199, 2707, 377, 21715, 1206, 3084, 9263, 654, 5258, 6084, 1, 199, 624, 199, 199, 3, 961, 365, 282, 283, 14890, 13, 66, 4548, 7, 1978, 370, 2040, 8837, 8603, 687, 282, 3486, 199, 3, 1890, 13, 2441, 2018, 2884, 370, 282, 2884, 1255, 701, 314, 1654, 12, 641, 314, 593, 45, 12960, 199, 3, 2884, 316, 2435, 14, 199, 3, 4005, 675, 314, 2884, 12, 9329, 20901, 314, 2396, 402, 314, 2884, 334, 1397, 314, 1950, 199, 3, 1233, 9, 1901, 314, 2376, 22141, 5084, 14, 199, 3, 437, 1655, 4890, 1978, 12, 367, 283, 3093, 13, 7617, 7, 10554, 12, 365, 2597, 5120, 315, 642, 199, 3, 4922, 199, 3, 961, 2884, 6181, 376, 6047, 2870, 465, 282, 2725, 687, 314, 2884, 316, 2435, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 27122, 14, 1974, 14, 1579, 63, 1208, 465, 2884, 9562, 199, 504, 27122, 14, 7019, 492, 699, 29382, 12455, 199, 504, 2680, 492, 394, 2340, 12, 1109, 708, 199, 504, 6077, 63, 7474, 12960, 63, 8516, 492, 13044, 2339, 12, 21705, 5172, 12, 25741, 12, 25562, 199, 504, 6077, 63, 7474, 12960, 63, 8516, 492, 1834, 1304, 199, 199, 3, 14914, 5492, 199, 199, 1631, 275, 699, 29382, 12455, 8, 11958, 12, 21705, 5172, 12, 1591, 29, 5449, 12, 1844, 29, 3657, 9, 199, 1631, 14, 2242, 342, 199, 199, 3, 7758, 8495, 26, 2372, 314, 437, 3652, 7148, 574, 367, 282, 2013, 4897, 26, 199, 1569, 275, 2557, 14, 362, 1692, 480, 3491, 401, 1834, 1304, 9, 199, 1361, 8, 1569, 14, 16405, 1012, 199, 890, 63, 90, 275, 1834, 14, 362, 2320, 58, 342, 199, 890, 63, 67, 275, 1834, 14, 362, 2320, 35, 342, 199, 890, 63, 84, 275, 1834, 14, 362, 2320, 52, 342, 199, 84, 12, 286, 275, 378, 12, 378, 9326, 327, 1642, 16388, 402, 314, 1834, 199, 90, 275, 1568, 63, 90, 15, 18, 9326, 327, 737, 314, 10887, 3107, 13, 2792, 199, 88, 12, 612, 12, 336, 12, 394, 275, 959, 12, 959, 12, 2948, 12, 2948, 263, 327, 25119, 876, 13, 4037, 671, 12, 612, 12, 336, 12, 394, 199, 7172, 275, 334, 88, 12, 612, 12, 336, 12, 394, 9, 199, 15727, 275, 1834, 14, 362, 14908, 29170, 342, 199, 7172, 63, 576, 275, 11094, 14, 362, 29746, 8, 90, 12, 286, 12, 307, 12, 12835, 9, 420, 327, 664, 282, 2680, 1625, 14, 199, 1361, 480, 29746, 737, 1315, 319, 12835, 26, 3872, 1315, 12, 286, 12, 307, 12, 12835, 9, 199, 1361, 8, 7172, 63, 576, 9, 199, 1361, 480, 1392, 26, 3872, 12835, 63, 576, 14, 1392, 9, 199, 1361, 480, 827, 6783, 12835, 63, 576, 14, 827, 1062, 298, 1390, 6783, 12835, 63, 576, 14, 988, 1062, 489, 298, 8435, 730, 6783, 12835, 63, 576, 14, 2271, 14, 354, 9, 199, 8536, 275, 2069, 8, 7172, 63, 576, 14, 1838, 1012, 1182, 334, 87, 627, 394, 9, 199, 1361, 480, 17400, 520, 401, 8095, 9, 421, 199, 3, 32445, 26, 2104, 1924, 900, 2376, 12, 664, 282, 2763, 402, 666, 334, 37, 14, 71, 14, 367, 1022, 89, 573, 2180, 9, 199, 890, 63, 89, 275, 1834, 14, 362, 2320, 57, 342, 199, 890, 63, 88, 275, 1834, 14, 362, 2320, 56, 342, 199, 88, 275, 1568, 63, 88, 15, 18, 199, 89, 275, 378, 199, 2063, 275, 1616, 263, 327, 781, 4898, 20864, 367, 283, 17, 7, 1325, 642, 10734, 30023, 199, 3333, 275, 1568, 63, 88, 199, 7172, 275, 334, 88, 12, 612, 12, 3462, 12, 4569, 9, 199, 761, 63, 576, 275, 942, 257, 327, 4691, 1159, 8775, 314, 2763, 666, 367, 1924, 900, 2376, 199, 199, 509, 307, 315, 1425, 8, 890, 63, 84, 304, 272, 870, 480, 28277, 666, 367, 377, 12, 12835, 6783, 307, 12, 12835, 9, 272, 1048, 275, 11094, 14, 362, 29746, 8, 90, 12, 286, 12, 307, 12, 12835, 9, 272, 1048, 63, 576, 14, 740, 8, 761, 9, 199, 199, 3, 1011, 699, 615, 1668, 1011, 199, 3, 3464, 314, 2680, 4362, 394, 7366, 1183, 14, 394, 2340, 365, 282, 2680, 805, 199, 10562, 573, 2180, 63, 576, 275, 394, 2340, 8, 761, 63, 576, 9, 199, 1361, 480, 10562, 573, 2180, 63, 576, 401, 1022, 89, 573, 2180, 63, 576, 14, 1392, 9, 199, 199, 354, 275, 298, 10562, 573, 2180, 14, 4524, 2, 199, 827, 63, 988, 275, 334, 10562, 573, 2180, 63, 576, 14, 827, 1062, 1022, 89, 573, 2180, 63, 576, 14, 988, 1012, 199, 1579, 9562, 14, 4714, 63, 2117, 63, 305, 63, 1569, 8, 10562, 573, 2180, 63, 576, 12, 1748, 63, 988, 12, 1109, 708, 12, 536, 9, 199, 199, 3, 6554, 314, 25296, 370, 314, 1834, 199, 493, 63, 1189, 275, 2557, 14, 981, 1173, 2493, 78, 504, 5339, 1173, 8, 272, 536, 12, 12200, 628, 1569, 15, 4524, 531, 199, 1361, 480, 13240, 316, 450, 83, 370, 1834, 2, 450, 536, 9, 199, 1569, 14, 1073, 16768, 8, 493, 63, 1189, 9, 199, 199, 1188, 275, 298, 29746, 8095, 574, 26, 450, 83, 2, 450, 8095, 199, 199, 3, 15524, 1950, 26, 199, 3, 7819, 199, 3, 3979, 1265, 787, 4224, 12, 4002, 314, 2351, 370, 2867, 1536, 1654, 5944, 14, 199, 1631, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 15904, 402, 577, 324, 11192, 1253, 3232, 27022, 83, 1574, 9711, 14, 199, 3, 8540, 2900, 5924, 5702, 14, 199, 3, 3645, 365, 5420, 370, 4190, 2895, 6841, 315, 5113, 14, 2424, 199, 3, 199, 199, 624, 199, 2707, 377, 21715, 1206, 3084, 9263, 654, 5258, 6084, 1, 199, 624, 199, 199, 3, 961, 365, 282, 283, 14890, 13, 66, 4548, 7, 1978, 370, 2040, 8837, 8603, 687, 282, 3486, 199, 3, 1890, 13, 2441, 2018, 2884, 370, 282, 2884, 1255, 701, 314, 1654, 12, 641, 314, 593, 45, 12960, 199, 3, 2884, 316, 2435, 14, 199, 3, 4005, 675, 314, 2884, 12, 9329, 20901, 314, 2396, 402, 314, 2884, 334, 1397, 314, 1950, 199, 3, 1233, 9, 1901, 314, 2376, 22141, 5084, 14, 199, 3, 437, 1655, 4890, 1978, 12, 367, 283, 3093, 13, 7617, 7, 10554, 12, 365, 2597, 5120, 315, 642, 199, 3, 4922, 199, 3, 961, 2884, 6181, 376, 6047, 2870, 465, 282, 2725, 687, 314, 2884, 316, 2435, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 27122, 14, 1974, 14, 1579, 63, 1208, 465, 2884, 9562, 199, 504, 27122, 14, 7019, 492, 699, 29382, 12455, 199, 504, 2680, 492, 394, 2340, 12, 1109, 708, 199, 504, 6077, 63, 7474, 12960, 63, 8516, 492, 13044, 2339, 12, 21705, 5172, 12, 25741, 12, 25562, 199, 504, 6077, 63, 7474, 12960, 63, 8516, 492, 1834, 1304, 199, 199, 3, 14914, 5492, 199, 199, 1631, 275, 699, 29382, 12455, 8, 11958, 12, 21705, 5172, 12, 1591, 29, 5449, 12, 1844, 29, 3657, 9, 199, 1631, 14, 2242, 342, 199, 199, 3, 7758, 8495, 26, 2372, 314, 437, 3652, 7148, 574, 367, 282, 2013, 4897, 26, 199, 1569, 275, 2557, 14, 362, 1692, 480, 3491, 401, 1834, 1304, 9, 199, 1361, 8, 1569, 14, 16405, 1012, 199, 890, 63, 90, 275, 1834, 14, 362, 2320, 58, 342, 199, 890, 63, 67, 275, 1834, 14, 362, 2320, 35, 342, 199, 890, 63, 84, 275, 1834, 14, 362, 2320, 52, 342, 199, 84, 12, 286, 275, 378, 12, 378, 9326, 327, 1642, 16388, 402, 314, 1834, 199, 90, 275, 1568, 63, 90, 15, 18, 9326, 327, 737, 314, 10887, 3107, 13, 2792, 199, 88, 12, 612, 12, 336, 12, 394, 275, 959, 12, 959, 12, 2948, 12, 2948, 263, 327, 25119, 876, 13, 4037, 671, 12, 612, 12, 336, 12, 394, 199, 7172, 275, 334, 88, 12, 612, 12, 336, 12, 394, 9, 199, 15727, 275, 1834, 14, 362, 14908, 29170, 342, 199, 7172, 63, 576, 275, 11094, 14, 362, 29746, 8, 90, 12, 286, 12, 307, 12, 12835, 9, 420, 327, 664, 282, 2680, 1625, 14, 199, 1361, 480, 29746, 737, 1315, 319, 12835, 26, 3872, 1315, 12, 286, 12, 307, 12, 12835, 9, 199, 1361, 8, 7172, 63, 576, 9, 199, 1361, 480, 1392, 26, 3872, 12835, 63, 576, 14, 1392, 9, 199, 1361, 480, 827, 6783, 12835, 63, 576, 14, 827, 1062, 298, 1390, 6783, 12835, 63, 576, 14, 988, 1062, 489, 298, 8435, 730, 6783, 12835, 63, 576, 14, 2271, 14, 354, 9, 199, 8536, 275, 2069, 8, 7172, 63, 576, 14, 1838, 1012, 1182, 334, 87, 627, 394, 9, 199, 1361, 480, 17400, 520, 401, 8095, 9, 421, 199, 3, 32445, 26, 2104, 1924, 900, 2376, 12, 664, 282, 2763, 402, 666, 334, 37, 14, 71, 14, 367, 1022, 89, 573, 2180, 9, 199, 890, 63, 89, 275, 1834, 14, 362, 2320, 57, 342, 199, 890, 63, 88, 275, 1834, 14, 362, 2320, 56, 342, 199, 88, 275, 1568, 63, 88, 15, 18, 199, 89, 275, 378, 199, 2063, 275, 1616, 263, 327, 781, 4898, 20864, 367, 283, 17, 7, 1325, 642, 10734, 30023, 199, 3333, 275, 1568, 63, 88, 199, 7172, 275, 334, 88, 12, 612, 12, 3462, 12, 4569, 9, 199, 761, 63, 576, 275, 942, 257, 327, 4691, 1159, 8775, 314, 2763, 666, 367, 1924, 900, 2376, 199, 199, 509, 307, 315, 1425, 8, 890, 63, 84, 304, 272, 870, 480, 28277, 666, 367, 377, 12, 12835, 6783, 307, 12, 12835, 9, 272, 1048, 275, 11094, 14, 362, 29746, 8, 90, 12, 286, 12, 307, 12, 12835, 9, 272, 1048, 63, 576, 14, 740, 8, 761, 9, 199, 199, 3, 1011, 699, 615, 1668, 1011, 199, 3, 3464, 314, 2680, 4362, 394, 7366, 1183, 14, 394, 2340, 365, 282, 2680, 805, 199, 10562, 573, 2180, 63, 576, 275, 394, 2340, 8, 761, 63, 576, 9, 199, 1361, 480, 10562, 573, 2180, 63, 576, 401, 1022, 89, 573, 2180, 63, 576, 14, 1392, 9, 199, 199, 354, 275, 298, 10562, 573, 2180, 14, 4524, 2, 199, 827, 63, 988, 275, 334, 10562, 573, 2180, 63, 576, 14, 827, 1062, 1022, 89, 573, 2180, 63, 576, 14, 988, 1012, 199, 1579, 9562, 14, 4714, 63, 2117, 63, 305, 63, 1569, 8, 10562, 573, 2180, 63, 576, 12, 1748, 63, 988, 12, 1109, 708, 12, 536, 9, 199, 199, 3, 6554, 314, 25296, 370, 314, 1834, 199, 493, 63, 1189, 275, 2557, 14, 981, 1173, 2493, 78, 504, 5339, 1173, 8, 272, 536, 12, 12200, 628, 1569, 15, 4524, 531, 199, 1361, 480, 13240, 316, 450, 83, 370, 1834, 2, 450, 536, 9, 199, 1569, 14, 1073, 16768, 8, 493, 63, 1189, 9, 199, 199, 1188, 275, 298, 29746, 8095, 574, 26, 450, 83, 2, 450, 8095, 199, 199, 3, 15524, 1950, 26, 199, 3, 7819, 199, 3, 3979, 1265, 787, 4224, 12, 4002, 314, 2351, 370, 2867, 1536, 1654, 5944, 14, 199, 1631, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1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
vmlinz/python_koans
python2/koans/about_attribute_access.py
88
7140
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Partially based on AboutMessagePassing in the Ruby Koans # from runner.koan import * class AboutAttributeAccess(Koan): class TypicalObject(object): pass def test_calling_undefined_functions_normally_results_in_errors(self): typical = self.TypicalObject() try: typical.foobar() except Exception as exception: self.assertEqual(__, exception.__class__.__name__) self.assertMatch(__, exception[0]) def test_calling_getattribute_causes_an_attribute_error(self): typical = self.TypicalObject() try: typical.__getattribute__('foobar') except AttributeError as exception: self.assertMatch(__, exception[0]) # THINK ABOUT IT: # # If the method __getattribute__() causes the AttributeError, then # what would happen if we redefine __getattribute__()? # ------------------------------------------------------------------ class CatchAllAttributeReads(object): def __getattribute__(self, attr_name): return "Someone called '" + attr_name + \ "' and it could not be found" def test_all_attribute_reads_are_caught(self): catcher = self.CatchAllAttributeReads() self.assertMatch(__, catcher.foobar) def test_intercepting_return_values_can_disrupt_the_call_chain(self): catcher = self.CatchAllAttributeReads() self.assertMatch(__, catcher.foobaz) # This is fine try: catcher.foobaz(1) except TypeError as ex: self.assertMatch(__, ex[0]) # foobaz returns a string. What happens to the '(1)' part? # Try entering this into a python console to reproduce the issue: # # "foobaz"(1) # def test_changing_getattribute_will_affect__the_getattr_function(self): catcher = self.CatchAllAttributeReads() self.assertMatch(__, getattr(catcher, 'any_attribute')) # ------------------------------------------------------------------ class WellBehavedFooCatcher(object): def __getattribute__(self, attr_name): if attr_name[:3] == "foo": return "Foo to you too" else: return \ super(AboutAttributeAccess.WellBehavedFooCatcher, self). \ __getattribute__(attr_name) def test_foo_attributes_are_caught(self): catcher = self.WellBehavedFooCatcher() self.assertEqual(__, catcher.foo_bar) self.assertEqual(__, catcher.foo_baz) def test_non_foo_messages_are_treated_normally(self): catcher = self.WellBehavedFooCatcher() try: catcher.normal_undefined_attribute except AttributeError as ex: self.assertMatch(__, ex[0]) # ------------------------------------------------------------------ global stack_depth stack_depth = 0 class RecursiveCatcher(object): def __init__(self): global stack_depth stack_depth = 0 self.no_of_getattribute_calls = 0 def __getattribute__(self, attr_name): #Uncomment for debugging info: #print 'Debug __getattribute__(' + type(self).__name__ + \ # "." + attr_name + ") dict=" + str(self.__dict__) # We need something that is outside the scope of this class: global stack_depth stack_depth += 1 if stack_depth <= 10: # to prevent a stack overflow self.no_of_getattribute_calls += 1 # Oops! We just accessed an attribute: no_of_getattribute_calls # Guess what happens when self.no_of_getattribute_calls is # accessed? # Using 'object' directly because using super() here will also # trigger a __getattribute__() call. return object.__getattribute__(self, attr_name) def my_method(self): pass def test_getattribute_is_a_bit_overzealous_sometimes(self): catcher = self.RecursiveCatcher() catcher.my_method() global stack_depth self.assertEqual(__, stack_depth) # ------------------------------------------------------------------ class MinimalCatcher(object): class DuffObject(object): pass def __init__(self): self.no_of_getattr_calls = 0 def __getattr__(self, attr_name): self.no_of_getattr_calls += 1 return self.DuffObject def my_method(self): pass def test_getattr_ignores_known_attributes(self): catcher = self.MinimalCatcher() catcher.my_method() self.assertEqual(__, catcher.no_of_getattr_calls) def test_getattr_only_catches_unknown_attributes(self): catcher = self.MinimalCatcher() catcher.purple_flamingos() catcher.free_pie() self.assertEqual(__, catcher.give_me_duff_or_give_me_death().__class__.__name__) self.assertEqual(__, catcher.no_of_getattr_calls) # ------------------------------------------------------------------ class PossessiveSetter(object): def __setattr__(self, attr_name, value): new_attr_name = attr_name if attr_name[-5:] == 'comic': new_attr_name = "my_" + new_attr_name elif attr_name[-3:] == 'pie': new_attr_name = "a_" + new_attr_name object.__setattr__(self, new_attr_name, value) def test_setattr_intercepts_attribute_assignments(self): fanboy = self.PossessiveSetter() fanboy.comic = 'The Laminator, issue #1' fanboy.pie = 'blueberry' self.assertEqual(__, fanboy.a_pie) # # NOTE: Change the prefix to make this next assert pass # prefix = '__' self.assertEqual( "The Laminator, issue #1", getattr(fanboy, prefix + '_comic')) # ------------------------------------------------------------------ class ScarySetter(object): def __init__(self): self.num_of_coconuts = 9 self._num_of_private_coconuts = 2 def __setattr__(self, attr_name, value): new_attr_name = attr_name if attr_name[0] != '_': new_attr_name = "altered_" + new_attr_name object.__setattr__(self, new_attr_name, value) def test_it_modifies_external_attribute_as_expected(self): setter = self.ScarySetter() setter.e = "mc hammer" self.assertEqual(__, setter.altered_e) def test_it_mangles_some_internal_attributes(self): setter = self.ScarySetter() try: coconuts = setter.num_of_coconuts except AttributeError: self.assertEqual(__, setter.altered_num_of_coconuts) def test_in_this_case_private_attributes_remain_unmangled(self): setter = self.ScarySetter() self.assertEqual(__, setter._num_of_private_coconuts)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 199, 3, 2235, 9406, 4079, 641, 25225, 2209, 4986, 316, 315, 314, 820, 10972, 1804, 79, 796, 199, 3, 199, 199, 504, 7876, 14, 7697, 290, 492, 627, 421, 199, 533, 25225, 1646, 3946, 8, 31305, 290, 304, 339, 1021, 29267, 1692, 8, 785, 304, 267, 986, 339, 347, 511, 63, 25566, 63, 10705, 63, 5777, 63, 4791, 1183, 63, 2604, 63, 262, 63, 2550, 8, 277, 304, 267, 25780, 275, 291, 14, 26876, 1692, 342, 398, 862, 26, 288, 25780, 14, 9664, 342, 267, 871, 2186, 465, 1919, 26, 288, 291, 14, 629, 32485, 1919, 855, 533, 4914, 354, 3368, 288, 291, 14, 479, 4486, 32485, 1919, 59, 16, 566, 339, 347, 511, 63, 25566, 63, 18480, 63, 696, 5589, 63, 290, 63, 3215, 63, 705, 8, 277, 304, 267, 25780, 275, 291, 14, 26876, 1692, 342, 398, 862, 26, 288, 25780, 855, 18480, 19734, 9664, 358, 267, 871, 4281, 465, 1919, 26, 288, 291, 14, 479, 4486, 32485, 1919, 59, 16, 566, 398, 327, 4221, 12394, 14840, 1877, 473, 52, 26, 267, 327, 267, 327, 982, 314, 1083, 636, 18480, 4533, 14486, 314, 4281, 12, 2066, 267, 327, 4052, 3955, 5992, 340, 781, 295, 4640, 636, 18480, 4533, 31, 339, 327, 5620, 306, 339, 1021, 32754, 2422, 1646, 23614, 8, 785, 304, 267, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 372, 298, 7700, 368, 2797, 5522, 435, 1921, 63, 354, 435, 971, 355, 3546, 436, 652, 4293, 440, 506, 1911, 2, 339, 347, 511, 63, 452, 63, 3215, 63, 15656, 63, 1530, 63, 24872, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 8579, 281, 14, 9664, 9, 339, 347, 511, 63, 10863, 316, 63, 1107, 63, 1459, 63, 2425, 63, 2297, 6987, 63, 1589, 63, 1250, 63, 4429, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 8579, 281, 14, 1421, 6185, 9, 221, 327, 961, 365, 15701, 398, 862, 26, 288, 8579, 281, 14, 1421, 6185, 8, 17, 9, 267, 871, 3146, 465, 444, 26, 288, 291, 14, 479, 4486, 32485, 444, 59, 16, 566, 398, 327, 3925, 6185, 2529, 282, 1059, 14, 14791, 10986, 370, 314, 8189, 17, 3171, 1777, 31, 267, 327, 7649, 9509, 316, 642, 1901, 282, 2366, 8559, 370, 9172, 314, 4976, 26, 267, 327, 267, 327, 258, 298, 1421, 6185, 26507, 17, 9, 267, 327, 339, 347, 511, 63, 29131, 63, 18480, 63, 14117, 63, 65, 5551, 363, 1589, 63, 5675, 63, 1593, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 2519, 8, 9341, 281, 12, 283, 1629, 63, 3215, 1333, 339, 327, 5620, 306, 339, 1021, 644, 1697, 3655, 72, 4292, 5686, 26096, 281, 8, 785, 304, 267, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 340, 1921, 63, 354, 1491, 19, 61, 508, 298, 1421, 582, 355, 372, 298, 5686, 370, 1265, 4634, 2, 288, 587, 26, 355, 372, 971, 490, 1613, 8, 18816, 1646, 3946, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 12, 291, 680, 971, 490, 636, 18480, 721, 962, 63, 354, 9, 339, 347, 511, 63, 1421, 63, 2987, 63, 1530, 63, 24872, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 342, 398, 291, 14, 629, 32485, 8579, 281, 14, 1421, 63, 1700, 9, 267, 291, 14, 629, 32485, 8579, 281, 14, 1421, 63, 6185, 9, 339, 347, 511, 63, 2865, 63, 1421, 63, 3431, 63, 1530, 63, 84, 9640, 63, 4791, 1183, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 342, 398, 862, 26, 288, 8579, 281, 14, 3302, 63, 10705, 63, 3215, 267, 871, 4281, 465, 444, 26, 288, 291, 14, 479, 4486, 32485, 444, 59, 16, 566, 339, 327, 5620, 306, 339, 2288, 3464, 63, 4631, 272, 3464, 63, 4631, 275, 378, 339, 1021, 18306, 3398, 26096, 281, 8, 785, 304, 267, 347, 636, 826, 721, 277, 304, 288, 2288, 3464, 63, 4631, 288, 3464, 63, 4631, 275, 378, 288, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 275, 378, 398, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 327, 1358, 3349, 367, 10201, 2256, 26, 288, 327, 1361, 283, 7084, 636, 18480, 19734, 435, 730, 8, 277, 2843, 354, 363, 435, 971, 288, 327, 259, 14530, 435, 1921, 63, 354, 435, 6099, 1211, 628, 435, 620, 8, 277, 855, 807, 3368, 953, 327, 2136, 1929, 6020, 626, 365, 9682, 314, 4194, 402, 642, 1021, 26, 288, 2288, 3464, 63, 4631, 288, 3464, 63, 4631, 847, 413, 953, 340, 3464, 63, 4631, 2695, 1616, 26, 221, 327, 370, 7981, 282, 3464, 15784, 355, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 847, 413, 355, 327, 593, 1483, 1, 2136, 2951, 13810, 376, 2225, 26, 949, 63, 1618, 63, 18480, 63, 5352, 355, 327, 24570, 4052, 10986, 1380, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 365, 355, 327, 13810, 31, 953, 327, 11719, 283, 785, 7, 5370, 2952, 1808, 1613, 342, 2348, 911, 2597, 288, 327, 6804, 282, 636, 18480, 4533, 1240, 14, 288, 372, 909, 855, 18480, 721, 277, 12, 1921, 63, 354, 9, 398, 347, 3002, 63, 765, 8, 277, 304, 288, 986, 339, 347, 511, 63, 18480, 63, 374, 63, 65, 63, 2075, 63, 1883, 806, 279, 1785, 63, 3972, 4508, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 25122, 26096, 281, 342, 267, 8579, 281, 14, 1662, 63, 765, 342, 267, 2288, 3464, 63, 4631, 267, 291, 14, 629, 32485, 3464, 63, 4631, 9, 339, 327, 5620, 306, 339, 1021, 10195, 7265, 26096, 281, 8, 785, 304, 267, 1021, 577, 3043, 1692, 8, 785, 304, 288, 986, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 889, 63, 1618, 63, 5675, 63, 5352, 275, 378, 398, 347, 636, 5675, 721, 277, 12, 1921, 63, 354 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 199, 3, 2235, 9406, 4079, 641, 25225, 2209, 4986, 316, 315, 314, 820, 10972, 1804, 79, 796, 199, 3, 199, 199, 504, 7876, 14, 7697, 290, 492, 627, 421, 199, 533, 25225, 1646, 3946, 8, 31305, 290, 304, 339, 1021, 29267, 1692, 8, 785, 304, 267, 986, 339, 347, 511, 63, 25566, 63, 10705, 63, 5777, 63, 4791, 1183, 63, 2604, 63, 262, 63, 2550, 8, 277, 304, 267, 25780, 275, 291, 14, 26876, 1692, 342, 398, 862, 26, 288, 25780, 14, 9664, 342, 267, 871, 2186, 465, 1919, 26, 288, 291, 14, 629, 32485, 1919, 855, 533, 4914, 354, 3368, 288, 291, 14, 479, 4486, 32485, 1919, 59, 16, 566, 339, 347, 511, 63, 25566, 63, 18480, 63, 696, 5589, 63, 290, 63, 3215, 63, 705, 8, 277, 304, 267, 25780, 275, 291, 14, 26876, 1692, 342, 398, 862, 26, 288, 25780, 855, 18480, 19734, 9664, 358, 267, 871, 4281, 465, 1919, 26, 288, 291, 14, 479, 4486, 32485, 1919, 59, 16, 566, 398, 327, 4221, 12394, 14840, 1877, 473, 52, 26, 267, 327, 267, 327, 982, 314, 1083, 636, 18480, 4533, 14486, 314, 4281, 12, 2066, 267, 327, 4052, 3955, 5992, 340, 781, 295, 4640, 636, 18480, 4533, 31, 339, 327, 5620, 306, 339, 1021, 32754, 2422, 1646, 23614, 8, 785, 304, 267, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 372, 298, 7700, 368, 2797, 5522, 435, 1921, 63, 354, 435, 971, 355, 3546, 436, 652, 4293, 440, 506, 1911, 2, 339, 347, 511, 63, 452, 63, 3215, 63, 15656, 63, 1530, 63, 24872, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 8579, 281, 14, 9664, 9, 339, 347, 511, 63, 10863, 316, 63, 1107, 63, 1459, 63, 2425, 63, 2297, 6987, 63, 1589, 63, 1250, 63, 4429, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 8579, 281, 14, 1421, 6185, 9, 221, 327, 961, 365, 15701, 398, 862, 26, 288, 8579, 281, 14, 1421, 6185, 8, 17, 9, 267, 871, 3146, 465, 444, 26, 288, 291, 14, 479, 4486, 32485, 444, 59, 16, 566, 398, 327, 3925, 6185, 2529, 282, 1059, 14, 14791, 10986, 370, 314, 8189, 17, 3171, 1777, 31, 267, 327, 7649, 9509, 316, 642, 1901, 282, 2366, 8559, 370, 9172, 314, 4976, 26, 267, 327, 267, 327, 258, 298, 1421, 6185, 26507, 17, 9, 267, 327, 339, 347, 511, 63, 29131, 63, 18480, 63, 14117, 63, 65, 5551, 363, 1589, 63, 5675, 63, 1593, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 26096, 2422, 1646, 23614, 342, 398, 291, 14, 479, 4486, 32485, 2519, 8, 9341, 281, 12, 283, 1629, 63, 3215, 1333, 339, 327, 5620, 306, 339, 1021, 644, 1697, 3655, 72, 4292, 5686, 26096, 281, 8, 785, 304, 267, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 340, 1921, 63, 354, 1491, 19, 61, 508, 298, 1421, 582, 355, 372, 298, 5686, 370, 1265, 4634, 2, 288, 587, 26, 355, 372, 971, 490, 1613, 8, 18816, 1646, 3946, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 12, 291, 680, 971, 490, 636, 18480, 721, 962, 63, 354, 9, 339, 347, 511, 63, 1421, 63, 2987, 63, 1530, 63, 24872, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 342, 398, 291, 14, 629, 32485, 8579, 281, 14, 1421, 63, 1700, 9, 267, 291, 14, 629, 32485, 8579, 281, 14, 1421, 63, 6185, 9, 339, 347, 511, 63, 2865, 63, 1421, 63, 3431, 63, 1530, 63, 84, 9640, 63, 4791, 1183, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 55, 1697, 3655, 72, 4292, 5686, 26096, 281, 342, 398, 862, 26, 288, 8579, 281, 14, 3302, 63, 10705, 63, 3215, 267, 871, 4281, 465, 444, 26, 288, 291, 14, 479, 4486, 32485, 444, 59, 16, 566, 339, 327, 5620, 306, 339, 2288, 3464, 63, 4631, 272, 3464, 63, 4631, 275, 378, 339, 1021, 18306, 3398, 26096, 281, 8, 785, 304, 267, 347, 636, 826, 721, 277, 304, 288, 2288, 3464, 63, 4631, 288, 3464, 63, 4631, 275, 378, 288, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 275, 378, 398, 347, 636, 18480, 721, 277, 12, 1921, 63, 354, 304, 288, 327, 1358, 3349, 367, 10201, 2256, 26, 288, 327, 1361, 283, 7084, 636, 18480, 19734, 435, 730, 8, 277, 2843, 354, 363, 435, 971, 288, 327, 259, 14530, 435, 1921, 63, 354, 435, 6099, 1211, 628, 435, 620, 8, 277, 855, 807, 3368, 953, 327, 2136, 1929, 6020, 626, 365, 9682, 314, 4194, 402, 642, 1021, 26, 288, 2288, 3464, 63, 4631, 288, 3464, 63, 4631, 847, 413, 953, 340, 3464, 63, 4631, 2695, 1616, 26, 221, 327, 370, 7981, 282, 3464, 15784, 355, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 847, 413, 355, 327, 593, 1483, 1, 2136, 2951, 13810, 376, 2225, 26, 949, 63, 1618, 63, 18480, 63, 5352, 355, 327, 24570, 4052, 10986, 1380, 291, 14, 889, 63, 1618, 63, 18480, 63, 5352, 365, 355, 327, 13810, 31, 953, 327, 11719, 283, 785, 7, 5370, 2952, 1808, 1613, 342, 2348, 911, 2597, 288, 327, 6804, 282, 636, 18480, 4533, 1240, 14, 288, 372, 909, 855, 18480, 721, 277, 12, 1921, 63, 354, 9, 398, 347, 3002, 63, 765, 8, 277, 304, 288, 986, 339, 347, 511, 63, 18480, 63, 374, 63, 65, 63, 2075, 63, 1883, 806, 279, 1785, 63, 3972, 4508, 8, 277, 304, 267, 8579, 281, 275, 291, 14, 25122, 26096, 281, 342, 267, 8579, 281, 14, 1662, 63, 765, 342, 267, 2288, 3464, 63, 4631, 267, 291, 14, 629, 32485, 3464, 63, 4631, 9, 339, 327, 5620, 306, 339, 1021, 10195, 7265, 26096, 281, 8, 785, 304, 267, 1021, 577, 3043, 1692, 8, 785, 304, 288, 986, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 889, 63, 1618, 63, 5675, 63, 5352, 275, 378, 398, 347, 636, 5675, 721, 277, 12, 1921, 63, 354, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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auto__add_field_mapdata_hist_region__add_field_mapdata_region.py
3
9163
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MapData_hist.region' db.add_column('maps_mapdata_hist', 'region', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['regions.Region'], null=True), keep_default=False) # Adding field 'MapData.region' db.add_column('maps_mapdata', 'region', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['regions.Region'], null=True), keep_default=False) def backwards(self, orm): # Deleting field 'MapData_hist.region' db.delete_column('maps_mapdata_hist', 'region_id') # Deleting field 'MapData.region' db.delete_column('maps_mapdata', 'region_id') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'maps.mapdata': { 'Meta': {'object_name': 'MapData'}, 'geom': ('maps.fields.FlatCollectionFrom', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'length': ('django.db.models.fields.FloatField', [], {'null': 'True'}), 'lines': ('django.contrib.gis.db.models.fields.MultiLineStringField', [], {'null': 'True', 'blank': 'True'}), 'page': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['pages.Page']", 'unique': 'True'}), 'points': ('django.contrib.gis.db.models.fields.MultiPointField', [], {'null': 'True', 'blank': 'True'}), 'polys': ('django.contrib.gis.db.models.fields.MultiPolygonField', [], {'null': 'True', 'blank': 'True'}), 'region': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regions.Region']", 'null': 'True'}) }, 'maps.mapdata_hist': { 'Meta': {'ordering': "('-history_date',)", 'object_name': 'MapData_hist'}, 'geom': ('maps.fields.FlatCollectionFrom', [], {'null': 'True'}), 'history_comment': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'history_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'history_reverted_to_version': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['maps.MapData_hist']", 'null': 'True'}), 'history_type': ('django.db.models.fields.SmallIntegerField', [], {}), 'history_user': ('versionutils.versioning.fields.AutoUserField', [], {'to': "orm['auth.User']", 'null': 'True'}), 'history_user_ip': ('versionutils.versioning.fields.AutoIPAddressField', [], {'max_length': '15', 'null': 'True'}), 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), 'length': ('django.db.models.fields.FloatField', [], {'null': 'True'}), 'lines': ('django.contrib.gis.db.models.fields.MultiLineStringField', [], {'null': 'True', 'blank': 'True'}), 'page': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['pages.Page_hist']"}), 'points': ('django.contrib.gis.db.models.fields.MultiPointField', [], {'null': 'True', 'blank': 'True'}), 'polys': ('django.contrib.gis.db.models.fields.MultiPolygonField', [], {'null': 'True', 'blank': 'True'}), 'region': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regions.Region']", 'null': 'True'}) }, 'pages.page': { 'Meta': {'unique_together': "(('slug', 'region'),)", 'object_name': 'Page'}, 'content': ('pages.fields.WikiHTMLField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'region': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regions.Region']", 'null': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'}) }, 'pages.page_hist': { 'Meta': {'ordering': "('-history_date',)", 'object_name': 'Page_hist'}, 'content': ('pages.fields.WikiHTMLField', [], {}), 'history_comment': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), 'history_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'history_reverted_to_version': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['pages.Page_hist']", 'null': 'True'}), 'history_type': ('django.db.models.fields.SmallIntegerField', [], {}), 'history_user': ('versionutils.versioning.fields.AutoUserField', [], {'to': "orm['auth.User']", 'null': 'True'}), 'history_user_ip': ('versionutils.versioning.fields.AutoIPAddressField', [], {'max_length': '15', 'null': 'True'}), 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'region': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regions.Region']", 'null': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'}) }, 'regions.region': { 'Meta': {'object_name': 'Region'}, 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}) } } complete_apps = ['maps']
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 2956, 1451, 63, 11141, 14, 4551, 7, 267, 1592, 14, 525, 63, 2301, 360, 8919, 63, 1130, 576, 63, 11141, 297, 283, 4551, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 11963, 14, 10708, 995, 2973, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 2956, 1451, 14, 4551, 7, 267, 1592, 14, 525, 63, 2301, 360, 8919, 63, 1130, 576, 297, 283, 4551, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 11963, 14, 10708, 995, 2973, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 2956, 1451, 63, 11141, 14, 4551, 7, 267, 1592, 14, 1807, 63, 2301, 360, 8919, 63, 1130, 576, 63, 11141, 297, 283, 4551, 63, 344, 358, 398, 327, 15920, 901, 283, 2956, 1451, 14, 4551, 7, 267, 1592, 14, 1807, 63, 2301, 360, 8919, 63, 1130, 576, 297, 283, 4551, 63, 344, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 2956, 1451, 63, 11141, 14, 4551, 7, 267, 1592, 14, 525, 63, 2301, 360, 8919, 63, 1130, 576, 63, 11141, 297, 283, 4551, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 11963, 14, 10708, 995, 2973, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 2956, 1451, 14, 4551, 7, 267, 1592, 14, 525, 63, 2301, 360, 8919, 63, 1130, 576, 297, 283, 4551, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 11963, 14, 10708, 995, 2973, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 2956, 1451, 63, 11141, 14, 4551, 7, 267, 1592, 14, 1807, 63, 2301, 360, 8919, 63, 1130, 576, 63, 11141, 297, 283, 4551, 63, 344, 358, 398, 327, 15920, 901, 283, 2956, 1451, 14, 4551, 7, 267, 1592, 14, 1807, 63, 2301, 360, 8919, 63, 1130, 576, 297, 283, 4551, 63, 344, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283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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 ]
ruslanloman/nova
nova/tests/unit/api/openstack/compute/contrib/test_tenant_networks.py
18
12160
# Copyright 2014 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import copy import mock from oslo_config import cfg import webob from nova.api.openstack.compute.contrib import os_tenant_networks as networks from nova.api.openstack.compute.plugins.v3 import tenant_networks \ as networks_v21 from nova import exception from nova import test from nova.tests.unit.api.openstack import fakes CONF = cfg.CONF NETWORKS = [ { "id": 1, "cidr": "10.20.105.0/24", "label": "new net 1" }, { "id": 2, "cidr": "10.20.105.0/24", "label": "new net 2" } ] DEFAULT_NETWORK = { "id": 3, "cidr": "10.20.105.0/24", "label": "default" } NETWORKS_WITH_DEFAULT_NET = copy.deepcopy(NETWORKS) NETWORKS_WITH_DEFAULT_NET.append(DEFAULT_NETWORK) DEFAULT_TENANT_ID = 1 def fake_network_api_get_all(context): if (context.project_id == DEFAULT_TENANT_ID): return NETWORKS_WITH_DEFAULT_NET else: return NETWORKS class TenantNetworksTestV21(test.NoDBTestCase): ctrlr = networks_v21.TenantNetworkController validation_error = exception.ValidationError def setUp(self): super(TenantNetworksTestV21, self).setUp() self.controller = self.ctrlr() self.flags(enable_network_quota=True) self.req = fakes.HTTPRequest.blank('') self.original_value = CONF.use_neutron_default_nets def tearDown(self): super(TenantNetworksTestV21, self).tearDown() CONF.set_override("use_neutron_default_nets", self.original_value) def _fake_network_api_create(self, context, **kwargs): self.assertEqual(context.project_id, kwargs['project_id']) return NETWORKS @mock.patch('nova.quota.QUOTAS.reserve') @mock.patch('nova.quota.QUOTAS.rollback') @mock.patch('nova.network.api.API.disassociate') @mock.patch('nova.network.api.API.delete') def _test_network_delete_exception(self, delete_ex, disassociate_ex, expex, delete_mock, disassociate_mock, rollback_mock, reserve_mock): ctxt = self.req.environ['nova.context'] reserve_mock.return_value = 'rv' if delete_mock: delete_mock.side_effect = delete_ex if disassociate_ex: disassociate_mock.side_effect = disassociate_ex self.assertRaises(expex, self.controller.delete, self.req, 1) disassociate_mock.assert_called_once_with(ctxt, 1) if not disassociate_ex: delete_mock.assert_called_once_with(ctxt, 1) rollback_mock.assert_called_once_with(ctxt, 'rv') reserve_mock.assert_called_once_with(ctxt, networks=-1) def test_network_delete_exception_network_not_found(self): ex = exception.NetworkNotFound(network_id=1) expex = webob.exc.HTTPNotFound self._test_network_delete_exception(None, ex, expex) def test_network_delete_exception_policy_failed(self): ex = exception.PolicyNotAuthorized(action='dummy') expex = webob.exc.HTTPForbidden self._test_network_delete_exception(ex, None, expex) def test_network_delete_exception_network_in_use(self): ex = exception.NetworkInUse(network_id=1) expex = webob.exc.HTTPConflict self._test_network_delete_exception(ex, None, expex) @mock.patch('nova.quota.QUOTAS.reserve') @mock.patch('nova.quota.QUOTAS.commit') @mock.patch('nova.network.api.API.delete') @mock.patch('nova.network.api.API.disassociate') def test_network_delete(self, disassociate_mock, delete_mock, commit_mock, reserve_mock): ctxt = self.req.environ['nova.context'] reserve_mock.return_value = 'rv' res = self.controller.delete(self.req, 1) # NOTE: on v2.1, http status code is set as wsgi_code of API # method instead of status_int in a response object. if isinstance(self.controller, networks_v21.TenantNetworkController): status_int = self.controller.delete.wsgi_code else: status_int = res.status_int self.assertEqual(202, status_int) disassociate_mock.assert_called_once_with(ctxt, 1) delete_mock.assert_called_once_with(ctxt, 1) commit_mock.assert_called_once_with(ctxt, 'rv') reserve_mock.assert_called_once_with(ctxt, networks=-1) @mock.patch('nova.network.api.API.get') def test_network_show(self, get_mock): get_mock.return_value = NETWORKS[0] res = self.controller.show(self.req, 1) self.assertEqual(res['network'], NETWORKS[0]) @mock.patch('nova.network.api.API.get') def test_network_show_not_found(self, get_mock): ctxt = self.req.environ['nova.context'] get_mock.side_effect = exception.NetworkNotFound(network_id=1) self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, self.req, 1) get_mock.assert_called_once_with(ctxt, 1) @mock.patch('nova.network.api.API.get_all') def _test_network_index(self, get_all_mock, default_net=True): CONF.set_override("use_neutron_default_nets", default_net) get_all_mock.side_effect = fake_network_api_get_all expected = NETWORKS if default_net is True: self.req.environ['nova.context'].project_id = DEFAULT_TENANT_ID expected = NETWORKS_WITH_DEFAULT_NET res = self.controller.index(self.req) self.assertEqual(res['networks'], expected) def test_network_index_with_default_net(self): self._test_network_index() def test_network_index_without_default_net(self): self._test_network_index(default_net=False) @mock.patch('nova.quota.QUOTAS.reserve') @mock.patch('nova.quota.QUOTAS.commit') @mock.patch('nova.network.api.API.create') def test_network_create(self, create_mock, commit_mock, reserve_mock): ctxt = self.req.environ['nova.context'] reserve_mock.return_value = 'rv' create_mock.side_effect = self._fake_network_api_create body = copy.deepcopy(NETWORKS[0]) del body['id'] body = {'network': body} res = self.controller.create(self.req, body=body) self.assertEqual(res['network'], NETWORKS[0]) commit_mock.assert_called_once_with(ctxt, 'rv') reserve_mock.assert_called_once_with(ctxt, networks=1) @mock.patch('nova.quota.QUOTAS.reserve') def test_network_create_quota_error(self, reserve_mock): ctxt = self.req.environ['nova.context'] reserve_mock.side_effect = exception.OverQuota(overs='fake') body = {'network': {"cidr": "10.20.105.0/24", "label": "new net 1"}} self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, self.req, body=body) reserve_mock.assert_called_once_with(ctxt, networks=1) @mock.patch('nova.quota.QUOTAS.reserve') @mock.patch('nova.quota.QUOTAS.rollback') @mock.patch('nova.network.api.API.create') def _test_network_create_exception(self, ex, expex, create_mock, rollback_mock, reserve_mock): ctxt = self.req.environ['nova.context'] reserve_mock.return_value = 'rv' create_mock.side_effect = ex body = {'network': {"cidr": "10.20.105.0/24", "label": "new net 1"}} self.assertRaises(expex, self.controller.create, self.req, body=body) reserve_mock.assert_called_once_with(ctxt, networks=1) def test_network_create_exception_policy_failed(self): ex = exception.PolicyNotAuthorized(action='dummy') expex = webob.exc.HTTPForbidden self._test_network_create_exception(ex, expex) def test_network_create_exception_service_unavailable(self): ex = Exception expex = webob.exc.HTTPServiceUnavailable self._test_network_create_exception(ex, expex) def test_network_create_empty_body(self): self.assertRaises(exception.ValidationError, self.controller.create, self.req, body={}) def test_network_create_without_cidr(self): body = {'network': {"label": "new net 1"}} self.assertRaises(self.validation_error, self.controller.create, self.req, body=body) def test_network_create_bad_format_cidr(self): body = {'network': {"cidr": "123", "label": "new net 1"}} self.assertRaises(self.validation_error, self.controller.create, self.req, body=body) def test_network_create_empty_network(self): body = {'network': {}} self.assertRaises(self.validation_error, self.controller.create, self.req, body=body) def test_network_create_without_label(self): body = {'network': {"cidr": "10.20.105.0/24"}} self.assertRaises(self.validation_error, self.controller.create, self.req, body=body) class TenantNetworksTestV2(TenantNetworksTestV21): ctrlr = networks.NetworkController validation_error = webob.exc.HTTPBadRequest def setUp(self): super(TenantNetworksTestV2, self).setUp() self.req = fakes.HTTPRequest.blank('', use_admin_context=True) def test_network_create_empty_body(self): self.assertRaises(webob.exc.HTTPUnprocessableEntity, self.controller.create, self.req, {}) class TenantNetworksEnforcementV21(test.NoDBTestCase): def setUp(self): super(TenantNetworksEnforcementV21, self).setUp() self.controller = networks_v21.TenantNetworkController() self.req = fakes.HTTPRequest.blank('') def test_create_policy_failed(self): rule_name = 'os_compute_api:os-tenant-networks' self.policy.set_rules({rule_name: "project:non_fake"}) exc = self.assertRaises( exception.PolicyNotAuthorized, self.controller.create, self.req, body={'network': {'label': 'test', 'cidr': '10.0.0.0/32'}}) self.assertEqual( "Policy doesn't allow %s to be performed." % rule_name, exc.format_message()) def test_index_policy_failed(self): rule_name = 'os_compute_api:os-tenant-networks' self.policy.set_rules({rule_name: "project:non_fake"}) exc = self.assertRaises( exception.PolicyNotAuthorized, self.controller.index, self.req) self.assertEqual( "Policy doesn't allow %s to be performed." % rule_name, exc.format_message()) def test_delete_policy_failed(self): rule_name = 'os_compute_api:os-tenant-networks' self.policy.set_rules({rule_name: "project:non_fake"}) exc = self.assertRaises( exception.PolicyNotAuthorized, self.controller.delete, self.req, fakes.FAKE_UUID) self.assertEqual( "Policy doesn't allow %s to be performed." % rule_name, exc.format_message()) def test_show_policy_failed(self): rule_name = 'os_compute_api:os-tenant-networks' self.policy.set_rules({rule_name: "project:non_fake"}) exc = self.assertRaises( exception.PolicyNotAuthorized, self.controller.show, self.req, fakes.FAKE_UUID) self.assertEqual( "Policy doesn't allow %s to be performed." % rule_name, exc.format_message())
apache-2.0
[ 3, 1898, 6927, 26202, 22304, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1331, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 492, 747, 63, 4647, 63, 7642, 465, 11759, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 5265, 14, 86, 19, 492, 8261, 63, 7642, 971, 1362, 465, 11759, 63, 86, 2025, 199, 504, 5913, 492, 1919, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1246, 14, 8512, 492, 14063, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 14560, 51, 275, 359, 272, 469, 267, 298, 344, 582, 413, 12, 267, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 267, 298, 1302, 582, 298, 1222, 1851, 413, 2, 272, 1660, 272, 469, 267, 298, 344, 582, 499, 12, 267, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 267, 298, 1302, 582, 298, 1222, 1851, 499, 2, 272, 789, 199, 61, 199, 199, 3472, 63, 14560, 275, 469, 272, 298, 344, 582, 650, 12, 272, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 272, 298, 1302, 582, 298, 885, 2, 199, 93, 199, 199, 14560, 51, 63, 9139, 63, 3472, 63, 7278, 275, 1331, 14, 8293, 8, 14560, 51, 9, 199, 14560, 51, 63, 9139, 63, 3472, 63, 7278, 14, 740, 8, 3472, 63, 14560, 9, 199, 199, 3472, 63, 52, 31718, 63, 998, 275, 413, 421, 199, 318, 4026, 63, 1200, 63, 1246, 63, 362, 63, 452, 8, 1100, 304, 272, 340, 334, 1100, 14, 1715, 63, 344, 508, 6186, 63, 52, 31718, 63, 998, 304, 267, 372, 18340, 8406, 51, 63, 9139, 63, 3472, 63, 7278, 272, 587, 26, 267, 372, 18340, 8406, 51, 421, 199, 533, 377, 287, 867, 4491, 26935, 54, 2025, 8, 396, 14, 32437, 304, 272, 15427, 82, 275, 11759, 63, 86, 2025, 14, 27807, 4491, 7506, 272, 6411, 63, 705, 275, 1919, 14, 8172, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 27807, 4491, 26935, 54, 2025, 12, 291, 680, 5996, 342, 267, 291, 14, 5538, 275, 291, 14, 12476, 82, 342, 267, 291, 14, 2469, 8, 4296, 63, 1200, 63, 8848, 29, 549, 9, 267, 291, 14, 2103, 275, 14063, 14, 21053, 14, 2500, 8355, 267, 291, 14, 5043, 63, 585, 275, 6392, 14, 1180, 63, 10271, 63, 885, 63, 20490, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 27807, 4491, 26935, 54, 2025, 12, 291, 680, 12336, 342, 267, 6392, 14, 409, 63, 4415, 480, 1180, 63, 10271, 63, 885, 63, 20490, 401, 291, 14, 5043, 63, 585, 9, 339, 347, 485, 3183, 63, 1200, 63, 1246, 63, 981, 8, 277, 12, 1067, 12, 1011, 958, 304, 267, 291, 14, 629, 8, 1100, 14, 1715, 63, 344, 12, 2074, 459, 1715, 63, 344, 1105, 267, 372, 18340, 8406, 51, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8848, 14, 18654, 1179, 14, 19643, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 8848, 14, 18654, 1179, 14, 10437, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 1200, 14, 1246, 14, 3735, 14, 2297, 16021, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 1200, 14, 1246, 14, 3735, 14, 1807, 358, 272, 347, 485, 396, 63, 1200, 63, 1807, 63, 1971, 8, 277, 12, 3145, 63, 476, 12, 2153, 16021, 63, 476, 12, 444, 16531, 12, 4318, 3145, 63, 1805, 12, 2153, 16021, 63, 1805, 12, 4318, 16475, 63, 1805, 12, 32606, 63, 1805, 304, 267, 11216, 275, 291, 14, 2103, 14, 2314, 459, 6765, 14, 1100, 418, 398, 32606, 63, 1805, 14, 1107, 63, 585, 275, 283, 6310, 7, 267, 340, 3145, 63, 1805, 26, 288, 3145, 63, 1805, 14, 2441, 63, 5881, 275, 3145, 63, 476, 267, 340, 2153, 16021, 63, 476, 26, 288, 2153, 16021, 63, 1805, 14, 2441, 63, 5881, 275, 2153, 16021, 63, 476, 398, 291, 14, 1855, 8, 476, 16531, 12, 291, 14, 5538, 14, 1807, 12, 291, 14, 2103, 12, 413, 9, 398, 2153, 16021, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 413, 9, 267, 340, 440, 2153, 16021, 63, 476, 26, 288, 3145, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 413, 9, 267, 16475, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 283, 6310, 358, 267, 32606, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 11759, 4022, 17, 9, 339, 347, 511, 63, 1200, 63, 1807, 63, 1971, 63, 1200, 63, 1397, 63, 4214, 8, 277, 304, 267, 444, 275, 1919, 14, 4491, 4667, 8, 1200, 63, 344, 29, 17, 9, 267, 444, 16531, 275, 14568, 14, 2804, 14, 26553, 267, 291, 423, 396, 63, 1200, 63, 1807, 63, 1971, 8, 403, 12, 444, 12, 444, 16531, 9, 339, 347, 511, 63, 1200, 63, 1807, 63, 1971, 63, 3185, 63, 4892, 8, 277, 304, 267, 444, 275, 1919, 14, 4845, 1763, 29284, 8, 1287, 534, 5869, 358, 267, 444, 16531, 275, 14568, 14, 2804, 14, 2856, 17454, 267, 291, 423, 396, 63, 1200, 63, 1807, 63, 1971, 8, 476, 12, 488, 12, 444, 16531, 9, 339, 347, 511, 63, 1200, 63, 1807, 63 ]
[ 1898, 6927, 26202, 22304, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1331, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 492, 747, 63, 4647, 63, 7642, 465, 11759, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 5265, 14, 86, 19, 492, 8261, 63, 7642, 971, 1362, 465, 11759, 63, 86, 2025, 199, 504, 5913, 492, 1919, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1246, 14, 8512, 492, 14063, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 14560, 51, 275, 359, 272, 469, 267, 298, 344, 582, 413, 12, 267, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 267, 298, 1302, 582, 298, 1222, 1851, 413, 2, 272, 1660, 272, 469, 267, 298, 344, 582, 499, 12, 267, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 267, 298, 1302, 582, 298, 1222, 1851, 499, 2, 272, 789, 199, 61, 199, 199, 3472, 63, 14560, 275, 469, 272, 298, 344, 582, 650, 12, 272, 298, 10509, 582, 298, 709, 14, 1165, 14, 7320, 14, 16, 15, 1194, 401, 272, 298, 1302, 582, 298, 885, 2, 199, 93, 199, 199, 14560, 51, 63, 9139, 63, 3472, 63, 7278, 275, 1331, 14, 8293, 8, 14560, 51, 9, 199, 14560, 51, 63, 9139, 63, 3472, 63, 7278, 14, 740, 8, 3472, 63, 14560, 9, 199, 199, 3472, 63, 52, 31718, 63, 998, 275, 413, 421, 199, 318, 4026, 63, 1200, 63, 1246, 63, 362, 63, 452, 8, 1100, 304, 272, 340, 334, 1100, 14, 1715, 63, 344, 508, 6186, 63, 52, 31718, 63, 998, 304, 267, 372, 18340, 8406, 51, 63, 9139, 63, 3472, 63, 7278, 272, 587, 26, 267, 372, 18340, 8406, 51, 421, 199, 533, 377, 287, 867, 4491, 26935, 54, 2025, 8, 396, 14, 32437, 304, 272, 15427, 82, 275, 11759, 63, 86, 2025, 14, 27807, 4491, 7506, 272, 6411, 63, 705, 275, 1919, 14, 8172, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 27807, 4491, 26935, 54, 2025, 12, 291, 680, 5996, 342, 267, 291, 14, 5538, 275, 291, 14, 12476, 82, 342, 267, 291, 14, 2469, 8, 4296, 63, 1200, 63, 8848, 29, 549, 9, 267, 291, 14, 2103, 275, 14063, 14, 21053, 14, 2500, 8355, 267, 291, 14, 5043, 63, 585, 275, 6392, 14, 1180, 63, 10271, 63, 885, 63, 20490, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 27807, 4491, 26935, 54, 2025, 12, 291, 680, 12336, 342, 267, 6392, 14, 409, 63, 4415, 480, 1180, 63, 10271, 63, 885, 63, 20490, 401, 291, 14, 5043, 63, 585, 9, 339, 347, 485, 3183, 63, 1200, 63, 1246, 63, 981, 8, 277, 12, 1067, 12, 1011, 958, 304, 267, 291, 14, 629, 8, 1100, 14, 1715, 63, 344, 12, 2074, 459, 1715, 63, 344, 1105, 267, 372, 18340, 8406, 51, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8848, 14, 18654, 1179, 14, 19643, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 8848, 14, 18654, 1179, 14, 10437, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 1200, 14, 1246, 14, 3735, 14, 2297, 16021, 358, 272, 768, 1805, 14, 2068, 360, 6765, 14, 1200, 14, 1246, 14, 3735, 14, 1807, 358, 272, 347, 485, 396, 63, 1200, 63, 1807, 63, 1971, 8, 277, 12, 3145, 63, 476, 12, 2153, 16021, 63, 476, 12, 444, 16531, 12, 4318, 3145, 63, 1805, 12, 2153, 16021, 63, 1805, 12, 4318, 16475, 63, 1805, 12, 32606, 63, 1805, 304, 267, 11216, 275, 291, 14, 2103, 14, 2314, 459, 6765, 14, 1100, 418, 398, 32606, 63, 1805, 14, 1107, 63, 585, 275, 283, 6310, 7, 267, 340, 3145, 63, 1805, 26, 288, 3145, 63, 1805, 14, 2441, 63, 5881, 275, 3145, 63, 476, 267, 340, 2153, 16021, 63, 476, 26, 288, 2153, 16021, 63, 1805, 14, 2441, 63, 5881, 275, 2153, 16021, 63, 476, 398, 291, 14, 1855, 8, 476, 16531, 12, 291, 14, 5538, 14, 1807, 12, 291, 14, 2103, 12, 413, 9, 398, 2153, 16021, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 413, 9, 267, 340, 440, 2153, 16021, 63, 476, 26, 288, 3145, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 413, 9, 267, 16475, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 283, 6310, 358, 267, 32606, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 6725, 12, 11759, 4022, 17, 9, 339, 347, 511, 63, 1200, 63, 1807, 63, 1971, 63, 1200, 63, 1397, 63, 4214, 8, 277, 304, 267, 444, 275, 1919, 14, 4491, 4667, 8, 1200, 63, 344, 29, 17, 9, 267, 444, 16531, 275, 14568, 14, 2804, 14, 26553, 267, 291, 423, 396, 63, 1200, 63, 1807, 63, 1971, 8, 403, 12, 444, 12, 444, 16531, 9, 339, 347, 511, 63, 1200, 63, 1807, 63, 1971, 63, 3185, 63, 4892, 8, 277, 304, 267, 444, 275, 1919, 14, 4845, 1763, 29284, 8,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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 ]
Diti24/python-ivi
ivi/tektronix/tektronixMDOAFG.py
1
23718
""" Python Interchangeable Virtual Instrument Library Copyright (c) 2016 Alex Forencich 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 numpy as np import struct from .. import ivi from .. import fgen OutputMode = set(['function', 'arbitrary']) OperationMode = set(['continuous']) StandardWaveformMapping = { 'sine': 'sine', 'square': 'square', 'triangle': 'ramp', 'ramp_up': 'ramp', 'ramp_down': 'ramp', 'dc': 'dc', 'pulse': 'pulse', 'noise': 'noise', 'dc': 'dc', 'sinc': 'sinc', 'exprise': 'erise', 'expfall': 'edecay', 'cardiac': 'cardiac', 'gaussian': 'gaussian', 'lorentz': 'lorentz', 'haversine': 'haversine' } class tektronixMDOAFG(fgen.Base, fgen.StdFunc, fgen.ArbWfm, fgen.ArbFrequency, fgen.ArbChannelWfm): "Tektronix MDO series AFG option IVI function generator driver" def __init__(self, *args, **kwargs): self.__dict__.setdefault('_instrument_id', 'MDO3000') self._output_standard_waveform_pulse_width = list() self._output_standard_waveform_symmetry = list() self._output_noise_enabled = list() self._output_noise_percent = list() super(tektronixMDOAFG, self).__init__(*args, **kwargs) # AFG option self._output_count = 1 self._arbitrary_sample_rate = 0 self._arbitrary_waveform_number_waveforms_max = 0 self._arbitrary_waveform_size_max = 131072 self._arbitrary_waveform_size_min = 2 self._arbitrary_waveform_quantum = 1 self._add_property('outputs[].standard_waveform.pulse_width', self._get_output_standard_waveform_pulse_width, self._set_output_standard_waveform_pulse_width, None, """ Specifies the pulse width for a pulse waveform. This attribute affects function generator behavior only when the Waveform attribute is set to Waveform Pulse. The units are seconds. """) self._add_property('outputs[].standard_waveform.symmetry', self._get_output_standard_waveform_symmetry, self._set_output_standard_waveform_symmetry, None, """ Specifies the symmetry for a ramp or triangle waveform. This attribute affects function generator behavior only when the Waveform attribute is set to Waveform Triangle, Ramp Up, or Ramp Down. The value is expressed as a percentage. """) self._add_property('outputs[].noise.enabled', self._get_output_noise_enabled, self._set_output_noise_enabled, None, """ Enables additive noise on the selected channel. """) self._add_property('outputs[].noise.percent', self._get_output_noise_percent, self._set_output_noise_percent, None, """ Specifies the level of the added noise in percent of the amplitude. """) self._identity_description = "Tektronix MDO series AFG option IVI function generator driver" self._identity_supported_instrument_models = ['MDO3012', 'MDO3014', 'MDO3022', 'MDO3024', 'MDO3032', 'MDO3034', 'MDO3052', 'MDO3054', 'MDO3102', 'MDO3104'] self._init_outputs() def _init_outputs(self): try: super(tektronixMDOAFG, self)._init_outputs() except AttributeError: pass self._output_name = list() self._output_operation_mode = list() self._output_enabled = list() self._output_impedance = list() self._output_mode = list() self._output_reference_clock_source = list() self._output_standard_waveform_pulse_width = list() self._output_standard_waveform_ramp_symmetry = list() self._output_noise_enabled = list() self._output_noise_percent = list() for i in range(self._output_count): if self._output_count == 1: self._output_name.append("afg") else: self._output_name.append("afg%d" % (i+1)) self._output_operation_mode.append('continuous') self._output_enabled.append(False) self._output_impedance.append(50) self._output_mode.append('function') self._output_reference_clock_source.append('internal') self._output_standard_waveform_pulse_width.append(100e-6) self._output_standard_waveform_symmetry.append(50.0) self._output_noise_enabled.append(False) self._output_noise_percent.append(10.0) self.outputs._set_list(self._output_name) # AFG option def _get_output_operation_mode(self, index): index = ivi.get_index(self._output_name, index) return self._output_operation_mode[index] def _set_output_operation_mode(self, index, value): index = ivi.get_index(self._output_name, index) if value not in OperationMode: raise ivi.ValueNotSupportedException() self._output_operation_mode[index] = value def _get_output_enabled(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:output:state?" % self._output_name[index]) self._output_enabled[index] = bool(int(resp)) self._set_cache_valid(index=index) return self._output_enabled[index] def _set_output_enabled(self, index, value): index = ivi.get_index(self._output_name, index) value = bool(value) if not self._driver_operation_simulate: self._write(":%s:output:state %d" % (self._output_name[index], value)) self._output_enabled[index] = value self._set_cache_valid(index=index) def _get_output_impedance(self, index): index = ivi.get_index(self._analog_channel_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): val = self._ask(":%s:output:load:impedance?" % self._output_name[index]) if val == 'HIGHZ': self._output_impedance[index] = 1000000 elif val == 'FIF': self._output_impedance[index] = 50 self._set_cache_valid(index=index) return self._output_impedance[index] def _set_output_impedance(self, index, value): value = float(value) index = ivi.get_index(self._analog_channel_name, index) if value != 50 and value != 1000000: raise Exception('Invalid impedance selection') if not self._driver_operation_simulate: if value == 1000000: self._write(":%s:output:load:impedance highz" % self._output_name[index]) elif value == 50: self._write(":%s:output:load:impedance fifty" % self._output_name[index]) self._output_impedance[index] = value self._set_cache_valid(index=index) self._set_cache_valid(False, 'output_standard_waveform_amplitude', index) def _get_output_mode(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:function?" % self._output_name[index]).lower() if resp == 'arbitrary': self._output_mode[index] = 'arbitrary' else: self._output_mode[index] = 'function' self._set_cache_valid(index=index) return self._output_mode[index] def _set_output_mode(self, index, value): index = ivi.get_index(self._output_name, index) if value not in OutputMode: raise ivi.ValueNotSupportedException() if not self._driver_operation_simulate: if value == 'arbitrary': self._write(":%s:function arbitrary" % self._output_name[index]) else: if self._get_cache_valid('output_standard_waveform_waveform', index=index): self._set_output_standard_waveform_waveform(index, self._output_standard_waveform_waveform[index]) else: self._set_output_standard_waveform_waveform(index, 'sine') self._output_mode[index] = value self._set_cache_valid(index=index) def _get_output_reference_clock_source(self, index): index = ivi.get_index(self._output_name, index) return self._output_reference_clock_source[index] def _set_output_reference_clock_source(self, index, value): index = ivi.get_index(self._output_name, index) value = 'internal' self._output_reference_clock_source[index] = value def abort_generation(self): pass def initiate_generation(self): pass def _get_output_standard_waveform_amplitude(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:amplitude?" % self._output_name[index]) self._output_standard_waveform_amplitude[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_amplitude[index] def _set_output_standard_waveform_amplitude(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < 0.01 or value > 5.0: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:amplitude %e" % (self._output_name[index], value)) self._output_standard_waveform_amplitude[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_dc_offset(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:offset?" % self._output_name[index]) self._output_standard_waveform_dc_offset[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_dc_offset[index] def _set_output_standard_waveform_dc_offset(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if not self._driver_operation_simulate: self._write(":%s:offset %e" % (self._output_name[index], value)) self._output_standard_waveform_dc_offset[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_duty_cycle_high(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:square:duty?" % self._output_name[index]) self._output_standard_waveform_duty_cycle_high[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_duty_cycle_high[index] def _set_output_standard_waveform_duty_cycle_high(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < 10.0 or value > 90.0: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:square:duty %e" % (self._output_name[index], value)) self._output_standard_waveform_duty_cycle_high[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_pulse_width(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:pulse:width?" % self._output_name[index]) self._output_standard_waveform_pulse_width[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_pulse_width[index] def _set_output_standard_waveform_pulse_width(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if not self._driver_operation_simulate: self._write(":%s:pulse:width %e" % (self._output_name[index], value)) self._output_standard_waveform_pulse_width[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_symmetry(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:ramp:symmetry?" % self._output_name[index]) self._output_standard_waveform_symmetry[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_symmetry[index] def _set_output_standard_waveform_symmetry(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < 0.0 or value > 100.0: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:ramp:symmetry %e" % (self._output_name[index], value)) self._output_standard_waveform_symmetry[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_start_phase(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:phase?" % self._output_name[index]) self._output_standard_waveform_start_phase[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_start_phase[index] def _set_output_standard_waveform_start_phase(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < -180.0 or value > 180.0: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:phase %e" % (self._output_name[index], value)) self._output_standard_waveform_start_phase[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_frequency(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:frequency?" % self._output_name[index]) self._output_standard_waveform_frequency[index] = float(resp) self._set_cache_valid(index=index) return self._output_standard_waveform_frequency[index] def _set_output_standard_waveform_frequency(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < 0.1 or value > 50e6: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:frequency %e" % (self._output_name[index], value)) self._output_standard_waveform_frequency[index] = value self._set_cache_valid(index=index) def _get_output_standard_waveform_waveform(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:function?" % self._output_name[index]).lower() if resp == 'arbitrary': resp = 'sine' resp = [k for k,v in StandardWaveformMapping.items() if v==resp][0] if resp == 'ramp_up': if self._get_output_standard_waveform_symmetry(index) <= 10.0: resp = 'ramp_down' elif self._get_output_standard_waveform_symmetry(index) >= 90.0: resp = 'ramp_up' else: resp = 'triangle' self._output_standard_waveform_waveform[index] = resp self._set_cache_valid(index=index) return self._output_standard_waveform_waveform[index] def _set_output_standard_waveform_waveform(self, index, value): index = ivi.get_index(self._output_name, index) if value not in StandardWaveformMapping: raise ivi.ValueNotSupportedException() if not self._driver_operation_simulate: self._write(":%s:function %s" % (self._output_name[index], StandardWaveformMapping[value])) if value == 'triangle': if self._get_output_standard_waveform_symmetry(index) <= 10.0 or self._get_output_standard_waveform_symmetry(index) >= 90: self._set_output_standard_waveform_symmetry(index, 50.0) elif value == 'ramp_up': self._set_output_standard_waveform_symmetry(index, 100.0) elif value == 'ramp_down': self._set_output_standard_waveform_symmetry(index, 0.0) self._output_standard_waveform_waveform[index] = value self._set_cache_valid(index=index) self._output_mode[index] = 'function' self._set_cache_valid(True, 'output_mode', index=index) def _get_output_noise_enabled(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:noiseadd:state?" % self._output_name[index]) self._output_noise_enabled[index] = bool(int(resp)) self._set_cache_valid(index=index) return self._output_noise_enabled[index] def _set_output_noise_enabled(self, index, value): index = ivi.get_index(self._output_name, index) value = bool(value) if not self._driver_operation_simulate: self._write(":%s:noiseadd:state %d" % (self._output_name[index], value)) self._output_noise_enabled[index] = value self._set_cache_valid(index=index) def _get_output_noise_percent(self, index): index = ivi.get_index(self._output_name, index) if not self._driver_operation_simulate and not self._get_cache_valid(index=index): resp = self._ask(":%s:noiseadd:percent?" % self._output_name[index]) self._output_noise_percent[index] = float(resp) self._set_cache_valid(index=index) return self._output_noise_percent[index] def _set_output_noise_percent(self, index, value): index = ivi.get_index(self._output_name, index) value = float(value) if value < 0.0 or value > 100.0: raise ivi.OutOfRangeException() if not self._driver_operation_simulate: self._write(":%s:noiseadd:percent %e" % (self._output_name[index], value)) self._output_noise_percent[index] = value self._set_cache_valid(index=index) def _get_output_arbitrary_gain(self, index): return self._get_output_standard_waveform_amplitude(index) def _set_output_arbitrary_gain(self, index, value): self._set_output_standard_waveform_amplitude(index, value) def _get_output_arbitrary_offset(self, index): return self._get_output_standard_waveform_dc_offset(index) def _set_output_arbitrary_offset(self, index, value): self._set_output_standard_waveform_dc_offset(index, value) def _get_output_arbitrary_waveform(self, index): index = ivi.get_index(self._output_name, index) return self._output_arbitrary_waveform[index] def _set_output_arbitrary_waveform(self, index, value): index = ivi.get_index(self._output_name, index) value = str(value) self._output_arbitrary_waveform[index] = value def _get_arbitrary_sample_rate(self): return self._arbitrary_sample_rate def _set_arbitrary_sample_rate(self, value): value = float(value) self._arbitrary_sample_rate = value def _get_arbitrary_waveform_number_waveforms_max(self): return self._arbitrary_waveform_number_waveforms_max def _get_arbitrary_waveform_size_max(self): return self._arbitrary_waveform_size_max def _get_arbitrary_waveform_size_min(self): return self._arbitrary_waveform_size_min def _get_arbitrary_waveform_quantum(self): return self._arbitrary_waveform_quantum def _arbitrary_waveform_clear(self, handle): pass def _arbitrary_waveform_configure(self, index, handle, gain, offset): self._set_output_arbitrary_waveform(index, handle) self._set_output_arbitrary_gain(index, gain) self._set_output_arbitrary_offset(index, offset) def _arbitrary_waveform_create(self, data): return "handle" def _get_output_arbitrary_frequency(self, index): return self._get_output_standard_waveform_frequency(index) def _set_output_arbitrary_frequency(self, index, value): self._set_output_standard_waveform_frequency(index, value) def _arbitrary_waveform_create_channel_waveform(self, index, data): y = None x = None if type(data) == list and type(data[0]) == float: # list y = array(data) elif type(data) == np.ndarray and len(data.shape) == 1: # 1D array y = data elif type(data) == np.ndarray and len(data.shape) == 2 and data.shape[0] == 1: # 2D array, hieght 1 y = data[0] elif type(data) == np.ndarray and len(data.shape) == 2 and data.shape[1] == 1: # 2D array, width 1 y = data[:,0] else: x, y = ivi.get_sig(data) if len(y) % self._arbitrary_waveform_quantum != 0: raise ivi.ValueNotSupportedException() # clip on [-1,1] yc = y.clip(-1, 1) raw_data = yc.astype('<f').tobytes() self._write(':%s:arbitrary:emem:points:encdg binary' % self._output_name[index]) self._write_ieee_block(raw_data, ':%s:arbitrary:emem:points ' % self._output_name[index]) return self._output_name[index]
mit
[ 624, 199, 199, 4718, 6551, 1461, 461, 13311, 25767, 11243, 199, 199, 7384, 334, 67, 9, 7800, 22986, 21684, 78, 559, 335, 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, 199, 452, 6866, 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, 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, 199, 18061, 4141, 14, 199, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 646, 2702, 199, 199, 504, 2508, 492, 284, 433, 199, 504, 2508, 492, 289, 2268, 199, 199, 2959, 1385, 275, 663, 2941, 1593, 297, 283, 285, 8734, 1105, 199, 6044, 1385, 275, 663, 2941, 23458, 1105, 199, 9232, 21393, 964, 7674, 275, 469, 267, 283, 83, 1132, 356, 283, 83, 1132, 297, 267, 283, 9646, 356, 283, 9646, 297, 267, 283, 21584, 356, 283, 345, 311, 297, 267, 283, 345, 311, 63, 384, 356, 283, 345, 311, 297, 267, 283, 345, 311, 63, 2110, 356, 283, 345, 311, 297, 267, 283, 3833, 356, 283, 3833, 297, 267, 283, 19538, 356, 283, 19538, 297, 267, 283, 11838, 356, 283, 11838, 297, 267, 283, 3833, 356, 283, 3833, 297, 267, 283, 5911, 67, 356, 283, 5911, 67, 297, 267, 283, 476, 13219, 356, 283, 281, 572, 297, 267, 283, 1474, 70, 452, 356, 283, 69, 16889, 297, 267, 283, 7007, 328, 645, 356, 283, 7007, 328, 645, 297, 267, 283, 22911, 356, 283, 22911, 297, 267, 283, 320, 640, 90, 356, 283, 320, 640, 90, 297, 267, 283, 2411, 14895, 1132, 356, 283, 2411, 14895, 1132, 7, 267, 789, 199, 199, 533, 1565, 75, 454, 265, 1148, 45, 1649, 5699, 39, 8, 70, 2268, 14, 1563, 12, 289, 2268, 14, 11976, 7465, 12, 289, 2268, 14, 1596, 66, 55, 10886, 12, 289, 2268, 14, 1596, 66, 18285, 12, 355, 289, 2268, 14, 1596, 66, 5358, 55, 10886, 304, 272, 298, 52, 5711, 454, 265, 1148, 603, 1649, 6779, 20089, 39, 945, 473, 17655, 805, 4306, 5253, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 855, 807, 4343, 5486, 6412, 13321, 63, 344, 297, 283, 45, 1649, 19962, 358, 398, 291, 423, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 275, 769, 342, 267, 291, 423, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 275, 769, 342, 267, 291, 423, 1199, 63, 11838, 63, 3827, 275, 769, 342, 267, 291, 423, 1199, 63, 11838, 63, 7045, 275, 769, 342, 398, 1613, 8, 266, 75, 454, 265, 1148, 45, 1649, 5699, 39, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 20089, 39, 945, 267, 291, 423, 1199, 63, 835, 275, 413, 267, 291, 423, 285, 8734, 63, 3271, 63, 1866, 275, 378, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 1955, 63, 10024, 3351, 63, 988, 275, 378, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 890, 63, 988, 275, 4944, 709, 2819, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 890, 63, 827, 275, 499, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 25999, 275, 413, 398, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 6807, 63, 10024, 964, 14, 19538, 63, 2063, 297, 717, 291, 423, 362, 63, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 12, 717, 291, 423, 409, 63, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 27949, 3462, 367, 282, 27949, 12204, 964, 14, 961, 2225, 29476, 717, 805, 4306, 5953, 1454, 1380, 314, 644, 811, 964, 2225, 365, 663, 370, 717, 644, 811, 964, 510, 13055, 14, 710, 6204, 787, 4696, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 6807, 63, 10024, 964, 14, 3840, 10987, 297, 717, 291, 423, 362, 63, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 12, 717, 291, 423, 409, 63, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 30246, 367, 282, 660, 311, 503, 26268, 12204, 964, 14, 961, 2225, 717, 29476, 805, 4306, 5953, 1454, 1380, 314, 644, 811, 964, 2225, 365, 717, 663, 370, 644, 811, 964, 12480, 4593, 12, 3898, 311, 4949, 12, 503, 3898, 311, 13392, 14, 710, 574, 365, 19147, 717, 465, 282, 16327, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 11838, 14, 3827, 297, 717, 291, 423, 362, 63, 1199, 63, 11838, 63, 3827, 12, 717, 291, 423, 409, 63, 1199, 63, 11838, 63, 3827, 12, 717, 488, 12, 717, 408, 717, 3447, 5921, 1503, 30844, 11145, 641, 314, 4895, 3623, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 11838, 14, 7045, 297, 717, 291, 423, 362, 63, 1199, 63, 11838, 63, 7045, 12, 717, 291, 423, 409, 63, 1199, 63, 11838, 63, 7045, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 2166, 402, 314, 3483, 11145, 315, 8878, 402, 314, 30727, 14, 717, 7857, 398, 291, 423, 5582, 63, 1802, 275, 298, 52, 5711, 454, 265, 1148, 603, 1649, 6779 ]
[ 199, 199, 4718, 6551, 1461, 461, 13311, 25767, 11243, 199, 199, 7384, 334, 67, 9, 7800, 22986, 21684, 78, 559, 335, 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, 199, 452, 6866, 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, 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, 199, 18061, 4141, 14, 199, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 646, 2702, 199, 199, 504, 2508, 492, 284, 433, 199, 504, 2508, 492, 289, 2268, 199, 199, 2959, 1385, 275, 663, 2941, 1593, 297, 283, 285, 8734, 1105, 199, 6044, 1385, 275, 663, 2941, 23458, 1105, 199, 9232, 21393, 964, 7674, 275, 469, 267, 283, 83, 1132, 356, 283, 83, 1132, 297, 267, 283, 9646, 356, 283, 9646, 297, 267, 283, 21584, 356, 283, 345, 311, 297, 267, 283, 345, 311, 63, 384, 356, 283, 345, 311, 297, 267, 283, 345, 311, 63, 2110, 356, 283, 345, 311, 297, 267, 283, 3833, 356, 283, 3833, 297, 267, 283, 19538, 356, 283, 19538, 297, 267, 283, 11838, 356, 283, 11838, 297, 267, 283, 3833, 356, 283, 3833, 297, 267, 283, 5911, 67, 356, 283, 5911, 67, 297, 267, 283, 476, 13219, 356, 283, 281, 572, 297, 267, 283, 1474, 70, 452, 356, 283, 69, 16889, 297, 267, 283, 7007, 328, 645, 356, 283, 7007, 328, 645, 297, 267, 283, 22911, 356, 283, 22911, 297, 267, 283, 320, 640, 90, 356, 283, 320, 640, 90, 297, 267, 283, 2411, 14895, 1132, 356, 283, 2411, 14895, 1132, 7, 267, 789, 199, 199, 533, 1565, 75, 454, 265, 1148, 45, 1649, 5699, 39, 8, 70, 2268, 14, 1563, 12, 289, 2268, 14, 11976, 7465, 12, 289, 2268, 14, 1596, 66, 55, 10886, 12, 289, 2268, 14, 1596, 66, 18285, 12, 355, 289, 2268, 14, 1596, 66, 5358, 55, 10886, 304, 272, 298, 52, 5711, 454, 265, 1148, 603, 1649, 6779, 20089, 39, 945, 473, 17655, 805, 4306, 5253, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 855, 807, 4343, 5486, 6412, 13321, 63, 344, 297, 283, 45, 1649, 19962, 358, 398, 291, 423, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 275, 769, 342, 267, 291, 423, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 275, 769, 342, 267, 291, 423, 1199, 63, 11838, 63, 3827, 275, 769, 342, 267, 291, 423, 1199, 63, 11838, 63, 7045, 275, 769, 342, 398, 1613, 8, 266, 75, 454, 265, 1148, 45, 1649, 5699, 39, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 20089, 39, 945, 267, 291, 423, 1199, 63, 835, 275, 413, 267, 291, 423, 285, 8734, 63, 3271, 63, 1866, 275, 378, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 1955, 63, 10024, 3351, 63, 988, 275, 378, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 890, 63, 988, 275, 4944, 709, 2819, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 890, 63, 827, 275, 499, 267, 291, 423, 285, 8734, 63, 10024, 964, 63, 25999, 275, 413, 398, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 6807, 63, 10024, 964, 14, 19538, 63, 2063, 297, 717, 291, 423, 362, 63, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 12, 717, 291, 423, 409, 63, 1199, 63, 6807, 63, 10024, 964, 63, 19538, 63, 2063, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 27949, 3462, 367, 282, 27949, 12204, 964, 14, 961, 2225, 29476, 717, 805, 4306, 5953, 1454, 1380, 314, 644, 811, 964, 2225, 365, 663, 370, 717, 644, 811, 964, 510, 13055, 14, 710, 6204, 787, 4696, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 6807, 63, 10024, 964, 14, 3840, 10987, 297, 717, 291, 423, 362, 63, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 12, 717, 291, 423, 409, 63, 1199, 63, 6807, 63, 10024, 964, 63, 3840, 10987, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 30246, 367, 282, 660, 311, 503, 26268, 12204, 964, 14, 961, 2225, 717, 29476, 805, 4306, 5953, 1454, 1380, 314, 644, 811, 964, 2225, 365, 717, 663, 370, 644, 811, 964, 12480, 4593, 12, 3898, 311, 4949, 12, 503, 3898, 311, 13392, 14, 710, 574, 365, 19147, 717, 465, 282, 16327, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 11838, 14, 3827, 297, 717, 291, 423, 362, 63, 1199, 63, 11838, 63, 3827, 12, 717, 291, 423, 409, 63, 1199, 63, 11838, 63, 3827, 12, 717, 488, 12, 717, 408, 717, 3447, 5921, 1503, 30844, 11145, 641, 314, 4895, 3623, 14, 717, 7857, 267, 291, 423, 525, 63, 1829, 360, 4467, 59, 1055, 11838, 14, 7045, 297, 717, 291, 423, 362, 63, 1199, 63, 11838, 63, 7045, 12, 717, 291, 423, 409, 63, 1199, 63, 11838, 63, 7045, 12, 717, 488, 12, 717, 408, 717, 11015, 314, 2166, 402, 314, 3483, 11145, 315, 8878, 402, 314, 30727, 14, 717, 7857, 398, 291, 423, 5582, 63, 1802, 275, 298, 52, 5711, 454, 265, 1148, 603, 1649, 6779, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bamboohill/PixyFMU
Tools/mavproxy_modules/magcal_graph.py
108
3748
# Copyright (C) 2016 Intel Corporation. All rights reserved. # # This file 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 file 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/>. ''' This module shows the geodesic sections hit by the samples collected during compass calibration, and also some status data. The objective of this module is to provide a reference on how to interpret the field `completion_mask` from the MAG_CAL_PROGRESS mavlink message. That information can be used in order to guide the vehicle user during calibration. The plot shown by this module isn't very helpful to the end user, but it might help developers during development of internal calibration support in ground control stations. ''' from MAVProxy.modules.lib import mp_module, mp_util import multiprocessing class MagcalGraph(): def __init__(self): self.parent_pipe, self.child_pipe = multiprocessing.Pipe() self.ui_process = None self._last_mavlink_msgs = {} def start(self): if self.is_active(): return if self.ui_process: self.ui_process.join() for l in self._last_mavlink_msgs.values(): for m in l: if not m: continue self.parent_pipe.send(m) self.ui_process = multiprocessing.Process(target=self.ui_task) self.ui_process.start() def stop(self): if not self.is_active(): return self.parent_pipe.send('close') self.ui_process.join() def ui_task(self): mp_util.child_close_fds() from MAVProxy.modules.lib import wx_processguard from MAVProxy.modules.lib.wx_loader import wx from lib.magcal_graph_ui import MagcalFrame app = wx.App(False) app.frame = MagcalFrame(self.child_pipe) app.frame.Show() app.MainLoop() def is_active(self): return self.ui_process is not None and self.ui_process.is_alive() def mavlink_packet(self, m): if m.compass_id not in self._last_mavlink_msgs: # Keep the two last messages so that, if one is the calibration # report message, the previous one is the last progress message. self._last_mavlink_msgs[m.compass_id] = [None, m] else: l = self._last_mavlink_msgs[m.compass_id] l[0] = l[1] l[1] = m if not self.is_active(): return self.parent_pipe.send(m) class MagcalGraphModule(mp_module.MPModule): def __init__(self, mpstate): super(MagcalGraphModule, self).__init__(mpstate, 'magcal_graph') self.add_command( 'magcal_graph', self.cmd_magcal_graph, 'open a window to report magcal progress and plot geodesic ' + 'sections hit by the collected data in real time', ) self.graph = MagcalGraph() def cmd_magcal_graph(self, args): self.graph.start() def mavlink_packet(self, m): if m.get_type() not in ('MAG_CAL_PROGRESS', 'MAG_CAL_REPORT'): return self.graph.mavlink_packet(m) def unload(self): self.graph.stop() def init(mpstate): return MagcalGraphModule(mpstate)
gpl-3.0
[ 3, 1898, 334, 35, 9, 7800, 221, 20619, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 570, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 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, 961, 570, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 2765, 859, 13703, 314, 2312, 380, 9916, 10189, 9793, 701, 314, 5845, 13736, 5309, 199, 863, 405, 25365, 12, 436, 2597, 2005, 2004, 666, 14, 710, 20632, 402, 642, 859, 365, 199, 475, 5647, 282, 3659, 641, 4212, 370, 15579, 314, 901, 658, 13207, 63, 2629, 64, 687, 314, 199, 45, 1254, 63, 13329, 63, 24547, 11456, 1073, 1245, 14, 10314, 2556, 883, 506, 1202, 315, 1865, 370, 199, 17348, 314, 27616, 922, 5309, 25365, 14, 199, 199, 1918, 5137, 9164, 701, 642, 859, 5712, 1133, 7437, 24606, 370, 314, 1284, 922, 12, 1325, 652, 5594, 199, 3437, 19782, 5309, 16367, 402, 5007, 25365, 2291, 315, 19252, 199, 2785, 410, 1298, 14, 199, 2344, 199, 504, 20553, 4936, 14, 3112, 14, 773, 492, 6118, 63, 578, 12, 6118, 63, 1974, 199, 646, 12866, 199, 199, 533, 603, 643, 915, 4578, 837, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1708, 63, 4990, 12, 291, 14, 1739, 63, 4990, 275, 12866, 14, 11867, 342, 267, 291, 14, 1907, 63, 1412, 275, 488, 267, 291, 423, 2019, 63, 24610, 63, 13429, 275, 1052, 339, 347, 1343, 8, 277, 304, 267, 340, 291, 14, 374, 63, 2682, 837, 288, 372, 267, 340, 291, 14, 1907, 63, 1412, 26, 288, 291, 14, 1907, 63, 1412, 14, 904, 342, 398, 367, 634, 315, 291, 423, 2019, 63, 24610, 63, 13429, 14, 1459, 837, 288, 367, 333, 315, 634, 26, 355, 340, 440, 333, 26, 490, 1980, 355, 291, 14, 1708, 63, 4990, 14, 2254, 8, 77, 9, 398, 291, 14, 1907, 63, 1412, 275, 12866, 14, 3498, 8, 1375, 29, 277, 14, 1907, 63, 1765, 9, 267, 291, 14, 1907, 63, 1412, 14, 928, 342, 339, 347, 3631, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 2682, 837, 288, 372, 398, 291, 14, 1708, 63, 4990, 14, 2254, 360, 1600, 358, 267, 291, 14, 1907, 63, 1412, 14, 904, 342, 339, 347, 8574, 63, 1765, 8, 277, 304, 267, 6118, 63, 1974, 14, 1739, 63, 1600, 63, 14240, 342, 398, 687, 20553, 4936, 14, 3112, 14, 773, 492, 4818, 63, 1412, 15606, 267, 687, 20553, 4936, 14, 3112, 14, 773, 14, 6323, 63, 3422, 492, 4818, 267, 687, 1973, 14, 5615, 915, 63, 2180, 63, 1907, 492, 603, 643, 915, 3160, 398, 1145, 275, 4818, 14, 2640, 8, 797, 9, 267, 1145, 14, 1943, 275, 603, 643, 915, 3160, 8, 277, 14, 1739, 63, 4990, 9, 267, 1145, 14, 1943, 14, 6824, 342, 267, 1145, 14, 6756, 7382, 342, 339, 347, 365, 63, 2682, 8, 277, 304, 267, 372, 291, 14, 1907, 63, 1412, 365, 440, 488, 436, 291, 14, 1907, 63, 1412, 14, 374, 63, 9631, 342, 339, 347, 11456, 1073, 63, 6253, 8, 277, 12, 333, 304, 267, 340, 333, 14, 863, 405, 63, 344, 440, 315, 291, 423, 2019, 63, 24610, 63, 13429, 26, 288, 327, 14797, 314, 2877, 2061, 3788, 880, 626, 12, 340, 1373, 365, 314, 25365, 288, 327, 3622, 1245, 12, 314, 4136, 1373, 365, 314, 2061, 6696, 1245, 14, 288, 291, 423, 2019, 63, 24610, 63, 13429, 59, 77, 14, 863, 405, 63, 344, 61, 275, 359, 403, 12, 333, 61, 267, 587, 26, 288, 634, 275, 291, 423, 2019, 63, 24610, 63, 13429, 59, 77, 14, 863, 405, 63, 344, 61, 288, 634, 59, 16, 61, 275, 634, 59, 17, 61, 288, 634, 59, 17, 61, 275, 333, 398, 340, 440, 291, 14, 374, 63, 2682, 837, 288, 372, 267, 291, 14, 1708, 63, 4990, 14, 2254, 8, 77, 9, 199, 199, 533, 603, 643, 915, 4578, 2377, 8, 311, 63, 578, 14, 1658, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 6118, 929, 304, 267, 1613, 8, 22745, 915, 4578, 2377, 12, 291, 2843, 826, 721, 311, 929, 12, 283, 5615, 915, 63, 2180, 358, 267, 291, 14, 525, 63, 1531, 8, 288, 283, 5615, 915, 63, 2180, 297, 288, 291, 14, 1760, 63, 5615, 915, 63, 2180, 12, 288, 283, 1490, 282, 4353, 370, 3622, 8127, 915, 6696, 436, 5137, 2312, 380, 9916, 283, 435, 288, 283, 7786, 9793, 701, 314, 13736, 666, 315, 3363, 900, 297, 267, 776, 398, 291, 14, 2180, 275, 603, 643, 915, 4578, 342, 339, 347, 2088, 63, 5615, 915, 63, 2180, 8, 277, 12, 1249, 304, 267, 291, 14, 2180, 14, 928, 342, 339, 347, 11456, 1073, 63, 6253, 8, 277, 12, 333, 304, 267, 340, 333, 14, 362, 63, 466, 342, 440, 315, 661, 45, 1254, 63, 13329, 63, 24547, 297, 283, 45, 1254, 63, 13329, 63, 17356, 735, 288, 372, 267, 291, 14, 2180, 14, 24610, 63, 6253, 8, 77, 9, 339, 347, 625, 912, 8, 277, 304, 267, 291, 14, 2180, 14, 2379, 342, 199, 199, 318, 4205, 8, 311, 929, 304, 272, 372, 603, 643, 915, 4578, 2377, 8, 311, 929, 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 ]
[ 1898, 334, 35, 9, 7800, 221, 20619, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 961, 570, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 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, 961, 570, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 2765, 859, 13703, 314, 2312, 380, 9916, 10189, 9793, 701, 314, 5845, 13736, 5309, 199, 863, 405, 25365, 12, 436, 2597, 2005, 2004, 666, 14, 710, 20632, 402, 642, 859, 365, 199, 475, 5647, 282, 3659, 641, 4212, 370, 15579, 314, 901, 658, 13207, 63, 2629, 64, 687, 314, 199, 45, 1254, 63, 13329, 63, 24547, 11456, 1073, 1245, 14, 10314, 2556, 883, 506, 1202, 315, 1865, 370, 199, 17348, 314, 27616, 922, 5309, 25365, 14, 199, 199, 1918, 5137, 9164, 701, 642, 859, 5712, 1133, 7437, 24606, 370, 314, 1284, 922, 12, 1325, 652, 5594, 199, 3437, 19782, 5309, 16367, 402, 5007, 25365, 2291, 315, 19252, 199, 2785, 410, 1298, 14, 199, 2344, 199, 504, 20553, 4936, 14, 3112, 14, 773, 492, 6118, 63, 578, 12, 6118, 63, 1974, 199, 646, 12866, 199, 199, 533, 603, 643, 915, 4578, 837, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1708, 63, 4990, 12, 291, 14, 1739, 63, 4990, 275, 12866, 14, 11867, 342, 267, 291, 14, 1907, 63, 1412, 275, 488, 267, 291, 423, 2019, 63, 24610, 63, 13429, 275, 1052, 339, 347, 1343, 8, 277, 304, 267, 340, 291, 14, 374, 63, 2682, 837, 288, 372, 267, 340, 291, 14, 1907, 63, 1412, 26, 288, 291, 14, 1907, 63, 1412, 14, 904, 342, 398, 367, 634, 315, 291, 423, 2019, 63, 24610, 63, 13429, 14, 1459, 837, 288, 367, 333, 315, 634, 26, 355, 340, 440, 333, 26, 490, 1980, 355, 291, 14, 1708, 63, 4990, 14, 2254, 8, 77, 9, 398, 291, 14, 1907, 63, 1412, 275, 12866, 14, 3498, 8, 1375, 29, 277, 14, 1907, 63, 1765, 9, 267, 291, 14, 1907, 63, 1412, 14, 928, 342, 339, 347, 3631, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 2682, 837, 288, 372, 398, 291, 14, 1708, 63, 4990, 14, 2254, 360, 1600, 358, 267, 291, 14, 1907, 63, 1412, 14, 904, 342, 339, 347, 8574, 63, 1765, 8, 277, 304, 267, 6118, 63, 1974, 14, 1739, 63, 1600, 63, 14240, 342, 398, 687, 20553, 4936, 14, 3112, 14, 773, 492, 4818, 63, 1412, 15606, 267, 687, 20553, 4936, 14, 3112, 14, 773, 14, 6323, 63, 3422, 492, 4818, 267, 687, 1973, 14, 5615, 915, 63, 2180, 63, 1907, 492, 603, 643, 915, 3160, 398, 1145, 275, 4818, 14, 2640, 8, 797, 9, 267, 1145, 14, 1943, 275, 603, 643, 915, 3160, 8, 277, 14, 1739, 63, 4990, 9, 267, 1145, 14, 1943, 14, 6824, 342, 267, 1145, 14, 6756, 7382, 342, 339, 347, 365, 63, 2682, 8, 277, 304, 267, 372, 291, 14, 1907, 63, 1412, 365, 440, 488, 436, 291, 14, 1907, 63, 1412, 14, 374, 63, 9631, 342, 339, 347, 11456, 1073, 63, 6253, 8, 277, 12, 333, 304, 267, 340, 333, 14, 863, 405, 63, 344, 440, 315, 291, 423, 2019, 63, 24610, 63, 13429, 26, 288, 327, 14797, 314, 2877, 2061, 3788, 880, 626, 12, 340, 1373, 365, 314, 25365, 288, 327, 3622, 1245, 12, 314, 4136, 1373, 365, 314, 2061, 6696, 1245, 14, 288, 291, 423, 2019, 63, 24610, 63, 13429, 59, 77, 14, 863, 405, 63, 344, 61, 275, 359, 403, 12, 333, 61, 267, 587, 26, 288, 634, 275, 291, 423, 2019, 63, 24610, 63, 13429, 59, 77, 14, 863, 405, 63, 344, 61, 288, 634, 59, 16, 61, 275, 634, 59, 17, 61, 288, 634, 59, 17, 61, 275, 333, 398, 340, 440, 291, 14, 374, 63, 2682, 837, 288, 372, 267, 291, 14, 1708, 63, 4990, 14, 2254, 8, 77, 9, 199, 199, 533, 603, 643, 915, 4578, 2377, 8, 311, 63, 578, 14, 1658, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 6118, 929, 304, 267, 1613, 8, 22745, 915, 4578, 2377, 12, 291, 2843, 826, 721, 311, 929, 12, 283, 5615, 915, 63, 2180, 358, 267, 291, 14, 525, 63, 1531, 8, 288, 283, 5615, 915, 63, 2180, 297, 288, 291, 14, 1760, 63, 5615, 915, 63, 2180, 12, 288, 283, 1490, 282, 4353, 370, 3622, 8127, 915, 6696, 436, 5137, 2312, 380, 9916, 283, 435, 288, 283, 7786, 9793, 701, 314, 13736, 666, 315, 3363, 900, 297, 267, 776, 398, 291, 14, 2180, 275, 603, 643, 915, 4578, 342, 339, 347, 2088, 63, 5615, 915, 63, 2180, 8, 277, 12, 1249, 304, 267, 291, 14, 2180, 14, 928, 342, 339, 347, 11456, 1073, 63, 6253, 8, 277, 12, 333, 304, 267, 340, 333, 14, 362, 63, 466, 342, 440, 315, 661, 45, 1254, 63, 13329, 63, 24547, 297, 283, 45, 1254, 63, 13329, 63, 17356, 735, 288, 372, 267, 291, 14, 2180, 14, 24610, 63, 6253, 8, 77, 9, 339, 347, 625, 912, 8, 277, 304, 267, 291, 14, 2180, 14, 2379, 342, 199, 199, 318, 4205, 8, 311, 929, 304, 272, 372, 603, 643, 915, 4578, 2377, 8, 311, 929, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tinkhaven-organization/odoo
openerp/addons/base/__openerp__.py
336
3703
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Base', 'version': '1.3', 'category': 'Hidden', 'description': """ The kernel of OpenERP, needed for all installation. =================================================== """, 'author': 'OpenERP SA', 'maintainer': 'OpenERP SA', 'website': 'http://www.openerp.com', 'depends': [], 'data': [ 'base_data.xml', 'res/res_currency_data.xml', 'res/res_country_data.xml', 'security/base_security.xml', 'base_menu.xml', 'res/res_config.xml', 'res/res.country.state.csv', 'ir/ir_actions.xml', 'ir/ir_config_parameter_view.xml', 'ir/ir_cron_view.xml', 'ir/ir_filters.xml', 'ir/ir_mail_server_view.xml', 'ir/ir_model_view.xml', 'ir/ir_attachment_view.xml', 'ir/ir_rule_view.xml', 'ir/ir_sequence_view.xml', 'ir/ir_translation_view.xml', 'ir/ir_ui_menu_view.xml', 'ir/ir_ui_view_view.xml', 'ir/ir_values_view.xml', 'ir/osv_memory_autovacuum.xml', 'ir/ir_model_report.xml', 'ir/ir_logging_view.xml', 'ir/ir_qweb.xml', 'workflow/workflow_view.xml', 'module/module_view.xml', 'module/module_data.xml', 'module/module_report.xml', 'module/wizard/base_module_update_view.xml', 'module/wizard/base_language_install_view.xml', 'module/wizard/base_import_language_view.xml', 'module/wizard/base_module_upgrade_view.xml', 'module/wizard/base_module_configuration_view.xml', 'module/wizard/base_export_language_view.xml', 'module/wizard/base_update_translations_view.xml', 'module/wizard/base_module_immediate_install.xml', 'res/res_company_view.xml', 'res/res_request_view.xml', 'res/res_lang_view.xml', 'res/res_partner_report.xml', 'res/res_partner_view.xml', 'res/res_bank_view.xml', 'res/res_country_view.xml', 'res/res_currency_view.xml', 'res/res_users_view.xml', 'res/res_partner_data.xml', 'res/ir_property_view.xml', 'res/res_security.xml', 'security/ir.model.access.csv', ], 'demo': [ 'base_demo.xml', 'res/res_partner_demo.xml', 'res/res_partner_demo.yml', 'res/res_partner_image_demo.xml', ], 'test': [ 'tests/base_test.yml', 'tests/test_osv_expression.yml', 'tests/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules. ], 'installable': True, 'auto_install': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 7409, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 1563, 297, 272, 283, 1023, 356, 283, 17, 14, 19, 297, 272, 283, 3710, 356, 283, 14983, 297, 272, 283, 1802, 356, 408, 199, 1918, 5114, 402, 7653, 12, 4346, 367, 1006, 12096, 14, 199, 12813, 5918, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 26665, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 8912, 356, 990, 272, 283, 576, 356, 359, 267, 283, 1095, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4968, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 6063, 63, 576, 14, 1652, 297, 267, 283, 4416, 15, 1095, 63, 4416, 14, 1652, 297, 267, 283, 1095, 63, 4470, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 888, 14, 1652, 297, 267, 283, 470, 15, 470, 14, 6063, 14, 929, 14, 4737, 297, 267, 283, 723, 15, 723, 63, 3723, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 888, 63, 5329, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 14829, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4273, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1198, 63, 1000, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1238, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 8905, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 2200, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4041, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 6893, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1907, 63, 4470, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1907, 63, 1345, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1459, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 4795, 63, 4844, 63, 2495, 15367, 19805, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1238, 63, 3070, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4806, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 22600, 14, 1652, 297, 267, 283, 8856, 15, 8856, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 576, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 3070, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 873, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 3671, 63, 3174, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 646, 63, 3671, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 9375, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 4758, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 3790, 63, 3671, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 873, 63, 13982, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 20250, 63, 3174, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4627, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 1069, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4159, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 3070, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 9860, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 6063, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4968, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3707, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 723, 63, 1829, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 272, 2156, 272, 283, 8768, 356, 359, 267, 283, 1095, 63, 8768, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 8768, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 8768, 14, 11714, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 1569, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 359, 267, 283, 2219, 15, 1095, 63, 396, 14, 11714, 297, 267, 283, 2219, 15, 396, 63, 4795, 63, 5599, 14, 11714, 297, 267, 283, 2219, 15, 396, 63, 723, 63, 2200, 14, 11714, 297, 327, 665, 306, 5723, 2295, 2811, 15, 525, 15, 1807, 8190, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 7409, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 1563, 297, 272, 283, 1023, 356, 283, 17, 14, 19, 297, 272, 283, 3710, 356, 283, 14983, 297, 272, 283, 1802, 356, 408, 199, 1918, 5114, 402, 7653, 12, 4346, 367, 1006, 12096, 14, 199, 12813, 5918, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 26665, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 8912, 356, 990, 272, 283, 576, 356, 359, 267, 283, 1095, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4968, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 6063, 63, 576, 14, 1652, 297, 267, 283, 4416, 15, 1095, 63, 4416, 14, 1652, 297, 267, 283, 1095, 63, 4470, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 888, 14, 1652, 297, 267, 283, 470, 15, 470, 14, 6063, 14, 929, 14, 4737, 297, 267, 283, 723, 15, 723, 63, 3723, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 888, 63, 5329, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 14829, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4273, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1198, 63, 1000, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1238, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 8905, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 2200, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4041, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 6893, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1907, 63, 4470, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1907, 63, 1345, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1459, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 4795, 63, 4844, 63, 2495, 15367, 19805, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 1238, 63, 3070, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 4806, 63, 1345, 14, 1652, 297, 267, 283, 723, 15, 723, 63, 22600, 14, 1652, 297, 267, 283, 8856, 15, 8856, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 576, 14, 1652, 297, 267, 283, 578, 15, 578, 63, 3070, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 873, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 3671, 63, 3174, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 646, 63, 3671, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 9375, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 4758, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 3790, 63, 3671, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 873, 63, 13982, 63, 1345, 14, 1652, 297, 267, 283, 578, 15, 9819, 15, 1095, 63, 578, 63, 20250, 63, 3174, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4627, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 1069, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4159, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 3070, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 9860, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 6063, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4968, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3707, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 576, 14, 1652, 297, 267, 283, 470, 15, 723, 63, 1829, 63, 1345, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 4416, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 272, 2156, 272, 283, 8768, 356, 359, 267, 283, 1095, 63, 8768, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 8768, 14, 1652, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 8768, 14, 11714, 297, 267, 283, 470, 15, 470, 63, 3899, 63, 1569, 63, 8768, 14, 1652, 297, 272, 2156, 272, 283, 396, 356, 359, 267, 283, 2219, 15, 1095, 63, 396, 14, 11714, 297, 267, 283, 2219, 15, 396, 63, 4795, 63, 5599, 14, 11714, 297, 267, 283, 2219, 15, 396, 63, 723, 63, 2200, 14, 11714, 297, 327, 665, 306, 5723, 2295, 2811, 15, 525, 15, 1807, 8190, 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,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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 ]
cyanna/edx-platform
lms/djangoapps/course_wiki/editors.py
101
2244
from django import forms from django.forms.util import flatatt from django.utils.encoding import force_unicode from django.utils.html import conditional_escape from django.utils.safestring import mark_safe from django.template.loader import render_to_string from wiki.editors.base import BaseEditor from wiki.editors.markitup import MarkItUpAdminWidget class CodeMirrorWidget(forms.Widget): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. default_attrs = {'class': 'markItUp', 'rows': '10', 'cols': '40', } if attrs: default_attrs.update(attrs) super(CodeMirrorWidget, self).__init__(default_attrs) def render(self, name, value, attrs=None): if value is None: value = '' final_attrs = self.build_attrs(attrs, name=name) # TODO use the help_text field of edit form instead of rendering a template return render_to_string('wiki/includes/editor_widget.html', {'attrs': mark_safe(flatatt(final_attrs)), 'content': conditional_escape(force_unicode(value)), }) class CodeMirror(BaseEditor): editor_id = 'codemirror' def get_admin_widget(self, instance=None): return MarkItUpAdminWidget() def get_widget(self, instance=None): return CodeMirrorWidget() class AdminMedia(object): # pylint: disable=missing-docstring css = { 'all': ("wiki/markitup/skins/simple/style.css", "wiki/markitup/sets/admin/style.css",) } js = ("wiki/markitup/admin.init.js", "wiki/markitup/jquery.markitup.js", "wiki/markitup/sets/admin/set.js", ) class Media(object): # pylint: disable=missing-docstring css = { 'all': ("js/vendor/CodeMirror/codemirror.css",) } js = ("js/vendor/CodeMirror/codemirror.js", "js/vendor/CodeMirror/addons/xml.js", "js/vendor/CodeMirror/addons/edx_markdown.js", "js/wiki/accessible.js", "js/wiki/CodeMirror.init.js", )
agpl-3.0
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 3351, 14, 1974, 492, 6829, 6796, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 199, 504, 17195, 14, 3773, 1384, 14, 1095, 492, 3523, 10423, 199, 504, 17195, 14, 3773, 1384, 14, 1657, 390, 384, 492, 7173, 7940, 1721, 4880, 3339, 421, 199, 533, 5495, 28034, 3339, 8, 3351, 14, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 327, 710, 283, 3838, 7, 436, 283, 4574, 7, 3004, 787, 1415, 367, 4163, 29102, 14, 267, 849, 63, 3288, 275, 791, 533, 356, 283, 1657, 7940, 1721, 297, 586, 283, 3838, 356, 283, 709, 297, 283, 4574, 356, 283, 2167, 297, 789, 267, 340, 3290, 26, 288, 849, 63, 3288, 14, 873, 8, 3288, 9, 267, 1613, 8, 3034, 28034, 3339, 12, 291, 2843, 826, 721, 885, 63, 3288, 9, 339, 347, 3795, 8, 277, 12, 536, 12, 574, 12, 3290, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 2125, 398, 4242, 63, 3288, 275, 291, 14, 1506, 63, 3288, 8, 3288, 12, 536, 29, 354, 9, 398, 327, 3254, 675, 314, 1720, 63, 505, 901, 402, 5283, 1824, 3140, 402, 14066, 282, 1978, 398, 372, 3795, 63, 475, 63, 875, 360, 6797, 15, 9441, 15, 7515, 63, 3440, 14, 1360, 297, 1816, 791, 3288, 356, 2216, 63, 3489, 8, 7088, 6796, 8, 5094, 63, 3288, 1826, 639, 283, 1317, 356, 12303, 63, 3765, 8, 3990, 63, 2975, 8, 585, 1826, 639, 3828, 421, 199, 533, 5495, 28034, 8, 1563, 10423, 304, 272, 8823, 63, 344, 275, 283, 600, 12324, 7, 339, 347, 664, 63, 2113, 63, 3440, 8, 277, 12, 1256, 29, 403, 304, 267, 372, 7173, 7940, 1721, 4880, 3339, 342, 339, 347, 664, 63, 3440, 8, 277, 12, 1256, 29, 403, 304, 267, 372, 5495, 28034, 3339, 342, 339, 1021, 9516, 11398, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 11431, 275, 469, 288, 283, 452, 356, 1689, 6797, 15, 1657, 390, 384, 15, 1339, 3617, 15, 4129, 15, 2487, 14, 3919, 401, 490, 298, 6797, 15, 1657, 390, 384, 15, 2193, 15, 2113, 15, 2487, 14, 3919, 26360, 267, 789, 267, 8586, 275, 1689, 6797, 15, 1657, 390, 384, 15, 2113, 14, 826, 14, 3596, 401, 1598, 298, 6797, 15, 1657, 390, 384, 15, 22324, 14, 1657, 390, 384, 14, 3596, 401, 1598, 298, 6797, 15, 1657, 390, 384, 15, 2193, 15, 2113, 15, 409, 14, 3596, 401, 1598, 776, 339, 1021, 12300, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 11431, 275, 469, 288, 283, 452, 356, 1689, 3596, 15, 9884, 15, 3034, 28034, 15, 600, 12324, 14, 3919, 26360, 267, 789, 267, 8586, 275, 1689, 3596, 15, 9884, 15, 3034, 28034, 15, 600, 12324, 14, 3596, 401, 1598, 298, 3596, 15, 9884, 15, 3034, 28034, 15, 10788, 15, 1652, 14, 3596, 401, 1598, 298, 3596, 15, 9884, 15, 3034, 28034, 15, 10788, 15, 8268, 63, 15653, 14, 3596, 401, 1598, 298, 3596, 15, 6797, 15, 24669, 14, 3596, 401, 1598, 298, 3596, 15, 6797, 15, 3034, 28034, 14, 826, 14, 3596, 401, 1598, 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 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 3351, 14, 1974, 492, 6829, 6796, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 1360, 492, 12303, 63, 3765, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3795, 63, 475, 63, 875, 199, 199, 504, 17195, 14, 3773, 1384, 14, 1095, 492, 3523, 10423, 199, 504, 17195, 14, 3773, 1384, 14, 1657, 390, 384, 492, 7173, 7940, 1721, 4880, 3339, 421, 199, 533, 5495, 28034, 3339, 8, 3351, 14, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 327, 710, 283, 3838, 7, 436, 283, 4574, 7, 3004, 787, 1415, 367, 4163, 29102, 14, 267, 849, 63, 3288, 275, 791, 533, 356, 283, 1657, 7940, 1721, 297, 586, 283, 3838, 356, 283, 709, 297, 283, 4574, 356, 283, 2167, 297, 789, 267, 340, 3290, 26, 288, 849, 63, 3288, 14, 873, 8, 3288, 9, 267, 1613, 8, 3034, 28034, 3339, 12, 291, 2843, 826, 721, 885, 63, 3288, 9, 339, 347, 3795, 8, 277, 12, 536, 12, 574, 12, 3290, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 2125, 398, 4242, 63, 3288, 275, 291, 14, 1506, 63, 3288, 8, 3288, 12, 536, 29, 354, 9, 398, 327, 3254, 675, 314, 1720, 63, 505, 901, 402, 5283, 1824, 3140, 402, 14066, 282, 1978, 398, 372, 3795, 63, 475, 63, 875, 360, 6797, 15, 9441, 15, 7515, 63, 3440, 14, 1360, 297, 1816, 791, 3288, 356, 2216, 63, 3489, 8, 7088, 6796, 8, 5094, 63, 3288, 1826, 639, 283, 1317, 356, 12303, 63, 3765, 8, 3990, 63, 2975, 8, 585, 1826, 639, 3828, 421, 199, 533, 5495, 28034, 8, 1563, 10423, 304, 272, 8823, 63, 344, 275, 283, 600, 12324, 7, 339, 347, 664, 63, 2113, 63, 3440, 8, 277, 12, 1256, 29, 403, 304, 267, 372, 7173, 7940, 1721, 4880, 3339, 342, 339, 347, 664, 63, 3440, 8, 277, 12, 1256, 29, 403, 304, 267, 372, 5495, 28034, 3339, 342, 339, 1021, 9516, 11398, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 11431, 275, 469, 288, 283, 452, 356, 1689, 6797, 15, 1657, 390, 384, 15, 1339, 3617, 15, 4129, 15, 2487, 14, 3919, 401, 490, 298, 6797, 15, 1657, 390, 384, 15, 2193, 15, 2113, 15, 2487, 14, 3919, 26360, 267, 789, 267, 8586, 275, 1689, 6797, 15, 1657, 390, 384, 15, 2113, 14, 826, 14, 3596, 401, 1598, 298, 6797, 15, 1657, 390, 384, 15, 22324, 14, 1657, 390, 384, 14, 3596, 401, 1598, 298, 6797, 15, 1657, 390, 384, 15, 2193, 15, 2113, 15, 409, 14, 3596, 401, 1598, 776, 339, 1021, 12300, 8, 785, 304, 221, 327, 4287, 26, 3507, 29, 4752, 13, 12485, 267, 11431, 275, 469, 288, 283, 452, 356, 1689, 3596, 15, 9884, 15, 3034, 28034, 15, 600, 12324, 14, 3919, 26360, 267, 789, 267, 8586, 275, 1689, 3596, 15, 9884, 15, 3034, 28034, 15, 600, 12324, 14, 3596, 401, 1598, 298, 3596, 15, 9884, 15, 3034, 28034, 15, 10788, 15, 1652, 14, 3596, 401, 1598, 298, 3596, 15, 9884, 15, 3034, 28034, 15, 10788, 15, 8268, 63, 15653, 14, 3596, 401, 1598, 298, 3596, 15, 6797, 15, 24669, 14, 3596, 401, 1598, 298, 3596, 15, 6797, 15, 3034, 28034, 14, 826, 14, 3596, 401, 1598, 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, 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,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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 ]
antoviaque/edx-platform
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
73
7484
""" Management command to find all students that need certificates for courses that have finished, and put their cert requests on the queue. """ import logging import datetime from pytz import UTC from django.core.management.base import BaseCommand, CommandError from certificates.models import certificate_status_for_student from certificates.api import generate_user_certificates from django.contrib.auth.models import User from optparse import make_option from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey from xmodule.modulestore.django import modulestore from certificates.models import CertificateStatuses LOGGER = logging.getLogger(__name__) class Command(BaseCommand): """ Management command to find all students that need certificates for courses that have finished and put their cert requests on the queue. """ help = """ Find all students that need certificates for courses that have finished and put their cert requests on the queue. If --user is given, only grade and certify the requested username. Use the --noop option to test without actually putting certificates on the queue to be generated. """ option_list = BaseCommand.option_list + ( make_option('-n', '--noop', action='store_true', dest='noop', default=False, help="Don't add certificate requests to the queue"), make_option('--insecure', action='store_true', dest='insecure', default=False, help="Don't use https for the callback url to the LMS, useful in http test environments"), make_option('-c', '--course', metavar='COURSE_ID', dest='course', default=False, help='Grade and generate certificates ' 'for a specific course'), make_option('-f', '--force-gen', metavar='STATUS', dest='force', default=False, help='Will generate new certificates for only those users ' 'whose entry in the certificate table matches STATUS. ' 'STATUS can be generating, unavailable, deleted, error ' 'or notpassing.'), ) def handle(self, *args, **options): LOGGER.info( ( u"Starting to create tasks for ungenerated certificates " u"with arguments %s and options %s" ), unicode(args), unicode(options) ) # Will only generate a certificate if the current # status is in the unavailable state, can be set # to something else with the force flag if options['force']: valid_statuses = [getattr(CertificateStatuses, options['force'])] else: valid_statuses = [CertificateStatuses.unavailable] # Print update after this many students STATUS_INTERVAL = 500 if options['course']: # try to parse out the course from the serialized form try: course = CourseKey.from_string(options['course']) except InvalidKeyError: LOGGER.warning( ( u"Course id %s could not be parsed as a CourseKey; " u"falling back to SlashSeparatedCourseKey.from_deprecated_string()" ), options['course'] ) course = SlashSeparatedCourseKey.from_deprecated_string(options['course']) ended_courses = [course] else: raise CommandError("You must specify a course") for course_key in ended_courses: # prefetch all chapters/sequentials by saying depth=2 course = modulestore().get_course(course_key, depth=2) enrolled_students = User.objects.filter( courseenrollment__course_id=course_key ) total = enrolled_students.count() count = 0 start = datetime.datetime.now(UTC) for student in enrolled_students: count += 1 if count % STATUS_INTERVAL == 0: # Print a status update with an approximation of # how much time is left based on how long the last # interval took diff = datetime.datetime.now(UTC) - start timeleft = diff * (total - count) / STATUS_INTERVAL hours, remainder = divmod(timeleft.seconds, 3600) minutes, _seconds = divmod(remainder, 60) print "{0}/{1} completed ~{2:02}:{3:02}m remaining".format( count, total, hours, minutes) start = datetime.datetime.now(UTC) cert_status = certificate_status_for_student(student, course_key)['status'] LOGGER.info( ( u"Student %s has certificate status '%s' " u"in course '%s'" ), student.id, cert_status, unicode(course_key) ) if cert_status in valid_statuses: if not options['noop']: # Add the certificate request to the queue ret = generate_user_certificates( student, course_key, course=course, insecure=options['insecure'] ) if ret == 'generating': LOGGER.info( ( u"Added a certificate generation task to the XQueue " u"for student %s in course '%s'. " u"The new certificate status is '%s'." ), student.id, unicode(course_key), ret ) else: LOGGER.info( ( u"Skipping certificate generation for " u"student %s in course '%s' " u"because the noop flag is set." ), student.id, unicode(course_key) ) else: LOGGER.info( ( u"Skipped student %s because " u"certificate status '%s' is not in %s" ), student.id, cert_status, unicode(valid_statuses) ) LOGGER.info( ( u"Completed ungenerated certificates command " u"for course '%s'" ), unicode(course_key) )
agpl-3.0
[ 624, 199, 14552, 1414, 370, 2342, 1006, 18557, 626, 1929, 14512, 367, 199, 11653, 626, 1172, 9158, 12, 436, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 199, 624, 199, 646, 2050, 199, 646, 2197, 199, 504, 15444, 492, 12174, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 14512, 14, 992, 492, 5897, 63, 1205, 63, 509, 63, 5500, 199, 504, 14512, 14, 1246, 492, 3550, 63, 751, 63, 16159, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8691, 492, 1852, 63, 1422, 199, 504, 15058, 63, 1612, 492, 6378, 10230, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 14512, 14, 992, 492, 12904, 11232, 5589, 421, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 272, 8259, 1414, 370, 2342, 1006, 18557, 626, 1929, 14512, 272, 367, 13588, 626, 1172, 9158, 436, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 272, 408, 339, 1720, 275, 408, 272, 6668, 1006, 18557, 626, 1929, 14512, 367, 13588, 626, 1172, 9158, 436, 272, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 339, 982, 1553, 751, 365, 1627, 12, 1454, 16183, 436, 3361, 3338, 314, 5839, 3434, 14, 339, 3645, 314, 1553, 12921, 945, 370, 511, 1928, 5965, 32670, 14512, 641, 314, 272, 4126, 370, 506, 4046, 14, 272, 408, 339, 945, 63, 513, 275, 22239, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 3654, 78, 297, 2850, 12921, 297, 490, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 12921, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 16932, 1133, 1050, 5897, 4145, 370, 314, 4126, 1288, 267, 1852, 63, 1422, 4517, 24824, 297, 490, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 24824, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 16932, 1133, 675, 4178, 367, 314, 3233, 1166, 370, 314, 27540, 12, 2997, 315, 1455, 511, 22196, 1288, 267, 1852, 63, 1422, 3654, 67, 297, 2850, 1972, 297, 490, 8214, 534, 15552, 63, 998, 297, 490, 2053, 534, 1972, 297, 490, 849, 29, 797, 12, 490, 1720, 534, 5761, 271, 436, 3550, 14512, 283, 490, 283, 509, 282, 2488, 2518, 659, 267, 1852, 63, 1422, 3654, 70, 297, 2850, 3990, 13, 2268, 297, 490, 8214, 534, 6305, 297, 490, 2053, 534, 3990, 297, 490, 849, 29, 797, 12, 490, 1720, 534, 20326, 3550, 892, 14512, 367, 1454, 5204, 4390, 283, 490, 283, 11345, 261, 2397, 315, 314, 5897, 1817, 4450, 18460, 14, 283, 490, 283, 6305, 883, 506, 12999, 12, 18735, 12, 5463, 12, 1125, 283, 490, 283, 269, 440, 29436, 8038, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 20184, 14, 815, 8, 288, 334, 355, 399, 2, 14139, 370, 1218, 6527, 367, 625, 10176, 14512, 298, 355, 399, 2, 1045, 2368, 450, 83, 436, 1511, 450, 83, 2, 288, 2318, 288, 2649, 8, 589, 395, 288, 2649, 8, 1419, 9, 267, 776, 398, 327, 12823, 1454, 3550, 282, 5897, 340, 314, 1453, 267, 327, 2004, 365, 315, 314, 18735, 1174, 12, 883, 506, 663, 267, 327, 370, 6020, 587, 543, 314, 3542, 3305, 398, 340, 1511, 459, 3990, 2565, 288, 1686, 63, 17084, 275, 359, 5675, 8, 11414, 11232, 5589, 12, 1511, 459, 3990, 24437, 267, 587, 26, 288, 1686, 63, 17084, 275, 359, 11414, 11232, 5589, 14, 28119, 61, 398, 327, 9101, 1678, 2410, 642, 5002, 18557, 398, 18460, 63, 17359, 275, 6891, 398, 340, 1511, 459, 1972, 2565, 288, 327, 862, 370, 2198, 734, 314, 2518, 687, 314, 6380, 1824, 288, 862, 26, 355, 2518, 275, 22574, 14, 504, 63, 875, 8, 1419, 459, 1972, 1105, 288, 871, 6378, 10230, 26, 355, 20184, 14, 3764, 8, 490, 334, 717, 399, 2, 6979, 1305, 450, 83, 4293, 440, 506, 4565, 465, 282, 22574, 27, 298, 717, 399, 2, 70, 26039, 1771, 370, 30687, 14, 504, 63, 6667, 63, 875, 16493, 490, 2318, 490, 1511, 459, 1972, 418, 355, 776, 355, 2518, 275, 30687, 14, 504, 63, 6667, 63, 875, 8, 1419, 459, 1972, 1105, 288, 22480, 63, 11653, 275, 359, 1972, 61, 267, 587, 26, 288, 746, 14393, 480, 5556, 1471, 4165, 282, 2518, 531, 398, 367, 2518, 63, 498, 315, 22480, 63, 11653, 26, 288, 327, 21544, 1006, 26041, 15, 16211, 83, 701, 14722, 316, 5818, 29, 18, 288, 2518, 275, 10996, 1252, 362, 63, 1972, 8, 1972, 63, 498, 12, 5818, 29, 18, 9, 953, 26802, 63, 17921, 275, 2876, 14, 1462, 14, 1541, 8, 355, 2518, 12214, 363, 1972, 63, 344, 29, 1972, 63, 498, 288, 776, 953, 3141, 275, 26802, 63, 17921, 14, 835, 342, 288, 2338, 275, 378, 288, 1343, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 953, 367, 6474, 315, 26802, 63, 17921, 26, 355, 2338, 847, 413, 355, 340, 2338, 450, 18460, 63, 17359, 508, 378, 26, 490, 327, 9101, 282, 2004, 1678, 543, 376, 22772, 402, 490, 327, 4212, 8298, 900, 365, 3602, 4079, 641, 4212, 1846, 314, 2061, 490, 327, 6252, 27221, 490, 3915, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 446, 1343, 490, 900, 3039, 275, 3915, 627, 334, 2923, 446, 2338, 9, 1182, 18460, 63, 17359, 490, 10857, 12, 15748, 275, 16438, 8, 521, 3039, 14, 4515, 12, 15751, 9, 490, 9395, 12, 485, 4515, 275, 16438, 8, 23850, 12, 5212, 9, 490, 870, 5310, 16, 16152, 17, 93, 9709, 6146, 91, 18, 26, 996, 16495, 19, 26, 996, 93, 77, 7971, 1674, 908, 8, 717, 2338, 12, 3141, 12, 10857, 12, 9395, 9, 490, 1343, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 2234, 6250, 63, 1205, 275, 5897, 63, 1205, 63, 509, 63, 5500, 8, 5500, 12, 2518, 63, 498, 11820, 1205, 418, 355, 20184, 14, 815, 8, 490, 334, 717, 399, 2, 18086, 450, 83, 965, 5897, 2004, 1543, 83, 7, 298, 717, 399, 2, 262, 2518, 1543, 83, 4065, 490, 2318, 490, 6474, 14, 344, 12, 490, 6250, 63, 1205, 12, 490, 2649 ]
[ 199, 14552, 1414, 370, 2342, 1006, 18557, 626, 1929, 14512, 367, 199, 11653, 626, 1172, 9158, 12, 436, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 199, 624, 199, 646, 2050, 199, 646, 2197, 199, 504, 15444, 492, 12174, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 14512, 14, 992, 492, 5897, 63, 1205, 63, 509, 63, 5500, 199, 504, 14512, 14, 1246, 492, 3550, 63, 751, 63, 16159, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8691, 492, 1852, 63, 1422, 199, 504, 15058, 63, 1612, 492, 6378, 10230, 199, 504, 15058, 63, 1612, 14, 8268, 14, 1612, 492, 22574, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 199, 504, 9872, 14, 10012, 14, 1176, 492, 10996, 199, 504, 14512, 14, 992, 492, 12904, 11232, 5589, 421, 199, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5817, 8, 25150, 304, 272, 408, 272, 8259, 1414, 370, 2342, 1006, 18557, 626, 1929, 14512, 272, 367, 13588, 626, 1172, 9158, 436, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 272, 408, 339, 1720, 275, 408, 272, 6668, 1006, 18557, 626, 1929, 14512, 367, 13588, 626, 1172, 9158, 436, 272, 5324, 3932, 6250, 4145, 641, 314, 4126, 14, 339, 982, 1553, 751, 365, 1627, 12, 1454, 16183, 436, 3361, 3338, 314, 5839, 3434, 14, 339, 3645, 314, 1553, 12921, 945, 370, 511, 1928, 5965, 32670, 14512, 641, 314, 272, 4126, 370, 506, 4046, 14, 272, 408, 339, 945, 63, 513, 275, 22239, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 3654, 78, 297, 2850, 12921, 297, 490, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 12921, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 16932, 1133, 1050, 5897, 4145, 370, 314, 4126, 1288, 267, 1852, 63, 1422, 4517, 24824, 297, 490, 1595, 534, 1617, 63, 2052, 297, 490, 2053, 534, 24824, 297, 490, 849, 29, 797, 12, 490, 1720, 628, 16932, 1133, 675, 4178, 367, 314, 3233, 1166, 370, 314, 27540, 12, 2997, 315, 1455, 511, 22196, 1288, 267, 1852, 63, 1422, 3654, 67, 297, 2850, 1972, 297, 490, 8214, 534, 15552, 63, 998, 297, 490, 2053, 534, 1972, 297, 490, 849, 29, 797, 12, 490, 1720, 534, 5761, 271, 436, 3550, 14512, 283, 490, 283, 509, 282, 2488, 2518, 659, 267, 1852, 63, 1422, 3654, 70, 297, 2850, 3990, 13, 2268, 297, 490, 8214, 534, 6305, 297, 490, 2053, 534, 3990, 297, 490, 849, 29, 797, 12, 490, 1720, 534, 20326, 3550, 892, 14512, 367, 1454, 5204, 4390, 283, 490, 283, 11345, 261, 2397, 315, 314, 5897, 1817, 4450, 18460, 14, 283, 490, 283, 6305, 883, 506, 12999, 12, 18735, 12, 5463, 12, 1125, 283, 490, 283, 269, 440, 29436, 8038, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 398, 20184, 14, 815, 8, 288, 334, 355, 399, 2, 14139, 370, 1218, 6527, 367, 625, 10176, 14512, 298, 355, 399, 2, 1045, 2368, 450, 83, 436, 1511, 450, 83, 2, 288, 2318, 288, 2649, 8, 589, 395, 288, 2649, 8, 1419, 9, 267, 776, 398, 327, 12823, 1454, 3550, 282, 5897, 340, 314, 1453, 267, 327, 2004, 365, 315, 314, 18735, 1174, 12, 883, 506, 663, 267, 327, 370, 6020, 587, 543, 314, 3542, 3305, 398, 340, 1511, 459, 3990, 2565, 288, 1686, 63, 17084, 275, 359, 5675, 8, 11414, 11232, 5589, 12, 1511, 459, 3990, 24437, 267, 587, 26, 288, 1686, 63, 17084, 275, 359, 11414, 11232, 5589, 14, 28119, 61, 398, 327, 9101, 1678, 2410, 642, 5002, 18557, 398, 18460, 63, 17359, 275, 6891, 398, 340, 1511, 459, 1972, 2565, 288, 327, 862, 370, 2198, 734, 314, 2518, 687, 314, 6380, 1824, 288, 862, 26, 355, 2518, 275, 22574, 14, 504, 63, 875, 8, 1419, 459, 1972, 1105, 288, 871, 6378, 10230, 26, 355, 20184, 14, 3764, 8, 490, 334, 717, 399, 2, 6979, 1305, 450, 83, 4293, 440, 506, 4565, 465, 282, 22574, 27, 298, 717, 399, 2, 70, 26039, 1771, 370, 30687, 14, 504, 63, 6667, 63, 875, 16493, 490, 2318, 490, 1511, 459, 1972, 418, 355, 776, 355, 2518, 275, 30687, 14, 504, 63, 6667, 63, 875, 8, 1419, 459, 1972, 1105, 288, 22480, 63, 11653, 275, 359, 1972, 61, 267, 587, 26, 288, 746, 14393, 480, 5556, 1471, 4165, 282, 2518, 531, 398, 367, 2518, 63, 498, 315, 22480, 63, 11653, 26, 288, 327, 21544, 1006, 26041, 15, 16211, 83, 701, 14722, 316, 5818, 29, 18, 288, 2518, 275, 10996, 1252, 362, 63, 1972, 8, 1972, 63, 498, 12, 5818, 29, 18, 9, 953, 26802, 63, 17921, 275, 2876, 14, 1462, 14, 1541, 8, 355, 2518, 12214, 363, 1972, 63, 344, 29, 1972, 63, 498, 288, 776, 953, 3141, 275, 26802, 63, 17921, 14, 835, 342, 288, 2338, 275, 378, 288, 1343, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 953, 367, 6474, 315, 26802, 63, 17921, 26, 355, 2338, 847, 413, 355, 340, 2338, 450, 18460, 63, 17359, 508, 378, 26, 490, 327, 9101, 282, 2004, 1678, 543, 376, 22772, 402, 490, 327, 4212, 8298, 900, 365, 3602, 4079, 641, 4212, 1846, 314, 2061, 490, 327, 6252, 27221, 490, 3915, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 446, 1343, 490, 900, 3039, 275, 3915, 627, 334, 2923, 446, 2338, 9, 1182, 18460, 63, 17359, 490, 10857, 12, 15748, 275, 16438, 8, 521, 3039, 14, 4515, 12, 15751, 9, 490, 9395, 12, 485, 4515, 275, 16438, 8, 23850, 12, 5212, 9, 490, 870, 5310, 16, 16152, 17, 93, 9709, 6146, 91, 18, 26, 996, 16495, 19, 26, 996, 93, 77, 7971, 1674, 908, 8, 717, 2338, 12, 3141, 12, 10857, 12, 9395, 9, 490, 1343, 275, 2197, 14, 2083, 14, 2131, 8, 11288, 9, 2234, 6250, 63, 1205, 275, 5897, 63, 1205, 63, 509, 63, 5500, 8, 5500, 12, 2518, 63, 498, 11820, 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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 ]
beernarrd/gramps
gramps/gui/selectors/selectplace.py
1
2669
# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2009-2010 Gary Burton # Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # #------------------------------------------------------------------------- # # internationalization # #------------------------------------------------------------------------- #------------------------------------------------------------------------- # # gramps modules # #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext from ..views.treemodels.placemodel import PlaceTreeModel from .baseselector import BaseSelector from gramps.gui.display import display_help from gramps.gen.const import URL_MANUAL_SECT2 #------------------------------------------------------------------------- # # Constants # #------------------------------------------------------------------------- WIKI_HELP_PAGE = URL_MANUAL_SECT2 WIKI_HELP_SEC = _('manual|Select_Place_selector') #------------------------------------------------------------------------- # # SelectPlace # #------------------------------------------------------------------------- class SelectPlace(BaseSelector): def _local_init(self): """ Perform local initialisation for this class """ self.setup_configs('interface.place-sel', 600, 450) def get_window_title(self): return _("Select Place") def get_model_class(self): return PlaceTreeModel def get_column_titles(self): return [ (_('Name'), 200, BaseSelector.TEXT, 0), (_('ID'), 75, BaseSelector.TEXT, 1), (_('Type'), 100, BaseSelector.TEXT, 3), (_('Title'), 300, BaseSelector.TEXT, 2), (_('Last Change'), 150, BaseSelector.TEXT, 9), ] def get_from_handle_func(self): return self.db.get_place_from_handle
gpl-2.0
[ 3, 199, 3, 10268, 13408, 446, 282, 598, 15263, 19616, 39, 2826, 3635, 4079, 15599, 2548, 89, 2240, 199, 3, 199, 3, 1898, 334, 35, 9, 13004, 13, 7968, 221, 7529, 27075, 653, 14, 2900, 316, 10670, 199, 3, 1898, 334, 35, 9, 8937, 13, 6542, 221, 598, 695, 699, 300, 1860, 199, 3, 1898, 334, 35, 9, 7129, 755, 653, 2000, 869, 452, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 199, 25812, 199, 3, 199, 3, 10757, 6279, 2072, 199, 3, 199, 25812, 199, 199, 25812, 199, 3, 199, 3, 1999, 13408, 4621, 199, 3, 199, 25812, 199, 504, 1999, 13408, 14, 2268, 14, 1297, 492, 21772, 1156, 5067, 63, 20828, 465, 486, 5508, 199, 63, 275, 486, 5508, 14, 6893, 14, 83, 5152, 199, 504, 2508, 4196, 14, 2350, 992, 14, 2778, 1238, 492, 10902, 3987, 1685, 199, 504, 1275, 1095, 6662, 492, 3523, 11212, 199, 504, 1999, 13408, 14, 5885, 14, 2918, 492, 2929, 63, 3437, 199, 504, 1999, 13408, 14, 2268, 14, 1297, 492, 2851, 63, 6588, 13841, 63, 32379, 18, 199, 199, 25812, 199, 3, 199, 3, 22296, 199, 3, 199, 25812, 199, 18759, 16944, 63, 17930, 63, 12898, 275, 2851, 63, 6588, 13841, 63, 32379, 18, 199, 18759, 16944, 63, 17930, 63, 15048, 275, 4018, 9285, 92, 5446, 63, 11613, 63, 6662, 358, 199, 199, 25812, 199, 3, 199, 3, 9496, 11613, 199, 3, 199, 25812, 199, 533, 9496, 11613, 8, 1563, 11212, 304, 339, 347, 485, 1832, 63, 826, 8, 277, 304, 267, 408, 267, 14795, 2257, 2536, 19914, 367, 642, 1021, 267, 408, 267, 291, 14, 2758, 63, 7532, 360, 3266, 14, 2778, 13, 5891, 297, 11624, 12, 841, 1400, 9, 339, 347, 664, 63, 3806, 63, 1213, 8, 277, 304, 267, 372, 3824, 5446, 10902, 531, 339, 347, 664, 63, 1238, 63, 533, 8, 277, 304, 267, 372, 10902, 3987, 1685, 339, 347, 664, 63, 2301, 63, 8916, 8, 277, 304, 267, 372, 359, 288, 21790, 985, 659, 221, 1926, 12, 3523, 11212, 14, 3876, 12, 378, 395, 288, 21790, 998, 659, 259, 13098, 12, 221, 3523, 11212, 14, 3876, 12, 413, 395, 288, 21790, 804, 659, 221, 2948, 12, 3523, 11212, 14, 3876, 12, 650, 395, 288, 21790, 6888, 659, 9601, 12, 3523, 11212, 14, 3876, 12, 499, 395, 288, 21790, 6090, 7743, 659, 14711, 12, 3523, 11212, 14, 3876, 12, 1749, 395, 288, 1622, 339, 347, 664, 63, 504, 63, 2479, 63, 1532, 8, 277, 304, 267, 372, 291, 14, 697, 14, 362, 63, 2778, 63, 504, 63, 2479, 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 ]
[ 199, 3, 10268, 13408, 446, 282, 598, 15263, 19616, 39, 2826, 3635, 4079, 15599, 2548, 89, 2240, 199, 3, 199, 3, 1898, 334, 35, 9, 13004, 13, 7968, 221, 7529, 27075, 653, 14, 2900, 316, 10670, 199, 3, 1898, 334, 35, 9, 8937, 13, 6542, 221, 598, 695, 699, 300, 1860, 199, 3, 1898, 334, 35, 9, 7129, 755, 653, 2000, 869, 452, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 199, 25812, 199, 3, 199, 3, 10757, 6279, 2072, 199, 3, 199, 25812, 199, 199, 25812, 199, 3, 199, 3, 1999, 13408, 4621, 199, 3, 199, 25812, 199, 504, 1999, 13408, 14, 2268, 14, 1297, 492, 21772, 1156, 5067, 63, 20828, 465, 486, 5508, 199, 63, 275, 486, 5508, 14, 6893, 14, 83, 5152, 199, 504, 2508, 4196, 14, 2350, 992, 14, 2778, 1238, 492, 10902, 3987, 1685, 199, 504, 1275, 1095, 6662, 492, 3523, 11212, 199, 504, 1999, 13408, 14, 5885, 14, 2918, 492, 2929, 63, 3437, 199, 504, 1999, 13408, 14, 2268, 14, 1297, 492, 2851, 63, 6588, 13841, 63, 32379, 18, 199, 199, 25812, 199, 3, 199, 3, 22296, 199, 3, 199, 25812, 199, 18759, 16944, 63, 17930, 63, 12898, 275, 2851, 63, 6588, 13841, 63, 32379, 18, 199, 18759, 16944, 63, 17930, 63, 15048, 275, 4018, 9285, 92, 5446, 63, 11613, 63, 6662, 358, 199, 199, 25812, 199, 3, 199, 3, 9496, 11613, 199, 3, 199, 25812, 199, 533, 9496, 11613, 8, 1563, 11212, 304, 339, 347, 485, 1832, 63, 826, 8, 277, 304, 267, 408, 267, 14795, 2257, 2536, 19914, 367, 642, 1021, 267, 408, 267, 291, 14, 2758, 63, 7532, 360, 3266, 14, 2778, 13, 5891, 297, 11624, 12, 841, 1400, 9, 339, 347, 664, 63, 3806, 63, 1213, 8, 277, 304, 267, 372, 3824, 5446, 10902, 531, 339, 347, 664, 63, 1238, 63, 533, 8, 277, 304, 267, 372, 10902, 3987, 1685, 339, 347, 664, 63, 2301, 63, 8916, 8, 277, 304, 267, 372, 359, 288, 21790, 985, 659, 221, 1926, 12, 3523, 11212, 14, 3876, 12, 378, 395, 288, 21790, 998, 659, 259, 13098, 12, 221, 3523, 11212, 14, 3876, 12, 413, 395, 288, 21790, 804, 659, 221, 2948, 12, 3523, 11212, 14, 3876, 12, 650, 395, 288, 21790, 6888, 659, 9601, 12, 3523, 11212, 14, 3876, 12, 499, 395, 288, 21790, 6090, 7743, 659, 14711, 12, 3523, 11212, 14, 3876, 12, 1749, 395, 288, 1622, 339, 347, 664, 63, 504, 63, 2479, 63, 1532, 8, 277, 304, 267, 372, 291, 14, 697, 14, 362, 63, 2778, 63, 504, 63, 2479, 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, 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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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 ]
MechCoder/scikit-learn
examples/neighbors/plot_kde_1d.py
60
5120
""" =================================== Simple 1D Kernel Density Estimation =================================== This example uses the :class:`sklearn.neighbors.KernelDensity` class to demonstrate the principles of Kernel Density Estimation in one dimension. The first plot shows one of the problems with using histograms to visualize the density of points in 1D. Intuitively, a histogram can be thought of as a scheme in which a unit "block" is stacked above each point on a regular grid. As the top two panels show, however, the choice of gridding for these blocks can lead to wildly divergent ideas about the underlying shape of the density distribution. If we instead center each block on the point it represents, we get the estimate shown in the bottom left panel. This is a kernel density estimation with a "top hat" kernel. This idea can be generalized to other kernel shapes: the bottom-right panel of the first figure shows a Gaussian kernel density estimate over the same distribution. Scikit-learn implements efficient kernel density estimation using either a Ball Tree or KD Tree structure, through the :class:`sklearn.neighbors.KernelDensity` estimator. The available kernels are shown in the second figure of this example. The third figure compares kernel density estimates for a distribution of 100 samples in 1 dimension. Though this example uses 1D distributions, kernel density estimation is easily and efficiently extensible to higher dimensions as well. """ # Author: Jake Vanderplas <jakevdp@cs.washington.edu> # import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm from sklearn.neighbors import KernelDensity #---------------------------------------------------------------------- # Plot the progression of histograms to kernels np.random.seed(1) N = 20 X = np.concatenate((np.random.normal(0, 1, int(0.3 * N)), np.random.normal(5, 1, int(0.7 * N))))[:, np.newaxis] X_plot = np.linspace(-5, 10, 1000)[:, np.newaxis] bins = np.linspace(-5, 10, 10) fig, ax = plt.subplots(2, 2, sharex=True, sharey=True) fig.subplots_adjust(hspace=0.05, wspace=0.05) # histogram 1 ax[0, 0].hist(X[:, 0], bins=bins, fc='#AAAAFF', normed=True) ax[0, 0].text(-3.5, 0.31, "Histogram") # histogram 2 ax[0, 1].hist(X[:, 0], bins=bins + 0.75, fc='#AAAAFF', normed=True) ax[0, 1].text(-3.5, 0.31, "Histogram, bins shifted") # tophat KDE kde = KernelDensity(kernel='tophat', bandwidth=0.75).fit(X) log_dens = kde.score_samples(X_plot) ax[1, 0].fill(X_plot[:, 0], np.exp(log_dens), fc='#AAAAFF') ax[1, 0].text(-3.5, 0.31, "Tophat Kernel Density") # Gaussian KDE kde = KernelDensity(kernel='gaussian', bandwidth=0.75).fit(X) log_dens = kde.score_samples(X_plot) ax[1, 1].fill(X_plot[:, 0], np.exp(log_dens), fc='#AAAAFF') ax[1, 1].text(-3.5, 0.31, "Gaussian Kernel Density") for axi in ax.ravel(): axi.plot(X[:, 0], np.zeros(X.shape[0]) - 0.01, '+k') axi.set_xlim(-4, 9) axi.set_ylim(-0.02, 0.34) for axi in ax[:, 0]: axi.set_ylabel('Normalized Density') for axi in ax[1, :]: axi.set_xlabel('x') #---------------------------------------------------------------------- # Plot all available kernels X_plot = np.linspace(-6, 6, 1000)[:, None] X_src = np.zeros((1, 1)) fig, ax = plt.subplots(2, 3, sharex=True, sharey=True) fig.subplots_adjust(left=0.05, right=0.95, hspace=0.05, wspace=0.05) def format_func(x, loc): if x == 0: return '0' elif x == 1: return 'h' elif x == -1: return '-h' else: return '%ih' % x for i, kernel in enumerate(['gaussian', 'tophat', 'epanechnikov', 'exponential', 'linear', 'cosine']): axi = ax.ravel()[i] log_dens = KernelDensity(kernel=kernel).fit(X_src).score_samples(X_plot) axi.fill(X_plot[:, 0], np.exp(log_dens), '-k', fc='#AAAAFF') axi.text(-2.6, 0.95, kernel) axi.xaxis.set_major_formatter(plt.FuncFormatter(format_func)) axi.xaxis.set_major_locator(plt.MultipleLocator(1)) axi.yaxis.set_major_locator(plt.NullLocator()) axi.set_ylim(0, 1.05) axi.set_xlim(-2.9, 2.9) ax[0, 1].set_title('Available Kernels') #---------------------------------------------------------------------- # Plot a 1D density example N = 100 np.random.seed(1) X = np.concatenate((np.random.normal(0, 1, int(0.3 * N)), np.random.normal(5, 1, int(0.7 * N))))[:, np.newaxis] X_plot = np.linspace(-5, 10, 1000)[:, np.newaxis] true_dens = (0.3 * norm(0, 1).pdf(X_plot[:, 0]) + 0.7 * norm(5, 1).pdf(X_plot[:, 0])) fig, ax = plt.subplots() ax.fill(X_plot[:, 0], true_dens, fc='black', alpha=0.2, label='input distribution') for kernel in ['gaussian', 'tophat', 'epanechnikov']: kde = KernelDensity(kernel=kernel, bandwidth=0.5).fit(X) log_dens = kde.score_samples(X_plot) ax.plot(X_plot[:, 0], np.exp(log_dens), '-', label="kernel = '{0}'".format(kernel)) ax.text(6, 0.38, "N={0} points".format(N)) ax.legend(loc='upper left') ax.plot(X[:, 0], -0.005 - 0.01 * np.random.random(X.shape[0]), '+k') ax.set_xlim(-4, 9) ax.set_ylim(-0.02, 0.4) plt.show()
bsd-3-clause
[ 624, 199, 2486, 5918, 199, 3184, 413, 36, 24901, 25187, 3677, 15896, 8182, 199, 2486, 5918, 199, 2765, 2893, 4440, 314, 520, 533, 1705, 27993, 14, 11113, 14, 14127, 26211, 64, 1021, 370, 199, 271, 2106, 18161, 314, 5448, 10352, 2978, 402, 24901, 25187, 3677, 15896, 8182, 315, 1373, 6240, 14, 199, 199, 1918, 1642, 5137, 13703, 1373, 402, 314, 8826, 543, 1808, 394, 22137, 370, 13104, 794, 199, 1589, 13650, 402, 4501, 315, 413, 36, 14, 9805, 1907, 9462, 12, 282, 15379, 883, 506, 32463, 402, 465, 282, 199, 5512, 315, 1314, 282, 4137, 298, 1457, 2, 365, 28378, 3432, 1924, 2376, 641, 282, 5578, 6068, 14, 199, 2822, 314, 2746, 2877, 12748, 83, 2498, 12, 13432, 12, 314, 7141, 402, 27591, 617, 316, 367, 3520, 5664, 199, 2425, 12690, 370, 336, 668, 590, 487, 422, 12069, 9979, 305, 3595, 314, 8793, 2215, 402, 314, 13650, 199, 4972, 14, 221, 982, 781, 3140, 8126, 1924, 1853, 641, 314, 2376, 652, 8469, 12, 781, 199, 362, 314, 14497, 9164, 315, 314, 9048, 3602, 12748, 14, 221, 961, 365, 282, 5114, 13650, 199, 597, 8182, 543, 282, 298, 2119, 394, 292, 2, 5114, 14, 221, 961, 16819, 883, 506, 8605, 1759, 370, 1163, 199, 4989, 11751, 26, 314, 9048, 13, 1019, 12748, 402, 314, 1642, 9658, 13703, 282, 17131, 199, 4989, 13650, 14497, 1806, 314, 2011, 4084, 14, 199, 199, 29231, 6065, 13, 4643, 9031, 13402, 5114, 13650, 27156, 1808, 1902, 199, 65, 699, 452, 12178, 503, 31368, 12178, 5523, 12, 4012, 314, 199, 26, 533, 1705, 27993, 14, 11113, 14, 14127, 26211, 64, 8943, 14, 221, 710, 2808, 26091, 199, 1530, 9164, 315, 314, 3499, 9658, 402, 642, 2893, 14, 199, 199, 1918, 10919, 9658, 30827, 5114, 13650, 23505, 367, 282, 4084, 402, 2948, 199, 3356, 315, 413, 6240, 14, 221, 18049, 3080, 642, 2893, 4440, 413, 36, 10208, 12, 5114, 199, 15669, 27156, 365, 16174, 436, 30427, 2178, 1164, 370, 10948, 7365, 199, 305, 5521, 14, 199, 624, 199, 3, 6529, 26, 1603, 1728, 812, 11438, 1168, 305, 665, 74, 1728, 86, 5780, 32, 1259, 14, 87, 1119, 31673, 14, 8654, 30, 199, 3, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 14, 3200, 492, 6316, 199, 504, 6357, 14, 11113, 492, 24901, 26211, 421, 199, 7656, 8648, 199, 3, 14794, 314, 13205, 1941, 402, 394, 22137, 370, 26091, 199, 1590, 14, 2355, 14, 5176, 8, 17, 9, 199, 46, 275, 3388, 199, 56, 275, 980, 14, 13433, 1332, 1590, 14, 2355, 14, 3302, 8, 16, 12, 413, 12, 1109, 8, 16, 14, 19, 627, 653, 1826, 490, 980, 14, 2355, 14, 3302, 8, 21, 12, 413, 12, 1109, 8, 16, 14, 23, 627, 653, 7845, 3981, 980, 14, 14483, 61, 199, 56, 63, 2798, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 5198, 24517, 980, 14, 14483, 61, 199, 11329, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 1616, 9, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 18, 12, 499, 12, 8663, 88, 29, 549, 12, 8663, 89, 29, 549, 9, 199, 592, 14, 21430, 63, 10917, 8, 72, 2638, 29, 16, 14, 1717, 12, 336, 2638, 29, 16, 14, 1717, 9, 199, 199, 3, 15379, 413, 199, 1219, 59, 16, 12, 378, 1055, 11141, 8, 56, 3981, 378, 467, 13341, 29, 11329, 12, 10821, 26431, 6151, 1665, 297, 6590, 3594, 29, 549, 9, 199, 1219, 59, 16, 12, 378, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 25055, 531, 199, 199, 3, 15379, 499, 199, 1219, 59, 16, 12, 413, 1055, 11141, 8, 56, 3981, 378, 467, 13341, 29, 11329, 435, 378, 14, 2194, 12, 10821, 26431, 6151, 1665, 297, 6590, 3594, 29, 549, 9, 199, 1219, 59, 16, 12, 413, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 25055, 12, 13341, 31915, 531, 199, 199, 3, 370, 838, 292, 1804, 1093, 199, 29461, 275, 24901, 26211, 8, 4989, 534, 2119, 8554, 297, 20434, 29, 16, 14, 2194, 680, 3269, 8, 56, 9, 199, 793, 63, 28509, 275, 1022, 271, 14, 3397, 63, 3356, 8, 56, 63, 2798, 9, 199, 1219, 59, 17, 12, 378, 1055, 4498, 8, 56, 63, 2798, 3981, 378, 467, 980, 14, 1474, 8, 793, 63, 28509, 395, 10821, 26431, 6151, 1665, 358, 199, 1219, 59, 17, 12, 378, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 6105, 8554, 24901, 25187, 3677, 531, 199, 199, 3, 17131, 1804, 1093, 199, 29461, 275, 24901, 26211, 8, 4989, 534, 22911, 297, 20434, 29, 16, 14, 2194, 680, 3269, 8, 56, 9, 199, 793, 63, 28509, 275, 1022, 271, 14, 3397, 63, 3356, 8, 56, 63, 2798, 9, 199, 1219, 59, 17, 12, 413, 1055, 4498, 8, 56, 63, 2798, 3981, 378, 467, 980, 14, 1474, 8, 793, 63, 28509, 395, 10821, 26431, 6151, 1665, 358, 199, 1219, 59, 17, 12, 413, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 26756, 24901, 25187, 3677, 531, 199, 199, 509, 2185, 73, 315, 2185, 14, 11186, 837, 272, 2185, 73, 14, 2798, 8, 56, 3981, 378, 467, 980, 14, 4250, 8, 56, 14, 1392, 59, 16, 566, 446, 378, 14, 614, 12, 6681, 75, 358, 272, 2185, 73, 14, 409, 63, 18512, 2801, 20, 12, 1749, 9, 272, 2185, 73, 14, 409, 63, 18123, 2801, 16, 14, 996, 12, 378, 14, 1082, 9, 199, 199, 509, 2185, 73, 315, 2185, 3981, 378, 2189, 272, 2185, 73, 14, 409, 63, 13849, 360, 29492, 25187, 3677, 358, 199, 199, 509, 2185, 73, 315, 2185, 59, 17, 12, 520, 2189, 272, 2185, 73, 14, 409, 63, 14168, 360, 88, 358, 199, 199, 7656, 8648, 199, 3, 14794, 1006, 2808, 26091, 199, 56, 63, 2798, 275, 980, 14, 11649, 2801, 22, 12, 1227, 12, 5198, 24517, 488, 61, 199, 56, 63, 2164, 275, 980, 14, 4250, 1332, 17, 12, 413, 430, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 18, 12, 650, 12, 8663, 88, 29, 549, 12, 8663, 89, 29, 549, 9, 199, 592, 14, 21430, 63, 10917, 8, 3039, 29, 16, 14, 1717, 12 ]
[ 199, 2486, 5918, 199, 3184, 413, 36, 24901, 25187, 3677, 15896, 8182, 199, 2486, 5918, 199, 2765, 2893, 4440, 314, 520, 533, 1705, 27993, 14, 11113, 14, 14127, 26211, 64, 1021, 370, 199, 271, 2106, 18161, 314, 5448, 10352, 2978, 402, 24901, 25187, 3677, 15896, 8182, 315, 1373, 6240, 14, 199, 199, 1918, 1642, 5137, 13703, 1373, 402, 314, 8826, 543, 1808, 394, 22137, 370, 13104, 794, 199, 1589, 13650, 402, 4501, 315, 413, 36, 14, 9805, 1907, 9462, 12, 282, 15379, 883, 506, 32463, 402, 465, 282, 199, 5512, 315, 1314, 282, 4137, 298, 1457, 2, 365, 28378, 3432, 1924, 2376, 641, 282, 5578, 6068, 14, 199, 2822, 314, 2746, 2877, 12748, 83, 2498, 12, 13432, 12, 314, 7141, 402, 27591, 617, 316, 367, 3520, 5664, 199, 2425, 12690, 370, 336, 668, 590, 487, 422, 12069, 9979, 305, 3595, 314, 8793, 2215, 402, 314, 13650, 199, 4972, 14, 221, 982, 781, 3140, 8126, 1924, 1853, 641, 314, 2376, 652, 8469, 12, 781, 199, 362, 314, 14497, 9164, 315, 314, 9048, 3602, 12748, 14, 221, 961, 365, 282, 5114, 13650, 199, 597, 8182, 543, 282, 298, 2119, 394, 292, 2, 5114, 14, 221, 961, 16819, 883, 506, 8605, 1759, 370, 1163, 199, 4989, 11751, 26, 314, 9048, 13, 1019, 12748, 402, 314, 1642, 9658, 13703, 282, 17131, 199, 4989, 13650, 14497, 1806, 314, 2011, 4084, 14, 199, 199, 29231, 6065, 13, 4643, 9031, 13402, 5114, 13650, 27156, 1808, 1902, 199, 65, 699, 452, 12178, 503, 31368, 12178, 5523, 12, 4012, 314, 199, 26, 533, 1705, 27993, 14, 11113, 14, 14127, 26211, 64, 8943, 14, 221, 710, 2808, 26091, 199, 1530, 9164, 315, 314, 3499, 9658, 402, 642, 2893, 14, 199, 199, 1918, 10919, 9658, 30827, 5114, 13650, 23505, 367, 282, 4084, 402, 2948, 199, 3356, 315, 413, 6240, 14, 221, 18049, 3080, 642, 2893, 4440, 413, 36, 10208, 12, 5114, 199, 15669, 27156, 365, 16174, 436, 30427, 2178, 1164, 370, 10948, 7365, 199, 305, 5521, 14, 199, 624, 199, 3, 6529, 26, 1603, 1728, 812, 11438, 1168, 305, 665, 74, 1728, 86, 5780, 32, 1259, 14, 87, 1119, 31673, 14, 8654, 30, 199, 3, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 14, 3200, 492, 6316, 199, 504, 6357, 14, 11113, 492, 24901, 26211, 421, 199, 7656, 8648, 199, 3, 14794, 314, 13205, 1941, 402, 394, 22137, 370, 26091, 199, 1590, 14, 2355, 14, 5176, 8, 17, 9, 199, 46, 275, 3388, 199, 56, 275, 980, 14, 13433, 1332, 1590, 14, 2355, 14, 3302, 8, 16, 12, 413, 12, 1109, 8, 16, 14, 19, 627, 653, 1826, 490, 980, 14, 2355, 14, 3302, 8, 21, 12, 413, 12, 1109, 8, 16, 14, 23, 627, 653, 7845, 3981, 980, 14, 14483, 61, 199, 56, 63, 2798, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 5198, 24517, 980, 14, 14483, 61, 199, 11329, 275, 980, 14, 11649, 2801, 21, 12, 1616, 12, 1616, 9, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 18, 12, 499, 12, 8663, 88, 29, 549, 12, 8663, 89, 29, 549, 9, 199, 592, 14, 21430, 63, 10917, 8, 72, 2638, 29, 16, 14, 1717, 12, 336, 2638, 29, 16, 14, 1717, 9, 199, 199, 3, 15379, 413, 199, 1219, 59, 16, 12, 378, 1055, 11141, 8, 56, 3981, 378, 467, 13341, 29, 11329, 12, 10821, 26431, 6151, 1665, 297, 6590, 3594, 29, 549, 9, 199, 1219, 59, 16, 12, 378, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 25055, 531, 199, 199, 3, 15379, 499, 199, 1219, 59, 16, 12, 413, 1055, 11141, 8, 56, 3981, 378, 467, 13341, 29, 11329, 435, 378, 14, 2194, 12, 10821, 26431, 6151, 1665, 297, 6590, 3594, 29, 549, 9, 199, 1219, 59, 16, 12, 413, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 25055, 12, 13341, 31915, 531, 199, 199, 3, 370, 838, 292, 1804, 1093, 199, 29461, 275, 24901, 26211, 8, 4989, 534, 2119, 8554, 297, 20434, 29, 16, 14, 2194, 680, 3269, 8, 56, 9, 199, 793, 63, 28509, 275, 1022, 271, 14, 3397, 63, 3356, 8, 56, 63, 2798, 9, 199, 1219, 59, 17, 12, 378, 1055, 4498, 8, 56, 63, 2798, 3981, 378, 467, 980, 14, 1474, 8, 793, 63, 28509, 395, 10821, 26431, 6151, 1665, 358, 199, 1219, 59, 17, 12, 378, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 6105, 8554, 24901, 25187, 3677, 531, 199, 199, 3, 17131, 1804, 1093, 199, 29461, 275, 24901, 26211, 8, 4989, 534, 22911, 297, 20434, 29, 16, 14, 2194, 680, 3269, 8, 56, 9, 199, 793, 63, 28509, 275, 1022, 271, 14, 3397, 63, 3356, 8, 56, 63, 2798, 9, 199, 1219, 59, 17, 12, 413, 1055, 4498, 8, 56, 63, 2798, 3981, 378, 467, 980, 14, 1474, 8, 793, 63, 28509, 395, 10821, 26431, 6151, 1665, 358, 199, 1219, 59, 17, 12, 413, 1055, 505, 2801, 19, 14, 21, 12, 378, 14, 2192, 12, 298, 26756, 24901, 25187, 3677, 531, 199, 199, 509, 2185, 73, 315, 2185, 14, 11186, 837, 272, 2185, 73, 14, 2798, 8, 56, 3981, 378, 467, 980, 14, 4250, 8, 56, 14, 1392, 59, 16, 566, 446, 378, 14, 614, 12, 6681, 75, 358, 272, 2185, 73, 14, 409, 63, 18512, 2801, 20, 12, 1749, 9, 272, 2185, 73, 14, 409, 63, 18123, 2801, 16, 14, 996, 12, 378, 14, 1082, 9, 199, 199, 509, 2185, 73, 315, 2185, 3981, 378, 2189, 272, 2185, 73, 14, 409, 63, 13849, 360, 29492, 25187, 3677, 358, 199, 199, 509, 2185, 73, 315, 2185, 59, 17, 12, 520, 2189, 272, 2185, 73, 14, 409, 63, 14168, 360, 88, 358, 199, 199, 7656, 8648, 199, 3, 14794, 1006, 2808, 26091, 199, 56, 63, 2798, 275, 980, 14, 11649, 2801, 22, 12, 1227, 12, 5198, 24517, 488, 61, 199, 56, 63, 2164, 275, 980, 14, 4250, 1332, 17, 12, 413, 430, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 18, 12, 650, 12, 8663, 88, 29, 549, 12, 8663, 89, 29, 549, 9, 199, 592, 14, 21430, 63, 10917, 8, 3039, 29, 16, 14, 1717, 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, 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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 ]
rajiteh/taiga-back
taiga/base/api/settings.py
15
6956
# Copyright (C) 2015 Andrey Antukh <niwi@niwi.be> # Copyright (C) 2015 Jesús Espino <jespinog@gmail.com> # Copyright (C) 2015 David Barragán <bameda@dbarragan.com> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # This code is partially taken from django-rest-framework: # Copyright (c) 2011-2015, Tom Christie """ Settings for REST framework are all namespaced in the REST_FRAMEWORK setting. For example your project's `settings.py` file might look like this: REST_FRAMEWORK = { "DEFAULT_RENDERER_CLASSES": ( "taiga.base.api.renderers.JSONRenderer", ) "DEFAULT_PARSER_CLASSES": ( "taiga.base.api.parsers.JSONParser", ) } This module provides the `api_setting` object, that is used to access REST framework settings, checking for user settings first, then falling back to the defaults. """ from __future__ import unicode_literals from django.conf import settings from django.utils import importlib from django.utils import six from . import ISO_8601 USER_SETTINGS = getattr(settings, "REST_FRAMEWORK", None) DEFAULTS = { # Base API policies "DEFAULT_RENDERER_CLASSES": ( "taiga.base.api.renderers.JSONRenderer", "taiga.base.api.renderers.BrowsableAPIRenderer", ), "DEFAULT_PARSER_CLASSES": ( "taiga.base.api.parsers.JSONParser", "taiga.base.api.parsers.FormParser", "taiga.base.api.parsers.MultiPartParser" ), "DEFAULT_AUTHENTICATION_CLASSES": ( "taiga.base.api.authentication.SessionAuthentication", "taiga.base.api.authentication.BasicAuthentication" ), "DEFAULT_PERMISSION_CLASSES": ( "taiga.base.api.permissions.AllowAny", ), "DEFAULT_THROTTLE_CLASSES": ( ), "DEFAULT_CONTENT_NEGOTIATION_CLASS": "taiga.base.api.negotiation.DefaultContentNegotiation", # Genric view behavior "DEFAULT_MODEL_SERIALIZER_CLASS": "taiga.base.api.serializers.ModelSerializer", "DEFAULT_FILTER_BACKENDS": (), # Throttling "DEFAULT_THROTTLE_RATES": { "user": None, "anon": None, }, # Pagination "PAGINATE_BY": None, "PAGINATE_BY_PARAM": None, "MAX_PAGINATE_BY": None, # Authentication "UNAUTHENTICATED_USER": "django.contrib.auth.models.AnonymousUser", "UNAUTHENTICATED_TOKEN": None, # View configuration "VIEW_NAME_FUNCTION": "taiga.base.api.views.get_view_name", "VIEW_DESCRIPTION_FUNCTION": "taiga.base.api.views.get_view_description", # Exception handling "EXCEPTION_HANDLER": "taiga.base.api.views.exception_handler", # Testing "TEST_REQUEST_RENDERER_CLASSES": ( "taiga.base.api.renderers.MultiPartRenderer", "taiga.base.api.renderers.JSONRenderer" ), "TEST_REQUEST_DEFAULT_FORMAT": "multipart", # Browser enhancements "FORM_METHOD_OVERRIDE": "_method", "FORM_CONTENT_OVERRIDE": "_content", "FORM_CONTENTTYPE_OVERRIDE": "_content_type", "URL_ACCEPT_OVERRIDE": "accept", "URL_FORMAT_OVERRIDE": "format", "FORMAT_SUFFIX_KWARG": "format", "URL_FIELD_NAME": "url", # Input and output formats "DATE_INPUT_FORMATS": ( ISO_8601, ), "DATE_FORMAT": None, "DATETIME_INPUT_FORMATS": ( ISO_8601, ), "DATETIME_FORMAT": None, "TIME_INPUT_FORMATS": ( ISO_8601, ), "TIME_FORMAT": None, # Pending deprecation "FILTER_BACKEND": None, } # List of settings that may be in string import notation. IMPORT_STRINGS = ( "DEFAULT_RENDERER_CLASSES", "DEFAULT_PARSER_CLASSES", "DEFAULT_AUTHENTICATION_CLASSES", "DEFAULT_PERMISSION_CLASSES", "DEFAULT_THROTTLE_CLASSES", "DEFAULT_CONTENT_NEGOTIATION_CLASS", "DEFAULT_MODEL_SERIALIZER_CLASS", "DEFAULT_FILTER_BACKENDS", "EXCEPTION_HANDLER", "FILTER_BACKEND", "TEST_REQUEST_RENDERER_CLASSES", "UNAUTHENTICATED_USER", "UNAUTHENTICATED_TOKEN", "VIEW_NAME_FUNCTION", "VIEW_DESCRIPTION_FUNCTION" ) def perform_import(val, setting_name): """ If the given setting is a string import notation, then perform the necessary import or imports. """ if isinstance(val, six.string_types): return import_from_string(val, setting_name) elif isinstance(val, (list, tuple)): return [import_from_string(item, setting_name) for item in val] return val def import_from_string(val, setting_name): """ Attempt to import a class from a string representation. """ try: # Nod to tastypie's use of importlib. parts = val.split('.') module_path, class_name = '.'.join(parts[:-1]), parts[-1] module = importlib.import_module(module_path) return getattr(module, class_name) except ImportError as e: msg = "Could not import '%s' for API setting '%s'. %s: %s." % (val, setting_name, e.__class__.__name__, e) raise ImportError(msg) class APISettings(object): """ A settings object, that allows API settings to be accessed as properties. For example: from taiga.base.api.settings import api_settings print api_settings.DEFAULT_RENDERER_CLASSES Any setting with string import paths will be automatically resolved and return the class, rather than the string literal. """ def __init__(self, user_settings=None, defaults=None, import_strings=None): self.user_settings = user_settings or {} self.defaults = defaults or {} self.import_strings = import_strings or () def __getattr__(self, attr): if attr not in self.defaults.keys(): raise AttributeError("Invalid API setting: '%s'" % attr) try: # Check if present in user settings val = self.user_settings[attr] except KeyError: # Fall back to defaults val = self.defaults[attr] # Coerce import strings into classes if val and attr in self.import_strings: val = perform_import(val, attr) self.validate_setting(attr, val) # Cache the result setattr(self, attr, val) return val def validate_setting(self, attr, val): if attr == "FILTER_BACKEND" and val is not None: # Make sure we can initialize the class val() api_settings = APISettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS)
agpl-3.0
[ 3, 1898, 334, 35, 9, 6900, 6061, 17885, 437, 343, 3210, 72, 665, 8445, 14249, 32, 8445, 14249, 14, 1235, 30, 199, 3, 1898, 334, 35, 9, 6900, 1603, 397, 24602, 83, 662, 681, 10175, 665, 74, 397, 7751, 974, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6900, 20232, 12377, 2527, 11302, 78, 665, 66, 313, 983, 32, 697, 285, 2527, 290, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 1233, 365, 25172, 9394, 687, 1639, 13, 3911, 13, 4857, 26, 199, 3, 1898, 334, 67, 9, 7760, 13, 7806, 12, 21644, 2799, 18824, 1873, 421, 199, 624, 199, 5268, 367, 14880, 10059, 787, 1006, 3231, 68, 315, 314, 14880, 63, 12683, 8406, 4260, 14, 199, 1858, 2893, 2195, 2199, 1159, 658, 1751, 14, 647, 64, 570, 5594, 3648, 2839, 642, 26, 199, 199, 15740, 63, 12683, 8406, 275, 469, 272, 298, 3472, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 401, 272, 776, 272, 298, 3472, 63, 26078, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 6243, 2842, 401, 272, 776, 199, 93, 199, 199, 2765, 859, 6571, 314, 658, 1246, 63, 6031, 64, 909, 12, 626, 365, 1202, 370, 2879, 199, 15740, 10059, 2202, 12, 7907, 367, 922, 2202, 1642, 12, 2066, 32039, 199, 894, 370, 314, 4243, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 14802, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 492, 9055, 63, 15363, 421, 199, 3791, 63, 13931, 275, 2519, 8, 1751, 12, 298, 15740, 63, 12683, 8406, 401, 488, 9, 199, 199, 30773, 275, 469, 272, 327, 3523, 3261, 14118, 272, 298, 3472, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 34, 3838, 461, 3735, 11355, 401, 272, 2318, 272, 298, 3472, 63, 26078, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 6243, 2842, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 2821, 2842, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 3947, 8416, 2842, 2, 272, 2318, 272, 298, 3472, 63, 29599, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11725, 14, 4434, 10348, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11725, 14, 6845, 10348, 2, 272, 2318, 272, 298, 3472, 63, 4227, 22320, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 6060, 14, 7852, 9874, 401, 272, 2318, 272, 298, 3472, 63, 2080, 1092, 1481, 906, 63, 13748, 582, 334, 272, 2318, 272, 298, 3472, 63, 9663, 63, 31254, 1387, 41, 2594, 63, 6885, 582, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 21961, 425, 14, 2698, 2714, 4698, 14727, 425, 401, 339, 327, 18870, 1567, 2455, 5953, 272, 298, 3472, 63, 11429, 63, 19637, 5357, 540, 63, 6885, 582, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 12844, 14, 1685, 7299, 401, 272, 298, 3472, 63, 9905, 63, 28988, 582, 11969, 339, 327, 3868, 4571, 32642, 272, 298, 3472, 63, 2080, 1092, 1481, 906, 63, 50, 16601, 582, 469, 267, 298, 751, 582, 488, 12, 267, 298, 21009, 582, 488, 12, 272, 1660, 339, 327, 28006, 3155, 272, 298, 48, 1254, 568, 1951, 63, 8285, 582, 488, 12, 272, 298, 48, 1254, 568, 1951, 63, 8285, 63, 7258, 582, 488, 12, 272, 298, 4283, 63, 48, 1254, 568, 1951, 63, 8285, 582, 488, 12, 339, 327, 15995, 272, 298, 1734, 22923, 6989, 63, 3791, 582, 298, 1176, 14, 2828, 14, 1178, 14, 992, 14, 23902, 1899, 401, 272, 298, 1734, 22923, 6989, 63, 8803, 582, 488, 12, 339, 327, 10935, 2897, 272, 298, 12058, 63, 2339, 63, 15476, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 362, 63, 1345, 63, 354, 401, 272, 298, 12058, 63, 17705, 63, 15476, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 362, 63, 1345, 63, 1802, 401, 339, 327, 2186, 7252, 272, 298, 15375, 63, 30872, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 1971, 63, 2232, 401, 339, 327, 11940, 272, 298, 2864, 63, 6780, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 3947, 8416, 11355, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 2, 272, 2318, 272, 298, 2864, 63, 6780, 63, 3472, 63, 4807, 582, 298, 10123, 401, 339, 327, 27620, 655, 14666, 1470, 272, 298, 3516, 63, 9977, 63, 30024, 11259, 582, 2668, 765, 401, 272, 298, 3516, 63, 9663, 63, 30024, 11259, 582, 2668, 1317, 401, 272, 298, 3516, 63, 9663, 2711, 63, 30024, 11259, 582, 2668, 1317, 63, 466, 401, 272, 298, 2632, 63, 13089, 63, 30024, 11259, 582, 298, 5694, 401, 272, 298, 2632, 63, 4807, 63, 30024, 11259, 582, 298, 908, 401, 339, 298, 4807, 63, 12273, 63, 43 ]
[ 1898, 334, 35, 9, 6900, 6061, 17885, 437, 343, 3210, 72, 665, 8445, 14249, 32, 8445, 14249, 14, 1235, 30, 199, 3, 1898, 334, 35, 9, 6900, 1603, 397, 24602, 83, 662, 681, 10175, 665, 74, 397, 7751, 974, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6900, 20232, 12377, 2527, 11302, 78, 665, 66, 313, 983, 32, 697, 285, 2527, 290, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 1233, 365, 25172, 9394, 687, 1639, 13, 3911, 13, 4857, 26, 199, 3, 1898, 334, 67, 9, 7760, 13, 7806, 12, 21644, 2799, 18824, 1873, 421, 199, 624, 199, 5268, 367, 14880, 10059, 787, 1006, 3231, 68, 315, 314, 14880, 63, 12683, 8406, 4260, 14, 199, 1858, 2893, 2195, 2199, 1159, 658, 1751, 14, 647, 64, 570, 5594, 3648, 2839, 642, 26, 199, 199, 15740, 63, 12683, 8406, 275, 469, 272, 298, 3472, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 401, 272, 776, 272, 298, 3472, 63, 26078, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 6243, 2842, 401, 272, 776, 199, 93, 199, 199, 2765, 859, 6571, 314, 658, 1246, 63, 6031, 64, 909, 12, 626, 365, 1202, 370, 2879, 199, 15740, 10059, 2202, 12, 7907, 367, 922, 2202, 1642, 12, 2066, 32039, 199, 894, 370, 314, 4243, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 14802, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 492, 9055, 63, 15363, 421, 199, 3791, 63, 13931, 275, 2519, 8, 1751, 12, 298, 15740, 63, 12683, 8406, 401, 488, 9, 199, 199, 30773, 275, 469, 272, 327, 3523, 3261, 14118, 272, 298, 3472, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 34, 3838, 461, 3735, 11355, 401, 272, 2318, 272, 298, 3472, 63, 26078, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 6243, 2842, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 2821, 2842, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11531, 14, 3947, 8416, 2842, 2, 272, 2318, 272, 298, 3472, 63, 29599, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11725, 14, 4434, 10348, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 11725, 14, 6845, 10348, 2, 272, 2318, 272, 298, 3472, 63, 4227, 22320, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 6060, 14, 7852, 9874, 401, 272, 2318, 272, 298, 3472, 63, 2080, 1092, 1481, 906, 63, 13748, 582, 334, 272, 2318, 272, 298, 3472, 63, 9663, 63, 31254, 1387, 41, 2594, 63, 6885, 582, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 21961, 425, 14, 2698, 2714, 4698, 14727, 425, 401, 339, 327, 18870, 1567, 2455, 5953, 272, 298, 3472, 63, 11429, 63, 19637, 5357, 540, 63, 6885, 582, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 12844, 14, 1685, 7299, 401, 272, 298, 3472, 63, 9905, 63, 28988, 582, 11969, 339, 327, 3868, 4571, 32642, 272, 298, 3472, 63, 2080, 1092, 1481, 906, 63, 50, 16601, 582, 469, 267, 298, 751, 582, 488, 12, 267, 298, 21009, 582, 488, 12, 272, 1660, 339, 327, 28006, 3155, 272, 298, 48, 1254, 568, 1951, 63, 8285, 582, 488, 12, 272, 298, 48, 1254, 568, 1951, 63, 8285, 63, 7258, 582, 488, 12, 272, 298, 4283, 63, 48, 1254, 568, 1951, 63, 8285, 582, 488, 12, 339, 327, 15995, 272, 298, 1734, 22923, 6989, 63, 3791, 582, 298, 1176, 14, 2828, 14, 1178, 14, 992, 14, 23902, 1899, 401, 272, 298, 1734, 22923, 6989, 63, 8803, 582, 488, 12, 339, 327, 10935, 2897, 272, 298, 12058, 63, 2339, 63, 15476, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 362, 63, 1345, 63, 354, 401, 272, 298, 12058, 63, 17705, 63, 15476, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 362, 63, 1345, 63, 1802, 401, 339, 327, 2186, 7252, 272, 298, 15375, 63, 30872, 582, 298, 502, 29055, 14, 1095, 14, 1246, 14, 4196, 14, 1971, 63, 2232, 401, 339, 327, 11940, 272, 298, 2864, 63, 6780, 63, 31587, 540, 63, 13748, 582, 334, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 3947, 8416, 11355, 401, 267, 298, 502, 29055, 14, 1095, 14, 1246, 14, 828, 26529, 14, 6243, 11355, 2, 272, 2318, 272, 298, 2864, 63, 6780, 63, 3472, 63, 4807, 582, 298, 10123, 401, 339, 327, 27620, 655, 14666, 1470, 272, 298, 3516, 63, 9977, 63, 30024, 11259, 582, 2668, 765, 401, 272, 298, 3516, 63, 9663, 63, 30024, 11259, 582, 2668, 1317, 401, 272, 298, 3516, 63, 9663, 2711, 63, 30024, 11259, 582, 2668, 1317, 63, 466, 401, 272, 298, 2632, 63, 13089, 63, 30024, 11259, 582, 298, 5694, 401, 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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 ]
txm/make-good
django/contrib/admin/sites.py
80
17398
import re from django import http, template from django.contrib.admin import ModelAdmin, actions from django.contrib.admin.forms import AdminAuthenticationForm from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import csrf_protect from django.db.models.base import ModelBase from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse from django.shortcuts import render_to_response from django.utils.functional import update_wrapper from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.conf import settings LOGIN_FORM_KEY = 'this_is_the_login_form' class AlreadyRegistered(Exception): pass class NotRegistered(Exception): pass class AdminSite(object): """ An AdminSite object encapsulates an instance of the Django admin application, ready to be hooked in to your URLconf. Models are registered with the AdminSite using the register() method, and the get_urls() method can then be used to access Django view functions that present a full admin interface for the collection of registered models. """ login_form = None index_template = None app_index_template = None login_template = None logout_template = None password_change_template = None password_change_done_template = None def __init__(self, name=None, app_name='admin'): self._registry = {} # model_class class -> admin_class instance self.root_path = None if name is None: self.name = 'admin' else: self.name = name self.app_name = app_name self._actions = {'delete_selected': actions.delete_selected} self._global_actions = self._actions.copy() def register(self, model_or_iterable, admin_class=None, **options): """ Registers the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, it will use ModelAdmin (the default admin options). If keyword arguments are given -- e.g., list_display -- they'll be applied as options to the admin class. If a model is already registered, this will raise AlreadyRegistered. If a model is abstract, this will raise ImproperlyConfigured. """ if not admin_class: admin_class = ModelAdmin # Don't import the humongous validation code unless required if admin_class and settings.DEBUG: from django.contrib.admin.validation import validate else: validate = lambda model, adminclass: None if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] for model in model_or_iterable: if model._meta.abstract: raise ImproperlyConfigured('The model %s is abstract, so it ' 'cannot be registered with admin.' % model.__name__) if model in self._registry: raise AlreadyRegistered('The model %s is already registered' % model.__name__) # If we got **options then dynamically construct a subclass of # admin_class with those **options. if options: # For reasons I don't quite understand, without a __module__ # the created class appears to "live" in the wrong place, # which causes issues later on. options['__module__'] = __name__ admin_class = type("%sAdmin" % model.__name__, (admin_class,), options) # Validate (which might be a no-op) validate(admin_class, model) # Instantiate the admin class to save in the registry self._registry[model] = admin_class(model, self) def unregister(self, model_or_iterable): """ Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered. """ if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] for model in model_or_iterable: if model not in self._registry: raise NotRegistered('The model %s is not registered' % model.__name__) del self._registry[model] def add_action(self, action, name=None): """ Register an action to be available globally. """ name = name or action.__name__ self._actions[name] = action self._global_actions[name] = action def disable_action(self, name): """ Disable a globally-registered action. Raises KeyError for invalid names. """ del self._actions[name] def get_action(self, name): """ Explicitally get a registered global action wheather it's enabled or not. Raises KeyError for invalid names. """ return self._global_actions[name] @property def actions(self): """ Get all the enabled actions as an iterable of (name, func). """ return self._actions.iteritems() def has_permission(self, request): """ Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. """ return request.user.is_active and request.user.is_staff def check_dependencies(self): """ Check that all things needed to run the admin have been correctly installed. The default implementation checks that LogEntry, ContentType and the auth context processor are installed. """ from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType if not LogEntry._meta.installed: raise ImproperlyConfigured("Put 'django.contrib.admin' in your " "INSTALLED_APPS setting in order to use the admin application.") if not ContentType._meta.installed: raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in " "your INSTALLED_APPS setting in order to use the admin application.") if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or 'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS): raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' " "in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.") def admin_view(self, view, cacheable=False): """ Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``. You'll want to use this from within ``AdminSite.get_urls()``: class MyAdminSite(AdminSite): def get_urls(self): from django.conf.urls.defaults import patterns, url urls = super(MyAdminSite, self).get_urls() urls += patterns('', url(r'^my_view/$', self.admin_view(some_view)) ) return urls By default, admin_views are marked non-cacheable using the ``never_cache`` decorator. If the view can be safely cached, set cacheable=True. """ def inner(request, *args, **kwargs): if not self.has_permission(request): return self.login(request) return view(request, *args, **kwargs) if not cacheable: inner = never_cache(inner) # We add csrf_protect here so this function can be used as a utility # function for any view, without having to repeat 'csrf_protect'. if not getattr(view, 'csrf_exempt', False): inner = csrf_protect(inner) return update_wrapper(inner, view) def get_urls(self): from django.conf.urls.defaults import patterns, url, include if settings.DEBUG: self.check_dependencies() def wrap(view, cacheable=False): def wrapper(*args, **kwargs): return self.admin_view(view, cacheable)(*args, **kwargs) return update_wrapper(wrapper, view) # Admin-site-wide views. urlpatterns = patterns('', url(r'^$', wrap(self.index), name='index'), url(r'^logout/$', wrap(self.logout), name='logout'), url(r'^password_change/$', wrap(self.password_change, cacheable=True), name='password_change'), url(r'^password_change/done/$', wrap(self.password_change_done, cacheable=True), name='password_change_done'), url(r'^jsi18n/$', wrap(self.i18n_javascript, cacheable=True), name='jsi18n'), url(r'^r/(?P<content_type_id>[a-z\d]+)/(?P<object_id>.+)/$', wrap(contenttype_views.shortcut)), url(r'^(?P<app_label>\w+)/$', wrap(self.app_index), name='app_list') ) # Add in each model's views. for model, model_admin in self._registry.iteritems(): urlpatterns += patterns('', url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name), include(model_admin.urls)) ) return urlpatterns @property def urls(self): return self.get_urls(), self.app_name, self.name def password_change(self, request): """ Handles the "change password" task -- both form display and validation. """ from django.contrib.auth.views import password_change if self.root_path is not None: url = '%spassword_change/done/' % self.root_path else: url = reverse('admin:password_change_done', current_app=self.name) defaults = { 'current_app': self.name, 'post_change_redirect': url } if self.password_change_template is not None: defaults['template_name'] = self.password_change_template return password_change(request, **defaults) def password_change_done(self, request, extra_context=None): """ Displays the "success" page after a password change. """ from django.contrib.auth.views import password_change_done defaults = { 'current_app': self.name, 'extra_context': extra_context or {}, } if self.password_change_done_template is not None: defaults['template_name'] = self.password_change_done_template return password_change_done(request, **defaults) def i18n_javascript(self, request): """ Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster. """ if settings.USE_I18N: from django.views.i18n import javascript_catalog else: from django.views.i18n import null_javascript_catalog as javascript_catalog return javascript_catalog(request, packages=['django.conf', 'django.contrib.admin']) @never_cache def logout(self, request, extra_context=None): """ Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ from django.contrib.auth.views import logout defaults = { 'current_app': self.name, 'extra_context': extra_context or {}, } if self.logout_template is not None: defaults['template_name'] = self.logout_template return logout(request, **defaults) @never_cache def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ from django.contrib.auth.views import login context = { 'title': _('Log in'), 'root_path': self.root_path, 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: request.get_full_path(), } context.update(extra_context or {}) defaults = { 'extra_context': context, 'current_app': self.name, 'authentication_form': self.login_form or AdminAuthenticationForm, 'template_name': self.login_template or 'admin/login.html', } return login(request, **defaults) @never_cache def index(self, request, extra_context=None): """ Displays the main admin index page, which lists all of the installed apps that have been registered in this site. """ app_dict = {} user = request.user for model, model_admin in self._registry.items(): app_label = model._meta.app_label has_module_perms = user.has_module_perms(app_label) if has_module_perms: perms = model_admin.get_model_perms(request) # Check whether user has any perm for this module. # If so, add the module to the model_list. if True in perms.values(): model_dict = { 'name': capfirst(model._meta.verbose_name_plural), 'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())), 'perms': perms, } if app_label in app_dict: app_dict[app_label]['models'].append(model_dict) else: app_dict[app_label] = { 'name': app_label.title(), 'app_url': app_label + '/', 'has_module_perms': has_module_perms, 'models': [model_dict], } # Sort the apps alphabetically. app_list = app_dict.values() app_list.sort(key=lambda x: x['name']) # Sort the models alphabetically within each app. for app in app_list: app['models'].sort(key=lambda x: x['name']) context = { 'title': _('Site administration'), 'app_list': app_list, 'root_path': self.root_path, } context.update(extra_context or {}) context_instance = template.RequestContext(request, current_app=self.name) return render_to_response(self.index_template or 'admin/index.html', context, context_instance=context_instance ) def app_index(self, request, app_label, extra_context=None): user = request.user has_module_perms = user.has_module_perms(app_label) app_dict = {} for model, model_admin in self._registry.items(): if app_label == model._meta.app_label: if has_module_perms: perms = model_admin.get_model_perms(request) # Check whether user has any perm for this module. # If so, add the module to the model_list. if True in perms.values(): model_dict = { 'name': capfirst(model._meta.verbose_name_plural), 'admin_url': '%s/' % model.__name__.lower(), 'perms': perms, } if app_dict: app_dict['models'].append(model_dict), else: # First time around, now that we know there's # something to display, add in the necessary meta # information. app_dict = { 'name': app_label.title(), 'app_url': '', 'has_module_perms': has_module_perms, 'models': [model_dict], } if not app_dict: raise http.Http404('The requested admin page does not exist.') # Sort the models alphabetically within each app. app_dict['models'].sort(key=lambda x: x['name']) context = { 'title': _('%s administration') % capfirst(app_label), 'app_list': [app_dict], 'root_path': self.root_path, } context.update(extra_context or {}) context_instance = template.RequestContext(request, current_app=self.name) return render_to_response(self.app_index_template or ('admin/%s/app_index.html' % app_label, 'admin/app_index.html'), context, context_instance=context_instance ) # This global object represents the default admin site, for the common case. # You can instantiate AdminSite in your own code to create a custom admin site. site = AdminSite()
bsd-3-clause
[ 646, 295, 199, 504, 1639, 492, 1455, 12, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 492, 30093, 12, 5445, 199, 504, 1639, 14, 2828, 14, 2113, 14, 3351, 492, 9516, 10348, 2821, 199, 504, 1639, 14, 2828, 14, 1178, 492, 820, 7458, 4168, 63, 8609, 63, 2339, 199, 504, 1639, 14, 2828, 14, 10778, 492, 6858, 465, 1564, 466, 63, 4196, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 18292, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 5822, 1563, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1678, 63, 5029, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 17208, 63, 3516, 63, 3078, 275, 283, 3749, 63, 374, 63, 1589, 63, 2886, 63, 964, 7, 199, 199, 533, 21086, 20341, 8, 1726, 304, 272, 986, 199, 199, 533, 2832, 20341, 8, 1726, 304, 272, 986, 199, 199, 533, 9516, 8972, 8, 785, 304, 272, 408, 272, 1626, 9516, 8972, 909, 22667, 15409, 376, 1256, 402, 314, 5634, 4628, 4223, 12, 10144, 272, 370, 506, 5759, 379, 315, 370, 2195, 2851, 2190, 14, 29941, 787, 7264, 543, 314, 9516, 8972, 1808, 314, 272, 2274, 342, 1083, 12, 436, 314, 664, 63, 3603, 342, 1083, 883, 2066, 506, 1202, 370, 2879, 5634, 2455, 272, 3423, 626, 3451, 282, 2615, 4628, 3217, 367, 314, 3245, 402, 7264, 272, 1709, 14, 272, 408, 272, 4676, 63, 964, 275, 488, 272, 1478, 63, 1160, 275, 488, 272, 1145, 63, 1080, 63, 1160, 275, 488, 272, 4676, 63, 1160, 275, 488, 272, 22079, 63, 1160, 275, 488, 272, 2505, 63, 1461, 63, 1160, 275, 488, 272, 2505, 63, 1461, 63, 4456, 63, 1160, 275, 488, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1145, 63, 354, 534, 2113, 735, 267, 291, 423, 5189, 275, 1052, 327, 1402, 63, 533, 1021, 1035, 4628, 63, 533, 1256, 267, 291, 14, 1231, 63, 515, 275, 488, 267, 340, 536, 365, 488, 26, 288, 291, 14, 354, 275, 283, 2113, 7, 267, 587, 26, 288, 291, 14, 354, 275, 536, 267, 291, 14, 571, 63, 354, 275, 1145, 63, 354, 267, 291, 423, 3723, 275, 791, 1807, 63, 5511, 356, 5445, 14, 1807, 63, 5511, 93, 267, 291, 423, 2966, 63, 3723, 275, 291, 423, 3723, 14, 1574, 342, 339, 347, 2274, 8, 277, 12, 1402, 63, 269, 63, 8147, 12, 4628, 63, 533, 29, 403, 12, 1011, 1419, 304, 267, 408, 267, 5044, 14186, 314, 1627, 1402, 8, 83, 9, 543, 314, 1627, 4628, 1021, 14, 398, 710, 1402, 8, 83, 9, 1077, 506, 5822, 3992, 12, 440, 4454, 14, 398, 982, 376, 4628, 1021, 5712, 1133, 1627, 12, 652, 911, 675, 30093, 334, 1589, 849, 267, 4628, 1511, 680, 982, 4252, 2368, 787, 1627, 1553, 325, 14, 71, 2020, 769, 63, 2918, 1553, 267, 2985, 7171, 506, 6781, 465, 1511, 370, 314, 4628, 1021, 14, 398, 982, 282, 1402, 365, 2575, 7264, 12, 642, 911, 746, 21086, 20341, 14, 398, 982, 282, 1402, 365, 9006, 12, 642, 911, 746, 11897, 14, 267, 408, 267, 340, 440, 4628, 63, 533, 26, 288, 4628, 63, 533, 275, 30093, 398, 327, 7529, 1133, 492, 314, 394, 453, 951, 1785, 6411, 1233, 7444, 1415, 267, 340, 4628, 63, 533, 436, 2202, 14, 5287, 26, 288, 687, 1639, 14, 2828, 14, 2113, 14, 6136, 492, 4107, 267, 587, 26, 288, 4107, 275, 2400, 1402, 12, 4628, 533, 26, 488, 398, 340, 1228, 8, 1238, 63, 269, 63, 8147, 12, 5822, 1563, 304, 288, 1402, 63, 269, 63, 8147, 275, 359, 1238, 63, 269, 63, 8147, 61, 267, 367, 1402, 315, 1402, 63, 269, 63, 8147, 26, 288, 340, 1402, 423, 2024, 14, 6198, 26, 355, 746, 11897, 360, 1918, 1402, 450, 83, 365, 9006, 12, 880, 652, 283, 1993, 283, 11250, 506, 7264, 543, 4628, 3530, 450, 1402, 855, 354, 3368, 953, 340, 1402, 315, 291, 423, 5189, 26, 355, 746, 21086, 20341, 360, 1918, 1402, 450, 83, 365, 2575, 7264, 7, 450, 1402, 855, 354, 3368, 953, 327, 982, 781, 4788, 1011, 1419, 2066, 18774, 6982, 282, 5516, 402, 288, 327, 4628, 63, 533, 543, 5204, 1011, 1419, 14, 288, 340, 1511, 26, 355, 327, 2104, 14872, 473, 2793, 1133, 18794, 20647, 12, 1928, 282, 636, 578, 363, 355, 327, 314, 2737, 1021, 11337, 370, 298, 6442, 2, 315, 314, 6835, 4192, 12, 355, 327, 1314, 14486, 10876, 2945, 641, 14, 355, 1511, 13742, 578, 17501, 275, 636, 354, 363, 355, 4628, 63, 533, 275, 730, 3647, 83, 4880, 2, 450, 1402, 855, 354, 3108, 334, 2113, 63, 533, 4706, 1511, 9, 953, 327, 12134, 334, 6777, 5594, 506, 282, 949, 13, 411, 9, 288, 4107, 8, 2113, 63, 533, 12, 1402, 9, 953, 327, 32092, 314, 4628, 1021, 370, 3354, 315, 314, 7086, 288, 291, 423, 5189, 59, 1238, 61, 275, 4628, 63, 533, 8, 1238, 12, 291, 9, 339, 347, 24369, 8, 277, 12, 1402, 63, 269, 63, 8147, 304, 267, 408, 267, 1910, 30792, 314, 1627, 1402, 8, 83, 680, 398, 982, 282, 1402, 5712, 1133, 2575, 7264, 12, 642, 911, 746, 2832, 20341, 14, 267, 408, 267, 340, 1228, 8, 1238, 63, 269, 63, 8147, 12, 5822, 1563, 304, 288, 1402, 63, 269, 63, 8147, 275, 359, 1238, 63, 269, 63, 8147, 61, 267, 367, 1402, 315, 1402, 63, 269, 63, 8147, 26, 288, 340, 1402, 440, 315, 291, 423, 5189, 26, 355, 746, 2832, 20341, 360, 1918, 1402, 450, 83, 365, 440, 7264, 7, 450, 1402, 855, 354, 3368, 288, 2150, 291, 423, 5189, 59, 1238, 61, 339, 347, 1050, 63, 1287, 8, 277, 12, 1595, 12, 536, 29, 403, 304, 267, 408, 267, 11828, 376, 1595, 370, 506, 2808, 26662, 14, 267, 408, 267 ]
[ 295, 199, 504, 1639, 492, 1455, 12, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 492, 30093, 12, 5445, 199, 504, 1639, 14, 2828, 14, 2113, 14, 3351, 492, 9516, 10348, 2821, 199, 504, 1639, 14, 2828, 14, 1178, 492, 820, 7458, 4168, 63, 8609, 63, 2339, 199, 504, 1639, 14, 2828, 14, 10778, 492, 6858, 465, 1564, 466, 63, 4196, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 18292, 199, 504, 1639, 14, 697, 14, 992, 14, 1095, 492, 5822, 1563, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1678, 63, 5029, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 17208, 63, 3516, 63, 3078, 275, 283, 3749, 63, 374, 63, 1589, 63, 2886, 63, 964, 7, 199, 199, 533, 21086, 20341, 8, 1726, 304, 272, 986, 199, 199, 533, 2832, 20341, 8, 1726, 304, 272, 986, 199, 199, 533, 9516, 8972, 8, 785, 304, 272, 408, 272, 1626, 9516, 8972, 909, 22667, 15409, 376, 1256, 402, 314, 5634, 4628, 4223, 12, 10144, 272, 370, 506, 5759, 379, 315, 370, 2195, 2851, 2190, 14, 29941, 787, 7264, 543, 314, 9516, 8972, 1808, 314, 272, 2274, 342, 1083, 12, 436, 314, 664, 63, 3603, 342, 1083, 883, 2066, 506, 1202, 370, 2879, 5634, 2455, 272, 3423, 626, 3451, 282, 2615, 4628, 3217, 367, 314, 3245, 402, 7264, 272, 1709, 14, 272, 408, 272, 4676, 63, 964, 275, 488, 272, 1478, 63, 1160, 275, 488, 272, 1145, 63, 1080, 63, 1160, 275, 488, 272, 4676, 63, 1160, 275, 488, 272, 22079, 63, 1160, 275, 488, 272, 2505, 63, 1461, 63, 1160, 275, 488, 272, 2505, 63, 1461, 63, 4456, 63, 1160, 275, 488, 339, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1145, 63, 354, 534, 2113, 735, 267, 291, 423, 5189, 275, 1052, 327, 1402, 63, 533, 1021, 1035, 4628, 63, 533, 1256, 267, 291, 14, 1231, 63, 515, 275, 488, 267, 340, 536, 365, 488, 26, 288, 291, 14, 354, 275, 283, 2113, 7, 267, 587, 26, 288, 291, 14, 354, 275, 536, 267, 291, 14, 571, 63, 354, 275, 1145, 63, 354, 267, 291, 423, 3723, 275, 791, 1807, 63, 5511, 356, 5445, 14, 1807, 63, 5511, 93, 267, 291, 423, 2966, 63, 3723, 275, 291, 423, 3723, 14, 1574, 342, 339, 347, 2274, 8, 277, 12, 1402, 63, 269, 63, 8147, 12, 4628, 63, 533, 29, 403, 12, 1011, 1419, 304, 267, 408, 267, 5044, 14186, 314, 1627, 1402, 8, 83, 9, 543, 314, 1627, 4628, 1021, 14, 398, 710, 1402, 8, 83, 9, 1077, 506, 5822, 3992, 12, 440, 4454, 14, 398, 982, 376, 4628, 1021, 5712, 1133, 1627, 12, 652, 911, 675, 30093, 334, 1589, 849, 267, 4628, 1511, 680, 982, 4252, 2368, 787, 1627, 1553, 325, 14, 71, 2020, 769, 63, 2918, 1553, 267, 2985, 7171, 506, 6781, 465, 1511, 370, 314, 4628, 1021, 14, 398, 982, 282, 1402, 365, 2575, 7264, 12, 642, 911, 746, 21086, 20341, 14, 398, 982, 282, 1402, 365, 9006, 12, 642, 911, 746, 11897, 14, 267, 408, 267, 340, 440, 4628, 63, 533, 26, 288, 4628, 63, 533, 275, 30093, 398, 327, 7529, 1133, 492, 314, 394, 453, 951, 1785, 6411, 1233, 7444, 1415, 267, 340, 4628, 63, 533, 436, 2202, 14, 5287, 26, 288, 687, 1639, 14, 2828, 14, 2113, 14, 6136, 492, 4107, 267, 587, 26, 288, 4107, 275, 2400, 1402, 12, 4628, 533, 26, 488, 398, 340, 1228, 8, 1238, 63, 269, 63, 8147, 12, 5822, 1563, 304, 288, 1402, 63, 269, 63, 8147, 275, 359, 1238, 63, 269, 63, 8147, 61, 267, 367, 1402, 315, 1402, 63, 269, 63, 8147, 26, 288, 340, 1402, 423, 2024, 14, 6198, 26, 355, 746, 11897, 360, 1918, 1402, 450, 83, 365, 9006, 12, 880, 652, 283, 1993, 283, 11250, 506, 7264, 543, 4628, 3530, 450, 1402, 855, 354, 3368, 953, 340, 1402, 315, 291, 423, 5189, 26, 355, 746, 21086, 20341, 360, 1918, 1402, 450, 83, 365, 2575, 7264, 7, 450, 1402, 855, 354, 3368, 953, 327, 982, 781, 4788, 1011, 1419, 2066, 18774, 6982, 282, 5516, 402, 288, 327, 4628, 63, 533, 543, 5204, 1011, 1419, 14, 288, 340, 1511, 26, 355, 327, 2104, 14872, 473, 2793, 1133, 18794, 20647, 12, 1928, 282, 636, 578, 363, 355, 327, 314, 2737, 1021, 11337, 370, 298, 6442, 2, 315, 314, 6835, 4192, 12, 355, 327, 1314, 14486, 10876, 2945, 641, 14, 355, 1511, 13742, 578, 17501, 275, 636, 354, 363, 355, 4628, 63, 533, 275, 730, 3647, 83, 4880, 2, 450, 1402, 855, 354, 3108, 334, 2113, 63, 533, 4706, 1511, 9, 953, 327, 12134, 334, 6777, 5594, 506, 282, 949, 13, 411, 9, 288, 4107, 8, 2113, 63, 533, 12, 1402, 9, 953, 327, 32092, 314, 4628, 1021, 370, 3354, 315, 314, 7086, 288, 291, 423, 5189, 59, 1238, 61, 275, 4628, 63, 533, 8, 1238, 12, 291, 9, 339, 347, 24369, 8, 277, 12, 1402, 63, 269, 63, 8147, 304, 267, 408, 267, 1910, 30792, 314, 1627, 1402, 8, 83, 680, 398, 982, 282, 1402, 5712, 1133, 2575, 7264, 12, 642, 911, 746, 2832, 20341, 14, 267, 408, 267, 340, 1228, 8, 1238, 63, 269, 63, 8147, 12, 5822, 1563, 304, 288, 1402, 63, 269, 63, 8147, 275, 359, 1238, 63, 269, 63, 8147, 61, 267, 367, 1402, 315, 1402, 63, 269, 63, 8147, 26, 288, 340, 1402, 440, 315, 291, 423, 5189, 26, 355, 746, 2832, 20341, 360, 1918, 1402, 450, 83, 365, 440, 7264, 7, 450, 1402, 855, 354, 3368, 288, 2150, 291, 423, 5189, 59, 1238, 61, 339, 347, 1050, 63, 1287, 8, 277, 12, 1595, 12, 536, 29, 403, 304, 267, 408, 267, 11828, 376, 1595, 370, 506, 2808, 26662, 14, 267, 408, 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,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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 ]
Rositsazz/hack33
hack33/contrib/sites/migrations/0001_initial.py
378
1134
# -*- coding: utf-8 -*- from __future__ import unicode_literals import django.contrib.sites.models from django.contrib.sites.models import _simple_domain_name_validator from django.db import migrations, models class Migration(migrations.Migration): dependencies = [] operations = [ migrations.CreateModel( name='Site', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('domain', models.CharField( max_length=100, verbose_name='domain name', validators=[_simple_domain_name_validator] )), ('name', models.CharField(max_length=50, verbose_name='display name')), ], options={ 'ordering': ('domain',), 'db_table': 'django_site', 'verbose_name': 'site', 'verbose_name_plural': 'sites', }, bases=(models.Model,), managers=[ ('objects', django.contrib.sites.models.SiteManager()), ], ), ]
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1639, 14, 2828, 14, 8619, 14, 992, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 485, 4129, 63, 2261, 63, 354, 63, 11034, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 942, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 8972, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 2261, 297, 1709, 14, 2183, 8, 490, 1390, 63, 1267, 29, 1960, 12, 3376, 63, 354, 534, 2261, 536, 297, 14370, 1524, 63, 4129, 63, 2261, 63, 354, 63, 11034, 61, 355, 22583, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 3376, 63, 354, 534, 2918, 536, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 661, 2261, 5529, 355, 283, 697, 63, 1224, 356, 283, 1176, 63, 2124, 297, 355, 283, 3832, 63, 354, 356, 283, 2124, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 8619, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 288, 19680, 1524, 355, 661, 1462, 297, 1639, 14, 2828, 14, 8619, 14, 992, 14, 8972, 2988, 4000, 288, 2156, 267, 2318, 272, 1622, 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, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1639, 14, 2828, 14, 8619, 14, 992, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 485, 4129, 63, 2261, 63, 354, 63, 11034, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 942, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 8972, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 2261, 297, 1709, 14, 2183, 8, 490, 1390, 63, 1267, 29, 1960, 12, 3376, 63, 354, 534, 2261, 536, 297, 14370, 1524, 63, 4129, 63, 2261, 63, 354, 63, 11034, 61, 355, 22583, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 3376, 63, 354, 534, 2918, 536, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 7128, 356, 661, 2261, 5529, 355, 283, 697, 63, 1224, 356, 283, 1176, 63, 2124, 297, 355, 283, 3832, 63, 354, 356, 283, 2124, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 8619, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 288, 19680, 1524, 355, 661, 1462, 297, 1639, 14, 2828, 14, 8619, 14, 992, 14, 8972, 2988, 4000, 288, 2156, 267, 2318, 272, 1622, 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, 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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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 ]
z1gm4/desarrollo_web_udp
env/lib/python2.7/site-packages/faker/providers/person/de_DE/__init__.py
3
30301
# coding=utf-8 from __future__ import unicode_literals from .. import Provider as PersonProvider class Provider(PersonProvider): formats = ( '{{first_name_male}} {{last_name}}', '{{first_name_male}} {{last_name}}', '{{first_name_male}} {{last_name}}', '{{first_name_male}} {{last_name}}', '{{first_name_male}} {{last_name}}-{{last_name}}', '{{first_name_female}} {{last_name}}', '{{first_name_female}} {{last_name}}', '{{first_name_female}} {{last_name}}', '{{first_name_female}} {{last_name}}', '{{first_name_female}} {{last_name}}-{{last_name}}', '{{prefix_male}} {{first_name_male}} {{last_name}}', '{{prefix_female}} {{first_name_female}} {{last_name}}', '{{first_name_male}} {{last_name}} {{suffix}}', '{{first_name_female}} {{last_name}} {{suffix}}', '{{prefix_male}} {{first_name_male}} {{last_name}} {{suffix}}', '{{prefix_female}} {{first_name_female}} {{last_name}} {{suffix}}', ) # From http://de.wiktionary.org/wiki/Verzeichnis:Deutsch/Liste_der_h%C3%A4ufigsten_m%C3%A4nnlichen_Vornamen_Deutschlands first_names_male = ( 'Abbas', 'Abdul', 'Abdullah', 'Abraham', 'Abram', 'Achim', 'Ada', 'Adalbert', 'Adam', 'Adelbert', 'Adem', 'Adolf', 'Adrian', 'Ahmad', 'Ahmed', 'Ahmet', 'Alan', 'Alban', 'Albert', 'Alberto', 'Albin', 'Albrecht', 'Aldo', 'Aleksandar', 'Aleksander', 'Aleksandr', 'Aleksej', 'Alessandro', 'Alex', 'Alexander', 'Alexandre', 'Alexandros', 'Alexei', 'Alexej', 'Alf', 'Alfons', 'Alfonso', 'Alfred', 'Alfredo', 'Ali', 'Alois', 'Aloys', 'Alwin', 'Amir', 'Anastasios', 'Anatol', 'Anatoli', 'Anatolij', 'Andre', 'Andreas', 'Andree', 'Andrei', 'Andrej', 'Andres', 'Andrew', 'Andrey', 'Andrzej', 'André', 'Andy', 'Angelo', 'Anselm', 'Ansgar', 'Ante', 'Anthony', 'Anto', 'Anton', 'Antonino', 'Antonio', 'Antonios', 'Antonius', 'Apostolos', 'Aribert', 'Arif', 'Armin', 'Arnd', 'Arndt', 'Arne', 'Arnfried', 'Arnim', 'Arno', 'Arnold', 'Arnulf', 'Arthur', 'Artur', 'Athanasios', 'Attila', 'August', 'Augustin', 'Axel', 'Aziz', 'Baldur', 'Balthasar', 'Baptist', 'Bartholomäus', 'Bastian', 'Bayram', 'Bekir', 'Bela', 'Ben', 'Benedikt', 'Benjamin', 'Benno', 'Berend', 'Bernard', 'Bernd', 'Bernd-Dieter', 'Berndt', 'Bernfried', 'Bernhard', 'Bernt', 'Bernward', 'Bert', 'Berthold', 'Bertold', 'Bertram', 'Birger', 'Björn', 'Bodo', 'Bogdan', 'Boris', 'Branko', 'Brian', 'Bruno', 'Burckhard', 'Burghard', 'Burkard', 'Burkhard', 'Burkhardt', 'Calogero', 'Carl', 'Carl-Heinz', 'Carlo', 'Carlos', 'Carmelo', 'Carsten', 'Celal', 'Cemal', 'Cemil', 'Cengiz', 'Cetin', 'Charles', 'Christian', 'Christof', 'Christoph', 'Christopher', 'Christos', 'Claas', 'Claudio', 'Claudius', 'Claus', 'Claus-Dieter', 'Claus-Peter', 'Clemens', 'Conrad', 'Constantin', 'Cord', 'Cornelius', 'Cosimo', 'Curt', 'Czeslaw', 'Dagobert', 'Damian', 'Dan', 'Daniel', 'Daniele', 'Danilo', 'Danny', 'Darius', 'Dariusz', 'Darko', 'David', 'Denis', 'Dennis', 'Denny', 'Detlef', 'Detlev', 'Diedrich', 'Dierk', 'Dieter', 'Diethard', 'Diethelm', 'Diether', 'Dietmar', 'Dietrich', 'Dimitri', 'Dimitrios', 'Dino', 'Dirk', 'Ditmar', 'Dittmar', 'Dogan', 'Domenico', 'Dominic', 'Dominik', 'Donald', 'Dragan', 'Drago', 'Dursun', 'Dusan', 'Eberhard', 'Eberhardt', 'Eckard', 'Eckart', 'Eckehard', 'Eckhard', 'Eckhardt', 'Eckhart', 'Edelbert', 'Edgar', 'Edmund', 'Eduard', 'Edward', 'Edwin', 'Egbert', 'Eggert', 'Egon', 'Ehrenfried', 'Ehrhard', 'Eitel', 'Ekkehard', 'Ekkehart', 'Ekrem', 'Elias', 'Elmar', 'Emanuel', 'Emil', 'Emin', 'Emmerich', 'Engelbert', 'Engin', 'Enno', 'Enrico', 'Enver', 'Ercan', 'Erdal', 'Erdogan', 'Erhard', 'Erhardt', 'Eric', 'Erich', 'Erik', 'Erkan', 'Ernest', 'Ernst', 'Ernst-August', 'Ernst-Dieter', 'Ernst-Otto', 'Erol', 'Erwin', 'Eugen', 'Evangelos', 'Ewald', 'Fabian', 'Falk', 'Falko', 'Faruk', 'Fatih', 'Fedor', 'Felix', 'Ferdi', 'Ferdinand', 'Ferenc', 'Fernando', 'Filippo', 'Florian', 'Folker', 'Folkert', 'Francesco', 'Francis', 'Francisco', 'Franco', 'Franjo', 'Frank', 'Frank-Michael', 'Frank-Peter', 'Franz', 'Franz Josef', 'Franz-Josef', 'Franz-Peter', 'Franz-Xaver', 'Fred', 'Freddy', 'Frederic', 'Frederik', 'Fredi', 'Fredo', 'Fredy', 'Fridolin', 'Friedbert', 'Friedemann', 'Frieder', 'Friedhelm', 'Friedhold', 'Friedo', 'Friedrich', 'Friedrich-Karl', 'Friedrich-Wilhelm', 'Frithjof', 'Fritz', 'Gabor', 'Gabriel', 'Gaetano', 'Gebhard', 'Geert', 'Georg', 'George', 'Georgios', 'Gerald', 'Gerard', 'Gerd', 'Gereon', 'Gerfried', 'Gerhard', 'Gerhardt', 'Gerhart', 'German', 'Gernot', 'Gero', 'Gerold', 'Gerolf', 'Gert', 'Gerwin', 'Gilbert', 'Gino', 'Giorgio', 'Giovanni', 'Gisbert', 'Giuseppe', 'Goran', 'Gordon', 'Gottfried', 'Gotthard', 'Gotthilf', 'Gotthold', 'Gottlieb', 'Gottlob', 'Gregor', 'Grzegorz', 'Guenter', 'Guenther', 'Guido', 'Guiseppe', 'Gunar', 'Gundolf', 'Gunnar', 'Gunter', 'Gunther', 'Guntram', 'Gustav', 'Götz', 'Günter', 'Günther', 'H.-Dieter', 'Hagen', 'Hajo', 'Hakan', 'Halil', 'Hannes', 'Hanni', 'Hanno', 'Hanns', 'Hans', 'Hans D.', 'Hans Dieter', 'Hans Georg', 'Hans Josef', 'Hans Jörg', 'Hans Jürgen', 'Hans Peter', 'Hans-Adolf', 'Hans-Albert', 'Hans-Bernd', 'Hans-Christian', 'Hans-Detlef', 'Hans-Dieter', 'Hans-Dietrich', 'Hans-Eberhard', 'Hans-Erich', 'Hans-Friedrich', 'Hans-Georg', 'Hans-Gerd', 'Hans-Gerhard', 'Hans-Günter', 'Hans-Günther', 'Hans-H.', 'Hans-Heinrich', 'Hans-Helmut', 'Hans-Henning', 'Hans-Herbert', 'Hans-Hermann', 'Hans-Hinrich', 'Hans-J.', 'Hans-Joachim', 'Hans-Jochen', 'Hans-Josef', 'Hans-Jörg', 'Hans-Jürgen', 'Hans-Karl', 'Hans-Ludwig', 'Hans-Martin', 'Hans-Michael', 'Hans-Otto', 'Hans-Peter', 'Hans-Rainer', 'Hans-Rudolf', 'Hans-Theo', 'Hans-Ulrich', 'Hans-Uwe', 'Hans-Walter', 'Hans-Werner', 'Hans-Wilhelm', 'Hans-Willi', 'Hans-Wolfgang', 'Hansgeorg', 'Hansjoachim', 'Hansjörg', 'Hansjürgen', 'Hanspeter', 'Harald', 'Hardy', 'Harm', 'Harold', 'Harri', 'Harro', 'Harry', 'Hartmut', 'Hartmuth', 'Hartwig', 'Hasan', 'Hassan', 'Hasso', 'Heiko', 'Heimo', 'Heiner', 'Heinfried', 'Heini', 'Heino', 'Heinrich', 'Heinz', 'Heinz Dieter', 'Heinz-Dieter', 'Heinz-Georg', 'Heinz-Gerd', 'Heinz-Günter', 'Heinz-Günther', 'Heinz-Joachim', 'Heinz-Josef', 'Heinz-Jürgen', 'Heinz-Otto', 'Heinz-Peter', 'Heinz-Walter', 'Heinz-Werner', 'Heinz-Wilhelm', 'Heinz-Willi', 'Helfried', 'Helge', 'Hellmut', 'Hellmuth', 'Helmar', 'Helmut', 'Helmuth', 'Hendrik', 'Henner', 'Henning', 'Henrik', 'Henry', 'Henryk', 'Herbert', 'Heribert', 'Hermann', 'Hermann Josef', 'Hermann-Josef', 'Herrmann', 'Herwig', 'Hilmar', 'Hinrich', 'Holger', 'Holm', 'Horst', 'Horst-Dieter', 'Horst-Günter', 'Horst-Peter', 'Hubert', 'Hubertus', 'Hugo', 'Hüseyin', 'Ian', 'Ibrahim', 'Ignatz', 'Ignaz', 'Igor', 'Ilhan', 'Ilias', 'Ilija', 'Ilja', 'Immo', 'Imre', 'Ingbert', 'Ingmar', 'Ingo', 'Ingolf', 'Ioannis', 'Isidor', 'Ismail', 'Ismet', 'Istvan', 'Ivan', 'Ivo', 'Iwan', 'Jacek', 'Jacob', 'Jakob', 'James', 'Jan', 'Jan-Peter', 'Janko', 'Jann', 'Janos', 'Janus', 'Janusz', 'Jaroslav', 'Jaroslaw', 'Jens', 'Jens-Peter', 'Jens-Uwe', 'Jerzy', 'Jiri', 'Joachim', 'Jobst', 'Jochem', 'Jochen', 'Joerg', 'Johan', 'Johann', 'Johannes', 'John', 'Jonas', 'Jonas', 'Jonathan', 'Jorge', 'Jose', 'Josef', 'Joseph', 'Josip', 'Jost', 'José', 'Jovan', 'Jozef', 'Juan', 'Juergen', 'Julian', 'Julius', 'Juri', 'Jurij', 'Justus', 'Jörg', 'Jörg-Peter', 'Jörgen', 'Jörn', 'Jürgen', 'Kai-Uwe', 'Kamil', 'Karl', 'Karl Heinz', 'Karl-August', 'Karl-Dieter', 'Karl-Ernst', 'Karl-Friedrich', 'Karl-Georg', 'Karl-Hans', 'Karl-Heinrich', 'Karl-Heinz', 'Karl-Hermann', 'Karl-Josef', 'Karl-Jürgen', 'Karl-Ludwig', 'Karl-Otto', 'Karl-Peter', 'Karl-Werner', 'Karl-Wilhelm', 'Karlfried', 'Karlheinz', 'Karsten', 'Kasimir', 'Kaspar', 'Kay-Uwe', 'Kazim', 'Kemal', 'Kenan', 'Kenneth', 'Kevin', 'Kilian', 'Klaas', 'Klaus', 'Klaus Dieter', 'Klaus Peter', 'Klaus-D.', 'Klaus-Dieter', 'Klaus-Günter', 'Klaus-Jürgen', 'Klaus-Michael', 'Klaus-Peter', 'Klaus-Ulrich', 'Klaus-Werner', 'Klemens', 'Knud', 'Knut', 'Konrad', 'Konstantin', 'Konstantinos', 'Korbinian', 'Kornelius', 'Kristian', 'Krzysztof', 'Kunibert', 'Kuno', 'Kurt', 'Ladislaus', 'Lambert', 'Lars', 'Laszlo', 'Laurenz', 'Leander', 'Leif', 'Leo', 'Leon', 'Leonard', 'Leonardo', 'Leonhard', 'Leonid', 'Leopold', 'Leszek', 'Linus', 'Lorenz', 'Lorenzo', 'Lothar', 'Louis', 'Luciano', 'Ludger', 'Ludwig', 'Luigi', 'Luis', 'Lukas', 'Lutz', 'Magnus', 'Mahmoud', 'Mahmut', 'Maik', 'Malte', 'Manfred', 'Manuel', 'Marc', 'Marcel', 'Marco', 'Marcus', 'Marek', 'Marian', 'Marijan', 'Mario', 'Marius', 'Mariusz', 'Mark', 'Marko', 'Markus', 'Marten', 'Martin', 'Marvin', 'Massimo', 'Mathias', 'Mato', 'Matteo', 'Matthias', 'Matthäus', 'Mattias', 'Maurice', 'Maurizio', 'Max', 'Maxim', 'Maximilian', 'Mehdi', 'Mehmet', 'Meik', 'Meinhard', 'Meinolf', 'Meinrad', 'Mesut', 'Metin', 'Micha', 'Michael', 'Michail', 'Michel', 'Miguel', 'Mijo', 'Mike', 'Mikhail', 'Milan', 'Milos', 'Miodrag', 'Mirco', 'Mirko', 'Miroslav', 'Miroslaw', 'Mohamed', 'Mohammad', 'Mohammed', 'Moritz', 'Muharrem', 'Murat', 'Mustafa', 'Muzaffer', 'Necati', 'Nick', 'Nico', 'Nicolai', 'Nicolas', 'Nicolaus', 'Niels', 'Niklas', 'Niko', 'Nikola', 'Nikolai', 'Nikolaj', 'Nikolaos', 'Nikolas', 'Nikolaus', 'Nils', 'Norbert', 'Norman', 'Nurettin', 'Nuri', 'Olaf', 'Ole', 'Oliver', 'Orhan', 'Ortwin', 'Oscar', 'Oskar', 'Osman', 'Oswald', 'Oswin', 'Otfried', 'Othmar', 'Otmar', 'Ottfried', 'Ottmar', 'Otto', 'Ottokar', 'Ottomar', 'Paolo', 'Pascal', 'Pasquale', 'Patric', 'Patrick', 'Patrik', 'Paul', 'Paul-Gerhard', 'Paul-Heinz', 'Paulo', 'Pavel', 'Pawel', 'Pedro', 'Peer', 'Pero', 'Petar', 'Peter', 'Peter-Michael', 'Petros', 'Philip', 'Philipp', 'Philippe', 'Phillip', 'Pierre', 'Pietro', 'Piotr', 'Pirmin', 'Pius', 'Rafael', 'Raik', 'Raimund', 'Rainer', 'Ralf', 'Ralf-Dieter', 'Ralf-Peter', 'Ralph', 'Ramazan', 'Ramon', 'Randolf', 'Raphael', 'Raymond', 'Raymund', 'Recep', 'Reginald', 'Reimar', 'Reimer', 'Reimund', 'Reinald', 'Reiner', 'Reinhard', 'Reinhardt', 'Reinhart', 'Reinhold', 'Remo', 'Renato', 'Rene', 'René', 'Reza', 'Ricardo', 'Richard', 'Rico', 'Rigo', 'Riza', 'Robby', 'Robert', 'Roberto', 'Robin', 'Rocco', 'Rochus', 'Roderich', 'Roger', 'Roland', 'Rolf', 'Rolf-Dieter', 'Rolf-Peter', 'Roman', 'Romuald', 'Ron', 'Ronald', 'Ronny', 'Rouven', 'Roy', 'Ruben', 'Rudi', 'Rudolf', 'Rudolph', 'Rupert', 'Ryszard', 'Rüdiger', 'Saban', 'Sabri', 'Sahin', 'Salih', 'Salvatore', 'Sami', 'Samir', 'Samuel', 'Sandor', 'Sandro', 'Sebastian', 'Sebastiano', 'Sedat', 'Selim', 'Senol', 'Sepp', 'Serge', 'Sergei', 'Sergej', 'Sergio', 'Severin', 'Siegbert', 'Siegfried', 'Sieghard', 'Siegmar', 'Siegmund', 'Siegward', 'Sigfried', 'Sigismund', 'Sigmar', 'Sigmund', 'Sigurd', 'Silvester', 'Silvio', 'Simon', 'Slavko', 'Slawomir', 'Slobodan', 'Stanislaus', 'Stanislav', 'Stanislaw', 'Stavros', 'Stefan', 'Stefano', 'Steffen', 'Stephan', 'Stephen', 'Steve', 'Steven', 'Stjepan', 'Sven', 'Swen', 'Sylvester', 'Sylvio', 'Sönke', 'Sören', 'Sükrü', 'Süleyman', 'Tadeusz', 'Tassilo', 'Thaddäus', 'Theo', 'Theobald', 'Theodor', 'Theodoros', 'Thies', 'Thilo', 'Thomas', 'Thoralf', 'Thorben', 'Thorsten', 'Tibor', 'Till', 'Tillmann', 'Tilman', 'Tilmann', 'Tilo', 'Tim', 'Timm', 'Timo', 'Tino', 'Tobias', 'Tom', 'Tomas', 'Tomasz', 'Tomislav', 'Toni', 'Tony', 'Toralf', 'Torben', 'Torsten', 'Traugott', 'Udo', 'Ulf', 'Uli', 'Ullrich', 'Ulrich', 'Urban', 'Urs', 'Utz', 'Uwe', 'Vadim', 'Valentin', 'Valerij', 'Vassilios', 'Veit', 'Veli', 'Victor', 'Viktor', 'Vincent', 'Vincenzo', 'Vinko', 'Vinzenz', 'Vitali', 'Vito', 'Vittorio', 'Vitus', 'Vladimir', 'Vlado', 'Volker', 'Volkhard', 'Volkmar', 'Waldemar', 'Walfried', 'Walter', 'Walther', 'Wenzel', 'Werner', 'Wieland', 'Wieslaw', 'Wigbert', 'Wilfried', 'Wilhelm', 'Willfried', 'Willi', 'William', 'Willibald', 'Willibert', 'Willy', 'Winfried', 'Witold', 'Wladimir', 'Wojciech', 'Woldemar', 'Wolf', 'Wolf-Dieter', 'Wolf-Dietrich', 'Wolf-Rüdiger', 'Wolfgang', 'Wolfhard', 'Wolfram', 'Wulf', 'Xaver', 'Yilmaz', 'Yusuf', 'Zbigniew', 'Zdravko', 'Zeki', 'Zeljko', 'Zenon', 'Zlatko', 'Zoltan', 'Zoran', ) # From http://de.wiktionary.org/wiki/Verzeichnis:Deutsch/Liste_der_h%C3%A4ufigsten_weiblichen_Vornamen_Deutschlands first_names_female = ( 'Adele', 'Adelgunde', 'Adelheid', 'Adelinde', 'Adeline', 'Adina', 'Adolfine', 'Adriana', 'Adriane', 'Aenne', 'Änne', 'Agata', 'Agatha', 'Agathe', 'Agnes', 'Agnieszka', 'Albertine', 'Albina', 'Aleksandra', 'Alena', 'Alexa', 'Alexandra', 'Alice', 'Alicia', 'Alicja', 'Alida', 'Alina', 'Aline', 'Alla', 'Alma', 'Almut', 'Almuth', 'Aloisia', 'Alwina', 'Alwine', 'Amalia', 'Amalie', 'Amanda', 'Amelie', 'Ana', 'Anastasia', 'Andrea', 'Aneta', 'Anett', 'Anette', 'Angela', 'Angelica', 'Angelika', 'Angelina', 'Angelique', 'Anica', 'Anika', 'Anita', 'Anja', 'Anka', 'Anke', 'Ann', 'Ann-Kathrin', 'Anna', 'Anna-Lena', 'Anna-Luise', 'Anna-Maria', 'Anna-Marie', 'Annaliese', 'Annamaria', 'Anne', 'Anne-Kathrin', 'Anne-Katrin', 'Anne-Marie', 'Anne-Rose', 'Annedore', 'Annegret', 'Annegrete', 'Annekatrin', 'Anneke', 'Annelene', 'Anneli', 'Annelie', 'Annelies', 'Anneliese', 'Annelise', 'Annelore', 'Annemarie', 'Annemie', 'Annerose', 'Annett', 'Annette', 'Anni', 'Annie', 'Annika', 'Annita', 'Anny', 'Antje', 'Antoinette', 'Antonia', 'Antonie', 'Antonietta', 'Antonina', 'Apollonia', 'Ariane', 'Arzu', 'Asta', 'Astrid', 'Augusta', 'Auguste', 'Aurelia', 'Aynur', 'Ayse', 'Aysel', 'Ayten', 'Babett', 'Babette', 'Barbara', 'Beata', 'Beate', 'Beatrice', 'Beatrix', 'Belinda', 'Benita', 'Berit', 'Bernadette', 'Bernhardine', 'Berta', 'Bertha', 'Betina', 'Betti', 'Bettina', 'Betty', 'Bianca', 'Bianka', 'Birgid', 'Birgit', 'Birgitt', 'Birgitta', 'Birte', 'Birthe', 'Blanka', 'Bozena', 'Branka', 'Brigitta', 'Brigitte', 'Brit', 'Brita', 'Britt', 'Britta', 'Brunhild', 'Brunhilde', 'Bruni', 'Bärbel', 'Camilla', 'Canan', 'Caren', 'Carin', 'Carina', 'Carla', 'Carmela', 'Carmen', 'Carmine', 'Carola', 'Carolin', 'Carolina', 'Caroline', 'Caterina', 'Catharina', 'Catherine', 'Cathleen', 'Cathrin', 'Catrin', 'Cecilia', 'Centa', 'Chantal', 'Charlotte', 'Christa', 'Christa-Maria', 'Christel', 'Christiana', 'Christiane', 'Christin', 'Christina', 'Christine', 'Christl', 'Cilli', 'Cilly', 'Cindy', 'Claire', 'Clara', 'Clarissa', 'Claudia', 'Cläre', 'Concetta', 'Conny', 'Constance', 'Constanze', 'Cora', 'Cordula', 'Corina', 'Corinna', 'Corinne', 'Cornelia', 'Cosima', 'Cristina', 'Cynthia', 'Cäcilia', 'Cäcilie', 'Dagmar', 'Dajana', 'Damaris', 'Dana', 'Danica', 'Daniela', 'Danielle', 'Danuta', 'Daria', 'Deborah', 'Delia', 'Denise', 'Desiree', 'Diana', 'Diane', 'Dietlind', 'Dietlinde', 'Dina', 'Dolores', 'Donata', 'Dora', 'Doreen', 'Dorina', 'Doris', 'Dorit', 'Dorle', 'Dorota', 'Dorothe', 'Dorothea', 'Dorothee', 'Dragica', 'Dunja', 'Dörte', 'Dörthe', 'Edda', 'Edelgard', 'Edeltraud', 'Edeltraut', 'Edeltrud', 'Edit', 'Edith', 'Editha', 'Ehrentraud', 'Eileen', 'Ekaterina', 'Elena', 'Eleni', 'Elenore', 'Eleonora', 'Eleonore', 'Elfi', 'Elfie', 'Elfriede', 'Elif', 'Elisa', 'Elisabet', 'Elisabeth', 'Elise', 'Elizabeth', 'Elke', 'Ella', 'Ellen', 'Elli', 'Ellinor', 'Elly', 'Elma', 'Elsa', 'Elsbeth', 'Else', 'Elvira', 'Elwira', 'Elzbieta', 'Emilia', 'Emilie', 'Emine', 'Emma', 'Emmi', 'Emmy', 'Erdmute', 'Erica', 'Erika', 'Erna', 'Ernestine', 'Ester', 'Esther', 'Etta', 'Eugenia', 'Eugenie', 'Eva', 'Eva-Maria', 'Eva-Marie', 'Evamaria', 'Evangelia', 'Evelin', 'Eveline', 'Evelyn', 'Evelyne', 'Evi', 'Ewa', 'Fabienne', 'Fadime', 'Fanny', 'Fatima', 'Fatma', 'Felicia', 'Felicitas', 'Felizitas', 'Filiz', 'Flora', 'Florence', 'Florentine', 'Franca', 'Francesca', 'Francoise', 'Franka', 'Franziska', 'Frauke', 'Frederike', 'Freia', 'Freya', 'Frida', 'Frieda', 'Friedericke', 'Friederike', 'Friedhilde', 'Friedl', 'Friedlinde', 'Gabi', 'Gabriela', 'Gabriele', 'Gabriella', 'Gaby', 'Galina', 'Genoveva', 'Georgia', 'Georgine', 'Geraldine', 'Gerda', 'Gerdi', 'Gerhild', 'Gerlind', 'Gerlinde', 'Gerta', 'Gerti', 'Gertraud', 'Gertraude', 'Gertraut', 'Gertrud', 'Gertrude', 'Gesa', 'Gesche', 'Gesine', 'Geza', 'Giesela', 'Gilda', 'Gina', 'Giovanna', 'Gisa', 'Gisela', 'Gislinde', 'Gitta', 'Gitte', 'Giuseppina', 'Gloria', 'Gordana', 'Grazyna', 'Greta', 'Gretchen', 'Grete', 'Gretel', 'Gretl', 'Grit', 'Gudrun', 'Gudula', 'Gunda', 'Gundel', 'Gundi', 'Gundula', 'Gunhild', 'Gusti', 'Gönül', 'Gülay', 'Gülsen', 'Gülten', 'Halina', 'Hanife', 'Hanna', 'Hannah', 'Hannchen', 'Hanne', 'Hanne-Lore', 'Hannelore', 'Hanny', 'Harriet', 'Hatice', 'Hedda', 'Hedi', 'Hedwig', 'Hedy', 'Heide', 'Heide-Marie', 'Heidelinde', 'Heidelore', 'Heidemarie', 'Heiderose', 'Heidi', 'Heidrun', 'Heike', 'Helen', 'Helena', 'Helene', 'Helga', 'Hella', 'Helma', 'Helmtrud', 'Henni', 'Henny', 'Henri', 'Henriette', 'Henrike', 'Herlinde', 'Herma', 'Hermine', 'Herta', 'Hertha', 'Hilda', 'Hildburg', 'Hilde', 'Hildegard', 'Hildegart', 'Hildegund', 'Hildegunde', 'Hilma', 'Hiltraud', 'Hiltrud', 'Hubertine', 'Hulda', 'Hülya', 'Ida', 'Ildiko', 'Ilka', 'Ilona', 'Ilonka', 'Ilse', 'Imelda', 'Imke', 'Ina', 'Ines', 'Inga', 'Inge', 'Ingeborg', 'Ingeburg', 'Ingelore', 'Ingetraud', 'Ingetraut', 'Ingrid', 'Ingried', 'Inka', 'Inken', 'Inna', 'Insa', 'Ira', 'Irena', 'Irene', 'Irina', 'Iris', 'Irma', 'Irmela', 'Irmengard', 'Irmgard', 'Irmhild', 'Irmi', 'Irmingard', 'Irmtraud', 'Irmtraut', 'Irmtrud', 'Isa', 'Isabel', 'Isabell', 'Isabella', 'Isabelle', 'Isolde', 'Ivana', 'Ivanka', 'Ivonne', 'Iwona', 'Jacqueline', 'Jadwiga', 'Jana', 'Jane', 'Janet', 'Janett', 'Janette', 'Janin', 'Janina', 'Janine', 'Janna', 'Jaqueline', 'Jasmin', 'Jasmina', 'Jeanette', 'Jeannette', 'Jeannine', 'Jelena', 'Jennifer', 'Jenny', 'Jessica', 'Jessika', 'Jo', 'Joana', 'Joanna', 'Johanna', 'Johanne', 'Jolanda', 'Jolanta', 'Jolanthe', 'Josefa', 'Josefine', 'Josephine', 'Judith', 'Julia', 'Juliana', 'Juliane', 'Julie', 'Justina', 'Justine', 'Jutta', 'Karen', 'Karin', 'Karina', 'Karla', 'Karola', 'Karolin', 'Karolina', 'Karoline', 'Kata', 'Katalin', 'Katarina', 'Katarzyna', 'Katerina', 'Katharina', 'Katharine', 'Katherina', 'Kathi', 'Kathleen', 'Kathrin', 'Kathy', 'Kati', 'Katja', 'Katrin', 'Katy', 'Kerstin', 'Kira', 'Kirsten', 'Kirstin', 'Klara', 'Klaudia', 'Klothilde', 'Kläre', 'Konstanze', 'Kordula', 'Korinna', 'Kornelia', 'Kreszentia', 'Kreszenz', 'Kriemhild', 'Krista', 'Kristiane', 'Kristin', 'Kristina', 'Kristine', 'Krystyna', 'Kunigunda', 'Kunigunde', 'Käte', 'Käthe', 'Käthi', 'Laila', 'Lara', 'Larissa', 'Laura', 'Lea', 'Leila', 'Lena', 'Lene', 'Leni', 'Leokadia', 'Leonie', 'Leonore', 'Leopoldine', 'Leyla', 'Lia', 'Liane', 'Lidia', 'Lidija', 'Lidwina', 'Liesa', 'Liesbeth', 'Lieschen', 'Liesel', 'Lieselotte', 'Lili', 'Lilian', 'Liliana', 'Liliane', 'Lilija', 'Lilli', 'Lilly', 'Lilo', 'Lina', 'Linda', 'Lioba', 'Lisa', 'Lisbeth', 'Liselotte', 'Lisette', 'Lissi', 'Lissy', 'Ljiljana', 'Ljubica', 'Ljudmila', 'Loni', 'Lore', 'Loretta', 'Lotte', 'Lotti', 'Louise', 'Lucia', 'Lucie', 'Ludmila', 'Ludmilla', 'Ludwina', 'Luisa', 'Luise', 'Luitgard', 'Luka', 'Luzia', 'Luzie', 'Lydia', 'Madeleine', 'Madlen', 'Magarete', 'Magda', 'Magdalena', 'Magdalene', 'Magret', 'Magrit', 'Maike', 'Maja', 'Malgorzata', 'Mandy', 'Manja', 'Manuela', 'Mara', 'Marcella', 'Mareen', 'Mareike', 'Mareile', 'Maren', 'Marga', 'Margaret', 'Margareta', 'Margarete', 'Margaretha', 'Margarethe', 'Margarita', 'Margit', 'Margita', 'Margitta', 'Margot', 'Margret', 'Margrit', 'Maria', 'Maria-Luise', 'Maria-Theresia', 'Mariana', 'Marianna', 'Marianne', 'Marica', 'Marie', 'Marie-Louise', 'Marie-Luise', 'Marie-Theres', 'Marie-Therese', 'Mariechen', 'Mariele', 'Marieluise', 'Marietta', 'Marija', 'Marika', 'Marina', 'Mariola', 'Marion', 'Marisa', 'Marit', 'Marita', 'Maritta', 'Marjan', 'Marleen', 'Marlen', 'Marlene', 'Marlies', 'Marliese', 'Marlis', 'Marta', 'Martha', 'Martina', 'Martine', 'Mary', 'Marzena', 'Mathilde', 'Maya', 'Mechthild', 'Mechthilde', 'Mechtild', 'Meike', 'Melanie', 'Melissa', 'Melita', 'Melitta', 'Meral', 'Mercedes', 'Meryem', 'Meta', 'Mia', 'Michaela', 'Michaele', 'Michelle', 'Milena', 'Milica', 'Milka', 'Mina', 'Minna', 'Mira', 'Mirella', 'Miriam', 'Mirja', 'Mirjam', 'Mirjana', 'Miroslawa', 'Mona', 'Monica', 'Monika', 'Monique', 'Monja', 'Myriam', 'Nada', 'Nadeschda', 'Nadeshda', 'Nadia', 'Nadin', 'Nadine', 'Nadja', 'Nancy', 'Natali', 'Natalia', 'Natalie', 'Natalija', 'Natalja', 'Natascha', 'Nathalie', 'Nelli', 'Nelly', 'Nermin', 'Nevenka', 'Nicole', 'Nina', 'Nora', 'Norma', 'Notburga', 'Nuran', 'Nuray', 'Nurten', 'Oda', 'Olav', 'Olena', 'Olga', 'Olivia', 'Ortrud', 'Ortrun', 'Ottilie', 'Oxana', 'Pamela', 'Paola', 'Pascale', 'Patricia', 'Patrizia', 'Paula', 'Paulina', 'Pauline', 'Peggy', 'Petra', 'Philomena', 'Pia', 'Polina', 'Priska', 'Rabea', 'Radmila', 'Rahel', 'Raisa', 'Raissa', 'Ramona', 'Raphaela', 'Rebecca', 'Rebekka', 'Regina', 'Regine', 'Reingard', 'Reinhild', 'Reinhilde', 'Rena', 'Renata', 'Renate', 'Reni', 'Resi', 'Ria', 'Ricarda', 'Rita', 'Romana', 'Romy', 'Rosa', 'Rosa-Maria', 'Rosalia', 'Rosalie', 'Rosalinde', 'Rose', 'Rose-Marie', 'Rosel', 'Roselinde', 'Rosemarie', 'Rosi', 'Rosina', 'Rosita', 'Rosl', 'Rosmarie', 'Roswita', 'Roswitha', 'Rotraud', 'Rotraut', 'Ruth', 'Ruthild', 'Sabina', 'Sabine', 'Sabrina', 'Samira', 'Sandra', 'Sandy', 'Sara', 'Sarah', 'Sarina', 'Saskia', 'Selma', 'Semra', 'Senta', 'Serpil', 'Sevim', 'Sibel', 'Sibilla', 'Sibille', 'Sibylla', 'Sibylle', 'Sieglinde', 'Siegrid', 'Siegried', 'Siegrun', 'Siglinde', 'Sigrid', 'Sigrun', 'Silja', 'Silke', 'Silva', 'Silvana', 'Silvia', 'Simona', 'Simone', 'Sina', 'Sinaida', 'Slavica', 'Sofia', 'Sofie', 'Solveig', 'Songül', 'Sonia', 'Sonja', 'Sophia', 'Sophie', 'Stefani', 'Stefania', 'Stefanie', 'Steffi', 'Stella', 'Stephanie', 'Stilla', 'Susan', 'Susana', 'Susann', 'Susanna', 'Susanne', 'Suse', 'Susi', 'Suzanne', 'Svea', 'Svenja', 'Svetlana', 'Swantje', 'Swetlana', 'Sybilla', 'Sybille', 'Sylke', 'Sylvana', 'Sylvia', 'Sylvie', 'Sylwia', 'Tabea', 'Tamara', 'Tania', 'Tanja', 'Tatiana', 'Tatjana', 'Telse', 'Teresa', 'Thea', 'Theda', 'Thekla', 'Theodora', 'Theres', 'Theresa', 'Therese', 'Theresia', 'Tilly', 'Tina', 'Traude', 'Traudel', 'Traudl', 'Traute', 'Trude', 'Trudel', 'Trudi', 'Tülay', 'Türkan', 'Ulla', 'Ulrike', 'Undine', 'Ursel', 'Ursula', 'Urszula', 'Urte', 'Uschi', 'Uta', 'Ute', 'Valentina', 'Valentine', 'Valeri', 'Valeria', 'Valerie', 'Valeska', 'Vanessa', 'Vera', 'Verena', 'Veronica', 'Veronika', 'Veronique', 'Vesna', 'Victoria', 'Viktoria', 'Viola', 'Violetta', 'Virginia', 'Viviane', 'Walburga', 'Waldtraut', 'Walentina', 'Walli', 'Wally', 'Waltraud', 'Waltraut', 'Waltrud', 'Wanda', 'Wencke', 'Wendelin', 'Wenke', 'Wera', 'Wibke', 'Wiebke', 'Wilfriede', 'Wilhelmine', 'Wilma', 'Wiltrud', 'Xenia', 'Yasemin', 'Yasmin', 'Yvette', 'Yvonne', 'Zdenka', 'Zehra', 'Zenta', 'Zeynep', 'Zita', 'Zofia', ) first_names = first_names_male + first_names_female last_names = ( 'Ackermann', 'Adler', 'Adolph', 'Albers', 'Anders', 'Atzler', 'Aumann', 'Austermühle', 'Bachmann', 'Bähr', 'Bärer', 'Barkholz', 'Barth', 'Bauer', 'Baum', 'Becker', 'Beckmann', 'Beer', 'Beier', 'Bender', 'Benthin', 'Berger', 'Beyer', 'Bien', 'Biggen', 'Binner', 'Birnbaum', 'Bloch', 'Blümel', 'Bohlander', 'Bonbach', 'Bolander', 'Bolnbach', 'Bolzmann', 'Börner', 'Bohnbach', 'Boucsein', 'Briemer', 'Bruder', 'Buchholz', 'Budig', 'Butte', 'Carsten', 'Caspar', 'Christoph', 'Cichorius', 'Conradi', 'Davids', 'Dehmel', 'Dickhard', 'Dietz', 'Dippel', 'Ditschlerin', 'Dobes', 'Döhn', 'Döring', 'Dörr', 'Dörschner', 'Dowerg', 'Drewes', 'Drub', 'Drubin', 'Dussen van', 'Eberhardt', 'Ebert', 'Eberth', 'Eckbauer', 'Ehlert', 'Eigenwillig', 'Eimer', 'Ernst', 'Etzler', 'Etzold', 'Faust', 'Fechner', 'Fiebig', 'Finke', 'Fischer', 'Flantz', 'Fliegner', 'Förster', 'Franke', 'Freudenberger', 'Fritsch', 'Fröhlich', 'Gehringer', 'Geisel', 'Geisler', 'Geißler', 'Gerlach', 'Gertz', 'Gierschner', 'Gieß', 'Girschner', 'Gnatz', 'Gorlitz', 'Gotthard', 'Graf', 'Grein Groth', 'Gröttner', 'Gude', 'Gunpf', 'Gumprich', 'Gute', 'Gutknecht', 'Haase', 'Haering', 'Hänel', 'Häring', 'Hahn', 'Hamann', 'Hande', 'Harloff', 'Hartmann', 'Hartung', 'Hauffer', 'Hecker', 'Heidrich', 'Hein', 'Heinrich', 'Heintze', 'Heinz', 'Hellwig', 'Henck', 'Hendriks', 'Henk', 'Henschel', 'Hentschel', 'Hering', 'Hermann', 'Herrmann', 'Hermighausen', 'Hertrampf', 'Heser', 'Heß', 'Hesse', 'Hettner', 'Hethur', 'Heuser', 'Hiller', 'Heydrich', 'Höfig', 'Hofmann', 'Holsten', 'Holt', 'Holzapfel', 'Hölzenbecher', 'Hörle', 'Hövel', 'Hoffmann', 'Hornich', 'Hornig', 'Hübel', 'Huhn', 'Jacob', 'Jacobi Jäckel', 'Jähn', 'Jäkel', 'Jäntsch', 'Jessel', 'Jockel', 'Johann', 'Jopich', 'Junck', 'Juncken', 'Jungfer', 'Junitz', 'Junk', 'Junken', 'Jüttner', 'Kabus', 'Kade', 'Käster', 'Kallert', 'Kambs', 'Karge', 'Karz', 'Kaul', 'Kensy', 'Keudel', 'Killer', 'Kitzmann', 'Klapp', 'Klemm', 'Klemt', 'Klingelhöfer', 'Klotz', 'Knappe', 'Kobelt', 'Koch', 'Koch II', 'Köhler', 'Köster', 'Kohl', 'Kostolzin', 'Kramer', 'Kranz', 'Krause', 'Kraushaar', 'Krebs', 'Krein', 'Kreusel', 'Kroker', 'Kruschwitz', 'Kuhl', 'Kühnert', 'Kusch', 'Lachmann', 'Ladeck', 'Lange', 'Langern', 'Lehmann', 'Liebelt', 'Lindau', 'Lindner', 'Linke', 'Löchel', 'Löffler', 'Loos', 'Lorch', 'Losekann', 'Löwer', 'Lübs', 'Mälzer', 'Mangold', 'Mans', 'Margraf', 'Martin', 'Matthäi', 'Meister', 'Mende', 'Mentzel', 'Metz', 'Meyer', 'Mielcarek', 'Mies', 'Misicher', 'Mitschke', 'Mohaupt', 'Mosemann', 'Möchlichen', 'Mude', 'Mühle', 'Mülichen', 'Müller', 'Naser', 'Nerger', 'Nette', 'Neureuther', 'Neuschäfer', 'Niemeier', 'Noack', 'Nohlmans', 'Oderwald', 'Oestrovsky', 'Ortmann', 'Otto', 'Paffrath', 'Pärtzelt', 'Patberg', 'Pechel', 'Pergande', 'Peukert', 'Pieper', 'Plath', 'Pohl', 'Pölitz', 'Preiß', 'Pruschke', 'Putz', 'Rädel', 'Radisch', 'Reichmann', 'Reinhardt', 'Reising', 'Renner', 'Reuter', 'Riehl', 'Ring', 'Ritter', 'Rogge', 'Rogner', 'Rohleder', 'Röhrdanz', 'Röhricht', 'Roht', 'Römer', 'Rörricht', 'Rose', 'Rosemann', 'Rosenow', 'Roskoth', 'Rudolph', 'Ruppersberger', 'Ruppert', 'Rust', 'Sager', 'Salz', 'Säuberlich', 'Sauer', 'Schaaf', 'Schacht', 'Schäfer', 'Scheel', 'Scheibe', 'Schenk', 'Scheuermann', 'Schinke', 'Schleich', 'Schleich', 'auch Schlauchin', 'Schlosser', 'Schmidt', 'Schmidtke', 'Schmiedecke', 'Schmiedt', 'Schönland', 'Scholl', 'Scholtz', 'Scholz', 'Schomber', 'Schottin', 'Schuchhardt', 'Schüler', 'Schulz', 'Schuster', 'Schweitzer', 'Schwital', 'Segebahn', 'Seifert', 'Seidel', 'Seifert', 'Seip', 'Siering', 'Söding', 'Sölzer', 'Sontag', 'Sorgatz', 'Speer', 'Spieß', 'Stadelmann', 'Stahr', 'Staude', 'Steckel', 'Steinberg', 'Stey', 'Stiebitz', 'Stiffel', 'Stoll', 'Stolze', 'Striebitz', 'Stroh', 'Stumpf', 'Sucker', 'Süßebier', 'Täsche', 'Textor', 'Thanel', 'Thies', 'Tintzmann', 'Tlustek', 'Trapp', 'Trommler', 'Tröst', 'Trub', 'Trüb', 'Trubin', 'Trupp', 'Tschentscher', 'Ullmann', 'Ullrich', 'van der Dussen', 'Vogt', 'Vollbrecht', 'Wagenknecht', 'Wagner', 'Wähner', 'Walter', 'Warmer', 'Weihmann', 'Weimer', 'Weinhage', 'Weinhold', 'Weiß', 'Weitzel', 'Weller', 'Wende', 'Wernecke', 'Werner', 'Wesack', 'Wiek', 'Wieloch', 'Wilms', 'Wilmsen', 'Winkler', 'Wirth', 'Wohlgemut', 'Wulf', 'Wulff', 'Zahn', 'Zänker', 'Ziegert', 'Zimmer', 'Zirme', 'Zobel', 'Zorbach', ) prefixes_male = ( 'Herr', 'Dr.', 'Ing.', 'Dipl.-Ing.', 'Prof.', 'Univ.Prof.', ) prefixes_female = ( 'Frau', 'Dr.', 'Ing.', 'Dipl.-Ing.', 'Prof.', 'Univ.Prof.', ) suffixes = ('B.Sc.', 'B.A.', 'B.Eng.', 'MBA.', )
gpl-3.0
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2508, 492, 18489, 465, 8028, 6663, 421, 199, 533, 18489, 8, 7344, 6663, 304, 272, 6752, 275, 334, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 13, 3638, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 13, 3638, 2019, 63, 354, 29223, 267, 11400, 1861, 63, 17667, 4863, 8448, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 1861, 63, 771, 17667, 4863, 8448, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 1861, 63, 17667, 4863, 8448, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 1861, 63, 771, 17667, 4863, 8448, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 272, 776, 339, 327, 11606, 1455, 921, 271, 14, 5319, 296, 695, 14, 1308, 15, 6797, 15, 3673, 806, 1158, 26294, 26, 872, 14608, 335, 15, 44, 29729, 63, 424, 63, 72, 5, 35, 19, 5, 33, 20, 85, 5513, 724, 63, 77, 5, 35, 19, 5, 33, 20, 4411, 317, 24604, 63, 54, 269, 354, 78, 63, 872, 14608, 335, 31813, 272, 1642, 63, 1247, 63, 17667, 275, 334, 267, 283, 33, 2501, 305, 297, 283, 33, 3691, 348, 297, 283, 33, 3691, 348, 8093, 297, 283, 5583, 345, 10670, 297, 283, 5583, 5975, 297, 283, 33, 335, 1017, 297, 283, 33, 983, 297, 267, 283, 2767, 279, 12504, 297, 283, 32408, 297, 283, 33, 2264, 12504, 297, 283, 33, 23522, 297, 283, 33, 1117, 276, 297, 283, 2767, 18429, 297, 283, 33, 14038, 350, 297, 267, 283, 33, 72, 3594, 297, 283, 33, 72, 10207, 297, 283, 33, 1502, 297, 283, 2439, 13206, 297, 283, 2439, 12504, 297, 283, 2439, 605, 475, 297, 283, 2439, 1393, 297, 267, 283, 2439, 10205, 335, 84, 297, 283, 2439, 1117, 297, 283, 33, 274, 6080, 460, 285, 297, 283, 33, 274, 6080, 11438, 297, 283, 33, 274, 6080, 460, 82, 297, 283, 33, 274, 75, 261, 74, 297, 267, 283, 33, 2003, 460, 293, 297, 283, 33, 3113, 297, 283, 33, 3113, 11438, 297, 283, 33, 3113, 28547, 297, 283, 33, 3113, 460, 4796, 297, 283, 33, 274, 1845, 73, 297, 267, 283, 33, 274, 1845, 74, 297, 283, 33, 276, 297, 283, 33, 276, 4654, 297, 283, 33, 276, 265, 1152, 297, 283, 33, 276, 581, 297, 283, 33, 276, 30938, 297, 283, 6985, 297, 267, 283, 33, 320, 374, 297, 283, 33, 320, 588, 297, 283, 2439, 2676, 297, 283, 24566, 723, 297, 283, 2493, 1810, 305, 9207, 297, 283, 2493, 24504, 297, 283, 2493, 11318, 317, 297, 267, 283, 2493, 11318, 317, 74, 297, 283, 3325, 264, 297, 283, 3325, 264, 305, 297, 283, 3325, 850, 297, 283, 3325, 264, 73, 297, 283, 3325, 264, 74, 297, 283, 3325, 470, 297, 267, 283, 3325, 5257, 297, 283, 3325, 17885, 297, 283, 3325, 82, 806, 74, 297, 283, 3325, 82, 5741, 297, 283, 3325, 89, 297, 283, 2493, 303, 320, 297, 283, 2493, 5891, 77, 297, 267, 283, 33, 561, 23909, 297, 283, 2493, 266, 297, 283, 2493, 898, 89, 297, 283, 33, 29680, 297, 283, 31935, 265, 297, 283, 31935, 265, 10175, 297, 283, 31935, 265, 2308, 297, 267, 283, 31935, 265, 9207, 297, 283, 31935, 265, 73, 527, 297, 283, 33, 1932, 79, 11560, 297, 283, 26291, 12504, 297, 283, 33, 20546, 297, 283, 1596, 827, 297, 283, 1596, 977, 297, 267, 283, 1596, 977, 84, 297, 283, 1596, 685, 297, 283, 1596, 9914, 18906, 297, 283, 20498, 1017, 297, 283, 1596, 889, 297, 283, 20498, 1753, 297, 283, 1596, 4850, 276, 297, 267, 283, 1596, 273, 300, 297, 283, 1596, 16218, 297, 283, 33, 13797, 305, 9207, 297, 283, 1271, 280, 416, 297, 283, 21640, 833, 297, 283, 21640, 833, 262, 297, 283, 28000, 352, 297, 267, 283, 32171, 565, 297, 283, 13129, 30695, 297, 283, 34, 6130, 305, 285, 297, 283, 34, 439, 5011, 297, 283, 5281, 273, 79, 320, 77, 13733, 527, 297, 283, 34, 1810, 5653, 297, 267, 283, 29115, 5975, 297, 283, 3655, 75, 723, 297, 283, 34, 352, 65, 297, 283, 31231, 297, 283, 31231, 6297, 5973, 297, 283, 31231, 16997, 262, 297, 283, 31231, 889, 297, 267, 283, 3655, 16479, 297, 283, 24947, 78, 1005, 297, 283, 24947, 977, 297, 283, 24947, 977, 13, 1341, 69, 351, 297, 283, 24947, 977, 84, 297, 283, 24947, 9914, 18906, 297, 267, 283, 24947, 78, 8726, 297, 283, 24947, 343, 297, 283, 24947, 78, 3079, 297, 283, 34, 15299, 297, 283, 24947, 273, 1753, 297, 283, 34, 15299, 1753, 297, 267, 283, 24947, 1239, 77, 297, 283, 34, 723, 836, 297, 283, 34, 74, 14614, 11641, 297, 283, 34, 19657, 297, 283, 34, 974, 24863, 297, 283, 34, 269, 374, 297, 283, 34, 4648, 79, 297, 267, 283, 34, 18429, 297, 283, 34, 1065, 79, 297, 283, 34, 300, 346, 8726, 297, 283, 34, 300, 3561, 1005, 297, 283, 34, 300, 75, 1005, 297, 283, 34, 300, 75, 8726, 297, 267, 283, 34, 300, 75, 8726, 84, 297, 283, 6584, 79, 836, 79, 297, 283, 16034, 76, 297, 283 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2508, 492, 18489, 465, 8028, 6663, 421, 199, 533, 18489, 8, 7344, 6663, 304, 272, 6752, 275, 334, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 13, 3638, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 13, 3638, 2019, 63, 354, 29223, 267, 11400, 1861, 63, 17667, 4863, 8448, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 1861, 63, 771, 17667, 4863, 8448, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 29223, 267, 11400, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 1861, 63, 17667, 4863, 8448, 2246, 63, 354, 63, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 267, 11400, 1861, 63, 771, 17667, 4863, 8448, 2246, 63, 354, 63, 771, 17667, 4863, 8448, 2019, 63, 354, 4863, 8448, 4511, 29223, 272, 776, 339, 327, 11606, 1455, 921, 271, 14, 5319, 296, 695, 14, 1308, 15, 6797, 15, 3673, 806, 1158, 26294, 26, 872, 14608, 335, 15, 44, 29729, 63, 424, 63, 72, 5, 35, 19, 5, 33, 20, 85, 5513, 724, 63, 77, 5, 35, 19, 5, 33, 20, 4411, 317, 24604, 63, 54, 269, 354, 78, 63, 872, 14608, 335, 31813, 272, 1642, 63, 1247, 63, 17667, 275, 334, 267, 283, 33, 2501, 305, 297, 283, 33, 3691, 348, 297, 283, 33, 3691, 348, 8093, 297, 283, 5583, 345, 10670, 297, 283, 5583, 5975, 297, 283, 33, 335, 1017, 297, 283, 33, 983, 297, 267, 283, 2767, 279, 12504, 297, 283, 32408, 297, 283, 33, 2264, 12504, 297, 283, 33, 23522, 297, 283, 33, 1117, 276, 297, 283, 2767, 18429, 297, 283, 33, 14038, 350, 297, 267, 283, 33, 72, 3594, 297, 283, 33, 72, 10207, 297, 283, 33, 1502, 297, 283, 2439, 13206, 297, 283, 2439, 12504, 297, 283, 2439, 605, 475, 297, 283, 2439, 1393, 297, 267, 283, 2439, 10205, 335, 84, 297, 283, 2439, 1117, 297, 283, 33, 274, 6080, 460, 285, 297, 283, 33, 274, 6080, 11438, 297, 283, 33, 274, 6080, 460, 82, 297, 283, 33, 274, 75, 261, 74, 297, 267, 283, 33, 2003, 460, 293, 297, 283, 33, 3113, 297, 283, 33, 3113, 11438, 297, 283, 33, 3113, 28547, 297, 283, 33, 3113, 460, 4796, 297, 283, 33, 274, 1845, 73, 297, 267, 283, 33, 274, 1845, 74, 297, 283, 33, 276, 297, 283, 33, 276, 4654, 297, 283, 33, 276, 265, 1152, 297, 283, 33, 276, 581, 297, 283, 33, 276, 30938, 297, 283, 6985, 297, 267, 283, 33, 320, 374, 297, 283, 33, 320, 588, 297, 283, 2439, 2676, 297, 283, 24566, 723, 297, 283, 2493, 1810, 305, 9207, 297, 283, 2493, 24504, 297, 283, 2493, 11318, 317, 297, 267, 283, 2493, 11318, 317, 74, 297, 283, 3325, 264, 297, 283, 3325, 264, 305, 297, 283, 3325, 850, 297, 283, 3325, 264, 73, 297, 283, 3325, 264, 74, 297, 283, 3325, 470, 297, 267, 283, 3325, 5257, 297, 283, 3325, 17885, 297, 283, 3325, 82, 806, 74, 297, 283, 3325, 82, 5741, 297, 283, 3325, 89, 297, 283, 2493, 303, 320, 297, 283, 2493, 5891, 77, 297, 267, 283, 33, 561, 23909, 297, 283, 2493, 266, 297, 283, 2493, 898, 89, 297, 283, 33, 29680, 297, 283, 31935, 265, 297, 283, 31935, 265, 10175, 297, 283, 31935, 265, 2308, 297, 267, 283, 31935, 265, 9207, 297, 283, 31935, 265, 73, 527, 297, 283, 33, 1932, 79, 11560, 297, 283, 26291, 12504, 297, 283, 33, 20546, 297, 283, 1596, 827, 297, 283, 1596, 977, 297, 267, 283, 1596, 977, 84, 297, 283, 1596, 685, 297, 283, 1596, 9914, 18906, 297, 283, 20498, 1017, 297, 283, 1596, 889, 297, 283, 20498, 1753, 297, 283, 1596, 4850, 276, 297, 267, 283, 1596, 273, 300, 297, 283, 1596, 16218, 297, 283, 33, 13797, 305, 9207, 297, 283, 1271, 280, 416, 297, 283, 21640, 833, 297, 283, 21640, 833, 262, 297, 283, 28000, 352, 297, 267, 283, 32171, 565, 297, 283, 13129, 30695, 297, 283, 34, 6130, 305, 285, 297, 283, 34, 439, 5011, 297, 283, 5281, 273, 79, 320, 77, 13733, 527, 297, 283, 34, 1810, 5653, 297, 267, 283, 29115, 5975, 297, 283, 3655, 75, 723, 297, 283, 34, 352, 65, 297, 283, 31231, 297, 283, 31231, 6297, 5973, 297, 283, 31231, 16997, 262, 297, 283, 31231, 889, 297, 267, 283, 3655, 16479, 297, 283, 24947, 78, 1005, 297, 283, 24947, 977, 297, 283, 24947, 977, 13, 1341, 69, 351, 297, 283, 24947, 977, 84, 297, 283, 24947, 9914, 18906, 297, 267, 283, 24947, 78, 8726, 297, 283, 24947, 343, 297, 283, 24947, 78, 3079, 297, 283, 34, 15299, 297, 283, 24947, 273, 1753, 297, 283, 34, 15299, 1753, 297, 267, 283, 24947, 1239, 77, 297, 283, 34, 723, 836, 297, 283, 34, 74, 14614, 11641, 297, 283, 34, 19657, 297, 283, 34, 974, 24863, 297, 283, 34, 269, 374, 297, 283, 34, 4648, 79, 297, 267, 283, 34, 18429, 297, 283, 34, 1065, 79, 297, 283, 34, 300, 346, 8726, 297, 283, 34, 300, 3561, 1005, 297, 283, 34, 300, 75, 1005, 297, 283, 34, 300, 75, 8726, 297, 267, 283, 34, 300, 75, 8726, 84, 297, 283, 6584, 79, 836, 79, 297, 283, 16034, 76, 297, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
virgilio/timtec
forum/admin.py
7
1027
# -*- coding: utf-8 -*- from django.contrib import admin from django.forms import TextInput, Textarea from django.db import models from suit.admin import SortableTabularInline from models import Question, Answer, AnswerVote, QuestionVote class ModelAdmin(admin.ModelAdmin): formfield_overrides = { models.CharField: {'widget': TextInput(attrs={'class': 'span12'})}, models.TextField: {'widget': Textarea(attrs={'rows': 4, 'class': 'span12'})}, } class QuestionVoteInline(SortableTabularInline): model = QuestionVote sortable = 'id' extra = 1 class AnswerVoteInline(SortableTabularInline): model = AnswerVote sortable = 'id' extra = 1 class AnswerInline(SortableTabularInline): model = Answer sortable = 'id' extra = 1 class QuestionAdmin(ModelAdmin): inlines = (AnswerInline, QuestionVoteInline) class AnswerAdmin(ModelAdmin): inlines = (AnswerVoteInline,) admin.site.register(Question, QuestionAdmin) admin.site.register(Answer, AnswerAdmin)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 3351, 492, 4516, 3205, 12, 4516, 6789, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 504, 308, 4993, 14, 2113, 492, 16722, 461, 30187, 10307, 199, 199, 504, 1709, 492, 21421, 12, 30675, 12, 30675, 54, 1583, 12, 21421, 54, 1583, 421, 199, 533, 30093, 8, 2113, 14, 12976, 304, 272, 21388, 63, 12867, 275, 469, 267, 1709, 14, 2183, 26, 791, 3440, 356, 4516, 3205, 8, 3288, 3713, 533, 356, 283, 3751, 713, 3071, 1386, 267, 1709, 14, 6254, 26, 791, 3440, 356, 4516, 6789, 8, 3288, 3713, 3838, 356, 841, 12, 283, 533, 356, 283, 3751, 713, 3071, 1386, 272, 789, 421, 199, 533, 21421, 54, 1583, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 21421, 54, 1583, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 30675, 54, 1583, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 30675, 54, 1583, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 30675, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 30675, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 21421, 4880, 8, 12976, 304, 272, 29177, 275, 334, 19104, 10307, 12, 21421, 54, 1583, 10307, 9, 421, 199, 533, 30675, 4880, 8, 12976, 304, 272, 29177, 275, 334, 19104, 54, 1583, 10307, 4258, 421, 199, 2113, 14, 2124, 14, 2683, 8, 16778, 12, 21421, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 19104, 12, 30675, 4880, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 3351, 492, 4516, 3205, 12, 4516, 6789, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 504, 308, 4993, 14, 2113, 492, 16722, 461, 30187, 10307, 199, 199, 504, 1709, 492, 21421, 12, 30675, 12, 30675, 54, 1583, 12, 21421, 54, 1583, 421, 199, 533, 30093, 8, 2113, 14, 12976, 304, 272, 21388, 63, 12867, 275, 469, 267, 1709, 14, 2183, 26, 791, 3440, 356, 4516, 3205, 8, 3288, 3713, 533, 356, 283, 3751, 713, 3071, 1386, 267, 1709, 14, 6254, 26, 791, 3440, 356, 4516, 6789, 8, 3288, 3713, 3838, 356, 841, 12, 283, 533, 356, 283, 3751, 713, 3071, 1386, 272, 789, 421, 199, 533, 21421, 54, 1583, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 21421, 54, 1583, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 30675, 54, 1583, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 30675, 54, 1583, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 30675, 10307, 8, 14376, 461, 30187, 10307, 304, 272, 1402, 275, 30675, 272, 4069, 461, 275, 283, 344, 7, 272, 2402, 275, 413, 421, 199, 533, 21421, 4880, 8, 12976, 304, 272, 29177, 275, 334, 19104, 10307, 12, 21421, 54, 1583, 10307, 9, 421, 199, 533, 30675, 4880, 8, 12976, 304, 272, 29177, 275, 334, 19104, 54, 1583, 10307, 4258, 421, 199, 2113, 14, 2124, 14, 2683, 8, 16778, 12, 21421, 4880, 9, 199, 2113, 14, 2124, 14, 2683, 8, 19104, 12, 30675, 4880, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
archtool/archtool
src/gui/styles.py
1
12145
''' Created on Feb 15, 2014 @author: EHWAAL Copyright (C) 2014 Evert van de Waal This program is released under the conditions of the GNU General Public License. ''' # FIXME: Font names containing spaces are not handled properly. # TODO: Allow style export & import. Use that to initialise the database import re import model from util import Const from PyQt4 import QtGui, QtCore from json import loads import logging DEFAULT_COLOR = 'darkslateblue' DEFAULT_BACKGROUND = 'white' DEFAULT_FONT = 'Arial 12pt' NO_ICON = '---' class ArrowTypes(Const): START = 'start' END = 'end' class StyleTypes(Const): BOOL = 1 COLOR = 2 LINESTYLE = 3 ARROW = 4 HALIGN = 5 VALIGN = 6 FLOAT = 7 FONT = 8 XYCOOD = 9 CONNECTOR = 10 ICON = 11 class ConnectorTypes(Const): DIRECT = 1 SQUARED = 2 KNOWN_STYLEITEMS = {'halign' :StyleTypes.HALIGN, 'valign' :StyleTypes.VALIGN, 'font' :StyleTypes.FONT, 'color1' :StyleTypes.COLOR, 'color2' :StyleTypes.COLOR, 'background-color':StyleTypes.COLOR, 'color' :StyleTypes.COLOR, 'width' :StyleTypes.FLOAT, 'line' :StyleTypes.LINESTYLE, 'alpha' :StyleTypes.FLOAT, 'font' :StyleTypes.FONT, 'offset' :StyleTypes.XYCOOD, 'is_gradient' :StyleTypes.BOOL, 'end' :StyleTypes.ARROW, 'start' :StyleTypes.ARROW, 'constyle' :StyleTypes.CONNECTOR, 'icon' :StyleTypes.ICON } class StyledItem(object): ROLE = None def __init__(self, style, role, apply=True): self.style = style if isinstance(role, tuple): self.role, self.ROLE = role else: self.role = role @property def stereotype(self): item = self while True: if hasattr(item, 'ROLE'): return item.ROLE if item.parent(): item = item.parent() continue return None @property def full_role(self): if self.ROLE and self.role: return '%s-%s'%(self.role, self.ROLE) if self.role is not None: return self.role elif self.ROLE: return self.ROLE return '' def setRole(self, role): self.role = role self.applyStyle() def applyStyle(self): raise NotImplementedError() def getBool(text): ''' Convert a text to a boolean value ''' if text is None: return False return text.lower() in ['y', 'j', 'ja', 'yes', '1', 'true'] def getFont(text): fname = 'arial' size = 12 italic = False weight = 1 underline = False strikeout = False for pt in [f.strip().lower() for f in text.split()]: if pt == 'bold': weight = 3 elif pt == 'italic': italic = True elif pt.endswith('pt'): size = int(pt[:-2]) elif pt == 'underline': underline = True elif pt == 'strikeout': strikeout = True else: fname = pt font = QtGui.QFont(fname, size, weight, italic) font.setUnderline(underline) font.setStrikeOut(strikeout) return font def getItemType(item): type_name = item.split('-')[-1] return KNOWN_STYLEITEMS[type_name] class Observable(object): ''' An object which keeps track of which object is currently being styled. Supports the observer pattern ''' def __init__(self): self.subject = None self.listners = [] def set(self, object): self.subject = object for listner in self.listners: try: listner(object) except: logging.exception('Exception when calling observer') def get(self): return self.subject def subscribe(self, listner): if not listner in self.listners: self.listners.append(listner) def unsubscribe(self, listner): while listner in self.listners: self.listners.remove(listner) class Style(Observable): PART_SEP = '-' # Separates parts of a name. qt = QtCore.Qt linestyles = dict(solid=QtCore.Qt.SolidLine, dashed=QtCore.Qt.DashLine, dotted=QtCore.Qt.DotLine) halignopts = {'left': qt.AlignLeft, 'right': qt.AlignRight, 'center': qt.AlignHCenter} valignopts = {'top': qt.AlignTop, 'bottom': qt.AlignBottom, 'center': qt.AlignVCenter} current_object = Observable() # List of QGraphicsItems current_style = Observable() def __init__(self, details): Observable.__init__(self) self.details = details self.requested_keys = set() self.reloadDetails() def requestedItems(self, stereotype): pattern = '[A-Za-z0-9_\-]*%s-([A-Za-z0-9_\-]*)'%stereotype all_keys = '\n'.join(self.requested_keys) results = re.findall(pattern, all_keys) results = sorted(set(results)) return results def reloadDetails(self): pairs = self.details.Details.split(';') test = [d.split(':') for d in pairs] test = [d for d in test if len(d)==2] self.items = {key.strip():value.strip() for key, value in test} self.set(self.items) def setItem(self, role, stereotype, value): self.items['%s-%s'%(role, stereotype)] = value all_items = [':'.join(p) for p in self.items.items()] self.details.Details = ';\n'.join(sorted(all_items)) self.set(self.items) def findApplicableRoles(self, stereotype): pattern = '([A-Za-z0-9_\-]*)-%s-[A-Za-z0-9_]*'%stereotype all_keys = '\n'.join(self.items.keys()) results = re.findall(pattern, all_keys) return list(set(results)) def findItem(self, name, postfix): # Final part must be the 'postfix' if postfix and not name.endswith(postfix): name = '-'.join([name, postfix]) self.requested_keys.add(name) # The name consists of parts separated by dashes. parts = name.split('-') while parts: # if a name is not present, try a less specific one. try_name = '-'.join(parts) if try_name not in self.items: parts.pop(0) continue return self.items[try_name] return None def getColor(self, name): color = self.findItem(name, 'color') or DEFAULT_COLOR return QtGui.QColor(color) def getLineStyle(self, name): linestyle = self.findItem(name, 'line') or 'solid' return self.linestyles[linestyle] def getLineWidth(self, name): return int(self.findItem(name, 'width')) or 3 def getBrush(self, name): # Get the gradient is_gradient = getBool(self.findItem(name, 'is_gradient')) col1 = self.findItem(name, 'color1') or DEFAULT_BACKGROUND col2 = self.findItem(name, 'color2') or col1 color = self.findItem(name, 'background-color') or DEFAULT_BACKGROUND alpha = self.findItem(name, 'alpha') or '1.0' if is_gradient: Gradient = QtGui.QLinearGradient(0, 0, 100, 100) col1 = QtGui.QColor(col1) col2 = QtGui.QColor(col2) col1.setAlphaF(float(alpha)) col2.setAlphaF(float(alpha)) Gradient.setColorAt(0, col1) Gradient.setColorAt(1, col2) return QtGui.QBrush(Gradient) else: col = QtGui.QColor(color) col.setAlphaF(float(alpha)) return QtGui.QBrush(col) def getPen(self, name): color = self.getColor(name) style = self.getLineStyle(name) width = self.getLineWidth(name) return QtGui.QPen(color, width, style, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin) def getVAlign(self, name): align = self.findItem(name, 'valign') or 'center' return self.valignopts[align.lower()] def getHAlign(self, name): align = self.findItem(name, 'halign') or 'center' return self.halignopts[align.lower()] def getFont(self, name): ''' Font details are given in a space-separated list, e.g. "Arial bold 14pt" ''' font = self.findItem(name, 'font') or DEFAULT_FONT return getFont(font) def getArrow(self, name, arrow_type): ''' Returns the polygon object to be used for the arrow, or None. Location is either ''' points = self.findItem(name, arrow_type) if not points: return points = loads(points) points = [QtCore.QPointF(*p) for p in points] return QtGui.QPolygonF(points) def getOffset(self, name, default): ''' Returns a QPointF that can be used as an offset. ''' offset = self.findItem(name, 'offset') offset = loads(offset) if offset else default return QtCore.QPointF(*offset) def getFloat(self, name, default=0.0): ''' Returns a single floating point number ''' f = self.findItem(name, None) return float(f) if f else default def getIcon(self, name): """ Return a pixmap object, or None. """ icon = self.findItem(name, 'icon') if icon and icon != NO_ICON: session = Styles.style_sheet.session records = session.query(model.Icon).filter(model.Icon.Name == icon).all() if records: record = records[0] pixmap = QtGui.QPixmap() pixmap.loadFromData(record.Data) return pixmap def createDefaultStyle(session): with model.sessionScope(session): default = session.query(model.Style).filter(model.Style.Name=='Default').first() if not default: default = model.Style(Name='Default') session.add(default) default.Details = ''' background-color:white; font:Arial 12pt; halign:center; valign:center; is_gradient:True; color:#00529c; color1:white; color2:#00529c; text-is_gradient:False; icon:None; functionpoint-is_gradient:False; functionpoint-alpha:1.0; functionpoint-end:[[0,0], [-5, 5], [0, 0], [-5, -5], [0,0]]; arrow-functionpoint-offset:[-10,10]; connection-text-alpha:1.0; annotation-color2:#ffef5d; annotation-text-alpha:0.0; usecase-color2:#ff6347; usecase-text-alpha:0.0; width:3; archblock-width:1; archblock-offset:[0,0]; archblock-text-alpha:0.0; white-archblock-color2:white; dark-archblock-color2:#f2f2f2; type3-archblock-color2:#838383; time-archblock-color2:#ffc0cb; description-archblock-color2:#add8e6; party-archblock-color2:#90ee90; role-archblock-color2:#ffff80; inheritance-connection-end:[[0,0], [-10,10], [-10,-10], [0,0]]; aggregation-connection-start:[[0,0], [-10,-10], [-20,0], [-10,10], [0,0]]; association-connection-end:[[0,0],[-10,10],[0,0],[-10,-10],[0,0]]; ''' return default class Styles(object): style_sheet = None def __init__(self, session): self.session = session style_defs = session.query(model.Style).all() if len(style_defs) == 0: style_defs = [createDefaultStyle(session)] self.styles = [Style(d) for d in style_defs] self.style_names = {d.Name:s for d, s in zip(style_defs, self.styles)} self.style_ids = {d.Id:s for d, s in zip(style_defs, self.styles)} def getStyle(self, name): ''' Name can either be a number, refering to the Id of the style, or a string (the name). ''' if name is None: return self.style_names['Default'] if isinstance(name, basestring): return self.style_names[name] return self.style_ids[name] @staticmethod def load(session): ''' Load the styles from the database ''' Styles.style_sheet = Styles(session) def run(): d = model.Style(Details='background-color : yellow; color:blue; ') if __name__ == '__main__': run()
gpl-3.0
[ 2344, 202, 199, 10502, 641, 21141, 4114, 12, 6927, 2999, 199, 32, 2502, 26, 662, 40, 9004, 748, 2999, 199, 7384, 334, 35, 9, 6927, 662, 1884, 20744, 477, 644, 65, 279, 202, 199, 2765, 2240, 365, 14286, 1334, 314, 3704, 402, 314, 1664, 1696, 1684, 844, 14, 202, 199, 2344, 2999, 199, 3, 7600, 26, 26159, 1561, 3035, 7883, 787, 440, 8860, 7684, 14, 202, 199, 3, 3254, 26, 9812, 3449, 4843, 1253, 492, 14, 3645, 626, 370, 2536, 572, 314, 3050, 2999, 199, 646, 295, 202, 199, 646, 1402, 202, 199, 504, 4884, 492, 13435, 202, 199, 504, 14084, 20, 492, 5928, 12, 10565, 202, 199, 504, 2022, 492, 14404, 202, 199, 646, 2050, 2999, 199, 3472, 63, 7134, 420, 275, 283, 13625, 83, 750, 6304, 7, 202, 199, 3472, 63, 7111, 29497, 275, 283, 7510, 7, 202, 199, 3472, 63, 18398, 755, 275, 283, 33, 1383, 3144, 541, 7, 2999, 199, 2826, 63, 15903, 275, 283, 2595, 7, 2999, 199, 533, 1952, 1143, 4100, 8, 6361, 304, 10292, 13910, 275, 283, 928, 7, 10292, 7729, 257, 275, 283, 500, 7, 15497, 2999, 199, 533, 19442, 4100, 8, 6361, 304, 10292, 25849, 420, 275, 413, 10292, 13513, 726, 258, 275, 499, 10292, 491, 568, 1719, 57, 906, 275, 650, 10292, 4160, 11415, 258, 275, 841, 10292, 869, 15255, 259, 275, 959, 10292, 8986, 3203, 259, 275, 1227, 10292, 31241, 258, 275, 1520, 10292, 481, 5994, 420, 275, 1695, 10292, 1323, 57, 1439, 22041, 259, 275, 1749, 10292, 1868, 6930, 726, 275, 1616, 10292, 473, 1864, 420, 275, 4119, 8065, 199, 533, 13482, 2406, 4100, 8, 6361, 304, 10292, 8703, 221, 275, 413, 10292, 428, 2328, 689, 1149, 275, 499, 8065, 199, 20004, 63, 18466, 10439, 51, 275, 791, 72, 5743, 7, 3515, 520, 6609, 4100, 14, 40, 15255, 12, 4906, 283, 637, 1030, 7, 3515, 520, 6609, 4100, 14, 3204, 3203, 12, 4906, 283, 4246, 7, 3322, 520, 6609, 4100, 14, 18398, 12, 4906, 283, 2326, 17, 7, 3515, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 2326, 18, 7, 3515, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 7451, 13, 2326, 356, 6609, 4100, 14, 7134, 12, 4906, 283, 2326, 7, 3698, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 2063, 7, 3698, 520, 6609, 4100, 14, 11783, 12, 4906, 283, 604, 7, 3322, 520, 6609, 4100, 14, 6143, 1719, 57, 906, 12, 4906, 283, 4468, 7, 3698, 520, 6609, 4100, 14, 11783, 12, 4906, 283, 4246, 7, 3322, 520, 6609, 4100, 14, 18398, 12, 4906, 283, 2743, 7, 3515, 520, 6609, 4100, 14, 8195, 1439, 22041, 12, 4906, 283, 374, 63, 7490, 7, 258, 520, 6609, 4100, 14, 16026, 12, 4906, 283, 500, 7, 3777, 520, 6609, 4100, 14, 689, 11415, 12, 4906, 283, 928, 7, 3698, 520, 6609, 4100, 14, 689, 11415, 12, 4906, 283, 1297, 1775, 7, 263, 520, 6609, 4100, 14, 14657, 726, 12, 4906, 283, 4677, 7, 3322, 520, 6609, 4100, 14, 15903, 202, 673, 789, 8065, 199, 533, 428, 369, 1146, 2081, 8, 785, 304, 10292, 9769, 906, 275, 488, 10292, 347, 636, 826, 721, 277, 12, 3449, 12, 4719, 12, 4838, 29, 549, 304, 1128, 291, 14, 2487, 275, 3449, 1128, 340, 1228, 8, 3756, 12, 2008, 304, 8608, 291, 14, 3756, 12, 291, 14, 15468, 275, 4719, 1128, 587, 26, 8608, 291, 14, 3756, 275, 4719, 10292, 768, 1829, 10292, 347, 20345, 264, 7818, 8, 277, 304, 1128, 1242, 275, 291, 1128, 1830, 715, 26, 8608, 340, 2688, 8, 1053, 12, 283, 15468, 735, 1039, 372, 1242, 14, 15468, 8608, 340, 1242, 14, 1708, 837, 1039, 1242, 275, 1242, 14, 1708, 342, 1039, 1980, 8608, 372, 488, 8740, 10292, 768, 1829, 10292, 347, 2615, 63, 3756, 8, 277, 304, 1128, 340, 291, 14, 15468, 436, 291, 14, 3756, 26, 8608, 372, 1543, 83, 3295, 83, 13328, 277, 14, 3756, 12, 291, 14, 15468, 9, 1128, 340, 291, 14, 3756, 365, 440, 488, 26, 8608, 372, 291, 14, 3756, 1128, 916, 291, 14, 15468, 26, 8608, 372, 291, 14, 15468, 1128, 372, 2125, 10292, 347, 663, 7422, 8, 277, 12, 4719, 304, 1128, 291, 14, 3756, 275, 4719, 1128, 291, 14, 4998, 6609, 342, 10292, 347, 4838, 6609, 8, 277, 304, 1128, 746, 4279, 342, 1223, 8065, 199, 318, 664, 10349, 8, 505, 304, 10292, 1449, 7905, 282, 1318, 370, 282, 5046, 574, 1449, 10292, 340, 1318, 365, 488, 26, 1128, 372, 756, 10292, 372, 1318, 14, 2325, 342, 315, 788, 89, 297, 283, 74, 297, 283, 3387, 297, 283, 5066, 297, 283, 17, 297, 283, 2052, 418, 2999, 199, 318, 664, 6986, 8, 505, 304, 10292, 6748, 275, 283, 759, 279, 7, 10292, 1568, 275, 3144, 10292, 652, 17999, 275, 756, 10292, 5401, 275, 413, 10292, 25735, 275, 756, 10292, 4024, 415, 548, 275, 756, 10292, 367, 10063, 315, 359, 70, 14, 1913, 1252, 2325, 342, 367, 289, 315, 1318, 14, 1294, 342, 2189, 1128, 340, 10063, 508, 283, 9771, 356, 8608, 5401, 275, 650, 1128, 916, 10063, 508, 283, 21843, 356, 8608, 652, 17999, 275, 715, 1128, 916, 10063, 14, 4130, 360, 541, 735, 8608, 1568, 275, 1109, 8, 541, 4439, 18, 566, 1128, 916, 10063, 508, 283, 24396, 356, 8608, 25735, 275, 715, 1128, 916, 10063, 508, 283, 26845, 548, 356, 8608, 4024, 415, 548, 275, 715, 1128, 587, 26, 8608, 6748, 275, 10063, 10292, 5023, 275, 5928, 14, 49, 6986, 8, 5252, 12, 1568, 12, 5401, 12, 652, 17999, 9, 10292, 5023, 14, 409, 16001, 604, 8, 24396, 9, 10292, 5023, 14, 409, 24125, 415, 2204, 8, 26845, 548, 9, 10292, 372, 5023, 15497, 202, 199, 318, 664, 2081, 804, 8, 1053, 304, 10292, 730, 63, 354, 275, 1242, 14, 1294, 21950, 1988, 17, 61, 10292, 372, 1804, 9165, 63, 18466, 10439, 51, 59, 466, 63, 354, 61, 2999, 199, 533, 17985, 29454, 8, 785, 304, 10292, 1449, 1626, 909, 1314, 18578, 4426, 402, 1314, 909, 365, 5544, 3769, 32468, 1146, 14, 221, 8608, 32090, 314, 27336, 3851, 10292, 1449, 10292, 347, 636, 826, 721, 277, 304, 1128, 291, 14, 5875, 275, 488, 1128, 291, 14, 513, 8715, 257, 275, 942, 10292, 347, 663, 8, 277, 12, 909, 304, 1128 ]
[ 202, 199, 10502, 641, 21141, 4114, 12, 6927, 2999, 199, 32, 2502, 26, 662, 40, 9004, 748, 2999, 199, 7384, 334, 35, 9, 6927, 662, 1884, 20744, 477, 644, 65, 279, 202, 199, 2765, 2240, 365, 14286, 1334, 314, 3704, 402, 314, 1664, 1696, 1684, 844, 14, 202, 199, 2344, 2999, 199, 3, 7600, 26, 26159, 1561, 3035, 7883, 787, 440, 8860, 7684, 14, 202, 199, 3, 3254, 26, 9812, 3449, 4843, 1253, 492, 14, 3645, 626, 370, 2536, 572, 314, 3050, 2999, 199, 646, 295, 202, 199, 646, 1402, 202, 199, 504, 4884, 492, 13435, 202, 199, 504, 14084, 20, 492, 5928, 12, 10565, 202, 199, 504, 2022, 492, 14404, 202, 199, 646, 2050, 2999, 199, 3472, 63, 7134, 420, 275, 283, 13625, 83, 750, 6304, 7, 202, 199, 3472, 63, 7111, 29497, 275, 283, 7510, 7, 202, 199, 3472, 63, 18398, 755, 275, 283, 33, 1383, 3144, 541, 7, 2999, 199, 2826, 63, 15903, 275, 283, 2595, 7, 2999, 199, 533, 1952, 1143, 4100, 8, 6361, 304, 10292, 13910, 275, 283, 928, 7, 10292, 7729, 257, 275, 283, 500, 7, 15497, 2999, 199, 533, 19442, 4100, 8, 6361, 304, 10292, 25849, 420, 275, 413, 10292, 13513, 726, 258, 275, 499, 10292, 491, 568, 1719, 57, 906, 275, 650, 10292, 4160, 11415, 258, 275, 841, 10292, 869, 15255, 259, 275, 959, 10292, 8986, 3203, 259, 275, 1227, 10292, 31241, 258, 275, 1520, 10292, 481, 5994, 420, 275, 1695, 10292, 1323, 57, 1439, 22041, 259, 275, 1749, 10292, 1868, 6930, 726, 275, 1616, 10292, 473, 1864, 420, 275, 4119, 8065, 199, 533, 13482, 2406, 4100, 8, 6361, 304, 10292, 8703, 221, 275, 413, 10292, 428, 2328, 689, 1149, 275, 499, 8065, 199, 20004, 63, 18466, 10439, 51, 275, 791, 72, 5743, 7, 3515, 520, 6609, 4100, 14, 40, 15255, 12, 4906, 283, 637, 1030, 7, 3515, 520, 6609, 4100, 14, 3204, 3203, 12, 4906, 283, 4246, 7, 3322, 520, 6609, 4100, 14, 18398, 12, 4906, 283, 2326, 17, 7, 3515, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 2326, 18, 7, 3515, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 7451, 13, 2326, 356, 6609, 4100, 14, 7134, 12, 4906, 283, 2326, 7, 3698, 520, 6609, 4100, 14, 7134, 12, 4906, 283, 2063, 7, 3698, 520, 6609, 4100, 14, 11783, 12, 4906, 283, 604, 7, 3322, 520, 6609, 4100, 14, 6143, 1719, 57, 906, 12, 4906, 283, 4468, 7, 3698, 520, 6609, 4100, 14, 11783, 12, 4906, 283, 4246, 7, 3322, 520, 6609, 4100, 14, 18398, 12, 4906, 283, 2743, 7, 3515, 520, 6609, 4100, 14, 8195, 1439, 22041, 12, 4906, 283, 374, 63, 7490, 7, 258, 520, 6609, 4100, 14, 16026, 12, 4906, 283, 500, 7, 3777, 520, 6609, 4100, 14, 689, 11415, 12, 4906, 283, 928, 7, 3698, 520, 6609, 4100, 14, 689, 11415, 12, 4906, 283, 1297, 1775, 7, 263, 520, 6609, 4100, 14, 14657, 726, 12, 4906, 283, 4677, 7, 3322, 520, 6609, 4100, 14, 15903, 202, 673, 789, 8065, 199, 533, 428, 369, 1146, 2081, 8, 785, 304, 10292, 9769, 906, 275, 488, 10292, 347, 636, 826, 721, 277, 12, 3449, 12, 4719, 12, 4838, 29, 549, 304, 1128, 291, 14, 2487, 275, 3449, 1128, 340, 1228, 8, 3756, 12, 2008, 304, 8608, 291, 14, 3756, 12, 291, 14, 15468, 275, 4719, 1128, 587, 26, 8608, 291, 14, 3756, 275, 4719, 10292, 768, 1829, 10292, 347, 20345, 264, 7818, 8, 277, 304, 1128, 1242, 275, 291, 1128, 1830, 715, 26, 8608, 340, 2688, 8, 1053, 12, 283, 15468, 735, 1039, 372, 1242, 14, 15468, 8608, 340, 1242, 14, 1708, 837, 1039, 1242, 275, 1242, 14, 1708, 342, 1039, 1980, 8608, 372, 488, 8740, 10292, 768, 1829, 10292, 347, 2615, 63, 3756, 8, 277, 304, 1128, 340, 291, 14, 15468, 436, 291, 14, 3756, 26, 8608, 372, 1543, 83, 3295, 83, 13328, 277, 14, 3756, 12, 291, 14, 15468, 9, 1128, 340, 291, 14, 3756, 365, 440, 488, 26, 8608, 372, 291, 14, 3756, 1128, 916, 291, 14, 15468, 26, 8608, 372, 291, 14, 15468, 1128, 372, 2125, 10292, 347, 663, 7422, 8, 277, 12, 4719, 304, 1128, 291, 14, 3756, 275, 4719, 1128, 291, 14, 4998, 6609, 342, 10292, 347, 4838, 6609, 8, 277, 304, 1128, 746, 4279, 342, 1223, 8065, 199, 318, 664, 10349, 8, 505, 304, 10292, 1449, 7905, 282, 1318, 370, 282, 5046, 574, 1449, 10292, 340, 1318, 365, 488, 26, 1128, 372, 756, 10292, 372, 1318, 14, 2325, 342, 315, 788, 89, 297, 283, 74, 297, 283, 3387, 297, 283, 5066, 297, 283, 17, 297, 283, 2052, 418, 2999, 199, 318, 664, 6986, 8, 505, 304, 10292, 6748, 275, 283, 759, 279, 7, 10292, 1568, 275, 3144, 10292, 652, 17999, 275, 756, 10292, 5401, 275, 413, 10292, 25735, 275, 756, 10292, 4024, 415, 548, 275, 756, 10292, 367, 10063, 315, 359, 70, 14, 1913, 1252, 2325, 342, 367, 289, 315, 1318, 14, 1294, 342, 2189, 1128, 340, 10063, 508, 283, 9771, 356, 8608, 5401, 275, 650, 1128, 916, 10063, 508, 283, 21843, 356, 8608, 652, 17999, 275, 715, 1128, 916, 10063, 14, 4130, 360, 541, 735, 8608, 1568, 275, 1109, 8, 541, 4439, 18, 566, 1128, 916, 10063, 508, 283, 24396, 356, 8608, 25735, 275, 715, 1128, 916, 10063, 508, 283, 26845, 548, 356, 8608, 4024, 415, 548, 275, 715, 1128, 587, 26, 8608, 6748, 275, 10063, 10292, 5023, 275, 5928, 14, 49, 6986, 8, 5252, 12, 1568, 12, 5401, 12, 652, 17999, 9, 10292, 5023, 14, 409, 16001, 604, 8, 24396, 9, 10292, 5023, 14, 409, 24125, 415, 2204, 8, 26845, 548, 9, 10292, 372, 5023, 15497, 202, 199, 318, 664, 2081, 804, 8, 1053, 304, 10292, 730, 63, 354, 275, 1242, 14, 1294, 21950, 1988, 17, 61, 10292, 372, 1804, 9165, 63, 18466, 10439, 51, 59, 466, 63, 354, 61, 2999, 199, 533, 17985, 29454, 8, 785, 304, 10292, 1449, 1626, 909, 1314, 18578, 4426, 402, 1314, 909, 365, 5544, 3769, 32468, 1146, 14, 221, 8608, 32090, 314, 27336, 3851, 10292, 1449, 10292, 347, 636, 826, 721, 277, 304, 1128, 291, 14, 5875, 275, 488, 1128, 291, 14, 513, 8715, 257, 275, 942, 10292, 347, 663, 8, 277, 12, 909, 304, 1128, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
malelew/UCLA_Dining_Web_App
ENV/lib/python2.7/site-packages/pip/_vendor/lockfile/symlinklockfile.py
487
2613
from __future__ import absolute_import import time import os from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout, AlreadyLocked) class SymlinkLockFile(LockBase): """Lock access to a file using symlink(2).""" def __init__(self, path, threaded=True, timeout=None): # super(SymlinkLockFile).__init(...) LockBase.__init__(self, path, threaded, timeout) # split it back! self.unique_name = os.path.split(self.unique_name)[1] def acquire(self, timeout=None): # Hopefully unnecessary for symlink. #try: # open(self.unique_name, "wb").close() #except IOError: # raise LockFailed("failed to create %s" % self.unique_name) timeout = timeout is not None and timeout or self.timeout end_time = time.time() if timeout is not None and timeout > 0: end_time += timeout while True: # Try and create a symbolic link to it. try: os.symlink(self.unique_name, self.lock_file) except OSError: # Link creation failed. Maybe we've double-locked? if self.i_am_locking(): # Linked to out unique name. Proceed. return else: # Otherwise the lock creation failed. if timeout is not None and time.time() > end_time: if timeout > 0: raise LockTimeout("Timeout waiting to acquire" " lock for %s" % self.path) else: raise AlreadyLocked("%s is already locked" % self.path) time.sleep(timeout/10 if timeout is not None else 0.1) else: # Link creation succeeded. We're good to go. return def release(self): if not self.is_locked(): raise NotLocked("%s is not locked" % self.path) elif not self.i_am_locking(): raise NotMyLock("%s is locked, but not by me" % self.path) os.unlink(self.lock_file) def is_locked(self): return os.path.islink(self.lock_file) def i_am_locking(self): return os.path.islink(self.lock_file) and \ os.readlink(self.lock_file) == self.unique_name def break_lock(self): if os.path.islink(self.lock_file): # exists && link os.unlink(self.lock_file)
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 646, 747, 199, 199, 504, 1275, 492, 334, 6432, 1563, 12, 15536, 4276, 12, 2832, 22408, 12, 2832, 5713, 6432, 12, 15536, 6372, 12, 2049, 21086, 22408, 9, 199, 199, 533, 21478, 1073, 6432, 1173, 8, 6432, 1563, 304, 272, 408, 6432, 2879, 370, 282, 570, 1808, 15296, 8, 18, 10477, 339, 347, 636, 826, 721, 277, 12, 931, 12, 25396, 29, 549, 12, 2653, 29, 403, 304, 267, 327, 1613, 8, 16594, 1073, 6432, 1173, 2843, 826, 20186, 267, 15536, 1563, 855, 826, 721, 277, 12, 931, 12, 25396, 12, 2653, 9, 267, 327, 3715, 652, 1771, 1, 267, 291, 14, 3235, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 277, 14, 3235, 63, 354, 2788, 17, 61, 339, 347, 16919, 8, 277, 12, 2653, 29, 403, 304, 267, 327, 869, 13458, 5836, 23361, 367, 15296, 14, 267, 327, 893, 26, 267, 327, 259, 1551, 8, 277, 14, 3235, 63, 354, 12, 298, 6603, 3471, 1600, 342, 267, 327, 2590, 5925, 26, 267, 327, 259, 746, 15536, 4276, 480, 4892, 370, 1218, 450, 83, 2, 450, 291, 14, 3235, 63, 354, 9, 267, 2653, 275, 2653, 365, 440, 488, 436, 2653, 503, 291, 14, 2593, 267, 1284, 63, 521, 275, 900, 14, 521, 342, 267, 340, 2653, 365, 440, 488, 436, 2653, 690, 378, 26, 288, 1284, 63, 521, 847, 2653, 398, 1830, 715, 26, 288, 327, 7649, 436, 1218, 282, 13673, 2142, 370, 652, 14, 288, 862, 26, 355, 747, 14, 13380, 8, 277, 14, 3235, 63, 354, 12, 291, 14, 831, 63, 493, 9, 288, 871, 6440, 26, 355, 327, 10967, 7143, 3405, 14, 221, 23038, 781, 9064, 4270, 13, 9325, 31, 355, 340, 291, 14, 73, 63, 455, 63, 24056, 837, 490, 327, 10967, 379, 370, 734, 3747, 536, 14, 2165, 15648, 14, 490, 372, 355, 587, 26, 490, 327, 6630, 314, 4650, 7143, 3405, 14, 490, 340, 2653, 365, 440, 488, 436, 900, 14, 521, 342, 690, 1284, 63, 521, 26, 717, 340, 2653, 690, 378, 26, 1169, 746, 15536, 6372, 480, 6372, 10923, 370, 16919, 2, 6343, 298, 4650, 367, 450, 83, 2, 450, 6343, 291, 14, 515, 9, 717, 587, 26, 1169, 746, 21086, 22408, 3647, 83, 365, 2575, 14233, 2, 450, 6059, 291, 14, 515, 9, 490, 900, 14, 4532, 8, 2593, 15, 709, 340, 2653, 365, 440, 488, 587, 378, 14, 17, 9, 288, 587, 26, 355, 327, 10967, 7143, 19268, 14, 221, 2136, 3984, 6954, 370, 2621, 14, 355, 372, 339, 347, 4683, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 9325, 837, 288, 746, 2832, 22408, 3647, 83, 365, 440, 14233, 2, 450, 291, 14, 515, 9, 267, 916, 440, 291, 14, 73, 63, 455, 63, 24056, 837, 288, 746, 2832, 5713, 6432, 3647, 83, 365, 14233, 12, 1325, 440, 701, 562, 2, 450, 291, 14, 515, 9, 267, 747, 14, 7162, 8, 277, 14, 831, 63, 493, 9, 339, 347, 365, 63, 9325, 8, 277, 304, 267, 372, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 9, 339, 347, 284, 63, 455, 63, 24056, 8, 277, 304, 267, 372, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 9, 436, 971, 268, 747, 14, 31654, 8, 277, 14, 831, 63, 493, 9, 508, 291, 14, 3235, 63, 354, 339, 347, 2059, 63, 831, 8, 277, 304, 267, 340, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 304, 221, 327, 3495, 10883, 2142, 288, 747, 14, 7162, 8, 277, 14, 831, 63, 493, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 646, 747, 199, 199, 504, 1275, 492, 334, 6432, 1563, 12, 15536, 4276, 12, 2832, 22408, 12, 2832, 5713, 6432, 12, 15536, 6372, 12, 2049, 21086, 22408, 9, 199, 199, 533, 21478, 1073, 6432, 1173, 8, 6432, 1563, 304, 272, 408, 6432, 2879, 370, 282, 570, 1808, 15296, 8, 18, 10477, 339, 347, 636, 826, 721, 277, 12, 931, 12, 25396, 29, 549, 12, 2653, 29, 403, 304, 267, 327, 1613, 8, 16594, 1073, 6432, 1173, 2843, 826, 20186, 267, 15536, 1563, 855, 826, 721, 277, 12, 931, 12, 25396, 12, 2653, 9, 267, 327, 3715, 652, 1771, 1, 267, 291, 14, 3235, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 277, 14, 3235, 63, 354, 2788, 17, 61, 339, 347, 16919, 8, 277, 12, 2653, 29, 403, 304, 267, 327, 869, 13458, 5836, 23361, 367, 15296, 14, 267, 327, 893, 26, 267, 327, 259, 1551, 8, 277, 14, 3235, 63, 354, 12, 298, 6603, 3471, 1600, 342, 267, 327, 2590, 5925, 26, 267, 327, 259, 746, 15536, 4276, 480, 4892, 370, 1218, 450, 83, 2, 450, 291, 14, 3235, 63, 354, 9, 267, 2653, 275, 2653, 365, 440, 488, 436, 2653, 503, 291, 14, 2593, 267, 1284, 63, 521, 275, 900, 14, 521, 342, 267, 340, 2653, 365, 440, 488, 436, 2653, 690, 378, 26, 288, 1284, 63, 521, 847, 2653, 398, 1830, 715, 26, 288, 327, 7649, 436, 1218, 282, 13673, 2142, 370, 652, 14, 288, 862, 26, 355, 747, 14, 13380, 8, 277, 14, 3235, 63, 354, 12, 291, 14, 831, 63, 493, 9, 288, 871, 6440, 26, 355, 327, 10967, 7143, 3405, 14, 221, 23038, 781, 9064, 4270, 13, 9325, 31, 355, 340, 291, 14, 73, 63, 455, 63, 24056, 837, 490, 327, 10967, 379, 370, 734, 3747, 536, 14, 2165, 15648, 14, 490, 372, 355, 587, 26, 490, 327, 6630, 314, 4650, 7143, 3405, 14, 490, 340, 2653, 365, 440, 488, 436, 900, 14, 521, 342, 690, 1284, 63, 521, 26, 717, 340, 2653, 690, 378, 26, 1169, 746, 15536, 6372, 480, 6372, 10923, 370, 16919, 2, 6343, 298, 4650, 367, 450, 83, 2, 450, 6343, 291, 14, 515, 9, 717, 587, 26, 1169, 746, 21086, 22408, 3647, 83, 365, 2575, 14233, 2, 450, 6059, 291, 14, 515, 9, 490, 900, 14, 4532, 8, 2593, 15, 709, 340, 2653, 365, 440, 488, 587, 378, 14, 17, 9, 288, 587, 26, 355, 327, 10967, 7143, 19268, 14, 221, 2136, 3984, 6954, 370, 2621, 14, 355, 372, 339, 347, 4683, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 9325, 837, 288, 746, 2832, 22408, 3647, 83, 365, 440, 14233, 2, 450, 291, 14, 515, 9, 267, 916, 440, 291, 14, 73, 63, 455, 63, 24056, 837, 288, 746, 2832, 5713, 6432, 3647, 83, 365, 14233, 12, 1325, 440, 701, 562, 2, 450, 291, 14, 515, 9, 267, 747, 14, 7162, 8, 277, 14, 831, 63, 493, 9, 339, 347, 365, 63, 9325, 8, 277, 304, 267, 372, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 9, 339, 347, 284, 63, 455, 63, 24056, 8, 277, 304, 267, 372, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 9, 436, 971, 268, 747, 14, 31654, 8, 277, 14, 831, 63, 493, 9, 508, 291, 14, 3235, 63, 354, 339, 347, 2059, 63, 831, 8, 277, 304, 267, 340, 747, 14, 515, 14, 20719, 8, 277, 14, 831, 63, 493, 304, 221, 327, 3495, 10883, 2142, 288, 747, 14, 7162, 8, 277, 14, 831, 63, 493, 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, 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,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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 ]
minhtuancn/odoo
addons/account/account_cash_statement.py
283
15868
# encoding: utf-8 ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 PC Solutions (<http://pcsol.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from openerp.osv import fields, osv from openerp.tools import float_compare from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp class account_cashbox_line(osv.osv): """ Cash Box Details """ _name = 'account.cashbox.line' _description = 'CashBox Line' _rec_name = 'pieces' def _sub_total(self, cr, uid, ids, name, arg, context=None): """ Calculates Sub total @param name: Names of fields. @param arg: User defined arguments @return: Dictionary of values. """ res = {} for obj in self.browse(cr, uid, ids, context=context): res[obj.id] = { 'subtotal_opening' : obj.pieces * obj.number_opening, 'subtotal_closing' : obj.pieces * obj.number_closing, } return res def on_change_sub_opening(self, cr, uid, ids, pieces, number, *a): """ Compute the subtotal for the opening """ return {'value' : {'subtotal_opening' : (pieces * number) or 0.0 }} def on_change_sub_closing(self, cr, uid, ids, pieces, number, *a): """ Compute the subtotal for the closing """ return {'value' : {'subtotal_closing' : (pieces * number) or 0.0 }} _columns = { 'pieces': fields.float('Unit of Currency', digits_compute=dp.get_precision('Account')), 'number_opening' : fields.integer('Number of Units', help='Opening Unit Numbers'), 'number_closing' : fields.integer('Number of Units', help='Closing Unit Numbers'), 'subtotal_opening': fields.function(_sub_total, string='Opening Subtotal', type='float', digits_compute=dp.get_precision('Account'), multi='subtotal'), 'subtotal_closing': fields.function(_sub_total, string='Closing Subtotal', type='float', digits_compute=dp.get_precision('Account'), multi='subtotal'), 'bank_statement_id' : fields.many2one('account.bank.statement', ondelete='cascade'), } class account_cash_statement(osv.osv): _inherit = 'account.bank.statement' def _update_balances(self, cr, uid, ids, context=None): """ Set starting and ending balances according to pieces count """ res = {} for statement in self.browse(cr, uid, ids, context=context): if (statement.journal_id.type not in ('cash',)): continue if not statement.journal_id.cash_control: prec = self.pool['decimal.precision'].precision_get(cr, uid, 'Account') if float_compare(statement.balance_end_real, statement.balance_end, precision_digits=prec): statement.write({'balance_end_real' : statement.balance_end}) continue start = end = 0 for line in statement.details_ids: start += line.subtotal_opening end += line.subtotal_closing data = { 'balance_start': start, 'balance_end_real': end, } res[statement.id] = data super(account_cash_statement, self).write(cr, uid, [statement.id], data, context=context) return res def _get_sum_entry_encoding(self, cr, uid, ids, name, arg, context=None): """ Find encoding total of statements " @param name: Names of fields. @param arg: User defined arguments @return: Dictionary of values. """ res = {} for statement in self.browse(cr, uid, ids, context=context): res[statement.id] = sum((line.amount for line in statement.line_ids), 0.0) return res def _get_company(self, cr, uid, context=None): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') user = user_pool.browse(cr, uid, uid, context=context) company_id = user.company_id if not company_id: company_id = company_pool.search(cr, uid, []) return company_id and company_id[0] or False def _get_statement_from_line(self, cr, uid, ids, context=None): result = {} for line in self.pool.get('account.bank.statement.line').browse(cr, uid, ids, context=context): result[line.statement_id.id] = True return result.keys() def _compute_difference(self, cr, uid, ids, fieldnames, args, context=None): result = dict.fromkeys(ids, 0.0) for obj in self.browse(cr, uid, ids, context=context): result[obj.id] = obj.balance_end_real - obj.balance_end return result def _compute_last_closing_balance(self, cr, uid, ids, fieldnames, args, context=None): result = dict.fromkeys(ids, 0.0) for obj in self.browse(cr, uid, ids, context=context): if obj.state == 'draft': statement_ids = self.search(cr, uid, [('journal_id', '=', obj.journal_id.id),('state', '=', 'confirm')], order='create_date desc', limit=1, context=context ) if not statement_ids: continue else: st = self.browse(cr, uid, statement_ids[0], context=context) result[obj.id] = st.balance_end_real return result def onchange_journal_id(self, cr, uid, ids, journal_id, context=None): result = super(account_cash_statement, self).onchange_journal_id(cr, uid, ids, journal_id) if not journal_id: return result statement_ids = self.search(cr, uid, [('journal_id', '=', journal_id),('state', '=', 'confirm')], order='create_date desc', limit=1, context=context ) opening_details_ids = self._get_cash_open_box_lines(cr, uid, journal_id, context) if opening_details_ids: result['value']['opening_details_ids'] = opening_details_ids if not statement_ids: return result st = self.browse(cr, uid, statement_ids[0], context=context) result.setdefault('value', {}).update({'last_closing_balance' : st.balance_end_real}) return result _columns = { 'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Total Transactions", store = { 'account.bank.statement': (lambda self, cr, uid, ids, context=None: ids, ['line_ids','move_line_ids'], 10), 'account.bank.statement.line': (_get_statement_from_line, ['amount'], 10), }, help="Total of cash transaction lines."), 'closing_date': fields.datetime("Closed On"), 'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines', copy=True), 'opening_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Opening Cashbox Lines'), 'closing_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Closing Cashbox Lines'), 'user_id': fields.many2one('res.users', 'Responsible', required=False), 'difference' : fields.function(_compute_difference, method=True, string="Difference", type="float", help="Difference between the theoretical closing balance and the real closing balance."), 'last_closing_balance' : fields.function(_compute_last_closing_balance, method=True, string='Last Closing Balance', type='float'), } _defaults = { 'state': 'draft', 'date': lambda self, cr, uid, context={}: context.get('date', time.strftime("%Y-%m-%d %H:%M:%S")), 'user_id': lambda self, cr, uid, context=None: uid, } def _get_cash_open_box_lines(self, cr, uid, journal_id, context): details_ids = [] if not journal_id: return details_ids journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) if journal and (journal.type == 'cash'): last_pieces = None if journal.with_last_closing_balance == True: domain = [('journal_id', '=', journal.id), ('state', '=', 'confirm')] last_bank_statement_ids = self.search(cr, uid, domain, limit=1, order='create_date desc', context=context) if last_bank_statement_ids: last_bank_statement = self.browse(cr, uid, last_bank_statement_ids[0], context=context) last_pieces = dict( (line.pieces, line.number_closing) for line in last_bank_statement.details_ids ) for value in journal.cashbox_line_ids: nested_values = { 'number_closing' : 0, 'number_opening' : last_pieces.get(value.pieces, 0) if isinstance(last_pieces, dict) else 0, 'pieces' : value.pieces } details_ids.append([0, False, nested_values]) return details_ids def create(self, cr, uid, vals, context=None): journal_id = vals.get('journal_id') if journal_id and not vals.get('opening_details_ids'): vals['opening_details_ids'] = vals.get('opening_details_ids') or self._get_cash_open_box_lines(cr, uid, journal_id, context) res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) self._update_balances(cr, uid, [res_id], context) return res_id def write(self, cr, uid, ids, vals, context=None): """ Update redord(s) comes in {ids}, with new value comes as {vals} return True on success, False otherwise @param cr: cursor to database @param user: id of current user @param ids: list of record ids to be update @param vals: dict of new values to be set @param context: context arguments, like lang, time zone @return: True on success, False otherwise """ if vals.get('journal_id', False): cashbox_line_obj = self.pool.get('account.cashbox.line') cashbox_ids = cashbox_line_obj.search(cr, uid, [('bank_statement_id', 'in', ids)], context=context) cashbox_line_obj.unlink(cr, uid, cashbox_ids, context) res = super(account_cash_statement, self).write(cr, uid, ids, vals, context=context) self._update_balances(cr, uid, ids, context) return res def _user_allow(self, cr, uid, statement_id, context=None): return True def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ obj_seq = self.pool.get('ir.sequence') if context is None: context = {} statement_pool = self.pool.get('account.bank.statement') for statement in statement_pool.browse(cr, uid, ids, context=context): vals = {} if not self._user_allow(cr, uid, statement.id, context=context): raise osv.except_osv(_('Error!'), (_('You do not have rights to open this %s journal!') % (statement.journal_id.name, ))) if statement.name and statement.name == '/': c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id} if statement.journal_id.sequence_id: st_number = obj_seq.next_by_id(cr, uid, statement.journal_id.sequence_id.id, context=c) else: st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement', context=c) vals.update({ 'name': st_number }) vals.update({ 'state': 'open', }) self.write(cr, uid, [statement.id], vals, context=context) return True def statement_close(self, cr, uid, ids, journal_type='bank', context=None): if journal_type == 'bank': return super(account_cash_statement, self).statement_close(cr, uid, ids, journal_type, context) vals = { 'state':'confirm', 'closing_date': time.strftime("%Y-%m-%d %H:%M:%S") } return self.write(cr, uid, ids, vals, context=context) def check_status_condition(self, cr, uid, state, journal_type='bank'): if journal_type == 'bank': return super(account_cash_statement, self).check_status_condition(cr, uid, state, journal_type) return state=='open' def button_confirm_cash(self, cr, uid, ids, context=None): absl_proxy = self.pool.get('account.bank.statement.line') TABLES = ((_('Profit'), 'profit_account_id'), (_('Loss'), 'loss_account_id'),) for obj in self.browse(cr, uid, ids, context=context): if obj.difference == 0.0: continue elif obj.difference < 0.0: account = obj.journal_id.loss_account_id name = _('Loss') if not obj.journal_id.loss_account_id: raise osv.except_osv(_('Error!'), _('There is no Loss Account on the journal %s.') % (obj.journal_id.name,)) else: # obj.difference > 0.0 account = obj.journal_id.profit_account_id name = _('Profit') if not obj.journal_id.profit_account_id: raise osv.except_osv(_('Error!'), _('There is no Profit Account on the journal %s.') % (obj.journal_id.name,)) values = { 'statement_id' : obj.id, 'journal_id' : obj.journal_id.id, 'account_id' : account.id, 'amount' : obj.difference, 'name' : name, } absl_proxy.create(cr, uid, values, context=context) return super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context) class account_journal(osv.osv): _inherit = 'account.journal' def _default_cashbox_line_ids(self, cr, uid, context=None): # Return a list of coins in Euros. result = [ dict(pieces=value) for value in [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500] ] return result _columns = { 'cashbox_line_ids' : fields.one2many('account.journal.cashbox.line', 'journal_id', 'CashBox', copy=True), } _defaults = { 'cashbox_line_ids' : _default_cashbox_line_ids, } class account_journal_cashbox_line(osv.osv): _name = 'account.journal.cashbox.line' _rec_name = 'pieces' _columns = { 'pieces': fields.float('Values', digits_compute=dp.get_precision('Account')), 'journal_id' : fields.many2one('account.journal', 'Journal', required=True, select=1, ondelete="cascade"), } _order = 'pieces asc' # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 2644, 26, 2774, 13, 24, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 9300, 510, 35, 17991, 8653, 8642, 1014, 921, 80, 1259, 393, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 492, 2069, 63, 5785, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 14, 10788, 14, 6355, 63, 6833, 465, 12392, 199, 199, 533, 2933, 63, 20084, 1977, 63, 604, 8, 4795, 14, 4795, 304, 339, 408, 445, 1119, 20783, 15621, 408, 339, 485, 354, 275, 283, 2048, 14, 20084, 1977, 14, 604, 7, 272, 485, 1802, 275, 283, 35, 1119, 3532, 7030, 7, 272, 485, 2761, 63, 354, 275, 283, 15655, 7, 339, 347, 485, 954, 63, 2923, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 398, 408, 28562, 4804, 3141, 267, 768, 635, 536, 26, 23923, 402, 1504, 14, 267, 768, 635, 1680, 26, 2876, 3247, 2368, 267, 768, 1107, 26, 11932, 402, 1338, 14, 267, 408, 267, 522, 275, 1052, 267, 367, 1559, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 1113, 14, 344, 61, 275, 469, 355, 283, 954, 2923, 63, 21849, 7, 520, 1559, 14, 15655, 627, 1559, 14, 1955, 63, 21849, 12, 355, 283, 954, 2923, 63, 11707, 7, 520, 1559, 14, 15655, 627, 1559, 14, 1955, 63, 11707, 12, 288, 789, 267, 372, 522, 339, 347, 641, 63, 1461, 63, 954, 63, 21849, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 10338, 12, 1329, 12, 627, 65, 304, 267, 408, 8354, 314, 1007, 2923, 367, 314, 13618, 408, 267, 372, 791, 585, 7, 520, 791, 954, 2923, 63, 21849, 7, 520, 334, 15655, 627, 1329, 9, 503, 378, 14, 16, 3586, 339, 347, 641, 63, 1461, 63, 954, 63, 11707, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 10338, 12, 1329, 12, 627, 65, 304, 267, 408, 8354, 314, 1007, 2923, 367, 314, 11261, 408, 267, 372, 791, 585, 7, 520, 791, 954, 2923, 63, 11707, 7, 520, 334, 15655, 627, 1329, 9, 503, 378, 14, 16, 3586, 339, 485, 3406, 275, 469, 267, 283, 15655, 356, 1504, 14, 1609, 360, 5072, 402, 7319, 3860, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 3855, 267, 283, 1955, 63, 21849, 7, 520, 1504, 14, 4115, 360, 3259, 402, 1910, 1405, 297, 1720, 534, 4299, 316, 12008, 4860, 83, 659, 267, 283, 1955, 63, 11707, 7, 520, 1504, 14, 4115, 360, 3259, 402, 1910, 1405, 297, 1720, 534, 18433, 12008, 4860, 83, 659, 267, 283, 954, 2923, 63, 21849, 356, 1504, 14, 1593, 1547, 954, 63, 2923, 12, 1059, 534, 4299, 316, 4804, 2923, 297, 730, 534, 1609, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 659, 3510, 534, 954, 2923, 659, 267, 283, 954, 2923, 63, 11707, 356, 1504, 14, 1593, 1547, 954, 63, 2923, 12, 1059, 534, 18433, 4804, 2923, 297, 730, 534, 1609, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 659, 3510, 534, 954, 2923, 659, 267, 283, 9860, 63, 6242, 63, 344, 7, 520, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9860, 14, 6242, 297, 16549, 534, 15377, 659, 1362, 789, 421, 199, 533, 2933, 63, 20084, 63, 6242, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 9860, 14, 6242, 7, 339, 347, 485, 873, 63, 7358, 83, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 288, 2494, 6617, 436, 13401, 8091, 13236, 7182, 370, 10338, 2338, 267, 408, 267, 522, 275, 1052, 267, 367, 5164, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 334, 6242, 14, 7067, 63, 344, 14, 466, 440, 315, 661, 20084, 297, 2298, 355, 1980, 288, 340, 440, 5164, 14, 7067, 63, 344, 14, 20084, 63, 2785, 26, 355, 13826, 275, 291, 14, 2293, 459, 6355, 14, 6833, 2278, 6833, 63, 362, 8, 1556, 12, 1747, 12, 283, 6009, 358, 355, 340, 2069, 63, 5785, 8, 6242, 14, 7358, 63, 500, 63, 3093, 12, 5164, 14, 7358, 63, 500, 12, 7151, 63, 7022, 29, 9218, 304, 490, 5164, 14, 952, 3252, 7358, 63, 500, 63, 3093, 7, 520, 5164, 14, 7358, 63, 500, 1552, 355, 1980, 288, 1343, 275, 1284, 275, 378, 288, 367, 1004, 315, 5164, 14, 5087, 63, 1580, 26, 355, 1343, 847, 1004, 14, 954, 2923, 63, 21849, 355, 1284, 847, 1004, 14, 954, 2923, 63, 11707, 288, 666, 275, 469, 355, 283, 7358, 63, 928, 356, 1343, 12, 355, 283, 7358, 63, 500, 63, 3093, 356, 1284, 12, 288, 789, 288, 522, 59, 6242, 14, 344, 61, 275, 666, 288, 1613, 8, 2048, 63, 20084, 63, 6242, 12, 291, 680, 952, 8, 1556, 12, 1747, 12, 359, 6242, 14, 344, 467, 666, 12, 1067, 29, 1100, 9, 267, 372, 522, 339, 347, 485 ]
[ 2644, 26, 2774, 13, 24, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 9300, 510, 35, 17991, 8653, 8642, 1014, 921, 80, 1259, 393, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 492, 2069, 63, 5785, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 5166, 14, 10788, 14, 6355, 63, 6833, 465, 12392, 199, 199, 533, 2933, 63, 20084, 1977, 63, 604, 8, 4795, 14, 4795, 304, 339, 408, 445, 1119, 20783, 15621, 408, 339, 485, 354, 275, 283, 2048, 14, 20084, 1977, 14, 604, 7, 272, 485, 1802, 275, 283, 35, 1119, 3532, 7030, 7, 272, 485, 2761, 63, 354, 275, 283, 15655, 7, 339, 347, 485, 954, 63, 2923, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 398, 408, 28562, 4804, 3141, 267, 768, 635, 536, 26, 23923, 402, 1504, 14, 267, 768, 635, 1680, 26, 2876, 3247, 2368, 267, 768, 1107, 26, 11932, 402, 1338, 14, 267, 408, 267, 522, 275, 1052, 267, 367, 1559, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 1113, 14, 344, 61, 275, 469, 355, 283, 954, 2923, 63, 21849, 7, 520, 1559, 14, 15655, 627, 1559, 14, 1955, 63, 21849, 12, 355, 283, 954, 2923, 63, 11707, 7, 520, 1559, 14, 15655, 627, 1559, 14, 1955, 63, 11707, 12, 288, 789, 267, 372, 522, 339, 347, 641, 63, 1461, 63, 954, 63, 21849, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 10338, 12, 1329, 12, 627, 65, 304, 267, 408, 8354, 314, 1007, 2923, 367, 314, 13618, 408, 267, 372, 791, 585, 7, 520, 791, 954, 2923, 63, 21849, 7, 520, 334, 15655, 627, 1329, 9, 503, 378, 14, 16, 3586, 339, 347, 641, 63, 1461, 63, 954, 63, 11707, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 10338, 12, 1329, 12, 627, 65, 304, 267, 408, 8354, 314, 1007, 2923, 367, 314, 11261, 408, 267, 372, 791, 585, 7, 520, 791, 954, 2923, 63, 11707, 7, 520, 334, 15655, 627, 1329, 9, 503, 378, 14, 16, 3586, 339, 485, 3406, 275, 469, 267, 283, 15655, 356, 1504, 14, 1609, 360, 5072, 402, 7319, 3860, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 3855, 267, 283, 1955, 63, 21849, 7, 520, 1504, 14, 4115, 360, 3259, 402, 1910, 1405, 297, 1720, 534, 4299, 316, 12008, 4860, 83, 659, 267, 283, 1955, 63, 11707, 7, 520, 1504, 14, 4115, 360, 3259, 402, 1910, 1405, 297, 1720, 534, 18433, 12008, 4860, 83, 659, 267, 283, 954, 2923, 63, 21849, 356, 1504, 14, 1593, 1547, 954, 63, 2923, 12, 1059, 534, 4299, 316, 4804, 2923, 297, 730, 534, 1609, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 659, 3510, 534, 954, 2923, 659, 267, 283, 954, 2923, 63, 11707, 356, 1504, 14, 1593, 1547, 954, 63, 2923, 12, 1059, 534, 18433, 4804, 2923, 297, 730, 534, 1609, 297, 7576, 63, 3357, 29, 5780, 14, 362, 63, 6833, 360, 6009, 659, 3510, 534, 954, 2923, 659, 267, 283, 9860, 63, 6242, 63, 344, 7, 520, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9860, 14, 6242, 297, 16549, 534, 15377, 659, 1362, 789, 421, 199, 533, 2933, 63, 20084, 63, 6242, 8, 4795, 14, 4795, 304, 339, 485, 6486, 275, 283, 2048, 14, 9860, 14, 6242, 7, 339, 347, 485, 873, 63, 7358, 83, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 288, 2494, 6617, 436, 13401, 8091, 13236, 7182, 370, 10338, 2338, 267, 408, 267, 522, 275, 1052, 267, 367, 5164, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 334, 6242, 14, 7067, 63, 344, 14, 466, 440, 315, 661, 20084, 297, 2298, 355, 1980, 288, 340, 440, 5164, 14, 7067, 63, 344, 14, 20084, 63, 2785, 26, 355, 13826, 275, 291, 14, 2293, 459, 6355, 14, 6833, 2278, 6833, 63, 362, 8, 1556, 12, 1747, 12, 283, 6009, 358, 355, 340, 2069, 63, 5785, 8, 6242, 14, 7358, 63, 500, 63, 3093, 12, 5164, 14, 7358, 63, 500, 12, 7151, 63, 7022, 29, 9218, 304, 490, 5164, 14, 952, 3252, 7358, 63, 500, 63, 3093, 7, 520, 5164, 14, 7358, 63, 500, 1552, 355, 1980, 288, 1343, 275, 1284, 275, 378, 288, 367, 1004, 315, 5164, 14, 5087, 63, 1580, 26, 355, 1343, 847, 1004, 14, 954, 2923, 63, 21849, 355, 1284, 847, 1004, 14, 954, 2923, 63, 11707, 288, 666, 275, 469, 355, 283, 7358, 63, 928, 356, 1343, 12, 355, 283, 7358, 63, 500, 63, 3093, 356, 1284, 12, 288, 789, 288, 522, 59, 6242, 14, 344, 61, 275, 666, 288, 1613, 8, 2048, 63, 20084, 63, 6242, 12, 291, 680, 952, 8, 1556, 12, 1747, 12, 359, 6242, 14, 344, 467, 666, 12, 1067, 29, 1100, 9, 267, 372, 522, 339, 347, 485, 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, 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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 ]
vrutkovs/gnome-news
gnomenews/post.py
2
3366
# Copyright (C) 2015 Felipe Borges <felipeborges@gnome.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from gi.repository import WebKit2, GObject, GLib import hashlib import os.path from gnomenews import log import logging logger = logging.getLogger(__name__) THUMBNAIL_WIDTH = 256 THUMBNAIL_HEIGHT = 256 # FIXME: Remove duplication with application.py CACHE_PATH = "~/.cache/gnome-news" class Post(GObject.GObject): __gsignals__ = { 'info-updated': (GObject.SignalFlags.RUN_FIRST, None, (GObject.GObject,)), } @log def __init__(self, cursor): GObject.GObject.__init__(self) self.cursor = cursor self.title = cursor['title'] self.content = cursor['content'] self.author = cursor['fullname'] # Check cache first hashed_url = hashlib.md5(cursor['url'].encode()).hexdigest() self.cached_thumbnail_path = os.path.join(os.path.expanduser(CACHE_PATH), '%s.png' % hashed_url) GLib.idle_add(self.try_to_load_image_from_cache) @log def try_to_load_image_from_cache(self): if os.path.isfile(self.cached_thumbnail_path): self.thumbnail = self.cached_thumbnail_path self.emit('info-updated', self) else: self.webview = WebKit2.WebView(sensitive=False) self.webview.connect('load-changed', self._draw_thumbnail) self._generate_thumbnail() @log def _generate_thumbnail(self): self.webview.load_html(""" <div style="width: 250px"> <h3 style="margin-bottom: 2px">%s</h3> <small style="color: #333">%s</small> <small style="color: #9F9F9F">%s</small> </div>""" % (self.title, self.author, self.content)) @log def _draw_thumbnail(self, webview, event): if event == WebKit2.LoadEvent.FINISHED: self.webview.get_snapshot(WebKit2.SnapshotRegion.FULL_DOCUMENT, WebKit2.SnapshotOptions.NONE, None, self._save_thumbnail, None) @log def _save_thumbnail(self, webview, res, data): try: original_surface = self.webview.get_snapshot_finish(res) import cairo new_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT) ctx = cairo.Context(new_surface) ctx.set_source_surface(original_surface, 0, 0) ctx.paint() new_surface.write_to_png(self.cached_thumbnail_path) self.thumbnail = self.cached_thumbnail_path self.emit('info-updated', self) except Exception as e: logger.error("Could not draw thumbnail for %s: %s" % (self.title, str(e)))
gpl-3.0
[ 3, 1898, 334, 35, 9, 6900, 7949, 317, 321, 699, 269, 3389, 665, 771, 317, 321, 31938, 3389, 32, 784, 1377, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 18895, 14, 8421, 492, 6001, 14591, 18, 12, 31264, 12, 3563, 1892, 199, 199, 646, 8337, 199, 646, 747, 14, 515, 199, 199, 504, 486, 29897, 13224, 492, 943, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 2080, 2639, 18273, 6593, 63, 11139, 275, 7633, 199, 2080, 2639, 18273, 6593, 63, 13509, 275, 7633, 199, 3, 7600, 26, 5852, 11866, 1863, 543, 4223, 14, 647, 199, 8677, 63, 3243, 275, 26810, 8083, 1637, 15, 784, 1377, 13, 13224, 2, 421, 199, 533, 7711, 8, 39, 1692, 14, 39, 1692, 304, 339, 636, 71, 10458, 363, 275, 469, 267, 283, 815, 13, 5334, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 334, 39, 1692, 14, 39, 1692, 16965, 272, 789, 339, 768, 793, 272, 347, 636, 826, 721, 277, 12, 3920, 304, 267, 31264, 14, 39, 1692, 855, 826, 721, 277, 9, 398, 291, 14, 3937, 275, 3920, 398, 291, 14, 1213, 275, 3920, 459, 1213, 418, 267, 291, 14, 1317, 275, 3920, 459, 1317, 418, 267, 291, 14, 2502, 275, 3920, 459, 9930, 418, 398, 327, 2670, 2581, 1642, 267, 19871, 63, 633, 275, 8337, 14, 1064, 21, 8, 3937, 459, 633, 2278, 2143, 8801, 11453, 342, 267, 291, 14, 5245, 63, 8311, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 12131, 8, 8677, 63, 3243, 395, 1543, 83, 14, 4524, 7, 450, 19871, 63, 633, 9, 398, 3563, 1892, 14, 12000, 63, 525, 8, 277, 14, 893, 63, 475, 63, 912, 63, 1569, 63, 504, 63, 1637, 9, 339, 768, 793, 272, 347, 862, 63, 475, 63, 912, 63, 1569, 63, 504, 63, 1637, 8, 277, 304, 267, 340, 747, 14, 515, 14, 6292, 8, 277, 14, 5245, 63, 8311, 63, 515, 304, 288, 291, 14, 8311, 275, 291, 14, 5245, 63, 8311, 63, 515, 288, 291, 14, 8159, 360, 815, 13, 5334, 297, 291, 9, 267, 587, 26, 288, 291, 14, 2520, 1345, 275, 6001, 14591, 18, 14, 5926, 2768, 8, 7361, 29, 797, 9, 288, 291, 14, 2520, 1345, 14, 2242, 360, 912, 13, 2489, 297, 291, 423, 5485, 63, 8311, 9, 288, 291, 423, 4208, 63, 8311, 342, 339, 768, 793, 272, 347, 485, 4208, 63, 8311, 8, 277, 304, 267, 291, 14, 2520, 1345, 14, 912, 63, 1360, 4852, 288, 665, 3015, 3449, 628, 2063, 26, 16074, 5326, 1743, 355, 665, 72, 19, 3449, 628, 9650, 13, 8305, 26, 499, 5326, 14423, 83, 1108, 72, 19, 30, 355, 665, 7241, 3449, 628, 2326, 26, 327, 11769, 14423, 83, 1108, 7241, 30, 355, 665, 7241, 3449, 628, 2326, 26, 327, 25, 38, 25, 38, 25, 38, 14423, 83, 1108, 7241, 30, 288, 3068, 3015, 11193, 450, 334, 277, 14, 1213, 12, 291, 14, 2502, 12, 291, 14, 1317, 430, 339, 768, 793, 272, 347, 485, 5485, 63, 8311, 8, 277, 12, 3330, 1345, 12, 1566, 304, 267, 340, 1566, 508, 6001, 14591, 18, 14, 6200, 2390, 14, 17383, 20450, 26, 288, 291, 14, 2520, 1345, 14, 362, 63, 4753, 8, 21666, 18, 14, 12038, 10708, 14, 14742, 63, 7884, 12, 4228, 6001, 14591, 18, 14, 12038, 4558, 14, 9185, 12, 4228, 488, 12, 291, 423, 2117, 63, 8311, 12, 488, 9, 339, 768, 793, 272, 347, 485, 2117, 63, 8311, 8, 277, 12, 3330, 1345, 12, 522, 12, 666, 304, 267, 862, 26, 288, 3379, 63, 10992, 275, 291, 14, 2520, 1345, 14, 362, 63, 4753, 63, 8192, 8, 470, 9, 953, 492, 1704, 14352, 288, 892, 63, 10992, 275, 1704, 14352, 14, 3491, 16923, 8, 21562, 14, 4807, 63, 689, 6487, 708, 12, 4221, 2639, 18273, 6593, 63, 11139, 12, 4221, 2639, 18273, 6593, 63, 13509, 9, 288, 4027, 275, 1704, 14352, 14, 2998, 8, 1222, 63, 10992, 9, 288, 4027, 14, 409, 63, 1365, 63, 10992, 8, 5043, 63, 10992, 12, 378, 12, 378, 9, 288, 4027, 14, 17486, 342, 953, 892, 63, 10992, 14, 952, 63, 475, 63, 4524, 8, 277, 14, 5245, 63, 8311, 63, 515, 9, 953, 291, 14, 8311, 275, 291, 14, 5245, 63, 8311, 63, 515, 288, 291, 14, 8159, 360, 815, 13, 5334, 297, 291, 9, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 705, 480, 6531, 440, 5954, 10062, 367, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 1213, 12, 620, 8, 69, 1724, 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 ]
[ 1898, 334, 35, 9, 6900, 7949, 317, 321, 699, 269, 3389, 665, 771, 317, 321, 31938, 3389, 32, 784, 1377, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 18895, 14, 8421, 492, 6001, 14591, 18, 12, 31264, 12, 3563, 1892, 199, 199, 646, 8337, 199, 646, 747, 14, 515, 199, 199, 504, 486, 29897, 13224, 492, 943, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 2080, 2639, 18273, 6593, 63, 11139, 275, 7633, 199, 2080, 2639, 18273, 6593, 63, 13509, 275, 7633, 199, 3, 7600, 26, 5852, 11866, 1863, 543, 4223, 14, 647, 199, 8677, 63, 3243, 275, 26810, 8083, 1637, 15, 784, 1377, 13, 13224, 2, 421, 199, 533, 7711, 8, 39, 1692, 14, 39, 1692, 304, 339, 636, 71, 10458, 363, 275, 469, 267, 283, 815, 13, 5334, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 334, 39, 1692, 14, 39, 1692, 16965, 272, 789, 339, 768, 793, 272, 347, 636, 826, 721, 277, 12, 3920, 304, 267, 31264, 14, 39, 1692, 855, 826, 721, 277, 9, 398, 291, 14, 3937, 275, 3920, 398, 291, 14, 1213, 275, 3920, 459, 1213, 418, 267, 291, 14, 1317, 275, 3920, 459, 1317, 418, 267, 291, 14, 2502, 275, 3920, 459, 9930, 418, 398, 327, 2670, 2581, 1642, 267, 19871, 63, 633, 275, 8337, 14, 1064, 21, 8, 3937, 459, 633, 2278, 2143, 8801, 11453, 342, 267, 291, 14, 5245, 63, 8311, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 12131, 8, 8677, 63, 3243, 395, 1543, 83, 14, 4524, 7, 450, 19871, 63, 633, 9, 398, 3563, 1892, 14, 12000, 63, 525, 8, 277, 14, 893, 63, 475, 63, 912, 63, 1569, 63, 504, 63, 1637, 9, 339, 768, 793, 272, 347, 862, 63, 475, 63, 912, 63, 1569, 63, 504, 63, 1637, 8, 277, 304, 267, 340, 747, 14, 515, 14, 6292, 8, 277, 14, 5245, 63, 8311, 63, 515, 304, 288, 291, 14, 8311, 275, 291, 14, 5245, 63, 8311, 63, 515, 288, 291, 14, 8159, 360, 815, 13, 5334, 297, 291, 9, 267, 587, 26, 288, 291, 14, 2520, 1345, 275, 6001, 14591, 18, 14, 5926, 2768, 8, 7361, 29, 797, 9, 288, 291, 14, 2520, 1345, 14, 2242, 360, 912, 13, 2489, 297, 291, 423, 5485, 63, 8311, 9, 288, 291, 423, 4208, 63, 8311, 342, 339, 768, 793, 272, 347, 485, 4208, 63, 8311, 8, 277, 304, 267, 291, 14, 2520, 1345, 14, 912, 63, 1360, 4852, 288, 665, 3015, 3449, 628, 2063, 26, 16074, 5326, 1743, 355, 665, 72, 19, 3449, 628, 9650, 13, 8305, 26, 499, 5326, 14423, 83, 1108, 72, 19, 30, 355, 665, 7241, 3449, 628, 2326, 26, 327, 11769, 14423, 83, 1108, 7241, 30, 355, 665, 7241, 3449, 628, 2326, 26, 327, 25, 38, 25, 38, 25, 38, 14423, 83, 1108, 7241, 30, 288, 3068, 3015, 11193, 450, 334, 277, 14, 1213, 12, 291, 14, 2502, 12, 291, 14, 1317, 430, 339, 768, 793, 272, 347, 485, 5485, 63, 8311, 8, 277, 12, 3330, 1345, 12, 1566, 304, 267, 340, 1566, 508, 6001, 14591, 18, 14, 6200, 2390, 14, 17383, 20450, 26, 288, 291, 14, 2520, 1345, 14, 362, 63, 4753, 8, 21666, 18, 14, 12038, 10708, 14, 14742, 63, 7884, 12, 4228, 6001, 14591, 18, 14, 12038, 4558, 14, 9185, 12, 4228, 488, 12, 291, 423, 2117, 63, 8311, 12, 488, 9, 339, 768, 793, 272, 347, 485, 2117, 63, 8311, 8, 277, 12, 3330, 1345, 12, 522, 12, 666, 304, 267, 862, 26, 288, 3379, 63, 10992, 275, 291, 14, 2520, 1345, 14, 362, 63, 4753, 63, 8192, 8, 470, 9, 953, 492, 1704, 14352, 288, 892, 63, 10992, 275, 1704, 14352, 14, 3491, 16923, 8, 21562, 14, 4807, 63, 689, 6487, 708, 12, 4221, 2639, 18273, 6593, 63, 11139, 12, 4221, 2639, 18273, 6593, 63, 13509, 9, 288, 4027, 275, 1704, 14352, 14, 2998, 8, 1222, 63, 10992, 9, 288, 4027, 14, 409, 63, 1365, 63, 10992, 8, 5043, 63, 10992, 12, 378, 12, 378, 9, 288, 4027, 14, 17486, 342, 953, 892, 63, 10992, 14, 952, 63, 475, 63, 4524, 8, 277, 14, 5245, 63, 8311, 63, 515, 9, 953, 291, 14, 8311, 275, 291, 14, 5245, 63, 8311, 63, 515, 288, 291, 14, 8159, 360, 815, 13, 5334, 297, 291, 9, 267, 871, 2186, 465, 325, 26, 288, 2512, 14, 705, 480, 6531, 440, 5954, 10062, 367, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 1213, 12, 620, 8, 69, 1724, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rohitsm/spsoldboys
main.py
1
4255
"""`main` is the top level module for your Flask application.""" __author__ = 'rohitsm' __page__ = 'https://github.com/rohitsm/spsoldboys' # Python import urllib2 import json import sys import cgi # Flask from flask import Flask from flask import request, redirect, url_for from flask import render_template # App Engine from google.appengine.ext import ndb import logging # Application related files import config from db import Oldboy app = Flask(__name__, static_url_path='/static') # URL format: recaptcha_url? + secret=your_secret & response=response_string&remoteip=user_ip_address' recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify' # ReCAPTCHA secret key recaptcha_secret = config.conf['SHARED_KEY'] def verify_captcha(recaptcha_response): res = recaptcha_url + \ "?secret=" + recaptcha_secret + \ "&response=" + recaptcha_response # resp = True|False Type=bool resp = json.load(urllib2.urlopen(res))["success"] # print "resp[success] = %r" %resp return resp @app.route('/') def index(): """Return a friendly HTTP greeting.""" # To add entry to DB, uncomment below line. set_record() reads from csv input. # num_of_records = Oldboy.set_record() # print "No of records written = " + str(num_of_records) # return "helloWorld!" return render_template('index.html') @app.route('/search', methods=['GET', 'POST']) def authentication(): # Verify reCaptcha input and render page correctly if captcha verified if request.method == 'POST': if(verify_captcha(request.form['g-recaptcha-response'])): return render_template('search.html') return render_template('search.html') #Delete this line and uncomment 2 above # For GET requests return redirect(url_for('index')) # Send data from DB to 'results' page @app.route('/results', methods=['GET', 'POST']) def search_request(): # Get search terms record = [] # For table headers of HTML tables headers = {} if request.method == 'POST': try: firstName = cgi.escape(request.form['firstname'], True).lower().replace(' ', '') lastName = cgi.escape(request.form['lastname'], True).lower().replace(' ', '') year = cgi.escape(request.form['year'], True) # print 'firstname = %s \nlastName = %s, \nyear =%s ' %(firstName, lastName, year) if(not year): year = None if( (not firstName) or (firstName.isspace()) ): firstName = None if( (not lastName) or (lastName.isspace()) ): lastName = None # Retrieve query from the datastore. # record = DB query results # header = for rendering table headers record = Oldboy.get_record(firstName, lastName, year) # print "record = %s" %(record) if (record is not None): count = len(record) headers = record[0] # Records sorted by Last names sorted_records = sorted(record, key=lambda k: k['Last Name']) # print "Dict = ", sorted_records return render_template('results.html', records = sorted_records, \ headers = headers, \ count = count) return render_template('notfound.html') except Exception as e: print "Woah horsey! This shouldn't be happening!" logging.error(sys.exc_info()) print e # Redirect to "not_found" page return render_template('notfound.html') # For GET requests return redirect(url_for('index')) @app.route('/addrecord') def addrecord(): """ Page contains Google form embedded for entering new record.""" return render_template('addrecord.html') @app.errorhandler(404) def page_not_found(e): """Return a custom 404 error.""" return 'Sorry, Nothing at this URL.', 404 @app.errorhandler(500) def page_not_found(e): """Return a custom 500 error.""" return 'Sorry, unexpected error: {}'.format(e), 500
mit
[ 624, 64, 973, 64, 365, 314, 2746, 2166, 859, 367, 2195, 16704, 4223, 1041, 199, 199, 363, 2502, 363, 275, 283, 293, 16595, 77, 7, 199, 363, 1606, 363, 275, 283, 2859, 921, 5031, 14, 957, 15, 293, 16595, 77, 15, 681, 83, 1753, 656, 588, 7, 199, 199, 3, 2018, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 984, 199, 646, 16004, 199, 199, 3, 16704, 199, 504, 7209, 492, 16704, 199, 504, 7209, 492, 1056, 12, 4660, 12, 1166, 63, 509, 199, 504, 7209, 492, 3795, 63, 1160, 199, 199, 3, 4693, 12580, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 646, 2050, 199, 199, 3, 13515, 4048, 1584, 199, 646, 1101, 199, 504, 1592, 492, 21238, 656, 89, 199, 199, 571, 275, 16704, 3460, 354, 3108, 2955, 63, 633, 63, 515, 8805, 1986, 358, 199, 199, 3, 2851, 1475, 26, 295, 20559, 63, 633, 31, 435, 7565, 29, 12695, 63, 4731, 1253, 1177, 29, 1310, 63, 875, 6, 3846, 711, 29, 751, 63, 711, 63, 1562, 7, 199, 2761, 6182, 9518, 63, 633, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 2761, 6182, 9518, 15, 1246, 15, 2124, 4712, 7, 199, 199, 3, 799, 28342, 26363, 7565, 790, 199, 2761, 6182, 9518, 63, 4731, 275, 1101, 14, 2190, 459, 13772, 63, 3078, 418, 199, 199, 318, 4911, 63, 20559, 8, 2761, 6182, 9518, 63, 1310, 304, 272, 522, 275, 221, 295, 20559, 63, 633, 435, 971, 288, 23665, 4731, 628, 435, 295, 20559, 63, 4731, 435, 971, 288, 11746, 1310, 628, 435, 295, 20559, 63, 1310, 339, 327, 3085, 275, 715, 92, 797, 2434, 29, 2245, 272, 3085, 275, 2022, 14, 912, 8, 4078, 18, 14, 10890, 8, 470, 430, 905, 3742, 937, 272, 327, 870, 298, 4518, 59, 3742, 61, 275, 450, 82, 2, 450, 4518, 272, 372, 3085, 421, 199, 32, 571, 14, 4449, 7825, 199, 318, 1478, 837, 272, 408, 1767, 282, 21428, 3101, 486, 23457, 1041, 2286, 327, 4005, 1050, 2397, 370, 6249, 12, 625, 3349, 5084, 1004, 14, 663, 63, 3059, 342, 11597, 687, 7392, 1324, 14, 5591, 327, 1967, 63, 1618, 63, 6502, 275, 21238, 656, 89, 14, 409, 63, 3059, 342, 272, 327, 870, 298, 1944, 402, 5767, 5313, 275, 298, 435, 620, 8, 1507, 63, 1618, 63, 6502, 9, 272, 327, 372, 298, 5006, 15943, 9539, 272, 372, 3795, 63, 1160, 360, 1080, 14, 1360, 358, 421, 199, 32, 571, 14, 4449, 2336, 1733, 297, 3102, 2968, 2970, 297, 283, 4030, 1105, 199, 318, 6299, 837, 272, 327, 7635, 295, 13519, 9518, 1324, 436, 3795, 2034, 6657, 340, 12162, 9518, 16317, 272, 340, 1056, 14, 765, 508, 283, 4030, 356, 1362, 198, 692, 8, 4712, 63, 20559, 8, 1069, 14, 964, 459, 71, 13, 2761, 6182, 9518, 13, 1310, 26536, 19066, 198, 1107, 3795, 63, 1160, 360, 1733, 14, 1360, 358, 267, 372, 3795, 63, 1160, 360, 1733, 14, 1360, 358, 327, 5392, 642, 1004, 436, 625, 3349, 499, 3432, 2286, 327, 2104, 9576, 4145, 272, 372, 4660, 8, 633, 63, 509, 360, 1080, 1333, 421, 199, 3, 10217, 666, 687, 6249, 370, 283, 2604, 7, 2034, 199, 32, 571, 14, 4449, 2336, 2604, 297, 3102, 2968, 2970, 297, 283, 4030, 1105, 199, 318, 2754, 63, 1069, 837, 2286, 327, 2372, 2754, 2895, 272, 2777, 275, 942, 2286, 327, 2104, 1817, 2323, 402, 4163, 6716, 272, 2323, 275, 1052, 5591, 340, 1056, 14, 765, 508, 283, 4030, 356, 267, 862, 26, 288, 1642, 985, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 25603, 995, 715, 680, 2325, 1252, 1814, 360, 1656, 4074, 288, 2061, 985, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 31164, 995, 715, 680, 2325, 1252, 1814, 360, 1656, 4074, 288, 5361, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 3403, 995, 715, 9, 288, 327, 870, 283, 25603, 275, 450, 83, 971, 78, 2019, 985, 275, 450, 83, 12, 971, 78, 3403, 275, 5, 83, 283, 2818, 2246, 985, 12, 2061, 985, 12, 5361, 9, 953, 340, 8, 1397, 5361, 304, 3777, 355, 5361, 275, 488, 7846, 340, 8, 334, 1397, 1642, 985, 9, 503, 334, 2246, 985, 14, 23360, 1012, 3461, 355, 1642, 985, 275, 488, 953, 340, 8, 334, 1397, 2061, 985, 9, 503, 334, 2019, 985, 14, 23360, 1012, 3461, 355, 2061, 985, 275, 488, 953, 327, 13939, 1827, 687, 314, 12007, 14, 288, 327, 2777, 275, 6249, 1827, 2058, 288, 327, 1406, 275, 367, 14066, 1817, 2323, 288, 2777, 275, 21238, 656, 89, 14, 362, 63, 3059, 8, 2246, 985, 12, 2061, 985, 12, 5361, 9, 7205, 327, 870, 298, 3059, 275, 450, 83, 2, 2818, 3059, 9, 953, 340, 334, 3059, 365, 440, 488, 304, 355, 2338, 275, 822, 8, 3059, 9, 355, 2323, 275, 2777, 59, 16, 61, 2234, 327, 799, 3692, 3355, 701, 15237, 1561, 355, 3355, 63, 6502, 275, 3355, 8, 3059, 12, 790, 29, 2734, 1022, 26, 1022, 459, 6090, 2812, 1105, 2234, 327, 870, 298, 2141, 275, 3872, 3355, 63, 6502, 355, 372, 3795, 63, 1160, 360, 2604, 14, 1360, 297, 221, 5767, 275, 3355, 63, 6502, 12, 971, 9144, 2323, 275, 2323, 12, 971, 9144, 2338, 275, 2338, 9, 953, 372, 3795, 63, 1160, 360, 32353, 14, 1360, 358, 2728, 871, 2186, 465, 325, 26, 288, 870, 298, 26724, 11326, 394, 9050, 89, 1, 961, 9296, 1133, 506, 5992, 316, 9539, 288, 2050, 14, 705, 8, 1274, 14, 2804, 63, 815, 1012, 288, 870, 325, 953, 327, 18532, 370, 298, 1397, 63, 4214, 2, 2034, 288, 372, 3795, 63, 1160, 360, 32353, 14, 1360, 358, 339, 327, 2104, 9576, 4145, 272, 372, 4660, 8, 633, 63, 509, 360, 1080, 1333, 421, 199, 32, 571, 14, 4449, 2336, 525, 3059, 358, 199, 318, 1050, 3059, 837, 272, 408, 10331, 3509, 4475, 1824, 12169, 367, 9509, 316, 892, 2777, 1041, 14821, 372, 3795, 63, 1160, 360, 525, 3059, 14, 1360, 358, 421, 199, 32, 571, 14, 705, 2232, 8, 5188, 9, 199, 318, 2034, 63, 1397, 63, 4214, 8, 69, 304, 272, 408, 1767, 282, 3537, 7901, 1125, 1041, 272, 372, 283, 27143, 12, 20550, 737, 642, 2851, 3130, 7901, 421, 199 ]
[ 64, 973, 64, 365, 314, 2746, 2166, 859, 367, 2195, 16704, 4223, 1041, 199, 199, 363, 2502, 363, 275, 283, 293, 16595, 77, 7, 199, 363, 1606, 363, 275, 283, 2859, 921, 5031, 14, 957, 15, 293, 16595, 77, 15, 681, 83, 1753, 656, 588, 7, 199, 199, 3, 2018, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 984, 199, 646, 16004, 199, 199, 3, 16704, 199, 504, 7209, 492, 16704, 199, 504, 7209, 492, 1056, 12, 4660, 12, 1166, 63, 509, 199, 504, 7209, 492, 3795, 63, 1160, 199, 199, 3, 4693, 12580, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 646, 2050, 199, 199, 3, 13515, 4048, 1584, 199, 646, 1101, 199, 504, 1592, 492, 21238, 656, 89, 199, 199, 571, 275, 16704, 3460, 354, 3108, 2955, 63, 633, 63, 515, 8805, 1986, 358, 199, 199, 3, 2851, 1475, 26, 295, 20559, 63, 633, 31, 435, 7565, 29, 12695, 63, 4731, 1253, 1177, 29, 1310, 63, 875, 6, 3846, 711, 29, 751, 63, 711, 63, 1562, 7, 199, 2761, 6182, 9518, 63, 633, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 2761, 6182, 9518, 15, 1246, 15, 2124, 4712, 7, 199, 199, 3, 799, 28342, 26363, 7565, 790, 199, 2761, 6182, 9518, 63, 4731, 275, 1101, 14, 2190, 459, 13772, 63, 3078, 418, 199, 199, 318, 4911, 63, 20559, 8, 2761, 6182, 9518, 63, 1310, 304, 272, 522, 275, 221, 295, 20559, 63, 633, 435, 971, 288, 23665, 4731, 628, 435, 295, 20559, 63, 4731, 435, 971, 288, 11746, 1310, 628, 435, 295, 20559, 63, 1310, 339, 327, 3085, 275, 715, 92, 797, 2434, 29, 2245, 272, 3085, 275, 2022, 14, 912, 8, 4078, 18, 14, 10890, 8, 470, 430, 905, 3742, 937, 272, 327, 870, 298, 4518, 59, 3742, 61, 275, 450, 82, 2, 450, 4518, 272, 372, 3085, 421, 199, 32, 571, 14, 4449, 7825, 199, 318, 1478, 837, 272, 408, 1767, 282, 21428, 3101, 486, 23457, 1041, 2286, 327, 4005, 1050, 2397, 370, 6249, 12, 625, 3349, 5084, 1004, 14, 663, 63, 3059, 342, 11597, 687, 7392, 1324, 14, 5591, 327, 1967, 63, 1618, 63, 6502, 275, 21238, 656, 89, 14, 409, 63, 3059, 342, 272, 327, 870, 298, 1944, 402, 5767, 5313, 275, 298, 435, 620, 8, 1507, 63, 1618, 63, 6502, 9, 272, 327, 372, 298, 5006, 15943, 9539, 272, 372, 3795, 63, 1160, 360, 1080, 14, 1360, 358, 421, 199, 32, 571, 14, 4449, 2336, 1733, 297, 3102, 2968, 2970, 297, 283, 4030, 1105, 199, 318, 6299, 837, 272, 327, 7635, 295, 13519, 9518, 1324, 436, 3795, 2034, 6657, 340, 12162, 9518, 16317, 272, 340, 1056, 14, 765, 508, 283, 4030, 356, 1362, 198, 692, 8, 4712, 63, 20559, 8, 1069, 14, 964, 459, 71, 13, 2761, 6182, 9518, 13, 1310, 26536, 19066, 198, 1107, 3795, 63, 1160, 360, 1733, 14, 1360, 358, 267, 372, 3795, 63, 1160, 360, 1733, 14, 1360, 358, 327, 5392, 642, 1004, 436, 625, 3349, 499, 3432, 2286, 327, 2104, 9576, 4145, 272, 372, 4660, 8, 633, 63, 509, 360, 1080, 1333, 421, 199, 3, 10217, 666, 687, 6249, 370, 283, 2604, 7, 2034, 199, 32, 571, 14, 4449, 2336, 2604, 297, 3102, 2968, 2970, 297, 283, 4030, 1105, 199, 318, 2754, 63, 1069, 837, 2286, 327, 2372, 2754, 2895, 272, 2777, 275, 942, 2286, 327, 2104, 1817, 2323, 402, 4163, 6716, 272, 2323, 275, 1052, 5591, 340, 1056, 14, 765, 508, 283, 4030, 356, 267, 862, 26, 288, 1642, 985, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 25603, 995, 715, 680, 2325, 1252, 1814, 360, 1656, 4074, 288, 2061, 985, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 31164, 995, 715, 680, 2325, 1252, 1814, 360, 1656, 4074, 288, 5361, 275, 16004, 14, 3765, 8, 1069, 14, 964, 459, 3403, 995, 715, 9, 288, 327, 870, 283, 25603, 275, 450, 83, 971, 78, 2019, 985, 275, 450, 83, 12, 971, 78, 3403, 275, 5, 83, 283, 2818, 2246, 985, 12, 2061, 985, 12, 5361, 9, 953, 340, 8, 1397, 5361, 304, 3777, 355, 5361, 275, 488, 7846, 340, 8, 334, 1397, 1642, 985, 9, 503, 334, 2246, 985, 14, 23360, 1012, 3461, 355, 1642, 985, 275, 488, 953, 340, 8, 334, 1397, 2061, 985, 9, 503, 334, 2019, 985, 14, 23360, 1012, 3461, 355, 2061, 985, 275, 488, 953, 327, 13939, 1827, 687, 314, 12007, 14, 288, 327, 2777, 275, 6249, 1827, 2058, 288, 327, 1406, 275, 367, 14066, 1817, 2323, 288, 2777, 275, 21238, 656, 89, 14, 362, 63, 3059, 8, 2246, 985, 12, 2061, 985, 12, 5361, 9, 7205, 327, 870, 298, 3059, 275, 450, 83, 2, 2818, 3059, 9, 953, 340, 334, 3059, 365, 440, 488, 304, 355, 2338, 275, 822, 8, 3059, 9, 355, 2323, 275, 2777, 59, 16, 61, 2234, 327, 799, 3692, 3355, 701, 15237, 1561, 355, 3355, 63, 6502, 275, 3355, 8, 3059, 12, 790, 29, 2734, 1022, 26, 1022, 459, 6090, 2812, 1105, 2234, 327, 870, 298, 2141, 275, 3872, 3355, 63, 6502, 355, 372, 3795, 63, 1160, 360, 2604, 14, 1360, 297, 221, 5767, 275, 3355, 63, 6502, 12, 971, 9144, 2323, 275, 2323, 12, 971, 9144, 2338, 275, 2338, 9, 953, 372, 3795, 63, 1160, 360, 32353, 14, 1360, 358, 2728, 871, 2186, 465, 325, 26, 288, 870, 298, 26724, 11326, 394, 9050, 89, 1, 961, 9296, 1133, 506, 5992, 316, 9539, 288, 2050, 14, 705, 8, 1274, 14, 2804, 63, 815, 1012, 288, 870, 325, 953, 327, 18532, 370, 298, 1397, 63, 4214, 2, 2034, 288, 372, 3795, 63, 1160, 360, 32353, 14, 1360, 358, 339, 327, 2104, 9576, 4145, 272, 372, 4660, 8, 633, 63, 509, 360, 1080, 1333, 421, 199, 32, 571, 14, 4449, 2336, 525, 3059, 358, 199, 318, 1050, 3059, 837, 272, 408, 10331, 3509, 4475, 1824, 12169, 367, 9509, 316, 892, 2777, 1041, 14821, 372, 3795, 63, 1160, 360, 525, 3059, 14, 1360, 358, 421, 199, 32, 571, 14, 705, 2232, 8, 5188, 9, 199, 318, 2034, 63, 1397, 63, 4214, 8, 69, 304, 272, 408, 1767, 282, 3537, 7901, 1125, 1041, 272, 372, 283, 27143, 12, 20550, 737, 642, 2851, 3130, 7901, 421, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jbreitbart/fast-lib
vendor/mosquitto-1.3.5/test/lib/01-con-discon-success.py
19
1806
#!/usr/bin/env python # Test whether a client produces a correct connect and subsequent disconnect. # The client should connect to port 1888 with keepalive=60, clean session set, # and client id 01-con-discon-success # The test will send a CONNACK message to the client with rc=0. Upon receiving # the CONNACK and verifying that rc=0, the client should send a DISCONNECT # message. If rc!=0, the client should exit with an error. import inspect import os import subprocess import socket import sys import time # From http://stackoverflow.com/questions/279237/python-import-a-module-from-a-folder cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],".."))) if cmd_subfolder not in sys.path: sys.path.insert(0, cmd_subfolder) import mosq_test rc = 1 keepalive = 60 connect_packet = mosq_test.gen_connect("01-con-discon-success", keepalive=keepalive) connack_packet = mosq_test.gen_connack(rc=0) disconnect_packet = mosq_test.gen_disconnect() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.settimeout(10) sock.bind(('', 1888)) sock.listen(5) client_args = sys.argv[1:] env = dict(os.environ) env['LD_LIBRARY_PATH'] = '../../lib:../../lib/cpp' try: pp = env['PYTHONPATH'] except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp client = subprocess.Popen(client_args, env=env) try: (conn, address) = sock.accept() conn.settimeout(10) if mosq_test.expect_packet(conn, "connect", connect_packet): conn.send(connack_packet) if mosq_test.expect_packet(conn, "disconnect", disconnect_packet): rc = 0 conn.close() finally: client.terminate() client.wait() sock.close() exit(rc)
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1379, 3775, 282, 1890, 16904, 282, 3211, 4907, 436, 13372, 17639, 14, 199, 199, 3, 710, 1890, 1077, 4907, 370, 1844, 413, 13997, 543, 4215, 9631, 29, 2259, 12, 3633, 2351, 663, 12, 199, 3, 436, 1890, 1305, 17163, 13, 388, 13, 2297, 388, 13, 3742, 199, 3, 710, 511, 911, 3222, 282, 1868, 46, 3099, 1245, 370, 314, 1890, 543, 4819, 29, 16, 14, 738, 678, 18390, 199, 3, 314, 1868, 46, 3099, 436, 31866, 626, 4819, 29, 16, 12, 314, 1890, 1077, 3222, 282, 7587, 14657, 199, 3, 1245, 14, 982, 4819, 1111, 16, 12, 314, 1890, 1077, 4458, 543, 376, 1125, 14, 199, 199, 646, 6485, 199, 646, 747, 199, 646, 3873, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 199, 3, 11606, 1455, 921, 23153, 14, 957, 15, 16069, 15, 1465, 2942, 1401, 15, 1548, 13, 646, 13, 65, 13, 578, 13, 504, 13, 65, 13, 3741, 199, 1760, 63, 954, 3741, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 8, 10955, 14, 23462, 8, 6485, 14, 1818, 1943, 342, 5082, 59, 16, 20007, 703, 13324, 199, 692, 2088, 63, 954, 3741, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 2088, 63, 954, 3741, 9, 199, 199, 646, 333, 736, 81, 63, 396, 199, 199, 1195, 275, 413, 199, 28227, 275, 5212, 199, 2242, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 2242, 480, 614, 13, 388, 13, 2297, 388, 13, 3742, 401, 4215, 9631, 29, 28227, 9, 199, 1631, 564, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 1631, 564, 8, 1195, 29, 16, 9, 199, 199, 10673, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 10673, 342, 199, 199, 5096, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 199, 5096, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 199, 5096, 14, 24630, 8, 709, 9, 199, 5096, 14, 3409, 4725, 297, 413, 13997, 430, 199, 5096, 14, 5859, 8, 21, 9, 199, 199, 1258, 63, 589, 275, 984, 14, 3020, 59, 17, 2938, 199, 1813, 275, 1211, 8, 736, 14, 2314, 9, 199, 1813, 459, 6533, 63, 16983, 63, 3243, 418, 275, 283, 9707, 773, 26, 9707, 773, 15, 5910, 7, 199, 893, 26, 272, 11618, 275, 2589, 459, 29266, 418, 199, 2590, 4067, 26, 272, 11618, 275, 2125, 199, 1813, 459, 29266, 418, 275, 283, 9707, 773, 15, 1548, 4881, 11, 802, 199, 1258, 275, 3873, 14, 7942, 8, 1258, 63, 589, 12, 2589, 29, 1813, 9, 199, 199, 893, 26, 272, 334, 1631, 12, 2287, 9, 275, 6771, 14, 5694, 342, 272, 2557, 14, 24630, 8, 709, 9, 339, 340, 333, 736, 81, 63, 396, 14, 4921, 63, 6253, 8, 1631, 12, 298, 2242, 401, 4907, 63, 6253, 304, 267, 2557, 14, 2254, 8, 1631, 564, 63, 6253, 9, 398, 340, 333, 736, 81, 63, 396, 14, 4921, 63, 6253, 8, 1631, 12, 298, 10673, 401, 17639, 63, 6253, 304, 288, 4819, 275, 378, 339, 2557, 14, 1600, 342, 199, 15172, 26, 272, 1890, 14, 14478, 342, 272, 1890, 14, 2573, 342, 272, 6771, 14, 1600, 342, 199, 199, 2224, 8, 1195, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1379, 3775, 282, 1890, 16904, 282, 3211, 4907, 436, 13372, 17639, 14, 199, 199, 3, 710, 1890, 1077, 4907, 370, 1844, 413, 13997, 543, 4215, 9631, 29, 2259, 12, 3633, 2351, 663, 12, 199, 3, 436, 1890, 1305, 17163, 13, 388, 13, 2297, 388, 13, 3742, 199, 3, 710, 511, 911, 3222, 282, 1868, 46, 3099, 1245, 370, 314, 1890, 543, 4819, 29, 16, 14, 738, 678, 18390, 199, 3, 314, 1868, 46, 3099, 436, 31866, 626, 4819, 29, 16, 12, 314, 1890, 1077, 3222, 282, 7587, 14657, 199, 3, 1245, 14, 982, 4819, 1111, 16, 12, 314, 1890, 1077, 4458, 543, 376, 1125, 14, 199, 199, 646, 6485, 199, 646, 747, 199, 646, 3873, 199, 646, 2838, 199, 646, 984, 199, 646, 900, 199, 199, 3, 11606, 1455, 921, 23153, 14, 957, 15, 16069, 15, 1465, 2942, 1401, 15, 1548, 13, 646, 13, 65, 13, 578, 13, 504, 13, 65, 13, 3741, 199, 1760, 63, 954, 3741, 275, 747, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 8, 10955, 14, 23462, 8, 6485, 14, 1818, 1943, 342, 5082, 59, 16, 20007, 703, 13324, 199, 692, 2088, 63, 954, 3741, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 2088, 63, 954, 3741, 9, 199, 199, 646, 333, 736, 81, 63, 396, 199, 199, 1195, 275, 413, 199, 28227, 275, 5212, 199, 2242, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 2242, 480, 614, 13, 388, 13, 2297, 388, 13, 3742, 401, 4215, 9631, 29, 28227, 9, 199, 1631, 564, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 1631, 564, 8, 1195, 29, 16, 9, 199, 199, 10673, 63, 6253, 275, 333, 736, 81, 63, 396, 14, 2268, 63, 10673, 342, 199, 199, 5096, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 199, 5096, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 199, 5096, 14, 24630, 8, 709, 9, 199, 5096, 14, 3409, 4725, 297, 413, 13997, 430, 199, 5096, 14, 5859, 8, 21, 9, 199, 199, 1258, 63, 589, 275, 984, 14, 3020, 59, 17, 2938, 199, 1813, 275, 1211, 8, 736, 14, 2314, 9, 199, 1813, 459, 6533, 63, 16983, 63, 3243, 418, 275, 283, 9707, 773, 26, 9707, 773, 15, 5910, 7, 199, 893, 26, 272, 11618, 275, 2589, 459, 29266, 418, 199, 2590, 4067, 26, 272, 11618, 275, 2125, 199, 1813, 459, 29266, 418, 275, 283, 9707, 773, 15, 1548, 4881, 11, 802, 199, 1258, 275, 3873, 14, 7942, 8, 1258, 63, 589, 12, 2589, 29, 1813, 9, 199, 199, 893, 26, 272, 334, 1631, 12, 2287, 9, 275, 6771, 14, 5694, 342, 272, 2557, 14, 24630, 8, 709, 9, 339, 340, 333, 736, 81, 63, 396, 14, 4921, 63, 6253, 8, 1631, 12, 298, 2242, 401, 4907, 63, 6253, 304, 267, 2557, 14, 2254, 8, 1631, 564, 63, 6253, 9, 398, 340, 333, 736, 81, 63, 396, 14, 4921, 63, 6253, 8, 1631, 12, 298, 10673, 401, 17639, 63, 6253, 304, 288, 4819, 275, 378, 339, 2557, 14, 1600, 342, 199, 15172, 26, 272, 1890, 14, 14478, 342, 272, 1890, 14, 2573, 342, 272, 6771, 14, 1600, 342, 199, 199, 2224, 8, 1195, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tlepoint/NFLlib
doc/conf.py
2
9266
# -*- coding: utf-8 -*- # # nfllib documentation build configuration file, created by # sphinx-quickstart on Thu Mar 19 09:32:40 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.imgmath', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'nfl' # General information about the project. project = u'nfllib' copyright = u'2015, Carlos Aguilar, Tancrède Lepoint, Adrien Guinet and Serge Guelton' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1' # The full version, including alpha/beta/rc tags. release = '1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' #html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value #html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'nfllibdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', # Latex figure (float) alignment #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('nfl', 'nfllib.tex', u'nfllib Documentation', u'Carlos Aguilar, Tancrède Lepoint, Adrien Guinet and Serge Guelton', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('nfl', 'nfllib', u'nfllib Documentation', [u'Carlos Aguilar, Tancrède Lepoint, Adrien Guinet and Serge Guelton'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('nfl', 'nfllib', u'nfllib Documentation', u'Carlos Aguilar, Tancrède Lepoint, Adrien Guinet and Serge Guelton', 'nfllib', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False # -- Breathe options extensions.append('breathe') breathe_projects = { "nfl": "xml" } breathe_default_project = "nfl"
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 302, 2327, 773, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 16794, 5851, 21798, 26, 708, 26, 2167, 6900, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 4060, 3442, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 78, 2327, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 78, 2327, 773, 7, 199, 7307, 275, 399, 7, 7806, 12, 14243, 11560, 437, 6051, 6734, 12, 377, 290, 1556, 18631, 271, 7005, 1403, 12, 4431, 322, 287, 12436, 10811, 436, 3739, 303, 598, 13086, 1860, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 17, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 17, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 199, 3, 961, 365, 2597, 1202, 340, 1265, 886, 1564, 7761, 4799, 9796, 6230, 18238, 14, 199, 3, 24612, 1265, 663, 298, 3671, 2, 687, 314, 1414, 1004, 367, 3520, 5560, 14, 199, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 279, 371, 2311, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 302, 2327, 773, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 16794, 5851, 21798, 26, 708, 26, 2167, 6900, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 199, 3, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 199, 3, 5478, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 199, 3, 7869, 14, 199, 5359, 275, 359, 272, 283, 8008, 14, 832, 14, 4060, 3442, 297, 199, 61, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 78, 2327, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 78, 2327, 773, 7, 199, 7307, 275, 399, 7, 7806, 12, 14243, 11560, 437, 6051, 6734, 12, 377, 290, 1556, 18631, 271, 7005, 1403, 12, 4431, 322, 287, 12436, 10811, 436, 3739, 303, 598, 13086, 1860, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 17, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 17, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 199, 3, 961, 365, 2597, 1202, 340, 1265, 886, 1564, 7761, 4799, 9796, 6230, 18238, 14, 199, 3, 24612, 1265, 663, 298, 3671, 2, 687, 314, 1414, 1004, 367, 3520, 5560, 14, 199, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 199, 3, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 11016, 10965, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 279, 371, 2311, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 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,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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 ]
Fale/ansible
test/lib/ansible_test/_internal/cloud/opennebula.py
49
1908
"""OpenNebula plugin for integration tests.""" from __future__ import (absolute_import, division, print_function) __metaclass__ = type from . import ( CloudProvider, CloudEnvironment, CloudEnvironmentConfig, ) from ..util import ( display, ConfigParser, ) class OpenNebulaCloudProvider(CloudProvider): """Checks if a configuration file has been passed or fixtures are going to be used for testing""" def filter(self, targets, exclude): """ no need to filter modules, they can either run from config file or from fixtures""" def setup(self): """Setup the cloud resource before delegation and register a cleanup callback.""" super(OpenNebulaCloudProvider, self).setup() if not self._use_static_config(): self._setup_dynamic() def _setup_dynamic(self): display.info('No config file provided, will run test from fixtures') config = self._read_config_template() values = dict( URL="http://localhost/RPC2", USERNAME='oneadmin', PASSWORD='onepass', FIXTURES='true', REPLAY='true', ) config = self._populate_config_template(config, values) self._write_config(config) class OpenNebulaCloudEnvironment(CloudEnvironment): """ Updates integration test environment after delegation. Will setup the config file as parameter. """ def get_environment_config(self): """ :rtype: CloudEnvironmentConfig """ parser = ConfigParser() parser.read(self.config_path) ansible_vars = dict( resource_prefix=self.resource_prefix, ) ansible_vars.update(dict(parser.items('default'))) display.sensitive.add(ansible_vars.get('opennebula_password')) return CloudEnvironmentConfig( ansible_vars=ansible_vars, )
gpl-3.0
[ 624, 4299, 46, 2871, 7586, 3589, 367, 13150, 2295, 1041, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 1275, 492, 334, 272, 8142, 6663, 12, 272, 8142, 8263, 12, 272, 8142, 8263, 2028, 12, 199, 9, 199, 199, 504, 2508, 1974, 492, 334, 272, 2929, 12, 272, 14196, 12, 199, 9, 421, 199, 533, 3232, 46, 2871, 7586, 9089, 6663, 8, 9089, 6663, 304, 272, 408, 11834, 340, 282, 2897, 570, 965, 2757, 3032, 503, 15188, 787, 9995, 370, 506, 1202, 367, 5343, 624, 339, 347, 2457, 8, 277, 12, 4545, 12, 5760, 304, 267, 408, 949, 1929, 370, 2457, 4621, 12, 2985, 883, 1902, 1255, 687, 1101, 570, 503, 687, 15188, 624, 339, 347, 3272, 8, 277, 304, 267, 408, 8555, 314, 8002, 2073, 2544, 18703, 425, 436, 2274, 282, 9058, 3233, 1041, 267, 1613, 8, 4299, 46, 2871, 7586, 9089, 6663, 12, 291, 680, 2758, 342, 398, 340, 440, 291, 423, 1180, 63, 1986, 63, 888, 837, 288, 291, 423, 2758, 63, 7764, 342, 339, 347, 485, 2758, 63, 7764, 8, 277, 304, 267, 2929, 14, 815, 360, 1944, 1101, 570, 2741, 12, 911, 1255, 511, 687, 15188, 358, 398, 1101, 275, 291, 423, 739, 63, 888, 63, 1160, 342, 267, 1338, 275, 1211, 8, 288, 2851, 628, 1014, 921, 5967, 15, 8171, 18, 401, 288, 13044, 2339, 534, 368, 2113, 297, 288, 21705, 5172, 534, 368, 1529, 297, 288, 7333, 52, 10799, 534, 2052, 297, 288, 5363, 11625, 534, 2052, 297, 267, 776, 267, 1101, 275, 291, 423, 13817, 63, 888, 63, 1160, 8, 888, 12, 1338, 9, 267, 291, 423, 952, 63, 888, 8, 888, 9, 421, 199, 533, 3232, 46, 2871, 7586, 9089, 8263, 8, 9089, 8263, 304, 272, 408, 272, 24663, 13150, 511, 3734, 2410, 18703, 425, 14, 12823, 3272, 314, 1101, 570, 465, 2725, 14, 272, 408, 272, 347, 664, 63, 5418, 63, 888, 8, 277, 304, 267, 408, 267, 520, 4500, 26, 8142, 8263, 2028, 267, 408, 267, 1798, 275, 14196, 342, 267, 1798, 14, 739, 8, 277, 14, 888, 63, 515, 9, 398, 3242, 63, 2936, 275, 1211, 8, 288, 2073, 63, 1861, 29, 277, 14, 1927, 63, 1861, 12, 267, 776, 398, 3242, 63, 2936, 14, 873, 8, 807, 8, 2087, 14, 1744, 360, 885, 7058, 398, 2929, 14, 7361, 14, 525, 8, 4853, 63, 2936, 14, 362, 360, 1490, 685, 66, 7586, 63, 2060, 1333, 398, 372, 8142, 8263, 2028, 8, 288, 3242, 63, 2936, 29, 4853, 63, 2936, 12, 267, 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 ]
[ 4299, 46, 2871, 7586, 3589, 367, 13150, 2295, 1041, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 1275, 492, 334, 272, 8142, 6663, 12, 272, 8142, 8263, 12, 272, 8142, 8263, 2028, 12, 199, 9, 199, 199, 504, 2508, 1974, 492, 334, 272, 2929, 12, 272, 14196, 12, 199, 9, 421, 199, 533, 3232, 46, 2871, 7586, 9089, 6663, 8, 9089, 6663, 304, 272, 408, 11834, 340, 282, 2897, 570, 965, 2757, 3032, 503, 15188, 787, 9995, 370, 506, 1202, 367, 5343, 624, 339, 347, 2457, 8, 277, 12, 4545, 12, 5760, 304, 267, 408, 949, 1929, 370, 2457, 4621, 12, 2985, 883, 1902, 1255, 687, 1101, 570, 503, 687, 15188, 624, 339, 347, 3272, 8, 277, 304, 267, 408, 8555, 314, 8002, 2073, 2544, 18703, 425, 436, 2274, 282, 9058, 3233, 1041, 267, 1613, 8, 4299, 46, 2871, 7586, 9089, 6663, 12, 291, 680, 2758, 342, 398, 340, 440, 291, 423, 1180, 63, 1986, 63, 888, 837, 288, 291, 423, 2758, 63, 7764, 342, 339, 347, 485, 2758, 63, 7764, 8, 277, 304, 267, 2929, 14, 815, 360, 1944, 1101, 570, 2741, 12, 911, 1255, 511, 687, 15188, 358, 398, 1101, 275, 291, 423, 739, 63, 888, 63, 1160, 342, 267, 1338, 275, 1211, 8, 288, 2851, 628, 1014, 921, 5967, 15, 8171, 18, 401, 288, 13044, 2339, 534, 368, 2113, 297, 288, 21705, 5172, 534, 368, 1529, 297, 288, 7333, 52, 10799, 534, 2052, 297, 288, 5363, 11625, 534, 2052, 297, 267, 776, 267, 1101, 275, 291, 423, 13817, 63, 888, 63, 1160, 8, 888, 12, 1338, 9, 267, 291, 423, 952, 63, 888, 8, 888, 9, 421, 199, 533, 3232, 46, 2871, 7586, 9089, 8263, 8, 9089, 8263, 304, 272, 408, 272, 24663, 13150, 511, 3734, 2410, 18703, 425, 14, 12823, 3272, 314, 1101, 570, 465, 2725, 14, 272, 408, 272, 347, 664, 63, 5418, 63, 888, 8, 277, 304, 267, 408, 267, 520, 4500, 26, 8142, 8263, 2028, 267, 408, 267, 1798, 275, 14196, 342, 267, 1798, 14, 739, 8, 277, 14, 888, 63, 515, 9, 398, 3242, 63, 2936, 275, 1211, 8, 288, 2073, 63, 1861, 29, 277, 14, 1927, 63, 1861, 12, 267, 776, 398, 3242, 63, 2936, 14, 873, 8, 807, 8, 2087, 14, 1744, 360, 885, 7058, 398, 2929, 14, 7361, 14, 525, 8, 4853, 63, 2936, 14, 362, 360, 1490, 685, 66, 7586, 63, 2060, 1333, 398, 372, 8142, 8263, 2028, 8, 288, 3242, 63, 2936, 29, 4853, 63, 2936, 12, 267, 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, 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 ]
arnif/CouchPotatoServer
couchpotato/core/notifications/notifymyandroid/__init__.py
7
1281
from .main import NotifyMyAndroid def start(): return NotifyMyAndroid() config = [{ 'name': 'notifymyandroid', 'groups': [ { 'tab': 'notifications', 'name': 'notifymyandroid', 'label': 'Notify My Android', 'options': [ { 'name': 'enabled', 'default': 0, 'type': 'enabler', }, { 'name': 'api_key', 'description': 'Multiple keys seperated by a comma. Maximum of 5.' }, { 'name': 'dev_key', 'advanced': True, }, { 'name': 'priority', 'default': 0, 'type': 'dropdown', 'values': [('Very Low', -2), ('Moderate', -1), ('Normal', 0), ('High', 1), ('Emergency', 2)], }, { 'name': 'on_snatch', 'default': 0, 'type': 'bool', 'advanced': True, 'description': 'Also send message when movie is snatched.', }, ], } ], }]
gpl-3.0
[ 504, 1275, 973, 492, 31949, 5713, 20762, 199, 199, 318, 1343, 837, 272, 372, 31949, 5713, 20762, 342, 199, 199, 888, 275, 8910, 272, 283, 354, 356, 283, 6814, 1662, 6238, 297, 272, 283, 2634, 356, 359, 267, 469, 288, 283, 2902, 356, 283, 12782, 297, 288, 283, 354, 356, 283, 6814, 1662, 6238, 297, 288, 283, 1302, 356, 283, 8645, 4932, 14694, 297, 288, 283, 1419, 356, 359, 355, 469, 490, 283, 354, 356, 283, 3827, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 4296, 82, 297, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 1246, 63, 498, 297, 490, 283, 1802, 356, 283, 8433, 2883, 542, 529, 972, 701, 282, 10029, 14, 14212, 402, 959, 3530, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 2374, 63, 498, 297, 490, 283, 14652, 356, 715, 12, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 6693, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 29595, 297, 490, 283, 1459, 356, 4274, 54, 994, 21766, 297, 446, 18, 395, 661, 1385, 1866, 297, 446, 17, 395, 661, 6241, 297, 378, 395, 661, 11688, 297, 413, 395, 661, 37, 2626, 27798, 297, 499, 4360, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 265, 63, 5167, 693, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 2245, 297, 490, 283, 14652, 356, 715, 12, 490, 283, 1802, 356, 283, 31892, 3222, 1245, 1380, 14360, 365, 6895, 693, 379, 3130, 355, 1660, 288, 2156, 267, 789, 272, 2156, 199, 11049, 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 ]
[ 1275, 973, 492, 31949, 5713, 20762, 199, 199, 318, 1343, 837, 272, 372, 31949, 5713, 20762, 342, 199, 199, 888, 275, 8910, 272, 283, 354, 356, 283, 6814, 1662, 6238, 297, 272, 283, 2634, 356, 359, 267, 469, 288, 283, 2902, 356, 283, 12782, 297, 288, 283, 354, 356, 283, 6814, 1662, 6238, 297, 288, 283, 1302, 356, 283, 8645, 4932, 14694, 297, 288, 283, 1419, 356, 359, 355, 469, 490, 283, 354, 356, 283, 3827, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 4296, 82, 297, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 1246, 63, 498, 297, 490, 283, 1802, 356, 283, 8433, 2883, 542, 529, 972, 701, 282, 10029, 14, 14212, 402, 959, 3530, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 2374, 63, 498, 297, 490, 283, 14652, 356, 715, 12, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 6693, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 29595, 297, 490, 283, 1459, 356, 4274, 54, 994, 21766, 297, 446, 18, 395, 661, 1385, 1866, 297, 446, 17, 395, 661, 6241, 297, 378, 395, 661, 11688, 297, 413, 395, 661, 37, 2626, 27798, 297, 499, 4360, 355, 1660, 355, 469, 490, 283, 354, 356, 283, 265, 63, 5167, 693, 297, 490, 283, 885, 356, 378, 12, 490, 283, 466, 356, 283, 2245, 297, 490, 283, 14652, 356, 715, 12, 490, 283, 1802, 356, 283, 31892, 3222, 1245, 1380, 14360, 365, 6895, 693, 379, 3130, 355, 1660, 288, 2156, 267, 789, 272, 2156, 199, 11049, 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, 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 ]
AustinRoy7/Pomodoro-timer
venv/Lib/copyreg.py
165
6833
"""Helper to provide extensibility for pickle. This is only useful to add pickle support for extension types defined in C, not for instances of user-defined classes. """ __all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] dispatch_table = {} def pickle(ob_type, pickle_function, constructor_ob=None): if not callable(pickle_function): raise TypeError("reduction functions must be callable") dispatch_table[ob_type] = pickle_function # The constructor_ob function is a vestige of safe for unpickling. # There is no reason for the caller to pass it anymore. if constructor_ob is not None: constructor(constructor_ob) def constructor(object): if not callable(object): raise TypeError("constructors must be callable") # Example: provide pickling support for complex numbers. try: complex except NameError: pass else: def pickle_complex(c): return complex, (c.real, c.imag) pickle(complex, pickle_complex, complex) # Support for pickling new-style objects def _reconstructor(cls, base, state): if base is object: obj = object.__new__(cls) else: obj = base.__new__(cls, state) if base.__init__ != object.__init__: base.__init__(obj, state) return obj _HEAPTYPE = 1<<9 # Python code for object.__reduce_ex__ for protocols 0 and 1 def _reduce_ex(self, proto): assert proto < 2 for base in self.__class__.__mro__: if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE: break else: base = object # not really reachable if base is object: state = None else: if base is self.__class__: raise TypeError("can't pickle %s objects" % base.__name__) state = base(self) args = (self.__class__, base, state) try: getstate = self.__getstate__ except AttributeError: if getattr(self, "__slots__", None): raise TypeError("a class that defines __slots__ without " "defining __getstate__ cannot be pickled") try: dict = self.__dict__ except AttributeError: dict = None else: dict = getstate() if dict: return _reconstructor, args, dict else: return _reconstructor, args # Helper for __reduce_ex__ protocol 2 def __newobj__(cls, *args): return cls.__new__(cls, *args) def __newobj_ex__(cls, args, kwargs): """Used by pickle protocol 4, instead of __newobj__ to allow classes with keyword-only arguments to be pickled correctly. """ return cls.__new__(cls, *args, **kwargs) def _slotnames(cls): """Return a list of slot names for a given class. This needs to find slots defined by the class and its bases, so we can't simply return the __slots__ attribute. We must walk down the Method Resolution Order and concatenate the __slots__ of each class found there. (This assumes classes don't modify their __slots__ attribute to misrepresent their slots after the class is defined.) """ # Get the value from a cache in the class if possible names = cls.__dict__.get("__slotnames__") if names is not None: return names # Not cached -- calculate the value names = [] if not hasattr(cls, "__slots__"): # This class has no slots pass else: # Slots found -- gather slot names from all base classes for c in cls.__mro__: if "__slots__" in c.__dict__: slots = c.__dict__['__slots__'] # if class has a single slot, it can be given as a string if isinstance(slots, str): slots = (slots,) for name in slots: # special descriptors if name in ("__dict__", "__weakref__"): continue # mangled names elif name.startswith('__') and not name.endswith('__'): names.append('_%s%s' % (c.__name__, name)) else: names.append(name) # Cache the outcome in the class if at all possible try: cls.__slotnames__ = names except: pass # But don't die if we can't return names # A registry of extension codes. This is an ad-hoc compression # mechanism. Whenever a global reference to <module>, <name> is about # to be pickled, the (<module>, <name>) tuple is looked up here to see # if it is a registered extension code for it. Extension codes are # universal, so that the meaning of a pickle does not depend on # context. (There are also some codes reserved for local use that # don't have this restriction.) Codes are positive ints; 0 is # reserved. _extension_registry = {} # key -> code _inverted_registry = {} # code -> key _extension_cache = {} # code -> object # Don't ever rebind those names: pickling grabs a reference to them when # it's initialized, and won't see a rebinding. def add_extension(module, name, code): """Register an extension code.""" code = int(code) if not 1 <= code <= 0x7fffffff: raise ValueError("code out of range") key = (module, name) if (_extension_registry.get(key) == code and _inverted_registry.get(code) == key): return # Redundant registrations are benign if key in _extension_registry: raise ValueError("key %s is already registered with code %s" % (key, _extension_registry[key])) if code in _inverted_registry: raise ValueError("code %s is already in use for key %s" % (code, _inverted_registry[code])) _extension_registry[key] = code _inverted_registry[code] = key def remove_extension(module, name, code): """Unregister an extension code. For testing only.""" key = (module, name) if (_extension_registry.get(key) != code or _inverted_registry.get(code) != key): raise ValueError("key %s is not registered with code %s" % (key, code)) del _extension_registry[key] del _inverted_registry[code] if code in _extension_cache: del _extension_cache[code] def clear_extension_cache(): _extension_cache.clear() # Standard extension code assignments # Reserved ranges # First Last Count Purpose # 1 127 127 Reserved for Python standard library # 128 191 64 Reserved for Zope # 192 239 48 Reserved for 3rd parties # 240 255 16 Reserved for private use (will never be assigned) # 256 Inf Inf Reserved for future assignment # Extension codes are assigned by the Python Software Foundation.
mit
[ 624, 4433, 370, 5647, 2178, 4783, 367, 5927, 14, 199, 199, 2765, 365, 1454, 2997, 370, 1050, 5927, 2291, 367, 3329, 2943, 3247, 315, 199, 35, 12, 440, 367, 4454, 402, 922, 13, 4037, 3992, 14, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 8092, 401, 298, 1880, 401, 1779, 298, 525, 63, 3435, 401, 298, 2168, 63, 3435, 401, 298, 3584, 63, 3435, 63, 1637, 937, 199, 199, 6052, 63, 1224, 275, 1052, 199, 199, 318, 5927, 8, 2873, 63, 466, 12, 5927, 63, 1593, 12, 3787, 63, 2873, 29, 403, 304, 272, 340, 440, 4550, 8, 8092, 63, 1593, 304, 267, 746, 3146, 480, 22508, 3423, 1471, 506, 4550, 531, 272, 7634, 63, 1224, 59, 2873, 63, 466, 61, 275, 5927, 63, 1593, 339, 327, 710, 3787, 63, 2873, 805, 365, 282, 373, 597, 73, 303, 402, 5048, 367, 625, 24773, 14, 272, 327, 6006, 365, 949, 4499, 367, 314, 8025, 370, 986, 652, 20827, 14, 272, 340, 3787, 63, 2873, 365, 440, 488, 26, 267, 3787, 8, 1880, 63, 2873, 9, 199, 199, 318, 3787, 8, 785, 304, 272, 340, 440, 4550, 8, 785, 304, 267, 746, 3146, 480, 1880, 83, 1471, 506, 4550, 531, 199, 199, 3, 5679, 26, 5647, 24394, 2291, 367, 6114, 5579, 14, 199, 199, 893, 26, 272, 6114, 199, 2590, 12746, 26, 272, 986, 199, 2836, 26, 339, 347, 5927, 63, 5254, 8, 67, 304, 267, 372, 6114, 12, 334, 67, 14, 3093, 12, 286, 14, 14688, 9, 339, 5927, 8, 5254, 12, 5927, 63, 5254, 12, 6114, 9, 199, 199, 3, 12502, 367, 24394, 892, 13, 2487, 2251, 199, 199, 318, 485, 264, 1880, 8, 1886, 12, 1300, 12, 1174, 304, 272, 340, 1300, 365, 909, 26, 267, 1559, 275, 909, 855, 1222, 721, 1886, 9, 272, 587, 26, 267, 1559, 275, 1300, 855, 1222, 721, 1886, 12, 1174, 9, 267, 340, 1300, 855, 826, 363, 1137, 909, 855, 826, 10651, 288, 1300, 855, 826, 721, 1113, 12, 1174, 9, 272, 372, 1559, 199, 199, 63, 23707, 2711, 275, 413, 8999, 25, 199, 199, 3, 2018, 1233, 367, 909, 855, 5270, 63, 476, 363, 367, 19230, 378, 436, 413, 199, 199, 318, 485, 5270, 63, 476, 8, 277, 12, 4104, 304, 272, 702, 4104, 665, 499, 272, 367, 1300, 315, 291, 855, 533, 4914, 17335, 10651, 267, 340, 2688, 8, 1095, 12, 2560, 2469, 13766, 436, 440, 1300, 855, 2469, 363, 1253, 485, 23707, 2711, 26, 288, 2059, 272, 587, 26, 267, 1300, 275, 909, 327, 440, 7710, 29542, 272, 340, 1300, 365, 909, 26, 267, 1174, 275, 488, 272, 587, 26, 267, 340, 1300, 365, 291, 855, 533, 10651, 288, 746, 3146, 480, 2425, 1133, 5927, 450, 83, 2251, 2, 450, 1300, 855, 354, 3368, 267, 1174, 275, 1300, 8, 277, 9, 272, 1249, 275, 334, 277, 855, 533, 3108, 1300, 12, 1174, 9, 272, 862, 26, 267, 664, 929, 275, 291, 855, 16011, 363, 272, 871, 4281, 26, 267, 340, 2519, 8, 277, 12, 4396, 7257, 13915, 488, 304, 288, 746, 3146, 480, 65, 1021, 626, 7890, 636, 7257, 363, 1928, 298, 1169, 298, 318, 7969, 636, 16011, 363, 3913, 506, 18731, 531, 267, 862, 26, 288, 1211, 275, 291, 855, 807, 363, 267, 871, 4281, 26, 288, 1211, 275, 488, 272, 587, 26, 267, 1211, 275, 664, 929, 342, 272, 340, 1211, 26, 267, 372, 485, 264, 1880, 12, 1249, 12, 1211, 272, 587, 26, 267, 372, 485, 264, 1880, 12, 1249, 199, 199, 3, 11642, 367, 636, 5270, 63, 476, 363, 4113, 499, 199, 199, 318, 636, 1222, 1113, 721, 1886, 12, 627, 589, 304, 272, 372, 843, 855, 1222, 721, 1886, 12, 627, 589, 9, 199, 199, 318, 636, 1222, 1113, 63, 476, 721, 1886, 12, 1249, 12, 2074, 304, 272, 408, 9167, 701, 5927, 4113, 841, 12, 3140, 402, 636, 1222, 1113, 363, 370, 2040, 3992, 543, 272, 4252, 13, 2118, 2368, 370, 506, 18731, 6657, 14, 272, 408, 272, 372, 843, 855, 1222, 721, 1886, 12, 627, 589, 12, 1011, 958, 9, 199, 199, 318, 485, 7998, 1247, 8, 1886, 304, 272, 408, 1767, 282, 769, 402, 9348, 1561, 367, 282, 1627, 1021, 14, 339, 961, 4839, 370, 2342, 14319, 3247, 701, 314, 1021, 436, 2399, 9768, 12, 880, 781, 272, 883, 1133, 9329, 372, 314, 636, 7257, 363, 2225, 14, 221, 2136, 1471, 12778, 3224, 272, 314, 9075, 3591, 3347, 9240, 436, 24788, 314, 636, 7257, 363, 402, 1924, 272, 1021, 1911, 2337, 14, 221, 334, 2765, 15194, 3992, 2793, 1133, 2811, 3932, 272, 636, 7257, 363, 2225, 370, 3201, 13063, 3932, 14319, 2410, 314, 1021, 365, 272, 3247, 4959, 272, 408, 339, 327, 2372, 314, 574, 687, 282, 2581, 315, 314, 1021, 340, 3962, 272, 1561, 275, 843, 855, 807, 4343, 362, 16232, 7998, 1247, 18617, 272, 340, 1561, 365, 440, 488, 26, 267, 372, 1561, 339, 327, 2832, 6328, 1553, 8671, 314, 574, 272, 1561, 275, 942, 272, 340, 440, 2688, 8, 1886, 12, 4396, 7257, 363, 2349, 267, 327, 961, 1021, 965, 949, 14319, 267, 986, 272, 587, 26, 267, 327, 428, 4555, 1911, 1553, 13082, 9348, 1561, 687, 1006, 1300, 3992, 267, 367, 286, 315, 843, 855, 17335, 10651, 288, 340, 4396, 7257, 16526, 315, 286, 855, 807, 10651, 355, 14319, 275, 286, 855, 807, 363, 13742, 7257, 17501, 355, 327, 340, 1021, 965, 282, 2849, 9348, 12, 652, 883, 506, 1627, 465, 282, 1059, 355, 340, 1228, 8, 7257, 12, 620, 304, 490, 14319, 275, 334, 7257, 4258, 355, 367, 536, 315, 14319, 26, 490, 327, 4539, 15428, 490, 340, 536, 315, 1689, 363, 807, 13915, 4396, 21330, 363, 2349, 717, 1980, 490, 327, 333, 22183, 1561, 490, 916, 536, 14, 2460, 10714, 358, 436, 440, 536, 14, 4130, 10714, 735, 717, 1561, 14, 740, 360, 4970, 83, 5, 83, 7, 450, 334, 67, 855, 354, 3108, 536, 430, 490, 587, 26, 717, 1561, 14, 740, 8, 354, 9, 339, 327, 11977, 314, 15955, 315, 314, 1021, 340, 737, 1006, 3962, 272, 862, 26, 267, 843, 855, 7998, 1247, 363, 275, 1561, 272, 871, 26, 267, 986, 327, 11017, 2793, 1133, 18833, 340, 781, 883, 1133, 339, 372, 1561, 199, 199 ]
[ 4433, 370, 5647, 2178, 4783, 367, 5927, 14, 199, 199, 2765, 365, 1454, 2997, 370, 1050, 5927, 2291, 367, 3329, 2943, 3247, 315, 199, 35, 12, 440, 367, 4454, 402, 922, 13, 4037, 3992, 14, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 8092, 401, 298, 1880, 401, 1779, 298, 525, 63, 3435, 401, 298, 2168, 63, 3435, 401, 298, 3584, 63, 3435, 63, 1637, 937, 199, 199, 6052, 63, 1224, 275, 1052, 199, 199, 318, 5927, 8, 2873, 63, 466, 12, 5927, 63, 1593, 12, 3787, 63, 2873, 29, 403, 304, 272, 340, 440, 4550, 8, 8092, 63, 1593, 304, 267, 746, 3146, 480, 22508, 3423, 1471, 506, 4550, 531, 272, 7634, 63, 1224, 59, 2873, 63, 466, 61, 275, 5927, 63, 1593, 339, 327, 710, 3787, 63, 2873, 805, 365, 282, 373, 597, 73, 303, 402, 5048, 367, 625, 24773, 14, 272, 327, 6006, 365, 949, 4499, 367, 314, 8025, 370, 986, 652, 20827, 14, 272, 340, 3787, 63, 2873, 365, 440, 488, 26, 267, 3787, 8, 1880, 63, 2873, 9, 199, 199, 318, 3787, 8, 785, 304, 272, 340, 440, 4550, 8, 785, 304, 267, 746, 3146, 480, 1880, 83, 1471, 506, 4550, 531, 199, 199, 3, 5679, 26, 5647, 24394, 2291, 367, 6114, 5579, 14, 199, 199, 893, 26, 272, 6114, 199, 2590, 12746, 26, 272, 986, 199, 2836, 26, 339, 347, 5927, 63, 5254, 8, 67, 304, 267, 372, 6114, 12, 334, 67, 14, 3093, 12, 286, 14, 14688, 9, 339, 5927, 8, 5254, 12, 5927, 63, 5254, 12, 6114, 9, 199, 199, 3, 12502, 367, 24394, 892, 13, 2487, 2251, 199, 199, 318, 485, 264, 1880, 8, 1886, 12, 1300, 12, 1174, 304, 272, 340, 1300, 365, 909, 26, 267, 1559, 275, 909, 855, 1222, 721, 1886, 9, 272, 587, 26, 267, 1559, 275, 1300, 855, 1222, 721, 1886, 12, 1174, 9, 267, 340, 1300, 855, 826, 363, 1137, 909, 855, 826, 10651, 288, 1300, 855, 826, 721, 1113, 12, 1174, 9, 272, 372, 1559, 199, 199, 63, 23707, 2711, 275, 413, 8999, 25, 199, 199, 3, 2018, 1233, 367, 909, 855, 5270, 63, 476, 363, 367, 19230, 378, 436, 413, 199, 199, 318, 485, 5270, 63, 476, 8, 277, 12, 4104, 304, 272, 702, 4104, 665, 499, 272, 367, 1300, 315, 291, 855, 533, 4914, 17335, 10651, 267, 340, 2688, 8, 1095, 12, 2560, 2469, 13766, 436, 440, 1300, 855, 2469, 363, 1253, 485, 23707, 2711, 26, 288, 2059, 272, 587, 26, 267, 1300, 275, 909, 327, 440, 7710, 29542, 272, 340, 1300, 365, 909, 26, 267, 1174, 275, 488, 272, 587, 26, 267, 340, 1300, 365, 291, 855, 533, 10651, 288, 746, 3146, 480, 2425, 1133, 5927, 450, 83, 2251, 2, 450, 1300, 855, 354, 3368, 267, 1174, 275, 1300, 8, 277, 9, 272, 1249, 275, 334, 277, 855, 533, 3108, 1300, 12, 1174, 9, 272, 862, 26, 267, 664, 929, 275, 291, 855, 16011, 363, 272, 871, 4281, 26, 267, 340, 2519, 8, 277, 12, 4396, 7257, 13915, 488, 304, 288, 746, 3146, 480, 65, 1021, 626, 7890, 636, 7257, 363, 1928, 298, 1169, 298, 318, 7969, 636, 16011, 363, 3913, 506, 18731, 531, 267, 862, 26, 288, 1211, 275, 291, 855, 807, 363, 267, 871, 4281, 26, 288, 1211, 275, 488, 272, 587, 26, 267, 1211, 275, 664, 929, 342, 272, 340, 1211, 26, 267, 372, 485, 264, 1880, 12, 1249, 12, 1211, 272, 587, 26, 267, 372, 485, 264, 1880, 12, 1249, 199, 199, 3, 11642, 367, 636, 5270, 63, 476, 363, 4113, 499, 199, 199, 318, 636, 1222, 1113, 721, 1886, 12, 627, 589, 304, 272, 372, 843, 855, 1222, 721, 1886, 12, 627, 589, 9, 199, 199, 318, 636, 1222, 1113, 63, 476, 721, 1886, 12, 1249, 12, 2074, 304, 272, 408, 9167, 701, 5927, 4113, 841, 12, 3140, 402, 636, 1222, 1113, 363, 370, 2040, 3992, 543, 272, 4252, 13, 2118, 2368, 370, 506, 18731, 6657, 14, 272, 408, 272, 372, 843, 855, 1222, 721, 1886, 12, 627, 589, 12, 1011, 958, 9, 199, 199, 318, 485, 7998, 1247, 8, 1886, 304, 272, 408, 1767, 282, 769, 402, 9348, 1561, 367, 282, 1627, 1021, 14, 339, 961, 4839, 370, 2342, 14319, 3247, 701, 314, 1021, 436, 2399, 9768, 12, 880, 781, 272, 883, 1133, 9329, 372, 314, 636, 7257, 363, 2225, 14, 221, 2136, 1471, 12778, 3224, 272, 314, 9075, 3591, 3347, 9240, 436, 24788, 314, 636, 7257, 363, 402, 1924, 272, 1021, 1911, 2337, 14, 221, 334, 2765, 15194, 3992, 2793, 1133, 2811, 3932, 272, 636, 7257, 363, 2225, 370, 3201, 13063, 3932, 14319, 2410, 314, 1021, 365, 272, 3247, 4959, 272, 408, 339, 327, 2372, 314, 574, 687, 282, 2581, 315, 314, 1021, 340, 3962, 272, 1561, 275, 843, 855, 807, 4343, 362, 16232, 7998, 1247, 18617, 272, 340, 1561, 365, 440, 488, 26, 267, 372, 1561, 339, 327, 2832, 6328, 1553, 8671, 314, 574, 272, 1561, 275, 942, 272, 340, 440, 2688, 8, 1886, 12, 4396, 7257, 363, 2349, 267, 327, 961, 1021, 965, 949, 14319, 267, 986, 272, 587, 26, 267, 327, 428, 4555, 1911, 1553, 13082, 9348, 1561, 687, 1006, 1300, 3992, 267, 367, 286, 315, 843, 855, 17335, 10651, 288, 340, 4396, 7257, 16526, 315, 286, 855, 807, 10651, 355, 14319, 275, 286, 855, 807, 363, 13742, 7257, 17501, 355, 327, 340, 1021, 965, 282, 2849, 9348, 12, 652, 883, 506, 1627, 465, 282, 1059, 355, 340, 1228, 8, 7257, 12, 620, 304, 490, 14319, 275, 334, 7257, 4258, 355, 367, 536, 315, 14319, 26, 490, 327, 4539, 15428, 490, 340, 536, 315, 1689, 363, 807, 13915, 4396, 21330, 363, 2349, 717, 1980, 490, 327, 333, 22183, 1561, 490, 916, 536, 14, 2460, 10714, 358, 436, 440, 536, 14, 4130, 10714, 735, 717, 1561, 14, 740, 360, 4970, 83, 5, 83, 7, 450, 334, 67, 855, 354, 3108, 536, 430, 490, 587, 26, 717, 1561, 14, 740, 8, 354, 9, 339, 327, 11977, 314, 15955, 315, 314, 1021, 340, 737, 1006, 3962, 272, 862, 26, 267, 843, 855, 7998, 1247, 363, 275, 1561, 272, 871, 26, 267, 986, 327, 11017, 2793, 1133, 18833, 340, 781, 883, 1133, 339, 372, 1561, 199, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
WayneKoorts/TornChat
Server/RequestHandlers/ChatWebSocketHandler.py
1
4249
import tornado.websocket from Server.Chat.SimpleTypes import Participant from Server.Tools.Response.Json import * class ChatWebSocketManager(tornado.websocket.WebSocketHandler): """ The main chat socket manager, which handles both server commands from the user as well as chat messages themselves. """ def initialize(self, appManager): self._participantsManager = appManager.getParticipantsManager() self._roomManager = appManager.getRoomManager() def _handleServerCommand(self, command, args): if command == "getNicks": responseData = { "roomName": args["roomName"], "nicks": self._roomManager.getRoom(args["roomName"]).getParticipantNicks() } self.write_message(getServerCommandResponseJson(command, responseData)) def _handleUserCommand(self, command, commandArgument): """ Handle server commands such as for joining rooms, connecting to the server etc. :param command: The command string itself, e.g. 'join' :param commandArgument: The argument to the command. :return: void """ if command == "/join": participant = self._participantsManager.getParticipantBySocket(self) if self._roomManager.roomExists(commandArgument): room = self._roomManager.getRoom(commandArgument) # Don't let them join again if they're already in the room. if room.hasParticipant(self): self.write_message(getServerMessageJson("alreadyInRoom", "error")) else: room.addParticipant(participant) self.write_message(getServerMessageJson("roomJoinSuccess")) else: self._roomManager.createRoom(commandArgument, [participant]) self.write_message(getServerMessageJson("roomCreateSuccess")) elif command == "/leave" and self._roomManager.roomExists(commandArgument): room = self._roomManager.getRoom(commandArgument) room.removeParticipant(self) self.write_message(getServerMessageJson("roomLeaveSuccess")) elif command == "/connect": self._participantsManager.addParticipant(Participant(nick = commandArgument, socket = self)) self.write_message(getServerMessageJson("connectSuccess")) print(str.format("New participant, adding to participants manager. Total participants: {0}", self._participantsManager.participantsCount())) else: self.write_message(getServerMessageJson("Unknown command", "error")) def _handleChatMessage(self, room, message): self._roomManager.getRoom(room).broadcastMessage(message, self._participantsManager.getParticipantBySocket(self)) def open(self): print("New client connection.") def on_message(self, message): """ Called when data is received from the client on this socket. :param message: The data received (should be JSON in our case). :return: void """ incomingData = json.loads(message) # Check for a server command, e.g. get nick list for room. if incomingData.get("serverCommand"): self._handleServerCommand(incomingData["command"], incomingData["args"]) # Check if it's a user command. elif incomingData["message"][0] == "/": messageParts = incomingData["message"].split(" ") self._handleUserCommand(messageParts[0], messageParts[1]) else: # Regular message, broadcast it to the room. self._handleChatMessage(incomingData["room"], incomingData["message"]) def on_close(self): for room in self._roomManager.getRooms().keys(): self._roomManager.getRooms()[room].removeParticipant(self) self._participantsManager.removeParticipant(self) print(str.format("Participant left. Total participants: {0}", self._participantsManager.participantsCount())) def check_origin(self, origin): # TODO: If you use this for anything serious then change this # to check against a real origin for your domain. return True
apache-2.0
[ 646, 12148, 14, 13508, 199, 199, 504, 7146, 14, 21954, 14, 3184, 4100, 492, 2235, 16448, 199, 504, 7146, 14, 11654, 14, 2364, 14, 9653, 492, 627, 199, 199, 533, 2799, 292, 18477, 2988, 8, 18443, 14, 13508, 14, 18477, 2461, 304, 272, 408, 272, 710, 2446, 21472, 2838, 5256, 12, 1314, 10022, 3865, 1654, 3718, 272, 687, 314, 922, 465, 5521, 465, 21472, 3788, 17279, 14, 272, 408, 272, 347, 8265, 8, 277, 12, 1145, 2988, 304, 267, 291, 423, 31790, 2988, 275, 1145, 2988, 14, 362, 1262, 20989, 2988, 342, 267, 291, 423, 11245, 2988, 275, 1145, 2988, 14, 362, 25779, 2988, 342, 339, 347, 485, 2479, 3120, 3110, 8, 277, 12, 1414, 12, 1249, 304, 267, 340, 1414, 508, 298, 362, 32172, 83, 582, 288, 1177, 1451, 275, 469, 355, 298, 11245, 985, 582, 1249, 905, 11245, 985, 2255, 355, 298, 11082, 83, 582, 291, 423, 11245, 2988, 14, 362, 25779, 8, 589, 905, 11245, 985, 29126, 362, 1262, 16448, 32172, 83, 342, 288, 789, 953, 291, 14, 952, 63, 1188, 8, 362, 3120, 3110, 2364, 9653, 8, 1531, 12, 1177, 1451, 430, 339, 347, 485, 2479, 1899, 3110, 8, 277, 12, 1414, 12, 1414, 5201, 304, 267, 408, 267, 8690, 1654, 3718, 4066, 465, 367, 4263, 316, 14726, 83, 12, 18170, 267, 370, 314, 1654, 5423, 14, 267, 520, 635, 1414, 26, 710, 1414, 1059, 6337, 12, 325, 14, 71, 14, 283, 904, 7, 267, 520, 635, 1414, 5201, 26, 710, 1423, 370, 314, 1414, 14, 267, 520, 1107, 26, 2309, 267, 408, 267, 340, 1414, 508, 3286, 904, 582, 288, 623, 16448, 275, 291, 423, 31790, 2988, 14, 362, 1262, 16448, 2175, 3869, 8, 277, 9, 953, 340, 291, 423, 11245, 2988, 14, 11245, 7965, 8, 1531, 5201, 304, 355, 14726, 275, 291, 423, 11245, 2988, 14, 362, 25779, 8, 1531, 5201, 9, 355, 327, 7529, 1133, 4691, 3062, 4263, 4020, 340, 2985, 3984, 2575, 315, 314, 14726, 14, 355, 340, 14726, 14, 1989, 1262, 16448, 8, 277, 304, 490, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 14039, 607, 25779, 401, 298, 705, 2237, 355, 587, 26, 490, 14726, 14, 525, 1262, 16448, 8, 29253, 9, 490, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 13005, 8300, 2237, 288, 587, 26, 355, 291, 423, 11245, 2988, 14, 981, 25779, 8, 1531, 5201, 12, 359, 29253, 566, 355, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 2499, 8300, 2237, 267, 916, 1414, 508, 3286, 12422, 2, 436, 291, 423, 11245, 2988, 14, 11245, 7965, 8, 1531, 5201, 304, 288, 14726, 275, 291, 423, 11245, 2988, 14, 362, 25779, 8, 1531, 5201, 9, 288, 14726, 14, 2168, 1262, 16448, 8, 277, 9, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 23679, 8300, 2237, 267, 916, 1414, 508, 3286, 2242, 582, 288, 291, 423, 31790, 2988, 14, 525, 1262, 16448, 8, 1262, 16448, 8, 11082, 275, 1414, 5201, 12, 2838, 275, 291, 430, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 2242, 8300, 2237, 288, 870, 8, 495, 14, 908, 480, 4665, 623, 16448, 12, 7791, 370, 623, 20989, 5256, 14, 221, 19271, 623, 20989, 26, 469, 16, 10750, 291, 423, 31790, 2988, 14, 31790, 2353, 4059, 267, 587, 26, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 5912, 1414, 401, 298, 705, 2237, 339, 347, 485, 2479, 21954, 2209, 8, 277, 12, 14726, 12, 1245, 304, 267, 291, 423, 11245, 2988, 14, 362, 25779, 8, 11245, 680, 10786, 2209, 8, 1188, 12, 291, 423, 31790, 2988, 14, 362, 1262, 16448, 2175, 3869, 8, 277, 430, 339, 347, 1551, 8, 277, 304, 267, 870, 480, 4665, 1890, 1950, 2685, 339, 347, 641, 63, 1188, 8, 277, 12, 1245, 304, 267, 408, 267, 12295, 1380, 666, 365, 3086, 687, 314, 1890, 641, 642, 2838, 14, 267, 520, 635, 1245, 26, 710, 666, 3086, 334, 5626, 506, 4840, 315, 4154, 1930, 680, 267, 520, 1107, 26, 2309, 267, 408, 267, 12467, 1451, 275, 2022, 14, 3640, 8, 1188, 9, 267, 327, 2670, 367, 282, 1654, 1414, 12, 325, 14, 71, 14, 664, 14900, 769, 367, 14726, 14, 267, 340, 12467, 1451, 14, 362, 480, 1000, 3110, 2349, 288, 291, 423, 2479, 3120, 3110, 8, 15994, 1451, 905, 1531, 2255, 12467, 1451, 905, 589, 3135, 267, 327, 2670, 340, 652, 1159, 282, 922, 1414, 14, 267, 916, 12467, 1451, 905, 1188, 9210, 16, 61, 508, 30681, 288, 1245, 28662, 275, 12467, 1451, 905, 1188, 4140, 1294, 480, 6099, 288, 291, 423, 2479, 1899, 3110, 8, 1188, 28662, 59, 16, 467, 1245, 28662, 59, 17, 566, 267, 587, 26, 288, 327, 18528, 1245, 12, 11180, 652, 370, 314, 14726, 14, 288, 291, 423, 2479, 21954, 2209, 8, 15994, 1451, 905, 11245, 2255, 12467, 1451, 905, 1188, 3135, 339, 347, 641, 63, 1600, 8, 277, 304, 267, 367, 14726, 315, 291, 423, 11245, 2988, 14, 362, 3863, 22491, 1252, 1612, 837, 288, 291, 423, 11245, 2988, 14, 362, 3863, 22491, 3430, 11245, 1055, 2168, 1262, 16448, 8, 277, 9, 267, 291, 423, 31790, 2988, 14, 2168, 1262, 16448, 8, 277, 9, 267, 870, 8, 495, 14, 908, 480, 1262, 16448, 3602, 14, 221, 19271, 623, 20989, 26, 469, 16, 10750, 291, 423, 31790, 2988, 14, 31790, 2353, 4059, 339, 347, 1104, 63, 6493, 8, 277, 12, 6330, 304, 267, 327, 3254, 26, 982, 1265, 675, 642, 367, 7003, 542, 322, 1785, 2066, 1570, 642, 267, 327, 370, 1104, 6169, 282, 3363, 6330, 367, 2195, 2881, 14, 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 ]
[ 12148, 14, 13508, 199, 199, 504, 7146, 14, 21954, 14, 3184, 4100, 492, 2235, 16448, 199, 504, 7146, 14, 11654, 14, 2364, 14, 9653, 492, 627, 199, 199, 533, 2799, 292, 18477, 2988, 8, 18443, 14, 13508, 14, 18477, 2461, 304, 272, 408, 272, 710, 2446, 21472, 2838, 5256, 12, 1314, 10022, 3865, 1654, 3718, 272, 687, 314, 922, 465, 5521, 465, 21472, 3788, 17279, 14, 272, 408, 272, 347, 8265, 8, 277, 12, 1145, 2988, 304, 267, 291, 423, 31790, 2988, 275, 1145, 2988, 14, 362, 1262, 20989, 2988, 342, 267, 291, 423, 11245, 2988, 275, 1145, 2988, 14, 362, 25779, 2988, 342, 339, 347, 485, 2479, 3120, 3110, 8, 277, 12, 1414, 12, 1249, 304, 267, 340, 1414, 508, 298, 362, 32172, 83, 582, 288, 1177, 1451, 275, 469, 355, 298, 11245, 985, 582, 1249, 905, 11245, 985, 2255, 355, 298, 11082, 83, 582, 291, 423, 11245, 2988, 14, 362, 25779, 8, 589, 905, 11245, 985, 29126, 362, 1262, 16448, 32172, 83, 342, 288, 789, 953, 291, 14, 952, 63, 1188, 8, 362, 3120, 3110, 2364, 9653, 8, 1531, 12, 1177, 1451, 430, 339, 347, 485, 2479, 1899, 3110, 8, 277, 12, 1414, 12, 1414, 5201, 304, 267, 408, 267, 8690, 1654, 3718, 4066, 465, 367, 4263, 316, 14726, 83, 12, 18170, 267, 370, 314, 1654, 5423, 14, 267, 520, 635, 1414, 26, 710, 1414, 1059, 6337, 12, 325, 14, 71, 14, 283, 904, 7, 267, 520, 635, 1414, 5201, 26, 710, 1423, 370, 314, 1414, 14, 267, 520, 1107, 26, 2309, 267, 408, 267, 340, 1414, 508, 3286, 904, 582, 288, 623, 16448, 275, 291, 423, 31790, 2988, 14, 362, 1262, 16448, 2175, 3869, 8, 277, 9, 953, 340, 291, 423, 11245, 2988, 14, 11245, 7965, 8, 1531, 5201, 304, 355, 14726, 275, 291, 423, 11245, 2988, 14, 362, 25779, 8, 1531, 5201, 9, 355, 327, 7529, 1133, 4691, 3062, 4263, 4020, 340, 2985, 3984, 2575, 315, 314, 14726, 14, 355, 340, 14726, 14, 1989, 1262, 16448, 8, 277, 304, 490, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 14039, 607, 25779, 401, 298, 705, 2237, 355, 587, 26, 490, 14726, 14, 525, 1262, 16448, 8, 29253, 9, 490, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 13005, 8300, 2237, 288, 587, 26, 355, 291, 423, 11245, 2988, 14, 981, 25779, 8, 1531, 5201, 12, 359, 29253, 566, 355, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 2499, 8300, 2237, 267, 916, 1414, 508, 3286, 12422, 2, 436, 291, 423, 11245, 2988, 14, 11245, 7965, 8, 1531, 5201, 304, 288, 14726, 275, 291, 423, 11245, 2988, 14, 362, 25779, 8, 1531, 5201, 9, 288, 14726, 14, 2168, 1262, 16448, 8, 277, 9, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 11245, 23679, 8300, 2237, 267, 916, 1414, 508, 3286, 2242, 582, 288, 291, 423, 31790, 2988, 14, 525, 1262, 16448, 8, 1262, 16448, 8, 11082, 275, 1414, 5201, 12, 2838, 275, 291, 430, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 2242, 8300, 2237, 288, 870, 8, 495, 14, 908, 480, 4665, 623, 16448, 12, 7791, 370, 623, 20989, 5256, 14, 221, 19271, 623, 20989, 26, 469, 16, 10750, 291, 423, 31790, 2988, 14, 31790, 2353, 4059, 267, 587, 26, 288, 291, 14, 952, 63, 1188, 8, 362, 3120, 2209, 9653, 480, 5912, 1414, 401, 298, 705, 2237, 339, 347, 485, 2479, 21954, 2209, 8, 277, 12, 14726, 12, 1245, 304, 267, 291, 423, 11245, 2988, 14, 362, 25779, 8, 11245, 680, 10786, 2209, 8, 1188, 12, 291, 423, 31790, 2988, 14, 362, 1262, 16448, 2175, 3869, 8, 277, 430, 339, 347, 1551, 8, 277, 304, 267, 870, 480, 4665, 1890, 1950, 2685, 339, 347, 641, 63, 1188, 8, 277, 12, 1245, 304, 267, 408, 267, 12295, 1380, 666, 365, 3086, 687, 314, 1890, 641, 642, 2838, 14, 267, 520, 635, 1245, 26, 710, 666, 3086, 334, 5626, 506, 4840, 315, 4154, 1930, 680, 267, 520, 1107, 26, 2309, 267, 408, 267, 12467, 1451, 275, 2022, 14, 3640, 8, 1188, 9, 267, 327, 2670, 367, 282, 1654, 1414, 12, 325, 14, 71, 14, 664, 14900, 769, 367, 14726, 14, 267, 340, 12467, 1451, 14, 362, 480, 1000, 3110, 2349, 288, 291, 423, 2479, 3120, 3110, 8, 15994, 1451, 905, 1531, 2255, 12467, 1451, 905, 589, 3135, 267, 327, 2670, 340, 652, 1159, 282, 922, 1414, 14, 267, 916, 12467, 1451, 905, 1188, 9210, 16, 61, 508, 30681, 288, 1245, 28662, 275, 12467, 1451, 905, 1188, 4140, 1294, 480, 6099, 288, 291, 423, 2479, 1899, 3110, 8, 1188, 28662, 59, 16, 467, 1245, 28662, 59, 17, 566, 267, 587, 26, 288, 327, 18528, 1245, 12, 11180, 652, 370, 314, 14726, 14, 288, 291, 423, 2479, 21954, 2209, 8, 15994, 1451, 905, 11245, 2255, 12467, 1451, 905, 1188, 3135, 339, 347, 641, 63, 1600, 8, 277, 304, 267, 367, 14726, 315, 291, 423, 11245, 2988, 14, 362, 3863, 22491, 1252, 1612, 837, 288, 291, 423, 11245, 2988, 14, 362, 3863, 22491, 3430, 11245, 1055, 2168, 1262, 16448, 8, 277, 9, 267, 291, 423, 31790, 2988, 14, 2168, 1262, 16448, 8, 277, 9, 267, 870, 8, 495, 14, 908, 480, 1262, 16448, 3602, 14, 221, 19271, 623, 20989, 26, 469, 16, 10750, 291, 423, 31790, 2988, 14, 31790, 2353, 4059, 339, 347, 1104, 63, 6493, 8, 277, 12, 6330, 304, 267, 327, 3254, 26, 982, 1265, 675, 642, 367, 7003, 542, 322, 1785, 2066, 1570, 642, 267, 327, 370, 1104, 6169, 282, 3363, 6330, 367, 2195, 2881, 14, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
janko33bd/bitcoin
qa/rpc-tests/signmessages.py
1
1460
#!/usr/bin/env python2 # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * class SignMessagesTest(BitcoinTestFramework): """Tests RPC commands for signing and verifying messages.""" def setup_chain(self): print('Initializing test directory ' + self.options.tmpdir) initialize_chain_clean(self.options.tmpdir, 1) def setup_network(self, split=False): self.nodes = start_nodes(1, self.options.tmpdir) self.is_network_split = False def run_test(self): message = 'This is just a test message' # Test the signing with a privkey privKey = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N' address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB' signature = self.nodes[0].signmessagewithprivkey(privKey, message) # Verify the message assert(self.nodes[0].verifymessage(address, signature, message)) # Test the signing with an address with wallet address = self.nodes[0].getnewaddress() signature = self.nodes[0].signmessage(address, message) # Verify the message assert(self.nodes[0].verifymessage(address, signature, message)) if __name__ == '__main__': SignMessagesTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 7800, 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, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 421, 199, 533, 6632, 14508, 774, 8, 4734, 9061, 26203, 304, 272, 408, 2925, 11785, 3718, 367, 18057, 436, 31866, 3788, 1041, 339, 347, 3272, 63, 4429, 8, 277, 304, 267, 870, 360, 5733, 9147, 511, 2082, 283, 435, 291, 14, 1419, 14, 8616, 9, 267, 8265, 63, 4429, 63, 3118, 8, 277, 14, 1419, 14, 8616, 12, 413, 9, 339, 347, 3272, 63, 1200, 8, 277, 12, 3715, 29, 797, 304, 267, 291, 14, 2415, 275, 1343, 63, 2415, 8, 17, 12, 291, 14, 1419, 14, 8616, 9, 267, 291, 14, 374, 63, 1200, 63, 1294, 275, 756, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1245, 275, 283, 2765, 365, 2951, 282, 511, 1245, 7, 398, 327, 1379, 314, 18057, 543, 282, 16254, 498, 267, 16254, 1197, 275, 283, 67, 53, 69, 30392, 68, 21, 269, 90, 52, 19, 28808, 24, 48, 25, 80, 1702, 907, 40, 2319, 55, 84, 54, 70, 458, 70, 36, 8047, 9909, 34, 24862, 2533, 33, 65, 39, 75, 17, 19162, 74, 23, 46, 7, 267, 2287, 275, 283, 311, 44, 49, 32008, 43, 1965, 66, 23, 2571, 54, 20, 6849, 42, 5408, 9004, 74, 21, 45, 5326, 24, 1721, 21, 90, 8094, 7, 267, 4955, 275, 291, 14, 2415, 59, 16, 1055, 1037, 1188, 1045, 10605, 498, 8, 10605, 1197, 12, 1245, 9, 398, 327, 7635, 314, 1245, 267, 702, 8, 277, 14, 2415, 59, 16, 1055, 4712, 1188, 8, 1562, 12, 4955, 12, 1245, 430, 398, 327, 1379, 314, 18057, 543, 376, 2287, 543, 20534, 267, 2287, 275, 291, 14, 2415, 59, 16, 1055, 21102, 342, 267, 4955, 275, 291, 14, 2415, 59, 16, 1055, 1037, 1188, 8, 1562, 12, 1245, 9, 398, 327, 7635, 314, 1245, 267, 702, 8, 277, 14, 2415, 59, 16, 1055, 4712, 1188, 8, 1562, 12, 4955, 12, 1245, 430, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6632, 14508, 774, 1252, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 7800, 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, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 421, 199, 533, 6632, 14508, 774, 8, 4734, 9061, 26203, 304, 272, 408, 2925, 11785, 3718, 367, 18057, 436, 31866, 3788, 1041, 339, 347, 3272, 63, 4429, 8, 277, 304, 267, 870, 360, 5733, 9147, 511, 2082, 283, 435, 291, 14, 1419, 14, 8616, 9, 267, 8265, 63, 4429, 63, 3118, 8, 277, 14, 1419, 14, 8616, 12, 413, 9, 339, 347, 3272, 63, 1200, 8, 277, 12, 3715, 29, 797, 304, 267, 291, 14, 2415, 275, 1343, 63, 2415, 8, 17, 12, 291, 14, 1419, 14, 8616, 9, 267, 291, 14, 374, 63, 1200, 63, 1294, 275, 756, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 1245, 275, 283, 2765, 365, 2951, 282, 511, 1245, 7, 398, 327, 1379, 314, 18057, 543, 282, 16254, 498, 267, 16254, 1197, 275, 283, 67, 53, 69, 30392, 68, 21, 269, 90, 52, 19, 28808, 24, 48, 25, 80, 1702, 907, 40, 2319, 55, 84, 54, 70, 458, 70, 36, 8047, 9909, 34, 24862, 2533, 33, 65, 39, 75, 17, 19162, 74, 23, 46, 7, 267, 2287, 275, 283, 311, 44, 49, 32008, 43, 1965, 66, 23, 2571, 54, 20, 6849, 42, 5408, 9004, 74, 21, 45, 5326, 24, 1721, 21, 90, 8094, 7, 267, 4955, 275, 291, 14, 2415, 59, 16, 1055, 1037, 1188, 1045, 10605, 498, 8, 10605, 1197, 12, 1245, 9, 398, 327, 7635, 314, 1245, 267, 702, 8, 277, 14, 2415, 59, 16, 1055, 4712, 1188, 8, 1562, 12, 4955, 12, 1245, 430, 398, 327, 1379, 314, 18057, 543, 376, 2287, 543, 20534, 267, 2287, 275, 291, 14, 2415, 59, 16, 1055, 21102, 342, 267, 4955, 275, 291, 14, 2415, 59, 16, 1055, 1037, 1188, 8, 1562, 12, 1245, 9, 398, 327, 7635, 314, 1245, 267, 702, 8, 277, 14, 2415, 59, 16, 1055, 4712, 1188, 8, 1562, 12, 4955, 12, 1245, 430, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 6632, 14508, 774, 1252, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
mvs-org/metaverse
test/test-rpc-v3/TestCase/Asset/test_transfer_multisig_cert.py
3
2659
import time from utils import common from TestCase.MVSTestCase import * class TestTransferMultisigCert(MVSTestCaseBase): def test_0_transfer_multisig_cert(self): # Alice create asset domain_symbol, asset_symbol = Alice.create_random_asset(secondary=-1) Alice.mining() # create multisig # description = "Alice & Zac's multi-sig address" multisig_address = Alice.new_multisigaddress(description, [Zac], 2) multisig_address2 = Zac.new_multisigaddress(description, [Alice], 2) self.assertEqual(multisig_address, multisig_address2, "multisig addresses dismatch.") # send etp to multisig_address # result, message = mvs_rpc.sendfrom(Alice.name, Alice.password, Alice.mainaddress(), multisig_address, 3 * 10 ** 8) assert (result == 0) Alice.mining() # register did to multisig_address # multisig_did_symbol = "Multisig" + common.get_random_str() ec, tx = mvs_rpc.register_did(Alice.name, Alice.password, multisig_address, multisig_did_symbol) self.assertEqual(ec, code.success, tx) # sign multisig rawtx ec, tx2 = mvs_rpc.sign_multisigtx(Zac.name, Zac.password, tx, True) self.assertEqual(ec, 0, tx2) Alice.mining() # transfer cert to multisig_did_symbol # ec, message = mvs_rpc.transfer_cert(Alice.name, Alice.password, multisig_did_symbol, asset_symbol, 'issue') self.assertEqual(ec, code.success, message) Alice.mining() # check cert certs = Zac.get_addressasset(multisig_address, True); self.assertGreater(len(certs), 0, "not cert found at " + multisig_address) exist_symbols = list( filter(lambda a: a.symbol == asset_symbol and a.cert == "issue", certs) ) self.assertEqual(len(exist_symbols), 1, "not cert found at " + multisig_address) # transfer cert to Cindy # ec, tx = mvs_rpc.transfer_cert(Alice.name, Alice.password, Cindy.did_symbol, asset_symbol, 'issue') self.assertEqual(ec, code.success, tx) # sign multisig rawtx ec, tx2 = mvs_rpc.sign_multisigtx(Zac.name, Zac.password, tx, True) self.assertEqual(ec, 0, tx2) Alice.mining() # check cert certs = Cindy.get_addressasset(Cindy.didaddress(), True); self.assertGreater(len(certs), 0, "not cert found at " + Cindy.didaddress()) exist_symbols = list( filter(lambda a: a.symbol == asset_symbol and a.cert == "issue", certs) ) self.assertEqual(len(exist_symbols), 1, "not cert found at " + Cindy.didaddress())
agpl-3.0
[ 646, 900, 199, 504, 3778, 492, 2863, 199, 504, 7640, 14, 45, 7428, 1746, 492, 627, 199, 199, 533, 1379, 11761, 3947, 4093, 14768, 8, 45, 7428, 1746, 1563, 304, 339, 347, 511, 63, 16, 63, 9609, 63, 3029, 4093, 63, 4736, 8, 277, 304, 267, 327, 437, 3037, 1218, 8977, 267, 2881, 63, 5155, 12, 8977, 63, 5155, 275, 437, 3037, 14, 981, 63, 2355, 63, 6562, 8, 12371, 4022, 17, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1218, 3510, 4093, 267, 327, 267, 1369, 275, 298, 28001, 1253, 3107, 645, 1159, 3510, 13, 4093, 2287, 2, 398, 3510, 4093, 63, 1562, 275, 437, 3037, 14, 1222, 63, 3029, 4093, 1562, 8, 1802, 12, 359, 58, 645, 467, 499, 9, 267, 3510, 4093, 63, 1562, 18, 275, 3107, 645, 14, 1222, 63, 3029, 4093, 1562, 8, 1802, 12, 359, 28001, 467, 499, 9, 267, 291, 14, 629, 8, 3029, 4093, 63, 1562, 12, 3510, 4093, 63, 1562, 18, 12, 298, 3029, 4093, 7149, 2153, 1431, 2685, 398, 327, 3222, 325, 683, 370, 3510, 4093, 63, 1562, 267, 327, 267, 754, 12, 1245, 275, 333, 3122, 63, 4354, 14, 2254, 504, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 288, 437, 3037, 14, 973, 1562, 1062, 3510, 4093, 63, 1562, 12, 650, 627, 1616, 1011, 1695, 9, 267, 702, 334, 1099, 508, 378, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 2274, 8103, 370, 3510, 4093, 63, 1562, 267, 327, 267, 3510, 4093, 63, 14887, 63, 5155, 275, 298, 3947, 4093, 2, 435, 2863, 14, 362, 63, 2355, 63, 495, 342, 267, 7062, 12, 4773, 275, 333, 3122, 63, 4354, 14, 2683, 63, 14887, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 3510, 4093, 63, 1562, 12, 3510, 4093, 63, 14887, 63, 5155, 9, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 4773, 9, 398, 327, 2070, 3510, 4093, 3066, 2347, 267, 7062, 12, 4773, 18, 275, 333, 3122, 63, 4354, 14, 1037, 63, 3029, 4093, 2347, 8, 58, 645, 14, 354, 12, 3107, 645, 14, 2060, 12, 4773, 12, 715, 9, 267, 291, 14, 629, 8, 825, 12, 378, 12, 4773, 18, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 9307, 6250, 370, 3510, 4093, 63, 14887, 63, 5155, 267, 327, 267, 7062, 12, 1245, 275, 333, 3122, 63, 4354, 14, 9609, 63, 4736, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 3510, 4093, 63, 14887, 63, 5155, 12, 8977, 63, 5155, 12, 283, 5237, 358, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 1245, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1104, 6250, 267, 25949, 275, 3107, 645, 14, 362, 63, 1562, 6562, 8, 3029, 4093, 63, 1562, 12, 715, 2736, 267, 291, 14, 15070, 8, 552, 8, 8356, 395, 378, 12, 298, 1397, 6250, 1911, 737, 298, 435, 3510, 4093, 63, 1562, 9, 267, 2187, 63, 7450, 275, 769, 8, 2457, 8, 2734, 282, 26, 282, 14, 5155, 508, 8977, 63, 5155, 436, 282, 14, 4736, 508, 298, 5237, 401, 25949, 9, 776, 267, 291, 14, 629, 8, 552, 8, 4494, 63, 7450, 395, 413, 12, 298, 1397, 6250, 1911, 737, 298, 435, 3510, 4093, 63, 1562, 9, 398, 327, 9307, 6250, 370, 445, 688, 89, 267, 327, 267, 7062, 12, 4773, 275, 333, 3122, 63, 4354, 14, 9609, 63, 4736, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 445, 688, 89, 14, 14887, 63, 5155, 12, 8977, 63, 5155, 12, 283, 5237, 358, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 4773, 9, 398, 327, 2070, 3510, 4093, 3066, 2347, 267, 7062, 12, 4773, 18, 275, 333, 3122, 63, 4354, 14, 1037, 63, 3029, 4093, 2347, 8, 58, 645, 14, 354, 12, 3107, 645, 14, 2060, 12, 4773, 12, 715, 9, 267, 291, 14, 629, 8, 825, 12, 378, 12, 4773, 18, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1104, 6250, 267, 25949, 275, 445, 688, 89, 14, 362, 63, 1562, 6562, 8, 35, 688, 89, 14, 14887, 1562, 1062, 715, 2736, 267, 291, 14, 15070, 8, 552, 8, 8356, 395, 378, 12, 298, 1397, 6250, 1911, 737, 298, 435, 445, 688, 89, 14, 14887, 1562, 1012, 267, 2187, 63, 7450, 275, 769, 8, 2457, 8, 2734, 282, 26, 282, 14, 5155, 508, 8977, 63, 5155, 436, 282, 14, 4736, 508, 298, 5237, 401, 25949, 9, 776, 267, 291, 14, 629, 8, 552, 8, 4494, 63, 7450, 395, 413, 12, 298, 1397, 6250, 1911, 737, 298, 435, 445, 688, 89, 14, 14887, 1562, 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 ]
[ 900, 199, 504, 3778, 492, 2863, 199, 504, 7640, 14, 45, 7428, 1746, 492, 627, 199, 199, 533, 1379, 11761, 3947, 4093, 14768, 8, 45, 7428, 1746, 1563, 304, 339, 347, 511, 63, 16, 63, 9609, 63, 3029, 4093, 63, 4736, 8, 277, 304, 267, 327, 437, 3037, 1218, 8977, 267, 2881, 63, 5155, 12, 8977, 63, 5155, 275, 437, 3037, 14, 981, 63, 2355, 63, 6562, 8, 12371, 4022, 17, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1218, 3510, 4093, 267, 327, 267, 1369, 275, 298, 28001, 1253, 3107, 645, 1159, 3510, 13, 4093, 2287, 2, 398, 3510, 4093, 63, 1562, 275, 437, 3037, 14, 1222, 63, 3029, 4093, 1562, 8, 1802, 12, 359, 58, 645, 467, 499, 9, 267, 3510, 4093, 63, 1562, 18, 275, 3107, 645, 14, 1222, 63, 3029, 4093, 1562, 8, 1802, 12, 359, 28001, 467, 499, 9, 267, 291, 14, 629, 8, 3029, 4093, 63, 1562, 12, 3510, 4093, 63, 1562, 18, 12, 298, 3029, 4093, 7149, 2153, 1431, 2685, 398, 327, 3222, 325, 683, 370, 3510, 4093, 63, 1562, 267, 327, 267, 754, 12, 1245, 275, 333, 3122, 63, 4354, 14, 2254, 504, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 288, 437, 3037, 14, 973, 1562, 1062, 3510, 4093, 63, 1562, 12, 650, 627, 1616, 1011, 1695, 9, 267, 702, 334, 1099, 508, 378, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 2274, 8103, 370, 3510, 4093, 63, 1562, 267, 327, 267, 3510, 4093, 63, 14887, 63, 5155, 275, 298, 3947, 4093, 2, 435, 2863, 14, 362, 63, 2355, 63, 495, 342, 267, 7062, 12, 4773, 275, 333, 3122, 63, 4354, 14, 2683, 63, 14887, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 3510, 4093, 63, 1562, 12, 3510, 4093, 63, 14887, 63, 5155, 9, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 4773, 9, 398, 327, 2070, 3510, 4093, 3066, 2347, 267, 7062, 12, 4773, 18, 275, 333, 3122, 63, 4354, 14, 1037, 63, 3029, 4093, 2347, 8, 58, 645, 14, 354, 12, 3107, 645, 14, 2060, 12, 4773, 12, 715, 9, 267, 291, 14, 629, 8, 825, 12, 378, 12, 4773, 18, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 9307, 6250, 370, 3510, 4093, 63, 14887, 63, 5155, 267, 327, 267, 7062, 12, 1245, 275, 333, 3122, 63, 4354, 14, 9609, 63, 4736, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 3510, 4093, 63, 14887, 63, 5155, 12, 8977, 63, 5155, 12, 283, 5237, 358, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 1245, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1104, 6250, 267, 25949, 275, 3107, 645, 14, 362, 63, 1562, 6562, 8, 3029, 4093, 63, 1562, 12, 715, 2736, 267, 291, 14, 15070, 8, 552, 8, 8356, 395, 378, 12, 298, 1397, 6250, 1911, 737, 298, 435, 3510, 4093, 63, 1562, 9, 267, 2187, 63, 7450, 275, 769, 8, 2457, 8, 2734, 282, 26, 282, 14, 5155, 508, 8977, 63, 5155, 436, 282, 14, 4736, 508, 298, 5237, 401, 25949, 9, 776, 267, 291, 14, 629, 8, 552, 8, 4494, 63, 7450, 395, 413, 12, 298, 1397, 6250, 1911, 737, 298, 435, 3510, 4093, 63, 1562, 9, 398, 327, 9307, 6250, 370, 445, 688, 89, 267, 327, 267, 7062, 12, 4773, 275, 333, 3122, 63, 4354, 14, 9609, 63, 4736, 8, 28001, 14, 354, 12, 437, 3037, 14, 2060, 12, 445, 688, 89, 14, 14887, 63, 5155, 12, 8977, 63, 5155, 12, 283, 5237, 358, 267, 291, 14, 629, 8, 825, 12, 1233, 14, 3742, 12, 4773, 9, 398, 327, 2070, 3510, 4093, 3066, 2347, 267, 7062, 12, 4773, 18, 275, 333, 3122, 63, 4354, 14, 1037, 63, 3029, 4093, 2347, 8, 58, 645, 14, 354, 12, 3107, 645, 14, 2060, 12, 4773, 12, 715, 9, 267, 291, 14, 629, 8, 825, 12, 378, 12, 4773, 18, 9, 267, 437, 3037, 14, 827, 316, 342, 398, 327, 1104, 6250, 267, 25949, 275, 445, 688, 89, 14, 362, 63, 1562, 6562, 8, 35, 688, 89, 14, 14887, 1562, 1062, 715, 2736, 267, 291, 14, 15070, 8, 552, 8, 8356, 395, 378, 12, 298, 1397, 6250, 1911, 737, 298, 435, 445, 688, 89, 14, 14887, 1562, 1012, 267, 2187, 63, 7450, 275, 769, 8, 2457, 8, 2734, 282, 26, 282, 14, 5155, 508, 8977, 63, 5155, 436, 282, 14, 4736, 508, 298, 5237, 401, 25949, 9, 776, 267, 291, 14, 629, 8, 552, 8, 4494, 63, 7450, 395, 413, 12, 298, 1397, 6250, 1911, 737, 298, 435, 445, 688, 89, 14, 14887, 1562, 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, 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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1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
landrito/api-client-staging
generated/python/gapic-google-cloud-pubsub-v1/setup.py
7
1614
"""A setup module for the GAPIC Google Cloud Pub/Sub API library. See: https://packaging.python.org/en/latest/distributing.html https://github.com/pypa/sampleproject """ from setuptools import setup, find_packages import sys install_requires = [ 'google-gax>=0.15.7, <0.16dev', 'oauth2client>=2.0.0, <4.0dev', 'proto-google-cloud-pubsub-v1[grpc]>=0.15.4, <0.16dev', 'googleapis-common-protos[grpc]>=1.5.2, <2.0dev', 'grpc-google-iam-v1>=0.11.1, <0.12dev', ] setup( name='gapic-google-cloud-pubsub-v1', version='0.15.4', author='Google Inc', author_email='googleapis-packages@google.com', classifiers=[ 'Intended Audience :: Developers', 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', ], description='GAPIC library for the Google Cloud Pub/Sub API', include_package_data=True, long_description=open('README.rst').read(), install_requires=install_requires, license='Apache-2.0', packages=find_packages(), namespace_packages=[ 'google', 'google.cloud', 'google.cloud.gapic', 'google.cloud.gapic.pubsub' ], url='https://github.com/googleapis/googleapis')
bsd-3-clause
[ 624, 33, 3272, 859, 367, 314, 598, 1282, 948, 4475, 8142, 510, 456, 15, 2610, 3261, 3555, 14, 199, 199, 9295, 26, 199, 2859, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 20231, 4655, 14, 1360, 199, 2859, 921, 5031, 14, 957, 15, 647, 387, 15, 3271, 1715, 199, 624, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 646, 984, 199, 199, 3174, 63, 6537, 275, 359, 272, 283, 3098, 13, 71, 1219, 8119, 16, 14, 1046, 14, 23, 12, 665, 16, 14, 975, 2374, 297, 272, 283, 6126, 18, 1258, 8119, 18, 14, 16, 14, 16, 12, 665, 20, 14, 16, 2374, 297, 272, 283, 2625, 13, 3098, 13, 4091, 13, 20213, 13, 86, 17, 59, 15391, 61, 8119, 16, 14, 1046, 14, 20, 12, 665, 16, 14, 975, 2374, 297, 272, 283, 17533, 13, 2330, 13, 27478, 59, 15391, 61, 8119, 17, 14, 21, 14, 18, 12, 665, 18, 14, 16, 2374, 297, 272, 283, 15391, 13, 3098, 13, 17741, 13, 86, 17, 8119, 16, 14, 845, 14, 17, 12, 665, 16, 14, 713, 2374, 297, 199, 61, 199, 199, 2758, 8, 272, 536, 534, 15046, 530, 13, 3098, 13, 4091, 13, 20213, 13, 86, 17, 297, 272, 1015, 534, 16, 14, 1046, 14, 20, 297, 272, 4132, 534, 13266, 3277, 297, 272, 4132, 63, 2123, 534, 17533, 13, 5154, 32, 3098, 14, 957, 297, 272, 19137, 1524, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 25654, 297, 272, 2156, 272, 1369, 534, 39, 1282, 948, 3555, 367, 314, 4475, 8142, 510, 456, 15, 2610, 3261, 297, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 3907, 63, 6537, 29, 3174, 63, 6537, 12, 272, 4190, 534, 28993, 13, 18, 14, 16, 297, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 3231, 63, 5154, 1524, 267, 283, 3098, 297, 283, 3098, 14, 4091, 297, 283, 3098, 14, 4091, 14, 15046, 530, 297, 267, 283, 3098, 14, 4091, 14, 15046, 530, 14, 20213, 7, 272, 2156, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 17533, 15, 17533, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 33, 3272, 859, 367, 314, 598, 1282, 948, 4475, 8142, 510, 456, 15, 2610, 3261, 3555, 14, 199, 199, 9295, 26, 199, 2859, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 20231, 4655, 14, 1360, 199, 2859, 921, 5031, 14, 957, 15, 647, 387, 15, 3271, 1715, 199, 624, 199, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 646, 984, 199, 199, 3174, 63, 6537, 275, 359, 272, 283, 3098, 13, 71, 1219, 8119, 16, 14, 1046, 14, 23, 12, 665, 16, 14, 975, 2374, 297, 272, 283, 6126, 18, 1258, 8119, 18, 14, 16, 14, 16, 12, 665, 20, 14, 16, 2374, 297, 272, 283, 2625, 13, 3098, 13, 4091, 13, 20213, 13, 86, 17, 59, 15391, 61, 8119, 16, 14, 1046, 14, 20, 12, 665, 16, 14, 975, 2374, 297, 272, 283, 17533, 13, 2330, 13, 27478, 59, 15391, 61, 8119, 17, 14, 21, 14, 18, 12, 665, 18, 14, 16, 2374, 297, 272, 283, 15391, 13, 3098, 13, 17741, 13, 86, 17, 8119, 16, 14, 845, 14, 17, 12, 665, 16, 14, 713, 2374, 297, 199, 61, 199, 199, 2758, 8, 272, 536, 534, 15046, 530, 13, 3098, 13, 4091, 13, 20213, 13, 86, 17, 297, 272, 1015, 534, 16, 14, 1046, 14, 20, 297, 272, 4132, 534, 13266, 3277, 297, 272, 4132, 63, 2123, 534, 17533, 13, 5154, 32, 3098, 14, 957, 297, 272, 19137, 1524, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 23753, 9795, 3800, 650, 446, 32657, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 3668, 2290, 844, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 25654, 297, 272, 2156, 272, 1369, 534, 39, 1282, 948, 3555, 367, 314, 4475, 8142, 510, 456, 15, 2610, 3261, 297, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 3907, 63, 6537, 29, 3174, 63, 6537, 12, 272, 4190, 534, 28993, 13, 18, 14, 16, 297, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 3231, 63, 5154, 1524, 267, 283, 3098, 297, 283, 3098, 14, 4091, 297, 283, 3098, 14, 4091, 14, 15046, 530, 297, 267, 283, 3098, 14, 4091, 14, 15046, 530, 14, 20213, 7, 272, 2156, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 17533, 15, 17533, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
waytai/odoo
addons/auth_ldap/__openerp__.py
260
1516
############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name' : 'Authentication via LDAP', 'version' : '1.0', 'depends' : ['base'], 'author' : 'OpenERP SA', #'description': < auto-loaded from README file 'website' : 'https://www.odoo.com', 'category' : 'Authentication', 'data' : [ 'users_ldap_view.xml', 'user_ldap_installer.xml', 'security/ir.model.access.csv', ], 'auto_install': False, 'installable': True, 'external_dependencies' : { 'python' : ['ldap'], } } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 7, 520, 283, 10348, 4799, 20717, 297, 272, 283, 1023, 7, 520, 283, 17, 14, 16, 297, 272, 283, 8912, 7, 520, 788, 1095, 995, 272, 283, 2502, 7, 520, 283, 25347, 13950, 297, 272, 17384, 1802, 356, 665, 2599, 13, 4591, 687, 27781, 570, 272, 283, 7360, 7, 520, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 3710, 7, 520, 283, 10348, 297, 272, 283, 576, 7, 520, 359, 267, 283, 3707, 63, 9642, 63, 1345, 14, 1652, 297, 267, 283, 751, 63, 9642, 63, 17047, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 272, 2156, 272, 283, 2495, 63, 3174, 356, 756, 12, 272, 283, 21762, 356, 715, 12, 272, 283, 5159, 63, 5714, 7, 520, 469, 267, 283, 1548, 7, 520, 788, 9642, 995, 272, 789, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 7, 520, 283, 10348, 4799, 20717, 297, 272, 283, 1023, 7, 520, 283, 17, 14, 16, 297, 272, 283, 8912, 7, 520, 788, 1095, 995, 272, 283, 2502, 7, 520, 283, 25347, 13950, 297, 272, 17384, 1802, 356, 665, 2599, 13, 4591, 687, 27781, 570, 272, 283, 7360, 7, 520, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 3710, 7, 520, 283, 10348, 297, 272, 283, 576, 7, 520, 359, 267, 283, 3707, 63, 9642, 63, 1345, 14, 1652, 297, 267, 283, 751, 63, 9642, 63, 17047, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 272, 2156, 272, 283, 2495, 63, 3174, 356, 756, 12, 272, 283, 21762, 356, 715, 12, 272, 283, 5159, 63, 5714, 7, 520, 469, 267, 283, 1548, 7, 520, 788, 9642, 995, 272, 789, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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
2823
from rest_framework.decorators import api_view from rest_framework.response import Response import view_utils as utils from django.db.models import Q from frontend.models import PCT, Practice @api_view(['GET']) def org_codes(request, format=None): org_codes = utils.param_to_list(request.query_params.get('q', None)) org_types = utils.param_to_list(request.query_params.get('org_type', None)) is_exact = request.GET.get('exact', '') if not org_types: org_types = [''] if not org_codes: org_codes = [''] data = [] for org_code in org_codes: for org_type in org_types: data += _get_org_from_code(org_code, is_exact, org_type) return Response(data) def _get_org_from_code(q, is_exact, org_type): if is_exact: if len(q) == 3: results = PCT.objects.filter(Q(code=q) | Q(name=q)) \ .filter(org_type='CCG') values = results.values('name', 'code') for v in values: v['id'] = v['code'] v['type'] = 'CCG' else: results = Practice.objects.filter(Q(code=q) | Q(name=q)) values = results.values('name', 'code', 'ccg') for v in values: v['id'] = v['code'] v['type'] = 'practice' else: values = [] if org_type == 'practice': values += _get_practices_like_code(q) elif org_type == 'CCG': values += _get_pcts_like_code(q) else: values += _get_pcts_like_code(q) values += _get_practices_like_code(q) return values def _get_practices_like_code(q): if q: practices = Practice.objects.filter( Q(setting=4) & Q(status_code='A') & ( Q(code__istartswith=q) | Q(name__icontains=q) | Q(postcode__istartswith=q))).order_by('name') else: practices = Practice.objects.all() results = [] for p in practices: data = { 'id': p.code, 'code': p.code, 'name': p.name, 'postcode': p.postcode, 'setting': p.setting, 'setting_name': None, 'type': 'practice', 'ccg': None } data['setting_name'] = p.get_setting_display() if p.ccg: data['ccg'] = p.ccg.code results.append(data) return results def _get_pcts_like_code(q): pcts = PCT.objects.filter(close_date__isnull=True) if q: pcts = pcts.filter(Q(code__istartswith=q) | Q(name__icontains=q)) \ .filter(org_type='CCG') pct_values = pcts.values('name', 'code') for p in pct_values: p['id'] = p['code'] p['type'] = 'CCG' return pct_values
mit
[ 504, 4618, 63, 4857, 14, 11582, 492, 2986, 63, 1345, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 646, 2455, 63, 1208, 465, 3778, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 22523, 14, 992, 492, 510, 1028, 12, 510, 6457, 3548, 199, 199, 32, 1246, 63, 1345, 2941, 2970, 1105, 199, 318, 5981, 63, 6021, 8, 1069, 12, 1475, 29, 403, 304, 272, 5981, 63, 6021, 275, 3778, 14, 635, 63, 475, 63, 513, 8, 1069, 14, 1131, 63, 1162, 14, 362, 360, 81, 297, 488, 430, 272, 5981, 63, 1313, 275, 3778, 14, 635, 63, 475, 63, 513, 8, 1069, 14, 1131, 63, 1162, 14, 362, 360, 1308, 63, 466, 297, 488, 430, 272, 365, 63, 7327, 275, 1056, 14, 2970, 14, 362, 360, 7327, 297, 4074, 272, 340, 440, 5981, 63, 1313, 26, 267, 5981, 63, 1313, 275, 24506, 272, 340, 440, 5981, 63, 6021, 26, 267, 5981, 63, 6021, 275, 24506, 272, 666, 275, 942, 272, 367, 5981, 63, 600, 315, 5981, 63, 6021, 26, 267, 367, 5981, 63, 466, 315, 5981, 63, 1313, 26, 288, 666, 847, 485, 362, 63, 1308, 63, 504, 63, 600, 8, 1308, 63, 600, 12, 365, 63, 7327, 12, 5981, 63, 466, 9, 272, 372, 7232, 8, 576, 9, 421, 199, 318, 485, 362, 63, 1308, 63, 504, 63, 600, 8, 81, 12, 365, 63, 7327, 12, 5981, 63, 466, 304, 272, 340, 365, 63, 7327, 26, 267, 340, 822, 8, 81, 9, 508, 650, 26, 288, 2058, 275, 510, 1028, 14, 1462, 14, 1541, 8, 49, 8, 600, 29, 81, 9, 1204, 1413, 8, 354, 29, 81, 430, 971, 639, 1275, 1541, 8, 1308, 63, 466, 534, 18636, 358, 288, 1338, 275, 2058, 14, 1459, 360, 354, 297, 283, 600, 358, 288, 367, 373, 315, 1338, 26, 355, 373, 459, 344, 418, 275, 373, 459, 600, 418, 355, 373, 459, 466, 418, 275, 283, 18636, 7, 267, 587, 26, 288, 2058, 275, 510, 6457, 3548, 14, 1462, 14, 1541, 8, 49, 8, 600, 29, 81, 9, 1204, 1413, 8, 354, 29, 81, 430, 288, 1338, 275, 2058, 14, 1459, 360, 354, 297, 283, 600, 297, 283, 2055, 71, 358, 288, 367, 373, 315, 1338, 26, 355, 373, 459, 344, 418, 275, 373, 459, 600, 418, 355, 373, 459, 466, 418, 275, 283, 80, 6457, 3548, 7, 272, 587, 26, 267, 1338, 275, 942, 267, 340, 5981, 63, 466, 508, 283, 80, 6457, 3548, 356, 288, 1338, 847, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 9, 267, 916, 5981, 63, 466, 508, 283, 18636, 356, 288, 1338, 847, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 9, 267, 587, 26, 288, 1338, 847, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 9, 288, 1338, 847, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 9, 272, 372, 1338, 421, 199, 318, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 304, 272, 340, 1894, 26, 267, 20594, 7724, 275, 510, 6457, 3548, 14, 1462, 14, 1541, 8, 288, 1413, 8, 6031, 29, 20, 9, 1253, 1413, 8, 1205, 63, 600, 534, 33, 358, 1253, 334, 355, 1413, 8, 600, 363, 631, 580, 1908, 29, 81, 9, 1204, 355, 1413, 8, 354, 363, 30314, 29, 81, 9, 1204, 1413, 8, 1932, 600, 363, 631, 580, 1908, 29, 81, 23261, 1648, 63, 991, 360, 354, 358, 272, 587, 26, 267, 20594, 7724, 275, 510, 6457, 3548, 14, 1462, 14, 452, 342, 272, 2058, 275, 942, 272, 367, 299, 315, 20594, 7724, 26, 267, 666, 275, 469, 288, 283, 344, 356, 299, 14, 600, 12, 288, 283, 600, 356, 299, 14, 600, 12, 288, 283, 354, 356, 299, 14, 354, 12, 288, 283, 1932, 600, 356, 299, 14, 1932, 600, 12, 288, 283, 6031, 356, 299, 14, 6031, 12, 288, 283, 6031, 63, 354, 356, 488, 12, 288, 283, 466, 356, 283, 80, 6457, 3548, 297, 288, 283, 2055, 71, 356, 488, 267, 789, 267, 666, 459, 6031, 63, 354, 418, 275, 299, 14, 362, 63, 6031, 63, 2918, 342, 267, 340, 299, 14, 2055, 71, 26, 288, 666, 459, 2055, 71, 418, 275, 299, 14, 2055, 71, 14, 600, 267, 2058, 14, 740, 8, 576, 9, 272, 372, 2058, 421, 199, 318, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 304, 272, 299, 3021, 275, 510, 1028, 14, 1462, 14, 1541, 8, 1600, 63, 602, 363, 15114, 29, 549, 9, 272, 340, 1894, 26, 267, 299, 3021, 275, 299, 3021, 14, 1541, 8, 49, 8, 600, 363, 631, 580, 1908, 29, 81, 9, 1204, 2574, 1413, 8, 354, 363, 30314, 29, 81, 430, 971, 717, 1275, 1541, 8, 1308, 63, 466, 534, 18636, 358, 272, 299, 319, 63, 1459, 275, 299, 3021, 14, 1459, 360, 354, 297, 283, 600, 358, 272, 367, 299, 315, 299, 319, 63, 1459, 26, 267, 299, 459, 344, 418, 275, 299, 459, 600, 418, 267, 299, 459, 466, 418, 275, 283, 18636, 7, 272, 372, 299, 319, 63, 1459, 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 ]
[ 4618, 63, 4857, 14, 11582, 492, 2986, 63, 1345, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 646, 2455, 63, 1208, 465, 3778, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 22523, 14, 992, 492, 510, 1028, 12, 510, 6457, 3548, 199, 199, 32, 1246, 63, 1345, 2941, 2970, 1105, 199, 318, 5981, 63, 6021, 8, 1069, 12, 1475, 29, 403, 304, 272, 5981, 63, 6021, 275, 3778, 14, 635, 63, 475, 63, 513, 8, 1069, 14, 1131, 63, 1162, 14, 362, 360, 81, 297, 488, 430, 272, 5981, 63, 1313, 275, 3778, 14, 635, 63, 475, 63, 513, 8, 1069, 14, 1131, 63, 1162, 14, 362, 360, 1308, 63, 466, 297, 488, 430, 272, 365, 63, 7327, 275, 1056, 14, 2970, 14, 362, 360, 7327, 297, 4074, 272, 340, 440, 5981, 63, 1313, 26, 267, 5981, 63, 1313, 275, 24506, 272, 340, 440, 5981, 63, 6021, 26, 267, 5981, 63, 6021, 275, 24506, 272, 666, 275, 942, 272, 367, 5981, 63, 600, 315, 5981, 63, 6021, 26, 267, 367, 5981, 63, 466, 315, 5981, 63, 1313, 26, 288, 666, 847, 485, 362, 63, 1308, 63, 504, 63, 600, 8, 1308, 63, 600, 12, 365, 63, 7327, 12, 5981, 63, 466, 9, 272, 372, 7232, 8, 576, 9, 421, 199, 318, 485, 362, 63, 1308, 63, 504, 63, 600, 8, 81, 12, 365, 63, 7327, 12, 5981, 63, 466, 304, 272, 340, 365, 63, 7327, 26, 267, 340, 822, 8, 81, 9, 508, 650, 26, 288, 2058, 275, 510, 1028, 14, 1462, 14, 1541, 8, 49, 8, 600, 29, 81, 9, 1204, 1413, 8, 354, 29, 81, 430, 971, 639, 1275, 1541, 8, 1308, 63, 466, 534, 18636, 358, 288, 1338, 275, 2058, 14, 1459, 360, 354, 297, 283, 600, 358, 288, 367, 373, 315, 1338, 26, 355, 373, 459, 344, 418, 275, 373, 459, 600, 418, 355, 373, 459, 466, 418, 275, 283, 18636, 7, 267, 587, 26, 288, 2058, 275, 510, 6457, 3548, 14, 1462, 14, 1541, 8, 49, 8, 600, 29, 81, 9, 1204, 1413, 8, 354, 29, 81, 430, 288, 1338, 275, 2058, 14, 1459, 360, 354, 297, 283, 600, 297, 283, 2055, 71, 358, 288, 367, 373, 315, 1338, 26, 355, 373, 459, 344, 418, 275, 373, 459, 600, 418, 355, 373, 459, 466, 418, 275, 283, 80, 6457, 3548, 7, 272, 587, 26, 267, 1338, 275, 942, 267, 340, 5981, 63, 466, 508, 283, 80, 6457, 3548, 356, 288, 1338, 847, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 9, 267, 916, 5981, 63, 466, 508, 283, 18636, 356, 288, 1338, 847, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 9, 267, 587, 26, 288, 1338, 847, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 9, 288, 1338, 847, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 9, 272, 372, 1338, 421, 199, 318, 485, 362, 63, 80, 6457, 7724, 63, 2930, 63, 600, 8, 81, 304, 272, 340, 1894, 26, 267, 20594, 7724, 275, 510, 6457, 3548, 14, 1462, 14, 1541, 8, 288, 1413, 8, 6031, 29, 20, 9, 1253, 1413, 8, 1205, 63, 600, 534, 33, 358, 1253, 334, 355, 1413, 8, 600, 363, 631, 580, 1908, 29, 81, 9, 1204, 355, 1413, 8, 354, 363, 30314, 29, 81, 9, 1204, 1413, 8, 1932, 600, 363, 631, 580, 1908, 29, 81, 23261, 1648, 63, 991, 360, 354, 358, 272, 587, 26, 267, 20594, 7724, 275, 510, 6457, 3548, 14, 1462, 14, 452, 342, 272, 2058, 275, 942, 272, 367, 299, 315, 20594, 7724, 26, 267, 666, 275, 469, 288, 283, 344, 356, 299, 14, 600, 12, 288, 283, 600, 356, 299, 14, 600, 12, 288, 283, 354, 356, 299, 14, 354, 12, 288, 283, 1932, 600, 356, 299, 14, 1932, 600, 12, 288, 283, 6031, 356, 299, 14, 6031, 12, 288, 283, 6031, 63, 354, 356, 488, 12, 288, 283, 466, 356, 283, 80, 6457, 3548, 297, 288, 283, 2055, 71, 356, 488, 267, 789, 267, 666, 459, 6031, 63, 354, 418, 275, 299, 14, 362, 63, 6031, 63, 2918, 342, 267, 340, 299, 14, 2055, 71, 26, 288, 666, 459, 2055, 71, 418, 275, 299, 14, 2055, 71, 14, 600, 267, 2058, 14, 740, 8, 576, 9, 272, 372, 2058, 421, 199, 318, 485, 362, 63, 80, 3021, 63, 2930, 63, 600, 8, 81, 304, 272, 299, 3021, 275, 510, 1028, 14, 1462, 14, 1541, 8, 1600, 63, 602, 363, 15114, 29, 549, 9, 272, 340, 1894, 26, 267, 299, 3021, 275, 299, 3021, 14, 1541, 8, 49, 8, 600, 363, 631, 580, 1908, 29, 81, 9, 1204, 2574, 1413, 8, 354, 363, 30314, 29, 81, 430, 971, 717, 1275, 1541, 8, 1308, 63, 466, 534, 18636, 358, 272, 299, 319, 63, 1459, 275, 299, 3021, 14, 1459, 360, 354, 297, 283, 600, 358, 272, 367, 299, 315, 299, 319, 63, 1459, 26, 267, 299, 459, 344, 418, 275, 299, 459, 600, 418, 267, 299, 459, 466, 418, 275, 283, 18636, 7, 272, 372, 299, 319, 63, 1459, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
FabriceSalvaire/PyDVI
unit_test/test_Encoding.py
1
1812
#################################################################################################### # # PyDvi - A Python Library to Process DVI Stream. # Copyright (C) 2011 Salvaire Fabrice # #################################################################################################### #################################################################################################### # # Audit # # - 20/11/2011 fabrice # #################################################################################################### #################################################################################################### import unittest #################################################################################################### from PyDvi.Font.Encoding import * from PyDvi.Kpathsea import * #################################################################################################### class TestEncoding(unittest.TestCase): def test(self): encoding_file = kpsewhich('ec', file_format='enc files') self.assertIsNotNone(encoding_file) print 'Encoding file:', encoding_file encoding = Encoding(encoding_file) self.assertEqual(len(encoding), 256) self.assertEqual(encoding.to_name(0xA0), 'abreve') self.assertEqual(encoding[0xA0], 'abreve') self.assertEqual(encoding.to_index('abreve'), 0xA0) self.assertEqual(encoding['abreve'], 0xA0) #################################################################################################### if __name__ == '__main__': unittest.main() #################################################################################################### # # End # ####################################################################################################
gpl-3.0
[ 3060, 1371, 381, 199, 3, 199, 3, 1611, 36, 433, 446, 437, 2018, 11243, 370, 7132, 577, 17655, 8271, 14, 199, 3, 1898, 334, 35, 9, 7760, 428, 279, 3042, 3621, 481, 371, 322, 301, 199, 3, 199, 3060, 1371, 381, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 31853, 1741, 199, 3, 199, 3, 446, 3388, 15, 845, 15, 8128, 31507, 322, 301, 199, 3, 199, 3060, 1371, 381, 199, 199, 3060, 1371, 381, 199, 199, 646, 2882, 199, 199, 3060, 1371, 381, 199, 199, 504, 1611, 36, 433, 14, 6986, 14, 7630, 492, 627, 199, 504, 1611, 36, 433, 14, 43, 515, 27590, 492, 627, 199, 199, 3060, 1371, 381, 199, 199, 533, 1379, 7630, 8, 2796, 14, 1746, 304, 339, 347, 511, 8, 277, 304, 398, 2644, 63, 493, 275, 1022, 80, 261, 6777, 360, 825, 297, 570, 63, 908, 534, 10945, 1584, 358, 267, 291, 14, 10389, 8, 2991, 63, 493, 9, 267, 870, 283, 7630, 570, 6536, 2644, 63, 493, 398, 2644, 275, 19694, 8, 2991, 63, 493, 9, 267, 291, 14, 629, 8, 552, 8, 2991, 395, 7633, 9, 267, 291, 14, 629, 8, 2991, 14, 475, 63, 354, 8, 16, 7471, 16, 395, 283, 371, 30496, 358, 267, 291, 14, 629, 8, 2991, 59, 16, 7471, 16, 467, 283, 371, 30496, 358, 267, 291, 14, 629, 8, 2991, 14, 475, 63, 1080, 360, 371, 30496, 659, 378, 7471, 16, 9, 267, 291, 14, 629, 8, 2991, 459, 371, 30496, 995, 378, 7471, 16, 9, 199, 199, 3060, 1371, 381, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 2882, 14, 973, 342, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 9599, 199, 3, 199, 3060, 1371, 381, 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 ]
[ 1371, 381, 199, 3, 199, 3, 1611, 36, 433, 446, 437, 2018, 11243, 370, 7132, 577, 17655, 8271, 14, 199, 3, 1898, 334, 35, 9, 7760, 428, 279, 3042, 3621, 481, 371, 322, 301, 199, 3, 199, 3060, 1371, 381, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 31853, 1741, 199, 3, 199, 3, 446, 3388, 15, 845, 15, 8128, 31507, 322, 301, 199, 3, 199, 3060, 1371, 381, 199, 199, 3060, 1371, 381, 199, 199, 646, 2882, 199, 199, 3060, 1371, 381, 199, 199, 504, 1611, 36, 433, 14, 6986, 14, 7630, 492, 627, 199, 504, 1611, 36, 433, 14, 43, 515, 27590, 492, 627, 199, 199, 3060, 1371, 381, 199, 199, 533, 1379, 7630, 8, 2796, 14, 1746, 304, 339, 347, 511, 8, 277, 304, 398, 2644, 63, 493, 275, 1022, 80, 261, 6777, 360, 825, 297, 570, 63, 908, 534, 10945, 1584, 358, 267, 291, 14, 10389, 8, 2991, 63, 493, 9, 267, 870, 283, 7630, 570, 6536, 2644, 63, 493, 398, 2644, 275, 19694, 8, 2991, 63, 493, 9, 267, 291, 14, 629, 8, 552, 8, 2991, 395, 7633, 9, 267, 291, 14, 629, 8, 2991, 14, 475, 63, 354, 8, 16, 7471, 16, 395, 283, 371, 30496, 358, 267, 291, 14, 629, 8, 2991, 59, 16, 7471, 16, 467, 283, 371, 30496, 358, 267, 291, 14, 629, 8, 2991, 14, 475, 63, 1080, 360, 371, 30496, 659, 378, 7471, 16, 9, 267, 291, 14, 629, 8, 2991, 459, 371, 30496, 995, 378, 7471, 16, 9, 199, 199, 3060, 1371, 381, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 2882, 14, 973, 342, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 9599, 199, 3, 199, 3060, 1371, 381, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
PaddlePaddle/models
PaddleCV/image_classification/dali.py
1
9463
# Copyright (c) 2019 PaddlePaddle 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. from __future__ import division import os from nvidia.dali.pipeline import Pipeline import nvidia.dali.ops as ops import nvidia.dali.types as types from nvidia.dali.plugin.paddle import DALIGenericIterator import paddle from paddle import fluid class HybridTrainPipe(Pipeline): def __init__(self, file_root, file_list, batch_size, resize_shorter, crop, min_area, lower, upper, interp, mean, std, device_id, shard_id=0, num_shards=1, random_shuffle=True, num_threads=4, seed=42, pad_output=False, output_dtype=types.FLOAT): super(HybridTrainPipe, self).__init__( batch_size, num_threads, device_id, seed=seed) self.input = ops.FileReader( file_root=file_root, file_list=file_list, shard_id=shard_id, num_shards=num_shards, random_shuffle=random_shuffle) # set internal nvJPEG buffers size to handle full-sized ImageNet images # without additional reallocations device_memory_padding = 211025920 host_memory_padding = 140544512 self.decode = ops.ImageDecoderRandomCrop( device='mixed', output_type=types.RGB, device_memory_padding=device_memory_padding, host_memory_padding=host_memory_padding, random_aspect_ratio=[lower, upper], random_area=[min_area, 1.0], num_attempts=100) self.res = ops.Resize( device='gpu', resize_x=crop, resize_y=crop, interp_type=interp) self.cmnp = ops.CropMirrorNormalize( device="gpu", output_dtype=output_dtype, output_layout=types.NCHW, crop=(crop, crop), image_type=types.RGB, mean=mean, std=std, pad_output=pad_output) self.coin = ops.CoinFlip(probability=0.5) self.to_int64 = ops.Cast(dtype=types.INT64, device="gpu") def define_graph(self): rng = self.coin() jpegs, labels = self.input(name="Reader") images = self.decode(jpegs) images = self.res(images) output = self.cmnp(images.gpu(), mirror=rng) return [output, self.to_int64(labels.gpu())] def __len__(self): return self.epoch_size("Reader") class HybridValPipe(Pipeline): def __init__(self, file_root, file_list, batch_size, resize_shorter, crop, interp, mean, std, device_id, shard_id=0, num_shards=1, random_shuffle=False, num_threads=4, seed=42, pad_output=False, output_dtype=types.FLOAT): super(HybridValPipe, self).__init__( batch_size, num_threads, device_id, seed=seed) self.input = ops.FileReader( file_root=file_root, file_list=file_list, shard_id=shard_id, num_shards=num_shards, random_shuffle=random_shuffle) self.decode = ops.ImageDecoder(device="mixed", output_type=types.RGB) self.res = ops.Resize( device="gpu", resize_shorter=resize_shorter, interp_type=interp) self.cmnp = ops.CropMirrorNormalize( device="gpu", output_dtype=output_dtype, output_layout=types.NCHW, crop=(crop, crop), image_type=types.RGB, mean=mean, std=std, pad_output=pad_output) self.to_int64 = ops.Cast(dtype=types.INT64, device="gpu") def define_graph(self): jpegs, labels = self.input(name="Reader") images = self.decode(jpegs) images = self.res(images) output = self.cmnp(images) return [output, self.to_int64(labels.gpu())] def __len__(self): return self.epoch_size("Reader") def build(settings, mode='train'): env = os.environ assert settings.use_gpu, "gpu training is required for DALI" assert not settings.use_mixup, "mixup is not supported by DALI reader" assert not settings.use_aa, "auto augment is not supported by DALI reader" assert float(env.get('FLAGS_fraction_of_gpu_memory_to_use', 0.92)) < 0.9, \ "Please leave enough GPU memory for DALI workspace, e.g., by setting" \ " `export FLAGS_fraction_of_gpu_memory_to_use=0.8`" file_root = settings.data_dir bs = settings.batch_size assert bs % paddle.fluid.core.get_cuda_device_count() == 0, \ "batch size must be multiple of number of devices" batch_size = bs // paddle.fluid.core.get_cuda_device_count() mean = [v * 255 for v in settings.image_mean] std = [v * 255 for v in settings.image_std] crop = settings.image_shape[1] resize_shorter = settings.resize_short_size min_area = settings.lower_scale lower = settings.lower_ratio upper = settings.upper_ratio output_dtype = types.FLOAT16 if (settings.use_amp and settings.use_pure_fp16) else types.FLOAT interp = settings.interpolation or 1 # default to linear interp_map = { 0: types.INTERP_NN, # cv2.INTER_NEAREST 1: types.INTERP_LINEAR, # cv2.INTER_LINEAR 2: types.INTERP_CUBIC, # cv2.INTER_CUBIC 4: types.INTERP_LANCZOS3, # XXX use LANCZOS3 for cv2.INTER_LANCZOS4 } assert interp in interp_map, "interpolation method not supported by DALI" interp = interp_map[interp] pad_output = False if settings.image_shape[0] == 4: pad_output = True if mode != 'train': p = fluid.framework.cuda_places()[0] place = fluid.core.Place() place.set_place(p) device_id = place.gpu_device_id() file_list = os.path.join(file_root, 'val_list.txt') if not os.path.exists(file_list): file_list = None file_root = os.path.join(file_root, 'val') pipe = HybridValPipe( file_root, file_list, batch_size, resize_shorter, crop, interp, mean, std, device_id=device_id, pad_output=pad_output, output_dtype=output_dtype) pipe.build() return DALIGenericIterator( pipe, ['feed_image', 'feed_label'], size=len(pipe), dynamic_shape=True, fill_last_batch=True, last_batch_padded=True) file_list = os.path.join(file_root, 'train_list.txt') if not os.path.exists(file_list): file_list = None file_root = os.path.join(file_root, 'train') if 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env: shard_id = int(env['PADDLE_TRAINER_ID']) num_shards = int(env['PADDLE_TRAINERS_NUM']) device_id = int(env['FLAGS_selected_gpus']) pipe = HybridTrainPipe( file_root, file_list, batch_size, resize_shorter, crop, min_area, lower, upper, interp, mean, std, device_id, shard_id, num_shards, seed=42 + shard_id, pad_output=pad_output, output_dtype=output_dtype) pipe.build() pipelines = [pipe] sample_per_shard = len(pipe) // num_shards else: pipelines = [] places = fluid.framework.cuda_places() num_shards = len(places) for idx, p in enumerate(places): place = fluid.core.Place() place.set_place(p) device_id = place.gpu_device_id() pipe = HybridTrainPipe( file_root, file_list, batch_size, resize_shorter, crop, min_area, lower, upper, interp, mean, std, device_id, idx, num_shards, seed=42 + idx, pad_output=pad_output, output_dtype=output_dtype) pipe.build() pipelines.append(pipe) sample_per_shard = len(pipelines[0]) return DALIGenericIterator( pipelines, ['feed_image', 'feed_label'], size=sample_per_shard) def train(settings): return build(settings, 'train') def val(settings): return build(settings, 'val')
apache-2.0
[ 3, 1898, 334, 67, 9, 20312, 510, 20101, 48, 20101, 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, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 199, 504, 302, 433, 2391, 14, 68, 10874, 14, 7379, 492, 19090, 199, 646, 302, 433, 2391, 14, 68, 10874, 14, 1483, 465, 4156, 199, 646, 302, 433, 2391, 14, 68, 10874, 14, 1313, 465, 2943, 199, 504, 302, 433, 2391, 14, 68, 10874, 14, 2718, 14, 80, 20101, 492, 577, 748, 1277, 727, 530, 3585, 199, 199, 646, 28525, 199, 504, 28525, 492, 25462, 421, 199, 533, 29591, 14601, 18591, 11867, 8, 17562, 304, 272, 347, 636, 826, 721, 277, 12, 326, 570, 63, 1231, 12, 326, 570, 63, 513, 12, 326, 3522, 63, 890, 12, 326, 15210, 63, 609, 3968, 12, 326, 18366, 12, 326, 1748, 63, 6789, 12, 326, 5117, 12, 326, 7008, 12, 326, 23716, 12, 326, 4615, 12, 326, 2418, 12, 326, 2243, 63, 344, 12, 326, 11814, 63, 344, 29, 16, 12, 326, 1967, 63, 15570, 29, 17, 12, 326, 2196, 63, 11777, 29, 549, 12, 326, 1967, 63, 6962, 29, 20, 12, 326, 6347, 29, 2260, 12, 326, 6567, 63, 1199, 29, 797, 12, 326, 1072, 63, 2271, 29, 1313, 14, 11783, 304, 267, 1613, 8, 21568, 14601, 18591, 11867, 12, 291, 2843, 826, 721, 288, 3522, 63, 890, 12, 1967, 63, 6962, 12, 2243, 63, 344, 12, 6347, 29, 5176, 9, 267, 291, 14, 1210, 275, 4156, 14, 1173, 5929, 8, 288, 570, 63, 1231, 29, 493, 63, 1231, 12, 288, 570, 63, 513, 29, 493, 63, 513, 12, 288, 11814, 63, 344, 29, 10810, 63, 344, 12, 288, 1967, 63, 15570, 29, 1507, 63, 15570, 12, 288, 2196, 63, 11777, 29, 2355, 63, 11777, 9, 267, 327, 663, 5007, 26510, 28412, 19383, 1568, 370, 2429, 2615, 13, 15308, 6047, 2480, 5935, 267, 327, 1928, 4722, 3363, 8022, 267, 2243, 63, 4844, 63, 8358, 275, 499, 6019, 11990, 1165, 267, 1591, 63, 4844, 63, 8358, 275, 22796, 1477, 2322, 713, 267, 291, 14, 2708, 275, 4156, 14, 3491, 8326, 3883, 35, 2675, 8, 288, 2243, 534, 10455, 297, 288, 1072, 63, 466, 29, 1313, 14, 12067, 12, 288, 2243, 63, 4844, 63, 8358, 29, 1782, 63, 4844, 63, 8358, 12, 288, 1591, 63, 4844, 63, 8358, 29, 1102, 63, 4844, 63, 8358, 12, 288, 2196, 63, 18658, 63, 6884, 1524, 2325, 12, 7008, 467, 288, 2196, 63, 6789, 1524, 827, 63, 6789, 12, 413, 14, 16, 467, 288, 1967, 63, 13143, 29, 1960, 9, 267, 291, 14, 470, 275, 4156, 14, 24559, 8, 288, 2243, 534, 6477, 297, 15210, 63, 88, 29, 15816, 12, 15210, 63, 89, 29, 15816, 12, 23716, 63, 466, 29, 14252, 9, 267, 291, 14, 4400, 1590, 275, 4156, 14, 35, 2675, 28034, 22580, 8, 288, 2243, 628, 6477, 401, 288, 1072, 63, 2271, 29, 1199, 63, 2271, 12, 288, 1072, 63, 4209, 29, 1313, 14, 27086, 12, 288, 18366, 2687, 15816, 12, 18366, 395, 288, 1834, 63, 466, 29, 1313, 14, 12067, 12, 288, 4615, 29, 3670, 12, 288, 2418, 29, 1516, 12, 288, 6567, 63, 1199, 29, 6226, 63, 1199, 9, 267, 291, 14, 9061, 275, 4156, 14, 967, 262, 38, 3587, 8, 17210, 29, 16, 14, 21, 9, 267, 291, 14, 475, 63, 442, 772, 275, 4156, 14, 24654, 8, 2271, 29, 1313, 14, 2919, 772, 12, 2243, 628, 6477, 531, 339, 347, 5627, 63, 2180, 8, 277, 304, 267, 9038, 275, 291, 14, 9061, 342, 267, 1335, 321, 458, 12, 3628, 275, 291, 14, 1210, 8, 354, 628, 5929, 531, 267, 5935, 275, 291, 14, 2708, 8, 74, 321, 458, 9, 267, 5935, 275, 291, 14, 470, 8, 4782, 9, 267, 1072, 275, 291, 14, 4400, 1590, 8, 4782, 14, 6477, 1062, 15216, 29, 12686, 9, 267, 372, 359, 1199, 12, 291, 14, 475, 63, 442, 772, 8, 3512, 14, 6477, 24821, 339, 347, 636, 552, 721, 277, 304, 267, 372, 291, 14, 7367, 63, 890, 480, 5929, 531, 421, 199, 533, 29591, 14601, 7562, 11867, 8, 17562, 304, 272, 347, 636, 826, 721, 277, 12, 326, 570, 63, 1231, 12, 326, 570, 63, 513, 12, 326, 3522, 63, 890, 12, 326, 15210, 63, 609, 3968, 12, 326, 18366, 12, 326, 23716, 12, 326, 4615, 12, 326, 2418, 12, 326, 2243, 63, 344, 12, 326, 11814, 63, 344, 29, 16, 12, 326, 1967, 63, 15570, 29, 17, 12, 326, 2196, 63, 11777, 29, 797, 12, 326, 1967, 63, 6962, 29, 20, 12, 326, 6347, 29, 2260, 12, 326, 6567, 63, 1199, 29, 797, 12, 326, 1072, 63, 2271, 29, 1313, 14, 11783, 304, 267, 1613, 8, 21568, 14601, 7562, 11867, 12, 291, 2843, 826, 721, 288, 3522, 63, 890, 12, 1967, 63, 6962, 12, 2243, 63, 344, 12, 6347, 29, 5176, 9, 267, 291, 14, 1210, 275, 4156, 14, 1173, 5929, 8, 288, 570, 63, 1231, 29, 493, 63, 1231, 12, 288, 570, 63, 513, 29, 493, 63, 513, 12, 288, 11814, 63, 344, 29, 10810, 63, 344, 12, 288, 1967, 63, 15570, 29, 1507, 63, 15570, 12, 288, 2196, 63, 11777, 29, 2355, 63, 11777, 9, 267, 291, 14, 2708, 275, 4156, 14, 3491, 8326, 8, 1782, 628, 10455, 401, 1072, 63, 466, 29, 1313, 14, 12067, 9, 267, 291, 14, 470, 275, 4156, 14, 24559, 8, 288, 2243, 628, 6477, 401, 15210, 63, 609, 3968, 29 ]
[ 1898, 334, 67, 9, 20312, 510, 20101, 48, 20101, 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, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 199, 504, 302, 433, 2391, 14, 68, 10874, 14, 7379, 492, 19090, 199, 646, 302, 433, 2391, 14, 68, 10874, 14, 1483, 465, 4156, 199, 646, 302, 433, 2391, 14, 68, 10874, 14, 1313, 465, 2943, 199, 504, 302, 433, 2391, 14, 68, 10874, 14, 2718, 14, 80, 20101, 492, 577, 748, 1277, 727, 530, 3585, 199, 199, 646, 28525, 199, 504, 28525, 492, 25462, 421, 199, 533, 29591, 14601, 18591, 11867, 8, 17562, 304, 272, 347, 636, 826, 721, 277, 12, 326, 570, 63, 1231, 12, 326, 570, 63, 513, 12, 326, 3522, 63, 890, 12, 326, 15210, 63, 609, 3968, 12, 326, 18366, 12, 326, 1748, 63, 6789, 12, 326, 5117, 12, 326, 7008, 12, 326, 23716, 12, 326, 4615, 12, 326, 2418, 12, 326, 2243, 63, 344, 12, 326, 11814, 63, 344, 29, 16, 12, 326, 1967, 63, 15570, 29, 17, 12, 326, 2196, 63, 11777, 29, 549, 12, 326, 1967, 63, 6962, 29, 20, 12, 326, 6347, 29, 2260, 12, 326, 6567, 63, 1199, 29, 797, 12, 326, 1072, 63, 2271, 29, 1313, 14, 11783, 304, 267, 1613, 8, 21568, 14601, 18591, 11867, 12, 291, 2843, 826, 721, 288, 3522, 63, 890, 12, 1967, 63, 6962, 12, 2243, 63, 344, 12, 6347, 29, 5176, 9, 267, 291, 14, 1210, 275, 4156, 14, 1173, 5929, 8, 288, 570, 63, 1231, 29, 493, 63, 1231, 12, 288, 570, 63, 513, 29, 493, 63, 513, 12, 288, 11814, 63, 344, 29, 10810, 63, 344, 12, 288, 1967, 63, 15570, 29, 1507, 63, 15570, 12, 288, 2196, 63, 11777, 29, 2355, 63, 11777, 9, 267, 327, 663, 5007, 26510, 28412, 19383, 1568, 370, 2429, 2615, 13, 15308, 6047, 2480, 5935, 267, 327, 1928, 4722, 3363, 8022, 267, 2243, 63, 4844, 63, 8358, 275, 499, 6019, 11990, 1165, 267, 1591, 63, 4844, 63, 8358, 275, 22796, 1477, 2322, 713, 267, 291, 14, 2708, 275, 4156, 14, 3491, 8326, 3883, 35, 2675, 8, 288, 2243, 534, 10455, 297, 288, 1072, 63, 466, 29, 1313, 14, 12067, 12, 288, 2243, 63, 4844, 63, 8358, 29, 1782, 63, 4844, 63, 8358, 12, 288, 1591, 63, 4844, 63, 8358, 29, 1102, 63, 4844, 63, 8358, 12, 288, 2196, 63, 18658, 63, 6884, 1524, 2325, 12, 7008, 467, 288, 2196, 63, 6789, 1524, 827, 63, 6789, 12, 413, 14, 16, 467, 288, 1967, 63, 13143, 29, 1960, 9, 267, 291, 14, 470, 275, 4156, 14, 24559, 8, 288, 2243, 534, 6477, 297, 15210, 63, 88, 29, 15816, 12, 15210, 63, 89, 29, 15816, 12, 23716, 63, 466, 29, 14252, 9, 267, 291, 14, 4400, 1590, 275, 4156, 14, 35, 2675, 28034, 22580, 8, 288, 2243, 628, 6477, 401, 288, 1072, 63, 2271, 29, 1199, 63, 2271, 12, 288, 1072, 63, 4209, 29, 1313, 14, 27086, 12, 288, 18366, 2687, 15816, 12, 18366, 395, 288, 1834, 63, 466, 29, 1313, 14, 12067, 12, 288, 4615, 29, 3670, 12, 288, 2418, 29, 1516, 12, 288, 6567, 63, 1199, 29, 6226, 63, 1199, 9, 267, 291, 14, 9061, 275, 4156, 14, 967, 262, 38, 3587, 8, 17210, 29, 16, 14, 21, 9, 267, 291, 14, 475, 63, 442, 772, 275, 4156, 14, 24654, 8, 2271, 29, 1313, 14, 2919, 772, 12, 2243, 628, 6477, 531, 339, 347, 5627, 63, 2180, 8, 277, 304, 267, 9038, 275, 291, 14, 9061, 342, 267, 1335, 321, 458, 12, 3628, 275, 291, 14, 1210, 8, 354, 628, 5929, 531, 267, 5935, 275, 291, 14, 2708, 8, 74, 321, 458, 9, 267, 5935, 275, 291, 14, 470, 8, 4782, 9, 267, 1072, 275, 291, 14, 4400, 1590, 8, 4782, 14, 6477, 1062, 15216, 29, 12686, 9, 267, 372, 359, 1199, 12, 291, 14, 475, 63, 442, 772, 8, 3512, 14, 6477, 24821, 339, 347, 636, 552, 721, 277, 304, 267, 372, 291, 14, 7367, 63, 890, 480, 5929, 531, 421, 199, 533, 29591, 14601, 7562, 11867, 8, 17562, 304, 272, 347, 636, 826, 721, 277, 12, 326, 570, 63, 1231, 12, 326, 570, 63, 513, 12, 326, 3522, 63, 890, 12, 326, 15210, 63, 609, 3968, 12, 326, 18366, 12, 326, 23716, 12, 326, 4615, 12, 326, 2418, 12, 326, 2243, 63, 344, 12, 326, 11814, 63, 344, 29, 16, 12, 326, 1967, 63, 15570, 29, 17, 12, 326, 2196, 63, 11777, 29, 797, 12, 326, 1967, 63, 6962, 29, 20, 12, 326, 6347, 29, 2260, 12, 326, 6567, 63, 1199, 29, 797, 12, 326, 1072, 63, 2271, 29, 1313, 14, 11783, 304, 267, 1613, 8, 21568, 14601, 7562, 11867, 12, 291, 2843, 826, 721, 288, 3522, 63, 890, 12, 1967, 63, 6962, 12, 2243, 63, 344, 12, 6347, 29, 5176, 9, 267, 291, 14, 1210, 275, 4156, 14, 1173, 5929, 8, 288, 570, 63, 1231, 29, 493, 63, 1231, 12, 288, 570, 63, 513, 29, 493, 63, 513, 12, 288, 11814, 63, 344, 29, 10810, 63, 344, 12, 288, 1967, 63, 15570, 29, 1507, 63, 15570, 12, 288, 2196, 63, 11777, 29, 2355, 63, 11777, 9, 267, 291, 14, 2708, 275, 4156, 14, 3491, 8326, 8, 1782, 628, 10455, 401, 1072, 63, 466, 29, 1313, 14, 12067, 9, 267, 291, 14, 470, 275, 4156, 14, 24559, 8, 288, 2243, 628, 6477, 401, 15210, 63, 609, 3968, 29, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cmusv-sc/DIWD-Team4-Wei-Lin-Tsai
src/python/data_2015_fall/api/queryExperts.py
1
1307
from django.http import JsonResponse from data_2015_fall.models import * import simplejson from collections import defaultdict from operator import itemgetter # =================================================== # Classes # =================================================== class Expert(object): def __init__(self, name): self.name = name def toDict(self): return { "name": self.name } # =================================================== # Functions # =================================================== def getTopKExpertsByKeywords(request, keywords, k): keywordsList = keywords.split("+") expertHash = defaultdict(int) # map expert name to its count list1 = [] # count appearance of author who publish the paper matches keyword for keyword in keywordsList: for article in Article.nodes.filter(title__icontains=keyword): list1.append(article.title) for author in article.authors: expertHash[author.name]+=1 experts = [] for key, value in sorted(expertHash.iteritems(), key=itemgetter(1), reverse=True)[0:int(k)]: experts.append(Expert(key)) #print key + ", " + str(value) # debug msg return JsonResponse({ "experts": [e.toDict() for e in experts] })
unlicense
[ 504, 1639, 14, 1014, 492, 21072, 199, 504, 666, 63, 7806, 63, 70, 452, 14, 992, 492, 627, 199, 646, 13804, 199, 504, 5055, 492, 10018, 199, 504, 4182, 492, 1242, 7416, 199, 199, 3, 19691, 389, 199, 3, 198, 15711, 221, 199, 3, 19691, 389, 199, 533, 1316, 28621, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 272, 347, 370, 2141, 8, 277, 304, 267, 372, 469, 288, 298, 354, 582, 291, 14, 354, 267, 789, 221, 421, 199, 3, 19691, 389, 199, 3, 198, 13967, 221, 199, 3, 19691, 389, 199, 318, 664, 6105, 43, 920, 529, 1086, 2175, 23611, 8, 1069, 12, 7681, 12, 1022, 304, 272, 7681, 1296, 275, 7681, 14, 1294, 480, 21425, 272, 444, 28621, 3476, 275, 10018, 8, 442, 9, 327, 2341, 444, 28621, 536, 370, 2399, 2338, 272, 769, 17, 275, 942, 272, 327, 2338, 7468, 554, 402, 4132, 3963, 2780, 314, 15220, 4450, 4252, 272, 367, 4252, 315, 7681, 1296, 26, 267, 367, 9772, 315, 8281, 14, 2415, 14, 1541, 8, 1213, 363, 30314, 29, 6691, 304, 288, 769, 17, 14, 740, 8, 6934, 14, 1213, 9, 288, 367, 4132, 315, 9772, 14, 8149, 26, 355, 444, 28621, 3476, 59, 2502, 14, 354, 2807, 29, 17, 339, 444, 529, 1086, 275, 942, 272, 367, 790, 12, 574, 315, 3355, 8, 476, 28621, 3476, 14, 4611, 1062, 790, 29, 20832, 8, 17, 395, 3837, 29, 549, 2788, 16, 26, 442, 8, 75, 19532, 4960, 444, 529, 1086, 14, 740, 8, 920, 28621, 8, 498, 430, 267, 327, 1361, 790, 435, 3872, 298, 435, 620, 8, 585, 9, 327, 3105, 1499, 339, 372, 21072, 2561, 298, 476, 529, 1086, 582, 359, 69, 14, 475, 2141, 342, 367, 325, 315, 444, 529, 1086, 61, 3828, 259, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1014, 492, 21072, 199, 504, 666, 63, 7806, 63, 70, 452, 14, 992, 492, 627, 199, 646, 13804, 199, 504, 5055, 492, 10018, 199, 504, 4182, 492, 1242, 7416, 199, 199, 3, 19691, 389, 199, 3, 198, 15711, 221, 199, 3, 19691, 389, 199, 533, 1316, 28621, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 272, 347, 370, 2141, 8, 277, 304, 267, 372, 469, 288, 298, 354, 582, 291, 14, 354, 267, 789, 221, 421, 199, 3, 19691, 389, 199, 3, 198, 13967, 221, 199, 3, 19691, 389, 199, 318, 664, 6105, 43, 920, 529, 1086, 2175, 23611, 8, 1069, 12, 7681, 12, 1022, 304, 272, 7681, 1296, 275, 7681, 14, 1294, 480, 21425, 272, 444, 28621, 3476, 275, 10018, 8, 442, 9, 327, 2341, 444, 28621, 536, 370, 2399, 2338, 272, 769, 17, 275, 942, 272, 327, 2338, 7468, 554, 402, 4132, 3963, 2780, 314, 15220, 4450, 4252, 272, 367, 4252, 315, 7681, 1296, 26, 267, 367, 9772, 315, 8281, 14, 2415, 14, 1541, 8, 1213, 363, 30314, 29, 6691, 304, 288, 769, 17, 14, 740, 8, 6934, 14, 1213, 9, 288, 367, 4132, 315, 9772, 14, 8149, 26, 355, 444, 28621, 3476, 59, 2502, 14, 354, 2807, 29, 17, 339, 444, 529, 1086, 275, 942, 272, 367, 790, 12, 574, 315, 3355, 8, 476, 28621, 3476, 14, 4611, 1062, 790, 29, 20832, 8, 17, 395, 3837, 29, 549, 2788, 16, 26, 442, 8, 75, 19532, 4960, 444, 529, 1086, 14, 740, 8, 920, 28621, 8, 498, 430, 267, 327, 1361, 790, 435, 3872, 298, 435, 620, 8, 585, 9, 327, 3105, 1499, 339, 372, 21072, 2561, 298, 476, 529, 1086, 582, 359, 69, 14, 475, 2141, 342, 367, 325, 315, 444, 529, 1086, 61, 3828, 259, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nekulin/arangodb
3rdParty/V8-4.3.61/third_party/python_26/Lib/site-packages/win32/lib/win32evtlogutil.py
21
6500
"""Event Log Utilities - helper for win32evtlog.pyd """ import win32api, win32con, winerror, win32evtlog, string error = win32api.error # The error the evtlog module raises. langid = win32api.MAKELANGID(win32con.LANG_NEUTRAL, win32con.SUBLANG_NEUTRAL) def AddSourceToRegistry(appName, msgDLL = None, eventLogType = "Application", eventLogFlags = None): """Add a source of messages to the event log. Allows Python program to register a custom source of messages in the registry. You must also provide the DLL name that has the message table, so the full message text appears in the event log. Note that the win32evtlog.pyd file has a number of string entries with just "%1" built in, so many Python programs can simply use this DLL. Disadvantages are that you do not get language translation, and the full text is stored in the event log, blowing the size of the log up. """ # When an application uses the RegisterEventSource or OpenEventLog # function to get a handle of an event log, the event loggging service # searches for the specified source name in the registry. You can add a # new source name to the registry by opening a new registry subkey # under the Application key and adding registry values to the new # subkey. if msgDLL is None: msgDLL = win32evtlog.__file__ # Create a new key for our application hkey = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, \ "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) # Add the Event-ID message-file name to the subkey. win32api.RegSetValueEx(hkey, "EventMessageFile", # value name \ 0, # reserved \ win32con.REG_EXPAND_SZ,# value type \ msgDLL) # Set the supported types flags and add it to the subkey. if eventLogFlags is None: eventLogFlags = win32evtlog.EVENTLOG_ERROR_TYPE | win32evtlog.EVENTLOG_WARNING_TYPE | win32evtlog.EVENTLOG_INFORMATION_TYPE win32api.RegSetValueEx(hkey, # subkey handle \ "TypesSupported", # value name \ 0, # reserved \ win32con.REG_DWORD, # value type \ eventLogFlags) win32api.RegCloseKey(hkey) def RemoveSourceFromRegistry(appName, eventLogType = "Application"): """Removes a source of messages from the event log. """ # Delete our key try: win32api.RegDeleteKey(win32con.HKEY_LOCAL_MACHINE, \ "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName)) except win32api.error, (hr, fn, desc): if hr != winerror.ERROR_FILE_NOT_FOUND: raise def ReportEvent(appName, eventID, eventCategory = 0, eventType=win32evtlog.EVENTLOG_ERROR_TYPE, strings = None, data = None, sid=None): """Report an event for a previously added event source. """ # Get a handle to the Application event log hAppLog = win32evtlog.RegisterEventSource(None, appName) # Now report the event, which will add this event to the event log */ win32evtlog.ReportEvent(hAppLog, # event-log handle \ eventType, eventCategory, eventID, sid, strings, data) win32evtlog.DeregisterEventSource(hAppLog); def FormatMessage( eventLogRecord, logType="Application" ): """Given a tuple from ReadEventLog, and optionally where the event record came from, load the message, and process message inserts. Note that this function may raise win32api.error. See also the function SafeFormatMessage which will return None if the message can not be processed. """ # From the event log source name, we know the name of the registry # key to look under for the name of the message DLL that contains # the messages we need to extract with FormatMessage. So first get # the event log source name... keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName) # Now open this key and get the EventMessageFile value, which is # the name of the message DLL. handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName) try: dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";") # Win2k etc appear to allow multiple DLL names data = None for dllName in dllNames: try: # Expand environment variable strings in the message DLL path name, # in case any are there. dllName = win32api.ExpandEnvironmentStrings(dllName) dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.DONT_RESOLVE_DLL_REFERENCES) try: data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE, dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts) finally: win32api.FreeLibrary(dllHandle) except win32api.error: pass # Not in this DLL - try the next if data is not None: break finally: win32api.RegCloseKey(handle) return data or u'' # Don't want "None" ever being returned. def SafeFormatMessage( eventLogRecord, logType=None ): """As for FormatMessage, except returns an error message if the message can not be processed. """ if logType is None: logType = "Application" try: return FormatMessage(eventLogRecord, logType) except win32api.error: if eventLogRecord.StringInserts is None: desc = "" else: desc = u", ".join(eventLogRecord.StringInserts) return u"<The description for Event ID ( %d ) in Source ( %r ) could not be found. It contains the following insertion string(s):%r.>" % (winerror.HRESULT_CODE(eventLogRecord.EventID), eventLogRecord.SourceName, desc) def FeedEventLogRecords(feeder, machineName = None, logName = "Application", readFlags = None): if readFlags is None: readFlags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ h=win32evtlog.OpenEventLog(machineName, logName) try: while 1: objects = win32evtlog.ReadEventLog(h, readFlags, 0) if not objects: break map(lambda item, feeder = feeder: apply(feeder, (item,)), objects) finally: win32evtlog.CloseEventLog(h)
apache-2.0
[ 624, 2390, 5297, 738, 17933, 446, 5922, 367, 4747, 708, 19296, 793, 14, 647, 68, 199, 624, 199, 199, 646, 4747, 708, 1246, 12, 4747, 708, 388, 12, 4747, 705, 12, 4747, 708, 19296, 793, 12, 1059, 199, 199, 705, 275, 4747, 708, 1246, 14, 705, 327, 710, 1125, 314, 16330, 793, 859, 6534, 14, 199, 199, 4159, 344, 275, 4747, 708, 1246, 14, 18421, 7442, 998, 8, 2676, 708, 388, 14, 7442, 63, 6388, 934, 50, 748, 12, 4747, 708, 388, 14, 28230, 63, 6388, 934, 50, 748, 9, 199, 199, 318, 2654, 2980, 1378, 10899, 8, 571, 985, 12, 1499, 15982, 275, 488, 12, 1566, 2445, 804, 275, 298, 5039, 401, 1566, 2445, 6381, 275, 488, 304, 272, 408, 1123, 282, 1350, 402, 3788, 370, 314, 1566, 943, 14, 339, 22819, 2018, 2240, 370, 2274, 282, 3537, 1350, 402, 3788, 315, 314, 272, 7086, 14, 221, 2047, 1471, 2597, 5647, 314, 577, 4464, 536, 626, 965, 314, 1245, 1817, 12, 880, 314, 272, 2615, 1245, 1318, 11337, 315, 314, 1566, 943, 14, 339, 3390, 626, 314, 4747, 708, 19296, 793, 14, 647, 68, 570, 965, 282, 1329, 402, 1059, 4811, 543, 2951, 2071, 17, 2, 272, 6137, 315, 12, 880, 5002, 2018, 18572, 883, 9329, 675, 642, 577, 4464, 14, 221, 5289, 21650, 867, 7441, 787, 626, 272, 1265, 886, 440, 664, 2637, 7761, 12, 436, 314, 2615, 1318, 365, 5489, 315, 314, 1566, 943, 12, 272, 28511, 316, 314, 1568, 402, 314, 943, 1536, 14, 272, 408, 339, 327, 3979, 376, 4223, 4440, 314, 11828, 2390, 2980, 503, 3232, 2390, 2445, 272, 327, 805, 370, 664, 282, 2429, 402, 376, 1566, 943, 12, 314, 1566, 943, 71, 1540, 2435, 272, 327, 21858, 367, 314, 2013, 1350, 536, 315, 314, 7086, 14, 2047, 883, 1050, 282, 272, 327, 892, 1350, 536, 370, 314, 7086, 701, 13618, 282, 892, 7086, 1007, 498, 272, 327, 1334, 314, 13515, 790, 436, 7791, 7086, 1338, 370, 314, 892, 272, 327, 1007, 498, 14, 339, 340, 1499, 15982, 365, 488, 26, 267, 1499, 15982, 275, 4747, 708, 19296, 793, 855, 493, 363, 339, 327, 2790, 282, 892, 790, 367, 4154, 4223, 272, 394, 498, 275, 4747, 708, 1246, 14, 2872, 2499, 1197, 8, 2676, 708, 388, 14, 23802, 63, 7486, 63, 20890, 12, 971, 267, 298, 12711, 1103, 5639, 3717, 1084, 1103, 15803, 1103, 2390, 2445, 1103, 5, 83, 1103, 5, 83, 2, 450, 334, 1430, 2445, 804, 12, 1145, 985, 430, 339, 327, 2654, 314, 6763, 13, 998, 1245, 13, 493, 536, 370, 314, 1007, 498, 14, 272, 4747, 708, 1246, 14, 2872, 21322, 920, 8, 72, 498, 12, 267, 298, 2390, 2209, 1173, 401, 259, 327, 574, 536, 971, 267, 378, 12, 9326, 327, 4644, 971, 267, 4747, 708, 388, 14, 5616, 63, 20612, 63, 18101, 12790, 574, 730, 971, 267, 1499, 15982, 9, 339, 327, 2494, 314, 3748, 2943, 3285, 436, 1050, 652, 370, 314, 1007, 498, 14, 272, 340, 1566, 2445, 6381, 365, 488, 26, 267, 1566, 2445, 6381, 275, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 3170, 63, 2711, 1204, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 9171, 63, 2711, 1204, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 21583, 63, 2711, 272, 4747, 708, 1246, 14, 2872, 21322, 920, 8, 72, 498, 12, 327, 1007, 498, 2429, 971, 267, 298, 4100, 10682, 401, 263, 327, 574, 536, 971, 267, 378, 12, 9668, 327, 4644, 971, 267, 4747, 708, 388, 14, 5616, 63, 24754, 12, 420, 327, 574, 730, 971, 267, 1566, 2445, 6381, 9, 272, 4747, 708, 1246, 14, 2872, 4724, 1197, 8, 72, 498, 9, 199, 199, 318, 5852, 2980, 2532, 10899, 8, 571, 985, 12, 1566, 2445, 804, 275, 298, 5039, 2349, 272, 408, 22948, 282, 1350, 402, 3788, 687, 314, 1566, 943, 14, 272, 408, 339, 327, 8496, 4154, 790, 272, 862, 26, 267, 4747, 708, 1246, 14, 2872, 5392, 1197, 8, 2676, 708, 388, 14, 23802, 63, 7486, 63, 20890, 12, 971, 2151, 298, 12711, 1103, 5639, 3717, 1084, 1103, 15803, 1103, 2390, 2445, 1103, 5, 83, 1103, 5, 83, 2, 450, 334, 1430, 2445, 804, 12, 1145, 985, 430, 272, 871, 4747, 708, 1246, 14, 705, 12, 334, 6271, 12, 4325, 12, 4328, 304, 267, 340, 16140, 1137, 4747, 705, 14, 3170, 63, 3817, 63, 4609, 63, 13945, 26, 288, 746, 421, 199, 318, 11774, 2390, 8, 571, 985, 12, 1566, 998, 12, 1566, 7841, 275, 378, 12, 1566, 804, 29, 2676, 708, 19296, 793, 14, 8193, 4947, 63, 3170, 63, 2711, 12, 3326, 275, 488, 12, 666, 275, 488, 12, 15764, 29, 403, 304, 272, 408, 7457, 376, 1566, 367, 282, 10889, 3483, 1566, 1350, 14, 272, 408, 272, 327, 2372, 282, 2429, 370, 314, 13515, 1566, 943, 272, 394, 2640, 2445, 275, 4747, 708, 19296, 793, 14, 7099, 2390, 2980, 8, 403, 12, 1145, 985, 9, 339, 327, 7356, 3622, 314, 1566, 12, 1314, 911, 1050, 642, 1566, 370, 314, 1566, 943, 11589, 272, 4747, 708, 19296, 793, 14, 7457, 2390, 8, 72, 2640, 2445, 12, 327, 1566, 13, 793, 2429, 971, 267, 1566, 804, 12, 267, 1566, 7841, 12, 267, 1566, 998, 12, 267, 15764, 12, 267, 3326, 12, 267, 666, 9, 339, 4747, 708, 19296, 793, 14, 872, 2683, 2390, 2980, 8, 72, 2640, 2445, 2736, 199, 199, 318, 9701, 2209, 8, 1566, 2445, 5433, 12, 943, 804, 628, 5039, 2, 3461, 272, 408, 13735, 282, 2008, 687, 5574, 2390, 2445, 12, 436, 14190, 2382, 314, 1566, 272, 2777, 20382, 687, 12, 2248, 314, 1245, 12, 436, 2112, 1245, 28203, 14, 339, 3390, 626, 642, 805, 1443, 746, 4747, 708, 1246, 14, 705, 14, 221, 1666, 2597, 314, 272, 805, 14969, 3484, 2209, 1314, 911, 372, 488, 340, 314, 1245, 883, 272, 440, 506, 7686, 14, 272, 408, 339, 327, 11606, 314, 1566, 943, 1350, 536, 12, 781, 5715, 314, 536, 402, 314, 7086, 272, 327, 790, 370, 3648, 1334, 367, 314, 536, 402, 314, 1245, 577, 4464, 626, 3509, 272, 327, 314, 3788, 781, 1929, 370, 5536, 543, 9701, 2209, 14, 2002, 1642, 664, 272, 327, 314, 1566, 943, 1350, 536, 1396, 272, 790, 985, 275, 298, 12711, 1103 ]
[ 2390, 5297, 738, 17933, 446, 5922, 367, 4747, 708, 19296, 793, 14, 647, 68, 199, 624, 199, 199, 646, 4747, 708, 1246, 12, 4747, 708, 388, 12, 4747, 705, 12, 4747, 708, 19296, 793, 12, 1059, 199, 199, 705, 275, 4747, 708, 1246, 14, 705, 327, 710, 1125, 314, 16330, 793, 859, 6534, 14, 199, 199, 4159, 344, 275, 4747, 708, 1246, 14, 18421, 7442, 998, 8, 2676, 708, 388, 14, 7442, 63, 6388, 934, 50, 748, 12, 4747, 708, 388, 14, 28230, 63, 6388, 934, 50, 748, 9, 199, 199, 318, 2654, 2980, 1378, 10899, 8, 571, 985, 12, 1499, 15982, 275, 488, 12, 1566, 2445, 804, 275, 298, 5039, 401, 1566, 2445, 6381, 275, 488, 304, 272, 408, 1123, 282, 1350, 402, 3788, 370, 314, 1566, 943, 14, 339, 22819, 2018, 2240, 370, 2274, 282, 3537, 1350, 402, 3788, 315, 314, 272, 7086, 14, 221, 2047, 1471, 2597, 5647, 314, 577, 4464, 536, 626, 965, 314, 1245, 1817, 12, 880, 314, 272, 2615, 1245, 1318, 11337, 315, 314, 1566, 943, 14, 339, 3390, 626, 314, 4747, 708, 19296, 793, 14, 647, 68, 570, 965, 282, 1329, 402, 1059, 4811, 543, 2951, 2071, 17, 2, 272, 6137, 315, 12, 880, 5002, 2018, 18572, 883, 9329, 675, 642, 577, 4464, 14, 221, 5289, 21650, 867, 7441, 787, 626, 272, 1265, 886, 440, 664, 2637, 7761, 12, 436, 314, 2615, 1318, 365, 5489, 315, 314, 1566, 943, 12, 272, 28511, 316, 314, 1568, 402, 314, 943, 1536, 14, 272, 408, 339, 327, 3979, 376, 4223, 4440, 314, 11828, 2390, 2980, 503, 3232, 2390, 2445, 272, 327, 805, 370, 664, 282, 2429, 402, 376, 1566, 943, 12, 314, 1566, 943, 71, 1540, 2435, 272, 327, 21858, 367, 314, 2013, 1350, 536, 315, 314, 7086, 14, 2047, 883, 1050, 282, 272, 327, 892, 1350, 536, 370, 314, 7086, 701, 13618, 282, 892, 7086, 1007, 498, 272, 327, 1334, 314, 13515, 790, 436, 7791, 7086, 1338, 370, 314, 892, 272, 327, 1007, 498, 14, 339, 340, 1499, 15982, 365, 488, 26, 267, 1499, 15982, 275, 4747, 708, 19296, 793, 855, 493, 363, 339, 327, 2790, 282, 892, 790, 367, 4154, 4223, 272, 394, 498, 275, 4747, 708, 1246, 14, 2872, 2499, 1197, 8, 2676, 708, 388, 14, 23802, 63, 7486, 63, 20890, 12, 971, 267, 298, 12711, 1103, 5639, 3717, 1084, 1103, 15803, 1103, 2390, 2445, 1103, 5, 83, 1103, 5, 83, 2, 450, 334, 1430, 2445, 804, 12, 1145, 985, 430, 339, 327, 2654, 314, 6763, 13, 998, 1245, 13, 493, 536, 370, 314, 1007, 498, 14, 272, 4747, 708, 1246, 14, 2872, 21322, 920, 8, 72, 498, 12, 267, 298, 2390, 2209, 1173, 401, 259, 327, 574, 536, 971, 267, 378, 12, 9326, 327, 4644, 971, 267, 4747, 708, 388, 14, 5616, 63, 20612, 63, 18101, 12790, 574, 730, 971, 267, 1499, 15982, 9, 339, 327, 2494, 314, 3748, 2943, 3285, 436, 1050, 652, 370, 314, 1007, 498, 14, 272, 340, 1566, 2445, 6381, 365, 488, 26, 267, 1566, 2445, 6381, 275, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 3170, 63, 2711, 1204, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 9171, 63, 2711, 1204, 4747, 708, 19296, 793, 14, 8193, 4947, 63, 21583, 63, 2711, 272, 4747, 708, 1246, 14, 2872, 21322, 920, 8, 72, 498, 12, 327, 1007, 498, 2429, 971, 267, 298, 4100, 10682, 401, 263, 327, 574, 536, 971, 267, 378, 12, 9668, 327, 4644, 971, 267, 4747, 708, 388, 14, 5616, 63, 24754, 12, 420, 327, 574, 730, 971, 267, 1566, 2445, 6381, 9, 272, 4747, 708, 1246, 14, 2872, 4724, 1197, 8, 72, 498, 9, 199, 199, 318, 5852, 2980, 2532, 10899, 8, 571, 985, 12, 1566, 2445, 804, 275, 298, 5039, 2349, 272, 408, 22948, 282, 1350, 402, 3788, 687, 314, 1566, 943, 14, 272, 408, 339, 327, 8496, 4154, 790, 272, 862, 26, 267, 4747, 708, 1246, 14, 2872, 5392, 1197, 8, 2676, 708, 388, 14, 23802, 63, 7486, 63, 20890, 12, 971, 2151, 298, 12711, 1103, 5639, 3717, 1084, 1103, 15803, 1103, 2390, 2445, 1103, 5, 83, 1103, 5, 83, 2, 450, 334, 1430, 2445, 804, 12, 1145, 985, 430, 272, 871, 4747, 708, 1246, 14, 705, 12, 334, 6271, 12, 4325, 12, 4328, 304, 267, 340, 16140, 1137, 4747, 705, 14, 3170, 63, 3817, 63, 4609, 63, 13945, 26, 288, 746, 421, 199, 318, 11774, 2390, 8, 571, 985, 12, 1566, 998, 12, 1566, 7841, 275, 378, 12, 1566, 804, 29, 2676, 708, 19296, 793, 14, 8193, 4947, 63, 3170, 63, 2711, 12, 3326, 275, 488, 12, 666, 275, 488, 12, 15764, 29, 403, 304, 272, 408, 7457, 376, 1566, 367, 282, 10889, 3483, 1566, 1350, 14, 272, 408, 272, 327, 2372, 282, 2429, 370, 314, 13515, 1566, 943, 272, 394, 2640, 2445, 275, 4747, 708, 19296, 793, 14, 7099, 2390, 2980, 8, 403, 12, 1145, 985, 9, 339, 327, 7356, 3622, 314, 1566, 12, 1314, 911, 1050, 642, 1566, 370, 314, 1566, 943, 11589, 272, 4747, 708, 19296, 793, 14, 7457, 2390, 8, 72, 2640, 2445, 12, 327, 1566, 13, 793, 2429, 971, 267, 1566, 804, 12, 267, 1566, 7841, 12, 267, 1566, 998, 12, 267, 15764, 12, 267, 3326, 12, 267, 666, 9, 339, 4747, 708, 19296, 793, 14, 872, 2683, 2390, 2980, 8, 72, 2640, 2445, 2736, 199, 199, 318, 9701, 2209, 8, 1566, 2445, 5433, 12, 943, 804, 628, 5039, 2, 3461, 272, 408, 13735, 282, 2008, 687, 5574, 2390, 2445, 12, 436, 14190, 2382, 314, 1566, 272, 2777, 20382, 687, 12, 2248, 314, 1245, 12, 436, 2112, 1245, 28203, 14, 339, 3390, 626, 642, 805, 1443, 746, 4747, 708, 1246, 14, 705, 14, 221, 1666, 2597, 314, 272, 805, 14969, 3484, 2209, 1314, 911, 372, 488, 340, 314, 1245, 883, 272, 440, 506, 7686, 14, 272, 408, 339, 327, 11606, 314, 1566, 943, 1350, 536, 12, 781, 5715, 314, 536, 402, 314, 7086, 272, 327, 790, 370, 3648, 1334, 367, 314, 536, 402, 314, 1245, 577, 4464, 626, 3509, 272, 327, 314, 3788, 781, 1929, 370, 5536, 543, 9701, 2209, 14, 2002, 1642, 664, 272, 327, 314, 1566, 943, 1350, 536, 1396, 272, 790, 985, 275, 298, 12711, 1103, 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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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 ]
dgzurita/odoo
addons/purchase/wizard/purchase_line_invoice.py
177
5258
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp.tools.translate import _ class purchase_line_invoice(osv.osv_memory): """ To create invoice for purchase order line""" _name = 'purchase.order.line_invoice' _description = 'Purchase Order Line Make Invoice' def _make_invoice_by_partner(self, cr, uid, partner, orders, lines_ids, context=None): """ create a new invoice for one supplier @param cr : Cursor @param uid : Id of current user @param partner : The object partner @param orders : The set of orders to add in the invoice @param lines : The list of line's id """ purchase_obj = self.pool.get('purchase.order') account_jrnl_obj = self.pool.get('account.journal') invoice_obj = self.pool.get('account.invoice') name = orders and orders[0].name or '' journal_id = account_jrnl_obj\ .search(cr, uid, [('type', '=', 'purchase')], context=None) journal_id = journal_id and journal_id[0] or False a = partner.property_account_payable.id inv = { 'name': name, 'origin': name, 'type': 'in_invoice', 'journal_id': journal_id, 'reference': partner.ref, 'account_id': a, 'partner_id': partner.id, 'invoice_line': [(6, 0, lines_ids)], 'currency_id': orders[0].currency_id.id, 'comment': " \n".join([order.notes for order in orders if order.notes]), 'payment_term': orders[0].payment_term_id.id, 'fiscal_position': partner.property_account_position.id } inv_id = invoice_obj.create(cr, uid, inv, context=context) purchase_obj.write(cr, uid, [order.id for order in orders], {'invoice_ids': [(4, inv_id)]}, context=context) return inv_id def makeInvoices(self, cr, uid, ids, context=None): """ To get Purchase Order line and create Invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : retrun view of Invoice """ if context is None: context={} record_ids = context.get('active_ids',[]) if record_ids: res = False invoices = {} purchase_obj = self.pool.get('purchase.order') purchase_line_obj = self.pool.get('purchase.order.line') invoice_line_obj = self.pool.get('account.invoice.line') for line in purchase_line_obj.browse(cr, uid, record_ids, context=context): if (not line.invoiced) and (line.state not in ('draft', 'cancel')): if not line.partner_id.id in invoices: invoices[line.partner_id.id] = [] acc_id = purchase_obj._choose_account_from_po_line(cr, uid, line, context=context) inv_line_data = purchase_obj._prepare_inv_line(cr, uid, acc_id, line, context=context) inv_line_data.update({'origin': line.order_id.name}) inv_id = invoice_line_obj.create(cr, uid, inv_line_data, context=context) purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]}) invoices[line.partner_id.id].append((line,inv_id)) res = [] for result in invoices.values(): il = map(lambda x: x[1], result) orders = list(set(map(lambda x : x[0].order_id, result))) res.append(self._make_invoice_by_partner(cr, uid, orders[0].partner_id, orders, il, context=context)) return { 'domain': "[('id','in', ["+','.join(map(str,res))+"])]", 'name': _('Supplier Invoices'), 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'account.invoice', 'view_id': False, 'context': "{'type':'in_invoice', 'journal_type': 'purchase'}", 'type': 'ir.actions.act_window' } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 15932, 63, 604, 63, 5404, 8, 4795, 14, 4795, 63, 4844, 304, 339, 408, 4005, 1218, 8485, 367, 15932, 1865, 1004, 624, 339, 485, 354, 275, 283, 9533, 14, 1648, 14, 604, 63, 5404, 7, 272, 485, 1802, 275, 283, 20486, 9240, 7030, 4155, 19868, 7, 339, 347, 485, 1875, 63, 5404, 63, 991, 63, 3899, 8, 277, 12, 2467, 12, 1747, 12, 5854, 12, 15460, 12, 2385, 63, 1580, 12, 1067, 29, 403, 304, 267, 408, 288, 1218, 282, 892, 8485, 367, 1373, 23700, 288, 768, 635, 2467, 520, 20385, 288, 768, 635, 1747, 520, 15418, 402, 1453, 922, 288, 768, 635, 5854, 520, 710, 909, 5854, 288, 768, 635, 15460, 520, 710, 663, 402, 15460, 370, 1050, 315, 314, 8485, 288, 768, 635, 2385, 520, 710, 769, 402, 1004, 1159, 1305, 267, 408, 267, 15932, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 358, 267, 2933, 63, 32099, 7530, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 7067, 358, 267, 8485, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 358, 267, 536, 275, 15460, 436, 15460, 59, 16, 1055, 354, 503, 2125, 267, 9605, 63, 344, 275, 2933, 63, 32099, 7530, 63, 1113, 60, 288, 1275, 1733, 8, 1556, 12, 1747, 12, 4274, 466, 297, 6291, 283, 9533, 2665, 1067, 29, 403, 9, 267, 9605, 63, 344, 275, 9605, 63, 344, 436, 9605, 63, 344, 59, 16, 61, 503, 756, 267, 282, 275, 5854, 14, 1829, 63, 2048, 63, 5989, 461, 14, 344, 267, 4572, 275, 469, 288, 283, 354, 356, 536, 12, 288, 283, 6493, 356, 536, 12, 288, 283, 466, 356, 283, 262, 63, 5404, 297, 288, 283, 7067, 63, 344, 356, 9605, 63, 344, 12, 288, 283, 4443, 356, 5854, 14, 1121, 12, 288, 283, 2048, 63, 344, 356, 282, 12, 288, 283, 3899, 63, 344, 356, 5854, 14, 344, 12, 288, 283, 5404, 63, 604, 356, 3842, 22, 12, 378, 12, 2385, 63, 1580, 4360, 288, 283, 4968, 63, 344, 356, 15460, 59, 16, 1055, 4968, 63, 344, 14, 344, 12, 288, 283, 3349, 356, 298, 971, 78, 1674, 904, 779, 1648, 14, 5983, 367, 1865, 315, 15460, 340, 1865, 14, 5983, 2522, 288, 283, 7948, 63, 5125, 356, 15460, 59, 16, 1055, 7948, 63, 5125, 63, 344, 14, 344, 12, 288, 283, 18646, 63, 3124, 356, 5854, 14, 1829, 63, 2048, 63, 3124, 14, 344, 267, 789, 267, 4572, 63, 344, 275, 8485, 63, 1113, 14, 981, 8, 1556, 12, 1747, 12, 4572, 12, 1067, 29, 1100, 9, 267, 15932, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 359, 1648, 14, 344, 367, 1865, 315, 15460, 467, 791, 5404, 63, 1580, 356, 3842, 20, 12, 4572, 63, 344, 26804, 1067, 29, 1100, 9, 267, 372, 4572, 63, 344, 339, 347, 1852, 607, 16687, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 398, 408, 1467, 4005, 664, 23177, 6703, 9240, 1004, 436, 1218, 19868, 1467, 768, 635, 291, 26, 710, 909, 7849, 14, 1467, 768, 635, 2467, 26, 437, 3050, 3920, 1467, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 1467, 768, 635, 1067, 26, 437, 4465, 2600, 1467, 768, 1107, 520, 295, 454, 324, 2455, 402, 19868, 267, 408, 398, 340, 1067, 365, 488, 26, 288, 1067, 7622, 398, 2777, 63, 1580, 275, 221, 1067, 14, 362, 360, 2682, 63, 1580, 23993, 566, 267, 340, 2777, 63, 1580, 26, 288, 522, 275, 756, 288, 26175, 275, 1052, 288, 15932, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 358, 288, 15932, 63, 604, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 14, 604, 358, 288, 8485, 63, 604, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 14, 604, 358, 953, 367, 1004, 315, 15932, 63, 604, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2777, 63, 1580, 12, 1067, 29, 1100, 304, 355, 340, 334, 1397, 1004, 14, 25614, 9, 436, 334, 604, 14, 929, 440, 315, 661, 7185, 297, 283, 6406, 8109, 490, 340, 440, 1004, 14, 3899, 63, 344, 14, 344, 315, 26175, 26, 717, 26175, 59, 604, 14, 3899, 63, 344, 14, 344, 61, 275, 942, 490, 6907, 63, 344, 275, 15932, 63, 1113, 423, 16143, 63, 2048, 63, 504, 63, 555, 63, 604, 8, 1556, 12, 1747, 12, 1004, 12, 1067, 29, 1100, 9, 490, 4572, 63, 604, 63, 576, 275, 15932, 63, 1113, 423, 6726, 63, 5350, 63, 604, 8, 1556, 12, 1747, 12, 6907, 63, 344, 12, 1004, 12, 1067, 29, 1100, 9, 490, 4572, 63, 604, 63, 576, 14, 873, 3252, 6493, 356, 1004, 14, 1648, 63, 344, 14, 354, 1552, 490, 4572, 63, 344, 275, 8485, 63, 604, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 421, 199, 533, 15932, 63, 604, 63, 5404, 8, 4795, 14, 4795, 63, 4844, 304, 339, 408, 4005, 1218, 8485, 367, 15932, 1865, 1004, 624, 339, 485, 354, 275, 283, 9533, 14, 1648, 14, 604, 63, 5404, 7, 272, 485, 1802, 275, 283, 20486, 9240, 7030, 4155, 19868, 7, 339, 347, 485, 1875, 63, 5404, 63, 991, 63, 3899, 8, 277, 12, 2467, 12, 1747, 12, 5854, 12, 15460, 12, 2385, 63, 1580, 12, 1067, 29, 403, 304, 267, 408, 288, 1218, 282, 892, 8485, 367, 1373, 23700, 288, 768, 635, 2467, 520, 20385, 288, 768, 635, 1747, 520, 15418, 402, 1453, 922, 288, 768, 635, 5854, 520, 710, 909, 5854, 288, 768, 635, 15460, 520, 710, 663, 402, 15460, 370, 1050, 315, 314, 8485, 288, 768, 635, 2385, 520, 710, 769, 402, 1004, 1159, 1305, 267, 408, 267, 15932, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 358, 267, 2933, 63, 32099, 7530, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 7067, 358, 267, 8485, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 358, 267, 536, 275, 15460, 436, 15460, 59, 16, 1055, 354, 503, 2125, 267, 9605, 63, 344, 275, 2933, 63, 32099, 7530, 63, 1113, 60, 288, 1275, 1733, 8, 1556, 12, 1747, 12, 4274, 466, 297, 6291, 283, 9533, 2665, 1067, 29, 403, 9, 267, 9605, 63, 344, 275, 9605, 63, 344, 436, 9605, 63, 344, 59, 16, 61, 503, 756, 267, 282, 275, 5854, 14, 1829, 63, 2048, 63, 5989, 461, 14, 344, 267, 4572, 275, 469, 288, 283, 354, 356, 536, 12, 288, 283, 6493, 356, 536, 12, 288, 283, 466, 356, 283, 262, 63, 5404, 297, 288, 283, 7067, 63, 344, 356, 9605, 63, 344, 12, 288, 283, 4443, 356, 5854, 14, 1121, 12, 288, 283, 2048, 63, 344, 356, 282, 12, 288, 283, 3899, 63, 344, 356, 5854, 14, 344, 12, 288, 283, 5404, 63, 604, 356, 3842, 22, 12, 378, 12, 2385, 63, 1580, 4360, 288, 283, 4968, 63, 344, 356, 15460, 59, 16, 1055, 4968, 63, 344, 14, 344, 12, 288, 283, 3349, 356, 298, 971, 78, 1674, 904, 779, 1648, 14, 5983, 367, 1865, 315, 15460, 340, 1865, 14, 5983, 2522, 288, 283, 7948, 63, 5125, 356, 15460, 59, 16, 1055, 7948, 63, 5125, 63, 344, 14, 344, 12, 288, 283, 18646, 63, 3124, 356, 5854, 14, 1829, 63, 2048, 63, 3124, 14, 344, 267, 789, 267, 4572, 63, 344, 275, 8485, 63, 1113, 14, 981, 8, 1556, 12, 1747, 12, 4572, 12, 1067, 29, 1100, 9, 267, 15932, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 359, 1648, 14, 344, 367, 1865, 315, 15460, 467, 791, 5404, 63, 1580, 356, 3842, 20, 12, 4572, 63, 344, 26804, 1067, 29, 1100, 9, 267, 372, 4572, 63, 344, 339, 347, 1852, 607, 16687, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 398, 408, 1467, 4005, 664, 23177, 6703, 9240, 1004, 436, 1218, 19868, 1467, 768, 635, 291, 26, 710, 909, 7849, 14, 1467, 768, 635, 2467, 26, 437, 3050, 3920, 1467, 768, 635, 1747, 26, 2870, 402, 314, 922, 5544, 10367, 315, 1467, 768, 635, 1067, 26, 437, 4465, 2600, 1467, 768, 1107, 520, 295, 454, 324, 2455, 402, 19868, 267, 408, 398, 340, 1067, 365, 488, 26, 288, 1067, 7622, 398, 2777, 63, 1580, 275, 221, 1067, 14, 362, 360, 2682, 63, 1580, 23993, 566, 267, 340, 2777, 63, 1580, 26, 288, 522, 275, 756, 288, 26175, 275, 1052, 288, 15932, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 358, 288, 15932, 63, 604, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 9533, 14, 1648, 14, 604, 358, 288, 8485, 63, 604, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 5404, 14, 604, 358, 953, 367, 1004, 315, 15932, 63, 604, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2777, 63, 1580, 12, 1067, 29, 1100, 304, 355, 340, 334, 1397, 1004, 14, 25614, 9, 436, 334, 604, 14, 929, 440, 315, 661, 7185, 297, 283, 6406, 8109, 490, 340, 440, 1004, 14, 3899, 63, 344, 14, 344, 315, 26175, 26, 717, 26175, 59, 604, 14, 3899, 63, 344, 14, 344, 61, 275, 942, 490, 6907, 63, 344, 275, 15932, 63, 1113, 423, 16143, 63, 2048, 63, 504, 63, 555, 63, 604, 8, 1556, 12, 1747, 12, 1004, 12, 1067, 29, 1100, 9, 490, 4572, 63, 604, 63, 576, 275, 15932, 63, 1113, 423, 6726, 63, 5350, 63, 604, 8, 1556, 12, 1747, 12, 6907, 63, 344, 12, 1004, 12, 1067, 29, 1100, 9, 490, 4572, 63, 604, 63, 576, 14, 873, 3252, 6493, 356, 1004, 14, 1648, 63, 344, 14, 354, 1552, 490, 4572, 63, 344, 275, 8485, 63, 604, 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, 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io import time from thrift.server.TAsyncioServer import ThriftClientProtocolFactory from tutorial import Calculator from tutorial.ttypes import Work, Operation, InvalidOperation @asyncio.coroutine def main(loop): (transport, protocol) = yield from loop.create_connection( ThriftClientProtocolFactory(Calculator.Client), host="127.0.0.1", port=8848) client = protocol.client # Wait for the server to solve this super hard problem indefinitely. sum = yield from asyncio.wait_for(client.add(1, 2), None) print("1 + 2 = {}".format(sum)) # Try divide by zero. try: work = Work(num1=2, num2=0, op=Operation.DIVIDE) yield from asyncio.wait_for(client.calculate(1, work), None) except InvalidOperation as e: print("InvalidOperation: {}".format(e)) # Make a few asynchronous calls concurrently and wait for all of them. start = time.time() calls = [ client.add(2, 3), client.add(1990, 1991), client.calculate(2, Work(num1=4, num2=2, op=Operation.MULTIPLY)), client.calculate(3, Work(num1=9, num2=3, op=Operation.SUBTRACT)), client.calculate(4, Work(num1=6, num2=8, op=Operation.ADD)), client.ping(), client.zip(), ] done, pending = yield from asyncio.wait(calls) if len(done) != len(calls): raise RuntimeError("Not all calls finished!") time_spent = time.time() - start print("Time spent on processing {} requests: {:f} secs, results are:" .format(len(calls), time_spent)) for fut in done: print(fut.result()) if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(main(loop))
apache-2.0
[ 3, 768, 3854, 13, 27403, 13, 647, 29677, 18, 199, 3, 768, 3854, 13, 27403, 13, 1548, 13, 19, 13, 15390, 13, 12775, 199, 199, 646, 16195, 199, 646, 900, 199, 199, 504, 17199, 14, 1000, 14, 52, 2822, 11706, 3120, 492, 3868, 6501, 3041, 3658, 2927, 199, 199, 504, 307, 15888, 492, 19821, 707, 199, 504, 307, 15888, 14, 21776, 492, 9361, 12, 17954, 12, 6378, 6044, 421, 199, 32, 19343, 14, 16675, 199, 318, 2446, 8, 3813, 304, 272, 334, 5545, 12, 4113, 9, 275, 1995, 687, 4438, 14, 981, 63, 2105, 8, 288, 3868, 6501, 3041, 3658, 2927, 8, 20000, 14, 3041, 395, 288, 1591, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 288, 1844, 29, 1299, 2006, 9, 272, 1890, 275, 4113, 14, 1258, 339, 327, 13144, 367, 314, 1654, 370, 14241, 642, 1613, 7508, 5160, 315, 23442, 590, 14, 272, 3089, 275, 1995, 687, 16195, 14, 2573, 63, 509, 8, 1258, 14, 525, 8, 17, 12, 499, 395, 488, 9, 272, 870, 480, 17, 435, 499, 275, 8352, 908, 8, 1838, 430, 339, 327, 7649, 23003, 701, 4697, 14, 272, 862, 26, 267, 1736, 275, 9361, 8, 1507, 17, 29, 18, 12, 1967, 18, 29, 16, 12, 1687, 29, 6044, 14, 1914, 5437, 37, 9, 267, 1995, 687, 16195, 14, 2573, 63, 509, 8, 1258, 14, 12063, 8, 17, 12, 1736, 395, 488, 9, 272, 871, 6378, 6044, 465, 325, 26, 267, 870, 480, 27355, 26, 8352, 908, 8, 69, 430, 339, 327, 4155, 282, 9284, 15608, 4882, 406, 19767, 436, 3618, 367, 1006, 402, 3062, 14, 272, 1343, 275, 900, 14, 521, 342, 272, 4882, 275, 359, 288, 1890, 14, 525, 8, 18, 12, 650, 395, 288, 1890, 14, 525, 8, 7155, 16, 12, 9013, 17, 395, 288, 1890, 14, 12063, 8, 18, 12, 9361, 8, 1507, 17, 29, 20, 12, 1967, 18, 29, 18, 12, 1687, 29, 6044, 14, 21894, 6084, 1826, 288, 1890, 14, 12063, 8, 19, 12, 9361, 8, 1507, 17, 29, 25, 12, 1967, 18, 29, 19, 12, 1687, 29, 6044, 14, 6348, 22280, 1826, 288, 1890, 14, 12063, 8, 20, 12, 9361, 8, 1507, 17, 29, 22, 12, 1967, 18, 29, 24, 12, 1687, 29, 6044, 14, 9732, 1826, 288, 1890, 14, 4073, 1062, 288, 1890, 14, 3065, 1062, 288, 1622, 272, 4224, 12, 9413, 275, 1995, 687, 16195, 14, 2573, 8, 5352, 9, 272, 340, 822, 8, 4456, 9, 1137, 822, 8, 5352, 304, 267, 746, 6064, 480, 1763, 1006, 4882, 9158, 9124, 272, 900, 63, 19435, 275, 900, 14, 521, 342, 446, 1343, 272, 870, 480, 1366, 2249, 484, 641, 6661, 1052, 4145, 26, 19850, 70, 93, 20091, 12, 2058, 787, 5424, 288, 1275, 908, 8, 552, 8, 5352, 395, 900, 63, 19435, 430, 272, 367, 289, 337, 315, 4224, 26, 267, 870, 8, 70, 337, 14, 1099, 1012, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4438, 275, 16195, 14, 362, 63, 1430, 63, 3813, 342, 272, 4438, 14, 1065, 63, 8111, 63, 4883, 8, 973, 8, 3813, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 768, 3854, 13, 27403, 13, 647, 29677, 18, 199, 3, 768, 3854, 13, 27403, 13, 1548, 13, 19, 13, 15390, 13, 12775, 199, 199, 646, 16195, 199, 646, 900, 199, 199, 504, 17199, 14, 1000, 14, 52, 2822, 11706, 3120, 492, 3868, 6501, 3041, 3658, 2927, 199, 199, 504, 307, 15888, 492, 19821, 707, 199, 504, 307, 15888, 14, 21776, 492, 9361, 12, 17954, 12, 6378, 6044, 421, 199, 32, 19343, 14, 16675, 199, 318, 2446, 8, 3813, 304, 272, 334, 5545, 12, 4113, 9, 275, 1995, 687, 4438, 14, 981, 63, 2105, 8, 288, 3868, 6501, 3041, 3658, 2927, 8, 20000, 14, 3041, 395, 288, 1591, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 288, 1844, 29, 1299, 2006, 9, 272, 1890, 275, 4113, 14, 1258, 339, 327, 13144, 367, 314, 1654, 370, 14241, 642, 1613, 7508, 5160, 315, 23442, 590, 14, 272, 3089, 275, 1995, 687, 16195, 14, 2573, 63, 509, 8, 1258, 14, 525, 8, 17, 12, 499, 395, 488, 9, 272, 870, 480, 17, 435, 499, 275, 8352, 908, 8, 1838, 430, 339, 327, 7649, 23003, 701, 4697, 14, 272, 862, 26, 267, 1736, 275, 9361, 8, 1507, 17, 29, 18, 12, 1967, 18, 29, 16, 12, 1687, 29, 6044, 14, 1914, 5437, 37, 9, 267, 1995, 687, 16195, 14, 2573, 63, 509, 8, 1258, 14, 12063, 8, 17, 12, 1736, 395, 488, 9, 272, 871, 6378, 6044, 465, 325, 26, 267, 870, 480, 27355, 26, 8352, 908, 8, 69, 430, 339, 327, 4155, 282, 9284, 15608, 4882, 406, 19767, 436, 3618, 367, 1006, 402, 3062, 14, 272, 1343, 275, 900, 14, 521, 342, 272, 4882, 275, 359, 288, 1890, 14, 525, 8, 18, 12, 650, 395, 288, 1890, 14, 525, 8, 7155, 16, 12, 9013, 17, 395, 288, 1890, 14, 12063, 8, 18, 12, 9361, 8, 1507, 17, 29, 20, 12, 1967, 18, 29, 18, 12, 1687, 29, 6044, 14, 21894, 6084, 1826, 288, 1890, 14, 12063, 8, 19, 12, 9361, 8, 1507, 17, 29, 25, 12, 1967, 18, 29, 19, 12, 1687, 29, 6044, 14, 6348, 22280, 1826, 288, 1890, 14, 12063, 8, 20, 12, 9361, 8, 1507, 17, 29, 22, 12, 1967, 18, 29, 24, 12, 1687, 29, 6044, 14, 9732, 1826, 288, 1890, 14, 4073, 1062, 288, 1890, 14, 3065, 1062, 288, 1622, 272, 4224, 12, 9413, 275, 1995, 687, 16195, 14, 2573, 8, 5352, 9, 272, 340, 822, 8, 4456, 9, 1137, 822, 8, 5352, 304, 267, 746, 6064, 480, 1763, 1006, 4882, 9158, 9124, 272, 900, 63, 19435, 275, 900, 14, 521, 342, 446, 1343, 272, 870, 480, 1366, 2249, 484, 641, 6661, 1052, 4145, 26, 19850, 70, 93, 20091, 12, 2058, 787, 5424, 288, 1275, 908, 8, 552, 8, 5352, 395, 900, 63, 19435, 430, 272, 367, 289, 337, 315, 4224, 26, 267, 870, 8, 70, 337, 14, 1099, 1012, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4438, 275, 16195, 14, 362, 63, 1430, 63, 3813, 342, 272, 4438, 14, 1065, 63, 8111, 63, 4883, 8, 973, 8, 3813, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1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PPU/GrenadaLandInformation
geonode/security/views.py
2
3949
# -*- coding: utf-8 -*- ######################################################################### # # Copyright (C) 2012 OpenPlans # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### from django.utils.translation import ugettext_lazy as _ from geonode.security.enumerations import ANONYMOUS_USERS, AUTHENTICATED_USERS from django.utils import simplejson as json from django.core.exceptions import PermissionDenied from geonode.utils import resolve_object from django.http import HttpResponse, HttpResponseRedirect from geonode.layers.models import Layer from geonode.maps.models import Map from geonode.documents.models import Document def _view_perms_context(obj, level_names): ctx = obj.get_all_level_info() def lname(l): return level_names.get(l, _("???")) ctx[ANONYMOUS_USERS] = lname(ctx.get(ANONYMOUS_USERS, obj.LEVEL_NONE)) ctx[AUTHENTICATED_USERS] = lname(ctx.get(AUTHENTICATED_USERS, obj.LEVEL_NONE)) ulevs = [] for u, l in ctx['users'].items(): ulevs.append([u, lname(l)]) ulevs.sort() ctx['users'] = ulevs return ctx def _perms_info(obj, level_names): info = obj.get_all_level_info() # these are always specified even if none info[ANONYMOUS_USERS] = info.get(ANONYMOUS_USERS, obj.LEVEL_NONE) info[AUTHENTICATED_USERS] = info.get(AUTHENTICATED_USERS, obj.LEVEL_NONE) info['users'] = sorted(info['users'].items()) info['levels'] = [(i, level_names[i]) for i in obj.permission_levels] if hasattr(obj, 'owner') and obj.owner is not None: info['owner'] = obj.owner.username return info def _perms_info_json(obj, level_names): return json.dumps(_perms_info(obj, level_names)) def resource_permissions(request, type, resource_id): try: if type == "layer": resource = resolve_object(request, Layer, {'id':resource_id}, 'layers.change_layer_permissions') elif type == "map": resource = resolve_object(request, Map, {'id':resource_id}, 'maps.change_map_permissions') elif type == "document": resource = resolve_object(request, Document, {'id':resource_id}, 'documents.change_document_permissions') else: return HttpResponse( 'Invalid resource type', status=401, mimetype='text/plain') except PermissionDenied: # we are handling this in a non-standard way return HttpResponse( 'You are not allowed to change permissions for this resource', status=401, mimetype='text/plain') if request.method == 'POST': permission_spec = json.loads(request.raw_post_data) resource.set_permissions(permission_spec) return HttpResponse( json.dumps({'success': True}), status=200, mimetype='text/plain' ) elif request.method == 'GET': permission_spec = json.dumps(resource.get_all_level_info()) return HttpResponse( json.dumps({'success': True, 'permissions': permission_spec}), status=200, mimetype='text/plain' ) else: return HttpResponse( 'No methods other than get and post are allowed', status=401, mimetype='text/plain')
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3949, 3, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 3232, 3714, 796, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3949, 3, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 2312, 29118, 14, 4416, 14, 18632, 3801, 492, 1261, 32537, 2679, 1668, 63, 28164, 12, 7560, 20987, 6989, 63, 28164, 199, 199, 504, 1639, 14, 1208, 492, 13804, 465, 2022, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 2312, 29118, 14, 1208, 492, 7512, 63, 785, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 199, 504, 2312, 29118, 14, 4359, 14, 992, 492, 11915, 199, 504, 2312, 29118, 14, 8919, 14, 992, 492, 9672, 199, 504, 2312, 29118, 14, 12233, 14, 992, 492, 7543, 199, 199, 318, 485, 1345, 63, 12068, 63, 1100, 8, 1113, 12, 2166, 63, 1247, 304, 339, 4027, 275, 221, 1559, 14, 362, 63, 452, 63, 1896, 63, 815, 342, 272, 347, 634, 354, 8, 76, 304, 267, 372, 2166, 63, 1247, 14, 362, 8, 76, 12, 3824, 10674, 31, 2237, 272, 4027, 59, 879, 32537, 2679, 1668, 63, 28164, 61, 275, 634, 354, 8, 3799, 14, 362, 8, 879, 32537, 2679, 1668, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 430, 272, 4027, 59, 22923, 6989, 63, 28164, 61, 275, 634, 354, 8, 3799, 14, 362, 8, 22923, 6989, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 430, 339, 399, 274, 3122, 275, 942, 272, 367, 399, 12, 634, 315, 4027, 459, 3707, 2278, 1744, 837, 267, 399, 274, 3122, 14, 740, 779, 85, 12, 634, 354, 8, 76, 3948, 272, 399, 274, 3122, 14, 3191, 342, 272, 4027, 459, 3707, 418, 275, 399, 274, 3122, 339, 372, 4027, 199, 199, 318, 485, 12068, 63, 815, 8, 1113, 12, 2166, 63, 1247, 304, 272, 2256, 275, 1559, 14, 362, 63, 452, 63, 1896, 63, 815, 342, 272, 327, 3520, 787, 3544, 2013, 2755, 340, 7179, 272, 2256, 59, 879, 32537, 2679, 1668, 63, 28164, 61, 275, 2256, 14, 362, 8, 879, 32537, 2679, 1668, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 9, 272, 2256, 59, 22923, 6989, 63, 28164, 61, 275, 2256, 14, 362, 8, 22923, 6989, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 9, 272, 2256, 459, 3707, 418, 275, 3355, 8, 815, 459, 3707, 2278, 1744, 1012, 272, 2256, 459, 11402, 418, 275, 3842, 73, 12, 2166, 63, 1247, 59, 73, 566, 367, 284, 315, 1559, 14, 5693, 63, 11402, 61, 272, 340, 2688, 8, 1113, 12, 283, 4597, 358, 436, 1559, 14, 4597, 365, 440, 488, 26, 267, 2256, 459, 4597, 418, 275, 1559, 14, 4597, 14, 2473, 272, 372, 2256, 421, 199, 318, 485, 12068, 63, 815, 63, 1001, 8, 1113, 12, 2166, 63, 1247, 304, 272, 372, 2022, 14, 4180, 1547, 12068, 63, 815, 8, 1113, 12, 2166, 63, 1247, 430, 199, 199, 318, 2073, 63, 6060, 8, 1069, 12, 730, 12, 2073, 63, 344, 304, 272, 862, 26, 267, 340, 730, 508, 298, 1897, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 11915, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 4359, 14, 1461, 63, 1897, 63, 6060, 358, 267, 916, 730, 508, 298, 1130, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 9672, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 8919, 14, 1461, 63, 1130, 63, 6060, 358, 267, 916, 730, 508, 298, 3554, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 7543, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 12233, 14, 1461, 63, 3554, 63, 6060, 358, 267, 587, 26, 288, 372, 6183, 8, 355, 283, 3364, 2073, 730, 297, 355, 2004, 29, 8854, 12, 355, 12200, 534, 505, 15, 6104, 358, 272, 871, 23724, 26, 267, 327, 781, 787, 7252, 642, 315, 282, 2222, 13, 6807, 4340, 267, 372, 6183, 8, 288, 283, 5556, 787, 440, 4370, 370, 1570, 3443, 367, 642, 2073, 297, 288, 2004, 29, 8854, 12, 288, 12200, 534, 505, 15, 6104, 358, 339, 340, 1056, 14, 765, 508, 283, 4030, 356, 267, 4983, 63, 1650, 275, 2022, 14, 3640, 8, 1069, 14, 1773, 63, 1932, 63, 576, 9, 267, 2073, 14, 409, 63, 6060, 8, 5693, 63, 1650, 9, 398, 372, 6183, 8, 288, 2022, 14, 4180, 3252, 3742, 356, 715, 8688, 288, 2004, 29, 1840, 12, 288, 12200, 534, 505, 15, 6104, 7, 267, 776, 339, 916, 1056, 14, 765, 508, 283, 2970, 356, 267, 4983, 63, 1650, 275, 2022, 14, 4180, 8, 1927, 14, 362, 63, 452, 63, 1896, 63, 815, 1012, 267, 372, 6183, 8, 288, 2022, 14, 4180, 3252, 3742, 356, 715, 12, 283, 6060, 356, 4983, 63, 1650, 8688, 288, 2004, 29, 1840, 12, 288, 12200, 534, 505, 15, 6104, 7, 267, 776, 272, 587, 26, 267, 372, 6183, 8, 288, 283, 1944, 3102, 1163, 2419, 664, 436, 2963, 787, 4370, 297, 288, 2004, 29, 8854, 12, 288, 12200, 534, 505, 15, 6104, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3949, 3, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 3232, 3714, 796, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3949, 3, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 2312, 29118, 14, 4416, 14, 18632, 3801, 492, 1261, 32537, 2679, 1668, 63, 28164, 12, 7560, 20987, 6989, 63, 28164, 199, 199, 504, 1639, 14, 1208, 492, 13804, 465, 2022, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 2312, 29118, 14, 1208, 492, 7512, 63, 785, 199, 504, 1639, 14, 1014, 492, 6183, 12, 14935, 199, 504, 2312, 29118, 14, 4359, 14, 992, 492, 11915, 199, 504, 2312, 29118, 14, 8919, 14, 992, 492, 9672, 199, 504, 2312, 29118, 14, 12233, 14, 992, 492, 7543, 199, 199, 318, 485, 1345, 63, 12068, 63, 1100, 8, 1113, 12, 2166, 63, 1247, 304, 339, 4027, 275, 221, 1559, 14, 362, 63, 452, 63, 1896, 63, 815, 342, 272, 347, 634, 354, 8, 76, 304, 267, 372, 2166, 63, 1247, 14, 362, 8, 76, 12, 3824, 10674, 31, 2237, 272, 4027, 59, 879, 32537, 2679, 1668, 63, 28164, 61, 275, 634, 354, 8, 3799, 14, 362, 8, 879, 32537, 2679, 1668, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 430, 272, 4027, 59, 22923, 6989, 63, 28164, 61, 275, 634, 354, 8, 3799, 14, 362, 8, 22923, 6989, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 430, 339, 399, 274, 3122, 275, 942, 272, 367, 399, 12, 634, 315, 4027, 459, 3707, 2278, 1744, 837, 267, 399, 274, 3122, 14, 740, 779, 85, 12, 634, 354, 8, 76, 3948, 272, 399, 274, 3122, 14, 3191, 342, 272, 4027, 459, 3707, 418, 275, 399, 274, 3122, 339, 372, 4027, 199, 199, 318, 485, 12068, 63, 815, 8, 1113, 12, 2166, 63, 1247, 304, 272, 2256, 275, 1559, 14, 362, 63, 452, 63, 1896, 63, 815, 342, 272, 327, 3520, 787, 3544, 2013, 2755, 340, 7179, 272, 2256, 59, 879, 32537, 2679, 1668, 63, 28164, 61, 275, 2256, 14, 362, 8, 879, 32537, 2679, 1668, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 9, 272, 2256, 59, 22923, 6989, 63, 28164, 61, 275, 2256, 14, 362, 8, 22923, 6989, 63, 28164, 12, 1559, 14, 11817, 63, 9185, 9, 272, 2256, 459, 3707, 418, 275, 3355, 8, 815, 459, 3707, 2278, 1744, 1012, 272, 2256, 459, 11402, 418, 275, 3842, 73, 12, 2166, 63, 1247, 59, 73, 566, 367, 284, 315, 1559, 14, 5693, 63, 11402, 61, 272, 340, 2688, 8, 1113, 12, 283, 4597, 358, 436, 1559, 14, 4597, 365, 440, 488, 26, 267, 2256, 459, 4597, 418, 275, 1559, 14, 4597, 14, 2473, 272, 372, 2256, 421, 199, 318, 485, 12068, 63, 815, 63, 1001, 8, 1113, 12, 2166, 63, 1247, 304, 272, 372, 2022, 14, 4180, 1547, 12068, 63, 815, 8, 1113, 12, 2166, 63, 1247, 430, 199, 199, 318, 2073, 63, 6060, 8, 1069, 12, 730, 12, 2073, 63, 344, 304, 272, 862, 26, 267, 340, 730, 508, 298, 1897, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 11915, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 4359, 14, 1461, 63, 1897, 63, 6060, 358, 267, 916, 730, 508, 298, 1130, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 9672, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 8919, 14, 1461, 63, 1130, 63, 6060, 358, 267, 916, 730, 508, 298, 3554, 582, 288, 2073, 275, 7512, 63, 785, 8, 1069, 12, 7543, 12, 791, 344, 356, 1927, 63, 344, 1386, 283, 12233, 14, 1461, 63, 3554, 63, 6060, 358, 267, 587, 26, 288, 372, 6183, 8, 355, 283, 3364, 2073, 730, 297, 355, 2004, 29, 8854, 12, 355, 12200, 534, 505, 15, 6104, 358, 272, 871, 23724, 26, 267, 327, 781, 787, 7252, 642, 315, 282, 2222, 13, 6807, 4340, 267, 372, 6183, 8, 288, 283, 5556, 787, 440, 4370, 370, 1570, 3443, 367, 642, 2073, 297, 288, 2004, 29, 8854, 12, 288, 12200, 534, 505, 15, 6104, 358, 339, 340, 1056, 14, 765, 508, 283, 4030, 356, 267, 4983, 63, 1650, 275, 2022, 14, 3640, 8, 1069, 14, 1773, 63, 1932, 63, 576, 9, 267, 2073, 14, 409, 63, 6060, 8, 5693, 63, 1650, 9, 398, 372, 6183, 8, 288, 2022, 14, 4180, 3252, 3742, 356, 715, 8688, 288, 2004, 29, 1840, 12, 288, 12200, 534, 505, 15, 6104, 7, 267, 776, 339, 916, 1056, 14, 765, 508, 283, 2970, 356, 267, 4983, 63, 1650, 275, 2022, 14, 4180, 8, 1927, 14, 362, 63, 452, 63, 1896, 63, 815, 1012, 267, 372, 6183, 8, 288, 2022, 14, 4180, 3252, 3742, 356, 715, 12, 283, 6060, 356, 4983, 63, 1650, 8688, 288, 2004, 29, 1840, 12, 288, 12200, 534, 505, 15, 6104, 7, 267, 776, 272, 587, 26, 267, 372, 6183, 8, 288, 283, 1944, 3102, 1163, 2419, 664, 436, 2963, 787, 4370, 297, 288, 2004, 29, 8854, 12, 288, 12200, 534, 505, 15, 6104, 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, 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, 1, 1, 1, 1, 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 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 ]
hoelsner/product-database
app/productdb/models.py
1
40333
import hashlib import re from collections import Counter from datetime import timedelta from django.contrib.auth.models import User from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator, MaxValueValidator from django.core.cache import cache from django.core.cache.utils import make_template_fragment_key from django.db import models from django.db.models import Q from django.db.models.signals import pre_delete, post_save, pre_save, post_delete from django.dispatch import receiver from django.utils.timezone import datetime, now from app.config.settings import AppSettings from app.productdb.validators import validate_product_list_string from app.productdb import utils CURRENCY_CHOICES = ( ('EUR', 'Euro'), ('USD', 'US-Dollar'), ) class JobFile(models.Model): """Uploaded files for tasks""" file = models.FileField(upload_to=settings.DATA_DIRECTORY) @receiver(pre_delete, sender=JobFile) def delete_job_file(sender, instance, **kwargs): """remove the file from the disk if the Job File object is deleted""" instance.file.delete(False) class Vendor(models.Model): """ Vendor """ name = models.CharField( max_length=128, unique=True ) def __str__(self): return self.name def delete(self, using=None, **kwargs): # prevent the deletion of the "unassigned" value from model if self.id == 0: raise Exception("Operation not allowed") super().delete(using) def save(self, **kwargs): # clean the object before save self.full_clean() super(Vendor, self).save(**kwargs) class Meta: verbose_name = "vendor" verbose_name_plural = "vendors" ordering = ('name',) class ProductGroup(models.Model): """ Product Group """ name = models.CharField( max_length=512, help_text="Name of the Product Group" ) vendor = models.ForeignKey( Vendor, blank=False, null=False, default=0, verbose_name="Vendor", on_delete=models.SET_DEFAULT ) def get_all_products(self): """returns a query set that contains all Products""" result = None if self.pk: result = Product.objects.filter(product_group_id=self.pk) if result.count() == 0: result = None return result def save(self, *args, **kwargs): # clean the object before save self.full_clean() super(ProductGroup, self).save(*args, **kwargs) def clean(self): # check that the Product Group Name already exist in the database for the given vendor if ProductGroup.objects.filter(vendor=self.vendor, name=self.name).exists(): raise ValidationError({ "name": ValidationError("group name already defined for this vendor") }) # verify that all associated Products have the same Vendor as the product list associated_products = self.get_all_products() import logging logging.debug("Associated Products to %s: %s - %s" %( self.name, len(associated_products) if associated_products is not None else "0 (None)", associated_products.values_list("product_id", flat=True) if associated_products is not None else "[]" )) # if no products are associated to the group, no check is required if associated_products: products_with_different_vendor = [False for product in self.get_all_products() if product.vendor != self.vendor] if len(products_with_different_vendor) != 0: raise ValidationError({ "vendor": ValidationError("cannot set new vendor as long as there are products associated to it") }) def __str__(self): return self.name class Meta: verbose_name = "Product Group" verbose_name_plural = "Product Groups" unique_together = ("name", "vendor") class Product(models.Model): END_OF_SUPPORT_STR = "End of Support" END_OF_SALE_STR = "End of Sale" END_OF_NEW_SERVICE_ATTACHMENT_STR = "End of New Service Attachment Date" END_OF_SW_MAINTENANCE_RELEASES_STR = "End of SW Maintenance Releases Date" END_OF_ROUTINE_FAILURE_ANALYSIS_STR = "End of Routine Failure Analysis Date" END_OF_SERVICE_CONTRACT_RENEWAL_STR = "End of Service Contract Renewal Date" END_OF_VUL_SUPPORT_STR = "End of Vulnerability/Security Support date" EOS_ANNOUNCED_STR = "EoS announced" NO_EOL_ANNOUNCEMENT_STR = "No EoL announcement" # preference greater than the following constant is considered preferred LESS_PREFERRED_PREFERENCE_VALUE = 25 product_id = models.CharField( unique=False, max_length=512, help_text="Product ID/Number" ) description = models.TextField( default="", blank=True, null=True, help_text="description of the product" ) list_price = models.FloatField( null=True, blank=True, verbose_name="list price", help_text="list price of the element", validators=[MinValueValidator(0)] ) currency = models.CharField( max_length=16, choices=CURRENCY_CHOICES, default="USD", verbose_name="currency", help_text="currency of the list price" ) tags = models.TextField( default="", blank=True, null=True, verbose_name="Tags", help_text="unstructured tag field" ) vendor = models.ForeignKey( Vendor, blank=False, null=False, default=0, verbose_name="Vendor", on_delete=models.SET_DEFAULT ) eox_update_time_stamp = models.DateField( null=True, blank=True, verbose_name="EoX lifecycle data timestamp", help_text="Indicates that the product has lifecycle data and when they were updated. If no " "EoL announcement date is set but an update timestamp, the product is considered as not EoL/EoS." ) eol_ext_announcement_date = models.DateField( null=True, blank=True, verbose_name="End-of-Life Announcement Date" ) end_of_sale_date = models.DateField( null=True, blank=True, verbose_name="End-of-Sale Date" ) end_of_new_service_attachment_date = models.DateField( null=True, blank=True, verbose_name="End of New Service Attachment Date" ) end_of_sw_maintenance_date = models.DateField( null=True, blank=True, verbose_name="End of SW Maintenance Releases Date" ) end_of_routine_failure_analysis = models.DateField( null=True, blank=True, verbose_name="End of Routine Failure Analysis Date" ) end_of_service_contract_renewal = models.DateField( null=True, blank=True, verbose_name="End of Service Contract Renewal Date" ) end_of_support_date = models.DateField( null=True, blank=True, verbose_name="Last Date of Support", ) end_of_sec_vuln_supp_date = models.DateField( null=True, blank=True, verbose_name="End of Vulnerability/Security Support date" ) eol_reference_number = models.CharField( max_length=2048, null=True, blank=True, verbose_name="EoL reference number", help_text="Product bulletin number or vendor specific reference for EoL" ) eol_reference_url = models.URLField( null=True, blank=True, max_length=1024, verbose_name="EoL reference URL", help_text="URL to the Product bulletin or EoL reference" ) product_group = models.ForeignKey( ProductGroup, null=True, blank=True, verbose_name="Product Group", on_delete=models.SET_NULL ) lc_state_sync = models.BooleanField( default=False, verbose_name="lifecycle data automatically synchronized", help_text="product is automatically synchronized against the vendor data" # always false except for Cisco EoX # API entries ) internal_product_id = models.CharField( verbose_name="Internal Product ID", help_text="optional internal reference for the Product", max_length=255, null=True, blank=True ) update_timestamp = models.DateField( verbose_name="update timestamp", help_text="last changes to the product data", auto_created=True, default=now ) list_price_timestamp = models.DateField( verbose_name="list price timestamp", help_text="last change of the list price", null=True, blank=True ) @property def current_lifecycle_states(self): """ returns a list with all EoL states or None if no EoL announcement ist set """ # compute only if an EoL announcement date is specified if self.eol_ext_announcement_date: # check the current state result = [] today = datetime.now().date() # if not defined, use a date in the future end_of_sale_date = self.end_of_sale_date \ if self.end_of_sale_date else (datetime.now() + timedelta(days=7)).date() end_of_support_date = self.end_of_support_date \ if self.end_of_support_date else (datetime.now() + timedelta(days=7)).date() end_of_new_service_attachment_date = self.end_of_new_service_attachment_date \ if self.end_of_new_service_attachment_date else (datetime.now() + timedelta(days=7)).date() end_of_sw_maintenance_date = self.end_of_sw_maintenance_date \ if self.end_of_sw_maintenance_date else (datetime.now() + timedelta(days=7)).date() end_of_routine_failure_analysis = self.end_of_routine_failure_analysis \ if self.end_of_routine_failure_analysis else (datetime.now() + timedelta(days=7)).date() end_of_service_contract_renewal = self.end_of_service_contract_renewal \ if self.end_of_service_contract_renewal else (datetime.now() + timedelta(days=7)).date() end_of_sec_vuln_supp_date = self.end_of_sec_vuln_supp_date \ if self.end_of_sec_vuln_supp_date else (datetime.now() + timedelta(days=7)).date() if today >= end_of_sale_date: if today >= end_of_support_date: result.append(self.END_OF_SUPPORT_STR) else: result.append(self.END_OF_SALE_STR) if today >= end_of_new_service_attachment_date: result.append(self.END_OF_NEW_SERVICE_ATTACHMENT_STR) if today >= end_of_sw_maintenance_date: result.append(self.END_OF_SW_MAINTENANCE_RELEASES_STR) if today >= end_of_routine_failure_analysis: result.append(self.END_OF_ROUTINE_FAILURE_ANALYSIS_STR) if today >= end_of_service_contract_renewal: result.append(self.END_OF_SERVICE_CONTRACT_RENEWAL_STR) if today >= end_of_sec_vuln_supp_date: result.append(self.END_OF_VUL_SUPPORT_STR) else: # product is eos announced result.append(self.EOS_ANNOUNCED_STR) return result else: if self.eox_update_time_stamp is not None: return [self.NO_EOL_ANNOUNCEMENT_STR] else: return None def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.__loaded_list_price = self.list_price self.__loaded_lc_state_sync = self.lc_state_sync def __str__(self): return self.product_id def save(self, *args, **kwargs): # strip URL value if self.eol_reference_url is not None: self.eol_reference_url = self.eol_reference_url.strip() if self.__loaded_list_price != self.list_price: # price has changed, update flag self.list_price_timestamp = datetime.today() # the state sync is only updated within a separate task and always updated separately if self.__loaded_lc_state_sync == self.lc_state_sync: # state sync not changed, update of the update timestamp self.update_timestamp = datetime.today() # clean the object before save self.full_clean() super(Product, self).save(*args, **kwargs) def clean(self): # the vendor values of the product group and the product must be the same if self.product_group: if self.product_group.vendor != self.vendor: raise ValidationError({ "product_group": ValidationError( "Invalid product group, group and product must be associated to the same vendor", code='invalid' ) }) def has_migration_options(self): return self.productmigrationoption_set.exists() def has_preferred_migration_option(self): """check that a preferred migration option exist (Product Migration Source preference > 25)""" return self.productmigrationoption_set.filter( migration_source__preference__gt=self.LESS_PREFERRED_PREFERENCE_VALUE ).count() != 0 def get_preferred_replacement_option(self): """Return the preferred replacement option (Product Migration Sources with a preference greater than 25)""" if self.has_migration_options() and self.has_preferred_migration_option(): return self.get_migration_path(self.productmigrationoption_set.filter( migration_source__preference__gt=self.LESS_PREFERRED_PREFERENCE_VALUE ).first().migration_source.name)[-1] return None def get_migration_path(self, migration_source_name=None): """ recursive lookup of the given migration source name, result is an ordered list, the first element is the direct replacement and the last one is the valid replacement """ if not migration_source_name: if not self.productmigrationoption_set.all().exists(): return [] else: # use the preferred path (except all Migration sources with a preference of 25 and lower) migration_source_name = self.productmigrationoption_set.filter( migration_source__preference__gt=self.LESS_PREFERRED_PREFERENCE_VALUE ).first().migration_source.name if type(migration_source_name) is not str: raise AttributeError("attribute 'migration_source_name' must be a string") result = [] if self.productmigrationoption_set.filter(migration_source__name=migration_source_name).exists(): result.append(self.productmigrationoption_set.filter(migration_source__name=migration_source_name).first()) while True: # test, that the product migration option is valid and that a replacement_product_id exists if not result[-1].is_valid_replacement() and result[-1].replacement_product_id: # test if it is in the database if result[-1].is_replacement_in_db(): # get replacement product ID from database p = Product.objects.get(product_id=result[-1].replacement_product_id) if p.productmigrationoption_set.filter(migration_source__name=migration_source_name).exists(): result.append( p.productmigrationoption_set.filter( migration_source__name=migration_source_name )[:1].first() ) else: break else: break else: break return result def get_product_migration_source_names_set(self): return list(self.productmigrationoption_set.all().values_list("migration_source__name", flat=True)) class Meta: verbose_name = "Product" verbose_name_plural = "Products" unique_together = ("product_id", "vendor",) ordering = ("product_id",) class ProductMigrationSource(models.Model): name = models.CharField( help_text="name of the migration source", unique=True, max_length=255 ) description = models.TextField( help_text="", max_length=4096, blank=True, null=True ) preference = models.PositiveSmallIntegerField( help_text="preference value, identifies which source is preferred over another (100 is most preferred)", validators=[ MaxValueValidator(100), MinValueValidator(1) ], default=50 ) def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.full_clean() super().save(force_insert, force_update, using, update_fields) def __str__(self): return self.name class Meta: verbose_name = "Product Migration Source" verbose_name_plural = "Product Migration Sources" ordering = ["-preference", "name"] # sort descending, that the most preferred source is always on op class ProductMigrationOption(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) migration_source = models.ForeignKey(ProductMigrationSource, on_delete=models.CASCADE) replacement_product_id = models.CharField( max_length=512, help_text="the suggested replacement option", null=False, blank=True ) replacement_db_product = models.ForeignKey( Product, null=True, blank=True, on_delete=models.SET_NULL, related_name="replacement_db_product" ) comment = models.TextField( max_length=4096, help_text="comment from the group (optional)", null=False, blank=True ) migration_product_info_url = models.URLField( null=True, blank=True, verbose_name="Migration Product Info URL", help_text="Migration Product Information URL" ) def is_replacement_in_db(self): """True, if the replacement product exists in the database""" return self.replacement_db_product is not None def get_product_replacement_id(self): """returns the product ID of the replacement, if not defined or not in the database, result is None""" return self.replacement_db_product.id if self.replacement_db_product else None def is_valid_replacement(self): """Check that the object is a valid replacement option. A replacement option is valid if * a replacement Product ID is set and not part of the database * a replacement Product ID is set and part of the database (only, if the Product is not EoL announced) """ if self.replacement_product_id: if self.is_replacement_in_db(): # replacement product ID is part of the database if not self.replacement_db_product.end_of_sale_date or \ self.replacement_db_product.current_lifecycle_states == [Product.NO_EOL_ANNOUNCEMENT_STR]: # product is not EoL and therefore valid return True else: return False else: return True return False def get_valid_replacement_product(self): """get a valid replacement product for this migration source""" if self.is_valid_replacement(): return self.replacement_db_product return None def clean(self): # check required to get a proper validation working within the Django admin (unique together with the required # FK values) if self.product_id is not None and self.migration_source_id is not None: # validate that this combination does not already exist (issue when using django admin) qs = ProductMigrationOption.objects.exclude(pk=self.pk).filter( product__id=self.product_id, migration_source__id=self.migration_source_id ) if qs.count() > 0: # one of the fields must be changed, therefore view the error on both attributes msg = "Product Migration Option with this Product ID and Migration Source already exists" raise ValidationError({"product_id": msg, "migration_source": msg}) def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.full_clean() super().save(force_insert, force_update, using, update_fields) def __str__(self): return "replacement option for %s" % self.product.product_id class Meta: # only a single migration option is allowed per migration source unique_together = ["product", "migration_source"] ordering = ["-migration_source__preference"] # first element is from the source that is most preferred verbose_name = "Product Migration Option" verbose_name_plural = "Product Migration Options" class ProductList(models.Model): name = models.CharField( max_length=2048, unique=True, help_text="unique name for the product list", verbose_name="Product List Name" ) vendor = models.ForeignKey( Vendor, help_text="vendor for the product list (only products from a single vendor can be used within a product list)", verbose_name="Vendor", on_delete=models.CASCADE, # auto-discovery based on the list entries is implemented as part of the save function # required only for data migration null=True, blank=False ) string_product_list = models.TextField( help_text="Product IDs separated by word wrap or semicolon", verbose_name="Unstructured Product IDs separated by line break" ) description = models.TextField( max_length=4096, blank=True, null=False, verbose_name="Description", help_text="short description what's part of this Product List (markdown and/or HTML)" ) version_note = models.TextField( max_length=16384, blank=True, null=False, verbose_name="Version note", help_text="some version information for the product list (markdown and/or HTML)" ) update_date = models.DateField( auto_now=True ) update_user = models.ForeignKey( User, related_name='product_lists', on_delete=models.CASCADE ) hash = models.CharField( max_length=64, null=False, blank=True, default="" ) def get_string_product_list_as_list(self): result = [] for line in self.string_product_list.splitlines(): result += line.split(";") return sorted([e.strip() for e in result]) def get_product_list_objects(self): q_filter = Q() for product_id in self.get_string_product_list_as_list(): q_filter.add(Q(product_id=product_id, vendor_id=self.vendor_id), Q.OR) return Product.objects.filter(q_filter).prefetch_related("vendor", "product_group") def full_clean(self, exclude=None, validate_unique=True): # validate product list string together with selected vendor result = super().full_clean(exclude, validate_unique) # validation between fields self.__discover_vendor_based_on_products() if self.vendor is not None: validate_product_list_string(self.string_product_list, self.vendor.id) else: raise ValidationError("vendor not set") return result def save(self, **kwargs): self.__discover_vendor_based_on_products() self.full_clean() # normalize value in database, remove duplicates and sort the list values = self.get_string_product_list_as_list() self.string_product_list = "\n".join(sorted(list(set(values)))) # calculate hash value for Product check linking on the queries s = "%s:%s:%s" % (self.name, self.string_product_list, self.vendor_id) self.hash = hashlib.sha256(s.encode()).hexdigest() super(ProductList, self).save(**kwargs) def __discover_vendor_based_on_products(self): # discovery vendor based on the products (if not set, used primary for data migration) if self.vendor is None: product_id_list = self.get_string_product_list_as_list() if len(product_id_list) > 0: self.vendor = Product.objects.filter(product_id=product_id_list[-1]).first().vendor def __str__(self): return self.name class Meta: verbose_name = "Product List" verbose_name_plural = "Product Lists" ordering = ('name',) class UserProfileManager(models.Manager): def get_by_natural_key(self, username): return self.get(user=User.objects.get(username=username)) class UserProfile(models.Model): objects = UserProfileManager() user = models.OneToOneField( User, related_name='profile', on_delete=models.CASCADE, unique=True ) preferred_vendor = models.ForeignKey( Vendor, blank=False, null=False, default=1, verbose_name="preferred vendor", help_text="vendor that is selected by default in all vendor specific views", on_delete=models.SET_DEFAULT ) regex_search = models.BooleanField( default=False, verbose_name="use regular expressions in search fields", help_text="Use regular expression in any search field (fallback to simple search if no valid " "regular expression is used)" ) choose_migration_source = models.BooleanField( default=False, verbose_name="choose Migration Source in Product Check", help_text="specify the Migration Source for a Product Check (don't use the preferred migration path)" ) def natural_key(self): return self.user.username def __str__(self): return "User Profile for %s" % self.user.username class ProductCheckInputChunks(models.Model): """chunks for the input product IDs field in the product check""" sequence = models.PositiveIntegerField() input_product_ids_chunk = models.CharField( max_length=65536, null=False, blank=True ) product_check = models.ForeignKey( "ProductCheck", on_delete=models.CASCADE ) class Meta: ordering = ['sequence'] class ProductCheck(models.Model): name = models.CharField( verbose_name="Name", help_text="Name to identify the Product Check", max_length=256 ) migration_source = models.ForeignKey( ProductMigrationSource, verbose_name="migration source", help_text="migration source to identify the replacement options, if not selected the preferred migration path " "is used", null=True, blank=True, on_delete=models.CASCADE ) @property def use_preferred_migration_source(self): """if no migration source is choosen, always use the preferred one""" return self.migration_source is None # buffer value (before save) _input_product_ids = "" @property def input_product_ids(self): """return concat string of all input product id chunks""" if self._input_product_ids == "": values = self.productcheckinputchunks_set.values_list("input_product_ids_chunk", flat=True) return "".join(values) else: return self._input_product_ids @input_product_ids.setter def input_product_ids(self, value): if type(value) is not str: raise AttributeError("value must be a string type") self._input_product_ids = value @property def input_product_ids_list(self): result = [] for line in [line.strip() for line in self.input_product_ids.splitlines() if line.strip() != ""]: result += line.split(";") return sorted([e.strip() for e in result]) last_change = models.DateTimeField( auto_now=True ) create_user = models.ForeignKey( User, help_text="if not null, the product check is available to all users", on_delete=models.CASCADE, null=True, blank=True ) @property def is_public(self): return self.create_user is None task_id = models.CharField( help_text="if set, the product check is currently executed", max_length=64, null=True, blank=True ) @property def in_progress(self): """product check is currently processed""" return self.task_id is not None def perform_product_check(self): """perform the product check and populate the ProductCheckEntries""" unique_products = [line.strip() for line in set(self.input_product_ids_list) if line.strip() != ""] amounts = Counter(self.input_product_ids_list) # clean all entries self.productcheckentry_set.all().delete() for input_product_id in unique_products: product_entry, _ = ProductCheckEntry.objects.get_or_create( input_product_id=input_product_id, product_check=self ) product_entry.amount = amounts[input_product_id] product_entry.discover_product_list_values() product_entry.save() # increments statistics settings = AppSettings() settings.set_amount_of_product_checks(settings.get_amount_of_product_checks() + 1) settings.set_amount_of_unique_product_check_entries(settings.get_amount_of_unique_product_check_entries() + len(unique_products)) self.save() def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.full_clean() super().save(force_insert, force_update, using, update_fields) # save chunks to database (if new value is set) if self._input_product_ids != "": self.productcheckinputchunks_set.all().delete() chunks = utils.split_string(self._input_product_ids, 65536) counter = 1 for chunk in chunks: ProductCheckInputChunks.objects.create(product_check=self, input_product_ids_chunk=chunk, sequence=counter) counter += 1 def __str__(self): return self.name def __repr__(self): return "<Class 'ProductCheck' %d> %s" % (self.id, self.name) class Meta: verbose_name = "Product Check" verbose_name_plural = "Product Checks" class ProductCheckEntry(models.Model): product_check = models.ForeignKey( ProductCheck, on_delete=models.CASCADE ) input_product_id = models.CharField( verbose_name="Product ID", max_length=256 ) product_in_database = models.ForeignKey( Product, null=True, blank=True, on_delete=models.SET_NULL ) @property def in_database(self): return self.product_in_database is not None amount = models.PositiveIntegerField( verbose_name="amount", default=0 ) migration_product = models.ForeignKey( ProductMigrationOption, verbose_name="Migration Option", on_delete=models.CASCADE, null=True, blank=True ) part_of_product_list = models.TextField( verbose_name="product list hash values", help_text="hash values of product lists that contain the Product (at time of the check)", max_length=8192, null=False, blank=True, default="" ) @property def product_list_hash_values(self): """return an unordered list of hash strings that contains the Product at time of the check""" return self.part_of_product_list.splitlines() def get_product_list_names(self): """return an list of Product List Names that contains the Product at time of the check""" self.__discover_product_relation_in_database() return ProductList.objects.filter(hash__in=self.product_list_hash_values).values_list("name", flat=True) def discover_product_list_values(self): """populate the part_of_product_list field""" self.part_of_product_list = "" query = ProductList.objects.filter(string_product_list__contains=self.input_product_id) self.part_of_product_list += "\n".join(query.values_list("hash", flat=True)) def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.full_clean() self.__discover_product_relation_in_database(force_update=True) super().save(force_insert, force_update, using, update_fields) def __discover_product_relation_in_database(self, force_update=False): """populate the 'product_in_database' relation as a shortcut if possible""" if (self.product_in_database is None) or (force_update is False): query = Product.objects.filter(product_id=self.input_product_id) if query.count() != 0: self.product_in_database = query.first() if self.product_check.migration_source: # if the product check defines a migration source, try a lookup on this verison replacement_product_list = self.product_in_database.get_migration_path(self.product_check.migration_source.name) if len(replacement_product_list) != 0: self.migration_product = replacement_product_list[-1] else: # if nothing is specified, get the preferred replacement option self.migration_product = self.product_in_database.get_preferred_replacement_option() def __str__(self): return "%s: %s (%d)" % (self.product_check, self.input_product_id, self.amount) def __repr__(self): return "<Class 'ProductCheckEntry' %d> %s (ProductCheck '%d')" % (self.id, self.input_product_id, self.product_check_id) class Meta: verbose_name = "Product Check Entry" verbose_name_plural = "Product Check Entries" class ProductIdNormalizationRule(models.Model): """ Normalization rule for a Product ID """ vendor = models.ForeignKey( Vendor, verbose_name="Vendor", help_text="Vendor where the rule should apply", on_delete=models.CASCADE ) product_id = models.CharField( verbose_name="Product ID", help_text="Normalized Product ID that should be used", max_length=255, null=True, blank=True ) regex_match = models.CharField( verbose_name="RegEx to Match", help_text="Condition for a given input to match the Product ID", max_length=255, null=True, blank=True ) comment = models.CharField( verbose_name="Comment", help_text="Rule comment", max_length=4096, null=True, blank=True ) priority = models.IntegerField( verbose_name="Priority", help_text="priority of the rule", default=500 ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._pattern = None def matches(self, raw_product_id): """ returns True if the given Product ID matches the pattern from the instance :param raw_product_id: raw Product ID :return: """ if self._pattern is None: self._pattern = re.compile(self.regex_match) if self._pattern.match(raw_product_id): return True else: return False def get_normalized_product_id(self, raw_product_id): """ get the normalization result of a given raw_product_id :raises AttributeError: if the raw_product_id doesn't match this entry :param raw_product_id: :return: """ if not self.matches(raw_product_id): raise AttributeError("input product ID does not match normalization") if self._pattern.match(raw_product_id): groups = self._pattern.match(raw_product_id).groups() if len(groups) != 0: return self.product_id % groups return self.product_id def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.full_clean() super().save(force_insert, force_update, using, update_fields) class Meta: verbose_name = "Product ID Normalization Rule" verbose_name_plural = "Product ID Normalization Rules" ordering = [ "priority", "product_id" ] unique_together = ( "vendor", "product_id", "regex_match" ) @receiver(post_save, sender=User) def create_user_profile_if_not_exist(sender, instance, **kwargs): if not UserProfile.objects.filter(user=instance).exists(): # create new user profile with default options UserProfile.objects.create(user=instance) @receiver([post_save, post_delete], sender=ProductList) def invalidate_page_cache(sender, instance, **kwargs): key = make_template_fragment_key("productlist_detail", [instance.id, False]) if key: cache.delete(key) key = make_template_fragment_key("productlist_detail", [instance.id, True]) if key: cache.delete(key) @receiver(post_save, sender=Product) def update_db_state_for_the_migration_options_with_product_id(sender, instance, **kwargs): """save all Product Migration Options where the replacement product ID is the same as the Product ID that was saved to update the replacement_in_db flag""" for pmo in ProductMigrationOption.objects.filter(replacement_product_id=instance.product_id): pmo.save() @receiver([post_save, post_delete], sender=Product) def invalidate_product_related_cache_values(sender, instance, **kwargs): """delete cache values that are somehow related to the Product data model""" cache.delete("PDB_HOMEPAGE_CONTEXT") @receiver(pre_save, sender=ProductMigrationOption) def update_product_migration_replacement_id_relation_field(sender, instance, **kwargs): """ensures that a database relation for a replacement product ID exists, if the replacement_product_id is part of the database, validates that these two values cannot be the same""" try: # check that the replacement product id is not the same as the original product id (would create a loop # within migration path computation) if instance.replacement_product_id != instance.product.product_id: instance.replacement_db_product = Product.objects.get(product_id=instance.replacement_product_id) else: raise ValidationError({ "replacement_product_id": "Product ID that should be replaced cannot be the same as the suggested " "replacement Product ID" }) except ValidationError: raise # propagate to the save method except Exception: instance.replacement_db_product = None
mit
[ 646, 8337, 199, 646, 295, 199, 504, 5055, 492, 14427, 199, 504, 2197, 492, 6871, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 11346, 492, 10195, 1110, 8640, 12, 8228, 1110, 8640, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 1637, 14, 1208, 492, 1852, 63, 1160, 63, 7677, 63, 498, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 876, 63, 1807, 12, 2963, 63, 2117, 12, 876, 63, 2117, 12, 2963, 63, 1807, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 1208, 14, 7145, 492, 2197, 12, 3063, 199, 504, 1145, 14, 888, 14, 1751, 492, 4693, 5268, 199, 504, 1145, 14, 2558, 697, 14, 11346, 492, 4107, 63, 2558, 63, 513, 63, 875, 199, 504, 1145, 14, 2558, 697, 492, 3778, 199, 199, 7013, 24861, 63, 16236, 275, 334, 272, 661, 37, 1230, 297, 283, 37, 9129, 659, 272, 661, 1668, 36, 297, 283, 1668, 13, 36, 25317, 659, 199, 9, 421, 199, 533, 15057, 1173, 8, 992, 14, 1685, 304, 272, 408, 21145, 1584, 367, 6527, 624, 272, 570, 275, 1709, 14, 23252, 8, 5064, 63, 475, 29, 1751, 14, 3998, 63, 16436, 9, 421, 199, 32, 10244, 8, 657, 63, 1807, 12, 8904, 29, 6694, 1173, 9, 199, 318, 3145, 63, 2423, 63, 493, 8, 8114, 12, 1256, 12, 1011, 958, 304, 272, 408, 2168, 314, 570, 687, 314, 4543, 340, 314, 15057, 3814, 909, 365, 5463, 624, 272, 1256, 14, 493, 14, 1807, 8, 797, 9, 421, 199, 533, 812, 7454, 8, 992, 14, 1685, 304, 272, 408, 272, 812, 7454, 272, 408, 272, 536, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 3933, 12, 267, 3747, 29, 549, 272, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 3145, 8, 277, 12, 1808, 29, 403, 12, 1011, 958, 304, 267, 327, 7981, 314, 14068, 402, 314, 298, 324, 12941, 2, 574, 687, 1402, 267, 340, 291, 14, 344, 508, 378, 26, 288, 746, 2186, 480, 6044, 440, 4370, 531, 267, 1613, 1252, 1807, 8, 4941, 9, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 327, 3633, 314, 909, 2544, 3354, 267, 291, 14, 2861, 63, 3118, 342, 267, 1613, 8, 27111, 12, 291, 680, 2117, 3682, 958, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 9884, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 86, 500, 1384, 2, 267, 7794, 275, 661, 354, 9538, 421, 199, 533, 12705, 2448, 8, 992, 14, 1685, 304, 272, 408, 272, 12705, 5611, 272, 408, 272, 536, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 7736, 12, 267, 1720, 63, 505, 628, 985, 402, 314, 12705, 5611, 2, 272, 776, 339, 20868, 275, 1709, 14, 3190, 8, 267, 812, 7454, 12, 267, 4596, 29, 797, 12, 267, 2973, 29, 797, 12, 267, 849, 29, 16, 12, 267, 3376, 63, 354, 628, 27111, 401, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 3472, 272, 776, 339, 347, 664, 63, 452, 63, 13336, 8, 277, 304, 267, 408, 5808, 282, 1827, 663, 626, 3509, 1006, 32411, 624, 267, 754, 275, 488, 267, 340, 291, 14, 2051, 26, 288, 754, 275, 12705, 14, 1462, 14, 1541, 8, 2558, 63, 923, 63, 344, 29, 277, 14, 2051, 9, 288, 340, 754, 14, 835, 342, 508, 378, 26, 355, 754, 275, 488, 398, 372, 754, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 3633, 314, 909, 2544, 3354, 267, 291, 14, 2861, 63, 3118, 342, 267, 1613, 8, 5884, 2448, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 304, 267, 327, 1104, 626, 314, 12705, 5611, 2812, 2575, 2187, 315, 314, 3050, 367, 314, 1627, 20868, 267, 340, 12705, 2448, 14, 1462, 14, 1541, 8, 9884, 29, 277, 14, 9884, 12, 536, 29, 277, 14, 354, 680, 2444, 837, 288, 746, 8505, 2561, 355, 298, 354, 582, 8505, 480, 923, 536, 2575, 3247, 367, 642, 20868, 531, 288, 3828, 398, 327, 4911, 626, 1006, 4568, 32411, 1172, 314, 2011, 812, 7454, 465, 314, 3336, 769, 267, 4568, 63, 13336, 275, 291, 14, 362, 63, 452, 63, 13336, 342, 267, 492, 2050, 267, 2050, 14, 1757, 480, 14889, 972, 32411, 370, 450, 83, 26, 450, 83, 446, 450, 83, 2, 2818, 288, 291, 14, 354, 12, 288, 822, 8, 22288, 63, 13336, 9, 340, 4568, 63, 13336, 365, 440, 488, 587, 298, 16, 334, 403, 4186, 288, 4568, 63, 13336, 14, 1459, 63, 513, 480, 2558, 63, 344, 401, 6829, 29, 549, 9, 340, 4568, 63, 13336, 365, 440, 488, 587, 7369, 8480, 267, 5082, 398, 327, 340, 949, 7585, 787, 4568, 370, 314, 1572, 12, 949, 1104, 365, 1415, 267, 340, 4568, 63, 13336, 26, 288, 7585, 63, 1045, 63, 14020, 63, 9884, 275, 359, 797, 367, 3336, 315, 291, 14, 362, 63, 452, 63, 13336, 342, 6343, 340, 3336, 14, 9884, 1137, 291, 14, 9884, 61, 288, 340, 822, 8, 13336, 63, 1045, 63, 14020, 63, 9884, 9, 1137, 378, 26, 355, 746, 8505, 2561, 490, 298, 9884, 582, 8505, 480, 11250, 663, 892, 20868, 465, 1846, 465, 2337, 787, 7585, 4568, 370, 652, 531, 355, 3828, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 5884, 5611, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 5884, 25031, 2, 267, 3747, 63, 6314, 275, 1689, 354, 401, 298, 9884, 531, 421, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 7729, 63, 3359, 63, 10640, 63, 3027, 275, 298, 3005, 402, 12502, 2, 272, 7729, 63, 3359, 63, 51, 28553, 63, 3027, 275, 298, 3005, 402, 428, 1895, 2, 272, 7729, 63, 3359, 63, 11365, 63, 10486, 63 ]
[ 8337, 199, 646, 295, 199, 504, 5055, 492, 14427, 199, 504, 2197, 492, 6871, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 1018, 14, 11346, 492, 10195, 1110, 8640, 12, 8228, 1110, 8640, 199, 504, 1639, 14, 1018, 14, 1637, 492, 2581, 199, 504, 1639, 14, 1018, 14, 1637, 14, 1208, 492, 1852, 63, 1160, 63, 7677, 63, 498, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 697, 14, 992, 14, 10458, 492, 876, 63, 1807, 12, 2963, 63, 2117, 12, 876, 63, 2117, 12, 2963, 63, 1807, 199, 504, 1639, 14, 6052, 492, 13035, 199, 504, 1639, 14, 1208, 14, 7145, 492, 2197, 12, 3063, 199, 504, 1145, 14, 888, 14, 1751, 492, 4693, 5268, 199, 504, 1145, 14, 2558, 697, 14, 11346, 492, 4107, 63, 2558, 63, 513, 63, 875, 199, 504, 1145, 14, 2558, 697, 492, 3778, 199, 199, 7013, 24861, 63, 16236, 275, 334, 272, 661, 37, 1230, 297, 283, 37, 9129, 659, 272, 661, 1668, 36, 297, 283, 1668, 13, 36, 25317, 659, 199, 9, 421, 199, 533, 15057, 1173, 8, 992, 14, 1685, 304, 272, 408, 21145, 1584, 367, 6527, 624, 272, 570, 275, 1709, 14, 23252, 8, 5064, 63, 475, 29, 1751, 14, 3998, 63, 16436, 9, 421, 199, 32, 10244, 8, 657, 63, 1807, 12, 8904, 29, 6694, 1173, 9, 199, 318, 3145, 63, 2423, 63, 493, 8, 8114, 12, 1256, 12, 1011, 958, 304, 272, 408, 2168, 314, 570, 687, 314, 4543, 340, 314, 15057, 3814, 909, 365, 5463, 624, 272, 1256, 14, 493, 14, 1807, 8, 797, 9, 421, 199, 533, 812, 7454, 8, 992, 14, 1685, 304, 272, 408, 272, 812, 7454, 272, 408, 272, 536, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 3933, 12, 267, 3747, 29, 549, 272, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 3145, 8, 277, 12, 1808, 29, 403, 12, 1011, 958, 304, 267, 327, 7981, 314, 14068, 402, 314, 298, 324, 12941, 2, 574, 687, 1402, 267, 340, 291, 14, 344, 508, 378, 26, 288, 746, 2186, 480, 6044, 440, 4370, 531, 267, 1613, 1252, 1807, 8, 4941, 9, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 327, 3633, 314, 909, 2544, 3354, 267, 291, 14, 2861, 63, 3118, 342, 267, 1613, 8, 27111, 12, 291, 680, 2117, 3682, 958, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 9884, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 86, 500, 1384, 2, 267, 7794, 275, 661, 354, 9538, 421, 199, 533, 12705, 2448, 8, 992, 14, 1685, 304, 272, 408, 272, 12705, 5611, 272, 408, 272, 536, 275, 1709, 14, 2183, 8, 267, 1390, 63, 1267, 29, 7736, 12, 267, 1720, 63, 505, 628, 985, 402, 314, 12705, 5611, 2, 272, 776, 339, 20868, 275, 1709, 14, 3190, 8, 267, 812, 7454, 12, 267, 4596, 29, 797, 12, 267, 2973, 29, 797, 12, 267, 849, 29, 16, 12, 267, 3376, 63, 354, 628, 27111, 401, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 3472, 272, 776, 339, 347, 664, 63, 452, 63, 13336, 8, 277, 304, 267, 408, 5808, 282, 1827, 663, 626, 3509, 1006, 32411, 624, 267, 754, 275, 488, 267, 340, 291, 14, 2051, 26, 288, 754, 275, 12705, 14, 1462, 14, 1541, 8, 2558, 63, 923, 63, 344, 29, 277, 14, 2051, 9, 288, 340, 754, 14, 835, 342, 508, 378, 26, 355, 754, 275, 488, 398, 372, 754, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 3633, 314, 909, 2544, 3354, 267, 291, 14, 2861, 63, 3118, 342, 267, 1613, 8, 5884, 2448, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 304, 267, 327, 1104, 626, 314, 12705, 5611, 2812, 2575, 2187, 315, 314, 3050, 367, 314, 1627, 20868, 267, 340, 12705, 2448, 14, 1462, 14, 1541, 8, 9884, 29, 277, 14, 9884, 12, 536, 29, 277, 14, 354, 680, 2444, 837, 288, 746, 8505, 2561, 355, 298, 354, 582, 8505, 480, 923, 536, 2575, 3247, 367, 642, 20868, 531, 288, 3828, 398, 327, 4911, 626, 1006, 4568, 32411, 1172, 314, 2011, 812, 7454, 465, 314, 3336, 769, 267, 4568, 63, 13336, 275, 291, 14, 362, 63, 452, 63, 13336, 342, 267, 492, 2050, 267, 2050, 14, 1757, 480, 14889, 972, 32411, 370, 450, 83, 26, 450, 83, 446, 450, 83, 2, 2818, 288, 291, 14, 354, 12, 288, 822, 8, 22288, 63, 13336, 9, 340, 4568, 63, 13336, 365, 440, 488, 587, 298, 16, 334, 403, 4186, 288, 4568, 63, 13336, 14, 1459, 63, 513, 480, 2558, 63, 344, 401, 6829, 29, 549, 9, 340, 4568, 63, 13336, 365, 440, 488, 587, 7369, 8480, 267, 5082, 398, 327, 340, 949, 7585, 787, 4568, 370, 314, 1572, 12, 949, 1104, 365, 1415, 267, 340, 4568, 63, 13336, 26, 288, 7585, 63, 1045, 63, 14020, 63, 9884, 275, 359, 797, 367, 3336, 315, 291, 14, 362, 63, 452, 63, 13336, 342, 6343, 340, 3336, 14, 9884, 1137, 291, 14, 9884, 61, 288, 340, 822, 8, 13336, 63, 1045, 63, 14020, 63, 9884, 9, 1137, 378, 26, 355, 746, 8505, 2561, 490, 298, 9884, 582, 8505, 480, 11250, 663, 892, 20868, 465, 1846, 465, 2337, 787, 7585, 4568, 370, 652, 531, 355, 3828, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 3376, 63, 354, 275, 298, 5884, 5611, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 5884, 25031, 2, 267, 3747, 63, 6314, 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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 ]
pershoot/android_kernel_asus_tf701t
tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time 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 * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass 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(interval): while 1: clear_term() 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): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 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, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 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, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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 ]
[ 2656, 1240, 2746, 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, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 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, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 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, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hastexo/edx-platform
lms/djangoapps/grades/migrations/0013_persistentsubsectiongradeoverride.py
21
1201
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models from coursewarehistoryextended.fields import UnsignedBigIntOneToOneField class Migration(migrations.Migration): dependencies = [ ('grades', '0012_computegradessetting'), ] operations = [ migrations.CreateModel( name='PersistentSubsectionGradeOverride', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateTimeField(auto_now_add=True, db_index=True)), ('modified', models.DateTimeField(auto_now=True, db_index=True)), ('earned_all_override', models.FloatField(null=True, blank=True)), ('possible_all_override', models.FloatField(null=True, blank=True)), ('earned_graded_override', models.FloatField(null=True, blank=True)), ('possible_graded_override', models.FloatField(null=True, blank=True)), ('grade', UnsignedBigIntOneToOneField(related_name='override', to='grades.PersistentSubsectionGrade')), ], ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 199, 504, 20736, 5570, 10525, 14, 955, 492, 1910, 1737, 7279, 3241, 14298, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 18050, 297, 283, 22728, 63, 3357, 18050, 6031, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 31966, 31839, 5761, 271, 11954, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 5540, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 69, 31772, 63, 452, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 13893, 63, 452, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 69, 31772, 63, 13688, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 13893, 63, 13688, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 4523, 297, 1910, 1737, 7279, 3241, 14298, 8, 2407, 63, 354, 534, 4415, 297, 370, 534, 18050, 14, 31966, 31839, 5761, 271, 3855, 288, 2156, 267, 2318, 272, 1622, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 199, 504, 20736, 5570, 10525, 14, 955, 492, 1910, 1737, 7279, 3241, 14298, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 18050, 297, 283, 22728, 63, 3357, 18050, 6031, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 31966, 31839, 5761, 271, 11954, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 3966, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 5540, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 69, 31772, 63, 452, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 13893, 63, 452, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 69, 31772, 63, 13688, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 13893, 63, 13688, 63, 4415, 297, 1709, 14, 13019, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 4523, 297, 1910, 1737, 7279, 3241, 14298, 8, 2407, 63, 354, 534, 4415, 297, 370, 534, 18050, 14, 31966, 31839, 5761, 271, 3855, 288, 2156, 267, 2318, 272, 1622, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
VaibhavAgarwalVA/sympy
sympy/physics/unitsystems/prefixes.py
91
4190
# -*- coding: utf-8 -*- """ Module defining unit prefixe class and some constants. Constant dict for SI and binary prefixes are defined as PREFIXES and BIN_PREFIXES. """ from sympy import sympify class Prefix(object): """ This class represent prefixes, with their name, symbol and factor. Prefixes are used to create derived units from a given unit. They should always be encapsulated into units. The factor is constructed from a base (default is 10) to some power, and it gives the total multiple or fraction. For example the kilometer km is constructed from the meter (factor 1) and the kilo (10 to the power 3, i.e. 1000). The base can be changed to allow e.g. binary prefixes. A prefix multiplied by something will always return the product of this other object times the factor, except if the other object: - is a prefix and they can be combined into a new prefix; - defines multiplication with prefixes (which is the case for the Unit class). """ def __init__(self, name, abbrev, exponent, base=sympify(10)): self.name = name self.abbrev = abbrev self.factor = base**exponent def __str__(self): return self.name __repr__ = __str__ def __mul__(self, other): fact = self.factor * other.factor if fact == 1: return 1 elif isinstance(other, Prefix): # simplify prefix for p in PREFIXES: if PREFIXES[p].factor == fact: return PREFIXES[p] return fact return self.factor * other def __div__(self, other): fact = self.factor / other.factor if fact == 1: return 1 elif isinstance(other, Prefix): for p in PREFIXES: if PREFIXES[p].factor == fact: return PREFIXES[p] return fact return self.factor / other __truediv__ = __div__ def __rdiv__(self, other): if other == 1: for p in PREFIXES: if PREFIXES[p].factor == 1 / self.factor: return PREFIXES[p] return other / self.factor __rtruediv__ = __rdiv__ def prefix_unit(unit, prefixes): """ Return a list of all units formed by unit and the given prefixes. You can use the predefined PREFIXES or BIN_PREFIXES, but you can also pass as argument a subdict of them if you don't want all prefixed units. >>> from sympy.physics.unitsystems.prefixes import (PREFIXES, ... prefix_unit) >>> from sympy.physics.unitsystems.systems import mks >>> m = mks["m"] >>> pref = {"m": PREFIXES["m"], "c": PREFIXES["c"], "d": PREFIXES["d"]} >>> prefix_unit(m, pref) #doctest: +SKIP [cm, dm, mm] """ from sympy.physics.unitsystems.units import Unit prefixed_units = [] for prefix in prefixes: prefixed_units.append(Unit(unit, abbrev=unit.abbrev, prefix=prefixes[prefix])) return prefixed_units # http://physics.nist.gov/cuu/Units/prefixes.html PREFIXES = { 'Y': Prefix('yotta', 'Y', 24), 'Z': Prefix('zetta', 'Z', 21), 'E': Prefix('exa', 'E', 18), 'P': Prefix('peta', 'P', 15), 'T': Prefix('tera', 'T', 12), 'G': Prefix('giga', 'G', 9), 'M': Prefix('mega', 'M', 6), 'k': Prefix('kilo', 'k', 3), 'h': Prefix('hecto', 'h', 2), 'da': Prefix('deca', 'da', 1), 'd': Prefix('deci', 'd', -1), 'c': Prefix('centi', 'c', -2), 'm': Prefix('milli', 'm', -3), 'µ': Prefix('micro', 'µ', -6), 'n': Prefix('nano', 'n', -9), 'p': Prefix('pico', 'p', -12), 'f': Prefix('femto', 'f', -15), 'a': Prefix('atto', 'a', -18), 'z': Prefix('zepto', 'z', -21), 'y': Prefix('yocto', 'y', -24) } # http://physics.nist.gov/cuu/Units/binary.html BIN_PREFIXES = { 'Ki': Prefix('kibi', 'Y', 10, 2), 'Mi': Prefix('mebi', 'Y', 20, 2), 'Gi': Prefix('gibi', 'Y', 30, 2), 'Ti': Prefix('tebi', 'Y', 40, 2), 'Pi': Prefix('pebi', 'Y', 50, 2), 'Ei': Prefix('exbi', 'Y', 60, 2) }
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2377, 12669, 4137, 2403, 69, 1021, 436, 2005, 5262, 14, 199, 199, 9737, 1211, 367, 428, 41, 436, 3366, 13158, 787, 3247, 465, 27884, 654, 436, 199, 9431, 63, 6351, 654, 14, 199, 624, 199, 199, 504, 5840, 492, 25991, 421, 199, 533, 25110, 8, 785, 304, 272, 408, 272, 961, 1021, 2954, 13158, 12, 543, 3932, 536, 12, 5272, 436, 6535, 14, 339, 25110, 397, 787, 1202, 370, 1218, 7131, 6204, 687, 282, 1627, 4137, 14, 9322, 1077, 272, 3544, 506, 22667, 8097, 1901, 6204, 14, 339, 710, 6535, 365, 14701, 687, 282, 1300, 334, 885, 365, 1616, 9, 370, 2005, 7074, 12, 436, 272, 652, 10557, 314, 3141, 3663, 503, 12347, 14, 2104, 2893, 314, 1022, 25617, 16155, 272, 365, 14701, 687, 314, 21247, 334, 4778, 413, 9, 436, 314, 1022, 11737, 334, 709, 370, 314, 7074, 650, 12, 272, 284, 14, 69, 14, 5198, 680, 710, 1300, 883, 506, 2896, 370, 2040, 325, 14, 71, 14, 3366, 13158, 14, 339, 437, 2403, 29597, 701, 6020, 911, 3544, 372, 314, 3336, 402, 642, 272, 1163, 909, 5431, 314, 6535, 12, 871, 340, 314, 1163, 909, 26, 339, 446, 365, 282, 2403, 436, 2985, 883, 506, 12149, 1901, 282, 892, 2403, 27, 272, 446, 7890, 24638, 543, 13158, 334, 6777, 365, 314, 1930, 367, 314, 12008, 489, 1021, 680, 272, 408, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2236, 66, 4964, 12, 16588, 12, 1300, 29, 1786, 18456, 8, 709, 2298, 398, 291, 14, 354, 275, 536, 267, 291, 14, 31349, 275, 2236, 66, 4964, 398, 291, 14, 4778, 275, 1300, 538, 23475, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 636, 2722, 363, 275, 636, 495, 363, 339, 347, 636, 3703, 721, 277, 12, 1163, 304, 267, 10572, 275, 291, 14, 4778, 627, 1163, 14, 4778, 398, 340, 10572, 508, 413, 26, 288, 372, 413, 267, 916, 1228, 8, 1848, 12, 25110, 304, 288, 327, 15037, 2403, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 10572, 26, 490, 372, 27884, 654, 59, 80, 61, 288, 372, 10572, 398, 372, 291, 14, 4778, 627, 1163, 339, 347, 636, 3015, 721, 277, 12, 1163, 304, 267, 10572, 275, 291, 14, 4778, 1182, 1163, 14, 4778, 398, 340, 10572, 508, 413, 26, 288, 372, 413, 267, 916, 1228, 8, 1848, 12, 25110, 304, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 10572, 26, 490, 372, 27884, 654, 59, 80, 61, 288, 372, 10572, 398, 372, 291, 14, 4778, 1182, 1163, 339, 636, 22062, 363, 275, 636, 3015, 363, 339, 347, 636, 82, 3015, 721, 277, 12, 1163, 304, 267, 340, 1163, 508, 413, 26, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 413, 1182, 291, 14, 4778, 26, 490, 372, 27884, 654, 59, 80, 61, 267, 372, 1163, 1182, 291, 14, 4778, 339, 636, 82, 22062, 363, 275, 636, 82, 3015, 363, 421, 199, 318, 2403, 63, 3248, 8, 3248, 12, 13158, 304, 272, 408, 272, 1432, 282, 769, 402, 1006, 6204, 28917, 701, 4137, 436, 314, 1627, 13158, 14, 339, 2047, 883, 675, 314, 27684, 27884, 654, 503, 26348, 63, 6351, 654, 12, 1325, 1265, 883, 2597, 272, 986, 465, 1423, 282, 1007, 807, 402, 3062, 340, 1265, 2793, 1133, 2934, 1006, 18239, 6204, 14, 398, 1306, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 14124, 492, 334, 6351, 654, 12, 267, 2263, 2476, 463, 2403, 63, 3248, 9, 267, 1306, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 19135, 492, 333, 6080, 267, 1306, 333, 275, 333, 6080, 905, 77, 937, 267, 1306, 20491, 275, 2420, 77, 582, 27884, 654, 905, 77, 2255, 298, 67, 582, 27884, 654, 905, 67, 2255, 298, 68, 582, 27884, 654, 905, 68, 27635, 267, 1306, 2403, 63, 3248, 8, 77, 12, 20491, 9, 221, 327, 11390, 26, 435, 13525, 267, 359, 4400, 12, 17547, 12, 8562, 61, 272, 408, 339, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 5260, 492, 12008, 339, 18239, 63, 5260, 275, 942, 339, 367, 2403, 315, 13158, 26, 267, 18239, 63, 5260, 14, 740, 8, 5072, 8, 3248, 12, 2236, 66, 4964, 29, 3248, 14, 31349, 12, 3521, 2403, 29, 14124, 59, 1861, 2459, 339, 372, 18239, 63, 5260, 421, 199, 3, 1455, 921, 24724, 14, 78, 631, 14, 16294, 15, 15140, 85, 15, 15121, 15, 14124, 14, 1360, 199, 6351, 654, 275, 469, 272, 283, 57, 356, 25110, 360, 89, 357, 502, 297, 283, 57, 297, 5504, 395, 272, 283, 58, 356, 25110, 360, 90, 386, 502, 297, 283, 58, 297, 7829, 395, 272, 283, 37, 356, 25110, 360, 476, 65, 297, 283, 37, 297, 6155, 395, 272, 283, 48, 356, 25110, 360, 321, 502, 297, 283, 48, 297, 4114, 395, 272, 283, 52, 356, 25110, 360, 2967, 297, 283, 52, 297, 3144, 395, 272, 283, 39, 356, 25110, 360, 71, 29055, 297, 283, 39, 297, 1749, 395, 272, 283, 45, 356, 25110, 360, 29073, 297, 283, 45, 297, 1227, 395, 272, 283, 75, 356, 25110, 360, 8810, 320, 297, 283, 75, 297, 650, 395, 272, 283, 72, 356, 25110, 360, 426, 319, 79, 297, 283, 72, 297, 499, 395, 272, 283, 983, 356, 25110, 360, 271, 696, 297, 283, 983, 297, 413, 395, 272, 283, 68, 356, 25110, 360, 22612, 297, 283, 68, 297, 446, 17, 395, 272, 283, 67, 356, 25110, 360, 2497, 280, 297, 283, 67, 297, 446, 18, 395, 272, 283, 77, 356, 25110, 360, 19579, 297, 283, 77, 297, 446, 19, 395, 272, 283, 127, 114, 356, 25110, 360, 6453, 297, 283, 127, 114, 297, 446, 22, 395, 272, 283, 78, 356, 25110, 360, 4304, 79, 297, 283, 78, 297, 446, 25, 395, 272, 283, 80, 356, 25110, 360, 1038, 331, 297, 283, 80, 297, 446, 713, 395, 272, 283, 70, 356, 25110, 360, 771, 77, 475, 297, 283, 70, 297, 446, 1046, 395, 272, 283, 65, 356, 25110, 360, 292, 475, 297, 283, 65, 297, 446, 1085, 395, 272, 283, 90, 356 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 2377, 12669, 4137, 2403, 69, 1021, 436, 2005, 5262, 14, 199, 199, 9737, 1211, 367, 428, 41, 436, 3366, 13158, 787, 3247, 465, 27884, 654, 436, 199, 9431, 63, 6351, 654, 14, 199, 624, 199, 199, 504, 5840, 492, 25991, 421, 199, 533, 25110, 8, 785, 304, 272, 408, 272, 961, 1021, 2954, 13158, 12, 543, 3932, 536, 12, 5272, 436, 6535, 14, 339, 25110, 397, 787, 1202, 370, 1218, 7131, 6204, 687, 282, 1627, 4137, 14, 9322, 1077, 272, 3544, 506, 22667, 8097, 1901, 6204, 14, 339, 710, 6535, 365, 14701, 687, 282, 1300, 334, 885, 365, 1616, 9, 370, 2005, 7074, 12, 436, 272, 652, 10557, 314, 3141, 3663, 503, 12347, 14, 2104, 2893, 314, 1022, 25617, 16155, 272, 365, 14701, 687, 314, 21247, 334, 4778, 413, 9, 436, 314, 1022, 11737, 334, 709, 370, 314, 7074, 650, 12, 272, 284, 14, 69, 14, 5198, 680, 710, 1300, 883, 506, 2896, 370, 2040, 325, 14, 71, 14, 3366, 13158, 14, 339, 437, 2403, 29597, 701, 6020, 911, 3544, 372, 314, 3336, 402, 642, 272, 1163, 909, 5431, 314, 6535, 12, 871, 340, 314, 1163, 909, 26, 339, 446, 365, 282, 2403, 436, 2985, 883, 506, 12149, 1901, 282, 892, 2403, 27, 272, 446, 7890, 24638, 543, 13158, 334, 6777, 365, 314, 1930, 367, 314, 12008, 489, 1021, 680, 272, 408, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2236, 66, 4964, 12, 16588, 12, 1300, 29, 1786, 18456, 8, 709, 2298, 398, 291, 14, 354, 275, 536, 267, 291, 14, 31349, 275, 2236, 66, 4964, 398, 291, 14, 4778, 275, 1300, 538, 23475, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 636, 2722, 363, 275, 636, 495, 363, 339, 347, 636, 3703, 721, 277, 12, 1163, 304, 267, 10572, 275, 291, 14, 4778, 627, 1163, 14, 4778, 398, 340, 10572, 508, 413, 26, 288, 372, 413, 267, 916, 1228, 8, 1848, 12, 25110, 304, 288, 327, 15037, 2403, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 10572, 26, 490, 372, 27884, 654, 59, 80, 61, 288, 372, 10572, 398, 372, 291, 14, 4778, 627, 1163, 339, 347, 636, 3015, 721, 277, 12, 1163, 304, 267, 10572, 275, 291, 14, 4778, 1182, 1163, 14, 4778, 398, 340, 10572, 508, 413, 26, 288, 372, 413, 267, 916, 1228, 8, 1848, 12, 25110, 304, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 10572, 26, 490, 372, 27884, 654, 59, 80, 61, 288, 372, 10572, 398, 372, 291, 14, 4778, 1182, 1163, 339, 636, 22062, 363, 275, 636, 3015, 363, 339, 347, 636, 82, 3015, 721, 277, 12, 1163, 304, 267, 340, 1163, 508, 413, 26, 288, 367, 299, 315, 27884, 654, 26, 355, 340, 27884, 654, 59, 80, 1055, 4778, 508, 413, 1182, 291, 14, 4778, 26, 490, 372, 27884, 654, 59, 80, 61, 267, 372, 1163, 1182, 291, 14, 4778, 339, 636, 82, 22062, 363, 275, 636, 82, 3015, 363, 421, 199, 318, 2403, 63, 3248, 8, 3248, 12, 13158, 304, 272, 408, 272, 1432, 282, 769, 402, 1006, 6204, 28917, 701, 4137, 436, 314, 1627, 13158, 14, 339, 2047, 883, 675, 314, 27684, 27884, 654, 503, 26348, 63, 6351, 654, 12, 1325, 1265, 883, 2597, 272, 986, 465, 1423, 282, 1007, 807, 402, 3062, 340, 1265, 2793, 1133, 2934, 1006, 18239, 6204, 14, 398, 1306, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 14124, 492, 334, 6351, 654, 12, 267, 2263, 2476, 463, 2403, 63, 3248, 9, 267, 1306, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 19135, 492, 333, 6080, 267, 1306, 333, 275, 333, 6080, 905, 77, 937, 267, 1306, 20491, 275, 2420, 77, 582, 27884, 654, 905, 77, 2255, 298, 67, 582, 27884, 654, 905, 67, 2255, 298, 68, 582, 27884, 654, 905, 68, 27635, 267, 1306, 2403, 63, 3248, 8, 77, 12, 20491, 9, 221, 327, 11390, 26, 435, 13525, 267, 359, 4400, 12, 17547, 12, 8562, 61, 272, 408, 339, 687, 5840, 14, 24724, 14, 3248, 19135, 14, 5260, 492, 12008, 339, 18239, 63, 5260, 275, 942, 339, 367, 2403, 315, 13158, 26, 267, 18239, 63, 5260, 14, 740, 8, 5072, 8, 3248, 12, 2236, 66, 4964, 29, 3248, 14, 31349, 12, 3521, 2403, 29, 14124, 59, 1861, 2459, 339, 372, 18239, 63, 5260, 421, 199, 3, 1455, 921, 24724, 14, 78, 631, 14, 16294, 15, 15140, 85, 15, 15121, 15, 14124, 14, 1360, 199, 6351, 654, 275, 469, 272, 283, 57, 356, 25110, 360, 89, 357, 502, 297, 283, 57, 297, 5504, 395, 272, 283, 58, 356, 25110, 360, 90, 386, 502, 297, 283, 58, 297, 7829, 395, 272, 283, 37, 356, 25110, 360, 476, 65, 297, 283, 37, 297, 6155, 395, 272, 283, 48, 356, 25110, 360, 321, 502, 297, 283, 48, 297, 4114, 395, 272, 283, 52, 356, 25110, 360, 2967, 297, 283, 52, 297, 3144, 395, 272, 283, 39, 356, 25110, 360, 71, 29055, 297, 283, 39, 297, 1749, 395, 272, 283, 45, 356, 25110, 360, 29073, 297, 283, 45, 297, 1227, 395, 272, 283, 75, 356, 25110, 360, 8810, 320, 297, 283, 75, 297, 650, 395, 272, 283, 72, 356, 25110, 360, 426, 319, 79, 297, 283, 72, 297, 499, 395, 272, 283, 983, 356, 25110, 360, 271, 696, 297, 283, 983, 297, 413, 395, 272, 283, 68, 356, 25110, 360, 22612, 297, 283, 68, 297, 446, 17, 395, 272, 283, 67, 356, 25110, 360, 2497, 280, 297, 283, 67, 297, 446, 18, 395, 272, 283, 77, 356, 25110, 360, 19579, 297, 283, 77, 297, 446, 19, 395, 272, 283, 127, 114, 356, 25110, 360, 6453, 297, 283, 127, 114, 297, 446, 22, 395, 272, 283, 78, 356, 25110, 360, 4304, 79, 297, 283, 78, 297, 446, 25, 395, 272, 283, 80, 356, 25110, 360, 1038, 331, 297, 283, 80, 297, 446, 713, 395, 272, 283, 70, 356, 25110, 360, 771, 77, 475, 297, 283, 70, 297, 446, 1046, 395, 272, 283, 65, 356, 25110, 360, 292, 475, 297, 283, 65, 297, 446, 1085, 395, 272, 283, 90, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
caesar2164/edx-platform
openedx/core/djangoapps/theming/storage.py
23
13341
""" Comprehensive Theming support for Django's collectstatic functionality. See https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/ """ import posixpath import os.path from django.conf import settings from django.utils._os import safe_join from django.contrib.staticfiles.storage import StaticFilesStorage, CachedFilesMixin from django.contrib.staticfiles.finders import find from django.utils.six.moves.urllib.parse import ( # pylint: disable=no-name-in-module, import-error unquote, urlsplit, ) from pipeline.storage import PipelineMixin from openedx.core.djangoapps.theming.helpers import ( get_theme_base_dir, get_project_root_name, get_current_theme, get_themes, is_comprehensive_theming_enabled, ) class ThemeStorage(StaticFilesStorage): """ Comprehensive theme aware Static files storage. """ # prefix for file path, this prefix is added at the beginning of file path before saving static files during # collectstatic command. # e.g. having "edx.org" as prefix will cause files to be saved as "edx.org/images/logo.png" # instead of "images/logo.png" prefix = None def __init__(self, location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None, prefix=None): self.prefix = prefix super(ThemeStorage, self).__init__( location=location, base_url=base_url, file_permissions_mode=file_permissions_mode, directory_permissions_mode=directory_permissions_mode, ) def url(self, name): """ Returns url of the asset, themed url will be returned if the asset is themed otherwise default asset url will be returned. Args: name: name of the asset, e.g. 'images/logo.png' Returns: url of the asset, e.g. '/static/red-theme/images/logo.png' if current theme is red-theme and logo is provided by red-theme otherwise '/static/images/logo.png' """ prefix = '' theme = get_current_theme() # get theme prefix from site address if if asset is accessed via a url if theme: prefix = theme.theme_dir_name # get theme prefix from storage class, if asset is accessed during collectstatic run elif self.prefix: prefix = self.prefix # join theme prefix with asset name if theme is applied and themed asset exists if prefix and self.themed(name, prefix): name = os.path.join(prefix, name) return super(ThemeStorage, self).url(name) def themed(self, name, theme): """ Returns True if given asset override is provided by the given theme otherwise returns False. Args: name: asset name e.g. 'images/logo.png' theme: theme name e.g. 'red-theme', 'edx.org' Returns: True if given asset override is provided by the given theme otherwise returns False """ if not is_comprehensive_theming_enabled(): return False # in debug mode check static asset from within the project directory if settings.DEBUG: themes_location = get_theme_base_dir(theme, suppress_error=True) # Nothing can be themed if we don't have a theme location or required params. if not all((themes_location, theme, name)): return False themed_path = "/".join([ themes_location, theme, get_project_root_name(), "static/" ]) name = name[1:] if name.startswith("/") else name path = safe_join(themed_path, name) return os.path.exists(path) # in live mode check static asset in the static files dir defined by "STATIC_ROOT" setting else: return self.exists(os.path.join(theme, name)) class ThemeCachedFilesMixin(CachedFilesMixin): """ Comprehensive theme aware CachedFilesMixin. Main purpose of subclassing CachedFilesMixin is to override the following methods. 1 - url 2 - url_converter url: This method takes asset name as argument and is responsible for adding hash to the name to support caching. This method is called during both collectstatic command and live server run. When called during collectstatic command that name argument will be asset name inside STATIC_ROOT, for non themed assets it will be the usual path (e.g. 'images/logo.png') but for themed asset it will also contain themes dir prefix (e.g. 'red-theme/images/logo.png'). So, here we check whether the themed asset exists or not, if it exists we pass the same name up in the MRO chain for further processing and if it does not exists we strip theme name and pass the new asset name to the MRO chain for further processing. When called during server run, we get the theme dir for the current site using `get_current_theme` and make sure to prefix theme dir to the asset name. This is done to ensure the usage of correct hash in file name. e.g. if our red-theme overrides 'images/logo.png' and we do not prefix theme dir to the asset name, the hash for '{platform-dir}/lms/static/images/logo.png' would be used instead of '{themes_base_dir}/red-theme/images/logo.png' url_converter: This function returns another function that is responsible for hashing urls that appear inside assets (e.g. url("images/logo.png") inside css). The method defined in the superclass adds a hash to file and returns relative url of the file. e.g. for url("../images/logo.png") it would return url("../images/logo.790c9a5340cb.png"). However we would want it to return absolute url (e.g. url("/static/images/logo.790c9a5340cb.png")) so that it works properly with themes. The overridden method here simply comments out the two lines that convert absolute url to relative url, hence absolute urls are used instead of relative urls. """ def url(self, name, force=False): """ Returns themed url for the given asset. """ theme = get_current_theme() if theme and theme.theme_dir_name not in name: # during server run, append theme name to the asset name if it is not already there # this is ensure that correct hash is created and default asset is not always # used to create hash of themed assets. name = os.path.join(theme.theme_dir_name, name) parsed_name = urlsplit(unquote(name)) clean_name = parsed_name.path.strip() asset_name = name if not self.exists(clean_name): # if themed asset does not exists then use default asset theme = name.split("/", 1)[0] # verify that themed asset was accessed if theme in [theme.theme_dir_name for theme in get_themes()]: asset_name = "/".join(name.split("/")[1:]) return super(ThemeCachedFilesMixin, self).url(asset_name, force) def url_converter(self, name, template=None): """ This is an override of url_converter from CachedFilesMixin. It just comments out two lines at the end of the method. The purpose of this override is to make converter method return absolute urls instead of relative urls. This behavior is necessary for theme overrides, as we get 404 on assets with relative urls on a themed site. """ if template is None: template = self.default_template def converter(matchobj): """ Converts the matched URL depending on the parent level (`..`) and returns the normalized and hashed URL using the url method of the storage. """ matched, url = matchobj.groups() # Completely ignore http(s) prefixed URLs, # fragments and data-uri URLs if url.startswith(('#', 'http:', 'https:', 'data:', '//')): return matched name_parts = name.split(os.sep) # Using posix normpath here to remove duplicates url = posixpath.normpath(url) url_parts = url.split('/') parent_level, sub_level = url.count('..'), url.count('/') if url.startswith('/'): sub_level -= 1 url_parts = url_parts[1:] if parent_level or not url.startswith('/'): start, end = parent_level + 1, parent_level else: if sub_level: if sub_level == 1: parent_level -= 1 start, end = parent_level, 1 else: start, end = 1, sub_level - 1 joined_result = '/'.join(name_parts[:-start] + url_parts[end:]) hashed_url = self.url(unquote(joined_result), force=True) # NOTE: # following two lines are commented out so that absolute urls are used instead of relative urls # to make themed assets work correctly. # # The lines are commented and not removed to make future django upgrade easier and # show exactly what is changed in this method override # # file_name = hashed_url.split('/')[-1:] # relative_url = '/'.join(url.split('/')[:-1] + file_name) # Return the hashed version to the file return template % unquote(hashed_url) return converter class ThemePipelineMixin(PipelineMixin): """ Mixin to make sure themed assets are also packaged and used along with non themed assets. if a source asset for a particular package is not present then the default asset is used. e.g. in the following package and for 'red-theme' 'style-vendor': { 'source_filenames': [ 'js/vendor/afontgarde/afontgarde.css', 'css/vendor/font-awesome.css', 'css/vendor/jquery.qtip.min.css', 'css/vendor/responsive-carousel/responsive-carousel.css', 'css/vendor/responsive-carousel/responsive-carousel.slide.css', ], 'output_filename': 'css/lms-style-vendor.css' } 'red-theme/css/vendor/responsive-carousel/responsive-carousel.css' will be used of it exists otherwise 'css/vendor/responsive-carousel/responsive-carousel.css' will be used to create 'red-theme/css/lms-style-vendor.css' """ packing = True def post_process(self, paths, dry_run=False, **options): """ This post_process hook is used to package all themed assets. """ if dry_run: return themes = get_themes() for theme in themes: css_packages = self.get_themed_packages(theme.theme_dir_name, settings.PIPELINE_CSS) js_packages = self.get_themed_packages(theme.theme_dir_name, settings.PIPELINE_JS) from pipeline.packager import Packager packager = Packager(storage=self, css_packages=css_packages, js_packages=js_packages) for package_name in packager.packages['css']: package = packager.package_for('css', package_name) output_file = package.output_filename if self.packing: packager.pack_stylesheets(package) paths[output_file] = (self, output_file) yield output_file, output_file, True for package_name in packager.packages['js']: package = packager.package_for('js', package_name) output_file = package.output_filename if self.packing: packager.pack_javascripts(package) paths[output_file] = (self, output_file) yield output_file, output_file, True super_class = super(ThemePipelineMixin, self) if hasattr(super_class, 'post_process'): for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options): yield name, hashed_name, processed @staticmethod def get_themed_packages(prefix, packages): """ Update paths with the themed assets, Args: prefix: theme prefix for which to update asset paths e.g. 'red-theme', 'edx.org' etc. packages: packages to update Returns: list of updated paths and a boolean indicating whether any path was path or not """ themed_packages = {} for name in packages: # collect source file names for the package source_files = [] for path in packages[name].get('source_filenames', []): # if themed asset exists use that, otherwise use default asset. if find(os.path.join(prefix, path)): source_files.append(os.path.join(prefix, path)) else: source_files.append(path) themed_packages[name] = { 'output_filename': os.path.join(prefix, packages[name].get('output_filename', '')), 'source_filenames': source_files, } return themed_packages
agpl-3.0
[ 624, 199, 2404, 22868, 3398, 710, 14566, 2291, 367, 5634, 1159, 8775, 1986, 9330, 14, 199, 9295, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 2828, 15, 18373, 15, 199, 624, 199, 646, 15454, 199, 646, 747, 14, 515, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 199, 504, 1639, 14, 2828, 14, 18373, 14, 3494, 492, 13599, 5535, 6408, 12, 445, 4583, 5535, 4256, 199, 504, 1639, 14, 2828, 14, 18373, 14, 26677, 492, 2342, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 221, 327, 4287, 26, 3507, 29, 889, 13, 354, 13, 262, 13, 578, 12, 492, 13, 705, 272, 14342, 12, 29596, 12, 199, 9, 199, 199, 504, 7679, 14, 3494, 492, 19090, 4256, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1589, 14566, 14, 7546, 492, 334, 272, 664, 63, 7915, 63, 1095, 63, 694, 12, 272, 664, 63, 1715, 63, 1231, 63, 354, 12, 272, 664, 63, 1818, 63, 7915, 12, 272, 664, 63, 23900, 12, 272, 365, 63, 863, 22868, 3398, 63, 1589, 14566, 63, 3827, 12, 199, 9, 421, 199, 533, 23978, 6408, 8, 9278, 5535, 6408, 304, 272, 408, 272, 3599, 22868, 3398, 8879, 20381, 13599, 1584, 4887, 14, 272, 408, 272, 327, 2403, 367, 570, 931, 12, 642, 2403, 365, 3483, 737, 314, 9608, 402, 570, 931, 2544, 13369, 2955, 1584, 5309, 272, 327, 8775, 1986, 1414, 14, 272, 327, 325, 14, 71, 14, 9445, 298, 8268, 14, 1308, 2, 465, 2403, 911, 7675, 1584, 370, 506, 6290, 465, 298, 8268, 14, 1308, 15, 4782, 15, 9733, 14, 4524, 2, 272, 327, 3140, 402, 298, 4782, 15, 9733, 14, 4524, 2, 272, 2403, 275, 488, 339, 347, 636, 826, 721, 277, 12, 2909, 29, 403, 12, 1300, 63, 633, 29, 403, 12, 570, 63, 6060, 63, 632, 29, 403, 12, 326, 2082, 63, 6060, 63, 632, 29, 403, 12, 2403, 29, 403, 304, 398, 291, 14, 1861, 275, 2403, 267, 1613, 8, 16849, 6408, 12, 291, 2843, 826, 721, 288, 2909, 29, 1985, 12, 288, 1300, 63, 633, 29, 1095, 63, 633, 12, 288, 570, 63, 6060, 63, 632, 29, 493, 63, 6060, 63, 632, 12, 288, 2082, 63, 6060, 63, 632, 29, 3619, 63, 6060, 63, 632, 12, 267, 776, 339, 347, 1166, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 1166, 402, 314, 8977, 12, 314, 3594, 1166, 911, 506, 2138, 340, 314, 8977, 365, 314, 3594, 4257, 849, 267, 8977, 1166, 911, 506, 2138, 14, 398, 3033, 26, 288, 536, 26, 536, 402, 314, 8977, 12, 325, 14, 71, 14, 283, 4782, 15, 9733, 14, 4524, 7, 398, 1803, 26, 288, 1166, 402, 314, 8977, 12, 325, 14, 71, 14, 1994, 1986, 15, 581, 13, 7915, 15, 4782, 15, 9733, 14, 4524, 7, 340, 1453, 8879, 365, 8992, 13, 7915, 436, 23623, 288, 365, 2741, 701, 8992, 13, 7915, 4257, 1994, 1986, 15, 4782, 15, 9733, 14, 4524, 7, 267, 408, 267, 2403, 275, 2125, 267, 8879, 275, 664, 63, 1818, 63, 7915, 342, 398, 327, 664, 8879, 2403, 687, 4770, 2287, 340, 340, 8977, 365, 13810, 4799, 282, 1166, 267, 340, 8879, 26, 288, 2403, 275, 8879, 14, 7915, 63, 694, 63, 354, 398, 327, 664, 8879, 2403, 687, 4887, 1021, 12, 340, 8977, 365, 13810, 5309, 8775, 1986, 1255, 267, 916, 291, 14, 1861, 26, 288, 2403, 275, 291, 14, 1861, 398, 327, 4263, 8879, 2403, 543, 8977, 536, 340, 8879, 365, 6781, 436, 314, 3594, 8977, 3495, 267, 340, 2403, 436, 291, 14, 1589, 3594, 8, 354, 12, 2403, 304, 288, 536, 275, 747, 14, 515, 14, 904, 8, 1861, 12, 536, 9, 398, 372, 1613, 8, 16849, 6408, 12, 291, 680, 633, 8, 354, 9, 339, 347, 314, 3594, 8, 277, 12, 536, 12, 8879, 304, 267, 408, 267, 1803, 715, 340, 1627, 8977, 4278, 365, 2741, 701, 314, 1627, 8879, 4257, 2529, 756, 14, 267, 3033, 26, 288, 536, 26, 8977, 536, 325, 14, 71, 14, 283, 4782, 15, 9733, 14, 4524, 7, 288, 8879, 26, 8879, 536, 325, 14, 71, 14, 283, 581, 13, 7915, 297, 283, 8268, 14, 1308, 7, 398, 1803, 26, 288, 715, 340, 1627, 8977, 4278, 365, 2741, 701, 314, 1627, 8879, 4257, 2529, 756, 267, 408, 267, 340, 440, 365, 63, 863, 22868, 3398, 63, 1589, 14566, 63, 3827, 837, 288, 372, 756, 398, 327, 315, 3105, 818, 1104, 2955, 8977, 687, 4453, 314, 2199, 2082, 267, 340, 2202, 14, 5287, 26, 288, 17915, 63, 1985, 275, 664, 63, 7915, 63, 1095, 63, 694, 8, 7915, 12, 15678, 63, 705, 29, 549, 9, 288, 327, 20550, 883, 506, 314, 3594, 340, 781, 2793, 1133, 1172, 282, 8879, 2909, 503, 1415, 1862, 14, 288, 340, 440, 1006, 1332, 23900, 63, 1985, 12, 8879, 12, 536, 2298, 355, 372, 756, 953, 314, 3594, 63, 515, 275, 3286, 1674, 904, 779, 355, 17915, 63, 1985, 12, 355, 8879, 12, 355, 664, 63, 1715, 63, 1231, 63, 354, 1062, 355, 298, 1986, 6687, 288, 4794, 288, 536, 275, 536, 59, 17, 2938, 340, 536, 14, 2460, 19031, 587, 536, 288, 931, 275, 5048, 63, 904, 8, 1589, 3594, 63, 515, 12, 536, 9, 288, 372, 747, 14, 515, 14, 2444, 8, 515, 9, 267, 327, 315, 12166, 818, 1104, 2955, 8977, 315, 314, 2955, 1584, 2935, 3247, 701, 298, 10449, 63, 5441, 2, 4260, 267, 587, 26, 288, 372, 291, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 7915, 12, 536, 430, 421, 199, 533, 23978, 16138, 5535, 4256, 8, 16138, 5535, 4256, 304, 272, 408, 272, 3599, 22868, 3398, 8879, 20381, 445, 4583, 5535, 4256, 14, 272, 11298, 12016, 402, 24572, 445, 4583, 5535, 4256, 365, 370, 4278, 314, 2569, 3102, 14, 272, 413, 446, 1166, 272, 499, 446, 1166, 63, 11256, 339, 1166, 26, 267, 961, 1083, 6181, 8977, 536, 465, 1423, 436, 365, 17845, 367, 7791, 2631, 370, 314, 536, 370, 2291, 13627, 14, 267, 961, 1083, 365, 2797, 5309, 3865, 8775, 1986, 1414, 436, 12166, 1654, 1255, 14, 398, 3979, 2797, 5309, 8775 ]
[ 199, 2404, 22868, 3398, 710, 14566, 2291, 367, 5634, 1159, 8775, 1986, 9330, 14, 199, 9295, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 1121, 15, 2828, 15, 18373, 15, 199, 624, 199, 646, 15454, 199, 646, 747, 14, 515, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 199, 504, 1639, 14, 2828, 14, 18373, 14, 3494, 492, 13599, 5535, 6408, 12, 445, 4583, 5535, 4256, 199, 504, 1639, 14, 2828, 14, 18373, 14, 26677, 492, 2342, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 334, 221, 327, 4287, 26, 3507, 29, 889, 13, 354, 13, 262, 13, 578, 12, 492, 13, 705, 272, 14342, 12, 29596, 12, 199, 9, 199, 199, 504, 7679, 14, 3494, 492, 19090, 4256, 199, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1589, 14566, 14, 7546, 492, 334, 272, 664, 63, 7915, 63, 1095, 63, 694, 12, 272, 664, 63, 1715, 63, 1231, 63, 354, 12, 272, 664, 63, 1818, 63, 7915, 12, 272, 664, 63, 23900, 12, 272, 365, 63, 863, 22868, 3398, 63, 1589, 14566, 63, 3827, 12, 199, 9, 421, 199, 533, 23978, 6408, 8, 9278, 5535, 6408, 304, 272, 408, 272, 3599, 22868, 3398, 8879, 20381, 13599, 1584, 4887, 14, 272, 408, 272, 327, 2403, 367, 570, 931, 12, 642, 2403, 365, 3483, 737, 314, 9608, 402, 570, 931, 2544, 13369, 2955, 1584, 5309, 272, 327, 8775, 1986, 1414, 14, 272, 327, 325, 14, 71, 14, 9445, 298, 8268, 14, 1308, 2, 465, 2403, 911, 7675, 1584, 370, 506, 6290, 465, 298, 8268, 14, 1308, 15, 4782, 15, 9733, 14, 4524, 2, 272, 327, 3140, 402, 298, 4782, 15, 9733, 14, 4524, 2, 272, 2403, 275, 488, 339, 347, 636, 826, 721, 277, 12, 2909, 29, 403, 12, 1300, 63, 633, 29, 403, 12, 570, 63, 6060, 63, 632, 29, 403, 12, 326, 2082, 63, 6060, 63, 632, 29, 403, 12, 2403, 29, 403, 304, 398, 291, 14, 1861, 275, 2403, 267, 1613, 8, 16849, 6408, 12, 291, 2843, 826, 721, 288, 2909, 29, 1985, 12, 288, 1300, 63, 633, 29, 1095, 63, 633, 12, 288, 570, 63, 6060, 63, 632, 29, 493, 63, 6060, 63, 632, 12, 288, 2082, 63, 6060, 63, 632, 29, 3619, 63, 6060, 63, 632, 12, 267, 776, 339, 347, 1166, 8, 277, 12, 536, 304, 267, 408, 267, 1803, 1166, 402, 314, 8977, 12, 314, 3594, 1166, 911, 506, 2138, 340, 314, 8977, 365, 314, 3594, 4257, 849, 267, 8977, 1166, 911, 506, 2138, 14, 398, 3033, 26, 288, 536, 26, 536, 402, 314, 8977, 12, 325, 14, 71, 14, 283, 4782, 15, 9733, 14, 4524, 7, 398, 1803, 26, 288, 1166, 402, 314, 8977, 12, 325, 14, 71, 14, 1994, 1986, 15, 581, 13, 7915, 15, 4782, 15, 9733, 14, 4524, 7, 340, 1453, 8879, 365, 8992, 13, 7915, 436, 23623, 288, 365, 2741, 701, 8992, 13, 7915, 4257, 1994, 1986, 15, 4782, 15, 9733, 14, 4524, 7, 267, 408, 267, 2403, 275, 2125, 267, 8879, 275, 664, 63, 1818, 63, 7915, 342, 398, 327, 664, 8879, 2403, 687, 4770, 2287, 340, 340, 8977, 365, 13810, 4799, 282, 1166, 267, 340, 8879, 26, 288, 2403, 275, 8879, 14, 7915, 63, 694, 63, 354, 398, 327, 664, 8879, 2403, 687, 4887, 1021, 12, 340, 8977, 365, 13810, 5309, 8775, 1986, 1255, 267, 916, 291, 14, 1861, 26, 288, 2403, 275, 291, 14, 1861, 398, 327, 4263, 8879, 2403, 543, 8977, 536, 340, 8879, 365, 6781, 436, 314, 3594, 8977, 3495, 267, 340, 2403, 436, 291, 14, 1589, 3594, 8, 354, 12, 2403, 304, 288, 536, 275, 747, 14, 515, 14, 904, 8, 1861, 12, 536, 9, 398, 372, 1613, 8, 16849, 6408, 12, 291, 680, 633, 8, 354, 9, 339, 347, 314, 3594, 8, 277, 12, 536, 12, 8879, 304, 267, 408, 267, 1803, 715, 340, 1627, 8977, 4278, 365, 2741, 701, 314, 1627, 8879, 4257, 2529, 756, 14, 267, 3033, 26, 288, 536, 26, 8977, 536, 325, 14, 71, 14, 283, 4782, 15, 9733, 14, 4524, 7, 288, 8879, 26, 8879, 536, 325, 14, 71, 14, 283, 581, 13, 7915, 297, 283, 8268, 14, 1308, 7, 398, 1803, 26, 288, 715, 340, 1627, 8977, 4278, 365, 2741, 701, 314, 1627, 8879, 4257, 2529, 756, 267, 408, 267, 340, 440, 365, 63, 863, 22868, 3398, 63, 1589, 14566, 63, 3827, 837, 288, 372, 756, 398, 327, 315, 3105, 818, 1104, 2955, 8977, 687, 4453, 314, 2199, 2082, 267, 340, 2202, 14, 5287, 26, 288, 17915, 63, 1985, 275, 664, 63, 7915, 63, 1095, 63, 694, 8, 7915, 12, 15678, 63, 705, 29, 549, 9, 288, 327, 20550, 883, 506, 314, 3594, 340, 781, 2793, 1133, 1172, 282, 8879, 2909, 503, 1415, 1862, 14, 288, 340, 440, 1006, 1332, 23900, 63, 1985, 12, 8879, 12, 536, 2298, 355, 372, 756, 953, 314, 3594, 63, 515, 275, 3286, 1674, 904, 779, 355, 17915, 63, 1985, 12, 355, 8879, 12, 355, 664, 63, 1715, 63, 1231, 63, 354, 1062, 355, 298, 1986, 6687, 288, 4794, 288, 536, 275, 536, 59, 17, 2938, 340, 536, 14, 2460, 19031, 587, 536, 288, 931, 275, 5048, 63, 904, 8, 1589, 3594, 63, 515, 12, 536, 9, 288, 372, 747, 14, 515, 14, 2444, 8, 515, 9, 267, 327, 315, 12166, 818, 1104, 2955, 8977, 315, 314, 2955, 1584, 2935, 3247, 701, 298, 10449, 63, 5441, 2, 4260, 267, 587, 26, 288, 372, 291, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 7915, 12, 536, 430, 421, 199, 533, 23978, 16138, 5535, 4256, 8, 16138, 5535, 4256, 304, 272, 408, 272, 3599, 22868, 3398, 8879, 20381, 445, 4583, 5535, 4256, 14, 272, 11298, 12016, 402, 24572, 445, 4583, 5535, 4256, 365, 370, 4278, 314, 2569, 3102, 14, 272, 413, 446, 1166, 272, 499, 446, 1166, 63, 11256, 339, 1166, 26, 267, 961, 1083, 6181, 8977, 536, 465, 1423, 436, 365, 17845, 367, 7791, 2631, 370, 314, 536, 370, 2291, 13627, 14, 267, 961, 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 ]
withorwithoutgod/tacozmq
cherrypy/lib/jsontools.py
39
3666
import sys import cherrypy from cherrypy._cpcompat import basestring, ntou, json, json_encode, json_decode def json_processor(entity): """Read application/json data into request.json.""" if not entity.headers.get(ntou("Content-Length"), ntou("")): raise cherrypy.HTTPError(411) body = entity.fp.read() try: cherrypy.serving.request.json = json_decode(body.decode('utf-8')) except ValueError: raise cherrypy.HTTPError(400, 'Invalid JSON document') def json_in(content_type=[ntou('application/json'), ntou('text/javascript')], force=True, debug=False, processor = json_processor): """Add a processor to parse JSON request entities: The default processor places the parsed data into request.json. Incoming request entities which match the given content_type(s) will be deserialized from JSON to the Python equivalent, and the result stored at cherrypy.request.json. The 'content_type' argument may be a Content-Type string or a list of allowable Content-Type strings. If the 'force' argument is True (the default), then entities of other content types will not be allowed; "415 Unsupported Media Type" is raised instead. Supply your own processor to use a custom decoder, or to handle the parsed data differently. The processor can be configured via tools.json_in.processor or via the decorator method. Note that the deserializer requires the client send a Content-Length request header, or it will raise "411 Length Required". If for any other reason the request entity cannot be deserialized from JSON, it will raise "400 Bad Request: Invalid JSON document". You must be using Python 2.6 or greater, or have the 'simplejson' package importable; otherwise, ValueError is raised during processing. """ request = cherrypy.serving.request if isinstance(content_type, basestring): content_type = [content_type] if force: if debug: cherrypy.log('Removing body processors %s' % repr(request.body.processors.keys()), 'TOOLS.JSON_IN') request.body.processors.clear() request.body.default_proc = cherrypy.HTTPError( 415, 'Expected an entity of content type %s' % ', '.join(content_type)) for ct in content_type: if debug: cherrypy.log('Adding body processor for %s' % ct, 'TOOLS.JSON_IN') request.body.processors[ct] = processor def json_handler(*args, **kwargs): value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) return json_encode(value) def json_out(content_type='application/json', debug=False, handler=json_handler): """Wrap request.handler to serialize its output to JSON. Sets Content-Type. If the given content_type is None, the Content-Type response header is not set. Provide your own handler to use a custom encoder. For example cherrypy.config['tools.json_out.handler'] = <function>, or @json_out(handler=function). You must be using Python 2.6 or greater, or have the 'simplejson' package importable; otherwise, ValueError is raised during processing. """ request = cherrypy.serving.request if debug: cherrypy.log('Replacing %s with JSON handler' % request.handler, 'TOOLS.JSON_OUT') request._json_inner_handler = request.handler request.handler = handler if content_type is not None: if debug: cherrypy.log('Setting Content-Type to %s' % content_type, 'TOOLS.JSON_OUT') cherrypy.serving.response.headers['Content-Type'] = content_type
mit
[ 646, 984, 199, 646, 13397, 199, 504, 13397, 423, 1850, 5819, 492, 7116, 12, 302, 475, 85, 12, 2022, 12, 2022, 63, 2143, 12, 2022, 63, 2708, 199, 199, 318, 2022, 63, 6459, 8, 4502, 304, 272, 408, 3284, 4223, 15, 1001, 666, 1901, 1056, 14, 1001, 1041, 272, 340, 440, 4642, 14, 2139, 14, 362, 8, 343, 810, 480, 2714, 13, 4625, 1288, 302, 475, 85, 11986, 2298, 267, 746, 13397, 14, 12815, 8, 25390, 9, 339, 2396, 275, 4642, 14, 3997, 14, 739, 342, 272, 862, 26, 267, 13397, 14, 14717, 14, 1069, 14, 1001, 275, 2022, 63, 2708, 8, 2030, 14, 2708, 360, 1624, 13, 24, 1333, 272, 871, 1722, 26, 267, 746, 13397, 14, 12815, 8, 5303, 12, 283, 3364, 4840, 2213, 358, 199, 199, 318, 2022, 63, 262, 8, 1317, 63, 466, 1524, 343, 810, 360, 3578, 15, 1001, 659, 302, 475, 85, 360, 505, 15, 9554, 2665, 288, 3542, 29, 549, 12, 3105, 29, 797, 12, 12495, 275, 2022, 63, 6459, 304, 272, 408, 1123, 282, 12495, 370, 2198, 4840, 1056, 9045, 26, 272, 710, 849, 12495, 9825, 314, 4565, 666, 1901, 1056, 14, 1001, 14, 339, 1010, 7909, 1056, 9045, 1314, 1336, 314, 1627, 1564, 63, 466, 8, 83, 9, 911, 272, 506, 13256, 687, 4840, 370, 314, 2018, 7353, 12, 436, 314, 754, 272, 5489, 737, 13397, 14, 1069, 14, 1001, 14, 710, 283, 1317, 63, 466, 7, 1423, 1443, 272, 506, 282, 6646, 13, 804, 1059, 503, 282, 769, 402, 32518, 6646, 13, 804, 3326, 14, 339, 982, 314, 283, 3990, 7, 1423, 365, 715, 334, 1589, 849, 395, 2066, 9045, 402, 1163, 272, 1564, 2943, 911, 440, 506, 4370, 27, 298, 24415, 19022, 12300, 2434, 2, 365, 272, 4915, 3140, 14, 339, 6820, 19786, 2195, 5705, 12495, 370, 675, 282, 3537, 10334, 12, 503, 370, 2429, 314, 4565, 272, 666, 23142, 14, 221, 710, 12495, 883, 506, 7526, 4799, 272, 7249, 14, 1001, 63, 262, 14, 6459, 503, 4799, 314, 7531, 1083, 14, 339, 3390, 626, 314, 30237, 5074, 314, 1890, 3222, 282, 6646, 13, 4625, 272, 1056, 1406, 12, 503, 652, 911, 746, 298, 25390, 19893, 11105, 1674, 982, 367, 1263, 272, 1163, 4499, 314, 1056, 4642, 3913, 506, 13256, 687, 4840, 12, 272, 652, 911, 746, 298, 5303, 8857, 4784, 26, 6378, 4840, 2213, 1674, 339, 2047, 1471, 506, 1808, 2018, 499, 14, 22, 503, 8932, 12, 503, 1172, 314, 283, 4129, 1001, 7, 272, 2559, 492, 461, 27, 4257, 12, 1722, 365, 4915, 5309, 6661, 14, 272, 408, 272, 1056, 275, 13397, 14, 14717, 14, 1069, 272, 340, 1228, 8, 1317, 63, 466, 12, 7116, 304, 267, 1564, 63, 466, 275, 359, 1317, 63, 466, 61, 339, 340, 3542, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 23420, 2396, 21620, 450, 83, 7, 450, 586, 4700, 8, 1069, 14, 2030, 14, 10547, 14, 1612, 4000, 283, 20261, 14, 6243, 63, 568, 358, 267, 1056, 14, 2030, 14, 10547, 14, 3584, 342, 267, 1056, 14, 2030, 14, 885, 63, 4687, 275, 13397, 14, 12815, 8, 288, 841, 1046, 12, 283, 6964, 376, 4642, 402, 1564, 730, 450, 83, 7, 450, 288, 1656, 1987, 904, 8, 1317, 63, 466, 430, 339, 367, 9428, 315, 1564, 63, 466, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 20897, 2396, 12495, 367, 450, 83, 7, 450, 9428, 12, 283, 20261, 14, 6243, 63, 568, 358, 267, 1056, 14, 2030, 14, 10547, 59, 319, 61, 275, 12495, 199, 199, 318, 2022, 63, 2232, 2031, 589, 12, 1011, 958, 304, 272, 574, 275, 13397, 14, 14717, 14, 1069, 423, 1001, 63, 5216, 63, 2232, 2031, 589, 12, 1011, 958, 9, 272, 372, 2022, 63, 2143, 8, 585, 9, 199, 199, 318, 2022, 63, 548, 8, 1317, 63, 466, 534, 3578, 15, 1001, 297, 3105, 29, 797, 12, 3016, 29, 1001, 63, 2232, 304, 272, 408, 15991, 1056, 14, 2232, 370, 8437, 2399, 1072, 370, 4840, 14, 10729, 6646, 13, 804, 14, 339, 982, 314, 1627, 1564, 63, 466, 365, 488, 12, 314, 6646, 13, 804, 1177, 1406, 272, 365, 440, 663, 14, 339, 22896, 2195, 5705, 3016, 370, 675, 282, 3537, 10295, 14, 221, 2104, 2893, 272, 13397, 14, 888, 459, 2537, 14, 1001, 63, 548, 14, 2232, 418, 275, 665, 1593, 6244, 503, 272, 768, 1001, 63, 548, 8, 2232, 29, 1593, 680, 339, 2047, 1471, 506, 1808, 2018, 499, 14, 22, 503, 8932, 12, 503, 1172, 314, 283, 4129, 1001, 7, 272, 2559, 492, 461, 27, 4257, 12, 1722, 365, 4915, 5309, 6661, 14, 272, 408, 272, 1056, 275, 13397, 14, 14717, 14, 1069, 272, 340, 3105, 26, 267, 13397, 14, 793, 360, 6875, 13121, 450, 83, 543, 4840, 3016, 7, 450, 1056, 14, 2232, 12, 2151, 283, 20261, 14, 6243, 63, 1877, 358, 272, 1056, 423, 1001, 63, 5216, 63, 2232, 275, 1056, 14, 2232, 272, 1056, 14, 2232, 275, 3016, 272, 340, 1564, 63, 466, 365, 440, 488, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 7776, 6646, 13, 804, 370, 450, 83, 7, 450, 1564, 63, 466, 12, 283, 20261, 14, 6243, 63, 1877, 358, 267, 13397, 14, 14717, 14, 1310, 14, 2139, 459, 2714, 13, 804, 418, 275, 1564, 63, 466, 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 ]
[ 984, 199, 646, 13397, 199, 504, 13397, 423, 1850, 5819, 492, 7116, 12, 302, 475, 85, 12, 2022, 12, 2022, 63, 2143, 12, 2022, 63, 2708, 199, 199, 318, 2022, 63, 6459, 8, 4502, 304, 272, 408, 3284, 4223, 15, 1001, 666, 1901, 1056, 14, 1001, 1041, 272, 340, 440, 4642, 14, 2139, 14, 362, 8, 343, 810, 480, 2714, 13, 4625, 1288, 302, 475, 85, 11986, 2298, 267, 746, 13397, 14, 12815, 8, 25390, 9, 339, 2396, 275, 4642, 14, 3997, 14, 739, 342, 272, 862, 26, 267, 13397, 14, 14717, 14, 1069, 14, 1001, 275, 2022, 63, 2708, 8, 2030, 14, 2708, 360, 1624, 13, 24, 1333, 272, 871, 1722, 26, 267, 746, 13397, 14, 12815, 8, 5303, 12, 283, 3364, 4840, 2213, 358, 199, 199, 318, 2022, 63, 262, 8, 1317, 63, 466, 1524, 343, 810, 360, 3578, 15, 1001, 659, 302, 475, 85, 360, 505, 15, 9554, 2665, 288, 3542, 29, 549, 12, 3105, 29, 797, 12, 12495, 275, 2022, 63, 6459, 304, 272, 408, 1123, 282, 12495, 370, 2198, 4840, 1056, 9045, 26, 272, 710, 849, 12495, 9825, 314, 4565, 666, 1901, 1056, 14, 1001, 14, 339, 1010, 7909, 1056, 9045, 1314, 1336, 314, 1627, 1564, 63, 466, 8, 83, 9, 911, 272, 506, 13256, 687, 4840, 370, 314, 2018, 7353, 12, 436, 314, 754, 272, 5489, 737, 13397, 14, 1069, 14, 1001, 14, 710, 283, 1317, 63, 466, 7, 1423, 1443, 272, 506, 282, 6646, 13, 804, 1059, 503, 282, 769, 402, 32518, 6646, 13, 804, 3326, 14, 339, 982, 314, 283, 3990, 7, 1423, 365, 715, 334, 1589, 849, 395, 2066, 9045, 402, 1163, 272, 1564, 2943, 911, 440, 506, 4370, 27, 298, 24415, 19022, 12300, 2434, 2, 365, 272, 4915, 3140, 14, 339, 6820, 19786, 2195, 5705, 12495, 370, 675, 282, 3537, 10334, 12, 503, 370, 2429, 314, 4565, 272, 666, 23142, 14, 221, 710, 12495, 883, 506, 7526, 4799, 272, 7249, 14, 1001, 63, 262, 14, 6459, 503, 4799, 314, 7531, 1083, 14, 339, 3390, 626, 314, 30237, 5074, 314, 1890, 3222, 282, 6646, 13, 4625, 272, 1056, 1406, 12, 503, 652, 911, 746, 298, 25390, 19893, 11105, 1674, 982, 367, 1263, 272, 1163, 4499, 314, 1056, 4642, 3913, 506, 13256, 687, 4840, 12, 272, 652, 911, 746, 298, 5303, 8857, 4784, 26, 6378, 4840, 2213, 1674, 339, 2047, 1471, 506, 1808, 2018, 499, 14, 22, 503, 8932, 12, 503, 1172, 314, 283, 4129, 1001, 7, 272, 2559, 492, 461, 27, 4257, 12, 1722, 365, 4915, 5309, 6661, 14, 272, 408, 272, 1056, 275, 13397, 14, 14717, 14, 1069, 272, 340, 1228, 8, 1317, 63, 466, 12, 7116, 304, 267, 1564, 63, 466, 275, 359, 1317, 63, 466, 61, 339, 340, 3542, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 23420, 2396, 21620, 450, 83, 7, 450, 586, 4700, 8, 1069, 14, 2030, 14, 10547, 14, 1612, 4000, 283, 20261, 14, 6243, 63, 568, 358, 267, 1056, 14, 2030, 14, 10547, 14, 3584, 342, 267, 1056, 14, 2030, 14, 885, 63, 4687, 275, 13397, 14, 12815, 8, 288, 841, 1046, 12, 283, 6964, 376, 4642, 402, 1564, 730, 450, 83, 7, 450, 288, 1656, 1987, 904, 8, 1317, 63, 466, 430, 339, 367, 9428, 315, 1564, 63, 466, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 20897, 2396, 12495, 367, 450, 83, 7, 450, 9428, 12, 283, 20261, 14, 6243, 63, 568, 358, 267, 1056, 14, 2030, 14, 10547, 59, 319, 61, 275, 12495, 199, 199, 318, 2022, 63, 2232, 2031, 589, 12, 1011, 958, 304, 272, 574, 275, 13397, 14, 14717, 14, 1069, 423, 1001, 63, 5216, 63, 2232, 2031, 589, 12, 1011, 958, 9, 272, 372, 2022, 63, 2143, 8, 585, 9, 199, 199, 318, 2022, 63, 548, 8, 1317, 63, 466, 534, 3578, 15, 1001, 297, 3105, 29, 797, 12, 3016, 29, 1001, 63, 2232, 304, 272, 408, 15991, 1056, 14, 2232, 370, 8437, 2399, 1072, 370, 4840, 14, 10729, 6646, 13, 804, 14, 339, 982, 314, 1627, 1564, 63, 466, 365, 488, 12, 314, 6646, 13, 804, 1177, 1406, 272, 365, 440, 663, 14, 339, 22896, 2195, 5705, 3016, 370, 675, 282, 3537, 10295, 14, 221, 2104, 2893, 272, 13397, 14, 888, 459, 2537, 14, 1001, 63, 548, 14, 2232, 418, 275, 665, 1593, 6244, 503, 272, 768, 1001, 63, 548, 8, 2232, 29, 1593, 680, 339, 2047, 1471, 506, 1808, 2018, 499, 14, 22, 503, 8932, 12, 503, 1172, 314, 283, 4129, 1001, 7, 272, 2559, 492, 461, 27, 4257, 12, 1722, 365, 4915, 5309, 6661, 14, 272, 408, 272, 1056, 275, 13397, 14, 14717, 14, 1069, 272, 340, 3105, 26, 267, 13397, 14, 793, 360, 6875, 13121, 450, 83, 543, 4840, 3016, 7, 450, 1056, 14, 2232, 12, 2151, 283, 20261, 14, 6243, 63, 1877, 358, 272, 1056, 423, 1001, 63, 5216, 63, 2232, 275, 1056, 14, 2232, 272, 1056, 14, 2232, 275, 3016, 272, 340, 1564, 63, 466, 365, 440, 488, 26, 267, 340, 3105, 26, 288, 13397, 14, 793, 360, 7776, 6646, 13, 804, 370, 450, 83, 7, 450, 1564, 63, 466, 12, 283, 20261, 14, 6243, 63, 1877, 358, 267, 13397, 14, 14717, 14, 1310, 14, 2139, 459, 2714, 13, 804, 418, 275, 1564, 63, 466, 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, 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,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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 ]
google/contentbox
third_party/django/contrib/gis/tests/distapp/tests.py
109
19389
from __future__ import absolute_import from django.db import connection from django.db.models import Q from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.measure import D # alias for Distance from django.contrib.gis.tests.utils import ( HAS_SPATIAL_DB, mysql, oracle, postgis, spatialite, no_oracle, no_spatialite ) from django.test import TestCase from django.utils.unittest import skipUnless if HAS_GEOS and HAS_SPATIAL_DB: from django.contrib.gis.geos import GEOSGeometry, LineString from .models import (AustraliaCity, Interstate, SouthTexasInterstate, SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode) @skipUnless(HAS_GEOS and HAS_SPATIAL_DB and not mysql, "Geos and spatial db (not mysql) are required.") class DistanceTest(TestCase): if HAS_GEOS and HAS_SPATIAL_DB: # A point we are testing distances with -- using a WGS84 # coordinate that'll be implicitly transormed to that to # the coordinate system of the field, EPSG:32140 (Texas South Central # w/units in meters) stx_pnt = GEOSGeometry('POINT (-95.370401017314293 29.704867409475465)', 4326) # Another one for Australia au_pnt = GEOSGeometry('POINT (150.791 -34.4919)', 4326) def get_names(self, qs): cities = [c.name for c in qs] cities.sort() return cities def test01_init(self): "Test initialization of distance models." self.assertEqual(9, SouthTexasCity.objects.count()) self.assertEqual(9, SouthTexasCityFt.objects.count()) self.assertEqual(11, AustraliaCity.objects.count()) self.assertEqual(4, SouthTexasZipcode.objects.count()) self.assertEqual(4, CensusZipcode.objects.count()) self.assertEqual(1, Interstate.objects.count()) self.assertEqual(1, SouthTexasInterstate.objects.count()) @no_spatialite def test02_dwithin(self): "Testing the `dwithin` lookup type." # Distances -- all should be equal (except for the # degree/meter pair in au_cities, that's somewhat # approximate). tx_dists = [(7000, 22965.83), D(km=7), D(mi=4.349)] au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)] # Expected cities for Australia and Texas. tx_cities = ['Downtown Houston', 'Southside Place'] au_cities = ['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong'] # Performing distance queries on two projected coordinate systems one # with units in meters and the other in units of U.S. survey feet. for dist in tx_dists: if isinstance(dist, tuple): dist1, dist2 = dist else: dist1 = dist2 = dist qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1)) qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2)) for qs in qs1, qs2: self.assertEqual(tx_cities, self.get_names(qs)) # Now performing the `dwithin` queries on a geodetic coordinate system. for dist in au_dists: if isinstance(dist, D) and not oracle: type_error = True else: type_error = False if isinstance(dist, tuple): if oracle: dist = dist[1] else: dist = dist[0] # Creating the query set. qs = AustraliaCity.objects.order_by('name') if type_error: # A ValueError should be raised on PostGIS when trying to pass # Distance objects into a DWithin query using a geodetic field. self.assertRaises(ValueError, AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).count) else: self.assertEqual(au_cities, self.get_names(qs.filter(point__dwithin=(self.au_pnt, dist)))) def test03a_distance_method(self): "Testing the `distance` GeoQuerySet method on projected coordinate systems." # The point for La Grange, TX lagrange = GEOSGeometry('POINT(-96.876369 29.905320)', 4326) # Reference distances in feet and in meters. Got these values from # using the provided raw SQL statements. # SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 32140)) FROM distapp_southtexascity; m_distances = [147075.069813, 139630.198056, 140888.552826, 138809.684197, 158309.246259, 212183.594374, 70870.188967, 165337.758878, 139196.085105] # SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 2278)) FROM distapp_southtexascityft; # Oracle 11 thinks this is not a projected coordinate system, so it's s # not tested. ft_distances = [482528.79154625, 458103.408123001, 462231.860397575, 455411.438904354, 519386.252102563, 696139.009211594, 232513.278304279, 542445.630586414, 456679.155883207] # Testing using different variations of parameters and using models # with different projected coordinate systems. dist1 = SouthTexasCity.objects.distance(lagrange, field_name='point') dist2 = SouthTexasCity.objects.distance(lagrange) # Using GEOSGeometry parameter if spatialite or oracle: dist_qs = [dist1, dist2] else: dist3 = SouthTexasCityFt.objects.distance(lagrange.ewkt) # Using EWKT string parameter. dist4 = SouthTexasCityFt.objects.distance(lagrange) dist_qs = [dist1, dist2, dist3, dist4] # Original query done on PostGIS, have to adjust AlmostEqual tolerance # for Oracle. if oracle: tol = 2 else: tol = 5 # Ensuring expected distances are returned for each distance queryset. for qs in dist_qs: for i, c in enumerate(qs): self.assertAlmostEqual(m_distances[i], c.distance.m, tol) self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol) @no_spatialite def test03b_distance_method(self): "Testing the `distance` GeoQuerySet method on geodetic coordnate systems." if oracle: tol = 2 else: tol = 5 # Testing geodetic distance calculation with a non-point geometry # (a LineString of Wollongong and Shellharbour coords). ls = LineString( ( (150.902, -34.4245), (150.87, -34.5789) ) ) if oracle or connection.ops.geography: # Reference query: # SELECT ST_distance_sphere(point, ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326)) FROM distapp_australiacity ORDER BY name; distances = [1120954.92533513, 140575.720018241, 640396.662906304, 60580.9693849269, 972807.955955075, 568451.8357838, 40435.4335201384, 0, 68272.3896586844, 12375.0643697706, 0] qs = AustraliaCity.objects.distance(ls).order_by('name') for city, distance in zip(qs, distances): # Testing equivalence to within a meter. self.assertAlmostEqual(distance, city.distance.m, 0) else: # PostGIS 1.4 and below is limited to disance queries only # to/from point geometries, check for raising of ValueError. self.assertRaises(ValueError, AustraliaCity.objects.distance, ls) self.assertRaises(ValueError, AustraliaCity.objects.distance, ls.wkt) # Got the reference distances using the raw SQL statements: # SELECT ST_distance_spheroid(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326), 'SPHEROID["WGS 84",6378137.0,298.257223563]') FROM distapp_australiacity WHERE (NOT (id = 11)); # SELECT ST_distance_sphere(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326)) FROM distapp_australiacity WHERE (NOT (id = 11)); st_distance_sphere if connection.ops.postgis and connection.ops.proj_version_tuple() >= (4, 7, 0): # PROJ.4 versions 4.7+ have updated datums, and thus different # distance values. spheroid_distances = [60504.0628957201, 77023.9489850262, 49154.8867574404, 90847.4358768573, 217402.811919332, 709599.234564757, 640011.483550888, 7772.00667991925, 1047861.78619339, 1165126.55236034] sphere_distances = [60580.9693849267, 77144.0435286473, 49199.4415344719, 90804.7533823494, 217713.384600405, 709134.127242793, 639828.157159169, 7786.82949717788, 1049204.06569028, 1162623.7238134] else: spheroid_distances = [60504.0628825298, 77023.948962654, 49154.8867507115, 90847.435881812, 217402.811862568, 709599.234619957, 640011.483583758, 7772.00667666425, 1047861.7859506, 1165126.55237647] sphere_distances = [60580.7612632291, 77143.7785056615, 49199.2725132184, 90804.4414289463, 217712.63666124, 709131.691061906, 639825.959074112, 7786.80274606706, 1049200.46122281, 1162619.7297006] # Testing with spheroid distances first. hillsdale = AustraliaCity.objects.get(name='Hillsdale') qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point, spheroid=True) for i, c in enumerate(qs): self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol) if postgis: # PostGIS uses sphere-only distances by default, testing these as well. qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point) for i, c in enumerate(qs): self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol) @no_oracle # Oracle already handles geographic distance calculation. def test03c_distance_method(self): "Testing the `distance` GeoQuerySet method used with `transform` on a geographic field." # Normally you can't compute distances from a geometry field # that is not a PointField (on PostGIS 1.4 and below). if not connection.ops.geography: self.assertRaises(ValueError, CensusZipcode.objects.distance, self.stx_pnt) # We'll be using a Polygon (created by buffering the centroid # of 77005 to 100m) -- which aren't allowed in geographic distance # queries normally, however our field has been transformed to # a non-geographic system. z = SouthTexasZipcode.objects.get(name='77005') # Reference query: # SELECT ST_Distance(ST_Transform("distapp_censuszipcode"."poly", 32140), ST_GeomFromText('<buffer_wkt>', 32140)) FROM "distapp_censuszipcode"; dists_m = [3553.30384972258, 1243.18391525602, 2186.15439472242] # Having our buffer in the SRID of the transformation and of the field # -- should get the same results. The first buffer has no need for # transformation SQL because it is the same SRID as what was given # to `transform()`. The second buffer will need to be transformed, # however. buf1 = z.poly.centroid.buffer(100) buf2 = buf1.transform(4269, clone=True) ref_zips = ['77002', '77025', '77401'] for buf in [buf1, buf2]: qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf) self.assertEqual(ref_zips, self.get_names(qs)) for i, z in enumerate(qs): self.assertAlmostEqual(z.distance.m, dists_m[i], 5) def test04_distance_lookups(self): "Testing the `distance_lt`, `distance_gt`, `distance_lte`, and `distance_gte` lookup types." # Retrieving the cities within a 20km 'donut' w/a 7km radius 'hole' # (thus, Houston and Southside place will be excluded as tested in # the `test02_dwithin` above). qs1 = SouthTexasCity.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20))) # Can't determine the units on SpatiaLite from PROJ.4 string, and # Oracle 11 incorrectly thinks it is not projected. if spatialite or oracle: dist_qs = (qs1,) else: qs2 = SouthTexasCityFt.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20))) dist_qs = (qs1, qs2) for qs in dist_qs: cities = self.get_names(qs) self.assertEqual(cities, ['Bellaire', 'Pearland', 'West University Place']) # Doing a distance query using Polygons instead of a Point. z = SouthTexasZipcode.objects.get(name='77005') qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=275))) self.assertEqual(['77025', '77401'], self.get_names(qs)) # If we add a little more distance 77002 should be included. qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=300))) self.assertEqual(['77002', '77025', '77401'], self.get_names(qs)) def test05_geodetic_distance_lookups(self): "Testing distance lookups on geodetic coordinate systems." # Line is from Canberra to Sydney. Query is for all other cities within # a 100km of that line (which should exclude only Hobart & Adelaide). line = GEOSGeometry('LINESTRING(144.9630 -37.8143,151.2607 -33.8870)', 4326) dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100))) if oracle or connection.ops.geography: # Oracle and PostGIS 1.5 can do distance lookups on arbitrary geometries. self.assertEqual(9, dist_qs.count()) self.assertEqual(['Batemans Bay', 'Canberra', 'Hillsdale', 'Melbourne', 'Mittagong', 'Shellharbour', 'Sydney', 'Thirroul', 'Wollongong'], self.get_names(dist_qs)) else: # PostGIS 1.4 and below only allows geodetic distance queries (utilizing # ST_Distance_Sphere/ST_Distance_Spheroid) from Points to PointFields # on geometry columns. self.assertRaises(ValueError, dist_qs.count) # Ensured that a ValueError was raised, none of the rest of the test is # support on this backend, so bail now. if spatialite: return # Too many params (4 in this case) should raise a ValueError. self.assertRaises(ValueError, len, AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4'))) # Not enough params should raise a ValueError. self.assertRaises(ValueError, len, AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)',))) # Getting all cities w/in 550 miles of Hobart. hobart = AustraliaCity.objects.get(name='Hobart') qs = AustraliaCity.objects.exclude(name='Hobart').filter(point__distance_lte=(hobart.point, D(mi=550))) cities = self.get_names(qs) self.assertEqual(cities, ['Batemans Bay', 'Canberra', 'Melbourne']) # Cities that are either really close or really far from Wollongong -- # and using different units of distance. wollongong = AustraliaCity.objects.get(name='Wollongong') d1, d2 = D(yd=19500), D(nm=400) # Yards (~17km) & Nautical miles. # Normal geodetic distance lookup (uses `distance_sphere` on PostGIS. gq1 = Q(point__distance_lte=(wollongong.point, d1)) gq2 = Q(point__distance_gte=(wollongong.point, d2)) qs1 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq1 | gq2) # Geodetic distance lookup but telling GeoDjango to use `distance_spheroid` # instead (we should get the same results b/c accuracy variance won't matter # in this test case). if postgis: gq3 = Q(point__distance_lte=(wollongong.point, d1, 'spheroid')) gq4 = Q(point__distance_gte=(wollongong.point, d2, 'spheroid')) qs2 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq3 | gq4) querysets = [qs1, qs2] else: querysets = [qs1] for qs in querysets: cities = self.get_names(qs) self.assertEqual(cities, ['Adelaide', 'Hobart', 'Shellharbour', 'Thirroul']) def test06_area(self): "Testing the `area` GeoQuerySet method." # Reference queries: # SELECT ST_Area(poly) FROM distapp_southtexaszipcode; area_sq_m = [5437908.90234375, 10183031.4389648, 11254471.0073242, 9881708.91772461] # Tolerance has to be lower for Oracle and differences # with GEOS 3.0.0RC4 tol = 2 for i, z in enumerate(SouthTexasZipcode.objects.area()): self.assertAlmostEqual(area_sq_m[i], z.area.sq_m, tol) def test07_length(self): "Testing the `length` GeoQuerySet method." # Reference query (should use `length_spheroid`). # SELECT ST_length_spheroid(ST_GeomFromText('<wkt>', 4326) 'SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]]'); len_m1 = 473504.769553813 len_m2 = 4617.668 if spatialite: # Does not support geodetic coordinate systems. self.assertRaises(ValueError, Interstate.objects.length) else: qs = Interstate.objects.length() if oracle: tol = 2 else: tol = 3 self.assertAlmostEqual(len_m1, qs[0].length.m, tol) # Now doing length on a projected coordinate system. i10 = SouthTexasInterstate.objects.length().get(name='I-10') self.assertAlmostEqual(len_m2, i10.length.m, 2) @no_spatialite def test08_perimeter(self): "Testing the `perimeter` GeoQuerySet method." # Reference query: # SELECT ST_Perimeter(distapp_southtexaszipcode.poly) FROM distapp_southtexaszipcode; perim_m = [18404.3550889361, 15627.2108551001, 20632.5588368978, 17094.5996143697] if oracle: tol = 2 else: tol = 7 for i, z in enumerate(SouthTexasZipcode.objects.perimeter()): self.assertAlmostEqual(perim_m[i], z.perimeter.m, tol) # Running on points; should return 0. for i, c in enumerate(SouthTexasCity.objects.perimeter(model_att='perim')): self.assertEqual(0, c.perim.m) def test09_measurement_null_fields(self): "Testing the measurement GeoQuerySet methods on fields with NULL values." # Creating SouthTexasZipcode w/NULL value. SouthTexasZipcode.objects.create(name='78212') # Performing distance/area queries against the NULL PolygonField, # and ensuring the result of the operations is None. htown = SouthTexasCity.objects.get(name='Downtown Houston') z = SouthTexasZipcode.objects.distance(htown.point).area().get(name='78212') self.assertEqual(None, z.distance) self.assertEqual(None, z.area)
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7509, 63, 14151, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 577, 327, 5162, 367, 21892, 199, 504, 1639, 14, 2828, 14, 5668, 14, 2219, 14, 1208, 492, 334, 272, 7509, 63, 51, 2805, 4938, 63, 2846, 12, 12896, 12, 28123, 12, 2963, 5668, 12, 11469, 1175, 12, 949, 63, 16404, 12, 949, 63, 25873, 199, 9, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 692, 7509, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 26, 272, 687, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21479, 12, 30020, 339, 687, 1275, 992, 492, 334, 29459, 17024, 12, 6551, 929, 12, 23150, 30121, 2620, 929, 12, 267, 23150, 30121, 17024, 12, 23150, 30121, 17024, 38, 84, 12, 445, 8764, 527, 8674, 600, 12, 23150, 30121, 8674, 600, 9, 421, 199, 32, 11278, 8, 13533, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 436, 440, 12896, 12, 272, 298, 4240, 736, 436, 11469, 1592, 334, 1397, 12896, 9, 787, 1415, 2685, 199, 533, 21892, 774, 8, 1746, 304, 339, 340, 7509, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 26, 267, 327, 437, 2376, 781, 787, 5343, 15108, 543, 1553, 1808, 282, 644, 8021, 1349, 267, 327, 10021, 626, 7171, 506, 19796, 1752, 13469, 370, 626, 370, 267, 327, 314, 10021, 2656, 402, 314, 901, 12, 31922, 4254, 26, 708, 10037, 334, 30121, 23150, 32267, 9117, 267, 327, 336, 15, 5260, 315, 24808, 9, 267, 410, 88, 63, 24519, 275, 21479, 360, 7217, 5868, 2720, 14, 1401, 966, 11502, 2898, 1079, 16417, 7349, 14, 32170, 1184, 1342, 1643, 2417, 1477, 2182, 3196, 26719, 9, 267, 327, 22604, 1373, 367, 437, 22306, 267, 10576, 63, 24519, 275, 21479, 360, 7217, 334, 8251, 14, 26814, 446, 1082, 14, 1887, 1167, 3196, 26719, 9, 339, 347, 664, 63, 1247, 8, 277, 12, 6377, 304, 267, 286, 12107, 275, 359, 67, 14, 354, 367, 286, 315, 6377, 61, 267, 286, 12107, 14, 3191, 342, 267, 372, 286, 12107, 339, 347, 511, 614, 63, 826, 8, 277, 304, 267, 298, 774, 11097, 402, 6033, 1709, 2122, 267, 291, 14, 629, 8, 25, 12, 23150, 30121, 17024, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 25, 12, 23150, 30121, 17024, 38, 84, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 845, 12, 437, 22306, 17024, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 20, 12, 23150, 30121, 8674, 600, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 20, 12, 445, 8764, 527, 8674, 600, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 17, 12, 6551, 929, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 17, 12, 23150, 30121, 2620, 929, 14, 1462, 14, 835, 1012, 339, 768, 889, 63, 25873, 272, 347, 511, 996, 63, 68, 12541, 8, 277, 304, 267, 298, 9029, 314, 658, 68, 12541, 64, 4237, 730, 2122, 267, 327, 21892, 83, 1553, 1006, 1077, 506, 4472, 334, 2590, 367, 314, 267, 327, 13666, 15, 10011, 4092, 315, 10576, 63, 18207, 12, 626, 1159, 30362, 267, 327, 19917, 680, 267, 4773, 63, 18552, 275, 3842, 23, 1493, 12, 499, 26163, 14, 2658, 395, 577, 8, 14595, 29, 23, 395, 577, 8, 2664, 29, 20, 14, 11991, 1874, 267, 10576, 63, 18552, 275, 3842, 16, 14, 21, 12, 4337, 1493, 395, 577, 8, 14595, 29, 708, 395, 577, 8, 2664, 29, 1167, 14, 16303, 1874, 398, 327, 13796, 286, 12107, 367, 437, 22306, 436, 20566, 305, 14, 267, 4773, 63, 18207, 275, 788, 36, 583, 343, 944, 869, 810, 17874, 297, 283, 30534, 2441, 10902, 418, 267, 10576, 63, 18207, 275, 788, 45, 390, 1450, 951, 297, 283, 8529, 8210, 66, 567, 297, 283, 2719, 723, 293, 348, 297, 283, 55, 393, 2809, 951, 418, 398, 327, 14795, 316, 6033, 9212, 641, 2877, 27294, 10021, 10460, 1373, 267, 327, 543, 6204, 315, 24808, 436, 314, 1163, 315, 6204, 402, 738, 14, 51, 14, 16576, 1964, 386, 14, 267, 367, 2917, 315, 4773, 63, 18552, 26, 288, 340, 1228, 8, 2686, 12, 2008, 304, 2917, 17, 12, 2917, 18, 275, 2917, 288, 587, 26, 2917, 17, 275, 2917, 18, 275, 2917, 288, 6377, 17, 275, 23150, 30121, 17024, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 270, 88, 63, 24519, 12, 2917, 17, 430, 288, 6377, 18, 275, 23150, 30121, 17024, 38, 84, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 270, 88, 63, 24519, 12, 2917, 18, 430, 288, 367, 6377, 315, 6377, 17, 12, 6377, 18, 26, 355, 291, 14, 629, 8, 2347, 63, 18207, 12, 291, 14, 362, 63, 1247, 8, 6177, 430, 398, 327, 7356, 19203, 314, 658, 68, 12541, 64, 9212, 641, 282, 2312, 32230, 10021, 2656, 14, 267, 367, 2917, 315, 10576, 63, 18552, 26, 288, 340, 1228, 8, 2686, 12, 577, 9, 436, 440, 28123, 26, 730, 63, 705, 275, 715, 288, 587, 26, 730, 63, 705, 275, 756, 953, 340, 1228, 8, 2686, 12, 2008, 304, 355, 340, 28123, 26, 2917, 275, 2917, 59, 17, 61, 355, 587, 26, 2917, 275, 2917, 59, 16, 61, 953, 327, 20507, 314, 1827, 663, 14, 288, 6377, 275, 437, 22306, 17024, 14, 1462, 14, 1648, 63, 991, 360, 354, 358, 288, 340, 730, 63, 705, 26, 355, 327, 437, 1722, 1077, 506, 4915, 641, 20929, 1380, 9936, 370, 986, 355, 327, 21892, 2251, 1901, 282, 577, 3007, 262, 1827, 1808, 282, 2312, 32230, 901, 14, 355, 291, 14, 1855, 8, 3393, 12, 437, 22306, 17024, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 3844, 63, 24519, 12, 2917, 4992, 835, 9, 288, 587, 26, 355, 291, 14, 629, 8, 3844, 63, 18207, 12, 291, 14, 362, 63, 1247, 8, 6177, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 3844, 63, 24519, 12, 2917, 7845, 339 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7509, 63, 14151, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 577, 327, 5162, 367, 21892, 199, 504, 1639, 14, 2828, 14, 5668, 14, 2219, 14, 1208, 492, 334, 272, 7509, 63, 51, 2805, 4938, 63, 2846, 12, 12896, 12, 28123, 12, 2963, 5668, 12, 11469, 1175, 12, 949, 63, 16404, 12, 949, 63, 25873, 199, 9, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 692, 7509, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 26, 272, 687, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21479, 12, 30020, 339, 687, 1275, 992, 492, 334, 29459, 17024, 12, 6551, 929, 12, 23150, 30121, 2620, 929, 12, 267, 23150, 30121, 17024, 12, 23150, 30121, 17024, 38, 84, 12, 445, 8764, 527, 8674, 600, 12, 23150, 30121, 8674, 600, 9, 421, 199, 32, 11278, 8, 13533, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 436, 440, 12896, 12, 272, 298, 4240, 736, 436, 11469, 1592, 334, 1397, 12896, 9, 787, 1415, 2685, 199, 533, 21892, 774, 8, 1746, 304, 339, 340, 7509, 63, 14151, 436, 7509, 63, 51, 2805, 4938, 63, 2846, 26, 267, 327, 437, 2376, 781, 787, 5343, 15108, 543, 1553, 1808, 282, 644, 8021, 1349, 267, 327, 10021, 626, 7171, 506, 19796, 1752, 13469, 370, 626, 370, 267, 327, 314, 10021, 2656, 402, 314, 901, 12, 31922, 4254, 26, 708, 10037, 334, 30121, 23150, 32267, 9117, 267, 327, 336, 15, 5260, 315, 24808, 9, 267, 410, 88, 63, 24519, 275, 21479, 360, 7217, 5868, 2720, 14, 1401, 966, 11502, 2898, 1079, 16417, 7349, 14, 32170, 1184, 1342, 1643, 2417, 1477, 2182, 3196, 26719, 9, 267, 327, 22604, 1373, 367, 437, 22306, 267, 10576, 63, 24519, 275, 21479, 360, 7217, 334, 8251, 14, 26814, 446, 1082, 14, 1887, 1167, 3196, 26719, 9, 339, 347, 664, 63, 1247, 8, 277, 12, 6377, 304, 267, 286, 12107, 275, 359, 67, 14, 354, 367, 286, 315, 6377, 61, 267, 286, 12107, 14, 3191, 342, 267, 372, 286, 12107, 339, 347, 511, 614, 63, 826, 8, 277, 304, 267, 298, 774, 11097, 402, 6033, 1709, 2122, 267, 291, 14, 629, 8, 25, 12, 23150, 30121, 17024, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 25, 12, 23150, 30121, 17024, 38, 84, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 845, 12, 437, 22306, 17024, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 20, 12, 23150, 30121, 8674, 600, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 20, 12, 445, 8764, 527, 8674, 600, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 17, 12, 6551, 929, 14, 1462, 14, 835, 1012, 267, 291, 14, 629, 8, 17, 12, 23150, 30121, 2620, 929, 14, 1462, 14, 835, 1012, 339, 768, 889, 63, 25873, 272, 347, 511, 996, 63, 68, 12541, 8, 277, 304, 267, 298, 9029, 314, 658, 68, 12541, 64, 4237, 730, 2122, 267, 327, 21892, 83, 1553, 1006, 1077, 506, 4472, 334, 2590, 367, 314, 267, 327, 13666, 15, 10011, 4092, 315, 10576, 63, 18207, 12, 626, 1159, 30362, 267, 327, 19917, 680, 267, 4773, 63, 18552, 275, 3842, 23, 1493, 12, 499, 26163, 14, 2658, 395, 577, 8, 14595, 29, 23, 395, 577, 8, 2664, 29, 20, 14, 11991, 1874, 267, 10576, 63, 18552, 275, 3842, 16, 14, 21, 12, 4337, 1493, 395, 577, 8, 14595, 29, 708, 395, 577, 8, 2664, 29, 1167, 14, 16303, 1874, 398, 327, 13796, 286, 12107, 367, 437, 22306, 436, 20566, 305, 14, 267, 4773, 63, 18207, 275, 788, 36, 583, 343, 944, 869, 810, 17874, 297, 283, 30534, 2441, 10902, 418, 267, 10576, 63, 18207, 275, 788, 45, 390, 1450, 951, 297, 283, 8529, 8210, 66, 567, 297, 283, 2719, 723, 293, 348, 297, 283, 55, 393, 2809, 951, 418, 398, 327, 14795, 316, 6033, 9212, 641, 2877, 27294, 10021, 10460, 1373, 267, 327, 543, 6204, 315, 24808, 436, 314, 1163, 315, 6204, 402, 738, 14, 51, 14, 16576, 1964, 386, 14, 267, 367, 2917, 315, 4773, 63, 18552, 26, 288, 340, 1228, 8, 2686, 12, 2008, 304, 2917, 17, 12, 2917, 18, 275, 2917, 288, 587, 26, 2917, 17, 275, 2917, 18, 275, 2917, 288, 6377, 17, 275, 23150, 30121, 17024, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 270, 88, 63, 24519, 12, 2917, 17, 430, 288, 6377, 18, 275, 23150, 30121, 17024, 38, 84, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 270, 88, 63, 24519, 12, 2917, 18, 430, 288, 367, 6377, 315, 6377, 17, 12, 6377, 18, 26, 355, 291, 14, 629, 8, 2347, 63, 18207, 12, 291, 14, 362, 63, 1247, 8, 6177, 430, 398, 327, 7356, 19203, 314, 658, 68, 12541, 64, 9212, 641, 282, 2312, 32230, 10021, 2656, 14, 267, 367, 2917, 315, 10576, 63, 18552, 26, 288, 340, 1228, 8, 2686, 12, 577, 9, 436, 440, 28123, 26, 730, 63, 705, 275, 715, 288, 587, 26, 730, 63, 705, 275, 756, 953, 340, 1228, 8, 2686, 12, 2008, 304, 355, 340, 28123, 26, 2917, 275, 2917, 59, 17, 61, 355, 587, 26, 2917, 275, 2917, 59, 16, 61, 953, 327, 20507, 314, 1827, 663, 14, 288, 6377, 275, 437, 22306, 17024, 14, 1462, 14, 1648, 63, 991, 360, 354, 358, 288, 340, 730, 63, 705, 26, 355, 327, 437, 1722, 1077, 506, 4915, 641, 20929, 1380, 9936, 370, 986, 355, 327, 21892, 2251, 1901, 282, 577, 3007, 262, 1827, 1808, 282, 2312, 32230, 901, 14, 355, 291, 14, 1855, 8, 3393, 12, 437, 22306, 17024, 14, 1462, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277, 14, 3844, 63, 24519, 12, 2917, 4992, 835, 9, 288, 587, 26, 355, 291, 14, 629, 8, 3844, 63, 18207, 12, 291, 14, 362, 63, 1247, 8, 6177, 14, 1541, 8, 1403, 363, 68, 12541, 2687, 277,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
benpatterson/edx-platform
common/djangoapps/student/migrations/0003_auto__add_usertestgroup.py
188
8942
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'UserTestGroup' db.create_table('student_usertestgroup', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(max_length=32, db_index=True)), ('description', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal('student', ['UserTestGroup']) # Adding M2M table for field users on 'UserTestGroup' db.create_table('student_usertestgroup_users', ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('usertestgroup', models.ForeignKey(orm['student.usertestgroup'], null=False)), ('user', models.ForeignKey(orm['auth.user'], null=False)) )) db.create_unique('student_usertestgroup_users', ['usertestgroup_id', 'user_id']) def backwards(self, orm): # Deleting model 'UserTestGroup' db.delete_table('student_usertestgroup') # Removing M2M table for field users on 'UserTestGroup' db.delete_table('student_usertestgroup_users') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}), 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}), 'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}), 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), 'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}), 'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}), 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}), 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}), 'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'student.registration': { 'Meta': {'object_name': 'Registration', 'db_table': "'auth_registration'"}, 'activation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}) }, 'student.userprofile': { 'Meta': {'object_name': 'UserProfile', 'db_table': "'auth_userprofile'"}, 'courseware': ('django.db.models.fields.CharField', [], {'default': "'course.xml'", 'max_length': '255', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'location': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'meta': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}) }, 'student.usertestgroup': { 'Meta': {'object_name': 'UserTestGroup'}, 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 'users': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'db_index': 'True', 'symmetrical': 'False'}) } } complete_apps = ['student']
agpl-3.0
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 12934, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 5500, 297, 788, 1899, 774, 2448, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 751, 396, 923, 297, 1709, 14, 3190, 8, 1025, 459, 5500, 14, 751, 396, 923, 995, 2973, 29, 797, 1826, 288, 661, 751, 297, 1709, 14, 3190, 8, 1025, 459, 1178, 14, 751, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 788, 751, 396, 923, 63, 344, 297, 283, 751, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 15920, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 10254, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 14584, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 78, 4662, 283, 988, 63, 1267, 356, 283, 17, 1604, 288, 283, 66, 2641, 806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 388, 19068, 63, 4899, 63, 5427, 63, 835, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 6063, 356, 661, 1176, 63, 23598, 14, 955, 14, 17393, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 602, 63, 1618, 63, 10907, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2918, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2123, 63, 374, 1078, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2123, 63, 498, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 2123, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 17, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 23628, 356, 661, 1176 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 398, 327, 12934, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 708, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 1802, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2500, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 5500, 297, 788, 1899, 774, 2448, 1105, 398, 327, 12934, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 981, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 334, 288, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 5062, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 1826, 288, 661, 751, 396, 923, 297, 1709, 14, 3190, 8, 1025, 459, 5500, 14, 751, 396, 923, 995, 2973, 29, 797, 1826, 288, 661, 751, 297, 1709, 14, 3190, 8, 1025, 459, 1178, 14, 751, 995, 2973, 29, 797, 430, 267, 5082, 267, 1592, 14, 981, 63, 3235, 360, 5500, 63, 751, 396, 923, 63, 3707, 297, 788, 751, 396, 923, 63, 344, 297, 283, 751, 63, 344, 1105, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 15920, 1402, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 358, 398, 327, 29343, 603, 18, 45, 1817, 367, 901, 4390, 641, 283, 1899, 774, 2448, 7, 267, 1592, 14, 1807, 63, 1224, 360, 5500, 63, 751, 396, 923, 63, 3707, 358, 339, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 10254, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 791, 2500, 356, 283, 549, 1604, 288, 283, 14584, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 3546, 78, 4662, 283, 988, 63, 1267, 356, 283, 17, 1604, 288, 283, 66, 2641, 806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 388, 19068, 63, 4899, 63, 5427, 63, 835, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 3901, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 6063, 356, 661, 1176, 63, 23598, 14, 955, 14, 17393, 792, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 602, 63, 1618, 63, 10907, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14071, 297, 990, 791, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2918, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 16, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2123, 63, 374, 1078, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2123, 63, 498, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 2123, 63, 1450, 63, 1541, 63, 8590, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 14640, 297, 990, 791, 885, 356, 283, 17, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 23628, 356,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 1, 1, 1, 1, 1 ]
drufat/sympy
sympy/functions/special/tests/test_bessel.py
36
22192
from itertools import product from sympy import (jn, yn, symbols, Symbol, sin, cos, pi, S, jn_zeros, besselj, bessely, besseli, besselk, hankel1, hankel2, hn1, hn2, expand_func, sqrt, sinh, cosh, diff, series, gamma, hyper, Abs, I, O, oo, conjugate) from sympy.functions.special.bessel import fn from sympy.functions.special.bessel import (airyai, airybi, airyaiprime, airybiprime) from sympy.utilities.randtest import (random_complex_number as randcplx, verify_numerically as tn, test_derivative_numerically as td, _randint) from sympy.utilities.pytest import raises from sympy.abc import z, n, k, x randint = _randint() def test_bessel_rand(): for f in [besselj, bessely, besseli, besselk, hankel1, hankel2]: assert td(f(randcplx(), z), z) for f in [jn, yn, hn1, hn2]: assert td(f(randint(-10, 10), z), z) def test_bessel_twoinputs(): for f in [besselj, bessely, besseli, besselk, hankel1, hankel2, jn, yn]: raises(TypeError, lambda: f(1)) raises(TypeError, lambda: f(1, 2, 3)) def test_diff(): assert besselj(n, z).diff(z) == besselj(n - 1, z)/2 - besselj(n + 1, z)/2 assert bessely(n, z).diff(z) == bessely(n - 1, z)/2 - bessely(n + 1, z)/2 assert besseli(n, z).diff(z) == besseli(n - 1, z)/2 + besseli(n + 1, z)/2 assert besselk(n, z).diff(z) == -besselk(n - 1, z)/2 - besselk(n + 1, z)/2 assert hankel1(n, z).diff(z) == hankel1(n - 1, z)/2 - hankel1(n + 1, z)/2 assert hankel2(n, z).diff(z) == hankel2(n - 1, z)/2 - hankel2(n + 1, z)/2 def test_rewrite(): from sympy import polar_lift, exp, I assert besselj(n, z).rewrite(jn) == sqrt(2*z/pi)*jn(n - S(1)/2, z) assert bessely(n, z).rewrite(yn) == sqrt(2*z/pi)*yn(n - S(1)/2, z) assert besseli(n, z).rewrite(besselj) == \ exp(-I*n*pi/2)*besselj(n, polar_lift(I)*z) assert besselj(n, z).rewrite(besseli) == \ exp(I*n*pi/2)*besseli(n, polar_lift(-I)*z) nu = randcplx() assert tn(besselj(nu, z), besselj(nu, z).rewrite(besseli), z) assert tn(besselj(nu, z), besselj(nu, z).rewrite(bessely), z) assert tn(besseli(nu, z), besseli(nu, z).rewrite(besselj), z) assert tn(besseli(nu, z), besseli(nu, z).rewrite(bessely), z) assert tn(bessely(nu, z), bessely(nu, z).rewrite(besselj), z) assert tn(bessely(nu, z), bessely(nu, z).rewrite(besseli), z) assert tn(besselk(nu, z), besselk(nu, z).rewrite(besselj), z) assert tn(besselk(nu, z), besselk(nu, z).rewrite(besseli), z) assert tn(besselk(nu, z), besselk(nu, z).rewrite(bessely), z) # check that a rewrite was triggered, when the order is set to a generic # symbol 'nu' assert yn(nu, z) != yn(nu, z).rewrite(jn) assert hn1(nu, z) != hn1(nu, z).rewrite(jn) assert hn2(nu, z) != hn2(nu, z).rewrite(jn) assert jn(nu, z) != jn(nu, z).rewrite(yn) assert hn1(nu, z) != hn1(nu, z).rewrite(yn) assert hn2(nu, z) != hn2(nu, z).rewrite(yn) # rewriting spherical bessel functions (SBFs) w.r.t. besselj, bessely is # not allowed if a generic symbol 'nu' is used as the order of the SBFs # to avoid inconsistencies (the order of bessel[jy] is allowed to be # complex-valued, whereas SBFs are defined only for integer orders) order = nu for f in (besselj, bessely): assert yn(order, z) == yn(order, z).rewrite(f) assert jn(order, z) == jn(order, z).rewrite(f) assert hn1(order, z) == hn1(order, z).rewrite(f) assert hn2(order, z) == hn2(order, z).rewrite(f) # for integral orders rewriting SBFs w.r.t bessel[jy] is allowed N = Symbol('n', integer=True) ri = randint(-11, 10) for order in (ri, N): for f in (besselj, bessely): assert yn(order, z) != yn(order, z).rewrite(f) assert jn(order, z) != jn(order, z).rewrite(f) assert hn1(order, z) != hn1(order, z).rewrite(f) assert hn2(order, z) != hn2(order, z).rewrite(f) for func, refunc in product((yn, jn, hn1, hn2), (jn, yn, besselj, bessely)): assert tn(func(ri, z), func(ri, z).rewrite(refunc), z) def test_expand(): from sympy import besselsimp, Symbol, exp, exp_polar, I assert expand_func(besselj(S(1)/2, z).rewrite(jn)) == \ sqrt(2)*sin(z)/(sqrt(pi)*sqrt(z)) assert expand_func(bessely(S(1)/2, z).rewrite(yn)) == \ -sqrt(2)*cos(z)/(sqrt(pi)*sqrt(z)) # XXX: teach sin/cos to work around arguments like # x*exp_polar(I*pi*n/2). Then change besselsimp -> expand_func assert besselsimp(besselj(S(1)/2, z)) == sqrt(2)*sin(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(besselj(S(-1)/2, z)) == sqrt(2)*cos(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(besselj(S(5)/2, z)) == \ -sqrt(2)*(z**2*sin(z) + 3*z*cos(z) - 3*sin(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(besselj(-S(5)/2, z)) == \ -sqrt(2)*(z**2*cos(z) - 3*z*sin(z) - 3*cos(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(bessely(S(1)/2, z)) == \ -(sqrt(2)*cos(z))/(sqrt(pi)*sqrt(z)) assert besselsimp(bessely(S(-1)/2, z)) == sqrt(2)*sin(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(bessely(S(5)/2, z)) == \ sqrt(2)*(z**2*cos(z) - 3*z*sin(z) - 3*cos(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(bessely(S(-5)/2, z)) == \ -sqrt(2)*(z**2*sin(z) + 3*z*cos(z) - 3*sin(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(besseli(S(1)/2, z)) == sqrt(2)*sinh(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(besseli(S(-1)/2, z)) == \ sqrt(2)*cosh(z)/(sqrt(pi)*sqrt(z)) assert besselsimp(besseli(S(5)/2, z)) == \ sqrt(2)*(z**2*sinh(z) - 3*z*cosh(z) + 3*sinh(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(besseli(S(-5)/2, z)) == \ sqrt(2)*(z**2*cosh(z) - 3*z*sinh(z) + 3*cosh(z))/(sqrt(pi)*z**(S(5)/2)) assert besselsimp(besselk(S(1)/2, z)) == \ besselsimp(besselk(S(-1)/2, z)) == sqrt(pi)*exp(-z)/(sqrt(2)*sqrt(z)) assert besselsimp(besselk(S(5)/2, z)) == \ besselsimp(besselk(S(-5)/2, z)) == \ sqrt(2)*sqrt(pi)*(z**2 + 3*z + 3)*exp(-z)/(2*z**(S(5)/2)) def check(eq, ans): return tn(eq, ans) and eq == ans rn = randcplx(a=1, b=0, d=0, c=2) for besselx in [besselj, bessely, besseli, besselk]: ri = S(2*randint(-11, 10) + 1) / 2 # half integer in [-21/2, 21/2] assert tn(besselsimp(besselx(ri, z)), besselx(ri, z)) assert check(expand_func(besseli(rn, x)), besseli(rn - 2, x) - 2*(rn - 1)*besseli(rn - 1, x)/x) assert check(expand_func(besseli(-rn, x)), besseli(-rn + 2, x) + 2*(-rn + 1)*besseli(-rn + 1, x)/x) assert check(expand_func(besselj(rn, x)), -besselj(rn - 2, x) + 2*(rn - 1)*besselj(rn - 1, x)/x) assert check(expand_func(besselj(-rn, x)), -besselj(-rn + 2, x) + 2*(-rn + 1)*besselj(-rn + 1, x)/x) assert check(expand_func(besselk(rn, x)), besselk(rn - 2, x) + 2*(rn - 1)*besselk(rn - 1, x)/x) assert check(expand_func(besselk(-rn, x)), besselk(-rn + 2, x) - 2*(-rn + 1)*besselk(-rn + 1, x)/x) assert check(expand_func(bessely(rn, x)), -bessely(rn - 2, x) + 2*(rn - 1)*bessely(rn - 1, x)/x) assert check(expand_func(bessely(-rn, x)), -bessely(-rn + 2, x) + 2*(-rn + 1)*bessely(-rn + 1, x)/x) n = Symbol('n', integer=True, positive=True) assert expand_func(besseli(n + 2, z)) == \ besseli(n, z) + (-2*n - 2)*(-2*n*besseli(n, z)/z + besseli(n - 1, z))/z assert expand_func(besselj(n + 2, z)) == \ -besselj(n, z) + (2*n + 2)*(2*n*besselj(n, z)/z - besselj(n - 1, z))/z assert expand_func(besselk(n + 2, z)) == \ besselk(n, z) + (2*n + 2)*(2*n*besselk(n, z)/z + besselk(n - 1, z))/z assert expand_func(bessely(n + 2, z)) == \ -bessely(n, z) + (2*n + 2)*(2*n*bessely(n, z)/z - bessely(n - 1, z))/z assert expand_func(besseli(n + S(1)/2, z).rewrite(jn)) == \ (sqrt(2)*sqrt(z)*exp(-I*pi*(n + S(1)/2)/2) * exp_polar(I*pi/4)*jn(n, z*exp_polar(I*pi/2))/sqrt(pi)) assert expand_func(besselj(n + S(1)/2, z).rewrite(jn)) == \ sqrt(2)*sqrt(z)*jn(n, z)/sqrt(pi) r = Symbol('r', real=True) p = Symbol('p', positive=True) i = Symbol('i', integer=True) for besselx in [besselj, bessely, besseli, besselk]: assert besselx(i, p).is_real assert besselx(i, x).is_real is None assert besselx(x, z).is_real is None for besselx in [besselj, besseli]: assert besselx(i, r).is_real for besselx in [bessely, besselk]: assert besselx(i, r).is_real is None def test_fn(): x, z = symbols("x z") assert fn(1, z) == 1/z**2 assert fn(2, z) == -1/z + 3/z**3 assert fn(3, z) == -6/z**2 + 15/z**4 assert fn(4, z) == 1/z - 45/z**3 + 105/z**5 def mjn(n, z): return expand_func(jn(n, z)) def myn(n, z): return expand_func(yn(n, z)) def test_jn(): z = symbols("z") assert mjn(0, z) == sin(z)/z assert mjn(1, z) == sin(z)/z**2 - cos(z)/z assert mjn(2, z) == (3/z**3 - 1/z)*sin(z) - (3/z**2) * cos(z) assert mjn(3, z) == (15/z**4 - 6/z**2)*sin(z) + (1/z - 15/z**3)*cos(z) assert mjn(4, z) == (1/z + 105/z**5 - 45/z**3)*sin(z) + \ (-105/z**4 + 10/z**2)*cos(z) assert mjn(5, z) == (945/z**6 - 420/z**4 + 15/z**2)*sin(z) + \ (-1/z - 945/z**5 + 105/z**3)*cos(z) assert mjn(6, z) == (-1/z + 10395/z**7 - 4725/z**5 + 210/z**3)*sin(z) + \ (-10395/z**6 + 1260/z**4 - 21/z**2)*cos(z) assert expand_func(jn(n, z)) == jn(n, z) # SBFs not defined for complex-valued orders assert jn(2+3j, 5.2+0.3j).evalf() == jn(2+3j, 5.2+0.3j) assert eq([jn(2, 5.2+0.3j).evalf(10)], [0.09941975672 - 0.05452508024*I]) def test_yn(): z = symbols("z") assert myn(0, z) == -cos(z)/z assert myn(1, z) == -cos(z)/z**2 - sin(z)/z assert myn(2, z) == -((3/z**3 - 1/z)*cos(z) + (3/z**2)*sin(z)) assert expand_func(yn(n, z)) == yn(n, z) # SBFs not defined for complex-valued orders assert yn(2+3j, 5.2+0.3j).evalf() == yn(2+3j, 5.2+0.3j) assert eq([yn(2, 5.2+0.3j).evalf(10)], [0.185250342 + 0.01489557397*I]) def test_sympify_yn(): assert S(15) in myn(3, pi).atoms() assert myn(3, pi) == 15/pi**4 - 6/pi**2 def eq(a, b, tol=1e-6): for x, y in zip(a, b): if not (abs(x - y) < tol): return False return True def test_jn_zeros(): assert eq(jn_zeros(0, 4), [3.141592, 6.283185, 9.424777, 12.566370]) assert eq(jn_zeros(1, 4), [4.493409, 7.725251, 10.904121, 14.066193]) assert eq(jn_zeros(2, 4), [5.763459, 9.095011, 12.322940, 15.514603]) assert eq(jn_zeros(3, 4), [6.987932, 10.417118, 13.698023, 16.923621]) assert eq(jn_zeros(4, 4), [8.182561, 11.704907, 15.039664, 18.301255]) def test_bessel_eval(): from sympy import I, Symbol n, m, k = Symbol('n', integer=True), Symbol('m'), Symbol('k', integer=True, zero=False) for f in [besselj, besseli]: assert f(0, 0) == S.One assert f(2.1, 0) == S.Zero assert f(-3, 0) == S.Zero assert f(-10.2, 0) == S.ComplexInfinity assert f(1 + 3*I, 0) == S.Zero assert f(-3 + I, 0) == S.ComplexInfinity assert f(-2*I, 0) == S.NaN assert f(n, 0) != S.One and f(n, 0) != S.Zero assert f(m, 0) != S.One and f(m, 0) != S.Zero assert f(k, 0) == S.Zero assert bessely(0, 0) == S.NegativeInfinity assert besselk(0, 0) == S.Infinity for f in [bessely, besselk]: assert f(1 + I, 0) == S.ComplexInfinity assert f(I, 0) == S.NaN for f in [besselj, bessely]: assert f(m, S.Infinity) == S.Zero assert f(m, S.NegativeInfinity) == S.Zero for f in [besseli, besselk]: assert f(m, I*S.Infinity) == S.Zero assert f(m, I*S.NegativeInfinity) == S.Zero for f in [besseli, besselk]: assert f(-4, z) == f(4, z) assert f(-3, z) == f(3, z) assert f(-n, z) == f(n, z) assert f(-m, z) != f(m, z) for f in [besselj, bessely]: assert f(-4, z) == f(4, z) assert f(-3, z) == -f(3, z) assert f(-n, z) == (-1)**n*f(n, z) assert f(-m, z) != (-1)**m*f(m, z) for f in [besselj, besseli]: assert f(m, -z) == (-z)**m*z**(-m)*f(m, z) assert besseli(2, -z) == besseli(2, z) assert besseli(3, -z) == -besseli(3, z) assert besselj(0, -z) == besselj(0, z) assert besselj(1, -z) == -besselj(1, z) assert besseli(0, I*z) == besselj(0, z) assert besseli(1, I*z) == I*besselj(1, z) assert besselj(3, I*z) == -I*besseli(3, z) def test_bessel_nan(): # FIXME: could have these return NaN; for now just fix infinite recursion for f in [besselj, bessely, besseli, besselk, hankel1, hankel2, yn, jn]: assert f(1, S.NaN) == f(1, S.NaN, evaluate=False) def test_conjugate(): from sympy import conjugate, I, Symbol n, z, x = Symbol('n'), Symbol('z', real=False), Symbol('x', real=True) y, t = Symbol('y', real=True, positive=True), Symbol('t', negative=True) for f in [besseli, besselj, besselk, bessely, hankel1, hankel2]: assert f(n, -1).conjugate() != f(conjugate(n), -1) assert f(n, x).conjugate() != f(conjugate(n), x) assert f(n, t).conjugate() != f(conjugate(n), t) rz = randcplx(b=0.5) for f in [besseli, besselj, besselk, bessely]: assert f(n, 1 + I).conjugate() == f(conjugate(n), 1 - I) assert f(n, 0).conjugate() == f(conjugate(n), 0) assert f(n, 1).conjugate() == f(conjugate(n), 1) assert f(n, z).conjugate() == f(conjugate(n), conjugate(z)) assert f(n, y).conjugate() == f(conjugate(n), y) assert tn(f(n, rz).conjugate(), f(conjugate(n), conjugate(rz))) assert hankel1(n, 1 + I).conjugate() == hankel2(conjugate(n), 1 - I) assert hankel1(n, 0).conjugate() == hankel2(conjugate(n), 0) assert hankel1(n, 1).conjugate() == hankel2(conjugate(n), 1) assert hankel1(n, y).conjugate() == hankel2(conjugate(n), y) assert hankel1(n, z).conjugate() == hankel2(conjugate(n), conjugate(z)) assert tn(hankel1(n, rz).conjugate(), hankel2(conjugate(n), conjugate(rz))) assert hankel2(n, 1 + I).conjugate() == hankel1(conjugate(n), 1 - I) assert hankel2(n, 0).conjugate() == hankel1(conjugate(n), 0) assert hankel2(n, 1).conjugate() == hankel1(conjugate(n), 1) assert hankel2(n, y).conjugate() == hankel1(conjugate(n), y) assert hankel2(n, z).conjugate() == hankel1(conjugate(n), conjugate(z)) assert tn(hankel2(n, rz).conjugate(), hankel1(conjugate(n), conjugate(rz))) def test_branching(): from sympy import exp_polar, polar_lift, Symbol, I, exp assert besselj(polar_lift(k), x) == besselj(k, x) assert besseli(polar_lift(k), x) == besseli(k, x) n = Symbol('n', integer=True) assert besselj(n, exp_polar(2*pi*I)*x) == besselj(n, x) assert besselj(n, polar_lift(x)) == besselj(n, x) assert besseli(n, exp_polar(2*pi*I)*x) == besseli(n, x) assert besseli(n, polar_lift(x)) == besseli(n, x) def tn(func, s): from random import uniform c = uniform(1, 5) expr = func(s, c*exp_polar(I*pi)) - func(s, c*exp_polar(-I*pi)) eps = 1e-15 expr2 = func(s + eps, -c + eps*I) - func(s + eps, -c - eps*I) return abs(expr.n() - expr2.n()).n() < 1e-10 nu = Symbol('nu') assert besselj(nu, exp_polar(2*pi*I)*x) == exp(2*pi*I*nu)*besselj(nu, x) assert besseli(nu, exp_polar(2*pi*I)*x) == exp(2*pi*I*nu)*besseli(nu, x) assert tn(besselj, 2) assert tn(besselj, pi) assert tn(besselj, I) assert tn(besseli, 2) assert tn(besseli, pi) assert tn(besseli, I) def test_airy_base(): z = Symbol('z') x = Symbol('x', real=True) y = Symbol('y', real=True) assert conjugate(airyai(z)) == airyai(conjugate(z)) assert airyai(x).is_real assert airyai(x+I*y).as_real_imag() == ( airyai(x - I*x*Abs(y)/Abs(x))/2 + airyai(x + I*x*Abs(y)/Abs(x))/2, I*x*(airyai(x - I*x*Abs(y)/Abs(x)) - airyai(x + I*x*Abs(y)/Abs(x)))*Abs(y)/(2*y*Abs(x))) def test_airyai(): z = Symbol('z', real=False) t = Symbol('t', negative=True) p = Symbol('p', positive=True) assert isinstance(airyai(z), airyai) assert airyai(0) == 3**(S(1)/3)/(3*gamma(S(2)/3)) assert airyai(oo) == 0 assert airyai(-oo) == 0 assert diff(airyai(z), z) == airyaiprime(z) assert series(airyai(z), z, 0, 3) == ( 3**(S(5)/6)*gamma(S(1)/3)/(6*pi) - 3**(S(1)/6)*z*gamma(S(2)/3)/(2*pi) + O(z**3)) assert airyai(z).rewrite(hyper) == ( -3**(S(2)/3)*z*hyper((), (S(4)/3,), z**S(3)/9)/(3*gamma(S(1)/3)) + 3**(S(1)/3)*hyper((), (S(2)/3,), z**S(3)/9)/(3*gamma(S(2)/3))) assert isinstance(airyai(z).rewrite(besselj), airyai) assert airyai(t).rewrite(besselj) == ( sqrt(-t)*(besselj(-S(1)/3, 2*(-t)**(S(3)/2)/3) + besselj(S(1)/3, 2*(-t)**(S(3)/2)/3))/3) assert airyai(z).rewrite(besseli) == ( -z*besseli(S(1)/3, 2*z**(S(3)/2)/3)/(3*(z**(S(3)/2))**(S(1)/3)) + (z**(S(3)/2))**(S(1)/3)*besseli(-S(1)/3, 2*z**(S(3)/2)/3)/3) assert airyai(p).rewrite(besseli) == ( sqrt(p)*(besseli(-S(1)/3, 2*p**(S(3)/2)/3) - besseli(S(1)/3, 2*p**(S(3)/2)/3))/3) assert expand_func(airyai(2*(3*z**5)**(S(1)/3))) == ( -sqrt(3)*(-1 + (z**5)**(S(1)/3)/z**(S(5)/3))*airybi(2*3**(S(1)/3)*z**(S(5)/3))/6 + (1 + (z**5)**(S(1)/3)/z**(S(5)/3))*airyai(2*3**(S(1)/3)*z**(S(5)/3))/2) def test_airybi(): z = Symbol('z', real=False) t = Symbol('t', negative=True) p = Symbol('p', positive=True) assert isinstance(airybi(z), airybi) assert airybi(0) == 3**(S(5)/6)/(3*gamma(S(2)/3)) assert airybi(oo) == oo assert airybi(-oo) == 0 assert diff(airybi(z), z) == airybiprime(z) assert series(airybi(z), z, 0, 3) == ( 3**(S(1)/3)*gamma(S(1)/3)/(2*pi) + 3**(S(2)/3)*z*gamma(S(2)/3)/(2*pi) + O(z**3)) assert airybi(z).rewrite(hyper) == ( 3**(S(1)/6)*z*hyper((), (S(4)/3,), z**S(3)/9)/gamma(S(1)/3) + 3**(S(5)/6)*hyper((), (S(2)/3,), z**S(3)/9)/(3*gamma(S(2)/3))) assert isinstance(airybi(z).rewrite(besselj), airybi) assert airyai(t).rewrite(besselj) == ( sqrt(-t)*(besselj(-S(1)/3, 2*(-t)**(S(3)/2)/3) + besselj(S(1)/3, 2*(-t)**(S(3)/2)/3))/3) assert airybi(z).rewrite(besseli) == ( sqrt(3)*(z*besseli(S(1)/3, 2*z**(S(3)/2)/3)/(z**(S(3)/2))**(S(1)/3) + (z**(S(3)/2))**(S(1)/3)*besseli(-S(1)/3, 2*z**(S(3)/2)/3))/3) assert airybi(p).rewrite(besseli) == ( sqrt(3)*sqrt(p)*(besseli(-S(1)/3, 2*p**(S(3)/2)/3) + besseli(S(1)/3, 2*p**(S(3)/2)/3))/3) assert expand_func(airybi(2*(3*z**5)**(S(1)/3))) == ( sqrt(3)*(1 - (z**5)**(S(1)/3)/z**(S(5)/3))*airyai(2*3**(S(1)/3)*z**(S(5)/3))/2 + (1 + (z**5)**(S(1)/3)/z**(S(5)/3))*airybi(2*3**(S(1)/3)*z**(S(5)/3))/2) def test_airyaiprime(): z = Symbol('z', real=False) t = Symbol('t', negative=True) p = Symbol('p', positive=True) assert isinstance(airyaiprime(z), airyaiprime) assert airyaiprime(0) == -3**(S(2)/3)/(3*gamma(S(1)/3)) assert airyaiprime(oo) == 0 assert diff(airyaiprime(z), z) == z*airyai(z) assert series(airyaiprime(z), z, 0, 3) == ( -3**(S(2)/3)/(3*gamma(S(1)/3)) + 3**(S(1)/3)*z**2/(6*gamma(S(2)/3)) + O(z**3)) assert airyaiprime(z).rewrite(hyper) == ( 3**(S(1)/3)*z**2*hyper((), (S(5)/3,), z**S(3)/9)/(6*gamma(S(2)/3)) - 3**(S(2)/3)*hyper((), (S(1)/3,), z**S(3)/9)/(3*gamma(S(1)/3))) assert isinstance(airyaiprime(z).rewrite(besselj), airyaiprime) assert airyai(t).rewrite(besselj) == ( sqrt(-t)*(besselj(-S(1)/3, 2*(-t)**(S(3)/2)/3) + besselj(S(1)/3, 2*(-t)**(S(3)/2)/3))/3) assert airyaiprime(z).rewrite(besseli) == ( z**2*besseli(S(2)/3, 2*z**(S(3)/2)/3)/(3*(z**(S(3)/2))**(S(2)/3)) - (z**(S(3)/2))**(S(2)/3)*besseli(-S(1)/3, 2*z**(S(3)/2)/3)/3) assert airyaiprime(p).rewrite(besseli) == ( p*(-besseli(-S(2)/3, 2*p**(S(3)/2)/3) + besseli(S(2)/3, 2*p**(S(3)/2)/3))/3) assert expand_func(airyaiprime(2*(3*z**5)**(S(1)/3))) == ( sqrt(3)*(z**(S(5)/3)/(z**5)**(S(1)/3) - 1)*airybiprime(2*3**(S(1)/3)*z**(S(5)/3))/6 + (z**(S(5)/3)/(z**5)**(S(1)/3) + 1)*airyaiprime(2*3**(S(1)/3)*z**(S(5)/3))/2) def test_airybiprime(): z = Symbol('z', real=False) t = Symbol('t', negative=True) p = Symbol('p', positive=True) assert isinstance(airybiprime(z), airybiprime) assert airybiprime(0) == 3**(S(1)/6)/gamma(S(1)/3) assert airybiprime(oo) == oo assert airybiprime(-oo) == 0 assert diff(airybiprime(z), z) == z*airybi(z) assert series(airybiprime(z), z, 0, 3) == ( 3**(S(1)/6)/gamma(S(1)/3) + 3**(S(5)/6)*z**2/(6*gamma(S(2)/3)) + O(z**3)) assert airybiprime(z).rewrite(hyper) == ( 3**(S(5)/6)*z**2*hyper((), (S(5)/3,), z**S(3)/9)/(6*gamma(S(2)/3)) + 3**(S(1)/6)*hyper((), (S(1)/3,), z**S(3)/9)/gamma(S(1)/3)) assert isinstance(airybiprime(z).rewrite(besselj), airybiprime) assert airyai(t).rewrite(besselj) == ( sqrt(-t)*(besselj(-S(1)/3, 2*(-t)**(S(3)/2)/3) + besselj(S(1)/3, 2*(-t)**(S(3)/2)/3))/3) assert airybiprime(z).rewrite(besseli) == ( sqrt(3)*(z**2*besseli(S(2)/3, 2*z**(S(3)/2)/3)/(z**(S(3)/2))**(S(2)/3) + (z**(S(3)/2))**(S(2)/3)*besseli(-S(2)/3, 2*z**(S(3)/2)/3))/3) assert airybiprime(p).rewrite(besseli) == ( sqrt(3)*p*(besseli(-S(2)/3, 2*p**(S(3)/2)/3) + besseli(S(2)/3, 2*p**(S(3)/2)/3))/3) assert expand_func(airybiprime(2*(3*z**5)**(S(1)/3))) == ( sqrt(3)*(z**(S(5)/3)/(z**5)**(S(1)/3) - 1)*airyaiprime(2*3**(S(1)/3)*z**(S(5)/3))/2 + (z**(S(5)/3)/(z**5)**(S(1)/3) + 1)*airybiprime(2*3**(S(1)/3)*z**(S(5)/3))/2)
bsd-3-clause
[ 504, 7975, 492, 3336, 199, 199, 504, 5840, 492, 334, 24016, 12, 612, 78, 12, 6698, 12, 10080, 12, 9829, 12, 9794, 12, 6682, 12, 428, 12, 1335, 78, 63, 4250, 12, 330, 28817, 74, 12, 673, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 12, 394, 78, 17, 12, 394, 78, 18, 12, 673, 6544, 63, 1532, 12, 7452, 12, 9829, 72, 12, 512, 609, 12, 3915, 12, 6779, 12, 10169, 12, 10342, 12, 673, 20319, 12, 473, 12, 593, 12, 16390, 12, 27246, 9, 199, 504, 5840, 14, 5777, 14, 6664, 14, 11562, 5891, 492, 4325, 199, 504, 5840, 14, 5777, 14, 6664, 14, 11562, 5891, 492, 334, 5789, 651, 5789, 12, 15933, 651, 4492, 12, 4490, 15933, 651, 65, 711, 322, 278, 12, 15933, 651, 27566, 322, 278, 9, 199, 504, 5840, 14, 16355, 14, 3759, 396, 492, 334, 2355, 63, 5254, 63, 1955, 465, 10261, 67, 1168, 88, 12, 4228, 4911, 63, 6677, 1183, 465, 22762, 12, 4228, 511, 63, 26851, 63, 6677, 1183, 465, 12749, 12, 4228, 485, 8393, 9, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 504, 5840, 14, 3175, 492, 1315, 12, 302, 12, 1022, 12, 671, 199, 199, 8393, 275, 485, 8393, 342, 421, 199, 318, 511, 63, 11562, 5891, 63, 3759, 837, 272, 367, 289, 315, 359, 11562, 5891, 74, 12, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 2189, 267, 702, 12749, 8, 70, 8, 3759, 67, 1168, 88, 1062, 1315, 395, 1315, 9, 339, 367, 289, 315, 359, 24016, 12, 612, 78, 12, 394, 78, 17, 12, 394, 78, 18, 2189, 267, 702, 12749, 8, 70, 8, 8393, 2801, 709, 12, 1616, 395, 1315, 395, 1315, 9, 421, 199, 318, 511, 63, 11562, 5891, 63, 5601, 3711, 837, 272, 367, 289, 315, 359, 11562, 5891, 74, 12, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 12, 1335, 78, 12, 612, 78, 2189, 267, 6534, 8, 4333, 12, 2400, 26, 289, 8, 17, 430, 267, 6534, 8, 4333, 12, 2400, 26, 289, 8, 17, 12, 499, 12, 650, 430, 421, 199, 318, 511, 63, 3028, 837, 272, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 28817, 74, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 28817, 74, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 397, 261, 590, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 397, 261, 590, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 397, 261, 590, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 397, 261, 317, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 397, 261, 317, 8, 78, 446, 413, 12, 1315, 2447, 18, 435, 330, 397, 261, 317, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 28817, 75, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 446, 11562, 5891, 75, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 28817, 75, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 394, 3580, 352, 17, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 394, 3580, 352, 17, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 394, 3580, 352, 17, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 394, 3580, 352, 18, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 394, 3580, 352, 18, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 394, 3580, 352, 18, 8, 78, 435, 413, 12, 1315, 2447, 18, 421, 199, 318, 511, 63, 14366, 837, 272, 687, 5840, 492, 29167, 63, 30133, 12, 1437, 12, 473, 339, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 14366, 8, 24016, 9, 508, 7452, 8, 18, 10, 90, 15, 1038, 3342, 24016, 8, 78, 446, 428, 8, 17, 2447, 18, 12, 1315, 9, 272, 702, 330, 397, 261, 590, 8, 78, 12, 1315, 680, 14366, 8, 1236, 9, 508, 7452, 8, 18, 10, 90, 15, 1038, 3342, 1236, 8, 78, 446, 428, 8, 17, 2447, 18, 12, 1315, 9, 272, 702, 330, 397, 261, 317, 8, 78, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 9, 508, 971, 267, 1437, 2801, 41, 10, 78, 10, 1038, 15, 18, 3342, 11562, 5891, 74, 8, 78, 12, 29167, 63, 30133, 8, 41, 3342, 90, 9, 272, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 14366, 8, 11562, 261, 317, 9, 508, 971, 267, 1437, 8, 41, 10, 78, 10, 1038, 15, 18, 3342, 11562, 261, 317, 8, 78, 12, 29167, 63, 30133, 2801, 41, 3342, 90, 9, 339, 15699, 275, 10261, 67, 1168, 88, 342, 339, 702, 22762, 8, 11562, 5891, 74, 8, 4850, 12, 1315, 395, 330, 28817, 74, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 317, 395, 1315, 9, 272, 702, 22762, 8, 11562, 5891, 74, 8, 4850, 12, 1315, 395, 330, 28817, 74, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 590, 395, 1315, 9, 339, 702, 22762, 8, 11562, 261, 317, 8, 4850, 12, 1315, 395, 330, 397, 261, 317, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 395, 1315, 9, 272, 702, 22762, 8, 11562, 261, 317, 8, 4850, 12, 1315, 395, 330, 397, 261, 317, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 590, 395, 1315, 9, 339, 702, 22762, 8, 11562, 261, 590, 8, 4850, 12, 1315, 395, 330, 397, 261, 590, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 395, 1315, 9, 272, 702, 22762, 8, 11562, 261, 590, 8, 4850, 12, 1315, 395, 330, 397, 261, 590, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 317, 395, 1315, 9, 339, 702, 22762, 8, 11562, 5891, 75, 8, 4850, 12, 1315, 395, 330, 28817, 75, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 395, 1315, 9, 272, 702, 22762, 8 ]
[ 7975, 492, 3336, 199, 199, 504, 5840, 492, 334, 24016, 12, 612, 78, 12, 6698, 12, 10080, 12, 9829, 12, 9794, 12, 6682, 12, 428, 12, 1335, 78, 63, 4250, 12, 330, 28817, 74, 12, 673, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 12, 394, 78, 17, 12, 394, 78, 18, 12, 673, 6544, 63, 1532, 12, 7452, 12, 9829, 72, 12, 512, 609, 12, 3915, 12, 6779, 12, 10169, 12, 10342, 12, 673, 20319, 12, 473, 12, 593, 12, 16390, 12, 27246, 9, 199, 504, 5840, 14, 5777, 14, 6664, 14, 11562, 5891, 492, 4325, 199, 504, 5840, 14, 5777, 14, 6664, 14, 11562, 5891, 492, 334, 5789, 651, 5789, 12, 15933, 651, 4492, 12, 4490, 15933, 651, 65, 711, 322, 278, 12, 15933, 651, 27566, 322, 278, 9, 199, 504, 5840, 14, 16355, 14, 3759, 396, 492, 334, 2355, 63, 5254, 63, 1955, 465, 10261, 67, 1168, 88, 12, 4228, 4911, 63, 6677, 1183, 465, 22762, 12, 4228, 511, 63, 26851, 63, 6677, 1183, 465, 12749, 12, 4228, 485, 8393, 9, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 504, 5840, 14, 3175, 492, 1315, 12, 302, 12, 1022, 12, 671, 199, 199, 8393, 275, 485, 8393, 342, 421, 199, 318, 511, 63, 11562, 5891, 63, 3759, 837, 272, 367, 289, 315, 359, 11562, 5891, 74, 12, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 2189, 267, 702, 12749, 8, 70, 8, 3759, 67, 1168, 88, 1062, 1315, 395, 1315, 9, 339, 367, 289, 315, 359, 24016, 12, 612, 78, 12, 394, 78, 17, 12, 394, 78, 18, 2189, 267, 702, 12749, 8, 70, 8, 8393, 2801, 709, 12, 1616, 395, 1315, 395, 1315, 9, 421, 199, 318, 511, 63, 11562, 5891, 63, 5601, 3711, 837, 272, 367, 289, 315, 359, 11562, 5891, 74, 12, 330, 397, 261, 590, 12, 330, 397, 261, 317, 12, 330, 28817, 75, 12, 394, 3580, 352, 17, 12, 394, 3580, 352, 18, 12, 1335, 78, 12, 612, 78, 2189, 267, 6534, 8, 4333, 12, 2400, 26, 289, 8, 17, 430, 267, 6534, 8, 4333, 12, 2400, 26, 289, 8, 17, 12, 499, 12, 650, 430, 421, 199, 318, 511, 63, 3028, 837, 272, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 28817, 74, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 28817, 74, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 397, 261, 590, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 397, 261, 590, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 397, 261, 590, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 397, 261, 317, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 330, 397, 261, 317, 8, 78, 446, 413, 12, 1315, 2447, 18, 435, 330, 397, 261, 317, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 330, 28817, 75, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 446, 11562, 5891, 75, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 330, 28817, 75, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 394, 3580, 352, 17, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 394, 3580, 352, 17, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 394, 3580, 352, 17, 8, 78, 435, 413, 12, 1315, 2447, 18, 272, 702, 394, 3580, 352, 18, 8, 78, 12, 1315, 680, 3028, 8, 90, 9, 508, 394, 3580, 352, 18, 8, 78, 446, 413, 12, 1315, 2447, 18, 446, 394, 3580, 352, 18, 8, 78, 435, 413, 12, 1315, 2447, 18, 421, 199, 318, 511, 63, 14366, 837, 272, 687, 5840, 492, 29167, 63, 30133, 12, 1437, 12, 473, 339, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 14366, 8, 24016, 9, 508, 7452, 8, 18, 10, 90, 15, 1038, 3342, 24016, 8, 78, 446, 428, 8, 17, 2447, 18, 12, 1315, 9, 272, 702, 330, 397, 261, 590, 8, 78, 12, 1315, 680, 14366, 8, 1236, 9, 508, 7452, 8, 18, 10, 90, 15, 1038, 3342, 1236, 8, 78, 446, 428, 8, 17, 2447, 18, 12, 1315, 9, 272, 702, 330, 397, 261, 317, 8, 78, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 9, 508, 971, 267, 1437, 2801, 41, 10, 78, 10, 1038, 15, 18, 3342, 11562, 5891, 74, 8, 78, 12, 29167, 63, 30133, 8, 41, 3342, 90, 9, 272, 702, 330, 28817, 74, 8, 78, 12, 1315, 680, 14366, 8, 11562, 261, 317, 9, 508, 971, 267, 1437, 8, 41, 10, 78, 10, 1038, 15, 18, 3342, 11562, 261, 317, 8, 78, 12, 29167, 63, 30133, 2801, 41, 3342, 90, 9, 339, 15699, 275, 10261, 67, 1168, 88, 342, 339, 702, 22762, 8, 11562, 5891, 74, 8, 4850, 12, 1315, 395, 330, 28817, 74, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 317, 395, 1315, 9, 272, 702, 22762, 8, 11562, 5891, 74, 8, 4850, 12, 1315, 395, 330, 28817, 74, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 590, 395, 1315, 9, 339, 702, 22762, 8, 11562, 261, 317, 8, 4850, 12, 1315, 395, 330, 397, 261, 317, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 395, 1315, 9, 272, 702, 22762, 8, 11562, 261, 317, 8, 4850, 12, 1315, 395, 330, 397, 261, 317, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 261, 590, 395, 1315, 9, 339, 702, 22762, 8, 11562, 261, 590, 8, 4850, 12, 1315, 395, 330, 397, 261, 590, 8, 4850, 12, 1315, 680, 14366, 8, 11562, 5891, 74, 395, 1315, 9, 272, 702, 22762, 8, 11562, 261, 590, 8, 4850, 12, 1315, 395, 330, 397, 261, 590, 8, 4850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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 ]
germn/python-for-android
pythonforandroid/pythonpackage.py
4
30760
""" This module offers highlevel functions to get package metadata like the METADATA file, the name, or a list of dependencies. Usage examples: # Getting package name from pip reference: from pytonforandroid.pythonpackage import get_package_name print(get_package_name("pillow")) # Outputs: "Pillow" (note the spelling!) # Getting package dependencies: from pytonforandroid.pythonpackage import get_package_dependencies print(get_package_dependencies("pep517")) # Outputs: "['pytoml']" # Get package name from arbitrary package source: from pytonforandroid.pythonpackage import get_package_name print(get_package_name("/some/local/project/folder/")) # Outputs package name NOTE: Yes, this module doesn't fit well into python-for-android, but this functionality isn't available ANYWHERE ELSE, and upstream (pip, ...) currently has no interest in taking this over, so it has no other place to go. (Unless someone reading this puts it into yet another packaging lib) Reference discussion/upstream inclusion attempt: https://github.com/pypa/packaging-problems/issues/247 """ import functools import os import shutil import subprocess import sys import tarfile import tempfile import textwrap import time import zipfile from io import open # needed for python 2 from urllib.parse import unquote as urlunquote from urllib.parse import urlparse import toml from pep517.envbuild import BuildEnvironment from pep517.wrappers import Pep517HookCaller def transform_dep_for_pip(dependency): if dependency.find("@") > 0 and ( dependency.find("@") < dependency.find("://") or "://" not in dependency ): # WORKAROUND FOR UPSTREAM BUG: # https://github.com/pypa/pip/issues/6097 # (Please REMOVE workaround once that is fixed & released upstream!) # # Basically, setup_requires() can contain a format pip won't install # from a requirements.txt (PEP 508 URLs). # To avoid this, translate to an #egg= reference: if dependency.endswith("#"): dependency = dependency[:-1] url = (dependency.partition("@")[2].strip().partition("#egg")[0] + "#egg=" + dependency.partition("@")[0].strip() ) return url return dependency def extract_metainfo_files_from_package( package, output_folder, debug=False ): """ Extracts metdata files from the given package to the given folder, which may be referenced in any way that is permitted in a requirements.txt file or install_requires=[] listing. Current supported metadata files that will be extracted: - pytoml.yml (only if package wasn't obtained as wheel) - METADATA """ if package is None: raise ValueError("package cannot be None") if not os.path.exists(output_folder) or os.path.isfile(output_folder): raise ValueError("output folder needs to be existing folder") if debug: print("extract_metainfo_files_from_package: extracting for " + "package: " + str(package)) # A temp folder for making a package copy in case it's a local folder, # because extracting metadata might modify files # (creating sdists/wheels...) temp_folder = tempfile.mkdtemp(prefix="pythonpackage-package-copy-") try: # Package is indeed a folder! Get a temp copy to work on: if is_filesystem_path(package): shutil.copytree( parse_as_folder_reference(package), os.path.join(temp_folder, "package"), ignore=shutil.ignore_patterns(".tox") ) package = os.path.join(temp_folder, "package") # Because PEP517 can be noisy and contextlib.redirect_* fails to # contain it, we will run the actual analysis in a separate process: try: subprocess.check_output([ sys.executable, "-c", "import importlib\n" "import json\n" "import os\n" "import sys\n" "sys.path = [os.path.dirname(sys.argv[3])] + sys.path\n" "m = importlib.import_module(\n" " os.path.basename(sys.argv[3]).partition('.')[0]\n" ")\n" "m._extract_metainfo_files_from_package_unsafe(" " sys.argv[1]," " sys.argv[2]," ")", package, output_folder, os.path.abspath(__file__)], stderr=subprocess.STDOUT, # make sure stderr is muted. cwd=os.path.join(os.path.dirname(__file__), "..") ) except subprocess.CalledProcessError as e: output = e.output.decode("utf-8", "replace") if debug: print("Got error obtaining meta info.") print("Detail output:") print(output) print("End of Detail output.") raise ValueError( "failed to obtain meta info - " "is '{}' a valid package? " "Detailed output:\n{}".format(package, output) ) finally: shutil.rmtree(temp_folder) def _get_system_python_executable(): """ Returns the path the system-wide python binary. (In case we're running in a virtualenv or venv) """ # This function is required by get_package_as_folder() to work # inside a virtualenv, since venv creation will fail with # the virtualenv's local python binary. # (venv/virtualenv incompatibility) # Abort if not in virtualenv or venv: if not hasattr(sys, "real_prefix") and ( not hasattr(sys, "base_prefix") or os.path.normpath(sys.base_prefix) == os.path.normpath(sys.prefix)): return sys.executable # Extract prefix we need to look in: if hasattr(sys, "real_prefix"): search_prefix = sys.real_prefix # virtualenv else: search_prefix = sys.base_prefix # venv def python_binary_from_folder(path): def binary_is_usable(python_bin): """ Helper function to see if a given binary name refers to a usable python interpreter binary """ # Abort if path isn't present at all or a directory: if not os.path.exists( os.path.join(path, python_bin) ) or os.path.isdir(os.path.join(path, python_bin)): return # We should check file not found anyway trying to run it, # since it might be a dead symlink: try: filenotfounderror = FileNotFoundError except NameError: # Python 2 filenotfounderror = OSError try: # Run it and see if version output works with no error: subprocess.check_output([ os.path.join(path, python_bin), "--version" ], stderr=subprocess.STDOUT) return True except (subprocess.CalledProcessError, filenotfounderror): return False python_name = "python" + sys.version while (not binary_is_usable(python_name) and python_name.find(".") > 0): # Try less specific binary name: python_name = python_name.rpartition(".")[0] if binary_is_usable(python_name): return os.path.join(path, python_name) return None # Return from sys.real_prefix if present: result = python_binary_from_folder(search_prefix) if result is not None: return result # Check out all paths in $PATH: bad_candidates = [] good_candidates = [] ever_had_nonvenv_path = False ever_had_path_starting_with_prefix = False for p in os.environ.get("PATH", "").split(":"): # Skip if not possibly the real system python: if not os.path.normpath(p).startswith( os.path.normpath(search_prefix) ): continue ever_had_path_starting_with_prefix = True # First folders might be virtualenv/venv we want to avoid: if not ever_had_nonvenv_path: sep = os.path.sep if ( ("system32" not in p.lower() and "usr" not in p and not p.startswith("/opt/python")) or {"home", ".tox"}.intersection(set(p.split(sep))) or "users" in p.lower() ): # Doesn't look like bog-standard system path. if (p.endswith(os.path.sep + "bin") or p.endswith(os.path.sep + "bin" + os.path.sep)): # Also ends in "bin" -> likely virtualenv/venv. # Add as unfavorable / end of candidates: bad_candidates.append(p) continue ever_had_nonvenv_path = True good_candidates.append(p) # If we have a bad env with PATH not containing any reference to our # real python (travis, why would you do that to me?) then just guess # based from the search prefix location itself: if not ever_had_path_starting_with_prefix: # ... and yes we're scanning all the folders for that, it's dumb # but i'm not aware of a better way: (@JonasT) for root, dirs, files in os.walk(search_prefix, topdown=True): for name in dirs: bad_candidates.append(os.path.join(root, name)) # Sort candidates by length (to prefer shorter ones): def candidate_cmp(a, b): return len(a) - len(b) good_candidates = sorted( good_candidates, key=functools.cmp_to_key(candidate_cmp) ) bad_candidates = sorted( bad_candidates, key=functools.cmp_to_key(candidate_cmp) ) # See if we can now actually find the system python: for p in good_candidates + bad_candidates: result = python_binary_from_folder(p) if result is not None: return result raise RuntimeError( "failed to locate system python in: {}" " - checked candidates were: {}, {}" .format(sys.real_prefix, good_candidates, bad_candidates) ) def get_package_as_folder(dependency): """ This function downloads the given package / dependency and extracts the raw contents into a folder. Afterwards, it returns a tuple with the type of distribution obtained, and the temporary folder it extracted to. It is the caller's responsibility to delete the returned temp folder after use. Examples of returned values: ("source", "/tmp/pythonpackage-venv-e84toiwjw") ("wheel", "/tmp/pythonpackage-venv-85u78uj") What the distribution type will be depends on what pip decides to download. """ venv_parent = tempfile.mkdtemp( prefix="pythonpackage-venv-" ) try: # Create a venv to install into: try: if int(sys.version.partition(".")[0]) < 3: # Python 2.x has no venv. subprocess.check_output([ sys.executable, # no venv conflict possible, # -> no need to use system python "-m", "virtualenv", "--python=" + _get_system_python_executable(), os.path.join(venv_parent, 'venv') ], cwd=venv_parent) else: # On modern Python 3, use venv. subprocess.check_output([ _get_system_python_executable(), "-m", "venv", os.path.join(venv_parent, 'venv') ], cwd=venv_parent) except subprocess.CalledProcessError as e: output = e.output.decode('utf-8', 'replace') raise ValueError( 'venv creation unexpectedly ' + 'failed. error output: ' + str(output) ) venv_path = os.path.join(venv_parent, "venv") # Update pip and wheel in venv for latest feature support: try: filenotfounderror = FileNotFoundError except NameError: # Python 2. filenotfounderror = OSError try: subprocess.check_output([ os.path.join(venv_path, "bin", "pip"), "install", "-U", "pip", "wheel", ]) except filenotfounderror: raise RuntimeError( "venv appears to be missing pip. " "did we fail to use a proper system python??\n" "system python path detected: {}\n" "os.environ['PATH']: {}".format( _get_system_python_executable(), os.environ.get("PATH", "") ) ) # Create download subfolder: os.mkdir(os.path.join(venv_path, "download")) # Write a requirements.txt with our package and download: with open(os.path.join(venv_path, "requirements.txt"), "w", encoding="utf-8" ) as f: def to_unicode(s): # Needed for Python 2. try: return s.decode("utf-8") except AttributeError: return s f.write(to_unicode(transform_dep_for_pip(dependency))) try: subprocess.check_output( [ os.path.join(venv_path, "bin", "pip"), "download", "--no-deps", "-r", "../requirements.txt", "-d", os.path.join(venv_path, "download") ], stderr=subprocess.STDOUT, cwd=os.path.join(venv_path, "download") ) except subprocess.CalledProcessError as e: raise RuntimeError("package download failed: " + str(e.output)) if len(os.listdir(os.path.join(venv_path, "download"))) == 0: # No download. This can happen if the dependency has a condition # which prohibits install in our environment. # (the "package ; ... conditional ... " type of condition) return (None, None) # Get the result and make sure it's an extracted directory: result_folder_or_file = os.path.join( venv_path, "download", os.listdir(os.path.join(venv_path, "download"))[0] ) dl_type = "source" if not os.path.isdir(result_folder_or_file): # Must be an archive. if result_folder_or_file.endswith((".zip", ".whl")): if result_folder_or_file.endswith(".whl"): dl_type = "wheel" with zipfile.ZipFile(result_folder_or_file) as f: f.extractall(os.path.join(venv_path, "download", "extracted" )) result_folder_or_file = os.path.join( venv_path, "download", "extracted" ) elif result_folder_or_file.find(".tar.") > 0: # Probably a tarball. with tarfile.open(result_folder_or_file) as f: f.extractall(os.path.join(venv_path, "download", "extracted" )) result_folder_or_file = os.path.join( venv_path, "download", "extracted" ) else: raise RuntimeError( "unknown archive or download " + "type: " + str(result_folder_or_file) ) # If the result is hidden away in an additional subfolder, # descend into it: while os.path.isdir(result_folder_or_file) and \ len(os.listdir(result_folder_or_file)) == 1 and \ os.path.isdir(os.path.join( result_folder_or_file, os.listdir(result_folder_or_file)[0] )): result_folder_or_file = os.path.join( result_folder_or_file, os.listdir(result_folder_or_file)[0] ) # Copy result to new dedicated folder so we can throw away # our entire virtualenv nonsense after returning: result_path = tempfile.mkdtemp() shutil.rmtree(result_path) shutil.copytree(result_folder_or_file, result_path) return (dl_type, result_path) finally: shutil.rmtree(venv_parent) def _extract_metainfo_files_from_package_unsafe( package, output_path ): # This is the unwrapped function that will # 1. make lots of stdout/stderr noise # 2. possibly modify files (if the package source is a local folder) # Use extract_metainfo_files_from_package_folder instead which avoids # these issues. clean_up_path = False path_type = "source" path = parse_as_folder_reference(package) if path is None: # This is not a path. Download it: (path_type, path) = get_package_as_folder(package) if path_type is None: # Download failed. raise ValueError( "cannot get info for this package, " + "pip says it has no downloads (conditional dependency?)" ) clean_up_path = True try: build_requires = [] metadata_path = None if path_type != "wheel": # We need to process this first to get the metadata. # Ensure pyproject.toml is available (pep517 expects it) if not os.path.exists(os.path.join(path, "pyproject.toml")): with open(os.path.join(path, "pyproject.toml"), "w") as f: f.write(textwrap.dedent(u"""\ [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" """)) # Copy the pyproject.toml: shutil.copyfile( os.path.join(path, 'pyproject.toml'), os.path.join(output_path, 'pyproject.toml') ) # Get build backend and requirements from pyproject.toml: with open(os.path.join(path, 'pyproject.toml')) as f: build_sys = toml.load(f)['build-system'] backend = build_sys["build-backend"] build_requires.extend(build_sys["requires"]) # Get a virtualenv with build requirements and get all metadata: env = BuildEnvironment() metadata = None with env: hooks = Pep517HookCaller(path, backend) env.pip_install( [transform_dep_for_pip(req) for req in build_requires] ) reqs = hooks.get_requires_for_build_wheel({}) env.pip_install([transform_dep_for_pip(req) for req in reqs]) try: metadata = hooks.prepare_metadata_for_build_wheel(path) except Exception: # sadly, pep517 has no good error here pass if metadata is not None: metadata_path = os.path.join( path, metadata, "METADATA" ) else: # This is a wheel, so metadata should be in *.dist-info folder: metadata_path = os.path.join( path, [f for f in os.listdir(path) if f.endswith(".dist-info")][0], "METADATA" ) # Store type of metadata source. Can be "wheel", "source" for source # distribution, and others get_package_as_folder() may support # in the future. with open(os.path.join(output_path, "metadata_source"), "w") as f: try: f.write(path_type) except TypeError: # in python 2 path_type may be str/bytes: f.write(path_type.decode("utf-8", "replace")) # Copy the metadata file: shutil.copyfile(metadata_path, os.path.join(output_path, "METADATA")) finally: if clean_up_path: shutil.rmtree(path) def is_filesystem_path(dep): """ Convenience function around parse_as_folder_reference() to check if a dependency refers to a folder path or something remote. Returns True if local, False if remote. """ return (parse_as_folder_reference(dep) is not None) def parse_as_folder_reference(dep): """ See if a dependency reference refers to a folder path. If it does, return the folder path (which parses and resolves file:// urls in the process). If it doesn't, return None. """ # Special case: pep508 urls if dep.find("@") > 0 and ( (dep.find("@") < dep.find("/") or "/" not in dep) and (dep.find("@") < dep.find(":") or ":" not in dep) ): # This should be a 'pkgname @ https://...' style path, or # 'pkname @ /local/file/path'. return parse_as_folder_reference(dep.partition("@")[2].lstrip()) # Check if this is either not an url, or a file URL: if dep.startswith(("/", "file://")) or ( dep.find("/") > 0 and dep.find("://") < 0) or (dep in ["", "."]): if dep.startswith("file://"): dep = urlunquote(urlparse(dep).path) return dep return None def _extract_info_from_package(dependency, extract_type=None, debug=False, include_build_requirements=False ): """ Internal function to extract metainfo from a package. Currently supported info types: - name - dependencies (a list of dependencies) """ if debug: print("_extract_info_from_package called with " "extract_type={} include_build_requirements={}".format( extract_type, include_build_requirements, )) output_folder = tempfile.mkdtemp(prefix="pythonpackage-metafolder-") try: extract_metainfo_files_from_package( dependency, output_folder, debug=debug ) # Extract the type of data source we used to get the metadata: with open(os.path.join(output_folder, "metadata_source"), "r") as f: metadata_source_type = f.read().strip() # Extract main METADATA file: with open(os.path.join(output_folder, "METADATA"), "r", encoding="utf-8" ) as f: # Get metadata and cut away description (is after 2 linebreaks) metadata_entries = f.read().partition("\n\n")[0].splitlines() if extract_type == "name": name = None for meta_entry in metadata_entries: if meta_entry.lower().startswith("name:"): return meta_entry.partition(":")[2].strip() if name is None: raise ValueError("failed to obtain package name") return name elif extract_type == "dependencies": # First, make sure we don't attempt to return build requirements # for wheels since they usually come without pyproject.toml # and we haven't implemented another way to get them: if include_build_requirements and \ metadata_source_type == "wheel": if debug: print("_extract_info_from_package: was called " "with include_build_requirements=True on " "package obtained as wheel, raising error...") raise NotImplementedError( "fetching build requirements for " "wheels is not implemented" ) # Get build requirements from pyproject.toml if requested: requirements = [] if os.path.exists(os.path.join(output_folder, 'pyproject.toml') ) and include_build_requirements: # Read build system from pyproject.toml file: (PEP518) with open(os.path.join(output_folder, 'pyproject.toml')) as f: build_sys = toml.load(f)['build-system'] if "requires" in build_sys: requirements += build_sys["requires"] elif include_build_requirements: # For legacy packages with no pyproject.toml, we have to # add setuptools as default build system. requirements.append("setuptools") # Add requirements from metadata: requirements += [ entry.rpartition("Requires-Dist:")[2].strip() for entry in metadata_entries if entry.startswith("Requires-Dist") ] return list(set(requirements)) # remove duplicates finally: shutil.rmtree(output_folder) package_name_cache = dict() def get_package_name(dependency, use_cache=True): def timestamp(): try: return time.monotonic() except AttributeError: return time.time() # Python 2. try: value = package_name_cache[dependency] if value[0] + 600.0 > timestamp() and use_cache: return value[1] except KeyError: pass result = _extract_info_from_package(dependency, extract_type="name") package_name_cache[dependency] = (timestamp(), result) return result def get_package_dependencies(package, recursive=False, verbose=False, include_build_requirements=False): """ Obtain the dependencies from a package. Please note this function is possibly SLOW, especially if you enable the recursive mode. """ packages_processed = set() package_queue = [package] reqs = set() reqs_as_names = set() while len(package_queue) > 0: current_queue = package_queue package_queue = [] for package_dep in current_queue: new_reqs = set() if verbose: print("get_package_dependencies: resolving dependency " f"to package name: {package_dep}") package = get_package_name(package_dep) if package.lower() in packages_processed: continue if verbose: print("get_package_dependencies: " "processing package: {}".format(package)) print("get_package_dependencies: " "Packages seen so far: {}".format( packages_processed )) packages_processed.add(package.lower()) # Use our regular folder processing to examine: new_reqs = new_reqs.union(_extract_info_from_package( package_dep, extract_type="dependencies", debug=verbose, include_build_requirements=include_build_requirements, )) # Process new requirements: if verbose: print('get_package_dependencies: collected ' "deps of '{}': {}".format( package_dep, str(new_reqs), )) for new_req in new_reqs: try: req_name = get_package_name(new_req) except ValueError as e: if new_req.find(";") >= 0: # Conditional dep where condition isn't met? # --> ignore it continue if verbose: print("get_package_dependencies: " + "unexpected failure to get name " + "of '" + str(new_req) + "': " + str(e)) raise RuntimeError( "failed to get " + "name of dependency: " + str(e) ) if req_name.lower() in reqs_as_names: continue if req_name.lower() not in packages_processed: package_queue.append(new_req) reqs.add(new_req) reqs_as_names.add(req_name.lower()) # Bail out here if we're not scanning recursively: if not recursive: package_queue[:] = [] # wipe queue break if verbose: print("get_package_dependencies: returning result: {}".format(reqs)) return reqs def get_dep_names_of_package( package, keep_version_pins=False, recursive=False, verbose=False, include_build_requirements=False ): """ Gets the dependencies from the package in the given folder, then attempts to deduce the actual package name resulting from each dependency line, stripping away everything else. """ # First, obtain the dependencies: dependencies = get_package_dependencies( package, recursive=recursive, verbose=verbose, include_build_requirements=include_build_requirements, ) if verbose: print("get_dep_names_of_package_folder: " + "processing dependency list to names: " + str(dependencies)) # Transform dependencies to their stripped down names: # (they can still have version pins/restrictions, conditionals, ...) dependency_names = set() for dep in dependencies: # If we are supposed to keep exact version pins, extract first: pin_to_append = "" if keep_version_pins and "(==" in dep and dep.endswith(")"): # This is a dependency of the format: 'pkg (==1.0)' pin_to_append = "==" + dep.rpartition("==")[2][:-1] elif keep_version_pins and "==" in dep and not dep.endswith(")"): # This is a dependency of the format: 'pkg==1.0' pin_to_append = "==" + dep.rpartition("==")[2] # Now get true (and e.g. case-corrected) dependency name: dep_name = get_package_name(dep) + pin_to_append dependency_names.add(dep_name) return dependency_names
mit
[ 624, 961, 859, 32563, 4721, 1896, 3423, 370, 664, 2559, 3341, 272, 2839, 314, 19357, 8071, 570, 12, 314, 536, 12, 503, 282, 769, 402, 5124, 14, 339, 11028, 7251, 26, 10817, 327, 20703, 2559, 536, 687, 7305, 3659, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 354, 2126, 870, 8, 362, 63, 2491, 63, 354, 480, 80, 382, 674, 2237, 2126, 327, 29206, 26, 298, 48, 382, 674, 2, 334, 4610, 314, 27928, 21866, 10817, 327, 20703, 2559, 5124, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 5714, 2126, 870, 8, 362, 63, 2491, 63, 5714, 480, 12636, 27696, 2237, 2126, 327, 29206, 26, 25280, 647, 475, 757, 18721, 10817, 327, 2372, 2559, 536, 687, 9697, 2559, 1350, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 354, 2126, 870, 8, 362, 63, 2491, 63, 354, 4769, 3972, 15, 1832, 15, 1715, 15, 3741, 15, 2237, 2126, 327, 29206, 2559, 536, 339, 6944, 26, 339, 29715, 12, 642, 859, 3181, 1133, 5542, 5521, 1901, 2366, 13, 509, 13, 6238, 12, 1325, 642, 272, 9330, 5712, 1133, 2808, 1821, 17688, 22325, 899, 12, 436, 18932, 334, 9983, 12, 19172, 272, 5544, 965, 949, 13518, 315, 16466, 642, 1806, 12, 880, 652, 965, 949, 1163, 4192, 272, 370, 2621, 14, 272, 334, 5524, 17122, 7664, 642, 27000, 652, 1901, 5966, 4573, 27369, 1973, 9, 339, 10944, 16582, 15, 20099, 20396, 7427, 26, 339, 4178, 921, 5031, 14, 957, 15, 647, 387, 15, 27796, 13, 22959, 15, 10115, 15, 11717, 199, 199, 624, 421, 199, 646, 9143, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 13390, 199, 646, 900, 199, 646, 10392, 199, 504, 5890, 492, 1551, 221, 327, 4346, 367, 2366, 499, 199, 504, 4011, 14, 1122, 492, 14342, 465, 1166, 12240, 199, 504, 4011, 14, 1122, 492, 7097, 199, 199, 646, 370, 757, 199, 504, 22602, 27696, 14, 1813, 1506, 492, 6516, 8263, 199, 504, 22602, 27696, 14, 21148, 492, 510, 1545, 27696, 8481, 6584, 1435, 421, 199, 318, 5793, 63, 2601, 63, 509, 63, 9983, 8, 8575, 304, 272, 340, 5936, 14, 1623, 25915, 531, 690, 378, 436, 334, 288, 5936, 14, 1623, 25915, 531, 665, 5936, 14, 1623, 480, 921, 531, 503, 288, 298, 30443, 440, 315, 5936, 288, 3461, 267, 327, 29557, 43, 689, 47, 6131, 2381, 7215, 9484, 699, 10134, 26, 267, 327, 4178, 921, 5031, 14, 957, 15, 647, 387, 15, 9983, 15, 10115, 15, 14520, 23, 267, 327, 334, 8254, 5363, 16207, 18092, 5403, 626, 365, 6317, 1253, 14286, 18932, 21866, 267, 327, 267, 327, 10082, 1183, 12, 3272, 63, 6537, 342, 883, 1395, 282, 1475, 7305, 7859, 1133, 3907, 267, 327, 687, 282, 9760, 14, 2424, 334, 25633, 959, 2036, 10867, 680, 267, 327, 4005, 5126, 642, 12, 9028, 370, 376, 327, 5799, 29, 3659, 26, 267, 340, 5936, 14, 4130, 10064, 2349, 288, 5936, 275, 5936, 4439, 17, 61, 267, 1166, 275, 334, 8575, 14, 5312, 25915, 9981, 18, 1055, 1913, 1252, 5312, 10064, 5799, 9981, 16, 61, 435, 2049, 5426, 5799, 628, 435, 2049, 5936, 14, 5312, 25915, 9981, 16, 1055, 1913, 342, 1598, 776, 267, 372, 1166, 272, 372, 5936, 421, 199, 318, 5536, 63, 2024, 815, 63, 1725, 63, 504, 63, 2491, 8, 267, 2559, 12, 267, 1072, 63, 3741, 12, 267, 3105, 29, 797, 267, 3461, 272, 408, 12892, 83, 7647, 576, 1584, 687, 314, 1627, 2559, 370, 314, 1627, 4922, 12, 267, 1314, 1443, 506, 11812, 315, 1263, 4340, 626, 365, 8211, 315, 267, 282, 9760, 14, 2424, 570, 503, 3907, 63, 6537, 9811, 13778, 14, 398, 9338, 3748, 3341, 1584, 626, 911, 506, 12509, 26, 398, 446, 1134, 475, 757, 14, 11714, 221, 334, 2118, 340, 2559, 17373, 1133, 15884, 465, 9989, 9, 267, 446, 19357, 8071, 272, 408, 339, 340, 2559, 365, 488, 26, 267, 746, 1722, 480, 2491, 3913, 506, 488, 531, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 1199, 63, 3741, 9, 503, 747, 14, 515, 14, 6292, 8, 1199, 63, 3741, 304, 267, 746, 1722, 480, 1199, 4922, 4839, 370, 506, 3411, 4922, 531, 339, 340, 3105, 26, 267, 870, 480, 5005, 63, 2024, 815, 63, 1725, 63, 504, 63, 2491, 26, 30137, 367, 298, 435, 1598, 298, 2491, 26, 298, 435, 620, 8, 2491, 430, 339, 327, 437, 2388, 4922, 367, 10663, 282, 2559, 1331, 315, 1930, 652, 1159, 282, 2257, 4922, 12, 272, 327, 2952, 30137, 3341, 5594, 2811, 1584, 272, 327, 334, 20358, 308, 18552, 15, 11798, 83, 11965, 272, 2388, 63, 3741, 275, 5549, 14, 11983, 8, 1861, 628, 1548, 2491, 13, 2491, 13, 1574, 13, 531, 272, 862, 26, 267, 327, 15665, 365, 31043, 379, 282, 4922, 1, 2372, 282, 2388, 1331, 370, 1736, 641, 26, 267, 340, 365, 63, 11381, 63, 515, 8, 2491, 304, 288, 5145, 14, 29296, 8, 355, 2198, 63, 305, 63, 3741, 63, 4443, 8, 2491, 395, 355, 747, 14, 515, 14, 904, 8, 808, 63, 3741, 12, 298, 2491, 1288, 355, 3686, 29, 20938, 14, 4247, 63, 7435, 9520, 475, 88, 531, 288, 776, 288, 2559, 275, 747, 14, 515, 14, 904, 8, 808, 63, 3741, 12, 298, 2491, 531, 398, 327, 13821, 13663, 27696, 883, 506, 949, 19765, 436, 15502, 14, 4876, 15192, 6918, 370, 267, 327, 1395, 652, 12, 781, 911, 1255, 314, 3503, 11284, 315, 282, 7396, 2112, 26, 267, 862, 26, 288, 3873, 14, 1074, 63, 1199, 779, 355, 984, 14, 5904, 12, 355, 3905, 67, 401, 355, 298, 646, 14802, 60, 78, 2, 355, 298, 646, 2022, 60, 78, 2, 355, 298, 646, 747, 60, 78, 2, 355, 298, 646, 984, 60, 78, 2, 355, 298, 1274, 14, 515, 275, 359, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 19, 12457, 435, 984, 14, 515, 60, 78, 2, 355, 298, 77, 275, 14802, 14, 646, 63, 578, 2961, 78, 2, 355, 298, 259, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 19, 6575, 5312, 19237, 16, 7272, 78, 2, 355, 298, 2862 ]
[ 961, 859, 32563, 4721, 1896, 3423, 370, 664, 2559, 3341, 272, 2839, 314, 19357, 8071, 570, 12, 314, 536, 12, 503, 282, 769, 402, 5124, 14, 339, 11028, 7251, 26, 10817, 327, 20703, 2559, 536, 687, 7305, 3659, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 354, 2126, 870, 8, 362, 63, 2491, 63, 354, 480, 80, 382, 674, 2237, 2126, 327, 29206, 26, 298, 48, 382, 674, 2, 334, 4610, 314, 27928, 21866, 10817, 327, 20703, 2559, 5124, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 5714, 2126, 870, 8, 362, 63, 2491, 63, 5714, 480, 12636, 27696, 2237, 2126, 327, 29206, 26, 25280, 647, 475, 757, 18721, 10817, 327, 2372, 2559, 536, 687, 9697, 2559, 1350, 26, 2126, 687, 1134, 1860, 509, 6238, 14, 1548, 2491, 492, 664, 63, 2491, 63, 354, 2126, 870, 8, 362, 63, 2491, 63, 354, 4769, 3972, 15, 1832, 15, 1715, 15, 3741, 15, 2237, 2126, 327, 29206, 2559, 536, 339, 6944, 26, 339, 29715, 12, 642, 859, 3181, 1133, 5542, 5521, 1901, 2366, 13, 509, 13, 6238, 12, 1325, 642, 272, 9330, 5712, 1133, 2808, 1821, 17688, 22325, 899, 12, 436, 18932, 334, 9983, 12, 19172, 272, 5544, 965, 949, 13518, 315, 16466, 642, 1806, 12, 880, 652, 965, 949, 1163, 4192, 272, 370, 2621, 14, 272, 334, 5524, 17122, 7664, 642, 27000, 652, 1901, 5966, 4573, 27369, 1973, 9, 339, 10944, 16582, 15, 20099, 20396, 7427, 26, 339, 4178, 921, 5031, 14, 957, 15, 647, 387, 15, 27796, 13, 22959, 15, 10115, 15, 11717, 199, 199, 624, 421, 199, 646, 9143, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 13608, 199, 646, 5549, 199, 646, 13390, 199, 646, 900, 199, 646, 10392, 199, 504, 5890, 492, 1551, 221, 327, 4346, 367, 2366, 499, 199, 504, 4011, 14, 1122, 492, 14342, 465, 1166, 12240, 199, 504, 4011, 14, 1122, 492, 7097, 199, 199, 646, 370, 757, 199, 504, 22602, 27696, 14, 1813, 1506, 492, 6516, 8263, 199, 504, 22602, 27696, 14, 21148, 492, 510, 1545, 27696, 8481, 6584, 1435, 421, 199, 318, 5793, 63, 2601, 63, 509, 63, 9983, 8, 8575, 304, 272, 340, 5936, 14, 1623, 25915, 531, 690, 378, 436, 334, 288, 5936, 14, 1623, 25915, 531, 665, 5936, 14, 1623, 480, 921, 531, 503, 288, 298, 30443, 440, 315, 5936, 288, 3461, 267, 327, 29557, 43, 689, 47, 6131, 2381, 7215, 9484, 699, 10134, 26, 267, 327, 4178, 921, 5031, 14, 957, 15, 647, 387, 15, 9983, 15, 10115, 15, 14520, 23, 267, 327, 334, 8254, 5363, 16207, 18092, 5403, 626, 365, 6317, 1253, 14286, 18932, 21866, 267, 327, 267, 327, 10082, 1183, 12, 3272, 63, 6537, 342, 883, 1395, 282, 1475, 7305, 7859, 1133, 3907, 267, 327, 687, 282, 9760, 14, 2424, 334, 25633, 959, 2036, 10867, 680, 267, 327, 4005, 5126, 642, 12, 9028, 370, 376, 327, 5799, 29, 3659, 26, 267, 340, 5936, 14, 4130, 10064, 2349, 288, 5936, 275, 5936, 4439, 17, 61, 267, 1166, 275, 334, 8575, 14, 5312, 25915, 9981, 18, 1055, 1913, 1252, 5312, 10064, 5799, 9981, 16, 61, 435, 2049, 5426, 5799, 628, 435, 2049, 5936, 14, 5312, 25915, 9981, 16, 1055, 1913, 342, 1598, 776, 267, 372, 1166, 272, 372, 5936, 421, 199, 318, 5536, 63, 2024, 815, 63, 1725, 63, 504, 63, 2491, 8, 267, 2559, 12, 267, 1072, 63, 3741, 12, 267, 3105, 29, 797, 267, 3461, 272, 408, 12892, 83, 7647, 576, 1584, 687, 314, 1627, 2559, 370, 314, 1627, 4922, 12, 267, 1314, 1443, 506, 11812, 315, 1263, 4340, 626, 365, 8211, 315, 267, 282, 9760, 14, 2424, 570, 503, 3907, 63, 6537, 9811, 13778, 14, 398, 9338, 3748, 3341, 1584, 626, 911, 506, 12509, 26, 398, 446, 1134, 475, 757, 14, 11714, 221, 334, 2118, 340, 2559, 17373, 1133, 15884, 465, 9989, 9, 267, 446, 19357, 8071, 272, 408, 339, 340, 2559, 365, 488, 26, 267, 746, 1722, 480, 2491, 3913, 506, 488, 531, 339, 340, 440, 747, 14, 515, 14, 2444, 8, 1199, 63, 3741, 9, 503, 747, 14, 515, 14, 6292, 8, 1199, 63, 3741, 304, 267, 746, 1722, 480, 1199, 4922, 4839, 370, 506, 3411, 4922, 531, 339, 340, 3105, 26, 267, 870, 480, 5005, 63, 2024, 815, 63, 1725, 63, 504, 63, 2491, 26, 30137, 367, 298, 435, 1598, 298, 2491, 26, 298, 435, 620, 8, 2491, 430, 339, 327, 437, 2388, 4922, 367, 10663, 282, 2559, 1331, 315, 1930, 652, 1159, 282, 2257, 4922, 12, 272, 327, 2952, 30137, 3341, 5594, 2811, 1584, 272, 327, 334, 20358, 308, 18552, 15, 11798, 83, 11965, 272, 2388, 63, 3741, 275, 5549, 14, 11983, 8, 1861, 628, 1548, 2491, 13, 2491, 13, 1574, 13, 531, 272, 862, 26, 267, 327, 15665, 365, 31043, 379, 282, 4922, 1, 2372, 282, 2388, 1331, 370, 1736, 641, 26, 267, 340, 365, 63, 11381, 63, 515, 8, 2491, 304, 288, 5145, 14, 29296, 8, 355, 2198, 63, 305, 63, 3741, 63, 4443, 8, 2491, 395, 355, 747, 14, 515, 14, 904, 8, 808, 63, 3741, 12, 298, 2491, 1288, 355, 3686, 29, 20938, 14, 4247, 63, 7435, 9520, 475, 88, 531, 288, 776, 288, 2559, 275, 747, 14, 515, 14, 904, 8, 808, 63, 3741, 12, 298, 2491, 531, 398, 327, 13821, 13663, 27696, 883, 506, 949, 19765, 436, 15502, 14, 4876, 15192, 6918, 370, 267, 327, 1395, 652, 12, 781, 911, 1255, 314, 3503, 11284, 315, 282, 7396, 2112, 26, 267, 862, 26, 288, 3873, 14, 1074, 63, 1199, 779, 355, 984, 14, 5904, 12, 355, 3905, 67, 401, 355, 298, 646, 14802, 60, 78, 2, 355, 298, 646, 2022, 60, 78, 2, 355, 298, 646, 747, 60, 78, 2, 355, 298, 646, 984, 60, 78, 2, 355, 298, 1274, 14, 515, 275, 359, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 19, 12457, 435, 984, 14, 515, 60, 78, 2, 355, 298, 77, 275, 14802, 14, 646, 63, 578, 2961, 78, 2, 355, 298, 259, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 19, 6575, 5312, 19237, 16, 7272, 78, 2, 355, 298, 2862, 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, 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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 ]
stshine/servo
tests/wpt/web-platform-tests/tools/py/py/_code/_assertionold.py
218
17863
import py import sys, inspect from compiler import parse, ast, pycodegen from py._code.assertion import BuiltinAssertionError, _format_explanation passthroughex = py.builtin._sysex class Failure: def __init__(self, node): self.exc, self.value, self.tb = sys.exc_info() self.node = node class View(object): """View base class. If C is a subclass of View, then C(x) creates a proxy object around the object x. The actual class of the proxy is not C in general, but a *subclass* of C determined by the rules below. To avoid confusion we call view class the class of the proxy (a subclass of C, so of View) and object class the class of x. Attributes and methods not found in the proxy are automatically read on x. Other operations like setting attributes are performed on the proxy, as determined by its view class. The object x is available from the proxy as its __obj__ attribute. The view class selection is determined by the __view__ tuples and the optional __viewkey__ method. By default, the selected view class is the most specific subclass of C whose __view__ mentions the class of x. If no such subclass is found, the search proceeds with the parent object classes. For example, C(True) will first look for a subclass of C with __view__ = (..., bool, ...) and only if it doesn't find any look for one with __view__ = (..., int, ...), and then ..., object,... If everything fails the class C itself is considered to be the default. Alternatively, the view class selection can be driven by another aspect of the object x, instead of the class of x, by overriding __viewkey__. See last example at the end of this module. """ _viewcache = {} __view__ = () def __new__(rootclass, obj, *args, **kwds): self = object.__new__(rootclass) self.__obj__ = obj self.__rootclass__ = rootclass key = self.__viewkey__() try: self.__class__ = self._viewcache[key] except KeyError: self.__class__ = self._selectsubclass(key) return self def __getattr__(self, attr): # attributes not found in the normal hierarchy rooted on View # are looked up in the object's real class return getattr(self.__obj__, attr) def __viewkey__(self): return self.__obj__.__class__ def __matchkey__(self, key, subclasses): if inspect.isclass(key): keys = inspect.getmro(key) else: keys = [key] for key in keys: result = [C for C in subclasses if key in C.__view__] if result: return result return [] def _selectsubclass(self, key): subclasses = list(enumsubclasses(self.__rootclass__)) for C in subclasses: if not isinstance(C.__view__, tuple): C.__view__ = (C.__view__,) choices = self.__matchkey__(key, subclasses) if not choices: return self.__rootclass__ elif len(choices) == 1: return choices[0] else: # combine the multiple choices return type('?', tuple(choices), {}) def __repr__(self): return '%s(%r)' % (self.__rootclass__.__name__, self.__obj__) def enumsubclasses(cls): for subcls in cls.__subclasses__(): for subsubclass in enumsubclasses(subcls): yield subsubclass yield cls class Interpretable(View): """A parse tree node with a few extra methods.""" explanation = None def is_builtin(self, frame): return False def eval(self, frame): # fall-back for unknown expression nodes try: expr = ast.Expression(self.__obj__) expr.filename = '<eval>' self.__obj__.filename = '<eval>' co = pycodegen.ExpressionCodeGenerator(expr).getCode() result = frame.eval(co) except passthroughex: raise except: raise Failure(self) self.result = result self.explanation = self.explanation or frame.repr(self.result) def run(self, frame): # fall-back for unknown statement nodes try: expr = ast.Module(None, ast.Stmt([self.__obj__])) expr.filename = '<run>' co = pycodegen.ModuleCodeGenerator(expr).getCode() frame.exec_(co) except passthroughex: raise except: raise Failure(self) def nice_explanation(self): return _format_explanation(self.explanation) class Name(Interpretable): __view__ = ast.Name def is_local(self, frame): source = '%r in locals() is not globals()' % self.name try: return frame.is_true(frame.eval(source)) except passthroughex: raise except: return False def is_global(self, frame): source = '%r in globals()' % self.name try: return frame.is_true(frame.eval(source)) except passthroughex: raise except: return False def is_builtin(self, frame): source = '%r not in locals() and %r not in globals()' % ( self.name, self.name) try: return frame.is_true(frame.eval(source)) except passthroughex: raise except: return False def eval(self, frame): super(Name, self).eval(frame) if not self.is_local(frame): self.explanation = self.name class Compare(Interpretable): __view__ = ast.Compare def eval(self, frame): expr = Interpretable(self.expr) expr.eval(frame) for operation, expr2 in self.ops: if hasattr(self, 'result'): # shortcutting in chained expressions if not frame.is_true(self.result): break expr2 = Interpretable(expr2) expr2.eval(frame) self.explanation = "%s %s %s" % ( expr.explanation, operation, expr2.explanation) source = "__exprinfo_left %s __exprinfo_right" % operation try: self.result = frame.eval(source, __exprinfo_left=expr.result, __exprinfo_right=expr2.result) except passthroughex: raise except: raise Failure(self) expr = expr2 class And(Interpretable): __view__ = ast.And def eval(self, frame): explanations = [] for expr in self.nodes: expr = Interpretable(expr) expr.eval(frame) explanations.append(expr.explanation) self.result = expr.result if not frame.is_true(expr.result): break self.explanation = '(' + ' and '.join(explanations) + ')' class Or(Interpretable): __view__ = ast.Or def eval(self, frame): explanations = [] for expr in self.nodes: expr = Interpretable(expr) expr.eval(frame) explanations.append(expr.explanation) self.result = expr.result if frame.is_true(expr.result): break self.explanation = '(' + ' or '.join(explanations) + ')' # == Unary operations == keepalive = [] for astclass, astpattern in { ast.Not : 'not __exprinfo_expr', ast.Invert : '(~__exprinfo_expr)', }.items(): class UnaryArith(Interpretable): __view__ = astclass def eval(self, frame, astpattern=astpattern): expr = Interpretable(self.expr) expr.eval(frame) self.explanation = astpattern.replace('__exprinfo_expr', expr.explanation) try: self.result = frame.eval(astpattern, __exprinfo_expr=expr.result) except passthroughex: raise except: raise Failure(self) keepalive.append(UnaryArith) # == Binary operations == for astclass, astpattern in { ast.Add : '(__exprinfo_left + __exprinfo_right)', ast.Sub : '(__exprinfo_left - __exprinfo_right)', ast.Mul : '(__exprinfo_left * __exprinfo_right)', ast.Div : '(__exprinfo_left / __exprinfo_right)', ast.Mod : '(__exprinfo_left % __exprinfo_right)', ast.Power : '(__exprinfo_left ** __exprinfo_right)', }.items(): class BinaryArith(Interpretable): __view__ = astclass def eval(self, frame, astpattern=astpattern): left = Interpretable(self.left) left.eval(frame) right = Interpretable(self.right) right.eval(frame) self.explanation = (astpattern .replace('__exprinfo_left', left .explanation) .replace('__exprinfo_right', right.explanation)) try: self.result = frame.eval(astpattern, __exprinfo_left=left.result, __exprinfo_right=right.result) except passthroughex: raise except: raise Failure(self) keepalive.append(BinaryArith) class CallFunc(Interpretable): __view__ = ast.CallFunc def is_bool(self, frame): source = 'isinstance(__exprinfo_value, bool)' try: return frame.is_true(frame.eval(source, __exprinfo_value=self.result)) except passthroughex: raise except: return False def eval(self, frame): node = Interpretable(self.node) node.eval(frame) explanations = [] vars = {'__exprinfo_fn': node.result} source = '__exprinfo_fn(' for a in self.args: if isinstance(a, ast.Keyword): keyword = a.name a = a.expr else: keyword = None a = Interpretable(a) a.eval(frame) argname = '__exprinfo_%d' % len(vars) vars[argname] = a.result if keyword is None: source += argname + ',' explanations.append(a.explanation) else: source += '%s=%s,' % (keyword, argname) explanations.append('%s=%s' % (keyword, a.explanation)) if self.star_args: star_args = Interpretable(self.star_args) star_args.eval(frame) argname = '__exprinfo_star' vars[argname] = star_args.result source += '*' + argname + ',' explanations.append('*' + star_args.explanation) if self.dstar_args: dstar_args = Interpretable(self.dstar_args) dstar_args.eval(frame) argname = '__exprinfo_kwds' vars[argname] = dstar_args.result source += '**' + argname + ',' explanations.append('**' + dstar_args.explanation) self.explanation = "%s(%s)" % ( node.explanation, ', '.join(explanations)) if source.endswith(','): source = source[:-1] source += ')' try: self.result = frame.eval(source, **vars) except passthroughex: raise except: raise Failure(self) if not node.is_builtin(frame) or not self.is_bool(frame): r = frame.repr(self.result) self.explanation = '%s\n{%s = %s\n}' % (r, r, self.explanation) class Getattr(Interpretable): __view__ = ast.Getattr def eval(self, frame): expr = Interpretable(self.expr) expr.eval(frame) source = '__exprinfo_expr.%s' % self.attrname try: self.result = frame.eval(source, __exprinfo_expr=expr.result) except passthroughex: raise except: raise Failure(self) self.explanation = '%s.%s' % (expr.explanation, self.attrname) # if the attribute comes from the instance, its value is interesting source = ('hasattr(__exprinfo_expr, "__dict__") and ' '%r in __exprinfo_expr.__dict__' % self.attrname) try: from_instance = frame.is_true( frame.eval(source, __exprinfo_expr=expr.result)) except passthroughex: raise except: from_instance = True if from_instance: r = frame.repr(self.result) self.explanation = '%s\n{%s = %s\n}' % (r, r, self.explanation) # == Re-interpretation of full statements == class Assert(Interpretable): __view__ = ast.Assert def run(self, frame): test = Interpretable(self.test) test.eval(frame) # simplify 'assert False where False = ...' if (test.explanation.startswith('False\n{False = ') and test.explanation.endswith('\n}')): test.explanation = test.explanation[15:-2] # print the result as 'assert <explanation>' self.result = test.result self.explanation = 'assert ' + test.explanation if not frame.is_true(test.result): try: raise BuiltinAssertionError except passthroughex: raise except: raise Failure(self) class Assign(Interpretable): __view__ = ast.Assign def run(self, frame): expr = Interpretable(self.expr) expr.eval(frame) self.result = expr.result self.explanation = '... = ' + expr.explanation # fall-back-run the rest of the assignment ass = ast.Assign(self.nodes, ast.Name('__exprinfo_expr')) mod = ast.Module(None, ast.Stmt([ass])) mod.filename = '<run>' co = pycodegen.ModuleCodeGenerator(mod).getCode() try: frame.exec_(co, __exprinfo_expr=expr.result) except passthroughex: raise except: raise Failure(self) class Discard(Interpretable): __view__ = ast.Discard def run(self, frame): expr = Interpretable(self.expr) expr.eval(frame) self.result = expr.result self.explanation = expr.explanation class Stmt(Interpretable): __view__ = ast.Stmt def run(self, frame): for stmt in self.nodes: stmt = Interpretable(stmt) stmt.run(frame) def report_failure(e): explanation = e.node.nice_explanation() if explanation: explanation = ", in: " + explanation else: explanation = "" sys.stdout.write("%s: %s%s\n" % (e.exc.__name__, e.value, explanation)) def check(s, frame=None): if frame is None: frame = sys._getframe(1) frame = py.code.Frame(frame) expr = parse(s, 'eval') assert isinstance(expr, ast.Expression) node = Interpretable(expr.node) try: node.eval(frame) except passthroughex: raise except Failure: e = sys.exc_info()[1] report_failure(e) else: if not frame.is_true(node.result): sys.stderr.write("assertion failed: %s\n" % node.nice_explanation()) ########################################################### # API / Entry points # ######################################################### def interpret(source, frame, should_fail=False): module = Interpretable(parse(source, 'exec').node) #print "got module", module if isinstance(frame, py.std.types.FrameType): frame = py.code.Frame(frame) try: module.run(frame) except Failure: e = sys.exc_info()[1] return getfailure(e) except passthroughex: raise except: import traceback traceback.print_exc() if should_fail: return ("(assertion failed, but when it was re-run for " "printing intermediate values, it did not fail. Suggestions: " "compute assert expression before the assert or use --nomagic)") else: return None def getmsg(excinfo): if isinstance(excinfo, tuple): excinfo = py.code.ExceptionInfo(excinfo) #frame, line = gettbline(tb) #frame = py.code.Frame(frame) #return interpret(line, frame) tb = excinfo.traceback[-1] source = str(tb.statement).strip() x = interpret(source, tb.frame, should_fail=True) if not isinstance(x, str): raise TypeError("interpret returned non-string %r" % (x,)) return x def getfailure(e): explanation = e.node.nice_explanation() if str(e.value): lines = explanation.split('\n') lines[0] += " << %s" % (e.value,) explanation = '\n'.join(lines) text = "%s: %s" % (e.exc.__name__, explanation) if text.startswith('AssertionError: assert '): text = text[16:] return text def run(s, frame=None): if frame is None: frame = sys._getframe(1) frame = py.code.Frame(frame) module = Interpretable(parse(s, 'exec').node) try: module.run(frame) except Failure: e = sys.exc_info()[1] report_failure(e) if __name__ == '__main__': # example: def f(): return 5 def g(): return 3 def h(x): return 'never' check("f() * g() == 5") check("not f()") check("not (f() and g() or 0)") check("f() == g()") i = 4 check("i == f()") check("len(f()) == 0") check("isinstance(2+3+4, float)") run("x = i") check("x == 5") run("assert not f(), 'oops'") run("a, b, c = 1, 2") run("a, b, c = f()") check("max([f(),g()]) == 4") check("'hello'[g()] == 'h'") run("'guk%d' % h(f())")
mpl-2.0
[ 646, 1134, 199, 646, 984, 12, 6485, 199, 504, 6365, 492, 2198, 12, 6073, 12, 1134, 600, 2268, 199, 504, 1134, 423, 600, 14, 18487, 492, 22422, 14844, 12, 485, 908, 63, 15228, 199, 199, 15534, 17082, 21765, 4097, 275, 1134, 14, 5351, 423, 1786, 20160, 199, 199, 533, 20367, 26, 272, 347, 636, 826, 721, 277, 12, 1031, 304, 267, 291, 14, 2804, 12, 291, 14, 585, 12, 291, 14, 5842, 275, 984, 14, 2804, 63, 815, 342, 267, 291, 14, 932, 275, 1031, 199, 199, 533, 10935, 8, 785, 304, 272, 408, 2768, 1300, 1021, 14, 339, 982, 445, 365, 282, 5516, 402, 10935, 12, 2066, 445, 8, 88, 9, 8491, 282, 4566, 909, 6818, 272, 314, 909, 671, 14, 221, 710, 3503, 1021, 402, 314, 4566, 365, 440, 445, 315, 8605, 12, 272, 1325, 282, 627, 6083, 10, 402, 445, 12037, 701, 314, 4713, 5084, 14, 221, 4005, 5126, 26314, 272, 781, 1240, 2455, 1021, 314, 1021, 402, 314, 4566, 334, 65, 5516, 402, 445, 12, 880, 402, 10935, 9, 272, 436, 909, 1021, 314, 1021, 402, 671, 14, 339, 9382, 436, 3102, 440, 1911, 315, 314, 4566, 787, 5847, 1586, 641, 671, 14, 272, 5439, 5331, 2839, 4260, 3004, 787, 10585, 641, 314, 4566, 12, 465, 272, 12037, 701, 2399, 2455, 1021, 14, 221, 710, 909, 671, 365, 2808, 687, 314, 4566, 272, 465, 2399, 636, 1113, 363, 2225, 14, 339, 710, 2455, 1021, 7267, 365, 12037, 701, 314, 636, 1345, 363, 6346, 436, 314, 272, 2716, 636, 1345, 498, 363, 1083, 14, 221, 4885, 849, 12, 314, 4895, 2455, 1021, 365, 314, 272, 4750, 2488, 5516, 402, 445, 7447, 636, 1345, 363, 12953, 852, 314, 1021, 402, 671, 14, 272, 982, 949, 4066, 5516, 365, 1911, 12, 314, 2754, 557, 301, 5923, 543, 314, 1676, 272, 909, 3992, 14, 221, 2104, 2893, 12, 445, 8, 549, 9, 911, 1642, 3648, 367, 282, 5516, 272, 402, 445, 543, 636, 1345, 363, 275, 334, 11577, 2155, 12, 19172, 436, 1454, 340, 652, 3181, 1133, 2342, 1263, 272, 3648, 367, 1373, 543, 636, 1345, 363, 275, 334, 11577, 1109, 12, 2263, 395, 436, 2066, 14263, 909, 12, 1396, 272, 982, 8137, 6918, 314, 1021, 445, 6337, 365, 8652, 370, 506, 314, 849, 14, 339, 26776, 12, 314, 2455, 1021, 7267, 883, 506, 20921, 1856, 701, 4573, 17435, 272, 402, 314, 909, 671, 12, 3140, 402, 314, 1021, 402, 671, 12, 701, 18972, 636, 1345, 498, 4343, 272, 1666, 2061, 2893, 737, 314, 1284, 402, 642, 859, 14, 272, 408, 339, 485, 1345, 1637, 275, 1052, 272, 636, 1345, 363, 275, 6248, 339, 347, 636, 1222, 721, 1231, 533, 12, 1559, 12, 627, 589, 12, 1011, 10340, 304, 267, 291, 275, 909, 855, 1222, 721, 1231, 533, 9, 267, 291, 855, 1113, 363, 275, 1559, 267, 291, 855, 1231, 533, 363, 275, 1738, 533, 267, 790, 275, 291, 855, 1345, 498, 4533, 267, 862, 26, 288, 291, 855, 533, 363, 275, 291, 423, 1345, 1637, 59, 498, 61, 267, 871, 4067, 26, 288, 291, 855, 533, 363, 275, 291, 423, 2416, 6083, 8, 498, 9, 267, 372, 291, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 327, 3004, 440, 1911, 315, 314, 3293, 14446, 882, 5731, 641, 10935, 267, 327, 787, 21182, 1536, 315, 314, 909, 1159, 3363, 1021, 267, 372, 2519, 8, 277, 855, 1113, 3108, 1921, 9, 339, 347, 636, 1345, 498, 721, 277, 304, 267, 372, 291, 855, 1113, 4914, 533, 363, 339, 347, 636, 1431, 498, 721, 277, 12, 790, 12, 9180, 304, 267, 340, 6485, 14, 28450, 8, 498, 304, 288, 2883, 275, 6485, 14, 362, 17335, 8, 498, 9, 267, 587, 26, 288, 2883, 275, 359, 498, 61, 267, 367, 790, 315, 2883, 26, 288, 754, 275, 359, 35, 367, 445, 315, 9180, 340, 790, 315, 445, 855, 1345, 22705, 288, 340, 754, 26, 355, 372, 754, 267, 372, 942, 339, 347, 485, 2416, 6083, 8, 277, 12, 790, 304, 267, 9180, 275, 769, 8, 4869, 19094, 8, 277, 855, 1231, 533, 8964, 267, 367, 445, 315, 9180, 26, 288, 340, 440, 1228, 8, 35, 855, 1345, 3108, 2008, 304, 355, 445, 855, 1345, 363, 275, 334, 35, 855, 1345, 3108, 9, 267, 3415, 275, 291, 855, 1431, 498, 721, 498, 12, 9180, 9, 267, 340, 440, 3415, 26, 288, 372, 291, 855, 1231, 533, 363, 267, 916, 822, 8, 4577, 9, 508, 413, 26, 288, 372, 3415, 59, 16, 61, 267, 587, 26, 288, 327, 13323, 314, 3663, 3415, 288, 372, 730, 360, 7044, 2008, 8, 4577, 395, 5009, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 1543, 83, 4042, 82, 3171, 450, 334, 277, 855, 1231, 533, 4914, 354, 3108, 291, 855, 1113, 3368, 421, 199, 318, 4952, 19094, 8, 1886, 304, 272, 367, 1007, 1886, 315, 843, 855, 19094, 721, 304, 267, 367, 1007, 6083, 315, 4952, 19094, 8, 954, 1886, 304, 288, 1995, 1007, 6083, 272, 1995, 843, 421, 199, 533, 6551, 657, 1224, 8, 2768, 304, 272, 408, 33, 2198, 3123, 1031, 543, 282, 9284, 2402, 3102, 1041, 272, 17531, 275, 488, 339, 347, 365, 63, 5351, 8, 277, 12, 2787, 304, 267, 372, 756, 339, 347, 3468, 8, 277, 12, 2787, 304, 267, 327, 11264, 13, 894, 367, 5809, 3965, 3380, 267, 862, 26, 288, 5348, 275, 6073, 14, 9093, 8, 277, 855, 1113, 3368, 288, 5348, 14, 1501, 275, 2650, 2579, 3524, 288, 291, 855, 1113, 4343, 1501, 275, 2650, 2579, 3524, 288, 512, 275, 1134, 600, 2268, 14, 9093, 3034, 7599, 8, 3684, 680, 362, 3034, 342, 288, 754, 275, 2787, 14, 2579, 8, 331, 9, 267, 871, 19099, 17082, 21765, 4097, 26, 288, 746, 267, 871, 26, 288, 746, 20367, 8, 277, 9, 267, 291, 14, 1099, 275, 754, 267, 291, 14, 15228, 275, 291, 14, 15228, 503, 2787, 14, 2722, 8, 277, 14, 1099, 9, 339, 347, 1255, 8, 277, 12, 2787, 304, 267, 327, 11264, 13, 894, 367, 5809, 5164, 3380, 267, 862, 26, 288, 5348, 275, 6073, 14, 2377, 8, 403, 12, 6073, 14, 32431, 779, 277, 855, 1113, 363, 2459, 288, 5348, 14, 1501, 275, 2650, 1065, 3524, 288, 512, 275 ]
[ 1134, 199, 646, 984, 12, 6485, 199, 504, 6365, 492, 2198, 12, 6073, 12, 1134, 600, 2268, 199, 504, 1134, 423, 600, 14, 18487, 492, 22422, 14844, 12, 485, 908, 63, 15228, 199, 199, 15534, 17082, 21765, 4097, 275, 1134, 14, 5351, 423, 1786, 20160, 199, 199, 533, 20367, 26, 272, 347, 636, 826, 721, 277, 12, 1031, 304, 267, 291, 14, 2804, 12, 291, 14, 585, 12, 291, 14, 5842, 275, 984, 14, 2804, 63, 815, 342, 267, 291, 14, 932, 275, 1031, 199, 199, 533, 10935, 8, 785, 304, 272, 408, 2768, 1300, 1021, 14, 339, 982, 445, 365, 282, 5516, 402, 10935, 12, 2066, 445, 8, 88, 9, 8491, 282, 4566, 909, 6818, 272, 314, 909, 671, 14, 221, 710, 3503, 1021, 402, 314, 4566, 365, 440, 445, 315, 8605, 12, 272, 1325, 282, 627, 6083, 10, 402, 445, 12037, 701, 314, 4713, 5084, 14, 221, 4005, 5126, 26314, 272, 781, 1240, 2455, 1021, 314, 1021, 402, 314, 4566, 334, 65, 5516, 402, 445, 12, 880, 402, 10935, 9, 272, 436, 909, 1021, 314, 1021, 402, 671, 14, 339, 9382, 436, 3102, 440, 1911, 315, 314, 4566, 787, 5847, 1586, 641, 671, 14, 272, 5439, 5331, 2839, 4260, 3004, 787, 10585, 641, 314, 4566, 12, 465, 272, 12037, 701, 2399, 2455, 1021, 14, 221, 710, 909, 671, 365, 2808, 687, 314, 4566, 272, 465, 2399, 636, 1113, 363, 2225, 14, 339, 710, 2455, 1021, 7267, 365, 12037, 701, 314, 636, 1345, 363, 6346, 436, 314, 272, 2716, 636, 1345, 498, 363, 1083, 14, 221, 4885, 849, 12, 314, 4895, 2455, 1021, 365, 314, 272, 4750, 2488, 5516, 402, 445, 7447, 636, 1345, 363, 12953, 852, 314, 1021, 402, 671, 14, 272, 982, 949, 4066, 5516, 365, 1911, 12, 314, 2754, 557, 301, 5923, 543, 314, 1676, 272, 909, 3992, 14, 221, 2104, 2893, 12, 445, 8, 549, 9, 911, 1642, 3648, 367, 282, 5516, 272, 402, 445, 543, 636, 1345, 363, 275, 334, 11577, 2155, 12, 19172, 436, 1454, 340, 652, 3181, 1133, 2342, 1263, 272, 3648, 367, 1373, 543, 636, 1345, 363, 275, 334, 11577, 1109, 12, 2263, 395, 436, 2066, 14263, 909, 12, 1396, 272, 982, 8137, 6918, 314, 1021, 445, 6337, 365, 8652, 370, 506, 314, 849, 14, 339, 26776, 12, 314, 2455, 1021, 7267, 883, 506, 20921, 1856, 701, 4573, 17435, 272, 402, 314, 909, 671, 12, 3140, 402, 314, 1021, 402, 671, 12, 701, 18972, 636, 1345, 498, 4343, 272, 1666, 2061, 2893, 737, 314, 1284, 402, 642, 859, 14, 272, 408, 339, 485, 1345, 1637, 275, 1052, 272, 636, 1345, 363, 275, 6248, 339, 347, 636, 1222, 721, 1231, 533, 12, 1559, 12, 627, 589, 12, 1011, 10340, 304, 267, 291, 275, 909, 855, 1222, 721, 1231, 533, 9, 267, 291, 855, 1113, 363, 275, 1559, 267, 291, 855, 1231, 533, 363, 275, 1738, 533, 267, 790, 275, 291, 855, 1345, 498, 4533, 267, 862, 26, 288, 291, 855, 533, 363, 275, 291, 423, 1345, 1637, 59, 498, 61, 267, 871, 4067, 26, 288, 291, 855, 533, 363, 275, 291, 423, 2416, 6083, 8, 498, 9, 267, 372, 291, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 327, 3004, 440, 1911, 315, 314, 3293, 14446, 882, 5731, 641, 10935, 267, 327, 787, 21182, 1536, 315, 314, 909, 1159, 3363, 1021, 267, 372, 2519, 8, 277, 855, 1113, 3108, 1921, 9, 339, 347, 636, 1345, 498, 721, 277, 304, 267, 372, 291, 855, 1113, 4914, 533, 363, 339, 347, 636, 1431, 498, 721, 277, 12, 790, 12, 9180, 304, 267, 340, 6485, 14, 28450, 8, 498, 304, 288, 2883, 275, 6485, 14, 362, 17335, 8, 498, 9, 267, 587, 26, 288, 2883, 275, 359, 498, 61, 267, 367, 790, 315, 2883, 26, 288, 754, 275, 359, 35, 367, 445, 315, 9180, 340, 790, 315, 445, 855, 1345, 22705, 288, 340, 754, 26, 355, 372, 754, 267, 372, 942, 339, 347, 485, 2416, 6083, 8, 277, 12, 790, 304, 267, 9180, 275, 769, 8, 4869, 19094, 8, 277, 855, 1231, 533, 8964, 267, 367, 445, 315, 9180, 26, 288, 340, 440, 1228, 8, 35, 855, 1345, 3108, 2008, 304, 355, 445, 855, 1345, 363, 275, 334, 35, 855, 1345, 3108, 9, 267, 3415, 275, 291, 855, 1431, 498, 721, 498, 12, 9180, 9, 267, 340, 440, 3415, 26, 288, 372, 291, 855, 1231, 533, 363, 267, 916, 822, 8, 4577, 9, 508, 413, 26, 288, 372, 3415, 59, 16, 61, 267, 587, 26, 288, 327, 13323, 314, 3663, 3415, 288, 372, 730, 360, 7044, 2008, 8, 4577, 395, 5009, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 1543, 83, 4042, 82, 3171, 450, 334, 277, 855, 1231, 533, 4914, 354, 3108, 291, 855, 1113, 3368, 421, 199, 318, 4952, 19094, 8, 1886, 304, 272, 367, 1007, 1886, 315, 843, 855, 19094, 721, 304, 267, 367, 1007, 6083, 315, 4952, 19094, 8, 954, 1886, 304, 288, 1995, 1007, 6083, 272, 1995, 843, 421, 199, 533, 6551, 657, 1224, 8, 2768, 304, 272, 408, 33, 2198, 3123, 1031, 543, 282, 9284, 2402, 3102, 1041, 272, 17531, 275, 488, 339, 347, 365, 63, 5351, 8, 277, 12, 2787, 304, 267, 372, 756, 339, 347, 3468, 8, 277, 12, 2787, 304, 267, 327, 11264, 13, 894, 367, 5809, 3965, 3380, 267, 862, 26, 288, 5348, 275, 6073, 14, 9093, 8, 277, 855, 1113, 3368, 288, 5348, 14, 1501, 275, 2650, 2579, 3524, 288, 291, 855, 1113, 4343, 1501, 275, 2650, 2579, 3524, 288, 512, 275, 1134, 600, 2268, 14, 9093, 3034, 7599, 8, 3684, 680, 362, 3034, 342, 288, 754, 275, 2787, 14, 2579, 8, 331, 9, 267, 871, 19099, 17082, 21765, 4097, 26, 288, 746, 267, 871, 26, 288, 746, 20367, 8, 277, 9, 267, 291, 14, 1099, 275, 754, 267, 291, 14, 15228, 275, 291, 14, 15228, 503, 2787, 14, 2722, 8, 277, 14, 1099, 9, 339, 347, 1255, 8, 277, 12, 2787, 304, 267, 327, 11264, 13, 894, 367, 5809, 5164, 3380, 267, 862, 26, 288, 5348, 275, 6073, 14, 2377, 8, 403, 12, 6073, 14, 32431, 779, 277, 855, 1113, 363, 2459, 288, 5348, 14, 1501, 275, 2650, 1065, 3524, 288, 512, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
HiSPARC/station-software
user/python/Lib/idlelib/idle_test/test_warning.py
49
2757
'''Test warnings replacement in PyShell.py and run.py. This file could be expanded to include traceback overrides (in same two modules). If so, change name. Revise if output destination changes (http://bugs.python.org/issue18318). Make sure warnings module is left unaltered (http://bugs.python.org/issue18081). ''' import unittest from test.test_support import captured_stderr import warnings # Try to capture default showwarning before Idle modules are imported. showwarning = warnings.showwarning # But if we run this file within idle, we are in the middle of the run.main loop # and default showwarnings has already been replaced. running_in_idle = 'idle' in showwarning.__name__ from idlelib import run from idlelib import PyShell as shell # The following was generated from PyShell.idle_formatwarning # and checked as matching expectation. idlemsg = ''' Warning (from warnings module): File "test_warning.py", line 99 Line of code UserWarning: Test ''' shellmsg = idlemsg + ">>> " class RunWarnTest(unittest.TestCase): @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") def test_showwarnings(self): self.assertIs(warnings.showwarning, showwarning) run.capture_warnings(True) self.assertIs(warnings.showwarning, run.idle_showwarning_subproc) run.capture_warnings(False) self.assertIs(warnings.showwarning, showwarning) def test_run_show(self): with captured_stderr() as f: run.idle_showwarning_subproc( 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') # The following uses .splitlines to erase line-ending differences self.assertEqual(idlemsg.splitlines(), f.getvalue().splitlines()) class ShellWarnTest(unittest.TestCase): @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") def test_showwarnings(self): self.assertIs(warnings.showwarning, showwarning) shell.capture_warnings(True) self.assertIs(warnings.showwarning, shell.idle_showwarning) shell.capture_warnings(False) self.assertIs(warnings.showwarning, showwarning) def test_idle_formatter(self): # Will fail if format changed without regenerating idlemsg s = shell.idle_formatwarning( 'Test', UserWarning, 'test_warning.py', 99, 'Line of code') self.assertEqual(idlemsg, s) def test_shell_show(self): with captured_stderr() as f: shell.idle_showwarning( 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines()) if __name__ == '__main__': unittest.main(verbosity=2, exit=False)
gpl-3.0
[ 2344, 774, 3598, 8343, 315, 1611, 8529, 14, 647, 436, 1255, 14, 647, 14, 199, 199, 2765, 570, 4293, 506, 11507, 370, 2387, 5190, 10580, 199, 8, 262, 2011, 2877, 4621, 680, 982, 880, 12, 1570, 536, 14, 199, 497, 433, 261, 340, 1072, 5724, 4493, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 12363, 1085, 680, 199, 5483, 3238, 3598, 859, 365, 3602, 625, 279, 3014, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 1085, 19896, 680, 199, 2344, 199, 199, 646, 2882, 199, 504, 511, 14, 396, 63, 4058, 492, 17487, 63, 3083, 199, 199, 646, 3598, 199, 3, 7649, 370, 12296, 849, 930, 25268, 2544, 473, 3011, 4621, 787, 8439, 14, 199, 29109, 275, 3598, 14, 29109, 199, 3, 11017, 340, 781, 1255, 642, 570, 4453, 15072, 12, 781, 787, 315, 314, 12180, 402, 314, 1255, 14, 973, 4438, 199, 3, 436, 849, 930, 978, 2627, 965, 2575, 2757, 8717, 14, 199, 5720, 63, 262, 63, 12000, 275, 283, 12000, 7, 315, 930, 25268, 855, 354, 363, 199, 199, 504, 15072, 773, 492, 1255, 199, 504, 15072, 773, 492, 1611, 8529, 465, 5218, 199, 199, 3, 710, 2569, 1990, 4046, 687, 1611, 8529, 14, 12000, 63, 908, 3764, 199, 3, 436, 7923, 465, 4877, 17513, 14, 199, 12000, 1328, 275, 1449, 199, 3849, 334, 504, 3598, 859, 304, 523, 3814, 298, 396, 63, 3764, 14, 647, 401, 1004, 8806, 272, 7030, 402, 1233, 199, 32114, 26, 1379, 199, 2344, 199, 5641, 1328, 275, 15072, 1328, 435, 298, 6071, 298, 199, 199, 533, 3378, 22673, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 5720, 63, 262, 63, 12000, 12, 298, 6586, 440, 1736, 1380, 1255, 4453, 473, 3011, 2685, 272, 347, 511, 63, 13927, 978, 2627, 8, 277, 304, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 267, 1255, 14, 12685, 63, 5451, 8, 549, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 1255, 14, 12000, 63, 29109, 63, 954, 4687, 9, 267, 1255, 14, 12685, 63, 5451, 8, 797, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 339, 347, 511, 63, 1065, 63, 2384, 8, 277, 304, 267, 543, 17487, 63, 3083, 342, 465, 289, 26, 288, 1255, 14, 12000, 63, 29109, 63, 954, 4687, 8, 490, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 289, 12, 283, 3049, 402, 1233, 358, 288, 327, 710, 2569, 4440, 1275, 7644, 370, 28343, 1004, 13, 3219, 15109, 288, 291, 14, 629, 8, 12000, 1328, 14, 7644, 1062, 289, 14, 7150, 1252, 7644, 1012, 199, 199, 533, 24599, 22673, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 5720, 63, 262, 63, 12000, 12, 298, 6586, 440, 1736, 1380, 1255, 4453, 473, 3011, 2685, 272, 347, 511, 63, 13927, 978, 2627, 8, 277, 304, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 267, 5218, 14, 12685, 63, 5451, 8, 549, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 5218, 14, 12000, 63, 29109, 9, 267, 5218, 14, 12685, 63, 5451, 8, 797, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 339, 347, 511, 63, 12000, 63, 8911, 8, 277, 304, 267, 327, 12823, 2449, 340, 1475, 2896, 1928, 1295, 727, 1958, 15072, 1328, 267, 308, 275, 5218, 14, 12000, 63, 908, 3764, 8, 355, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 283, 3049, 402, 1233, 358, 267, 291, 14, 629, 8, 12000, 1328, 12, 308, 9, 339, 347, 511, 63, 5641, 63, 2384, 8, 277, 304, 267, 543, 17487, 63, 3083, 342, 465, 289, 26, 288, 5218, 14, 12000, 63, 29109, 8, 490, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 289, 12, 283, 3049, 402, 1233, 358, 288, 291, 14, 629, 8, 5641, 1328, 14, 7644, 1062, 289, 14, 7150, 1252, 7644, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 9833, 29, 18, 12, 4458, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 774, 3598, 8343, 315, 1611, 8529, 14, 647, 436, 1255, 14, 647, 14, 199, 199, 2765, 570, 4293, 506, 11507, 370, 2387, 5190, 10580, 199, 8, 262, 2011, 2877, 4621, 680, 982, 880, 12, 1570, 536, 14, 199, 497, 433, 261, 340, 1072, 5724, 4493, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 12363, 1085, 680, 199, 5483, 3238, 3598, 859, 365, 3602, 625, 279, 3014, 334, 1014, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 1085, 19896, 680, 199, 2344, 199, 199, 646, 2882, 199, 504, 511, 14, 396, 63, 4058, 492, 17487, 63, 3083, 199, 199, 646, 3598, 199, 3, 7649, 370, 12296, 849, 930, 25268, 2544, 473, 3011, 4621, 787, 8439, 14, 199, 29109, 275, 3598, 14, 29109, 199, 3, 11017, 340, 781, 1255, 642, 570, 4453, 15072, 12, 781, 787, 315, 314, 12180, 402, 314, 1255, 14, 973, 4438, 199, 3, 436, 849, 930, 978, 2627, 965, 2575, 2757, 8717, 14, 199, 5720, 63, 262, 63, 12000, 275, 283, 12000, 7, 315, 930, 25268, 855, 354, 363, 199, 199, 504, 15072, 773, 492, 1255, 199, 504, 15072, 773, 492, 1611, 8529, 465, 5218, 199, 199, 3, 710, 2569, 1990, 4046, 687, 1611, 8529, 14, 12000, 63, 908, 3764, 199, 3, 436, 7923, 465, 4877, 17513, 14, 199, 12000, 1328, 275, 1449, 199, 3849, 334, 504, 3598, 859, 304, 523, 3814, 298, 396, 63, 3764, 14, 647, 401, 1004, 8806, 272, 7030, 402, 1233, 199, 32114, 26, 1379, 199, 2344, 199, 5641, 1328, 275, 15072, 1328, 435, 298, 6071, 298, 199, 199, 533, 3378, 22673, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 5720, 63, 262, 63, 12000, 12, 298, 6586, 440, 1736, 1380, 1255, 4453, 473, 3011, 2685, 272, 347, 511, 63, 13927, 978, 2627, 8, 277, 304, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 267, 1255, 14, 12685, 63, 5451, 8, 549, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 1255, 14, 12000, 63, 29109, 63, 954, 4687, 9, 267, 1255, 14, 12685, 63, 5451, 8, 797, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 339, 347, 511, 63, 1065, 63, 2384, 8, 277, 304, 267, 543, 17487, 63, 3083, 342, 465, 289, 26, 288, 1255, 14, 12000, 63, 29109, 63, 954, 4687, 8, 490, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 289, 12, 283, 3049, 402, 1233, 358, 288, 327, 710, 2569, 4440, 1275, 7644, 370, 28343, 1004, 13, 3219, 15109, 288, 291, 14, 629, 8, 12000, 1328, 14, 7644, 1062, 289, 14, 7150, 1252, 7644, 1012, 199, 199, 533, 24599, 22673, 774, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 5720, 63, 262, 63, 12000, 12, 298, 6586, 440, 1736, 1380, 1255, 4453, 473, 3011, 2685, 272, 347, 511, 63, 13927, 978, 2627, 8, 277, 304, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 267, 5218, 14, 12685, 63, 5451, 8, 549, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 5218, 14, 12000, 63, 29109, 9, 267, 5218, 14, 12685, 63, 5451, 8, 797, 9, 267, 291, 14, 3436, 8, 5451, 14, 29109, 12, 930, 25268, 9, 339, 347, 511, 63, 12000, 63, 8911, 8, 277, 304, 267, 327, 12823, 2449, 340, 1475, 2896, 1928, 1295, 727, 1958, 15072, 1328, 267, 308, 275, 5218, 14, 12000, 63, 908, 3764, 8, 355, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 283, 3049, 402, 1233, 358, 267, 291, 14, 629, 8, 12000, 1328, 12, 308, 9, 339, 347, 511, 63, 5641, 63, 2384, 8, 277, 304, 267, 543, 17487, 63, 3083, 342, 465, 289, 26, 288, 5218, 14, 12000, 63, 29109, 8, 490, 283, 774, 297, 2876, 3849, 12, 283, 396, 63, 3764, 14, 647, 297, 8806, 12, 289, 12, 283, 3049, 402, 1233, 358, 288, 291, 14, 629, 8, 5641, 1328, 14, 7644, 1062, 289, 14, 7150, 1252, 7644, 1012, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 8, 9833, 29, 18, 12, 4458, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CausalityLtd/ponyc
lib/gbenchmark/tools/compare.py
7
12626
#!/usr/bin/env python """ compare.py - versatile benchmark output compare tool """ import argparse from argparse import ArgumentParser import sys import gbench from gbench import util, report from gbench.util import * def check_inputs(in1, in2, flags): """ Perform checking on the user provided inputs and diagnose any abnormalities """ in1_kind, in1_err = classify_input_file(in1) in2_kind, in2_err = classify_input_file(in2) output_file = find_benchmark_flag('--benchmark_out=', flags) output_type = find_benchmark_flag('--benchmark_out_format=', flags) if in1_kind == IT_Executable and in2_kind == IT_Executable and output_file: print(("WARNING: '--benchmark_out=%s' will be passed to both " "benchmarks causing it to be overwritten") % output_file) if in1_kind == IT_JSON and in2_kind == IT_JSON and len(flags) > 0: print("WARNING: passing optional flags has no effect since both " "inputs are JSON") if output_type is not None and output_type != 'json': print(("ERROR: passing '--benchmark_out_format=%s' to 'compare.py`" " is not supported.") % output_type) sys.exit(1) def create_parser(): parser = ArgumentParser( description='versatile benchmark output compare tool') subparsers = parser.add_subparsers( help='This tool has multiple modes of operation:', dest='mode') parser_a = subparsers.add_parser( 'benchmarks', help='The most simple use-case, compare all the output of these two benchmarks') baseline = parser_a.add_argument_group( 'baseline', 'The benchmark baseline') baseline.add_argument( 'test_baseline', metavar='test_baseline', type=argparse.FileType('r'), nargs=1, help='A benchmark executable or JSON output file') contender = parser_a.add_argument_group( 'contender', 'The benchmark that will be compared against the baseline') contender.add_argument( 'test_contender', metavar='test_contender', type=argparse.FileType('r'), nargs=1, help='A benchmark executable or JSON output file') parser_a.add_argument( 'benchmark_options', metavar='benchmark_options', nargs=argparse.REMAINDER, help='Arguments to pass when running benchmark executables') parser_b = subparsers.add_parser( 'filters', help='Compare filter one with the filter two of benchmark') baseline = parser_b.add_argument_group( 'baseline', 'The benchmark baseline') baseline.add_argument( 'test', metavar='test', type=argparse.FileType('r'), nargs=1, help='A benchmark executable or JSON output file') baseline.add_argument( 'filter_baseline', metavar='filter_baseline', type=str, nargs=1, help='The first filter, that will be used as baseline') contender = parser_b.add_argument_group( 'contender', 'The benchmark that will be compared against the baseline') contender.add_argument( 'filter_contender', metavar='filter_contender', type=str, nargs=1, help='The second filter, that will be compared against the baseline') parser_b.add_argument( 'benchmark_options', metavar='benchmark_options', nargs=argparse.REMAINDER, help='Arguments to pass when running benchmark executables') parser_c = subparsers.add_parser( 'benchmarksfiltered', help='Compare filter one of first benchmark with filter two of the second benchmark') baseline = parser_c.add_argument_group( 'baseline', 'The benchmark baseline') baseline.add_argument( 'test_baseline', metavar='test_baseline', type=argparse.FileType('r'), nargs=1, help='A benchmark executable or JSON output file') baseline.add_argument( 'filter_baseline', metavar='filter_baseline', type=str, nargs=1, help='The first filter, that will be used as baseline') contender = parser_c.add_argument_group( 'contender', 'The benchmark that will be compared against the baseline') contender.add_argument( 'test_contender', metavar='test_contender', type=argparse.FileType('r'), nargs=1, help='The second benchmark executable or JSON output file, that will be compared against the baseline') contender.add_argument( 'filter_contender', metavar='filter_contender', type=str, nargs=1, help='The second filter, that will be compared against the baseline') parser_c.add_argument( 'benchmark_options', metavar='benchmark_options', nargs=argparse.REMAINDER, help='Arguments to pass when running benchmark executables') return parser def main(): # Parse the command line flags parser = create_parser() args, unknown_args = parser.parse_known_args() assert not unknown_args benchmark_options = args.benchmark_options if args.mode == 'benchmarks': test_baseline = args.test_baseline[0].name test_contender = args.test_contender[0].name filter_baseline = '' filter_contender = '' # NOTE: if test_baseline == test_contender, you are analyzing the stdev description = 'Comparing %s to %s' % (test_baseline, test_contender) elif args.mode == 'filters': test_baseline = args.test[0].name test_contender = args.test[0].name filter_baseline = args.filter_baseline[0] filter_contender = args.filter_contender[0] # NOTE: if filter_baseline == filter_contender, you are analyzing the # stdev description = 'Comparing %s to %s (from %s)' % ( filter_baseline, filter_contender, args.test[0].name) elif args.mode == 'benchmarksfiltered': test_baseline = args.test_baseline[0].name test_contender = args.test_contender[0].name filter_baseline = args.filter_baseline[0] filter_contender = args.filter_contender[0] # NOTE: if test_baseline == test_contender and # filter_baseline == filter_contender, you are analyzing the stdev description = 'Comparing %s (from %s) to %s (from %s)' % ( filter_baseline, test_baseline, filter_contender, test_contender) else: # should never happen print("Unrecognized mode of operation: '%s'" % args.mode) exit(1) check_inputs(test_baseline, test_contender, benchmark_options) options_baseline = [] options_contender = [] if filter_baseline and filter_contender: options_baseline = ['--benchmark_filter=%s' % filter_baseline] options_contender = ['--benchmark_filter=%s' % filter_contender] # Run the benchmarks and report the results json1 = json1_orig = gbench.util.run_or_load_benchmark( test_baseline, benchmark_options + options_baseline) json2 = json2_orig = gbench.util.run_or_load_benchmark( test_contender, benchmark_options + options_contender) # Now, filter the benchmarks so that the difference report can work if filter_baseline and filter_contender: replacement = '[%s vs. %s]' % (filter_baseline, filter_contender) json1 = gbench.report.filter_benchmark( json1_orig, filter_baseline, replacement) json2 = gbench.report.filter_benchmark( json2_orig, filter_contender, replacement) # Diff and output output_lines = gbench.report.generate_difference_report(json1, json2) print(description) for ln in output_lines: print(ln) import unittest class TestParser(unittest.TestCase): def setUp(self): self.parser = create_parser() testInputs = os.path.join( os.path.dirname( os.path.realpath(__file__)), 'gbench', 'Inputs') self.testInput0 = os.path.join(testInputs, 'test_baseline_run1.json') self.testInput1 = os.path.join(testInputs, 'test_baseline_run2.json') def test_benchmarks_basic(self): parsed = self.parser.parse_args( ['benchmarks', self.testInput0, self.testInput1]) self.assertEqual(parsed.mode, 'benchmarks') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertFalse(parsed.benchmark_options) def test_benchmarks_with_remainder(self): parsed = self.parser.parse_args( ['benchmarks', self.testInput0, self.testInput1, 'd']) self.assertEqual(parsed.mode, 'benchmarks') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertEqual(parsed.benchmark_options, ['d']) def test_benchmarks_with_remainder_after_doubleminus(self): parsed = self.parser.parse_args( ['benchmarks', self.testInput0, self.testInput1, '--', 'e']) self.assertEqual(parsed.mode, 'benchmarks') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertEqual(parsed.benchmark_options, ['e']) def test_filters_basic(self): parsed = self.parser.parse_args( ['filters', self.testInput0, 'c', 'd']) self.assertEqual(parsed.mode, 'filters') self.assertEqual(parsed.test[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.filter_contender[0], 'd') self.assertFalse(parsed.benchmark_options) def test_filters_with_remainder(self): parsed = self.parser.parse_args( ['filters', self.testInput0, 'c', 'd', 'e']) self.assertEqual(parsed.mode, 'filters') self.assertEqual(parsed.test[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.filter_contender[0], 'd') self.assertEqual(parsed.benchmark_options, ['e']) def test_filters_with_remainder_after_doubleminus(self): parsed = self.parser.parse_args( ['filters', self.testInput0, 'c', 'd', '--', 'f']) self.assertEqual(parsed.mode, 'filters') self.assertEqual(parsed.test[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.filter_contender[0], 'd') self.assertEqual(parsed.benchmark_options, ['f']) def test_benchmarksfiltered_basic(self): parsed = self.parser.parse_args( ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e']) self.assertEqual(parsed.mode, 'benchmarksfiltered') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertEqual(parsed.filter_contender[0], 'e') self.assertFalse(parsed.benchmark_options) def test_benchmarksfiltered_with_remainder(self): parsed = self.parser.parse_args( ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e', 'f']) self.assertEqual(parsed.mode, 'benchmarksfiltered') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertEqual(parsed.filter_contender[0], 'e') self.assertEqual(parsed.benchmark_options[0], 'f') def test_benchmarksfiltered_with_remainder_after_doubleminus(self): parsed = self.parser.parse_args( ['benchmarksfiltered', self.testInput0, 'c', self.testInput1, 'e', '--', 'g']) self.assertEqual(parsed.mode, 'benchmarksfiltered') self.assertEqual(parsed.test_baseline[0].name, self.testInput0) self.assertEqual(parsed.filter_baseline[0], 'c') self.assertEqual(parsed.test_contender[0].name, self.testInput1) self.assertEqual(parsed.filter_contender[0], 'e') self.assertEqual(parsed.benchmark_options[0], 'g') if __name__ == '__main__': # unittest.main() main() # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # kate: tab-width: 4; replace-tabs on; indent-width 4; tab-indents: off; # kate: indent-mode python; remove-trailing-spaces modified;
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 5785, 14, 647, 446, 809, 83, 23590, 12338, 1072, 6540, 4744, 199, 624, 199, 199, 646, 7534, 199, 504, 7534, 492, 27615, 199, 646, 984, 199, 646, 486, 16571, 199, 504, 486, 16571, 492, 4884, 12, 3622, 199, 504, 486, 16571, 14, 1974, 492, 627, 421, 199, 318, 1104, 63, 3711, 8, 262, 17, 12, 315, 18, 12, 3285, 304, 272, 408, 272, 14795, 7907, 641, 314, 922, 2741, 4153, 436, 8348, 21085, 1263, 2236, 3302, 12107, 272, 408, 272, 315, 17, 63, 5091, 12, 315, 17, 63, 1508, 275, 28837, 63, 1210, 63, 493, 8, 262, 17, 9, 272, 315, 18, 63, 5091, 12, 315, 18, 63, 1508, 275, 28837, 63, 1210, 63, 493, 8, 262, 18, 9, 272, 1072, 63, 493, 275, 2342, 63, 11861, 63, 4173, 4517, 11861, 63, 548, 4009, 3285, 9, 272, 1072, 63, 466, 275, 2342, 63, 11861, 63, 4173, 4517, 11861, 63, 548, 63, 908, 4009, 3285, 9, 272, 340, 315, 17, 63, 5091, 508, 473, 52, 63, 18039, 436, 315, 18, 63, 5091, 508, 473, 52, 63, 18039, 436, 1072, 63, 493, 26, 267, 870, 9313, 9171, 26, 2850, 11861, 63, 548, 2458, 83, 7, 911, 506, 3032, 370, 3865, 298, 2049, 298, 11861, 83, 25498, 652, 370, 506, 20200, 531, 450, 1072, 63, 493, 9, 272, 340, 315, 17, 63, 5091, 508, 473, 52, 63, 6243, 436, 315, 18, 63, 5091, 508, 473, 52, 63, 6243, 436, 822, 8, 2469, 9, 690, 378, 26, 267, 870, 480, 9171, 26, 9476, 2716, 3285, 965, 949, 7763, 3967, 3865, 298, 1598, 298, 3711, 787, 4840, 531, 272, 340, 1072, 63, 466, 365, 440, 488, 436, 1072, 63, 466, 1137, 283, 1001, 356, 267, 870, 9313, 3170, 26, 9476, 2850, 11861, 63, 548, 63, 908, 2458, 83, 7, 370, 283, 5785, 14, 647, 64, 2, 2049, 298, 365, 440, 3748, 2685, 450, 1072, 63, 466, 9, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 1218, 63, 2087, 837, 272, 1798, 275, 27615, 8, 267, 1369, 534, 14895, 23590, 12338, 1072, 6540, 4744, 358, 272, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 267, 1720, 534, 2765, 4744, 965, 3663, 12404, 402, 3439, 6536, 267, 2053, 534, 632, 358, 339, 1798, 63, 65, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 11861, 83, 297, 267, 1720, 534, 1918, 4750, 3486, 675, 13, 2546, 12, 6540, 1006, 314, 1072, 402, 3520, 2877, 12338, 83, 358, 272, 18828, 275, 1798, 63, 65, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 14232, 297, 267, 8214, 534, 396, 63, 14232, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 406, 724, 424, 275, 1798, 63, 65, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 388, 724, 424, 297, 283, 1918, 12338, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 406, 724, 424, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 388, 724, 424, 297, 267, 8214, 534, 396, 63, 388, 724, 424, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 1798, 63, 65, 14, 525, 63, 2094, 8, 267, 283, 11861, 63, 1419, 297, 267, 8214, 534, 11861, 63, 1419, 297, 267, 9237, 29, 18978, 14, 907, 2054, 3192, 540, 12, 267, 1720, 534, 14517, 370, 986, 1380, 3879, 12338, 31172, 358, 339, 1798, 63, 66, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 4273, 297, 1720, 534, 16051, 2457, 1373, 543, 314, 2457, 2877, 402, 12338, 358, 272, 18828, 275, 1798, 63, 66, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 297, 267, 8214, 534, 396, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 14232, 297, 267, 8214, 534, 1541, 63, 14232, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 1642, 2457, 12, 626, 911, 506, 1202, 465, 18828, 358, 272, 406, 724, 424, 275, 1798, 63, 66, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 388, 724, 424, 297, 283, 1918, 12338, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 406, 724, 424, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 388, 724, 424, 297, 267, 8214, 534, 1541, 63, 388, 724, 424, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 3499, 2457, 12, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 1798, 63, 66, 14, 525, 63, 2094, 8, 267, 283, 11861, 63, 1419, 297, 267, 8214, 534, 11861, 63, 1419, 297, 267, 9237, 29, 18978, 14, 907, 2054, 3192, 540, 12, 267, 1720, 534, 14517, 370, 986, 1380, 3879, 12338, 31172, 358, 339, 1798, 63, 67, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 11861, 83, 11142, 297, 267, 1720, 534, 16051, 2457, 1373, 402, 1642, 12338, 543, 2457, 2877, 402, 314, 3499, 12338, 358, 272, 18828, 275, 1798, 63, 67, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 14232, 297, 267, 8214, 534, 396, 63, 14232, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 14232, 297, 267, 8214, 534, 1541, 63, 14232, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 1642, 2457, 12, 626, 911, 506, 1202, 465, 18828, 358, 272, 406, 724, 424, 275, 1798, 63, 67, 14, 525, 63, 2094 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 5785, 14, 647, 446, 809, 83, 23590, 12338, 1072, 6540, 4744, 199, 624, 199, 199, 646, 7534, 199, 504, 7534, 492, 27615, 199, 646, 984, 199, 646, 486, 16571, 199, 504, 486, 16571, 492, 4884, 12, 3622, 199, 504, 486, 16571, 14, 1974, 492, 627, 421, 199, 318, 1104, 63, 3711, 8, 262, 17, 12, 315, 18, 12, 3285, 304, 272, 408, 272, 14795, 7907, 641, 314, 922, 2741, 4153, 436, 8348, 21085, 1263, 2236, 3302, 12107, 272, 408, 272, 315, 17, 63, 5091, 12, 315, 17, 63, 1508, 275, 28837, 63, 1210, 63, 493, 8, 262, 17, 9, 272, 315, 18, 63, 5091, 12, 315, 18, 63, 1508, 275, 28837, 63, 1210, 63, 493, 8, 262, 18, 9, 272, 1072, 63, 493, 275, 2342, 63, 11861, 63, 4173, 4517, 11861, 63, 548, 4009, 3285, 9, 272, 1072, 63, 466, 275, 2342, 63, 11861, 63, 4173, 4517, 11861, 63, 548, 63, 908, 4009, 3285, 9, 272, 340, 315, 17, 63, 5091, 508, 473, 52, 63, 18039, 436, 315, 18, 63, 5091, 508, 473, 52, 63, 18039, 436, 1072, 63, 493, 26, 267, 870, 9313, 9171, 26, 2850, 11861, 63, 548, 2458, 83, 7, 911, 506, 3032, 370, 3865, 298, 2049, 298, 11861, 83, 25498, 652, 370, 506, 20200, 531, 450, 1072, 63, 493, 9, 272, 340, 315, 17, 63, 5091, 508, 473, 52, 63, 6243, 436, 315, 18, 63, 5091, 508, 473, 52, 63, 6243, 436, 822, 8, 2469, 9, 690, 378, 26, 267, 870, 480, 9171, 26, 9476, 2716, 3285, 965, 949, 7763, 3967, 3865, 298, 1598, 298, 3711, 787, 4840, 531, 272, 340, 1072, 63, 466, 365, 440, 488, 436, 1072, 63, 466, 1137, 283, 1001, 356, 267, 870, 9313, 3170, 26, 9476, 2850, 11861, 63, 548, 63, 908, 2458, 83, 7, 370, 283, 5785, 14, 647, 64, 2, 2049, 298, 365, 440, 3748, 2685, 450, 1072, 63, 466, 9, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 1218, 63, 2087, 837, 272, 1798, 275, 27615, 8, 267, 1369, 534, 14895, 23590, 12338, 1072, 6540, 4744, 358, 272, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 267, 1720, 534, 2765, 4744, 965, 3663, 12404, 402, 3439, 6536, 267, 2053, 534, 632, 358, 339, 1798, 63, 65, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 11861, 83, 297, 267, 1720, 534, 1918, 4750, 3486, 675, 13, 2546, 12, 6540, 1006, 314, 1072, 402, 3520, 2877, 12338, 83, 358, 272, 18828, 275, 1798, 63, 65, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 14232, 297, 267, 8214, 534, 396, 63, 14232, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 406, 724, 424, 275, 1798, 63, 65, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 388, 724, 424, 297, 283, 1918, 12338, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 406, 724, 424, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 388, 724, 424, 297, 267, 8214, 534, 396, 63, 388, 724, 424, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 1798, 63, 65, 14, 525, 63, 2094, 8, 267, 283, 11861, 63, 1419, 297, 267, 8214, 534, 11861, 63, 1419, 297, 267, 9237, 29, 18978, 14, 907, 2054, 3192, 540, 12, 267, 1720, 534, 14517, 370, 986, 1380, 3879, 12338, 31172, 358, 339, 1798, 63, 66, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 4273, 297, 1720, 534, 16051, 2457, 1373, 543, 314, 2457, 2877, 402, 12338, 358, 272, 18828, 275, 1798, 63, 66, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 297, 267, 8214, 534, 396, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 14232, 297, 267, 8214, 534, 1541, 63, 14232, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 1642, 2457, 12, 626, 911, 506, 1202, 465, 18828, 358, 272, 406, 724, 424, 275, 1798, 63, 66, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 388, 724, 424, 297, 283, 1918, 12338, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 406, 724, 424, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 388, 724, 424, 297, 267, 8214, 534, 1541, 63, 388, 724, 424, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 3499, 2457, 12, 626, 911, 506, 13524, 6169, 314, 18828, 358, 272, 1798, 63, 66, 14, 525, 63, 2094, 8, 267, 283, 11861, 63, 1419, 297, 267, 8214, 534, 11861, 63, 1419, 297, 267, 9237, 29, 18978, 14, 907, 2054, 3192, 540, 12, 267, 1720, 534, 14517, 370, 986, 1380, 3879, 12338, 31172, 358, 339, 1798, 63, 67, 275, 26763, 14, 525, 63, 2087, 8, 267, 283, 11861, 83, 11142, 297, 267, 1720, 534, 16051, 2457, 1373, 402, 1642, 12338, 543, 2457, 2877, 402, 314, 3499, 12338, 358, 272, 18828, 275, 1798, 63, 67, 14, 525, 63, 2094, 63, 923, 8, 267, 283, 14232, 297, 283, 1918, 12338, 18828, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 396, 63, 14232, 297, 267, 8214, 534, 396, 63, 14232, 297, 267, 730, 29, 18978, 14, 20683, 360, 82, 659, 267, 9237, 29, 17, 12, 267, 1720, 534, 33, 12338, 7286, 503, 4840, 1072, 570, 358, 272, 18828, 14, 525, 63, 2094, 8, 267, 283, 1541, 63, 14232, 297, 267, 8214, 534, 1541, 63, 14232, 297, 267, 730, 29, 495, 12, 267, 9237, 29, 17, 12, 267, 1720, 534, 1918, 1642, 2457, 12, 626, 911, 506, 1202, 465, 18828, 358, 272, 406, 724, 424, 275, 1798, 63, 67, 14, 525, 63, 2094, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
taktik/account-financial-tools
__unported__/account_move_batch_validate/__init__.py
46
1541
# -*- coding: utf-8 -*- ############################################################################### # # # Author: Leonardo Pistone # Copyright 2014 Camptocamp SA # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # # published by the Free Software Foundation, either version 3 of the # # License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU Affero General Public License for more details. # # # # You should have received a copy of the GNU Affero General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # ############################################################################### """Account Move Batch Validate.""" from . import account # noqa from . import wizard # noqa
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 6208, 3777, 327, 199, 3, 257, 6529, 26, 7005, 265, 1005, 79, 510, 631, 368, 199, 3, 257, 1898, 6927, 24569, 475, 20290, 13950, 199, 3, 6208, 3777, 327, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 420, 327, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3322, 327, 199, 3, 257, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 263, 327, 199, 3, 257, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 13235, 327, 199, 3, 6208, 3777, 327, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 3698, 327, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3322, 327, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 3777, 327, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 9668, 327, 199, 3, 6208, 3777, 327, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 221, 327, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 258, 327, 199, 3, 6208, 3777, 327, 199, 11490, 199, 624, 6009, 14171, 17206, 12134, 1041, 199, 199, 504, 1275, 492, 2933, 221, 327, 8151, 199, 504, 1275, 492, 12262, 221, 327, 8151, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 6208, 3777, 327, 199, 3, 257, 6529, 26, 7005, 265, 1005, 79, 510, 631, 368, 199, 3, 257, 1898, 6927, 24569, 475, 20290, 13950, 199, 3, 6208, 3777, 327, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 420, 327, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3322, 327, 199, 3, 257, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 263, 327, 199, 3, 257, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 13235, 327, 199, 3, 6208, 3777, 327, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 3698, 327, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3322, 327, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 3777, 327, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 9668, 327, 199, 3, 6208, 3777, 327, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 221, 327, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 258, 327, 199, 3, 6208, 3777, 327, 199, 11490, 199, 624, 6009, 14171, 17206, 12134, 1041, 199, 199, 504, 1275, 492, 2933, 221, 327, 8151, 199, 504, 1275, 492, 12262, 221, 327, 8151, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mjgrav2001/scikit-learn
benchmarks/bench_plot_ward.py
290
1260
""" Benchmark scikit-learn's Ward implement compared to SciPy's """ import time import numpy as np from scipy.cluster import hierarchy import pylab as pl from sklearn.cluster import AgglomerativeClustering ward = AgglomerativeClustering(n_clusters=3, linkage='ward') n_samples = np.logspace(.5, 3, 9) n_features = np.logspace(1, 3.5, 7) N_samples, N_features = np.meshgrid(n_samples, n_features) scikits_time = np.zeros(N_samples.shape) scipy_time = np.zeros(N_samples.shape) for i, n in enumerate(n_samples): for j, p in enumerate(n_features): X = np.random.normal(size=(n, p)) t0 = time.time() ward.fit(X) scikits_time[j, i] = time.time() - t0 t0 = time.time() hierarchy.ward(X) scipy_time[j, i] = time.time() - t0 ratio = scikits_time / scipy_time pl.figure("scikit-learn Ward's method benchmark results") pl.imshow(np.log(ratio), aspect='auto', origin="lower") pl.colorbar() pl.contour(ratio, levels=[1, ], colors='k') pl.yticks(range(len(n_features)), n_features.astype(np.int)) pl.ylabel('N features') pl.xticks(range(len(n_samples)), n_samples.astype(np.int)) pl.xlabel('N samples') pl.title("Scikit's time, in units of scipy time (log)") pl.show()
bsd-3-clause
[ 624, 199, 18644, 6276, 6065, 13, 4643, 1159, 644, 1005, 5669, 13524, 370, 16578, 2713, 1159, 199, 624, 199, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 4201, 492, 14446, 199, 646, 19199, 465, 1620, 199, 199, 504, 6357, 14, 4201, 492, 18693, 320, 278, 30498, 31174, 199, 199, 3079, 275, 18693, 320, 278, 30498, 31174, 8, 78, 63, 9170, 29, 19, 12, 26087, 534, 3079, 358, 199, 199, 78, 63, 3356, 275, 980, 14, 7270, 1142, 13417, 21, 12, 650, 12, 1749, 9, 199, 78, 63, 3179, 275, 980, 14, 7270, 1142, 8, 17, 12, 650, 14, 21, 12, 1520, 9, 199, 46, 63, 3356, 12, 653, 63, 3179, 275, 980, 14, 6480, 3825, 8, 78, 63, 3356, 12, 2511, 302, 63, 3179, 9, 199, 551, 3258, 1405, 63, 521, 275, 980, 14, 4250, 8, 46, 63, 3356, 14, 1392, 9, 199, 14248, 63, 521, 275, 980, 14, 4250, 8, 46, 63, 3356, 14, 1392, 9, 199, 199, 509, 284, 12, 302, 315, 3874, 8, 78, 63, 3356, 304, 272, 367, 1335, 12, 299, 315, 3874, 8, 78, 63, 3179, 304, 267, 1323, 275, 980, 14, 2355, 14, 3302, 8, 890, 2687, 78, 12, 299, 430, 267, 307, 16, 275, 900, 14, 521, 342, 267, 336, 1005, 14, 3269, 8, 56, 9, 267, 6276, 75, 1405, 63, 521, 59, 74, 12, 284, 61, 275, 900, 14, 521, 342, 446, 307, 16, 267, 307, 16, 275, 900, 14, 521, 342, 267, 14446, 14, 3079, 8, 56, 9, 267, 7026, 63, 521, 59, 74, 12, 284, 61, 275, 900, 14, 521, 342, 446, 307, 16, 199, 199, 6884, 275, 6276, 75, 1405, 63, 521, 1182, 7026, 63, 521, 199, 199, 1168, 14, 8941, 480, 551, 3258, 390, 13, 4643, 644, 1005, 1159, 1083, 12338, 2058, 531, 199, 1168, 14, 20413, 8, 1590, 14, 793, 8, 6884, 395, 17435, 534, 2495, 297, 6330, 628, 2325, 531, 199, 1168, 14, 30995, 342, 199, 1168, 14, 17798, 8, 6884, 12, 11106, 1524, 17, 12, 2156, 9229, 534, 75, 358, 199, 1168, 14, 30588, 8, 1842, 8, 552, 8, 78, 63, 3179, 1826, 302, 63, 3179, 14, 6041, 8, 1590, 14, 442, 430, 199, 1168, 14, 13849, 360, 46, 4534, 358, 199, 1168, 14, 26217, 8, 1842, 8, 552, 8, 78, 63, 3356, 1826, 302, 63, 3356, 14, 6041, 8, 1590, 14, 442, 430, 199, 1168, 14, 14168, 360, 46, 5845, 358, 199, 1168, 14, 1213, 480, 29231, 6065, 1159, 900, 12, 315, 6204, 402, 7026, 900, 334, 793, 6320, 199, 1168, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 18644, 6276, 6065, 13, 4643, 1159, 644, 1005, 5669, 13524, 370, 16578, 2713, 1159, 199, 624, 199, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 4201, 492, 14446, 199, 646, 19199, 465, 1620, 199, 199, 504, 6357, 14, 4201, 492, 18693, 320, 278, 30498, 31174, 199, 199, 3079, 275, 18693, 320, 278, 30498, 31174, 8, 78, 63, 9170, 29, 19, 12, 26087, 534, 3079, 358, 199, 199, 78, 63, 3356, 275, 980, 14, 7270, 1142, 13417, 21, 12, 650, 12, 1749, 9, 199, 78, 63, 3179, 275, 980, 14, 7270, 1142, 8, 17, 12, 650, 14, 21, 12, 1520, 9, 199, 46, 63, 3356, 12, 653, 63, 3179, 275, 980, 14, 6480, 3825, 8, 78, 63, 3356, 12, 2511, 302, 63, 3179, 9, 199, 551, 3258, 1405, 63, 521, 275, 980, 14, 4250, 8, 46, 63, 3356, 14, 1392, 9, 199, 14248, 63, 521, 275, 980, 14, 4250, 8, 46, 63, 3356, 14, 1392, 9, 199, 199, 509, 284, 12, 302, 315, 3874, 8, 78, 63, 3356, 304, 272, 367, 1335, 12, 299, 315, 3874, 8, 78, 63, 3179, 304, 267, 1323, 275, 980, 14, 2355, 14, 3302, 8, 890, 2687, 78, 12, 299, 430, 267, 307, 16, 275, 900, 14, 521, 342, 267, 336, 1005, 14, 3269, 8, 56, 9, 267, 6276, 75, 1405, 63, 521, 59, 74, 12, 284, 61, 275, 900, 14, 521, 342, 446, 307, 16, 267, 307, 16, 275, 900, 14, 521, 342, 267, 14446, 14, 3079, 8, 56, 9, 267, 7026, 63, 521, 59, 74, 12, 284, 61, 275, 900, 14, 521, 342, 446, 307, 16, 199, 199, 6884, 275, 6276, 75, 1405, 63, 521, 1182, 7026, 63, 521, 199, 199, 1168, 14, 8941, 480, 551, 3258, 390, 13, 4643, 644, 1005, 1159, 1083, 12338, 2058, 531, 199, 1168, 14, 20413, 8, 1590, 14, 793, 8, 6884, 395, 17435, 534, 2495, 297, 6330, 628, 2325, 531, 199, 1168, 14, 30995, 342, 199, 1168, 14, 17798, 8, 6884, 12, 11106, 1524, 17, 12, 2156, 9229, 534, 75, 358, 199, 1168, 14, 30588, 8, 1842, 8, 552, 8, 78, 63, 3179, 1826, 302, 63, 3179, 14, 6041, 8, 1590, 14, 442, 430, 199, 1168, 14, 13849, 360, 46, 4534, 358, 199, 1168, 14, 26217, 8, 1842, 8, 552, 8, 78, 63, 3356, 1826, 302, 63, 3356, 14, 6041, 8, 1590, 14, 442, 430, 199, 1168, 14, 14168, 360, 46, 5845, 358, 199, 1168, 14, 1213, 480, 29231, 6065, 1159, 900, 12, 315, 6204, 402, 7026, 900, 334, 793, 6320, 199, 1168, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
Jenselme/servo
tests/wpt/web-platform-tests/tools/pywebsocket/src/test/test_http_header_util.py
496
3372
#!/usr/bin/env python # # Copyright 2011, Google 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 Google 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. """Tests for http_header_util module.""" import unittest from mod_pywebsocket import http_header_util class UnitTest(unittest.TestCase): """A unittest for http_header_util module.""" def test_parse_relative_uri(self): host, port, resource = http_header_util.parse_uri('/ws/test') self.assertEqual(None, host) self.assertEqual(None, port) self.assertEqual('/ws/test', resource) def test_parse_absolute_uri(self): host, port, resource = http_header_util.parse_uri( 'ws://localhost:10080/ws/test') self.assertEqual('localhost', host) self.assertEqual(10080, port) self.assertEqual('/ws/test', resource) host, port, resource = http_header_util.parse_uri( 'ws://example.com/ws/test') self.assertEqual('example.com', host) self.assertEqual(80, port) self.assertEqual('/ws/test', resource) host, port, resource = http_header_util.parse_uri( 'wss://example.com/') self.assertEqual('example.com', host) self.assertEqual(443, port) self.assertEqual('/', resource) host, port, resource = http_header_util.parse_uri( 'ws://example.com:8080') self.assertEqual('example.com', host) self.assertEqual(8080, port) self.assertEqual('/', resource) def test_parse_invalid_uri(self): host, port, resource = http_header_util.parse_uri('ws:///') self.assertEqual(None, resource) host, port, resource = http_header_util.parse_uri('ws://localhost:') self.assertEqual(None, resource) host, port, resource = http_header_util.parse_uri('ws://localhost:/ws') self.assertEqual(None, resource) if __name__ == '__main__': unittest.main() # vi:sts=4 sw=4 et
mpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7760, 12, 4475, 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, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 421, 199, 624, 2925, 367, 1455, 63, 1291, 63, 1974, 859, 1041, 421, 199, 646, 2882, 199, 199, 504, 3413, 63, 21387, 492, 1455, 63, 1291, 63, 1974, 421, 199, 533, 12008, 774, 8, 2796, 14, 1746, 304, 272, 408, 33, 2882, 367, 1455, 63, 1291, 63, 1974, 859, 1041, 339, 347, 511, 63, 1122, 63, 6188, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 2336, 3569, 15, 396, 358, 267, 291, 14, 629, 8, 403, 12, 1591, 9, 267, 291, 14, 629, 8, 403, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 339, 347, 511, 63, 1122, 63, 6116, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 5967, 26, 1960, 1257, 15, 3569, 15, 396, 358, 267, 291, 14, 629, 360, 5967, 297, 1591, 9, 267, 291, 14, 629, 8, 1960, 1257, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 2694, 14, 957, 15, 3569, 15, 396, 358, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 1257, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 87, 385, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 16284, 12, 1844, 9, 267, 291, 14, 629, 10998, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 2694, 14, 957, 26, 15844, 358, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 15844, 12, 1844, 9, 267, 291, 14, 629, 10998, 2073, 9, 339, 347, 511, 63, 1122, 63, 3197, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 6217, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 5967, 10993, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 5967, 11254, 3569, 358, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7760, 12, 4475, 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, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 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, 421, 199, 624, 2925, 367, 1455, 63, 1291, 63, 1974, 859, 1041, 421, 199, 646, 2882, 199, 199, 504, 3413, 63, 21387, 492, 1455, 63, 1291, 63, 1974, 421, 199, 533, 12008, 774, 8, 2796, 14, 1746, 304, 272, 408, 33, 2882, 367, 1455, 63, 1291, 63, 1974, 859, 1041, 339, 347, 511, 63, 1122, 63, 6188, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 2336, 3569, 15, 396, 358, 267, 291, 14, 629, 8, 403, 12, 1591, 9, 267, 291, 14, 629, 8, 403, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 339, 347, 511, 63, 1122, 63, 6116, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 5967, 26, 1960, 1257, 15, 3569, 15, 396, 358, 267, 291, 14, 629, 360, 5967, 297, 1591, 9, 267, 291, 14, 629, 8, 1960, 1257, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 2694, 14, 957, 15, 3569, 15, 396, 358, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 1257, 12, 1844, 9, 267, 291, 14, 629, 2336, 3569, 15, 396, 297, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 87, 385, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 16284, 12, 1844, 9, 267, 291, 14, 629, 10998, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 8, 288, 283, 3569, 921, 2694, 14, 957, 26, 15844, 358, 267, 291, 14, 629, 360, 2694, 14, 957, 297, 1591, 9, 267, 291, 14, 629, 8, 15844, 12, 1844, 9, 267, 291, 14, 629, 10998, 2073, 9, 339, 347, 511, 63, 1122, 63, 3197, 63, 2302, 8, 277, 304, 267, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 6217, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 5967, 10993, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 398, 1591, 12, 1844, 12, 2073, 275, 1455, 63, 1291, 63, 1974, 14, 1122, 63, 2302, 360, 3569, 921, 5967, 11254, 3569, 358, 267, 291, 14, 629, 8, 403, 12, 2073, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 421, 199, 3, 1321, 26, 10329, 29, 20, 5584, 29, 20, 10844, 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, 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,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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 ]
mohamed--abdel-maksoud/chromium.src
third_party/cython/src/Cython/Distutils/build_ext.py
94
12955
"""Cython.Distutils.build_ext Implements a version of the Distutils 'build_ext' command, for building Cython extension modules.""" # This module should be kept compatible with Python 2.3. __revision__ = "$Id:$" import sys import os import re from distutils.core import Command from distutils.errors import DistutilsPlatformError from distutils.sysconfig import customize_compiler, get_python_version from distutils.dep_util import newer, newer_group from distutils import log from distutils.dir_util import mkpath from distutils.command import build_ext as _build_ext from distutils import sysconfig extension_name_re = _build_ext.extension_name_re show_compilers = _build_ext.show_compilers class Optimization(object): def __init__(self): self.flags = ( 'OPT', 'CFLAGS', 'CPPFLAGS', 'EXTRA_CFLAGS', 'BASECFLAGS', 'PY_CFLAGS', ) self.state = sysconfig.get_config_vars(*self.flags) self.config_vars = sysconfig.get_config_vars() def disable_optimization(self): "disable optimization for the C or C++ compiler" badoptions = ('-O1', '-O2', '-O3') for flag, option in zip(self.flags, self.state): if option is not None: L = [opt for opt in option.split() if opt not in badoptions] self.config_vars[flag] = ' '.join(L) def restore_state(self): "restore the original state" for flag, option in zip(self.flags, self.state): if option is not None: self.config_vars[flag] = option optimization = Optimization() class build_ext(_build_ext.build_ext): description = "build C/C++ and Cython extensions (compile/link to build directory)" sep_by = _build_ext.build_ext.sep_by user_options = _build_ext.build_ext.user_options boolean_options = _build_ext.build_ext.boolean_options help_options = _build_ext.build_ext.help_options # Add the pyrex specific data. user_options.extend([ ('cython-cplus', None, "generate C++ source files"), ('cython-create-listing', None, "write errors to a listing file"), ('cython-line-directives', None, "emit source line directives"), ('cython-include-dirs=', None, "path to the Cython include files" + sep_by), ('cython-c-in-temp', None, "put generated C files in temp directory"), ('cython-gen-pxi', None, "generate .pxi file for public declarations"), ('cython-directives=', None, "compiler directive overrides"), ('cython-gdb', None, "generate debug information for cygdb"), ('cython-compile-time-env', None, "cython compile time environment"), # For backwards compatibility. ('pyrex-cplus', None, "generate C++ source files"), ('pyrex-create-listing', None, "write errors to a listing file"), ('pyrex-line-directives', None, "emit source line directives"), ('pyrex-include-dirs=', None, "path to the Cython include files" + sep_by), ('pyrex-c-in-temp', None, "put generated C files in temp directory"), ('pyrex-gen-pxi', None, "generate .pxi file for public declarations"), ('pyrex-directives=', None, "compiler directive overrides"), ('pyrex-gdb', None, "generate debug information for cygdb"), ]) boolean_options.extend([ 'cython-cplus', 'cython-create-listing', 'cython-line-directives', 'cython-c-in-temp', 'cython-gdb', # For backwards compatibility. 'pyrex-cplus', 'pyrex-create-listing', 'pyrex-line-directives', 'pyrex-c-in-temp', 'pyrex-gdb', ]) def initialize_options(self): _build_ext.build_ext.initialize_options(self) self.cython_cplus = 0 self.cython_create_listing = 0 self.cython_line_directives = 0 self.cython_include_dirs = None self.cython_directives = None self.cython_c_in_temp = 0 self.cython_gen_pxi = 0 self.cython_gdb = False self.no_c_in_traceback = 0 self.cython_compile_time_env = None def __getattr__(self, name): if name[:6] == 'pyrex_': return getattr(self, 'cython_' + name[6:]) else: return _build_ext.build_ext.__getattr__(self, name) def __setattr__(self, name, value): if name[:6] == 'pyrex_': return setattr(self, 'cython_' + name[6:], value) else: # _build_ext.build_ext.__setattr__(self, name, value) self.__dict__[name] = value def finalize_options (self): _build_ext.build_ext.finalize_options(self) if self.cython_include_dirs is None: self.cython_include_dirs = [] elif isinstance(self.cython_include_dirs, basestring): self.cython_include_dirs = \ self.cython_include_dirs.split(os.pathsep) if self.cython_directives is None: self.cython_directives = {} # finalize_options () def run(self): # We have one shot at this before build_ext initializes the compiler. # If --pyrex-gdb is in effect as a command line option or as option # of any Extension module, disable optimization for the C or C++ # compiler. if self.cython_gdb or [1 for ext in self.extensions if getattr(ext, 'cython_gdb', False)]: optimization.disable_optimization() _build_ext.build_ext.run(self) def build_extensions(self): # First, sanity-check the 'extensions' list self.check_extensions_list(self.extensions) for ext in self.extensions: ext.sources = self.cython_sources(ext.sources, ext) self.build_extension(ext) def cython_sources(self, sources, extension): """ Walk the list of source files in 'sources', looking for Cython source files (.pyx and .py). Run Cython on all that are found, and return a modified 'sources' list with Cython source files replaced by the generated C (or C++) files. """ try: from Cython.Compiler.Main \ import CompilationOptions, \ default_options as cython_default_options, \ compile as cython_compile from Cython.Compiler.Errors import PyrexError except ImportError: e = sys.exc_info()[1] print("failed to import Cython: %s" % e) raise DistutilsPlatformError("Cython does not appear to be installed") new_sources = [] cython_sources = [] cython_targets = {} # Setup create_list and cplus from the extension options if # Cython.Distutils.extension.Extension is used, otherwise just # use what was parsed from the command-line or the configuration file. # cplus will also be set to true is extension.language is equal to # 'C++' or 'c++'. #try: # create_listing = self.cython_create_listing or \ # extension.cython_create_listing # cplus = self.cython_cplus or \ # extension.cython_cplus or \ # (extension.language != None and \ # extension.language.lower() == 'c++') #except AttributeError: # create_listing = self.cython_create_listing # cplus = self.cython_cplus or \ # (extension.language != None and \ # extension.language.lower() == 'c++') create_listing = self.cython_create_listing or \ getattr(extension, 'cython_create_listing', 0) line_directives = self.cython_line_directives or \ getattr(extension, 'cython_line_directives', 0) no_c_in_traceback = self.no_c_in_traceback or \ getattr(extension, 'no_c_in_traceback', 0) cplus = self.cython_cplus or getattr(extension, 'cython_cplus', 0) or \ (extension.language and extension.language.lower() == 'c++') cython_gen_pxi = self.cython_gen_pxi or getattr(extension, 'cython_gen_pxi', 0) cython_gdb = self.cython_gdb or getattr(extension, 'cython_gdb', False) cython_compile_time_env = self.cython_compile_time_env or \ getattr(extension, 'cython_compile_time_env', None) # Set up the include_path for the Cython compiler: # 1. Start with the command line option. # 2. Add in any (unique) paths from the extension # cython_include_dirs (if Cython.Distutils.extension is used). # 3. Add in any (unique) paths from the extension include_dirs includes = self.cython_include_dirs try: for i in extension.cython_include_dirs: if not i in includes: includes.append(i) except AttributeError: pass for i in extension.include_dirs: if not i in includes: includes.append(i) # Set up Cython compiler directives: # 1. Start with the command line option. # 2. Add in any (unique) entries from the extension # cython_directives (if Cython.Distutils.extension is used). directives = self.cython_directives if hasattr(extension, "cython_directives"): directives.update(extension.cython_directives) # Set the target_ext to '.c'. Cython will change this to '.cpp' if # needed. if cplus: target_ext = '.cpp' else: target_ext = '.c' # Decide whether to drop the generated C files into the temp dir # or the source tree. if not self.inplace and (self.cython_c_in_temp or getattr(extension, 'cython_c_in_temp', 0)): target_dir = os.path.join(self.build_temp, "pyrex") for package_name in extension.name.split('.')[:-1]: target_dir = os.path.join(target_dir, package_name) else: target_dir = None newest_dependency = None for source in sources: (base, ext) = os.path.splitext(os.path.basename(source)) if ext == ".py": # FIXME: we might want to special case this some more ext = '.pyx' if ext == ".pyx": # Cython source file output_dir = target_dir or os.path.dirname(source) new_sources.append(os.path.join(output_dir, base + target_ext)) cython_sources.append(source) cython_targets[source] = new_sources[-1] elif ext == '.pxi' or ext == '.pxd': if newest_dependency is None \ or newer(source, newest_dependency): newest_dependency = source else: new_sources.append(source) if not cython_sources: return new_sources module_name = extension.name for source in cython_sources: target = cython_targets[source] depends = [source] + list(extension.depends or ()) if(source[-4:].lower()==".pyx" and os.path.isfile(source[:-3]+"pxd")): depends += [source[:-3]+"pxd"] rebuild = self.force or newer_group(depends, target, 'newer') if not rebuild and newest_dependency is not None: rebuild = newer(newest_dependency, target) if rebuild: log.info("cythoning %s to %s", source, target) self.mkpath(os.path.dirname(target)) if self.inplace: output_dir = os.curdir else: output_dir = self.build_lib options = CompilationOptions(cython_default_options, use_listing_file = create_listing, include_path = includes, compiler_directives = directives, output_file = target, cplus = cplus, emit_linenums = line_directives, c_line_in_traceback = not no_c_in_traceback, generate_pxi = cython_gen_pxi, output_dir = output_dir, gdb_debug = cython_gdb, compile_time_env = cython_compile_time_env) result = cython_compile(source, options=options, full_module_name=module_name) else: log.info("skipping '%s' Cython extension (up-to-date)", target) return new_sources # cython_sources () # class build_ext
bsd-3-clause
[ 624, 9156, 898, 14, 12012, 1208, 14, 1506, 63, 832, 199, 199, 29452, 282, 1015, 402, 314, 12577, 283, 1506, 63, 832, 7, 1414, 12, 367, 199, 17952, 26741, 3329, 4621, 1041, 199, 199, 3, 961, 859, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 19, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 17351, 199, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 504, 7065, 14, 1018, 492, 5817, 199, 504, 7065, 14, 2550, 492, 12577, 10397, 547, 199, 504, 7065, 14, 24030, 492, 17551, 63, 5772, 12, 664, 63, 1548, 63, 1023, 199, 504, 7065, 14, 2601, 63, 1974, 492, 15666, 12, 15666, 63, 923, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 694, 63, 1974, 492, 9199, 515, 199, 504, 7065, 14, 1531, 492, 1900, 63, 832, 465, 485, 1506, 63, 832, 199, 504, 7065, 492, 22381, 199, 199, 3435, 63, 354, 63, 264, 275, 485, 1506, 63, 832, 14, 3435, 63, 354, 63, 264, 199, 199, 2384, 63, 32593, 275, 485, 1506, 63, 832, 14, 2384, 63, 32593, 199, 199, 533, 19246, 2072, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2469, 275, 334, 288, 283, 5123, 297, 288, 283, 14804, 297, 288, 283, 14533, 4831, 297, 288, 283, 18555, 63, 14804, 297, 288, 283, 5825, 14804, 297, 288, 283, 4521, 63, 14804, 297, 267, 776, 267, 291, 14, 929, 275, 22381, 14, 362, 63, 888, 63, 2936, 2031, 277, 14, 2469, 9, 267, 291, 14, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 342, 2378, 347, 3507, 63, 31405, 8, 277, 304, 267, 298, 5993, 13712, 367, 314, 445, 503, 445, 4176, 6365, 2, 267, 4875, 1419, 275, 12291, 47, 17, 297, 2475, 47, 18, 297, 2475, 47, 19, 358, 398, 367, 3305, 12, 945, 315, 3482, 8, 277, 14, 2469, 12, 291, 14, 929, 304, 288, 340, 945, 365, 440, 488, 26, 355, 491, 275, 359, 2992, 367, 2450, 315, 945, 14, 1294, 342, 340, 2450, 440, 315, 4875, 1419, 61, 355, 291, 14, 888, 63, 2936, 59, 4173, 61, 275, 283, 1987, 904, 8, 44, 9, 339, 347, 9066, 63, 929, 8, 277, 304, 267, 298, 8011, 314, 3379, 1174, 2, 267, 367, 3305, 12, 945, 315, 3482, 8, 277, 14, 2469, 12, 291, 14, 929, 304, 288, 340, 945, 365, 440, 488, 26, 355, 291, 14, 888, 63, 2936, 59, 4173, 61, 275, 945, 421, 199, 31405, 275, 19246, 2072, 342, 421, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 14, 1506, 63, 832, 304, 339, 1369, 275, 298, 1506, 445, 15, 35, 4176, 436, 26741, 5478, 334, 2014, 15, 1073, 370, 1900, 2082, 2924, 339, 7375, 63, 991, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 4127, 63, 991, 272, 922, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 751, 63, 1419, 272, 5046, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 4871, 63, 1419, 272, 1720, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 3437, 63, 1419, 339, 327, 2654, 314, 1134, 15063, 2488, 666, 14, 272, 922, 63, 1419, 14, 2880, 779, 267, 661, 20747, 13, 67, 6666, 297, 488, 12, 268, 298, 4208, 445, 4176, 1350, 1584, 1288, 267, 661, 20747, 13, 981, 13, 16115, 297, 488, 12, 268, 298, 952, 2552, 370, 282, 13778, 570, 1288, 267, 661, 20747, 13, 604, 13, 23216, 297, 488, 12, 268, 298, 8159, 1350, 1004, 13502, 1288, 267, 661, 20747, 13, 2613, 13, 3220, 4009, 488, 12, 268, 298, 515, 370, 314, 26741, 2387, 1584, 2, 435, 7375, 63, 991, 395, 267, 661, 20747, 13, 67, 13, 262, 13, 808, 297, 488, 12, 268, 298, 524, 4046, 445, 1584, 315, 2388, 2082, 1288, 267, 661, 20747, 13, 2268, 13, 5326, 73, 297, 488, 12, 288, 298, 4208, 1275, 5326, 73, 570, 367, 4575, 18707, 1288, 267, 661, 20747, 13, 23216, 4009, 488, 12, 288, 298, 5772, 13613, 10580, 1288, 267, 661, 20747, 13, 17119, 297, 488, 12, 268, 298, 4208, 3105, 2556, 367, 286, 5016, 697, 1288, 267, 661, 20747, 13, 2014, 13, 521, 13, 1813, 297, 488, 12, 288, 298, 20747, 6555, 900, 3734, 1288, 10631, 327, 2104, 8552, 7163, 14, 267, 661, 647, 15063, 13, 67, 6666, 297, 488, 12, 268, 298, 4208, 445, 4176, 1350, 1584, 1288, 267, 661, 647, 15063, 13, 981, 13, 16115, 297, 488, 12, 268, 298, 952, 2552, 370, 282, 13778, 570, 1288, 267, 661, 647, 15063, 13, 604, 13, 23216, 297, 488, 12, 268, 298, 8159, 1350, 1004, 13502, 1288, 267, 661, 647, 15063, 13, 2613, 13, 3220, 4009, 488, 12, 268, 298, 515, 370, 314, 26741, 2387, 1584, 2, 435, 7375, 63, 991, 395, 267, 661, 647, 15063, 13, 67, 13, 262, 13, 808, 297, 488, 12, 268, 298, 524, 4046, 445, 1584, 315, 2388, 2082, 1288, 267, 661, 647, 15063, 13, 2268, 13, 5326, 73, 297, 488, 12, 288, 298, 4208, 1275, 5326, 73, 570, 367, 4575, 18707, 1288, 267, 661, 647, 15063, 13, 23216, 4009, 488, 12, 288, 298, 5772, 13613, 10580, 1288, 267, 661, 647, 15063, 13, 17119, 297, 488, 12, 268, 298, 4208, 3105, 2556, 367, 286, 5016, 697, 1288, 267, 4794, 339, 5046, 63, 1419, 14, 2880, 779, 267, 283, 20747, 13, 67, 6666, 297, 283, 20747, 13, 981, 13, 16115, 297, 283, 20747, 13, 604, 13, 23216, 297, 267, 283, 20747, 13, 67, 13, 262, 13, 808, 297, 283, 20747, 13, 17119, 297, 2728, 327, 2104, 8552, 7163, 14, 267, 283, 647, 15063, 13, 67, 6666, 297, 283, 647, 15063, 13, 981, 13, 16115, 297, 283, 647, 15063, 13, 604, 13, 23216, 297, 267, 283, 647, 15063, 13, 67, 13, 262, 13, 808, 297, 283, 647, 15063, 13, 17119, 297, 272, 4794, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 20747, 63, 67, 6666, 275, 378, 267, 291, 14, 20747, 63, 981, 63, 16115, 275, 378, 267, 291, 14, 20747, 63, 604, 63, 23216, 275, 378, 267, 291, 14, 20747, 63, 2613, 63 ]
[ 9156, 898, 14, 12012, 1208, 14, 1506, 63, 832, 199, 199, 29452, 282, 1015, 402, 314, 12577, 283, 1506, 63, 832, 7, 1414, 12, 367, 199, 17952, 26741, 3329, 4621, 1041, 199, 199, 3, 961, 859, 1077, 506, 16204, 9025, 543, 2018, 499, 14, 19, 14, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 17351, 199, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 504, 7065, 14, 1018, 492, 5817, 199, 504, 7065, 14, 2550, 492, 12577, 10397, 547, 199, 504, 7065, 14, 24030, 492, 17551, 63, 5772, 12, 664, 63, 1548, 63, 1023, 199, 504, 7065, 14, 2601, 63, 1974, 492, 15666, 12, 15666, 63, 923, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 694, 63, 1974, 492, 9199, 515, 199, 504, 7065, 14, 1531, 492, 1900, 63, 832, 465, 485, 1506, 63, 832, 199, 504, 7065, 492, 22381, 199, 199, 3435, 63, 354, 63, 264, 275, 485, 1506, 63, 832, 14, 3435, 63, 354, 63, 264, 199, 199, 2384, 63, 32593, 275, 485, 1506, 63, 832, 14, 2384, 63, 32593, 199, 199, 533, 19246, 2072, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2469, 275, 334, 288, 283, 5123, 297, 288, 283, 14804, 297, 288, 283, 14533, 4831, 297, 288, 283, 18555, 63, 14804, 297, 288, 283, 5825, 14804, 297, 288, 283, 4521, 63, 14804, 297, 267, 776, 267, 291, 14, 929, 275, 22381, 14, 362, 63, 888, 63, 2936, 2031, 277, 14, 2469, 9, 267, 291, 14, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 342, 2378, 347, 3507, 63, 31405, 8, 277, 304, 267, 298, 5993, 13712, 367, 314, 445, 503, 445, 4176, 6365, 2, 267, 4875, 1419, 275, 12291, 47, 17, 297, 2475, 47, 18, 297, 2475, 47, 19, 358, 398, 367, 3305, 12, 945, 315, 3482, 8, 277, 14, 2469, 12, 291, 14, 929, 304, 288, 340, 945, 365, 440, 488, 26, 355, 491, 275, 359, 2992, 367, 2450, 315, 945, 14, 1294, 342, 340, 2450, 440, 315, 4875, 1419, 61, 355, 291, 14, 888, 63, 2936, 59, 4173, 61, 275, 283, 1987, 904, 8, 44, 9, 339, 347, 9066, 63, 929, 8, 277, 304, 267, 298, 8011, 314, 3379, 1174, 2, 267, 367, 3305, 12, 945, 315, 3482, 8, 277, 14, 2469, 12, 291, 14, 929, 304, 288, 340, 945, 365, 440, 488, 26, 355, 291, 14, 888, 63, 2936, 59, 4173, 61, 275, 945, 421, 199, 31405, 275, 19246, 2072, 342, 421, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 14, 1506, 63, 832, 304, 339, 1369, 275, 298, 1506, 445, 15, 35, 4176, 436, 26741, 5478, 334, 2014, 15, 1073, 370, 1900, 2082, 2924, 339, 7375, 63, 991, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 4127, 63, 991, 272, 922, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 751, 63, 1419, 272, 5046, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 4871, 63, 1419, 272, 1720, 63, 1419, 275, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 3437, 63, 1419, 339, 327, 2654, 314, 1134, 15063, 2488, 666, 14, 272, 922, 63, 1419, 14, 2880, 779, 267, 661, 20747, 13, 67, 6666, 297, 488, 12, 268, 298, 4208, 445, 4176, 1350, 1584, 1288, 267, 661, 20747, 13, 981, 13, 16115, 297, 488, 12, 268, 298, 952, 2552, 370, 282, 13778, 570, 1288, 267, 661, 20747, 13, 604, 13, 23216, 297, 488, 12, 268, 298, 8159, 1350, 1004, 13502, 1288, 267, 661, 20747, 13, 2613, 13, 3220, 4009, 488, 12, 268, 298, 515, 370, 314, 26741, 2387, 1584, 2, 435, 7375, 63, 991, 395, 267, 661, 20747, 13, 67, 13, 262, 13, 808, 297, 488, 12, 268, 298, 524, 4046, 445, 1584, 315, 2388, 2082, 1288, 267, 661, 20747, 13, 2268, 13, 5326, 73, 297, 488, 12, 288, 298, 4208, 1275, 5326, 73, 570, 367, 4575, 18707, 1288, 267, 661, 20747, 13, 23216, 4009, 488, 12, 288, 298, 5772, 13613, 10580, 1288, 267, 661, 20747, 13, 17119, 297, 488, 12, 268, 298, 4208, 3105, 2556, 367, 286, 5016, 697, 1288, 267, 661, 20747, 13, 2014, 13, 521, 13, 1813, 297, 488, 12, 288, 298, 20747, 6555, 900, 3734, 1288, 10631, 327, 2104, 8552, 7163, 14, 267, 661, 647, 15063, 13, 67, 6666, 297, 488, 12, 268, 298, 4208, 445, 4176, 1350, 1584, 1288, 267, 661, 647, 15063, 13, 981, 13, 16115, 297, 488, 12, 268, 298, 952, 2552, 370, 282, 13778, 570, 1288, 267, 661, 647, 15063, 13, 604, 13, 23216, 297, 488, 12, 268, 298, 8159, 1350, 1004, 13502, 1288, 267, 661, 647, 15063, 13, 2613, 13, 3220, 4009, 488, 12, 268, 298, 515, 370, 314, 26741, 2387, 1584, 2, 435, 7375, 63, 991, 395, 267, 661, 647, 15063, 13, 67, 13, 262, 13, 808, 297, 488, 12, 268, 298, 524, 4046, 445, 1584, 315, 2388, 2082, 1288, 267, 661, 647, 15063, 13, 2268, 13, 5326, 73, 297, 488, 12, 288, 298, 4208, 1275, 5326, 73, 570, 367, 4575, 18707, 1288, 267, 661, 647, 15063, 13, 23216, 4009, 488, 12, 288, 298, 5772, 13613, 10580, 1288, 267, 661, 647, 15063, 13, 17119, 297, 488, 12, 268, 298, 4208, 3105, 2556, 367, 286, 5016, 697, 1288, 267, 4794, 339, 5046, 63, 1419, 14, 2880, 779, 267, 283, 20747, 13, 67, 6666, 297, 283, 20747, 13, 981, 13, 16115, 297, 283, 20747, 13, 604, 13, 23216, 297, 267, 283, 20747, 13, 67, 13, 262, 13, 808, 297, 283, 20747, 13, 17119, 297, 2728, 327, 2104, 8552, 7163, 14, 267, 283, 647, 15063, 13, 67, 6666, 297, 283, 647, 15063, 13, 981, 13, 16115, 297, 283, 647, 15063, 13, 604, 13, 23216, 297, 267, 283, 647, 15063, 13, 67, 13, 262, 13, 808, 297, 283, 647, 15063, 13, 17119, 297, 272, 4794, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 1506, 63, 832, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 20747, 63, 67, 6666, 275, 378, 267, 291, 14, 20747, 63, 981, 63, 16115, 275, 378, 267, 291, 14, 20747, 63, 604, 63, 23216, 275, 378, 267, 291, 14, 20747, 63, 2613, 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, 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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 ]
lvdongr/spark
python/pyspark/find_spark_home.py
34
2766
#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # This script attempt to determine the correct setting for SPARK_HOME given # that Spark may have been installed on the system with pip. from __future__ import print_function import os import sys def _find_spark_home(): """Find the SPARK_HOME.""" # If the environment has SPARK_HOME set trust it. if "SPARK_HOME" in os.environ: return os.environ["SPARK_HOME"] def is_spark_home(path): """Takes a path and returns true if the provided path could be a reasonable SPARK_HOME""" return (os.path.isfile(os.path.join(path, "bin/spark-submit")) and (os.path.isdir(os.path.join(path, "jars")) or os.path.isdir(os.path.join(path, "assembly")))) paths = ["../", os.path.dirname(os.path.realpath(__file__))] # Add the path of the PySpark module if it exists if sys.version < "3": import imp try: module_home = imp.find_module("pyspark")[1] paths.append(module_home) # If we are installed in edit mode also look two dirs up paths.append(os.path.join(module_home, "../../")) except ImportError: # Not pip installed no worries pass else: from importlib.util import find_spec try: module_home = os.path.dirname(find_spec("pyspark").origin) paths.append(module_home) # If we are installed in edit mode also look two dirs up paths.append(os.path.join(module_home, "../../")) except ImportError: # Not pip installed no worries pass # Normalize the paths paths = [os.path.abspath(p) for p in paths] try: return next(path for path in paths if is_spark_home(path)) except StopIteration: print("Could not find valid SPARK_HOME while searching {0}".format(paths), file=sys.stderr) sys.exit(-1) if __name__ == "__main__": print(_find_spark_home())
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 961, 2884, 7427, 370, 6705, 314, 3211, 4260, 367, 428, 28535, 63, 9524, 1627, 199, 3, 626, 13932, 1443, 1172, 2757, 4903, 641, 314, 2656, 543, 7305, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 747, 199, 646, 984, 421, 199, 318, 485, 1623, 63, 9852, 63, 4219, 837, 272, 408, 6591, 314, 428, 28535, 63, 9524, 1041, 272, 327, 982, 314, 3734, 965, 428, 28535, 63, 9524, 663, 16822, 652, 14, 272, 340, 298, 51, 28535, 63, 9524, 2, 315, 747, 14, 2314, 26, 267, 372, 747, 14, 2314, 905, 51, 28535, 63, 9524, 937, 339, 347, 365, 63, 9852, 63, 4219, 8, 515, 304, 267, 408, 32488, 282, 931, 436, 2529, 2549, 340, 314, 2741, 931, 4293, 506, 282, 23255, 428, 28535, 63, 9524, 624, 267, 372, 334, 736, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 1393, 15, 9852, 13, 7275, 2237, 436, 355, 334, 736, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 32262, 2237, 503, 326, 747, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 17828, 2237, 430, 339, 3792, 275, 2097, 5093, 401, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 61, 339, 327, 2654, 314, 931, 402, 314, 1611, 27110, 859, 340, 652, 3495, 272, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 492, 1742, 267, 862, 26, 288, 859, 63, 4219, 275, 1742, 14, 1623, 63, 578, 480, 28911, 9981, 17, 61, 288, 3792, 14, 740, 8, 578, 63, 4219, 9, 288, 327, 982, 781, 787, 4903, 315, 5283, 818, 2597, 3648, 2877, 7606, 1536, 288, 3792, 14, 740, 8, 736, 14, 515, 14, 904, 8, 578, 63, 4219, 12, 298, 9707, 2237, 267, 871, 3545, 26, 288, 327, 2832, 7305, 4903, 949, 1319, 1996, 288, 986, 272, 587, 26, 267, 687, 14802, 14, 1974, 492, 2342, 63, 1650, 267, 862, 26, 288, 859, 63, 4219, 275, 747, 14, 515, 14, 3475, 8, 1623, 63, 1650, 480, 28911, 3471, 6493, 9, 288, 3792, 14, 740, 8, 578, 63, 4219, 9, 288, 327, 982, 781, 787, 4903, 315, 5283, 818, 2597, 3648, 2877, 7606, 1536, 288, 3792, 14, 740, 8, 736, 14, 515, 14, 904, 8, 578, 63, 4219, 12, 298, 9707, 2237, 267, 871, 3545, 26, 288, 327, 2832, 7305, 4903, 949, 1319, 1996, 288, 986, 339, 327, 21017, 314, 3792, 272, 3792, 275, 359, 736, 14, 515, 14, 4832, 8, 80, 9, 367, 299, 315, 3792, 61, 339, 862, 26, 267, 372, 2163, 8, 515, 367, 931, 315, 3792, 340, 365, 63, 9852, 63, 4219, 8, 515, 430, 272, 871, 10852, 26, 267, 870, 480, 6531, 440, 2342, 1686, 428, 28535, 63, 9524, 1830, 18112, 469, 16, 5469, 908, 8, 3771, 395, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 2801, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 870, 1547, 1623, 63, 9852, 63, 4219, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 961, 2884, 7427, 370, 6705, 314, 3211, 4260, 367, 428, 28535, 63, 9524, 1627, 199, 3, 626, 13932, 1443, 1172, 2757, 4903, 641, 314, 2656, 543, 7305, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 747, 199, 646, 984, 421, 199, 318, 485, 1623, 63, 9852, 63, 4219, 837, 272, 408, 6591, 314, 428, 28535, 63, 9524, 1041, 272, 327, 982, 314, 3734, 965, 428, 28535, 63, 9524, 663, 16822, 652, 14, 272, 340, 298, 51, 28535, 63, 9524, 2, 315, 747, 14, 2314, 26, 267, 372, 747, 14, 2314, 905, 51, 28535, 63, 9524, 937, 339, 347, 365, 63, 9852, 63, 4219, 8, 515, 304, 267, 408, 32488, 282, 931, 436, 2529, 2549, 340, 314, 2741, 931, 4293, 506, 282, 23255, 428, 28535, 63, 9524, 624, 267, 372, 334, 736, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 1393, 15, 9852, 13, 7275, 2237, 436, 355, 334, 736, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 32262, 2237, 503, 326, 747, 14, 515, 14, 6027, 8, 736, 14, 515, 14, 904, 8, 515, 12, 298, 17828, 2237, 430, 339, 3792, 275, 2097, 5093, 401, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 61, 339, 327, 2654, 314, 931, 402, 314, 1611, 27110, 859, 340, 652, 3495, 272, 340, 984, 14, 1023, 665, 298, 19, 582, 267, 492, 1742, 267, 862, 26, 288, 859, 63, 4219, 275, 1742, 14, 1623, 63, 578, 480, 28911, 9981, 17, 61, 288, 3792, 14, 740, 8, 578, 63, 4219, 9, 288, 327, 982, 781, 787, 4903, 315, 5283, 818, 2597, 3648, 2877, 7606, 1536, 288, 3792, 14, 740, 8, 736, 14, 515, 14, 904, 8, 578, 63, 4219, 12, 298, 9707, 2237, 267, 871, 3545, 26, 288, 327, 2832, 7305, 4903, 949, 1319, 1996, 288, 986, 272, 587, 26, 267, 687, 14802, 14, 1974, 492, 2342, 63, 1650, 267, 862, 26, 288, 859, 63, 4219, 275, 747, 14, 515, 14, 3475, 8, 1623, 63, 1650, 480, 28911, 3471, 6493, 9, 288, 3792, 14, 740, 8, 578, 63, 4219, 9, 288, 327, 982, 781, 787, 4903, 315, 5283, 818, 2597, 3648, 2877, 7606, 1536, 288, 3792, 14, 740, 8, 736, 14, 515, 14, 904, 8, 578, 63, 4219, 12, 298, 9707, 2237, 267, 871, 3545, 26, 288, 327, 2832, 7305, 4903, 949, 1319, 1996, 288, 986, 339, 327, 21017, 314, 3792, 272, 3792, 275, 359, 736, 14, 515, 14, 4832, 8, 80, 9, 367, 299, 315, 3792, 61, 339, 862, 26, 267, 372, 2163, 8, 515, 367, 931, 315, 3792, 340, 365, 63, 9852, 63, 4219, 8, 515, 430, 272, 871, 10852, 26, 267, 870, 480, 6531, 440, 2342, 1686, 428, 28535, 63, 9524, 1830, 18112, 469, 16, 5469, 908, 8, 3771, 395, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 2801, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 870, 1547, 1623, 63, 9852, 63, 4219, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ma314smith/home-assistant
homeassistant/components/media_player/kodi.py
3
11137
""" Support for interfacing with the XBMC/Kodi JSON-RPC API. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/media_player.kodi/ """ import logging import urllib import voluptuous as vol from homeassistant.components.media_player import ( SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK, SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_STOP, SUPPORT_TURN_OFF, MediaPlayerDevice, PLATFORM_SCHEMA) from homeassistant.const import ( STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING, CONF_HOST, CONF_NAME, CONF_PORT, CONF_USERNAME, CONF_PASSWORD) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['jsonrpc-requests==0.3'] _LOGGER = logging.getLogger(__name__) CONF_TURN_OFF_ACTION = 'turn_off_action' DEFAULT_NAME = 'Kodi' DEFAULT_PORT = 8080 TURN_OFF_ACTION = [None, 'quit', 'hibernate', 'suspend', 'reboot', 'shutdown'] SUPPORT_KODI = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK | \ SUPPORT_PLAY_MEDIA | SUPPORT_STOP PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, vol.Optional(CONF_TURN_OFF_ACTION, default=None): vol.In(TURN_OFF_ACTION), vol.Inclusive(CONF_USERNAME, 'auth'): cv.string, vol.Inclusive(CONF_PASSWORD, 'auth'): cv.string, }) def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Kodi platform.""" url = '{}:{}'.format(config.get(CONF_HOST), config.get(CONF_PORT)) jsonrpc_url = config.get('url') # deprecated if jsonrpc_url: url = jsonrpc_url.rstrip('/jsonrpc') username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) if username is not None: auth = (username, password) else: auth = None add_devices([ KodiDevice( config.get(CONF_NAME), url, auth=auth, turn_off_action=config.get(CONF_TURN_OFF_ACTION)), ]) class KodiDevice(MediaPlayerDevice): """Representation of a XBMC/Kodi device.""" def __init__(self, name, url, auth=None, turn_off_action=None): """Initialize the Kodi device.""" import jsonrpc_requests self._name = name self._url = url self._basic_auth_url = None kwargs = {'timeout': 5} if auth is not None: kwargs['auth'] = auth scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url) self._basic_auth_url = \ urllib.parse.urlunsplit((scheme, '{}:{}@{}'.format (auth[0], auth[1], netloc), path, query, fragment)) self._server = jsonrpc_requests.Server( '{}/jsonrpc'.format(self._url), **kwargs) self._turn_off_action = turn_off_action self._players = list() self._properties = None self._item = None self._app_properties = None self.update() @property def name(self): """Return the name of the device.""" return self._name def _get_players(self): """Return the active player objects or None.""" import jsonrpc_requests try: return self._server.Player.GetActivePlayers() except jsonrpc_requests.jsonrpc.TransportError: if self._players is not None: _LOGGER.warning('Unable to fetch kodi data') _LOGGER.debug('Unable to fetch kodi data', exc_info=True) return None @property def state(self): """Return the state of the device.""" if self._players is None: return STATE_OFF if len(self._players) == 0: return STATE_IDLE if self._properties['speed'] == 0 and not self._properties['live']: return STATE_PAUSED else: return STATE_PLAYING def update(self): """Retrieve latest state.""" self._players = self._get_players() if self._players is not None and len(self._players) > 0: player_id = self._players[0]['playerid'] assert isinstance(player_id, int) self._properties = self._server.Player.GetProperties( player_id, ['time', 'totaltime', 'speed', 'live'] ) self._item = self._server.Player.GetItem( player_id, ['title', 'file', 'uniqueid', 'thumbnail', 'artist'] )['item'] self._app_properties = self._server.Application.GetProperties( ['volume', 'muted'] ) else: self._properties = None self._item = None self._app_properties = None @property def volume_level(self): """Volume level of the media player (0..1).""" if self._app_properties is not None: return self._app_properties['volume'] / 100.0 @property def is_volume_muted(self): """Boolean if volume is currently muted.""" if self._app_properties is not None: return self._app_properties['muted'] @property def media_content_id(self): """Content ID of current playing media.""" if self._item is not None: return self._item.get('uniqueid', None) @property def media_content_type(self): """Content type of current playing media.""" if self._players is not None and len(self._players) > 0: return self._players[0]['type'] @property def media_duration(self): """Duration of current playing media in seconds.""" if self._properties is not None and not self._properties['live']: total_time = self._properties['totaltime'] return ( total_time['hours'] * 3600 + total_time['minutes'] * 60 + total_time['seconds']) @property def media_image_url(self): """Image url of current playing media.""" if self._item is not None: return self._get_image_url() def _get_image_url(self): """Helper function that parses the thumbnail URLs used by Kodi.""" url_components = urllib.parse.urlparse(self._item['thumbnail']) if url_components.scheme == 'image': if self._basic_auth_url is not None: return '{}/image/{}'.format( self._basic_auth_url, urllib.parse.quote_plus(self._item['thumbnail'])) return '{}/image/{}'.format( self._url, urllib.parse.quote_plus(self._item['thumbnail'])) @property def media_title(self): """Title of current playing media.""" # find a string we can use as a title if self._item is not None: return self._item.get( 'title', self._item.get('label', self._item.get('file', 'unknown'))) @property def supported_media_commands(self): """Flag of media commands that are supported.""" supported_media_commands = SUPPORT_KODI if self._turn_off_action in TURN_OFF_ACTION: supported_media_commands |= SUPPORT_TURN_OFF return supported_media_commands def turn_off(self): """Execute turn_off_action to turn off media player.""" if self._turn_off_action == 'quit': self._server.Application.Quit() elif self._turn_off_action == 'hibernate': self._server.System.Hibernate() elif self._turn_off_action == 'suspend': self._server.System.Suspend() elif self._turn_off_action == 'reboot': self._server.System.Reboot() elif self._turn_off_action == 'shutdown': self._server.System.Shutdown() else: _LOGGER.warning('turn_off requested but turn_off_action is none') self.update_ha_state() def volume_up(self): """Volume up the media player.""" assert self._server.Input.ExecuteAction('volumeup') == 'OK' self.update_ha_state() def volume_down(self): """Volume down the media player.""" assert self._server.Input.ExecuteAction('volumedown') == 'OK' self.update_ha_state() def set_volume_level(self, volume): """Set volume level, range 0..1.""" self._server.Application.SetVolume(int(volume * 100)) self.update_ha_state() def mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" self._server.Application.SetMute(mute) self.update_ha_state() def _set_play_state(self, state): """Helper method for play/pause/toggle.""" players = self._get_players() if len(players) != 0: self._server.Player.PlayPause(players[0]['playerid'], state) self.update_ha_state() def media_play_pause(self): """Pause media on media player.""" self._set_play_state('toggle') def media_play(self): """Play media.""" self._set_play_state(True) def media_pause(self): """Pause the media player.""" self._set_play_state(False) def media_stop(self): """Stop the media player.""" players = self._get_players() if len(players) != 0: self._server.Player.Stop(players[0]['playerid']) def _goto(self, direction): """Helper method used for previous/next track.""" players = self._get_players() if len(players) != 0: self._server.Player.GoTo(players[0]['playerid'], direction) self.update_ha_state() def media_next_track(self): """Send next track command.""" self._goto('next') def media_previous_track(self): """Send next track command.""" # first seek to position 0, Kodi seems to go to the beginning # of the current track current track is not at the beginning self.media_seek(0) self._goto('previous') def media_seek(self, position): """Send seek command.""" players = self._get_players() time = {} time['milliseconds'] = int((position % 1) * 1000) position = int(position) time['seconds'] = int(position % 60) position /= 60 time['minutes'] = int(position % 60) position /= 60 time['hours'] = int(position) if len(players) != 0: self._server.Player.Seek(players[0]['playerid'], time) self.update_ha_state() def play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the media player.""" if media_type == "CHANNEL": self._server.Player.Open({"item": {"channelid": int(media_id)}}) else: self._server.Player.Open({"item": {"file": str(media_id)}})
mit
[ 624, 199, 11532, 367, 1640, 32552, 543, 314, 1323, 28994, 15, 31305, 328, 4840, 13, 8171, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4603, 63, 6147, 14, 7697, 328, 15, 199, 624, 199, 646, 2050, 199, 646, 4011, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 4603, 63, 6147, 492, 334, 272, 13756, 63, 21917, 63, 19755, 12, 13756, 63, 8470, 4701, 12, 13756, 63, 28422, 25657, 63, 19755, 12, 13756, 63, 18439, 12, 272, 13756, 63, 11625, 63, 13669, 12, 13756, 63, 16689, 63, 45, 4586, 12, 13756, 63, 16689, 63, 3597, 12, 13756, 63, 11632, 12, 272, 13756, 63, 52, 7648, 63, 7517, 12, 12300, 10921, 2510, 12, 21966, 63, 10926, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 23715, 12, 11377, 63, 7517, 12, 11377, 63, 8470, 8558, 12, 11377, 63, 11625, 1206, 12, 6392, 63, 5449, 12, 6392, 63, 2339, 12, 272, 6392, 63, 3657, 12, 6392, 63, 11958, 12, 6392, 63, 9032, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 31395, 13, 6615, 389, 16, 14, 19, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 275, 283, 353, 63, 1997, 63, 1287, 7, 199, 199, 3472, 63, 2339, 275, 283, 31305, 328, 7, 199, 3472, 63, 3657, 275, 30220, 199, 199, 52, 7648, 63, 7517, 63, 10052, 275, 359, 403, 12, 283, 10589, 297, 283, 5812, 605, 78, 323, 297, 283, 14480, 297, 283, 15051, 297, 283, 8831, 418, 199, 199, 10640, 63, 24839, 1914, 275, 13756, 63, 8470, 4701, 1204, 13756, 63, 16689, 63, 3597, 1204, 13756, 63, 16689, 63, 45, 4586, 1204, 971, 272, 13756, 63, 28422, 25657, 63, 19755, 1204, 13756, 63, 21917, 63, 19755, 1204, 13756, 63, 18439, 1204, 971, 272, 13756, 63, 11625, 63, 13669, 1204, 13756, 63, 11632, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 3657, 304, 6277, 14, 719, 12, 272, 5236, 14, 7012, 8, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 12, 849, 29, 403, 304, 5236, 14, 607, 8, 52, 7648, 63, 7517, 63, 10052, 395, 272, 5236, 14, 607, 6563, 8, 3103, 63, 11958, 12, 283, 1178, 735, 6277, 14, 875, 12, 272, 5236, 14, 607, 6563, 8, 3103, 63, 9032, 12, 283, 1178, 735, 6277, 14, 875, 12, 199, 1552, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 1804, 79, 328, 4298, 1041, 272, 1166, 275, 9005, 26, 11123, 908, 8, 888, 14, 362, 8, 3103, 63, 5449, 395, 1101, 14, 362, 8, 3103, 63, 3657, 430, 339, 2022, 4354, 63, 633, 275, 1101, 14, 362, 360, 633, 358, 221, 327, 5906, 272, 340, 2022, 4354, 63, 633, 26, 267, 1166, 275, 2022, 4354, 63, 633, 14, 6735, 2336, 31395, 358, 339, 3434, 275, 1101, 14, 362, 8, 3103, 63, 11958, 9, 272, 2505, 275, 1101, 14, 362, 8, 3103, 63, 9032, 9, 339, 340, 3434, 365, 440, 488, 26, 267, 1790, 275, 334, 2473, 12, 2505, 9, 272, 587, 26, 267, 1790, 275, 488, 339, 1050, 63, 6410, 779, 267, 1804, 79, 328, 2510, 8, 288, 1101, 14, 362, 8, 3103, 63, 2339, 395, 288, 1166, 12, 288, 1790, 29, 1178, 12, 288, 7485, 63, 1997, 63, 1287, 29, 888, 14, 362, 8, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 1826, 272, 4794, 421, 199, 533, 1804, 79, 328, 2510, 8, 11398, 10921, 2510, 304, 272, 408, 20609, 402, 282, 1323, 28994, 15, 31305, 328, 2243, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1166, 12, 1790, 29, 403, 12, 7485, 63, 1997, 63, 1287, 29, 403, 304, 267, 408, 9345, 314, 1804, 79, 328, 2243, 1041, 267, 492, 2022, 4354, 63, 6615, 267, 291, 423, 354, 275, 536, 267, 291, 423, 633, 275, 1166, 267, 291, 423, 4316, 63, 1178, 63, 633, 275, 488, 398, 2074, 275, 791, 2593, 356, 959, 93, 398, 340, 1790, 365, 440, 488, 26, 288, 2074, 459, 1178, 418, 275, 1790, 288, 5687, 12, 10154, 12, 931, 12, 1827, 12, 7956, 275, 4011, 14, 1122, 14, 29491, 8, 633, 9, 288, 291, 423, 4316, 63, 1178, 63, 633, 275, 971, 355, 4011, 14, 1122, 14, 633, 30038, 1332, 5512, 12, 9005, 29930, 32, 11123, 908, 1460, 334, 1178, 59, 16, 467, 1790, 59, 17, 467, 10154, 395, 1460, 931, 12, 1827, 12, 7956, 430, 398, 291, 423, 1000, 275, 2022, 4354, 63, 6615, 14, 3120, 8, 288, 9005, 15, 31395, 1370, 908, 8, 277, 423, 633, 395, 1011, 958, 9, 398, 291, 423, 353, 63, 1997, 63, 1287, 275, 7485, 63, 1997, 63, 1287, 267, 291, 423, 20716, 275, 769, 342, 267, 291, 423, 3282, 275, 488, 267, 291, 423, 1053, 275, 488, 267, 291, 423, 571, 63, 3282, 275, 488, 267, 291, 14, 873, 342, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 2243, 1041, 267, 372, 291, 423, 354, 339, 347, 485, 362, 63, 20716, 8, 277, 304, 267, 408, 1767, 314, 4702, 7748, 2251, 503, 488, 1041, 267, 492, 2022, 4354, 63, 6615, 267, 862, 26, 288, 372, 291, 423, 1000, 14, 10921, 14, 1002, 7472, 48, 4359, 342, 267, 871, 2022, 4354, 63, 6615, 14, 31395, 14, 7836, 547, 26, 288, 340, 291, 423, 20716, 365, 440, 488, 26, 355, 485, 10186, 14, 3764, 360, 6005, 370, 5267, 20817, 328, 666, 358, 355, 485, 10186, 14, 1757, 360, 6005, 370, 5267, 20817, 328, 666, 297, 3178, 63, 815, 29, 549, 9, 288, 372, 488, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408 ]
[ 199, 11532, 367, 1640, 32552, 543, 314, 1323, 28994, 15, 31305, 328, 4840, 13, 8171, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4603, 63, 6147, 14, 7697, 328, 15, 199, 624, 199, 646, 2050, 199, 646, 4011, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 4603, 63, 6147, 492, 334, 272, 13756, 63, 21917, 63, 19755, 12, 13756, 63, 8470, 4701, 12, 13756, 63, 28422, 25657, 63, 19755, 12, 13756, 63, 18439, 12, 272, 13756, 63, 11625, 63, 13669, 12, 13756, 63, 16689, 63, 45, 4586, 12, 13756, 63, 16689, 63, 3597, 12, 13756, 63, 11632, 12, 272, 13756, 63, 52, 7648, 63, 7517, 12, 12300, 10921, 2510, 12, 21966, 63, 10926, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 23715, 12, 11377, 63, 7517, 12, 11377, 63, 8470, 8558, 12, 11377, 63, 11625, 1206, 12, 6392, 63, 5449, 12, 6392, 63, 2339, 12, 272, 6392, 63, 3657, 12, 6392, 63, 11958, 12, 6392, 63, 9032, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 29168, 20967, 275, 788, 31395, 13, 6615, 389, 16, 14, 19, 418, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 275, 283, 353, 63, 1997, 63, 1287, 7, 199, 199, 3472, 63, 2339, 275, 283, 31305, 328, 7, 199, 3472, 63, 3657, 275, 30220, 199, 199, 52, 7648, 63, 7517, 63, 10052, 275, 359, 403, 12, 283, 10589, 297, 283, 5812, 605, 78, 323, 297, 283, 14480, 297, 283, 15051, 297, 283, 8831, 418, 199, 199, 10640, 63, 24839, 1914, 275, 13756, 63, 8470, 4701, 1204, 13756, 63, 16689, 63, 3597, 1204, 13756, 63, 16689, 63, 45, 4586, 1204, 971, 272, 13756, 63, 28422, 25657, 63, 19755, 1204, 13756, 63, 21917, 63, 19755, 1204, 13756, 63, 18439, 1204, 971, 272, 13756, 63, 11625, 63, 13669, 1204, 13756, 63, 11632, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 3657, 304, 6277, 14, 719, 12, 272, 5236, 14, 7012, 8, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 12, 849, 29, 403, 304, 5236, 14, 607, 8, 52, 7648, 63, 7517, 63, 10052, 395, 272, 5236, 14, 607, 6563, 8, 3103, 63, 11958, 12, 283, 1178, 735, 6277, 14, 875, 12, 272, 5236, 14, 607, 6563, 8, 3103, 63, 9032, 12, 283, 1178, 735, 6277, 14, 875, 12, 199, 1552, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 1804, 79, 328, 4298, 1041, 272, 1166, 275, 9005, 26, 11123, 908, 8, 888, 14, 362, 8, 3103, 63, 5449, 395, 1101, 14, 362, 8, 3103, 63, 3657, 430, 339, 2022, 4354, 63, 633, 275, 1101, 14, 362, 360, 633, 358, 221, 327, 5906, 272, 340, 2022, 4354, 63, 633, 26, 267, 1166, 275, 2022, 4354, 63, 633, 14, 6735, 2336, 31395, 358, 339, 3434, 275, 1101, 14, 362, 8, 3103, 63, 11958, 9, 272, 2505, 275, 1101, 14, 362, 8, 3103, 63, 9032, 9, 339, 340, 3434, 365, 440, 488, 26, 267, 1790, 275, 334, 2473, 12, 2505, 9, 272, 587, 26, 267, 1790, 275, 488, 339, 1050, 63, 6410, 779, 267, 1804, 79, 328, 2510, 8, 288, 1101, 14, 362, 8, 3103, 63, 2339, 395, 288, 1166, 12, 288, 1790, 29, 1178, 12, 288, 7485, 63, 1997, 63, 1287, 29, 888, 14, 362, 8, 3103, 63, 52, 7648, 63, 7517, 63, 10052, 1826, 272, 4794, 421, 199, 533, 1804, 79, 328, 2510, 8, 11398, 10921, 2510, 304, 272, 408, 20609, 402, 282, 1323, 28994, 15, 31305, 328, 2243, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1166, 12, 1790, 29, 403, 12, 7485, 63, 1997, 63, 1287, 29, 403, 304, 267, 408, 9345, 314, 1804, 79, 328, 2243, 1041, 267, 492, 2022, 4354, 63, 6615, 267, 291, 423, 354, 275, 536, 267, 291, 423, 633, 275, 1166, 267, 291, 423, 4316, 63, 1178, 63, 633, 275, 488, 398, 2074, 275, 791, 2593, 356, 959, 93, 398, 340, 1790, 365, 440, 488, 26, 288, 2074, 459, 1178, 418, 275, 1790, 288, 5687, 12, 10154, 12, 931, 12, 1827, 12, 7956, 275, 4011, 14, 1122, 14, 29491, 8, 633, 9, 288, 291, 423, 4316, 63, 1178, 63, 633, 275, 971, 355, 4011, 14, 1122, 14, 633, 30038, 1332, 5512, 12, 9005, 29930, 32, 11123, 908, 1460, 334, 1178, 59, 16, 467, 1790, 59, 17, 467, 10154, 395, 1460, 931, 12, 1827, 12, 7956, 430, 398, 291, 423, 1000, 275, 2022, 4354, 63, 6615, 14, 3120, 8, 288, 9005, 15, 31395, 1370, 908, 8, 277, 423, 633, 395, 1011, 958, 9, 398, 291, 423, 353, 63, 1997, 63, 1287, 275, 7485, 63, 1997, 63, 1287, 267, 291, 423, 20716, 275, 769, 342, 267, 291, 423, 3282, 275, 488, 267, 291, 423, 1053, 275, 488, 267, 291, 423, 571, 63, 3282, 275, 488, 267, 291, 14, 873, 342, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 2243, 1041, 267, 372, 291, 423, 354, 339, 347, 485, 362, 63, 20716, 8, 277, 304, 267, 408, 1767, 314, 4702, 7748, 2251, 503, 488, 1041, 267, 492, 2022, 4354, 63, 6615, 267, 862, 26, 288, 372, 291, 423, 1000, 14, 10921, 14, 1002, 7472, 48, 4359, 342, 267, 871, 2022, 4354, 63, 6615, 14, 31395, 14, 7836, 547, 26, 288, 340, 291, 423, 20716, 365, 440, 488, 26, 355, 485, 10186, 14, 3764, 360, 6005, 370, 5267, 20817, 328, 666, 358, 355, 485, 10186, 14, 1757, 360, 6005, 370, 5267, 20817, 328, 666, 297, 3178, 63, 815, 29, 549, 9, 288, 372, 488, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 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,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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 ]
valentin-krasontovitsch/ansible
lib/ansible/modules/cloud/scaleway/scaleway_security_group_rule.py
28
7313
#!/usr/bin/python # # Scaleway Security Group Rule management module # # Copyright (C) 2018 Antoine Barbare (antoinebarbare@gmail.com). # # GNU General Public License v3.0+ (see COPYING or # https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' --- module: scaleway_security_group_rule short_description: Scaleway Security Group Rule management module version_added: "2.8" author: Antoine Barbare (@abarbare) description: - This module manages Security Group Rule on Scaleway account U(https://developer.scaleway.com) extends_documentation_fragment: scaleway options: state: description: - Indicate desired state of the Security Group Rule. default: present choices: - present - absent region: description: - Scaleway region to use (for example C(par1)). required: true choices: - ams1 - EMEA-NL-EVS - par1 - EMEA-FR-PAR1 protocol: description: - Network protocol to use choices: - TCP - UDP - ICMP required: true port: description: - Port related to the rule, null value for all the ports required: true type: int ip_range: description: - IPV4 CIDR notation to apply to the rule default: 0.0.0.0/0 direction: description: - Rule direction choices: - inbound - outbound required: true action: description: - Rule action choices: - accept - drop required: true security_group: description: - Security Group unique identifier required: true ''' EXAMPLES = ''' - name: Create a Security Group Rule scaleway_security_group_rule: state: present region: par1 protocol: TCP port: 80 ip_range: 0.0.0.0/0 direction: inbound action: accept security_group: b57210ee-1281-4820-a6db-329f78596ecb register: security_group_rule_creation_task ''' RETURN = ''' data: description: This is only present when C(state=present) returned: when C(state=present) type: dict sample: { "scaleway_security_group_rule": { "direction": "inbound", "protocol": "TCP", "ip_range": "0.0.0.0/0", "dest_port_from": 80, "action": "accept", "position": 2, "dest_port_to": null, "editable": null, "id": "10cb0b9a-80f6-4830-abd7-a31cd828b5e9" } } ''' from ansible.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object from ansible.module_utils.compat.ipaddress import ip_network from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule def get_sgr_from_api(security_group_rules, security_group_rule): """ Check if a security_group_rule specs are present in security_group_rules Return None if no rules match the specs Return the rule if found """ for sgr in security_group_rules: if (sgr['ip_range'] == security_group_rule['ip_range'] and sgr['dest_port_from'] == security_group_rule['dest_port_from'] and sgr['direction'] == security_group_rule['direction'] and sgr['action'] == security_group_rule['action'] and sgr['protocol'] == security_group_rule['protocol']): return sgr return None def present_strategy(api, security_group_id, security_group_rule): ret = {'changed': False} response = api.get('security_groups/%s/rules' % security_group_id) if not response.ok: api.module.fail_json( msg='Error getting security group rules "%s": "%s" (%s)' % (response.info['msg'], response.json['message'], response.json)) existing_rule = get_sgr_from_api( response.json['rules'], security_group_rule) if not existing_rule: ret['changed'] = True if api.module.check_mode: return ret # Create Security Group Rule response = api.post('/security_groups/%s/rules' % security_group_id, data=payload_from_object(security_group_rule)) if not response.ok: api.module.fail_json( msg='Error during security group rule creation: "%s": "%s" (%s)' % (response.info['msg'], response.json['message'], response.json)) ret['scaleway_security_group_rule'] = response.json['rule'] else: ret['scaleway_security_group_rule'] = existing_rule return ret def absent_strategy(api, security_group_id, security_group_rule): ret = {'changed': False} response = api.get('security_groups/%s/rules' % security_group_id) if not response.ok: api.module.fail_json( msg='Error getting security group rules "%s": "%s" (%s)' % (response.info['msg'], response.json['message'], response.json)) existing_rule = get_sgr_from_api( response.json['rules'], security_group_rule) if not existing_rule: return ret ret['changed'] = True if api.module.check_mode: return ret response = api.delete( '/security_groups/%s/rules/%s' % (security_group_id, existing_rule['id'])) if not response.ok: api.module.fail_json( msg='Error deleting security group rule "%s": "%s" (%s)' % (response.info['msg'], response.json['message'], response.json)) return ret def core(module): api = Scaleway(module=module) security_group_rule = { 'protocol': module.params['protocol'], 'dest_port_from': module.params['port'], 'ip_range': module.params['ip_range'], 'direction': module.params['direction'], 'action': module.params['action'], } region = module.params['region'] module.params['api_url'] = SCALEWAY_LOCATION[region]['api_endpoint'] if module.params['state'] == 'present': summary = present_strategy( api=api, security_group_id=module.params['security_group'], security_group_rule=security_group_rule) else: summary = absent_strategy( api=api, security_group_id=module.params['security_group'], security_group_rule=security_group_rule) module.exit_json(**summary) def main(): argument_spec = scaleway_argument_spec() argument_spec.update(dict( state=dict(default='present', choices=['absent', 'present']), region=dict(required=True, choices=SCALEWAY_LOCATION.keys()), protocol=dict(required=True, choices=['TCP', 'UDP', 'ICMP']), port=dict(required=True, type=int), ip_range=dict(default='0.0.0.0/0', type=lambda x: to_text(ip_network(to_text(x)))), direction=dict(required=True, choices=['inbound', 'outbound']), action=dict(required=True, choices=['accept', 'drop']), security_group=dict(required=True), )) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) core(module) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 22869, 3316, 13863, 5611, 11949, 10041, 859, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 437, 29680, 1132, 699, 10325, 1530, 334, 290, 475, 1132, 1700, 14890, 32, 6799, 14, 957, 680, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 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, 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, 9387, 7, 199, 93, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4666, 3316, 63, 4416, 63, 923, 63, 2200, 199, 3612, 63, 1802, 26, 22869, 3316, 13863, 5611, 11949, 10041, 859, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 2502, 26, 437, 29680, 1132, 699, 10325, 1530, 8593, 371, 10325, 1530, 9, 199, 1802, 26, 272, 446, 961, 859, 31965, 13863, 5611, 11949, 641, 22869, 3316, 2933, 489, 738, 8, 2859, 921, 11071, 14, 3467, 3316, 14, 957, 9, 199, 11036, 63, 9970, 63, 7677, 26, 4666, 3316, 199, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 1010, 10188, 6387, 1174, 402, 314, 13863, 5611, 11949, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 819, 4897, 26, 272, 1369, 26, 489, 446, 22869, 3316, 4897, 370, 675, 334, 509, 2893, 445, 8, 462, 17, 4992, 272, 1415, 26, 2549, 272, 3415, 26, 489, 446, 282, 706, 17, 489, 446, 662, 3635, 33, 13, 14176, 13, 37, 7428, 489, 446, 623, 17, 489, 446, 662, 3635, 33, 13, 5372, 13, 4014, 17, 819, 4113, 26, 272, 1369, 26, 489, 446, 7220, 4113, 370, 675, 272, 3415, 26, 489, 446, 13488, 489, 446, 21802, 489, 446, 473, 23181, 272, 1415, 26, 2549, 819, 1844, 26, 272, 1369, 26, 489, 446, 10977, 4048, 370, 314, 2332, 12, 2973, 574, 367, 1006, 314, 8873, 272, 1415, 26, 2549, 272, 730, 26, 1109, 819, 3384, 63, 1842, 26, 272, 1369, 26, 489, 446, 3531, 54, 20, 29215, 15843, 370, 4838, 370, 314, 2332, 272, 849, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 819, 7581, 26, 272, 1369, 26, 489, 446, 11949, 7581, 272, 3415, 26, 489, 446, 30819, 489, 446, 734, 3556, 272, 1415, 26, 2549, 819, 1595, 26, 272, 1369, 26, 489, 446, 11949, 1595, 272, 3415, 26, 489, 446, 4729, 489, 446, 5978, 272, 1415, 26, 2549, 819, 6391, 63, 923, 26, 272, 1369, 26, 489, 446, 13863, 5611, 3747, 5148, 272, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 523, 446, 536, 26, 2790, 282, 13863, 5611, 11949, 272, 4666, 3316, 63, 4416, 63, 923, 63, 2200, 26, 489, 1174, 26, 3451, 489, 4897, 26, 623, 17, 489, 4113, 26, 13488, 489, 1844, 26, 5939, 489, 3384, 63, 1842, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 489, 7581, 26, 30819, 489, 1595, 26, 4729, 489, 6391, 63, 923, 26, 330, 1641, 12725, 1024, 13, 713, 2835, 13, 2006, 1165, 13, 65, 22, 697, 13, 11685, 70, 2277, 15112, 25467, 272, 2274, 26, 6391, 63, 923, 63, 2200, 63, 8782, 63, 1765, 199, 2344, 199, 199, 9677, 275, 1449, 199, 576, 26, 272, 1369, 26, 961, 365, 1454, 3451, 1380, 445, 8, 929, 29, 1881, 9, 272, 2138, 26, 1380, 445, 8, 929, 29, 1881, 9, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 3467, 3316, 63, 4416, 63, 923, 63, 2200, 582, 469, 288, 298, 6874, 582, 298, 26108, 401, 288, 298, 3922, 582, 298, 9735, 401, 288, 298, 711, 63, 1842, 582, 298, 16, 14, 16, 14, 16, 14, 16, 15, 16, 401, 288, 298, 2614, 63, 719, 63, 504, 582, 5939, 12, 288, 298, 1287, 582, 298, 5694, 401, 288, 298, 3124, 582, 499, 12, 288, 298, 2614, 63, 719, 63, 475, 582, 2973, 12, 288, 298, 10820, 582, 2973, 12, 288, 298, 344, 582, 298, 709, 2894, 16, 66, 25, 65, 13, 1257, 70, 22, 13, 2006, 1216, 13, 25492, 23, 13, 65, 2192, 2866, 32043, 66, 21, 69, 25, 2, 267, 789, 272, 789, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 3467, 3316, 492, 12075, 28553, 17488, 63, 16575, 12, 4666, 3316, 63, 2094, 63, 1650, 12, 22869, 3316, 12, 4886, 63, 504, 63, 785, 199, 504, 3242, 14, 578, 63, 1208, 14, 5819, 14, 21809, 492, 3384, 63, 1200, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 664, 63, 1226, 82, 63, 504, 63, 1246, 8, 4416, 63, 923, 63, 4423, 12, 6391, 63, 923, 63, 2200, 304, 272, 408, 2670, 340, 282, 6391, 63, 923, 63, 2200, 15941, 787, 3451, 315, 6391, 63, 923, 63, 4423, 267, 1432, 488, 340, 949, 4713, 1336, 314, 15941, 267, 1432, 314, 2332, 340, 1911, 272, 408, 272, 367, 308, 2587, 315, 6391, 63, 923, 63, 4423, 26, 267, 340, 334, 1226, 82, 459, 711, 63, 1842, 418, 508, 6391, 63, 923, 63, 2200, 459, 711, 63, 1842, 418, 436, 308, 2587, 459, 2614, 63, 719, 63, 504, 418, 508, 6391, 63, 923, 63, 2200, 459, 2614, 63, 719, 63, 504, 418, 436, 288, 308, 2587, 459, 6874, 418, 508, 6391, 63, 923, 63, 2200, 459, 6874, 418, 436, 308, 2587, 459, 1287, 418, 508, 6391, 63, 923, 63, 2200, 459, 1287, 418, 436, 355, 308, 2587, 459, 3922, 418, 508, 6391, 63, 923, 63, 2200, 459, 3922, 9090, 288, 372, 308, 2587, 339, 372, 488, 421, 199, 318, 3451, 63, 8590, 8, 1246, 12, 6391, 63, 923, 63, 344, 12, 6391, 63, 923, 63, 2200, 304, 272, 2203, 275, 791, 2489, 356, 756, 93, 339, 1177, 275, 2986, 14, 362, 360, 4416, 63, 2634, 3149, 83, 15, 4423, 7, 450 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 22869, 3316, 13863, 5611, 11949, 10041, 859, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 437, 29680, 1132, 699, 10325, 1530, 334, 290, 475, 1132, 1700, 14890, 32, 6799, 14, 957, 680, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 199, 3, 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, 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, 9387, 7, 199, 93, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4666, 3316, 63, 4416, 63, 923, 63, 2200, 199, 3612, 63, 1802, 26, 22869, 3316, 13863, 5611, 11949, 10041, 859, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 2502, 26, 437, 29680, 1132, 699, 10325, 1530, 8593, 371, 10325, 1530, 9, 199, 1802, 26, 272, 446, 961, 859, 31965, 13863, 5611, 11949, 641, 22869, 3316, 2933, 489, 738, 8, 2859, 921, 11071, 14, 3467, 3316, 14, 957, 9, 199, 11036, 63, 9970, 63, 7677, 26, 4666, 3316, 199, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 1010, 10188, 6387, 1174, 402, 314, 13863, 5611, 11949, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 819, 4897, 26, 272, 1369, 26, 489, 446, 22869, 3316, 4897, 370, 675, 334, 509, 2893, 445, 8, 462, 17, 4992, 272, 1415, 26, 2549, 272, 3415, 26, 489, 446, 282, 706, 17, 489, 446, 662, 3635, 33, 13, 14176, 13, 37, 7428, 489, 446, 623, 17, 489, 446, 662, 3635, 33, 13, 5372, 13, 4014, 17, 819, 4113, 26, 272, 1369, 26, 489, 446, 7220, 4113, 370, 675, 272, 3415, 26, 489, 446, 13488, 489, 446, 21802, 489, 446, 473, 23181, 272, 1415, 26, 2549, 819, 1844, 26, 272, 1369, 26, 489, 446, 10977, 4048, 370, 314, 2332, 12, 2973, 574, 367, 1006, 314, 8873, 272, 1415, 26, 2549, 272, 730, 26, 1109, 819, 3384, 63, 1842, 26, 272, 1369, 26, 489, 446, 3531, 54, 20, 29215, 15843, 370, 4838, 370, 314, 2332, 272, 849, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 819, 7581, 26, 272, 1369, 26, 489, 446, 11949, 7581, 272, 3415, 26, 489, 446, 30819, 489, 446, 734, 3556, 272, 1415, 26, 2549, 819, 1595, 26, 272, 1369, 26, 489, 446, 11949, 1595, 272, 3415, 26, 489, 446, 4729, 489, 446, 5978, 272, 1415, 26, 2549, 819, 6391, 63, 923, 26, 272, 1369, 26, 489, 446, 13863, 5611, 3747, 5148, 272, 1415, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 523, 446, 536, 26, 2790, 282, 13863, 5611, 11949, 272, 4666, 3316, 63, 4416, 63, 923, 63, 2200, 26, 489, 1174, 26, 3451, 489, 4897, 26, 623, 17, 489, 4113, 26, 13488, 489, 1844, 26, 5939, 489, 3384, 63, 1842, 26, 378, 14, 16, 14, 16, 14, 16, 15, 16, 489, 7581, 26, 30819, 489, 1595, 26, 4729, 489, 6391, 63, 923, 26, 330, 1641, 12725, 1024, 13, 713, 2835, 13, 2006, 1165, 13, 65, 22, 697, 13, 11685, 70, 2277, 15112, 25467, 272, 2274, 26, 6391, 63, 923, 63, 2200, 63, 8782, 63, 1765, 199, 2344, 199, 199, 9677, 275, 1449, 199, 576, 26, 272, 1369, 26, 961, 365, 1454, 3451, 1380, 445, 8, 929, 29, 1881, 9, 272, 2138, 26, 1380, 445, 8, 929, 29, 1881, 9, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 3467, 3316, 63, 4416, 63, 923, 63, 2200, 582, 469, 288, 298, 6874, 582, 298, 26108, 401, 288, 298, 3922, 582, 298, 9735, 401, 288, 298, 711, 63, 1842, 582, 298, 16, 14, 16, 14, 16, 14, 16, 15, 16, 401, 288, 298, 2614, 63, 719, 63, 504, 582, 5939, 12, 288, 298, 1287, 582, 298, 5694, 401, 288, 298, 3124, 582, 499, 12, 288, 298, 2614, 63, 719, 63, 475, 582, 2973, 12, 288, 298, 10820, 582, 2973, 12, 288, 298, 344, 582, 298, 709, 2894, 16, 66, 25, 65, 13, 1257, 70, 22, 13, 2006, 1216, 13, 25492, 23, 13, 65, 2192, 2866, 32043, 66, 21, 69, 25, 2, 267, 789, 272, 789, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 3467, 3316, 492, 12075, 28553, 17488, 63, 16575, 12, 4666, 3316, 63, 2094, 63, 1650, 12, 22869, 3316, 12, 4886, 63, 504, 63, 785, 199, 504, 3242, 14, 578, 63, 1208, 14, 5819, 14, 21809, 492, 3384, 63, 1200, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 664, 63, 1226, 82, 63, 504, 63, 1246, 8, 4416, 63, 923, 63, 4423, 12, 6391, 63, 923, 63, 2200, 304, 272, 408, 2670, 340, 282, 6391, 63, 923, 63, 2200, 15941, 787, 3451, 315, 6391, 63, 923, 63, 4423, 267, 1432, 488, 340, 949, 4713, 1336, 314, 15941, 267, 1432, 314, 2332, 340, 1911, 272, 408, 272, 367, 308, 2587, 315, 6391, 63, 923, 63, 4423, 26, 267, 340, 334, 1226, 82, 459, 711, 63, 1842, 418, 508, 6391, 63, 923, 63, 2200, 459, 711, 63, 1842, 418, 436, 308, 2587, 459, 2614, 63, 719, 63, 504, 418, 508, 6391, 63, 923, 63, 2200, 459, 2614, 63, 719, 63, 504, 418, 436, 288, 308, 2587, 459, 6874, 418, 508, 6391, 63, 923, 63, 2200, 459, 6874, 418, 436, 308, 2587, 459, 1287, 418, 508, 6391, 63, 923, 63, 2200, 459, 1287, 418, 436, 355, 308, 2587, 459, 3922, 418, 508, 6391, 63, 923, 63, 2200, 459, 3922, 9090, 288, 372, 308, 2587, 339, 372, 488, 421, 199, 318, 3451, 63, 8590, 8, 1246, 12, 6391, 63, 923, 63, 344, 12, 6391, 63, 923, 63, 2200, 304, 272, 2203, 275, 791, 2489, 356, 756, 93, 339, 1177, 275, 2986, 14, 362, 360, 4416, 63, 2634, 3149, 83, 15, 4423, 7, 450, 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, 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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 ]
yamahata/qemu
scripts/tracetool.py
111
3993
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Command-line wrapper for the tracetool machinery. """ __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>" __copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>" __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" __email__ = "stefanha@linux.vnet.ibm.com" import sys import getopt from tracetool import error_write, out import tracetool.backend import tracetool.format _SCRIPT = "" def error_opt(msg = None): if msg is not None: error_write("Error: " + msg + "\n") backend_descr = "\n".join([ " %-15s %s" % (n, d) for n,d in tracetool.backend.get_list() ]) format_descr = "\n".join([ " %-15s %s" % (n, d) for n,d in tracetool.format.get_list() ]) error_write("""\ Usage: %(script)s --format=<format> --backend=<backend> [<options>] Backends: %(backends)s Formats: %(formats)s Options: --help This help message. --list-backends Print list of available backends. --check-backend Check if the given backend is valid. --binary <path> Full path to QEMU binary. --target-type <type> QEMU emulator target type ('system' or 'user'). --target-arch <arch> QEMU emulator target arch. --probe-prefix <prefix> Prefix for dtrace probe names (default: qemu-<target-type>-<target-arch>).\ """ % { "script" : _SCRIPT, "backends" : backend_descr, "formats" : format_descr, }) if msg is None: sys.exit(0) else: sys.exit(1) def main(args): global _SCRIPT _SCRIPT = args[0] long_opts = [ "backend=", "format=", "help", "list-backends", "check-backend" ] long_opts += [ "binary=", "target-type=", "target-arch=", "probe-prefix=" ] try: opts, args = getopt.getopt(args[1:], "", long_opts) except getopt.GetoptError, err: error_opt(str(err)) check_backend = False arg_backend = "" arg_format = "" binary = None target_type = None target_arch = None probe_prefix = None for opt, arg in opts: if opt == "--help": error_opt() elif opt == "--backend": arg_backend = arg elif opt == "--format": arg_format = arg elif opt == "--list-backends": backends = tracetool.backend.get_list() out(", ".join([ b for b,_ in backends ])) sys.exit(0) elif opt == "--check-backend": check_backend = True elif opt == "--binary": binary = arg elif opt == '--target-type': target_type = arg elif opt == '--target-arch': target_arch = arg elif opt == '--probe-prefix': probe_prefix = arg else: error_opt("unhandled option: %s" % opt) if arg_backend is None: error_opt("backend not set") if check_backend: if tracetool.backend.exists(arg_backend): sys.exit(0) else: sys.exit(1) if arg_format == "stap": if binary is None: error_opt("--binary is required for SystemTAP tapset generator") if probe_prefix is None and target_type is None: error_opt("--target-type is required for SystemTAP tapset generator") if probe_prefix is None and target_arch is None: error_opt("--target-arch is required for SystemTAP tapset generator") if probe_prefix is None: probe_prefix = ".".join([ "qemu", target_type, target_arch ]) try: tracetool.generate(sys.stdin, arg_format, arg_backend, binary = binary, probe_prefix = probe_prefix) except tracetool.TracetoolError, e: error_opt(str(e)) if __name__ == "__main__": main(sys.argv)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 3110, 13, 604, 4975, 367, 314, 3307, 3557, 28540, 14, 199, 624, 199, 199, 363, 2502, 363, 258, 275, 298, 44, 10836, 13676, 83, 812, 382, 8143, 3042, 665, 29792, 8143, 3042, 32, 645, 14, 384, 67, 14, 8654, 4335, 199, 363, 7307, 363, 221, 275, 298, 7384, 6029, 12, 491, 10836, 13676, 83, 812, 382, 8143, 3042, 665, 29792, 8143, 3042, 32, 645, 14, 384, 67, 14, 8654, 4335, 199, 363, 1682, 363, 259, 275, 298, 12006, 1015, 499, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 2, 199, 199, 363, 26665, 363, 275, 298, 26696, 12269, 869, 9091, 23507, 16079, 2, 199, 363, 2123, 363, 420, 275, 298, 1597, 12269, 2411, 32, 5135, 14, 86, 846, 14, 19870, 14, 957, 2, 421, 199, 646, 984, 199, 646, 12733, 199, 199, 504, 3307, 3557, 492, 1125, 63, 952, 12, 734, 199, 646, 3307, 3557, 14, 4620, 199, 646, 3307, 3557, 14, 908, 421, 199, 63, 10484, 275, 3087, 199, 199, 318, 1125, 63, 2992, 8, 1328, 275, 488, 304, 272, 340, 1499, 365, 440, 488, 26, 267, 1125, 63, 952, 480, 547, 26, 298, 435, 1499, 435, 1867, 78, 531, 339, 4865, 63, 12113, 275, 1867, 78, 1674, 904, 779, 298, 259, 19752, 1046, 83, 450, 83, 2, 450, 334, 78, 12, 366, 9, 1816, 367, 302, 12, 68, 315, 3307, 3557, 14, 4620, 14, 362, 63, 513, 342, 4794, 272, 1475, 63, 12113, 275, 1867, 78, 1674, 904, 779, 298, 259, 19752, 1046, 83, 450, 83, 2, 450, 334, 78, 12, 366, 9, 3044, 367, 302, 12, 68, 315, 3307, 3557, 14, 908, 14, 362, 63, 513, 342, 4794, 272, 1125, 63, 952, 21723, 199, 7692, 26, 2818, 1579, 9, 83, 1553, 908, 18987, 908, 30, 1553, 4620, 18987, 4620, 30, 24936, 1419, 19109, 199, 199, 4540, 3198, 26, 199, 2840, 7765, 9, 83, 199, 199, 29717, 26, 199, 2840, 6321, 9, 83, 199, 199, 4558, 26, 272, 1553, 3437, 7861, 961, 1720, 1245, 14, 272, 1553, 513, 13, 7765, 3515, 9101, 769, 402, 2808, 14745, 14, 272, 1553, 1074, 13, 4620, 3515, 2670, 340, 314, 1627, 4865, 365, 1686, 14, 272, 1553, 3008, 665, 515, 30, 3515, 16579, 931, 370, 1413, 2769, 53, 3366, 14, 272, 1553, 1375, 13, 466, 665, 466, 30, 258, 1413, 2769, 53, 17423, 707, 1347, 730, 661, 2253, 7, 503, 283, 751, 1959, 272, 1553, 1375, 13, 1047, 665, 1047, 30, 258, 1413, 2769, 53, 17423, 707, 1347, 3819, 14, 272, 1553, 15944, 13, 1861, 665, 1861, 30, 221, 25110, 367, 366, 3446, 22362, 1561, 2490, 334, 885, 26, 1894, 14756, 13, 28, 1375, 13, 466, 24860, 28, 1375, 13, 1047, 10121, 60, 199, 624, 450, 469, 288, 298, 1579, 2, 520, 485, 10484, 12, 288, 298, 7765, 2, 520, 4865, 63, 12113, 12, 288, 298, 6321, 2, 520, 1475, 63, 12113, 12, 288, 3828, 339, 340, 1499, 365, 488, 26, 267, 984, 14, 2224, 8, 16, 9, 272, 587, 26, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 2446, 8, 589, 304, 272, 2288, 485, 10484, 272, 485, 10484, 275, 1249, 59, 16, 61, 339, 1846, 63, 3291, 221, 275, 359, 298, 4620, 11107, 298, 908, 11107, 298, 3437, 401, 298, 513, 13, 7765, 401, 298, 1074, 13, 4620, 2, 1622, 272, 1846, 63, 3291, 847, 359, 298, 3008, 11107, 298, 1375, 13, 466, 11107, 298, 1375, 13, 1047, 11107, 298, 15944, 13, 1861, 628, 1622, 339, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 589, 59, 17, 8429, 4873, 1846, 63, 3291, 9, 272, 871, 12733, 14, 1002, 29368, 12, 2329, 26, 267, 1125, 63, 2992, 8, 495, 8, 1508, 430, 339, 1104, 63, 4620, 275, 756, 272, 1680, 63, 4620, 275, 3087, 272, 1680, 63, 908, 275, 3087, 272, 3366, 275, 488, 272, 1347, 63, 466, 275, 488, 272, 1347, 63, 1047, 275, 488, 272, 22362, 63, 1861, 275, 488, 272, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 508, 4320, 3437, 582, 288, 1125, 63, 2992, 342, 398, 916, 2450, 508, 4320, 4620, 582, 288, 1680, 63, 4620, 275, 1680, 267, 916, 2450, 508, 4320, 908, 582, 288, 1680, 63, 908, 275, 1680, 398, 916, 2450, 508, 4320, 513, 13, 7765, 582, 288, 14745, 275, 3307, 3557, 14, 4620, 14, 362, 63, 513, 342, 288, 734, 11854, 3680, 904, 779, 330, 367, 330, 16987, 315, 14745, 22979, 288, 984, 14, 2224, 8, 16, 9, 267, 916, 2450, 508, 4320, 1074, 13, 4620, 582, 288, 1104, 63, 4620, 275, 715, 398, 916, 2450, 508, 4320, 3008, 582, 288, 3366, 275, 1680, 267, 916, 2450, 508, 2850, 1375, 13, 466, 356, 288, 1347, 63, 466, 275, 1680, 267, 916, 2450, 508, 2850, 1375, 13, 1047, 356, 288, 1347, 63, 1047, 275, 1680, 267, 916, 2450, 508, 2850, 15944, 13, 1861, 356, 288, 22362, 63, 1861, 275, 1680, 398, 587, 26, 288, 1125, 63, 2992, 480, 23648, 945, 26, 450, 83, 2, 450, 2450, 9, 339, 340, 1680, 63, 4620, 365, 488, 26, 267, 1125, 63, 2992, 480, 4620, 440, 663, 531, 339, 340, 1104, 63, 4620, 26, 267, 340, 3307, 3557, 14, 4620, 14, 2444, 8, 1273, 63, 4620, 304, 288, 984, 14, 2224, 8, 16, 9, 267, 587, 26, 288, 984, 14, 2224, 8, 17, 9, 339, 340, 1680, 63, 908, 508, 298, 270, 439, 582, 267, 340, 3366, 365, 488, 26, 288, 1125, 63, 2992, 6739, 3008, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 267, 340, 22362, 63, 1861, 365, 488, 436, 1347, 63, 466, 365, 488, 26, 288, 1125, 63, 2992, 6739, 1375, 13, 466, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 267, 340, 22362, 63, 1861, 365, 488, 436, 1347, 63, 1047, 365, 488, 26, 288, 1125, 63, 2992, 6739, 1375, 13, 1047, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 398, 340, 22362, 63, 1861, 365, 488, 26, 288, 22362, 63, 1861, 275, 32443, 904, 779, 298, 19839, 401, 1347, 63, 466, 12, 1347, 63, 1047, 4794, 339, 862, 26, 267, 3307, 3557 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 3110, 13, 604, 4975, 367, 314, 3307, 3557, 28540, 14, 199, 624, 199, 199, 363, 2502, 363, 258, 275, 298, 44, 10836, 13676, 83, 812, 382, 8143, 3042, 665, 29792, 8143, 3042, 32, 645, 14, 384, 67, 14, 8654, 4335, 199, 363, 7307, 363, 221, 275, 298, 7384, 6029, 12, 491, 10836, 13676, 83, 812, 382, 8143, 3042, 665, 29792, 8143, 3042, 32, 645, 14, 384, 67, 14, 8654, 4335, 199, 363, 1682, 363, 259, 275, 298, 12006, 1015, 499, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 2, 199, 199, 363, 26665, 363, 275, 298, 26696, 12269, 869, 9091, 23507, 16079, 2, 199, 363, 2123, 363, 420, 275, 298, 1597, 12269, 2411, 32, 5135, 14, 86, 846, 14, 19870, 14, 957, 2, 421, 199, 646, 984, 199, 646, 12733, 199, 199, 504, 3307, 3557, 492, 1125, 63, 952, 12, 734, 199, 646, 3307, 3557, 14, 4620, 199, 646, 3307, 3557, 14, 908, 421, 199, 63, 10484, 275, 3087, 199, 199, 318, 1125, 63, 2992, 8, 1328, 275, 488, 304, 272, 340, 1499, 365, 440, 488, 26, 267, 1125, 63, 952, 480, 547, 26, 298, 435, 1499, 435, 1867, 78, 531, 339, 4865, 63, 12113, 275, 1867, 78, 1674, 904, 779, 298, 259, 19752, 1046, 83, 450, 83, 2, 450, 334, 78, 12, 366, 9, 1816, 367, 302, 12, 68, 315, 3307, 3557, 14, 4620, 14, 362, 63, 513, 342, 4794, 272, 1475, 63, 12113, 275, 1867, 78, 1674, 904, 779, 298, 259, 19752, 1046, 83, 450, 83, 2, 450, 334, 78, 12, 366, 9, 3044, 367, 302, 12, 68, 315, 3307, 3557, 14, 908, 14, 362, 63, 513, 342, 4794, 272, 1125, 63, 952, 21723, 199, 7692, 26, 2818, 1579, 9, 83, 1553, 908, 18987, 908, 30, 1553, 4620, 18987, 4620, 30, 24936, 1419, 19109, 199, 199, 4540, 3198, 26, 199, 2840, 7765, 9, 83, 199, 199, 29717, 26, 199, 2840, 6321, 9, 83, 199, 199, 4558, 26, 272, 1553, 3437, 7861, 961, 1720, 1245, 14, 272, 1553, 513, 13, 7765, 3515, 9101, 769, 402, 2808, 14745, 14, 272, 1553, 1074, 13, 4620, 3515, 2670, 340, 314, 1627, 4865, 365, 1686, 14, 272, 1553, 3008, 665, 515, 30, 3515, 16579, 931, 370, 1413, 2769, 53, 3366, 14, 272, 1553, 1375, 13, 466, 665, 466, 30, 258, 1413, 2769, 53, 17423, 707, 1347, 730, 661, 2253, 7, 503, 283, 751, 1959, 272, 1553, 1375, 13, 1047, 665, 1047, 30, 258, 1413, 2769, 53, 17423, 707, 1347, 3819, 14, 272, 1553, 15944, 13, 1861, 665, 1861, 30, 221, 25110, 367, 366, 3446, 22362, 1561, 2490, 334, 885, 26, 1894, 14756, 13, 28, 1375, 13, 466, 24860, 28, 1375, 13, 1047, 10121, 60, 199, 624, 450, 469, 288, 298, 1579, 2, 520, 485, 10484, 12, 288, 298, 7765, 2, 520, 4865, 63, 12113, 12, 288, 298, 6321, 2, 520, 1475, 63, 12113, 12, 288, 3828, 339, 340, 1499, 365, 488, 26, 267, 984, 14, 2224, 8, 16, 9, 272, 587, 26, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 2446, 8, 589, 304, 272, 2288, 485, 10484, 272, 485, 10484, 275, 1249, 59, 16, 61, 339, 1846, 63, 3291, 221, 275, 359, 298, 4620, 11107, 298, 908, 11107, 298, 3437, 401, 298, 513, 13, 7765, 401, 298, 1074, 13, 4620, 2, 1622, 272, 1846, 63, 3291, 847, 359, 298, 3008, 11107, 298, 1375, 13, 466, 11107, 298, 1375, 13, 1047, 11107, 298, 15944, 13, 1861, 628, 1622, 339, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 589, 59, 17, 8429, 4873, 1846, 63, 3291, 9, 272, 871, 12733, 14, 1002, 29368, 12, 2329, 26, 267, 1125, 63, 2992, 8, 495, 8, 1508, 430, 339, 1104, 63, 4620, 275, 756, 272, 1680, 63, 4620, 275, 3087, 272, 1680, 63, 908, 275, 3087, 272, 3366, 275, 488, 272, 1347, 63, 466, 275, 488, 272, 1347, 63, 1047, 275, 488, 272, 22362, 63, 1861, 275, 488, 272, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 508, 4320, 3437, 582, 288, 1125, 63, 2992, 342, 398, 916, 2450, 508, 4320, 4620, 582, 288, 1680, 63, 4620, 275, 1680, 267, 916, 2450, 508, 4320, 908, 582, 288, 1680, 63, 908, 275, 1680, 398, 916, 2450, 508, 4320, 513, 13, 7765, 582, 288, 14745, 275, 3307, 3557, 14, 4620, 14, 362, 63, 513, 342, 288, 734, 11854, 3680, 904, 779, 330, 367, 330, 16987, 315, 14745, 22979, 288, 984, 14, 2224, 8, 16, 9, 267, 916, 2450, 508, 4320, 1074, 13, 4620, 582, 288, 1104, 63, 4620, 275, 715, 398, 916, 2450, 508, 4320, 3008, 582, 288, 3366, 275, 1680, 267, 916, 2450, 508, 2850, 1375, 13, 466, 356, 288, 1347, 63, 466, 275, 1680, 267, 916, 2450, 508, 2850, 1375, 13, 1047, 356, 288, 1347, 63, 1047, 275, 1680, 267, 916, 2450, 508, 2850, 15944, 13, 1861, 356, 288, 22362, 63, 1861, 275, 1680, 398, 587, 26, 288, 1125, 63, 2992, 480, 23648, 945, 26, 450, 83, 2, 450, 2450, 9, 339, 340, 1680, 63, 4620, 365, 488, 26, 267, 1125, 63, 2992, 480, 4620, 440, 663, 531, 339, 340, 1104, 63, 4620, 26, 267, 340, 3307, 3557, 14, 4620, 14, 2444, 8, 1273, 63, 4620, 304, 288, 984, 14, 2224, 8, 16, 9, 267, 587, 26, 288, 984, 14, 2224, 8, 17, 9, 339, 340, 1680, 63, 908, 508, 298, 270, 439, 582, 267, 340, 3366, 365, 488, 26, 288, 1125, 63, 2992, 6739, 3008, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 267, 340, 22362, 63, 1861, 365, 488, 436, 1347, 63, 466, 365, 488, 26, 288, 1125, 63, 2992, 6739, 1375, 13, 466, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 267, 340, 22362, 63, 1861, 365, 488, 436, 1347, 63, 1047, 365, 488, 26, 288, 1125, 63, 2992, 6739, 1375, 13, 1047, 365, 1415, 367, 6187, 52, 1282, 24410, 409, 4306, 531, 398, 340, 22362, 63, 1861, 365, 488, 26, 288, 22362, 63, 1861, 275, 32443, 904, 779, 298, 19839, 401, 1347, 63, 466, 12, 1347, 63, 1047, 4794, 339, 862, 26, 267, 3307, 3557, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
RondaStrauch/landlab
landlab/grid/structured_quad/rectilinear.py
6
4954
#! /usr/bin/env python import numpy as np from .structured import StructuredQuadGrid class RectilinearGrid(StructuredQuadGrid): """ Parameters ---------- coord : tuple Coordinates of node rows and node columns. Examples -------- >>> import numpy as np >>> from landlab.grid.structured_quad.rectilinear import RectilinearGrid >>> (y, x) = np.arange(4.), np.arange(5.) >>> grid = RectilinearGrid((y, x)) >>> grid.number_of_nodes 20 >>> grid.number_of_node_rows 4 >>> grid.number_of_node_columns 5 >>> grid.nodes_at_corners_of_grid array([ 0, 4, 15, 19]) >>> grid.number_of_cells 6 >>> grid.node_row_coord array([ 0., 1., 2., 3.]) >>> grid.node_col_coord array([ 0., 1., 2., 3., 4.]) """ def __init__(self, coord): """ Parameters ---------- coord : tuple Coordinates of node rows and node columns. """ if len(coord) != 2: raise ValueError('only 2d grids are supported') shape = ( len(coord[0]), len(coord[1]), ) node_coord = np.meshgrid(*coord, indexing='ij') super(RectilinearGrid, self).__init__(node_coord, shape, cells=True) self._coord = (coord[0], coord[1]) @property def coord(self): """Node row and column coordinates. """ return self._coord @property def node_row_coord(self): return self._coord[0] @property def node_col_coord(self): return self._coord[1] class UniformRectilinearGrid(RectilinearGrid): """ Parameters ---------- shape : tuple Shape of the grid in nodes. spacing : tuple, optional Spacing between rows and columns. origin : tuple, optional Coordinates of grid origin. Examples -------- >>> from landlab.grid.structured_quad.rectilinear import UniformRectilinearGrid >>> grid = UniformRectilinearGrid((4, 5), spacing=(2, 3), origin=(-1, 1)) >>> grid.number_of_nodes 20 #>>> grid.number_of_core_nodes 6 >>> grid.number_of_node_rows 4 >>> grid.number_of_node_columns 5 >>> grid.nodes_at_corners_of_grid array([ 0, 4, 15, 19]) >>> grid.number_of_cells 6 >>> grid.node_row_coord array([-1., 1., 3., 5.]) >>> grid.node_col_coord array([ 1., 4., 7., 10., 13.]) """ def __init__(self, shape, spacing=(1., 1.), origin=(0., 0.)): """ Parameters ---------- shape : tuple Shape of the grid in nodes. spacing : tuple, optional Spacing between rows and columns. origin : tuple, optional Coordinates of grid origin. """ if len(shape) != 2: raise ValueError('only 2d grids are supported') coords = ( np.arange(origin[0], origin[0] + shape[0] * spacing[0], spacing[0], dtype=np.float64), np.arange(origin[1], origin[1] + shape[1] * spacing[1], spacing[1], dtype=np.float64), ) super(UniformRectilinearGrid, self).__init__(coords) self._spacing = tuple(spacing) @property def spacing(self): """Spacing of rows and columns of grid nodes. """ return self._spacing @property def dy(self): """Spacing between rows of grid nodes. """ return self._spacing[0] @property def dx(self): """Spacing between columns of grid nodes. """ return self._spacing[1] class RasterGrid(UniformRectilinearGrid): """ Parameters ---------- shape : tuple Shape of the grid in nodes. spacing : float, optional Spacing between rows and columns. origin : tuple, optional Coordinates of grid origin. Examples -------- >>> from landlab.grid.structured_quad.rectilinear import RasterGrid >>> grid = RasterGrid((4, 5), spacing=2, origin=(-1, 1)) >>> grid.number_of_nodes 20 #>>> grid.number_of_core_nodes 6 >>> grid.number_of_node_rows 4 >>> grid.number_of_node_columns 5 >>> grid.nodes_at_corners_of_grid array([ 0, 4, 15, 19]) >>> grid.number_of_cells 6 >>> grid.node_row_coord array([-1., 1., 3., 5.]) >>> grid.node_col_coord array([ 1., 3., 5., 7., 9.]) """ def __init__(self, shape, spacing=1., origin=0.): """ Parameters ---------- shape : tuple Shape of the grid in nodes. spacing : float, optional Spacing between rows and columns. origin : tuple, optional Coordinates of grid origin. """ super(RasterGrid, self).__init__(shape, origin=origin, spacing=(spacing, ) * len(shape))
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 15774, 492, 13039, 3297, 23053, 7900, 421, 199, 533, 799, 67, 280, 6676, 7900, 8, 27486, 23053, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 11021, 520, 2008, 267, 25334, 2335, 402, 1031, 4730, 436, 1031, 4362, 14, 339, 6058, 272, 3001, 272, 1306, 492, 2680, 465, 980, 272, 1306, 687, 20078, 5561, 14, 3825, 14, 15774, 63, 14567, 14, 2761, 280, 6676, 492, 799, 67, 280, 6676, 7900, 272, 1306, 334, 89, 12, 671, 9, 275, 980, 14, 5605, 8, 20, 15631, 980, 14, 5605, 8, 21, 4959, 272, 1306, 6068, 275, 799, 67, 280, 6676, 7900, 1332, 89, 12, 671, 430, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 2415, 272, 3388, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3838, 272, 841, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3406, 272, 959, 272, 1306, 6068, 14, 2415, 63, 292, 63, 30652, 63, 1618, 63, 3825, 272, 1625, 779, 378, 12, 221, 841, 12, 4114, 12, 5851, 566, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 9041, 272, 1227, 272, 1306, 6068, 14, 932, 63, 1143, 63, 7988, 272, 1625, 779, 378, 2020, 221, 413, 2020, 221, 499, 2020, 221, 650, 14444, 272, 1306, 6068, 14, 932, 63, 761, 63, 7988, 272, 1625, 779, 378, 2020, 221, 413, 2020, 221, 499, 2020, 221, 650, 2020, 221, 841, 14444, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11021, 304, 267, 408, 267, 3897, 267, 4143, 267, 11021, 520, 2008, 288, 25334, 2335, 402, 1031, 4730, 436, 1031, 4362, 14, 267, 408, 267, 340, 822, 8, 7988, 9, 1137, 499, 26, 288, 746, 1722, 360, 2118, 499, 68, 27591, 795, 787, 3748, 358, 398, 2215, 275, 334, 288, 822, 8, 7988, 59, 16, 2522, 288, 822, 8, 7988, 59, 17, 2522, 267, 776, 267, 1031, 63, 7988, 275, 980, 14, 6480, 3825, 2031, 7988, 12, 16356, 534, 7879, 358, 398, 1613, 8, 21561, 280, 6676, 7900, 12, 291, 2843, 826, 721, 932, 63, 7988, 12, 2215, 12, 10106, 29, 549, 9, 398, 291, 423, 7988, 275, 334, 7988, 59, 16, 467, 11021, 59, 17, 566, 339, 768, 1829, 272, 347, 11021, 8, 277, 304, 267, 408, 1716, 1962, 436, 2763, 8983, 14, 267, 408, 267, 372, 291, 423, 7988, 339, 768, 1829, 272, 347, 1031, 63, 1143, 63, 7988, 8, 277, 304, 267, 372, 291, 423, 7988, 59, 16, 61, 339, 768, 1829, 272, 347, 1031, 63, 761, 63, 7988, 8, 277, 304, 267, 372, 291, 423, 7988, 59, 17, 61, 421, 199, 533, 1910, 8241, 21561, 280, 6676, 7900, 8, 21561, 280, 6676, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 2215, 520, 2008, 267, 16528, 402, 314, 6068, 315, 3380, 14, 272, 19621, 520, 2008, 12, 2716, 267, 17812, 4477, 3382, 4730, 436, 4362, 14, 272, 6330, 520, 2008, 12, 2716, 267, 25334, 2335, 402, 6068, 6330, 14, 339, 6058, 272, 3001, 272, 1306, 687, 20078, 5561, 14, 3825, 14, 15774, 63, 14567, 14, 2761, 280, 6676, 492, 1910, 8241, 21561, 280, 6676, 7900, 272, 1306, 6068, 275, 1910, 8241, 21561, 280, 6676, 7900, 1332, 20, 12, 959, 395, 19621, 2687, 18, 12, 650, 395, 6330, 26154, 17, 12, 413, 430, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 2415, 272, 3388, 339, 327, 6071, 6068, 14, 1955, 63, 1618, 63, 1018, 63, 2415, 272, 1227, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3838, 272, 841, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3406, 272, 959, 272, 1306, 6068, 14, 2415, 63, 292, 63, 30652, 63, 1618, 63, 3825, 272, 1625, 779, 378, 12, 221, 841, 12, 4114, 12, 5851, 566, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 9041, 272, 1227, 272, 1306, 6068, 14, 932, 63, 1143, 63, 7988, 272, 1625, 11468, 17, 2020, 221, 413, 2020, 221, 650, 2020, 221, 959, 14444, 272, 1306, 6068, 14, 932, 63, 761, 63, 7988, 272, 1625, 779, 221, 413, 2020, 257, 841, 2020, 257, 1520, 2020, 221, 1616, 2020, 221, 4944, 14444, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2215, 12, 19621, 2687, 17, 2020, 413, 15631, 6330, 2687, 16, 2020, 378, 14, 2298, 267, 408, 267, 3897, 267, 4143, 267, 2215, 520, 2008, 288, 16528, 402, 314, 6068, 315, 3380, 14, 267, 19621, 520, 2008, 12, 2716, 288, 17812, 4477, 3382, 4730, 436, 4362, 14, 267, 6330, 520, 2008, 12, 2716, 288, 25334, 2335, 402, 6068, 6330, 14, 267, 408, 267, 340, 822, 8, 1392, 9, 1137, 499, 26, 288, 746, 1722, 360, 2118, 499, 68, 27591, 795, 787, 3748, 358, 398, 13259, 275, 334, 288, 980, 14, 5605, 8, 6493, 59, 16, 467, 6330, 59, 16, 61, 435, 2215, 59, 16, 61, 627, 19621, 59, 16, 467, 19621, 59, 16, 467, 1993, 2152, 29, 1590, 14, 1609, 772, 395, 288, 980, 14, 5605, 8, 6493, 59, 17, 467, 6330, 59, 17, 61, 435, 2215, 59, 17, 61, 627, 19621, 59, 17, 467, 19621, 59, 17, 467, 1993, 2152, 29, 1590, 14, 1609, 772, 395, 267, 776, 398, 1613, 8, 12421, 21561, 280, 6676, 7900, 12, 291, 2843, 826, 721, 8032, 9, 398, 291, 423, 15880, 275, 2008, 8, 15880, 9, 339, 768, 1829, 272, 347, 19621, 8, 277, 304, 267, 408, 24052, 402, 4730, 436, 4362, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 339, 768, 1829, 272, 347, 13119, 8, 277, 304, 267, 408, 24052, 3382, 4730, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 59, 16, 61, 339, 768, 1829, 272, 347, 11868, 8, 277, 304, 267, 408, 24052, 3382, 4362, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 59, 17, 61, 421, 199, 533, 820, 2311, 7900, 8, 12421, 21561, 280, 6676, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 2215, 520, 2008, 267, 16528, 402, 314, 6068, 315, 3380, 14, 272, 19621, 520, 2069, 12, 2716, 267, 17812, 4477, 3382, 4730, 436, 4362, 14, 272, 6330, 520, 2008, 12, 2716, 267, 25334, 2335, 402, 6068, 6330, 14, 5493, 6058, 272, 3001, 272 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 15774, 492, 13039, 3297, 23053, 7900, 421, 199, 533, 799, 67, 280, 6676, 7900, 8, 27486, 23053, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 11021, 520, 2008, 267, 25334, 2335, 402, 1031, 4730, 436, 1031, 4362, 14, 339, 6058, 272, 3001, 272, 1306, 492, 2680, 465, 980, 272, 1306, 687, 20078, 5561, 14, 3825, 14, 15774, 63, 14567, 14, 2761, 280, 6676, 492, 799, 67, 280, 6676, 7900, 272, 1306, 334, 89, 12, 671, 9, 275, 980, 14, 5605, 8, 20, 15631, 980, 14, 5605, 8, 21, 4959, 272, 1306, 6068, 275, 799, 67, 280, 6676, 7900, 1332, 89, 12, 671, 430, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 2415, 272, 3388, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3838, 272, 841, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3406, 272, 959, 272, 1306, 6068, 14, 2415, 63, 292, 63, 30652, 63, 1618, 63, 3825, 272, 1625, 779, 378, 12, 221, 841, 12, 4114, 12, 5851, 566, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 9041, 272, 1227, 272, 1306, 6068, 14, 932, 63, 1143, 63, 7988, 272, 1625, 779, 378, 2020, 221, 413, 2020, 221, 499, 2020, 221, 650, 14444, 272, 1306, 6068, 14, 932, 63, 761, 63, 7988, 272, 1625, 779, 378, 2020, 221, 413, 2020, 221, 499, 2020, 221, 650, 2020, 221, 841, 14444, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11021, 304, 267, 408, 267, 3897, 267, 4143, 267, 11021, 520, 2008, 288, 25334, 2335, 402, 1031, 4730, 436, 1031, 4362, 14, 267, 408, 267, 340, 822, 8, 7988, 9, 1137, 499, 26, 288, 746, 1722, 360, 2118, 499, 68, 27591, 795, 787, 3748, 358, 398, 2215, 275, 334, 288, 822, 8, 7988, 59, 16, 2522, 288, 822, 8, 7988, 59, 17, 2522, 267, 776, 267, 1031, 63, 7988, 275, 980, 14, 6480, 3825, 2031, 7988, 12, 16356, 534, 7879, 358, 398, 1613, 8, 21561, 280, 6676, 7900, 12, 291, 2843, 826, 721, 932, 63, 7988, 12, 2215, 12, 10106, 29, 549, 9, 398, 291, 423, 7988, 275, 334, 7988, 59, 16, 467, 11021, 59, 17, 566, 339, 768, 1829, 272, 347, 11021, 8, 277, 304, 267, 408, 1716, 1962, 436, 2763, 8983, 14, 267, 408, 267, 372, 291, 423, 7988, 339, 768, 1829, 272, 347, 1031, 63, 1143, 63, 7988, 8, 277, 304, 267, 372, 291, 423, 7988, 59, 16, 61, 339, 768, 1829, 272, 347, 1031, 63, 761, 63, 7988, 8, 277, 304, 267, 372, 291, 423, 7988, 59, 17, 61, 421, 199, 533, 1910, 8241, 21561, 280, 6676, 7900, 8, 21561, 280, 6676, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 2215, 520, 2008, 267, 16528, 402, 314, 6068, 315, 3380, 14, 272, 19621, 520, 2008, 12, 2716, 267, 17812, 4477, 3382, 4730, 436, 4362, 14, 272, 6330, 520, 2008, 12, 2716, 267, 25334, 2335, 402, 6068, 6330, 14, 339, 6058, 272, 3001, 272, 1306, 687, 20078, 5561, 14, 3825, 14, 15774, 63, 14567, 14, 2761, 280, 6676, 492, 1910, 8241, 21561, 280, 6676, 7900, 272, 1306, 6068, 275, 1910, 8241, 21561, 280, 6676, 7900, 1332, 20, 12, 959, 395, 19621, 2687, 18, 12, 650, 395, 6330, 26154, 17, 12, 413, 430, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 2415, 272, 3388, 339, 327, 6071, 6068, 14, 1955, 63, 1618, 63, 1018, 63, 2415, 272, 1227, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3838, 272, 841, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 932, 63, 3406, 272, 959, 272, 1306, 6068, 14, 2415, 63, 292, 63, 30652, 63, 1618, 63, 3825, 272, 1625, 779, 378, 12, 221, 841, 12, 4114, 12, 5851, 566, 272, 1306, 6068, 14, 1955, 63, 1618, 63, 9041, 272, 1227, 272, 1306, 6068, 14, 932, 63, 1143, 63, 7988, 272, 1625, 11468, 17, 2020, 221, 413, 2020, 221, 650, 2020, 221, 959, 14444, 272, 1306, 6068, 14, 932, 63, 761, 63, 7988, 272, 1625, 779, 221, 413, 2020, 257, 841, 2020, 257, 1520, 2020, 221, 1616, 2020, 221, 4944, 14444, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2215, 12, 19621, 2687, 17, 2020, 413, 15631, 6330, 2687, 16, 2020, 378, 14, 2298, 267, 408, 267, 3897, 267, 4143, 267, 2215, 520, 2008, 288, 16528, 402, 314, 6068, 315, 3380, 14, 267, 19621, 520, 2008, 12, 2716, 288, 17812, 4477, 3382, 4730, 436, 4362, 14, 267, 6330, 520, 2008, 12, 2716, 288, 25334, 2335, 402, 6068, 6330, 14, 267, 408, 267, 340, 822, 8, 1392, 9, 1137, 499, 26, 288, 746, 1722, 360, 2118, 499, 68, 27591, 795, 787, 3748, 358, 398, 13259, 275, 334, 288, 980, 14, 5605, 8, 6493, 59, 16, 467, 6330, 59, 16, 61, 435, 2215, 59, 16, 61, 627, 19621, 59, 16, 467, 19621, 59, 16, 467, 1993, 2152, 29, 1590, 14, 1609, 772, 395, 288, 980, 14, 5605, 8, 6493, 59, 17, 467, 6330, 59, 17, 61, 435, 2215, 59, 17, 61, 627, 19621, 59, 17, 467, 19621, 59, 17, 467, 1993, 2152, 29, 1590, 14, 1609, 772, 395, 267, 776, 398, 1613, 8, 12421, 21561, 280, 6676, 7900, 12, 291, 2843, 826, 721, 8032, 9, 398, 291, 423, 15880, 275, 2008, 8, 15880, 9, 339, 768, 1829, 272, 347, 19621, 8, 277, 304, 267, 408, 24052, 402, 4730, 436, 4362, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 339, 768, 1829, 272, 347, 13119, 8, 277, 304, 267, 408, 24052, 3382, 4730, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 59, 16, 61, 339, 768, 1829, 272, 347, 11868, 8, 277, 304, 267, 408, 24052, 3382, 4362, 402, 6068, 3380, 14, 267, 408, 267, 372, 291, 423, 15880, 59, 17, 61, 421, 199, 533, 820, 2311, 7900, 8, 12421, 21561, 280, 6676, 7900, 304, 272, 408, 272, 3897, 272, 4143, 272, 2215, 520, 2008, 267, 16528, 402, 314, 6068, 315, 3380, 14, 272, 19621, 520, 2069, 12, 2716, 267, 17812, 4477, 3382, 4730, 436, 4362, 14, 272, 6330, 520, 2008, 12, 2716, 267, 25334, 2335, 402, 6068, 6330, 14, 5493, 6058, 272, 3001, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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el.py
18
2966
""" Provide a mock alarm_control_panel platform. Call init before using it in your tests to ensure clean test data. """ from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity from homeassistant.components.alarm_control_panel.const import ( SUPPORT_ALARM_ARM_AWAY, SUPPORT_ALARM_ARM_HOME, SUPPORT_ALARM_ARM_NIGHT, SUPPORT_ALARM_TRIGGER, ) from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED, ) from tests.common import MockEntity ENTITIES = {} def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( {} if empty else { "arm_code": MockAlarm( name="Alarm arm code", code_arm_required=True, unique_id="unique_arm_code", ), "no_arm_code": MockAlarm( name="Alarm no arm code", code_arm_required=False, unique_id="unique_no_arm_code", ), } ) async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(list(ENTITIES.values())) class MockAlarm(MockEntity, AlarmControlPanelEntity): """Mock Alarm control panel class.""" def __init__(self, **values): """Init the Mock Alarm Control Panel.""" self._state = None MockEntity.__init__(self, **values) @property def code_arm_required(self): """Whether the code is required for arm actions.""" return self._handle("code_arm_required") @property def state(self): """Return the state of the device.""" return self._state @property def supported_features(self) -> int: """Return the list of supported features.""" return ( SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER ) def alarm_arm_away(self, code=None): """Send arm away command.""" self._state = STATE_ALARM_ARMED_AWAY self.async_write_ha_state() def alarm_arm_home(self, code=None): """Send arm home command.""" self._state = STATE_ALARM_ARMED_HOME self.async_write_ha_state() def alarm_arm_night(self, code=None): """Send arm night command.""" self._state = STATE_ALARM_ARMED_NIGHT self.async_write_ha_state() def alarm_disarm(self, code=None): """Send disarm command.""" if code == "1234": self._state = STATE_ALARM_DISARMED self.async_write_ha_state() def alarm_trigger(self, code=None): """Send alarm trigger command.""" self._state = STATE_ALARM_TRIGGERED self.async_write_ha_state()
apache-2.0
[ 624, 199, 25107, 282, 1683, 17987, 63, 2785, 63, 7885, 4298, 14, 199, 199, 2176, 4205, 2544, 1808, 652, 315, 2195, 2295, 370, 4868, 3633, 511, 666, 14, 199, 624, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 492, 4580, 5362, 3717, 10185, 7302, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 14, 1297, 492, 334, 272, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 12, 272, 13756, 63, 748, 12482, 63, 30073, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 12, 272, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 12, 272, 11377, 63, 748, 12482, 63, 30073, 1149, 12, 199, 9, 199, 199, 504, 2295, 14, 2330, 492, 4420, 7302, 199, 199, 1309, 19144, 275, 1052, 421, 199, 318, 4205, 8, 1667, 29, 797, 304, 272, 408, 9345, 314, 4298, 543, 9045, 1041, 272, 2288, 32526, 19144, 339, 32526, 19144, 275, 334, 267, 1052, 267, 340, 2701, 267, 587, 469, 288, 298, 5362, 63, 600, 582, 4420, 30655, 8, 355, 536, 628, 30655, 30701, 1233, 401, 355, 1233, 63, 5362, 63, 2427, 29, 549, 12, 355, 3747, 63, 344, 628, 3235, 63, 5362, 63, 600, 401, 288, 2318, 288, 298, 889, 63, 5362, 63, 600, 582, 4420, 30655, 8, 355, 536, 628, 30655, 949, 30701, 1233, 401, 355, 1233, 63, 5362, 63, 2427, 29, 797, 12, 355, 3747, 63, 344, 628, 3235, 63, 889, 63, 5362, 63, 600, 401, 288, 2318, 267, 789, 272, 776, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 272, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 63, 3058, 12, 13172, 63, 815, 29, 403, 199, 304, 272, 408, 1767, 1683, 9045, 1041, 272, 5316, 63, 525, 63, 8327, 63, 3058, 8, 513, 8, 1309, 19144, 14, 1459, 4059, 421, 199, 533, 4420, 30655, 8, 3346, 7302, 12, 4580, 5362, 3717, 10185, 7302, 304, 272, 408, 3346, 4580, 5362, 3304, 12748, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 1011, 1459, 304, 267, 408, 9346, 314, 4420, 4580, 5362, 8612, 510, 4822, 1041, 267, 291, 423, 929, 275, 488, 398, 4420, 7302, 855, 826, 721, 277, 12, 1011, 1459, 9, 339, 768, 1829, 272, 347, 1233, 63, 5362, 63, 2427, 8, 277, 304, 267, 408, 26625, 314, 1233, 365, 1415, 367, 30701, 5445, 1041, 267, 372, 291, 423, 2479, 480, 600, 63, 5362, 63, 2427, 531, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 2243, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 3748, 63, 3179, 8, 277, 9, 1035, 1109, 26, 267, 408, 1767, 314, 769, 402, 3748, 4534, 1041, 267, 372, 334, 288, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 288, 1204, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 288, 1204, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 288, 1204, 13756, 63, 748, 12482, 63, 30073, 267, 776, 339, 347, 17987, 63, 5362, 63, 22703, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 13437, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 5362, 63, 4219, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 5629, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 5362, 63, 14873, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 302, 1070, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 2297, 5362, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 2153, 5362, 1414, 1041, 267, 340, 1233, 508, 298, 4321, 582, 288, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 288, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 7631, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 17987, 6804, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 30073, 1149, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 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 ]
[ 199, 25107, 282, 1683, 17987, 63, 2785, 63, 7885, 4298, 14, 199, 199, 2176, 4205, 2544, 1808, 652, 315, 2195, 2295, 370, 4868, 3633, 511, 666, 14, 199, 624, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 492, 4580, 5362, 3717, 10185, 7302, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 14, 1297, 492, 334, 272, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 12, 272, 13756, 63, 748, 12482, 63, 30073, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 12, 272, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 12, 272, 11377, 63, 748, 12482, 63, 30073, 1149, 12, 199, 9, 199, 199, 504, 2295, 14, 2330, 492, 4420, 7302, 199, 199, 1309, 19144, 275, 1052, 421, 199, 318, 4205, 8, 1667, 29, 797, 304, 272, 408, 9345, 314, 4298, 543, 9045, 1041, 272, 2288, 32526, 19144, 339, 32526, 19144, 275, 334, 267, 1052, 267, 340, 2701, 267, 587, 469, 288, 298, 5362, 63, 600, 582, 4420, 30655, 8, 355, 536, 628, 30655, 30701, 1233, 401, 355, 1233, 63, 5362, 63, 2427, 29, 549, 12, 355, 3747, 63, 344, 628, 3235, 63, 5362, 63, 600, 401, 288, 2318, 288, 298, 889, 63, 5362, 63, 600, 582, 4420, 30655, 8, 355, 536, 628, 30655, 949, 30701, 1233, 401, 355, 1233, 63, 5362, 63, 2427, 29, 797, 12, 355, 3747, 63, 344, 628, 3235, 63, 889, 63, 5362, 63, 600, 401, 288, 2318, 267, 789, 272, 776, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 272, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 63, 3058, 12, 13172, 63, 815, 29, 403, 199, 304, 272, 408, 1767, 1683, 9045, 1041, 272, 5316, 63, 525, 63, 8327, 63, 3058, 8, 513, 8, 1309, 19144, 14, 1459, 4059, 421, 199, 533, 4420, 30655, 8, 3346, 7302, 12, 4580, 5362, 3717, 10185, 7302, 304, 272, 408, 3346, 4580, 5362, 3304, 12748, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 1011, 1459, 304, 267, 408, 9346, 314, 4420, 4580, 5362, 8612, 510, 4822, 1041, 267, 291, 423, 929, 275, 488, 398, 4420, 7302, 855, 826, 721, 277, 12, 1011, 1459, 9, 339, 768, 1829, 272, 347, 1233, 63, 5362, 63, 2427, 8, 277, 304, 267, 408, 26625, 314, 1233, 365, 1415, 367, 30701, 5445, 1041, 267, 372, 291, 423, 2479, 480, 600, 63, 5362, 63, 2427, 531, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 2243, 1041, 267, 372, 291, 423, 929, 339, 768, 1829, 272, 347, 3748, 63, 3179, 8, 277, 9, 1035, 1109, 26, 267, 408, 1767, 314, 769, 402, 3748, 4534, 1041, 267, 372, 334, 288, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 288, 1204, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 288, 1204, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 288, 1204, 13756, 63, 748, 12482, 63, 30073, 267, 776, 339, 347, 17987, 63, 5362, 63, 22703, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 13437, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 5362, 63, 4219, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 5629, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 5362, 63, 14873, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 30701, 302, 1070, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 2297, 5362, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 2153, 5362, 1414, 1041, 267, 340, 1233, 508, 298, 4321, 582, 288, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 288, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 17987, 63, 7631, 8, 277, 12, 1233, 29, 403, 304, 267, 408, 6795, 17987, 6804, 1414, 1041, 267, 291, 423, 929, 275, 11377, 63, 748, 12482, 63, 30073, 1149, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 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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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 ]
sugarlabs/sugar
src/jarabe/testrunner.py
5
1607
# Copyright (C) 2013, Daniel Narvaez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import sys import subprocess from gi.repository import GLib from sugar3.logger import get_logs_dir def _test_child_watch_cb(pid, condition, log_file): if os.WIFEXITED(condition): log_file.close() sys.exit(os.WEXITSTATUS(condition)) def check_environment(): run_test = os.environ.get("SUGAR_RUN_TEST", None) if run_test is not None: log_path = os.environ.get("SUGAR_TEST_LOG", None) if log_path is None: log_path = os.path.join(get_logs_dir(), "test.log") log_file = open(log_path, "w") else: log_file = open(log_path, "a") test_process = subprocess.Popen(run_test, stdout=log_file, stderr=subprocess.STDOUT, shell=True) GLib.child_watch_add(test_process.pid, _test_child_watch_cb, log_file)
gpl-3.0
[ 3, 1898, 334, 35, 9, 6171, 12, 24747, 14769, 653, 285, 3042, 27263, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 504, 18895, 14, 8421, 492, 3563, 1892, 199, 199, 504, 308, 21922, 19, 14, 2921, 492, 664, 63, 7270, 63, 694, 421, 199, 318, 485, 396, 63, 1739, 63, 6821, 63, 2894, 8, 3150, 12, 5558, 12, 943, 63, 493, 304, 272, 340, 747, 14, 55, 4656, 17219, 1149, 8, 5394, 304, 267, 943, 63, 493, 14, 1600, 342, 267, 984, 14, 2224, 8, 736, 14, 55, 17219, 6305, 8, 5394, 430, 421, 199, 318, 1104, 63, 5418, 837, 272, 1255, 63, 396, 275, 747, 14, 2314, 14, 362, 480, 6195, 21443, 63, 9390, 63, 2864, 401, 488, 9, 272, 340, 1255, 63, 396, 365, 440, 488, 26, 267, 943, 63, 515, 275, 747, 14, 2314, 14, 362, 480, 6195, 21443, 63, 2864, 63, 4947, 401, 488, 9, 267, 340, 943, 63, 515, 365, 488, 26, 288, 943, 63, 515, 275, 747, 14, 515, 14, 904, 8, 362, 63, 7270, 63, 694, 1062, 298, 396, 14, 793, 531, 288, 943, 63, 493, 275, 1551, 8, 793, 63, 515, 12, 298, 87, 531, 267, 587, 26, 288, 943, 63, 493, 275, 1551, 8, 793, 63, 515, 12, 298, 65, 531, 398, 511, 63, 1412, 275, 3873, 14, 7942, 8, 1065, 63, 396, 12, 3147, 3839, 29, 793, 63, 493, 12, 3147, 4635, 29, 5781, 14, 13850, 12, 3147, 5218, 29, 549, 9, 398, 3563, 1892, 14, 1739, 63, 6821, 63, 525, 8, 396, 63, 1412, 14, 3150, 12, 485, 396, 63, 1739, 63, 6821, 63, 2894, 12, 943, 63, 493, 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 ]
[ 1898, 334, 35, 9, 6171, 12, 24747, 14769, 653, 285, 3042, 27263, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 504, 18895, 14, 8421, 492, 3563, 1892, 199, 199, 504, 308, 21922, 19, 14, 2921, 492, 664, 63, 7270, 63, 694, 421, 199, 318, 485, 396, 63, 1739, 63, 6821, 63, 2894, 8, 3150, 12, 5558, 12, 943, 63, 493, 304, 272, 340, 747, 14, 55, 4656, 17219, 1149, 8, 5394, 304, 267, 943, 63, 493, 14, 1600, 342, 267, 984, 14, 2224, 8, 736, 14, 55, 17219, 6305, 8, 5394, 430, 421, 199, 318, 1104, 63, 5418, 837, 272, 1255, 63, 396, 275, 747, 14, 2314, 14, 362, 480, 6195, 21443, 63, 9390, 63, 2864, 401, 488, 9, 272, 340, 1255, 63, 396, 365, 440, 488, 26, 267, 943, 63, 515, 275, 747, 14, 2314, 14, 362, 480, 6195, 21443, 63, 2864, 63, 4947, 401, 488, 9, 267, 340, 943, 63, 515, 365, 488, 26, 288, 943, 63, 515, 275, 747, 14, 515, 14, 904, 8, 362, 63, 7270, 63, 694, 1062, 298, 396, 14, 793, 531, 288, 943, 63, 493, 275, 1551, 8, 793, 63, 515, 12, 298, 87, 531, 267, 587, 26, 288, 943, 63, 493, 275, 1551, 8, 793, 63, 515, 12, 298, 65, 531, 398, 511, 63, 1412, 275, 3873, 14, 7942, 8, 1065, 63, 396, 12, 3147, 3839, 29, 793, 63, 493, 12, 3147, 4635, 29, 5781, 14, 13850, 12, 3147, 5218, 29, 549, 9, 398, 3563, 1892, 14, 1739, 63, 6821, 63, 525, 8, 396, 63, 1412, 14, 3150, 12, 485, 396, 63, 1739, 63, 6821, 63, 2894, 12, 943, 63, 493, 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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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 ]
xiaobozi/boinc
py/Boinc/add_util.py
22
6256
#!/usr/bin/env python # $Id$ # add_util.py - code shared between add and xadd import database, tools import time, pprint import MySQLdb CREATE_TIME = ['?create_time', int(time.time())] TRANSITION_TIME = ['?transition_time', int(time.time())] class XAppVersion(database.AppVersion): def __init__(self,**kwargs): kwargs['xml_doc'] = tools.process_app_version( app = kwargs['app'], version_num = int(kwargs['version_num']), exec_files = kwargs['exec_files'], signature_files = kwargs.setdefault('signature_files',{})) del kwargs['signature_files'] del kwargs['exec_files'] del kwargs['exec_file'] database.AppVersion.__init__(self,**kwargs) # format: [ database.Object, args, ...] # arg format: # 'arg' # '?arg' optional # [ 'arg', default_value ] # NOTE TO KARL: If cross_project_id is not supplied, the default value # should be a random 32 character script obtained by doing the md5sum # hash of (say) 512 bytes from /dev/urandom or similar. list_objects_to_add = [ [ database.Platform, 'name', 'user_friendly_name', CREATE_TIME ], [ database.App, 'name', 'user_friendly_name', ['?min_version',0], CREATE_TIME], [ XAppVersion, 'app', 'platform', 'version_num', 'exec_file', '?signature_file', CREATE_TIME ], [ database.User, 'name', 'email_addr', 'authenticator', ['?country','United States'], ['?postal_code','0'], ['?cross_project_id', '0'], '?global_prefs', '?global_prefs_file', CREATE_TIME ], # [ database.Workunit, 'zzzz' ], ] class AddObject: pass add_objects = {} for o in list_objects_to_add: add_object = AddObject() add_object.DatabaseObject = o[0] add_object.name = add_object.DatabaseObject._table.table add_object.args = [] add_object.optional_args = [] add_object.default_values = {} for arg in o[1:]: if isinstance(arg, list): default_value = arg[1] arg = arg[0] else: default_value = None if arg.startswith('?'): optional = True arg = arg[1:] else: optional = False if optional: add_object.optional_args.append(arg) else: add_object.args.append(arg) if default_value: add_object.default_values[arg] = default_value add_objects[add_object.name] = add_object most_recent_exec_file = None def translate_arg(object, arg, value, args_dict): '''Translate various user argument values, for adding given ``object``. Modifies ``args_dict``.''' database_table = None try: database_table = database.__dict__[arg.capitalize()]._table except: pass if database_table: args_dict[arg] = translate_database_arg(database_table, arg, value) return if arg == 'global_prefs_file': args_dict['global_prefs'] = open(value).read() return if object.DatabaseObject == XAppVersion: # 'add app_version' accepts multiple '-exec_file's with # '-signature_file' applying to the most recent exec_file if arg == 'exec_file': global most_recent_exec_file most_recent_exec_file = value args_dict.setdefault('exec_files',[]).append(value) # since 'exec_file' (without 's') is required, set it to None so # that argument checker knows we got one; we'll delete it later. args_dict[arg] = None return if arg == 'signature_file': args_dict.setdefault('signature_files',{})[most_recent_exec_file] = value return if arg == 'cross_project_id': if not value: value = tools.make_uuid() args_dict[arg] = value def translate_database_arg(database_table, arg, value): '''Look up an object ``value`` either as a database ID or string. This allows us to accept e.g. either --app Astropulse or --app 1''' try: id = int(value) results = database_table.find(id=id) if not results: raise Exception("") except: results = database_table.find(name=value) if len(results) == 0: raise SystemExit('No %s "%s" found' %(arg,value)) if len(results) > 1: print >>sys.stderr, 'Too many %ss match "%s": '%(arg,value) for result in results: print >>sys.stderr, ' ', result.name raise SystemExit return results[0] class AddObjectException(Exception): pass def check_required_arguments(add_object, args_dict): for arg in add_object.args: if not arg in args_dict: raise AddObjectException('required value for %s not given'%arg) def translate_args_dict(add_object, untranslated_args_dict): args_dict = add_object.default_values.copy() for arg,value in untranslated_args_dict.items(): translate_arg(add_object,arg,value,args_dict) return args_dict def exception_is_duplicate_entry(exception): '''Checks a MySQLdb.IntegrityError for whether the error is Duplicate Entry. Kludgy.''' return (isinstance(exception, MySQLdb.IntegrityError) and str(exception).find('Duplicate entry')!=-1) def do_add_object(add_object, untranslated_args_dict, skip_old=False): '''Input ```args_dict``` must have been translated already.''' args_dict = translate_args_dict(add_object, untranslated_args_dict) check_required_arguments(add_object, args_dict) dbobject = add_object.DatabaseObject(**args_dict) print "Processing", dbobject, "..." # print "Commiting", dbobject, "with args:" # pprint.pprint(dbobject.__dict__) try: dbobject.commit() except MySQLdb.MySQLError, e: if skip_old and exception_is_duplicate_entry(e): print " Skipped existing", dbobject return else: raise SystemExit('Error committing %s: %s' %(dbobject, e)) # delete object and re-select it from database to allow user to check # consistency id = dbobject.id del dbobject dbobject = add_object.DatabaseObject._table[id] print " Committed", dbobject, "; values:" pprint.pprint(dbobject.__dict__)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 2672, 1304, 4, 199, 199, 3, 1050, 63, 1974, 14, 647, 446, 1233, 5709, 3382, 1050, 436, 671, 525, 199, 199, 646, 3050, 12, 7249, 199, 646, 900, 12, 10933, 199, 646, 25709, 199, 199, 8366, 63, 4961, 275, 788, 31, 981, 63, 521, 297, 1109, 8, 521, 14, 521, 24821, 199, 12191, 12039, 63, 4961, 275, 788, 31, 14143, 63, 521, 297, 1109, 8, 521, 14, 521, 24821, 199, 199, 533, 1323, 2640, 3353, 8, 4659, 14, 2640, 3353, 304, 272, 347, 636, 826, 721, 277, 12663, 958, 304, 267, 2074, 459, 1652, 63, 1301, 418, 275, 7249, 14, 1412, 63, 571, 63, 1023, 8, 288, 1145, 275, 2074, 459, 571, 995, 288, 1015, 63, 1507, 275, 1109, 8, 958, 459, 1023, 63, 1507, 3815, 288, 2146, 63, 1725, 275, 2074, 459, 1628, 63, 1725, 995, 288, 4955, 63, 1725, 275, 2074, 14, 5486, 360, 5233, 63, 1725, 297, 2440, 430, 267, 2150, 2074, 459, 5233, 63, 1725, 418, 267, 2150, 2074, 459, 1628, 63, 1725, 418, 267, 2150, 2074, 459, 1628, 63, 493, 418, 267, 3050, 14, 2640, 3353, 855, 826, 721, 277, 12663, 958, 9, 199, 199, 3, 1475, 26, 359, 3050, 14, 1692, 12, 1249, 12, 21214, 199, 3, 257, 1680, 1475, 26, 199, 3, 755, 283, 1273, 7, 199, 3, 755, 8720, 1273, 7, 259, 2716, 199, 3, 755, 359, 283, 1273, 297, 849, 63, 585, 1622, 199, 199, 3, 6944, 2296, 1804, 689, 44, 26, 982, 8059, 63, 1715, 63, 344, 365, 440, 6841, 12, 314, 849, 574, 199, 3, 1077, 506, 282, 2196, 4337, 4528, 2884, 15884, 701, 9689, 314, 6128, 21, 1838, 199, 3, 2631, 402, 334, 19787, 9, 10574, 2783, 687, 1182, 2374, 15, 22776, 503, 8545, 14, 199, 199, 513, 63, 1462, 63, 475, 63, 525, 275, 359, 272, 359, 3050, 14, 10397, 12, 257, 283, 354, 297, 283, 751, 63, 17317, 63, 354, 297, 16999, 63, 4961, 2156, 272, 359, 3050, 14, 2640, 12, 263, 283, 354, 297, 283, 751, 63, 17317, 63, 354, 297, 788, 31, 827, 63, 1023, 297, 16, 467, 16999, 63, 4961, 467, 272, 359, 1323, 2640, 3353, 12, 283, 571, 297, 283, 3246, 297, 283, 1023, 63, 1507, 297, 283, 1628, 63, 493, 297, 8720, 5233, 63, 493, 297, 489, 16999, 63, 4961, 2156, 272, 359, 3050, 14, 1899, 12, 755, 283, 354, 297, 283, 2123, 63, 2697, 297, 283, 1178, 21345, 297, 489, 788, 31, 6063, 1673, 1358, 5703, 24230, 995, 788, 31, 31580, 63, 600, 1673, 16, 995, 788, 31, 7925, 63, 1715, 63, 344, 297, 283, 16, 995, 489, 8720, 2966, 63, 17253, 297, 8720, 2966, 63, 17253, 63, 493, 297, 489, 16999, 63, 4961, 2156, 272, 327, 359, 3050, 14, 6517, 3248, 12, 257, 283, 11335, 7, 2156, 272, 1622, 199, 199, 533, 2654, 1692, 26, 272, 986, 199, 199, 525, 63, 1462, 275, 1052, 199, 509, 312, 315, 769, 63, 1462, 63, 475, 63, 525, 26, 272, 1050, 63, 785, 275, 2654, 1692, 342, 272, 1050, 63, 785, 14, 7243, 1692, 275, 312, 59, 16, 61, 272, 1050, 63, 785, 14, 354, 275, 1050, 63, 785, 14, 7243, 1692, 423, 1224, 14, 1224, 272, 1050, 63, 785, 14, 589, 275, 942, 272, 1050, 63, 785, 14, 4144, 63, 589, 275, 942, 272, 1050, 63, 785, 14, 885, 63, 1459, 275, 1052, 272, 367, 1680, 315, 312, 59, 17, 10688, 267, 340, 1228, 8, 1273, 12, 769, 304, 288, 849, 63, 585, 275, 1680, 59, 17, 61, 288, 1680, 275, 1680, 59, 16, 61, 267, 587, 26, 288, 849, 63, 585, 275, 488, 267, 340, 1680, 14, 2460, 360, 31, 735, 288, 2716, 275, 715, 288, 1680, 275, 1680, 59, 17, 2938, 267, 587, 26, 288, 2716, 275, 756, 267, 340, 2716, 26, 288, 1050, 63, 785, 14, 4144, 63, 589, 14, 740, 8, 1273, 9, 267, 587, 26, 288, 1050, 63, 785, 14, 589, 14, 740, 8, 1273, 9, 267, 340, 849, 63, 585, 26, 288, 1050, 63, 785, 14, 885, 63, 1459, 59, 1273, 61, 275, 849, 63, 585, 272, 1050, 63, 1462, 59, 525, 63, 785, 14, 354, 61, 275, 1050, 63, 785, 199, 199, 2786, 63, 14951, 63, 1628, 63, 493, 275, 488, 199, 199, 318, 9028, 63, 1273, 8, 785, 12, 1680, 12, 574, 12, 1249, 63, 807, 304, 272, 1449, 18355, 7750, 922, 1423, 1338, 12, 367, 7791, 1627, 1124, 785, 4345, 272, 12972, 5604, 1124, 589, 63, 807, 4345, 2344, 339, 3050, 63, 1224, 275, 488, 272, 862, 26, 267, 3050, 63, 1224, 275, 3050, 855, 807, 12298, 1273, 14, 18351, 5106, 423, 1224, 272, 871, 26, 267, 986, 272, 340, 3050, 63, 1224, 26, 267, 1249, 63, 807, 59, 1273, 61, 275, 9028, 63, 4659, 63, 1273, 8, 4659, 63, 1224, 12, 1680, 12, 574, 9, 267, 372, 339, 340, 1680, 508, 283, 2966, 63, 17253, 63, 493, 356, 267, 1249, 63, 807, 459, 2966, 63, 17253, 418, 275, 1551, 8, 585, 680, 739, 342, 267, 372, 339, 340, 909, 14, 7243, 1692, 508, 1323, 2640, 3353, 26, 267, 327, 283, 525, 1145, 63, 1023, 7, 11479, 3663, 2475, 1628, 63, 493, 1159, 543, 267, 327, 2475, 5233, 63, 493, 7, 18876, 370, 314, 4750, 8058, 2146, 63, 493, 267, 340, 1680, 508, 283, 1628, 63, 493, 356, 288, 2288, 4750, 63, 14951, 63, 1628, 63, 493, 288, 4750, 63, 14951, 63, 1628, 63, 493, 275, 574, 288, 1249, 63, 807, 14, 5486, 360, 1628, 63, 1725, 23993, 6575, 740, 8, 585, 9, 288, 327, 3967, 283, 1628, 63, 493, 7, 334, 7395, 283, 83, 358, 365, 1415, 12, 663, 652, 370, 488, 880, 288, 327, 626, 1423, 7739, 19428, 781, 4788, 1373, 27, 781, 7171, 3145, 652, 2945, 14, 288, 1249, 63, 807, 59, 1273, 61, 275, 488, 288, 372, 267, 340, 1680, 508, 283, 5233, 63, 493, 356, 288, 1249, 63, 807, 14, 5486, 360, 5233, 63, 1725, 297, 91, 1552, 59, 2786, 63, 14951, 63, 1628, 63, 493, 61, 275, 574, 288, 372, 339, 340, 1680, 508, 283, 7925, 63, 1715, 63, 344, 356, 267, 340, 440, 574, 26, 288, 574, 275, 7249 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 2672, 1304, 4, 199, 199, 3, 1050, 63, 1974, 14, 647, 446, 1233, 5709, 3382, 1050, 436, 671, 525, 199, 199, 646, 3050, 12, 7249, 199, 646, 900, 12, 10933, 199, 646, 25709, 199, 199, 8366, 63, 4961, 275, 788, 31, 981, 63, 521, 297, 1109, 8, 521, 14, 521, 24821, 199, 12191, 12039, 63, 4961, 275, 788, 31, 14143, 63, 521, 297, 1109, 8, 521, 14, 521, 24821, 199, 199, 533, 1323, 2640, 3353, 8, 4659, 14, 2640, 3353, 304, 272, 347, 636, 826, 721, 277, 12663, 958, 304, 267, 2074, 459, 1652, 63, 1301, 418, 275, 7249, 14, 1412, 63, 571, 63, 1023, 8, 288, 1145, 275, 2074, 459, 571, 995, 288, 1015, 63, 1507, 275, 1109, 8, 958, 459, 1023, 63, 1507, 3815, 288, 2146, 63, 1725, 275, 2074, 459, 1628, 63, 1725, 995, 288, 4955, 63, 1725, 275, 2074, 14, 5486, 360, 5233, 63, 1725, 297, 2440, 430, 267, 2150, 2074, 459, 5233, 63, 1725, 418, 267, 2150, 2074, 459, 1628, 63, 1725, 418, 267, 2150, 2074, 459, 1628, 63, 493, 418, 267, 3050, 14, 2640, 3353, 855, 826, 721, 277, 12663, 958, 9, 199, 199, 3, 1475, 26, 359, 3050, 14, 1692, 12, 1249, 12, 21214, 199, 3, 257, 1680, 1475, 26, 199, 3, 755, 283, 1273, 7, 199, 3, 755, 8720, 1273, 7, 259, 2716, 199, 3, 755, 359, 283, 1273, 297, 849, 63, 585, 1622, 199, 199, 3, 6944, 2296, 1804, 689, 44, 26, 982, 8059, 63, 1715, 63, 344, 365, 440, 6841, 12, 314, 849, 574, 199, 3, 1077, 506, 282, 2196, 4337, 4528, 2884, 15884, 701, 9689, 314, 6128, 21, 1838, 199, 3, 2631, 402, 334, 19787, 9, 10574, 2783, 687, 1182, 2374, 15, 22776, 503, 8545, 14, 199, 199, 513, 63, 1462, 63, 475, 63, 525, 275, 359, 272, 359, 3050, 14, 10397, 12, 257, 283, 354, 297, 283, 751, 63, 17317, 63, 354, 297, 16999, 63, 4961, 2156, 272, 359, 3050, 14, 2640, 12, 263, 283, 354, 297, 283, 751, 63, 17317, 63, 354, 297, 788, 31, 827, 63, 1023, 297, 16, 467, 16999, 63, 4961, 467, 272, 359, 1323, 2640, 3353, 12, 283, 571, 297, 283, 3246, 297, 283, 1023, 63, 1507, 297, 283, 1628, 63, 493, 297, 8720, 5233, 63, 493, 297, 489, 16999, 63, 4961, 2156, 272, 359, 3050, 14, 1899, 12, 755, 283, 354, 297, 283, 2123, 63, 2697, 297, 283, 1178, 21345, 297, 489, 788, 31, 6063, 1673, 1358, 5703, 24230, 995, 788, 31, 31580, 63, 600, 1673, 16, 995, 788, 31, 7925, 63, 1715, 63, 344, 297, 283, 16, 995, 489, 8720, 2966, 63, 17253, 297, 8720, 2966, 63, 17253, 63, 493, 297, 489, 16999, 63, 4961, 2156, 272, 327, 359, 3050, 14, 6517, 3248, 12, 257, 283, 11335, 7, 2156, 272, 1622, 199, 199, 533, 2654, 1692, 26, 272, 986, 199, 199, 525, 63, 1462, 275, 1052, 199, 509, 312, 315, 769, 63, 1462, 63, 475, 63, 525, 26, 272, 1050, 63, 785, 275, 2654, 1692, 342, 272, 1050, 63, 785, 14, 7243, 1692, 275, 312, 59, 16, 61, 272, 1050, 63, 785, 14, 354, 275, 1050, 63, 785, 14, 7243, 1692, 423, 1224, 14, 1224, 272, 1050, 63, 785, 14, 589, 275, 942, 272, 1050, 63, 785, 14, 4144, 63, 589, 275, 942, 272, 1050, 63, 785, 14, 885, 63, 1459, 275, 1052, 272, 367, 1680, 315, 312, 59, 17, 10688, 267, 340, 1228, 8, 1273, 12, 769, 304, 288, 849, 63, 585, 275, 1680, 59, 17, 61, 288, 1680, 275, 1680, 59, 16, 61, 267, 587, 26, 288, 849, 63, 585, 275, 488, 267, 340, 1680, 14, 2460, 360, 31, 735, 288, 2716, 275, 715, 288, 1680, 275, 1680, 59, 17, 2938, 267, 587, 26, 288, 2716, 275, 756, 267, 340, 2716, 26, 288, 1050, 63, 785, 14, 4144, 63, 589, 14, 740, 8, 1273, 9, 267, 587, 26, 288, 1050, 63, 785, 14, 589, 14, 740, 8, 1273, 9, 267, 340, 849, 63, 585, 26, 288, 1050, 63, 785, 14, 885, 63, 1459, 59, 1273, 61, 275, 849, 63, 585, 272, 1050, 63, 1462, 59, 525, 63, 785, 14, 354, 61, 275, 1050, 63, 785, 199, 199, 2786, 63, 14951, 63, 1628, 63, 493, 275, 488, 199, 199, 318, 9028, 63, 1273, 8, 785, 12, 1680, 12, 574, 12, 1249, 63, 807, 304, 272, 1449, 18355, 7750, 922, 1423, 1338, 12, 367, 7791, 1627, 1124, 785, 4345, 272, 12972, 5604, 1124, 589, 63, 807, 4345, 2344, 339, 3050, 63, 1224, 275, 488, 272, 862, 26, 267, 3050, 63, 1224, 275, 3050, 855, 807, 12298, 1273, 14, 18351, 5106, 423, 1224, 272, 871, 26, 267, 986, 272, 340, 3050, 63, 1224, 26, 267, 1249, 63, 807, 59, 1273, 61, 275, 9028, 63, 4659, 63, 1273, 8, 4659, 63, 1224, 12, 1680, 12, 574, 9, 267, 372, 339, 340, 1680, 508, 283, 2966, 63, 17253, 63, 493, 356, 267, 1249, 63, 807, 459, 2966, 63, 17253, 418, 275, 1551, 8, 585, 680, 739, 342, 267, 372, 339, 340, 909, 14, 7243, 1692, 508, 1323, 2640, 3353, 26, 267, 327, 283, 525, 1145, 63, 1023, 7, 11479, 3663, 2475, 1628, 63, 493, 1159, 543, 267, 327, 2475, 5233, 63, 493, 7, 18876, 370, 314, 4750, 8058, 2146, 63, 493, 267, 340, 1680, 508, 283, 1628, 63, 493, 356, 288, 2288, 4750, 63, 14951, 63, 1628, 63, 493, 288, 4750, 63, 14951, 63, 1628, 63, 493, 275, 574, 288, 1249, 63, 807, 14, 5486, 360, 1628, 63, 1725, 23993, 6575, 740, 8, 585, 9, 288, 327, 3967, 283, 1628, 63, 493, 7, 334, 7395, 283, 83, 358, 365, 1415, 12, 663, 652, 370, 488, 880, 288, 327, 626, 1423, 7739, 19428, 781, 4788, 1373, 27, 781, 7171, 3145, 652, 2945, 14, 288, 1249, 63, 807, 59, 1273, 61, 275, 488, 288, 372, 267, 340, 1680, 508, 283, 5233, 63, 493, 356, 288, 1249, 63, 807, 14, 5486, 360, 5233, 63, 1725, 297, 91, 1552, 59, 2786, 63, 14951, 63, 1628, 63, 493, 61, 275, 574, 288, 372, 339, 340, 1680, 508, 283, 7925, 63, 1715, 63, 344, 356, 267, 340, 440, 574, 26, 288, 574, 275, 7249, 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 ]
bigzz/glibc
localedata/unicode-gen/ctype_compatibility.py
13
23044
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Copyright (C) 2014-2015 Free Software Foundation, Inc. # This file is part of the GNU C Library. # # The GNU C Library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # The GNU C Library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with the GNU C Library; if not, see # <http://www.gnu.org/licenses/>. ''' This script is useful for checking the differences between an old LC_CTYPE file /usr/share/i18n/locale/i18n and a new one generated by gen_unicode_ctype.py To see how it is used, call it with the “-h” option: $ ./ctype_compatibility.py -h … prints usage message … ''' import sys import re import unicodedata import argparse from ctype_compatibility_test_cases import TEST_CASES def get_lines_from_file(filename): '''Get all non-comment lines from a i18n file Also merge all lines which are continued on the next line because they end in “/” into a single line. ''' with open(filename) as i18n_file: current_line = '' for line in i18n_file: line = line.strip('\n') if '%' in line: if line.endswith('/'): line = line[0:line.find('%')] + '/' else: line = line[0:line.find('%')] line = line.strip() if line.endswith('/'): current_line += line[:-1] else: yield current_line + line current_line = '' if current_line: # file ends with a continuation line yield current_line def extract_character_classes(filename): '''Get all Unicode code points for each character class from a file Store these code points in a dictionary using the character classes as keys and the list of code points in this character class as values. In case of the character classes “toupper”, “tolower”, and “totitle”, these area actually pairs of code points ''' ctype_dict = {} for line in get_lines_from_file(filename): for char_class in [ 'upper', 'lower', 'alpha', 'digit', 'outdigit', 'space', 'cntrl', 'punct', 'graph', 'print', 'xdigit', 'blank', 'combining', 'combining_level3', 'toupper', 'tolower', 'totitle']: match = re.match(r'^(' +'(?:(?:class|map)\s+")' +re.escape(char_class)+ '(?:";)\s+' +'|' +re.escape(char_class)+'\s+' +')', line) if match: if char_class not in ctype_dict: ctype_dict[char_class] = [] process_chars( ctype_dict[char_class], line[match.end():]) return ctype_dict def process_chars(char_class_list, code_point_line): ''' Extract Unicode values from code_point_line and add to the list of code points in a character class ''' for code_points in code_point_line.split(';'): code_points = code_points.strip() match = re.match(r'^<U(?P<codepoint>[0-9A-F]{4,8})>$', code_points) if match: # <Uxxxx> char_class_list.append( int(match.group('codepoint'), 16)) continue match = re.match( r'^<U(?P<codepoint1>[0-9A-F]{4,8})>' +'\.\.'+ '<U(?P<codepoint2>[0-9A-F]{4,8})>$', code_points) if match: # <Uxxxx>..<Uxxxx> for codepoint in range( int(match.group('codepoint1'), 16), int(match.group('codepoint2'), 16) + 1): char_class_list.append(codepoint) continue match = re.match( r'^<U(?P<codepoint1>[0-9A-F]{4,8})>' +'\.\.\(2\)\.\.'+ '<U(?P<codepoint2>[0-9A-F]{4,8})>$', code_points) if match: # <Uxxxx>..(2)..<Uxxxx> for codepoint in range( int(match.group('codepoint1'), 16), int(match.group('codepoint2'), 16) + 1, 2): char_class_list.append(codepoint) continue match = re.match( r'^\(' +'<U(?P<codepoint1>[0-9A-F]{4,8})>' +','+ '<U(?P<codepoint2>[0-9A-F]{4,8})>' +'\)$', code_points) if match: # (<Uxxxx>,<Uxxxx>) char_class_list.append(( int(match.group('codepoint1'), 16), int(match.group('codepoint2'), 16))) continue sys.stderr.write( ('None of the regexps matched ' + 'code_points=%(cp)s in code_point_line=%(cpl)s\n') %{ 'cp': code_points, 'cpl': code_point_line }) exit(1) def compare_lists(old_ctype_dict, new_ctype_dict): '''Compare character classes in the old and the new LC_CTYPE''' print('****************************************************') print('Character classes which are only in the new ' + 'or only in the old file:') for char_class in sorted(old_ctype_dict): if char_class not in new_ctype_dict: print('Character class %s is in old ctype but not in new ctype' %char_class) for char_class in sorted(new_ctype_dict): if char_class not in old_ctype_dict: print('Character class %s is in new ctype but not in old ctype' %char_class) for char_class in sorted(old_ctype_dict): print("****************************************************") print("%s: %d chars in old ctype and %d chars in new ctype" %( char_class, len(old_ctype_dict[char_class]), len(new_ctype_dict[char_class]))) print("----------------------------------------------------") report(char_class, old_ctype_dict[char_class], new_ctype_dict[char_class]) def report_code_points(char_class, code_point_list, text=''): '''Report all code points which have been added to or removed from a character class. ''' for code_point in sorted(code_point_list): if type(code_point) == type(int()): print('%(char_class)s: %(text)s: %(char)s %(code_point)s %(name)s' %{'text': text, 'char': chr(code_point), 'char_class': char_class, 'code_point': hex(code_point), 'name': unicodedata.name(chr(code_point), 'name unknown')}) else: print(('%(char_class)s: %(text)s: ' + '%(char0)s → %(char1)s ' + '%(code_point0)s → %(code_point1)s ' + '%(name0)s → %(name1)s') %{ 'text': text, 'char_class': char_class, 'char0': chr(code_point[0]), 'code_point0': hex(code_point[0]), 'name0': unicodedata.name(chr(code_point[0]), 'name unknown'), 'char1': chr(code_point[1]), 'code_point1': hex(code_point[1]), 'name1': unicodedata.name(chr(code_point[1]), 'name unknown') }) def report(char_class, old_list, new_list): '''Report the differences for a certain LC_CTYPE character class between the old and the newly generated state ''' missing_chars = list(set(old_list)-set(new_list)) print(('%(char_class)s: Missing %(number)d characters ' + 'of old ctype in new ctype ') %{'char_class': char_class, 'number': len(missing_chars)}) if ARGS.show_missing_characters: report_code_points(char_class, missing_chars, 'Missing') added_chars = list(set(new_list)-set(old_list)) print(('%(char_class)s: Added %(number)d characters ' + 'in new ctype which were not in old ctype') %{'char_class': char_class, 'number': len(added_chars)}) if ARGS.show_added_characters: report_code_points(char_class, added_chars, 'Added') def cperror(error_message, errorcounter=0): '''Increase number of errors by one and print an error message''' print(error_message) return errorcounter + 1 def cpcheck(ctype_dict, code_point_list_with_ranges, char_classes, reason='', errorcounter=0): '''The parameter “code_point_list_with_ranges” is a list of integers or pairs of integers, for example: [0x0E31, (0x0E34, 0x0E3A), (0x0E47, 0x0E4E)] where the pairs of integers stand for all the code points in the range of the two integers given, including the two integers of the pair. ''' for code_point_range in code_point_list_with_ranges: for code_point in ([code_point_range] if type(code_point_range) == type(int()) else range(code_point_range[0], code_point_range[1]+1)): for char_class_tuple in char_classes: char_class = char_class_tuple[0] in_char_class = char_class_tuple[1] if (code_point in ctype_dict[char_class]) != in_char_class: errorcounter = cperror( ('error: %(code_point)s %(char)s ' + '%(char_class)s %(in)s: %(reason)s') %{ 'code_point': hex(code_point), 'char': chr(code_point), 'char_class': char_class, 'in': not in_char_class, 'reason': reason}, errorcounter) return errorcounter def tests(ctype_dict, errorcounter = 0): '''Test a LC_CTYPE character class dictionary for known errors''' # copy the information from ctype_dict (which contains lists) in # a new dictionary ctype_dict2 (which contains dictionaries). # The checks below are easier with that type of data structure. ctype_dict2 = {} for key in ctype_dict: ctype_dict2[key] = {} if ctype_dict[key]: if type(ctype_dict[key][0]) == type(int()): for value in ctype_dict[key]: ctype_dict2[key][value] = 1 else: # key is 'toupper', 'tolower', or 'totitle' for value in ctype_dict[key]: ctype_dict2[key][value[0]] = value[1] for test_case in TEST_CASES: errorcounter = cpcheck(ctype_dict2, test_case[0], test_case[1], test_case[2], errorcounter = errorcounter) for code_point in range(0, 0x110000): # toupper restriction: "Only characters specified for the keywords # lower and upper shall be specified. if (code_point in ctype_dict2['toupper'] and code_point != ctype_dict2['toupper'][code_point] and not (code_point in ctype_dict2['lower'] or code_point in ctype_dict2['upper'])): errorcounter = cperror( ('error: %(char1)s is not upper|lower ' + 'but toupper(%(cp1)s)=%(cp2)s (%(char2)s)') %{ 'char1': chr(code_point), 'cp1': hex(code_point), 'cp2': hex(ctype_dict2['toupper'][code_point]), 'char2': chr(ctype_dict2['toupper'][code_point]) }, errorcounter) # tolower restriction: "Only characters specified for the keywords # lower and upper shall be specified. if (code_point in ctype_dict2['tolower'] and code_point != ctype_dict2['tolower'][code_point] and not (code_point in ctype_dict2['lower'] or code_point in ctype_dict2['upper'])): errorcounter = cperror( ('error: %(char1)s is not upper|lower ' + 'but tolower(%(cp1)s)=%(cp2)s (%(char2)s)') %{ 'char1': chr(code_point), 'cp1': hex(code_point), 'cp2': hex(ctype_dict2['tolower'][code_point]), 'char2': chr(ctype_dict2['tolower'][code_point]) }, errorcounter) # alpha restriction: "Characters classified as either upper or lower # shall automatically belong to this class. if ((code_point in ctype_dict2['lower'] or code_point in ctype_dict2['upper']) and code_point not in ctype_dict2['alpha']): errorcounter = cperror( 'error: %(char)s %(cp)s is upper|lower but not alpha' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) # alpha restriction: "No character specified for the keywords cntrl, # digit, punct or space shall be specified." if (code_point in ctype_dict2['alpha'] and code_point in ctype_dict2['cntrl']): errorcounter = cperror( 'error: %(char)s %(cp)s is alpha and cntrl' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['alpha'] and code_point in ctype_dict2['digit']): errorcounter = cperror( 'error: %(char)s %(cp)s is alpha and digit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['alpha'] and code_point in ctype_dict2['punct']): errorcounter = cperror( 'error: %(char)s %(cp)s is alpha and punct' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['alpha'] and code_point in ctype_dict2['space']): errorcounter = cperror( 'error: %(char)s %(cp)s is alpha and space' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) # space restriction: "No character specified for the keywords upper, # lower, alpha, digit, graph or xdigit shall be specified." # upper, lower, alpha already checked above. if (code_point in ctype_dict2['space'] and code_point in ctype_dict2['digit']): errorcounter = cperror( 'error: %(char)s %(cp)s is space and digit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['space'] and code_point in ctype_dict2['graph']): errorcounter = cperror( 'error: %(char)s %(cp)s is space and graph' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['space'] and code_point in ctype_dict2['xdigit']): errorcounter = cperror( 'error: %(char)s %(cp)s is space and xdigit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) # cntrl restriction: "No character specified for the keywords upper, # lower, alpha, digit, punct, graph, print or xdigit shall be # specified." upper, lower, alpha already checked above. if (code_point in ctype_dict2['cntrl'] and code_point in ctype_dict2['digit']): errorcounter = cperror( 'error: %(char)s %(cp)s is cntrl and digit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['cntrl'] and code_point in ctype_dict2['punct']): errorcounter = cperror( 'error: %(char)s %(cp)s is cntrl and punct' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['cntrl'] and code_point in ctype_dict2['graph']): errorcounter = cperror( 'error: %(char)s %(cp)s is cntrl and graph' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['cntrl'] and code_point in ctype_dict2['print']): errorcounter = cperror( 'error: %(char)s %(cp)s is cntrl and print' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['cntrl'] and code_point in ctype_dict2['xdigit']): errorcounter = cperror( 'error: %(char)s %(cp)s is cntrl and xdigit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) # punct restriction: "No character specified for the keywords upper, # lower, alpha, digit, cntrl, xdigit or as the <space> character shall # be specified." upper, lower, alpha, cntrl already checked above. if (code_point in ctype_dict2['punct'] and code_point in ctype_dict2['digit']): errorcounter = cperror( 'error: %(char)s %(cp)s is punct and digit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['punct'] and code_point in ctype_dict2['xdigit']): errorcounter = cperror( 'error: %(char)s %(cp)s is punct and xdigit' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point in ctype_dict2['punct'] and code_point == 0x0020): errorcounter = cperror( 'error: %(char)s %(cp)s is punct.' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) # graph restriction: "No character specified for the keyword cntrl # shall be specified." Already checked above. # print restriction: "No character specified for the keyword cntrl # shall be specified." Already checked above. # graph - print relation: differ only in the <space> character. # How is this possible if there are more than one space character?! # I think susv2/xbd/locale.html should speak of "space characters", # not "space character". if (code_point in ctype_dict2['print'] and not (code_point in ctype_dict2['graph'] or code_point in ctype_dict2['space'])): errorcounter = cperror( 'error: %(char)s %(cp)s is print but not graph|space' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) if (code_point not in ctype_dict2['print'] and (code_point in ctype_dict2['graph'] or code_point == 0x0020)): errorcounter = cperror( 'error: %(char)s %(cp)s graph|space but not print' %{ 'char': chr(code_point), 'cp': hex(code_point) }, errorcounter) return errorcounter if __name__ == "__main__": PARSER = argparse.ArgumentParser( description=''' Compare the contents of LC_CTYPE in two files and check for errors. ''') PARSER.add_argument( '-o', '--old_ctype_file', nargs='?', type=str, default='i18n', help='The old ctype file, default: %(default)s') PARSER.add_argument( '-n', '--new_ctype_file', nargs='?', type=str, default='unicode-ctype', help='The new ctype file, default: %(default)s') PARSER.add_argument( '-a', '--show_added_characters', action='store_true', help=('Show characters which were added to each ' + 'character class in detail.')) PARSER.add_argument( '-m', '--show_missing_characters', action='store_true', help=('Show characters which were removed from each ' + 'character class in detail.')) ARGS = PARSER.parse_args() OLD_CTYPE_DICT = extract_character_classes( ARGS.old_ctype_file) NEW_CTYPE_DICT = extract_character_classes( ARGS.new_ctype_file) compare_lists(OLD_CTYPE_DICT, NEW_CTYPE_DICT) print('============================================================') print('Checking for errors in old ctype file: %s' %ARGS.old_ctype_file) print('------------------------------------------------------------') NUMBER_OF_ERRORS_IN_OLD_FILE = tests(OLD_CTYPE_DICT, errorcounter = 0) print('------------------------------------------------------------') print('Old file = %s' %ARGS.old_ctype_file) print('Number of errors in old file = %s' %NUMBER_OF_ERRORS_IN_OLD_FILE) print('------------------------------------------------------------') print('============================================================') print('Checking for errors in new ctype file: %s' %ARGS.new_ctype_file) print('------------------------------------------------------------') NUMBER_OF_ERRORS_IN_NEW_FILE = tests(NEW_CTYPE_DICT, errorcounter = 0) print('------------------------------------------------------------') print('New file = %s' %ARGS.new_ctype_file) print('Number of errors in new file = %s' %NUMBER_OF_ERRORS_IN_NEW_FILE) print('------------------------------------------------------------') if NUMBER_OF_ERRORS_IN_NEW_FILE > 0: exit(1) else: exit(0)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 6927, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 961, 570, 365, 1777, 402, 314, 1664, 445, 11243, 14, 199, 3, 199, 3, 710, 1664, 445, 11243, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 710, 1664, 445, 11243, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 314, 1664, 445, 11243, 27, 340, 440, 12, 1937, 199, 3, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 2344, 199, 2765, 2884, 365, 2997, 367, 7907, 314, 15109, 3382, 199, 290, 2269, 26703, 63, 7540, 570, 1182, 2647, 15, 6251, 15, 73, 1085, 78, 15, 5508, 15, 73, 1085, 78, 436, 282, 199, 1222, 1373, 4046, 701, 3805, 63, 2975, 63, 3667, 14, 647, 199, 199, 1378, 1937, 4212, 652, 365, 1202, 12, 1240, 652, 543, 314, 27430, 251, 13, 72, 8477, 252, 945, 26, 339, 2672, 16605, 3667, 63, 15390, 14, 647, 446, 72, 272, 27430, 100, 14767, 4503, 1245, 27430, 100, 199, 2344, 199, 199, 646, 984, 199, 646, 295, 199, 646, 23128, 199, 646, 7534, 199, 199, 504, 16360, 63, 15390, 63, 396, 63, 9403, 492, 7393, 63, 9777, 654, 199, 199, 318, 664, 63, 1278, 63, 504, 63, 493, 8, 1501, 304, 272, 1449, 1002, 1006, 2222, 13, 3349, 2385, 687, 282, 284, 1085, 78, 570, 339, 6121, 5389, 1006, 2385, 1314, 787, 32541, 641, 314, 2163, 1004, 2952, 272, 2985, 1284, 315, 27430, 251, 15, 8477, 252, 1901, 282, 2849, 1004, 14, 272, 1449, 272, 543, 1551, 8, 1501, 9, 465, 284, 1085, 78, 63, 493, 26, 267, 1453, 63, 604, 275, 2125, 267, 367, 1004, 315, 284, 1085, 78, 63, 493, 26, 288, 1004, 275, 1004, 14, 1913, 2258, 78, 358, 288, 340, 26386, 315, 1004, 26, 355, 340, 1004, 14, 4130, 18265, 490, 1004, 275, 1004, 59, 16, 26, 604, 14, 1623, 3508, 5440, 435, 7324, 355, 587, 26, 490, 1004, 275, 1004, 59, 16, 26, 604, 14, 1623, 3508, 5440, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 1004, 14, 4130, 18265, 355, 1453, 63, 604, 847, 1004, 4439, 17, 61, 288, 587, 26, 355, 1995, 1453, 63, 604, 435, 1004, 355, 1453, 63, 604, 275, 2125, 272, 340, 1453, 63, 604, 26, 327, 570, 11187, 543, 282, 16015, 1004, 267, 1995, 1453, 63, 604, 199, 199, 318, 5536, 63, 10856, 63, 2888, 8, 1501, 304, 272, 1449, 1002, 1006, 6140, 1233, 4501, 367, 1924, 4528, 1021, 687, 282, 570, 339, 13874, 3520, 1233, 4501, 315, 282, 2600, 1808, 314, 4528, 3992, 272, 465, 2883, 436, 314, 769, 402, 1233, 4501, 315, 642, 4528, 1021, 465, 1338, 14, 339, 1010, 1930, 221, 402, 314, 4528, 3992, 27430, 251, 475, 4142, 8477, 252, 12, 27430, 251, 475, 2325, 8477, 252, 12, 436, 27430, 251, 475, 1213, 8477, 252, 12, 272, 3520, 9150, 5965, 6342, 402, 1233, 4501, 272, 1449, 272, 16360, 63, 807, 275, 1052, 272, 367, 1004, 315, 664, 63, 1278, 63, 504, 63, 493, 8, 1501, 304, 267, 367, 1495, 63, 533, 315, 359, 355, 283, 4142, 297, 355, 283, 2325, 297, 355, 283, 4468, 297, 355, 283, 8573, 297, 355, 283, 548, 8573, 297, 355, 283, 2638, 297, 355, 283, 6507, 4308, 297, 355, 283, 27003, 297, 355, 283, 2180, 297, 355, 283, 1361, 297, 355, 283, 88, 8573, 297, 355, 283, 2500, 297, 355, 283, 6560, 7969, 297, 355, 283, 6560, 7969, 63, 1896, 19, 297, 355, 283, 475, 4142, 297, 355, 283, 475, 2325, 297, 355, 283, 475, 1213, 2565, 288, 1336, 275, 295, 14, 1431, 8, 82, 4289, 360, 2490, 435, 20459, 5169, 533, 92, 1130, 2862, 83, 21425, 7, 2490, 435, 264, 14, 3765, 8, 1560, 63, 533, 6393, 2490, 283, 5169, 11436, 2862, 83, 4786, 2490, 435, 26972, 2490, 435, 264, 14, 3765, 8, 1560, 63, 533, 6393, 1154, 83, 4786, 2490, 435, 358, 297, 1004, 9, 288, 340, 1336, 26, 355, 340, 1495, 63, 533, 440, 315, 16360, 63, 807, 26, 490, 16360, 63, 807, 59, 1560, 63, 533, 61, 275, 942, 355, 2112, 63, 6574, 8, 490, 16360, 63, 807, 59, 1560, 63, 533, 467, 490, 1004, 59, 1431, 14, 500, 837, 566, 272, 372, 16360, 63, 807, 199, 199, 318, 2112, 63, 6574, 8, 1560, 63, 533, 63, 513, 12, 1233, 63, 1403, 63, 604, 304, 272, 1449, 272, 12892, 6140, 1338, 687, 1233, 63, 1403, 63, 604, 272, 436, 1050, 370, 314, 769, 402, 1233, 4501, 315, 282, 4528, 1021, 272, 1449, 272, 367, 1233, 63, 3438, 315, 1233, 63, 1403, 63, 604, 14, 1294, 25282, 735, 267, 1233, 63, 3438, 275, 1233, 63, 3438, 14, 1913, 342, 267, 1336, 275, 295, 14, 1431, 8, 82, 4289, 28, 53, 2229, 48, 28, 19300, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 30, 4268, 1233, 63, 3438, 9, 267, 340, 1336, 26, 327, 665, 53, 5336, 30, 288, 1495, 63, 533, 63, 513, 14, 740, 8, 355, 1109, 8, 1431, 14, 923, 360, 19300, 659, 3193, 430, 288, 1980, 267, 1336, 275, 295, 14, 1431, 8, 288, 519, 4289, 28, 53, 2229, 48, 28, 19300, 17, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 3524, 288, 435, 1154, 3134, 3530, 11, 288, 2650, 53, 2229, 48, 28, 19300, 18, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 30, 4268, 288, 1233, 63, 3438, 9 ]
[ 2647, 15, 1393, 15, 1548, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 6927, 13, 7806, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 961, 570, 365, 1777, 402, 314, 1664, 445, 11243, 14, 199, 3, 199, 3, 710, 1664, 445, 11243, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 710, 1664, 445, 11243, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 314, 1664, 445, 11243, 27, 340, 440, 12, 1937, 199, 3, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 2344, 199, 2765, 2884, 365, 2997, 367, 7907, 314, 15109, 3382, 199, 290, 2269, 26703, 63, 7540, 570, 1182, 2647, 15, 6251, 15, 73, 1085, 78, 15, 5508, 15, 73, 1085, 78, 436, 282, 199, 1222, 1373, 4046, 701, 3805, 63, 2975, 63, 3667, 14, 647, 199, 199, 1378, 1937, 4212, 652, 365, 1202, 12, 1240, 652, 543, 314, 27430, 251, 13, 72, 8477, 252, 945, 26, 339, 2672, 16605, 3667, 63, 15390, 14, 647, 446, 72, 272, 27430, 100, 14767, 4503, 1245, 27430, 100, 199, 2344, 199, 199, 646, 984, 199, 646, 295, 199, 646, 23128, 199, 646, 7534, 199, 199, 504, 16360, 63, 15390, 63, 396, 63, 9403, 492, 7393, 63, 9777, 654, 199, 199, 318, 664, 63, 1278, 63, 504, 63, 493, 8, 1501, 304, 272, 1449, 1002, 1006, 2222, 13, 3349, 2385, 687, 282, 284, 1085, 78, 570, 339, 6121, 5389, 1006, 2385, 1314, 787, 32541, 641, 314, 2163, 1004, 2952, 272, 2985, 1284, 315, 27430, 251, 15, 8477, 252, 1901, 282, 2849, 1004, 14, 272, 1449, 272, 543, 1551, 8, 1501, 9, 465, 284, 1085, 78, 63, 493, 26, 267, 1453, 63, 604, 275, 2125, 267, 367, 1004, 315, 284, 1085, 78, 63, 493, 26, 288, 1004, 275, 1004, 14, 1913, 2258, 78, 358, 288, 340, 26386, 315, 1004, 26, 355, 340, 1004, 14, 4130, 18265, 490, 1004, 275, 1004, 59, 16, 26, 604, 14, 1623, 3508, 5440, 435, 7324, 355, 587, 26, 490, 1004, 275, 1004, 59, 16, 26, 604, 14, 1623, 3508, 5440, 288, 1004, 275, 1004, 14, 1913, 342, 288, 340, 1004, 14, 4130, 18265, 355, 1453, 63, 604, 847, 1004, 4439, 17, 61, 288, 587, 26, 355, 1995, 1453, 63, 604, 435, 1004, 355, 1453, 63, 604, 275, 2125, 272, 340, 1453, 63, 604, 26, 327, 570, 11187, 543, 282, 16015, 1004, 267, 1995, 1453, 63, 604, 199, 199, 318, 5536, 63, 10856, 63, 2888, 8, 1501, 304, 272, 1449, 1002, 1006, 6140, 1233, 4501, 367, 1924, 4528, 1021, 687, 282, 570, 339, 13874, 3520, 1233, 4501, 315, 282, 2600, 1808, 314, 4528, 3992, 272, 465, 2883, 436, 314, 769, 402, 1233, 4501, 315, 642, 4528, 1021, 465, 1338, 14, 339, 1010, 1930, 221, 402, 314, 4528, 3992, 27430, 251, 475, 4142, 8477, 252, 12, 27430, 251, 475, 2325, 8477, 252, 12, 436, 27430, 251, 475, 1213, 8477, 252, 12, 272, 3520, 9150, 5965, 6342, 402, 1233, 4501, 272, 1449, 272, 16360, 63, 807, 275, 1052, 272, 367, 1004, 315, 664, 63, 1278, 63, 504, 63, 493, 8, 1501, 304, 267, 367, 1495, 63, 533, 315, 359, 355, 283, 4142, 297, 355, 283, 2325, 297, 355, 283, 4468, 297, 355, 283, 8573, 297, 355, 283, 548, 8573, 297, 355, 283, 2638, 297, 355, 283, 6507, 4308, 297, 355, 283, 27003, 297, 355, 283, 2180, 297, 355, 283, 1361, 297, 355, 283, 88, 8573, 297, 355, 283, 2500, 297, 355, 283, 6560, 7969, 297, 355, 283, 6560, 7969, 63, 1896, 19, 297, 355, 283, 475, 4142, 297, 355, 283, 475, 2325, 297, 355, 283, 475, 1213, 2565, 288, 1336, 275, 295, 14, 1431, 8, 82, 4289, 360, 2490, 435, 20459, 5169, 533, 92, 1130, 2862, 83, 21425, 7, 2490, 435, 264, 14, 3765, 8, 1560, 63, 533, 6393, 2490, 283, 5169, 11436, 2862, 83, 4786, 2490, 435, 26972, 2490, 435, 264, 14, 3765, 8, 1560, 63, 533, 6393, 1154, 83, 4786, 2490, 435, 358, 297, 1004, 9, 288, 340, 1336, 26, 355, 340, 1495, 63, 533, 440, 315, 16360, 63, 807, 26, 490, 16360, 63, 807, 59, 1560, 63, 533, 61, 275, 942, 355, 2112, 63, 6574, 8, 490, 16360, 63, 807, 59, 1560, 63, 533, 467, 490, 1004, 59, 1431, 14, 500, 837, 566, 272, 372, 16360, 63, 807, 199, 199, 318, 2112, 63, 6574, 8, 1560, 63, 533, 63, 513, 12, 1233, 63, 1403, 63, 604, 304, 272, 1449, 272, 12892, 6140, 1338, 687, 1233, 63, 1403, 63, 604, 272, 436, 1050, 370, 314, 769, 402, 1233, 4501, 315, 282, 4528, 1021, 272, 1449, 272, 367, 1233, 63, 3438, 315, 1233, 63, 1403, 63, 604, 14, 1294, 25282, 735, 267, 1233, 63, 3438, 275, 1233, 63, 3438, 14, 1913, 342, 267, 1336, 275, 295, 14, 1431, 8, 82, 4289, 28, 53, 2229, 48, 28, 19300, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 30, 4268, 1233, 63, 3438, 9, 267, 340, 1336, 26, 327, 665, 53, 5336, 30, 288, 1495, 63, 533, 63, 513, 14, 740, 8, 355, 1109, 8, 1431, 14, 923, 360, 19300, 659, 3193, 430, 288, 1980, 267, 1336, 275, 295, 14, 1431, 8, 288, 519, 4289, 28, 53, 2229, 48, 28, 19300, 17, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 3524, 288, 435, 1154, 3134, 3530, 11, 288, 2650, 53, 2229, 48, 28, 19300, 18, 9514, 16, 13, 25, 33, 13, 38, 8194, 20, 12, 24, 1552, 30, 4268, 288, 1233, 63, 3438, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
18F/regulations-parser
tests/commands/annual_editions_tests.py
3
3916
from datetime import date, timedelta import click import pytest from django.utils import timezone from mock import Mock from regparser.commands import annual_editions from regparser.history.versions import Version from regparser.index import dependency, entry from regparser.notice.citation import Citation from regparser.tree.struct import Node from regparser.web.index.models import Entry as DBEntry @pytest.mark.django_db def test_last_versions_raises_exception(): """If there are no versions available, we should receive an exception""" with pytest.raises(click.UsageError): list(annual_editions.last_versions('12', '1000')) @pytest.mark.django_db def test_last_versions_multiple_versions(monkeypatch): """If multiple versions affect the same annual edition, we should only receive the last""" monkeypatch.setattr(annual_editions.annual, 'find_volume', Mock()) annual_editions.annual.find_volume.return_value = True path = entry.Version('12', '1000') (path / '1111').write(Version('1111', date(2000, 12, 1), Citation(1, 1))) (path / '2222').write(Version('2222', date(2000, 12, 2), Citation(1, 2))) (path / '3333').write(Version('3333', date(2001, 12, 1), Citation(1, 1))) results = list(annual_editions.last_versions(12, 1000)) assert results == [annual_editions.LastVersionInYear('2222', 2001), annual_editions.LastVersionInYear('3333', 2002)] @pytest.mark.django_db def test_last_versions_not_printed(monkeypatch): """We should only find the annual editions which have been published already""" # 2001 exists; no other years do monkeypatch.setattr(annual_editions.annual, 'find_volume', Mock()) annual_editions.annual.find_volume = lambda year, title, part: year == 2001 path = entry.Version('12', '1000') (path / '1111').write(Version('1111', date(2000, 12, 1), Citation(1, 1))) (path / '2222').write(Version('2222', date(2001, 12, 1), Citation(1, 1))) results = list(annual_editions.last_versions(12, 1000)) assert results == [annual_editions.LastVersionInYear('1111', 2001)] @pytest.mark.django_db def test_process_if_needed_missing_dependency_error(): """If the annual XML or version isn't present, we should see a dependency error.""" last_versions = [annual_editions.LastVersionInYear('1111', 2000)] with pytest.raises(dependency.Missing): annual_editions.process_if_needed('12', '1000', last_versions) entry.Version('12', '1000', '1111').write( Version('1111', date(2000, 1, 1), Citation(1, 1))) with pytest.raises(dependency.Missing): annual_editions.process_if_needed('12', '1000', last_versions) @pytest.mark.django_db def test_process_if_needed_missing_writes(monkeypatch): """If output isn't already present, we should process. If it is present, we don't need to, unless a dependency has changed.""" monkeypatch.setattr(annual_editions, 'gpo_cfr', Mock()) build_tree = annual_editions.gpo_cfr.builder.build_tree build_tree.return_value = Node() last_versions = [annual_editions.LastVersionInYear('1111', 2000)] entry.Version('12', '1000', '1111').write( Version('1111', date(2000, 1, 1), Citation(1, 1))) entry.Entry('annual', '12', '1000', 2000).write(b'<ROOT></ROOT>') annual_editions.process_if_needed('12', '1000', last_versions) assert build_tree.called build_tree.reset_mock() entry.Entry('tree', '12', '1000', '1111').write(b'tree-here') annual_editions.process_if_needed('12', '1000', last_versions) assert not build_tree.called # Simulate a change to an input file label_id = str(entry.Annual(12, 1000, 2000)) new_time = timezone.now() + timedelta(hours=1) DBEntry.objects.filter(label_id=label_id).update(modified=new_time) annual_editions.process_if_needed('12', '1000', last_versions) assert build_tree.called
cc0-1.0
[ 504, 2197, 492, 1434, 12, 6871, 199, 199, 646, 8968, 199, 646, 4613, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1683, 492, 4420, 199, 199, 504, 1295, 2087, 14, 4405, 492, 21172, 1061, 63, 69, 3138, 199, 504, 1295, 2087, 14, 5570, 14, 6234, 492, 3394, 199, 504, 1295, 2087, 14, 1080, 492, 5936, 12, 2397, 199, 504, 1295, 2087, 14, 20556, 14, 6210, 492, 445, 5314, 199, 504, 1295, 2087, 14, 2350, 14, 1820, 492, 5013, 199, 504, 1295, 2087, 14, 2520, 14, 1080, 14, 992, 492, 11855, 465, 6249, 3900, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 3536, 63, 1971, 837, 272, 408, 3917, 2337, 787, 949, 5459, 2808, 12, 781, 1077, 9128, 376, 1919, 624, 272, 543, 4613, 14, 3536, 8, 4891, 14, 7692, 547, 304, 267, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 360, 713, 297, 283, 5279, 1333, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 6048, 63, 6234, 8, 20372, 2068, 304, 272, 408, 3917, 3663, 5459, 12787, 314, 2011, 21172, 1061, 325, 1671, 12, 781, 1077, 1454, 272, 9128, 314, 2061, 624, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 14, 1189, 1061, 12, 283, 1623, 63, 2405, 297, 4420, 1012, 272, 21172, 1061, 63, 69, 3138, 14, 1189, 1061, 14, 1623, 63, 2405, 14, 1107, 63, 585, 275, 715, 272, 931, 275, 2397, 14, 3353, 360, 713, 297, 283, 5279, 358, 272, 334, 515, 1182, 283, 6984, 1959, 952, 8, 3353, 360, 6984, 297, 1434, 8, 8269, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 334, 515, 1182, 283, 9993, 1959, 952, 8, 3353, 360, 9993, 297, 1434, 8, 8269, 12, 3144, 12, 499, 395, 445, 5314, 8, 17, 12, 499, 1724, 272, 334, 515, 1182, 283, 6772, 1959, 952, 8, 3353, 360, 6772, 297, 1434, 8, 8339, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 2058, 275, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 8, 713, 12, 5198, 430, 272, 702, 2058, 508, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 9993, 297, 12521, 395, 2432, 21172, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6772, 297, 14790, 1874, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 1397, 63, 27131, 8, 20372, 2068, 304, 272, 408, 6004, 1077, 1454, 2342, 314, 21172, 1061, 325, 3138, 1314, 1172, 2757, 3267, 272, 2575, 624, 272, 327, 12521, 3495, 27, 949, 1163, 17399, 886, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 14, 1189, 1061, 12, 283, 1623, 63, 2405, 297, 4420, 1012, 272, 21172, 1061, 63, 69, 3138, 14, 1189, 1061, 14, 1623, 63, 2405, 275, 2400, 5361, 12, 2538, 12, 1777, 26, 5361, 508, 12521, 272, 931, 275, 2397, 14, 3353, 360, 713, 297, 283, 5279, 358, 272, 334, 515, 1182, 283, 6984, 1959, 952, 8, 3353, 360, 6984, 297, 1434, 8, 8269, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 334, 515, 1182, 283, 9993, 1959, 952, 8, 3353, 360, 9993, 297, 1434, 8, 8339, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 2058, 275, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 8, 713, 12, 5198, 430, 272, 702, 2058, 508, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12521, 1874, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 1412, 63, 692, 63, 11368, 63, 4752, 63, 8575, 63, 705, 837, 272, 408, 3917, 314, 21172, 1061, 4692, 503, 1015, 5712, 1133, 3451, 12, 781, 1077, 1937, 282, 5936, 272, 1125, 1041, 272, 2061, 63, 6234, 275, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12293, 1874, 339, 543, 4613, 14, 3536, 8, 8575, 14, 7718, 304, 267, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 339, 2397, 14, 3353, 360, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 267, 3394, 360, 6984, 297, 1434, 8, 8269, 12, 413, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 543, 4613, 14, 3536, 8, 8575, 14, 7718, 304, 267, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 1412, 63, 692, 63, 11368, 63, 4752, 63, 16334, 8, 20372, 2068, 304, 272, 408, 3917, 1072, 5712, 1133, 2575, 3451, 12, 781, 1077, 2112, 14, 982, 652, 365, 3451, 12, 272, 781, 2793, 1133, 1929, 370, 12, 7444, 282, 5936, 965, 2896, 1041, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 12, 283, 71, 555, 63, 2177, 82, 297, 4420, 1012, 272, 1900, 63, 2350, 275, 21172, 1061, 63, 69, 3138, 14, 71, 555, 63, 2177, 82, 14, 5649, 14, 1506, 63, 2350, 272, 1900, 63, 2350, 14, 1107, 63, 585, 275, 5013, 342, 272, 2061, 63, 6234, 275, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12293, 1874, 272, 2397, 14, 3353, 360, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 267, 3394, 360, 6984, 297, 1434, 8, 8269, 12, 413, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 2397, 14, 3900, 360, 1189, 1061, 297, 283, 713, 297, 283, 5279, 297, 12293, 680, 952, 8, 66, 7601, 5441, 2957, 5441, 5971, 339, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 272, 702, 1900, 63, 2350, 14, 3527, 339, 1900, 63, 2350, 14, 3958, 63, 1805, 342, 272, 2397, 14, 3900, 360, 2350, 297, 283, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 66, 1133, 850, 13, 1681, 358, 272, 21172, 1061 ]
[ 2197, 492, 1434, 12, 6871, 199, 199, 646, 8968, 199, 646, 4613, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1683, 492, 4420, 199, 199, 504, 1295, 2087, 14, 4405, 492, 21172, 1061, 63, 69, 3138, 199, 504, 1295, 2087, 14, 5570, 14, 6234, 492, 3394, 199, 504, 1295, 2087, 14, 1080, 492, 5936, 12, 2397, 199, 504, 1295, 2087, 14, 20556, 14, 6210, 492, 445, 5314, 199, 504, 1295, 2087, 14, 2350, 14, 1820, 492, 5013, 199, 504, 1295, 2087, 14, 2520, 14, 1080, 14, 992, 492, 11855, 465, 6249, 3900, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 3536, 63, 1971, 837, 272, 408, 3917, 2337, 787, 949, 5459, 2808, 12, 781, 1077, 9128, 376, 1919, 624, 272, 543, 4613, 14, 3536, 8, 4891, 14, 7692, 547, 304, 267, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 360, 713, 297, 283, 5279, 1333, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 6048, 63, 6234, 8, 20372, 2068, 304, 272, 408, 3917, 3663, 5459, 12787, 314, 2011, 21172, 1061, 325, 1671, 12, 781, 1077, 1454, 272, 9128, 314, 2061, 624, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 14, 1189, 1061, 12, 283, 1623, 63, 2405, 297, 4420, 1012, 272, 21172, 1061, 63, 69, 3138, 14, 1189, 1061, 14, 1623, 63, 2405, 14, 1107, 63, 585, 275, 715, 272, 931, 275, 2397, 14, 3353, 360, 713, 297, 283, 5279, 358, 272, 334, 515, 1182, 283, 6984, 1959, 952, 8, 3353, 360, 6984, 297, 1434, 8, 8269, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 334, 515, 1182, 283, 9993, 1959, 952, 8, 3353, 360, 9993, 297, 1434, 8, 8269, 12, 3144, 12, 499, 395, 445, 5314, 8, 17, 12, 499, 1724, 272, 334, 515, 1182, 283, 6772, 1959, 952, 8, 3353, 360, 6772, 297, 1434, 8, 8339, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 2058, 275, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 8, 713, 12, 5198, 430, 272, 702, 2058, 508, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 9993, 297, 12521, 395, 2432, 21172, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6772, 297, 14790, 1874, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 2019, 63, 6234, 63, 1397, 63, 27131, 8, 20372, 2068, 304, 272, 408, 6004, 1077, 1454, 2342, 314, 21172, 1061, 325, 3138, 1314, 1172, 2757, 3267, 272, 2575, 624, 272, 327, 12521, 3495, 27, 949, 1163, 17399, 886, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 14, 1189, 1061, 12, 283, 1623, 63, 2405, 297, 4420, 1012, 272, 21172, 1061, 63, 69, 3138, 14, 1189, 1061, 14, 1623, 63, 2405, 275, 2400, 5361, 12, 2538, 12, 1777, 26, 5361, 508, 12521, 272, 931, 275, 2397, 14, 3353, 360, 713, 297, 283, 5279, 358, 272, 334, 515, 1182, 283, 6984, 1959, 952, 8, 3353, 360, 6984, 297, 1434, 8, 8269, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 334, 515, 1182, 283, 9993, 1959, 952, 8, 3353, 360, 9993, 297, 1434, 8, 8339, 12, 3144, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 2058, 275, 769, 8, 1189, 1061, 63, 69, 3138, 14, 2019, 63, 6234, 8, 713, 12, 5198, 430, 272, 702, 2058, 508, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12521, 1874, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 1412, 63, 692, 63, 11368, 63, 4752, 63, 8575, 63, 705, 837, 272, 408, 3917, 314, 21172, 1061, 4692, 503, 1015, 5712, 1133, 3451, 12, 781, 1077, 1937, 282, 5936, 272, 1125, 1041, 272, 2061, 63, 6234, 275, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12293, 1874, 339, 543, 4613, 14, 3536, 8, 8575, 14, 7718, 304, 267, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 339, 2397, 14, 3353, 360, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 267, 3394, 360, 6984, 297, 1434, 8, 8269, 12, 413, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 339, 543, 4613, 14, 3536, 8, 8575, 14, 7718, 304, 267, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 1412, 63, 692, 63, 11368, 63, 4752, 63, 16334, 8, 20372, 2068, 304, 272, 408, 3917, 1072, 5712, 1133, 2575, 3451, 12, 781, 1077, 2112, 14, 982, 652, 365, 3451, 12, 272, 781, 2793, 1133, 1929, 370, 12, 7444, 282, 5936, 965, 2896, 1041, 272, 17309, 14, 10202, 8, 1189, 1061, 63, 69, 3138, 12, 283, 71, 555, 63, 2177, 82, 297, 4420, 1012, 272, 1900, 63, 2350, 275, 21172, 1061, 63, 69, 3138, 14, 71, 555, 63, 2177, 82, 14, 5649, 14, 1506, 63, 2350, 272, 1900, 63, 2350, 14, 1107, 63, 585, 275, 5013, 342, 272, 2061, 63, 6234, 275, 359, 1189, 1061, 63, 69, 3138, 14, 6090, 3353, 607, 15731, 360, 6984, 297, 12293, 1874, 272, 2397, 14, 3353, 360, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 267, 3394, 360, 6984, 297, 1434, 8, 8269, 12, 413, 12, 413, 395, 445, 5314, 8, 17, 12, 413, 1724, 272, 2397, 14, 3900, 360, 1189, 1061, 297, 283, 713, 297, 283, 5279, 297, 12293, 680, 952, 8, 66, 7601, 5441, 2957, 5441, 5971, 339, 21172, 1061, 63, 69, 3138, 14, 1412, 63, 692, 63, 11368, 360, 713, 297, 283, 5279, 297, 2061, 63, 6234, 9, 272, 702, 1900, 63, 2350, 14, 3527, 339, 1900, 63, 2350, 14, 3958, 63, 1805, 342, 272, 2397, 14, 3900, 360, 2350, 297, 283, 713, 297, 283, 5279, 297, 283, 6984, 1959, 952, 8, 66, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
hoosteeno/fjord
smoketests/pages/regions/date_filter.py
7
9651
#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from pages.base import Page class DateFilter(Page): _current_when_link_locator = (By.CSS_SELECTOR, 'a.when.selected') _last_day_locator = (By.LINK_TEXT, '1d') _last_seven_days_locator = (By.LINK_TEXT, '7d') _last_thirty_days_locator = (By.LINK_TEXT, '30d') _show_custom_dates_locator = (By.CSS_SELECTOR, 'a.expander') _custom_dates_locator = (By.CSS_SELECTOR, 'div.filter a.custom-date') _custom_start_date_locator = (By.CSS_SELECTOR, 'input[name=date_start]') _custom_end_date_locator = (By.CSS_SELECTOR, 'input[name=date_end]') _set_custom_date_locator = (By.ID, 'whensubmit') _datepicker_locator = (By.ID, 'ui-datepicker-div') _datepicker_calendar_locator = (By.CSS_SELECTOR, '.ui-datepicker-calendar') _datepicker_month_locator = (By.CSS_SELECTOR, '.ui-datepicker-month') _datepicker_year_locator = (By.CSS_SELECTOR, '.ui-datepicker-year') _datepicker_previous_month_locator = (By.CSS_SELECTOR, '.ui-datepicker-prev') _datepicker_next_month_locator = (By.CSS_SELECTOR, '.ui-datepicker-next') _datepicker_next_month_disabled_locator = (By.CSS_SELECTOR, '.ui-datepicker-next.ui-state-disabled') _custom_date_only_error_locator = (By.XPATH, "//div[@id='custom-date']/ul/li") _custom_date_first_error_locator = (By.XPATH, "//div[@id='custom-date']/ul[1]/li") _custom_date_second_error_locator = (By.XPATH, "//div[@id='custom-date']/ul[2]/li") @property def current_days(self): """Returns the link text of the currently applied days filter.""" return self.selenium.find_element(*self._current_when_link_locator).text def click_last_day(self): return self.selenium.find_element(*self._last_day_locator).click() def click_last_seven_days(self): return self.selenium.find_element(*self._last_seven_days_locator).click() def click_last_thirty_days(self): return self.selenium.find_element(*self._last_thirty_days_locator).click() def enable_custom_dates(self): """Clicks the custom date filter button and waits for the form to appear.""" custom_dates = self.selenium.find_element(*self._show_custom_dates_locator) if 'selected' not in custom_dates.get_attribute('class'): custom_dates.click() @property def is_custom_date_filter_visible(self): """Returns True if the custom date filter form is visible.""" return self.is_element_visible_no_wait(self._custom_dates_locator) @property def is_datepicker_visible(self): """Returns True if the datepicker pop up is visible.""" datepicker = self.selenium.find_element(*self._datepicker_locator) return datepicker.is_displayed() and datepicker.location['x'] > 0 @property def is_custom_start_date_visible(self): """Returns True if the custom start date input form is visible.""" return self.is_element_visible_no_wait(self._custom_start_date_locator) @property def is_custom_end_date_visible(self): """Returns True if the custom end date input form is visible.""" return self.is_element_visible_no_wait(self._custom_end_date_locator) @property def is_datepicker_next_month_button_disabled(self): return self.is_element_visible_no_wait(self._datepicker_next_month_disabled_locator) def wait_for_datepicker_to_open(self): WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_datepicker_visible) WebDriverWait(self.selenium, self.timeout).until(lambda s: s.find_element(*self._datepicker_locator).size['width'] == 251) def wait_for_datepicker_to_close(self): WebDriverWait(self.selenium, self.timeout).until(lambda s: not self.is_datepicker_visible) def close_datepicker(self): self.selenium.find_element(*self._custom_start_date_locator).send_keys(Keys.ESCAPE) WebDriverWait(self.selenium, self.timeout).until(lambda s: not self.is_datepicker_visible) def click_start_date(self): """Clicks the start date in the custom date filter form and waits for the datepicker to appear.""" self.selenium.find_element(*self._custom_start_date_locator).click() self.wait_for_datepicker_to_open() def click_end_date(self): """Clicks the end date in the custom date filter form and waits for the datepicker to appear.""" self.selenium.find_element(*self._custom_end_date_locator).click() self.wait_for_datepicker_to_open() def click_previous_month(self): """Clicks the previous month button in the datepicker.""" self.selenium.find_element(*self._datepicker_previous_month_locator).click() def click_next_month(self): """Clicks the next month button in the datepicker.""" # TODO: Throw an error if the next month button is disabled self.selenium.find_element(*self._datepicker_next_month_locator).click() def click_day(self, day): """Clicks the day in the datepicker and waits for the datepicker to disappear.""" # TODO: Throw an error if the day button is disabled calendar = self.selenium.find_element(*self._datepicker_calendar_locator) calendar.find_element(By.LINK_TEXT, str(day)).click() self.wait_for_datepicker_to_close() def select_date_from_datepicker(self, target_date): """Navigates to the target month in the datepicker and clicks the target day.""" currentYear = int(self.selenium.find_element(*self._datepicker_year_locator).text) targetYear = target_date.year yearDelta = targetYear - currentYear monthDelta = yearDelta * 12 months = {"January": 1, "February": 2, "March": 3, "April": 4, "May": 5, "June": 6, "July": 7, "August": 8, "September": 9, "October": 10, "November": 11, "December": 12} currentMonth = months[self.selenium.find_element(*self._datepicker_month_locator).text] targetMonth = target_date.month monthDelta += targetMonth - currentMonth count = 0 while (count < abs(monthDelta)): if monthDelta < 0: self.click_previous_month() elif monthDelta > 0: self.click_next_month() count = count + 1 self.click_day(target_date.day) def type_custom_start_date(self, date_start): date_start_box = self.selenium.find_element(*self._custom_start_date_locator) date_start_box.clear() date_start_box.send_keys(date_start) def type_custom_end_date(self, date_end): date_end_box = self.selenium.find_element(*self._custom_end_date_locator) date_end_box.clear() date_end_box.send_keys(date_end) def select_custom_start_date_using_datepicker(self, date): self.click_start_date() self.select_date_from_datepicker(date) def select_custom_end_date_using_datepicker(self, date): self.click_end_date() self.select_date_from_datepicker(date) def filter_by_custom_dates_using_datepicker(self, start_date, end_date): """Filters by a custom date range.""" self.enable_custom_dates() self.select_custom_start_date_using_datepicker(start_date) self.select_custom_end_date_using_datepicker(end_date) self.selenium.find_element(*self._set_custom_date_locator).click() def filter_by_custom_dates_using_keyboard(self, start_date, end_date): """Filters by a custom date range using any input type, not using date() format. This uses selenium.type_keys in an attempt to mimic actual typing """ self.enable_custom_dates() self.type_custom_start_date(start_date) self.type_custom_end_date(end_date) self.selenium.find_element(*self._set_custom_date_locator).click() @property def is_last_day_visible(self): return self.is_element_visible(self._last_day_locator) @property def is_last_seven_days_visible(self): return self.is_element_visible(self._last_seven_days_locator) @property def is_last_thirty_days_visible(self): return self.is_element_visible(self._last_thirty_days_locator) @property def is_date_filter_applied(self): from pages.base import Page base = Page(self.testsetup) return base.date_start_from_url and base.date_end_from_url or False @property def custom_date_only_error(self): return self.selenium.find_element(*self._custom_date_only_error_locator).text @property def custom_date_first_error(self): return self.selenium.find_element(*self._custom_date_first_error_locator).text @property def custom_date_second_error(self): return self.selenium.find_element(*self._custom_date_second_error_locator).text @property def custom_start_date(self): return self.selenium.find_element(*self._custom_start_date_locator).get_attribute('value') @property def custom_end_date(self): return self.selenium.find_element(*self._custom_end_date_locator).get_attribute('value')
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 504, 19481, 14, 17946, 14, 2330, 14, 991, 492, 4885, 199, 504, 19481, 14, 17946, 14, 2330, 14, 1612, 492, 17276, 199, 504, 19481, 14, 17946, 14, 4058, 14, 1907, 492, 27104, 7536, 199, 199, 504, 6497, 14, 1095, 492, 10331, 421, 199, 533, 6148, 4131, 8, 3276, 304, 339, 485, 1818, 63, 6526, 63, 1073, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 65, 14, 6526, 14, 5511, 358, 339, 485, 2019, 63, 2977, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 17, 68, 358, 272, 485, 2019, 63, 27346, 63, 4899, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 23, 68, 358, 272, 485, 2019, 63, 273, 723, 369, 63, 4899, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 1216, 68, 358, 272, 485, 2384, 63, 4229, 63, 9356, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 65, 14, 1474, 11438, 358, 272, 485, 4229, 63, 9356, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 14, 1541, 282, 14, 4229, 13, 602, 358, 272, 485, 4229, 63, 928, 63, 602, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 1210, 59, 354, 29, 602, 63, 928, 10374, 272, 485, 4229, 63, 500, 63, 602, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 1210, 59, 354, 29, 602, 63, 500, 10374, 339, 485, 409, 63, 4229, 63, 602, 63, 6354, 275, 334, 2175, 14, 998, 12, 283, 6526, 7275, 358, 339, 485, 602, 4510, 281, 63, 6354, 275, 334, 2175, 14, 998, 12, 283, 1907, 13, 602, 4510, 281, 13, 3015, 358, 272, 485, 602, 4510, 281, 63, 8183, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 8183, 358, 272, 485, 602, 4510, 281, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 4482, 358, 272, 485, 602, 4510, 281, 63, 3403, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 3403, 358, 272, 485, 602, 4510, 281, 63, 6352, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 5701, 358, 272, 485, 602, 4510, 281, 63, 2184, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 2184, 358, 272, 485, 602, 4510, 281, 63, 2184, 63, 4482, 63, 7011, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 2184, 14, 1907, 13, 929, 13, 7011, 358, 339, 485, 4229, 63, 602, 63, 2118, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 15, 317, 531, 272, 485, 4229, 63, 602, 63, 2246, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 59, 17, 12978, 317, 531, 272, 485, 4229, 63, 602, 63, 4375, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 59, 18, 12978, 317, 531, 339, 768, 1829, 272, 347, 1453, 63, 4899, 8, 277, 304, 267, 408, 3407, 314, 2142, 1318, 402, 314, 5544, 6781, 7609, 2457, 1041, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 1818, 63, 6526, 63, 1073, 63, 6354, 680, 505, 339, 347, 8968, 63, 2019, 63, 2977, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 2977, 63, 6354, 680, 4891, 342, 339, 347, 8968, 63, 2019, 63, 27346, 63, 4899, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 27346, 63, 4899, 63, 6354, 680, 4891, 342, 339, 347, 8968, 63, 2019, 63, 273, 723, 369, 63, 4899, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 273, 723, 369, 63, 4899, 63, 6354, 680, 4891, 342, 339, 347, 4756, 63, 4229, 63, 9356, 8, 277, 304, 267, 408, 20653, 5618, 314, 3537, 1434, 2457, 5528, 436, 14442, 1405, 367, 314, 1824, 370, 7468, 1041, 267, 3537, 63, 9356, 275, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2384, 63, 4229, 63, 9356, 63, 6354, 9, 267, 340, 283, 5511, 7, 440, 315, 3537, 63, 9356, 14, 362, 63, 3215, 360, 533, 735, 288, 3537, 63, 9356, 14, 4891, 342, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 602, 63, 1541, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 3537, 1434, 2457, 1824, 365, 8917, 1041, 267, 372, 291, 14, 374, 63, 2108, 63, 6604, 63, 889, 63, 2573, 8, 277, 423, 4229, 63, 9356, 63, 6354, 9, 339, 768, 1829, 272, 347, 365, 63, 602, 4510, 281, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 1434, 4510, 281, 4560, 1536, 365, 8917, 1041, 267, 1434, 4510, 281, 275, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 602, 4510, 281, 63, 6354, 9, 267, 372, 1434, 4510, 281, 14, 374, 63, 22283, 342, 436, 1434, 4510, 281, 14, 1985, 459, 88, 418, 690, 378, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 928, 63, 602, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 3537, 1343, 1434, 1324, 1824, 365, 8917, 1041, 267, 372, 291, 14, 374, 63, 2108, 63, 6604, 63, 889, 63, 2573, 8, 277, 423, 4229, 63, 928, 63, 602, 63, 6354, 9, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 500, 63, 602, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 504, 19481, 14, 17946, 14, 2330, 14, 991, 492, 4885, 199, 504, 19481, 14, 17946, 14, 2330, 14, 1612, 492, 17276, 199, 504, 19481, 14, 17946, 14, 4058, 14, 1907, 492, 27104, 7536, 199, 199, 504, 6497, 14, 1095, 492, 10331, 421, 199, 533, 6148, 4131, 8, 3276, 304, 339, 485, 1818, 63, 6526, 63, 1073, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 65, 14, 6526, 14, 5511, 358, 339, 485, 2019, 63, 2977, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 17, 68, 358, 272, 485, 2019, 63, 27346, 63, 4899, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 23, 68, 358, 272, 485, 2019, 63, 273, 723, 369, 63, 4899, 63, 6354, 275, 334, 2175, 14, 7916, 63, 3876, 12, 283, 1216, 68, 358, 272, 485, 2384, 63, 4229, 63, 9356, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 65, 14, 1474, 11438, 358, 272, 485, 4229, 63, 9356, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 14, 1541, 282, 14, 4229, 13, 602, 358, 272, 485, 4229, 63, 928, 63, 602, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 1210, 59, 354, 29, 602, 63, 928, 10374, 272, 485, 4229, 63, 500, 63, 602, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 283, 1210, 59, 354, 29, 602, 63, 500, 10374, 339, 485, 409, 63, 4229, 63, 602, 63, 6354, 275, 334, 2175, 14, 998, 12, 283, 6526, 7275, 358, 339, 485, 602, 4510, 281, 63, 6354, 275, 334, 2175, 14, 998, 12, 283, 1907, 13, 602, 4510, 281, 13, 3015, 358, 272, 485, 602, 4510, 281, 63, 8183, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 8183, 358, 272, 485, 602, 4510, 281, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 4482, 358, 272, 485, 602, 4510, 281, 63, 3403, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 3403, 358, 272, 485, 602, 4510, 281, 63, 6352, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 5701, 358, 272, 485, 602, 4510, 281, 63, 2184, 63, 4482, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 2184, 358, 272, 485, 602, 4510, 281, 63, 2184, 63, 4482, 63, 7011, 63, 6354, 275, 334, 2175, 14, 14391, 63, 25691, 12, 1987, 1907, 13, 602, 4510, 281, 13, 2184, 14, 1907, 13, 929, 13, 7011, 358, 339, 485, 4229, 63, 602, 63, 2118, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 15, 317, 531, 272, 485, 4229, 63, 602, 63, 2246, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 59, 17, 12978, 317, 531, 272, 485, 4229, 63, 602, 63, 4375, 63, 705, 63, 6354, 275, 334, 2175, 14, 56, 3243, 12, 23057, 3015, 14251, 344, 534, 4229, 13, 602, 28178, 348, 59, 18, 12978, 317, 531, 339, 768, 1829, 272, 347, 1453, 63, 4899, 8, 277, 304, 267, 408, 3407, 314, 2142, 1318, 402, 314, 5544, 6781, 7609, 2457, 1041, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 1818, 63, 6526, 63, 1073, 63, 6354, 680, 505, 339, 347, 8968, 63, 2019, 63, 2977, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 2977, 63, 6354, 680, 4891, 342, 339, 347, 8968, 63, 2019, 63, 27346, 63, 4899, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 27346, 63, 4899, 63, 6354, 680, 4891, 342, 339, 347, 8968, 63, 2019, 63, 273, 723, 369, 63, 4899, 8, 277, 304, 267, 372, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2019, 63, 273, 723, 369, 63, 4899, 63, 6354, 680, 4891, 342, 339, 347, 4756, 63, 4229, 63, 9356, 8, 277, 304, 267, 408, 20653, 5618, 314, 3537, 1434, 2457, 5528, 436, 14442, 1405, 367, 314, 1824, 370, 7468, 1041, 267, 3537, 63, 9356, 275, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 2384, 63, 4229, 63, 9356, 63, 6354, 9, 267, 340, 283, 5511, 7, 440, 315, 3537, 63, 9356, 14, 362, 63, 3215, 360, 533, 735, 288, 3537, 63, 9356, 14, 4891, 342, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 602, 63, 1541, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 3537, 1434, 2457, 1824, 365, 8917, 1041, 267, 372, 291, 14, 374, 63, 2108, 63, 6604, 63, 889, 63, 2573, 8, 277, 423, 4229, 63, 9356, 63, 6354, 9, 339, 768, 1829, 272, 347, 365, 63, 602, 4510, 281, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 1434, 4510, 281, 4560, 1536, 365, 8917, 1041, 267, 1434, 4510, 281, 275, 291, 14, 15041, 14, 1623, 63, 2108, 2031, 277, 423, 602, 4510, 281, 63, 6354, 9, 267, 372, 1434, 4510, 281, 14, 374, 63, 22283, 342, 436, 1434, 4510, 281, 14, 1985, 459, 88, 418, 690, 378, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 928, 63, 602, 63, 6604, 8, 277, 304, 267, 408, 3407, 715, 340, 314, 3537, 1343, 1434, 1324, 1824, 365, 8917, 1041, 267, 372, 291, 14, 374, 63, 2108, 63, 6604, 63, 889, 63, 2573, 8, 277, 423, 4229, 63, 928, 63, 602, 63, 6354, 9, 339, 768, 1829, 272, 347, 365, 63, 4229, 63, 500, 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, 1, 1, 1, 1, 1 ]
jhaux/tensorflow
tensorflow/contrib/cluster_resolver/python/training/__init__.py
8
1143
# 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. # ============================================================================== """Library Imports for Cluster Resolvers.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.cluster_resolver.python.training.cluster_resolver import ClusterResolver from tensorflow.contrib.cluster_resolver.python.training.cluster_resolver import SimpleClusterResolver from tensorflow.contrib.cluster_resolver.python.training.cluster_resolver import UnionClusterResolver
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, 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, 7424, 24339, 367, 16454, 26046, 83, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 16454, 12407, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 5870, 9581, 12407, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 15961, 9581, 12407, 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, 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, 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, 7424, 24339, 367, 16454, 26046, 83, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 16454, 12407, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 5870, 9581, 12407, 199, 504, 3228, 14, 2828, 14, 4201, 63, 7717, 14, 1548, 14, 7588, 14, 4201, 63, 7717, 492, 15961, 9581, 12407, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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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 ]
loadimpact/loadimpact-sdk-python
examples/test_runner.py
1
2782
#!/usr/bin/env python # coding=utf-8 """ Copyright 2013 Load Impact 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 optparse import sys import traceback from loadimpact import ( ApiTokenClient, ApiError, LoadZone, Test, TestConfig, TestResult, __version__ as li_sdk_version) def start_test(client, test_config_id): assert test_config_id is not None, \ "'test_config_id' is mandatory for 'start'" test_id = TestConfig.start_test_from_id( client, test_config_id) test = Test.get(client, test_id) world_id = LoadZone.name_to_id(LoadZone.AGGREGATE_WORLD) stream = test.result_stream([ TestResult.result_id_from_name(TestResult.LIVE_FEEDBACK), TestResult.result_id_from_name(TestResult.USER_LOAD_TIME, load_zone_id=world_id), TestResult.result_id_from_name(TestResult.ACTIVE_USERS, load_zone_id=world_id)]) try: print("Starting test #%d (view test: %s)..." % (test.id, test.public_url)) try: for data in stream: print(data) except KeyboardInterrupt: print("Aborting test.") test.abort() for data in stream: print(data) print("Test completed with status '%s'" % (Test.status_code_to_text(test.status))) except ApiError as e: print("Aborting test, unhandled error: %s" % str(e)) test.abort() def usage(): print("Usage: specify a test configuration ID") if __name__ == "__main__": p = optparse.OptionParser(version=('%%prog %s' % li_sdk_version)) p.add_option('--api-token', action='store', dest='api_token', default=None, help=("Your Load Impact API token.")) p.add_option('--debug', action='store_true', dest='debug', default=False, help=(".")) opts, args = p.parse_args() if 1 > len(args): usage() sys.exit(2) test_config_id = None if 1 <= len(args): test_config_id = args[0] try: client = ApiTokenClient(opts.api_token, debug=opts.debug) start_test(client, test_config_id) except ApiError: print("Error encountered: %s" % traceback.format_exc())
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 7384, 6171, 7190, 8362, 2442, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 560, 65, 328, 311, 2442, 492, 334, 272, 13986, 3264, 3041, 12, 13986, 547, 12, 7190, 11860, 12, 1379, 12, 1379, 2028, 12, 23795, 12, 272, 636, 1023, 363, 465, 1212, 63, 9277, 63, 1023, 9, 421, 199, 318, 1343, 63, 396, 8, 1258, 12, 511, 63, 888, 63, 344, 304, 272, 702, 511, 63, 888, 63, 344, 365, 440, 488, 12, 971, 267, 3546, 396, 63, 888, 63, 344, 7, 365, 15230, 367, 283, 928, 4065, 339, 511, 63, 344, 275, 1379, 2028, 14, 928, 63, 396, 63, 504, 63, 344, 8, 267, 1890, 12, 511, 63, 888, 63, 344, 9, 272, 511, 275, 1379, 14, 362, 8, 1258, 12, 511, 63, 344, 9, 272, 6701, 63, 344, 275, 7190, 11860, 14, 354, 63, 475, 63, 344, 8, 6200, 11860, 14, 14083, 5616, 1951, 63, 22125, 9, 272, 2547, 275, 511, 14, 1099, 63, 1745, 779, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 31541, 63, 18068, 7111, 395, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 3791, 63, 7405, 63, 4961, 12, 4318, 2248, 63, 2619, 63, 344, 29, 7617, 63, 344, 395, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 10401, 63, 28164, 12, 4318, 2248, 63, 2619, 63, 344, 29, 7617, 63, 344, 3948, 339, 862, 26, 267, 870, 480, 14139, 511, 24307, 68, 334, 1345, 511, 26, 450, 83, 680, 703, 2, 450, 334, 396, 14, 344, 12, 511, 14, 3455, 63, 633, 430, 267, 862, 26, 288, 367, 666, 315, 2547, 26, 355, 870, 8, 576, 9, 27439, 871, 13483, 26, 288, 870, 480, 16682, 316, 511, 2685, 288, 511, 14, 13845, 342, 288, 367, 666, 315, 2547, 26, 355, 870, 8, 576, 9, 267, 870, 480, 774, 9709, 543, 2004, 1543, 83, 4065, 1598, 450, 334, 774, 14, 1205, 63, 600, 63, 475, 63, 505, 8, 396, 14, 1205, 1724, 272, 871, 13986, 547, 465, 325, 26, 267, 870, 480, 16682, 316, 511, 12, 23090, 1125, 26, 450, 83, 2, 450, 620, 8, 69, 430, 267, 511, 14, 13845, 342, 421, 199, 318, 4503, 837, 272, 870, 480, 7692, 26, 4165, 282, 511, 2897, 2870, 531, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 299, 275, 8691, 14, 14553, 8, 1023, 29, 3508, 5, 6595, 450, 83, 7, 450, 1212, 63, 9277, 63, 1023, 430, 272, 299, 14, 525, 63, 1422, 4517, 1246, 13, 1418, 297, 1595, 534, 1617, 297, 326, 2053, 534, 1246, 63, 1418, 297, 849, 29, 403, 12, 326, 1720, 15387, 14398, 7190, 8362, 2442, 3261, 1526, 13853, 272, 299, 14, 525, 63, 1422, 4517, 1757, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 1757, 297, 849, 29, 797, 12, 326, 1720, 15387, 13853, 272, 3999, 12, 1249, 275, 299, 14, 1122, 63, 589, 342, 339, 340, 413, 690, 822, 8, 589, 304, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 339, 511, 63, 888, 63, 344, 275, 488, 339, 340, 413, 2695, 822, 8, 589, 304, 267, 511, 63, 888, 63, 344, 275, 1249, 59, 16, 61, 339, 862, 26, 267, 1890, 275, 13986, 3264, 3041, 8, 3291, 14, 1246, 63, 1418, 12, 3105, 29, 3291, 14, 1757, 9, 267, 1343, 63, 396, 8, 1258, 12, 511, 63, 888, 63, 344, 9, 272, 871, 13986, 547, 26, 267, 870, 480, 547, 14556, 26, 450, 83, 2, 450, 5190, 14, 908, 63, 2804, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 7384, 6171, 7190, 8362, 2442, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 560, 65, 328, 311, 2442, 492, 334, 272, 13986, 3264, 3041, 12, 13986, 547, 12, 7190, 11860, 12, 1379, 12, 1379, 2028, 12, 23795, 12, 272, 636, 1023, 363, 465, 1212, 63, 9277, 63, 1023, 9, 421, 199, 318, 1343, 63, 396, 8, 1258, 12, 511, 63, 888, 63, 344, 304, 272, 702, 511, 63, 888, 63, 344, 365, 440, 488, 12, 971, 267, 3546, 396, 63, 888, 63, 344, 7, 365, 15230, 367, 283, 928, 4065, 339, 511, 63, 344, 275, 1379, 2028, 14, 928, 63, 396, 63, 504, 63, 344, 8, 267, 1890, 12, 511, 63, 888, 63, 344, 9, 272, 511, 275, 1379, 14, 362, 8, 1258, 12, 511, 63, 344, 9, 272, 6701, 63, 344, 275, 7190, 11860, 14, 354, 63, 475, 63, 344, 8, 6200, 11860, 14, 14083, 5616, 1951, 63, 22125, 9, 272, 2547, 275, 511, 14, 1099, 63, 1745, 779, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 31541, 63, 18068, 7111, 395, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 3791, 63, 7405, 63, 4961, 12, 4318, 2248, 63, 2619, 63, 344, 29, 7617, 63, 344, 395, 267, 23795, 14, 1099, 63, 344, 63, 504, 63, 354, 8, 13120, 14, 10401, 63, 28164, 12, 4318, 2248, 63, 2619, 63, 344, 29, 7617, 63, 344, 3948, 339, 862, 26, 267, 870, 480, 14139, 511, 24307, 68, 334, 1345, 511, 26, 450, 83, 680, 703, 2, 450, 334, 396, 14, 344, 12, 511, 14, 3455, 63, 633, 430, 267, 862, 26, 288, 367, 666, 315, 2547, 26, 355, 870, 8, 576, 9, 27439, 871, 13483, 26, 288, 870, 480, 16682, 316, 511, 2685, 288, 511, 14, 13845, 342, 288, 367, 666, 315, 2547, 26, 355, 870, 8, 576, 9, 267, 870, 480, 774, 9709, 543, 2004, 1543, 83, 4065, 1598, 450, 334, 774, 14, 1205, 63, 600, 63, 475, 63, 505, 8, 396, 14, 1205, 1724, 272, 871, 13986, 547, 465, 325, 26, 267, 870, 480, 16682, 316, 511, 12, 23090, 1125, 26, 450, 83, 2, 450, 620, 8, 69, 430, 267, 511, 14, 13845, 342, 421, 199, 318, 4503, 837, 272, 870, 480, 7692, 26, 4165, 282, 511, 2897, 2870, 531, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 299, 275, 8691, 14, 14553, 8, 1023, 29, 3508, 5, 6595, 450, 83, 7, 450, 1212, 63, 9277, 63, 1023, 430, 272, 299, 14, 525, 63, 1422, 4517, 1246, 13, 1418, 297, 1595, 534, 1617, 297, 326, 2053, 534, 1246, 63, 1418, 297, 849, 29, 403, 12, 326, 1720, 15387, 14398, 7190, 8362, 2442, 3261, 1526, 13853, 272, 299, 14, 525, 63, 1422, 4517, 1757, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 1757, 297, 849, 29, 797, 12, 326, 1720, 15387, 13853, 272, 3999, 12, 1249, 275, 299, 14, 1122, 63, 589, 342, 339, 340, 413, 690, 822, 8, 589, 304, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 339, 511, 63, 888, 63, 344, 275, 488, 339, 340, 413, 2695, 822, 8, 589, 304, 267, 511, 63, 888, 63, 344, 275, 1249, 59, 16, 61, 339, 862, 26, 267, 1890, 275, 13986, 3264, 3041, 8, 3291, 14, 1246, 63, 1418, 12, 3105, 29, 3291, 14, 1757, 9, 267, 1343, 63, 396, 8, 1258, 12, 511, 63, 888, 63, 344, 9, 272, 871, 13986, 547, 26, 267, 870, 480, 547, 14556, 26, 450, 83, 2, 450, 5190, 14, 908, 63, 2804, 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, 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, 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 ]
direvus/ansible
lib/ansible/plugins/cliconf/nos.py
10
3576
# # (c) 2018 Extreme Networks Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # from __future__ import (absolute_import, division, print_function) __metaclass__ = type import re import json from ansible.module_utils._text import to_text from ansible.module_utils.network.common.utils import to_list from ansible.plugins.cliconf import CliconfBase class Cliconf(CliconfBase): def get_device_info(self): device_info = {} device_info['network_os'] = 'nos' reply = self.get(b'show version') data = to_text(reply, errors='surrogate_or_strict').strip() match = re.search(r'Network Operating System Version: (\S+)', data) if match: device_info['network_os_version'] = match.group(1) reply = self.get(b'show chassis') data = to_text(reply, errors='surrogate_or_strict').strip() match = re.search(r'^Chassis Name:(\s+)(\S+)', data, re.M) if match: device_info['network_os_model'] = match.group(2) reply = self.get(b'show running-config | inc "switch-attributes host-name"') data = to_text(reply, errors='surrogate_or_strict').strip() match = re.search(r'switch-attributes host-name (\S+)', data, re.M) if match: device_info['network_os_hostname'] = match.group(1) return device_info def get_config(self, source='running', flags=None): if source not in 'running': raise ValueError("fetching configuration from %s is not supported" % source) if source == 'running': cmd = 'show running-config' flags = [] if flags is None else flags cmd += ' '.join(flags) cmd = cmd.strip() return self.send_command(cmd) def edit_config(self, command): resp = {} results = [] requests = [] self.send_command('configure terminal') for cmd in to_list(command): if isinstance(cmd, dict): command = cmd['command'] prompt = cmd['prompt'] answer = cmd['answer'] newline = cmd.get('newline', True) else: command = cmd prompt = None answer = None newline = True if cmd != 'end' and cmd[0] != '!': results.append(self.send_command(command, prompt, answer, False, newline)) requests.append(cmd) self.send_command('end') resp['request'] = requests resp['response'] = results return resp def get(self, command, prompt=None, answer=None, sendonly=False): return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly) def get_capabilities(self): result = {} result['rpc'] = self.get_base_rpc() result['network_api'] = 'cliconf' result['device_info'] = self.get_device_info() return json.dumps(result)
gpl-3.0
[ 3, 199, 3, 334, 67, 9, 14894, 7255, 17817, 17138, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 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, 295, 199, 646, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 370, 63, 513, 199, 504, 3242, 14, 5265, 14, 2764, 2190, 492, 445, 317, 2190, 1563, 421, 199, 533, 445, 317, 2190, 8, 20653, 2190, 1563, 304, 339, 347, 664, 63, 1782, 63, 815, 8, 277, 304, 267, 2243, 63, 815, 275, 1052, 398, 2243, 63, 815, 459, 1200, 63, 736, 418, 275, 283, 12712, 7, 267, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 1015, 358, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 7, 4491, 6654, 1958, 6187, 3394, 26, 14749, 51, 14705, 666, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 1023, 418, 275, 1336, 14, 923, 8, 17, 9, 398, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 682, 20743, 358, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 4289, 1049, 20743, 2812, 26, 2961, 83, 27860, 51, 14705, 666, 12, 295, 14, 45, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 1238, 418, 275, 1336, 14, 923, 8, 18, 9, 398, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 3879, 13, 888, 1204, 12864, 298, 5656, 13, 2987, 1591, 13, 354, 9008, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 1159, 3111, 13, 2987, 1591, 13, 354, 14749, 51, 14705, 666, 12, 295, 14, 45, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 4269, 418, 275, 1336, 14, 923, 8, 17, 9, 398, 372, 2243, 63, 815, 339, 347, 664, 63, 888, 8, 277, 12, 1350, 534, 5720, 297, 3285, 29, 403, 304, 267, 340, 1350, 440, 315, 283, 5720, 356, 288, 746, 1722, 480, 3535, 316, 2897, 687, 450, 83, 365, 440, 3748, 2, 450, 1350, 9, 267, 340, 1350, 508, 283, 5720, 356, 288, 2088, 275, 283, 2384, 3879, 13, 888, 7, 398, 3285, 275, 942, 340, 3285, 365, 488, 587, 3285, 267, 2088, 847, 283, 1987, 904, 8, 2469, 9, 267, 2088, 275, 2088, 14, 1913, 342, 398, 372, 291, 14, 2254, 63, 1531, 8, 1760, 9, 339, 347, 5283, 63, 888, 8, 277, 12, 1414, 304, 267, 3085, 275, 1052, 267, 2058, 275, 942, 267, 4145, 275, 942, 267, 291, 14, 2254, 63, 1531, 360, 6472, 11167, 358, 267, 367, 2088, 315, 370, 63, 513, 8, 1531, 304, 288, 340, 1228, 8, 1760, 12, 1211, 304, 355, 1414, 275, 2088, 459, 1531, 418, 355, 8457, 275, 2088, 459, 7650, 418, 355, 6385, 275, 2088, 459, 5934, 418, 355, 8057, 275, 2088, 14, 362, 360, 12210, 297, 715, 9, 288, 587, 26, 355, 1414, 275, 2088, 355, 8457, 275, 488, 355, 6385, 275, 488, 355, 8057, 275, 715, 953, 340, 2088, 1137, 283, 500, 7, 436, 2088, 59, 16, 61, 1137, 14597, 356, 355, 2058, 14, 740, 8, 277, 14, 2254, 63, 1531, 8, 1531, 12, 8457, 12, 6385, 12, 756, 12, 8057, 430, 355, 4145, 14, 740, 8, 1760, 9, 398, 291, 14, 2254, 63, 1531, 360, 500, 358, 398, 3085, 459, 1069, 418, 275, 4145, 267, 3085, 459, 1310, 418, 275, 2058, 267, 372, 3085, 339, 347, 664, 8, 277, 12, 1414, 12, 8457, 29, 403, 12, 6385, 29, 403, 12, 3222, 2118, 29, 797, 304, 267, 372, 291, 14, 2254, 63, 1531, 8, 1531, 12, 8457, 29, 7650, 12, 6385, 29, 5934, 12, 3222, 2118, 29, 2254, 2118, 9, 339, 347, 664, 63, 10732, 8, 277, 304, 267, 754, 275, 1052, 267, 754, 459, 4354, 418, 275, 291, 14, 362, 63, 1095, 63, 4354, 342, 267, 754, 459, 1200, 63, 1246, 418, 275, 283, 2764, 2190, 7, 267, 754, 459, 1782, 63, 815, 418, 275, 291, 14, 362, 63, 1782, 63, 815, 342, 267, 372, 2022, 14, 4180, 8, 1099, 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 ]
[ 199, 3, 334, 67, 9, 14894, 7255, 17817, 17138, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 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, 295, 199, 646, 2022, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 505, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 370, 63, 513, 199, 504, 3242, 14, 5265, 14, 2764, 2190, 492, 445, 317, 2190, 1563, 421, 199, 533, 445, 317, 2190, 8, 20653, 2190, 1563, 304, 339, 347, 664, 63, 1782, 63, 815, 8, 277, 304, 267, 2243, 63, 815, 275, 1052, 398, 2243, 63, 815, 459, 1200, 63, 736, 418, 275, 283, 12712, 7, 267, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 1015, 358, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 7, 4491, 6654, 1958, 6187, 3394, 26, 14749, 51, 14705, 666, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 1023, 418, 275, 1336, 14, 923, 8, 17, 9, 398, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 682, 20743, 358, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 4289, 1049, 20743, 2812, 26, 2961, 83, 27860, 51, 14705, 666, 12, 295, 14, 45, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 1238, 418, 275, 1336, 14, 923, 8, 18, 9, 398, 9351, 275, 291, 14, 362, 8, 66, 1159, 1917, 3879, 13, 888, 1204, 12864, 298, 5656, 13, 2987, 1591, 13, 354, 9008, 267, 666, 275, 370, 63, 505, 8, 8102, 12, 2552, 534, 16380, 63, 269, 63, 4768, 1959, 1913, 342, 398, 1336, 275, 295, 14, 1733, 8, 82, 1159, 3111, 13, 2987, 1591, 13, 354, 14749, 51, 14705, 666, 12, 295, 14, 45, 9, 267, 340, 1336, 26, 288, 2243, 63, 815, 459, 1200, 63, 736, 63, 4269, 418, 275, 1336, 14, 923, 8, 17, 9, 398, 372, 2243, 63, 815, 339, 347, 664, 63, 888, 8, 277, 12, 1350, 534, 5720, 297, 3285, 29, 403, 304, 267, 340, 1350, 440, 315, 283, 5720, 356, 288, 746, 1722, 480, 3535, 316, 2897, 687, 450, 83, 365, 440, 3748, 2, 450, 1350, 9, 267, 340, 1350, 508, 283, 5720, 356, 288, 2088, 275, 283, 2384, 3879, 13, 888, 7, 398, 3285, 275, 942, 340, 3285, 365, 488, 587, 3285, 267, 2088, 847, 283, 1987, 904, 8, 2469, 9, 267, 2088, 275, 2088, 14, 1913, 342, 398, 372, 291, 14, 2254, 63, 1531, 8, 1760, 9, 339, 347, 5283, 63, 888, 8, 277, 12, 1414, 304, 267, 3085, 275, 1052, 267, 2058, 275, 942, 267, 4145, 275, 942, 267, 291, 14, 2254, 63, 1531, 360, 6472, 11167, 358, 267, 367, 2088, 315, 370, 63, 513, 8, 1531, 304, 288, 340, 1228, 8, 1760, 12, 1211, 304, 355, 1414, 275, 2088, 459, 1531, 418, 355, 8457, 275, 2088, 459, 7650, 418, 355, 6385, 275, 2088, 459, 5934, 418, 355, 8057, 275, 2088, 14, 362, 360, 12210, 297, 715, 9, 288, 587, 26, 355, 1414, 275, 2088, 355, 8457, 275, 488, 355, 6385, 275, 488, 355, 8057, 275, 715, 953, 340, 2088, 1137, 283, 500, 7, 436, 2088, 59, 16, 61, 1137, 14597, 356, 355, 2058, 14, 740, 8, 277, 14, 2254, 63, 1531, 8, 1531, 12, 8457, 12, 6385, 12, 756, 12, 8057, 430, 355, 4145, 14, 740, 8, 1760, 9, 398, 291, 14, 2254, 63, 1531, 360, 500, 358, 398, 3085, 459, 1069, 418, 275, 4145, 267, 3085, 459, 1310, 418, 275, 2058, 267, 372, 3085, 339, 347, 664, 8, 277, 12, 1414, 12, 8457, 29, 403, 12, 6385, 29, 403, 12, 3222, 2118, 29, 797, 304, 267, 372, 291, 14, 2254, 63, 1531, 8, 1531, 12, 8457, 29, 7650, 12, 6385, 29, 5934, 12, 3222, 2118, 29, 2254, 2118, 9, 339, 347, 664, 63, 10732, 8, 277, 304, 267, 754, 275, 1052, 267, 754, 459, 4354, 418, 275, 291, 14, 362, 63, 1095, 63, 4354, 342, 267, 754, 459, 1200, 63, 1246, 418, 275, 283, 2764, 2190, 7, 267, 754, 459, 1782, 63, 815, 418, 275, 291, 14, 362, 63, 1782, 63, 815, 342, 267, 372, 2022, 14, 4180, 8, 1099, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vinicius-alves/InternetBanking
env/lib/python3.4/site-packages/django/core/checks/security/base.py
45
6645
from django.conf import settings from .. import Tags, Warning, register from ..utils import patch_middleware_message SECRET_KEY_MIN_LENGTH = 50 SECRET_KEY_MIN_UNIQUE_CHARACTERS = 5 W001 = Warning( "You do not have 'django.middleware.security.SecurityMiddleware' " "in your MIDDLEWARE so the SECURE_HSTS_SECONDS, " "SECURE_CONTENT_TYPE_NOSNIFF, " "SECURE_BROWSER_XSS_FILTER, and SECURE_SSL_REDIRECT settings " "will have no effect.", id='security.W001', ) W002 = Warning( "You do not have " "'django.middleware.clickjacking.XFrameOptionsMiddleware' in your " "MIDDLEWARE, so your pages will not be served with an " "'x-frame-options' header. Unless there is a good reason for your " "site to be served in a frame, you should consider enabling this " "header to help prevent clickjacking attacks.", id='security.W002', ) W004 = Warning( "You have not set a value for the SECURE_HSTS_SECONDS setting. " "If your entire site is served only over SSL, you may want to consider " "setting a value and enabling HTTP Strict Transport Security. " "Be sure to read the documentation first; enabling HSTS carelessly " "can cause serious, irreversible problems.", id='security.W004', ) W005 = Warning( "You have not set the SECURE_HSTS_INCLUDE_SUBDOMAINS setting to True. " "Without this, your site is potentially vulnerable to attack " "via an insecure connection to a subdomain. Only set this to True if " "you are certain that all subdomains of your domain should be served " "exclusively via SSL.", id='security.W005', ) W006 = Warning( "Your SECURE_CONTENT_TYPE_NOSNIFF setting is not set to True, " "so your pages will not be served with an " "'x-content-type-options: nosniff' header. " "You should consider enabling this header to prevent the " "browser from identifying content types incorrectly.", id='security.W006', ) W007 = Warning( "Your SECURE_BROWSER_XSS_FILTER setting is not set to True, " "so your pages will not be served with an " "'x-xss-protection: 1; mode=block' header. " "You should consider enabling this header to activate the " "browser's XSS filtering and help prevent XSS attacks.", id='security.W007', ) W008 = Warning( "Your SECURE_SSL_REDIRECT setting is not set to True. " "Unless your site should be available over both SSL and non-SSL " "connections, you may want to either set this setting True " "or configure a load balancer or reverse-proxy server " "to redirect all connections to HTTPS.", id='security.W008', ) W009 = Warning( "Your SECRET_KEY has less than %(min_length)s characters or less than " "%(min_unique_chars)s unique characters. Please generate a long and random " "SECRET_KEY, otherwise many of Django's security-critical features will be " "vulnerable to attack." % { 'min_length': SECRET_KEY_MIN_LENGTH, 'min_unique_chars': SECRET_KEY_MIN_UNIQUE_CHARACTERS, }, id='security.W009', ) W018 = Warning( "You should not have DEBUG set to True in deployment.", id='security.W018', ) W019 = Warning( "You have " "'django.middleware.clickjacking.XFrameOptionsMiddleware' in your " "MIDDLEWARE, but X_FRAME_OPTIONS is not set to 'DENY'. " "The default is 'SAMEORIGIN', but unless there is a good reason for " "your site to serve other parts of itself in a frame, you should " "change it to 'DENY'.", id='security.W019', ) W020 = Warning( "ALLOWED_HOSTS must not be empty in deployment.", id='security.W020', ) def _security_middleware(): return ("django.middleware.security.SecurityMiddleware" in settings.MIDDLEWARE_CLASSES or settings.MIDDLEWARE and "django.middleware.security.SecurityMiddleware" in settings.MIDDLEWARE) def _xframe_middleware(): return ("django.middleware.clickjacking.XFrameOptionsMiddleware" in settings.MIDDLEWARE_CLASSES or settings.MIDDLEWARE and "django.middleware.clickjacking.XFrameOptionsMiddleware" in settings.MIDDLEWARE) @register(Tags.security, deploy=True) def check_security_middleware(app_configs, **kwargs): passed_check = _security_middleware() return [] if passed_check else [patch_middleware_message(W001)] @register(Tags.security, deploy=True) def check_xframe_options_middleware(app_configs, **kwargs): passed_check = _xframe_middleware() return [] if passed_check else [patch_middleware_message(W002)] @register(Tags.security, deploy=True) def check_sts(app_configs, **kwargs): passed_check = not _security_middleware() or settings.SECURE_HSTS_SECONDS return [] if passed_check else [W004] @register(Tags.security, deploy=True) def check_sts_include_subdomains(app_configs, **kwargs): passed_check = ( not _security_middleware() or not settings.SECURE_HSTS_SECONDS or settings.SECURE_HSTS_INCLUDE_SUBDOMAINS is True ) return [] if passed_check else [W005] @register(Tags.security, deploy=True) def check_content_type_nosniff(app_configs, **kwargs): passed_check = ( not _security_middleware() or settings.SECURE_CONTENT_TYPE_NOSNIFF is True ) return [] if passed_check else [W006] @register(Tags.security, deploy=True) def check_xss_filter(app_configs, **kwargs): passed_check = ( not _security_middleware() or settings.SECURE_BROWSER_XSS_FILTER is True ) return [] if passed_check else [W007] @register(Tags.security, deploy=True) def check_ssl_redirect(app_configs, **kwargs): passed_check = ( not _security_middleware() or settings.SECURE_SSL_REDIRECT is True ) return [] if passed_check else [W008] @register(Tags.security, deploy=True) def check_secret_key(app_configs, **kwargs): passed_check = ( getattr(settings, 'SECRET_KEY', None) and len(set(settings.SECRET_KEY)) >= SECRET_KEY_MIN_UNIQUE_CHARACTERS and len(settings.SECRET_KEY) >= SECRET_KEY_MIN_LENGTH ) return [] if passed_check else [W009] @register(Tags.security, deploy=True) def check_debug(app_configs, **kwargs): passed_check = not settings.DEBUG return [] if passed_check else [W018] @register(Tags.security, deploy=True) def check_xframe_deny(app_configs, **kwargs): passed_check = ( not _xframe_middleware() or settings.X_FRAME_OPTIONS == 'DENY' ) return [] if passed_check else [patch_middleware_message(W019)] @register(Tags.security, deploy=True) def check_allowed_hosts(app_configs, **kwargs): return [] if settings.ALLOWED_HOSTS else [W020]
gpl-3.0
[ 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 2508, 492, 25204, 12, 15902, 12, 2274, 199, 504, 2508, 1208, 492, 3371, 63, 5754, 63, 1188, 199, 199, 12961, 63, 3078, 63, 4896, 63, 9127, 275, 5238, 199, 12961, 63, 3078, 63, 4896, 63, 28060, 63, 5901, 3036, 3960, 275, 959, 199, 199, 55, 4587, 275, 15902, 8, 272, 298, 5556, 886, 440, 1172, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 7, 298, 272, 298, 262, 2195, 30718, 880, 314, 24143, 3942, 63, 40, 840, 51, 63, 23319, 12, 298, 272, 298, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 12, 298, 272, 298, 20696, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 12, 436, 24143, 3942, 63, 5413, 63, 19747, 2202, 298, 272, 298, 14117, 1172, 949, 7763, 4765, 272, 1305, 534, 4416, 14, 55, 4587, 297, 199, 9, 199, 199, 55, 7432, 275, 15902, 8, 272, 298, 5556, 886, 440, 1172, 298, 272, 3546, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 7, 315, 2195, 298, 272, 298, 19987, 12, 880, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 1943, 13, 1419, 7, 1406, 14, 4158, 2337, 365, 282, 6954, 4499, 367, 2195, 298, 272, 298, 2124, 370, 506, 19733, 315, 282, 2787, 12, 1265, 1077, 11201, 29310, 642, 298, 272, 298, 1291, 370, 1720, 7981, 8968, 19193, 316, 28140, 4765, 272, 1305, 534, 4416, 14, 55, 7432, 297, 199, 9, 199, 199, 55, 7979, 275, 15902, 8, 272, 298, 5556, 1172, 440, 663, 282, 574, 367, 314, 24143, 3942, 63, 40, 840, 51, 63, 23319, 4260, 14, 298, 272, 298, 3917, 2195, 8039, 4770, 365, 19733, 1454, 1806, 7799, 12, 1265, 1443, 2934, 370, 11201, 298, 272, 298, 6031, 282, 574, 436, 29310, 3101, 23052, 27018, 13863, 14, 298, 272, 298, 3655, 3238, 370, 1586, 314, 3794, 1642, 27, 29310, 869, 840, 51, 10296, 2003, 590, 298, 272, 298, 2425, 7675, 542, 322, 1785, 12, 8190, 264, 422, 1164, 8826, 4765, 272, 1305, 534, 4416, 14, 55, 7979, 297, 199, 9, 199, 199, 55, 7972, 275, 15902, 8, 272, 298, 5556, 1172, 440, 663, 314, 24143, 3942, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 4260, 370, 715, 14, 298, 272, 298, 12450, 642, 12, 2195, 4770, 365, 18994, 373, 21406, 461, 370, 23326, 298, 272, 298, 12897, 376, 26097, 1950, 370, 282, 23301, 14, 5972, 663, 642, 370, 715, 340, 298, 272, 298, 13297, 787, 9842, 626, 1006, 1007, 9756, 402, 2195, 2881, 1077, 506, 19733, 298, 272, 298, 476, 1016, 9840, 4799, 7799, 4765, 272, 1305, 534, 4416, 14, 55, 7972, 297, 199, 9, 199, 199, 55, 8010, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 4260, 365, 440, 663, 370, 715, 12, 298, 272, 298, 1152, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 1317, 13, 466, 13, 1419, 26, 302, 736, 8445, 556, 7, 1406, 14, 298, 272, 298, 5556, 1077, 11201, 29310, 642, 1406, 370, 7981, 314, 298, 272, 298, 5750, 687, 21119, 1564, 2943, 22743, 4765, 272, 1305, 534, 4416, 14, 55, 8010, 297, 199, 9, 199, 199, 55, 8255, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 4260, 365, 440, 663, 370, 715, 12, 298, 272, 298, 1152, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 88, 385, 13, 14103, 26, 413, 27, 818, 29, 1457, 7, 1406, 14, 298, 272, 298, 5556, 1077, 11201, 29310, 642, 1406, 370, 15422, 314, 298, 272, 298, 5750, 1159, 1323, 2300, 14545, 436, 1720, 7981, 1323, 2300, 28140, 4765, 272, 1305, 534, 4416, 14, 55, 8255, 297, 199, 9, 199, 199, 55, 8662, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 5413, 63, 19747, 4260, 365, 440, 663, 370, 715, 14, 298, 272, 298, 5524, 2195, 4770, 1077, 506, 2808, 1806, 3865, 7799, 436, 2222, 13, 5413, 298, 272, 298, 7995, 12, 1265, 1443, 2934, 370, 1902, 663, 642, 4260, 715, 298, 272, 298, 269, 7908, 282, 2248, 17005, 503, 3837, 13, 3280, 1654, 298, 272, 298, 475, 4660, 1006, 6947, 370, 14147, 4765, 272, 1305, 534, 4416, 14, 55, 8662, 297, 199, 9, 199, 199, 55, 8581, 275, 15902, 8, 272, 298, 14398, 5795, 11771, 63, 3078, 965, 6656, 2419, 2818, 827, 63, 1267, 9, 83, 4110, 503, 6656, 2419, 298, 272, 11792, 827, 63, 3235, 63, 6574, 9, 83, 3747, 4110, 14, 7754, 3550, 282, 1846, 436, 2196, 298, 272, 298, 12961, 63, 3078, 12, 4257, 5002, 402, 5634, 1159, 6391, 13, 13138, 4534, 911, 506, 298, 272, 298, 86, 21406, 461, 370, 23326, 2122, 450, 469, 267, 283, 827, 63, 1267, 356, 5795, 11771, 63, 3078, 63, 4896, 63, 9127, 12, 267, 283, 827, 63, 3235, 63, 6574, 356, 5795, 11771, 63, 3078, 63, 4896, 63, 28060, 63, 5901, 3036, 3960, 12, 272, 1660, 272, 1305, 534, 4416, 14, 55, 8581, 297, 199, 9, 199, 199, 55, 12549, 275, 15902, 8, 272, 298, 5556, 1077, 440, 1172, 10990, 663, 370, 715, 315, 14295, 4765, 272, 1305, 534, 4416, 14, 55, 12549, 297, 199, 9, 199, 199, 55, 12512, 275, 15902, 8, 272, 298, 5556, 1172, 298, 272, 3546, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 7, 315, 2195, 298, 272, 298, 19987, 12, 1325, 1323, 63, 12683, 63, 8808, 365, 440, 663, 370, 283, 23282, 57, 1370, 298, 272, 298, 1918, 849, 365, 283, 19935, 24832, 297, 1325, 7444, 2337, 365, 282, 6954, 4499, 367, 298, 272, 298, 12695, 4770, 370, 14062, 1163, 4184, 402, 6337, 315, 282, 2787, 12, 1265, 1077, 298, 272, 298, 1461, 652, 370, 283, 23282, 57, 30532, 272, 1305, 534, 4416, 14, 55, 12512, 297, 199, 9, 199, 199, 55, 10173, 275, 15902, 8, 272, 298, 17350, 63, 23775, 1471, 440, 506, 2701, 315, 14295, 4765, 272, 1305, 534, 4416, 14, 55, 10173, 297, 199, 9, 421, 199, 318, 485, 4416, 63, 5754, 837, 272, 372, 1689, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 2, 315, 2202, 14, 19987, 63, 13748, 503 ]
[ 1639, 14, 2190, 492, 2202, 199, 199, 504, 2508, 492, 25204, 12, 15902, 12, 2274, 199, 504, 2508, 1208, 492, 3371, 63, 5754, 63, 1188, 199, 199, 12961, 63, 3078, 63, 4896, 63, 9127, 275, 5238, 199, 12961, 63, 3078, 63, 4896, 63, 28060, 63, 5901, 3036, 3960, 275, 959, 199, 199, 55, 4587, 275, 15902, 8, 272, 298, 5556, 886, 440, 1172, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 7, 298, 272, 298, 262, 2195, 30718, 880, 314, 24143, 3942, 63, 40, 840, 51, 63, 23319, 12, 298, 272, 298, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 12, 298, 272, 298, 20696, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 12, 436, 24143, 3942, 63, 5413, 63, 19747, 2202, 298, 272, 298, 14117, 1172, 949, 7763, 4765, 272, 1305, 534, 4416, 14, 55, 4587, 297, 199, 9, 199, 199, 55, 7432, 275, 15902, 8, 272, 298, 5556, 886, 440, 1172, 298, 272, 3546, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 7, 315, 2195, 298, 272, 298, 19987, 12, 880, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 1943, 13, 1419, 7, 1406, 14, 4158, 2337, 365, 282, 6954, 4499, 367, 2195, 298, 272, 298, 2124, 370, 506, 19733, 315, 282, 2787, 12, 1265, 1077, 11201, 29310, 642, 298, 272, 298, 1291, 370, 1720, 7981, 8968, 19193, 316, 28140, 4765, 272, 1305, 534, 4416, 14, 55, 7432, 297, 199, 9, 199, 199, 55, 7979, 275, 15902, 8, 272, 298, 5556, 1172, 440, 663, 282, 574, 367, 314, 24143, 3942, 63, 40, 840, 51, 63, 23319, 4260, 14, 298, 272, 298, 3917, 2195, 8039, 4770, 365, 19733, 1454, 1806, 7799, 12, 1265, 1443, 2934, 370, 11201, 298, 272, 298, 6031, 282, 574, 436, 29310, 3101, 23052, 27018, 13863, 14, 298, 272, 298, 3655, 3238, 370, 1586, 314, 3794, 1642, 27, 29310, 869, 840, 51, 10296, 2003, 590, 298, 272, 298, 2425, 7675, 542, 322, 1785, 12, 8190, 264, 422, 1164, 8826, 4765, 272, 1305, 534, 4416, 14, 55, 7979, 297, 199, 9, 199, 199, 55, 7972, 275, 15902, 8, 272, 298, 5556, 1172, 440, 663, 314, 24143, 3942, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 4260, 370, 715, 14, 298, 272, 298, 12450, 642, 12, 2195, 4770, 365, 18994, 373, 21406, 461, 370, 23326, 298, 272, 298, 12897, 376, 26097, 1950, 370, 282, 23301, 14, 5972, 663, 642, 370, 715, 340, 298, 272, 298, 13297, 787, 9842, 626, 1006, 1007, 9756, 402, 2195, 2881, 1077, 506, 19733, 298, 272, 298, 476, 1016, 9840, 4799, 7799, 4765, 272, 1305, 534, 4416, 14, 55, 7972, 297, 199, 9, 199, 199, 55, 8010, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 4260, 365, 440, 663, 370, 715, 12, 298, 272, 298, 1152, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 1317, 13, 466, 13, 1419, 26, 302, 736, 8445, 556, 7, 1406, 14, 298, 272, 298, 5556, 1077, 11201, 29310, 642, 1406, 370, 7981, 314, 298, 272, 298, 5750, 687, 21119, 1564, 2943, 22743, 4765, 272, 1305, 534, 4416, 14, 55, 8010, 297, 199, 9, 199, 199, 55, 8255, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 4260, 365, 440, 663, 370, 715, 12, 298, 272, 298, 1152, 2195, 6497, 911, 440, 506, 19733, 543, 376, 298, 272, 3546, 88, 13, 88, 385, 13, 14103, 26, 413, 27, 818, 29, 1457, 7, 1406, 14, 298, 272, 298, 5556, 1077, 11201, 29310, 642, 1406, 370, 15422, 314, 298, 272, 298, 5750, 1159, 1323, 2300, 14545, 436, 1720, 7981, 1323, 2300, 28140, 4765, 272, 1305, 534, 4416, 14, 55, 8255, 297, 199, 9, 199, 199, 55, 8662, 275, 15902, 8, 272, 298, 14398, 24143, 3942, 63, 5413, 63, 19747, 4260, 365, 440, 663, 370, 715, 14, 298, 272, 298, 5524, 2195, 4770, 1077, 506, 2808, 1806, 3865, 7799, 436, 2222, 13, 5413, 298, 272, 298, 7995, 12, 1265, 1443, 2934, 370, 1902, 663, 642, 4260, 715, 298, 272, 298, 269, 7908, 282, 2248, 17005, 503, 3837, 13, 3280, 1654, 298, 272, 298, 475, 4660, 1006, 6947, 370, 14147, 4765, 272, 1305, 534, 4416, 14, 55, 8662, 297, 199, 9, 199, 199, 55, 8581, 275, 15902, 8, 272, 298, 14398, 5795, 11771, 63, 3078, 965, 6656, 2419, 2818, 827, 63, 1267, 9, 83, 4110, 503, 6656, 2419, 298, 272, 11792, 827, 63, 3235, 63, 6574, 9, 83, 3747, 4110, 14, 7754, 3550, 282, 1846, 436, 2196, 298, 272, 298, 12961, 63, 3078, 12, 4257, 5002, 402, 5634, 1159, 6391, 13, 13138, 4534, 911, 506, 298, 272, 298, 86, 21406, 461, 370, 23326, 2122, 450, 469, 267, 283, 827, 63, 1267, 356, 5795, 11771, 63, 3078, 63, 4896, 63, 9127, 12, 267, 283, 827, 63, 3235, 63, 6574, 356, 5795, 11771, 63, 3078, 63, 4896, 63, 28060, 63, 5901, 3036, 3960, 12, 272, 1660, 272, 1305, 534, 4416, 14, 55, 8581, 297, 199, 9, 199, 199, 55, 12549, 275, 15902, 8, 272, 298, 5556, 1077, 440, 1172, 10990, 663, 370, 715, 315, 14295, 4765, 272, 1305, 534, 4416, 14, 55, 12549, 297, 199, 9, 199, 199, 55, 12512, 275, 15902, 8, 272, 298, 5556, 1172, 298, 272, 3546, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 7, 315, 2195, 298, 272, 298, 19987, 12, 1325, 1323, 63, 12683, 63, 8808, 365, 440, 663, 370, 283, 23282, 57, 1370, 298, 272, 298, 1918, 849, 365, 283, 19935, 24832, 297, 1325, 7444, 2337, 365, 282, 6954, 4499, 367, 298, 272, 298, 12695, 4770, 370, 14062, 1163, 4184, 402, 6337, 315, 282, 2787, 12, 1265, 1077, 298, 272, 298, 1461, 652, 370, 283, 23282, 57, 30532, 272, 1305, 534, 4416, 14, 55, 12512, 297, 199, 9, 199, 199, 55, 10173, 275, 15902, 8, 272, 298, 17350, 63, 23775, 1471, 440, 506, 2701, 315, 14295, 4765, 272, 1305, 534, 4416, 14, 55, 10173, 297, 199, 9, 421, 199, 318, 485, 4416, 63, 5754, 837, 272, 372, 1689, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 2, 315, 2202, 14, 19987, 63, 13748, 503, 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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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 ]
yongtang/tensorflow
tensorflow/python/debug/lib/debug_events_writer.py
6
6377
# Copyright 2019 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. # ============================================================================== """Writer class for `DebugEvent` protos in tfdbg v2.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import time from tensorflow.core.protobuf import debug_event_pb2 from tensorflow.python.client import _pywrap_debug_events_writer # Default size of each circular buffer (unit: number of DebugEvent protos). DEFAULT_CIRCULAR_BUFFER_SIZE = 1000 class DebugEventsWriter(object): """A writer for TF debugging events. Used by tfdbg v2.""" def __init__(self, dump_root, tfdbg_run_id, circular_buffer_size=DEFAULT_CIRCULAR_BUFFER_SIZE): """Construct a DebugEventsWriter object. NOTE: Given the same `dump_root`, all objects from this constructor will point to the same underlying set of writers. In other words, they will write to the same set of debug events files in the `dump_root` folder. Args: dump_root: The root directory for dumping debug data. If `dump_root` does not exist as a directory, it will be created. tfdbg_run_id: Debugger Run ID. circular_buffer_size: Size of the circular buffer for each of the two execution-related debug events files: with the following suffixes: - .execution - .graph_execution_traces If <= 0, the circular-buffer behavior will be abolished in the constructed object. """ if not dump_root: raise ValueError("Empty or None dump root") self._dump_root = dump_root self._tfdbg_run_id = tfdbg_run_id _pywrap_debug_events_writer.Init(self._dump_root, self._tfdbg_run_id, circular_buffer_size) def WriteSourceFile(self, source_file): """Write a SourceFile proto with the writer. Args: source_file: A SourceFile proto, describing the content of a source file involved in the execution of the debugged TensorFlow program. """ # TODO(cais): Explore performance optimization that avoids memcpy. debug_event = debug_event_pb2.DebugEvent(source_file=source_file) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteSourceFile(self._dump_root, debug_event) def WriteStackFrameWithId(self, stack_frame_with_id): """Write a StackFrameWithId proto with the writer. Args: stack_frame_with_id: A StackFrameWithId proto, describing the content a stack frame involved in the execution of the debugged TensorFlow program. """ debug_event = debug_event_pb2.DebugEvent( stack_frame_with_id=stack_frame_with_id) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteStackFrameWithId(self._dump_root, debug_event) def WriteGraphOpCreation(self, graph_op_creation): """Write a GraphOpCreation proto with the writer. Args: graph_op_creation: A GraphOpCreation proto, describing the details of the creation of an op inside a TensorFlow Graph. """ debug_event = debug_event_pb2.DebugEvent( graph_op_creation=graph_op_creation) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteGraphOpCreation(self._dump_root, debug_event) def WriteDebuggedGraph(self, debugged_graph): """Write a DebuggedGraph proto with the writer. Args: debugged_graph: A DebuggedGraph proto, describing the details of a TensorFlow Graph that has completed its construction. """ debug_event = debug_event_pb2.DebugEvent(debugged_graph=debugged_graph) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteDebuggedGraph(self._dump_root, debug_event) def WriteExecution(self, execution): """Write a Execution proto with the writer. Args: execution: An Execution proto, describing a TensorFlow op or graph execution event. """ debug_event = debug_event_pb2.DebugEvent(execution=execution) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteExecution(self._dump_root, debug_event) def WriteGraphExecutionTrace(self, graph_execution_trace): """Write a GraphExecutionTrace proto with the writer. Args: graph_execution_trace: A GraphExecutionTrace proto, concerning the value of an intermediate tensor or a list of intermediate tensors that are computed during the graph's execution. """ debug_event = debug_event_pb2.DebugEvent( graph_execution_trace=graph_execution_trace) self._EnsureTimestampAdded(debug_event) _pywrap_debug_events_writer.WriteGraphExecutionTrace( self._dump_root, debug_event) def RegisterDeviceAndGetId(self, device_name): return _pywrap_debug_events_writer.RegisterDeviceAndGetId( self._dump_root, device_name) def FlushNonExecutionFiles(self): """Flush the non-execution debug event files.""" _pywrap_debug_events_writer.FlushNonExecutionFiles(self._dump_root) def FlushExecutionFiles(self): """Flush the execution debug event files. Causes the current content of the cyclic buffers to be written to the .execution and .graph_execution_traces debug events files. Also clears those cyclic buffers. """ _pywrap_debug_events_writer.FlushExecutionFiles(self._dump_root) def Close(self): """Close the writer.""" _pywrap_debug_events_writer.Close(self._dump_root) @property def dump_root(self): return self._dump_root def _EnsureTimestampAdded(self, debug_event): if debug_event.wall_time == 0: debug_event.wall_time = time.time()
apache-2.0
[ 3, 1898, 20312, 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, 6261, 1021, 367, 658, 7084, 2390, 64, 4104, 83, 315, 2833, 16310, 373, 18, 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, 900, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 3105, 63, 1430, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 199, 199, 3, 3758, 1568, 402, 1924, 15032, 3335, 334, 3248, 26, 1329, 402, 14245, 2390, 4104, 83, 680, 199, 3472, 63, 31749, 3038, 63, 10960, 63, 4305, 275, 5198, 421, 199, 533, 14245, 11770, 6261, 8, 785, 304, 523, 408, 33, 7060, 367, 21721, 10201, 4474, 14, 8051, 701, 2833, 16310, 373, 18, 1041, 819, 347, 636, 826, 721, 277, 12, 2049, 5461, 63, 1231, 12, 2049, 2833, 16310, 63, 1065, 63, 344, 12, 2049, 15032, 63, 2738, 63, 890, 29, 3472, 63, 31749, 3038, 63, 10960, 63, 4305, 304, 272, 408, 11493, 282, 14245, 11770, 6261, 909, 14, 339, 6944, 26, 9138, 314, 2011, 658, 2724, 63, 1231, 3559, 1006, 2251, 687, 642, 3787, 489, 911, 2376, 370, 314, 2011, 8793, 663, 402, 2211, 878, 14, 1010, 1163, 5932, 12, 2985, 489, 911, 2218, 370, 314, 2011, 663, 402, 3105, 4474, 1584, 315, 314, 658, 2724, 63, 1231, 64, 489, 4922, 14, 339, 3033, 26, 489, 5461, 63, 1231, 26, 710, 1738, 2082, 367, 5461, 316, 3105, 666, 14, 982, 658, 2724, 63, 1231, 64, 1630, 267, 440, 2187, 465, 282, 2082, 12, 652, 911, 506, 2737, 14, 489, 2833, 16310, 63, 1065, 63, 344, 26, 14245, 836, 3378, 2870, 14, 489, 15032, 63, 2738, 63, 890, 26, 14579, 402, 314, 15032, 3335, 367, 1924, 402, 314, 2877, 267, 6451, 13, 2407, 3105, 4474, 1584, 26, 543, 314, 2569, 19475, 26, 446, 881, 1275, 9416, 446, 1275, 2180, 63, 9416, 63, 28388, 982, 2695, 378, 12, 314, 15032, 13, 2738, 881, 5953, 911, 506, 282, 656, 1891, 379, 315, 314, 14701, 909, 14, 272, 408, 272, 340, 440, 5461, 63, 1231, 26, 489, 746, 1722, 480, 4699, 503, 488, 5461, 1738, 531, 272, 291, 423, 2724, 63, 1231, 275, 5461, 63, 1231, 272, 291, 423, 3249, 16310, 63, 1065, 63, 344, 275, 2833, 16310, 63, 1065, 63, 344, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 9346, 8, 277, 423, 2724, 63, 1231, 12, 291, 423, 3249, 16310, 63, 1065, 63, 344, 12, 3660, 15032, 63, 2738, 63, 890, 9, 819, 347, 6990, 2980, 1173, 8, 277, 12, 1350, 63, 493, 304, 272, 408, 3534, 282, 5800, 1173, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 1350, 63, 493, 26, 437, 5800, 1173, 4104, 12, 13660, 314, 1564, 402, 282, 1350, 570, 267, 28244, 315, 314, 6451, 402, 314, 3105, 3046, 9134, 2240, 14, 272, 408, 272, 327, 3254, 8, 696, 374, 304, 7910, 28037, 10238, 13712, 626, 23674, 562, 5466, 647, 14, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 1365, 63, 493, 29, 1365, 63, 493, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 2980, 1173, 8, 277, 423, 2724, 63, 1231, 12, 3105, 63, 1430, 9, 819, 347, 6990, 4851, 3160, 3007, 1304, 8, 277, 12, 3464, 63, 1943, 63, 1045, 63, 344, 304, 272, 408, 3534, 282, 13894, 3160, 3007, 1304, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3464, 63, 1943, 63, 1045, 63, 344, 26, 437, 13894, 3160, 3007, 1304, 4104, 12, 13660, 314, 1564, 282, 267, 3464, 2787, 28244, 315, 314, 6451, 402, 314, 3105, 3046, 9134, 267, 2240, 14, 272, 408, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 267, 3464, 63, 1943, 63, 1045, 63, 344, 29, 2340, 63, 1943, 63, 1045, 63, 344, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 4851, 3160, 3007, 1304, 8, 277, 423, 2724, 63, 1231, 12, 10028, 3105, 63, 1430, 9, 819, 347, 6990, 4578, 4619, 13921, 8, 277, 12, 3343, 63, 411, 63, 8782, 304, 272, 408, 3534, 282, 11513, 4619, 13921, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3343, 63, 411, 63, 8782, 26, 437, 11513, 4619, 13921, 4104, 12, 13660, 314, 2436, 402, 314, 267, 7143, 402, 376, 1687, 6272, 282, 9134, 11513, 14, 272, 408, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 267, 3343, 63, 411, 63, 8782, 29, 2180, 63, 411, 63, 8782, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 4578, 4619, 13921, 8, 277, 423, 2724, 63, 1231, 12, 9349, 3105, 63, 1430, 9, 819, 347, 6990, 7084, 3046, 4578, 8, 277, 12, 3105, 3046, 63, 2180, 304, 272, 408, 3534, 282, 14245, 3046, 4578, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3105, 3046, 63, 2180, 26, 437, 14245, 3046, 4578, 4104, 12, 13660, 314, 2436, 402, 282, 267, 9134, 11513, 626, 965, 9709, 2399, 14538 ]
[ 1898, 20312, 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, 6261, 1021, 367, 658, 7084, 2390, 64, 4104, 83, 315, 2833, 16310, 373, 18, 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, 900, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 3105, 63, 1430, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 199, 199, 3, 3758, 1568, 402, 1924, 15032, 3335, 334, 3248, 26, 1329, 402, 14245, 2390, 4104, 83, 680, 199, 3472, 63, 31749, 3038, 63, 10960, 63, 4305, 275, 5198, 421, 199, 533, 14245, 11770, 6261, 8, 785, 304, 523, 408, 33, 7060, 367, 21721, 10201, 4474, 14, 8051, 701, 2833, 16310, 373, 18, 1041, 819, 347, 636, 826, 721, 277, 12, 2049, 5461, 63, 1231, 12, 2049, 2833, 16310, 63, 1065, 63, 344, 12, 2049, 15032, 63, 2738, 63, 890, 29, 3472, 63, 31749, 3038, 63, 10960, 63, 4305, 304, 272, 408, 11493, 282, 14245, 11770, 6261, 909, 14, 339, 6944, 26, 9138, 314, 2011, 658, 2724, 63, 1231, 3559, 1006, 2251, 687, 642, 3787, 489, 911, 2376, 370, 314, 2011, 8793, 663, 402, 2211, 878, 14, 1010, 1163, 5932, 12, 2985, 489, 911, 2218, 370, 314, 2011, 663, 402, 3105, 4474, 1584, 315, 314, 658, 2724, 63, 1231, 64, 489, 4922, 14, 339, 3033, 26, 489, 5461, 63, 1231, 26, 710, 1738, 2082, 367, 5461, 316, 3105, 666, 14, 982, 658, 2724, 63, 1231, 64, 1630, 267, 440, 2187, 465, 282, 2082, 12, 652, 911, 506, 2737, 14, 489, 2833, 16310, 63, 1065, 63, 344, 26, 14245, 836, 3378, 2870, 14, 489, 15032, 63, 2738, 63, 890, 26, 14579, 402, 314, 15032, 3335, 367, 1924, 402, 314, 2877, 267, 6451, 13, 2407, 3105, 4474, 1584, 26, 543, 314, 2569, 19475, 26, 446, 881, 1275, 9416, 446, 1275, 2180, 63, 9416, 63, 28388, 982, 2695, 378, 12, 314, 15032, 13, 2738, 881, 5953, 911, 506, 282, 656, 1891, 379, 315, 314, 14701, 909, 14, 272, 408, 272, 340, 440, 5461, 63, 1231, 26, 489, 746, 1722, 480, 4699, 503, 488, 5461, 1738, 531, 272, 291, 423, 2724, 63, 1231, 275, 5461, 63, 1231, 272, 291, 423, 3249, 16310, 63, 1065, 63, 344, 275, 2833, 16310, 63, 1065, 63, 344, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 9346, 8, 277, 423, 2724, 63, 1231, 12, 291, 423, 3249, 16310, 63, 1065, 63, 344, 12, 3660, 15032, 63, 2738, 63, 890, 9, 819, 347, 6990, 2980, 1173, 8, 277, 12, 1350, 63, 493, 304, 272, 408, 3534, 282, 5800, 1173, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 1350, 63, 493, 26, 437, 5800, 1173, 4104, 12, 13660, 314, 1564, 402, 282, 1350, 570, 267, 28244, 315, 314, 6451, 402, 314, 3105, 3046, 9134, 2240, 14, 272, 408, 272, 327, 3254, 8, 696, 374, 304, 7910, 28037, 10238, 13712, 626, 23674, 562, 5466, 647, 14, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 1365, 63, 493, 29, 1365, 63, 493, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 2980, 1173, 8, 277, 423, 2724, 63, 1231, 12, 3105, 63, 1430, 9, 819, 347, 6990, 4851, 3160, 3007, 1304, 8, 277, 12, 3464, 63, 1943, 63, 1045, 63, 344, 304, 272, 408, 3534, 282, 13894, 3160, 3007, 1304, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3464, 63, 1943, 63, 1045, 63, 344, 26, 437, 13894, 3160, 3007, 1304, 4104, 12, 13660, 314, 1564, 282, 267, 3464, 2787, 28244, 315, 314, 6451, 402, 314, 3105, 3046, 9134, 267, 2240, 14, 272, 408, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 267, 3464, 63, 1943, 63, 1045, 63, 344, 29, 2340, 63, 1943, 63, 1045, 63, 344, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 4851, 3160, 3007, 1304, 8, 277, 423, 2724, 63, 1231, 12, 10028, 3105, 63, 1430, 9, 819, 347, 6990, 4578, 4619, 13921, 8, 277, 12, 3343, 63, 411, 63, 8782, 304, 272, 408, 3534, 282, 11513, 4619, 13921, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3343, 63, 411, 63, 8782, 26, 437, 11513, 4619, 13921, 4104, 12, 13660, 314, 2436, 402, 314, 267, 7143, 402, 376, 1687, 6272, 282, 9134, 11513, 14, 272, 408, 272, 3105, 63, 1430, 275, 3105, 63, 1430, 63, 3317, 18, 14, 7084, 2390, 8, 267, 3343, 63, 411, 63, 8782, 29, 2180, 63, 411, 63, 8782, 9, 272, 291, 423, 13913, 10239, 20201, 8, 1757, 63, 1430, 9, 272, 485, 647, 3823, 63, 1757, 63, 4368, 63, 5491, 14, 3534, 4578, 4619, 13921, 8, 277, 423, 2724, 63, 1231, 12, 9349, 3105, 63, 1430, 9, 819, 347, 6990, 7084, 3046, 4578, 8, 277, 12, 3105, 3046, 63, 2180, 304, 272, 408, 3534, 282, 14245, 3046, 4578, 4104, 543, 314, 7060, 14, 339, 3033, 26, 489, 3105, 3046, 63, 2180, 26, 437, 14245, 3046, 4578, 4104, 12, 13660, 314, 2436, 402, 282, 267, 9134, 11513, 626, 965, 9709, 2399, 14538, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aherlihy/mongo-python-driver
test/mod_wsgi_test/test_client.py
2
4815
# Copyright 2012-2015 MongoDB, 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. """Test client for mod_wsgi application, see bug PYTHON-353. """ import sys import threading import time from optparse import OptionParser try: from urllib2 import urlopen except ImportError: # Python 3. from urllib.request import urlopen try: import thread except ImportError: # Python 3. import _thread as thread def parse_args(): parser = OptionParser("""usage: %prog [options] mode url mode:\tparallel or serial""") # Should be enough that any connection leak will exhaust available file # descriptors. parser.add_option( "-n", "--nrequests", type="int", dest="nrequests", default=50 * 1000, help="Number of times to GET the URL, in total") parser.add_option( "-t", "--nthreads", type="int", dest="nthreads", default=100, help="Number of threads with mode 'parallel'") parser.add_option( "-q", "--quiet", action="store_false", dest="verbose", default=True, help="Don't print status messages to stdout") parser.add_option( "-c", "--continue", action="store_true", dest="continue_", default=False, help="Continue after HTTP errors") try: options, (mode, url) = parser.parse_args() except ValueError: parser.print_usage() sys.exit(1) if mode not in ('parallel', 'serial'): parser.print_usage() sys.exit(1) return options, mode, url def get(url): urlopen(url).read().strip() class URLGetterThread(threading.Thread): # Class variables. counter_lock = threading.Lock() counter = 0 def __init__(self, options, url, nrequests_per_thread): super(URLGetterThread, self).__init__() self.options = options self.url = url self.nrequests_per_thread = nrequests_per_thread self.errors = 0 def run(self): for i in range(self.nrequests_per_thread): try: get(url) except Exception as e: print(e) if not options.continue_: thread.interrupt_main() thread.exit() self.errors += 1 with URLGetterThread.counter_lock: URLGetterThread.counter += 1 counter = URLGetterThread.counter should_print = options.verbose and not counter % 1000 if should_print: print(counter) def main(options, mode, url): start_time = time.time() errors = 0 if mode == 'parallel': nrequests_per_thread = options.nrequests // options.nthreads if options.verbose: print ( 'Getting %s %s times total in %s threads, ' '%s times per thread' % ( url, nrequests_per_thread * options.nthreads, options.nthreads, nrequests_per_thread)) threads = [ URLGetterThread(options, url, nrequests_per_thread) for _ in range(options.nthreads) ] for t in threads: t.start() for t in threads: t.join() errors = sum([t.errors for t in threads]) nthreads_with_errors = len([t for t in threads if t.errors]) if nthreads_with_errors: print('%d threads had errors! %d errors in total' % ( nthreads_with_errors, errors)) else: assert mode == 'serial' if options.verbose: print('Getting %s %s times in one thread' % ( url, options.nrequests )) for i in range(1, options.nrequests + 1): try: get(url) except Exception as e: print(e) if not options.continue_: sys.exit(1) errors += 1 if options.verbose and not i % 1000: print(i) if errors: print('%d errors!' % errors) if options.verbose: print('Completed in %.2f seconds' % (time.time() - start_time)) if errors: # Failure sys.exit(1) if __name__ == '__main__': options, mode, url = parse_args() main(options, mode, url)
apache-2.0
[ 3, 1898, 6029, 13, 7806, 28458, 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, 624, 774, 1890, 367, 3413, 63, 6508, 4223, 12, 1937, 6519, 18280, 13, 15355, 14, 199, 624, 199, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 199, 504, 8691, 492, 13491, 199, 199, 893, 26, 272, 687, 4011, 18, 492, 18279, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 272, 687, 4011, 14, 1069, 492, 18279, 421, 199, 893, 26, 272, 492, 2462, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 272, 492, 485, 2671, 465, 2462, 421, 199, 318, 2198, 63, 589, 837, 272, 1798, 275, 13491, 4852, 3807, 26, 450, 6595, 359, 1419, 61, 818, 1166, 819, 818, 3427, 84, 11887, 503, 3012, 6141, 339, 327, 7719, 506, 8321, 626, 1263, 1950, 25831, 911, 21354, 833, 2808, 570, 272, 327, 15428, 14, 272, 1798, 14, 525, 63, 1422, 8, 267, 3905, 78, 401, 4320, 78, 6615, 401, 730, 628, 442, 401, 267, 2053, 628, 78, 6615, 401, 849, 29, 1400, 627, 5198, 12, 267, 1720, 628, 3259, 402, 5431, 370, 9576, 314, 2851, 12, 315, 3141, 531, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 84, 401, 4320, 78, 6962, 401, 730, 628, 442, 401, 267, 2053, 628, 78, 6962, 401, 849, 29, 1960, 12, 267, 1720, 628, 3259, 402, 7183, 543, 818, 283, 11887, 9859, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 81, 401, 4320, 10243, 401, 267, 1595, 628, 1617, 63, 3910, 401, 2053, 628, 3832, 401, 849, 29, 549, 12, 267, 1720, 628, 16932, 1133, 870, 2004, 3788, 370, 3839, 531, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 67, 401, 4320, 6958, 401, 267, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 6958, 29808, 849, 29, 797, 12, 267, 1720, 628, 24055, 2410, 3101, 2552, 531, 339, 862, 26, 267, 1511, 12, 334, 632, 12, 1166, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 871, 1722, 26, 267, 1798, 14, 1361, 63, 3807, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 818, 440, 315, 661, 11887, 297, 283, 2171, 735, 267, 1798, 14, 1361, 63, 3807, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 372, 1511, 12, 818, 12, 1166, 421, 199, 318, 664, 8, 633, 304, 272, 18279, 8, 633, 680, 739, 1252, 1913, 342, 421, 199, 533, 2851, 22038, 4436, 8, 12562, 14, 4436, 304, 272, 327, 8089, 2860, 14, 272, 7055, 63, 831, 275, 5796, 14, 6432, 342, 272, 7055, 275, 378, 339, 347, 636, 826, 721, 277, 12, 1511, 12, 1166, 12, 302, 6615, 63, 529, 63, 2671, 304, 267, 1613, 8, 2632, 22038, 4436, 12, 291, 2843, 826, 4533, 267, 291, 14, 1419, 275, 1511, 267, 291, 14, 633, 275, 1166, 267, 291, 14, 78, 6615, 63, 529, 63, 2671, 275, 302, 6615, 63, 529, 63, 2671, 267, 291, 14, 2550, 275, 378, 339, 347, 1255, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 277, 14, 78, 6615, 63, 529, 63, 2671, 304, 288, 862, 26, 355, 664, 8, 633, 9, 288, 871, 2186, 465, 325, 26, 355, 870, 8, 69, 9, 2234, 340, 440, 1511, 14, 6958, 10388, 490, 2462, 14, 20172, 63, 973, 342, 490, 2462, 14, 2224, 342, 2234, 291, 14, 2550, 847, 413, 953, 543, 2851, 22038, 4436, 14, 5337, 63, 831, 26, 355, 2851, 22038, 4436, 14, 5337, 847, 413, 355, 7055, 275, 2851, 22038, 4436, 14, 5337, 953, 1077, 63, 1361, 275, 1511, 14, 3832, 436, 440, 7055, 450, 5198, 953, 340, 1077, 63, 1361, 26, 355, 870, 8, 5337, 9, 421, 199, 318, 2446, 8, 1419, 12, 818, 12, 1166, 304, 272, 1343, 63, 521, 275, 900, 14, 521, 342, 272, 2552, 275, 378, 272, 340, 818, 508, 283, 11887, 356, 267, 302, 6615, 63, 529, 63, 2671, 275, 1511, 14, 78, 6615, 5001, 1511, 14, 78, 6962, 398, 340, 1511, 14, 3832, 26, 288, 870, 334, 355, 283, 28277, 450, 83, 450, 83, 5431, 3141, 315, 450, 83, 7183, 12, 283, 355, 1543, 83, 5431, 1126, 2462, 7, 450, 334, 490, 1166, 12, 302, 6615, 63, 529, 63, 2671, 627, 1511, 14, 78, 6962, 12, 490, 1511, 14, 78, 6962, 12, 302, 6615, 63, 529, 63, 2671, 430, 267, 7183, 275, 359, 288, 2851, 22038, 4436, 8, 1419, 12, 1166, 12, 302, 6615, 63, 529, 63, 2671, 9, 288, 367, 485, 315, 1425, 8, 1419, 14, 78, 6962, 9, 267, 1622, 398, 367, 307, 315, 7183, 26, 288, 307, 14, 928, 342, 398, 367, 307, 315, 7183, 26, 288, 307, 14, 904, 342, 398, 2552, 275, 3089, 779, 84, 14, 2550, 367, 307, 315, 7183, 566, 267, 302, 6962, 63, 1045, 63, 2550, 275, 822, 779, 84, 367, 307, 315, 7183, 340, 307, 14, 2550, 566, 267, 340, 302, 6962, 63, 1045, 63, 2550, 26, 288, 870, 3508, 68, 7183, 10530, 2552, 1, 450, 68, 2552, 315, 3141, 7, 450, 334, 355, 302, 6962, 63, 1045, 63, 2550, 12, 2552, 430, 272, 587, 26, 267, 702, 818, 508, 283, 2171, 7, 267, 340, 1511, 14, 3832, 26, 288, 870, 360, 28277, 450, 83, 450, 83, 5431, 315, 1373, 2462, 7, 450, 334, 355, 1166, 12, 1511, 14, 78, 6615, 288, 5082, 398, 367, 284, 315, 1425, 8, 17, 12, 1511, 14, 78, 6615, 435, 413, 304, 288, 862, 26, 355, 664, 8, 633, 9, 288, 871, 2186, 465, 325, 26, 355 ]
[ 1898, 6029, 13, 7806, 28458, 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, 624, 774, 1890, 367, 3413, 63, 6508, 4223, 12, 1937, 6519, 18280, 13, 15355, 14, 199, 624, 199, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 199, 504, 8691, 492, 13491, 199, 199, 893, 26, 272, 687, 4011, 18, 492, 18279, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 272, 687, 4011, 14, 1069, 492, 18279, 421, 199, 893, 26, 272, 492, 2462, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 272, 492, 485, 2671, 465, 2462, 421, 199, 318, 2198, 63, 589, 837, 272, 1798, 275, 13491, 4852, 3807, 26, 450, 6595, 359, 1419, 61, 818, 1166, 819, 818, 3427, 84, 11887, 503, 3012, 6141, 339, 327, 7719, 506, 8321, 626, 1263, 1950, 25831, 911, 21354, 833, 2808, 570, 272, 327, 15428, 14, 272, 1798, 14, 525, 63, 1422, 8, 267, 3905, 78, 401, 4320, 78, 6615, 401, 730, 628, 442, 401, 267, 2053, 628, 78, 6615, 401, 849, 29, 1400, 627, 5198, 12, 267, 1720, 628, 3259, 402, 5431, 370, 9576, 314, 2851, 12, 315, 3141, 531, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 84, 401, 4320, 78, 6962, 401, 730, 628, 442, 401, 267, 2053, 628, 78, 6962, 401, 849, 29, 1960, 12, 267, 1720, 628, 3259, 402, 7183, 543, 818, 283, 11887, 9859, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 81, 401, 4320, 10243, 401, 267, 1595, 628, 1617, 63, 3910, 401, 2053, 628, 3832, 401, 849, 29, 549, 12, 267, 1720, 628, 16932, 1133, 870, 2004, 3788, 370, 3839, 531, 339, 1798, 14, 525, 63, 1422, 8, 267, 3905, 67, 401, 4320, 6958, 401, 267, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 6958, 29808, 849, 29, 797, 12, 267, 1720, 628, 24055, 2410, 3101, 2552, 531, 339, 862, 26, 267, 1511, 12, 334, 632, 12, 1166, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 871, 1722, 26, 267, 1798, 14, 1361, 63, 3807, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 818, 440, 315, 661, 11887, 297, 283, 2171, 735, 267, 1798, 14, 1361, 63, 3807, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 372, 1511, 12, 818, 12, 1166, 421, 199, 318, 664, 8, 633, 304, 272, 18279, 8, 633, 680, 739, 1252, 1913, 342, 421, 199, 533, 2851, 22038, 4436, 8, 12562, 14, 4436, 304, 272, 327, 8089, 2860, 14, 272, 7055, 63, 831, 275, 5796, 14, 6432, 342, 272, 7055, 275, 378, 339, 347, 636, 826, 721, 277, 12, 1511, 12, 1166, 12, 302, 6615, 63, 529, 63, 2671, 304, 267, 1613, 8, 2632, 22038, 4436, 12, 291, 2843, 826, 4533, 267, 291, 14, 1419, 275, 1511, 267, 291, 14, 633, 275, 1166, 267, 291, 14, 78, 6615, 63, 529, 63, 2671, 275, 302, 6615, 63, 529, 63, 2671, 267, 291, 14, 2550, 275, 378, 339, 347, 1255, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 277, 14, 78, 6615, 63, 529, 63, 2671, 304, 288, 862, 26, 355, 664, 8, 633, 9, 288, 871, 2186, 465, 325, 26, 355, 870, 8, 69, 9, 2234, 340, 440, 1511, 14, 6958, 10388, 490, 2462, 14, 20172, 63, 973, 342, 490, 2462, 14, 2224, 342, 2234, 291, 14, 2550, 847, 413, 953, 543, 2851, 22038, 4436, 14, 5337, 63, 831, 26, 355, 2851, 22038, 4436, 14, 5337, 847, 413, 355, 7055, 275, 2851, 22038, 4436, 14, 5337, 953, 1077, 63, 1361, 275, 1511, 14, 3832, 436, 440, 7055, 450, 5198, 953, 340, 1077, 63, 1361, 26, 355, 870, 8, 5337, 9, 421, 199, 318, 2446, 8, 1419, 12, 818, 12, 1166, 304, 272, 1343, 63, 521, 275, 900, 14, 521, 342, 272, 2552, 275, 378, 272, 340, 818, 508, 283, 11887, 356, 267, 302, 6615, 63, 529, 63, 2671, 275, 1511, 14, 78, 6615, 5001, 1511, 14, 78, 6962, 398, 340, 1511, 14, 3832, 26, 288, 870, 334, 355, 283, 28277, 450, 83, 450, 83, 5431, 3141, 315, 450, 83, 7183, 12, 283, 355, 1543, 83, 5431, 1126, 2462, 7, 450, 334, 490, 1166, 12, 302, 6615, 63, 529, 63, 2671, 627, 1511, 14, 78, 6962, 12, 490, 1511, 14, 78, 6962, 12, 302, 6615, 63, 529, 63, 2671, 430, 267, 7183, 275, 359, 288, 2851, 22038, 4436, 8, 1419, 12, 1166, 12, 302, 6615, 63, 529, 63, 2671, 9, 288, 367, 485, 315, 1425, 8, 1419, 14, 78, 6962, 9, 267, 1622, 398, 367, 307, 315, 7183, 26, 288, 307, 14, 928, 342, 398, 367, 307, 315, 7183, 26, 288, 307, 14, 904, 342, 398, 2552, 275, 3089, 779, 84, 14, 2550, 367, 307, 315, 7183, 566, 267, 302, 6962, 63, 1045, 63, 2550, 275, 822, 779, 84, 367, 307, 315, 7183, 340, 307, 14, 2550, 566, 267, 340, 302, 6962, 63, 1045, 63, 2550, 26, 288, 870, 3508, 68, 7183, 10530, 2552, 1, 450, 68, 2552, 315, 3141, 7, 450, 334, 355, 302, 6962, 63, 1045, 63, 2550, 12, 2552, 430, 272, 587, 26, 267, 702, 818, 508, 283, 2171, 7, 267, 340, 1511, 14, 3832, 26, 288, 870, 360, 28277, 450, 83, 450, 83, 5431, 315, 1373, 2462, 7, 450, 334, 355, 1166, 12, 1511, 14, 78, 6615, 288, 5082, 398, 367, 284, 315, 1425, 8, 17, 12, 1511, 14, 78, 6615, 435, 413, 304, 288, 862, 26, 355, 664, 8, 633, 9, 288, 871, 2186, 465, 325, 26, 355, 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,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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 ]
alxgu/ansible-modules-core
network/vyos/vyos_config.py
25
8988
#!/usr/bin/python # # 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: vyos_config version_added: "2.2" author: "Peter Sprygada (@privateip)" short_description: Manage VyOS configuration on remote device description: - This module provides configuration file management of VyOS devices. It provides arguments for managing both the configuration file and state of the active configuration. All configuration statements are based on `set` and `delete` commands in the device configuration. extends_documentation_fragment: vyos options: lines: description: - The ordered set of configuration lines to be managed and compared with the existing configuration on the remote device. required: false default: null src: description: - The C(src) argument specifies the path to the source config file to load. The source config file can either be in bracket format or set format. The source file can include Jinja2 template variables. required: no default: null match: description: - The C(match) argument controls the method used to match against the current active configuration. By default, the desired config is matched against the active config and the deltas are loaded. If the C(match) argument is set to C(none) the active configuration is ignored and the configuration is always loaded. required: false default: line choices: ['line', 'none'] backup: description: - The C(backup) argument will backup the current devices active configuration to the Ansible control host prior to making any changes. The backup file will be located in the backup folder in the root of the playbook required: false default: false choices: ['yes', 'no'] comment: description: - Allows a commit description to be specified to be included when the configuration is committed. If the configuration is not changed or committed, this argument is ignored. required: false default: 'configured by vyos_config' config: description: - The C(config) argument specifies the base configuration to use to compare against the desired configuration. If this value is not specified, the module will automatically retrieve the current active configuration from the remote device. required: false default: null save: description: - The C(save) argument controls whether or not changes made to the active configuration are saved to disk. This is independent of committing the config. When set to True, the active configuration is saved. required: false default: false choices: ['yes', 'no'] """ RETURN = """ updates: description: The list of configuration commands sent to the device returned: always type: list sample: ['...', '...'] filtered: description: The list of configuration commands removed to avoid a load failure returned: always type: list sample: ['...', '...'] """ EXAMPLES = """ # Note: examples below use the following provider dict to handle # transport and authentication to the node. vars: cli: host: "{{ inventory_hostname }}" username: vyos password: vyos transport: cli - name: configure the remote device vyos_config: lines: - set system host-name {{ inventory_hostname }} - set service lldp - delete service dhcp-server provider: "{{ cli }}" - name: backup and load from file vyos_config: src: vyos.cfg backup: yes provider: "{{ cli }}" """ import re from ansible.module_utils.network import Command, get_exception from ansible.module_utils.netcfg import NetworkConfig, dumps from ansible.module_utils.vyos import NetworkModule, NetworkError DEFAULT_COMMENT = 'configured by vyos_config' CONFIG_FILTERS = [ re.compile(r'set system login user \S+ authentication encrypted-password') ] def config_to_commands(config): set_format = config.startswith('set') or config.startswith('delete') candidate = NetworkConfig(indent=4, contents=config, device_os='junos') if not set_format: candidate = [c.line for c in candidate.items] commands = list() # this filters out less specific lines for item in candidate: for index, entry in enumerate(commands): if item.startswith(entry): del commands[index] break commands.append(item) else: commands = str(candidate).split('\n') return commands def get_config(module, result): contents = module.params['config'] if not contents: contents = module.config.get_config(output='set').split('\n') else: contents = config_to_commands(contents) return contents def get_candidate(module): contents = module.params['src'] or module.params['lines'] if module.params['lines']: contents = '\n'.join(contents) return config_to_commands(contents) def diff_config(commands, config): config = [str(c).replace("'", '') for c in config] updates = list() visited = set() for line in commands: item = str(line).replace("'", '') if not item.startswith('set') and not item.startswith('delete'): raise ValueError('line must start with either `set` or `delete`') elif item.startswith('set') and item not in config: updates.append(line) elif item.startswith('delete'): if not config: updates.append(line) else: item = re.sub(r'delete', 'set', item) for entry in config: if entry.startswith(item) and line not in visited: updates.append(line) visited.add(line) return list(updates) def sanitize_config(config, result): result['filtered'] = list() for regex in CONFIG_FILTERS: for index, line in enumerate(list(config)): if regex.search(line): result['filtered'].append(line) del config[index] def load_config(module, commands, result): comment = module.params['comment'] commit = not module.check_mode save = module.params['save'] # sanitize loadable config to remove items that will fail # remove items will be returned in the sanitized keyword # in the result. sanitize_config(commands, result) diff = module.config.load_config(commands, commit=commit, comment=comment, save=save) if diff: result['diff'] = dict(prepared=diff) result['changed'] = True def run(module, result): # get the current active config from the node or passed in via # the config param config = get_config(module, result) # create the candidate config object from the arguments candidate = get_candidate(module) # create loadable config that includes only the configuration updates updates = diff_config(candidate, config) result['updates'] = updates load_config(module, updates, result) if result.get('filtered'): result['warnings'].append('Some configuration commands where ' 'removed, please see the filtered key') def main(): argument_spec = dict( src=dict(type='path'), lines=dict(type='list'), match=dict(default='line', choices=['line', 'none']), comment=dict(default=DEFAULT_COMMENT), config=dict(), backup=dict(default=False, type='bool'), save=dict(default=False, type='bool'), ) mutually_exclusive = [('lines', 'src')] module = NetworkModule(argument_spec=argument_spec, connect_on_load=False, mutually_exclusive=mutually_exclusive, supports_check_mode=True) result = dict(changed=False) if module.params['backup']: result['__backup__'] = module.config.get_config() try: run(module, result) except NetworkError: exc = get_exception() module.fail_json(msg=str(exc), **exc.kwargs) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 31766, 736, 63, 888, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 8070, 351, 8360, 651, 71, 10641, 8593, 4239, 711, 2924, 199, 3612, 63, 1802, 26, 14944, 812, 89, 3100, 2897, 641, 3982, 2243, 199, 1802, 26, 523, 446, 961, 859, 6571, 2897, 570, 10041, 402, 812, 89, 3100, 272, 7256, 14, 221, 2779, 6571, 2368, 367, 28453, 3865, 314, 272, 2897, 570, 436, 1174, 402, 314, 4702, 2897, 14, 257, 2900, 272, 2897, 9834, 787, 4079, 641, 658, 409, 64, 436, 658, 1807, 64, 3718, 272, 315, 314, 2243, 2897, 14, 199, 11036, 63, 9970, 63, 7677, 26, 31766, 736, 199, 1419, 26, 523, 2385, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 2897, 2385, 370, 506, 12883, 436, 267, 13524, 543, 314, 3411, 2897, 641, 314, 3982, 267, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2928, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 2164, 9, 1423, 9314, 314, 931, 370, 314, 1350, 1101, 267, 570, 370, 2248, 14, 221, 710, 1350, 1101, 570, 883, 1902, 506, 315, 267, 14540, 1475, 503, 663, 1475, 14, 221, 710, 1350, 570, 883, 2387, 267, 17300, 18, 1978, 2860, 14, 272, 1415, 26, 949, 272, 849, 26, 2973, 523, 1336, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 1431, 9, 1423, 13467, 314, 1083, 1202, 370, 1336, 267, 6169, 314, 1453, 4702, 2897, 14, 221, 4885, 849, 12, 314, 267, 6387, 1101, 365, 7838, 6169, 314, 4702, 1101, 436, 314, 267, 27446, 787, 6511, 14, 221, 982, 314, 445, 8, 1431, 9, 1423, 365, 663, 370, 445, 8, 3592, 9, 267, 314, 4702, 2897, 365, 5525, 436, 314, 2897, 365, 267, 3544, 6511, 14, 272, 1415, 26, 3055, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 3592, 418, 523, 6902, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 5751, 9, 1423, 911, 6902, 314, 1453, 7256, 4702, 267, 2897, 370, 314, 2622, 3304, 1591, 6791, 370, 10663, 1263, 267, 4493, 14, 221, 710, 6902, 570, 911, 506, 16180, 315, 314, 6902, 4922, 267, 315, 314, 1738, 402, 314, 15695, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 3415, 26, 788, 5066, 297, 283, 889, 418, 523, 3721, 26, 272, 1369, 26, 489, 446, 22819, 282, 5532, 1369, 370, 506, 2013, 370, 506, 5120, 267, 1380, 314, 2897, 365, 27659, 14, 221, 982, 314, 2897, 365, 267, 440, 2896, 503, 27659, 12, 642, 1423, 365, 5525, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 11786, 701, 31766, 736, 63, 888, 7, 523, 1101, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 888, 9, 1423, 9314, 314, 1300, 2897, 370, 675, 267, 370, 6540, 6169, 314, 6387, 2897, 14, 221, 982, 642, 574, 267, 365, 440, 2013, 12, 314, 859, 911, 5847, 8044, 314, 267, 1453, 4702, 2897, 687, 314, 3982, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3354, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 2117, 9, 1423, 13467, 3775, 503, 440, 4493, 6326, 267, 370, 314, 4702, 2897, 787, 6290, 370, 4543, 14, 221, 961, 365, 267, 12717, 402, 5532, 1337, 314, 1101, 14, 221, 3979, 663, 370, 715, 12, 314, 267, 4702, 2897, 365, 6290, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 3415, 26, 788, 5066, 297, 283, 889, 418, 199, 624, 199, 199, 9677, 275, 408, 199, 7618, 26, 523, 1369, 26, 710, 769, 402, 2897, 3718, 4847, 370, 314, 2243, 523, 2138, 26, 3544, 523, 730, 26, 769, 523, 2690, 26, 788, 20833, 24352, 418, 199, 11142, 26, 523, 1369, 26, 710, 769, 402, 2897, 3718, 4829, 370, 5126, 282, 2248, 5988, 523, 2138, 26, 3544, 523, 730, 26, 769, 523, 2690, 26, 788, 20833, 24352, 418, 199, 624, 199, 199, 8918, 275, 408, 199, 3, 3390, 26, 7251, 5084, 675, 314, 2569, 5022, 1211, 370, 2429, 199, 3, 755, 7773, 436, 6299, 370, 314, 1031, 14, 199, 2936, 26, 523, 5053, 26, 272, 1591, 26, 7370, 8200, 63, 4269, 7820, 272, 3434, 26, 31766, 736, 272, 2505, 26, 31766, 736, 272, 7773, 26, 5053, 199, 199, 13, 536, 26, 7908, 314, 3982, 2243, 523, 31766, 736, 63, 888, 26, 272, 2385, 26, 489, 446, 663, 2656, 1591, 13, 354, 8448, 8200, 63, 4269, 3586, 489, 446, 663, 2435, 28768, 489, 446, 3145, 2435, 19064, 13, 1000, 272, 5022, 26, 7370, 5053, 7820, 199, 199, 13, 536, 26, 6902, 436, 2248, 687, 570, 523, 31766, 736, 63, 888, 26, 272, 2928, 26, 31766, 736, 14, 4128, 272, 6902, 26, 9456, 272, 5022, 26, 7370, 5053, 7820, 199, 624, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 492, 5817, 12, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 4128, 492, 7220, 2028, 12, 16864, 199, 504, 3242, 14, 578, 63, 1208, 14, 16091, 736, 492, 7220, 2377, 12, 7220, 547, 421, 199, 3472, 63, 10973, 275, 283, 11786, 701, 31766, 736, 63, 888, 7, 199, 199, 5569, 63, 9905, 51, 275, 359, 272, 295, 14, 2014, 8 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 31766, 736, 63, 888, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 8070, 351, 8360, 651, 71, 10641, 8593, 4239, 711, 2924, 199, 3612, 63, 1802, 26, 14944, 812, 89, 3100, 2897, 641, 3982, 2243, 199, 1802, 26, 523, 446, 961, 859, 6571, 2897, 570, 10041, 402, 812, 89, 3100, 272, 7256, 14, 221, 2779, 6571, 2368, 367, 28453, 3865, 314, 272, 2897, 570, 436, 1174, 402, 314, 4702, 2897, 14, 257, 2900, 272, 2897, 9834, 787, 4079, 641, 658, 409, 64, 436, 658, 1807, 64, 3718, 272, 315, 314, 2243, 2897, 14, 199, 11036, 63, 9970, 63, 7677, 26, 31766, 736, 199, 1419, 26, 523, 2385, 26, 272, 1369, 26, 489, 446, 710, 7741, 663, 402, 2897, 2385, 370, 506, 12883, 436, 267, 13524, 543, 314, 3411, 2897, 641, 314, 3982, 267, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2928, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 2164, 9, 1423, 9314, 314, 931, 370, 314, 1350, 1101, 267, 570, 370, 2248, 14, 221, 710, 1350, 1101, 570, 883, 1902, 506, 315, 267, 14540, 1475, 503, 663, 1475, 14, 221, 710, 1350, 570, 883, 2387, 267, 17300, 18, 1978, 2860, 14, 272, 1415, 26, 949, 272, 849, 26, 2973, 523, 1336, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 1431, 9, 1423, 13467, 314, 1083, 1202, 370, 1336, 267, 6169, 314, 1453, 4702, 2897, 14, 221, 4885, 849, 12, 314, 267, 6387, 1101, 365, 7838, 6169, 314, 4702, 1101, 436, 314, 267, 27446, 787, 6511, 14, 221, 982, 314, 445, 8, 1431, 9, 1423, 365, 663, 370, 445, 8, 3592, 9, 267, 314, 4702, 2897, 365, 5525, 436, 314, 2897, 365, 267, 3544, 6511, 14, 272, 1415, 26, 3055, 272, 849, 26, 1004, 272, 3415, 26, 788, 604, 297, 283, 3592, 418, 523, 6902, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 5751, 9, 1423, 911, 6902, 314, 1453, 7256, 4702, 267, 2897, 370, 314, 2622, 3304, 1591, 6791, 370, 10663, 1263, 267, 4493, 14, 221, 710, 6902, 570, 911, 506, 16180, 315, 314, 6902, 4922, 267, 315, 314, 1738, 402, 314, 15695, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 3415, 26, 788, 5066, 297, 283, 889, 418, 523, 3721, 26, 272, 1369, 26, 489, 446, 22819, 282, 5532, 1369, 370, 506, 2013, 370, 506, 5120, 267, 1380, 314, 2897, 365, 27659, 14, 221, 982, 314, 2897, 365, 267, 440, 2896, 503, 27659, 12, 642, 1423, 365, 5525, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 11786, 701, 31766, 736, 63, 888, 7, 523, 1101, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 888, 9, 1423, 9314, 314, 1300, 2897, 370, 675, 267, 370, 6540, 6169, 314, 6387, 2897, 14, 221, 982, 642, 574, 267, 365, 440, 2013, 12, 314, 859, 911, 5847, 8044, 314, 267, 1453, 4702, 2897, 687, 314, 3982, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3354, 26, 272, 1369, 26, 489, 446, 710, 445, 8, 2117, 9, 1423, 13467, 3775, 503, 440, 4493, 6326, 267, 370, 314, 4702, 2897, 787, 6290, 370, 4543, 14, 221, 961, 365, 267, 12717, 402, 5532, 1337, 314, 1101, 14, 221, 3979, 663, 370, 715, 12, 314, 267, 4702, 2897, 365, 6290, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 3415, 26, 788, 5066, 297, 283, 889, 418, 199, 624, 199, 199, 9677, 275, 408, 199, 7618, 26, 523, 1369, 26, 710, 769, 402, 2897, 3718, 4847, 370, 314, 2243, 523, 2138, 26, 3544, 523, 730, 26, 769, 523, 2690, 26, 788, 20833, 24352, 418, 199, 11142, 26, 523, 1369, 26, 710, 769, 402, 2897, 3718, 4829, 370, 5126, 282, 2248, 5988, 523, 2138, 26, 3544, 523, 730, 26, 769, 523, 2690, 26, 788, 20833, 24352, 418, 199, 624, 199, 199, 8918, 275, 408, 199, 3, 3390, 26, 7251, 5084, 675, 314, 2569, 5022, 1211, 370, 2429, 199, 3, 755, 7773, 436, 6299, 370, 314, 1031, 14, 199, 2936, 26, 523, 5053, 26, 272, 1591, 26, 7370, 8200, 63, 4269, 7820, 272, 3434, 26, 31766, 736, 272, 2505, 26, 31766, 736, 272, 7773, 26, 5053, 199, 199, 13, 536, 26, 7908, 314, 3982, 2243, 523, 31766, 736, 63, 888, 26, 272, 2385, 26, 489, 446, 663, 2656, 1591, 13, 354, 8448, 8200, 63, 4269, 3586, 489, 446, 663, 2435, 28768, 489, 446, 3145, 2435, 19064, 13, 1000, 272, 5022, 26, 7370, 5053, 7820, 199, 199, 13, 536, 26, 6902, 436, 2248, 687, 570, 523, 31766, 736, 63, 888, 26, 272, 2928, 26, 31766, 736, 14, 4128, 272, 6902, 26, 9456, 272, 5022, 26, 7370, 5053, 7820, 199, 624, 199, 646, 295, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 492, 5817, 12, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 4128, 492, 7220, 2028, 12, 16864, 199, 504, 3242, 14, 578, 63, 1208, 14, 16091, 736, 492, 7220, 2377, 12, 7220, 547, 421, 199, 3472, 63, 10973, 275, 283, 11786, 701, 31766, 736, 63, 888, 7, 199, 199, 5569, 63, 9905, 51, 275, 359, 272, 295, 14, 2014, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import time from openerp.osv import fields, osv from openerp import api class account_analytic_default(osv.osv): _name = "account.analytic.default" _description = "Analytic Distribution" _rec_name = "analytic_id" _order = "sequence" _columns = { 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of analytic distribution"), 'analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), 'product_id': fields.many2one('product.product', 'Product', ondelete='cascade', help="Select a product which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)"), 'partner_id': fields.many2one('res.partner', 'Partner', ondelete='cascade', help="Select a partner which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this partner, it will automatically take this as an analytic account)"), 'user_id': fields.many2one('res.users', 'User', ondelete='cascade', help="Select a user which will use analytic account specified in analytic default."), 'company_id': fields.many2one('res.company', 'Company', ondelete='cascade', help="Select a company which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this company, it will automatically take this as an analytic account)"), 'date_start': fields.date('Start Date', help="Default start date for this Analytic Account."), 'date_stop': fields.date('End Date', help="Default end date for this Analytic Account."), } def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, company_id=None, context=None): domain = [] if product_id: domain += ['|', ('product_id', '=', product_id)] domain += [('product_id','=', False)] if partner_id: domain += ['|', ('partner_id', '=', partner_id)] domain += [('partner_id', '=', False)] if company_id: domain += ['|', ('company_id', '=', company_id)] domain += [('company_id', '=', False)] if user_id: domain += ['|',('user_id', '=', user_id)] domain += [('user_id','=', False)] if date: domain += ['|', ('date_start', '<=', date), ('date_start', '=', False)] domain += ['|', ('date_stop', '>=', date), ('date_stop', '=', False)] best_index = -1 res = False for rec in self.browse(cr, uid, self.search(cr, uid, domain, context=context), context=context): index = 0 if rec.product_id: index += 1 if rec.partner_id: index += 1 if rec.company_id: index += 1 if rec.user_id: index += 1 if rec.date_start: index += 1 if rec.date_stop: index += 1 if index > best_index: res = rec best_index = index return res class account_invoice_line(osv.osv): _inherit = "account.invoice.line" _description = "Invoice Line" @api.onchange('product_id') def _onchange_product_id(self): res = super(account_invoice_line, self)._onchange_product_id() rec = self.env['account.analytic.default'].account_get(self.product_id.id, self.invoice_id.partner_id.id, self._uid, time.strftime('%Y-%m-%d'), company_id=self.company_id.id, context=self._context) if rec: self.account_analytic_id = rec.analytic_id.id else: self.account_analytic_id = False return res class stock_picking(osv.osv): _inherit = "stock.picking" def _get_account_analytic_invoice(self, cursor, user, picking, move_line): partner_id = picking.partner_id and picking.partner_id.id or False rec = self.pool.get('account.analytic.default').account_get(cursor, user, move_line.product_id.id, partner_id, user, time.strftime('%Y-%m-%d')) if rec: return rec.analytic_id.id return super(stock_picking, self)._get_account_analytic_invoice(cursor, user, picking, move_line) class sale_order_line(osv.osv): _inherit = "sale.order.line" @api.multi def _prepare_invoice_line(self, qty): res = super(sale_order_line, self)._prepare_invoice_line(qty) default_analytic_account = self.env['account.analytic.default'].account_get(self.product_id.id, self.order_id.partner_id.id, self.order_id.user_id.id, time.strftime('%Y-%m-%d')) if default_analytic_account: res.update({'account_analytic_id': default_analytic_account.analytic_id.id}) return res class product_product(osv.Model): _inherit = 'product.product' def _rules_count(self, cr, uid, ids, field_name, arg, context=None): Analytic = self.pool['account.analytic.default'] return { product_id: Analytic.search_count(cr, uid, [('product_id', '=', product_id)], context=context) for product_id in ids } _columns = { 'rules_count': fields.function(_rules_count, string='# Analytic Rules', type='integer'), } class product_template(osv.Model): _inherit = 'product.template' def _rules_count(self, cr, uid, ids, field_name, arg, context=None): Analytic = self.pool['account.analytic.default'] res = {} for product_tmpl_id in self.browse(cr, uid, ids, context=context): res[product_tmpl_id.id] = sum([p.rules_count for p in product_tmpl_id.product_variant_ids]) return res _columns = { 'rules_count': fields.function(_rules_count, string='# Analytic Rules', type='integer'), } def action_view_rules(self, cr, uid, ids, context=None): products = self._get_products(cr, uid, ids, context=context) result = self._get_act_window_dict(cr, uid, 'account_analytic_default.action_product_default_list', context=context) result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" # Remove context so it is not going to filter on product_id with active_id of template result['context'] = "{}" return result
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 199, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 492, 2986, 199, 199, 533, 2933, 63, 9782, 63, 885, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 9782, 14, 885, 2, 272, 485, 1802, 275, 298, 8014, 764, 11839, 2, 272, 485, 2761, 63, 354, 275, 298, 9782, 63, 344, 2, 272, 485, 1648, 275, 298, 4041, 2, 272, 485, 3406, 275, 469, 267, 283, 4041, 356, 1504, 14, 4115, 360, 5826, 297, 1720, 628, 39, 7602, 314, 3414, 1865, 1380, 20589, 282, 769, 402, 20705, 4084, 1288, 267, 283, 9782, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9782, 14, 2048, 297, 283, 8014, 764, 9973, 659, 267, 283, 2558, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 2558, 297, 283, 5884, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 3336, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 3336, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 5854, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 5854, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 922, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 7651, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 7233, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 7233, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 602, 63, 928, 356, 1504, 14, 602, 360, 3162, 6148, 297, 1720, 628, 2698, 1343, 1434, 367, 642, 14279, 764, 9973, 7651, 267, 283, 602, 63, 2379, 356, 1504, 14, 602, 360, 3005, 6148, 297, 1720, 628, 2698, 1284, 1434, 367, 642, 14279, 764, 9973, 7651, 272, 789, 339, 347, 2933, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 3336, 63, 344, 29, 403, 12, 5854, 63, 344, 29, 403, 12, 922, 63, 344, 29, 403, 12, 1434, 29, 403, 12, 7233, 63, 344, 29, 403, 12, 1067, 29, 403, 304, 267, 2881, 275, 942, 267, 340, 3336, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 2558, 63, 344, 297, 6291, 3336, 63, 344, 1874, 267, 2881, 847, 4274, 2558, 63, 344, 18937, 756, 1874, 267, 340, 5854, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 3899, 63, 344, 297, 6291, 5854, 63, 344, 1874, 267, 2881, 847, 4274, 3899, 63, 344, 297, 6291, 756, 1874, 267, 340, 7233, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 4627, 63, 344, 297, 6291, 7233, 63, 344, 1874, 267, 2881, 847, 4274, 4627, 63, 344, 297, 6291, 756, 1874, 267, 340, 922, 63, 344, 26, 288, 2881, 847, 788, 26320, 360, 751, 63, 344, 297, 6291, 922, 63, 344, 1874, 267, 2881, 847, 4274, 751, 63, 344, 18937, 756, 1874, 267, 340, 1434, 26, 288, 2881, 847, 788, 26320, 661, 602, 63, 928, 297, 2650, 4009, 1434, 395, 661, 602, 63, 928, 297, 6291, 756, 1874, 288, 2881, 847, 788, 26320, 661, 602, 63, 2379, 297, 12696, 4009, 1434, 395, 661, 602, 63, 2379, 297, 6291, 756, 1874, 267, 5526, 63, 1080, 275, 446, 17, 267, 522, 275, 756, 267, 367, 6488, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 1733, 8, 1556, 12, 1747, 12, 2881, 12, 1067, 29, 1100, 395, 1067, 29, 1100, 304, 288, 1478, 275, 378, 288, 340, 6488, 14, 2558, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 3899, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 4627, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 751, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 602, 63, 928, 26, 1478, 847, 413, 288, 340, 6488, 14, 602, 63, 2379, 26, 1478, 847, 413, 288, 340, 1478, 690, 5526, 63, 1080, 26, 355, 522, 275, 6488, 355, 5526, 63, 1080, 275, 1478, 267, 372, 522, 421, 199, 533, 2933, 63, 5404, 63, 604, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 2048, 14, 5404, 14, 604, 2, 272, 485, 1802, 275, 298, 21092, 7030, 2, 339, 768, 1246, 14, 18128, 360, 2558, 63, 344, 358, 272, 347, 485, 18128, 63, 2558, 63, 344, 8, 277, 304, 267, 522, 275, 1613, 8, 2048, 63, 5404, 63, 604, 12, 291, 10445, 18128, 63, 2558, 63, 344, 342, 267, 6488, 275, 291, 14, 1813, 459, 2048, 14, 9782, 14, 885, 2278, 2048, 63, 362, 8, 277, 14, 2558, 63, 344, 14, 344, 12, 291, 14, 5404, 63, 344, 14, 3899, 63, 344, 14, 344, 12, 291, 423, 1535, 12, 18295, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 659, 7233, 63, 344, 29, 277, 14, 4627, 63, 344, 14, 344, 12, 1067, 29, 277, 423, 1100, 9, 267, 340, 6488, 26, 288, 291, 14, 2048, 63, 9782, 63, 344, 275, 6488, 14, 9782, 63, 344, 14, 344, 267, 587, 26, 288, 291, 14, 2048, 63, 9782, 63, 344, 275, 756, 267, 372, 522, 421, 199, 533, 10952, 63, 11463, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 6088, 14, 11463, 2, 339, 347, 485, 362, 63, 2048, 63, 9782, 63, 5404, 8, 277, 12, 3920, 12, 922, 12, 12433, 12, 4057, 63, 604, 304, 267, 5854, 63, 344, 275, 12433, 14, 3899, 63, 344, 436, 12433, 14, 3899, 63, 344 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 199, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 492, 2986, 199, 199, 533, 2933, 63, 9782, 63, 885, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 2048, 14, 9782, 14, 885, 2, 272, 485, 1802, 275, 298, 8014, 764, 11839, 2, 272, 485, 2761, 63, 354, 275, 298, 9782, 63, 344, 2, 272, 485, 1648, 275, 298, 4041, 2, 272, 485, 3406, 275, 469, 267, 283, 4041, 356, 1504, 14, 4115, 360, 5826, 297, 1720, 628, 39, 7602, 314, 3414, 1865, 1380, 20589, 282, 769, 402, 20705, 4084, 1288, 267, 283, 9782, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 9782, 14, 2048, 297, 283, 8014, 764, 9973, 659, 267, 283, 2558, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2558, 14, 2558, 297, 283, 5884, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 3336, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 3336, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 5854, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 5854, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 751, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 922, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 7651, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 16549, 534, 15377, 297, 1720, 628, 5446, 282, 7233, 1314, 911, 675, 20705, 2933, 2013, 315, 20705, 849, 334, 69, 14, 71, 14, 1218, 892, 15229, 8485, 503, 428, 7098, 1865, 340, 781, 3504, 642, 7233, 12, 652, 911, 5847, 5452, 642, 465, 376, 20705, 2933, 13185, 267, 283, 602, 63, 928, 356, 1504, 14, 602, 360, 3162, 6148, 297, 1720, 628, 2698, 1343, 1434, 367, 642, 14279, 764, 9973, 7651, 267, 283, 602, 63, 2379, 356, 1504, 14, 602, 360, 3005, 6148, 297, 1720, 628, 2698, 1284, 1434, 367, 642, 14279, 764, 9973, 7651, 272, 789, 339, 347, 2933, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 3336, 63, 344, 29, 403, 12, 5854, 63, 344, 29, 403, 12, 922, 63, 344, 29, 403, 12, 1434, 29, 403, 12, 7233, 63, 344, 29, 403, 12, 1067, 29, 403, 304, 267, 2881, 275, 942, 267, 340, 3336, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 2558, 63, 344, 297, 6291, 3336, 63, 344, 1874, 267, 2881, 847, 4274, 2558, 63, 344, 18937, 756, 1874, 267, 340, 5854, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 3899, 63, 344, 297, 6291, 5854, 63, 344, 1874, 267, 2881, 847, 4274, 3899, 63, 344, 297, 6291, 756, 1874, 267, 340, 7233, 63, 344, 26, 288, 2881, 847, 788, 26320, 661, 4627, 63, 344, 297, 6291, 7233, 63, 344, 1874, 267, 2881, 847, 4274, 4627, 63, 344, 297, 6291, 756, 1874, 267, 340, 922, 63, 344, 26, 288, 2881, 847, 788, 26320, 360, 751, 63, 344, 297, 6291, 922, 63, 344, 1874, 267, 2881, 847, 4274, 751, 63, 344, 18937, 756, 1874, 267, 340, 1434, 26, 288, 2881, 847, 788, 26320, 661, 602, 63, 928, 297, 2650, 4009, 1434, 395, 661, 602, 63, 928, 297, 6291, 756, 1874, 288, 2881, 847, 788, 26320, 661, 602, 63, 2379, 297, 12696, 4009, 1434, 395, 661, 602, 63, 2379, 297, 6291, 756, 1874, 267, 5526, 63, 1080, 275, 446, 17, 267, 522, 275, 756, 267, 367, 6488, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 1733, 8, 1556, 12, 1747, 12, 2881, 12, 1067, 29, 1100, 395, 1067, 29, 1100, 304, 288, 1478, 275, 378, 288, 340, 6488, 14, 2558, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 3899, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 4627, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 751, 63, 344, 26, 1478, 847, 413, 288, 340, 6488, 14, 602, 63, 928, 26, 1478, 847, 413, 288, 340, 6488, 14, 602, 63, 2379, 26, 1478, 847, 413, 288, 340, 1478, 690, 5526, 63, 1080, 26, 355, 522, 275, 6488, 355, 5526, 63, 1080, 275, 1478, 267, 372, 522, 421, 199, 533, 2933, 63, 5404, 63, 604, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 2048, 14, 5404, 14, 604, 2, 272, 485, 1802, 275, 298, 21092, 7030, 2, 339, 768, 1246, 14, 18128, 360, 2558, 63, 344, 358, 272, 347, 485, 18128, 63, 2558, 63, 344, 8, 277, 304, 267, 522, 275, 1613, 8, 2048, 63, 5404, 63, 604, 12, 291, 10445, 18128, 63, 2558, 63, 344, 342, 267, 6488, 275, 291, 14, 1813, 459, 2048, 14, 9782, 14, 885, 2278, 2048, 63, 362, 8, 277, 14, 2558, 63, 344, 14, 344, 12, 291, 14, 5404, 63, 344, 14, 3899, 63, 344, 14, 344, 12, 291, 423, 1535, 12, 18295, 900, 14, 6205, 3508, 57, 3295, 77, 3295, 68, 659, 7233, 63, 344, 29, 277, 14, 4627, 63, 344, 14, 344, 12, 1067, 29, 277, 423, 1100, 9, 267, 340, 6488, 26, 288, 291, 14, 2048, 63, 9782, 63, 344, 275, 6488, 14, 9782, 63, 344, 14, 344, 267, 587, 26, 288, 291, 14, 2048, 63, 9782, 63, 344, 275, 756, 267, 372, 522, 421, 199, 533, 10952, 63, 11463, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 6088, 14, 11463, 2, 339, 347, 485, 362, 63, 2048, 63, 9782, 63, 5404, 8, 277, 12, 3920, 12, 922, 12, 12433, 12, 4057, 63, 604, 304, 267, 5854, 63, 344, 275, 12433, 14, 3899, 63, 344, 436, 12433, 14, 3899, 63, 344, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gautamMalu/rootfs_xen_arndale
usr/lib/python2.7/Cookie.py
1
26311
#### # Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu> # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Timothy O'Malley not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS # SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR # ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # #### # # Id: Cookie.py,v 2.29 2000/08/23 05:28:49 timo Exp # by Timothy O'Malley <timo@alum.mit.edu> # # Cookie.py is a Python module for the handling of HTTP # cookies as a Python dictionary. See RFC 2109 for more # information on cookies. # # The original idea to treat Cookies as a dictionary came from # Dave Mitchell (davem@magnet.com) in 1995, when he released the # first version of nscookie.py. # #### r""" Here's a sample session to show how to use this module. At the moment, this is the only documentation. The Basics ---------- Importing is easy.. >>> import Cookie Most of the time you start by creating a cookie. Cookies come in three flavors, each with slightly different encoding semantics, but more on that later. >>> C = Cookie.SimpleCookie() >>> C = Cookie.SerialCookie() >>> C = Cookie.SmartCookie() [Note: Long-time users of Cookie.py will remember using Cookie.Cookie() to create a Cookie object. Although deprecated, it is still supported by the code. See the Backward Compatibility notes for more information.] Once you've created your Cookie, you can add values just as if it were a dictionary. >>> C = Cookie.SmartCookie() >>> C["fig"] = "newton" >>> C["sugar"] = "wafer" >>> C.output() 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer' Notice that the printable representation of a Cookie is the appropriate format for a Set-Cookie: header. This is the default behavior. You can change the header and printed attributes by using the .output() function >>> C = Cookie.SmartCookie() >>> C["rocky"] = "road" >>> C["rocky"]["path"] = "/cookie" >>> print C.output(header="Cookie:") Cookie: rocky=road; Path=/cookie >>> print C.output(attrs=[], header="Cookie:") Cookie: rocky=road The load() method of a Cookie extracts cookies from a string. In a CGI script, you would use this method to extract the cookies from the HTTP_COOKIE environment variable. >>> C = Cookie.SmartCookie() >>> C.load("chips=ahoy; vienna=finger") >>> C.output() 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger' The load() method is darn-tootin smart about identifying cookies within a string. Escaped quotation marks, nested semicolons, and other such trickeries do not confuse it. >>> C = Cookie.SmartCookie() >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') >>> print C Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" Each element of the Cookie also supports all of the RFC 2109 Cookie attributes. Here's an example which sets the Path attribute. >>> C = Cookie.SmartCookie() >>> C["oreo"] = "doublestuff" >>> C["oreo"]["path"] = "/" >>> print C Set-Cookie: oreo=doublestuff; Path=/ Each dictionary element has a 'value' attribute, which gives you back the value associated with the key. >>> C = Cookie.SmartCookie() >>> C["twix"] = "none for you" >>> C["twix"].value 'none for you' A Bit More Advanced ------------------- As mentioned before, there are three different flavors of Cookie objects, each with different encoding/decoding semantics. This section briefly discusses the differences. SimpleCookie The SimpleCookie expects that all values should be standard strings. Just to be sure, SimpleCookie invokes the str() builtin to convert the value to a string, when the values are set dictionary-style. >>> C = Cookie.SimpleCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value '7' >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number=7\r\nSet-Cookie: string=seven' SerialCookie The SerialCookie expects that all values should be serialized using cPickle (or pickle, if cPickle isn't available). As a result of serializing, SerialCookie can save almost any Python object to a value, and recover the exact same object when the cookie has been returned. (SerialCookie can yield some strange-looking cookie values, however.) >>> C = Cookie.SerialCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value 7 >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."' Be warned, however, if SerialCookie cannot de-serialize a value (because it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION. SmartCookie The SmartCookie combines aspects of each of the other two flavors. When setting a value in a dictionary-fashion, the SmartCookie will serialize (ala cPickle) the value *if and only if* it isn't a Python string. String objects are *not* serialized. Similarly, when the load() method parses out values, it attempts to de-serialize the value. If it fails, then it fallsback to treating the value as a string. >>> C = Cookie.SmartCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value 7 >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven' Backwards Compatibility ----------------------- In order to keep compatibilty with earlier versions of Cookie.py, it is still possible to use Cookie.Cookie() to create a Cookie. In fact, this simply returns a SmartCookie. >>> C = Cookie.Cookie() >>> print C.__class__.__name__ SmartCookie Finis. """ #" # ^ # |----helps out font-lock # # Import our required modules # import string try: from cPickle import dumps, loads except ImportError: from pickle import dumps, loads import re, warnings __all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie", "SmartCookie","Cookie"] _nulljoin = ''.join _semispacejoin = '; '.join _spacejoin = ' '.join # # Define an exception visible to External modules # class CookieError(Exception): pass # These quoting routines conform to the RFC2109 specification, which in # turn references the character definitions from RFC2068. They provide # a two-way quoting algorithm. Any non-text character is translated # into a 4 character sequence: a forward-slash followed by the # three-digit octal equivalent of the character. Any '\' or '"' is # quoted with a preceding '\' slash. # # These are taken from RFC2068 and RFC2109. # _LegalChars is the list of chars which don't require "'s # _Translator hash-table for fast quoting # _LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~" _Translator = { '\000' : '\\000', '\001' : '\\001', '\002' : '\\002', '\003' : '\\003', '\004' : '\\004', '\005' : '\\005', '\006' : '\\006', '\007' : '\\007', '\010' : '\\010', '\011' : '\\011', '\012' : '\\012', '\013' : '\\013', '\014' : '\\014', '\015' : '\\015', '\016' : '\\016', '\017' : '\\017', '\020' : '\\020', '\021' : '\\021', '\022' : '\\022', '\023' : '\\023', '\024' : '\\024', '\025' : '\\025', '\026' : '\\026', '\027' : '\\027', '\030' : '\\030', '\031' : '\\031', '\032' : '\\032', '\033' : '\\033', '\034' : '\\034', '\035' : '\\035', '\036' : '\\036', '\037' : '\\037', # Because of the way browsers really handle cookies (as opposed # to what the RFC says) we also encode , and ; ',' : '\\054', ';' : '\\073', '"' : '\\"', '\\' : '\\\\', '\177' : '\\177', '\200' : '\\200', '\201' : '\\201', '\202' : '\\202', '\203' : '\\203', '\204' : '\\204', '\205' : '\\205', '\206' : '\\206', '\207' : '\\207', '\210' : '\\210', '\211' : '\\211', '\212' : '\\212', '\213' : '\\213', '\214' : '\\214', '\215' : '\\215', '\216' : '\\216', '\217' : '\\217', '\220' : '\\220', '\221' : '\\221', '\222' : '\\222', '\223' : '\\223', '\224' : '\\224', '\225' : '\\225', '\226' : '\\226', '\227' : '\\227', '\230' : '\\230', '\231' : '\\231', '\232' : '\\232', '\233' : '\\233', '\234' : '\\234', '\235' : '\\235', '\236' : '\\236', '\237' : '\\237', '\240' : '\\240', '\241' : '\\241', '\242' : '\\242', '\243' : '\\243', '\244' : '\\244', '\245' : '\\245', '\246' : '\\246', '\247' : '\\247', '\250' : '\\250', '\251' : '\\251', '\252' : '\\252', '\253' : '\\253', '\254' : '\\254', '\255' : '\\255', '\256' : '\\256', '\257' : '\\257', '\260' : '\\260', '\261' : '\\261', '\262' : '\\262', '\263' : '\\263', '\264' : '\\264', '\265' : '\\265', '\266' : '\\266', '\267' : '\\267', '\270' : '\\270', '\271' : '\\271', '\272' : '\\272', '\273' : '\\273', '\274' : '\\274', '\275' : '\\275', '\276' : '\\276', '\277' : '\\277', '\300' : '\\300', '\301' : '\\301', '\302' : '\\302', '\303' : '\\303', '\304' : '\\304', '\305' : '\\305', '\306' : '\\306', '\307' : '\\307', '\310' : '\\310', '\311' : '\\311', '\312' : '\\312', '\313' : '\\313', '\314' : '\\314', '\315' : '\\315', '\316' : '\\316', '\317' : '\\317', '\320' : '\\320', '\321' : '\\321', '\322' : '\\322', '\323' : '\\323', '\324' : '\\324', '\325' : '\\325', '\326' : '\\326', '\327' : '\\327', '\330' : '\\330', '\331' : '\\331', '\332' : '\\332', '\333' : '\\333', '\334' : '\\334', '\335' : '\\335', '\336' : '\\336', '\337' : '\\337', '\340' : '\\340', '\341' : '\\341', '\342' : '\\342', '\343' : '\\343', '\344' : '\\344', '\345' : '\\345', '\346' : '\\346', '\347' : '\\347', '\350' : '\\350', '\351' : '\\351', '\352' : '\\352', '\353' : '\\353', '\354' : '\\354', '\355' : '\\355', '\356' : '\\356', '\357' : '\\357', '\360' : '\\360', '\361' : '\\361', '\362' : '\\362', '\363' : '\\363', '\364' : '\\364', '\365' : '\\365', '\366' : '\\366', '\367' : '\\367', '\370' : '\\370', '\371' : '\\371', '\372' : '\\372', '\373' : '\\373', '\374' : '\\374', '\375' : '\\375', '\376' : '\\376', '\377' : '\\377' } _idmap = ''.join(chr(x) for x in xrange(256)) def _quote(str, LegalChars=_LegalChars, idmap=_idmap, translate=string.translate): # # If the string does not need to be double-quoted, # then just return the string. Otherwise, surround # the string in doublequotes and precede quote (with a \) # special characters. # if "" == translate(str, idmap, LegalChars): return str else: return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"' # end _quote _OctalPatt = re.compile(r"\\[0-3][0-7][0-7]") _QuotePatt = re.compile(r"[\\].") def _unquote(str): # If there aren't any doublequotes, # then there can't be any special characters. See RFC 2109. if len(str) < 2: return str if str[0] != '"' or str[-1] != '"': return str # We have to assume that we must decode this string. # Down to work. # Remove the "s str = str[1:-1] # Check for special sequences. Examples: # \012 --> \n # \" --> " # i = 0 n = len(str) res = [] while 0 <= i < n: Omatch = _OctalPatt.search(str, i) Qmatch = _QuotePatt.search(str, i) if not Omatch and not Qmatch: # Neither matched res.append(str[i:]) break # else: j = k = -1 if Omatch: j = Omatch.start(0) if Qmatch: k = Qmatch.start(0) if Qmatch and ( not Omatch or k < j ): # QuotePatt matched res.append(str[i:k]) res.append(str[k+1]) i = k+2 else: # OctalPatt matched res.append(str[i:j]) res.append( chr( int(str[j+1:j+4], 8) ) ) i = j+4 return _nulljoin(res) # end _unquote # The _getdate() routine is used to set the expiration time in # the cookie's HTTP header. By default, _getdate() returns the # current time in the appropriate "expires" format for a # Set-Cookie header. The one optional argument is an offset from # now, in seconds. For example, an offset of -3600 means "one hour ago". # The offset may be a floating point number. # _weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] _monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname): from time import gmtime, time now = time() year, month, day, hh, mm, ss, wd, y, z = gmtime(now + future) return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \ (weekdayname[wd], day, monthname[month], year, hh, mm, ss) # # A class to hold ONE key,value pair. # In a cookie, each such pair may have several attributes. # so this class is used to keep the attributes associated # with the appropriate key,value pair. # This class also includes a coded_value attribute, which # is used to hold the network representation of the # value. This is most useful when Python objects are # pickled for network transit. # class Morsel(dict): # RFC 2109 lists these attributes as reserved: # path comment domain # max-age secure version # # For historical reasons, these attributes are also reserved: # expires # # This is an extension from Microsoft: # httponly # # This dictionary provides a mapping from the lowercase # variant on the left to the appropriate traditional # formatting on the right. _reserved = { "expires" : "expires", "path" : "Path", "comment" : "Comment", "domain" : "Domain", "max-age" : "Max-Age", "secure" : "secure", "httponly" : "httponly", "version" : "Version", } _flags = {'secure', 'httponly'} def __init__(self): # Set defaults self.key = self.value = self.coded_value = None # Set default attributes for K in self._reserved: dict.__setitem__(self, K, "") # end __init__ def __setitem__(self, K, V): K = K.lower() if not K in self._reserved: raise CookieError("Invalid Attribute %s" % K) dict.__setitem__(self, K, V) # end __setitem__ def isReservedKey(self, K): return K.lower() in self._reserved # end isReservedKey def set(self, key, val, coded_val, LegalChars=_LegalChars, idmap=_idmap, translate=string.translate): # First we verify that the key isn't a reserved word # Second we make sure it only contains legal characters if key.lower() in self._reserved: raise CookieError("Attempt to set a reserved key: %s" % key) if "" != translate(key, idmap, LegalChars): raise CookieError("Illegal key value: %s" % key) # It's a good key, so save it. self.key = key self.value = val self.coded_value = coded_val # end set def output(self, attrs=None, header = "Set-Cookie:"): return "%s %s" % ( header, self.OutputString(attrs) ) __str__ = output def __repr__(self): return '<%s: %s=%s>' % (self.__class__.__name__, self.key, repr(self.value) ) def js_output(self, attrs=None): # Print javascript return """ <script type="text/javascript"> <!-- begin hiding document.cookie = \"%s\"; // end hiding --> </script> """ % ( self.OutputString(attrs).replace('"',r'\"'), ) # end js_output() def OutputString(self, attrs=None): # Build up our result # result = [] RA = result.append # First, the key=value pair RA("%s=%s" % (self.key, self.coded_value)) # Now add any defined attributes if attrs is None: attrs = self._reserved items = self.items() items.sort() for K,V in items: if V == "": continue if K not in attrs: continue if K == "expires" and type(V) == type(1): RA("%s=%s" % (self._reserved[K], _getdate(V))) elif K == "max-age" and type(V) == type(1): RA("%s=%d" % (self._reserved[K], V)) elif K == "secure": RA(str(self._reserved[K])) elif K == "httponly": RA(str(self._reserved[K])) else: RA("%s=%s" % (self._reserved[K], V)) # Return the result return _semispacejoin(result) # end OutputString # end Morsel class # # Pattern for finding cookie # # This used to be strict parsing based on the RFC2109 and RFC2068 # specifications. I have since discovered that MSIE 3.0x doesn't # follow the character rules outlined in those specs. As a # result, the parsing rules here are less strict. # _LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]" _CookiePattern = re.compile( r"(?x)" # This is a Verbose pattern r"\s*" # Optional whitespace at start of cookie r"(?P<key>" # Start of group 'key' ""+ _LegalCharsPatt +"+?" # Any word of at least one letter, nongreedy r")" # End of group 'key' r"(" # Optional group: there may not be a value. r"\s*=\s*" # Equal Sign r"(?P<val>" # Start of group 'val' r'"(?:[^\\"]|\\.)*"' # Any doublequoted string r"|" # or r"\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT" # Special case for "expires" attr r"|" # or ""+ _LegalCharsPatt +"*" # Any word or empty string r")" # End of group 'val' r")?" # End of optional value group r"\s*" # Any number of spaces. r"(\s+|;|$)" # Ending either at space, semicolon, or EOS. ) # At long last, here is the cookie class. # Using this class is almost just like using a dictionary. # See this module's docstring for example usage. # class BaseCookie(dict): # A container class for a set of Morsels # def value_decode(self, val): """real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies. """ return val, val # end value_encode def value_encode(self, val): """real_value, coded_value = value_encode(VALUE) Called prior to setting a cookie's value from the dictionary representation. The VALUE is the value being assigned. Override this function to modify the behavior of cookies. """ strval = str(val) return strval, strval # end value_encode def __init__(self, input=None): if input: self.load(input) # end __init__ def __set(self, key, real_value, coded_value): """Private method for setting a cookie's value""" M = self.get(key, Morsel()) M.set(key, real_value, coded_value) dict.__setitem__(self, key, M) # end __set def __setitem__(self, key, value): """Dictionary style assignment.""" rval, cval = self.value_encode(value) self.__set(key, rval, cval) # end __setitem__ def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"): """Return a string suitable for HTTP.""" result = [] items = self.items() items.sort() for K,V in items: result.append( V.output(attrs, header) ) return sep.join(result) # end output __str__ = output def __repr__(self): L = [] items = self.items() items.sort() for K,V in items: L.append( '%s=%s' % (K,repr(V.value) ) ) return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L)) def js_output(self, attrs=None): """Return a string suitable for JavaScript.""" result = [] items = self.items() items.sort() for K,V in items: result.append( V.js_output(attrs) ) return _nulljoin(result) # end js_output def load(self, rawdata): """Load cookies from a string (presumably HTTP_COOKIE) or from a dictionary. Loading cookies from a dictionary 'd' is equivalent to calling: map(Cookie.__setitem__, d.keys(), d.values()) """ if type(rawdata) == type(""): self.__ParseString(rawdata) else: # self.update() wouldn't call our custom __setitem__ for k, v in rawdata.items(): self[k] = v return # end load() def __ParseString(self, str, patt=_CookiePattern): i = 0 # Our starting point n = len(str) # Length of string M = None # current morsel while 0 <= i < n: # Start looking for a cookie match = patt.match(str, i) if not match: break # No more cookies K,V = match.group("key"), match.group("val") i = match.end(0) # Parse the key, value in case it's metainfo if K[0] == "$": # We ignore attributes which pertain to the cookie # mechanism as a whole. See RFC 2109. # (Does anyone care?) if M: M[ K[1:] ] = V elif K.lower() in Morsel._reserved: if M: if V is None: if K.lower() in Morsel._flags: M[K] = True else: M[K] = _unquote(V) elif V is not None: rval, cval = self.value_decode(V) self.__set(K, rval, cval) M = self[K] # end __ParseString # end BaseCookie class class SimpleCookie(BaseCookie): """SimpleCookie SimpleCookie supports strings as cookie values. When setting the value using the dictionary assignment notation, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings. """ def value_decode(self, val): return _unquote( val ), val def value_encode(self, val): strval = str(val) return strval, _quote( strval ) # end SimpleCookie class SerialCookie(BaseCookie): """SerialCookie SerialCookie supports arbitrary objects as cookie values. All values are serialized (using cPickle) before being sent to the client. All incoming values are assumed to be valid Pickle representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE FORMAT, THEN AN EXCEPTION WILL BE RAISED. Note: Large cookie values add overhead because they must be retransmitted on every HTTP transaction. Note: HTTP has a 2k limit on the size of a cookie. This class does not check for this limit, so be careful!!! """ def __init__(self, input=None): warnings.warn("SerialCookie class is insecure; do not use it", DeprecationWarning) BaseCookie.__init__(self, input) # end __init__ def value_decode(self, val): # This could raise an exception! return loads( _unquote(val) ), val def value_encode(self, val): return val, _quote( dumps(val) ) # end SerialCookie class SmartCookie(BaseCookie): """SmartCookie SmartCookie supports arbitrary objects as cookie values. If the object is a string, then it is quoted. If the object is not a string, however, then SmartCookie will use cPickle to serialize the object into a string representation. Note: Large cookie values add overhead because they must be retransmitted on every HTTP transaction. Note: HTTP has a 2k limit on the size of a cookie. This class does not check for this limit, so be careful!!! """ def __init__(self, input=None): warnings.warn("Cookie/SmartCookie class is insecure; do not use it", DeprecationWarning) BaseCookie.__init__(self, input) # end __init__ def value_decode(self, val): strval = _unquote(val) try: return loads(strval), val except: return strval, val def value_encode(self, val): if type(val) == type(""): return val, _quote(val) else: return val, _quote( dumps(val) ) # end SmartCookie ########################################################### # Backwards Compatibility: Don't break any existing code! # We provide Cookie() as an alias for SmartCookie() Cookie = SmartCookie # ########################################################### def _test(): import doctest, Cookie return doctest.testmod(Cookie) if __name__ == "__main__": _test() #Local Variables: #tab-width: 4 #end:
gpl-2.0
[ 381, 199, 3, 1898, 12293, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 4483, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 199, 3, 436, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 221, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 199, 3, 2401, 3092, 12, 1621, 4825, 6461, 7000, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 199, 3, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 381, 199, 3, 199, 3, 15418, 26, 14798, 14, 647, 12, 86, 499, 14, 1398, 12293, 15, 2036, 15, 1789, 22528, 26, 1651, 26, 1887, 3367, 573, 7910, 199, 3, 257, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 221, 14798, 14, 647, 365, 282, 2018, 859, 367, 314, 7252, 402, 3101, 199, 3, 221, 10049, 465, 282, 2018, 2600, 14, 221, 1666, 7329, 499, 6996, 367, 1655, 199, 3, 221, 2556, 641, 10049, 14, 199, 3, 199, 3, 221, 710, 3379, 16819, 370, 14312, 1849, 5635, 465, 282, 2600, 20382, 687, 199, 3, 221, 577, 811, 603, 9414, 1697, 334, 68, 811, 77, 32, 19902, 386, 14, 957, 9, 315, 9013, 21, 12, 1380, 946, 14286, 314, 199, 3, 221, 1642, 1015, 402, 700, 5306, 14, 647, 14, 199, 3, 199, 381, 199, 199, 82, 624, 199, 21741, 1159, 282, 2690, 2351, 370, 2498, 4212, 370, 675, 642, 859, 14, 199, 1271, 314, 12427, 12, 642, 365, 314, 1454, 3794, 14, 199, 199, 1918, 10082, 83, 199, 9460, 199, 199, 6295, 316, 365, 8837, 703, 8410, 1306, 492, 14798, 199, 199, 24625, 402, 314, 900, 1265, 1343, 701, 6425, 282, 5494, 14, 221, 1849, 5635, 11492, 315, 199, 10480, 23547, 12, 1924, 543, 18023, 3365, 2644, 19002, 12, 1325, 199, 6878, 641, 626, 2945, 14, 8410, 1306, 445, 275, 14798, 14, 3184, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 3571, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 199, 199, 59, 7443, 26, 19944, 13, 521, 4390, 402, 14798, 14, 647, 911, 21027, 1808, 199, 7810, 14, 7810, 342, 370, 1218, 282, 14798, 909, 14, 221, 4580, 15401, 5906, 12, 652, 199, 374, 5139, 3748, 701, 314, 1233, 14, 221, 1666, 314, 10257, 3079, 3599, 5880, 12681, 199, 509, 1655, 2556, 19784, 199, 199, 25690, 1265, 9064, 2737, 2195, 14798, 12, 1265, 883, 1050, 1338, 2951, 465, 340, 652, 4898, 199, 65, 2600, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 592, 937, 275, 298, 1222, 1860, 2, 2043, 1306, 445, 905, 83, 21922, 937, 275, 298, 758, 2412, 2, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 6085, 29, 1222, 1860, 60, 82, 60, 78, 1084, 13, 7810, 26, 308, 21922, 29, 758, 2412, 7, 199, 199, 1944, 3548, 626, 314, 21834, 6025, 402, 282, 14798, 365, 314, 199, 11227, 5655, 1475, 367, 282, 2494, 13, 7810, 26, 1406, 14, 221, 961, 365, 314, 199, 885, 5953, 14, 221, 2047, 883, 1570, 314, 1406, 436, 12487, 199, 2987, 701, 1808, 314, 1275, 1199, 342, 805, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 24892, 89, 937, 275, 298, 5063, 2, 2043, 1306, 445, 905, 24892, 89, 6611, 515, 937, 275, 3286, 5306, 2, 2043, 1306, 870, 445, 14, 1199, 8, 1291, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 27, 6912, 13043, 5306, 2043, 1306, 870, 445, 14, 1199, 8, 3288, 6034, 1406, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 199, 199, 1918, 2248, 342, 1083, 402, 282, 14798, 5536, 83, 10049, 687, 282, 1059, 14, 221, 1010, 282, 199, 21337, 2884, 12, 1265, 3955, 675, 642, 1083, 370, 5536, 314, 10049, 687, 314, 199, 2856, 63, 13665, 3734, 1750, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 480, 335, 6142, 29, 65, 526, 89, 27, 1321, 287, 3540, 29, 70, 7886, 531, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 682, 6142, 29, 65, 526, 89, 60, 82, 60, 78, 1084, 13, 7810, 26, 1321, 287, 3540, 29, 70, 7886, 7, 199, 199, 1918, 2248, 342, 1083, 365, 366, 1060, 13, 475, 357, 262, 11179, 3595, 21119, 10049, 199, 12541, 282, 1059, 14, 221, 21067, 68, 25101, 17370, 12, 6032, 18734, 761, 4654, 12, 436, 1163, 199, 10180, 20907, 5460, 886, 440, 3743, 1180, 652, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 360, 415, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 29, 15022, 2041, 2310, 1103, 11436, 289, 16603, 29, 1103, 11533, 9426, 10784, 2043, 1306, 870, 445, 2043, 2494, 13, 7810, 26, 10074, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 8178, 2041, 2310, 4451, 27, 289, 16603, 9529, 11533, 9426, 199, 199, 22321, 1819, 402, 314, 14798, 2597, 5171, 1006, 402, 314, 7329, 499, 6996, 199, 7810 ]
[ 199, 3, 1898, 12293, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 4483, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 199, 3, 436, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 221, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 199, 3, 2401, 3092, 12, 1621, 4825, 6461, 7000, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 199, 3, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 381, 199, 3, 199, 3, 15418, 26, 14798, 14, 647, 12, 86, 499, 14, 1398, 12293, 15, 2036, 15, 1789, 22528, 26, 1651, 26, 1887, 3367, 573, 7910, 199, 3, 257, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 221, 14798, 14, 647, 365, 282, 2018, 859, 367, 314, 7252, 402, 3101, 199, 3, 221, 10049, 465, 282, 2018, 2600, 14, 221, 1666, 7329, 499, 6996, 367, 1655, 199, 3, 221, 2556, 641, 10049, 14, 199, 3, 199, 3, 221, 710, 3379, 16819, 370, 14312, 1849, 5635, 465, 282, 2600, 20382, 687, 199, 3, 221, 577, 811, 603, 9414, 1697, 334, 68, 811, 77, 32, 19902, 386, 14, 957, 9, 315, 9013, 21, 12, 1380, 946, 14286, 314, 199, 3, 221, 1642, 1015, 402, 700, 5306, 14, 647, 14, 199, 3, 199, 381, 199, 199, 82, 624, 199, 21741, 1159, 282, 2690, 2351, 370, 2498, 4212, 370, 675, 642, 859, 14, 199, 1271, 314, 12427, 12, 642, 365, 314, 1454, 3794, 14, 199, 199, 1918, 10082, 83, 199, 9460, 199, 199, 6295, 316, 365, 8837, 703, 8410, 1306, 492, 14798, 199, 199, 24625, 402, 314, 900, 1265, 1343, 701, 6425, 282, 5494, 14, 221, 1849, 5635, 11492, 315, 199, 10480, 23547, 12, 1924, 543, 18023, 3365, 2644, 19002, 12, 1325, 199, 6878, 641, 626, 2945, 14, 8410, 1306, 445, 275, 14798, 14, 3184, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 3571, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 199, 199, 59, 7443, 26, 19944, 13, 521, 4390, 402, 14798, 14, 647, 911, 21027, 1808, 199, 7810, 14, 7810, 342, 370, 1218, 282, 14798, 909, 14, 221, 4580, 15401, 5906, 12, 652, 199, 374, 5139, 3748, 701, 314, 1233, 14, 221, 1666, 314, 10257, 3079, 3599, 5880, 12681, 199, 509, 1655, 2556, 19784, 199, 199, 25690, 1265, 9064, 2737, 2195, 14798, 12, 1265, 883, 1050, 1338, 2951, 465, 340, 652, 4898, 199, 65, 2600, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 592, 937, 275, 298, 1222, 1860, 2, 2043, 1306, 445, 905, 83, 21922, 937, 275, 298, 758, 2412, 2, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 6085, 29, 1222, 1860, 60, 82, 60, 78, 1084, 13, 7810, 26, 308, 21922, 29, 758, 2412, 7, 199, 199, 1944, 3548, 626, 314, 21834, 6025, 402, 282, 14798, 365, 314, 199, 11227, 5655, 1475, 367, 282, 2494, 13, 7810, 26, 1406, 14, 221, 961, 365, 314, 199, 885, 5953, 14, 221, 2047, 883, 1570, 314, 1406, 436, 12487, 199, 2987, 701, 1808, 314, 1275, 1199, 342, 805, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 24892, 89, 937, 275, 298, 5063, 2, 2043, 1306, 445, 905, 24892, 89, 6611, 515, 937, 275, 3286, 5306, 2, 2043, 1306, 870, 445, 14, 1199, 8, 1291, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 27, 6912, 13043, 5306, 2043, 1306, 870, 445, 14, 1199, 8, 3288, 6034, 1406, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 199, 199, 1918, 2248, 342, 1083, 402, 282, 14798, 5536, 83, 10049, 687, 282, 1059, 14, 221, 1010, 282, 199, 21337, 2884, 12, 1265, 3955, 675, 642, 1083, 370, 5536, 314, 10049, 687, 314, 199, 2856, 63, 13665, 3734, 1750, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 480, 335, 6142, 29, 65, 526, 89, 27, 1321, 287, 3540, 29, 70, 7886, 531, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 682, 6142, 29, 65, 526, 89, 60, 82, 60, 78, 1084, 13, 7810, 26, 1321, 287, 3540, 29, 70, 7886, 7, 199, 199, 1918, 2248, 342, 1083, 365, 366, 1060, 13, 475, 357, 262, 11179, 3595, 21119, 10049, 199, 12541, 282, 1059, 14, 221, 21067, 68, 25101, 17370, 12, 6032, 18734, 761, 4654, 12, 436, 1163, 199, 10180, 20907, 5460, 886, 440, 3743, 1180, 652, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 360, 415, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 29, 15022, 2041, 2310, 1103, 11436, 289, 16603, 29, 1103, 11533, 9426, 10784, 2043, 1306, 870, 445, 2043, 2494, 13, 7810, 26, 10074, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 8178, 2041, 2310, 4451, 27, 289, 16603, 9529, 11533, 9426, 199, 199, 22321, 1819, 402, 314, 14798, 2597, 5171, 1006, 402, 314, 7329, 499, 6996, 199, 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1, 1, 1, 1 ]
piyueh/SEM-Toolbox
utils/poly/Jacobi.py
1
1612
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2016 Pi-Yueh Chuang <pychuang@gwu.edu> # # Distributed under terms of the MIT license. """Definition of Jacobi polynomial class""" import numpy from utils.poly.Polynomial import Polynomial from utils.poly.jacobi_operations import jacobi_coef from utils.poly.poly_operations import find_roots class Jacobi(Polynomial): """Jacobi polynomial Its attributions are the same as the Polynomial class. """ def __init__(self, _n, _alpha, _beta): """initialize the instance of Jacobi polynomial Args: _n: the order of the Jacobi polynomial _alpha: the alpha of the Jacobi polynomial _beta: the beta of the Jacobi polynomial """ c = jacobi_coef(_n, _alpha, _beta) super().__init__(c) self.n = _n self.alpha = _alpha self.beta = _beta if self.n > 0: assert self.roots.dtype == numpy.float64, \ "The roots of a Jacobi polynomial should be real numbers. " +\ "Please check the source code of polynomial operations." self.roots = numpy.sort(self.roots) def __repr__(self): """__repr__""" return "{0}({1}, {2}, {3})".format( self.__class__, self.n, self.alpha, self.beta) def _find_roots(self): """calculate the roots and store them in self.root""" self.roots = numpy.array( [-numpy.cos((2*i+1)*numpy.pi/(2*self.n)) for i in range(self.n)]) self.roots = find_roots(self.coeffs)
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6695, 26, 70, 10945, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 22405, 103, 7800, 19835, 13, 57, 310, 72, 2799, 85, 621, 665, 647, 335, 85, 621, 32, 8392, 85, 14, 8654, 30, 199, 3, 199, 3, 17484, 1334, 2895, 402, 314, 10697, 4190, 14, 199, 199, 624, 10701, 402, 1603, 13286, 4492, 11849, 1021, 624, 199, 199, 646, 2680, 199, 504, 3778, 14, 6023, 14, 5858, 8887, 492, 8467, 8887, 199, 504, 3778, 14, 6023, 14, 21136, 4492, 63, 8170, 492, 1335, 13286, 4492, 63, 8009, 199, 504, 3778, 14, 6023, 14, 6023, 63, 8170, 492, 2342, 63, 12065, 421, 199, 533, 1603, 13286, 4492, 8, 5858, 8887, 304, 272, 408, 42, 13286, 4492, 11849, 339, 22940, 737, 26675, 787, 314, 2011, 465, 314, 8467, 8887, 1021, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 485, 78, 12, 485, 4468, 12, 485, 5683, 304, 267, 408, 8489, 314, 1256, 402, 1603, 13286, 4492, 11849, 398, 3033, 26, 288, 485, 78, 26, 314, 1865, 402, 314, 1603, 13286, 4492, 11849, 288, 485, 4468, 26, 314, 5131, 402, 314, 1603, 13286, 4492, 11849, 288, 485, 5683, 26, 314, 8201, 402, 314, 1603, 13286, 4492, 11849, 267, 408, 398, 286, 275, 1335, 13286, 4492, 63, 8009, 1547, 78, 12, 485, 4468, 12, 485, 5683, 9, 267, 1613, 11027, 826, 721, 67, 9, 398, 291, 14, 78, 275, 485, 78, 267, 291, 14, 4468, 275, 485, 4468, 267, 291, 14, 5683, 275, 485, 5683, 398, 340, 291, 14, 78, 690, 378, 26, 288, 702, 291, 14, 12065, 14, 2271, 508, 2680, 14, 1609, 772, 12, 971, 355, 298, 1918, 14361, 402, 282, 1603, 13286, 4492, 11849, 1077, 506, 3363, 5579, 14, 298, 17992, 355, 298, 8254, 1104, 314, 1350, 1233, 402, 11849, 5331, 2122, 953, 291, 14, 12065, 275, 2680, 14, 3191, 8, 277, 14, 12065, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 408, 363, 2722, 363, 624, 398, 372, 5310, 16, 93, 2561, 17, 1386, 469, 18, 1386, 469, 19, 25974, 908, 8, 288, 291, 855, 533, 3108, 291, 14, 78, 12, 291, 14, 4468, 12, 291, 14, 5683, 9, 339, 347, 485, 1623, 63, 12065, 8, 277, 304, 267, 408, 12063, 314, 14361, 436, 3877, 3062, 315, 291, 14, 1231, 624, 398, 291, 14, 12065, 275, 2680, 14, 1144, 8, 288, 5243, 4714, 14, 5197, 1332, 18, 10, 73, 11, 17, 3342, 4714, 14, 1038, 7985, 18, 10, 277, 14, 78, 430, 367, 284, 315, 1425, 8, 277, 14, 78, 3948, 398, 291, 14, 12065, 275, 2342, 63, 12065, 8, 277, 14, 15958, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6695, 26, 70, 10945, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 22405, 103, 7800, 19835, 13, 57, 310, 72, 2799, 85, 621, 665, 647, 335, 85, 621, 32, 8392, 85, 14, 8654, 30, 199, 3, 199, 3, 17484, 1334, 2895, 402, 314, 10697, 4190, 14, 199, 199, 624, 10701, 402, 1603, 13286, 4492, 11849, 1021, 624, 199, 199, 646, 2680, 199, 504, 3778, 14, 6023, 14, 5858, 8887, 492, 8467, 8887, 199, 504, 3778, 14, 6023, 14, 21136, 4492, 63, 8170, 492, 1335, 13286, 4492, 63, 8009, 199, 504, 3778, 14, 6023, 14, 6023, 63, 8170, 492, 2342, 63, 12065, 421, 199, 533, 1603, 13286, 4492, 8, 5858, 8887, 304, 272, 408, 42, 13286, 4492, 11849, 339, 22940, 737, 26675, 787, 314, 2011, 465, 314, 8467, 8887, 1021, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 485, 78, 12, 485, 4468, 12, 485, 5683, 304, 267, 408, 8489, 314, 1256, 402, 1603, 13286, 4492, 11849, 398, 3033, 26, 288, 485, 78, 26, 314, 1865, 402, 314, 1603, 13286, 4492, 11849, 288, 485, 4468, 26, 314, 5131, 402, 314, 1603, 13286, 4492, 11849, 288, 485, 5683, 26, 314, 8201, 402, 314, 1603, 13286, 4492, 11849, 267, 408, 398, 286, 275, 1335, 13286, 4492, 63, 8009, 1547, 78, 12, 485, 4468, 12, 485, 5683, 9, 267, 1613, 11027, 826, 721, 67, 9, 398, 291, 14, 78, 275, 485, 78, 267, 291, 14, 4468, 275, 485, 4468, 267, 291, 14, 5683, 275, 485, 5683, 398, 340, 291, 14, 78, 690, 378, 26, 288, 702, 291, 14, 12065, 14, 2271, 508, 2680, 14, 1609, 772, 12, 971, 355, 298, 1918, 14361, 402, 282, 1603, 13286, 4492, 11849, 1077, 506, 3363, 5579, 14, 298, 17992, 355, 298, 8254, 1104, 314, 1350, 1233, 402, 11849, 5331, 2122, 953, 291, 14, 12065, 275, 2680, 14, 3191, 8, 277, 14, 12065, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 408, 363, 2722, 363, 624, 398, 372, 5310, 16, 93, 2561, 17, 1386, 469, 18, 1386, 469, 19, 25974, 908, 8, 288, 291, 855, 533, 3108, 291, 14, 78, 12, 291, 14, 4468, 12, 291, 14, 5683, 9, 339, 347, 485, 1623, 63, 12065, 8, 277, 304, 267, 408, 12063, 314, 14361, 436, 3877, 3062, 315, 291, 14, 1231, 624, 398, 291, 14, 12065, 275, 2680, 14, 1144, 8, 288, 5243, 4714, 14, 5197, 1332, 18, 10, 73, 11, 17, 3342, 4714, 14, 1038, 7985, 18, 10, 277, 14, 78, 430, 367, 284, 315, 1425, 8, 277, 14, 78, 3948, 398, 291, 14, 12065, 275, 2342, 63, 12065, 8, 277, 14, 15958, 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, 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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 ]
theguardian/JIRA-APPy
lib/pkg_resources/__init__.py
2
107034
""" Package resource API -------------------- A resource is a logical file contained within a package, or a logical subdirectory thereof. The package resource API expects resource names to have their path parts separated with ``/``, *not* whatever the local path separator is. Do not use os.path operations to manipulate resource names being passed into the API. The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in a limited way with .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. """ from __future__ import absolute_import import sys import os import io import time import re import types import zipfile import zipimport import warnings import stat import functools import pkgutil import token import symbol import operator import platform import collections import plistlib import email.parser import tempfile import textwrap from pkgutil import get_importer try: import _imp except ImportError: # Python 3.2 compatibility import imp as _imp PY3 = sys.version_info > (3,) PY2 = not PY3 if PY3: from urllib.parse import urlparse, urlunparse if PY2: from urlparse import urlparse, urlunparse if PY3: string_types = str, else: string_types = str, eval('unicode') iteritems = (lambda i: i.items()) if PY3 else lambda i: i.iteritems() # capture these to bypass sandboxing from os import utime try: from os import mkdir, rename, unlink WRITE_SUPPORT = True except ImportError: # no write support, probably under GAE WRITE_SUPPORT = False from os import open as os_open from os.path import isdir, split # Avoid try/except due to potential problems with delayed import mechanisms. if sys.version_info >= (3, 3) and sys.implementation.name == "cpython": import importlib.machinery as importlib_machinery else: importlib_machinery = None try: import parser except ImportError: pass try: import lib.pkg_resources._vendor.packaging.version import lib.pkg_resources._vendor.packaging.specifiers from lib.pkg_resources._vendor import packaging #packaging = lib.pkg_resources._vendor.packaging except ImportError: # fallback to naturally-installed version; allows system packagers to # omit vendored packages. import pkg_resources.packaging.version import packaging.specifiers if (3, 0) < sys.version_info < (3, 3): msg = ( "Support for Python 3.0-3.2 has been dropped. Future versions " "will fail here." ) warnings.warn(msg) # declare some globals that will be defined later to # satisfy the linters. require = None working_set = None class PEP440Warning(RuntimeWarning): """ Used when there is an issue with a version or specifier not complying with PEP 440. """ class _SetuptoolsVersionMixin(object): def __hash__(self): return super(_SetuptoolsVersionMixin, self).__hash__() def __lt__(self, other): if isinstance(other, tuple): return tuple(self) < other else: return super(_SetuptoolsVersionMixin, self).__lt__(other) def __le__(self, other): if isinstance(other, tuple): return tuple(self) <= other else: return super(_SetuptoolsVersionMixin, self).__le__(other) def __eq__(self, other): if isinstance(other, tuple): return tuple(self) == other else: return super(_SetuptoolsVersionMixin, self).__eq__(other) def __ge__(self, other): if isinstance(other, tuple): return tuple(self) >= other else: return super(_SetuptoolsVersionMixin, self).__ge__(other) def __gt__(self, other): if isinstance(other, tuple): return tuple(self) > other else: return super(_SetuptoolsVersionMixin, self).__gt__(other) def __ne__(self, other): if isinstance(other, tuple): return tuple(self) != other else: return super(_SetuptoolsVersionMixin, self).__ne__(other) def __getitem__(self, key): return tuple(self)[key] def __iter__(self): component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE) replace = { 'pre': 'c', 'preview': 'c', '-': 'final-', 'rc': 'c', 'dev': '@', }.get def _parse_version_parts(s): for part in component_re.split(s): part = replace(part, part) if not part or part == '.': continue if part[:1] in '0123456789': # pad for numeric comparison yield part.zfill(8) else: yield '*'+part # ensure that alpha/beta/candidate are before final yield '*final' def old_parse_version(s): parts = [] for part in _parse_version_parts(s.lower()): if part.startswith('*'): # remove '-' before a prerelease tag if part < '*final': while parts and parts[-1] == '*final-': parts.pop() # remove trailing zeros from each series of numeric parts while parts and parts[-1] == '00000000': parts.pop() parts.append(part) return tuple(parts) # Warn for use of this function warnings.warn( "You have iterated over the result of " "pkg_resources.parse_version. This is a legacy behavior which is " "inconsistent with the new version class introduced in setuptools " "8.0. In most cases, conversion to a tuple is unnecessary. For " "comparison of versions, sort the Version instances directly. If " "you have another use case requiring the tuple, please file a " "bug with the setuptools project describing that need.", RuntimeWarning, stacklevel=1, ) for part in old_parse_version(str(self)): yield part class SetuptoolsVersion(_SetuptoolsVersionMixin, packaging.version.Version): pass class SetuptoolsLegacyVersion(_SetuptoolsVersionMixin, packaging.version.LegacyVersion): pass def parse_version(v): try: return SetuptoolsVersion(v) except packaging.version.InvalidVersion: return SetuptoolsLegacyVersion(v) _state_vars = {} def _declare_state(vartype, **kw): globals().update(kw) _state_vars.update(dict.fromkeys(kw, vartype)) def __getstate__(): state = {} g = globals() for k, v in _state_vars.items(): state[k] = g['_sget_'+v](g[k]) return state def __setstate__(state): g = globals() for k, v in state.items(): g['_sset_'+_state_vars[k]](k, g[k], v) return state def _sget_dict(val): return val.copy() def _sset_dict(key, ob, state): ob.clear() ob.update(state) def _sget_object(val): return val.__getstate__() def _sset_object(key, ob, state): ob.__setstate__(state) _sget_none = _sset_none = lambda *args: None def get_supported_platform(): """Return this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of Mac OS X that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of Mac OS X that we are *running*. To allow usage of packages that explicitly require a newer version of Mac OS X, we must also know the current version of the OS. If this condition occurs for any other platform with a version in its platform strings, this function should be extended accordingly. """ plat = get_build_platform() m = macosVersionString.match(plat) if m is not None and sys.platform == "darwin": try: plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3)) except ValueError: # not Mac OS X pass return plat __all__ = [ # Basic resource access and distribution/entry point discovery 'require', 'run_script', 'get_provider', 'get_distribution', 'load_entry_point', 'get_entry_map', 'get_entry_info', 'iter_entry_points', 'resource_string', 'resource_stream', 'resource_filename', 'resource_listdir', 'resource_exists', 'resource_isdir', # Environmental control 'declare_namespace', 'working_set', 'add_activation_listener', 'find_distributions', 'set_extraction_path', 'cleanup_resources', 'get_default_cache', # Primary implementation classes 'Environment', 'WorkingSet', 'ResourceManager', 'Distribution', 'Requirement', 'EntryPoint', # Exceptions 'ResolutionError', 'VersionConflict', 'DistributionNotFound', 'UnknownExtra', 'ExtractionError', # Warnings 'PEP440Warning', # Parsing functions and string utilities 'parse_requirements', 'parse_version', 'safe_name', 'safe_version', 'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections', 'safe_extra', 'to_filename', 'invalid_marker', 'evaluate_marker', # filesystem utilities 'ensure_directory', 'normalize_path', # Distribution "precedence" constants 'EGG_DIST', 'BINARY_DIST', 'SOURCE_DIST', 'CHECKOUT_DIST', 'DEVELOP_DIST', # "Provider" interfaces, implementations, and registration/lookup APIs 'IMetadataProvider', 'IResourceProvider', 'FileMetadata', 'PathMetadata', 'EggMetadata', 'EmptyProvider', 'empty_provider', 'NullProvider', 'EggProvider', 'DefaultProvider', 'ZipProvider', 'register_finder', 'register_namespace_handler', 'register_loader_type', 'fixup_namespace_packages', 'get_importer', # Deprecated/backward compatibility only 'run_main', 'AvailableDistributions', ] class ResolutionError(Exception): """Abstract base for dependency resolution errors""" def __repr__(self): return self.__class__.__name__+repr(self.args) class VersionConflict(ResolutionError): """ An already-installed version conflicts with the requested version. Should be initialized with the installed Distribution and the requested Requirement. """ _template = "{self.dist} is installed but {self.req} is required" @property def dist(self): return self.args[0] @property def req(self): return self.args[1] def report(self): return self._template.format(**locals()) def with_context(self, required_by): """ If required_by is non-empty, return a version of self that is a ContextualVersionConflict. """ if not required_by: return self args = self.args + (required_by,) return ContextualVersionConflict(*args) class ContextualVersionConflict(VersionConflict): """ A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. """ _template = VersionConflict._template + ' by {self.required_by}' @property def required_by(self): return self.args[2] class DistributionNotFound(ResolutionError): """A requested distribution was not found""" _template = ("The '{self.req}' distribution was not found " "and is required by {self.requirers_str}") @property def req(self): return self.args[0] @property def requirers(self): return self.args[1] @property def requirers_str(self): if not self.requirers: return 'the application' return ', '.join(self.requirers) def report(self): return self._template.format(**locals()) def __str__(self): return self.report() class UnknownExtra(ResolutionError): """Distribution doesn't have an "extra feature" of the given name""" _provider_factories = {} PY_MAJOR = sys.version[:3] EGG_DIST = 3 BINARY_DIST = 2 SOURCE_DIST = 1 CHECKOUT_DIST = 0 DEVELOP_DIST = -1 def register_loader_type(loader_type, provider_factory): """Register `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for that module. """ _provider_factories[loader_type] = provider_factory def get_provider(moduleOrReq): """Return an IResourceProvider for the named module or requirement""" if isinstance(moduleOrReq, Requirement): return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] try: module = sys.modules[moduleOrReq] except KeyError: __import__(moduleOrReq) module = sys.modules[moduleOrReq] loader = getattr(module, '__loader__', None) return _find_adapter(_provider_factories, loader)(module) def _macosx_vers(_cache=[]): if not _cache: version = platform.mac_ver()[0] # fallback for MacPorts if version == '': plist = '/System/Library/CoreServices/SystemVersion.plist' if os.path.exists(plist): if hasattr(plistlib, 'readPlist'): plist_content = plistlib.readPlist(plist) if 'ProductVersion' in plist_content: version = plist_content['ProductVersion'] _cache.append(version.split('.')) return _cache[0] def _macosx_arch(machine): return {'PowerPC': 'ppc', 'Power_Macintosh': 'ppc'}.get(machine, machine) def get_build_platform(): """Return this platform's string for platform-specific distributions XXX Currently this is the same as ``distutils.util.get_platform()``, but it needs some hacks for Linux and Mac OS X. """ try: # Python 2.7 or >=3.2 from sysconfig import get_platform except ImportError: from distutils.util import get_platform plat = get_platform() if sys.platform == "darwin" and not plat.startswith('macosx-'): try: version = _macosx_vers() machine = os.uname()[4].replace(" ", "_") return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]), _macosx_arch(machine)) except ValueError: # if someone is running a non-Mac darwin system, this will fall # through to the default implementation pass return plat macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)") darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)") # XXX backward compat get_platform = get_build_platform def compatible_platforms(provided, required): """Can code for the `provided` platform run on the `required` platform? Returns true if either platform is ``None``, or the platforms are equal. XXX Needs compatibility checks for Linux and other unixy OSes. """ if provided is None or required is None or provided==required: # easy case return True # Mac OS X special cases reqMac = macosVersionString.match(required) if reqMac: provMac = macosVersionString.match(provided) # is this a Mac package? if not provMac: # this is backwards compatibility for packages built before # setuptools 0.6. All packages built after this point will # use the new macosx designation. provDarwin = darwinVersionString.match(provided) if provDarwin: dversion = int(provDarwin.group(1)) macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2)) if dversion == 7 and macosversion >= "10.3" or \ dversion == 8 and macosversion >= "10.4": return True # egg isn't macosx or legacy darwin return False # are they the same major version and machine type? if provMac.group(1) != reqMac.group(1) or \ provMac.group(3) != reqMac.group(3): return False # is the required OS major update >= the provided one? if int(provMac.group(2)) > int(reqMac.group(2)): return False return True # XXX Linux and other platforms' special cases should go here return False def run_script(dist_spec, script_name): """Locate distribution `dist_spec` and run its `script_name` script""" ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name require(dist_spec)[0].run_script(script_name, ns) # backward compatibility run_main = run_script def get_distribution(dist): """Return a current distribution object for a Requirement or string""" if isinstance(dist, string_types): dist = Requirement.parse(dist) if isinstance(dist, Requirement): dist = get_provider(dist) if not isinstance(dist, Distribution): raise TypeError("Expected string, Requirement, or Distribution", dist) return dist def load_entry_point(dist, group, name): """Return `name` entry point of `group` for `dist` or raise ImportError""" return get_distribution(dist).load_entry_point(group, name) def get_entry_map(dist, group=None): """Return the entry point map for `group`, or the full entry map""" return get_distribution(dist).get_entry_map(group) def get_entry_info(dist, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return get_distribution(dist).get_entry_info(group, name) class IMetadataProvider: def has_metadata(name): """Does the package's distribution contain the named metadata?""" def get_metadata(name): """The named metadata resource as a string""" def get_metadata_lines(name): """Yield named metadata resource as list of non-blank non-comment lines Leading and trailing whitespace is stripped from each line, and lines with ``#`` as the first non-blank character are omitted.""" def metadata_isdir(name): """Is the named metadata a directory? (like ``os.path.isdir()``)""" def metadata_listdir(name): """List of metadata names in the directory (like ``os.listdir()``)""" def run_script(script_name, namespace): """Execute the named script in the supplied namespace dictionary""" class IResourceProvider(IMetadataProvider): """An object that provides access to package resources""" def get_resource_filename(manager, resource_name): """Return a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_stream(manager, resource_name): """Return a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_string(manager, resource_name): """Return a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``""" def has_resource(resource_name): """Does the package contain the named resource?""" def resource_isdir(resource_name): """Is the named resource a directory? (like ``os.path.isdir()``)""" def resource_listdir(resource_name): """List of resource names in the directory (like ``os.listdir()``)""" class WorkingSet(object): """A collection of active distributions on sys.path (or a similar list)""" def __init__(self, entries=None): """Create working set from list of path entries (default=sys.path)""" self.entries = [] self.entry_keys = {} self.by_key = {} self.callbacks = [] if entries is None: entries = sys.path for entry in entries: self.add_entry(entry) @classmethod def _build_master(cls): """ Prepare the master working set. """ ws = cls() try: from __main__ import __requires__ except ImportError: # The main program does not list any requirements return ws # ensure the requirements are met try: ws.require(__requires__) except VersionConflict: return cls._build_from_requirements(__requires__) return ws @classmethod def _build_from_requirements(cls, req_spec): """ Build a working set from a requirement spec. Rewrites sys.path. """ # try it without defaults already on sys.path # by starting with an empty path ws = cls([]) reqs = parse_requirements(req_spec) dists = ws.resolve(reqs, Environment()) for dist in dists: ws.add(dist) # add any missing entries from sys.path for entry in sys.path: if entry not in ws.entries: ws.add_entry(entry) # then copy back to sys.path sys.path[:] = ws.entries return ws def add_entry(self, entry): """Add a path item to ``.entries``, finding any distributions on it ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than once, and the ``.entries`` of the ``sys.path`` WorkingSet should always equal ``sys.path``.) """ self.entry_keys.setdefault(entry, []) self.entries.append(entry) for dist in find_distributions(entry, True): self.add(dist, entry, False) def __contains__(self, dist): """True if `dist` is the active distribution for its project""" return self.by_key.get(dist.key) == dist def find(self, req): """Find a distribution matching requirement `req` If there is an active distribution for the requested project, this returns it as long as it meets the version requirement specified by `req`. But, if there is an active distribution for the project and it does *not* meet the `req` requirement, ``VersionConflict`` is raised. If there is no active distribution for the requested project, ``None`` is returned. """ dist = self.by_key.get(req.key) if dist is not None and dist not in req: # XXX add more info raise VersionConflict(dist, req) return dist def iter_entry_points(self, group, name=None): """Yield entry point objects from `group` matching `name` If `name` is None, yields all entry points in `group` from all distributions in the working set, otherwise only ones matching both `group` and `name` are yielded (in distribution order). """ for dist in self: entries = dist.get_entry_map(group) if name is None: for ep in entries.values(): yield ep elif name in entries: yield entries[name] def run_script(self, requires, script_name): """Locate distribution for `requires` and run `script_name` script""" ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name self.require(requires)[0].run_script(script_name, ns) def __iter__(self): """Yield distributions for non-duplicate projects in the working set The yield order is the order in which the items' path entries were added to the working set. """ seen = {} for item in self.entries: if item not in self.entry_keys: # workaround a cache issue continue for key in self.entry_keys[item]: if key not in seen: seen[key]=1 yield self.by_key[key] def add(self, dist, entry=None, insert=True, replace=False): """Add `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called. """ if insert: dist.insert_on(self.entries, entry) if entry is None: entry = dist.location keys = self.entry_keys.setdefault(entry,[]) keys2 = self.entry_keys.setdefault(dist.location,[]) if not replace and dist.key in self.by_key: # ignore hidden distros return self.by_key[dist.key] = dist if dist.key not in keys: keys.append(dist.key) if dist.key not in keys2: keys2.append(dist.key) self._added_new(dist) def resolve(self, requirements, env=None, installer=None, replace_conflicting=False): """List all distributions needed to (recursively) meet `requirements` `requirements` must be a sequence of ``Requirement`` objects. `env`, if supplied, should be an ``Environment`` instance. If not supplied, it defaults to all distributions available within any entry or distribution in the working set. `installer`, if supplied, will be invoked with each requirement that cannot be met by an already-installed distribution; it should return a ``Distribution`` or ``None``. Unless `replace_conflicting=True`, raises a VersionConflict exception if any requirements are found on the path that have the correct name but the wrong version. Otherwise, if an `installer` is supplied it will be invoked to obtain the correct version of the requirement and activate it. """ # set up the stack requirements = list(requirements)[::-1] # set of processed requirements processed = {} # key -> dist best = {} to_activate = [] # Mapping of requirement to set of distributions that required it; # useful for reporting info about conflicts. required_by = collections.defaultdict(set) while requirements: # process dependencies breadth-first req = requirements.pop(0) if req in processed: # Ignore cyclic or redundant dependencies continue dist = best.get(req.key) if dist is None: # Find the best distribution and add it to the map dist = self.by_key.get(req.key) if dist is None or (dist not in req and replace_conflicting): ws = self if env is None: if dist is None: env = Environment(self.entries) else: # Use an empty environment and workingset to avoid # any further conflicts with the conflicting # distribution env = Environment([]) ws = WorkingSet([]) dist = best[req.key] = env.best_match(req, ws, installer) if dist is None: requirers = required_by.get(req, None) raise DistributionNotFound(req, requirers) to_activate.append(dist) if dist not in req: # Oops, the "best" so far conflicts with a dependency dependent_req = required_by[req] raise VersionConflict(dist, req).with_context(dependent_req) # push the new requirements onto the stack new_requirements = dist.requires(req.extras)[::-1] requirements.extend(new_requirements) # Register the new requirements needed by req for new_requirement in new_requirements: required_by[new_requirement].add(req.project_name) processed[req] = True # return list of distros to activate return to_activate def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True): """Find all activatable distributions in `plugin_env` Example usage:: distributions, errors = working_set.find_plugins( Environment(plugin_dirlist) ) # add plugins+libs to sys.path map(working_set.add, distributions) # display errors print('Could not load', errors) The `plugin_env` should be an ``Environment`` instance that contains only distributions that are in the project's "plugin directory" or directories. The `full_env`, if supplied, should be an ``Environment`` contains all currently-available distributions. If `full_env` is not supplied, one is created automatically from the ``WorkingSet`` this method is called on, which will typically mean that every directory on ``sys.path`` will be scanned for distributions. `installer` is a standard installer callback as used by the ``resolve()`` method. The `fallback` flag indicates whether we should attempt to resolve older versions of a plugin if the newest version cannot be resolved. This method returns a 2-tuple: (`distributions`, `error_info`), where `distributions` is a list of the distributions found in `plugin_env` that were loadable, along with any other distributions that are needed to resolve their dependencies. `error_info` is a dictionary mapping unloadable plugin distributions to an exception instance describing the error that occurred. Usually this will be a ``DistributionNotFound`` or ``VersionConflict`` instance. """ plugin_projects = list(plugin_env) # scan project names in alphabetic order plugin_projects.sort() error_info = {} distributions = {} if full_env is None: env = Environment(self.entries) env += plugin_env else: env = full_env + plugin_env shadow_set = self.__class__([]) # put all our entries in shadow_set list(map(shadow_set.add, self)) for project_name in plugin_projects: for dist in plugin_env[project_name]: req = [dist.as_requirement()] try: resolvees = shadow_set.resolve(req, env, installer) except ResolutionError as v: # save error info error_info[dist] = v if fallback: # try the next older version of project continue else: # give up on this project, keep going break else: list(map(shadow_set.add, resolvees)) distributions.update(dict.fromkeys(resolvees)) # success, no need to try any more versions of this project break distributions = list(distributions) distributions.sort() return distributions, error_info def require(self, *requirements): """Ensure that distributions matching `requirements` are activated `requirements` must be a string or a (possibly-nested) sequence thereof, specifying the distributions and versions required. The return value is a sequence of the distributions that needed to be activated to fulfill the requirements; all relevant distributions are included, even if they were already activated in this working set. """ needed = self.resolve(parse_requirements(requirements)) for dist in needed: self.add(dist) return needed def subscribe(self, callback): """Invoke `callback` for all distributions (including existing ones)""" if callback in self.callbacks: return self.callbacks.append(callback) for dist in self: callback(dist) def _added_new(self, dist): for callback in self.callbacks: callback(dist) def __getstate__(self): return ( self.entries[:], self.entry_keys.copy(), self.by_key.copy(), self.callbacks[:] ) def __setstate__(self, e_k_b_c): entries, keys, by_key, callbacks = e_k_b_c self.entries = entries[:] self.entry_keys = keys.copy() self.by_key = by_key.copy() self.callbacks = callbacks[:] class Environment(object): """Searchable snapshot of distributions on a search path""" def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR): """Snapshot distributions available on a search path Any distributions found on `search_path` are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. `platform` is an optional string specifying the name of the platform that platform-specific distributions must be compatible with. If unspecified, it defaults to the current platform. `python` is an optional string naming the desired version of Python (e.g. ``'3.3'``); it defaults to the current version. You may explicitly set `platform` (and/or `python`) to ``None`` if you wish to map *all* distributions, not just those compatible with the running platform or Python version. """ self._distmap = {} self.platform = platform self.python = python self.scan(search_path) def can_add(self, dist): """Is distribution `dist` acceptable for this environment? The distribution must match the platform and python version requirements specified when this environment was created, or False is returned. """ return (self.python is None or dist.py_version is None or dist.py_version==self.python) \ and compatible_platforms(dist.platform, self.platform) def remove(self, dist): """Remove `dist` from the environment""" self._distmap[dist.key].remove(dist) def scan(self, search_path=None): """Scan `search_path` for distributions usable in this environment Any distributions found are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. Only distributions conforming to the platform/python version defined at initialization are added. """ if search_path is None: search_path = sys.path for item in search_path: for dist in find_distributions(item): self.add(dist) def __getitem__(self, project_name): """Return a newest-to-oldest list of distributions for `project_name` Uses case-insensitive `project_name` comparison, assuming all the project's distributions use their project's name converted to all lowercase as their key. """ distribution_key = project_name.lower() return self._distmap.get(distribution_key, []) def add(self, dist): """Add `dist` if we ``can_add()`` it and it has not already been added """ if self.can_add(dist) and dist.has_version(): dists = self._distmap.setdefault(dist.key, []) if dist not in dists: dists.append(dist) dists.sort(key=operator.attrgetter('hashcmp'), reverse=True) def best_match(self, req, working_set, installer=None): """Find distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitable version of the project is already active in the specified `working_set`.) If a suitable distribution isn't active, this method returns the newest distribution in the environment that meets the ``Requirement`` in `req`. If no suitable distribution is found, and `installer` is supplied, then the result of calling the environment's ``obtain(req, installer)`` method will be returned. """ dist = working_set.find(req) if dist is not None: return dist for dist in self[req.key]: if dist in req: return dist # try to download/install return self.obtain(req, installer) def obtain(self, requirement, installer=None): """Obtain a distribution matching `requirement` (e.g. via download) Obtain a distro that matches requirement (e.g. via download). In the base ``Environment`` class, this routine just returns ``installer(requirement)``, unless `installer` is None, in which case None is returned instead. This method is a hook that allows subclasses to attempt other ways of obtaining a distribution before falling back to the `installer` argument.""" if installer is not None: return installer(requirement) def __iter__(self): """Yield the unique project names of the available distributions""" for key in self._distmap.keys(): if self[key]: yield key def __iadd__(self, other): """In-place addition of a distribution or environment""" if isinstance(other, Distribution): self.add(other) elif isinstance(other, Environment): for project in other: for dist in other[project]: self.add(dist) else: raise TypeError("Can't add %r to environment" % (other,)) return self def __add__(self, other): """Add an environment or distribution to an environment""" new = self.__class__([], platform=None, python=None) for env in self, other: new += env return new # XXX backward compatibility AvailableDistributions = Environment class ExtractionError(RuntimeError): """An error occurred extracting a resource The following attributes are available from instances of this exception: manager The resource manager that raised this exception cache_path The base directory for resource extraction original_error The exception instance that caused extraction to fail """ class ResourceManager: """Manage resource extraction and packages""" extraction_path = None def __init__(self): self.cached_files = {} def resource_exists(self, package_or_requirement, resource_name): """Does the named resource exist?""" return get_provider(package_or_requirement).has_resource(resource_name) def resource_isdir(self, package_or_requirement, resource_name): """Is the named resource an existing directory?""" return get_provider(package_or_requirement).resource_isdir( resource_name ) def resource_filename(self, package_or_requirement, resource_name): """Return a true filesystem path for specified resource""" return get_provider(package_or_requirement).get_resource_filename( self, resource_name ) def resource_stream(self, package_or_requirement, resource_name): """Return a readable file-like object for specified resource""" return get_provider(package_or_requirement).get_resource_stream( self, resource_name ) def resource_string(self, package_or_requirement, resource_name): """Return specified resource as a string""" return get_provider(package_or_requirement).get_resource_string( self, resource_name ) def resource_listdir(self, package_or_requirement, resource_name): """List the contents of the named resource directory""" return get_provider(package_or_requirement).resource_listdir( resource_name ) def extraction_error(self): """Give an error message for problems extracting file(s)""" old_exc = sys.exc_info()[1] cache_path = self.extraction_path or get_default_cache() err = ExtractionError("""Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: %s The Python egg cache directory is currently set to: %s Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. """ % (old_exc, cache_path) ) err.manager = self err.cache_path = cache_path err.original_error = old_exc raise err def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including its ".egg" extension. `names`, if provided, should be a sequence of path name parts "under" the egg's extraction location. This method should only be called by resource providers that need to obtain an extraction location, and only for names they intend to extract, as it tracks the generated names for possible cleanup later. """ extract_path = self.extraction_path or get_default_cache() target_path = os.path.join(extract_path, archive_name+'-tmp', *names) try: _bypass_ensure_directory(target_path) except: self.extraction_error() self._warn_unsafe_extraction_path(extract_path) self.cached_files[target_path] = 1 return target_path @staticmethod def _warn_unsafe_extraction_path(path): """ If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used. See Distribute #375 for more details. """ if os.name == 'nt' and not path.startswith(os.environ['windir']): # On Windows, permissions are generally restrictive by default # and temp directories are not writable by other users, so # bypass the warning. return mode = os.stat(path).st_mode if mode & stat.S_IWOTH or mode & stat.S_IWGRP: msg = ("%s is writable by group/others and vulnerable to attack " "when " "used with get_resource_filename. Consider a more secure " "location (set with .set_extraction_path or the " "PYTHON_EGG_CACHE environment variable)." % path) warnings.warn(msg, UserWarning) def postprocess(self, tempname, filename): """Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully extracting a compressed resource. They must NOT call it on resources that are already in the filesystem. `tempname` is the current (temporary) name of the file, and `filename` is the name it will be renamed to by the caller after this routine returns. """ if os.name == 'posix': # Make the resource executable mode = ((os.stat(tempname).st_mode) | 0o555) & 0o7777 os.chmod(tempname, mode) def set_extraction_path(self, path): """Set the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` environment variable, with various platform-specific fallbacks. See that routine's documentation for more details.) Resources are extracted to subdirectories of this path based upon information given by the ``IResourceProvider``. You may set this to a temporary directory, but then you must call ``cleanup_resources()`` to delete the extracted files when done. There is no guarantee that ``cleanup_resources()`` will be able to remove all extracted files. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call ``cleanup_resources()``.) """ if self.cached_files: raise ValueError( "Can't change extraction path, files already extracted" ) self.extraction_path = path def cleanup_resources(self, force=False): """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary directory exclusive to a single process. This method is not automatically called; you must call it explicitly or register it as an ``atexit`` function if you wish to ensure cleanup of a temporary directory used for extractions. """ # XXX def get_default_cache(): """Determine the default cache location This returns the ``PYTHON_EGG_CACHE`` environment variable, if set. Otherwise, on Windows, it returns a "Python-Eggs" subdirectory of the "Application Data" directory. On all other systems, it's "~/.python-eggs". """ try: return os.environ['PYTHON_EGG_CACHE'] except KeyError: pass if os.name!='nt': return os.path.expanduser('~/.python-eggs') # XXX this may be locale-specific! app_data = 'Application Data' app_homes = [ # best option, should be locale-safe (('APPDATA',), None), (('USERPROFILE',), app_data), (('HOMEDRIVE','HOMEPATH'), app_data), (('HOMEPATH',), app_data), (('HOME',), None), # 95/98/ME (('WINDIR',), app_data), ] for keys, subdir in app_homes: dirname = '' for key in keys: if key in os.environ: dirname = os.path.join(dirname, os.environ[key]) else: break else: if subdir: dirname = os.path.join(dirname, subdir) return os.path.join(dirname, 'Python-Eggs') else: raise RuntimeError( "Please set the PYTHON_EGG_CACHE enviroment variable" ) def safe_name(name): """Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. """ return re.sub('[^A-Za-z0-9.]+', '-', name) def safe_version(version): """ Convert an arbitrary string to a standard version string """ try: # normalize the version return str(packaging.version.Version(version)) except packaging.version.InvalidVersion: version = version.replace(' ','.') return re.sub('[^A-Za-z0-9.]+', '-', version) def safe_extra(extra): """Convert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased. """ return re.sub('[^A-Za-z0-9.]+', '_', extra).lower() def to_filename(name): """Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. """ return name.replace('-','_') class MarkerEvaluation(object): values = { 'os_name': lambda: os.name, 'sys_platform': lambda: sys.platform, 'python_full_version': platform.python_version, 'python_version': lambda: platform.python_version()[:3], 'platform_version': platform.version, 'platform_machine': platform.machine, 'platform_python_implementation': platform.python_implementation, 'python_implementation': platform.python_implementation, } @classmethod def is_invalid_marker(cls, text): """ Validate text as a PEP 426 environment marker; return an exception if invalid or False otherwise. """ try: cls.evaluate_marker(text) except SyntaxError as e: return cls.normalize_exception(e) return False @staticmethod def normalize_exception(exc): """ Given a SyntaxError from a marker evaluation, normalize the error message: - Remove indications of filename and line number. - Replace platform-specific error messages with standard error messages. """ subs = { 'unexpected EOF while parsing': 'invalid syntax', 'parenthesis is never closed': 'invalid syntax', } exc.filename = None exc.lineno = None exc.msg = subs.get(exc.msg, exc.msg) return exc @classmethod def and_test(cls, nodelist): # MUST NOT short-circuit evaluation, or invalid syntax can be skipped! items = [ cls.interpret(nodelist[i]) for i in range(1, len(nodelist), 2) ] return functools.reduce(operator.and_, items) @classmethod def test(cls, nodelist): # MUST NOT short-circuit evaluation, or invalid syntax can be skipped! items = [ cls.interpret(nodelist[i]) for i in range(1, len(nodelist), 2) ] return functools.reduce(operator.or_, items) @classmethod def atom(cls, nodelist): t = nodelist[1][0] if t == token.LPAR: if nodelist[2][0] == token.RPAR: raise SyntaxError("Empty parentheses") return cls.interpret(nodelist[2]) msg = "Language feature not supported in environment markers" raise SyntaxError(msg) @classmethod def comparison(cls, nodelist): if len(nodelist) > 4: msg = "Chained comparison not allowed in environment markers" raise SyntaxError(msg) comp = nodelist[2][1] cop = comp[1] if comp[0] == token.NAME: if len(nodelist[2]) == 3: if cop == 'not': cop = 'not in' else: cop = 'is not' try: cop = cls.get_op(cop) except KeyError: msg = repr(cop) + " operator not allowed in environment markers" raise SyntaxError(msg) return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3])) @classmethod def get_op(cls, op): ops = { symbol.test: cls.test, symbol.and_test: cls.and_test, symbol.atom: cls.atom, symbol.comparison: cls.comparison, 'not in': lambda x, y: x not in y, 'in': lambda x, y: x in y, '==': operator.eq, '!=': operator.ne, '<': operator.lt, '>': operator.gt, '<=': operator.le, '>=': operator.ge, } if hasattr(symbol, 'or_test'): ops[symbol.or_test] = cls.test return ops[op] @classmethod def evaluate_marker(cls, text, extra=None): """ Evaluate a PEP 426 environment marker on CPython 2.4+. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'parser' module, which is not implemented on Jython and has been superseded by the 'ast' module in Python 2.6 and later. """ return cls.interpret(parser.expr(text).totuple(1)[1]) @staticmethod def _translate_metadata2(env): """ Markerlib implements Metadata 1.2 (PEP 345) environment markers. Translate the variables to Metadata 2.0 (PEP 426). """ return dict( (key.replace('.', '_'), value) for key, value in env ) @classmethod def _markerlib_evaluate(cls, text): """ Evaluate a PEP 426 environment marker using markerlib. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. """ import _markerlib env = cls._translate_metadata2(_markerlib.default_environment()) try: result = _markerlib.interpret(text, env) except NameError as e: raise SyntaxError(e.args[0]) return result if 'parser' not in globals(): # Fall back to less-complete _markerlib implementation if 'parser' module # is not available. evaluate_marker = _markerlib_evaluate @classmethod def interpret(cls, nodelist): while len(nodelist)==2: nodelist = nodelist[1] try: op = cls.get_op(nodelist[0]) except KeyError: raise SyntaxError("Comparison or logical expression expected") return op(nodelist) @classmethod def evaluate(cls, nodelist): while len(nodelist)==2: nodelist = nodelist[1] kind = nodelist[0] name = nodelist[1] if kind==token.NAME: try: op = cls.values[name] except KeyError: raise SyntaxError("Unknown name %r" % name) return op() if kind==token.STRING: s = nodelist[1] if not cls._safe_string(s): raise SyntaxError( "Only plain strings allowed in environment markers") return s[1:-1] msg = "Language feature not supported in environment markers" raise SyntaxError(msg) @staticmethod def _safe_string(cand): return ( cand[:1] in "'\"" and not cand.startswith('"""') and not cand.startswith("'''") and '\\' not in cand ) invalid_marker = MarkerEvaluation.is_invalid_marker evaluate_marker = MarkerEvaluation.evaluate_marker class NullProvider: """Try to implement resources and metadata for arbitrary PEP 302 loaders""" egg_name = None egg_info = None loader = None def __init__(self, module): self.loader = getattr(module, '__loader__', None) self.module_path = os.path.dirname(getattr(module, '__file__', '')) def get_resource_filename(self, manager, resource_name): return self._fn(self.module_path, resource_name) def get_resource_stream(self, manager, resource_name): return io.BytesIO(self.get_resource_string(manager, resource_name)) def get_resource_string(self, manager, resource_name): return self._get(self._fn(self.module_path, resource_name)) def has_resource(self, resource_name): return self._has(self._fn(self.module_path, resource_name)) def has_metadata(self, name): return self.egg_info and self._has(self._fn(self.egg_info, name)) if sys.version_info <= (3,): def get_metadata(self, name): if not self.egg_info: return "" return self._get(self._fn(self.egg_info, name)) else: def get_metadata(self, name): if not self.egg_info: return "" return self._get(self._fn(self.egg_info, name)).decode("utf-8") def get_metadata_lines(self, name): return yield_lines(self.get_metadata(name)) def resource_isdir(self, resource_name): return self._isdir(self._fn(self.module_path, resource_name)) def metadata_isdir(self, name): return self.egg_info and self._isdir(self._fn(self.egg_info, name)) def resource_listdir(self, resource_name): return self._listdir(self._fn(self.module_path, resource_name)) def metadata_listdir(self, name): if self.egg_info: return self._listdir(self._fn(self.egg_info, name)) return [] def run_script(self, script_name, namespace): script = 'scripts/'+script_name if not self.has_metadata(script): raise ResolutionError("No script named %r" % script_name) script_text = self.get_metadata(script).replace('\r\n', '\n') script_text = script_text.replace('\r', '\n') script_filename = self._fn(self.egg_info, script) namespace['__file__'] = script_filename if os.path.exists(script_filename): source = open(script_filename).read() code = compile(source, script_filename, 'exec') exec(code, namespace, namespace) else: from linecache import cache cache[script_filename] = ( len(script_text), 0, script_text.split('\n'), script_filename ) script_code = compile(script_text, script_filename,'exec') exec(script_code, namespace, namespace) def _has(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _isdir(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _listdir(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _fn(self, base, resource_name): if resource_name: return os.path.join(base, *resource_name.split('/')) return base def _get(self, path): if hasattr(self.loader, 'get_data'): return self.loader.get_data(path) raise NotImplementedError( "Can't perform this operation for loaders without 'get_data()'" ) register_loader_type(object, NullProvider) class EggProvider(NullProvider): """Provider based on a virtual filesystem""" def __init__(self, module): NullProvider.__init__(self, module) self._setup_prefix() def _setup_prefix(self): # we assume here that our metadata may be nested inside a "basket" # of multiple eggs; that's why we use module_path instead of .archive path = self.module_path old = None while path!=old: if _is_unpacked_egg(path): self.egg_name = os.path.basename(path) self.egg_info = os.path.join(path, 'EGG-INFO') self.egg_root = path break old = path path, base = os.path.split(path) class DefaultProvider(EggProvider): """Provides access to package resources in the filesystem""" def _has(self, path): return os.path.exists(path) def _isdir(self, path): return os.path.isdir(path) def _listdir(self, path): return os.listdir(path) def get_resource_stream(self, manager, resource_name): return open(self._fn(self.module_path, resource_name), 'rb') def _get(self, path): with open(path, 'rb') as stream: return stream.read() register_loader_type(type(None), DefaultProvider) if importlib_machinery is not None: register_loader_type(importlib_machinery.SourceFileLoader, DefaultProvider) class EmptyProvider(NullProvider): """Provider that returns nothing for all requests""" _isdir = _has = lambda self, path: False _get = lambda self, path: '' _listdir = lambda self, path: [] module_path = None def __init__(self): pass empty_provider = EmptyProvider() class ZipManifests(dict): """ zip manifest builder """ @classmethod def build(cls, path): """ Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects. Use a platform-specific path separator (os.sep) for the path keys for compatibility with pypy on Windows. """ with ContextualZipFile(path) as zfile: items = ( ( name.replace('/', os.sep), zfile.getinfo(name), ) for name in zfile.namelist() ) return dict(items) load = build class MemoizedZipManifests(ZipManifests): """ Memoized zipfile manifests. """ manifest_mod = collections.namedtuple('manifest_mod', 'manifest mtime') def load(self, path): """ Load a manifest at path or return a suitable manifest already loaded. """ path = os.path.normpath(path) mtime = os.stat(path).st_mtime if path not in self or self[path].mtime != mtime: manifest = self.build(path) self[path] = self.manifest_mod(manifest, mtime) return self[path].manifest class ContextualZipFile(zipfile.ZipFile): """ Supplement ZipFile class to support context manager for Python 2.6 """ def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def __new__(cls, *args, **kwargs): """ Construct a ZipFile or ContextualZipFile as appropriate """ if hasattr(zipfile.ZipFile, '__exit__'): return zipfile.ZipFile(*args, **kwargs) return super(ContextualZipFile, cls).__new__(cls) class ZipProvider(EggProvider): """Resource support for zips and eggs""" eagers = None _zip_manifests = MemoizedZipManifests() def __init__(self, module): EggProvider.__init__(self, module) self.zip_pre = self.loader.archive+os.sep def _zipinfo_name(self, fspath): # Convert a virtual filename (full path to file) into a zipfile subpath # usable with the zipimport directory cache for our target archive if fspath.startswith(self.zip_pre): return fspath[len(self.zip_pre):] raise AssertionError( "%s is not a subpath of %s" % (fspath, self.zip_pre) ) def _parts(self, zip_path): # Convert a zipfile subpath into an egg-relative path part list. # pseudo-fs path fspath = self.zip_pre+zip_path if fspath.startswith(self.egg_root+os.sep): return fspath[len(self.egg_root)+1:].split(os.sep) raise AssertionError( "%s is not a subpath of %s" % (fspath, self.egg_root) ) @property def zipinfo(self): return self._zip_manifests.load(self.loader.archive) def get_resource_filename(self, manager, resource_name): if not self.egg_name: raise NotImplementedError( "resource_filename() only supported for .egg, not .zip" ) # no need to lock for extraction, since we use temp names zip_path = self._resource_to_zip(resource_name) eagers = self._get_eager_resources() if '/'.join(self._parts(zip_path)) in eagers: for name in eagers: self._extract_resource(manager, self._eager_to_zip(name)) return self._extract_resource(manager, zip_path) @staticmethod def _get_date_and_size(zip_stat): size = zip_stat.file_size # ymdhms+wday, yday, dst date_time = zip_stat.date_time + (0, 0, -1) # 1980 offset already done timestamp = time.mktime(date_time) return timestamp, size def _extract_resource(self, manager, zip_path): if zip_path in self._index(): for name in self._index()[zip_path]: last = self._extract_resource( manager, os.path.join(zip_path, name) ) # return the extracted directory name return os.path.dirname(last) timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not WRITE_SUPPORT: raise IOError('"os.rename" and "os.unlink" are not supported ' 'on this platform') try: real_path = manager.get_cache_path( self.egg_name, self._parts(zip_path) ) if self._is_current(real_path, zip_path): return real_path outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path)) os.write(outf, self.loader.get_data(zip_path)) os.close(outf) utime(tmpnam, (timestamp, timestamp)) manager.postprocess(tmpnam, real_path) try: rename(tmpnam, real_path) except os.error: if os.path.isfile(real_path): if self._is_current(real_path, zip_path): # the file became current since it was checked above, # so proceed. return real_path # Windows, del old file and retry elif os.name=='nt': unlink(real_path) rename(tmpnam, real_path) return real_path raise except os.error: # report a user-friendly error manager.extraction_error() return real_path def _is_current(self, file_path, zip_path): """ Return True if the file_path is current for this zip_path """ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not os.path.isfile(file_path): return False stat = os.stat(file_path) if stat.st_size!=size or stat.st_mtime!=timestamp: return False # check that the contents match zip_contents = self.loader.get_data(zip_path) with open(file_path, 'rb') as f: file_contents = f.read() return zip_contents == file_contents def _get_eager_resources(self): if self.eagers is None: eagers = [] for name in ('native_libs.txt', 'eager_resources.txt'): if self.has_metadata(name): eagers.extend(self.get_metadata_lines(name)) self.eagers = eagers return self.eagers def _index(self): try: return self._dirindex except AttributeError: ind = {} for path in self.zipinfo: parts = path.split(os.sep) while parts: parent = os.sep.join(parts[:-1]) if parent in ind: ind[parent].append(parts[-1]) break else: ind[parent] = [parts.pop()] self._dirindex = ind return ind def _has(self, fspath): zip_path = self._zipinfo_name(fspath) return zip_path in self.zipinfo or zip_path in self._index() def _isdir(self, fspath): return self._zipinfo_name(fspath) in self._index() def _listdir(self, fspath): return list(self._index().get(self._zipinfo_name(fspath), ())) def _eager_to_zip(self, resource_name): return self._zipinfo_name(self._fn(self.egg_root, resource_name)) def _resource_to_zip(self, resource_name): return self._zipinfo_name(self._fn(self.module_path, resource_name)) register_loader_type(zipimport.zipimporter, ZipProvider) class FileMetadata(EmptyProvider): """Metadata handler for standalone PKG-INFO files Usage:: metadata = FileMetadata("/path/to/PKG-INFO") This provider rejects all data and metadata requests except for PKG-INFO, which is treated as existing, and will be the contents of the file at the provided location. """ def __init__(self, path): self.path = path def has_metadata(self, name): return name=='PKG-INFO' def get_metadata(self, name): if name=='PKG-INFO': with open(self.path,'rU') as f: metadata = f.read() return metadata raise KeyError("No metadata except PKG-INFO is available") def get_metadata_lines(self, name): return yield_lines(self.get_metadata(name)) class PathMetadata(DefaultProvider): """Metadata provider for egg directories Usage:: # Development eggs: egg_info = "/path/to/PackageName.egg-info" base_dir = os.path.dirname(egg_info) metadata = PathMetadata(base_dir, egg_info) dist_name = os.path.splitext(os.path.basename(egg_info))[0] dist = Distribution(basedir, project_name=dist_name, metadata=metadata) # Unpacked egg directories: egg_path = "/path/to/PackageName-ver-pyver-etc.egg" metadata = PathMetadata(egg_path, os.path.join(egg_path,'EGG-INFO')) dist = Distribution.from_filename(egg_path, metadata=metadata) """ def __init__(self, path, egg_info): self.module_path = path self.egg_info = egg_info class EggMetadata(ZipProvider): """Metadata provider for .egg files""" def __init__(self, importer): """Create a metadata provider from a zipimporter""" self.zip_pre = importer.archive+os.sep self.loader = importer if importer.prefix: self.module_path = os.path.join(importer.archive, importer.prefix) else: self.module_path = importer.archive self._setup_prefix() _declare_state('dict', _distribution_finders = {}) def register_finder(importer_type, distribution_finder): """Register `distribution_finder` to find distributions in sys.path items `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `distribution_finder` is a callable that, passed a path item and the importer instance, yields ``Distribution`` instances found on that path item. See ``pkg_resources.find_on_path`` for an example.""" _distribution_finders[importer_type] = distribution_finder def find_distributions(path_item, only=False): """Yield distributions accessible via `path_item`""" importer = get_importer(path_item) finder = _find_adapter(_distribution_finders, importer) return finder(importer, path_item, only) def find_eggs_in_zip(importer, path_item, only=False): """ Find eggs in zip files; possibly multiple nested eggs. """ if importer.archive.endswith('.whl'): # wheels are not supported with this finder # they don't have PKG-INFO metadata, and won't ever contain eggs return metadata = EggMetadata(importer) if metadata.has_metadata('PKG-INFO'): yield Distribution.from_filename(path_item, metadata=metadata) if only: # don't yield nested distros return for subitem in metadata.resource_listdir('/'): if _is_unpacked_egg(subitem): subpath = os.path.join(path_item, subitem) for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath): yield dist register_finder(zipimport.zipimporter, find_eggs_in_zip) def find_nothing(importer, path_item, only=False): return () register_finder(object, find_nothing) def find_on_path(importer, path_item, only=False): """Yield distributions accessible on a sys.path directory""" path_item = _normalize_cached(path_item) if os.path.isdir(path_item) and os.access(path_item, os.R_OK): if _is_unpacked_egg(path_item): yield Distribution.from_filename( path_item, metadata=PathMetadata( path_item, os.path.join(path_item,'EGG-INFO') ) ) else: # scan for .egg and .egg-info in directory for entry in os.listdir(path_item): lower = entry.lower() if lower.endswith('.egg-info') or lower.endswith('.dist-info'): fullpath = os.path.join(path_item, entry) if os.path.isdir(fullpath): # egg-info directory, allow getting metadata metadata = PathMetadata(path_item, fullpath) else: metadata = FileMetadata(fullpath) yield Distribution.from_location( path_item, entry, metadata, precedence=DEVELOP_DIST ) elif not only and _is_unpacked_egg(entry): dists = find_distributions(os.path.join(path_item, entry)) for dist in dists: yield dist elif not only and lower.endswith('.egg-link'): with open(os.path.join(path_item, entry)) as entry_file: entry_lines = entry_file.readlines() for line in entry_lines: if not line.strip(): continue path = os.path.join(path_item, line.rstrip()) dists = find_distributions(path) for item in dists: yield item break register_finder(pkgutil.ImpImporter, find_on_path) if importlib_machinery is not None: register_finder(importlib_machinery.FileFinder, find_on_path) _declare_state('dict', _namespace_handlers={}) _declare_state('dict', _namespace_packages={}) def register_namespace_handler(importer_type, namespace_handler): """Register `namespace_handler` to declare namespace packages `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `namespace_handler` is a callable like this:: def namespace_handler(importer, path_entry, moduleName, module): # return a path_entry to use for child packages Namespace handlers are only called if the importer object has already agreed that it can handle the relevant path item, and they should only return a subpath if the module __path__ does not already contain an equivalent subpath. For an example namespace handler, see ``pkg_resources.file_ns_handler``. """ _namespace_handlers[importer_type] = namespace_handler def _handle_ns(packageName, path_item): """Ensure that named package includes a subpath of path_item (if needed)""" importer = get_importer(path_item) if importer is None: return None loader = importer.find_module(packageName) if loader is None: return None module = sys.modules.get(packageName) if module is None: module = sys.modules[packageName] = types.ModuleType(packageName) module.__path__ = [] _set_parent_ns(packageName) elif not hasattr(module,'__path__'): raise TypeError("Not a package:", packageName) handler = _find_adapter(_namespace_handlers, importer) subpath = handler(importer, path_item, packageName, module) if subpath is not None: path = module.__path__ path.append(subpath) loader.load_module(packageName) for path_item in path: if path_item not in module.__path__: module.__path__.append(path_item) return subpath def declare_namespace(packageName): """Declare that package 'packageName' is a namespace package""" _imp.acquire_lock() try: if packageName in _namespace_packages: return path, parent = sys.path, None if '.' in packageName: parent = '.'.join(packageName.split('.')[:-1]) declare_namespace(parent) if parent not in _namespace_packages: __import__(parent) try: path = sys.modules[parent].__path__ except AttributeError: raise TypeError("Not a package:", parent) # Track what packages are namespaces, so when new path items are added, # they can be updated _namespace_packages.setdefault(parent,[]).append(packageName) _namespace_packages.setdefault(packageName,[]) for path_item in path: # Ensure all the parent's path items are reflected in the child, # if they apply _handle_ns(packageName, path_item) finally: _imp.release_lock() def fixup_namespace_packages(path_item, parent=None): """Ensure that previously-declared namespace packages include path_item""" _imp.acquire_lock() try: for package in _namespace_packages.get(parent,()): subpath = _handle_ns(package, path_item) if subpath: fixup_namespace_packages(subpath, package) finally: _imp.release_lock() def file_ns_handler(importer, path_item, packageName, module): """Compute an ns-package subpath for a filesystem or zipfile importer""" subpath = os.path.join(path_item, packageName.split('.')[-1]) normalized = _normalize_cached(subpath) for item in module.__path__: if _normalize_cached(item)==normalized: break else: # Only return the path if it's not already there return subpath register_namespace_handler(pkgutil.ImpImporter, file_ns_handler) register_namespace_handler(zipimport.zipimporter, file_ns_handler) if importlib_machinery is not None: register_namespace_handler(importlib_machinery.FileFinder, file_ns_handler) def null_ns_handler(importer, path_item, packageName, module): return None register_namespace_handler(object, null_ns_handler) def normalize_path(filename): """Normalize a file/dir name for comparison purposes""" return os.path.normcase(os.path.realpath(filename)) def _normalize_cached(filename, _cache={}): try: return _cache[filename] except KeyError: _cache[filename] = result = normalize_path(filename) return result def _is_unpacked_egg(path): """ Determine if given path appears to be an unpacked egg. """ return ( path.lower().endswith('.egg') ) def _set_parent_ns(packageName): parts = packageName.split('.') name = parts.pop() if parts: parent = '.'.join(parts) setattr(sys.modules[parent], name, sys.modules[packageName]) def yield_lines(strs): """Yield non-empty/non-comment lines of a string or sequence""" if isinstance(strs, string_types): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments if s and not s.startswith('#'): yield s else: for ss in strs: for s in yield_lines(ss): yield s # whitespace and comment LINE_END = re.compile(r"\s*(#.*)?$").match # line continuation CONTINUE = re.compile(r"\s*\\\s*(#.*)?$").match # Distribution or extra DISTRO = re.compile(r"\s*((\w|[-.])+)").match # ver. info VERSION = re.compile(r"\s*(<=?|>=?|===?|!=|~=)\s*((\w|[-.*_!+])+)").match # comma between items COMMA = re.compile(r"\s*,").match OBRACKET = re.compile(r"\s*\[").match CBRACKET = re.compile(r"\s*\]").match MODULE = re.compile(r"\w+(\.\w+)*$").match EGG_NAME = re.compile( r""" (?P<name>[^-]+) ( -(?P<ver>[^-]+) ( -py(?P<pyver>[^-]+) ( -(?P<plat>.+) )? )? )? """, re.VERBOSE | re.IGNORECASE, ).match class EntryPoint(object): """Object representing an advertised importable object""" def __init__(self, name, module_name, attrs=(), extras=(), dist=None): if not MODULE(module_name): raise ValueError("Invalid module name", module_name) self.name = name self.module_name = module_name self.attrs = tuple(attrs) self.extras = Requirement.parse(("x[%s]" % ','.join(extras))).extras self.dist = dist def __str__(self): s = "%s = %s" % (self.name, self.module_name) if self.attrs: s += ':' + '.'.join(self.attrs) if self.extras: s += ' [%s]' % ','.join(self.extras) return s def __repr__(self): return "EntryPoint.parse(%r)" % str(self) def load(self, require=True, *args, **kwargs): """ Require packages for this EntryPoint, then resolve it. """ if not require or args or kwargs: warnings.warn( "Parameters to load are deprecated. Call .resolve and " ".require separately.", DeprecationWarning, stacklevel=2, ) if require: self.require(*args, **kwargs) return self.resolve() def resolve(self): """ Resolve the entry point from its module and attrs. """ module = __import__(self.module_name, fromlist=['__name__'], level=0) try: return functools.reduce(getattr, self.attrs, module) except AttributeError as exc: raise ImportError(str(exc)) def require(self, env=None, installer=None): if self.extras and not self.dist: raise UnknownExtra("Can't require() without a distribution", self) reqs = self.dist.requires(self.extras) items = working_set.resolve(reqs, env, installer) list(map(working_set.add, items)) pattern = re.compile( r'\s*' r'(?P<name>.+?)\s*' r'=\s*' r'(?P<module>[\w.]+)\s*' r'(:\s*(?P<attr>[\w.]+))?\s*' r'(?P<extras>\[.*\])?\s*$' ) @classmethod def parse(cls, src, dist=None): """Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional """ m = cls.pattern.match(src) if not m: msg = "EntryPoint must be in 'name=module:attrs [extras]' format" raise ValueError(msg, src) res = m.groupdict() extras = cls._parse_extras(res['extras']) attrs = res['attr'].split('.') if res['attr'] else () return cls(res['name'], res['module'], attrs, extras, dist) @classmethod def _parse_extras(cls, extras_spec): if not extras_spec: return () req = Requirement.parse('x' + extras_spec) if req.specs: raise ValueError() return req.extras @classmethod def parse_group(cls, group, lines, dist=None): """Parse an entry point group""" if not MODULE(group): raise ValueError("Invalid group name", group) this = {} for line in yield_lines(lines): ep = cls.parse(line, dist) if ep.name in this: raise ValueError("Duplicate entry point", group, ep.name) this[ep.name]=ep return this @classmethod def parse_map(cls, data, dist=None): """Parse a map of entry point groups""" if isinstance(data, dict): data = data.items() else: data = split_sections(data) maps = {} for group, lines in data: if group is None: if not lines: continue raise ValueError("Entry points must be listed in groups") group = group.strip() if group in maps: raise ValueError("Duplicate group name", group) maps[group] = cls.parse_group(group, lines, dist) return maps def _remove_md5_fragment(location): if not location: return '' parsed = urlparse(location) if parsed[-1].startswith('md5='): return urlunparse(parsed[:-1] + ('',)) return location class Distribution(object): """Wrap an actual or potential sys.path entry w/metadata""" PKG_INFO = 'PKG-INFO' def __init__(self, location=None, metadata=None, project_name=None, version=None, py_version=PY_MAJOR, platform=None, precedence=EGG_DIST): self.project_name = safe_name(project_name or 'Unknown') if version is not None: self._version = safe_version(version) self.py_version = py_version self.platform = platform self.location = location self.precedence = precedence self._provider = metadata or empty_provider @classmethod def from_location(cls, location, basename, metadata=None,**kw): project_name, version, py_version, platform = [None]*4 basename, ext = os.path.splitext(basename) if ext.lower() in _distributionImpl: # .dist-info gets much metadata differently match = EGG_NAME(basename) if match: project_name, version, py_version, platform = match.group( 'name','ver','pyver','plat' ) cls = _distributionImpl[ext.lower()] return cls( location, metadata, project_name=project_name, version=version, py_version=py_version, platform=platform, **kw ) @property def hashcmp(self): return ( self.parsed_version, self.precedence, self.key, _remove_md5_fragment(self.location), self.py_version or '', self.platform or '', ) def __hash__(self): return hash(self.hashcmp) def __lt__(self, other): return self.hashcmp < other.hashcmp def __le__(self, other): return self.hashcmp <= other.hashcmp def __gt__(self, other): return self.hashcmp > other.hashcmp def __ge__(self, other): return self.hashcmp >= other.hashcmp def __eq__(self, other): if not isinstance(other, self.__class__): # It's not a Distribution, so they are not equal return False return self.hashcmp == other.hashcmp def __ne__(self, other): return not self == other # These properties have to be lazy so that we don't have to load any # metadata until/unless it's actually needed. (i.e., some distributions # may not know their name or version without loading PKG-INFO) @property def key(self): try: return self._key except AttributeError: self._key = key = self.project_name.lower() return key @property def parsed_version(self): if not hasattr(self, "_parsed_version"): self._parsed_version = parse_version(self.version) return self._parsed_version def _warn_legacy_version(self): LV = packaging.version.LegacyVersion is_legacy = isinstance(self._parsed_version, LV) if not is_legacy: return # While an empty version is technically a legacy version and # is not a valid PEP 440 version, it's also unlikely to # actually come from someone and instead it is more likely that # it comes from setuptools attempting to parse a filename and # including it in the list. So for that we'll gate this warning # on if the version is anything at all or not. if not self.version: return tmpl = textwrap.dedent(""" '{project_name} ({version})' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommended to migrate to PEP 440 compatible versions. """).strip().replace('\n', ' ') warnings.warn(tmpl.format(**vars(self)), PEP440Warning) @property def version(self): try: return self._version except AttributeError: for line in self._get_metadata(self.PKG_INFO): if line.lower().startswith('version:'): self._version = safe_version(line.split(':',1)[1].strip()) return self._version else: tmpl = "Missing 'Version:' header and/or %s file" raise ValueError(tmpl % self.PKG_INFO, self) @property def _dep_map(self): try: return self.__dep_map except AttributeError: dm = self.__dep_map = {None: []} for name in 'requires.txt', 'depends.txt': for extra, reqs in split_sections(self._get_metadata(name)): if extra: if ':' in extra: extra, marker = extra.split(':', 1) if invalid_marker(marker): # XXX warn reqs=[] elif not evaluate_marker(marker): reqs=[] extra = safe_extra(extra) or None dm.setdefault(extra,[]).extend(parse_requirements(reqs)) return dm def requires(self, extras=()): """List of Requirements needed for this distro if `extras` are used""" dm = self._dep_map deps = [] deps.extend(dm.get(None, ())) for ext in extras: try: deps.extend(dm[safe_extra(ext)]) except KeyError: raise UnknownExtra( "%s has no such extra feature %r" % (self, ext) ) return deps def _get_metadata(self, name): if self.has_metadata(name): for line in self.get_metadata_lines(name): yield line def activate(self, path=None): """Ensure distribution is importable on `path` (default=sys.path)""" if path is None: path = sys.path self.insert_on(path) if path is sys.path: fixup_namespace_packages(self.location) for pkg in self._get_metadata('namespace_packages.txt'): if pkg in sys.modules: declare_namespace(pkg) def egg_name(self): """Return what this distribution's standard .egg filename should be""" filename = "%s-%s-py%s" % ( to_filename(self.project_name), to_filename(self.version), self.py_version or PY_MAJOR ) if self.platform: filename += '-' + self.platform return filename def __repr__(self): if self.location: return "%s (%s)" % (self, self.location) else: return str(self) def __str__(self): try: version = getattr(self, 'version', None) except ValueError: version = None version = version or "[unknown version]" return "%s %s" % (self.project_name, version) def __getattr__(self, attr): """Delegate all unrecognized public attributes to .metadata provider""" if attr.startswith('_'): raise AttributeError(attr) return getattr(self._provider, attr) @classmethod def from_filename(cls, filename, metadata=None, **kw): return cls.from_location( _normalize_cached(filename), os.path.basename(filename), metadata, **kw ) def as_requirement(self): """Return a ``Requirement`` that matches this distribution exactly""" if isinstance(self.parsed_version, packaging.version.Version): spec = "%s==%s" % (self.project_name, self.parsed_version) else: spec = "%s===%s" % (self.project_name, self.parsed_version) return Requirement.parse(spec) def load_entry_point(self, group, name): """Return the `name` entry point of `group` or raise ImportError""" ep = self.get_entry_info(group, name) if ep is None: raise ImportError("Entry point %r not found" % ((group, name),)) return ep.load() def get_entry_map(self, group=None): """Return the entry point map for `group`, or the full entry map""" try: ep_map = self._ep_map except AttributeError: ep_map = self._ep_map = EntryPoint.parse_map( self._get_metadata('entry_points.txt'), self ) if group is not None: return ep_map.get(group,{}) return ep_map def get_entry_info(self, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return self.get_entry_map(group).get(name) def insert_on(self, path, loc = None): """Insert self.location in path before its nearest parent directory""" loc = loc or self.location if not loc: return nloc = _normalize_cached(loc) bdir = os.path.dirname(nloc) npath= [(p and _normalize_cached(p) or p) for p in path] for p, item in enumerate(npath): if item == nloc: break elif item == bdir and self.precedence == EGG_DIST: # if it's an .egg, give it precedence over its directory if path is sys.path: self.check_version_conflict() path.insert(p, loc) npath.insert(p, nloc) break else: if path is sys.path: self.check_version_conflict() path.append(loc) return # p is the spot where we found or inserted loc; now remove duplicates while True: try: np = npath.index(nloc, p+1) except ValueError: break else: del npath[np], path[np] # ha! p = np return def check_version_conflict(self): if self.key == 'setuptools': # ignore the inevitable setuptools self-conflicts :( return nsp = dict.fromkeys(self._get_metadata('namespace_packages.txt')) loc = normalize_path(self.location) for modname in self._get_metadata('top_level.txt'): if (modname not in sys.modules or modname in nsp or modname in _namespace_packages): continue if modname in ('pkg_resources', 'setuptools', 'site'): continue fn = getattr(sys.modules[modname], '__file__', None) if fn and (normalize_path(fn).startswith(loc) or fn.startswith(self.location)): continue issue_warning( "Module %s was already imported from %s, but %s is being added" " to sys.path" % (modname, fn, self.location), ) def has_version(self): try: self.version except ValueError: issue_warning("Unbuilt egg for " + repr(self)) return False return True def clone(self,**kw): """Copy this distribution, substituting in any changed keyword args""" names = 'project_name version py_version platform location precedence' for attr in names.split(): kw.setdefault(attr, getattr(self, attr, None)) kw.setdefault('metadata', self._provider) return self.__class__(**kw) @property def extras(self): return [dep for dep in self._dep_map if dep] class DistInfoDistribution(Distribution): """Wrap an actual or potential sys.path entry w/metadata, .dist-info style""" PKG_INFO = 'METADATA' EQEQ = re.compile(r"([\(,])\s*(\d.*?)\s*([,\)])") @property def _parsed_pkg_info(self): """Parse and cache metadata""" try: return self._pkg_info except AttributeError: metadata = self.get_metadata(self.PKG_INFO) self._pkg_info = email.parser.Parser().parsestr(metadata) return self._pkg_info @property def _dep_map(self): try: return self.__dep_map except AttributeError: self.__dep_map = self._compute_dependencies() return self.__dep_map def _preparse_requirement(self, requires_dist): """Convert 'Foobar (1); baz' to ('Foobar ==1', 'baz') Split environment marker, add == prefix to version specifiers as necessary, and remove parenthesis. """ parts = requires_dist.split(';', 1) + [''] distvers = parts[0].strip() mark = parts[1].strip() distvers = re.sub(self.EQEQ, r"\1==\2\3", distvers) distvers = distvers.replace('(', '').replace(')', '') return (distvers, mark) def _compute_dependencies(self): """Recompute this distribution's dependencies.""" from _markerlib import compile as compile_marker dm = self.__dep_map = {None: []} reqs = [] # Including any condition expressions for req in self._parsed_pkg_info.get_all('Requires-Dist') or []: distvers, mark = self._preparse_requirement(req) parsed = next(parse_requirements(distvers)) parsed.marker_fn = compile_marker(mark) reqs.append(parsed) def reqs_for_extra(extra): for req in reqs: if req.marker_fn(override={'extra':extra}): yield req common = frozenset(reqs_for_extra(None)) dm[None].extend(common) for extra in self._parsed_pkg_info.get_all('Provides-Extra') or []: extra = safe_extra(extra.strip()) dm[extra] = list(frozenset(reqs_for_extra(extra)) - common) return dm _distributionImpl = { '.egg': Distribution, '.egg-info': Distribution, '.dist-info': DistInfoDistribution, } def issue_warning(*args,**kw): level = 1 g = globals() try: # find the first stack frame that is *not* code in # the pkg_resources module, to use for the warning while sys._getframe(level).f_globals is g: level += 1 except ValueError: pass warnings.warn(stacklevel=level + 1, *args, **kw) class RequirementParseError(ValueError): def __str__(self): return ' '.join(self.args) def parse_requirements(strs): """Yield ``Requirement`` objects for each specification in `strs` `strs` must be a string, or a (possibly-nested) iterable thereof. """ # create a steppable iterator, so we can handle \-continuations lines = iter(yield_lines(strs)) def scan_list(ITEM, TERMINATOR, line, p, groups, item_name): items = [] while not TERMINATOR(line, p): if CONTINUE(line, p): try: line = next(lines) p = 0 except StopIteration: msg = "\\ must not appear on the last nonblank line" raise RequirementParseError(msg) match = ITEM(line, p) if not match: msg = "Expected " + item_name + " in" raise RequirementParseError(msg, line, "at", line[p:]) items.append(match.group(*groups)) p = match.end() match = COMMA(line, p) if match: # skip the comma p = match.end() elif not TERMINATOR(line, p): msg = "Expected ',' or end-of-list in" raise RequirementParseError(msg, line, "at", line[p:]) match = TERMINATOR(line, p) # skip the terminator, if any if match: p = match.end() return line, p, items for line in lines: match = DISTRO(line) if not match: raise RequirementParseError("Missing distribution spec", line) project_name = match.group(1) p = match.end() extras = [] match = OBRACKET(line, p) if match: p = match.end() line, p, extras = scan_list( DISTRO, CBRACKET, line, p, (1,), "'extra' name" ) line, p, specs = scan_list(VERSION, LINE_END, line, p, (1, 2), "version spec") specs = [(op, val) for op, val in specs] yield Requirement(project_name, specs, extras) class Requirement: def __init__(self, project_name, specs, extras): """DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!""" self.unsafe_name, project_name = project_name, safe_name(project_name) self.project_name, self.key = project_name, project_name.lower() self.specifier = packaging.specifiers.SpecifierSet( ",".join(["".join([x, y]) for x, y in specs]) ) self.specs = specs self.extras = tuple(map(safe_extra, extras)) self.hashCmp = ( self.key, self.specifier, frozenset(self.extras), ) self.__hash = hash(self.hashCmp) def __str__(self): extras = ','.join(self.extras) if extras: extras = '[%s]' % extras return '%s%s%s' % (self.project_name, extras, self.specifier) def __eq__(self, other): return ( isinstance(other, Requirement) and self.hashCmp == other.hashCmp ) def __ne__(self, other): return not self == other def __contains__(self, item): if isinstance(item, Distribution): if item.key != self.key: return False item = item.version # Allow prereleases always in order to match the previous behavior of # this method. In the future this should be smarter and follow PEP 440 # more accurately. return self.specifier.contains(item, prereleases=True) def __hash__(self): return self.__hash def __repr__(self): return "Requirement.parse(%r)" % str(self) @staticmethod def parse(s): req, = parse_requirements(s) return req def _get_mro(cls): """Get an mro for a type or classic class""" if not isinstance(cls, type): class cls(cls, object): pass return cls.__mro__[1:] return cls.__mro__ def _find_adapter(registry, ob): """Return an adapter factory for `ob` from `registry`""" for t in _get_mro(getattr(ob, '__class__', type(ob))): if t in registry: return registry[t] def ensure_directory(path): """Ensure that the parent directory of `path` exists""" dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) def _bypass_ensure_directory(path): """Sandbox-bypassing version of ensure_directory()""" if not WRITE_SUPPORT: raise IOError('"os.mkdir" not supported on this platform.') dirname, filename = split(path) if dirname and filename and not isdir(dirname): _bypass_ensure_directory(dirname) mkdir(dirname, 0o755) def split_sections(s): """Split a string or iterable thereof into (section, content) pairs Each ``section`` is a stripped version of the section header ("[section]") and each ``content`` is a list of stripped lines excluding blank lines and comment-only lines. If there are any such lines before the first section header, they're returned in a first ``section`` of ``None``. """ section = None content = [] for line in yield_lines(s): if line.startswith("["): if line.endswith("]"): if section or content: yield section, content section = line[1:-1].strip() content = [] else: raise ValueError("Invalid section heading", line) else: content.append(line) # wrap up last segment yield section, content def _mkstemp(*args,**kw): old_open = os.open try: # temporarily bypass sandboxing os.open = os_open return tempfile.mkstemp(*args,**kw) finally: # and then put it back os.open = old_open # Silence the PEP440Warning by default, so that end users don't get hit by it # randomly just because they use pkg_resources. We want to append the rule # because we want earlier uses of filterwarnings to take precedence over this # one. warnings.filterwarnings("ignore", category=PEP440Warning, append=True) # from jaraco.functools 1.3 def _call_aside(f, *args, **kwargs): f(*args, **kwargs) return f @_call_aside def _initialize(g=globals()): "Set up global resource manager (deliberately not state-saved)" manager = ResourceManager() g['_manager'] = manager for name in dir(manager): if not name.startswith('_'): g[name] = getattr(manager, name) @_call_aside def _initialize_master_working_set(): """ Prepare the master working set and make the ``require()`` API available. This function has explicit effects on the global state of pkg_resources. It is intended to be invoked once at the initialization of this module. Invocation by other packages is unsupported and done at their own risk. """ working_set = WorkingSet._build_master() _declare_state('object', working_set=working_set) require = working_set.require iter_entry_points = working_set.iter_entry_points add_activation_listener = working_set.subscribe run_script = working_set.run_script # backward compatibility run_main = run_script # Activate all distributions already on sys.path, and ensure that # all distributions added to the working set in the future (e.g. by # calling ``require()``) will get activated as well. add_activation_listener(lambda dist: dist.activate()) working_set.entries=[] # match order list(map(working_set.add_entry, sys.path)) globals().update(locals())
gpl-2.0
[ 624, 199, 8599, 2073, 3261, 199, 777, 375, 199, 199, 33, 2073, 365, 282, 11461, 570, 10470, 4453, 282, 2559, 12, 503, 282, 11461, 199, 954, 3619, 2337, 1618, 14, 221, 710, 2559, 2073, 3261, 14292, 2073, 1561, 199, 475, 1172, 3932, 931, 4184, 11673, 543, 1124, 15, 4542, 627, 1397, 10, 15685, 314, 2257, 199, 515, 9432, 365, 14, 221, 4226, 440, 675, 747, 14, 515, 5331, 370, 27232, 2073, 199, 1247, 3769, 3032, 1901, 314, 3261, 14, 199, 199, 1918, 2559, 2073, 3261, 365, 19829, 370, 1736, 543, 3293, 10036, 6117, 12, 199, 14, 5799, 1584, 12, 436, 23389, 1275, 5799, 1584, 14, 221, 2779, 883, 2597, 1736, 315, 282, 13988, 4340, 543, 199, 14, 3065, 1584, 436, 543, 3537, 13663, 11485, 25520, 626, 2291, 314, 1124, 362, 63, 576, 8497, 199, 765, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 646, 747, 199, 646, 5890, 199, 646, 900, 199, 646, 295, 199, 646, 2943, 199, 646, 10392, 199, 646, 3482, 646, 199, 646, 3598, 199, 646, 5672, 199, 646, 9143, 199, 646, 28728, 199, 646, 1526, 199, 646, 5272, 199, 646, 4182, 199, 646, 4298, 199, 646, 5055, 199, 646, 14459, 773, 199, 646, 3031, 14, 2087, 199, 646, 5549, 199, 646, 13390, 199, 504, 28728, 492, 664, 63, 12138, 199, 199, 893, 26, 272, 492, 485, 3236, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 18, 7163, 272, 492, 1742, 465, 485, 3236, 199, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 690, 334, 19, 4258, 199, 4521, 18, 275, 440, 7843, 19, 199, 199, 692, 7843, 19, 26, 272, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 199, 199, 692, 7843, 18, 26, 272, 687, 7097, 492, 7097, 12, 30111, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 199, 2836, 26, 272, 1059, 63, 1313, 275, 620, 12, 3468, 360, 2975, 358, 199, 199, 4611, 275, 334, 2734, 284, 26, 284, 14, 1744, 1012, 340, 7843, 19, 587, 2400, 284, 26, 284, 14, 4611, 342, 199, 199, 3, 12296, 3520, 370, 21115, 19699, 316, 199, 504, 747, 492, 399, 521, 199, 893, 26, 272, 687, 747, 492, 20366, 12, 11441, 12, 17002, 272, 32280, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 327, 949, 2218, 2291, 12, 8646, 1334, 598, 12500, 272, 32280, 63, 10640, 275, 756, 199, 199, 504, 747, 492, 1551, 465, 747, 63, 1490, 199, 504, 747, 14, 515, 492, 26004, 12, 3715, 199, 199, 3, 19503, 862, 15, 2590, 7037, 370, 12330, 8826, 543, 24725, 492, 562, 10832, 706, 14, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 650, 9, 436, 984, 14, 12236, 14, 354, 508, 298, 67, 1548, 582, 272, 492, 14802, 14, 14121, 20067, 465, 14802, 63, 14121, 20067, 199, 2836, 26, 272, 14802, 63, 14121, 20067, 275, 488, 199, 199, 893, 26, 272, 492, 1798, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 14, 1023, 272, 492, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 14, 31659, 272, 687, 1973, 14, 4600, 63, 4435, 423, 9884, 492, 27369, 272, 327, 27796, 275, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 199, 2590, 3545, 26, 272, 327, 9567, 370, 13872, 300, 1183, 13, 7657, 1015, 27, 6127, 2656, 1706, 10246, 370, 272, 327, 221, 19413, 373, 500, 2908, 6117, 14, 272, 492, 5496, 63, 4435, 14, 27796, 14, 1023, 272, 492, 27369, 14, 31659, 421, 199, 692, 334, 19, 12, 378, 9, 665, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 650, 304, 272, 1499, 275, 334, 267, 298, 11532, 367, 2018, 650, 14, 16, 13, 19, 14, 18, 965, 2757, 17481, 14, 20799, 5459, 298, 267, 298, 14117, 2449, 2348, 2122, 272, 776, 272, 3598, 14, 4050, 8, 1328, 9, 199, 199, 3, 20771, 2005, 7992, 626, 911, 506, 3247, 2945, 370, 199, 3, 23082, 314, 7403, 878, 14, 199, 4365, 275, 488, 199, 9818, 63, 409, 275, 488, 421, 199, 533, 13663, 14162, 3849, 8, 14357, 3849, 304, 272, 408, 272, 8051, 1380, 2337, 365, 376, 4976, 543, 282, 1015, 503, 16628, 440, 1013, 6670, 543, 272, 13663, 841, 2167, 14, 272, 408, 421, 199, 533, 485, 8555, 2537, 3353, 4256, 8, 785, 304, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 2227, 4533, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 665, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 4116, 721, 1848, 9, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 2695, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 274, 721, 1848, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 508, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 4077, 721, 1848, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 2356, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 303, 721, 1848, 9, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 690, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 3308, 721, 1848, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 1137, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 685, 721, 1848, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 2008, 8, 277, 2788, 498, 61, 339, 347, 636, 1661 ]
[ 199, 8599, 2073, 3261, 199, 777, 375, 199, 199, 33, 2073, 365, 282, 11461, 570, 10470, 4453, 282, 2559, 12, 503, 282, 11461, 199, 954, 3619, 2337, 1618, 14, 221, 710, 2559, 2073, 3261, 14292, 2073, 1561, 199, 475, 1172, 3932, 931, 4184, 11673, 543, 1124, 15, 4542, 627, 1397, 10, 15685, 314, 2257, 199, 515, 9432, 365, 14, 221, 4226, 440, 675, 747, 14, 515, 5331, 370, 27232, 2073, 199, 1247, 3769, 3032, 1901, 314, 3261, 14, 199, 199, 1918, 2559, 2073, 3261, 365, 19829, 370, 1736, 543, 3293, 10036, 6117, 12, 199, 14, 5799, 1584, 12, 436, 23389, 1275, 5799, 1584, 14, 221, 2779, 883, 2597, 1736, 315, 282, 13988, 4340, 543, 199, 14, 3065, 1584, 436, 543, 3537, 13663, 11485, 25520, 626, 2291, 314, 1124, 362, 63, 576, 8497, 199, 765, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 646, 747, 199, 646, 5890, 199, 646, 900, 199, 646, 295, 199, 646, 2943, 199, 646, 10392, 199, 646, 3482, 646, 199, 646, 3598, 199, 646, 5672, 199, 646, 9143, 199, 646, 28728, 199, 646, 1526, 199, 646, 5272, 199, 646, 4182, 199, 646, 4298, 199, 646, 5055, 199, 646, 14459, 773, 199, 646, 3031, 14, 2087, 199, 646, 5549, 199, 646, 13390, 199, 504, 28728, 492, 664, 63, 12138, 199, 199, 893, 26, 272, 492, 485, 3236, 199, 2590, 3545, 26, 272, 327, 2018, 650, 14, 18, 7163, 272, 492, 1742, 465, 485, 3236, 199, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 690, 334, 19, 4258, 199, 4521, 18, 275, 440, 7843, 19, 199, 199, 692, 7843, 19, 26, 272, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 199, 199, 692, 7843, 18, 26, 272, 687, 7097, 492, 7097, 12, 30111, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 199, 2836, 26, 272, 1059, 63, 1313, 275, 620, 12, 3468, 360, 2975, 358, 199, 199, 4611, 275, 334, 2734, 284, 26, 284, 14, 1744, 1012, 340, 7843, 19, 587, 2400, 284, 26, 284, 14, 4611, 342, 199, 199, 3, 12296, 3520, 370, 21115, 19699, 316, 199, 504, 747, 492, 399, 521, 199, 893, 26, 272, 687, 747, 492, 20366, 12, 11441, 12, 17002, 272, 32280, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 327, 949, 2218, 2291, 12, 8646, 1334, 598, 12500, 272, 32280, 63, 10640, 275, 756, 199, 199, 504, 747, 492, 1551, 465, 747, 63, 1490, 199, 504, 747, 14, 515, 492, 26004, 12, 3715, 199, 199, 3, 19503, 862, 15, 2590, 7037, 370, 12330, 8826, 543, 24725, 492, 562, 10832, 706, 14, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 650, 9, 436, 984, 14, 12236, 14, 354, 508, 298, 67, 1548, 582, 272, 492, 14802, 14, 14121, 20067, 465, 14802, 63, 14121, 20067, 199, 2836, 26, 272, 14802, 63, 14121, 20067, 275, 488, 199, 199, 893, 26, 272, 492, 1798, 199, 2590, 3545, 26, 272, 986, 199, 199, 893, 26, 272, 492, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 14, 1023, 272, 492, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 14, 31659, 272, 687, 1973, 14, 4600, 63, 4435, 423, 9884, 492, 27369, 272, 327, 27796, 275, 1973, 14, 4600, 63, 4435, 423, 9884, 14, 27796, 199, 2590, 3545, 26, 272, 327, 9567, 370, 13872, 300, 1183, 13, 7657, 1015, 27, 6127, 2656, 1706, 10246, 370, 272, 327, 221, 19413, 373, 500, 2908, 6117, 14, 272, 492, 5496, 63, 4435, 14, 27796, 14, 1023, 272, 492, 27369, 14, 31659, 421, 199, 692, 334, 19, 12, 378, 9, 665, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 650, 304, 272, 1499, 275, 334, 267, 298, 11532, 367, 2018, 650, 14, 16, 13, 19, 14, 18, 965, 2757, 17481, 14, 20799, 5459, 298, 267, 298, 14117, 2449, 2348, 2122, 272, 776, 272, 3598, 14, 4050, 8, 1328, 9, 199, 199, 3, 20771, 2005, 7992, 626, 911, 506, 3247, 2945, 370, 199, 3, 23082, 314, 7403, 878, 14, 199, 4365, 275, 488, 199, 9818, 63, 409, 275, 488, 421, 199, 533, 13663, 14162, 3849, 8, 14357, 3849, 304, 272, 408, 272, 8051, 1380, 2337, 365, 376, 4976, 543, 282, 1015, 503, 16628, 440, 1013, 6670, 543, 272, 13663, 841, 2167, 14, 272, 408, 421, 199, 533, 485, 8555, 2537, 3353, 4256, 8, 785, 304, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 2227, 4533, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 665, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 4116, 721, 1848, 9, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 2695, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 274, 721, 1848, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 508, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 4077, 721, 1848, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 2356, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 303, 721, 1848, 9, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 690, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 3308, 721, 1848, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 340, 1228, 8, 1848, 12, 2008, 304, 288, 372, 2008, 8, 277, 9, 1137, 1163, 267, 587, 26, 288, 372, 1613, 1547, 8555, 2537, 3353, 4256, 12, 291, 2843, 685, 721, 1848, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 2008, 8, 277, 2788, 498, 61, 339, 347, 636, 1661, 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 ]
tlangerak/Multi-Agent-Systems
build/lib.win-amd64-2.7/tlslite/integration/TLSAsyncDispatcherMixIn.py
86
4732
"""TLS Lite + asyncore.""" import asyncore from tlslite.TLSConnection import TLSConnection from AsyncStateMachine import AsyncStateMachine class TLSAsyncDispatcherMixIn(AsyncStateMachine): """This class can be "mixed in" with an L{asyncore.dispatcher} to add TLS support. This class essentially sits between the dispatcher and the select loop, intercepting events and only calling the dispatcher when applicable. In the case of handle_read(), a read operation will be activated, and when it completes, the bytes will be placed in a buffer where the dispatcher can retrieve them by calling recv(), and the dispatcher's handle_read() will be called. In the case of handle_write(), the dispatcher's handle_write() will be called, and when it calls send(), a write operation will be activated. To use this class, you must combine it with an asyncore.dispatcher, and pass in a handshake operation with setServerHandshakeOp(). Below is an example of using this class with medusa. This class is mixed in with http_channel to create http_tls_channel. Note: 1. the mix-in is listed first in the inheritance list 2. the input buffer size must be at least 16K, otherwise the dispatcher might not read all the bytes from the TLS layer, leaving some bytes in limbo. 3. IE seems to have a problem receiving a whole HTTP response in a single TLS record, so HTML pages containing '\\r\\n\\r\\n' won't be displayed on IE. Add the following text into 'start_medusa.py', in the 'HTTP Server' section:: from tlslite.api import * s = open("./serverX509Cert.pem").read() x509 = X509() x509.parse(s) certChain = X509CertChain([x509]) s = open("./serverX509Key.pem").read() privateKey = parsePEMKey(s, private=True) class http_tls_channel(TLSAsyncDispatcherMixIn, http_server.http_channel): ac_in_buffer_size = 16384 def __init__ (self, server, conn, addr): http_server.http_channel.__init__(self, server, conn, addr) TLSAsyncDispatcherMixIn.__init__(self, conn) self.tlsConnection.ignoreAbruptClose = True self.setServerHandshakeOp(certChain=certChain, privateKey=privateKey) hs.channel_class = http_tls_channel If the TLS layer raises an exception, the exception will be caught in asyncore.dispatcher, which will call close() on this class. The TLS layer always closes the TLS connection before raising an exception, so the close operation will complete right away, causing asyncore.dispatcher.close() to be called, which closes the socket and removes this instance from the asyncore loop. """ def __init__(self, sock=None): AsyncStateMachine.__init__(self) if sock: self.tlsConnection = TLSConnection(sock) #Calculate the sibling I'm being mixed in with. #This is necessary since we override functions #like readable(), handle_read(), etc., but we #also want to call the sibling's versions. for cl in self.__class__.__bases__: if cl != TLSAsyncDispatcherMixIn and cl != AsyncStateMachine: self.siblingClass = cl break else: raise AssertionError() def readable(self): result = self.wantsReadEvent() if result != None: return result return self.siblingClass.readable(self) def writable(self): result = self.wantsWriteEvent() if result != None: return result return self.siblingClass.writable(self) def handle_read(self): self.inReadEvent() def handle_write(self): self.inWriteEvent() def outConnectEvent(self): self.siblingClass.handle_connect(self) def outCloseEvent(self): asyncore.dispatcher.close(self) def outReadEvent(self, readBuffer): self.readBuffer = readBuffer self.siblingClass.handle_read(self) def outWriteEvent(self): self.siblingClass.handle_write(self) def recv(self, bufferSize=16384): if bufferSize < 16384 or self.readBuffer == None: raise AssertionError() returnValue = self.readBuffer self.readBuffer = None return returnValue def send(self, writeBuffer): self.setWriteOp(writeBuffer) return len(writeBuffer) def close(self): if hasattr(self, "tlsConnection"): self.setCloseOp() else: asyncore.dispatcher.close(self)
lgpl-2.1
[ 624, 10224, 491, 1175, 435, 30328, 1041, 421, 199, 646, 30328, 199, 504, 15142, 5333, 14, 10224, 3225, 492, 12213, 3225, 199, 504, 15223, 23535, 492, 15223, 23535, 421, 199, 533, 12213, 12807, 15461, 26527, 8, 12807, 23535, 304, 272, 408, 2765, 1021, 883, 506, 298, 10455, 315, 2, 543, 376, 272, 491, 91, 305, 25400, 14, 14913, 93, 370, 1050, 12213, 2291, 14, 339, 961, 1021, 28891, 308, 1405, 3382, 314, 17475, 436, 314, 3504, 272, 4438, 12, 13926, 316, 4474, 436, 1454, 6358, 314, 17475, 1380, 272, 3964, 14, 339, 1010, 314, 1930, 402, 2429, 63, 739, 1062, 282, 1586, 3439, 911, 506, 22225, 12, 272, 436, 1380, 652, 29672, 12, 314, 2783, 911, 506, 15090, 315, 282, 3335, 2382, 272, 314, 17475, 883, 8044, 3062, 701, 6358, 11904, 1062, 436, 314, 272, 17475, 1159, 2429, 63, 739, 342, 911, 506, 2797, 14, 339, 1010, 314, 1930, 402, 2429, 63, 952, 1062, 314, 17475, 1159, 2429, 63, 952, 342, 911, 272, 506, 2797, 12, 436, 1380, 652, 4882, 3222, 1062, 282, 2218, 3439, 911, 506, 272, 22225, 14, 339, 4005, 675, 642, 1021, 12, 1265, 1471, 13323, 652, 543, 376, 30328, 14, 14913, 12, 272, 436, 986, 315, 282, 14305, 3439, 543, 663, 3120, 26392, 4619, 1252, 339, 6423, 674, 365, 376, 2893, 402, 1808, 642, 1021, 543, 562, 68, 527, 65, 14, 221, 961, 1021, 365, 272, 13492, 315, 543, 1455, 63, 2775, 370, 1218, 1455, 63, 9945, 63, 2775, 14, 221, 3390, 26, 1362, 413, 14, 314, 13667, 13, 262, 365, 10532, 1642, 315, 314, 15433, 769, 10813, 499, 14, 314, 1324, 3335, 1568, 1471, 506, 737, 5210, 3193, 43, 12, 4257, 314, 2126, 17475, 5594, 440, 1586, 1006, 314, 2783, 687, 314, 12213, 4045, 12, 2126, 23188, 2005, 2783, 315, 1212, 77, 656, 14, 10813, 650, 14, 15292, 12237, 370, 1172, 282, 5160, 18390, 282, 8852, 3101, 1177, 315, 282, 1362, 2849, 12213, 2777, 12, 880, 4163, 6497, 3035, 6468, 82, 1103, 78, 1103, 82, 1103, 78, 7, 7859, 1133, 1362, 506, 9080, 641, 15292, 14, 339, 2654, 314, 2569, 1318, 1901, 283, 928, 63, 3594, 527, 65, 14, 647, 297, 315, 314, 283, 2856, 7146, 7, 272, 3420, 447, 398, 687, 15142, 5333, 14, 1246, 492, 627, 267, 308, 275, 1551, 28615, 1000, 56, 6576, 14768, 14, 13102, 3471, 739, 342, 267, 671, 6576, 275, 1323, 6576, 342, 267, 671, 6576, 14, 1122, 8, 83, 9, 267, 6250, 10720, 275, 1323, 6576, 26464, 779, 88, 6576, 566, 398, 308, 275, 1551, 28615, 1000, 56, 6576, 1197, 14, 13102, 3471, 739, 342, 267, 30471, 275, 2198, 24160, 1197, 8, 83, 12, 5726, 29, 549, 9, 398, 1021, 1455, 63, 9945, 63, 2775, 8, 10224, 12807, 15461, 26527, 12, 3044, 1455, 63, 1000, 14, 1014, 63, 2775, 304, 288, 1066, 63, 262, 63, 2738, 63, 890, 275, 24619, 1349, 953, 347, 636, 826, 363, 334, 277, 12, 1654, 12, 2557, 12, 5552, 304, 355, 1455, 63, 1000, 14, 1014, 63, 2775, 855, 826, 721, 277, 12, 1654, 12, 2557, 12, 5552, 9, 355, 12213, 12807, 15461, 26527, 855, 826, 721, 277, 12, 2557, 9, 355, 291, 14, 9945, 3225, 14, 4247, 33, 3289, 22963, 4724, 275, 715, 355, 291, 14, 409, 3120, 26392, 4619, 8, 4736, 10720, 29, 4736, 10720, 12, 5101, 30471, 29, 4239, 1197, 9, 398, 17446, 14, 2775, 63, 533, 275, 1455, 63, 9945, 63, 2775, 339, 982, 314, 12213, 4045, 6534, 376, 1919, 12, 314, 1919, 911, 506, 15604, 272, 315, 30328, 14, 14913, 12, 1314, 911, 1240, 4002, 342, 641, 642, 1021, 14, 221, 710, 272, 12213, 4045, 3544, 27811, 314, 12213, 1950, 2544, 17026, 376, 272, 1919, 12, 880, 314, 4002, 3439, 911, 4890, 2451, 13437, 12, 25498, 272, 30328, 14, 14913, 14, 1600, 342, 370, 506, 2797, 12, 1314, 27811, 314, 2838, 272, 436, 14185, 642, 1256, 687, 314, 30328, 4438, 14, 339, 408, 2378, 347, 636, 826, 721, 277, 12, 6771, 29, 403, 304, 267, 15223, 23535, 855, 826, 721, 277, 9, 398, 340, 6771, 26, 288, 291, 14, 9945, 3225, 275, 12213, 3225, 8, 5096, 9, 398, 327, 14860, 314, 24238, 473, 6704, 3769, 13492, 315, 543, 14, 267, 327, 2765, 365, 5784, 3967, 781, 4278, 3423, 267, 327, 2930, 12701, 1062, 2429, 63, 739, 1062, 5423, 2020, 1325, 781, 267, 327, 12344, 2934, 370, 1240, 314, 24238, 1159, 5459, 14, 267, 367, 824, 315, 291, 855, 533, 4914, 12087, 10651, 288, 340, 824, 1137, 12213, 12807, 15461, 26527, 436, 824, 1137, 15223, 23535, 26, 355, 291, 14, 17285, 2543, 275, 824, 355, 2059, 267, 587, 26, 288, 746, 9070, 342, 339, 347, 12701, 8, 277, 304, 267, 754, 275, 291, 14, 28789, 3284, 2390, 342, 267, 340, 754, 1137, 488, 26, 288, 372, 754, 267, 372, 291, 14, 17285, 2543, 14, 11875, 8, 277, 9, 339, 347, 17267, 8, 277, 304, 267, 754, 275, 291, 14, 28789, 3534, 2390, 342, 267, 340, 754, 1137, 488, 26, 288, 372, 754, 267, 372, 291, 14, 17285, 2543, 14, 15053, 8, 277, 9, 339, 347, 2429, 63, 739, 8, 277, 304, 267, 291, 14, 262, 3284, 2390, 342, 339, 347, 2429, 63, 952, 8, 277, 304, 267, 291, 14, 262, 3534, 2390, 342, 339, 347, 734, 8631, 2390, 8, 277, 304, 267, 291, 14, 17285, 2543, 14, 2479, 63, 2242, 8, 277, 9, 339, 347, 734, 4724, 2390, 8, 277, 304, 267, 30328, 14, 14913, 14, 1600, 8, 277, 9, 339, 347, 734, 3284, 2390, 8, 277, 12, 1586, 3299, 304, 267, 291, 14, 739, 3299, 275, 1586, 3299, 267, 291, 14, 17285, 2543, 14, 2479, 63, 739, 8, 277, 9, 339, 347, 734, 3534, 2390, 8, 277, 304, 267, 291, 14, 17285, 2543, 14, 2479, 63, 952, 8, 277, 9, 339, 347, 11904, 8, 277, 12, 3335, 2320, 29, 975, 8188, 304, 267, 340, 3335, 2320, 665, 24619, 1349, 503, 291, 14, 739, 3299, 508, 488, 26, 288, 746, 9070, 342, 267, 372, 1110, 275, 291, 14, 739, 3299, 267, 291, 14, 739, 3299, 275, 488, 267, 372, 372, 1110, 339, 347, 3222, 8, 277, 12, 2218, 3299, 304, 267, 291, 14, 409, 3534, 4619, 8, 952, 3299, 9, 267, 372, 822 ]
[ 10224, 491, 1175, 435, 30328, 1041, 421, 199, 646, 30328, 199, 504, 15142, 5333, 14, 10224, 3225, 492, 12213, 3225, 199, 504, 15223, 23535, 492, 15223, 23535, 421, 199, 533, 12213, 12807, 15461, 26527, 8, 12807, 23535, 304, 272, 408, 2765, 1021, 883, 506, 298, 10455, 315, 2, 543, 376, 272, 491, 91, 305, 25400, 14, 14913, 93, 370, 1050, 12213, 2291, 14, 339, 961, 1021, 28891, 308, 1405, 3382, 314, 17475, 436, 314, 3504, 272, 4438, 12, 13926, 316, 4474, 436, 1454, 6358, 314, 17475, 1380, 272, 3964, 14, 339, 1010, 314, 1930, 402, 2429, 63, 739, 1062, 282, 1586, 3439, 911, 506, 22225, 12, 272, 436, 1380, 652, 29672, 12, 314, 2783, 911, 506, 15090, 315, 282, 3335, 2382, 272, 314, 17475, 883, 8044, 3062, 701, 6358, 11904, 1062, 436, 314, 272, 17475, 1159, 2429, 63, 739, 342, 911, 506, 2797, 14, 339, 1010, 314, 1930, 402, 2429, 63, 952, 1062, 314, 17475, 1159, 2429, 63, 952, 342, 911, 272, 506, 2797, 12, 436, 1380, 652, 4882, 3222, 1062, 282, 2218, 3439, 911, 506, 272, 22225, 14, 339, 4005, 675, 642, 1021, 12, 1265, 1471, 13323, 652, 543, 376, 30328, 14, 14913, 12, 272, 436, 986, 315, 282, 14305, 3439, 543, 663, 3120, 26392, 4619, 1252, 339, 6423, 674, 365, 376, 2893, 402, 1808, 642, 1021, 543, 562, 68, 527, 65, 14, 221, 961, 1021, 365, 272, 13492, 315, 543, 1455, 63, 2775, 370, 1218, 1455, 63, 9945, 63, 2775, 14, 221, 3390, 26, 1362, 413, 14, 314, 13667, 13, 262, 365, 10532, 1642, 315, 314, 15433, 769, 10813, 499, 14, 314, 1324, 3335, 1568, 1471, 506, 737, 5210, 3193, 43, 12, 4257, 314, 2126, 17475, 5594, 440, 1586, 1006, 314, 2783, 687, 314, 12213, 4045, 12, 2126, 23188, 2005, 2783, 315, 1212, 77, 656, 14, 10813, 650, 14, 15292, 12237, 370, 1172, 282, 5160, 18390, 282, 8852, 3101, 1177, 315, 282, 1362, 2849, 12213, 2777, 12, 880, 4163, 6497, 3035, 6468, 82, 1103, 78, 1103, 82, 1103, 78, 7, 7859, 1133, 1362, 506, 9080, 641, 15292, 14, 339, 2654, 314, 2569, 1318, 1901, 283, 928, 63, 3594, 527, 65, 14, 647, 297, 315, 314, 283, 2856, 7146, 7, 272, 3420, 447, 398, 687, 15142, 5333, 14, 1246, 492, 627, 267, 308, 275, 1551, 28615, 1000, 56, 6576, 14768, 14, 13102, 3471, 739, 342, 267, 671, 6576, 275, 1323, 6576, 342, 267, 671, 6576, 14, 1122, 8, 83, 9, 267, 6250, 10720, 275, 1323, 6576, 26464, 779, 88, 6576, 566, 398, 308, 275, 1551, 28615, 1000, 56, 6576, 1197, 14, 13102, 3471, 739, 342, 267, 30471, 275, 2198, 24160, 1197, 8, 83, 12, 5726, 29, 549, 9, 398, 1021, 1455, 63, 9945, 63, 2775, 8, 10224, 12807, 15461, 26527, 12, 3044, 1455, 63, 1000, 14, 1014, 63, 2775, 304, 288, 1066, 63, 262, 63, 2738, 63, 890, 275, 24619, 1349, 953, 347, 636, 826, 363, 334, 277, 12, 1654, 12, 2557, 12, 5552, 304, 355, 1455, 63, 1000, 14, 1014, 63, 2775, 855, 826, 721, 277, 12, 1654, 12, 2557, 12, 5552, 9, 355, 12213, 12807, 15461, 26527, 855, 826, 721, 277, 12, 2557, 9, 355, 291, 14, 9945, 3225, 14, 4247, 33, 3289, 22963, 4724, 275, 715, 355, 291, 14, 409, 3120, 26392, 4619, 8, 4736, 10720, 29, 4736, 10720, 12, 5101, 30471, 29, 4239, 1197, 9, 398, 17446, 14, 2775, 63, 533, 275, 1455, 63, 9945, 63, 2775, 339, 982, 314, 12213, 4045, 6534, 376, 1919, 12, 314, 1919, 911, 506, 15604, 272, 315, 30328, 14, 14913, 12, 1314, 911, 1240, 4002, 342, 641, 642, 1021, 14, 221, 710, 272, 12213, 4045, 3544, 27811, 314, 12213, 1950, 2544, 17026, 376, 272, 1919, 12, 880, 314, 4002, 3439, 911, 4890, 2451, 13437, 12, 25498, 272, 30328, 14, 14913, 14, 1600, 342, 370, 506, 2797, 12, 1314, 27811, 314, 2838, 272, 436, 14185, 642, 1256, 687, 314, 30328, 4438, 14, 339, 408, 2378, 347, 636, 826, 721, 277, 12, 6771, 29, 403, 304, 267, 15223, 23535, 855, 826, 721, 277, 9, 398, 340, 6771, 26, 288, 291, 14, 9945, 3225, 275, 12213, 3225, 8, 5096, 9, 398, 327, 14860, 314, 24238, 473, 6704, 3769, 13492, 315, 543, 14, 267, 327, 2765, 365, 5784, 3967, 781, 4278, 3423, 267, 327, 2930, 12701, 1062, 2429, 63, 739, 1062, 5423, 2020, 1325, 781, 267, 327, 12344, 2934, 370, 1240, 314, 24238, 1159, 5459, 14, 267, 367, 824, 315, 291, 855, 533, 4914, 12087, 10651, 288, 340, 824, 1137, 12213, 12807, 15461, 26527, 436, 824, 1137, 15223, 23535, 26, 355, 291, 14, 17285, 2543, 275, 824, 355, 2059, 267, 587, 26, 288, 746, 9070, 342, 339, 347, 12701, 8, 277, 304, 267, 754, 275, 291, 14, 28789, 3284, 2390, 342, 267, 340, 754, 1137, 488, 26, 288, 372, 754, 267, 372, 291, 14, 17285, 2543, 14, 11875, 8, 277, 9, 339, 347, 17267, 8, 277, 304, 267, 754, 275, 291, 14, 28789, 3534, 2390, 342, 267, 340, 754, 1137, 488, 26, 288, 372, 754, 267, 372, 291, 14, 17285, 2543, 14, 15053, 8, 277, 9, 339, 347, 2429, 63, 739, 8, 277, 304, 267, 291, 14, 262, 3284, 2390, 342, 339, 347, 2429, 63, 952, 8, 277, 304, 267, 291, 14, 262, 3534, 2390, 342, 339, 347, 734, 8631, 2390, 8, 277, 304, 267, 291, 14, 17285, 2543, 14, 2479, 63, 2242, 8, 277, 9, 339, 347, 734, 4724, 2390, 8, 277, 304, 267, 30328, 14, 14913, 14, 1600, 8, 277, 9, 339, 347, 734, 3284, 2390, 8, 277, 12, 1586, 3299, 304, 267, 291, 14, 739, 3299, 275, 1586, 3299, 267, 291, 14, 17285, 2543, 14, 2479, 63, 739, 8, 277, 9, 339, 347, 734, 3534, 2390, 8, 277, 304, 267, 291, 14, 17285, 2543, 14, 2479, 63, 952, 8, 277, 9, 339, 347, 11904, 8, 277, 12, 3335, 2320, 29, 975, 8188, 304, 267, 340, 3335, 2320, 665, 24619, 1349, 503, 291, 14, 739, 3299, 508, 488, 26, 288, 746, 9070, 342, 267, 372, 1110, 275, 291, 14, 739, 3299, 267, 291, 14, 739, 3299, 275, 488, 267, 372, 372, 1110, 339, 347, 3222, 8, 277, 12, 2218, 3299, 304, 267, 291, 14, 409, 3534, 4619, 8, 952, 3299, 9, 267, 372, 822, 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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